@chayns-components/core 5.6.3 → 5.6.5

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.
Files changed (29) hide show
  1. package/AGENTS.md +2 -0
  2. package/lib/cjs/components/accordion/Accordion.js +16 -1
  3. package/lib/cjs/components/accordion/Accordion.js.map +1 -1
  4. package/lib/cjs/components/accordion/Accordion.test.js +213 -0
  5. package/lib/cjs/components/accordion/Accordion.test.js.map +1 -0
  6. package/lib/cjs/components/sharing-bar/SharingBar.js +2 -0
  7. package/lib/cjs/components/sharing-bar/SharingBar.js.map +1 -1
  8. package/lib/cjs/components/sharing-button/SharingButton.js +2 -0
  9. package/lib/cjs/components/sharing-button/SharingButton.js.map +1 -1
  10. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +73 -22
  11. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  12. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.test.js +106 -2
  13. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.test.js.map +1 -1
  14. package/lib/esm/components/accordion/Accordion.js +16 -1
  15. package/lib/esm/components/accordion/Accordion.js.map +1 -1
  16. package/lib/esm/components/accordion/Accordion.test.js +209 -0
  17. package/lib/esm/components/accordion/Accordion.test.js.map +1 -0
  18. package/lib/esm/components/sharing-bar/SharingBar.js +2 -0
  19. package/lib/esm/components/sharing-bar/SharingBar.js.map +1 -1
  20. package/lib/esm/components/sharing-button/SharingButton.js +2 -0
  21. package/lib/esm/components/sharing-button/SharingButton.js.map +1 -1
  22. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +75 -24
  23. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  24. package/lib/esm/components/sharing-context-menu/SharingContextMenu.test.js +108 -4
  25. package/lib/esm/components/sharing-context-menu/SharingContextMenu.test.js.map +1 -1
  26. package/lib/types/components/sharing-bar/SharingBar.d.ts +4 -0
  27. package/lib/types/components/sharing-button/SharingButton.d.ts +1 -1
  28. package/lib/types/components/sharing-context-menu/SharingContextMenu.d.ts +8 -0
  29. package/package.json +2 -2
