@chayns-components/core 5.6.4 → 5.6.6
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/lib/cjs/components/accordion/Accordion.js +16 -1
- package/lib/cjs/components/accordion/Accordion.js.map +1 -1
- package/lib/cjs/components/accordion/Accordion.test.js +213 -0
- package/lib/cjs/components/accordion/Accordion.test.js.map +1 -0
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +47 -29
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
- package/lib/esm/components/accordion/Accordion.js +16 -1
- package/lib/esm/components/accordion/Accordion.js.map +1 -1
- package/lib/esm/components/accordion/Accordion.test.js +209 -0
- package/lib/esm/components/accordion/Accordion.test.js.map +1 -0
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +49 -31
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharingContextMenu.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_sharingBar","_environment","_sharingBar2","_ContextMenu","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","SharingContextMenu","forwardRef","link","text","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","useIsTouch","shareInApp","useCallback","provider","shareText","Error","invokeCall","action","value","sharingApp","providerId","androidIdentifier","sharingAndroidApp","handleImageDownload","shareWithUrl","SHAREPROVIDER","url","replace","encodeURIComponent","getSite","color","handleShare","key","trim","isApp","shareWithApp","copyToClipboard","contextMenuItems","icons","onClick","createElement","items","displayName","_default","exports"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.tsx"],"sourcesContent":["import { getSite, invokeCall, isApp } from 'chayns-api';\nimport React, { forwardRef, useCallback } from 'react';\nimport { SHAREPROVIDER } from '../../constants/sharingBar';\nimport type { SharingBarProvider } from '../../types/sharingBar';\nimport { useIsTouch } from '../../utils/environment';\nimport { copyToClipboard, shareWithApp, shareWithUrl } from '../../utils/sharingBar';\nimport ContextMenu from '../context-menu/ContextMenu';\nimport { ContextMenuProps, ContextMenuRef } from '../context-menu/ContextMenu.types';\n\nexport type SharingContextMenuProps = {\n /**\n * The link that should be shared.\n */\n link: string;\n /**\n * Optional text that is shared together with the link via WhatsApp, mail, and X.\n */\n text?: string;\n /**\n * Shows the action that copies the shared link to the clipboard.\n */\n shouldShowCopyAction?: boolean;\n /**\n * Shows the action that downloads a calling-code image.\n */\n shouldShowCallingCodeAction?: boolean;\n /**\n * Enables keyboard-only focus highlighting for the context menu trigger.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n} & Omit<ContextMenuProps, 'items' | 'shouldEnableKeyboardHighlighting'>;\n\nconst SharingContextMenu = forwardRef<ContextMenuRef, SharingContextMenuProps>(\n (\n {\n link,\n text,\n children,\n shouldEnableKeyboardHighlighting,\n shouldShowCallingCodeAction = true,\n shouldShowCopyAction = true,\n ...contextMenuProps\n },\n ref,\n ) => {\n const isTouch = useIsTouch();\n\n const shareInApp = useCallback(\n (provider: SharingBarProvider | undefined, shareText: string) => {\n if (!provider) {\n throw new Error('The requested sharing provider is not configured.');\n }\n\n void invokeCall({\n action: 80,\n value: {\n text: shareText,\n sharingApp: provider.providerId,\n ...(provider.androidIdentifier\n ? { sharingAndroidApp: provider.androidIdentifier }\n : {}),\n },\n });\n },\n [],\n );\n\n const handleImageDownload = useCallback(() => {\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[5].url\n .replace('{url}', encodeURIComponent(link))\n .replace('{linkText}', 'Teilen')\n .replace('{color}', getSite().color.replace('#', '')),\n );\n }, [link]);\n\n const handleShare = useCallback(\n (key: string) => {\n switch (key) {\n case 'whatsapp': {\n const shareText = text ? `${text}\\n\\n${link}` : `${link}`.trim();\n if (isApp()) {\n shareInApp(SHAREPROVIDER[0], shareText);\n break;\n }\n\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(shareText)),\n );\n break;\n }\n case 'facebook':\n if (isApp()) {\n shareInApp(SHAREPROVIDER[3], `${link}`.trim());\n break;\n }\n\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)),\n );\n break;\n case 'twitter':\n if (isApp()) {\n shareInApp(\n SHAREPROVIDER[4],\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n );\n break;\n }\n\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[4].url\n .replace('{url}', encodeURIComponent(link))\n .replace('{linkText}', encodeURIComponent(text ?? '')),\n );\n break;\n case 'mail':\n if (isApp()) {\n shareInApp(\n SHAREPROVIDER[2],\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n );\n } else if (isTouch) {\n shareWithApp(text ? `${text}\\n\\n${link}` : `${link}`.trim());\n } else {\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[2].url.replace(\n '{url}',\n encodeURIComponent(\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n ),\n ),\n );\n }\n break;\n case 'copy':\n copyToClipboard(link);\n break;\n default:\n break;\n }\n },\n [link, text, isTouch, shareInApp],\n );\n\n const contextMenuItems = [\n ...(shouldShowCopyAction\n ? [\n {\n icons: ['fa fa-copy'],\n key: 'copy',\n onClick: () => handleShare('copy'),\n text: 'Zwischenablage',\n },\n ]\n : []),\n {\n icons: ['fa-solid fa-brands fa-whatsapp'],\n key: 'whatsapp',\n onClick: () => handleShare('whatsapp'),\n text: 'Whatsapp',\n },\n {\n icons: ['fa-solid fa-brands fa-facebook-f'],\n key: 'facebook',\n onClick: () => handleShare('facebook'),\n text: 'Facebook',\n },\n {\n icons: ['fa-solid fa-brands fa-x-twitter'],\n key: 'twitter',\n onClick: () => handleShare('twitter'),\n text: 'X',\n },\n {\n icons: ['fa fa-envelope'],\n key: 'mail',\n onClick: () => handleShare('mail'),\n text: 'Mail',\n },\n ...(shouldShowCallingCodeAction\n ? [\n {\n icons: ['fa fa-qrcode'],\n key: 'callingCode',\n onClick: handleImageDownload,\n text: 'Calling Code herunterladen',\n },\n ]\n : []),\n ];\n\n return (\n <ContextMenu\n items={contextMenuItems}\n ref={ref}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n );\n },\n);\n\nSharingContextMenu.displayName = 'SharingContextMenu';\n\nexport default SharingContextMenu;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAsD,SAAAO,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAM,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,E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EAAEA,CAAA,KAAMR,WAAW,CAAC,SAAS,CAAC;IACrC7B,IAAI,EAAE;EACV,CAAC,EACD;IACIoC,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzBN,GAAG,EAAE,MAAM;IACXO,OAAO,EAAEA,CAAA,KAAMR,WAAW,CAAC,MAAM,CAAC;IAClC7B,IAAI,EAAE;EACV,CAAC,EACD,IAAIG,2BAA2B,GACzB,CACI;IACIiC,KAAK,EAAE,CAAC,cAAc,CAAC;IACvBN,GAAG,EAAE,aAAa;IAClBO,OAAO,EAAEhB,mBAAmB;IAC5BrB,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,CACZ;EAED,oBACInC,MAAA,CAAAS,OAAA,CAAAgE,aAAA,CAACpE,YAAA,CAAAI,OAAW,EAAAiB,QAAA;IACRgD,KAAK,EAAEJ,gBAAiB;IACxB7B,GAAG,EAAEA,GAAI;IACTJ,gCAAgC,EAAEA;IAClC;EAAA,GACIG,gBAAgB,GAEnBJ,QACQ,CAAC;AAEtB,CACJ,CAAC;AAEDJ,kBAAkB,CAAC2C,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApE,OAAA,GAEvCuB,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SharingContextMenu.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_sharingBar","_environment","_sharingBar2","_ContextMenu","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","SharingContextMenu","forwardRef","link","text","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","useIsTouch","app","os","useDevice","shouldUseAppCall","useMemo","name","AppName","CityApp","appVersion","shareInApp","useCallback","provider","shareText","callback","Error","invokeCall","action","value","sharingApp","providerId","androidIdentifier","sharingAndroidApp","retVal","status","handleImageDownload","shareWithUrl","SHAREPROVIDER","url","replace","encodeURIComponent","getSite","color","handleShare","key","trim","shareWithApp","copyToClipboard","contextMenuItems","icons","onClick","createElement","items","displayName","_default","exports"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.tsx"],"sourcesContent":["import { AppName, getSite, invokeCall, useDevice } from 'chayns-api';\nimport React, { forwardRef, useCallback, useMemo } from 'react';\nimport { SHAREPROVIDER } from '../../constants/sharingBar';\nimport type { SharingBarProvider } from '../../types/sharingBar';\nimport { useIsTouch } from '../../utils/environment';\nimport { copyToClipboard, shareWithApp, shareWithUrl } from '../../utils/sharingBar';\nimport ContextMenu from '../context-menu/ContextMenu';\nimport { ContextMenuProps, ContextMenuRef } from '../context-menu/ContextMenu.types';\n\nexport type SharingContextMenuProps = {\n /**\n * The link that should be shared.\n */\n link: string;\n /**\n * Optional text that is shared together with the link via WhatsApp, mail, and X.\n */\n text?: string;\n /**\n * Shows the action that copies the shared link to the clipboard.\n */\n shouldShowCopyAction?: boolean;\n /**\n * Shows the action that downloads a calling-code image.\n */\n shouldShowCallingCodeAction?: boolean;\n /**\n * Enables keyboard-only focus highlighting for the context menu trigger.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n} & Omit<ContextMenuProps, 'items' | 'shouldEnableKeyboardHighlighting'>;\n\nconst SharingContextMenu = forwardRef<ContextMenuRef, SharingContextMenuProps>(\n (\n {\n link,\n text,\n children,\n shouldEnableKeyboardHighlighting,\n shouldShowCallingCodeAction = true,\n shouldShowCopyAction = true,\n ...contextMenuProps\n },\n ref,\n ) => {\n const isTouch = useIsTouch();\n const { app, os } = useDevice();\n\n const shouldUseAppCall = useMemo(\n () =>\n app &&\n app.name === AppName.CityApp &&\n ((os === 'iOS' && app.appVersion >= 3313) ||\n (os === 'Android OS' && app.appVersion >= 7472)),\n [app, os],\n );\n\n const shareInApp = useCallback(\n (\n provider: SharingBarProvider | undefined,\n shareText: string,\n callback: VoidFunction,\n ) => {\n if (!provider) {\n throw new Error('The requested sharing provider is not configured.');\n }\n\n void invokeCall({\n action: 80,\n value: {\n text: shareText,\n sharingApp: provider.providerId,\n ...(provider.androidIdentifier\n ? { sharingAndroidApp: provider.androidIdentifier }\n : {}),\n callback: (retVal: { status: 0 | -1 | -2 }) => {\n if (retVal.status !== 0) {\n callback();\n }\n },\n },\n });\n },\n [],\n );\n\n const handleImageDownload = useCallback(() => {\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[5].url\n .replace('{url}', encodeURIComponent(link))\n .replace('{linkText}', 'Teilen')\n .replace('{color}', getSite().color.replace('#', '')),\n );\n }, [link]);\n\n const handleShare = useCallback(\n (key: string) => {\n switch (key) {\n case 'whatsapp': {\n const shareText = text ? `${text}\\n\\n${link}` : `${link}`.trim();\n const callback = () =>\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[0].url.replace(\n '{url}',\n encodeURIComponent(shareText),\n ),\n );\n\n if (shouldUseAppCall) {\n shareInApp(SHAREPROVIDER[0], shareText, callback);\n break;\n }\n\n callback();\n break;\n }\n case 'facebook': {\n const callback = () =>\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)),\n );\n\n if (shouldUseAppCall) {\n shareInApp(SHAREPROVIDER[3], `${link}`.trim(), callback);\n break;\n }\n\n callback();\n break;\n }\n case 'twitter': {\n const callback = () =>\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[4].url\n .replace('{url}', encodeURIComponent(link))\n .replace('{linkText}', encodeURIComponent(text ?? '')),\n );\n\n if (shouldUseAppCall) {\n shareInApp(\n SHAREPROVIDER[4],\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n callback,\n );\n break;\n }\n\n callback();\n break;\n }\n case 'mail': {\n const callback = () =>\n isTouch\n ? shareWithApp(text ? `${text}\\n\\n${link}` : `${link}`.trim())\n : shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[2].url.replace(\n '{url}',\n encodeURIComponent(\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n ),\n ),\n );\n\n if (shouldUseAppCall) {\n shareInApp(\n SHAREPROVIDER[2],\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n callback,\n );\n break;\n }\n\n callback();\n break;\n }\n case 'copy':\n copyToClipboard(link);\n break;\n default:\n break;\n }\n },\n [link, text, shouldUseAppCall, shareInApp, isTouch],\n );\n\n const contextMenuItems = [\n ...(shouldShowCopyAction\n ? [\n {\n icons: ['fa fa-copy'],\n key: 'copy',\n onClick: () => handleShare('copy'),\n text: 'Zwischenablage',\n },\n ]\n : []),\n {\n icons: ['fa-solid fa-brands fa-whatsapp'],\n key: 'whatsapp',\n onClick: () => handleShare('whatsapp'),\n text: 'Whatsapp',\n },\n {\n icons: ['fa-solid fa-brands fa-facebook-f'],\n key: 'facebook',\n onClick: () => handleShare('facebook'),\n text: 'Facebook',\n },\n {\n icons: ['fa-solid fa-brands fa-x-twitter'],\n key: 'twitter',\n onClick: () => handleShare('twitter'),\n text: 'X',\n },\n {\n icons: ['fa fa-envelope'],\n key: 'mail',\n onClick: () => handleShare('mail'),\n text: 'Mail',\n },\n ...(shouldShowCallingCodeAction\n ? [\n {\n icons: ['fa fa-qrcode'],\n key: 'callingCode',\n onClick: handleImageDownload,\n text: 'Calling Code herunterladen',\n },\n ]\n : []),\n ];\n\n return (\n <ContextMenu\n items={contextMenuItems}\n ref={ref}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n );\n },\n);\n\nSharingContextMenu.displayName = 'SharingContextMenu';\n\nexport default SharingContextMenu;\n"],"mappings":";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AAA,KAAMP,WAAW,CAAC,UAAU,CAAC;IACtCzC,IAAI,EAAE;EACV,CAAC,EACD;IACI+C,KAAK,EAAE,CAAC,iCAAiC,CAAC;IAC1CL,GAAG,EAAE,SAAS;IACdM,OAAO,EAAEA,CAAA,KAAMP,WAAW,CAAC,SAAS,CAAC;IACrCzC,IAAI,EAAE;EACV,CAAC,EACD;IACI+C,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzBL,GAAG,EAAE,MAAM;IACXM,OAAO,EAAEA,CAAA,KAAMP,WAAW,CAAC,MAAM,CAAC;IAClCzC,IAAI,EAAE;EACV,CAAC,EACD,IAAIG,2BAA2B,GACzB,CACI;IACI4C,KAAK,EAAE,CAAC,cAAc,CAAC;IACvBL,GAAG,EAAE,aAAa;IAClBM,OAAO,EAAEf,mBAAmB;IAC5BjC,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,CACZ;EAED,oBACInC,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC/E,YAAA,CAAAI,OAAW,EAAAiB,QAAA;IACR2D,KAAK,EAAEJ,gBAAiB;IACxBxC,GAAG,EAAEA,GAAI;IACTJ,gCAAgC,EAAEA;IAClC;EAAA,GACIG,gBAAgB,GAEnBJ,QACQ,CAAC;AAEtB,CACJ,CAAC;AAEDJ,kBAAkB,CAACsD,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEvCuB,kBAAkB","ignoreList":[]}
|
|
@@ -56,6 +56,7 @@ const Accordion = ({
|
|
|
56
56
|
accordionGroupUuid,
|
|
57
57
|
accordionUuids,
|
|
58
58
|
updateOpenAccordionUuid,
|
|
59
|
+
setOpenAccordionUuid,
|
|
59
60
|
activeAccordionUuid,
|
|
60
61
|
updateActiveAccordionUuid,
|
|
61
62
|
registerAccordionUuid,
|
|
@@ -77,7 +78,7 @@ const Accordion = ({
|
|
|
77
78
|
const accordionRef = useRef(null);
|
|
78
79
|
const initialRenderSkipRef = useInitialRenderRef(true);
|
|
79
80
|
const shouldSkipAnimation = shouldSkipAnimationProp ?? (initialRenderSkipRef.current && isDefaultOpen);
|
|
80
|
-
const isInGroup =
|
|
81
|
+
const isInGroup = typeof updateOpenAccordionUuid === 'function';
|
|
81
82
|
const isOpen = (() => {
|
|
82
83
|
if (isInGroup) return openAccordionUuid === uuid;
|
|
83
84
|
if (isControlled) return isOpened;
|
|
@@ -162,6 +163,20 @@ const Accordion = ({
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
}, [isDefaultOpen, updateOpenAccordionUuid, uuid, onOpen, isControlled]);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (!isInGroup || !isControlled) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (isOpened) {
|
|
171
|
+
updateOpenAccordionUuid?.(uuid, {
|
|
172
|
+
shouldOnlyOpen: true
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
setOpenAccordionUuid?.(currentUuid => currentUuid === uuid ? undefined : currentUuid);
|
|
176
|
+
}
|
|
177
|
+
// Only prop changes should request a group transition. Reasserting an unchanged true
|
|
178
|
+
// value after a sibling opens would make the accordions compete for the group state.
|
|
179
|
+
}, [isControlled, isInGroup, isOpened, setOpenAccordionUuid, updateOpenAccordionUuid, uuid]);
|
|
165
180
|
const accordionContextProviderValue = useMemo(() => ({
|
|
166
181
|
isWrapped: isWrapped === true
|
|
167
182
|
}), [isWrapped]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","names":["AnimatePresence","MotionConfig","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useTheme","useUuid","useFocusRingPortal","useKeyboardFocusHighlighting","AreaContext","useColorScheme","AccordionBody","AccordionGroupContext","AccordionHead","AccordionWrappedContext","StyledMotionAccordion","useInitialRenderRef","AccordionContext","createContext","isWrapped","undefined","Accordion","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onHoverEnd","onHoverStart","onOpen","onSearchChange","rightElement","searchPlaceholder","searchValue","shouldForceBackground","shouldForceBottomLine","shouldHideBackground","shouldRenderClosed","shouldRotateIcon","shouldHideBottomLine","title","titleElement","onTitleInputChange","titleInputProps","shouldSkipAnimation","shouldSkipAnimationProp","colors","shouldIndex","onBodyAnimationComplete","shouldEnableKeyboardHighlighting","theme","groupIsWrapped","openAccordionUuid","accordionGroupUuid","accordionUuids","updateOpenAccordionUuid","activeAccordionUuid","updateActiveAccordionUuid","registerAccordionUuid","unregisterAccordionUuid","isParentWrapped","contextIsWrapped","colorScheme","shouldEnableKeyboardHighlightingEffective","isControlled","internalOpen","setInternalOpen","uuid","isInitialRenderRef","accordionRef","initialRenderSkipRef","current","isInGroup","isOpen","isOpenRef","onCloseRef","onOpenRef","shouldShowKeyboardHighlighting","isKeyboardFocusable","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","isLastAccordion","length","handleHeadClick","prev","shouldOnlyOpen","accordionContextProviderValue","areaContextProviderValue","shouldChangeColor","accordionWrappedContextProviderValue","initialAnimation","height","opacity","tabIndex","handleKeyDown","e","isCurrentAccordionTarget","currentTarget","target","key","preventDefault","currentIndex","indexOf","nextIndex","nextAccordionUuid","nextAccordionElement","document","querySelector","focus","parentAccordion","parentElement","closest","parentGroupId","getAttribute","split","handleFocus","handleBlur","nextFocusedElement","relatedTarget","currentGroupElement","contains","createElement","ref","animate","className","exit","initial","$isOpen","$shouldShowLines","$isParentWrapped","$isWrapped","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBackground","$shouldHideBottomLine","$bottomBorderColor","borderBottomColor","$shouldEnableKeyboardHighlighting","$shouldShowKeyboardHighlighting","onKeyDown","onFocus","onBlur","onMouseEnter","onMouseLeave","transition","duration","Provider","value","type","onClick","titleColor","maxHeight","onScroll","onAnimationComplete","shouldHideBody","displayName"],"sources":["../../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import { AnimatePresence, MotionConfig } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n type MouseEventHandler,\n ReactNode,\n UIEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../hooks/uuid';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputProps } from '../input/Input';\nimport AccordionBody from './accordion-body/AccordionBody';\nimport { AccordionGroupContext } from './accordion-group/AccordionGroup';\nimport AccordionHead from './accordion-head/AccordionHead';\nimport { AccordionWrappedContext } from './accordion-provider/AccordionContextProvider';\nimport { StyledMotionAccordion } from './Accordion.styles';\nimport { useInitialRenderRef } from '../../hooks/ref';\n\nexport const AccordionContext = React.createContext<{ isWrapped?: boolean }>({\n isWrapped: undefined,\n});\n\ntype AccordionColors = {\n titleColor?: CSSProperties['color'];\n borderBottomColor?: CSSProperties['borderBottomColor'];\n};\n\nexport type AccordionProps = {\n /**\n * Maximum height of the accordion body element. This automatically makes the content of the\n * body element scrollable.\n */\n bodyMaxHeight?: number;\n /**\n * The content of the accordion body\n */\n children: ReactNode;\n /**\n * The icon that is displayed in front of the title\n */\n icon?: string;\n /**\n * This can be used to automatically expand the Accordion during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This will disable the Accordion so that it cannot be opened and will gray out the title. Does not work with isOpened.\n */\n isDisabled?: boolean;\n /**\n * This can be used so that the Accordion cannot be opened or closed.\n * In addition, in this case the icon is exchanged to mark the Accordions.\n */\n isFixed?: boolean;\n /**\n * This can be used to open the Accordion from the outside\n */\n isOpened?: boolean;\n /**\n * This will gray out the title of the Accordion to indicate hidden content, for example.\n */\n isTitleGreyed?: boolean;\n /**\n * Function that is executed when the accordion body will be scrolled\n */\n onBodyScroll?: (event: UIEvent<HTMLDivElement>) => void;\n /**\n * Function that is executed when the accordion will be closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the accordion is no longer hovered.\n */\n onHoverEnd?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the accordion is hovered.\n */\n onHoverStart?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the accordion will be opened.\n */\n onOpen?: VoidFunction;\n /**\n * Function that is executed when the accordion body is animated\n */\n onBodyAnimationComplete?: VoidFunction;\n /**\n * Function that is executed when the text of the search in the accordion\n * head changes. When this function is given, the search field is displayed\n * in the Accordion Head.\n */\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the search in the accordion\n * title changes. When this function is given, the search field is displayed\n * as the Accordion title.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Content to be displayed on the right side in the head of the Accordion\n */\n rightElement?: ReactNode;\n /**\n * The placeholder to be used for the search\n */\n searchPlaceholder?: string;\n /**\n * The value that is displayed inside the search\n */\n searchValue?: string;\n /**\n * This will force the background color of the accordion to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * This will hide the background color of the accordion\n */\n shouldHideBackground?: boolean;\n /**\n * Whether the bottom line should always be shown, regardless of other line-related props.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * This will render the Accordion closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the icon should be rotating.\n */\n shouldRotateIcon?: boolean;\n /**\n * Whether the animation should be skipped.\n * If 'isDefaultOpen' is true the initial animation will be skipped even this prop is false\n */\n shouldSkipAnimation?: boolean;\n /**\n * Title of the Accordion displayed in the head\n */\n title?: string;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n /**\n * The props of the title Input.\n */\n titleInputProps?: InputProps;\n /**\n * Provide custom colors to the Accordion Component\n */\n colors?: AccordionColors;\n /**\n * Whether the accordion should be indexed.\n */\n shouldIndex?: boolean;\n /**\n * Enables keyboard-only focus highlighting. The highlighting is only visible while the\n * user navigates with the keyboard and is reset on mouse movement or click.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst Accordion: FC<AccordionProps> = ({\n bodyMaxHeight,\n children,\n icon,\n isDefaultOpen = false,\n isDisabled = false,\n isFixed = false,\n isOpened,\n isTitleGreyed = false,\n onBodyScroll,\n onClose,\n onHoverEnd,\n onHoverStart,\n onOpen,\n onSearchChange,\n rightElement,\n searchPlaceholder,\n searchValue,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldHideBackground = false,\n shouldRenderClosed = false,\n shouldRotateIcon = true,\n shouldHideBottomLine = false,\n title,\n titleElement,\n onTitleInputChange,\n titleInputProps,\n shouldSkipAnimation: shouldSkipAnimationProp = false,\n colors,\n shouldIndex = false,\n onBodyAnimationComplete,\n shouldEnableKeyboardHighlighting,\n}) => {\n const theme = useTheme() as Theme;\n const {\n isWrapped: groupIsWrapped,\n openAccordionUuid,\n accordionGroupUuid,\n accordionUuids,\n updateOpenAccordionUuid,\n activeAccordionUuid,\n updateActiveAccordionUuid,\n registerAccordionUuid,\n unregisterAccordionUuid,\n } = useContext(AccordionGroupContext);\n const { isWrapped: isParentWrapped } = useContext(AccordionContext);\n\n const { isWrapped: contextIsWrapped } = useContext(AccordionWrappedContext);\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const isWrapped = useMemo(\n () => groupIsWrapped ?? contextIsWrapped,\n [contextIsWrapped, groupIsWrapped],\n );\n\n const isControlled = typeof isOpened === 'boolean';\n const [internalOpen, setInternalOpen] = useState<boolean>(isDefaultOpen ?? false);\n\n const uuid = useUuid();\n\n const isInitialRenderRef = useRef(true);\n const accordionRef = useRef<HTMLDivElement>(null);\n\n const initialRenderSkipRef = useInitialRenderRef(true);\n\n const shouldSkipAnimation =\n shouldSkipAnimationProp ?? (initialRenderSkipRef.current && isDefaultOpen);\n\n const isInGroup = shouldSkipAnimation ? false : typeof updateOpenAccordionUuid === 'function';\n\n const isOpen = (() => {\n if (isInGroup) return openAccordionUuid === uuid;\n if (isControlled) return isOpened;\n return internalOpen;\n })();\n\n const isOpenRef = useRef(isOpen);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n const isKeyboardFocusable =\n !isDisabled && (shouldIndex || shouldEnableKeyboardHighlightingEffective);\n\n useFocusRingPortal(accordionRef, {\n isEnabled: shouldShowKeyboardHighlighting && isKeyboardFocusable,\n borderRadius: `${theme.cardBorderRadius ?? 0}px`,\n });\n\n const isInKeyboardNavigationGroup =\n isKeyboardFocusable &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string';\n\n useEffect(() => {\n if (\n typeof accordionGroupUuid === 'string' &&\n typeof registerAccordionUuid === 'function' &&\n typeof unregisterAccordionUuid === 'function'\n ) {\n registerAccordionUuid(uuid);\n\n return () => {\n unregisterAccordionUuid(uuid);\n };\n }\n\n return undefined;\n }, [accordionGroupUuid, registerAccordionUuid, unregisterAccordionUuid, uuid]);\n\n const isLastAccordion = useMemo(\n () => (accordionUuids ? accordionUuids[accordionUuids.length - 1] === uuid : false),\n [accordionUuids, uuid],\n );\n\n useEffect(() => {\n isOpenRef.current = isOpen;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n const handleHeadClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function') {\n updateActiveAccordionUuid(uuid);\n }\n\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n } else if (!isControlled) {\n setInternalOpen((prev: boolean) => !prev);\n }\n\n if (isOpen) {\n onClose?.();\n } else {\n onOpen?.();\n }\n }, [\n isDisabled,\n isKeyboardFocusable,\n updateActiveAccordionUuid,\n updateOpenAccordionUuid,\n uuid,\n isOpen,\n onClose,\n onOpen,\n isControlled,\n ]);\n\n useEffect(() => {\n if (isDisabled && isOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n } else if (typeof onClose === 'function') {\n onClose();\n } else {\n // Uncontrolled mode: use the internal state\n setInternalOpen(false);\n }\n }\n }, [isDisabled, isOpen, updateOpenAccordionUuid, uuid, onClose]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (!isControlled && isDefaultOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });\n } else if (typeof onOpen === 'function') {\n onOpen();\n } else {\n setInternalOpen(true);\n }\n }\n }, [isDefaultOpen, updateOpenAccordionUuid, uuid, onOpen, isControlled]);\n\n const accordionContextProviderValue = useMemo(\n () => ({ isWrapped: isWrapped === true }),\n [isWrapped],\n );\n\n const areaContextProviderValue = useMemo(\n () => ({ shouldChangeColor: !shouldHideBackground }),\n [shouldHideBackground],\n );\n\n const accordionWrappedContextProviderValue = useMemo(() => ({ isWrapped: true }), []);\n\n const initialAnimation = useMemo(() => {\n if (shouldSkipAnimation) {\n return { height: 'auto', opacity: 1 };\n }\n\n return isOpen ? { height: 'auto', opacity: 1 } : { height: 0, opacity: 0 };\n }, [isOpen, shouldSkipAnimation]);\n\n const tabIndex = useMemo(() => (isKeyboardFocusable ? 0 : -1), [isKeyboardFocusable]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentAccordionTarget = e.currentTarget === e.target;\n\n if (\n isCurrentAccordionTarget &&\n isInKeyboardNavigationGroup &&\n accordionUuids?.length &&\n (e.key === 'ArrowDown' || e.key === 'ArrowUp')\n ) {\n e.preventDefault();\n const currentIndex = accordionUuids.indexOf(uuid);\n\n if (currentIndex !== -1) {\n const nextIndex =\n e.key === 'ArrowDown'\n ? (currentIndex + 1) % accordionUuids.length\n : (currentIndex - 1 + accordionUuids.length) % accordionUuids.length;\n const nextAccordionUuid = accordionUuids[nextIndex];\n\n if (nextAccordionUuid && nextAccordionUuid !== uuid) {\n const nextAccordionElement = document.querySelector<HTMLDivElement>(\n `[data-uuid=\"${accordionGroupUuid}---${nextAccordionUuid}\"]`,\n );\n\n if (nextAccordionElement) {\n updateActiveAccordionUuid(nextAccordionUuid);\n nextAccordionElement.focus();\n return;\n }\n }\n }\n }\n\n if (\n isCurrentAccordionTarget &&\n (e.key === 'Enter' || e.key === ' ') &&\n isKeyboardFocusable\n ) {\n handleHeadClick();\n }\n\n if (\n isCurrentAccordionTarget &&\n e.key === 'ArrowRight' &&\n isKeyboardFocusable &&\n !isOpen\n ) {\n e.preventDefault();\n handleHeadClick();\n }\n\n if (isCurrentAccordionTarget && (e.key === 'Escape' || e.key === 'ArrowLeft')) {\n if (isOpen && isKeyboardFocusable) {\n e.preventDefault();\n handleHeadClick();\n return;\n }\n\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n e.preventDefault();\n updateActiveAccordionUuid(undefined);\n let parentAccordion =\n e.currentTarget.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n while (parentAccordion) {\n const parentGroupId = parentAccordion\n .getAttribute('data-uuid')\n ?.split('---')[0];\n if (parentGroupId !== accordionGroupUuid) {\n parentAccordion.focus();\n break;\n }\n parentAccordion =\n parentAccordion.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n }\n }\n }\n },\n [\n accordionGroupUuid,\n accordionUuids,\n handleHeadClick,\n isInKeyboardNavigationGroup,\n isKeyboardFocusable,\n isOpen,\n updateActiveAccordionUuid,\n uuid,\n ],\n );\n\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n e.currentTarget === e.target &&\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n updateActiveAccordionUuid(uuid);\n }\n },\n [isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string'\n ) {\n const nextFocusedElement = e.relatedTarget as Node | null;\n const currentGroupElement = e.currentTarget as HTMLElement;\n\n if (!nextFocusedElement || !currentGroupElement.contains(nextFocusedElement)) {\n updateActiveAccordionUuid(undefined);\n }\n }\n },\n [accordionGroupUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid],\n );\n\n useEffect(() => {\n if (\n activeAccordionUuid == null &&\n typeof updateActiveAccordionUuid === 'function' &&\n accordionUuids?.[0] === uuid\n ) {\n updateActiveAccordionUuid(uuid);\n }\n }, [\n accordionUuids,\n activeAccordionUuid,\n isInKeyboardNavigationGroup,\n updateActiveAccordionUuid,\n uuid,\n ]);\n\n return (\n <StyledMotionAccordion\n ref={accordionRef}\n animate={{ height: 'auto', opacity: 1 }}\n data-uuid={`${accordionGroupUuid ?? ''}---${uuid}`}\n className=\"beta-chayns-accordion\"\n exit={{ height: 0, opacity: 0 }}\n initial={initialAnimation}\n $isOpen={isOpen}\n tabIndex={tabIndex}\n $shouldShowLines={!isLastAccordion || !isWrapped}\n $isParentWrapped={isParentWrapped}\n $isWrapped={isWrapped}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBackground={shouldHideBackground}\n $shouldHideBottomLine={shouldHideBottomLine}\n $bottomBorderColor={colors?.borderBottomColor}\n $shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onMouseEnter={onHoverStart}\n onMouseLeave={onHoverEnd}\n transition={{ duration: shouldSkipAnimation ? 0 : 0.25 }}\n >\n <AccordionContext.Provider value={accordionContextProviderValue}>\n <MotionConfig transition={{ type: 'tween' }}>\n <AccordionHead\n uuid={uuid}\n icon={icon}\n isOpen={isOpen}\n shouldSkipAnimation={shouldSkipAnimation}\n isFixed={isFixed}\n isTitleGreyed={isTitleGreyed || isDisabled}\n isWrapped={isWrapped === true}\n onClick={handleHeadClick}\n onSearchChange={onSearchChange}\n rightElement={rightElement}\n searchPlaceholder={searchPlaceholder}\n searchValue={searchValue}\n shouldRotateIcon={shouldRotateIcon}\n title={title}\n titleElement={titleElement}\n onTitleInputChange={onTitleInputChange}\n titleInputProps={titleInputProps}\n titleColor={colors?.titleColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n />\n <AnimatePresence initial={false}>\n {(isOpen || shouldRenderClosed) && (\n <AccordionBody\n shouldSkipAnimation={shouldSkipAnimation}\n maxHeight={bodyMaxHeight}\n onScroll={onBodyScroll}\n onAnimationComplete={onBodyAnimationComplete}\n shouldHideBody={shouldRenderClosed && !isOpen}\n >\n <AccordionWrappedContext.Provider\n value={accordionWrappedContextProviderValue}\n >\n <AreaContext.Provider value={areaContextProviderValue}>\n {children}\n </AreaContext.Provider>\n </AccordionWrappedContext.Provider>\n </AccordionBody>\n )}\n </AnimatePresence>\n </MotionConfig>\n </AccordionContext.Provider>\n </StyledMotionAccordion>\n );\n};\n\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,cAAc;AAC5D,OAAOC,KAAK,IAORC,WAAW,E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,CACvB,CAEN,CACP,CACS,CACR,CAAC;AAEhC,CAAC;AAEDF,SAAS,CAAC6I,WAAW,GAAG,WAAW;AAEnC,eAAe7I,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":["AnimatePresence","MotionConfig","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useTheme","useUuid","useFocusRingPortal","useKeyboardFocusHighlighting","AreaContext","useColorScheme","AccordionBody","AccordionGroupContext","AccordionHead","AccordionWrappedContext","StyledMotionAccordion","useInitialRenderRef","AccordionContext","createContext","isWrapped","undefined","Accordion","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onHoverEnd","onHoverStart","onOpen","onSearchChange","rightElement","searchPlaceholder","searchValue","shouldForceBackground","shouldForceBottomLine","shouldHideBackground","shouldRenderClosed","shouldRotateIcon","shouldHideBottomLine","title","titleElement","onTitleInputChange","titleInputProps","shouldSkipAnimation","shouldSkipAnimationProp","colors","shouldIndex","onBodyAnimationComplete","shouldEnableKeyboardHighlighting","theme","groupIsWrapped","openAccordionUuid","accordionGroupUuid","accordionUuids","updateOpenAccordionUuid","setOpenAccordionUuid","activeAccordionUuid","updateActiveAccordionUuid","registerAccordionUuid","unregisterAccordionUuid","isParentWrapped","contextIsWrapped","colorScheme","shouldEnableKeyboardHighlightingEffective","isControlled","internalOpen","setInternalOpen","uuid","isInitialRenderRef","accordionRef","initialRenderSkipRef","current","isInGroup","isOpen","isOpenRef","onCloseRef","onOpenRef","shouldShowKeyboardHighlighting","isKeyboardFocusable","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","isLastAccordion","length","handleHeadClick","prev","shouldOnlyOpen","currentUuid","accordionContextProviderValue","areaContextProviderValue","shouldChangeColor","accordionWrappedContextProviderValue","initialAnimation","height","opacity","tabIndex","handleKeyDown","e","isCurrentAccordionTarget","currentTarget","target","key","preventDefault","currentIndex","indexOf","nextIndex","nextAccordionUuid","nextAccordionElement","document","querySelector","focus","parentAccordion","parentElement","closest","parentGroupId","getAttribute","split","handleFocus","handleBlur","nextFocusedElement","relatedTarget","currentGroupElement","contains","createElement","ref","animate","className","exit","initial","$isOpen","$shouldShowLines","$isParentWrapped","$isWrapped","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBackground","$shouldHideBottomLine","$bottomBorderColor","borderBottomColor","$shouldEnableKeyboardHighlighting","$shouldShowKeyboardHighlighting","onKeyDown","onFocus","onBlur","onMouseEnter","onMouseLeave","transition","duration","Provider","value","type","onClick","titleColor","maxHeight","onScroll","onAnimationComplete","shouldHideBody","displayName"],"sources":["../../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import { AnimatePresence, MotionConfig } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n type MouseEventHandler,\n ReactNode,\n UIEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../hooks/uuid';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputProps } from '../input/Input';\nimport AccordionBody from './accordion-body/AccordionBody';\nimport { AccordionGroupContext } from './accordion-group/AccordionGroup';\nimport AccordionHead from './accordion-head/AccordionHead';\nimport { AccordionWrappedContext } from './accordion-provider/AccordionContextProvider';\nimport { StyledMotionAccordion } from './Accordion.styles';\nimport { useInitialRenderRef } from '../../hooks/ref';\n\nexport const AccordionContext = React.createContext<{ isWrapped?: boolean }>({\n isWrapped: undefined,\n});\n\ntype AccordionColors = {\n titleColor?: CSSProperties['color'];\n borderBottomColor?: CSSProperties['borderBottomColor'];\n};\n\nexport type AccordionProps = {\n /**\n * Maximum height of the accordion body element. This automatically makes the content of the\n * body element scrollable.\n */\n bodyMaxHeight?: number;\n /**\n * The content of the accordion body\n */\n children: ReactNode;\n /**\n * The icon that is displayed in front of the title\n */\n icon?: string;\n /**\n * This can be used to automatically expand the Accordion during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This will disable the Accordion so that it cannot be opened and will gray out the title. Does not work with isOpened.\n */\n isDisabled?: boolean;\n /**\n * This can be used so that the Accordion cannot be opened or closed.\n * In addition, in this case the icon is exchanged to mark the Accordions.\n */\n isFixed?: boolean;\n /**\n * This can be used to open the Accordion from the outside\n */\n isOpened?: boolean;\n /**\n * This will gray out the title of the Accordion to indicate hidden content, for example.\n */\n isTitleGreyed?: boolean;\n /**\n * Function that is executed when the accordion body will be scrolled\n */\n onBodyScroll?: (event: UIEvent<HTMLDivElement>) => void;\n /**\n * Function that is executed when the accordion will be closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the accordion is no longer hovered.\n */\n onHoverEnd?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the accordion is hovered.\n */\n onHoverStart?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the accordion will be opened.\n */\n onOpen?: VoidFunction;\n /**\n * Function that is executed when the accordion body is animated\n */\n onBodyAnimationComplete?: VoidFunction;\n /**\n * Function that is executed when the text of the search in the accordion\n * head changes. When this function is given, the search field is displayed\n * in the Accordion Head.\n */\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the search in the accordion\n * title changes. When this function is given, the search field is displayed\n * as the Accordion title.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Content to be displayed on the right side in the head of the Accordion\n */\n rightElement?: ReactNode;\n /**\n * The placeholder to be used for the search\n */\n searchPlaceholder?: string;\n /**\n * The value that is displayed inside the search\n */\n searchValue?: string;\n /**\n * This will force the background color of the accordion to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * This will hide the background color of the accordion\n */\n shouldHideBackground?: boolean;\n /**\n * Whether the bottom line should always be shown, regardless of other line-related props.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * This will render the Accordion closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the icon should be rotating.\n */\n shouldRotateIcon?: boolean;\n /**\n * Whether the animation should be skipped.\n * If 'isDefaultOpen' is true the initial animation will be skipped even this prop is false\n */\n shouldSkipAnimation?: boolean;\n /**\n * Title of the Accordion displayed in the head\n */\n title?: string;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n /**\n * The props of the title Input.\n */\n titleInputProps?: InputProps;\n /**\n * Provide custom colors to the Accordion Component\n */\n colors?: AccordionColors;\n /**\n * Whether the accordion should be indexed.\n */\n shouldIndex?: boolean;\n /**\n * Enables keyboard-only focus highlighting. The highlighting is only visible while the\n * user navigates with the keyboard and is reset on mouse movement or click.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst Accordion: FC<AccordionProps> = ({\n bodyMaxHeight,\n children,\n icon,\n isDefaultOpen = false,\n isDisabled = false,\n isFixed = false,\n isOpened,\n isTitleGreyed = false,\n onBodyScroll,\n onClose,\n onHoverEnd,\n onHoverStart,\n onOpen,\n onSearchChange,\n rightElement,\n searchPlaceholder,\n searchValue,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldHideBackground = false,\n shouldRenderClosed = false,\n shouldRotateIcon = true,\n shouldHideBottomLine = false,\n title,\n titleElement,\n onTitleInputChange,\n titleInputProps,\n shouldSkipAnimation: shouldSkipAnimationProp = false,\n colors,\n shouldIndex = false,\n onBodyAnimationComplete,\n shouldEnableKeyboardHighlighting,\n}) => {\n const theme = useTheme() as Theme;\n const {\n isWrapped: groupIsWrapped,\n openAccordionUuid,\n accordionGroupUuid,\n accordionUuids,\n updateOpenAccordionUuid,\n setOpenAccordionUuid,\n activeAccordionUuid,\n updateActiveAccordionUuid,\n registerAccordionUuid,\n unregisterAccordionUuid,\n } = useContext(AccordionGroupContext);\n const { isWrapped: isParentWrapped } = useContext(AccordionContext);\n\n const { isWrapped: contextIsWrapped } = useContext(AccordionWrappedContext);\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const isWrapped = useMemo(\n () => groupIsWrapped ?? contextIsWrapped,\n [contextIsWrapped, groupIsWrapped],\n );\n\n const isControlled = typeof isOpened === 'boolean';\n const [internalOpen, setInternalOpen] = useState<boolean>(isDefaultOpen ?? false);\n\n const uuid = useUuid();\n\n const isInitialRenderRef = useRef(true);\n const accordionRef = useRef<HTMLDivElement>(null);\n\n const initialRenderSkipRef = useInitialRenderRef(true);\n\n const shouldSkipAnimation =\n shouldSkipAnimationProp ?? (initialRenderSkipRef.current && isDefaultOpen);\n\n const isInGroup = typeof updateOpenAccordionUuid === 'function';\n\n const isOpen = (() => {\n if (isInGroup) return openAccordionUuid === uuid;\n if (isControlled) return isOpened;\n return internalOpen;\n })();\n\n const isOpenRef = useRef(isOpen);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n const isKeyboardFocusable =\n !isDisabled && (shouldIndex || shouldEnableKeyboardHighlightingEffective);\n\n useFocusRingPortal(accordionRef, {\n isEnabled: shouldShowKeyboardHighlighting && isKeyboardFocusable,\n borderRadius: `${theme.cardBorderRadius ?? 0}px`,\n });\n\n const isInKeyboardNavigationGroup =\n isKeyboardFocusable &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string';\n\n useEffect(() => {\n if (\n typeof accordionGroupUuid === 'string' &&\n typeof registerAccordionUuid === 'function' &&\n typeof unregisterAccordionUuid === 'function'\n ) {\n registerAccordionUuid(uuid);\n\n return () => {\n unregisterAccordionUuid(uuid);\n };\n }\n\n return undefined;\n }, [accordionGroupUuid, registerAccordionUuid, unregisterAccordionUuid, uuid]);\n\n const isLastAccordion = useMemo(\n () => (accordionUuids ? accordionUuids[accordionUuids.length - 1] === uuid : false),\n [accordionUuids, uuid],\n );\n\n useEffect(() => {\n isOpenRef.current = isOpen;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n const handleHeadClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function') {\n updateActiveAccordionUuid(uuid);\n }\n\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n } else if (!isControlled) {\n setInternalOpen((prev: boolean) => !prev);\n }\n\n if (isOpen) {\n onClose?.();\n } else {\n onOpen?.();\n }\n }, [\n isDisabled,\n isKeyboardFocusable,\n updateActiveAccordionUuid,\n updateOpenAccordionUuid,\n uuid,\n isOpen,\n onClose,\n onOpen,\n isControlled,\n ]);\n\n useEffect(() => {\n if (isDisabled && isOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n } else if (typeof onClose === 'function') {\n onClose();\n } else {\n // Uncontrolled mode: use the internal state\n setInternalOpen(false);\n }\n }\n }, [isDisabled, isOpen, updateOpenAccordionUuid, uuid, onClose]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (!isControlled && isDefaultOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });\n } else if (typeof onOpen === 'function') {\n onOpen();\n } else {\n setInternalOpen(true);\n }\n }\n }, [isDefaultOpen, updateOpenAccordionUuid, uuid, onOpen, isControlled]);\n\n useEffect(() => {\n if (!isInGroup || !isControlled) {\n return;\n }\n\n if (isOpened) {\n updateOpenAccordionUuid?.(uuid, { shouldOnlyOpen: true });\n } else {\n setOpenAccordionUuid?.((currentUuid) =>\n currentUuid === uuid ? undefined : currentUuid,\n );\n }\n // Only prop changes should request a group transition. Reasserting an unchanged true\n // value after a sibling opens would make the accordions compete for the group state.\n }, [isControlled, isInGroup, isOpened, setOpenAccordionUuid, updateOpenAccordionUuid, uuid]);\n\n const accordionContextProviderValue = useMemo(\n () => ({ isWrapped: isWrapped === true }),\n [isWrapped],\n );\n\n const areaContextProviderValue = useMemo(\n () => ({ shouldChangeColor: !shouldHideBackground }),\n [shouldHideBackground],\n );\n\n const accordionWrappedContextProviderValue = useMemo(() => ({ isWrapped: true }), []);\n\n const initialAnimation = useMemo(() => {\n if (shouldSkipAnimation) {\n return { height: 'auto', opacity: 1 };\n }\n\n return isOpen ? { height: 'auto', opacity: 1 } : { height: 0, opacity: 0 };\n }, [isOpen, shouldSkipAnimation]);\n\n const tabIndex = useMemo(() => (isKeyboardFocusable ? 0 : -1), [isKeyboardFocusable]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentAccordionTarget = e.currentTarget === e.target;\n\n if (\n isCurrentAccordionTarget &&\n isInKeyboardNavigationGroup &&\n accordionUuids?.length &&\n (e.key === 'ArrowDown' || e.key === 'ArrowUp')\n ) {\n e.preventDefault();\n const currentIndex = accordionUuids.indexOf(uuid);\n\n if (currentIndex !== -1) {\n const nextIndex =\n e.key === 'ArrowDown'\n ? (currentIndex + 1) % accordionUuids.length\n : (currentIndex - 1 + accordionUuids.length) % accordionUuids.length;\n const nextAccordionUuid = accordionUuids[nextIndex];\n\n if (nextAccordionUuid && nextAccordionUuid !== uuid) {\n const nextAccordionElement = document.querySelector<HTMLDivElement>(\n `[data-uuid=\"${accordionGroupUuid}---${nextAccordionUuid}\"]`,\n );\n\n if (nextAccordionElement) {\n updateActiveAccordionUuid(nextAccordionUuid);\n nextAccordionElement.focus();\n return;\n }\n }\n }\n }\n\n if (\n isCurrentAccordionTarget &&\n (e.key === 'Enter' || e.key === ' ') &&\n isKeyboardFocusable\n ) {\n handleHeadClick();\n }\n\n if (\n isCurrentAccordionTarget &&\n e.key === 'ArrowRight' &&\n isKeyboardFocusable &&\n !isOpen\n ) {\n e.preventDefault();\n handleHeadClick();\n }\n\n if (isCurrentAccordionTarget && (e.key === 'Escape' || e.key === 'ArrowLeft')) {\n if (isOpen && isKeyboardFocusable) {\n e.preventDefault();\n handleHeadClick();\n return;\n }\n\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n e.preventDefault();\n updateActiveAccordionUuid(undefined);\n let parentAccordion =\n e.currentTarget.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n while (parentAccordion) {\n const parentGroupId = parentAccordion\n .getAttribute('data-uuid')\n ?.split('---')[0];\n if (parentGroupId !== accordionGroupUuid) {\n parentAccordion.focus();\n break;\n }\n parentAccordion =\n parentAccordion.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n }\n }\n }\n },\n [\n accordionGroupUuid,\n accordionUuids,\n handleHeadClick,\n isInKeyboardNavigationGroup,\n isKeyboardFocusable,\n isOpen,\n updateActiveAccordionUuid,\n uuid,\n ],\n );\n\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n e.currentTarget === e.target &&\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n updateActiveAccordionUuid(uuid);\n }\n },\n [isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string'\n ) {\n const nextFocusedElement = e.relatedTarget as Node | null;\n const currentGroupElement = e.currentTarget as HTMLElement;\n\n if (!nextFocusedElement || !currentGroupElement.contains(nextFocusedElement)) {\n updateActiveAccordionUuid(undefined);\n }\n }\n },\n [accordionGroupUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid],\n );\n\n useEffect(() => {\n if (\n activeAccordionUuid == null &&\n typeof updateActiveAccordionUuid === 'function' &&\n accordionUuids?.[0] === uuid\n ) {\n updateActiveAccordionUuid(uuid);\n }\n }, [\n accordionUuids,\n activeAccordionUuid,\n isInKeyboardNavigationGroup,\n updateActiveAccordionUuid,\n uuid,\n ]);\n\n return (\n <StyledMotionAccordion\n ref={accordionRef}\n animate={{ height: 'auto', opacity: 1 }}\n data-uuid={`${accordionGroupUuid ?? ''}---${uuid}`}\n className=\"beta-chayns-accordion\"\n exit={{ height: 0, opacity: 0 }}\n initial={initialAnimation}\n $isOpen={isOpen}\n tabIndex={tabIndex}\n $shouldShowLines={!isLastAccordion || !isWrapped}\n $isParentWrapped={isParentWrapped}\n $isWrapped={isWrapped}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBackground={shouldHideBackground}\n $shouldHideBottomLine={shouldHideBottomLine}\n $bottomBorderColor={colors?.borderBottomColor}\n $shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onMouseEnter={onHoverStart}\n onMouseLeave={onHoverEnd}\n transition={{ duration: shouldSkipAnimation ? 0 : 0.25 }}\n >\n <AccordionContext.Provider value={accordionContextProviderValue}>\n <MotionConfig transition={{ type: 'tween' }}>\n <AccordionHead\n uuid={uuid}\n icon={icon}\n isOpen={isOpen}\n shouldSkipAnimation={shouldSkipAnimation}\n isFixed={isFixed}\n isTitleGreyed={isTitleGreyed || isDisabled}\n isWrapped={isWrapped === true}\n onClick={handleHeadClick}\n onSearchChange={onSearchChange}\n rightElement={rightElement}\n searchPlaceholder={searchPlaceholder}\n searchValue={searchValue}\n shouldRotateIcon={shouldRotateIcon}\n title={title}\n titleElement={titleElement}\n onTitleInputChange={onTitleInputChange}\n titleInputProps={titleInputProps}\n titleColor={colors?.titleColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n />\n <AnimatePresence initial={false}>\n {(isOpen || shouldRenderClosed) && (\n <AccordionBody\n shouldSkipAnimation={shouldSkipAnimation}\n maxHeight={bodyMaxHeight}\n onScroll={onBodyScroll}\n onAnimationComplete={onBodyAnimationComplete}\n shouldHideBody={shouldRenderClosed && !isOpen}\n >\n <AccordionWrappedContext.Provider\n value={accordionWrappedContextProviderValue}\n >\n <AreaContext.Provider value={areaContextProviderValue}>\n {children}\n </AreaContext.Provider>\n </AccordionWrappedContext.Provider>\n </AccordionBody>\n )}\n </AnimatePresence>\n </MotionConfig>\n </AccordionContext.Provider>\n </StyledMotionAccordion>\n );\n};\n\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,cAAc;AAC5D,OAAOC,KAAK,IAORC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,4BAA4B,QAAQ,0CAA0C;AACvF,SAASC,WAAW,QAAQ,sCAAsC;AAClE,SAAqBC,cAAc,QAAQ,8CAA8C;AAEzF,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SAASC,uBAAuB,QAAQ,+CAA+C;AACvF,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,mBAAmB,QAAQ,iBAAiB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AAW;AAEnC,eAAe/I,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import React, { StrictMode } from 'react';
|
|
3
|
+
import { ThemeProvider } from 'styled-components';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import Accordion from './Accordion';
|
|
6
|
+
import AccordionGroup from './accordion-group/AccordionGroup';
|
|
7
|
+
// Observe the open state passed to the head without timing animation frames.
|
|
8
|
+
vi.mock('./accordion-head/AccordionHead', () => ({
|
|
9
|
+
default: ({
|
|
10
|
+
title,
|
|
11
|
+
isOpen,
|
|
12
|
+
onClick
|
|
13
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
role: "button",
|
|
15
|
+
"aria-expanded": isOpen,
|
|
16
|
+
onClick: onClick
|
|
17
|
+
}, title)
|
|
18
|
+
}));
|
|
19
|
+
const Harness = ({
|
|
20
|
+
first,
|
|
21
|
+
second,
|
|
22
|
+
grouped = true,
|
|
23
|
+
skipAnimation = false,
|
|
24
|
+
external = false
|
|
25
|
+
}) => {
|
|
26
|
+
const children = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Accordion, {
|
|
27
|
+
shouldIndex: true,
|
|
28
|
+
title: "First",
|
|
29
|
+
isOpened: first,
|
|
30
|
+
shouldSkipAnimation: skipAnimation
|
|
31
|
+
}, "First body"), /*#__PURE__*/React.createElement(Accordion, {
|
|
32
|
+
shouldIndex: true,
|
|
33
|
+
title: "Second",
|
|
34
|
+
isOpened: second,
|
|
35
|
+
shouldSkipAnimation: skipAnimation
|
|
36
|
+
}, "Second body"));
|
|
37
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
38
|
+
theme: {}
|
|
39
|
+
}, grouped ? /*#__PURE__*/React.createElement(AccordionGroup, {
|
|
40
|
+
shouldDisableInternalHandling: external
|
|
41
|
+
}, children) : children);
|
|
42
|
+
};
|
|
43
|
+
const expectOpen = (first, second) => {
|
|
44
|
+
expect(screen.getByRole('button', {
|
|
45
|
+
name: 'First'
|
|
46
|
+
})).toHaveAttribute('aria-expanded', String(first));
|
|
47
|
+
expect(screen.getByRole('button', {
|
|
48
|
+
name: 'Second'
|
|
49
|
+
})).toHaveAttribute('aria-expanded', String(second));
|
|
50
|
+
};
|
|
51
|
+
describe('Accordion isOpened', () => {
|
|
52
|
+
it('opens a grouped accordion initially', () => {
|
|
53
|
+
render(/*#__PURE__*/React.createElement(Harness, {
|
|
54
|
+
first: true
|
|
55
|
+
}));
|
|
56
|
+
expectOpen(true, false);
|
|
57
|
+
});
|
|
58
|
+
it('reacts to subsequent grouped property updates in both directions', () => {
|
|
59
|
+
const {
|
|
60
|
+
rerender
|
|
61
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
62
|
+
first: false,
|
|
63
|
+
second: false
|
|
64
|
+
}));
|
|
65
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
66
|
+
first: true,
|
|
67
|
+
second: false
|
|
68
|
+
}));
|
|
69
|
+
expectOpen(true, false);
|
|
70
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
71
|
+
first: false,
|
|
72
|
+
second: false
|
|
73
|
+
}));
|
|
74
|
+
expectOpen(false, false);
|
|
75
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
76
|
+
first: false,
|
|
77
|
+
second: true
|
|
78
|
+
}));
|
|
79
|
+
expectOpen(false, true);
|
|
80
|
+
});
|
|
81
|
+
it('opens only the last initially opened sibling, including in StrictMode', () => {
|
|
82
|
+
render(/*#__PURE__*/React.createElement(StrictMode, null, /*#__PURE__*/React.createElement(Harness, {
|
|
83
|
+
first: true,
|
|
84
|
+
second: true
|
|
85
|
+
})));
|
|
86
|
+
expectOpen(false, true);
|
|
87
|
+
});
|
|
88
|
+
it('opens only the last sibling when multiple props change to true', () => {
|
|
89
|
+
const {
|
|
90
|
+
rerender
|
|
91
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
92
|
+
first: false,
|
|
93
|
+
second: false
|
|
94
|
+
}));
|
|
95
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
96
|
+
first: true,
|
|
97
|
+
second: true
|
|
98
|
+
}));
|
|
99
|
+
expectOpen(false, true);
|
|
100
|
+
});
|
|
101
|
+
it('does not let a false sibling close the opened sibling', () => {
|
|
102
|
+
const {
|
|
103
|
+
rerender
|
|
104
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
105
|
+
first: true,
|
|
106
|
+
second: true
|
|
107
|
+
}));
|
|
108
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
109
|
+
first: false,
|
|
110
|
+
second: true
|
|
111
|
+
}));
|
|
112
|
+
expectOpen(false, true);
|
|
113
|
+
});
|
|
114
|
+
it('does not reassert an unchanged true prop after a group click', () => {
|
|
115
|
+
const {
|
|
116
|
+
rerender
|
|
117
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
118
|
+
first: true
|
|
119
|
+
}));
|
|
120
|
+
fireEvent.click(screen.getByRole('button', {
|
|
121
|
+
name: 'Second'
|
|
122
|
+
}));
|
|
123
|
+
expectOpen(false, true);
|
|
124
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
125
|
+
first: true
|
|
126
|
+
}));
|
|
127
|
+
expectOpen(false, true);
|
|
128
|
+
});
|
|
129
|
+
it('honors a newer opening request while a sibling prop stays true', () => {
|
|
130
|
+
const {
|
|
131
|
+
rerender
|
|
132
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
133
|
+
first: false,
|
|
134
|
+
second: true
|
|
135
|
+
}));
|
|
136
|
+
expectOpen(false, true);
|
|
137
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
138
|
+
first: true,
|
|
139
|
+
second: true
|
|
140
|
+
}));
|
|
141
|
+
expectOpen(true, false);
|
|
142
|
+
});
|
|
143
|
+
it('preserves default-open grouping when animations are skipped', () => {
|
|
144
|
+
render(/*#__PURE__*/React.createElement(ThemeProvider, {
|
|
145
|
+
theme: {}
|
|
146
|
+
}, /*#__PURE__*/React.createElement(AccordionGroup, null, /*#__PURE__*/React.createElement(Accordion, {
|
|
147
|
+
key: "first",
|
|
148
|
+
title: "First",
|
|
149
|
+
isDefaultOpen: true,
|
|
150
|
+
shouldSkipAnimation: true
|
|
151
|
+
}, "First body"), /*#__PURE__*/React.createElement(Accordion, {
|
|
152
|
+
key: "second",
|
|
153
|
+
title: "Second",
|
|
154
|
+
isDefaultOpen: true,
|
|
155
|
+
shouldSkipAnimation: true
|
|
156
|
+
}, "Second body"))));
|
|
157
|
+
expectOpen(false, true);
|
|
158
|
+
});
|
|
159
|
+
it('enforces the group constraint when animations are skipped', () => {
|
|
160
|
+
render(/*#__PURE__*/React.createElement(Harness, {
|
|
161
|
+
first: true,
|
|
162
|
+
second: true,
|
|
163
|
+
skipAnimation: true
|
|
164
|
+
}));
|
|
165
|
+
expectOpen(false, true);
|
|
166
|
+
});
|
|
167
|
+
it('preserves fully controlled standalone rendering and prop updates', () => {
|
|
168
|
+
const {
|
|
169
|
+
rerender
|
|
170
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
171
|
+
first: true,
|
|
172
|
+
grouped: false
|
|
173
|
+
}));
|
|
174
|
+
fireEvent.click(screen.getByRole('button', {
|
|
175
|
+
name: 'First'
|
|
176
|
+
}));
|
|
177
|
+
expectOpen(true, false);
|
|
178
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
179
|
+
first: false,
|
|
180
|
+
second: true,
|
|
181
|
+
grouped: false
|
|
182
|
+
}));
|
|
183
|
+
expectOpen(false, true);
|
|
184
|
+
});
|
|
185
|
+
it('preserves the explicit opt-out of internal group handling', () => {
|
|
186
|
+
render(/*#__PURE__*/React.createElement(Harness, {
|
|
187
|
+
first: true,
|
|
188
|
+
second: true,
|
|
189
|
+
external: true
|
|
190
|
+
}));
|
|
191
|
+
expectOpen(true, true);
|
|
192
|
+
});
|
|
193
|
+
it('preserves uncontrolled click and keyboard toggling', () => {
|
|
194
|
+
render(/*#__PURE__*/React.createElement(Harness, null));
|
|
195
|
+
fireEvent.click(screen.getByRole('button', {
|
|
196
|
+
name: 'First'
|
|
197
|
+
}));
|
|
198
|
+
expectOpen(true, false);
|
|
199
|
+
const second = screen.getByRole('button', {
|
|
200
|
+
name: 'Second'
|
|
201
|
+
}).closest('.beta-chayns-accordion');
|
|
202
|
+
fireEvent.keyDown(second, {
|
|
203
|
+
key: 'Enter',
|
|
204
|
+
target: second
|
|
205
|
+
});
|
|
206
|
+
expectOpen(false, true);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
//# sourceMappingURL=Accordion.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.test.js","names":["fireEvent","render","screen","React","StrictMode","ThemeProvider","describe","expect","it","vi","Accordion","AccordionGroup","mock","default","title","isOpen","onClick","createElement","role","Harness","first","second","grouped","skipAnimation","external","children","Fragment","shouldIndex","isOpened","shouldSkipAnimation","theme","shouldDisableInternalHandling","expectOpen","getByRole","name","toHaveAttribute","String","rerender","click","key","isDefaultOpen","closest","keyDown","target"],"sources":["../../../../src/components/accordion/Accordion.test.tsx"],"sourcesContent":["import { fireEvent, render, screen } from '@testing-library/react';\nimport React, { StrictMode } from 'react';\nimport { ThemeProvider } from 'styled-components';\nimport { describe, expect, it, vi } from 'vitest';\nimport Accordion from './Accordion';\nimport AccordionGroup from './accordion-group/AccordionGroup';\nimport type { AccordionHeadProps } from './accordion-head/AccordionHead';\n\n// Observe the open state passed to the head without timing animation frames.\nvi.mock('./accordion-head/AccordionHead', () => ({\n default: ({ title, isOpen, onClick }: AccordionHeadProps) => (\n <div role=\"button\" aria-expanded={isOpen} onClick={onClick}>\n {title}\n </div>\n ),\n}));\n\nconst Harness = ({\n first,\n second,\n grouped = true,\n skipAnimation = false,\n external = false,\n}: {\n first?: boolean;\n second?: boolean;\n grouped?: boolean;\n skipAnimation?: boolean;\n external?: boolean;\n}) => {\n const children = (\n <>\n <Accordion\n shouldIndex\n title=\"First\"\n isOpened={first}\n shouldSkipAnimation={skipAnimation}\n >\n First body\n </Accordion>\n <Accordion\n shouldIndex\n title=\"Second\"\n isOpened={second}\n shouldSkipAnimation={skipAnimation}\n >\n Second body\n </Accordion>\n </>\n );\n return (\n <ThemeProvider theme={{}}>\n {grouped ? (\n <AccordionGroup shouldDisableInternalHandling={external}>{children}</AccordionGroup>\n ) : (\n children\n )}\n </ThemeProvider>\n );\n};\n\nconst expectOpen = (first: boolean, second: boolean) => {\n expect(screen.getByRole('button', { name: 'First' })).toHaveAttribute(\n 'aria-expanded',\n String(first),\n );\n expect(screen.getByRole('button', { name: 'Second' })).toHaveAttribute(\n 'aria-expanded',\n String(second),\n );\n};\n\ndescribe('Accordion isOpened', () => {\n it('opens a grouped accordion initially', () => {\n render(<Harness first />);\n expectOpen(true, false);\n });\n\n it('reacts to subsequent grouped property updates in both directions', () => {\n const { rerender } = render(<Harness first={false} second={false} />);\n rerender(<Harness first second={false} />);\n expectOpen(true, false);\n rerender(<Harness first={false} second={false} />);\n expectOpen(false, false);\n rerender(<Harness first={false} second />);\n expectOpen(false, true);\n });\n\n it('opens only the last initially opened sibling, including in StrictMode', () => {\n render(\n <StrictMode>\n <Harness first second />\n </StrictMode>,\n );\n expectOpen(false, true);\n });\n\n it('opens only the last sibling when multiple props change to true', () => {\n const { rerender } = render(<Harness first={false} second={false} />);\n rerender(<Harness first second />);\n expectOpen(false, true);\n });\n\n it('does not let a false sibling close the opened sibling', () => {\n const { rerender } = render(<Harness first second />);\n rerender(<Harness first={false} second />);\n expectOpen(false, true);\n });\n\n it('does not reassert an unchanged true prop after a group click', () => {\n const { rerender } = render(<Harness first />);\n fireEvent.click(screen.getByRole('button', { name: 'Second' }));\n expectOpen(false, true);\n rerender(<Harness first />);\n expectOpen(false, true);\n });\n\n it('honors a newer opening request while a sibling prop stays true', () => {\n const { rerender } = render(<Harness first={false} second />);\n expectOpen(false, true);\n rerender(<Harness first second />);\n expectOpen(true, false);\n });\n\n it('preserves default-open grouping when animations are skipped', () => {\n render(\n <ThemeProvider theme={{}}>\n <AccordionGroup>\n <Accordion key=\"first\" title=\"First\" isDefaultOpen shouldSkipAnimation>\n First body\n </Accordion>\n <Accordion key=\"second\" title=\"Second\" isDefaultOpen shouldSkipAnimation>\n Second body\n </Accordion>\n </AccordionGroup>\n </ThemeProvider>,\n );\n expectOpen(false, true);\n });\n\n it('enforces the group constraint when animations are skipped', () => {\n render(<Harness first second skipAnimation />);\n expectOpen(false, true);\n });\n\n it('preserves fully controlled standalone rendering and prop updates', () => {\n const { rerender } = render(<Harness first grouped={false} />);\n fireEvent.click(screen.getByRole('button', { name: 'First' }));\n expectOpen(true, false);\n rerender(<Harness first={false} second grouped={false} />);\n expectOpen(false, true);\n });\n\n it('preserves the explicit opt-out of internal group handling', () => {\n render(<Harness first second external />);\n expectOpen(true, true);\n });\n\n it('preserves uncontrolled click and keyboard toggling', () => {\n render(<Harness />);\n fireEvent.click(screen.getByRole('button', { name: 'First' }));\n expectOpen(true, false);\n const second = screen\n .getByRole('button', { name: 'Second' })\n .closest('.beta-chayns-accordion')!;\n fireEvent.keyDown(second, { key: 'Enter', target: second });\n expectOpen(false, true);\n });\n});\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,MAAM,QAAQ,wBAAwB;AAClE,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACjD,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,cAAc,MAAM,kCAAkC;AAG7D;AACAF,EAAE,CAACG,IAAI,CAAC,gCAAgC,EAAE,OAAO;EAC7CC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC,MAAM;IAAEC;E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