@chayns-components/core 5.6.3 → 5.6.4

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 CHANGED
@@ -5144,6 +5144,7 @@ import { SharingBar } from '@chayns-components/core';
5144
5144
  | `link` | `string` | yes | The link that should be shared. |
5145
5145
  | `popupAlignment` | `ContextMenuAlignment` | yes | The alignment of the sharing options. |
5146
5146
  | `shouldEnableKeyboardHighlighting` | `boolean \| undefined` | no | Enables keyboard-only focus highlighting and keyboard interaction. |
5147
+ | `text` | `string \| undefined` | no | Optional text that is shared together with the link via WhatsApp, mail, and X. |
5147
5148
 
5148
5149
  ### Types
5149
5150
 
@@ -5244,6 +5245,7 @@ import { SharingButton } from '@chayns-components/core';
5244
5245
  | `isDisabled` | `boolean \| undefined` | no | Whether the button is disabled and cannot be clicked anymore. |
5245
5246
  | `link` | `string` | yes | The link that should be shared. |
5246
5247
  | `shouldEnableKeyboardHighlighting` | `boolean \| undefined` | no | Enables keyboard-only focus highlighting. |
5248
+ | `text` | `string \| undefined` | no | Optional text that is shared together with the link via WhatsApp, mail, and X. |
5247
5249
 
5248
5250
  ### Types
5249
5251
 
