@chayns-components/core 5.4.13-alpha.0 → 5.4.14-alpha.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.
@@ -47,7 +47,7 @@ const PageProvider = ({
47
47
  const usableHeight = (0, _pageProvider.useUsableHeight)({
48
48
  shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight
49
49
  });
50
- const shouldUsePadding = !shouldRemovePadding && ![_chaynsApi.RuntimeEnviroment.IntercomPlugin, _chaynsApi.RuntimeEnviroment.PagemakerPlugin, 6].includes(runtimeEnvironment);
50
+ const shouldUsePadding = !shouldRemovePadding && ![_chaynsApi.RuntimeEnviroment.IntercomPlugin, _chaynsApi.RuntimeEnviroment.PagemakerPlugin, 6, 8].includes(runtimeEnvironment);
51
51
  return /*#__PURE__*/_react.default.createElement(_PageProvider.StyledPageProvider, {
52
52
  className: "page-provider",
53
53
  $shouldUsePadding: shouldUsePadding,
@@ -1 +1 @@
1
- {"version":3,"file":"PageProvider.js","names":["_chaynsApi","require","_react","_interopRequireDefault","_styledComponents","_pageProvider","_ColorSchemeProvider","_PageProvider","e","__esModule","default","GlobalStyle","createGlobalStyle","PageProvider","children","color","colorMode","secondaryColor","siteId","style","shouldReduceUsableHeightByCoverHeight","shouldRemovePadding","shouldUseUsableHeight","iconColor","customVariables","shouldEnableKeyboardHighlighting","runtimeEnvironment","useEnvironment","usableHeight","useUsableHeight","shouldReduceByCoverHeight","shouldUsePadding","RuntimeEnviroment","IntercomPlugin","PagemakerPlugin","includes","createElement","StyledPageProvider","className","$shouldUsePadding","$usableHeight","undefined","height","displayName","_default","exports"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { RuntimeEnviroment, useEnvironment } 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\n/**\n * Props for the PageProvider component.\n * @description\n * This interface defines the props that can be passed to the PageProvider component\n * for controlling the layout and styling behavior.\n * @example\n * <PageProvider shouldRemovePadding={true}>\n * {children}\n * </PageProvider>\n */\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Controls whether the usable height should be reduced by the cover height\n * @description\n * When true, the usable height will be reduced by the cover image height. This is useful\n * when the page should not be scrollable due to the cover image. The property has no effect\n * when `shouldUseUsableHeight` is false.\n * @default false\n * @optional\n */\n shouldReduceUsableHeightByCoverHeight?: boolean;\n /**\n * Controls whether padding should be removed from the page\n * @description\n * When true, the padding around the page content will be removed. This is useful when the\n * page should not have any padding, for example, when it is embedded in a pagemaker page.\n * @default false\n * @optional\n */\n shouldRemovePadding?: boolean;\n /**\n * Controls whether the component should use the calculated usable height\n * @description\n * When true, the page will cover the entire usable height of the screen. This means that\n * the viewport is not scrollable and the page takes up the full height not required by the\n * title or bottom bar. Optionally, the height of the cover image can be reduced by setting\n * `shouldReduceUsableHeightByCoverHeight` to true.\n * @default false\n * @optional\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 secondaryColor,\n siteId,\n style = {},\n shouldReduceUsableHeightByCoverHeight = false,\n shouldRemovePadding = false,\n shouldUseUsableHeight = false,\n iconColor,\n customVariables,\n shouldEnableKeyboardHighlighting,\n}) => {\n const { runtimeEnvironment } = useEnvironment();\n\n const usableHeight = useUsableHeight({\n shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight,\n });\n\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(\n runtimeEnvironment as number,\n );\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 siteId={siteId}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n customVariables={customVariables}\n iconColor={iconColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\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;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,MAAMG,WAAW,GAAG,IAAAC,mCAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,cAAc;EACdC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,qCAAqC,GAAG,KAAK;EAC7CC,mBAAmB,GAAG,KAAK;EAC3BC,qBAAqB,GAAG,KAAK;EAC7BC,SAAS;EACTC,eAAe;EACfC;AACJ,CAAC,KAAK;EACF,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,yBAAc,EAAC,CAAC;EAE/C,MAAMC,YAAY,GAAG,IAAAC,6BAAe,EAAC;IACjCC,yBAAyB,EAAEV;EAC/B,CAAC,CAAC;EAEF,MAAMW,gBAAgB,GAClB,CAACV,mBAAmB,IACpB,CAAC,CAACW,4BAAiB,CAACC,cAAc,EAAED,4BAAiB,CAACE,eAAe,EAAE,CAAC,CAAC,CAACC,QAAQ,CAC9ET,kBACJ,CAAC;EAEL,oBACIxB,MAAA,CAAAQ,OAAA,CAAA0B,aAAA,CAAC7B,aAAA,CAAA8B,kBAAkB;IACfC,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAER,gBAAiB;IACpCS,aAAa,EAAElB,qBAAqB,GAAGM,YAAY,GAAGa;EAAU,gBAEhEvC,MAAA,CAAAQ,OAAA,CAAA0B,aAAA,CAAC9B,oBAAA,CAAAI,OAAmB;IAChBK,KAAK,EAAEA,KAAM;IACbE,cAAc,EAAEA,cAAe;IAC/BD,SAAS,EAAEA,SAAU;IACrBE,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEuB,MAAM,EAAE;IAAO,CAAC,GAAGvB,KAAM;IACpEK,eAAe,EAAEA,eAAgB;IACjCD,SAAS,EAAEA,SAAU;IACrBE,gCAAgC,EAAEA;EAAiC,GAElEX,QACgB,CAAC,eACtBZ,MAAA,CAAAQ,OAAA,CAAA0B,aAAA,CAACzB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDE,YAAY,CAAC8B,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnC,OAAA,GAE3BG,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","secondaryColor","siteId","style","shouldReduceUsableHeightByCoverHeight","shouldRemovePadding","shouldUseUsableHeight","iconColor","customVariables","shouldEnableKeyboardHighlighting","runtimeEnvironment","useEnvironment","usableHeight","useUsableHeight","shouldReduceByCoverHeight","shouldUsePadding","RuntimeEnviroment","IntercomPlugin","PagemakerPlugin","includes","createElement","StyledPageProvider","className","$shouldUsePadding","$usableHeight","undefined","height","displayName","_default","exports"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { RuntimeEnviroment, useEnvironment } 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\n/**\n * Props for the PageProvider component.\n * @description\n * This interface defines the props that can be passed to the PageProvider component\n * for controlling the layout and styling behavior.\n * @example\n * <PageProvider shouldRemovePadding={true}>\n * {children}\n * </PageProvider>\n */\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Controls whether the usable height should be reduced by the cover height\n * @description\n * When true, the usable height will be reduced by the cover image height. This is useful\n * when the page should not be scrollable due to the cover image. The property has no effect\n * when `shouldUseUsableHeight` is false.\n * @default false\n * @optional\n */\n shouldReduceUsableHeightByCoverHeight?: boolean;\n /**\n * Controls whether padding should be removed from the page\n * @description\n * When true, the padding around the page content will be removed. This is useful when the\n * page should not have any padding, for example, when it is embedded in a pagemaker page.\n * @default false\n * @optional\n */\n shouldRemovePadding?: boolean;\n /**\n * Controls whether the component should use the calculated usable height\n * @description\n * When true, the page will cover the entire usable height of the screen. This means that\n * the viewport is not scrollable and the page takes up the full height not required by the\n * title or bottom bar. Optionally, the height of the cover image can be reduced by setting\n * `shouldReduceUsableHeightByCoverHeight` to true.\n * @default false\n * @optional\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 secondaryColor,\n siteId,\n style = {},\n shouldReduceUsableHeightByCoverHeight = false,\n shouldRemovePadding = false,\n shouldUseUsableHeight = false,\n iconColor,\n customVariables,\n shouldEnableKeyboardHighlighting,\n}) => {\n const { runtimeEnvironment } = useEnvironment();\n\n const usableHeight = useUsableHeight({\n shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight,\n });\n\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6, 8].includes(\n runtimeEnvironment as number,\n );\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 siteId={siteId}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n customVariables={customVariables}\n iconColor={iconColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\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;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,MAAMG,WAAW,GAAG,IAAAC,mCAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,cAAc;EACdC,MAAM;EACNC,KAAK,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YAAY","ignoreList":[]}
@@ -8,6 +8,8 @@ var _react = require("react");
8
8
  var _ColorSchemeProvider = require("../components/color-scheme-provider/ColorSchemeProvider");
9
9
  /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */
10
10
 
11
+ const KEYBOARD_NAVIGATION_KEYS = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Enter', ' ', 'Spacebar', 'Escape', 'Home', 'End', 'PageUp', 'PageDown']);
12
+
11
13
  /**
12
14
  * Tracks whether focus highlighting should be visible for keyboard navigation.
13
15
  * Keyboard mode is enabled via Tab and reset by mouse interaction.
@@ -23,31 +25,19 @@ const useKeyboardFocusHighlighting = isEnabledProp => {
23
25
  setIsKeyboardNavigation(true);
24
26
  };
25
27
  const handleKeyDown = event => {
26
- // Ignore pure modifier presses, but treat any real keyboard interaction as keyboard navigation.
27
28
  if (event.ctrlKey || event.altKey || event.metaKey) {
28
29
  return;
29
30
  }
30
- if (['Shift', 'Control', 'Alt', 'Meta'].includes(event.key)) {
31
+ if (!KEYBOARD_NAVIGATION_KEYS.has(event.key)) {
31
32
  return;
32
33
  }
33
34
  enableKeyboardNavigation();
34
35
  };
35
- const handleFocusIn = event => {
36
- const {
37
- target
38
- } = event;
39
-
40
- // Fallback for first tab-focus when the keydown was not observed.
41
- if (target instanceof HTMLElement && typeof target.matches === 'function' && target.matches(':focus-visible')) {
42
- enableKeyboardNavigation();
43
- }
44
- };
45
36
  const disableKeyboardNavigation = () => {
46
37
  setIsKeyboardNavigation(current => current ? false : current);
47
38
  };
48
39
  if (canListen) {
49
40
  window.addEventListener('keydown', handleKeyDown);
50
- window.addEventListener('focusin', handleFocusIn);
51
41
  window.addEventListener('mousedown', disableKeyboardNavigation);
52
42
  window.addEventListener('mousemove', disableKeyboardNavigation);
53
43
  } else {
@@ -56,7 +46,6 @@ const useKeyboardFocusHighlighting = isEnabledProp => {
56
46
  return () => {
57
47
  if (canListen) {
58
48
  window.removeEventListener('keydown', handleKeyDown);
59
- window.removeEventListener('focusin', handleFocusIn);
60
49
  window.removeEventListener('mousedown', disableKeyboardNavigation);
61
50
  window.removeEventListener('mousemove', disableKeyboardNavigation);
62
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyboardFocusHighlighting.js","names":["_react","require","_ColorSchemeProvider","useKeyboardFocusHighlighting","isEnabledProp","colorScheme","useContext","ColorSchemeContext","contextIsEnabled","shouldEnableKeyboardHighlighting","isEnabled","isKeyboardNavigation","setIsKeyboardNavigation","useState","useEffect","canListen","window","enableKeyboardNavigation","handleKeyDown","event","ctrlKey","altKey","metaKey","includes","key","handleFocusIn","target","HTMLElement","matches","disableKeyboardNavigation","current","addEventListener","removeEventListener","Boolean","exports"],"sources":["../../../src/hooks/useKeyboardFocusHighlighting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */\nimport { useContext, useEffect, useState } from 'react';\nimport {\n ColorSchemeContext,\n type ColorSchemeContextProps,\n} from '../components/color-scheme-provider/ColorSchemeProvider';\n\n/**\n * Tracks whether focus highlighting should be visible for keyboard navigation.\n * Keyboard mode is enabled via Tab and reset by mouse interaction.\n */\nexport const useKeyboardFocusHighlighting = (isEnabledProp?: boolean): boolean => {\n const colorScheme = useContext<ColorSchemeContextProps | undefined>(ColorSchemeContext);\n const contextIsEnabled: boolean = colorScheme?.shouldEnableKeyboardHighlighting === true;\n const isEnabled: boolean = isEnabledProp ?? contextIsEnabled;\n\n const [isKeyboardNavigation, setIsKeyboardNavigation] = useState(false);\n\n useEffect(() => {\n const canListen = isEnabled && typeof window !== 'undefined';\n\n const enableKeyboardNavigation = () => {\n setIsKeyboardNavigation(true);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n // Ignore pure modifier presses, but treat any real keyboard interaction as keyboard navigation.\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n\n if (['Shift', 'Control', 'Alt', 'Meta'].includes(event.key)) {\n return;\n }\n\n enableKeyboardNavigation();\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const { target } = event;\n\n // Fallback for first tab-focus when the keydown was not observed.\n if (\n target instanceof HTMLElement &&\n typeof target.matches === 'function' &&\n target.matches(':focus-visible')\n ) {\n enableKeyboardNavigation();\n }\n };\n\n const disableKeyboardNavigation = () => {\n setIsKeyboardNavigation((current) => (current ? false : current));\n };\n\n if (canListen) {\n window.addEventListener('keydown', handleKeyDown);\n window.addEventListener('focusin', handleFocusIn);\n window.addEventListener('mousedown', disableKeyboardNavigation);\n window.addEventListener('mousemove', disableKeyboardNavigation);\n } else {\n setIsKeyboardNavigation(false);\n }\n\n return () => {\n if (canListen) {\n window.removeEventListener('keydown', handleKeyDown);\n window.removeEventListener('focusin', handleFocusIn);\n window.removeEventListener('mousedown', disableKeyboardNavigation);\n window.removeEventListener('mousemove', disableKeyboardNavigation);\n }\n };\n }, [isEnabled]);\n\n return Boolean(isEnabled && isKeyboardNavigation);\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAFA;;AAOA;AACA;AACA;AACA;AACO,MAAME,4BAA4B,GAAIC,aAAuB,IAAc;EAC9E,MAAMC,WAAW,GAAG,IAAAC,iBAAU,EAAsCC,uCAAkB,CAAC;EACvF,MAAMC,gBAAyB,GAAG,CAAAH,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEI,gCAAgC,MAAK,IAAI;EACxF,MAAMC,SAAkB,GAAGN,aAAa,IAAII,gBAAgB;EAE5D,MAAM,CAACG,oBAAoB,EAAEC,uBAAuB,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAEvE,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,SAAS,GAAGL,SAAS,IAAI,OAAOM,MAAM,KAAK,WAAW;IAE5D,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;MACnCL,uBAAuB,CAAC,IAAI,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mB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;QAClEb,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;MACtE;IACJ,CAAC;EACL,CAAC,EAAE,CAACnB,SAAS,CAAC,CAAC;EAEf,OAAOuB,OAAO,CAACvB,SAAS,IAAIC,oBAAoB,CAAC;AACrD,CAAC;AAACuB,OAAA,CAAA/B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"file":"useKeyboardFocusHighlighting.js","names":["_react","require","_ColorSchemeProvider","KEYBOARD_NAVIGATION_KEYS","Set","useKeyboardFocusHighlighting","isEnabledProp","colorScheme","useContext","ColorSchemeContext","contextIsEnabled","shouldEnableKeyboardHighlighting","isEnabled","isKeyboardNavigation","setIsKeyboardNavigation","useState","useEffect","canListen","window","enableKeyboardNavigation","handleKeyDown","event","ctrlKey","altKey","metaKey","has","key","disableKeyboardNavigation","current","addEventListener","removeEventListener","Boolean","exports"],"sources":["../../../src/hooks/useKeyboardFocusHighlighting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */\nimport { useContext, useEffect, useState } from 'react';\nimport {\n ColorSchemeContext,\n type ColorSchemeContextProps,\n} from '../components/color-scheme-provider/ColorSchemeProvider';\n\nconst KEYBOARD_NAVIGATION_KEYS = new Set([\n 'Tab',\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n ' ',\n 'Spacebar',\n 'Escape',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n]);\n\n/**\n * Tracks whether focus highlighting should be visible for keyboard navigation.\n * Keyboard mode is enabled via Tab and reset by mouse interaction.\n */\nexport const useKeyboardFocusHighlighting = (isEnabledProp?: boolean): boolean => {\n const colorScheme = useContext<ColorSchemeContextProps | undefined>(ColorSchemeContext);\n const contextIsEnabled: boolean = colorScheme?.shouldEnableKeyboardHighlighting === true;\n const isEnabled: boolean = isEnabledProp ?? contextIsEnabled;\n\n const [isKeyboardNavigation, setIsKeyboardNavigation] = useState(false);\n\n useEffect(() => {\n const canListen = isEnabled && typeof window !== 'undefined';\n\n const enableKeyboardNavigation = () => {\n setIsKeyboardNavigation(true);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n\n if (!KEYBOARD_NAVIGATION_KEYS.has(event.key)) {\n return;\n }\n\n enableKeyboardNavigation();\n };\n\n const disableKeyboardNavigation = () => {\n setIsKeyboardNavigation((current) => (current ? false : current));\n };\n\n if (canListen) {\n window.addEventListener('keydown', handleKeyDown);\n window.addEventListener('mousedown', disableKeyboardNavigation);\n window.addEventListener('mousemove', disableKeyboardNavigation);\n } else {\n setIsKeyboardNavigation(false);\n }\n\n return () => {\n if (canListen) {\n window.removeEventListener('keydown', handleKeyDown);\n window.removeEventListener('mousedown', disableKeyboardNavigation);\n window.removeEventListener('mousemove', disableKeyboardNavigation);\n }\n };\n }, [isEnabled]);\n\n return Boolean(isEnabled && isKeyboardNavigation);\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAFA;;AAOA,MAAME,wBAAwB,GAAG,IAAIC,GAAG,CAAC,CACrC,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,OAAO,EACP,GAAG,EACH,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,UAAU,CACb,CAAC;;AAEF;AACA;AACA;AACA;AACO,MAAMC,4BAA4B,GAAIC,aAAuB,IAAc;EAC9E,MAAMC,WAAW,GAAG,IAAAC,iBAAU,EAAsCC,uCAAkB,CAAC;EACvF,MAAMC,gBAAyB,GAAG,CAAAH,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEI,gCAAgC,MAAK,IAAI;EACxF,MAAMC,SAAkB,GAAGN,aAAa,IAAII,gBAAgB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O,CAACnB,SAAS,IAAIC,oBAAoB,CAAC;AACrD,CAAC;AAACmB,OAAA,CAAA3B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -41,7 +41,7 @@ const PageProvider = ({
41
41
  const usableHeight = useUsableHeight({
42
42
  shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight
43
43
  });
44
- const shouldUsePadding = !shouldRemovePadding && ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(runtimeEnvironment);
44
+ const shouldUsePadding = !shouldRemovePadding && ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6, 8].includes(runtimeEnvironment);
45
45
  return /*#__PURE__*/React.createElement(StyledPageProvider, {
46
46
  className: "page-provider",
47
47
  $shouldUsePadding: shouldUsePadding,
@@ -1 +1 @@
1
- {"version":3,"file":"PageProvider.js","names":["RuntimeEnviroment","useEnvironment","React","createGlobalStyle","useUsableHeight","ColorSchemeProvider","StyledPageProvider","GlobalStyle","PageProvider","children","color","colorMode","secondaryColor","siteId","style","shouldReduceUsableHeightByCoverHeight","shouldRemovePadding","shouldUseUsableHeight","iconColor","customVariables","shouldEnableKeyboardHighlighting","runtimeEnvironment","usableHeight","shouldReduceByCoverHeight","shouldUsePadding","IntercomPlugin","PagemakerPlugin","includes","createElement","className","$shouldUsePadding","$usableHeight","undefined","height","displayName"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { RuntimeEnviroment, useEnvironment } 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\n/**\n * Props for the PageProvider component.\n * @description\n * This interface defines the props that can be passed to the PageProvider component\n * for controlling the layout and styling behavior.\n * @example\n * <PageProvider shouldRemovePadding={true}>\n * {children}\n * </PageProvider>\n */\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Controls whether the usable height should be reduced by the cover height\n * @description\n * When true, the usable height will be reduced by the cover image height. This is useful\n * when the page should not be scrollable due to the cover image. The property has no effect\n * when `shouldUseUsableHeight` is false.\n * @default false\n * @optional\n */\n shouldReduceUsableHeightByCoverHeight?: boolean;\n /**\n * Controls whether padding should be removed from the page\n * @description\n * When true, the padding around the page content will be removed. This is useful when the\n * page should not have any padding, for example, when it is embedded in a pagemaker page.\n * @default false\n * @optional\n */\n shouldRemovePadding?: boolean;\n /**\n * Controls whether the component should use the calculated usable height\n * @description\n * When true, the page will cover the entire usable height of the screen. This means that\n * the viewport is not scrollable and the page takes up the full height not required by the\n * title or bottom bar. Optionally, the height of the cover image can be reduced by setting\n * `shouldReduceUsableHeightByCoverHeight` to true.\n * @default false\n * @optional\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 secondaryColor,\n siteId,\n style = {},\n shouldReduceUsableHeightByCoverHeight = false,\n shouldRemovePadding = false,\n shouldUseUsableHeight = false,\n iconColor,\n customVariables,\n shouldEnableKeyboardHighlighting,\n}) => {\n const { runtimeEnvironment } = useEnvironment();\n\n const usableHeight = useUsableHeight({\n shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight,\n });\n\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(\n runtimeEnvironment as number,\n );\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 siteId={siteId}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n customVariables={customVariables}\n iconColor={iconColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,YAAY;AAC9D,OAAOC,KAAK,MAAc,OAAO;AACjC,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,OAAOC,mBAAmB,MAEnB,8CAA8C;AACrD,SAASC,kBAAkB,QAAQ,uBAAuB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,MAAMC,WAAW,GAAGJ,iBAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMK,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,cAAc;EACdC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,qCAAqC,GAAG,KAAK;EAC7CC,mBAAmB,GAAG,KAAK;EAC3BC,qBAAqB,GAAG,KAAK;EAC7BC,SAAS;EACTC,eAAe;EACfC;AACJ,CAAC,KAAK;EACF,MAAM;IAAEC;EAAmB,CAAC,GAAGpB,cAAc,CAAC,CAAC;EAE/C,MAAMqB,YAAY,GAAGlB,eAAe,CAAC;IACjCmB,yBAAyB,EAAER;EAC/B,CAAC,CAAC;EAEF,MAAMS,gBAAgB,GAClB,CAACR,mBAAmB,IACpB,CAAC,CAAChB,iBAAiB,CAACyB,cAAc,EAAEzB,iBAAiB,CAAC0B,eAAe,EAAE,CAAC,CAAC,CAACC,QAAQ,CAC9EN,kBACJ,CAAC;EAEL,oBACInB,KAAA,CAAA0B,aAAA,CAACtB,kBAAkB;IACfuB,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAEN,gBAAiB;IACpCO,aAAa,EAAEd,qBAAqB,GAAGK,YAAY,GAAGU;EAAU,gBAEhE9B,KAAA,CAAA0B,aAAA,CAACvB,mBAAmB;IAChBK,KAAK,EAAEA,KAAM;IACbE,cAAc,EAAEA,cAAe;IAC/BD,SAAS,EAAEA,SAAU;IACrBE,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEmB,MAAM,EAAE;IAAO,CAAC,GAAGnB,KAAM;IACpEK,eAAe,EAAEA,eAAgB;IACjCD,SAAS,EAAEA,SAAU;IACrBE,gCAAgC,EAAEA;EAAiC,GAElEX,QACgB,CAAC,eACtBP,KAAA,CAAA0B,aAAA,CAACrB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDC,YAAY,CAAC0B,WAAW,GAAG,cAAc;AAEzC,eAAe1B,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"PageProvider.js","names":["RuntimeEnviroment","useEnvironment","React","createGlobalStyle","useUsableHeight","ColorSchemeProvider","StyledPageProvider","GlobalStyle","PageProvider","children","color","colorMode","secondaryColor","siteId","style","shouldReduceUsableHeightByCoverHeight","shouldRemovePadding","shouldUseUsableHeight","iconColor","customVariables","shouldEnableKeyboardHighlighting","runtimeEnvironment","usableHeight","shouldReduceByCoverHeight","shouldUsePadding","IntercomPlugin","PagemakerPlugin","includes","createElement","className","$shouldUsePadding","$usableHeight","undefined","height","displayName"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { RuntimeEnviroment, useEnvironment } 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\n/**\n * Props for the PageProvider component.\n * @description\n * This interface defines the props that can be passed to the PageProvider component\n * for controlling the layout and styling behavior.\n * @example\n * <PageProvider shouldRemovePadding={true}>\n * {children}\n * </PageProvider>\n */\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Controls whether the usable height should be reduced by the cover height\n * @description\n * When true, the usable height will be reduced by the cover image height. This is useful\n * when the page should not be scrollable due to the cover image. The property has no effect\n * when `shouldUseUsableHeight` is false.\n * @default false\n * @optional\n */\n shouldReduceUsableHeightByCoverHeight?: boolean;\n /**\n * Controls whether padding should be removed from the page\n * @description\n * When true, the padding around the page content will be removed. This is useful when the\n * page should not have any padding, for example, when it is embedded in a pagemaker page.\n * @default false\n * @optional\n */\n shouldRemovePadding?: boolean;\n /**\n * Controls whether the component should use the calculated usable height\n * @description\n * When true, the page will cover the entire usable height of the screen. This means that\n * the viewport is not scrollable and the page takes up the full height not required by the\n * title or bottom bar. Optionally, the height of the cover image can be reduced by setting\n * `shouldReduceUsableHeightByCoverHeight` to true.\n * @default false\n * @optional\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 secondaryColor,\n siteId,\n style = {},\n shouldReduceUsableHeightByCoverHeight = false,\n shouldRemovePadding = false,\n shouldUseUsableHeight = false,\n iconColor,\n customVariables,\n shouldEnableKeyboardHighlighting,\n}) => {\n const { runtimeEnvironment } = useEnvironment();\n\n const usableHeight = useUsableHeight({\n shouldReduceByCoverHeight: shouldReduceUsableHeightByCoverHeight,\n });\n\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6, 8].includes(\n runtimeEnvironment as number,\n );\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 siteId={siteId}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n customVariables={customVariables}\n iconColor={iconColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,YAAY;AAC9D,OAAOC,KAAK,MAAc,OAAO;AACjC,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,OAAOC,mBAAmB,MAEnB,8CAA8C;AACrD,SAASC,kBAAkB,QAAQ,uBAAuB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,MAAMC,WAAW,GAAGJ,iBAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMK,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,cAAc;EACdC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,qCAAqC,GAAG,KAAK;EAC7CC,mBAAmB,GAAG,KAAK;EAC3BC,qBAAqB,GAAG,KAAK;EAC7BC,SAAS;EACTC,eAAe;EACfC;AACJ,CAAC,KAAK;EACF,MAAM;IAAEC;EAAmB,CAAC,GAAGpB,cAAc,CAAC,CAAC;EAE/C,MAAMqB,YAAY,GAAGlB,eAAe,CAAC;IACjCmB,yBAAyB,EAAER;EAC/B,CAAC,CAAC;EAEF,MAAMS,gBAAgB,GAClB,CAACR,mBAAmB,IACpB,CAAC,CAAChB,iBAAiB,CAACyB,cAAc,EAAEzB,iBAAiB,CAAC0B,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC,CAACC,QAAQ,CACjFN,kBACJ,CAAC;EAEL,oBACInB,KAAA,CAAA0B,aAAA,CAACtB,kBAAkB;IACfuB,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAEN,gBAAiB;IACpCO,aAAa,EAAEd,qBAAqB,GAAGK,YAAY,GAAGU;EAAU,gBAEhE9B,KAAA,CAAA0B,aAAA,CAACvB,mBAAmB;IAChBK,KAAK,EAAEA,KAAM;IACbE,cAAc,EAAEA,cAAe;IAC/BD,SAAS,EAAEA,SAAU;IACrBE,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEmB,MAAM,EAAE;IAAO,CAAC,GAAGnB,KAAM;IACpEK,eAAe,EAAEA,eAAgB;IACjCD,SAAS,EAAEA,SAAU;IACrBE,gCAAgC,EAAEA;EAAiC,GAElEX,QACgB,CAAC,eACtBP,KAAA,CAAA0B,aAAA,CAACrB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDC,YAAY,CAAC0B,WAAW,GAAG,cAAc;AAEzC,eAAe1B,YAAY","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */
2
2
  import { useContext, useEffect, useState } from 'react';
3
3
  import { ColorSchemeContext } from '../components/color-scheme-provider/ColorSchemeProvider';
4
+ const KEYBOARD_NAVIGATION_KEYS = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Enter', ' ', 'Spacebar', 'Escape', 'Home', 'End', 'PageUp', 'PageDown']);
4
5
 
5
6
  /**
6
7
  * Tracks whether focus highlighting should be visible for keyboard navigation.
@@ -17,31 +18,19 @@ export const useKeyboardFocusHighlighting = isEnabledProp => {
17
18
  setIsKeyboardNavigation(true);
18
19
  };
19
20
  const handleKeyDown = event => {
20
- // Ignore pure modifier presses, but treat any real keyboard interaction as keyboard navigation.
21
21
  if (event.ctrlKey || event.altKey || event.metaKey) {
22
22
  return;
23
23
  }
24
- if (['Shift', 'Control', 'Alt', 'Meta'].includes(event.key)) {
24
+ if (!KEYBOARD_NAVIGATION_KEYS.has(event.key)) {
25
25
  return;
26
26
  }
27
27
  enableKeyboardNavigation();
28
28
  };
29
- const handleFocusIn = event => {
30
- const {
31
- target
32
- } = event;
33
-
34
- // Fallback for first tab-focus when the keydown was not observed.
35
- if (target instanceof HTMLElement && typeof target.matches === 'function' && target.matches(':focus-visible')) {
36
- enableKeyboardNavigation();
37
- }
38
- };
39
29
  const disableKeyboardNavigation = () => {
40
30
  setIsKeyboardNavigation(current => current ? false : current);
41
31
  };
42
32
  if (canListen) {
43
33
  window.addEventListener('keydown', handleKeyDown);
44
- window.addEventListener('focusin', handleFocusIn);
45
34
  window.addEventListener('mousedown', disableKeyboardNavigation);
46
35
  window.addEventListener('mousemove', disableKeyboardNavigation);
47
36
  } else {
@@ -50,7 +39,6 @@ export const useKeyboardFocusHighlighting = isEnabledProp => {
50
39
  return () => {
51
40
  if (canListen) {
52
41
  window.removeEventListener('keydown', handleKeyDown);
53
- window.removeEventListener('focusin', handleFocusIn);
54
42
  window.removeEventListener('mousedown', disableKeyboardNavigation);
55
43
  window.removeEventListener('mousemove', disableKeyboardNavigation);
56
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyboardFocusHighlighting.js","names":["useContext","useEffect","useState","ColorSchemeContext","useKeyboardFocusHighlighting","isEnabledProp","colorScheme","contextIsEnabled","shouldEnableKeyboardHighlighting","isEnabled","isKeyboardNavigation","setIsKeyboardNavigation","canListen","window","enableKeyboardNavigation","handleKeyDown","event","ctrlKey","altKey","metaKey","includes","key","handleFocusIn","target","HTMLElement","matches","disableKeyboardNavigation","current","addEventListener","removeEventListener","Boolean"],"sources":["../../../src/hooks/useKeyboardFocusHighlighting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */\nimport { useContext, useEffect, useState } from 'react';\nimport {\n ColorSchemeContext,\n type ColorSchemeContextProps,\n} from '../components/color-scheme-provider/ColorSchemeProvider';\n\n/**\n * Tracks whether focus highlighting should be visible for keyboard navigation.\n * Keyboard mode is enabled via Tab and reset by mouse interaction.\n */\nexport const useKeyboardFocusHighlighting = (isEnabledProp?: boolean): boolean => {\n const colorScheme = useContext<ColorSchemeContextProps | undefined>(ColorSchemeContext);\n const contextIsEnabled: boolean = colorScheme?.shouldEnableKeyboardHighlighting === true;\n const isEnabled: boolean = isEnabledProp ?? contextIsEnabled;\n\n const [isKeyboardNavigation, setIsKeyboardNavigation] = useState(false);\n\n useEffect(() => {\n const canListen = isEnabled && typeof window !== 'undefined';\n\n const enableKeyboardNavigation = () => {\n setIsKeyboardNavigation(true);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n // Ignore pure modifier presses, but treat any real keyboard interaction as keyboard navigation.\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n\n if (['Shift', 'Control', 'Alt', 'Meta'].includes(event.key)) {\n return;\n }\n\n enableKeyboardNavigation();\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const { target } = event;\n\n // Fallback for first tab-focus when the keydown was not observed.\n if (\n target instanceof HTMLElement &&\n typeof target.matches === 'function' &&\n target.matches(':focus-visible')\n ) {\n enableKeyboardNavigation();\n }\n };\n\n const disableKeyboardNavigation = () => {\n setIsKeyboardNavigation((current) => (current ? false : current));\n };\n\n if (canListen) {\n window.addEventListener('keydown', handleKeyDown);\n window.addEventListener('focusin', handleFocusIn);\n window.addEventListener('mousedown', disableKeyboardNavigation);\n window.addEventListener('mousemove', disableKeyboardNavigation);\n } else {\n setIsKeyboardNavigation(false);\n }\n\n return () => {\n if (canListen) {\n window.removeEventListener('keydown', handleKeyDown);\n window.removeEventListener('focusin', handleFocusIn);\n window.removeEventListener('mousedown', disableKeyboardNavigation);\n window.removeEventListener('mousemove', disableKeyboardNavigation);\n }\n };\n }, [isEnabled]);\n\n return Boolean(isEnabled && isKeyboardNavigation);\n};\n"],"mappings":"AAAA;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACvD,SACIC,kBAAkB,QAEf,yDAAyD;;AAEhE;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ACe,gBAAgB,CAAC,SAAS,EAAEb,aAAa,CAAC;MACjDF,MAAM,CAACe,gBAAgB,CAAC,SAAS,EAAEN,aAAa,CAAC;MACjDT,MAAM,CAACe,gBAAgB,CAAC,WAAW,EAAEF,yBAAyB,CAAC;MAC/Db,MAAM,CAACe,gBAAgB,CAAC,WAAW,EAAEF,yBAAyB,CAAC;IACnE,CAAC,MAAM;MACHf,uBAAuB,CAAC,KAAK,CAAC;IAClC;IAEA,OAAO,MAAM;MACT,IAAIC,SAAS,EAAE;QACXC,MAAM,CAACgB,mBAAmB,CAAC,SAAS,EAAEd,aAAa,CAAC;QACpDF,MAAM,CAACgB,mBAAmB,CAAC,SAAS,EAAEP,aAAa,CAAC;QACpDT,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;QAClEb,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;MACtE;IACJ,CAAC;EACL,CAAC,EAAE,CAACjB,SAAS,CAAC,CAAC;EAEf,OAAOqB,OAAO,CAACrB,SAAS,IAAIC,oBAAoB,CAAC;AACrD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useKeyboardFocusHighlighting.js","names":["useContext","useEffect","useState","ColorSchemeContext","KEYBOARD_NAVIGATION_KEYS","Set","useKeyboardFocusHighlighting","isEnabledProp","colorScheme","contextIsEnabled","shouldEnableKeyboardHighlighting","isEnabled","isKeyboardNavigation","setIsKeyboardNavigation","canListen","window","enableKeyboardNavigation","handleKeyDown","event","ctrlKey","altKey","metaKey","has","key","disableKeyboardNavigation","current","addEventListener","removeEventListener","Boolean"],"sources":["../../../src/hooks/useKeyboardFocusHighlighting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */\nimport { useContext, useEffect, useState } from 'react';\nimport {\n ColorSchemeContext,\n type ColorSchemeContextProps,\n} from '../components/color-scheme-provider/ColorSchemeProvider';\n\nconst KEYBOARD_NAVIGATION_KEYS = new Set([\n 'Tab',\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n ' ',\n 'Spacebar',\n 'Escape',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n]);\n\n/**\n * Tracks whether focus highlighting should be visible for keyboard navigation.\n * Keyboard mode is enabled via Tab and reset by mouse interaction.\n */\nexport const useKeyboardFocusHighlighting = (isEnabledProp?: boolean): boolean => {\n const colorScheme = useContext<ColorSchemeContextProps | undefined>(ColorSchemeContext);\n const contextIsEnabled: boolean = colorScheme?.shouldEnableKeyboardHighlighting === true;\n const isEnabled: boolean = isEnabledProp ?? contextIsEnabled;\n\n const [isKeyboardNavigation, setIsKeyboardNavigation] = useState(false);\n\n useEffect(() => {\n const canListen = isEnabled && typeof window !== 'undefined';\n\n const enableKeyboardNavigation = () => {\n setIsKeyboardNavigation(true);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n\n if (!KEYBOARD_NAVIGATION_KEYS.has(event.key)) {\n return;\n }\n\n enableKeyboardNavigation();\n };\n\n const disableKeyboardNavigation = () => {\n setIsKeyboardNavigation((current) => (current ? false : current));\n };\n\n if (canListen) {\n window.addEventListener('keydown', handleKeyDown);\n window.addEventListener('mousedown', disableKeyboardNavigation);\n window.addEventListener('mousemove', disableKeyboardNavigation);\n } else {\n setIsKeyboardNavigation(false);\n }\n\n return () => {\n if (canListen) {\n window.removeEventListener('keydown', handleKeyDown);\n window.removeEventListener('mousedown', disableKeyboardNavigation);\n window.removeEventListener('mousemove', disableKeyboardNavigation);\n }\n };\n }, [isEnabled]);\n\n return Boolean(isEnabled && isKeyboardNavigation);\n};\n"],"mappings":"AAAA;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACvD,SACIC,kBAAkB,QAEf,yDAAyD;AAEhE,MAAMC,wBAAwB,GAAG,IAAIC,GAAG,CAAC,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W,EAAEF,yBAAyB,CAAC;IACnE,CAAC,MAAM;MACHX,uBAAuB,CAAC,KAAK,CAAC;IAClC;IAEA,OAAO,MAAM;MACT,IAAIC,SAAS,EAAE;QACXC,MAAM,CAACY,mBAAmB,CAAC,SAAS,EAAEV,aAAa,CAAC;QACpDF,MAAM,CAACY,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;QAClET,MAAM,CAACY,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;MACtE;IACJ,CAAC;EACL,CAAC,EAAE,CAACb,SAAS,CAAC,CAAC;EAEf,OAAOiB,OAAO,CAACjB,SAAS,IAAIC,oBAAoB,CAAC;AACrD,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.4.13-alpha.0",
3
+ "version": "5.4.14-alpha.0",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -88,5 +88,5 @@
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  },
91
- "gitHead": "d865a29f61b8f875fa7582a2b5fd9023de2dee9f"
91
+ "gitHead": "83d8c925dfdb3760ce82257c03c532d91f33a8d6"
92
92
  }