@chayns-components/core 5.6.10 → 5.6.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/AGENTS.md +13 -0
- package/lib/cjs/components/popup/Popup.js +52 -38
- package/lib/cjs/components/popup/Popup.js.map +1 -1
- package/lib/cjs/components/popup/Popup.styles.js +11 -1
- package/lib/cjs/components/popup/Popup.styles.js.map +1 -1
- package/lib/cjs/components/popup/Popup.test.js +259 -0
- package/lib/cjs/components/popup/Popup.test.js.map +1 -0
- package/lib/cjs/components/popup/Popup.types.js.map +1 -1
- package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
- package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
- package/lib/cjs/components/popup/popupPosition.js +33 -0
- package/lib/cjs/components/popup/popupPosition.js.map +1 -0
- package/lib/cjs/components/popup/popupPosition.test.js +47 -0
- package/lib/cjs/components/popup/popupPosition.test.js.map +1 -0
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +1 -1
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
- package/lib/esm/components/popup/Popup.js +54 -40
- package/lib/esm/components/popup/Popup.js.map +1 -1
- package/lib/esm/components/popup/Popup.styles.js +10 -0
- package/lib/esm/components/popup/Popup.styles.js.map +1 -1
- package/lib/esm/components/popup/Popup.test.js +254 -0
- package/lib/esm/components/popup/Popup.test.js.map +1 -0
- package/lib/esm/components/popup/Popup.types.js.map +1 -1
- package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
- package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
- package/lib/esm/components/popup/popupPosition.js +26 -0
- package/lib/esm/components/popup/popupPosition.js.map +1 -0
- package/lib/esm/components/popup/popupPosition.test.js +45 -0
- package/lib/esm/components/popup/popupPosition.test.js.map +1 -0
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +1 -1
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
- package/lib/types/components/popup/Popup.styles.d.ts +3 -0
- package/lib/types/components/popup/Popup.types.d.ts +16 -0
- package/lib/types/components/popup/popupPosition.d.ts +15 -0
- package/package.json +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { PopupAlignment } from '../../types/popup';
|
|
3
|
+
import { getPopupInsetPosition } from './popupPosition';
|
|
4
|
+
const alignments = Object.values(PopupAlignment).filter(value => typeof value === 'number');
|
|
5
|
+
describe('popup inset positioning', () => {
|
|
6
|
+
it.each(alignments)('keeps the surface and arrow aligned within asymmetric bounds for alignment %s', alignment => {
|
|
7
|
+
const isLeft = alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.BottomLeft;
|
|
8
|
+
const isCenter = alignment === PopupAlignment.TopCenter || alignment === PopupAlignment.BottomCenter;
|
|
9
|
+
[30, 100, 250, 350].forEach(anchorX => {
|
|
10
|
+
const width = 240;
|
|
11
|
+
const position = getPopupInsetPosition({
|
|
12
|
+
alignment,
|
|
13
|
+
anchorX,
|
|
14
|
+
width,
|
|
15
|
+
boundaryLeft: 17,
|
|
16
|
+
boundaryWidth: 330
|
|
17
|
+
});
|
|
18
|
+
let surfaceLeft = position.x - 13;
|
|
19
|
+
if (isLeft) surfaceLeft = position.x - width + 13;
|
|
20
|
+
if (isCenter) surfaceLeft = position.x - width / 2;
|
|
21
|
+
expect(surfaceLeft).toBeGreaterThanOrEqual(40);
|
|
22
|
+
expect(surfaceLeft + width).toBeLessThanOrEqual(324);
|
|
23
|
+
const arrowAnchor = isLeft ? position.x - position.offset : position.x + position.offset;
|
|
24
|
+
expect(arrowAnchor).toBe(anchorX);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
it('keeps scroll offsets in the same coordinate space', () => {
|
|
28
|
+
const options = {
|
|
29
|
+
alignment: PopupAlignment.BottomRight,
|
|
30
|
+
anchorX: 350,
|
|
31
|
+
width: 240,
|
|
32
|
+
boundaryLeft: 17,
|
|
33
|
+
boundaryWidth: 330
|
|
34
|
+
};
|
|
35
|
+
const position = getPopupInsetPosition(options);
|
|
36
|
+
const scrolled = getPopupInsetPosition({
|
|
37
|
+
...options,
|
|
38
|
+
anchorX: options.anchorX + 120,
|
|
39
|
+
boundaryLeft: options.boundaryLeft + 120
|
|
40
|
+
});
|
|
41
|
+
expect(scrolled.x).toBe(position.x + 120);
|
|
42
|
+
expect(scrolled.offset).toBe(position.offset);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=popupPosition.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popupPosition.test.js","names":["describe","expect","it","PopupAlignment","getPopupInsetPosition","alignments","Object","values","filter","value","each","alignment","isLeft","TopLeft","BottomLeft","isCenter","TopCenter","BottomCenter","forEach","anchorX","width","position","boundaryLeft","boundaryWidth","surfaceLeft","x","toBeGreaterThanOrEqual","toBeLessThanOrEqual","arrowAnchor","offset","toBe","options","BottomRight","scrolled"],"sources":["../../../../src/components/popup/popupPosition.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { PopupAlignment } from '../../types/popup';\nimport { getPopupInsetPosition } from './popupPosition';\n\nconst alignments = Object.values(PopupAlignment).filter(\n (value): value is PopupAlignment => typeof value === 'number',\n);\n\ndescribe('popup inset positioning', () => {\n it.each(alignments)(\n 'keeps the surface and arrow aligned within asymmetric bounds for alignment %s',\n (alignment) => {\n const isLeft =\n alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.BottomLeft;\n const isCenter =\n alignment === PopupAlignment.TopCenter || alignment === PopupAlignment.BottomCenter;\n [30, 100, 250, 350].forEach((anchorX) => {\n const width = 240;\n const position = getPopupInsetPosition({\n alignment,\n anchorX,\n width,\n boundaryLeft: 17,\n boundaryWidth: 330,\n });\n let surfaceLeft = position.x - 13;\n if (isLeft) surfaceLeft = position.x - width + 13;\n if (isCenter) surfaceLeft = position.x - width / 2;\n expect(surfaceLeft).toBeGreaterThanOrEqual(40);\n expect(surfaceLeft + width).toBeLessThanOrEqual(324);\n const arrowAnchor = isLeft\n ? position.x - position.offset\n : position.x + position.offset;\n expect(arrowAnchor).toBe(anchorX);\n });\n },\n );\n\n it('keeps scroll offsets in the same coordinate space', () => {\n const options = {\n alignment: PopupAlignment.BottomRight,\n anchorX: 350,\n width: 240,\n boundaryLeft: 17,\n boundaryWidth: 330,\n };\n const position = getPopupInsetPosition(options);\n const scrolled = getPopupInsetPosition({\n ...options,\n anchorX: options.anchorX + 120,\n boundaryLeft: options.boundaryLeft + 120,\n });\n expect(scrolled.x).toBe(position.x + 120);\n expect(scrolled.offset).toBe(position.offset);\n });\n});\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,qBAAqB,QAAQ,iBAAiB;AAEvD,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,cAAc,CAAC,CAACK,MAAM,CAClDC,KAAK,IAA8B,OAAOA,KAAK,KAAK,QACzD,CAAC;AAEDT,QAAQ,CAAC,yBAAyB,EAAE,MAAM;EACtCE,EAAE,CAACQ,IAAI,CAACL,UAAU,CAAC,CACf,+EAA+E,EAC9EM,SAAS,IAAK;IACX,MAAMC,MAAM,GACRD,SAAS,KAAKR,cAAc,CAACU,OAAO,IAAIF,SAAS,KAAKR,cAAc,CAACW,UAAU;IACnF,MAAMC,QAAQ,GACVJ,SAAS,KAAKR,cAAc,CAACa,SAAS,IAAIL,SAAS,KAAKR,cAAc,CAACc,YAAY;IACvF,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAACC,OAAO,CAAEC,OAAO,IAAK;MACrC,MAAMC,KAAK,GAAG,GAAG;MACjB,MAAMC,QAAQ,GAAGjB,qBAAqB,CAAC;QACnC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CAACI,CAAC,GAAG,GAAG,CAAC;IACzCxB,MAAM,CAACgC,QAAQ,CAACJ,MAAM,CAAC,CAACC,IAAI,CAACT,QAAQ,CAACQ,MAAM,CAAC;EACjD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
|
|
|
19
19
|
app,
|
|
20
20
|
os
|
|
21
21
|
} = useDevice();
|
|
22
|
-
const shouldUseAppCall = useMemo(() => app &&
|
|
22
|
+
const shouldUseAppCall = useMemo(() => app && [AppName.Chayns, AppName.CityApp].includes(app.name) && (os === 'iOS' && app.appVersion >= 7313 || os === 'Android OS' && app.appVersion >= 7472), [app, os]);
|
|
23
23
|
const shareInApp = useCallback((provider, shareText, callback) => {
|
|
24
24
|
if (!provider) {
|
|
25
25
|
throw new Error('The requested sharing provider is not configured.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharingContextMenu.js","names":["AppName","getSite","invokeCall","useDevice","React","forwardRef","useCallback","useMemo","SHAREPROVIDER","useIsTouch","copyToClipboard","shareWithApp","shareWithUrl","ContextMenu","SharingContextMenu","link","text","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","app","os","shouldUseAppCall","name","CityApp","appVersion","shareInApp","provider","shareText","callback","Error","action","value","sharingApp","providerId","then","retVal","status","handleImageDownload","url","replace","encodeURIComponent","color","handleShare","key","trim","contextMenuItems","icons","onClick","createElement","_extends","items","displayName"],"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 >= 7313) ||\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 },\n }).then((retVal: { status: 0 | -1 | -2 }) => {\n if (retVal.status !== 0) {\n callback();\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":";AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AACpE,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,aAAa,QAAQ,4BAA4B;AAE1D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,eAAe,EAAEC,YAAY,EAAEC,YAAY,QAAQ,wBAAwB;AACpF,OAAOC,WAAW,MAAM,6BAA6B;AA0BrD,MAAMC,kBAAkB,gBAAGT,UAAU,CACjC,CACI;EACIU,IAAI;EACJC,IAAI;EACJC,QAAQ;EACRC,gCAAgC;EAChCC,2BAA2B,GAAG,IAAI;EAClCC,oBAAoB,GAA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AAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SharingContextMenu.js","names":["AppName","getSite","invokeCall","useDevice","React","forwardRef","useCallback","useMemo","SHAREPROVIDER","useIsTouch","copyToClipboard","shareWithApp","shareWithUrl","ContextMenu","SharingContextMenu","link","text","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","app","os","shouldUseAppCall","Chayns","CityApp","includes","name","appVersion","shareInApp","provider","shareText","callback","Error","action","value","sharingApp","providerId","then","retVal","status","handleImageDownload","url","replace","encodeURIComponent","color","handleShare","key","trim","contextMenuItems","icons","onClick","createElement","_extends","items","displayName"],"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 [AppName.Chayns, AppName.CityApp].includes(app.name) &&\n ((os === 'iOS' && app.appVersion >= 7313) ||\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 },\n }).then((retVal: { status: 0 | -1 | -2 }) => {\n if (retVal.status !== 0) {\n callback();\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":";AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AACpE,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,aAAa,QAAQ,4BAA4B;AAE1D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,eAAe,EAAEC,YAAY,EAAEC,YAAY,QAAQ,wBAAwB;AACpF,OAAOC,WAAW,MAAM,6BAA6B;AA0BrD,MAAMC,kBAAkB,gBAAGT,UAAU,CACjC,CACI;EACIU,IAAI;EACJC,IAAI;EACJC,QAAQ;EACRC,gCAAgC;EAChCC,2BAA2B,GAAG,IAAI;EAClCC,oBAAoB,GAAG,IAAI;EAC3B,GAAGC;AACP,CAAC,EACDC,GAAG,KACF;EACD,MAAMC,OAAO,GAAGd,UAAU,CAAC,CAAC;EAC5B,MAAM;IAAEe,GAAG;IAAEC;EAAG,CAAC,GAAGtB,SAAS,CAAC,CAAC;EAE/B,MAAMuB,gBAAgB,GAAGnB,OAAO,CAC5B,MACIiB,GAAG,IACH,CAACxB,OAAO,CAAC2B,MAAM,EAAE3B,OAAO,CAAC4B,OAAO,CAAC,CAACC,QAAQ,CAACL,GAAG,CAACM,IAAI,CAAC,KAClDL,EAAE,KAAK,KAAK,IAAID,GAAG,CAACO,UAAU,IAAI,IAAI,IACnCN,EAAE,KAAK,YAAY,IAAID,GAAG,CAACO,UAAU,IAAI,IAAK,CAAC,EACxD,CAACP,GAAG,EAAEC,EAAE,CACZ,CAAC;EAED,MAAMO,UAAU,GAA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IqC,KAAK,EAAE,CAAC,iCAAiC,CAAC;IAC1CH,GAAG,EAAE,SAAS;IACdI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,SAAS,CAAC;IACrCjC,IAAI,EAAE;EACV,CAAC,EACD;IACIqC,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzBH,GAAG,EAAE,MAAM;IACXI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,MAAM,CAAC;IAClCjC,IAAI,EAAE;EACV,CAAC,EACD,IAAIG,2BAA2B,GACzB,CACI;IACIkC,KAAK,EAAE,CAAC,cAAc,CAAC;IACvBH,GAAG,EAAE,aAAa;IAClBI,OAAO,EAAEV,mBAAmB;IAC5B5B,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,CACZ;EAED,oBACIZ,KAAA,CAAAmD,aAAA,CAAC1C,WAAW,EAAA2C,QAAA;IACRC,KAAK,EAAEL,gBAAiB;IACxB9B,GAAG,EAAEA,GAAI;IACTJ,gCAAgC,EAAEA;IAClC;EAAA,GACIG,gBAAgB,GAEnBJ,QACQ,CAAC;AAEtB,CACJ,CAAC;AAEDH,kBAAkB,CAAC4C,WAAW,GAAG,oBAAoB;AAErD,eAAe5C,kBAAkB","ignoreList":[]}
|
|
@@ -11,4 +11,7 @@ export declare const StyledPopupPseudo: import("styled-components/dist/types").I
|
|
|
11
11
|
}, {
|
|
12
12
|
$menuHeight: number;
|
|
13
13
|
}>> & string;
|
|
14
|
+
export declare const StyledPopupInsetContent: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
15
|
+
style?: React.CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
16
|
+
}> & string;
|
|
14
17
|
export {};
|
|
@@ -21,6 +21,22 @@ export type PopupProps = {
|
|
|
21
21
|
* @optional
|
|
22
22
|
*/
|
|
23
23
|
children?: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Additional horizontal insets inside the positioning container, in CSS pixels.
|
|
26
|
+
* @description
|
|
27
|
+
* Reserve space for safe areas or host controls without moving the trigger. Each side defaults
|
|
28
|
+
* to zero and is added to the standard popup edge spacing. Insets use the positioning container's
|
|
29
|
+
* unscaled coordinate space; fixed popups use the document body. Updating the values repositions
|
|
30
|
+
* an open popup. Oversized content is constrained to the remaining width and allowed to wrap.
|
|
31
|
+
* @default { left: 0, right: 0 }
|
|
32
|
+
* @example
|
|
33
|
+
* <Popup boundaryInsets={{ left: 17, right: 43 }} content="Details">Open</Popup>
|
|
34
|
+
* @optional
|
|
35
|
+
*/
|
|
36
|
+
boundaryInsets?: {
|
|
37
|
+
left?: number;
|
|
38
|
+
right?: number;
|
|
39
|
+
};
|
|
24
40
|
/**
|
|
25
41
|
* The DOM element that should receive the popup portal.
|
|
26
42
|
* @description
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PopupAlignment } from '../../types/popup';
|
|
2
|
+
export declare const POPUP_HORIZONTAL_PADDING = 23;
|
|
3
|
+
interface PopupInsetPositionOptions {
|
|
4
|
+
alignment: PopupAlignment;
|
|
5
|
+
anchorX: number;
|
|
6
|
+
boundaryLeft: number;
|
|
7
|
+
boundaryWidth: number;
|
|
8
|
+
width: number;
|
|
9
|
+
}
|
|
10
|
+
/** Constrain the popup surface while keeping its arrow attached to the trigger. */
|
|
11
|
+
export declare const getPopupInsetPosition: ({ alignment, anchorX, boundaryLeft, boundaryWidth, width, }: PopupInsetPositionOptions) => {
|
|
12
|
+
x: number;
|
|
13
|
+
offset: number;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.12",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "c6d6890a4da8f52747fc279c13e53af0fd424a15"
|
|
97
97
|
}
|