@@ -16,6 +16,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
16
16
  const SharingBar = ({
17
17
  label,
18
18
  link,
19
+ text,
19
20
  popupAlignment,
20
21
  container,
21
22
  shouldEnableKeyboardHighlighting
@@ -66,6 +67,7 @@ const SharingBar = ({
66
67
  icons: ['fa fa-share-nodes']
67
68
  })), /*#__PURE__*/_react.default.createElement(_SharingContextMenu.default, {
68
69
  link: link,
70
+ text: text,
69
71
  ref: contextMenuRef,
70
72
  alignment: popupAlignment,
71
73
  container: container,
@@ -1 +1 @@
1
- {"version":3,"file":"SharingBar.js","names":["_react","_interopRequireWildcard","require","_useFocusRingPortal","_useKeyboardFocusHighlighting","_ColorSchemeProvider","_Icon","_interopRequireDefault","_SharingBar","_SharingContextMenu","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SharingBar","label","link","popupAlignment","container","shouldEnableKeyboardHighlighting","colorScheme","useColorScheme","shouldEnableKeyboardHighlightingEffective","contextMenuRef","useRef","sharingBarRef","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","useFocusRingPortal","isEnabled","showContextMenu","useCallback","_contextMenuRef$curre","current","show","handleSharingBarClick","event","preventDefault","stopPropagation","handleKeyDown","currentTarget","target","key","_contextMenuRef$curre2","hide","createElement","StyledSharingBar","ref","onClick","onKeyDown","undefined","tabIndex","role","StyledSharingBarIconWrapper","icons","alignment","shouldDisableClick","StyledSharingBarText","displayName","_default","exports"],"sources":["../../../../src/components/sharing-bar/SharingBar.tsx"],"sourcesContent":["import React, { FC, KeyboardEventHandler, MouseEventHandler, useCallback, useRef } from 'react';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledSharingBar,\n StyledSharingBarIconWrapper,\n StyledSharingBarText,\n} from './SharingBar.styles';\nimport type { ContextMenuAlignment } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu from '../sharing-context-menu/SharingContextMenu';\n\nexport type SharingBarProps = {\n /**\n * The element where the content of the `SharingBar` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The label that should be displayed.\n */\n label: string;\n /**\n * The link that should be shared.\n */\n link: string;\n /**\n * The alignment of the sharing options.\n */\n popupAlignment: ContextMenuAlignment;\n /**\n * Enables keyboard-only focus highlighting and keyboard interaction.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst SharingBar: FC<SharingBarProps> = ({\n label,\n link,\n popupAlignment,\n container,\n shouldEnableKeyboardHighlighting,\n}) => {\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const contextMenuRef = useRef<{ hide: VoidFunction; show: VoidFunction }>(null);\n const sharingBarRef = useRef<HTMLDivElement>(null);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n useFocusRingPortal(sharingBarRef, { isEnabled: shouldShowKeyboardHighlighting });\n\n const showContextMenu = useCallback(() => {\n contextMenuRef.current?.show();\n }, []);\n\n const handleSharingBarClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n showContextMenu();\n },\n [showContextMenu],\n );\n\n const handleKeyDown = useCallback<KeyboardEventHandler<HTMLDivElement>>(\n (event) => {\n if (event.currentTarget !== event.target) {\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.hide();\n return;\n }\n\n if (event.key !== 'Enter' && event.key !== ' ') {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n showContextMenu();\n },\n [showContextMenu],\n );\n\n return (\n <StyledSharingBar\n ref={sharingBarRef}\n onClick={handleSharingBarClick}\n onKeyDown={shouldEnableKeyboardHighlightingEffective ? handleKeyDown : undefined}\n tabIndex={shouldEnableKeyboardHighlightingEffective ? 0 : undefined}\n role={shouldEnableKeyboardHighlightingEffective ? 'button' : undefined}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n >\n <StyledSharingBarIconWrapper>\n <Icon icons={['fa fa-share-nodes']} />\n </StyledSharingBarIconWrapper>\n <SharingContextMenu\n link={link}\n ref={contextMenuRef}\n alignment={popupAlignment}\n container={container}\n shouldDisableClick\n >\n {null}\n </SharingContextMenu>\n <StyledSharingBarText>{label}</StyledSharingBarText>\n </StyledSharingBar>\n );\n};\n\nSharingBar.displayName = 'SharingBar';\n\nexport default SharingBar;\n"],"mapp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vE,MAAA,CAAAY,OAAA,CAAAgD,aAAA,CAACpD,WAAA,CAAAgE,oBAAoB,QAAE1C,KAA4B,CACrC,CAAC;AAE3B,CAAC;AAEDD,UAAU,CAAC4C,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/D,OAAA,GAEvBiB,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"SharingBar.js","names":["_react","_interopRequireWildcard","require","_useFocusRingPortal","_useKeyboardFocusHighlighting","_ColorSchemeProvider","_Icon","_interopRequireDefault","_SharingBar","_SharingContextMenu","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SharingBar","label","link","text","popupAlignment","container","shouldEnableKeyboardHighlighting","colorScheme","useColorScheme","shouldEnableKeyboardHighlightingEffective","contextMenuRef","useRef","sharingBarRef","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","useFocusRingPortal","isEnabled","showContextMenu","useCallback","_contextMenuRef$curre","current","show","handleSharingBarClick","event","preventDefault","stopPropagation","handleKeyDown","currentTarget","target","key","_contextMenuRef$curre2","hide","createElement","StyledSharingBar","ref","onClick","onKeyDown","undefined","tabIndex","role","StyledSharingBarIconWrapper","icons","alignment","shouldDisableClick","StyledSharingBarText","displayName","_default","exports"],"sources":["../../../../src/components/sharing-bar/SharingBar.tsx"],"sourcesContent":["import React, { FC, KeyboardEventHandler, MouseEventHandler, useCallback, useRef } from 'react';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledSharingBar,\n StyledSharingBarIconWrapper,\n StyledSharingBarText,\n} from './SharingBar.styles';\nimport type { ContextMenuAlignment } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu from '../sharing-context-menu/SharingContextMenu';\n\nexport type SharingBarProps = {\n /**\n * The element where the content of the `SharingBar` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The label that should be displayed.\n */\n label: string;\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 * The alignment of the sharing options.\n */\n popupAlignment: ContextMenuAlignment;\n /**\n * Enables keyboard-only focus highlighting and keyboard interaction.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst SharingBar: FC<SharingBarProps> = ({\n label,\n link,\n text,\n popupAlignment,\n container,\n shouldEnableKeyboardHighlighting,\n}) => {\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const contextMenuRef = useRef<{ hide: VoidFunction; show: VoidFunction }>(null);\n const sharingBarRef = useRef<HTMLDivElement>(null);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n useFocusRingPortal(sharingBarRef, { isEnabled: shouldShowKeyboardHighlighting });\n\n const showContextMenu = useCallback(() => {\n contextMenuRef.current?.show();\n }, []);\n\n const handleSharingBarClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n showContextMenu();\n },\n [showContextMenu],\n );\n\n const handleKeyDown = useCallback<KeyboardEventHandler<HTMLDivElement>>(\n (event) => {\n if (event.currentTarget !== event.target) {\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.hide();\n return;\n }\n\n if (event.key !== 'Enter' && event.key !== ' ') {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n showContextMenu();\n },\n [showContextMenu],\n );\n\n return (\n <StyledSharingBar\n ref={sharingBarRef}\n onClick={handleSharingBarClick}\n onKeyDown={shouldEnableKeyboardHighlightingEffective ? handleKeyDown : undefined}\n tabIndex={shouldEnableKeyboardHighlightingEffective ? 0 : undefined}\n role={shouldEnableKeyboardHighlightingEffective ? 'button' : undefined}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n >\n <StyledSharingBarIconWrapper>\n <Icon icons={['fa fa-share-nodes']} />\n </StyledSharingBarIconWrapper>\n <SharingContextMenu\n link={link}\n text={text}\n ref={contextMenuRef}\n alignment={popupAlignment}\n container={container}\n shouldDisableClick\n >\n {null}\n </SharingContextMenu>\n <StyledSharingBarText>{label}</StyledSharingBarText>\n </StyledSharingBar>\n );\n};\n\nSharingBar.displayName = 'SharingBar';\n\nexport default SharingBar;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAMA,IAAAO,mBAAA,GAAAF,sBAAA,CAAAL,OAAA;AAA4E,SAAAK,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,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;EAC7C,gBAEDlE,MAAA,CAAAY,OAAA,CAAAiD,aAAA,CAACrD,WAAA,CAAA6D,2BAA2B,qBACxBrE,MAAA,CAAAY,OAAA,CAAAiD,aAAA,CAACvD,KAAA,CAAAM,OAAI;IAAC0D,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACZ,CAAC,eAC9BtE,MAAA,CAAAY,OAAA,CAAAiD,aAAA,CAACpD,mBAAA,CAAAG,OAAkB;IACfmB,IAAI,EAAEA,IAAK;IACXC,IAAI,EAAEA,IAAK;IACX+B,GAAG,EAAExB,cAAe;IACpBgC,SAAS,EAAEtC,cAAe;IAC1BC,SAAS,EAAEA,SAAU;IACrBsC,kBAAkB;EAAA,GAEjB,IACe,CAAC,eACrBxE,MAAA,CAAAY,OAAA,CAAAiD,aAAA,CAACrD,WAAA,CAAAiE,oBAAoB,QAAE3C,KAA4B,CACrC,CAAC;AAE3B,CAAC;AAEDD,UAAU,CAAC6C,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhE,OAAA,GAEvBiB,UAAU","ignoreList":[]}
@@ -11,6 +11,7 @@ var _Button = _interopRequireDefault(require("../button/Button"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  const SharingButton = ({
13
13
  link,
14
+ text,
14
15
  alignment,
15
16
  container,
16
17
  children,
@@ -26,6 +27,7 @@ const SharingButton = ({
26
27
  };
27
28
  return /*#__PURE__*/_react.default.createElement(_SharingButton.StyledSharingButtonContainer, null, /*#__PURE__*/_react.default.createElement(_SharingContextMenu.default, {
28
29
  link: link,
30
+ text: text,
29
31
  alignment: alignment,
30
32
  container: container,
31
33
  ref: contextMenuRef,
@@ -1 +1 @@
1
- {"version":3,"file":"SharingButton.js","names":["_react","_interopRequireDefault","require","_SharingContextMenu","_SharingButton","_Button","e","__esModule","default","SharingButton","link","alignment","container","children","isDisabled","shouldEnableKeyboardHighlighting","contextMenuRef","React","useRef","handleButtonClick","event","_contextMenuRef$curre","preventDefault","stopPropagation","current","show","createElement","StyledSharingButtonContainer","ref","shouldDisableClick","onClick","_default","exports"],"sources":["../../../../src/components/sharing-button/SharingButton.tsx"],"sourcesContent":["import React, { FunctionComponent, PropsWithChildren } from 'react';\nimport { ContextMenuRef } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu, {\n SharingContextMenuProps,\n} from '../sharing-context-menu/SharingContextMenu';\nimport { StyledSharingButtonContainer } from './SharingButton.styles';\nimport Button from '../button/Button';\nimport { ButtonProps } from '../button/Button.types';\n\nexport type SharingButtonProps = PropsWithChildren<\n Pick<SharingContextMenuProps, 'link' | 'alignment' | 'container'> &\n Pick<ButtonProps, 'isDisabled' | 'shouldEnableKeyboardHighlighting'>\n>;\n\nconst SharingButton: FunctionComponent<SharingButtonProps> = ({\n link,\n alignment,\n container,\n children,\n isDisabled,\n shouldEnableKeyboardHighlighting,\n}) => {\n const contextMenuRef = React.useRef<ContextMenuRef>(null);\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.show();\n };\n\n return (\n <StyledSharingButtonContainer>\n <SharingContextMenu\n link={link}\n alignment={alignment}\n container={container}\n ref={contextMenuRef}\n shouldDisableClick\n >\n <Button\n onClick={handleButtonClick}\n isDisabled={isDisabled}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n >\n {children}\n </Button>\n </SharingContextMenu>\n </StyledSharingButtonContainer>\n );\n};\n\nexport default SharingButton;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAQtC,MAAMG,aAAoD,GAAGA,CAAC;EAC1DC,IAAI;EACJC,SAAS;EACTC,SAAS;EACTC,QAAQ;EACRC,UAAU;EACVC;AACJ,CAAC,KAAK;EACF,MAAMC,cAAc,GAAGC,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAEzD,MAAMC,iBAAiB,GAAIC,KAA0C,IAAK;IAAA,IAAAC,qBAAA;IACtED,KAAK,CAACE,cAAc,CAAC,CAAC;IACtBF,KAAK,CAACG,eAAe,CAAC,CAAC;IACvB,CAAAF,qBAAA,GAAAL,cAAc,CAACQ,OAAO,cAAAH,qBAAA,eAAtBA,qBAAA,CAAwBI,IAAI,CAAC,CAAC;EAClC,CAAC;EAED,oBACIzB,MAAA,CAAAQ,OAAA,CAAAkB,aAAA,CAACtB,cAAA,CAAAuB,4BAA4B,qBACzB3B,MAAA,CAAAQ,OAAA,CAAAkB,aAAA,CAACvB,mBAAA,CAAAK,OAAkB;IACfE,IAAI,EAAEA,IAAK;IACXC,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBgB,GAAG,EAAEZ,cAAe;IACpBa,kBAAkB;EAAA,gBAElB7B,MAAA,CAAAQ,OAAA,CAAAkB,aAAA,CAACrB,OAAA,CAAAG,OAAM;IACHsB,OAAO,EAAEX,iBAAkB;IAC3BL,UAAU,EAAEA,UAAW;IACvBC,gCAAgC,EAAEA;EAAiC,GAElEF,QACG,CACQ,CACM,CAAC;AAEvC,CAAC;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAxB,OAAA,GAEaC,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"SharingButton.js","names":["_react","_interopRequireDefault","require","_SharingContextMenu","_SharingButton","_Button","e","__esModule","default","SharingButton","link","text","alignment","container","children","isDisabled","shouldEnableKeyboardHighlighting","contextMenuRef","React","useRef","handleButtonClick","event","_contextMenuRef$curre","preventDefault","stopPropagation","current","show","createElement","StyledSharingButtonContainer","ref","shouldDisableClick","onClick","_default","exports"],"sources":["../../../../src/components/sharing-button/SharingButton.tsx"],"sourcesContent":["import React, { FunctionComponent, PropsWithChildren } from 'react';\nimport { ContextMenuRef } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu, {\n SharingContextMenuProps,\n} from '../sharing-context-menu/SharingContextMenu';\nimport { StyledSharingButtonContainer } from './SharingButton.styles';\nimport Button from '../button/Button';\nimport { ButtonProps } from '../button/Button.types';\n\nexport type SharingButtonProps = PropsWithChildren<\n Pick<SharingContextMenuProps, 'link' | 'text' | 'alignment' | 'container'> &\n Pick<ButtonProps, 'isDisabled' | 'shouldEnableKeyboardHighlighting'>\n>;\n\nconst SharingButton: FunctionComponent<SharingButtonProps> = ({\n link,\n text,\n alignment,\n container,\n children,\n isDisabled,\n shouldEnableKeyboardHighlighting,\n}) => {\n const contextMenuRef = React.useRef<ContextMenuRef>(null);\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.show();\n };\n\n return (\n <StyledSharingButtonContainer>\n <SharingContextMenu\n link={link}\n text={text}\n alignment={alignment}\n container={container}\n ref={contextMenuRef}\n shouldDisableClick\n >\n <Button\n onClick={handleButtonClick}\n isDisabled={isDisabled}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n >\n {children}\n </Button>\n </SharingContextMenu>\n </StyledSharingButtonContainer>\n );\n};\n\nexport default SharingButton;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAQtC,MAAMG,aAAoD,GAAGA,CAAC;EAC1DC,IAAI;EACJC,IAAI;EACJC,SAAS;EACTC,SAAS;EACTC,QAAQ;EACRC,UAAU;EACVC;AACJ,CAAC,KAAK;EACF,MAAMC,cAAc,GAAGC,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAEzD,MAAMC,iBAAiB,GAAIC,KAA0C,IAAK;IAAA,IAAAC,qBAAA;IACtED,KAAK,CAACE,cAAc,CAAC,CAAC;IACtBF,KAAK,CAACG,eAAe,CAAC,CAAC;IACvB,CAAAF,qBAAA,GAAAL,cAAc,CAACQ,OAAO,cAAAH,qBAAA,eAAtBA,qBAAA,CAAwBI,IAAI,CAAC,CAAC;EAClC,CAAC;EAED,oBACI1B,MAAA,CAAAQ,OAAA,CAAAmB,aAAA,CAACvB,cAAA,CAAAwB,4BAA4B,qBACzB5B,MAAA,CAAAQ,OAAA,CAAAmB,aAAA,CAACxB,mBAAA,CAAAK,OAAkB;IACfE,IAAI,EAAEA,IAAK;IACXC,IAAI,EAAEA,IAAK;IACXC,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBgB,GAAG,EAAEZ,cAAe;IACpBa,kBAAkB;EAAA,gBAElB9B,MAAA,CAAAQ,OAAA,CAAAmB,aAAA,CAACtB,OAAA,CAAAG,OAAM;IACHuB,OAAO,EAAEX,iBAAkB;IAC3BL,UAAU,EAAEA,UAAW;IACvBC,gCAAgC,EAAEA;EAAiC,GAElEF,QACG,CACQ,CACM,CAAC;AAEvC,CAAC;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAzB,OAAA,GAEaC,aAAa","ignoreList":[]}
@@ -15,6 +15,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
15
15
  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); }
16
16
  const SharingContextMenu = /*#__PURE__*/(0, _react.forwardRef)(({
17
17
  link,
18
+ text,
18
19
  children,
19
20
  shouldEnableKeyboardHighlighting,
20
21
  shouldShowCallingCodeAction = true,
@@ -22,6 +23,21 @@ const SharingContextMenu = /*#__PURE__*/(0, _react.forwardRef)(({
22
23
  ...contextMenuProps
23
24
  }, ref) => {
24
25
  const isTouch = (0, _environment.useIsTouch)();
26
+ const shareInApp = (0, _react.useCallback)((provider, shareText) => {
27
+ if (!provider) {
28
+ throw new Error('The requested sharing provider is not configured.');
29
+ }
30
+ void (0, _chaynsApi.invokeCall)({
31
+ action: 80,
32
+ value: {
33
+ text: shareText,
34
+ sharingApp: provider.providerId,
35
+ ...(provider.androidIdentifier ? {
36
+ sharingAndroidApp: provider.androidIdentifier
37
+ } : {})
38
+ }
39
+ });
40
+ }, []);
25
41
  const handleImageDownload = (0, _react.useCallback)(() => {
26
42
  (0, _sharingBar2.shareWithUrl)(
27
43
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -31,31 +47,48 @@ const SharingContextMenu = /*#__PURE__*/(0, _react.forwardRef)(({
31
47
  const handleShare = (0, _react.useCallback)(key => {
32
48
  switch (key) {
33
49
  case 'whatsapp':
34
- (0, _sharingBar2.shareWithUrl)(
35
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
- // @ts-ignore
37
- _sharingBar.SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(`${link}`.trim())));
38
- break;
50
+ {
51
+ const shareText = text ? `${text}\n\n${link}` : `${link}`.trim();
52
+ if ((0, _chaynsApi.isApp)()) {
53
+ shareInApp(_sharingBar.SHAREPROVIDER[0], shareText);
54
+ break;
55
+ }
56
+ (0, _sharingBar2.shareWithUrl)(
57
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
58
+ // @ts-ignore
59
+ _sharingBar.SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(shareText)));
60
+ break;
61
+ }
39
62
  case 'facebook':
63
+ if ((0, _chaynsApi.isApp)()) {
64
+ shareInApp(_sharingBar.SHAREPROVIDER[3], `${link}`.trim());
65
+ break;
66
+ }
40
67
  (0, _sharingBar2.shareWithUrl)(
41
68
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
69
  // @ts-ignore
43
70
  _sharingBar.SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)));
44
71
  break;
45
72
  case 'twitter':
73
+ if ((0, _chaynsApi.isApp)()) {
74
+ shareInApp(_sharingBar.SHAREPROVIDER[4], text ? `${text}\n\n${link}` : `${link}`.trim());
75
+ break;
76
+ }
46
77
  (0, _sharingBar2.shareWithUrl)(
47
78
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
48
79
  // @ts-ignore
49
- _sharingBar.SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', ''));
80
+ _sharingBar.SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', encodeURIComponent(text ?? '')));
50
81
  break;
51
82
  case 'mail':
52
- if (isTouch) {
53
- (0, _sharingBar2.shareWithApp)(`${link}`.trim());
83
+ if ((0, _chaynsApi.isApp)()) {
84
+ shareInApp(_sharingBar.SHAREPROVIDER[2], text ? `${text}\n\n${link}` : `${link}`.trim());
85
+ } else if (isTouch) {
86
+ (0, _sharingBar2.shareWithApp)(text ? `${text}\n\n${link}` : `${link}`.trim());
54
87
  } else {
55
88
  (0, _sharingBar2.shareWithUrl)(
56
89
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
90
  // @ts-ignore
58
- _sharingBar.SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(`${link}`.trim())));
91
+ _sharingBar.SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(text ? `${text}\n\n${link}` : `${link}`.trim())));
59
92
  }
60
93
  break;
61
94
  case 'copy':
@@ -64,7 +97,7 @@ const SharingContextMenu = /*#__PURE__*/(0, _react.forwardRef)(({
64
97
  default:
65
98
  break;
66
99
  }
67
- }, [link, isTouch]);
100
+ }, [link, text, isTouch, shareInApp]);
68
101
  const contextMenuItems = [...(shouldShowCopyAction ? [{
69
102
  icons: ['fa fa-copy'],
70
103
  key: 'copy',
@@ -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","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","useIsTouch","handleImageDownload","useCallback","shareWithUrl","SHAREPROVIDER","url","replace","encodeURIComponent","getSite","color","handleShare","key","trim","shareWithApp","copyToClipboard","contextMenuItems","icons","onClick","text","createElement","items","displayName","_default","exports"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.tsx"],"sourcesContent":["import { getSite } from 'chayns-api';\nimport React, { forwardRef, useCallback } from 'react';\nimport { SHAREPROVIDER } from '../../constants/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 * 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 children,\n shouldEnableKeyboardHighlighting,\n shouldShowCallingCodeAction = true,\n shouldShowCopyAction = true,\n ...contextMenuProps\n },\n ref,\n ) => {\n const isTouch = useIsTouch();\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 shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[0].url.replace(\n '{url}',\n encodeURIComponent(`${link}`.trim()),\n ),\n );\n break;\n case 'facebook':\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 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}', ''),\n );\n break;\n case 'mail':\n if (isTouch) {\n shareWithApp(`${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(`${link}`.trim()),\n ),\n );\n }\n break;\n case 'copy':\n copyToClipboard(link);\n break;\n default:\n break;\n }\n },\n [link, 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,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,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,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CA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E,CAAC,cAAc,CAAC;IACvBL,GAAG,EAAE,aAAa;IAClBM,OAAO,EAAEhB,mBAAmB;IAC5BiB,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,CACZ;EAED,oBACI5D,MAAA,CAAAS,OAAA,CAAAoD,aAAA,CAACxD,YAAA,CAAAI,OAAW,EAAAiB,QAAA;IACRoC,KAAK,EAAEL,gBAAiB;IACxBjB,GAAG,EAAEA,GAAI;IACTJ,gCAAgC,EAAEA;IAClC;EAAA,GACIG,gBAAgB,GAEnBJ,QACQ,CAAC;AAEtB,CACJ,CAAC;AAEDH,kBAAkB,CAAC+B,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxD,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","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,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,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zBN,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":[]}
@@ -5,10 +5,28 @@ var _react2 = _interopRequireDefault(require("react"));
5
5
  var _vitest = require("vitest");
6
6
  var _SharingContextMenu = _interopRequireDefault(require("./SharingContextMenu"));
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ const {
9
+ invokeCall,
10
+ isApp,
11
+ shareWithApp,
12
+ shareWithUrl
13
+ } = _vitest.vi.hoisted(() => ({
14
+ invokeCall: _vitest.vi.fn(),
15
+ isApp: _vitest.vi.fn(() => false),
16
+ shareWithApp: _vitest.vi.fn(),
17
+ shareWithUrl: _vitest.vi.fn()
18
+ }));
8
19
  _vitest.vi.mock('chayns-api', () => ({
9
20
  getSite: () => ({
10
21
  color: '#000000'
11
- })
22
+ }),
23
+ invokeCall,
24
+ isApp
25
+ }));
26
+ _vitest.vi.mock('../../utils/sharingBar', () => ({
27
+ copyToClipboard: _vitest.vi.fn(),
28
+ shareWithApp,
29
+ shareWithUrl
12
30
  }));
13
31
  _vitest.vi.mock('../../utils/environment', () => ({
14
32
  useIsTouch: () => false
@@ -19,9 +37,95 @@ _vitest.vi.mock('../context-menu/ContextMenu', () => ({
19
37
  items
20
38
  }) => /*#__PURE__*/_react2.default.createElement("div", {
21
39
  "data-item-keys": items.map(item => item.key).join(',')
22
- }, children)
40
+ }, items.map(item => /*#__PURE__*/_react2.default.createElement("button", {
41
+ key: item.key,
42
+ type: "button",
43
+ onClick: item.onClick
44
+ }, item.key)), children)
23
45
  }));
24
46
  (0, _vitest.describe)('SharingContextMenu', () => {
47
+ (0, _vitest.beforeEach)(() => {
48
+ _vitest.vi.clearAllMocks();
49
+ isApp.mockReturnValue(false);
50
+ });
51
+ (0, _vitest.it)('uses the native share call in the app', () => {
52
+ isApp.mockReturnValue(true);
53
+ const {
54
+ getByRole
55
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SharingContextMenu.default, {
56
+ link: "https://example.com",
57
+ text: "Check this out"
58
+ }, /*#__PURE__*/_react2.default.createElement("button", {
59
+ type: "button"
60
+ }, "Share")));
61
+ _react.fireEvent.click(getByRole('button', {
62
+ name: 'whatsapp'
63
+ }));
64
+ _react.fireEvent.click(getByRole('button', {
65
+ name: 'facebook'
66
+ }));
67
+ _react.fireEvent.click(getByRole('button', {
68
+ name: 'twitter'
69
+ }));
70
+ _react.fireEvent.click(getByRole('button', {
71
+ name: 'mail'
72
+ }));
73
+ (0, _vitest.expect)(invokeCall).toHaveBeenNthCalledWith(1, {
74
+ action: 80,
75
+ value: {
76
+ text: 'Check this out\n\nhttps://example.com',
77
+ sharingApp: 1,
78
+ sharingAndroidApp: 'com.whatsapp'
79
+ }
80
+ });
81
+ (0, _vitest.expect)(invokeCall).toHaveBeenNthCalledWith(2, {
82
+ action: 80,
83
+ value: {
84
+ text: 'https://example.com',
85
+ sharingApp: 2,
86
+ sharingAndroidApp: 'com.facebook.katana'
87
+ }
88
+ });
89
+ (0, _vitest.expect)(invokeCall).toHaveBeenNthCalledWith(3, {
90
+ action: 80,
91
+ value: {
92
+ text: 'Check this out\n\nhttps://example.com',
93
+ sharingApp: 5
94
+ }
95
+ });
96
+ (0, _vitest.expect)(invokeCall).toHaveBeenNthCalledWith(4, {
97
+ action: 80,
98
+ value: {
99
+ text: 'Check this out\n\nhttps://example.com',
100
+ sharingApp: 0
101
+ }
102
+ });
103
+ (0, _vitest.expect)(shareWithApp).not.toHaveBeenCalled();
104
+ (0, _vitest.expect)(shareWithUrl).not.toHaveBeenCalled();
105
+ });
106
+ (0, _vitest.it)('shares the optional text via WhatsApp, mail, and X only', () => {
107
+ const {
108
+ getByRole
109
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SharingContextMenu.default, {
110
+ link: "https://example.com",
111
+ text: "Check this out"
112
+ }, /*#__PURE__*/_react2.default.createElement("button", {
113
+ type: "button"
114
+ }, "Share")));
115
+ _react.fireEvent.click(getByRole('button', {
116
+ name: 'whatsapp'
117
+ }));
118
+ _react.fireEvent.click(getByRole('button', {
119
+ name: 'mail'
120
+ }));
121
+ _react.fireEvent.click(getByRole('button', {
122
+ name: 'twitter'
123
+ }));
124
+ (0, _vitest.expect)(shareWithUrl).toHaveBeenNthCalledWith(1, 'https://api.whatsapp.com/send?text=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com');
125
+ (0, _vitest.expect)(shareWithUrl).toHaveBeenNthCalledWith(2, 'mailto:?body=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com');
126
+ (0, _vitest.expect)(shareWithUrl).toHaveBeenNthCalledWith(3, 'http://twitter.com/intent/tweet?text=Check%20this%20out&url=https%3A%2F%2Fexample.com&hashtags=chayns');
127
+ (0, _vitest.expect)(shareWithApp).not.toHaveBeenCalled();
128
+ });
25
129
  (0, _vitest.it)('keeps copy and calling-code actions enabled by default', () => {
26
130
  const {
27
131
  container
@@ -1 +1 @@
1
- {"version":3,"file":"SharingContextMenu.test.js","names":["_react","require","_react2","_interopRequireDefault","_vitest","_SharingContextMenu","e","__esModule","default","vi","mock","getSite","color","useIsTouch","children","items","createElement","map","item","key","join","describe","it","container","render","link","type","expect","firstChild","getAttribute","toBe","shouldShowCallingCodeAction","shouldShowCopyAction"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.test.tsx"],"sourcesContent":["import { render } from '@testing-library/react';\nimport React, { ReactNode } from 'react';\nimport { describe, expect, it, vi } from 'vitest';\nimport SharingContextMenu from './SharingContextMenu';\n\nvi.mock('chayns-api', () => ({\n getSite: () => ({ color: '#000000' }),\n}));\n\nvi.mock('../../utils/environment', () => ({\n useIsTouch: () => false,\n}));\n\nvi.mock('../context-menu/ContextMenu', () => ({\n default: ({ children, items }: { children: ReactNode; items: Array<{ key: string }> }) => (\n <div data-item-keys={items.map((item) => item.key).join(',')}>{children}</div>\n ),\n}));\n\ndescribe('SharingContextMenu', () => {\n it('keeps copy and calling-code actions enabled by default', () => {\n const { container } = render(\n <SharingContextMenu link=\"https://example.com\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'copy,whatsapp,facebook,twitter,mail,callingCode',\n );\n });\n\n it('can hide copy and calling-code actions for dedicated content actions', () => {\n const { container } = render(\n <SharingContextMenu\n link=\"https://example.com\"\n shouldShowCallingCodeAction={false}\n shouldShowCopyAction={false}\n >\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'whatsapp,facebook,twitter,mail',\n );\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAsD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,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,qBAAqB;MAC1BM,2BAA2B,EAAE,KAAM;MACnCC,oBAAoB,EAAE;IAAM,gBAE5B9B,OAAA,CAAAM,OAAA,CAAAQ,aAAA;MAAQU,IAAI,EAAC;IAAQ,GAAC,OAAa,CACnB,CACxB,CAAC;IAED,IAAAC,cAAM,EAAEJ,SAAS,CAACK,UAAU,CAAiBC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAC7E,gCACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SharingContextMenu.test.js","names":["_react","require","_react2","_interopRequireDefault","_vitest","_SharingContextMenu","e","__esModule","default","invokeCall","isApp","shareWithApp","shareWithUrl","vi","hoisted","fn","mock","getSite","color","copyToClipboard","useIsTouch","children","items","createElement","map","item","key","join","type","onClick","describe","beforeEach","clearAllMocks","mockReturnValue","it","getByRole","render","link","text","fireEvent","click","name","expect","toHaveBeenNthCalledWith","action","value","sharingApp","sharingAndroidApp","not","toHaveBeenCalled","container","firstChild","getAttribute","toBe","shouldShowCallingCodeAction","shouldShowCopyAction"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.test.tsx"],"sourcesContent":["import { fireEvent, render } from '@testing-library/react';\nimport React, { ReactNode } from 'react';\nimport { beforeEach, describe, expect, it, vi } from 'vitest';\nimport SharingContextMenu from './SharingContextMenu';\n\nconst { invokeCall, isApp, shareWithApp, shareWithUrl } = vi.hoisted(() => ({\n invokeCall: vi.fn(),\n isApp: vi.fn(() => false),\n shareWithApp: vi.fn(),\n shareWithUrl: vi.fn(),\n}));\n\nvi.mock('chayns-api', () => ({\n getSite: () => ({ color: '#000000' }),\n invokeCall,\n isApp,\n}));\n\nvi.mock('../../utils/sharingBar', () => ({\n copyToClipboard: vi.fn(),\n shareWithApp,\n shareWithUrl,\n}));\n\nvi.mock('../../utils/environment', () => ({\n useIsTouch: () => false,\n}));\n\nvi.mock('../context-menu/ContextMenu', () => ({\n default: ({\n children,\n items,\n }: {\n children: ReactNode;\n items: Array<{ key: string; onClick: VoidFunction }>;\n }) => (\n <div data-item-keys={items.map((item) => item.key).join(',')}>\n {items.map((item) => (\n <button key={item.key} type=\"button\" onClick={item.onClick}>\n {item.key}\n </button>\n ))}\n {children}\n </div>\n ),\n}));\n\ndescribe('SharingContextMenu', () => {\n beforeEach(() => {\n vi.clearAllMocks();\n isApp.mockReturnValue(false);\n });\n\n it('uses the native share call in the app', () => {\n isApp.mockReturnValue(true);\n\n const { getByRole } = render(\n <SharingContextMenu link=\"https://example.com\" text=\"Check this out\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n fireEvent.click(getByRole('button', { name: 'whatsapp' }));\n fireEvent.click(getByRole('button', { name: 'facebook' }));\n fireEvent.click(getByRole('button', { name: 'twitter' }));\n fireEvent.click(getByRole('button', { name: 'mail' }));\n\n expect(invokeCall).toHaveBeenNthCalledWith(1, {\n action: 80,\n value: {\n text: 'Check this out\\n\\nhttps://example.com',\n sharingApp: 1,\n sharingAndroidApp: 'com.whatsapp',\n },\n });\n expect(invokeCall).toHaveBeenNthCalledWith(2, {\n action: 80,\n value: {\n text: 'https://example.com',\n sharingApp: 2,\n sharingAndroidApp: 'com.facebook.katana',\n },\n });\n expect(invokeCall).toHaveBeenNthCalledWith(3, {\n action: 80,\n value: {\n text: 'Check this out\\n\\nhttps://example.com',\n sharingApp: 5,\n },\n });\n expect(invokeCall).toHaveBeenNthCalledWith(4, {\n action: 80,\n value: {\n text: 'Check this out\\n\\nhttps://example.com',\n sharingApp: 0,\n },\n });\n expect(shareWithApp).not.toHaveBeenCalled();\n expect(shareWithUrl).not.toHaveBeenCalled();\n });\n\n it('shares the optional text via WhatsApp, mail, and X only', () => {\n const { getByRole } = render(\n <SharingContextMenu link=\"https://example.com\" text=\"Check this out\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n fireEvent.click(getByRole('button', { name: 'whatsapp' }));\n fireEvent.click(getByRole('button', { name: 'mail' }));\n fireEvent.click(getByRole('button', { name: 'twitter' }));\n\n expect(shareWithUrl).toHaveBeenNthCalledWith(\n 1,\n 'https://api.whatsapp.com/send?text=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com',\n );\n expect(shareWithUrl).toHaveBeenNthCalledWith(\n 2,\n 'mailto:?body=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com',\n );\n expect(shareWithUrl).toHaveBeenNthCalledWith(\n 3,\n 'http://twitter.com/intent/tweet?text=Check%20this%20out&url=https%3A%2F%2Fexample.com&hashtags=chayns',\n );\n expect(shareWithApp).not.toHaveBeenCalled();\n });\n\n it('keeps copy and calling-code actions enabled by default', () => {\n const { container } = render(\n <SharingContextMenu link=\"https://example.com\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'copy,whatsapp,facebook,twitter,mail,callingCode',\n );\n });\n\n it('can hide copy and calling-code actions for dedicated content actions', () => {\n const { container } = render(\n <SharingContextMenu\n link=\"https://example.com\"\n shouldShowCallingCodeAction={false}\n shouldShowCopyAction={false}\n >\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'whatsapp,facebook,twitter,mail',\n );\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAsD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD,MAAM;EAAEG,UAAU;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAa,CAAC,GAAGC,UAAE,CAACC,OAAO,CAAC,OAAO;EACxEL,UAAU,EAAEI,U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,CAAC,CAACC,IAAI,CAC7E,gCACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -8,6 +8,7 @@ import SharingContextMenu from '../sharing-context-menu/SharingContextMenu';
8
8
  const SharingBar = ({
9
9
  label,
10
10
  link,
11
+ text,
11
12
  popupAlignment,
12
13
  container,
13
14
  shouldEnableKeyboardHighlighting
@@ -56,6 +57,7 @@ const SharingBar = ({
56
57
  icons: ['fa fa-share-nodes']
57
58
  })), /*#__PURE__*/React.createElement(SharingContextMenu, {
58
59
  link: link,
60
+ text: text,
59
61
  ref: contextMenuRef,
60
62
  alignment: popupAlignment,
61
63
  container: container,
@@ -1 +1 @@
1
- {"version":3,"file":"SharingBar.js","names":["React","useCallback","useRef","useFocusRingPortal","useKeyboardFocusHighlighting","useColorScheme","Icon","StyledSharingBar","StyledSharingBarIconWrapper","StyledSharingBarText","SharingContextMenu","SharingBar","label","link","popupAlignment","container","shouldEnableKeyboardHighlighting","colorScheme","shouldEnableKeyboardHighlightingEffective","contextMenuRef","sharingBarRef","shouldShowKeyboardHighlighting","isEnabled","showContextMenu","current","show","handleSharingBarClick","event","preventDefault","stopPropagation","handleKeyDown","currentTarget","target","key","hide","createElement","ref","onClick","onKeyDown","undefined","tabIndex","role","icons","alignment","shouldDisableClick","displayName"],"sources":["../../../../src/components/sharing-bar/SharingBar.tsx"],"sourcesContent":["import React, { FC, KeyboardEventHandler, MouseEventHandler, useCallback, useRef } from 'react';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledSharingBar,\n StyledSharingBarIconWrapper,\n StyledSharingBarText,\n} from './SharingBar.styles';\nimport type { ContextMenuAlignment } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu from '../sharing-context-menu/SharingContextMenu';\n\nexport type SharingBarProps = {\n /**\n * The element where the content of the `SharingBar` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The label that should be displayed.\n */\n label: string;\n /**\n * The link that should be shared.\n */\n link: string;\n /**\n * The alignment of the sharing options.\n */\n popupAlignment: ContextMenuAlignment;\n /**\n * Enables keyboard-only focus highlighting and keyboard interaction.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst SharingBar: FC<SharingBarProps> = ({\n label,\n link,\n popupAlignment,\n container,\n shouldEnableKeyboardHighlighting,\n}) => {\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const contextMenuRef = useRef<{ hide: VoidFunction; show: VoidFunction }>(null);\n const sharingBarRef = useRef<HTMLDivElement>(null);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n useFocusRingPortal(sharingBarRef, { isEnabled: shouldShowKeyboardHighlighting });\n\n const showContextMenu = useCallback(() => {\n contextMenuRef.current?.show();\n }, []);\n\n const handleSharingBarClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n showContextMenu();\n },\n [showContextMenu],\n );\n\n const handleKeyDown = useCallback<KeyboardEventHandler<HTMLDivElement>>(\n (event) => {\n if (event.currentTarget !== event.target) {\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.hide();\n return;\n }\n\n if (event.key !== 'Enter' && event.key !== ' ') {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n showContextMenu();\n },\n [showContextMenu],\n );\n\n return (\n <StyledSharingBar\n ref={sharingBarRef}\n onClick={handleSharingBarClick}\n onKeyDown={shouldEnableKeyboardHighlightingEffective ? handleKeyDown : undefined}\n tabIndex={shouldEnableKeyboardHighlightingEffective ? 0 : undefined}\n role={shouldEnableKeyboardHighlightingEffective ? 'button' : undefined}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n >\n <StyledSharingBarIconWrapper>\n <Icon icons={['fa fa-share-nodes']} />\n </StyledSharingBarIconWrapper>\n <SharingContextMenu\n link={link}\n ref={contextMenuRef}\n alignment={popupAlignment}\n container={container}\n shouldDisableClick\n >\n {null}\n </SharingContextMenu>\n <StyledSharingBarText>{label}</StyledSharingBarText>\n </StyledSharingBar>\n );\n};\n\nSharingBar.displayName = 'SharingBar';\n\nexport default SharingBar;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAiDC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAC/F,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,4BAA4B,QAAQ,0CAA0C;AACvF,SAASC,cAAc,QAAQ,8CAA8C;AAC7E,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,gBAAgB,EAChBC,2BAA2B,EAC3BC,oBAAoB,QACjB,qBAAqB;AAE5B,OAAOC,kBAAkB,MAAM,4CAA4C;AAyB3E,MAAMC,UAA+B,GAAGA,CAAC;EACrCC,KAAK;EACLC,IAAI;EACJC,cAAc;EACdC,SAAS;EACTC;AACJ,CAAC,KAAK;EACF,MAAMC,WAAW,GAAGZ,cAAc,CAAC,CAAC;EACpC,MAAMa,yCAAyC,GAC3CF,gCAAgC,IAAIC,WAAW,EAAED,gCAAgC,IAAI,KAAK;EAE9F,MAAMG,cAAc,GAAGjB,MAAM,CAA6C,IAAI,CAAC;EAC/E,MAAMkB,aAAa,GAAGlB,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMmB,8BAA8B,GAAGjB,4BAA4B,CAC/Dc,yCACJ,CAAC;EACDf,kBAAkB,CAACiB,aAAa,EAAE;IAAEE,SAAS,EAAED;EAA+B,CAAC,CAAC;EAEhF,MAAME,eAAe,GAAGtB,WAAW,CAAC,MAAM;IACtCkB,cAAc,CAACK,OAAO,EAAEC,IAAI,CAAC,CA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AAC,mBAAmB;EAAE,CAAE,CACZ,CAAC,eAC9B1C,KAAA,CAAAmC,aAAA,CAACzB,kBAAkB;IACfG,IAAI,EAAEA,IAAK;IACXuB,GAAG,EAAEjB,cAAe;IACpBwB,SAAS,EAAE7B,cAAe;IAC1BC,SAAS,EAAEA,SAAU;IACrB6B,kBAAkB;EAAA,GAEjB,IACe,CAAC,eACrB5C,KAAA,CAAAmC,aAAA,CAAC1B,oBAAoB,QAAEG,KAA4B,CACrC,CAAC;AAE3B,CAAC;AAEDD,UAAU,CAACkC,WAAW,GAAG,YAAY;AAErC,eAAelC,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"SharingBar.js","names":["React","useCallback","useRef","useFocusRingPortal","useKeyboardFocusHighlighting","useColorScheme","Icon","StyledSharingBar","StyledSharingBarIconWrapper","StyledSharingBarText","SharingContextMenu","SharingBar","label","link","text","popupAlignment","container","shouldEnableKeyboardHighlighting","colorScheme","shouldEnableKeyboardHighlightingEffective","contextMenuRef","sharingBarRef","shouldShowKeyboardHighlighting","isEnabled","showContextMenu","current","show","handleSharingBarClick","event","preventDefault","stopPropagation","handleKeyDown","currentTarget","target","key","hide","createElement","ref","onClick","onKeyDown","undefined","tabIndex","role","icons","alignment","shouldDisableClick","displayName"],"sources":["../../../../src/components/sharing-bar/SharingBar.tsx"],"sourcesContent":["import React, { FC, KeyboardEventHandler, MouseEventHandler, useCallback, useRef } from 'react';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledSharingBar,\n StyledSharingBarIconWrapper,\n StyledSharingBarText,\n} from './SharingBar.styles';\nimport type { ContextMenuAlignment } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu from '../sharing-context-menu/SharingContextMenu';\n\nexport type SharingBarProps = {\n /**\n * The element where the content of the `SharingBar` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The label that should be displayed.\n */\n label: string;\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 * The alignment of the sharing options.\n */\n popupAlignment: ContextMenuAlignment;\n /**\n * Enables keyboard-only focus highlighting and keyboard interaction.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst SharingBar: FC<SharingBarProps> = ({\n label,\n link,\n text,\n popupAlignment,\n container,\n shouldEnableKeyboardHighlighting,\n}) => {\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const contextMenuRef = useRef<{ hide: VoidFunction; show: VoidFunction }>(null);\n const sharingBarRef = useRef<HTMLDivElement>(null);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n useFocusRingPortal(sharingBarRef, { isEnabled: shouldShowKeyboardHighlighting });\n\n const showContextMenu = useCallback(() => {\n contextMenuRef.current?.show();\n }, []);\n\n const handleSharingBarClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n showContextMenu();\n },\n [showContextMenu],\n );\n\n const handleKeyDown = useCallback<KeyboardEventHandler<HTMLDivElement>>(\n (event) => {\n if (event.currentTarget !== event.target) {\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.hide();\n return;\n }\n\n if (event.key !== 'Enter' && event.key !== ' ') {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n showContextMenu();\n },\n [showContextMenu],\n );\n\n return (\n <StyledSharingBar\n ref={sharingBarRef}\n onClick={handleSharingBarClick}\n onKeyDown={shouldEnableKeyboardHighlightingEffective ? handleKeyDown : undefined}\n tabIndex={shouldEnableKeyboardHighlightingEffective ? 0 : undefined}\n role={shouldEnableKeyboardHighlightingEffective ? 'button' : undefined}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n >\n <StyledSharingBarIconWrapper>\n <Icon icons={['fa fa-share-nodes']} />\n </StyledSharingBarIconWrapper>\n <SharingContextMenu\n link={link}\n text={text}\n ref={contextMenuRef}\n alignment={popupAlignment}\n container={container}\n shouldDisableClick\n >\n {null}\n </SharingContextMenu>\n <StyledSharingBarText>{label}</StyledSharingBarText>\n </StyledSharingBar>\n );\n};\n\nSharingBar.displayName = 'SharingBar';\n\nexport default SharingBar;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAiDC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAC/F,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,4BAA4B,QAAQ,0CAA0C;AACvF,SAASC,cAAc,QAAQ,8CAA8C;AAC7E,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,gBAAgB,EAChBC,2BAA2B,EAC3BC,oBAAoB,QACjB,qBAAqB;AAE5B,OAAOC,kBAAkB,MAAM,4CAA4C;AA6B3E,MAAMC,UAA+B,GAAGA,CAAC;EACrCC,KAAK;EACLC,IAAI;EACJC,IAAI;EACJC,cAAc;EACdC,SAAS;EACTC;AACJ,CAAC,KAAK;EACF,MAAMC,WAAW,GAAGb,cAAc,CAAC,CAAC;EACpC,MAAMc,yCAAyC,GAC3CF,gCAAgC,IAAIC,WAAW,EAAED,gCAAgC,IAAI,KAAK;EAE9F,MAAMG,cAAc,GAAGlB,MAAM,CAA6C,IAAI,CAAC;EAC/E,MAAMmB,aAAa,GAAGnB,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMoB,8BAA8B,GAAGlB,4BAA4B,CAC/De,yCACJ,CAAC;EACDhB,kBAAkB,CAACkB,aAAa,EAAE;IAAEE,SAAS,EAAED;EAA+B,CAAC,CAAC;EAEhF,MAAME,eAAe,GAAGvB,WAAW,CAAC,MAAM;IACtCmB,cA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A,CAAC9B,IAAI;IAACqC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACZ,CAAC,eAC9B3C,KAAA,CAAAoC,aAAA,CAAC1B,kBAAkB;IACfG,IAAI,EAAEA,IAAK;IACXC,IAAI,EAAEA,IAAK;IACXuB,GAAG,EAAEjB,cAAe;IACpBwB,SAAS,EAAE7B,cAAe;IAC1BC,SAAS,EAAEA,SAAU;IACrB6B,kBAAkB;EAAA,GAEjB,IACe,CAAC,eACrB7C,KAAA,CAAAoC,aAAA,CAAC3B,oBAAoB,QAAEG,KAA4B,CACrC,CAAC;AAE3B,CAAC;AAEDD,UAAU,CAACmC,WAAW,GAAG,YAAY;AAErC,eAAenC,UAAU","ignoreList":[]}
@@ -4,6 +4,7 @@ import { StyledSharingButtonContainer } from './SharingButton.styles';
4
4
  import Button from '../button/Button';
5
5
  const SharingButton = ({
6
6
  link,
7
+ text,
7
8
  alignment,
8
9
  container,
9
10
  children,
@@ -18,6 +19,7 @@ const SharingButton = ({
18
19
  };
19
20
  return /*#__PURE__*/React.createElement(StyledSharingButtonContainer, null, /*#__PURE__*/React.createElement(SharingContextMenu, {
20
21
  link: link,
22
+ text: text,
21
23
  alignment: alignment,
22
24
  container: container,
23
25
  ref: contextMenuRef,
@@ -1 +1 @@
1
- {"version":3,"file":"SharingButton.js","names":["React","SharingContextMenu","StyledSharingButtonContainer","Button","SharingButton","link","alignment","container","children","isDisabled","shouldEnableKeyboardHighlighting","contextMenuRef","useRef","handleButtonClick","event","preventDefault","stopPropagation","current","show","createElement","ref","shouldDisableClick","onClick"],"sources":["../../../../src/components/sharing-button/SharingButton.tsx"],"sourcesContent":["import React, { FunctionComponent, PropsWithChildren } from 'react';\nimport { ContextMenuRef } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu, {\n SharingContextMenuProps,\n} from '../sharing-context-menu/SharingContextMenu';\nimport { StyledSharingButtonContainer } from './SharingButton.styles';\nimport Button from '../button/Button';\nimport { ButtonProps } from '../button/Button.types';\n\nexport type SharingButtonProps = PropsWithChildren<\n Pick<SharingContextMenuProps, 'link' | 'alignment' | 'container'> &\n Pick<ButtonProps, 'isDisabled' | 'shouldEnableKeyboardHighlighting'>\n>;\n\nconst SharingButton: FunctionComponent<SharingButtonProps> = ({\n link,\n alignment,\n container,\n children,\n isDisabled,\n shouldEnableKeyboardHighlighting,\n}) => {\n const contextMenuRef = React.useRef<ContextMenuRef>(null);\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.show();\n };\n\n return (\n <StyledSharingButtonContainer>\n <SharingContextMenu\n link={link}\n alignment={alignment}\n container={container}\n ref={contextMenuRef}\n shouldDisableClick\n >\n <Button\n onClick={handleButtonClick}\n isDisabled={isDisabled}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n >\n {children}\n </Button>\n </SharingContextMenu>\n </StyledSharingButtonContainer>\n );\n};\n\nexport default SharingButton;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAgD,OAAO;AAEnE,OAAOC,kBAAkB,MAElB,4CAA4C;AACnD,SAASC,4BAA4B,QAAQ,wBAAwB;AACrE,OAAOC,MAAM,MAAM,kBAAkB;AAQrC,MAAMC,aAAoD,GAAGA,CAAC;EAC1DC,IAAI;EACJC,SAAS;EACTC,SAAS;EACTC,QAAQ;EACRC,UAAU;EACVC;AACJ,CAAC,KAAK;EACF,MAAMC,cAAc,GAAGX,KAAK,CAACY,MAAM,CAAiB,IAAI,CAAC;EAEzD,MAAMC,iBAAiB,GAAIC,KAA0C,IAAK;IACtEA,KAAK,CAACC,cAAc,CAAC,CAAC;IACtBD,KAAK,CAACE,eAAe,CAAC,CAAC;IACvBL,cAAc,CAACM,OAAO,EAAEC,IAAI,CAAC,CAAC;EAClC,CAAC;EAED,oBACIlB,KAAA,CAAAmB,aAAA,CAACjB,4BAA4B,qBACzBF,KAAA,CAAAmB,aAAA,CAAClB,kBAAkB;IACfI,IAAI,EAAEA,IAAK;IACXC,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBa,GAAG,EAAET,cAAe;IACpBU,kBAAkB;EAAA,gBAElBrB,KAAA,CAAAmB,aAAA,CAAChB,MAAM;IACHmB,OAAO,EAAET,iBAAkB;IAC3BJ,UAAU,EAAEA,UAAW;IACvBC,gCAAgC,EAAEA;EAAiC,GAElEF,QACG,CACQ,CACM,CAAC;AAEvC,CAAC;AAED,eAAeJ,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"SharingButton.js","names":["React","SharingContextMenu","StyledSharingButtonContainer","Button","SharingButton","link","text","alignment","container","children","isDisabled","shouldEnableKeyboardHighlighting","contextMenuRef","useRef","handleButtonClick","event","preventDefault","stopPropagation","current","show","createElement","ref","shouldDisableClick","onClick"],"sources":["../../../../src/components/sharing-button/SharingButton.tsx"],"sourcesContent":["import React, { FunctionComponent, PropsWithChildren } from 'react';\nimport { ContextMenuRef } from '../context-menu/ContextMenu.types';\nimport SharingContextMenu, {\n SharingContextMenuProps,\n} from '../sharing-context-menu/SharingContextMenu';\nimport { StyledSharingButtonContainer } from './SharingButton.styles';\nimport Button from '../button/Button';\nimport { ButtonProps } from '../button/Button.types';\n\nexport type SharingButtonProps = PropsWithChildren<\n Pick<SharingContextMenuProps, 'link' | 'text' | 'alignment' | 'container'> &\n Pick<ButtonProps, 'isDisabled' | 'shouldEnableKeyboardHighlighting'>\n>;\n\nconst SharingButton: FunctionComponent<SharingButtonProps> = ({\n link,\n text,\n alignment,\n container,\n children,\n isDisabled,\n shouldEnableKeyboardHighlighting,\n}) => {\n const contextMenuRef = React.useRef<ContextMenuRef>(null);\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n contextMenuRef.current?.show();\n };\n\n return (\n <StyledSharingButtonContainer>\n <SharingContextMenu\n link={link}\n text={text}\n alignment={alignment}\n container={container}\n ref={contextMenuRef}\n shouldDisableClick\n >\n <Button\n onClick={handleButtonClick}\n isDisabled={isDisabled}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n >\n {children}\n </Button>\n </SharingContextMenu>\n </StyledSharingButtonContainer>\n );\n};\n\nexport default SharingButton;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAgD,OAAO;AAEnE,OAAOC,kBAAkB,MAElB,4CAA4C;AACnD,SAASC,4BAA4B,QAAQ,wBAAwB;AACrE,OAAOC,MAAM,MAAM,kBAAkB;AAQrC,MAAMC,aAAoD,GAAGA,CAAC;EAC1DC,IAAI;EACJC,IAAI;EACJC,SAAS;EACTC,SAAS;EACTC,QAAQ;EACRC,UAAU;EACVC;AACJ,CAAC,KAAK;EACF,MAAMC,cAAc,GAAGZ,KAAK,CAACa,MAAM,CAAiB,IAAI,CAAC;EAEzD,MAAMC,iBAAiB,GAAIC,KAA0C,IAAK;IACtEA,KAAK,CAACC,cAAc,CAAC,CAAC;IACtBD,KAAK,CAACE,eAAe,CAAC,CAAC;IACvBL,cAAc,CAACM,OAAO,EAAEC,IAAI,CAAC,CAAC;EAClC,CAAC;EAED,oBACInB,KAAA,CAAAoB,aAAA,CAAClB,4BAA4B,qBACzBF,KAAA,CAAAoB,aAAA,CAACnB,kBAAkB;IACfI,IAAI,EAAEA,IAAK;IACXC,IAAI,EAAEA,IAAK;IACXC,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBa,GAAG,EAAET,cAAe;IACpBU,kBAAkB;EAAA,gBAElBtB,KAAA,CAAAoB,aAAA,CAACjB,MAAM;IACHoB,OAAO,EAAET,iBAAkB;IAC3BJ,UAAU,EAAEA,UAAW;IACvBC,gCAAgC,EAAEA;EAAiC,GAElEF,QACG,CACQ,CACM,CAAC;AAEvC,CAAC;AAED,eAAeL,aAAa","ignoreList":[]}
@@ -1,5 +1,5 @@
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 } from 'chayns-api';
2
+ import { getSite, invokeCall, isApp } from 'chayns-api';
3
3
  import React, { forwardRef, useCallback } from 'react';
4
4
  import { SHAREPROVIDER } from '../../constants/sharingBar';
5
5
  import { useIsTouch } from '../../utils/environment';
@@ -7,6 +7,7 @@ import { copyToClipboard, shareWithApp, shareWithUrl } from '../../utils/sharing
7
7
  import ContextMenu from '../context-menu/ContextMenu';
8
8
  const SharingContextMenu = /*#__PURE__*/forwardRef(({
9
9
  link,
10
+ text,
10
11
  children,
11
12
  shouldEnableKeyboardHighlighting,
12
13
  shouldShowCallingCodeAction = true,
@@ -14,6 +15,21 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
14
15
  ...contextMenuProps
15
16
  }, ref) => {
16
17
  const isTouch = useIsTouch();
18
+ const shareInApp = useCallback((provider, shareText) => {
19
+ if (!provider) {
20
+ throw new Error('The requested sharing provider is not configured.');
21
+ }
22
+ void invokeCall({
23
+ action: 80,
24
+ value: {
25
+ text: shareText,
26
+ sharingApp: provider.providerId,
27
+ ...(provider.androidIdentifier ? {
28
+ sharingAndroidApp: provider.androidIdentifier
29
+ } : {})
30
+ }
31
+ });
32
+ }, []);
17
33
  const handleImageDownload = useCallback(() => {
18
34
  shareWithUrl(
19
35
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -23,31 +39,48 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
23
39
  const handleShare = useCallback(key => {
24
40
  switch (key) {
25
41
  case 'whatsapp':
26
- shareWithUrl(
27
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
- // @ts-ignore
29
- SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(`${link}`.trim())));
30
- break;
42
+ {
43
+ const shareText = text ? `${text}\n\n${link}` : `${link}`.trim();
44
+ if (isApp()) {
45
+ shareInApp(SHAREPROVIDER[0], shareText);
46
+ break;
47
+ }
48
+ shareWithUrl(
49
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
+ // @ts-ignore
51
+ SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(shareText)));
52
+ break;
53
+ }
31
54
  case 'facebook':
55
+ if (isApp()) {
56
+ shareInApp(SHAREPROVIDER[3], `${link}`.trim());
57
+ break;
58
+ }
32
59
  shareWithUrl(
33
60
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
61
  // @ts-ignore
35
62
  SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)));
36
63
  break;
37
64
  case 'twitter':
65
+ if (isApp()) {
66
+ shareInApp(SHAREPROVIDER[4], text ? `${text}\n\n${link}` : `${link}`.trim());
67
+ break;
68
+ }
38
69
  shareWithUrl(
39
70
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
71
  // @ts-ignore
41
- SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', ''));
72
+ SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', encodeURIComponent(text ?? '')));
42
73
  break;
43
74
  case 'mail':
44
- if (isTouch) {
45
- shareWithApp(`${link}`.trim());
75
+ if (isApp()) {
76
+ shareInApp(SHAREPROVIDER[2], text ? `${text}\n\n${link}` : `${link}`.trim());
77
+ } else if (isTouch) {
78
+ shareWithApp(text ? `${text}\n\n${link}` : `${link}`.trim());
46
79
  } else {
47
80
  shareWithUrl(
48
81
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
82
  // @ts-ignore
50
- SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(`${link}`.trim())));
83
+ SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(text ? `${text}\n\n${link}` : `${link}`.trim())));
51
84
  }
52
85
  break;
53
86
  case 'copy':
@@ -56,7 +89,7 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
56
89
  default:
57
90
  break;
58
91
  }
59
- }, [link, isTouch]);
92
+ }, [link, text, isTouch, shareInApp]);
60
93
  const contextMenuItems = [...(shouldShowCopyAction ? [{
61
94
  icons: ['fa fa-copy'],
62
95
  key: 'copy',
@@ -1 +1 @@
1
- {"version":3,"file":"SharingContextMenu.js","names":["getSite","React","forwardRef","useCallback","SHAREPROVIDER","useIsTouch","copyToClipboard","shareWithApp","shareWithUrl","ContextMenu","SharingContextMenu","link","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","handleImageDownload","url","replace","encodeURIComponent","color","handleShare","key","trim","contextMenuItems","icons","onClick","text","createElement","_extends","items","displayName"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.tsx"],"sourcesContent":["import { getSite } from 'chayns-api';\nimport React, { forwardRef, useCallback } from 'react';\nimport { SHAREPROVIDER } from '../../constants/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 * 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 children,\n shouldEnableKeyboardHighlighting,\n shouldShowCallingCodeAction = true,\n shouldShowCopyAction = true,\n ...contextMenuProps\n },\n ref,\n ) => {\n const isTouch = useIsTouch();\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 shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[0].url.replace(\n '{url}',\n encodeURIComponent(`${link}`.trim()),\n ),\n );\n break;\n case 'facebook':\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 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}', ''),\n );\n break;\n case 'mail':\n if (isTouch) {\n shareWithApp(`${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(`${link}`.trim()),\n ),\n );\n }\n break;\n case 'copy':\n copyToClipboard(link);\n break;\n default:\n break;\n }\n },\n [link, 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,QAAQ,YAAY;AACpC,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,QAAQ,OAAO;AACtD,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,eAAe,EAAEC,YAAY,EAAEC,YAAY,QAAQ,wBAAwB;AACpF,OAAOC,WAAW,MAAM,6BAA6B;AAsBrD,MAAMC,kBAAkB,gBAAGR,UAAU,CACjC,CACI;EACIS,IAAI;EACJC,QAAQ;EACRC,gCAAgC;EAChCC,2BAA2B,GAAG,IAAI;EAClCC,oBAAoB,GAAG,IAAI;EAC3B,GAAGC;AACP,CAAC,EACDC,GAAG,KACF;EACD,MAAMC,OAAO,GAAGb,UAAU,CAAC,CAAC;EAE5B,MAAMc,mBAAmB,GAAGhB,WAAW,CAAC,MAAM;IAC1CK,YAAY;IACR;IACA;IACAJ,aAAa,CAAC,CAAC,CAAC,CAACgB,GAAG,CACfC,OAAO,CAAC,OAAO,EAAEC,kBAAkB,CAACX,IAAI,CAAC,CAAC,CAC1CU,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAC/BA,OAAO,CAAC,SAAS,EAAErB,OAAO,CAAC,CAAC,CAACuB,KAAK,CAACF,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAC5D,CAAC;EACL,CAAC,EAAE,CAACV,IAAI,C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AAW,CAAC,MAAM,CAAC;IAClCM,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,EACT;IACIF,KAAK,EAAE,CAAC,gCAAgC,CAAC;IACzCH,GAAG,EAAE,UAAU;IACfI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,UAAU,CAAC;IACtCM,IAAI,EAAE;EACV,CAAC,EACD;IACIF,KAAK,EAAE,CAAC,kCAAkC,CAAC;IAC3CH,GAAG,EAAE,UAAU;IACfI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,UAAU,CAAC;IACtCM,IAAI,EAAE;EACV,CAAC,EACD;IACIF,KAAK,EAAE,CAAC,iCAAiC,CAAC;IAC1CH,GAAG,EAAE,SAAS;IACdI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,SAAS,CAAC;IACrCM,IAAI,EAAE;EACV,CAAC,EACD;IACIF,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzBH,GAAG,EAAE,MAAM;IACXI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,MAAM,CAAC;IAClCM,IAAI,EAAE;EACV,CAAC,EACD,IAAIhB,2BAA2B,GACzB,CACI;IACIc,KAAK,EAAE,CAAC,cAAc,CAAC;IACvBH,GAAG,EAAE,aAAa;IAClBI,OAAO,EAAEV,mBAAmB;IAC5BW,IAAI,EAAE;EACV,CAAC,CACJ,GACD,EAAE,CAAC,CACZ;EAED,oBACI7B,KAAA,CAAA8B,aAAA,CAACtB,WAAW,EAAAuB,QAAA;IACRC,KAAK,EAAEN,gBAAiB;IACxBV,GAAG,EAAEA,GAAI;IACTJ,gCAAgC,EAAEA;IAClC;EAAA,GACIG,gBAAgB,GAEnBJ,QACQ,CAAC;AAEtB,CACJ,CAAC;AAEDF,kBAAkB,CAACwB,WAAW,GAAG,oBAAoB;AAErD,eAAexB,kBAAkB","ignoreList":[]}
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,OAA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E,CAAC,iCAAiC,CAAC;IAC1CH,GAAG,EAAE,SAAS;IACdI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,SAAS,CAAC;IACrCvB,IAAI,EAAE;EACV,CAAC,EACD;IACI2B,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzBH,GAAG,EAAE,MAAM;IACXI,OAAO,EAAEA,CAAA,KAAML,WAAW,CAAC,MAAM,CAAC;IAClCvB,IAAI,EAAE;EACV,CAAC,EACD,IAAIG,2BAA2B,GACzB,CACI;IACIwB,KAAK,EAAE,CAAC,cAAc,CAAC;IACvBH,GAAG,EAAE,aAAa;IAClBI,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,11 +1,29 @@
1
- import { render } from '@testing-library/react';
1
+ import { fireEvent, render } from '@testing-library/react';
2
2
  import React from 'react';
3
- import { describe, expect, it, vi } from 'vitest';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
  import SharingContextMenu from './SharingContextMenu';
5
+ const {
6
+ invokeCall,
7
+ isApp,
8
+ shareWithApp,
9
+ shareWithUrl
10
+ } = vi.hoisted(() => ({
11
+ invokeCall: vi.fn(),
12
+ isApp: vi.fn(() => false),
13
+ shareWithApp: vi.fn(),
14
+ shareWithUrl: vi.fn()
15
+ }));
5
16
  vi.mock('chayns-api', () => ({
6
17
  getSite: () => ({
7
18
  color: '#000000'
8
- })
19
+ }),
20
+ invokeCall,
21
+ isApp
22
+ }));
23
+ vi.mock('../../utils/sharingBar', () => ({
24
+ copyToClipboard: vi.fn(),
25
+ shareWithApp,
26
+ shareWithUrl
9
27
  }));
10
28
  vi.mock('../../utils/environment', () => ({
11
29
  useIsTouch: () => false
@@ -16,9 +34,95 @@ vi.mock('../context-menu/ContextMenu', () => ({
16
34
  items
17
35
  }) => /*#__PURE__*/React.createElement("div", {
18
36
  "data-item-keys": items.map(item => item.key).join(',')
19
- }, children)
37
+ }, items.map(item => /*#__PURE__*/React.createElement("button", {
38
+ key: item.key,
39
+ type: "button",
40
+ onClick: item.onClick
41
+ }, item.key)), children)
20
42
  }));
21
43
  describe('SharingContextMenu', () => {
44
+ beforeEach(() => {
45
+ vi.clearAllMocks();
46
+ isApp.mockReturnValue(false);
47
+ });
48
+ it('uses the native share call in the app', () => {
49
+ isApp.mockReturnValue(true);
50
+ const {
51
+ getByRole
52
+ } = render(/*#__PURE__*/React.createElement(SharingContextMenu, {
53
+ link: "https://example.com",
54
+ text: "Check this out"
55
+ }, /*#__PURE__*/React.createElement("button", {
56
+ type: "button"
57
+ }, "Share")));
58
+ fireEvent.click(getByRole('button', {
59
+ name: 'whatsapp'
60
+ }));
61
+ fireEvent.click(getByRole('button', {
62
+ name: 'facebook'
63
+ }));
64
+ fireEvent.click(getByRole('button', {
65
+ name: 'twitter'
66
+ }));
67
+ fireEvent.click(getByRole('button', {
68
+ name: 'mail'
69
+ }));
70
+ expect(invokeCall).toHaveBeenNthCalledWith(1, {
71
+ action: 80,
72
+ value: {
73
+ text: 'Check this out\n\nhttps://example.com',
74
+ sharingApp: 1,
75
+ sharingAndroidApp: 'com.whatsapp'
76
+ }
77
+ });
78
+ expect(invokeCall).toHaveBeenNthCalledWith(2, {
79
+ action: 80,
80
+ value: {
81
+ text: 'https://example.com',
82
+ sharingApp: 2,
83
+ sharingAndroidApp: 'com.facebook.katana'
84
+ }
85
+ });
86
+ expect(invokeCall).toHaveBeenNthCalledWith(3, {
87
+ action: 80,
88
+ value: {
89
+ text: 'Check this out\n\nhttps://example.com',
90
+ sharingApp: 5
91
+ }
92
+ });
93
+ expect(invokeCall).toHaveBeenNthCalledWith(4, {
94
+ action: 80,
95
+ value: {
96
+ text: 'Check this out\n\nhttps://example.com',
97
+ sharingApp: 0
98
+ }
99
+ });
100
+ expect(shareWithApp).not.toHaveBeenCalled();
101
+ expect(shareWithUrl).not.toHaveBeenCalled();
102
+ });
103
+ it('shares the optional text via WhatsApp, mail, and X only', () => {
104
+ const {
105
+ getByRole
106
+ } = render(/*#__PURE__*/React.createElement(SharingContextMenu, {
107
+ link: "https://example.com",
108
+ text: "Check this out"
109
+ }, /*#__PURE__*/React.createElement("button", {
110
+ type: "button"
111
+ }, "Share")));
112
+ fireEvent.click(getByRole('button', {
113
+ name: 'whatsapp'
114
+ }));
115
+ fireEvent.click(getByRole('button', {
116
+ name: 'mail'
117
+ }));
118
+ fireEvent.click(getByRole('button', {
119
+ name: 'twitter'
120
+ }));
121
+ expect(shareWithUrl).toHaveBeenNthCalledWith(1, 'https://api.whatsapp.com/send?text=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com');
122
+ expect(shareWithUrl).toHaveBeenNthCalledWith(2, 'mailto:?body=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com');
123
+ expect(shareWithUrl).toHaveBeenNthCalledWith(3, 'http://twitter.com/intent/tweet?text=Check%20this%20out&url=https%3A%2F%2Fexample.com&hashtags=chayns');
124
+ expect(shareWithApp).not.toHaveBeenCalled();
125
+ });
22
126
  it('keeps copy and calling-code actions enabled by default', () => {
23
127
  const {
24
128
  container
@@ -1 +1 @@
1
- {"version":3,"file":"SharingContextMenu.test.js","names":["render","React","describe","expect","it","vi","SharingContextMenu","mock","getSite","color","useIsTouch","default","children","items","createElement","map","item","key","join","container","link","type","firstChild","getAttribute","toBe","shouldShowCallingCodeAction","shouldShowCopyAction"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.test.tsx"],"sourcesContent":["import { render } from '@testing-library/react';\nimport React, { ReactNode } from 'react';\nimport { describe, expect, it, vi } from 'vitest';\nimport SharingContextMenu from './SharingContextMenu';\n\nvi.mock('chayns-api', () => ({\n getSite: () => ({ color: '#000000' }),\n}));\n\nvi.mock('../../utils/environment', () => ({\n useIsTouch: () => false,\n}));\n\nvi.mock('../context-menu/ContextMenu', () => ({\n default: ({ children, items }: { children: ReactNode; items: Array<{ key: string }> }) => (\n <div data-item-keys={items.map((item) => item.key).join(',')}>{children}</div>\n ),\n}));\n\ndescribe('SharingContextMenu', () => {\n it('keeps copy and calling-code actions enabled by default', () => {\n const { container } = render(\n <SharingContextMenu link=\"https://example.com\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'copy,whatsapp,facebook,twitter,mail,callingCode',\n );\n });\n\n it('can hide copy and calling-code actions for dedicated content actions', () => {\n const { container } = render(\n <SharingContextMenu\n link=\"https://example.com\"\n shouldShowCallingCodeAction={false}\n shouldShowCopyAction={false}\n >\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'whatsapp,facebook,twitter,mail',\n );\n });\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,OAAOC,KAAK,MAAqB,OAAO;AACxC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACjD,OAAOC,kBAAkB,MAAM,sBAAsB;AAErDD,EAAE,CAACE,IAAI,CAAC,YAAY,EAAE,OAAO;EACzBC,OAAO,EAAEA,CAAA,MAAO;IAAEC,KAAK,EAAE;EAAU,CAAC;AACxC,CAAC,CAAC,CAAC;AAEHJ,EAAE,CAACE,IAAI,CAAC,yBAAyB,EAAE,OAAO;EACtCG,UAAU,EAAEA,CAAA,KAAM;AACtB,CAAC,CAAC,CAAC;AAEHL,EAAE,CAACE,IAAI,CAAC,6BAA6B,EAAE,OAAO;EAC1CI,OAAO,EAAEA,CAAC;IAAEC,QAAQ;IAAEC;EAA8D,CAAC,kBACjFZ,KAAA,CAAAa,aAAA;IAAK,kBAAgBD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,GAAG,CAAC,CAACC,IAAI,CAAC,GAAG;EAAE,GAAEN,QAAc;AAErF,CAAC,CAAC,CAAC;AAEHV,QAAQ,CAAC,oBAAoB,EAAE,MAAM;EACjCE,EAAE,CAAC,wDAAwD,EAAE,MAAM;IAC/D,MAAM;MAAEe;IAAU,CAAC,GAAGnB,MAAM,cACxBC,KAAA,CAAAa,aAAA,CAACR,kBAAkB;MAACc,IAAI,EAAC;IAAqB,gBAC1CnB,KAAA,CAAAa,aAAA;MAAQO,IAAI,EAAC;IAAQ,GAAC,OAAa,CACnB,CACxB,CAAC;IAEDlB,MAAM,CAAEgB,SAAS,CAACG,UAAU,CAAiBC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAC7E,iDACJ,CAAC;EACL,CAAC,CAAC;EAEFpB,EAAE,CAAC,sEAAsE,EAAE,MAAM;IAC7E,MAAM;MAAEe;IAAU,CAAC,GAAGnB,MAAM,cACxBC,KAAA,CAAAa,aAAA,CAACR,kBAAkB;MACfc,IAAI,EAAC,qBAAqB;MAC1BK,2BAA2B,EAAE,KAAM;MACnCC,oBAAoB,EAAE;IAAM,gBAE5BzB,KAAA,CAAAa,aAAA;MAAQO,IAAI,EAAC;IAAQ,GAAC,OAAa,CACnB,CACxB,CAAC;IAEDlB,MAAM,CAAEgB,SAAS,CAACG,UAAU,CAAiBC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAC7E,gCACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SharingContextMenu.test.js","names":["fireEvent","render","React","beforeEach","describe","expect","it","vi","SharingContextMenu","invokeCall","isApp","shareWithApp","shareWithUrl","hoisted","fn","mock","getSite","color","copyToClipboard","useIsTouch","default","children","items","createElement","map","item","key","join","type","onClick","clearAllMocks","mockReturnValue","getByRole","link","text","click","name","toHaveBeenNthCalledWith","action","value","sharingApp","sharingAndroidApp","not","toHaveBeenCalled","container","firstChild","getAttribute","toBe","shouldShowCallingCodeAction","shouldShowCopyAction"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.test.tsx"],"sourcesContent":["import { fireEvent, render } from '@testing-library/react';\nimport React, { ReactNode } from 'react';\nimport { beforeEach, describe, expect, it, vi } from 'vitest';\nimport SharingContextMenu from './SharingContextMenu';\n\nconst { invokeCall, isApp, shareWithApp, shareWithUrl } = vi.hoisted(() => ({\n invokeCall: vi.fn(),\n isApp: vi.fn(() => false),\n shareWithApp: vi.fn(),\n shareWithUrl: vi.fn(),\n}));\n\nvi.mock('chayns-api', () => ({\n getSite: () => ({ color: '#000000' }),\n invokeCall,\n isApp,\n}));\n\nvi.mock('../../utils/sharingBar', () => ({\n copyToClipboard: vi.fn(),\n shareWithApp,\n shareWithUrl,\n}));\n\nvi.mock('../../utils/environment', () => ({\n useIsTouch: () => false,\n}));\n\nvi.mock('../context-menu/ContextMenu', () => ({\n default: ({\n children,\n items,\n }: {\n children: ReactNode;\n items: Array<{ key: string; onClick: VoidFunction }>;\n }) => (\n <div data-item-keys={items.map((item) => item.key).join(',')}>\n {items.map((item) => (\n <button key={item.key} type=\"button\" onClick={item.onClick}>\n {item.key}\n </button>\n ))}\n {children}\n </div>\n ),\n}));\n\ndescribe('SharingContextMenu', () => {\n beforeEach(() => {\n vi.clearAllMocks();\n isApp.mockReturnValue(false);\n });\n\n it('uses the native share call in the app', () => {\n isApp.mockReturnValue(true);\n\n const { getByRole } = render(\n <SharingContextMenu link=\"https://example.com\" text=\"Check this out\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n fireEvent.click(getByRole('button', { name: 'whatsapp' }));\n fireEvent.click(getByRole('button', { name: 'facebook' }));\n fireEvent.click(getByRole('button', { name: 'twitter' }));\n fireEvent.click(getByRole('button', { name: 'mail' }));\n\n expect(invokeCall).toHaveBeenNthCalledWith(1, {\n action: 80,\n value: {\n text: 'Check this out\\n\\nhttps://example.com',\n sharingApp: 1,\n sharingAndroidApp: 'com.whatsapp',\n },\n });\n expect(invokeCall).toHaveBeenNthCalledWith(2, {\n action: 80,\n value: {\n text: 'https://example.com',\n sharingApp: 2,\n sharingAndroidApp: 'com.facebook.katana',\n },\n });\n expect(invokeCall).toHaveBeenNthCalledWith(3, {\n action: 80,\n value: {\n text: 'Check this out\\n\\nhttps://example.com',\n sharingApp: 5,\n },\n });\n expect(invokeCall).toHaveBeenNthCalledWith(4, {\n action: 80,\n value: {\n text: 'Check this out\\n\\nhttps://example.com',\n sharingApp: 0,\n },\n });\n expect(shareWithApp).not.toHaveBeenCalled();\n expect(shareWithUrl).not.toHaveBeenCalled();\n });\n\n it('shares the optional text via WhatsApp, mail, and X only', () => {\n const { getByRole } = render(\n <SharingContextMenu link=\"https://example.com\" text=\"Check this out\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n fireEvent.click(getByRole('button', { name: 'whatsapp' }));\n fireEvent.click(getByRole('button', { name: 'mail' }));\n fireEvent.click(getByRole('button', { name: 'twitter' }));\n\n expect(shareWithUrl).toHaveBeenNthCalledWith(\n 1,\n 'https://api.whatsapp.com/send?text=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com',\n );\n expect(shareWithUrl).toHaveBeenNthCalledWith(\n 2,\n 'mailto:?body=Check%20this%20out%0A%0Ahttps%3A%2F%2Fexample.com',\n );\n expect(shareWithUrl).toHaveBeenNthCalledWith(\n 3,\n 'http://twitter.com/intent/tweet?text=Check%20this%20out&url=https%3A%2F%2Fexample.com&hashtags=chayns',\n );\n expect(shareWithApp).not.toHaveBeenCalled();\n });\n\n it('keeps copy and calling-code actions enabled by default', () => {\n const { container } = render(\n <SharingContextMenu link=\"https://example.com\">\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'copy,whatsapp,facebook,twitter,mail,callingCode',\n );\n });\n\n it('can hide copy and calling-code actions for dedicated content actions', () => {\n const { container } = render(\n <SharingContextMenu\n link=\"https://example.com\"\n shouldShowCallingCodeAction={false}\n shouldShowCopyAction={false}\n >\n <button type=\"button\">Share</button>\n </SharingContextMenu>,\n );\n\n expect((container.firstChild as HTMLElement).getAttribute('data-item-keys')).toBe(\n 'whatsapp,facebook,twitter,mail',\n );\n });\n});\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,wBAAwB;AAC1D,OAAOC,KAAK,MAAqB,OAAO;AACxC,SAASC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAC7D,OAAOC,kBAAkB,MAAM,sBAAsB;AAErD,MAAM;EAAEC,UAAU;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAa,CAAC,GAAGL,EAAE,CAACM,OAAO,CAAC,OAAO;EACxEJ,UAAU,EAAEF,EAAE,CAACO,EAAE,CAAC,CAAC;EACnBJ,KAAK,EAAEH,EAAE,CAACO,EAAE,CAAC,MAAM,KAAK,CAAC;EACzBH,YAAY,EAAEJ,EAAE,CAACO,EAAE,CAAC,CAAC;EACrBF,YAAY,EAAEL,EAAE,CAACO,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC;AAEHP,EAAE,CAACQ,IAAI,CAAC,YAAY,EAAE,OAAO;EACzBC,OAAO,EAAEA,CAAA,MAAO;IAAEC,KAAK,EAAE;EAAU,CAAC,CAAC;EACrCR,UAAU;EACVC;AACJ,CAAC,CAAC,CAAC;AAEHH,EAAE,CAACQ,IAAI,CAAC,wBAAwB,EAAE,OAAO;EACrCG,eAAe,EAAEX,EAAE,CAACO,EAAE,CAAC,CAAC;EACxBH,YAAY;EACZC;AACJ,CAAC,CAAC,CAAC;AAEHL,EAAE,CAAC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C,CAAC;EAEFzC,EAAE,CAAC,sEAAsE,EAAE,MAAM;IAC7E,MAAM;MAAEsC;IAAU,CAAC,GAAG3C,MAAM,cACxBC,KAAA,CAAAqB,aAAA,CAACf,kBAAkB;MACfyB,IAAI,EAAC,qBAAqB;MAC1Be,2BAA2B,EAAE,KAAM;MACnCC,oBAAoB,EAAE;IAAM,gBAE5B/C,KAAA,CAAAqB,aAAA;MAAQK,IAAI,EAAC;IAAQ,GAAC,OAAa,CACnB,CACxB,CAAC;IAEDvB,MAAM,CAAEuC,SAAS,CAACC,UAAU,CAAiBC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAC7E,gCACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -13,6 +13,10 @@ export type SharingBarProps = {
13
13
  * The link that should be shared.
14
14
  */
15
15
  link: string;
16
+ /**
17
+ * Optional text that is shared together with the link via WhatsApp, mail, and X.
18
+ */
19
+ text?: string;
16
20
  /**
17
21
  * The alignment of the sharing options.
18
22
  */
@@ -1,6 +1,6 @@
1
1
  import { FunctionComponent, PropsWithChildren } from 'react';
2
2
  import { SharingContextMenuProps } from '../sharing-context-menu/SharingContextMenu';
3
3
  import { ButtonProps } from '../button/Button.types';
4
- export type SharingButtonProps = PropsWithChildren<Pick<SharingContextMenuProps, 'link' | 'alignment' | 'container'> & Pick<ButtonProps, 'isDisabled' | 'shouldEnableKeyboardHighlighting'>>;
4
+ export type SharingButtonProps = PropsWithChildren<Pick<SharingContextMenuProps, 'link' | 'text' | 'alignment' | 'container'> & Pick<ButtonProps, 'isDisabled' | 'shouldEnableKeyboardHighlighting'>>;
5
5
  declare const SharingButton: FunctionComponent<SharingButtonProps>;
6
6
  export default SharingButton;
@@ -5,6 +5,10 @@ export type SharingContextMenuProps = {
5
5
  * The link that should be shared.
6
6
  */
7
7
  link: string;
8
+ /**
9
+ * Optional text that is shared together with the link via WhatsApp, mail, and X.
10
+ */
11
+ text?: string;
8
12
  /**
9
13
  * Shows the action that copies the shared link to the clipboard.
10
14
  */
@@ -23,6 +27,10 @@ declare const SharingContextMenu: React.ForwardRefExoticComponent<{
23
27
  * The link that should be shared.
24
28
  */
25
29
  link: string;
30
+ /**
31
+ * Optional text that is shared together with the link via WhatsApp, mail, and X.
32
+ */
33
+ text?: string;
26
34
  /**
27
35
  * Shows the action that copies the shared link to the clipboard.
28
36
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.6.3",
3
+ "version": "5.6.4",
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": "a64836dd4a68bad3ddf107d27b8cff4cd62c7885"
96
+ "gitHead": "14fd754461f54c94eb03455cabd6c114fc6993f2"
97
97
  }