@dynatrace/strato-components 0.84.12

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.
Files changed (139) hide show
  1. package/LICENSE +174 -0
  2. package/README.md +15 -0
  3. package/codeshift.config.js +5 -0
  4. package/core/components/app-root/AppRoot.css +2584 -0
  5. package/core/components/app-root/AppRoot.d.ts +17 -0
  6. package/core/components/app-root/AppRoot.js +1 -0
  7. package/core/components/app-root/AppRoot.sty.d.ts +1 -0
  8. package/core/components/app-root/AppRoot.sty.js +1 -0
  9. package/core/components/focus-scope/FocusScope.d.ts +29 -0
  10. package/core/components/focus-scope/FocusScope.js +1 -0
  11. package/core/contexts/FocusContext.d.ts +19 -0
  12. package/core/contexts/FocusContext.js +1 -0
  13. package/core/hooks/useActiveElement.d.ts +6 -0
  14. package/core/hooks/useActiveElement.js +1 -0
  15. package/core/hooks/useCurrentTheme.d.ts +2 -0
  16. package/core/hooks/useCurrentTheme.js +1 -0
  17. package/core/hooks/useFocusContext.d.ts +6 -0
  18. package/core/hooks/useFocusContext.js +1 -0
  19. package/core/index.d.ts +16 -0
  20. package/core/index.js +1 -0
  21. package/core/providers/FocusProvider.d.ts +17 -0
  22. package/core/providers/FocusProvider.js +1 -0
  23. package/core/types/data-props.d.ts +7 -0
  24. package/core/types/data-props.js +1 -0
  25. package/core/types/styling-props.d.ts +18 -0
  26. package/core/types/styling-props.js +1 -0
  27. package/core/types/with-children.d.ts +6 -0
  28. package/core/types/with-children.js +1 -0
  29. package/core/utils/focus-management/attempt-focus.d.ts +8 -0
  30. package/core/utils/focus-management/attempt-focus.js +1 -0
  31. package/core/utils/focus-management/focus-first-descendant.d.ts +8 -0
  32. package/core/utils/focus-management/focus-first-descendant.js +1 -0
  33. package/core/utils/focus-management/get-first-focusable-child.d.ts +10 -0
  34. package/core/utils/focus-management/get-first-focusable-child.js +1 -0
  35. package/core/utils/focus-management/get-last-focusable-child.d.ts +10 -0
  36. package/core/utils/focus-management/get-last-focusable-child.js +1 -0
  37. package/core/utils/focus-management/is-focusable.d.ts +7 -0
  38. package/core/utils/focus-management/is-focusable.js +1 -0
  39. package/core/utils/isBrowser.d.ts +7 -0
  40. package/core/utils/isBrowser.js +1 -0
  41. package/core/utils/merge-props.d.ts +31 -0
  42. package/core/utils/merge-props.js +1 -0
  43. package/esm/core/components/app-root/AppRoot.css +2584 -0
  44. package/esm/core/components/app-root/AppRoot.js +2 -0
  45. package/esm/core/components/app-root/AppRoot.js.map +7 -0
  46. package/esm/core/components/app-root/AppRoot.sty.js +2 -0
  47. package/esm/core/components/app-root/AppRoot.sty.js.map +7 -0
  48. package/esm/core/components/focus-scope/FocusScope.js +2 -0
  49. package/esm/core/components/focus-scope/FocusScope.js.map +7 -0
  50. package/esm/core/contexts/FocusContext.js +2 -0
  51. package/esm/core/contexts/FocusContext.js.map +7 -0
  52. package/esm/core/hooks/useActiveElement.js +2 -0
  53. package/esm/core/hooks/useActiveElement.js.map +7 -0
  54. package/esm/core/hooks/useCurrentTheme.js +2 -0
  55. package/esm/core/hooks/useCurrentTheme.js.map +7 -0
  56. package/esm/core/hooks/useFocusContext.js +2 -0
  57. package/esm/core/hooks/useFocusContext.js.map +7 -0
  58. package/esm/core/index.js +2 -0
  59. package/esm/core/index.js.map +7 -0
  60. package/esm/core/providers/FocusProvider.js +2 -0
  61. package/esm/core/providers/FocusProvider.js.map +7 -0
  62. package/esm/core/types/data-props.js +1 -0
  63. package/esm/core/types/data-props.js.map +7 -0
  64. package/esm/core/types/styling-props.js +1 -0
  65. package/esm/core/types/styling-props.js.map +7 -0
  66. package/esm/core/types/with-children.js +1 -0
  67. package/esm/core/types/with-children.js.map +7 -0
  68. package/esm/core/utils/focus-management/attempt-focus.js +2 -0
  69. package/esm/core/utils/focus-management/attempt-focus.js.map +7 -0
  70. package/esm/core/utils/focus-management/focus-first-descendant.js +2 -0
  71. package/esm/core/utils/focus-management/focus-first-descendant.js.map +7 -0
  72. package/esm/core/utils/focus-management/get-first-focusable-child.js +2 -0
  73. package/esm/core/utils/focus-management/get-first-focusable-child.js.map +7 -0
  74. package/esm/core/utils/focus-management/get-last-focusable-child.js +2 -0
  75. package/esm/core/utils/focus-management/get-last-focusable-child.js.map +7 -0
  76. package/esm/core/utils/focus-management/is-focusable.js +2 -0
  77. package/esm/core/utils/focus-management/is-focusable.js.map +7 -0
  78. package/esm/core/utils/isBrowser.js +2 -0
  79. package/esm/core/utils/isBrowser.js.map +7 -0
  80. package/esm/core/utils/merge-props.js +2 -0
  81. package/esm/core/utils/merge-props.js.map +7 -0
  82. package/esm/index.js +2 -0
  83. package/esm/index.js.map +7 -0
  84. package/index.d.ts +1 -0
  85. package/index.js +1 -0
  86. package/lang/en.json +2 -0
  87. package/lang/ja.json +2 -0
  88. package/lang/uncompiled/en.json +1 -0
  89. package/lang/uncompiled/ja.json +1 -0
  90. package/migrations.json +3 -0
  91. package/package.json +74 -0
  92. package/testing/custom-render.d.ts +10 -0
  93. package/testing/custom-render.js +1 -0
  94. package/testing/index.d.ts +22 -0
  95. package/testing/index.js +1 -0
  96. package/testing/jest/index.d.ts +1 -0
  97. package/testing/jest/index.js +5 -0
  98. package/testing/jest/jest-preset.d.ts +7 -0
  99. package/testing/jest/jest-preset.js +10 -0
  100. package/testing/jest/resolver.d.ts +0 -0
  101. package/testing/jest/resolver.js +27 -0
  102. package/testing/mocks/bounding-client-rect-mock.d.ts +4 -0
  103. package/testing/mocks/bounding-client-rect-mock.js +1 -0
  104. package/testing/mocks/canvas-mock.d.ts +11 -0
  105. package/testing/mocks/canvas-mock.js +1 -0
  106. package/testing/mocks/create-mock-element.d.ts +12 -0
  107. package/testing/mocks/create-mock-element.js +1 -0
  108. package/testing/mocks/create-range-mock.d.ts +7 -0
  109. package/testing/mocks/create-range-mock.js +1 -0
  110. package/testing/mocks/dom-rect-mock.d.ts +12 -0
  111. package/testing/mocks/dom-rect-mock.js +1 -0
  112. package/testing/mocks/fetch-mock.d.ts +6 -0
  113. package/testing/mocks/fetch-mock.js +1 -0
  114. package/testing/mocks/intersection-observer-mock.d.ts +7 -0
  115. package/testing/mocks/intersection-observer-mock.js +1 -0
  116. package/testing/mocks/match-media-mock.d.ts +7 -0
  117. package/testing/mocks/match-media-mock.js +1 -0
  118. package/testing/mocks/offset-height-mock.d.ts +4 -0
  119. package/testing/mocks/offset-height-mock.js +1 -0
  120. package/testing/mocks/offset-width-mock.d.ts +4 -0
  121. package/testing/mocks/offset-width-mock.js +1 -0
  122. package/testing/mocks/pointer-event-mock.d.ts +4 -0
  123. package/testing/mocks/pointer-event-mock.js +1 -0
  124. package/testing/mocks/resize-observer-mock.d.ts +7 -0
  125. package/testing/mocks/resize-observer-mock.js +1 -0
  126. package/testing/mocks/screen-size-mock.d.ts +4 -0
  127. package/testing/mocks/screen-size-mock.js +1 -0
  128. package/testing/mocks/scroll-into-view-mock.d.ts +8 -0
  129. package/testing/mocks/scroll-into-view-mock.js +1 -0
  130. package/testing/mocks/scroll-width-mock.d.ts +4 -0
  131. package/testing/mocks/scroll-width-mock.js +1 -0
  132. package/testing/mocks/select-mock.d.ts +10 -0
  133. package/testing/mocks/select-mock.js +1 -0
  134. package/testing/mocks/table-virtualization-mock.d.ts +7 -0
  135. package/testing/mocks/table-virtualization-mock.js +1 -0
  136. package/testing/mocks/text-ellipsis-mock.d.ts +4 -0
  137. package/testing/mocks/text-ellipsis-mock.js +1 -0
  138. package/testing/setup.d.ts +4 -0
  139. package/testing/setup.js +1 -0