@@ -0,0 +1,209 @@
1
+ import { fireEvent, render, screen } from '@testing-library/react';
2
+ import React, { StrictMode } from 'react';
3
+ import { ThemeProvider } from 'styled-components';
4
+ import { describe, expect, it, vi } from 'vitest';
5
+ import Accordion from './Accordion';
6
+ import AccordionGroup from './accordion-group/AccordionGroup';
7
+ // Observe the open state passed to the head without timing animation frames.
8
+ vi.mock('./accordion-head/AccordionHead', () => ({
9
+ default: ({
10
+ title,
11
+ isOpen,
12
+ onClick
13
+ }) => /*#__PURE__*/React.createElement("div", {
14
+ role: "button",
15
+ "aria-expanded": isOpen,
16
+ onClick: onClick
17
+ }, title)
18
+ }));
19
+ const Harness = ({
20
+ first,
21
+ second,
22
+ grouped = true,
23
+ skipAnimation = false,
24
+ external = false
25
+ }) => {
26
+ const children = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Accordion, {
27
+ shouldIndex: true,
28
+ title: "First",
29
+ isOpened: first,
30
+ shouldSkipAnimation: skipAnimation
31
+ }, "First body"), /*#__PURE__*/React.createElement(Accordion, {
32
+ shouldIndex: true,
33
+ title: "Second",
34
+ isOpened: second,
35
+ shouldSkipAnimation: skipAnimation
36
+ }, "Second body"));
37
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
38
+ theme: {}
39
+ }, grouped ? /*#__PURE__*/React.createElement(AccordionGroup, {
40
+ shouldDisableInternalHandling: external
41
+ }, children) : children);
42
+ };
43
+ const expectOpen = (first, second) => {
44
+ expect(screen.getByRole('button', {
45
+ name: 'First'
46
+ })).toHaveAttribute('aria-expanded', String(first));
47
+ expect(screen.getByRole('button', {
48
+ name: 'Second'
49
+ })).toHaveAttribute('aria-expanded', String(second));
50
+ };
51
+ describe('Accordion isOpened', () => {
52
+ it('opens a grouped accordion initially', () => {
53
+ render(/*#__PURE__*/React.createElement(Harness, {
54
+ first: true
55
+ }));
56
+ expectOpen(true, false);
57
+ });
58
+ it('reacts to subsequent grouped property updates in both directions', () => {
59
+ const {
60
+ rerender
61
+ } = render(/*#__PURE__*/React.createElement(Harness, {
62
+ first: false,
63
+ second: false
64
+ }));
65
+ rerender(/*#__PURE__*/React.createElement(Harness, {
66
+ first: true,
67
+ second: false
68
+ }));
69
+ expectOpen(true, false);
70
+ rerender(/*#__PURE__*/React.createElement(Harness, {
71
+ first: false,
72
+ second: false
73
+ }));
74
+ expectOpen(false, false);
75
+ rerender(/*#__PURE__*/React.createElement(Harness, {
76
+ first: false,
77
+ second: true
78
+ }));
79
+ expectOpen(false, true);
80
+ });
81
+ it('opens only the last initially opened sibling, including in StrictMode', () => {
82
+ render(/*#__PURE__*/React.createElement(StrictMode, null, /*#__PURE__*/React.createElement(Harness, {
83
+ first: true,
84
+ second: true
85
+ })));
86
+ expectOpen(false, true);
87
+ });
88
+ it('opens only the last sibling when multiple props change to true', () => {
89
+ const {
90
+ rerender
91
+ } = render(/*#__PURE__*/React.createElement(Harness, {
92
+ first: false,
93
+ second: false
94
+ }));
95
+ rerender(/*#__PURE__*/React.createElement(Harness, {
96
+ first: true,
97
+ second: true
98
+ }));
99
+ expectOpen(false, true);
100
+ });
101
+ it('does not let a false sibling close the opened sibling', () => {
102
+ const {
103
+ rerender
104
+ } = render(/*#__PURE__*/React.createElement(Harness, {
105
+ first: true,
106
+ second: true
107
+ }));
108
+ rerender(/*#__PURE__*/React.createElement(Harness, {
109
+ first: false,
110
+ second: true
111
+ }));
112
+ expectOpen(false, true);
113
+ });
114
+ it('does not reassert an unchanged true prop after a group click', () => {
115
+ const {
116
+ rerender
117
+ } = render(/*#__PURE__*/React.createElement(Harness, {
118
+ first: true
119
+ }));
120
+ fireEvent.click(screen.getByRole('button', {
121
+ name: 'Second'
122
+ }));
123
+ expectOpen(false, true);
124
+ rerender(/*#__PURE__*/React.createElement(Harness, {
125
+ first: true
126
+ }));
127
+ expectOpen(false, true);
128
+ });
129
+ it('honors a newer opening request while a sibling prop stays true', () => {
130
+ const {
131
+ rerender
132
+ } = render(/*#__PURE__*/React.createElement(Harness, {
133
+ first: false,
134
+ second: true
135
+ }));
136
+ expectOpen(false, true);
137
+ rerender(/*#__PURE__*/React.createElement(Harness, {
138
+ first: true,
139
+ second: true
140
+ }));
141
+ expectOpen(true, false);
142
+ });
143
+ it('preserves default-open grouping when animations are skipped', () => {
144
+ render(/*#__PURE__*/React.createElement(ThemeProvider, {
145
+ theme: {}
146
+ }, /*#__PURE__*/React.createElement(AccordionGroup, null, /*#__PURE__*/React.createElement(Accordion, {
147
+ key: "first",
148
+ title: "First",
149
+ isDefaultOpen: true,
150
+ shouldSkipAnimation: true
151
+ }, "First body"), /*#__PURE__*/React.createElement(Accordion, {
152
+ key: "second",
153
+ title: "Second",
154
+ isDefaultOpen: true,
155
+ shouldSkipAnimation: true
156
+ }, "Second body"))));
157
+ expectOpen(false, true);
158
+ });
159
+ it('enforces the group constraint when animations are skipped', () => {
160
+ render(/*#__PURE__*/React.createElement(Harness, {
161
+ first: true,
162
+ second: true,
163
+ skipAnimation: true
164
+ }));
165
+ expectOpen(false, true);
166
+ });
167
+ it('preserves fully controlled standalone rendering and prop updates', () => {
168
+ const {
169
+ rerender
170
+ } = render(/*#__PURE__*/React.createElement(Harness, {
171
+ first: true,
172
+ grouped: false
173
+ }));
174
+ fireEvent.click(screen.getByRole('button', {
175
+ name: 'First'
176
+ }));
177
+ expectOpen(true, false);
178
+ rerender(/*#__PURE__*/React.createElement(Harness, {
179
+ first: false,
180
+ second: true,
181
+ grouped: false
182
+ }));
183
+ expectOpen(false, true);
184
+ });
185
+ it('preserves the explicit opt-out of internal group handling', () => {
186
+ render(/*#__PURE__*/React.createElement(Harness, {
187
+ first: true,
188
+ second: true,
189
+ external: true
190
+ }));
191
+ expectOpen(true, true);
192
+ });
193
+ it('preserves uncontrolled click and keyboard toggling', () => {
194
+ render(/*#__PURE__*/React.createElement(Harness, null));
195
+ fireEvent.click(screen.getByRole('button', {
196
+ name: 'First'
197
+ }));
198
+ expectOpen(true, false);
199
+ const second = screen.getByRole('button', {
200
+ name: 'Second'
201
+ }).closest('.beta-chayns-accordion');
202
+ fireEvent.keyDown(second, {
203
+ key: 'Enter',
204
+ target: second
205
+ });
206
+ expectOpen(false, true);
207
+ });
208
+ });
209
+ //# sourceMappingURL=Accordion.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accordion.test.js","names":["fireEvent","render","screen","React","StrictMode","ThemeProvider","describe","expect","it","vi","Accordion","AccordionGroup","mock","default","title","isOpen","onClick","createElement","role","Harness","first","second","grouped","skipAnimation","external","children","Fragment","shouldIndex","isOpened","shouldSkipAnimation","theme","shouldDisableInternalHandling","expectOpen","getByRole","name","toHaveAttribute","String","rerender","click","key","isDefaultOpen","closest","keyDown","target"],"sources":["../../../../src/components/accordion/Accordion.test.tsx"],"sourcesContent":["import { fireEvent, render, screen } from '@testing-library/react';\nimport React, { StrictMode } from 'react';\nimport { ThemeProvider } from 'styled-components';\nimport { describe, expect, it, vi } from 'vitest';\nimport Accordion from './Accordion';\nimport AccordionGroup from './accordion-group/AccordionGroup';\nimport type { AccordionHeadProps } from './accordion-head/AccordionHead';\n\n// Observe the open state passed to the head without timing animation frames.\nvi.mock('./accordion-head/AccordionHead', () => ({\n default: ({ title, isOpen, onClick }: AccordionHeadProps) => (\n <div role=\"button\" aria-expanded={isOpen} onClick={onClick}>\n {title}\n </div>\n ),\n}));\n\nconst Harness = ({\n first,\n second,\n grouped = true,\n skipAnimation = false,\n external = false,\n}: {\n first?: boolean;\n second?: boolean;\n grouped?: boolean;\n skipAnimation?: boolean;\n external?: boolean;\n}) => {\n const children = (\n <>\n <Accordion\n shouldIndex\n title=\"First\"\n isOpened={first}\n shouldSkipAnimation={skipAnimation}\n >\n First body\n </Accordion>\n <Accordion\n shouldIndex\n title=\"Second\"\n isOpened={second}\n shouldSkipAnimation={skipAnimation}\n >\n Second body\n </Accordion>\n </>\n );\n return (\n <ThemeProvider theme={{}}>\n {grouped ? (\n <AccordionGroup shouldDisableInternalHandling={external}>{children}</AccordionGroup>\n ) : (\n children\n )}\n </ThemeProvider>\n );\n};\n\nconst expectOpen = (first: boolean, second: boolean) => {\n expect(screen.getByRole('button', { name: 'First' })).toHaveAttribute(\n 'aria-expanded',\n String(first),\n );\n expect(screen.getByRole('button', { name: 'Second' })).toHaveAttribute(\n 'aria-expanded',\n String(second),\n );\n};\n\ndescribe('Accordion isOpened', () => {\n it('opens a grouped accordion initially', () => {\n render(<Harness first />);\n expectOpen(true, false);\n });\n\n it('reacts to subsequent grouped property updates in both directions', () => {\n const { rerender } = render(<Harness first={false} second={false} />);\n rerender(<Harness first second={false} />);\n expectOpen(true, false);\n rerender(<Harness first={false} second={false} />);\n expectOpen(false, false);\n rerender(<Harness first={false} second />);\n expectOpen(false, true);\n });\n\n it('opens only the last initially opened sibling, including in StrictMode', () => {\n render(\n <StrictMode>\n <Harness first second />\n </StrictMode>,\n );\n expectOpen(false, true);\n });\n\n it('opens only the last sibling when multiple props change to true', () => {\n const { rerender } = render(<Harness first={false} second={false} />);\n rerender(<Harness first second />);\n expectOpen(false, true);\n });\n\n it('does not let a false sibling close the opened sibling', () => {\n const { rerender } = render(<Harness first second />);\n rerender(<Harness first={false} second />);\n expectOpen(false, true);\n });\n\n it('does not reassert an unchanged true prop after a group click', () => {\n const { rerender } = render(<Harness first />);\n fireEvent.click(screen.getByRole('button', { name: 'Second' }));\n expectOpen(false, true);\n rerender(<Harness first />);\n expectOpen(false, true);\n });\n\n it('honors a newer opening request while a sibling prop stays true', () => {\n const { rerender } = render(<Harness first={false} second />);\n expectOpen(false, true);\n rerender(<Harness first second />);\n expectOpen(true, false);\n });\n\n it('preserves default-open grouping when animations are skipped', () => {\n render(\n <ThemeProvider theme={{}}>\n <AccordionGroup>\n <Accordion key=\"first\" title=\"First\" isDefaultOpen shouldSkipAnimation>\n First body\n </Accordion>\n <Accordion key=\"second\" title=\"Second\" isDefaultOpen shouldSkipAnimation>\n Second body\n </Accordion>\n </AccordionGroup>\n </ThemeProvider>,\n );\n expectOpen(false, true);\n });\n\n it('enforces the group constraint when animations are skipped', () => {\n render(<Harness first second skipAnimation />);\n expectOpen(false, true);\n });\n\n it('preserves fully controlled standalone rendering and prop updates', () => {\n const { rerender } = render(<Harness first grouped={false} />);\n fireEvent.click(screen.getByRole('button', { name: 'First' }));\n expectOpen(true, false);\n rerender(<Harness first={false} second grouped={false} />);\n expectOpen(false, true);\n });\n\n it('preserves the explicit opt-out of internal group handling', () => {\n render(<Harness first second external />);\n expectOpen(true, true);\n });\n\n it('preserves uncontrolled click and keyboard toggling', () => {\n render(<Harness />);\n fireEvent.click(screen.getByRole('button', { name: 'First' }));\n expectOpen(true, false);\n const second = screen\n .getByRole('button', { name: 'Second' })\n .closest('.beta-chayns-accordion')!;\n fireEvent.keyDown(second, { key: 'Enter', target: second });\n expectOpen(false, true);\n });\n});\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,MAAM,QAAQ,wBAAwB;AAClE,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACjD,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,cAAc,MAAM,kCAAkC;AAG7D;AACAF,EAAE,CAACG,IAAI,CAAC,gCAAgC,EAAE,OAAO;EAC7CC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAA4B,CAAC,kBACpDb,KAAA,CAAAc,aAAA;IAAKC,IAAI,EAAC,QAAQ;IAAC,iBAAeH,MAAO;IAACC,OAAO,EAAEA;EAAQ,GACtDF,KACA;AAEb,CAAC,CAAC,CAAC;AAEH,MAAMK,OAAO,GAAGA,CAAC;EACbC,KAAK;EACLC,MAAM;EACNC,OAAO,GAAG,IAAI;EACdC,aAAa,GAAG,KAAK;E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AAM;MAACC,MAAM;MAACC,OAAO,EAAE;IAAM,CAAE,CAAC,CAAC;IAC1DU,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;EAC3B,CAAC,CAAC;EAEFxB,EAAE,CAAC,2DAA2D,EAAE,MAAM;IAClEP,MAAM,cAACE,KAAA,CAAAc,aAAA,CAACE,OAAO;MAACC,KAAK;MAACC,MAAM;MAACG,QAAQ;IAAA,CAAE,CAAC,CAAC;IACzCQ,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC;EAC1B,CAAC,CAAC;EAEFxB,EAAE,CAAC,oDAAoD,EAAE,MAAM;IAC3DP,MAAM,cAACE,KAAA,CAAAc,aAAA,CAACE,OAAO,MAAE,CAAC,CAAC;IACnBnB,SAAS,CAACsC,KAAK,CAACpC,MAAM,CAAC+B,SAAS,CAAC,QAAQ,EAAE;MAAEC,IAAI,EAAE;IAAQ,CAAC,CAAC,CAAC;IAC9DF,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;IACvB,MAAMX,MAAM,GAAGnB,MAAM,CAChB+B,SAAS,CAAC,QAAQ,EAAE;MAAEC,IAAI,EAAE;IAAS,CAAC,CAAC,CACvCO,OAAO,CAAC,wBAAwB,CAAE;IACvCzC,SAAS,CAAC0C,OAAO,CAACrB,MAAM,EAAE;MAAEkB,GAAG,EAAE,OAAO;MAAEI,MAAM,EAAEtB;IAAO,CAAC,CAAC;IAC3DW,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;EAC3B,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":"AA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AErC,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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ACrC,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,12 +1,13 @@
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';
3
- import React, { forwardRef, useCallback } from 'react';
2
+ import { AppName, getSite, invokeCall, useDevice } from 'chayns-api';
3
+ import React, { forwardRef, useCallback, useMemo } from 'react';
4
4
  import { SHAREPROVIDER } from '../../constants/sharingBar';
