@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,6 +1,6 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import { getSite, invokeCall,
|
|
3
|
-
import React, { forwardRef, useCallback } from 'react';
|
|
2
|
+
import { AppName, getSite, invokeCall, useDevice } from 'chayns-api';
|
|
3
|
+
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
4
4
|
import { SHAREPROVIDER } from '../../constants/sharingBar';
|
|
5
5
|
import { useIsTouch } from '../../utils/environment';
|
|
6
6
|
import { copyToClipboard, shareWithApp, shareWithUrl } from '../../utils/sharingBar';
|
|
@@ -15,7 +15,12 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
|
|
|
15
15
|
...contextMenuProps
|
|
16
16
|
}, ref) => {
|
|
17
17
|
const isTouch = useIsTouch();
|
|
18
|
-
const
|
|
18
|
+
const {
|
|
19
|
+
app,
|
|
20
|
+
os
|
|
21
|
+
} = useDevice();
|
|
22
|
+
const shouldUseAppCall = useMemo(() => app && app.name === AppName.CityApp && (os === 'iOS' && app.appVersion >= 3313 || os === 'Android OS' && app.appVersion >= 7472), [app, os]);
|
|
23
|
+
const shareInApp = useCallback((provider, shareText, callback) => {
|
|
19
24
|
if (!provider) {
|
|
20
25
|
throw new Error('The requested sharing provider is not configured.');
|
|
21
26
|
}
|
|
@@ -26,7 +31,12 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
|
|
|
26
31
|
sharingApp: provider.providerId,
|
|
27
32
|
...(provider.androidIdentifier ? {
|
|
28
33
|
sharingAndroidApp: provider.androidIdentifier
|
|
29
|
-
} : {})
|
|
34
|
+
} : {}),
|
|
35
|
+
callback: retVal => {
|
|
36
|
+
if (retVal.status !== 0) {
|
|
37
|
+
callback();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
30
40
|
}
|
|
31
41
|
});
|
|
32
42
|
}, []);
|
|
@@ -41,55 +51,63 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
|
|
|
41
51
|
case 'whatsapp':
|
|
42
52
|
{
|
|
43
53
|
const shareText = text ? `${text}\n\n${link}` : `${link}`.trim();
|
|
44
|
-
|
|
45
|
-
shareInApp(SHAREPROVIDER[0], shareText);
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
shareWithUrl(
|
|
54
|
+
const callback = () => shareWithUrl(
|
|
49
55
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
56
|
// @ts-ignore
|
|
51
57
|
SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(shareText)));
|
|
58
|
+
if (shouldUseAppCall) {
|
|
59
|
+
shareInApp(SHAREPROVIDER[0], shareText, callback);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
callback();
|
|
52
63
|
break;
|
|
53
64
|
}
|
|
54
65
|
case 'facebook':
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
{
|
|
67
|
+
const callback = () => shareWithUrl(
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)));
|
|
71
|
+
if (shouldUseAppCall) {
|
|
72
|
+
shareInApp(SHAREPROVIDER[3], `${link}`.trim(), callback);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
callback();
|
|
57
76
|
break;
|
|
58
77
|
}
|
|
59
|
-
shareWithUrl(
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)));
|
|
63
|
-
break;
|
|
64
78
|
case 'twitter':
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
{
|
|
80
|
+
const callback = () => shareWithUrl(
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', encodeURIComponent(text ?? '')));
|
|
84
|
+
if (shouldUseAppCall) {
|
|
85
|
+
shareInApp(SHAREPROVIDER[4], text ? `${text}\n\n${link}` : `${link}`.trim(), callback);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
callback();
|
|
67
89
|
break;
|
|
68
90
|
}
|
|
69
|
-
shareWithUrl(
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', encodeURIComponent(text ?? '')));
|
|
73
|
-
break;
|
|
74
91
|
case 'mail':
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} else if (isTouch) {
|
|
78
|
-
shareWithApp(text ? `${text}\n\n${link}` : `${link}`.trim());
|
|
79
|
-
} else {
|
|
80
|
-
shareWithUrl(
|
|
92
|
+
{
|
|
93
|
+
const callback = () => isTouch ? shareWithApp(text ? `${text}\n\n${link}` : `${link}`.trim()) : shareWithUrl(
|
|
81
94
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
95
|
// @ts-ignore
|
|
83
96
|
SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(text ? `${text}\n\n${link}` : `${link}`.trim())));
|
|
97
|
+
if (shouldUseAppCall) {
|
|
98
|
+
shareInApp(SHAREPROVIDER[2], text ? `${text}\n\n${link}` : `${link}`.trim(), callback);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
callback();
|
|
102
|
+
break;
|
|
84
103
|
}
|
|
85
|
-
break;
|
|
86
104
|
case 'copy':
|
|
87
105
|
copyToClipboard(link);
|
|
88
106
|
break;
|
|
89
107
|
default:
|
|
90
108
|
break;
|
|
91
109
|
}
|
|
92
|
-
}, [link, text,
|
|
110
|
+
}, [link, text, shouldUseAppCall, shareInApp, isTouch]);
|
|
93
111
|
const contextMenuItems = [...(shouldShowCopyAction ? [{
|
|
94
112
|
icons: ['fa fa-copy'],
|
|
95
113
|
key: 'copy',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharingContextMenu.js","names":["getSite","invokeCall","isApp","React","forwardRef","useCallback","SHAREPROVIDER","useIsTouch","copyToClipboard","shareWithApp","shareWithUrl","ContextMenu","SharingContextMenu","link","text","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","shareInApp","provider","shareText","Error","action","value","sharingApp","providerId","androidIdentifier","sharingAndroidApp","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 { 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,SAASA,OAAO,EAAEC,UAAU,EAAEC,KAAK,QAAQ,YAAY;AACvD,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,QAAQ,OAAO;AACtD,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,gBAAGR,UAAU,CACjC,CACI;EACIS,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;EAE5B,MAAMe,UAAU,GAAGjB,WAAW,CAC1B,CAACkB,QAAwC,EAAEC,SAAiB,KAAK;IAC7D,IAAI,CAACD,QAAQ,EAAE;MACX,MAAM,IAAIE,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OAAO,EAAEV,mBAAmB;IAC5BlB,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,CACZ;EAED,oBACIX,KAAA,CAAAwC,aAAA,CAAChC,WAAW,EAAAiC,QAAA;IACRC,KAAK,EAAEL,gBAAiB;IACxBpB,GAAG,EAAEA,GAAI;IACTJ,gCAAgC,EAAEA;IAClC;EAAA,GACIG,gBAAgB,GAEnBJ,QACQ,CAAC;AAEtB,CACJ,CAAC;AAEDH,kBAAkB,CAACkC,WAAW,GAAG,oBAAoB;AAErD,eAAelC,kBAAkB","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","name","CityApp","appVersion","shareInApp","provider","shareText","callback","Error","action","value","sharingApp","providerId","androidIdentifier","sharingAndroidApp","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 >= 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":";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;E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}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.6",
|
|
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": "9ef8867c1e39db865556e9c2f285771b7cf34e90"
|
|
97
97
|
}
|