@@ -0,0 +1,17 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import 'wicg-inert';
3
+ import './AppRoot.css.js';
4
+ import { type DataTestId } from '../../types/data-props.js';
5
+ import { type StylingProps } from '../../types/styling-props.js';
6
+ /** AppRoot component props. */
7
+ export type AppRootProps = PropsWithChildren<DataTestId & StylingProps>;
8
+ /**
9
+ * In order to have all the providers in place for rendering overlays, applying
10
+ * global styles or internationalization, you need to wrap your app in the
11
+ * `AppRoot`. If you're using the `dt-app` to create your app, this is
12
+ * automatically taken care of and you can start working on your app without
13
+ * further ado.
14
+ */
15
+ export declare const AppRoot: React.ForwardRefExoticComponent<DataTestId & StylingProps & {
16
+ children?: React.ReactNode;
17
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1 @@
1
+ var T=Object.create;var i=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var s in t)i(e,s,{get:t[s],enumerable:!0})},u=(e,t,s,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A(t))!F.call(e,n)&&n!==s&&i(e,n,{get:()=>t[n],enumerable:!(m=I(t,n))||m.enumerable});return e};var D=(e,t,s)=>(s=e!=null?T(C(e)):{},u(t||!e||!e.__esModule?i(s,"default",{value:e,enumerable:!0}):s,e)),L=e=>u(i({},"__esModule",{value:!0}),e);var b={};R(b,{AppRoot:()=>E});module.exports=L(b);var f=require("lodash"),o=D(require("react")),h=require("react-intl"),W=require("wicg-inert"),d=require("@dynatrace-sdk/user-preferences"),Z=require("./AppRoot.sty.js"),g=require("../../hooks/useCurrentTheme.js"),y=require("../../providers/FocusProvider.js");function N(){const t=document.querySelector("base")?.href??"/";return t.endsWith("/")?t:`${t}/`}const S="en",E=(0,o.forwardRef)((e,t)=>{const{style:s,className:m,"data-testid":n="app-root"}=e,[P,c]=(0,o.useState)({}),{children:v}=e,l=(0,g.useCurrentTheme)(),a=(0,d.getLanguage)();let p=(0,d.getTimezone)();try{new Intl.DateTimeFormat(a,{timeZone:p})}catch{p=Intl.DateTimeFormat().resolvedOptions().timeZone}return(0,o.useLayoutEffect)(()=>{const r=document.createElement("link");return r.rel="stylesheet",r.href="https://dt-cdn.net/fonts/fonts-v004.css",document.head.appendChild(r),()=>{document.head.removeChild(r)}},[]),(0,o.useLayoutEffect)(()=>{document!==void 0&&document.documentElement.setAttribute("data-theme",l)},[l]),(0,o.useEffect)(()=>{a!=="en"&&fetch(`${N()}lang/${a}.json`).then(r=>r.json()).then(r=>{c(r)}).catch(()=>{c(r=>(0,f.isEmpty)(r)?r:{})})},[a]),o.default.createElement("div",{ref:t,"data-testid":n,className:m,style:s,"data-theme":l},o.default.createElement(h.IntlProvider,{locale:a,timeZone:p,messages:P,defaultLocale:S},o.default.createElement(y.FocusProvider,null,v)))});E.displayName="AppRoot";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ var i=require("./AppRoot.css");
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import type { WithChildren } from '../../types/with-children.js';
3
+ /**
4
+ * Prop definition of the `FocusScope` component.
5
+ * @internal
6
+ */
7
+ export interface FocusScopeProps extends WithChildren {
8
+ /**
9
+ * If set to true, the focus scope automatically focuses the first focusable element inside.
10
+ * @defaultValue false
11
+ */
12
+ autoFocus?: boolean;
13
+ /**
14
+ * If set to true, the focus scope traps the focus inside.
15
+ * @defaultValue false
16
+ */
17
+ contain?: boolean;
18
+ }
19
+ /**
20
+ * @internal
21
+ * The `FocusScope` helps you manage the focus when opening any overlay. If you
22
+ * want to create a custom overlay, you can wrap the content of your overlay in the
23
+ * `FocusScope` to help you make the overlay accessible and handle focus
24
+ * appropriately.
25
+ */
26
+ export declare const FocusScope: {
27
+ (props: FocusScopeProps): React.JSX.Element;
28
+ displayName: string;
29
+ };
@@ -0,0 +1 @@
1
+ var y=Object.create;var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var F=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of v(t))!E.call(e,o)&&o!==n&&u(e,o,{get:()=>t[o],enumerable:!(c=b(t,o))||c.enumerable});return e};var x=(e,t,n)=>(n=e!=null?y(w(e)):{},f(t||!e||!e.__esModule?u(n,"default",{value:e,enumerable:!0}):n,e)),C=e=>f(u({},"__esModule",{value:!0}),e);var k={};F(k,{FocusScope:()=>m});module.exports=C(k);var r=x(require("react")),d=require("../../hooks/useActiveElement.js"),p=require("../../hooks/useFocusContext.js"),l=require("../../utils/focus-management/focus-first-descendant.js");const m=e=>{const{autoFocus:t,contain:n,children:c}=e,o=(0,p.useFocusContext)(),a=(0,r.useRef)(null),h=(0,d.useActiveElement)(),i=(0,r.useRef)(h);return(0,r.useEffect)(()=>{if((n||t)&&(0,l.focusFirstDescendant)(a.current),n){o.setBackgroundInertness(!0);const s=i.current;return()=>{o.setBackgroundInertness(!1),window.setTimeout(()=>s.focus(),0)}}!t&&!n&&document.addEventListener("keydown",s=>{s.key==="Tab"&&s.target===i.current&&(s.preventDefault(),(0,l.focusFirstDescendant)(a.current))});const g=i.current;return()=>{g.focus()}},[n,t]),r.default.createElement("div",{style:{display:"contents"},ref:a,"aria-labelledby":i.current.id},c)};m.displayName="FocusScope";
@@ -0,0 +1,19 @@
1
+ import { Modality } from '../providers/FocusProvider.js';
2
+ /**
3
+ * Defines the contents of the FocusContext.
4
+ * @internal
5
+ */
6
+ export type FocusContextProps = {
7
+ backgroundInertness?: boolean;
8
+ modality: Modality;
9
+ setBackgroundInertness: (value: boolean) => void;
10
+ };
11
+ /**
12
+ * @internal
13
+ *
14
+ * This context keeps all information needed for proper focus management.
15
+ * @param modality - currently used pointer device
16
+ * @param backgroundInertness - if the background (behind overlays) is currently inert (inactive)
17
+ * @param setBackgroundInertness - updates the backgrounds active status
18
+ */
19
+ export declare const FocusContext: import("react").Context<FocusContextProps>;
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=(e,o)=>{for(var t in o)r(e,t,{get:o[t],enumerable:!0})},i=(e,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of d(o))!l.call(e,n)&&n!==t&&r(e,n,{get:()=>o[n],enumerable:!(s=u(o,n))||s.enumerable});return e};var p=e=>i(r({},"__esModule",{value:!0}),e);var x={};c(x,{FocusContext:()=>m});module.exports=p(x);var a=require("react");const m=(0,a.createContext)({modality:"unknown",backgroundInertness:void 0,setBackgroundInertness:e=>null});
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @internal
3
+ * Hook used for getting the active element.
4
+ * @returns the currently focused element.
5
+ */
6
+ export declare const useActiveElement: () => HTMLElement;
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var E=(t,e)=>{for(var n in e)m(t,n,{get:e[n],enumerable:!0})},v=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of i(e))!r.call(t,c)&&c!==n&&m(t,c,{get:()=>e[c],enumerable:!(s=u(e,c))||s.enumerable});return t};var a=t=>v(m({},"__esModule",{value:!0}),t);var l={};E(l,{useActiveElement:()=>d});module.exports=a(l);var o=require("react");const d=()=>{const[t,e]=(0,o.useState)(document.activeElement),n=s=>{e(document.activeElement)};return(0,o.useEffect)(()=>(document.addEventListener("focusin",n),()=>{document.removeEventListener("focusin",n)}),[]),t};
@@ -0,0 +1,2 @@
1
+ /** Returns the current theme based on sdk-setting or browsers preferred color-scheme */
2
+ export declare function useCurrentTheme(): 'light' | 'dark';
@@ -0,0 +1 @@
1
+ var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var o in e)s(r,o,{get:e[o],enumerable:!0})},g=(r,e,o,h)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!d.call(r,t)&&t!==o&&s(r,t,{get:()=>e[t],enumerable:!(h=c(e,t))||h.enumerable});return r};var l=r=>g(s({},"__esModule",{value:!0}),r);var p={};f(p,{useCurrentTheme:()=>k});module.exports=l(p);var n=require("react"),m=require("@dynatrace-sdk/user-preferences"),i=require("../utils/isBrowser.js");function k(){const r=(0,n.useMemo)(()=>(0,m.getTheme)(),[]);if(r==="dark"||r==="light")return r;if(!i.isBrowser)return"light";const e=(0,n.useMemo)(()=>window&&window.matchMedia("(prefers-color-scheme: dark)"),[]),[o,h]=(0,n.useState)(e.matches?"dark":"light");return(0,n.useEffect)(()=>{const t=()=>{const a=e.matches;h(a?"dark":"light")};return e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[e]),o}
@@ -0,0 +1,6 @@
1
+ import { type FocusContextProps } from '../contexts/FocusContext.js';
2
+ /**
3
+ * Internal hook wrapper for accessing the FocusContext.
4
+ * @internal
5
+ */
6
+ export declare const useFocusContext: () => FocusContextProps;
@@ -0,0 +1 @@
1
+ var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var m=(t,o)=>{for(var r in o)s(t,r,{get:o[r],enumerable:!0})},F=(t,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!C.call(t,e)&&e!==r&&s(t,e,{get:()=>o[e],enumerable:!(n=x(o,e))||n.enumerable});return t};var f=t=>F(s({},"__esModule",{value:!0}),t);var P={};m(P,{useFocusContext:()=>i});module.exports=f(P);var u=require("react"),p=require("../contexts/FocusContext.js");const i=()=>(0,u.useContext)(p.FocusContext);
@@ -0,0 +1,16 @@
1
+ export { AppRoot, type AppRootProps } from './components/app-root/AppRoot.js';
2
+ export { FocusScope as _FocusScope, type FocusScopeProps as _FocusScopeProps, } from './components/focus-scope/FocusScope.js';
3
+ export { type FocusContextProps as _FocusContextProps } from './contexts/FocusContext.js';
4
+ export { useCurrentTheme } from './hooks/useCurrentTheme.js';
5
+ export { useFocusContext as _useFocusContext } from './hooks/useFocusContext.js';
6
+ export { FocusProvider as _FocusProvider, type Modality as _Modality, } from './providers/FocusProvider.js';
7
+ export type { DataTestId } from './types/data-props.js';
8
+ export type { StylingProps } from './types/styling-props.js';
9
+ export type { WithChildren } from './types/with-children.js';
10
+ export { attemptFocus as _attemptFocus } from './utils/focus-management/attempt-focus.js';
11
+ export { focusFirstDescendant as _focusFirstDescendant } from './utils/focus-management/focus-first-descendant.js';
12
+ export { getFirstFocusableChild as _getFirstFocusableChild } from './utils/focus-management/get-first-focusable-child.js';
13
+ export { getLastFocusableChild as _getLastFocusableChild } from './utils/focus-management/get-last-focusable-child.js';
14
+ export { isFocusable as _isFocusable } from './utils/focus-management/is-focusable.js';
15
+ export { isBrowser as _isBrowser } from './utils/isBrowser.js';
16
+ export { mergeProps as _mergeProps, type NullToObject as _NullToObject, type TupleTypes as _TupleTypes, type UnionToIntersection as _UnionToIntersection, } from './utils/merge-props.js';
package/core/index.js ADDED
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(e,o)=>{for(var t in o)r(e,t,{get:o[t],enumerable:!0})},h=(e,o,t,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of C(o))!P.call(e,s)&&s!==t&&r(e,s,{get:()=>o[s],enumerable:!(p=d(o,s))||p.enumerable});return e};var b=e=>h(r({},"__esModule",{value:!0}),e);var g={};T(g,{AppRoot:()=>a.AppRoot,_FocusProvider:()=>l.FocusProvider,_FocusScope:()=>c.FocusScope,_attemptFocus:()=>F.attemptFocus,_focusFirstDescendant:()=>m.focusFirstDescendant,_getFirstFocusableChild:()=>n.getFirstFocusableChild,_getLastFocusableChild:()=>x.getLastFocusableChild,_isBrowser:()=>f.isBrowser,_isFocusable:()=>y.isFocusable,_mergeProps:()=>_.mergeProps,_useFocusContext:()=>i.useFocusContext,useCurrentTheme:()=>u.useCurrentTheme});module.exports=b(g);var a=require("./components/app-root/AppRoot.js"),c=require("./components/focus-scope/FocusScope.js"),u=require("./hooks/useCurrentTheme.js"),i=require("./hooks/useFocusContext.js"),l=require("./providers/FocusProvider.js"),F=require("./utils/focus-management/attempt-focus.js"),m=require("./utils/focus-management/focus-first-descendant.js"),n=require("./utils/focus-management/get-first-focusable-child.js"),x=require("./utils/focus-management/get-last-focusable-child.js"),y=require("./utils/focus-management/is-focusable.js"),f=require("./utils/isBrowser.js"),_=require("./utils/merge-props.js");
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { WithChildren } from '../types/with-children.js';
3
+ /**
4
+ * @internal
5
+ * Type defining the modality options for the focus handling.
6
+ */
7
+ export type Modality = 'keyboard' | 'pointer' | 'touch' | 'unknown';
8
+ /**
9
+ * @internal
10
+ *
11
+ * Provider that can be reused in components for storing the focus context props.
12
+ * Loosely inspired by [what-input-js](https://github.com/ten1seven/what-input/blob/main/src/scripts/what-input.js).
13
+ */
14
+ export declare const FocusProvider: {
15
+ ({ children }: WithChildren): React.JSX.Element;
16
+ displayName: string;
17
+ };
@@ -0,0 +1 @@
1
+ var k=Object.create;var a=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(e,o)=>{for(var n in o)a(e,n,{get:o[n],enumerable:!0})},p=(e,o,n,d)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of f(o))!L.call(e,r)&&r!==n&&a(e,r,{get:()=>o[r],enumerable:!(d=v(o,r))||d.enumerable});return e};var g=(e,o,n)=>(n=e!=null?k(b(e)):{},p(o||!e||!e.__esModule?a(n,"default",{value:e,enumerable:!0}):n,e)),E=e=>p(a({},"__esModule",{value:!0}),e);var S={};M(S,{FocusProvider:()=>m});module.exports=E(S);var t=g(require("react")),w=require("../contexts/FocusContext.js"),l=require("../hooks/useFocusContext.js"),y=require("../utils/merge-props.js");const P=["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","OS","ScrollLock","Super","Symbol","SymbolLock"],C={keydown:"keyboard",keyup:"keyboard",mousedown:"mouse",mousemove:"mouse",MSPointerDown:"pointer",MSPointerMove:"pointer",pointerdown:"pointer",pointermove:"pointer",touchstart:"touch",touchend:"touch",wheel:"wheel"},x=["Tab","Esc","Escape"," ","ArrowDown","Down","ArrowUp","Up","ArrowLeft","Left","ArrowRight","Right","End","Home","PageDown","PageUp"],m=({children:e})=>{const[o,n]=(0,t.useState)(!1),d=(0,l.useFocusContext)(),[r,u]=(0,t.useState)("unknown"),c=(0,t.useCallback)(s=>{if(P.includes(s.key)){u("pointer");return}(!s.target||x.includes(s.key))&&u("keyboard")},[]),i=(0,t.useCallback)(s=>{switch(C[s.type]){case"touch":case"pen":return u("touch");case"mouse":case"pointer":case"wheel":return u("pointer");default:return"unknown"}},[]);(0,t.useEffect)(()=>(window.addEventListener("pointerdown",i),window.addEventListener("keydown",c,{capture:!0}),window.addEventListener("wheel",i),()=>{window.removeEventListener("pointerdown",i),window.removeEventListener("keydown",c,{capture:!0}),window.removeEventListener("wheel",i)}),[c,i]);const h=o?{inert:"true",tabIndex:-1,"aria-hidden":!0}:{inert:void 0,tabIndex:void 0,"aria-hidden":!1};return t.default.createElement(w.FocusContext.Provider,{value:{...(0,y.mergeProps)(d,{backgroundInertness:o,setBackgroundInertness:n,modality:r})}},t.default.createElement("div",{...h},e))};m.displayName="FocusProvider";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Type defining the data-testid prop that is mapped to the rendered components root node.
3
+ */
4
+ export type DataTestId = {
5
+ /** Test id used for selecting the component's container. */
6
+ 'data-testid'?: string;
7
+ };
@@ -0,0 +1 @@
1
+ var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var n=(a,t,i,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of r(t))!g.call(a,e)&&e!==i&&s(a,e,{get:()=>t[e],enumerable:!(d=p(t,e))||d.enumerable});return a};var o=a=>n(s({},"__esModule",{value:!0}),a);var x={};module.exports=o(x);
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ /**
3
+ * Collection of component styling props including `style` and `className` types.
4
+ */
5
+ export interface StylingProps {
6
+ /**
7
+ * Classname that gets applied to the root element of the component.
8
+ *
9
+ * Be aware that overriding certain styles may result in unexpected behavior!
10
+ */
11
+ className?: string;
12
+ /**
13
+ * Style attribute that will be mapped to the root element of the component.
14
+ *
15
+ * Be aware that overriding certain styles may result in unexpected behavior!
16
+ */
17
+ style?: React.CSSProperties;
18
+ }
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!p.call(t,r)&&r!==i&&a(t,r,{get:()=>e[r],enumerable:!(s=o(e,r))||s.enumerable});return t};var m=t=>l(a({},"__esModule",{value:!0}),t);var n={};module.exports=m(n);
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ /** Helper type to add children to props */
3
+ export interface WithChildren {
4
+ /** Children provided to the component. */
5
+ children?: ReactNode;
6
+ }
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var n=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!h.call(t,r)&&r!==o&&i(t,r,{get:()=>e[r],enumerable:!(c=a(e,r))||c.enumerable});return t};var p=t=>n(i({},"__esModule",{value:!0}),t);var f={};module.exports=p(f);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Set Attempt to set focus on the current node.
5
+ * @param element - The node to attempt to focus on.
6
+ * @returns - true if element is focused.
7
+ */
8
+ export declare const attemptFocus: (element: HTMLElement) => boolean;
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var i=(t,r)=>{for(var c in r)o(t,c,{get:r[c],enumerable:!0})},l=(t,r,c,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of n(r))!f.call(t,e)&&e!==c&&o(t,e,{get:()=>r[e],enumerable:!(u=a(r,e))||u.enumerable});return t};var m=t=>l(o({},"__esModule",{value:!0}),t);var v={};i(v,{attemptFocus:()=>p});module.exports=m(v);var s=require("./is-focusable.js");const p=t=>{if(!(0,s.isFocusable)(t))return!1;try{t.focus({preventScroll:!0})}catch{}return document.activeElement===t};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Set focus on descendant nodes until the first focusable element is found.
5
+ * @param element - DOM node for which to find the first focusable descendant.
6
+ * @returns true if a focusable element is found and focus is set.
7
+ */
8
+ export declare const focusFirstDescendant: (element: HTMLElement | null) => boolean;
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var a=(r,t)=>{for(var e in t)l(r,e,{get:t[e],enumerable:!0})},d=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f(t))!u.call(r,n)&&n!==e&&l(r,n,{get:()=>t[n],enumerable:!(s=o(t,n))||s.enumerable});return r};var h=r=>d(l({},"__esModule",{value:!0}),r);var m={};a(m,{focusFirstDescendant:()=>i});module.exports=h(m);var c=require("./attempt-focus.js");const i=r=>{if(!r)return!1;for(let t=0;t<r.children.length;t++){const e=r.children[t];if((0,c.attemptFocus)(e)||i(e))return!0}return!1};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * If you need access to the first focusable descendant of a container, you can use
5
+ * `getFirstFocusableChild`. The function uses the
6
+ * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker to
7
+ * iterate over the children of the container and returns either a `Node` if a
8
+ * focusable element is found, or `null`.
9
+ */
10
+ export declare function getFirstFocusableChild(container: HTMLElement | Node): Node | null;
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var a=(r,e)=>{for(var o in e)n(r,o,{get:e[o],enumerable:!0})},s=(r,e,o,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!i.call(r,t)&&t!==o&&n(r,t,{get:()=>e[t],enumerable:!(l=c(e,t))||l.enumerable});return r};var N=r=>s(n({},"__esModule",{value:!0}),r);var f={};a(f,{getFirstFocusableChild:()=>m});module.exports=N(f);var u=require("./is-focusable.js");function m(r){const e=document.createTreeWalker(r);for(;e.nextNode();)if((0,u.isFocusable)(e.currentNode))return e.currentNode;return null}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * If you need access to the last focusable descendant of a container, you can use
5
+ * `getLastFocusableChild`. The function uses the
6
+ * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker to
7
+ * iterate over the children of the container and returns either a `Node` if a
8
+ * focusable element is found, or `null`.
9
+ */
10
+ export declare function getLastFocusableChild(container: HTMLElement): Node | null;
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var c=(r,e)=>{for(var t in e)o(r,t,{get:e[t],enumerable:!0})},s=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of d(e))!a.call(r,l)&&l!==t&&o(r,l,{get:()=>e[l],enumerable:!(n=i(e,l))||n.enumerable});return r};var h=r=>s(o({},"__esModule",{value:!0}),r);var N={};c(N,{getLastFocusableChild:()=>m});module.exports=h(N);var u=require("./is-focusable.js");function m(r){const e=document.createTreeWalker(r);for(;e.lastChild();)e.lastChild();do if((0,u.isFocusable)(e.currentNode))return e.currentNode;while(e.previousNode());return null}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Use the `isFocusable` utility function to check whether an element can receive
5
+ * focus.
6
+ */
7
+ export declare function isFocusable(element: any): boolean;
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var i=(a,r)=>{for(var u in r)c(a,u,{get:r[u],enumerable:!0})},T=(a,r,u,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of t(r))!n.call(a,s)&&s!==u&&c(a,s,{get:()=>r[s],enumerable:!(d=e(r,s))||d.enumerable});return a};var f=a=>T(c({},"__esModule",{value:!0}),a);var o={};i(o,{isFocusable:()=>b});module.exports=f(o);function b(a){if(a.tabIndex<0||a.disabled)return!1;switch(a.nodeName){case"A":return!!a.href;case"INPUT":return a.type!=="hidden";case"BUTTON":case"SELECT":case"TEXTAREA":return!0;default:return a.tabIndex>=0}}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Whether the code is currently executed in a browser
5
+ * @see https://github.com/chakra-ui/chakra-ui/blob/main/packages/utils/src/dom.ts
6
+ */
7
+ export declare const isBrowser: boolean;
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(n,e)=>{for(var t in e)d(n,t,{get:e[t],enumerable:!0})},m=(n,e,t,w)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of i(e))!c.call(n,o)&&o!==t&&d(n,o,{get:()=>e[o],enumerable:!(w=r(e,o))||w.enumerable});return n};var s=n=>m(d({},"__esModule",{value:!0}),n);var p={};u(p,{isBrowser:()=>f});module.exports=s(p);const f=!!(typeof window<"u"&&window.document&&window.document.createElement);
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @internal
3
+ * Internal helper mapper type for mergeProps
4
+ */
5
+ export type TupleTypes<T> = {
6
+ [P in keyof T]: T[P];
7
+ } extends {
8
+ [key: number]: infer V;
9
+ } ? NullToObject<V> : never;
10
+ /**
11
+ * @internal
12
+ * Internal helper mapper type for mergeProps
13
+ */
14
+ export type NullToObject<T> = T extends null | undefined ? {} : T;
15
+ /**
16
+ * @internal
17
+ * Internal helper mapper type for mergeProps
18
+ */
19
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
20
+ /**
21
+ * @internal
22
+ *
23
+ * Merges multiple props objects together. Event handlers are chained,
24
+ * classNames are combined, and ids are deduplicated - different ids
25
+ * will trigger a side-effect and re-render components hooked up with `useId`.
26
+ * For all other props, the last prop object overrides all previous ones.
27
+ * @param args - Multiple sets of props to merge together.
28
+ */
29
+ export declare function mergeProps<T extends ({
30
+ [key: string]: any;
31
+ } | null | undefined)[]>(...args: T): UnionToIntersection<TupleTypes<T>>;
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)c(o,t,{get:e[t],enumerable:!0})},y=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of f(e))!p.call(o,n)&&n!==t&&c(o,n,{get:()=>e[n],enumerable:!(i=T(e,n))||i.enumerable});return o};var l=o=>y(c({},"__esModule",{value:!0}),o);var x={};u(x,{mergeProps:()=>a});module.exports=l(x);function d(...o){return(...e)=>{for(const t of o)typeof t=="function"&&t(...e)}}function a(...o){const e={...o[0]};for(let t=1;t<o.length;t++){const i=o[t];for(const n in i){const s=e[n],r=i[n];typeof s=="function"&&typeof r=="function"&&n[0]==="o"&&n[1]==="n"&&n.charCodeAt(2)>=65&&n.charCodeAt(2)<=90?e[n]=d(s,r):e[n]=r!==void 0?r:s}}return e}