@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.
- package/LICENSE +174 -0
- package/README.md +15 -0
- package/codeshift.config.js +5 -0
- package/core/components/app-root/AppRoot.css +2584 -0
- package/core/components/app-root/AppRoot.d.ts +17 -0
- package/core/components/app-root/AppRoot.js +1 -0
- package/core/components/app-root/AppRoot.sty.d.ts +1 -0
- package/core/components/app-root/AppRoot.sty.js +1 -0
- package/core/components/focus-scope/FocusScope.d.ts +29 -0
- package/core/components/focus-scope/FocusScope.js +1 -0
- package/core/contexts/FocusContext.d.ts +19 -0
- package/core/contexts/FocusContext.js +1 -0
- package/core/hooks/useActiveElement.d.ts +6 -0
- package/core/hooks/useActiveElement.js +1 -0
- package/core/hooks/useCurrentTheme.d.ts +2 -0
- package/core/hooks/useCurrentTheme.js +1 -0
- package/core/hooks/useFocusContext.d.ts +6 -0
- package/core/hooks/useFocusContext.js +1 -0
- package/core/index.d.ts +16 -0
- package/core/index.js +1 -0
- package/core/providers/FocusProvider.d.ts +17 -0
- package/core/providers/FocusProvider.js +1 -0
- package/core/types/data-props.d.ts +7 -0
- package/core/types/data-props.js +1 -0
- package/core/types/styling-props.d.ts +18 -0
- package/core/types/styling-props.js +1 -0
- package/core/types/with-children.d.ts +6 -0
- package/core/types/with-children.js +1 -0
- package/core/utils/focus-management/attempt-focus.d.ts +8 -0
- package/core/utils/focus-management/attempt-focus.js +1 -0
- package/core/utils/focus-management/focus-first-descendant.d.ts +8 -0
- package/core/utils/focus-management/focus-first-descendant.js +1 -0
- package/core/utils/focus-management/get-first-focusable-child.d.ts +10 -0
- package/core/utils/focus-management/get-first-focusable-child.js +1 -0
- package/core/utils/focus-management/get-last-focusable-child.d.ts +10 -0
- package/core/utils/focus-management/get-last-focusable-child.js +1 -0
- package/core/utils/focus-management/is-focusable.d.ts +7 -0
- package/core/utils/focus-management/is-focusable.js +1 -0
- package/core/utils/isBrowser.d.ts +7 -0
- package/core/utils/isBrowser.js +1 -0
- package/core/utils/merge-props.d.ts +31 -0
- package/core/utils/merge-props.js +1 -0
- package/esm/core/components/app-root/AppRoot.css +2584 -0
- package/esm/core/components/app-root/AppRoot.js +2 -0
- package/esm/core/components/app-root/AppRoot.js.map +7 -0
- package/esm/core/components/app-root/AppRoot.sty.js +2 -0
- package/esm/core/components/app-root/AppRoot.sty.js.map +7 -0
- package/esm/core/components/focus-scope/FocusScope.js +2 -0
- package/esm/core/components/focus-scope/FocusScope.js.map +7 -0
- package/esm/core/contexts/FocusContext.js +2 -0
- package/esm/core/contexts/FocusContext.js.map +7 -0
- package/esm/core/hooks/useActiveElement.js +2 -0
- package/esm/core/hooks/useActiveElement.js.map +7 -0
- package/esm/core/hooks/useCurrentTheme.js +2 -0
- package/esm/core/hooks/useCurrentTheme.js.map +7 -0
- package/esm/core/hooks/useFocusContext.js +2 -0
- package/esm/core/hooks/useFocusContext.js.map +7 -0
- package/esm/core/index.js +2 -0
- package/esm/core/index.js.map +7 -0
- package/esm/core/providers/FocusProvider.js +2 -0
- package/esm/core/providers/FocusProvider.js.map +7 -0
- package/esm/core/types/data-props.js +1 -0
- package/esm/core/types/data-props.js.map +7 -0
- package/esm/core/types/styling-props.js +1 -0
- package/esm/core/types/styling-props.js.map +7 -0
- package/esm/core/types/with-children.js +1 -0
- package/esm/core/types/with-children.js.map +7 -0
- package/esm/core/utils/focus-management/attempt-focus.js +2 -0
- package/esm/core/utils/focus-management/attempt-focus.js.map +7 -0
- package/esm/core/utils/focus-management/focus-first-descendant.js +2 -0
- package/esm/core/utils/focus-management/focus-first-descendant.js.map +7 -0
- package/esm/core/utils/focus-management/get-first-focusable-child.js +2 -0
- package/esm/core/utils/focus-management/get-first-focusable-child.js.map +7 -0
- package/esm/core/utils/focus-management/get-last-focusable-child.js +2 -0
- package/esm/core/utils/focus-management/get-last-focusable-child.js.map +7 -0
- package/esm/core/utils/focus-management/is-focusable.js +2 -0
- package/esm/core/utils/focus-management/is-focusable.js.map +7 -0
- package/esm/core/utils/isBrowser.js +2 -0
- package/esm/core/utils/isBrowser.js.map +7 -0
- package/esm/core/utils/merge-props.js +2 -0
- package/esm/core/utils/merge-props.js.map +7 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +7 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/lang/en.json +2 -0
- package/lang/ja.json +2 -0
- package/lang/uncompiled/en.json +1 -0
- package/lang/uncompiled/ja.json +1 -0
- package/migrations.json +3 -0
- package/package.json +74 -0
- package/testing/custom-render.d.ts +10 -0
- package/testing/custom-render.js +1 -0
- package/testing/index.d.ts +22 -0
- package/testing/index.js +1 -0
- package/testing/jest/index.d.ts +1 -0
- package/testing/jest/index.js +5 -0
- package/testing/jest/jest-preset.d.ts +7 -0
- package/testing/jest/jest-preset.js +10 -0
- package/testing/jest/resolver.d.ts +0 -0
- package/testing/jest/resolver.js +27 -0
- package/testing/mocks/bounding-client-rect-mock.d.ts +4 -0
- package/testing/mocks/bounding-client-rect-mock.js +1 -0
- package/testing/mocks/canvas-mock.d.ts +11 -0
- package/testing/mocks/canvas-mock.js +1 -0
- package/testing/mocks/create-mock-element.d.ts +12 -0
- package/testing/mocks/create-mock-element.js +1 -0
- package/testing/mocks/create-range-mock.d.ts +7 -0
- package/testing/mocks/create-range-mock.js +1 -0
- package/testing/mocks/dom-rect-mock.d.ts +12 -0
- package/testing/mocks/dom-rect-mock.js +1 -0
- package/testing/mocks/fetch-mock.d.ts +6 -0
- package/testing/mocks/fetch-mock.js +1 -0
- package/testing/mocks/intersection-observer-mock.d.ts +7 -0
- package/testing/mocks/intersection-observer-mock.js +1 -0
- package/testing/mocks/match-media-mock.d.ts +7 -0
- package/testing/mocks/match-media-mock.js +1 -0
- package/testing/mocks/offset-height-mock.d.ts +4 -0
- package/testing/mocks/offset-height-mock.js +1 -0
- package/testing/mocks/offset-width-mock.d.ts +4 -0
- package/testing/mocks/offset-width-mock.js +1 -0
- package/testing/mocks/pointer-event-mock.d.ts +4 -0
- package/testing/mocks/pointer-event-mock.js +1 -0
- package/testing/mocks/resize-observer-mock.d.ts +7 -0
- package/testing/mocks/resize-observer-mock.js +1 -0
- package/testing/mocks/screen-size-mock.d.ts +4 -0
- package/testing/mocks/screen-size-mock.js +1 -0
- package/testing/mocks/scroll-into-view-mock.d.ts +8 -0
- package/testing/mocks/scroll-into-view-mock.js +1 -0
- package/testing/mocks/scroll-width-mock.d.ts +4 -0
- package/testing/mocks/scroll-width-mock.js +1 -0
- package/testing/mocks/select-mock.d.ts +10 -0
- package/testing/mocks/select-mock.js +1 -0
- package/testing/mocks/table-virtualization-mock.d.ts +7 -0
- package/testing/mocks/table-virtualization-mock.js +1 -0
- package/testing/mocks/text-ellipsis-mock.d.ts +4 -0
- package/testing/mocks/text-ellipsis-mock.js +1 -0
- package/testing/setup.d.ts +4 -0
- package/testing/setup.js +1 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isEmpty as f}from"lodash-es";import a,{forwardRef as h,useEffect as g,useLayoutEffect as i,useState as y}from"react";import{IntlProvider as E}from"react-intl";import"wicg-inert";import{getLanguage as P,getTimezone as v}from"@dynatrace-sdk/user-preferences";import"./AppRoot.sty.js";import{useCurrentTheme as T}from"../../hooks/useCurrentTheme.js";import{FocusProvider as I}from"../../providers/FocusProvider.js";function A(){const t=document.querySelector("base")?.href??"/";return t.endsWith("/")?t:`${t}/`}const C="en",F=h((r,t)=>{const{style:d,className:l,"data-testid":p="app-root"}=r,[c,m]=y({}),{children:u}=r,s=T(),o=P();let n=v();try{new Intl.DateTimeFormat(o,{timeZone:n})}catch{n=Intl.DateTimeFormat().resolvedOptions().timeZone}return i(()=>{const e=document.createElement("link");return e.rel="stylesheet",e.href="https://dt-cdn.net/fonts/fonts-v004.css",document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]),i(()=>{document!==void 0&&document.documentElement.setAttribute("data-theme",s)},[s]),g(()=>{o!=="en"&&fetch(`${A()}lang/${o}.json`).then(e=>e.json()).then(e=>{m(e)}).catch(()=>{m(e=>f(e)?e:{})})},[o]),a.createElement("div",{ref:t,"data-testid":p,className:l,style:d,"data-theme":s},a.createElement(E,{locale:o,timeZone:n,messages:c,defaultLocale:C},a.createElement(I,null,u)))});F.displayName="AppRoot";export{F as AppRoot};
|
|
2
|
+
//# sourceMappingURL=AppRoot.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/components/app-root/AppRoot.tsx"],
|
|
4
|
+
"sourcesContent": ["import { isEmpty } from 'lodash-es';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { IntlProvider, type MessageFormatElement } from 'react-intl';\n\nimport 'wicg-inert';\nimport { getLanguage, getTimezone } from '@dynatrace-sdk/user-preferences';\n\nimport './AppRoot.sty.js';\nimport { useCurrentTheme } from '../../hooks/useCurrentTheme.js';\nimport { FocusProvider } from '../../providers/FocusProvider.js';\nimport { type DataTestId } from '../../types/data-props.js';\nimport { type StylingProps } from '../../types/styling-props.js';\n\n/**\n * Gets the href value set in the <base> element to prefix fetches correctly.\n * Will always end with a `/` value\n */\nfunction getBaseHref(): string {\n const baseElement = document.querySelector('base');\n const href = baseElement?.href ?? '/';\n return href.endsWith('/') ? href : `${href}/`;\n}\n\n/** AppRoot component props. */\nexport type AppRootProps = PropsWithChildren<DataTestId & StylingProps>;\n\nconst defaultLanguage = 'en';\n/**\n * In order to have all the providers in place for rendering overlays, applying\n * global styles or internationalization, you need to wrap your app in the\n * `AppRoot`. If you're using the `dt-app` to create your app, this is\n * automatically taken care of and you can start working on your app without\n * further ado.\n */\nexport const AppRoot = /* @__PURE__ */ forwardRef<HTMLDivElement, AppRootProps>(\n (props, forwardedRef) => {\n const {\n style: consumerStyle,\n className: consumerClassName,\n 'data-testid': dataTestId = 'app-root',\n } = props;\n\n /** Messages that are used for the translation. */\n const [messages, setMessages] = useState<\n Record<string, string> | Record<string, MessageFormatElement[]>\n >({});\n\n const { children } = props;\n\n const theme = useCurrentTheme();\n const language = getLanguage();\n let timezone = getTimezone();\n try {\n new Intl.DateTimeFormat(language, { timeZone: timezone });\n } catch (error) {\n // If the passed timezone is not valid, we can fall back to the browsers\n // configured one.\n timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /** Inject the font link into the head */\n useLayoutEffect(() => {\n // As we should not use @import within the createGlobalStyles\n // https://styled-components.com/docs/faqs#note-regarding-css-import-and-createglobalstyle\n // and we need to inject the fonts at run time to decouple font usage\n // from the cli build / deployment\n // we will inject the link tag here in the root on initial load.\n const link = document.createElement('link');\n\n link.rel = 'stylesheet';\n link.href = 'https://dt-cdn.net/fonts/fonts-v004.css';\n document.head.appendChild(link);\n return () => {\n document.head.removeChild(link);\n };\n }, []);\n\n /**\n * Synchronize the [data-theme] attribute to the root of the document\n * to have the design tokens defined in the cascade.\n */\n useLayoutEffect(() => {\n if (document !== undefined) {\n document.documentElement.setAttribute('data-theme', theme);\n }\n }, [theme]);\n\n useEffect(() => {\n if (language === 'en') {\n // Don't fetch translations for 'en' to avoid an additional render cycle.\n // The default messages are in english already.\n return;\n }\n\n fetch(`${getBaseHref()}lang/${language}.json`)\n .then((res) => {\n return res.json();\n })\n .then((receivedMessages) => {\n setMessages(receivedMessages);\n })\n .catch(() => {\n // Only set messages to a new empty object if the previous messages were not empty.\n // `setMessages({})` would make react believe that this is a new object and, hence, re-render.\n // By just returning `prev` if the messages were already empty, we can avoid the additional render.\n setMessages((prev) => (isEmpty(prev) ? prev : {}));\n });\n }, [language]);\n\n return (\n <div\n ref={forwardedRef}\n data-testid={dataTestId}\n className={consumerClassName}\n style={consumerStyle}\n data-theme={theme}\n >\n <IntlProvider\n locale={language}\n timeZone={timezone}\n messages={messages}\n defaultLocale={defaultLanguage}\n >\n <FocusProvider>{children}</FocusProvider>\n </IntlProvider>\n </div>\n );\n },\n);\n\n(AppRoot as typeof AppRoot & { displayName: string }).displayName = 'AppRoot';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,WAAAA,MAAe,YACxB,OAAOC,GAEL,cAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,YAAAC,MACK,QACP,OAAS,gBAAAC,MAA+C,aAExD,MAAO,aACP,OAAS,eAAAC,EAAa,eAAAC,MAAmB,kCAEzC,MAAO,mBACP,OAAS,mBAAAC,MAAuB,iCAChC,OAAS,iBAAAC,MAAqB,mCAQ9B,SAASC,GAAsB,CAE7B,MAAMC,EADc,SAAS,cAAc,MAAM,GACvB,MAAQ,IAClC,OAAOA,EAAK,SAAS,GAAG,EAAIA,EAAO,GAAGA,CAAI,GAC5C,CAKA,MAAMC,EAAkB,KAQXC,EAA0BZ,EACrC,CAACa,EAAOC,IAAiB,CACvB,KAAM,CACJ,MAAOC,EACP,UAAWC,EACX,cAAeC,EAAa,UAC9B,EAAIJ,EAGE,CAACK,EAAUC,CAAW,EAAIhB,EAE9B,CAAC,CAAC,EAEE,CAAE,SAAAiB,CAAS,EAAIP,EAEfQ,EAAQd,EAAgB,EACxBe,EAAWjB,EAAY,EAC7B,IAAIkB,EAAWjB,EAAY,EAC3B,GAAI,CACF,IAAI,KAAK,eAAegB,EAAU,CAAE,SAAUC,CAAS,CAAC,CAC1D,MAAgB,CAGdA,EAAW,KAAK,eAAe,EAAE,gBAAgB,EAAE,QACrD,CAGA,OAAArB,EAAgB,IAAM,CAMpB,MAAMsB,EAAO,SAAS,cAAc,MAAM,EAE1C,OAAAA,EAAK,IAAM,aACXA,EAAK,KAAO,0CACZ,SAAS,KAAK,YAAYA,CAAI,EACvB,IAAM,CACX,SAAS,KAAK,YAAYA,CAAI,CAChC,CACF,EAAG,CAAC,CAAC,EAMLtB,EAAgB,IAAM,CAChB,WAAa,QACf,SAAS,gBAAgB,aAAa,aAAcmB,CAAK,CAE7D,EAAG,CAACA,CAAK,CAAC,EAEVpB,EAAU,IAAM,CACVqB,IAAa,MAMjB,MAAM,GAAGb,EAAY,CAAC,QAAQa,CAAQ,OAAO,EAC1C,KAAMG,GACEA,EAAI,KAAK,CACjB,EACA,KAAMC,GAAqB,CAC1BP,EAAYO,CAAgB,CAC9B,CAAC,EACA,MAAM,IAAM,CAIXP,EAAaQ,GAAU7B,EAAQ6B,CAAI,EAAIA,EAAO,CAAC,CAAE,CACnD,CAAC,CACL,EAAG,CAACL,CAAQ,CAAC,EAGXvB,EAAA,cAAC,OACC,IAAKe,EACL,cAAaG,EACb,UAAWD,EACX,MAAOD,EACP,aAAYM,GAEZtB,EAAA,cAACK,EAAA,CACC,OAAQkB,EACR,SAAUC,EACV,SAAUL,EACV,cAAeP,GAEfZ,EAAA,cAACS,EAAA,KAAeY,CAAS,CAC3B,CACF,CAEJ,CACF,EAECR,EAAqD,YAAc",
|
|
6
|
+
"names": ["isEmpty", "React", "forwardRef", "useEffect", "useLayoutEffect", "useState", "IntlProvider", "getLanguage", "getTimezone", "useCurrentTheme", "FocusProvider", "getBaseHref", "href", "defaultLanguage", "AppRoot", "props", "forwardedRef", "consumerStyle", "consumerClassName", "dataTestId", "messages", "setMessages", "children", "theme", "language", "timezone", "link", "res", "receivedMessages", "prev"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import d,{useEffect as p,useRef as c}from"react";import{useActiveElement as m}from"../../hooks/useActiveElement.js";import{useFocusContext as h}from"../../hooks/useFocusContext.js";import{focusFirstDescendant as i}from"../../utils/focus-management/focus-first-descendant.js";const g=u=>{const{autoFocus:o,contain:t,children:a}=u,s=h(),r=c(null),l=m(),n=c(l);return p(()=>{if((t||o)&&i(r.current),t){s.setBackgroundInertness(!0);const e=n.current;return()=>{s.setBackgroundInertness(!1),window.setTimeout(()=>e.focus(),0)}}!o&&!t&&document.addEventListener("keydown",e=>{e.key==="Tab"&&e.target===n.current&&(e.preventDefault(),i(r.current))});const f=n.current;return()=>{f.focus()}},[t,o]),d.createElement("div",{style:{display:"contents"},ref:r,"aria-labelledby":n.current.id},a)};g.displayName="FocusScope";export{g as FocusScope};
|
|
2
|
+
//# sourceMappingURL=FocusScope.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/components/focus-scope/FocusScope.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useRef } from 'react';\n\nimport { useActiveElement } from '../../hooks/useActiveElement.js';\nimport { useFocusContext } from '../../hooks/useFocusContext.js';\nimport type { WithChildren } from '../../types/with-children.js';\nimport { focusFirstDescendant } from '../../utils/focus-management/focus-first-descendant.js';\n\n// #region Types\n\n/**\n * Prop definition of the `FocusScope` component.\n * @internal\n */\nexport interface FocusScopeProps extends WithChildren {\n /**\n * If set to true, the focus scope automatically focuses the first focusable element inside.\n * @defaultValue false\n */\n autoFocus?: boolean;\n /**\n * If set to true, the focus scope traps the focus inside.\n * @defaultValue false\n */\n contain?: boolean;\n}\n// #endregion Types\n\n/**\n * @internal\n * The `FocusScope` helps you manage the focus when opening any overlay. If you\n * want to create a custom overlay, you can wrap the content of your overlay in the\n * `FocusScope` to help you make the overlay accessible and handle focus\n * appropriately.\n */\nexport const FocusScope = (props: FocusScopeProps) => {\n const { autoFocus, contain, children } = props;\n const focusContext = useFocusContext();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const focusedElement = useActiveElement();\n const triggerElement = useRef(focusedElement);\n\n useEffect(() => {\n if (contain || autoFocus) {\n focusFirstDescendant(wrapperRef.current);\n }\n\n if (contain) {\n focusContext.setBackgroundInertness(true);\n const triggerElementCopy = triggerElement.current;\n\n return () => {\n focusContext.setBackgroundInertness(false);\n // The focus must be restored on the trigger after removing the inert prop on\n // AppRoot (rendering complete). SetTimeout creates a macrotask to change queueing order.\n window.setTimeout(() => triggerElementCopy.focus(), 0);\n };\n }\n\n if (!autoFocus && !contain) {\n document.addEventListener('keydown', (e) => {\n if (e.key !== 'Tab') {\n return;\n }\n\n if (e.target === triggerElement.current) {\n e.preventDefault();\n focusFirstDescendant(wrapperRef.current);\n }\n });\n }\n\n const triggerElementCopy = triggerElement.current;\n\n return () => {\n // restore focus on trigger when unmounting the focusscope\n triggerElementCopy.focus();\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [contain, autoFocus]);\n\n return (\n <div\n style={{ display: 'contents' }}\n ref={wrapperRef}\n aria-labelledby={triggerElement.current.id}\n // Prevents that focus is lost when clicking on non-focusable items inside (atm used in the internal Drawer).\n // Probably worth considering moving that to the focusScope when redoing the overlays.\n // tabIndex={-1}\n >\n {children}\n </div>\n );\n};\n\nFocusScope.displayName = 'FocusScope';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,GAAS,aAAAC,EAAW,UAAAC,MAAc,QAEzC,OAAS,oBAAAC,MAAwB,kCACjC,OAAS,mBAAAC,MAAuB,iCAEhC,OAAS,wBAAAC,MAA4B,yDA6B9B,MAAMC,EAAcC,GAA2B,CACpD,KAAM,CAAE,UAAAC,EAAW,QAAAC,EAAS,SAAAC,CAAS,EAAIH,EACnCI,EAAeP,EAAgB,EAC/BQ,EAAaV,EAAuB,IAAI,EACxCW,EAAiBV,EAAiB,EAClCW,EAAiBZ,EAAOW,CAAc,EAE5C,OAAAZ,EAAU,IAAM,CAKd,IAJIQ,GAAWD,IACbH,EAAqBO,EAAW,OAAO,EAGrCH,EAAS,CACXE,EAAa,uBAAuB,EAAI,EACxC,MAAMI,EAAqBD,EAAe,QAE1C,MAAO,IAAM,CACXH,EAAa,uBAAuB,EAAK,EAGzC,OAAO,WAAW,IAAMI,EAAmB,MAAM,EAAG,CAAC,CACvD,CACF,CAEI,CAACP,GAAa,CAACC,GACjB,SAAS,iBAAiB,UAAY,GAAM,CACtC,EAAE,MAAQ,OAIV,EAAE,SAAWK,EAAe,UAC9B,EAAE,eAAe,EACjBT,EAAqBO,EAAW,OAAO,EAE3C,CAAC,EAGH,MAAMG,EAAqBD,EAAe,QAE1C,MAAO,IAAM,CAEXC,EAAmB,MAAM,CAC3B,CAGF,EAAG,CAACN,EAASD,CAAS,CAAC,EAGrBR,EAAA,cAAC,OACC,MAAO,CAAE,QAAS,UAAW,EAC7B,IAAKY,EACL,kBAAiBE,EAAe,QAAQ,IAKvCJ,CACH,CAEJ,EAEAJ,EAAW,YAAc",
|
|
6
|
+
"names": ["React", "useEffect", "useRef", "useActiveElement", "useFocusContext", "focusFirstDescendant", "FocusScope", "props", "autoFocus", "contain", "children", "focusContext", "wrapperRef", "focusedElement", "triggerElement", "triggerElementCopy"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/contexts/FocusContext.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\n\nimport { Modality } from '../providers/FocusProvider.js';\n\n/**\n * Defines the contents of the FocusContext.\n * @internal\n */\nexport type FocusContextProps = {\n backgroundInertness?: boolean;\n modality: Modality;\n setBackgroundInertness: (value: boolean) => void;\n};\n\n/**\n * @internal\n *\n * This context keeps all information needed for proper focus management.\n * @param modality - currently used pointer device\n * @param backgroundInertness - if the background (behind overlays) is currently inert (inactive)\n * @param setBackgroundInertness - updates the backgrounds active status\n */\nexport const FocusContext = createContext<FocusContextProps>({\n modality: 'unknown',\n backgroundInertness: undefined,\n setBackgroundInertness: (value) => null,\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,QAsBvB,MAAMC,EAAeD,EAAiC,CAC3D,SAAU,UACV,oBAAqB,OACrB,uBAAyBE,GAAU,IACrC,CAAC",
|
|
6
|
+
"names": ["createContext", "FocusContext", "value"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useState as c,useEffect as o}from"react";const u=()=>{const[t,n]=c(document.activeElement),e=s=>{n(document.activeElement)};return o(()=>(document.addEventListener("focusin",e),()=>{document.removeEventListener("focusin",e)}),[]),t};export{u as useActiveElement};
|
|
2
|
+
//# sourceMappingURL=useActiveElement.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/hooks/useActiveElement.ts"],
|
|
4
|
+
"sourcesContent": ["import { useState, useEffect } from 'react';\n\n/**\n * @internal\n * Hook used for getting the active element.\n * @returns the currently focused element.\n */\nexport const useActiveElement = (): HTMLElement => {\n const [active, setActive] = useState(document.activeElement as HTMLElement);\n\n const handleFocusIn = (e: FocusEvent) => {\n setActive(document.activeElement as HTMLElement);\n };\n\n useEffect(() => {\n document.addEventListener('focusin', handleFocusIn);\n return () => {\n document.removeEventListener('focusin', handleFocusIn);\n };\n }, []);\n\n return active;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,EAAU,aAAAC,MAAiB,QAO7B,MAAMC,EAAmB,IAAmB,CACjD,KAAM,CAACC,EAAQC,CAAS,EAAIJ,EAAS,SAAS,aAA4B,EAEpEK,EAAiBC,GAAkB,CACvCF,EAAU,SAAS,aAA4B,CACjD,EAEA,OAAAH,EAAU,KACR,SAAS,iBAAiB,UAAWI,CAAa,EAC3C,IAAM,CACX,SAAS,oBAAoB,UAAWA,CAAa,CACvD,GACC,CAAC,CAAC,EAEEF,CACT",
|
|
6
|
+
"names": ["useState", "useEffect", "useActiveElement", "active", "setActive", "handleFocusIn", "e"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useEffect as m,useMemo as n,useState as i}from"react";import{getTheme as a}from"@dynatrace-sdk/user-preferences";import{isBrowser as c}from"../utils/isBrowser.js";function g(){const r=n(()=>a(),[]);if(r==="dark"||r==="light")return r;if(!c)return"light";const e=n(()=>window&&window.matchMedia("(prefers-color-scheme: dark)"),[]),[o,h]=i(e.matches?"dark":"light");return m(()=>{const t=()=>{const s=e.matches;h(s?"dark":"light")};return e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[e]),o}export{g as useCurrentTheme};
|
|
2
|
+
//# sourceMappingURL=useCurrentTheme.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/hooks/useCurrentTheme.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useMemo, useState } from 'react';\n\nimport { getTheme } from '@dynatrace-sdk/user-preferences';\n\nimport { isBrowser } from '../utils/isBrowser.js';\n\n/** Returns the current theme based on sdk-setting or browsers preferred color-scheme */\nexport function useCurrentTheme(): 'light' | 'dark' {\n const sdkTheme = useMemo(() => {\n return getTheme();\n }, []);\n\n if (sdkTheme === 'dark' || sdkTheme === 'light') {\n return sdkTheme;\n }\n\n if (!isBrowser) {\n return 'light';\n }\n\n // suppressing the rules of hooks because the sdkTheme is a constant that cannot\n // change through the applications' lifecycle.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const themeQuery = useMemo(\n () => window && window.matchMedia('(prefers-color-scheme: dark)'),\n [],\n );\n\n // suppressing the rules of hooks because the sdkTheme is a constant that cannot\n // change through the applications' lifecycle.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [currentTheme, setCurrentTheme] = useState<'light' | 'dark'>(\n themeQuery.matches ? 'dark' : 'light',\n );\n\n // suppressing the rules of hooks because the sdkTheme is a constant that cannot\n // change through the applications' lifecycle.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n const handlePrefersColorSchemeChange = () => {\n const prefersDark = themeQuery.matches;\n setCurrentTheme(prefersDark ? 'dark' : 'light');\n };\n\n themeQuery.addEventListener('change', handlePrefersColorSchemeChange);\n return () => {\n themeQuery.removeEventListener('change', handlePrefersColorSchemeChange);\n };\n }, [themeQuery]);\n\n return currentTheme;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,aAAAA,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAE7C,OAAS,YAAAC,MAAgB,kCAEzB,OAAS,aAAAC,MAAiB,wBAGnB,SAASC,GAAoC,CAClD,MAAMC,EAAWL,EAAQ,IAChBE,EAAS,EACf,CAAC,CAAC,EAEL,GAAIG,IAAa,QAAUA,IAAa,QACtC,OAAOA,EAGT,GAAI,CAACF,EACH,MAAO,QAMT,MAAMG,EAAaN,EACjB,IAAM,QAAU,OAAO,WAAW,8BAA8B,EAChE,CAAC,CACH,EAKM,CAACO,EAAcC,CAAe,EAAIP,EACtCK,EAAW,QAAU,OAAS,OAChC,EAKA,OAAAP,EAAU,IAAM,CACd,MAAMU,EAAiC,IAAM,CAC3C,MAAMC,EAAcJ,EAAW,QAC/BE,EAAgBE,EAAc,OAAS,OAAO,CAChD,EAEA,OAAAJ,EAAW,iBAAiB,SAAUG,CAA8B,EAC7D,IAAM,CACXH,EAAW,oBAAoB,SAAUG,CAA8B,CACzE,CACF,EAAG,CAACH,CAAU,CAAC,EAERC,CACT",
|
|
6
|
+
"names": ["useEffect", "useMemo", "useState", "getTheme", "isBrowser", "useCurrentTheme", "sdkTheme", "themeQuery", "currentTheme", "setCurrentTheme", "handlePrefersColorSchemeChange", "prefersDark"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/hooks/useFocusContext.ts"],
|
|
4
|
+
"sourcesContent": ["import { useContext } from 'react';\n\nimport {\n type FocusContextProps,\n FocusContext,\n} from '../contexts/FocusContext.js';\n\n/**\n * Internal hook wrapper for accessing the FocusContext.\n * @internal\n */\nexport const useFocusContext = (): FocusContextProps => {\n return useContext(FocusContext);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAAkB,QAE3B,OAEE,gBAAAC,MACK,8BAMA,MAAMC,EAAkB,IACtBF,EAAWC,CAAY",
|
|
6
|
+
"names": ["useContext", "FocusContext", "useFocusContext"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AppRoot as s}from"./components/app-root/AppRoot.js";import{FocusScope as r}from"./components/focus-scope/FocusScope.js";import{useCurrentTheme as c}from"./hooks/useCurrentTheme.js";import{useFocusContext as i}from"./hooks/useFocusContext.js";import{FocusProvider as F}from"./providers/FocusProvider.js";import{attemptFocus as n}from"./utils/focus-management/attempt-focus.js";import{focusFirstDescendant as y}from"./utils/focus-management/focus-first-descendant.js";import{getFirstFocusableChild as _}from"./utils/focus-management/get-first-focusable-child.js";import{getLastFocusableChild as C}from"./utils/focus-management/get-last-focusable-child.js";import{isFocusable as T}from"./utils/focus-management/is-focusable.js";import{isBrowser as b}from"./utils/isBrowser.js";import{mergeProps as j}from"./utils/merge-props.js";export{s as AppRoot,F as _FocusProvider,r as _FocusScope,n as _attemptFocus,y as _focusFirstDescendant,_ as _getFirstFocusableChild,C as _getLastFocusableChild,b as _isBrowser,T as _isFocusable,j as _mergeProps,i as _useFocusContext,c as useCurrentTheme};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { AppRoot, type AppRootProps } from './components/app-root/AppRoot.js';\nexport {\n FocusScope as _FocusScope,\n type FocusScopeProps as _FocusScopeProps,\n} from './components/focus-scope/FocusScope.js';\n\nexport { type FocusContextProps as _FocusContextProps } from './contexts/FocusContext.js';\n\nexport { useCurrentTheme } from './hooks/useCurrentTheme.js';\nexport { useFocusContext as _useFocusContext } from './hooks/useFocusContext.js';\nexport {\n FocusProvider as _FocusProvider,\n type Modality as _Modality,\n} from './providers/FocusProvider.js';\nexport type { DataTestId } from './types/data-props.js';\nexport type { StylingProps } from './types/styling-props.js';\nexport type { WithChildren } from './types/with-children.js';\n\nexport { attemptFocus as _attemptFocus } from './utils/focus-management/attempt-focus.js';\nexport { focusFirstDescendant as _focusFirstDescendant } from './utils/focus-management/focus-first-descendant.js';\nexport { getFirstFocusableChild as _getFirstFocusableChild } from './utils/focus-management/get-first-focusable-child.js';\nexport { getLastFocusableChild as _getLastFocusableChild } from './utils/focus-management/get-last-focusable-child.js';\nexport { isFocusable as _isFocusable } from './utils/focus-management/is-focusable.js';\nexport { isBrowser as _isBrowser } from './utils/isBrowser.js';\nexport {\n mergeProps as _mergeProps,\n type NullToObject as _NullToObject,\n type TupleTypes as _TupleTypes,\n type UnionToIntersection as _UnionToIntersection,\n} from './utils/merge-props.js';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,WAAAA,MAAkC,mCAC3C,OACgB,cAAdC,MAEK,yCAIP,OAAS,mBAAAC,MAAuB,6BAChC,OAA4B,mBAAnBC,MAA2C,6BACpD,OACmB,iBAAjBC,MAEK,+BAKP,OAAyB,gBAAhBC,MAAqC,4CAC9C,OAAiC,wBAAxBC,MAAqD,qDAC9D,OAAmC,0BAA1BC,MAAyD,wDAClE,OAAkC,yBAAzBC,MAAuD,uDAChE,OAAwB,eAAfC,MAAmC,2CAC5C,OAAsB,aAAbC,MAA+B,uBACxC,OACgB,cAAdC,MAIK",
|
|
6
|
+
"names": ["AppRoot", "FocusScope", "useCurrentTheme", "useFocusContext", "FocusProvider", "attemptFocus", "focusFirstDescendant", "getFirstFocusableChild", "getLastFocusableChild", "isFocusable", "isBrowser", "mergeProps"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import i,{useCallback as s,useEffect as l,useState as d}from"react";import{FocusContext as y}from"../contexts/FocusContext.js";import{useFocusContext as m}from"../hooks/useFocusContext.js";import{mergeProps as h}from"../utils/merge-props.js";const k=["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","OS","ScrollLock","Super","Symbol","SymbolLock"],v={keydown:"keyboard",keyup:"keyboard",mousedown:"mouse",mousemove:"mouse",MSPointerDown:"pointer",MSPointerMove:"pointer",pointerdown:"pointer",pointermove:"pointer",touchstart:"touch",touchend:"touch",wheel:"wheel"},f=["Tab","Esc","Escape"," ","ArrowDown","Down","ArrowUp","Up","ArrowLeft","Left","ArrowRight","Right","End","Home","PageDown","PageUp"],b=({children:u})=>{const[r,a]=d(!1),c=m(),[p,t]=d("unknown"),n=s(o=>{if(k.includes(o.key)){t("pointer");return}(!o.target||f.includes(o.key))&&t("keyboard")},[]),e=s(o=>{switch(v[o.type]){case"touch":case"pen":return t("touch");case"mouse":case"pointer":case"wheel":return t("pointer");default:return"unknown"}},[]);l(()=>(window.addEventListener("pointerdown",e),window.addEventListener("keydown",n,{capture:!0}),window.addEventListener("wheel",e),()=>{window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",n,{capture:!0}),window.removeEventListener("wheel",e)}),[n,e]);const w=r?{inert:"true",tabIndex:-1,"aria-hidden":!0}:{inert:void 0,tabIndex:void 0,"aria-hidden":!1};return i.createElement(y.Provider,{value:{...h(c,{backgroundInertness:r,setBackgroundInertness:a,modality:p})}},i.createElement("div",{...w},u))};b.displayName="FocusProvider";export{b as FocusProvider};
|
|
2
|
+
//# sourceMappingURL=FocusProvider.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/providers/FocusProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useEffect, useState } from 'react';\n\nimport { FocusContext } from '../contexts/FocusContext.js';\nimport { useFocusContext } from '../hooks/useFocusContext.js';\nimport type { WithChildren } from '../types/with-children.js';\nimport { mergeProps } from '../utils/merge-props.js';\n\n// list of modifier keys commonly used in a mouse or keyboard combination,\n// see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#modifier_keys.\nconst ignoreMap = [\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Hyper',\n 'Meta', // Command (Mac), in some browsers also Windows-key\n 'NumLock',\n 'OS', // Windows-key\n 'ScrollLock',\n 'Super', // Virtual keyboard key\n 'Symbol',\n 'SymbolLock',\n];\n\n/** Look-up map of all event types and the corresponding modalities. */\nconst eventTypeMap: Record<string, string> = {\n keydown: 'keyboard',\n keyup: 'keyboard',\n mousedown: 'mouse',\n mousemove: 'mouse',\n MSPointerDown: 'pointer',\n MSPointerMove: 'pointer',\n pointerdown: 'pointer',\n pointermove: 'pointer',\n touchstart: 'touch',\n touchend: 'touch',\n wheel: 'wheel',\n};\n\n/**\n * @internal\n * Type defining the modality options for the focus handling.\n */\nexport type Modality = 'keyboard' | 'pointer' | 'touch' | 'unknown';\n\n/**\n * All navigational keys that should be considered keyboard users,\n * see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#navigation_keys\n */\nconst navigationalKeys = [\n 'Tab',\n 'Esc',\n 'Escape',\n ' ',\n 'ArrowDown',\n 'Down',\n 'ArrowUp',\n 'Up',\n 'ArrowLeft',\n 'Left',\n 'ArrowRight',\n 'Right',\n 'End',\n 'Home',\n 'PageDown',\n 'PageUp',\n];\n\n/**\n * @internal\n *\n * Provider that can be reused in components for storing the focus context props.\n * Loosely inspired by [what-input-js](https://github.com/ten1seven/what-input/blob/main/src/scripts/what-input.js).\n */\nexport const FocusProvider = ({ children }: WithChildren) => {\n const [backgroundInertness, setBackgroundInertness] = useState(false);\n const focusContext = useFocusContext();\n const [modality, setModality] = useState<Modality>('unknown');\n\n const setKeyboardInputModality = useCallback((event: KeyboardEvent) => {\n if (ignoreMap.includes(event.key)) {\n setModality('pointer');\n return;\n }\n\n if (!event.target || navigationalKeys.includes(event.key)) {\n setModality('keyboard');\n }\n }, []);\n\n const setMouseInputModality = useCallback((event: MouseEvent) => {\n switch (eventTypeMap[event.type]) {\n case 'touch':\n case 'pen':\n return setModality('touch');\n case 'mouse':\n case 'pointer':\n case 'wheel':\n return setModality('pointer');\n default:\n return 'unknown';\n }\n }, []);\n\n useEffect(() => {\n window.addEventListener('pointerdown', setMouseInputModality);\n // we need to rely on the keydown event (already in the capture phase) here so we don't break usages where the event default behavior is prevented or propagation is stopped,\n // which would otherwise get the wrong, initial, modality (unknown); by using the capture phase, we can ensure we set the modality correctly before the other events occur\n window.addEventListener('keydown', setKeyboardInputModality, {\n capture: true,\n });\n window.addEventListener('wheel', setMouseInputModality);\n\n return () => {\n window.removeEventListener('pointerdown', setMouseInputModality);\n window.removeEventListener('keydown', setKeyboardInputModality, {\n capture: true,\n });\n window.removeEventListener('wheel', setMouseInputModality);\n };\n }, [setKeyboardInputModality, setMouseInputModality]);\n\n const focusProps = backgroundInertness\n ? {\n inert: 'true',\n tabIndex: -1,\n 'aria-hidden': true,\n }\n : { inert: undefined, tabIndex: undefined, 'aria-hidden': false };\n\n return (\n <FocusContext.Provider\n value={{\n ...mergeProps(focusContext, {\n backgroundInertness,\n setBackgroundInertness,\n modality,\n }),\n }}\n >\n <div {...focusProps}>{children}</div>\n </FocusContext.Provider>\n );\n};\n\nFocusProvider['displayName'] = 'FocusProvider';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,GAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAExD,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,mBAAAC,MAAuB,8BAEhC,OAAS,cAAAC,MAAkB,0BAI3B,MAAMC,EAAY,CAChB,MACA,WACA,WACA,UACA,KACA,SACA,QACA,OACA,UACA,KACA,aACA,QACA,SACA,YACF,EAGMC,EAAuC,CAC3C,QAAS,WACT,MAAO,WACP,UAAW,QACX,UAAW,QACX,cAAe,UACf,cAAe,UACf,YAAa,UACb,YAAa,UACb,WAAY,QACZ,SAAU,QACV,MAAO,OACT,EAYMC,EAAmB,CACvB,MACA,MACA,SACA,IACA,YACA,OACA,UACA,KACA,YACA,OACA,aACA,QACA,MACA,OACA,WACA,QACF,EAQaC,EAAgB,CAAC,CAAE,SAAAC,CAAS,IAAoB,CAC3D,KAAM,CAACC,EAAqBC,CAAsB,EAAIV,EAAS,EAAK,EAC9DW,EAAeT,EAAgB,EAC/B,CAACU,EAAUC,CAAW,EAAIb,EAAmB,SAAS,EAEtDc,EAA2BhB,EAAaiB,GAAyB,CACrE,GAAIX,EAAU,SAASW,EAAM,GAAG,EAAG,CACjCF,EAAY,SAAS,EACrB,MACF,EAEI,CAACE,EAAM,QAAUT,EAAiB,SAASS,EAAM,GAAG,IACtDF,EAAY,UAAU,CAE1B,EAAG,CAAC,CAAC,EAECG,EAAwBlB,EAAaiB,GAAsB,CAC/D,OAAQV,EAAaU,EAAM,IAAI,EAAG,CAChC,IAAK,QACL,IAAK,MACH,OAAOF,EAAY,OAAO,EAC5B,IAAK,QACL,IAAK,UACL,IAAK,QACH,OAAOA,EAAY,SAAS,EAC9B,QACE,MAAO,SACX,CACF,EAAG,CAAC,CAAC,EAELd,EAAU,KACR,OAAO,iBAAiB,cAAeiB,CAAqB,EAG5D,OAAO,iBAAiB,UAAWF,EAA0B,CAC3D,QAAS,EACX,CAAC,EACD,OAAO,iBAAiB,QAASE,CAAqB,EAE/C,IAAM,CACX,OAAO,oBAAoB,cAAeA,CAAqB,EAC/D,OAAO,oBAAoB,UAAWF,EAA0B,CAC9D,QAAS,EACX,CAAC,EACD,OAAO,oBAAoB,QAASE,CAAqB,CAC3D,GACC,CAACF,EAA0BE,CAAqB,CAAC,EAEpD,MAAMC,EAAaR,EACf,CACE,MAAO,OACP,SAAU,GACV,cAAe,EACjB,EACA,CAAE,MAAO,OAAW,SAAU,OAAW,cAAe,EAAM,EAElE,OACEZ,EAAA,cAACI,EAAa,SAAb,CACC,MAAO,CACL,GAAGE,EAAWQ,EAAc,CAC1B,oBAAAF,EACA,uBAAAC,EACA,SAAAE,CACF,CAAC,CACH,GAEAf,EAAA,cAAC,OAAK,GAAGoB,GAAaT,CAAS,CACjC,CAEJ,EAEAD,EAAc,YAAiB",
|
|
6
|
+
"names": ["React", "useCallback", "useEffect", "useState", "FocusContext", "useFocusContext", "mergeProps", "ignoreMap", "eventTypeMap", "navigationalKeys", "FocusProvider", "children", "backgroundInertness", "setBackgroundInertness", "focusContext", "modality", "setModality", "setKeyboardInputModality", "event", "setMouseInputModality", "focusProps"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=data-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=styling-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=with-children.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/utils/focus-management/attempt-focus.ts"],
|
|
4
|
+
"sourcesContent": ["import { isFocusable } from './is-focusable.js';\n\n/**\n * @internal\n *\n * Set Attempt to set focus on the current node.\n * @param element - The node to attempt to focus on.\n * @returns - true if element is focused.\n */\nexport const attemptFocus = (element: HTMLElement) => {\n if (!isFocusable(element)) {\n return false;\n }\n\n try {\n element.focus({ preventScroll: true });\n } catch (e) {\n // continue regardless of error\n }\n\n return document.activeElement === element;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,MAAmB,oBASrB,MAAMC,EAAgBC,GAAyB,CACpD,GAAI,CAACF,EAAYE,CAAO,EACtB,MAAO,GAGT,GAAI,CACFA,EAAQ,MAAM,CAAE,cAAe,EAAK,CAAC,CACvC,MAAY,CAEZ,CAEA,OAAO,SAAS,gBAAkBA,CACpC",
|
|
6
|
+
"names": ["isFocusable", "attemptFocus", "element"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/utils/focus-management/focus-first-descendant.ts"],
|
|
4
|
+
"sourcesContent": ["import { attemptFocus } from './attempt-focus.js';\n\n/**\n * @internal\n *\n * Set focus on descendant nodes until the first focusable element is found.\n * @param element - DOM node for which to find the first focusable descendant.\n * @returns true if a focusable element is found and focus is set.\n */\nexport const focusFirstDescendant = (element: HTMLElement | null) => {\n if (!element) {\n return false;\n }\n\n for (let i = 0; i < element.children.length; i++) {\n const child = element.children[i] as HTMLElement;\n if (attemptFocus(child) || focusFirstDescendant(child)) {\n return true;\n }\n }\n\n return false;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,gBAAAA,MAAoB,qBAStB,MAAMC,EAAwBC,GAAgC,CACnE,GAAI,CAACA,EACH,MAAO,GAGT,QAASC,EAAI,EAAGA,EAAID,EAAQ,SAAS,OAAQC,IAAK,CAChD,MAAMC,EAAQF,EAAQ,SAASC,CAAC,EAChC,GAAIH,EAAaI,CAAK,GAAKH,EAAqBG,CAAK,EACnD,MAAO,EAEX,CAEA,MAAO,EACT",
|
|
6
|
+
"names": ["attemptFocus", "focusFirstDescendant", "element", "i", "child"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/utils/focus-management/get-first-focusable-child.ts"],
|
|
4
|
+
"sourcesContent": ["import { isFocusable } from './is-focusable.js';\n\n/**\n * @internal\n *\n * If you need access to the first focusable descendant of a container, you can use\n * `getFirstFocusableChild`. The function uses the\n * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker to\n * iterate over the children of the container and returns either a `Node` if a\n * focusable element is found, or `null`.\n */\nexport function getFirstFocusableChild(\n container: HTMLElement | Node,\n): Node | null {\n const treeWalker = document.createTreeWalker(container);\n\n // Iterate over all the nodes inside the container and return the current node if it is focusable.\n while (treeWalker.nextNode()) {\n if (isFocusable(treeWalker.currentNode)) {\n return treeWalker.currentNode;\n }\n }\n\n return null;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,MAAmB,oBAWrB,SAASC,EACdC,EACa,CACb,MAAMC,EAAa,SAAS,iBAAiBD,CAAS,EAGtD,KAAOC,EAAW,SAAS,GACzB,GAAIH,EAAYG,EAAW,WAAW,EACpC,OAAOA,EAAW,YAItB,OAAO,IACT",
|
|
6
|
+
"names": ["isFocusable", "getFirstFocusableChild", "container", "treeWalker"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isFocusable as l}from"./is-focusable.js";function o(r){const e=document.createTreeWalker(r);for(;e.lastChild();)e.lastChild();do if(l(e.currentNode))return e.currentNode;while(e.previousNode());return null}export{o as getLastFocusableChild};
|
|
2
|
+
//# sourceMappingURL=get-last-focusable-child.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/utils/focus-management/get-last-focusable-child.ts"],
|
|
4
|
+
"sourcesContent": ["import { isFocusable } from './is-focusable.js';\n\n/**\n * @internal\n *\n * If you need access to the last focusable descendant of a container, you can use\n * `getLastFocusableChild`. The function uses the\n * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker to\n * iterate over the children of the container and returns either a `Node` if a\n * focusable element is found, or `null`.\n */\nexport function getLastFocusableChild(container: HTMLElement): Node | null {\n const treeWalker = document.createTreeWalker(container);\n\n // Move the current node to the last node of the container.\n while (treeWalker.lastChild()) {\n treeWalker.lastChild();\n }\n\n // Iterate backwards over all the nodes inside the container and return the current node if it is focusable.\n do {\n if (isFocusable(treeWalker.currentNode)) {\n return treeWalker.currentNode;\n }\n } while (treeWalker.previousNode());\n\n return null;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,MAAmB,oBAWrB,SAASC,EAAsBC,EAAqC,CACzE,MAAMC,EAAa,SAAS,iBAAiBD,CAAS,EAGtD,KAAOC,EAAW,UAAU,GAC1BA,EAAW,UAAU,EAIvB,EACE,IAAIH,EAAYG,EAAW,WAAW,EACpC,OAAOA,EAAW,kBAEbA,EAAW,aAAa,GAEjC,OAAO,IACT",
|
|
6
|
+
"names": ["isFocusable", "getLastFocusableChild", "container", "treeWalker"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function r(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}}export{r as isFocusable};
|
|
2
|
+
//# sourceMappingURL=is-focusable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/core/utils/focus-management/is-focusable.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @internal\n *\n * Use the `isFocusable` utility function to check whether an element can receive\n * focus.\n */\nexport function isFocusable(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n element: any,\n) {\n if (element.tabIndex < 0 || element.disabled) {\n return false;\n }\n\n switch (element.nodeName) {\n case 'A':\n return !!element.href;\n case 'INPUT':\n return element.type !== 'hidden';\n case 'BUTTON':\n case 'SELECT':\n case 'TEXTAREA':\n return true;\n default:\n return element.tabIndex >= 0;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMO,SAASA,EAEdC,EACA,CACA,GAAIA,EAAQ,SAAW,GAAKA,EAAQ,SAClC,MAAO,GAGT,OAAQA,EAAQ,SAAU,CACxB,IAAK,IACH,MAAO,CAAC,CAACA,EAAQ,KACnB,IAAK,QACH,OAAOA,EAAQ,OAAS,SAC1B,IAAK,SACL,IAAK,SACL,IAAK,WACH,MAAO,GACT,QACE,OAAOA,EAAQ,UAAY,CAC/B,CACF",
|
|
6
|
+
"names": ["isFocusable", "element"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/utils/isBrowser.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @internal\n *\n * Whether the code is currently executed in a browser\n * @see https://github.com/chakra-ui/chakra-ui/blob/main/packages/utils/src/dom.ts\n */\nexport const isBrowser = (() => {\n return !!(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n );\n})();\n"],
|
|
5
|
+
"mappings": "AAMO,MAAMA,EACJ,CAAC,EACN,OAAO,OAAW,KAClB,OAAO,UACP,OAAO,SAAS",
|
|
6
|
+
"names": ["isBrowser"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function c(...t){return(...n)=>{for(const o of t)typeof o=="function"&&o(...n)}}function T(...t){const n={...t[0]};for(let o=1;o<t.length;o++){const s=t[o];for(const e in s){const r=n[e],i=s[e];typeof r=="function"&&typeof i=="function"&&e[0]==="o"&&e[1]==="n"&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90?n[e]=c(r,i):n[e]=i!==void 0?i:r}}return n}export{T as mergeProps};
|
|
2
|
+
//# sourceMappingURL=merge-props.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/utils/merge-props.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Calls all functions in the order they were chained with the same arguments.\n */\nfunction chain(...callbacks: any[]): (...args: any[]) => void {\n return (...args: any[]) => {\n for (const callback of callbacks) {\n if (typeof callback === 'function') {\n callback(...args);\n }\n }\n };\n}\n\n// taken from: https://stackoverflow.com/questions/51603250/typescript-3-parameter-list-intersection-type/51604379#51604379\n/**\n * @internal\n * Internal helper mapper type for mergeProps\n */\nexport type TupleTypes<T> = { [P in keyof T]: T[P] } extends {\n [key: number]: infer V;\n}\n ? NullToObject<V>\n : never;\n\n/**\n * @internal\n * Internal helper mapper type for mergeProps\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type NullToObject<T> = T extends null | undefined ? {} : T;\n\n/**\n * @internal\n * Internal helper mapper type for mergeProps\n */\n// eslint-disable-next-line no-undef, @typescript-eslint/no-unused-vars\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => void\n ? I\n : never;\n\n/**\n * @internal\n *\n * Merges multiple props objects together. Event handlers are chained,\n * classNames are combined, and ids are deduplicated - different ids\n * will trigger a side-effect and re-render components hooked up with `useId`.\n * For all other props, the last prop object overrides all previous ones.\n * @param args - Multiple sets of props to merge together.\n */\nexport function mergeProps<\n T extends (\n | {\n [key: string]: any;\n }\n | null\n | undefined\n )[],\n>(...args: T): UnionToIntersection<TupleTypes<T>> {\n // Start with a base clone of the first argument. This is a lot faster than starting\n // with an empty object and adding properties as we go.\n const result = { ...args[0] };\n for (let i = 1; i < args.length; i++) {\n const props = args[i];\n for (const key in props) {\n const a = result[key];\n const b = props[key];\n\n // Chain events\n if (\n typeof a === 'function' &&\n typeof b === 'function' &&\n // This is a lot faster than a regex.\n key[0] === 'o' &&\n key[1] === 'n' &&\n key.charCodeAt(2) >= /* 'A' */ 65 &&\n key.charCodeAt(2) <= /* 'Z' */ 90\n ) {\n result[key] = chain(a, b);\n } else {\n result[key] = b !== undefined ? b : a;\n }\n }\n }\n\n return result as UnionToIntersection<TupleTypes<T>>;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAASA,KAASC,EAA4C,CAC5D,MAAO,IAAIC,IAAgB,CACzB,UAAWC,KAAYF,EACjB,OAAOE,GAAa,YACtBA,EAAS,GAAGD,CAAI,CAGtB,CACF,CAwCO,SAASE,KAQXF,EAA6C,CAGhD,MAAMG,EAAS,CAAE,GAAGH,EAAK,CAAC,CAAE,EAC5B,QAASI,EAAI,EAAGA,EAAIJ,EAAK,OAAQI,IAAK,CACpC,MAAMC,EAAQL,EAAKI,CAAC,EACpB,UAAWE,KAAOD,EAAO,CACvB,MAAME,EAAIJ,EAAOG,CAAG,EACdE,EAAIH,EAAMC,CAAG,EAIjB,OAAOC,GAAM,YACb,OAAOC,GAAM,YAEbF,EAAI,CAAC,IAAM,KACXA,EAAI,CAAC,IAAM,KACXA,EAAI,WAAW,CAAC,GAAe,IAC/BA,EAAI,WAAW,CAAC,GAAe,GAE/BH,EAAOG,CAAG,EAAIR,EAAMS,EAAGC,CAAC,EAExBL,EAAOG,CAAG,EAAIE,IAAM,OAAYA,EAAID,CAExC,CACF,CAEA,OAAOJ,CACT",
|
|
6
|
+
"names": ["chain", "callbacks", "args", "callback", "mergeProps", "result", "i", "props", "key", "a", "b"]
|
|
7
|
+
}
|
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core/index.js';
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./core/index.js"),module.exports);
|
package/lang/en.json
ADDED
package/lang/ja.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/migrations.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynatrace/strato-components",
|
|
3
|
+
"version": "0.84.12",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"lang": "lang/uncompiled",
|
|
7
|
+
"supportedLocales": [
|
|
8
|
+
"en",
|
|
9
|
+
"ja"
|
|
10
|
+
],
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"main": "./index.js",
|
|
13
|
+
"module": "./esm/index.js",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"require": "./index.js",
|
|
18
|
+
"browser": "./esm/index.js",
|
|
19
|
+
"module": "./esm/index.js",
|
|
20
|
+
"import": "./esm/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./core": {
|
|
23
|
+
"types": "./core/index.d.ts",
|
|
24
|
+
"require": "./core/index.js",
|
|
25
|
+
"browser": "./esm/core/index.js",
|
|
26
|
+
"module": "./esm/core/index.js",
|
|
27
|
+
"import": "./esm/core/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./testing": {
|
|
30
|
+
"types": "./testing/index.d.ts",
|
|
31
|
+
"require": "./testing/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./testing/jest": {
|
|
34
|
+
"types": "./testing/jest/index.d.ts",
|
|
35
|
+
"require": "./testing/jest/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@dynatrace/devkit": "^0.3.2",
|
|
40
|
+
"@formatjs/icu-messageformat-parser": "^2.0.18",
|
|
41
|
+
"@jest/globals": "^29.7.0",
|
|
42
|
+
"clsx": "^2.1.0",
|
|
43
|
+
"lodash-es": "^4.17.21",
|
|
44
|
+
"wicg-inert": "^3.1.2",
|
|
45
|
+
"@dynatrace/strato-design-tokens": "0.20.10",
|
|
46
|
+
"@dynatrace/strato-icons": "0.37.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@dynatrace-sdk/app-environment": ">= 1.0.0 < 2",
|
|
50
|
+
"@dynatrace-sdk/error-handlers": ">= 1.0.0 < 2",
|
|
51
|
+
"@dynatrace-sdk/navigation": ">= 1.0.0 < 2",
|
|
52
|
+
"@dynatrace-sdk/user-preferences": ">= 1.1.0 < 2",
|
|
53
|
+
"@testing-library/react": "^12.0.0 || ^14.0.0",
|
|
54
|
+
"@testing-library/user-event": ">= 13.1.8",
|
|
55
|
+
"react": "^17.0.2 || ^18.0.0",
|
|
56
|
+
"react-dom": "^17.0.2 || ^18.0.0",
|
|
57
|
+
"react-intl": "^6.0.8",
|
|
58
|
+
"react-is": "^17.0.2 || ^18.0.0"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"@testing-library/react": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"@testing-library/user-event": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"sideEffects": [
|
|
69
|
+
"./core/components/app-root/AppRoot.css",
|
|
70
|
+
"./esm/core/components/app-root/AppRoot.css",
|
|
71
|
+
"./core/components/app-root/AppRoot.sty.js",
|
|
72
|
+
"./esm/core/components/app-root/AppRoot.sty.js"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RenderOptions, RenderResult } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type RenderWithIntlOptions = {
|
|
4
|
+
locale?: string;
|
|
5
|
+
timeZone?: string;
|
|
6
|
+
} & Omit<RenderOptions, 'queries'>;
|
|
7
|
+
/** Wrapper to render components with all required providers */
|
|
8
|
+
export declare const customRender: (ui: React.ReactElement, { locale, timeZone, wrapper: CustomWrapper, ...renderOptions }?: RenderWithIntlOptions) => RenderResult;
|
|
9
|
+
export * from '@testing-library/react';
|
|
10
|
+
export { customRender as render };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.create;var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var v=(r,e)=>{for(var n in e)s(r,n,{get:e[n],enumerable:!0})},l=(r,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of R(e))!f.call(r,t)&&t!==n&&s(r,t,{get:()=>e[t],enumerable:!(i=c(e,t))||i.enumerable});return r},d=(r,e,n)=>(l(r,e,"default"),n&&l(n,e,"default")),C=(r,e,n)=>(n=r!=null?h(W(r)):{},l(e||!r||!r.__esModule?s(n,"default",{value:r,enumerable:!0}):n,r)),O=r=>l(s({},"__esModule",{value:!0}),r);var p={};v(p,{customRender:()=>a,render:()=>a});module.exports=O(p);var m=require("@testing-library/react"),o=C(require("react")),P=require("react-intl");d(p,require("@testing-library/react"),module.exports);const g=({children:r,locale:e="en",timeZone:n="UTC"})=>o.default.createElement(P.IntlProvider,{locale:e,timeZone:n},r),A=r=>o.default.createElement(o.default.Fragment,null,r.children),a=(r,{locale:e="en",timeZone:n="UTC",wrapper:i=A,...t}={})=>(0,m.render)(r,{wrapper:({children:u})=>o.default.createElement(g,{locale:e,timeZone:n},o.default.createElement(i,null,u)),...t});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import userEvent, { PointerEventsCheckLevel } from '@testing-library/user-event';
|
|
2
|
+
export * from './custom-render.js';
|
|
3
|
+
export { setupGetBoundingClientRectMock, clearGetBoundingClientRectMock, } from './mocks/bounding-client-rect-mock.js';
|
|
4
|
+
export { createMockElement } from './mocks/create-mock-element.js';
|
|
5
|
+
export { setupCanvasMeasureTextMock, clearCanvasMeasureTextMock, } from './mocks/canvas-mock.js';
|
|
6
|
+
export { setupResizeObserverMock, clearResizeObserverMock, } from './mocks/resize-observer-mock.js';
|
|
7
|
+
export { _setupSelectMocks } from './mocks/select-mock.js';
|
|
8
|
+
export { setupOffsetWidthMock, clearOffsetWidthMock, } from './mocks/offset-width-mock.js';
|
|
9
|
+
export { setupOffsetHeightMock, clearOffsetHeightMock, } from './mocks/offset-height-mock.js';
|
|
10
|
+
export { setupDomRectMock, clearDomRectMock } from './mocks/dom-rect-mock.js';
|
|
11
|
+
export { setupMatchMediaMock, clearMatchMediaMock, } from './mocks/match-media-mock.js';
|
|
12
|
+
export { setupPointerEventMock, clearPointerEventMock, } from './mocks/pointer-event-mock.js';
|
|
13
|
+
export { setupIntersectionObserverMock, clearIntersectionObserverMock, } from './mocks/intersection-observer-mock.js';
|
|
14
|
+
export { setupCreateRangeMock, clearCreateRangeMock, } from './mocks/create-range-mock.js';
|
|
15
|
+
export { setupScreenSizeMock, clearScreenSizeMock, } from './mocks/screen-size-mock.js';
|
|
16
|
+
export { setupScrollIntoViewMock, clearScrollIntoViewMock, } from './mocks/scroll-into-view-mock.js';
|
|
17
|
+
export { setupScrollWidthMock, clearScrollWidthMock, } from './mocks/scroll-width-mock.js';
|
|
18
|
+
export { setupFetchMock, clearFetchMock } from './mocks/fetch-mock.js';
|
|
19
|
+
export { setupTableVirtualizationMock, clearTableVirtualizationMock, } from './mocks/table-virtualization-mock.js';
|
|
20
|
+
export { setupTextEllipsisMock, clearTextEllipsisMock, } from './mocks/text-ellipsis-mock.js';
|
|
21
|
+
export { setup, clear } from './setup.js';
|
|
22
|
+
export { userEvent, PointerEventsCheckLevel };
|
package/testing/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var I=Object.create;var s=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var B=(e,o)=>{for(var t in o)s(e,t,{get:o[t],enumerable:!0})},p=(e,o,t,g)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of W(o))!w.call(e,c)&&c!==t&&s(e,c,{get:()=>o[c],enumerable:!(g=V(o,c))||g.enumerable});return e},b=(e,o,t)=>(p(e,o,"default"),t&&p(t,o,"default")),D=(e,o,t)=>(t=e!=null?I(P(e)):{},p(o||!e||!e.__esModule?s(t,"default",{value:e,enumerable:!0}):t,e)),F=e=>p(s({},"__esModule",{value:!0}),e);var M={};B(M,{PointerEventsCheckLevel:()=>r.PointerEventsCheckLevel,_setupSelectMocks:()=>T._setupSelectMocks,clear:()=>E.clear,clearCanvasMeasureTextMock:()=>l.clearCanvasMeasureTextMock,clearCreateRangeMock:()=>h.clearCreateRangeMock,clearDomRectMock:()=>n.clearDomRectMock,clearFetchMock:()=>O.clearFetchMock,clearGetBoundingClientRectMock:()=>a.clearGetBoundingClientRectMock,clearIntersectionObserverMock:()=>x.clearIntersectionObserverMock,clearMatchMediaMock:()=>m.clearMatchMediaMock,clearOffsetHeightMock:()=>f.clearOffsetHeightMock,clearOffsetWidthMock:()=>i.clearOffsetWidthMock,clearPointerEventMock:()=>u.clearPointerEventMock,clearResizeObserverMock:()=>k.clearResizeObserverMock,clearScreenSizeMock:()=>v.clearScreenSizeMock,clearScrollIntoViewMock:()=>S.clearScrollIntoViewMock,clearScrollWidthMock:()=>d.clearScrollWidthMock,clearTableVirtualizationMock:()=>R.clearTableVirtualizationMock,clearTextEllipsisMock:()=>C.clearTextEllipsisMock,createMockElement:()=>z.createMockElement,setup:()=>E.setup,setupCanvasMeasureTextMock:()=>l.setupCanvasMeasureTextMock,setupCreateRangeMock:()=>h.setupCreateRangeMock,setupDomRectMock:()=>n.setupDomRectMock,setupFetchMock:()=>O.setupFetchMock,setupGetBoundingClientRectMock:()=>a.setupGetBoundingClientRectMock,setupIntersectionObserverMock:()=>x.setupIntersectionObserverMock,setupMatchMediaMock:()=>m.setupMatchMediaMock,setupOffsetHeightMock:()=>f.setupOffsetHeightMock,setupOffsetWidthMock:()=>i.setupOffsetWidthMock,setupPointerEventMock:()=>u.setupPointerEventMock,setupResizeObserverMock:()=>k.setupResizeObserverMock,setupScreenSizeMock:()=>v.setupScreenSizeMock,setupScrollIntoViewMock:()=>S.setupScrollIntoViewMock,setupScrollWidthMock:()=>d.setupScrollWidthMock,setupTableVirtualizationMock:()=>R.setupTableVirtualizationMock,setupTextEllipsisMock:()=>C.setupTextEllipsisMock,userEvent:()=>r.default});module.exports=F(M);var r=D(require("@testing-library/user-event"));b(M,require("./custom-render.js"),module.exports);var a=require("./mocks/bounding-client-rect-mock.js"),z=require("./mocks/create-mock-element.js"),l=require("./mocks/canvas-mock.js"),k=require("./mocks/resize-observer-mock.js"),T=require("./mocks/select-mock.js"),i=require("./mocks/offset-width-mock.js"),f=require("./mocks/offset-height-mock.js"),n=require("./mocks/dom-rect-mock.js"),m=require("./mocks/match-media-mock.js"),u=require("./mocks/pointer-event-mock.js"),x=require("./mocks/intersection-observer-mock.js"),h=require("./mocks/create-range-mock.js"),v=require("./mocks/screen-size-mock.js"),S=require("./mocks/scroll-into-view-mock.js"),d=require("./mocks/scroll-width-mock.js"),O=require("./mocks/fetch-mock.js"),R=require("./mocks/table-virtualization-mock.js"),C=require("./mocks/text-ellipsis-mock.js"),E=require("./setup.js");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { stratoPreset } from './jest-preset.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stratoPreset = void 0;
|
|
4
|
+
var jest_preset_js_1 = require("./jest-preset.js");
|
|
5
|
+
Object.defineProperty(exports, "stratoPreset", { enumerable: true, get: function () { return jest_preset_js_1.stratoPreset; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stratoPreset = void 0;
|
|
4
|
+
exports.stratoPreset = {
|
|
5
|
+
moduleNameMapper: {
|
|
6
|
+
nanoid: '<rootDir>/node_modules/nanoid/index.cjs',
|
|
7
|
+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
8
|
+
},
|
|
9
|
+
resolver: '<rootDir>/node_modules/@dynatrace/strato-components/testing/jest/resolver.js',
|
|
10
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = (path, options) => {
|
|
2
|
+
// Call the defaultResolver, so we leverage its cache, error handling, etc.
|
|
3
|
+
return options.defaultResolver(path, {
|
|
4
|
+
...options,
|
|
5
|
+
// Use packageFilter to process parsed `package.json` before the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb)
|
|
6
|
+
packageFilter: (pkg) => {
|
|
7
|
+
// This is a workaround for https://github.com/uuidjs/uuid/pull/616
|
|
8
|
+
//
|
|
9
|
+
// jest-environment-jsdom 28+ tries to use browser exports instead of default exports,
|
|
10
|
+
// but uuid only offers an ESM browser export and not a CommonJS one. Jest does not yet
|
|
11
|
+
// support ESM modules natively, so this causes a Jest error related to trying to parse
|
|
12
|
+
// "export" syntax.
|
|
13
|
+
//
|
|
14
|
+
// This workaround prevents Jest from considering uuid's module-based exports at all;
|
|
15
|
+
// it falls back to uuid's CommonJS+node "main" property.
|
|
16
|
+
//
|
|
17
|
+
// Once we're able to migrate our Jest config to ESM and a browser crypto
|
|
18
|
+
// implementation is available for the browser+ESM version of uuid to use (eg, via
|
|
19
|
+
// https://github.com/jsdom/jsdom/pull/3352 or a similar polyfill), this can go away.
|
|
20
|
+
if (pkg.name === 'uuid') {
|
|
21
|
+
delete pkg['exports'];
|
|
22
|
+
delete pkg['module'];
|
|
23
|
+
}
|
|
24
|
+
return pkg;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Mocks the `getBoundingClientRect()` function on all HTMLElements. */
|
|
2
|
+
export declare function setupGetBoundingClientRectMock(widthOrMockFn: number | (() => DOMRect | null), height?: number, x?: number, y?: number, top?: number, right?: number, bottom?: number, left?: number): void;
|
|
3
|
+
/** Clears mocked `getBoundingClientRect()` function on HTMLElements. */
|
|
4
|
+
export declare function clearGetBoundingClientRectMock(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},C=(e,t,o,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b(t))!g.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(u=p(t,n))||u.enumerable});return e};var B=e=>C(i({},"__esModule",{value:!0}),e);var s={};R(s,{clearGetBoundingClientRectMock:()=>a,setupGetBoundingClientRectMock:()=>f});module.exports=B(s);var r=require("./dom-rect-mock.js");const d=Element.prototype.getBoundingClientRect;function f(e,t,o,u,n,c,l,m){Object.defineProperty(Element.prototype,"getBoundingClientRect",{writable:!0,value:typeof e=="number"?()=>(0,r.createDOMRect)(e,t,o,u,n,c,l,m):function(){return e.call(this)??r.FALLBACK_DOM_RECT}})}function a(){Element.prototype.getBoundingClientRect=d}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mocks the `getContext()` function of HTMLCanvasElements so it returns an
|
|
3
|
+
* object with an implementation of `measureText()`. If no `mockTextWidth` is
|
|
4
|
+
* set, it will fall back to a default implementation that attempts to calculate
|
|
5
|
+
* a reasonable value for each given string.
|
|
6
|
+
*
|
|
7
|
+
* @param mockTextWidth - The value returned by the `measureText()` mock for all strings
|
|
8
|
+
*/
|
|
9
|
+
export declare function setupCanvasMeasureTextMock(mockTextWidth?: number): void;
|
|
10
|
+
/** Clears mocked `getContext()` function on HTMLCanvasElements. */
|
|
11
|
+
export declare function clearCanvasMeasureTextMock(): void;
|