5
5
  import { useIsTouch } from '../../utils/environment';
6
6
  import { copyToClipboard, shareWithApp, shareWithUrl } from '../../utils/sharingBar';
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,31 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
14
15
  ...contextMenuProps
15
16
  }, ref) => {
16
17
  const isTouch = useIsTouch();
18
+ const {
19
+ app,
20
+ os
21
+ } = useDevice();
22
+ const shouldUseAppCall = useMemo(() => app && app.name === AppName.CityApp && (os === 'iOS' && app.appVersion >= 3313 || os === 'Android OS' && app.appVersion >= 3313), [app, os]);
23
+ const shareInApp = useCallback((provider, shareText, callback) => {
24
+ if (!provider) {
25
+ throw new Error('The requested sharing provider is not configured.');
26
+ }
27
+ void invokeCall({
28
+ action: 80,
29
+ value: {
30
+ text: shareText,
31
+ sharingApp: provider.providerId,
32
+ ...(provider.androidIdentifier ? {
33
+ sharingAndroidApp: provider.androidIdentifier
34
+ } : {}),
35
+ callback: retVal => {
36
+ if (retVal.status !== 0) {
37
+ callback();
38
+ }
39
+ }
40
+ }
41
+ });
42
+ }, []);
17
43
  const handleImageDownload = useCallback(() => {
18
44
  shareWithUrl(
19
45
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -23,40 +49,65 @@ const SharingContextMenu = /*#__PURE__*/forwardRef(({
23
49
  const handleShare = useCallback(key => {
24
50
  switch (key) {
25
51
  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;
52
+ {
53
+ const shareText = text ? `${text}\n\n${link}` : `${link}`.trim();
54
+ const callback = () => shareWithUrl(
55
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
+ // @ts-ignore
57
+ SHAREPROVIDER[0].url.replace('{url}', encodeURIComponent(shareText)));
58
+ if (shouldUseAppCall) {
59
+ shareInApp(SHAREPROVIDER[0], shareText, callback);
60
+ break;
61
+ }
62
+ callback();
63
+ break;
64
+ }
31
65
  case 'facebook':
32
- shareWithUrl(
33
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
- // @ts-ignore
35
- SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)));
36
- break;
66
+ {
67
+ const callback = () => shareWithUrl(
68
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
69
+ // @ts-ignore
70
+ SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)));
71
+ if (shouldUseAppCall) {
72
+ shareInApp(SHAREPROVIDER[3], `${link}`.trim(), callback);
73
+ break;
74
+ }
75
+ callback();
76
+ break;
77
+ }
37
78
  case 'twitter':
38
- shareWithUrl(
39
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
- // @ts-ignore
41
- SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', ''));
42
- break;
79
+ {
80
+ const callback = () => shareWithUrl(
81
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
82
+ // @ts-ignore
83
+ SHAREPROVIDER[4].url.replace('{url}', encodeURIComponent(link)).replace('{linkText}', encodeURIComponent(text ?? '')));
84
+ if (shouldUseAppCall) {
85
+ shareInApp(SHAREPROVIDER[4], text ? `${text}\n\n${link}` : `${link}`.trim(), callback);
86
+ break;
87
+ }
88
+ callback();
89
+ break;
90
+ }
43
91
  case 'mail':
44
- if (isTouch) {
45
- shareWithApp(`${link}`.trim());
46
- } else {
47
- shareWithUrl(
92
+ {
93
+ const callback = () => isTouch ? shareWithApp(text ? `${text}\n\n${link}` : `${link}`.trim()) : shareWithUrl(
48
94
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
95
  // @ts-ignore
50
- SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(`${link}`.trim())));
96
+ SHAREPROVIDER[2].url.replace('{url}', encodeURIComponent(text ? `${text}\n\n${link}` : `${link}`.trim())));
97
+ if (shouldUseAppCall) {
98
+ shareInApp(SHAREPROVIDER[2], text ? `${text}\n\n${link}` : `${link}`.trim(), callback);
99
+ break;
100
+ }
101
+ callback();
102
+ break;
51
103
  }
52
- break;
53
104
  case 'copy':
54
105
  copyToClipboard(link);
55
106
  break;
56
107
  default:
57
108
  break;
58
109
  }
59
- }, [link, isTouch]);
110
+ }, [link, text, shouldUseAppCall, shareInApp, isTouch]);
60
111
  const contextMenuItems = [...(shouldShowCopyAction ? [{
61
112
  icons: ['fa fa-copy'],
62
113
  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,C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A;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":["AppName","getSite","invokeCall","useDevice","React","forwardRef","useCallback","useMemo","SHAREPROVIDER","useIsTouch","copyToClipboard","shareWithApp","shareWithUrl","ContextMenu","SharingContextMenu","link","text","children","shouldEnableKeyboardHighlighting","shouldShowCallingCodeAction","shouldShowCopyAction","contextMenuProps","ref","isTouch","app","os","shouldUseAppCall","name","CityApp","appVersion","shareInApp","provider","shareText","callback","Error","action","value","sharingApp","providerId","androidIdentifier","sharingAndroidApp","retVal","status","handleImageDownload","url","replace","encodeURIComponent","color","handleShare","key","trim","contextMenuItems","icons","onClick","createElement","_extends","items","displayName"],"sources":["../../../../src/components/sharing-context-menu/SharingContextMenu.tsx"],"sourcesContent":["import { AppName, getSite, invokeCall, useDevice } from 'chayns-api';\nimport React, { forwardRef, useCallback, useMemo } from 'react';\nimport { SHAREPROVIDER } from '../../constants/sharingBar';\nimport type { SharingBarProvider } from '../../types/sharingBar';\nimport { useIsTouch } from '../../utils/environment';\nimport { copyToClipboard, shareWithApp, shareWithUrl } from '../../utils/sharingBar';\nimport ContextMenu from '../context-menu/ContextMenu';\nimport { ContextMenuProps, ContextMenuRef } from '../context-menu/ContextMenu.types';\n\nexport type SharingContextMenuProps = {\n /**\n * The link that should be shared.\n */\n link: string;\n /**\n * Optional text that is shared together with the link via WhatsApp, mail, and X.\n */\n text?: string;\n /**\n * Shows the action that copies the shared link to the clipboard.\n */\n shouldShowCopyAction?: boolean;\n /**\n * Shows the action that downloads a calling-code image.\n */\n shouldShowCallingCodeAction?: boolean;\n /**\n * Enables keyboard-only focus highlighting for the context menu trigger.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n} & Omit<ContextMenuProps, 'items' | 'shouldEnableKeyboardHighlighting'>;\n\nconst SharingContextMenu = forwardRef<ContextMenuRef, SharingContextMenuProps>(\n (\n {\n link,\n text,\n children,\n shouldEnableKeyboardHighlighting,\n shouldShowCallingCodeAction = true,\n shouldShowCopyAction = true,\n ...contextMenuProps\n },\n ref,\n ) => {\n const isTouch = useIsTouch();\n const { app, os } = useDevice();\n\n const shouldUseAppCall = useMemo(\n () =>\n app &&\n app.name === AppName.CityApp &&\n ((os === 'iOS' && app.appVersion >= 3313) ||\n (os === 'Android OS' && app.appVersion >= 3313)),\n [app, os],\n );\n\n const shareInApp = useCallback(\n (\n provider: SharingBarProvider | undefined,\n shareText: string,\n callback: VoidFunction,\n ) => {\n if (!provider) {\n throw new Error('The requested sharing provider is not configured.');\n }\n\n void invokeCall({\n action: 80,\n value: {\n text: shareText,\n sharingApp: provider.providerId,\n ...(provider.androidIdentifier\n ? { sharingAndroidApp: provider.androidIdentifier }\n : {}),\n callback: (retVal: { status: 0 | -1 | -2 }) => {\n if (retVal.status !== 0) {\n callback();\n }\n },\n },\n });\n },\n [],\n );\n\n const handleImageDownload = useCallback(() => {\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[5].url\n .replace('{url}', encodeURIComponent(link))\n .replace('{linkText}', 'Teilen')\n .replace('{color}', getSite().color.replace('#', '')),\n );\n }, [link]);\n\n const handleShare = useCallback(\n (key: string) => {\n switch (key) {\n case 'whatsapp': {\n const shareText = text ? `${text}\\n\\n${link}` : `${link}`.trim();\n const callback = () =>\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[0].url.replace(\n '{url}',\n encodeURIComponent(shareText),\n ),\n );\n\n if (shouldUseAppCall) {\n shareInApp(SHAREPROVIDER[0], shareText, callback);\n break;\n }\n\n callback();\n break;\n }\n case 'facebook': {\n const callback = () =>\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[3].url.replace('{url}', encodeURIComponent(link)),\n );\n\n if (shouldUseAppCall) {\n shareInApp(SHAREPROVIDER[3], `${link}`.trim(), callback);\n break;\n }\n\n callback();\n break;\n }\n case 'twitter': {\n const callback = () =>\n shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[4].url\n .replace('{url}', encodeURIComponent(link))\n .replace('{linkText}', encodeURIComponent(text ?? '')),\n );\n\n if (shouldUseAppCall) {\n shareInApp(\n SHAREPROVIDER[4],\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n callback,\n );\n break;\n }\n\n callback();\n break;\n }\n case 'mail': {\n const callback = () =>\n isTouch\n ? shareWithApp(text ? `${text}\\n\\n${link}` : `${link}`.trim())\n : shareWithUrl(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n SHAREPROVIDER[2].url.replace(\n '{url}',\n encodeURIComponent(\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n ),\n ),\n );\n\n if (shouldUseAppCall) {\n shareInApp(\n SHAREPROVIDER[2],\n text ? `${text}\\n\\n${link}` : `${link}`.trim(),\n callback,\n );\n break;\n }\n\n callback();\n break;\n }\n case 'copy':\n copyToClipboard(link);\n break;\n default:\n break;\n }\n },\n [link, text, shouldUseAppCall, shareInApp, isTouch],\n );\n\n const contextMenuItems = [\n ...(shouldShowCopyAction\n ? [\n {\n icons: ['fa fa-copy'],\n key: 'copy',\n onClick: () => handleShare('copy'),\n text: 'Zwischenablage',\n },\n ]\n : []),\n {\n icons: ['fa-solid fa-brands fa-whatsapp'],\n key: 'whatsapp',\n onClick: () => handleShare('whatsapp'),\n text: 'Whatsapp',\n },\n {\n icons: ['fa-solid fa-brands fa-facebook-f'],\n key: 'facebook',\n onClick: () => handleShare('facebook'),\n text: 'Facebook',\n },\n {\n icons: ['fa-solid fa-brands fa-x-twitter'],\n key: 'twitter',\n onClick: () => handleShare('twitter'),\n text: 'X',\n },\n {\n icons: ['fa fa-envelope'],\n key: 'mail',\n onClick: () => handleShare('mail'),\n text: 'Mail',\n },\n ...(shouldShowCallingCodeAction\n ? [\n {\n icons: ['fa fa-qrcode'],\n key: 'callingCode',\n onClick: handleImageDownload,\n text: 'Calling Code herunterladen',\n },\n ]\n : []),\n ];\n\n return (\n <ContextMenu\n items={contextMenuItems}\n ref={ref}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlighting}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n );\n },\n);\n\nSharingContextMenu.displayName = 'SharingContextMenu';\n\nexport default SharingContextMenu;\n"],"mappings":";AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AACpE,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,aAAa,QAAQ,4BAA4B;AAE1D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,eAAe,EAAEC,YAAY,EAAEC,YAAY,QAAQ,wBAAwB;AACpF,OAAOC,WAAW,MAAM,6BAA6B;AA0BrD,MAAMC,kBAAkB,gBAAGT,UAAU,CACjC,CACI;EACIU,IAAI;EACJC,IAAI;EACJC,QAAQ;EACRC,gCAAgC;EAChCC,2BAA2B,GAAG,IAAI;EAClCC,oBAAoB,GAAG,IAAI;EAC3B,GAAGC;AACP,CAAC,EACDC,GAAG,KACF;EACD,MAAMC,OAAO,GAAGd,UAAU,CAAC,CAAC;EAC5B,MAAM;IAAEe,GAAG;IAAEC;EAAG,CAAC,GAAGtB,SAAS,CAAC,CAAC;EAE/B,MAAMuB,gBAAgB,GAAGnB,OAAO,CAC5B,MACIiB,GAAG,IACHA,GAAG,CAACG,IAAI,KAAK3B,OAAO,CAAC4B,OAAO,KAC1BH,EAAE,KAAK,KAAK,IAAID,GAAG,CAACK,UAAU,IAAI,IAAI,IACnCJ,EAAE,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