@chayns-components/core 5.6.2 → 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 +8 -0
- package/lib/cjs/components/accordion/Accordion.js +28 -25
- package/lib/cjs/components/accordion/Accordion.js.map +1 -1
- package/lib/cjs/components/sharing-bar/SharingBar.js +2 -0
- package/lib/cjs/components/sharing-bar/SharingBar.js.map +1 -1
- package/lib/cjs/components/sharing-button/SharingButton.js +2 -0
- package/lib/cjs/components/sharing-button/SharingButton.js.map +1 -1
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +43 -10
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.test.js +106 -2
- package/lib/cjs/components/sharing-context-menu/SharingContextMenu.test.js.map +1 -1
- package/lib/esm/components/accordion/Accordion.js +28 -25
- package/lib/esm/components/accordion/Accordion.js.map +1 -1
- package/lib/esm/components/sharing-bar/SharingBar.js +2 -0
- package/lib/esm/components/sharing-bar/SharingBar.js.map +1 -1
- package/lib/esm/components/sharing-button/SharingButton.js +2 -0
- package/lib/esm/components/sharing-button/SharingButton.js.map +1 -1
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +44 -11
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.test.js +108 -4
- package/lib/esm/components/sharing-context-menu/SharingContextMenu.test.js.map +1 -1
- package/lib/types/components/sharing-bar/SharingBar.d.ts +4 -0
- package/lib/types/components/sharing-button/SharingButton.d.ts +1 -1
- package/lib/types/components/sharing-context-menu/SharingContextMenu.d.ts +8 -0
- package/package.json +2 -2
|
@@ -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
|
-
},
|
|
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,s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,GAAG,IAAAC,aAAM,eACxBtB,OAAA,CAAAM,OAAA,CAAAQ,aAAA,CAACX,mBAAA,CAAAG,OAAkB;MACfiB,IAAI,EAAC,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;EA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IAAQ,GAAC,OAAa,CACnB,CACxB,CAAC;IAED,IAAAc,cAAM,EAAEQ,SAAS,CAACC,UAAU,CAAiBC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAC7E,gCACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -70,15 +70,19 @@ const Accordion = ({
|
|
|
70
70
|
const colorScheme = useColorScheme();
|
|
71
71
|
const shouldEnableKeyboardHighlightingEffective = shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;
|
|
72
72
|
const isWrapped = useMemo(() => groupIsWrapped ?? contextIsWrapped, [contextIsWrapped, groupIsWrapped]);
|
|
73
|
-
const
|
|
74
|
-
const [
|
|
73
|
+
const isControlled = typeof isOpened === 'boolean';
|
|
74
|
+
const [internalOpen, setInternalOpen] = useState(isDefaultOpen ?? false);
|
|
75
75
|
const uuid = useUuid();
|
|
76
76
|
const isInitialRenderRef = useRef(true);
|
|
77
77
|
const accordionRef = useRef(null);
|
|
78
78
|
const initialRenderSkipRef = useInitialRenderRef(true);
|
|
79
79
|
const shouldSkipAnimation = shouldSkipAnimationProp ?? (initialRenderSkipRef.current && isDefaultOpen);
|
|
80
80
|
const isInGroup = shouldSkipAnimation ? false : typeof updateOpenAccordionUuid === 'function';
|
|
81
|
-
const isOpen =
|
|
81
|
+
const isOpen = (() => {
|
|
82
|
+
if (isInGroup) return openAccordionUuid === uuid;
|
|
83
|
+
if (isControlled) return isOpened;
|
|
84
|
+
return internalOpen;
|
|
85
|
+
})();
|
|
82
86
|
const isOpenRef = useRef(isOpen);
|
|
83
87
|
const onCloseRef = useRef(onClose);
|
|
84
88
|
const onOpenRef = useRef(onOpen);
|
|
@@ -86,7 +90,7 @@ const Accordion = ({
|
|
|
86
90
|
const isKeyboardFocusable = !isDisabled && (shouldIndex || shouldEnableKeyboardHighlightingEffective);
|
|
87
91
|
useFocusRingPortal(accordionRef, {
|
|
88
92
|
isEnabled: shouldShowKeyboardHighlighting && isKeyboardFocusable,
|
|
89
|
-
borderRadius: `${theme.cardBorderRadius}px`
|
|
93
|
+
borderRadius: `${theme.cardBorderRadius ?? 0}px`
|
|
90
94
|
});
|
|
91
95
|
const isInKeyboardNavigationGroup = isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function' && typeof accordionGroupUuid === 'string';
|
|
92
96
|
useEffect(() => {
|
|
@@ -113,17 +117,27 @@ const Accordion = ({
|
|
|
113
117
|
}
|
|
114
118
|
if (typeof updateOpenAccordionUuid === 'function') {
|
|
115
119
|
updateOpenAccordionUuid(uuid);
|
|
120
|
+
} else if (!isControlled) {
|
|
121
|
+
setInternalOpen(prev => !prev);
|
|
116
122
|
}
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
if (isOpen) {
|
|
124
|
+
onClose?.();
|
|
125
|
+
} else {
|
|
126
|
+
onOpen?.();
|
|
127
|
+
}
|
|
128
|
+
}, [isDisabled, isKeyboardFocusable, updateActiveAccordionUuid, updateOpenAccordionUuid, uuid, isOpen, onClose, onOpen, isControlled]);
|
|
119
129
|
useEffect(() => {
|
|
120
130
|
if (isDisabled && isOpen) {
|
|
121
131
|
if (typeof updateOpenAccordionUuid === 'function') {
|
|
122
132
|
updateOpenAccordionUuid(uuid);
|
|
133
|
+
} else if (typeof onClose === 'function') {
|
|
134
|
+
onClose();
|
|
135
|
+
} else {
|
|
136
|
+
// Uncontrolled mode: use the internal state
|
|
137
|
+
setInternalOpen(false);
|
|
123
138
|
}
|
|
124
|
-
setIsAccordionOpen(currentIsAccordionOpen => !currentIsAccordionOpen);
|
|
125
139
|
}
|
|
126
|
-
}, [isDisabled, isOpen, updateOpenAccordionUuid, uuid]);
|
|
140
|
+
}, [isDisabled, isOpen, updateOpenAccordionUuid, uuid, onClose]);
|
|
127
141
|
useEffect(() => {
|
|
128
142
|
if (isInitialRenderRef.current) {
|
|
129
143
|
isInitialRenderRef.current = false;
|
|
@@ -136,25 +150,18 @@ const Accordion = ({
|
|
|
136
150
|
}
|
|
137
151
|
}, [isOpen]);
|
|
138
152
|
useEffect(() => {
|
|
139
|
-
if (isDefaultOpen) {
|
|
153
|
+
if (!isControlled && isDefaultOpen) {
|
|
140
154
|
if (typeof updateOpenAccordionUuid === 'function') {
|
|
141
155
|
updateOpenAccordionUuid(uuid, {
|
|
142
156
|
shouldOnlyOpen: true
|
|
143
157
|
});
|
|
158
|
+
} else if (typeof onOpen === 'function') {
|
|
159
|
+
onOpen();
|
|
144
160
|
} else {
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}, [isDefaultOpen, updateOpenAccordionUuid, uuid]);
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
if (typeof isOpened === 'boolean') {
|
|
151
|
-
if (typeof updateOpenAccordionUuid === 'function' && isOpened !== isOpenRef.current) {
|
|
152
|
-
updateOpenAccordionUuid(uuid);
|
|
153
|
-
} else {
|
|
154
|
-
setIsAccordionOpen(isOpened);
|
|
161
|
+
setInternalOpen(true);
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
|
-
}, [
|
|
164
|
+
}, [isDefaultOpen, updateOpenAccordionUuid, uuid, onOpen, isControlled]);
|
|
158
165
|
const accordionContextProviderValue = useMemo(() => ({
|
|
159
166
|
isWrapped: isWrapped === true
|
|
160
167
|
}), [isWrapped]);
|
|
@@ -228,7 +235,6 @@ const Accordion = ({
|
|
|
228
235
|
}, [accordionGroupUuid, accordionUuids, handleHeadClick, isInKeyboardNavigationGroup, isKeyboardFocusable, isOpen, updateActiveAccordionUuid, uuid]);
|
|
229
236
|
const handleFocus = useCallback(e => {
|
|
230
237
|
if (e.currentTarget === e.target && isInKeyboardNavigationGroup && typeof updateActiveAccordionUuid === 'function') {
|
|
231
|
-
setIsGroupFocusWithin(true);
|
|
232
238
|
updateActiveAccordionUuid(uuid);
|
|
233
239
|
}
|
|
234
240
|
}, [isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid]);
|
|
@@ -237,15 +243,12 @@ const Accordion = ({
|
|
|
237
243
|
const nextFocusedElement = e.relatedTarget;
|
|
238
244
|
const currentGroupElement = e.currentTarget;
|
|
239
245
|
if (!nextFocusedElement || !currentGroupElement.contains(nextFocusedElement)) {
|
|
240
|
-
setIsGroupFocusWithin(false);
|
|
241
246
|
updateActiveAccordionUuid(undefined);
|
|
242
247
|
}
|
|
243
248
|
}
|
|
244
249
|
}, [accordionGroupUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid]);
|
|
245
250
|
useEffect(() => {
|
|
246
|
-
if (
|
|
247
|
-
setIsGroupFocusWithin(false);
|
|
248
|
-
} else if (activeAccordionUuid == null && typeof updateActiveAccordionUuid === 'function' && accordionUuids?.[0] === uuid) {
|
|
251
|
+
if (activeAccordionUuid == null && typeof updateActiveAccordionUuid === 'function' && accordionUuids?.[0] === uuid) {
|
|
249
252
|
updateActiveAccordionUuid(uuid);
|
|
250
253
|
}
|
|
251
254
|
}, [accordionUuids, activeAccordionUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","names":["AnimatePresence","MotionConfig","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useTheme","useUuid","useFocusRingPortal","useKeyboardFocusHighlighting","AreaContext","useColorScheme","AccordionBody","AccordionGroupContext","AccordionHead","AccordionWrappedContext","StyledMotionAccordion","useInitialRenderRef","AccordionContext","createContext","isWrapped","undefined","Accordion","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onHoverEnd","onHoverStart","onOpen","onSearchChange","rightElement","searchPlaceholder","searchValue","shouldForceBackground","shouldForceBottomLine","shouldHideBackground","shouldRenderClosed","shouldRotateIcon","shouldHideBottomLine","title","titleElement","onTitleInputChange","titleInputProps","shouldSkipAnimation","shouldSkipAnimationProp","colors","shouldIndex","onBodyAnimationComplete","shouldEnableKeyboardHighlighting","theme","groupIsWrapped","openAccordionUuid","accordionGroupUuid","accordionUuids","updateOpenAccordionUuid","activeAccordionUuid","updateActiveAccordionUuid","registerAccordionUuid","unregisterAccordionUuid","isParentWrapped","contextIsWrapped","colorScheme","shouldEnableKeyboardHighlightingEffective","isAccordionOpen","setIsAccordionOpen","isGroupFocusWithin","setIsGroupFocusWithin","uuid","isInitialRenderRef","accordionRef","initialRenderSkipRef","current","isInGroup","isOpen","isOpenRef","onCloseRef","onOpenRef","shouldShowKeyboardHighlighting","isKeyboardFocusable","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","isLastAccordion","length","handleHeadClick","currentIsAccordionOpen","shouldOnlyOpen","accordionContextProviderValue","areaContextProviderValue","shouldChangeColor","accordionWrappedContextProviderValue","initialAnimation","height","opacity","tabIndex","handleKeyDown","e","isCurrentAccordionTarget","currentTarget","target","key","preventDefault","currentIndex","indexOf","nextIndex","nextAccordionUuid","nextAccordionElement","document","querySelector","focus","parentAccordion","parentElement","closest","parentGroupId","getAttribute","split","handleFocus","handleBlur","nextFocusedElement","relatedTarget","currentGroupElement","contains","createElement","ref","animate","className","exit","initial","$isOpen","$shouldShowLines","$isParentWrapped","$isWrapped","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBackground","$shouldHideBottomLine","$bottomBorderColor","borderBottomColor","$shouldEnableKeyboardHighlighting","$shouldShowKeyboardHighlighting","onKeyDown","onFocus","onBlur","onMouseEnter","onMouseLeave","transition","duration","Provider","value","type","onClick","titleColor","maxHeight","onScroll","onAnimationComplete","shouldHideBody","displayName"],"sources":["../../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import { AnimatePresence, MotionConfig } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n type MouseEventHandler,\n ReactNode,\n UIEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../hooks/uuid';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputProps } from '../input/Input';\nimport AccordionBody from './accordion-body/AccordionBody';\nimport { AccordionGroupContext } from './accordion-group/AccordionGroup';\nimport AccordionHead from './accordion-head/AccordionHead';\nimport { AccordionWrappedContext } from './accordion-provider/AccordionContextProvider';\nimport { StyledMotionAccordion } from './Accordion.styles';\nimport { useInitialRenderRef } from '../../hooks/ref';\n\nexport const AccordionContext = React.createContext<{ isWrapped?: boolean }>({\n isWrapped: undefined,\n});\n\ntype AccordionColors = {\n titleColor?: CSSProperties['color'];\n borderBottomColor?: CSSProperties['borderBottomColor'];\n};\n\nexport type AccordionProps = {\n /**\n * Maximum height of the accordion body element. This automatically makes the content of the\n * body element scrollable.\n */\n bodyMaxHeight?: number;\n /**\n * The content of the accordion body\n */\n children: ReactNode;\n /**\n * The icon that is displayed in front of the title\n */\n icon?: string;\n /**\n * This can be used to automatically expand the Accordion during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This will disable the Accordion so that it cannot be opened and will gray out the title. Does not work with isOpened.\n */\n isDisabled?: boolean;\n /**\n * This can be used so that the Accordion cannot be opened or closed.\n * In addition, in this case the icon is exchanged to mark the Accordions.\n */\n isFixed?: boolean;\n /**\n * This can be used to open the Accordion from the outside\n */\n isOpened?: boolean;\n /**\n * This will gray out the title of the Accordion to indicate hidden content, for example.\n */\n isTitleGreyed?: boolean;\n /**\n * Function that is executed when the accordion body will be scrolled\n */\n onBodyScroll?: (event: UIEvent<HTMLDivElement>) => void;\n /**\n * Function that is executed when the accordion will be closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the accordion is no longer hovered.\n */\n onHoverEnd?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the accordion is hovered.\n */\n onHoverStart?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the accordion will be opened.\n */\n onOpen?: VoidFunction;\n /**\n * Function that is executed when the accordion body is animated\n */\n onBodyAnimationComplete?: VoidFunction;\n /**\n * Function that is executed when the text of the search in the accordion\n * head changes. When this function is given, the search field is displayed\n * in the Accordion Head.\n */\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the search in the accordion\n * title changes. When this function is given, the search field is displayed\n * as the Accordion title.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Content to be displayed on the right side in the head of the Accordion\n */\n rightElement?: ReactNode;\n /**\n * The placeholder to be used for the search\n */\n searchPlaceholder?: string;\n /**\n * The value that is displayed inside the search\n */\n searchValue?: string;\n /**\n * This will force the background color of the accordion to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * This will hide the background color of the accordion\n */\n shouldHideBackground?: boolean;\n /**\n * Whether the bottom line should always be shown, regardless of other line-related props.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * This will render the Accordion closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the icon should be rotating.\n */\n shouldRotateIcon?: boolean;\n /**\n * Whether the animation should be skipped.\n * If 'isDefaultOpen' is true the initial animation will be skipped even this prop is false\n */\n shouldSkipAnimation?: boolean;\n /**\n * Title of the Accordion displayed in the head\n */\n title?: string;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n /**\n * The props of the title Input.\n */\n titleInputProps?: InputProps;\n /**\n * Provide custom colors to the Accordion Component\n */\n colors?: AccordionColors;\n /**\n * Whether the accordion should be indexed.\n */\n shouldIndex?: boolean;\n /**\n * Enables keyboard-only focus highlighting. The highlighting is only visible while the\n * user navigates with the keyboard and is reset on mouse movement or click.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst Accordion: FC<AccordionProps> = ({\n bodyMaxHeight,\n children,\n icon,\n isDefaultOpen = false,\n isDisabled = false,\n isFixed = false,\n isOpened,\n isTitleGreyed = false,\n onBodyScroll,\n onClose,\n onHoverEnd,\n onHoverStart,\n onOpen,\n onSearchChange,\n rightElement,\n searchPlaceholder,\n searchValue,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldHideBackground = false,\n shouldRenderClosed = false,\n shouldRotateIcon = true,\n shouldHideBottomLine = false,\n title,\n titleElement,\n onTitleInputChange,\n titleInputProps,\n shouldSkipAnimation: shouldSkipAnimationProp = false,\n colors,\n shouldIndex = false,\n onBodyAnimationComplete,\n shouldEnableKeyboardHighlighting,\n}) => {\n const theme = useTheme() as Theme;\n const {\n isWrapped: groupIsWrapped,\n openAccordionUuid,\n accordionGroupUuid,\n accordionUuids,\n updateOpenAccordionUuid,\n activeAccordionUuid,\n updateActiveAccordionUuid,\n registerAccordionUuid,\n unregisterAccordionUuid,\n } = useContext(AccordionGroupContext);\n const { isWrapped: isParentWrapped } = useContext(AccordionContext);\n\n const { isWrapped: contextIsWrapped } = useContext(AccordionWrappedContext);\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const isWrapped = useMemo(\n () => groupIsWrapped ?? contextIsWrapped,\n [contextIsWrapped, groupIsWrapped],\n );\n\n const [isAccordionOpen, setIsAccordionOpen] = useState<boolean>(isDefaultOpen ?? isOpened);\n const [isGroupFocusWithin, setIsGroupFocusWithin] = useState(false);\n\n const uuid = useUuid();\n\n const isInitialRenderRef = useRef(true);\n const accordionRef = useRef<HTMLDivElement>(null);\n\n const initialRenderSkipRef = useInitialRenderRef(true);\n\n const shouldSkipAnimation =\n shouldSkipAnimationProp ?? (initialRenderSkipRef.current && isDefaultOpen);\n\n const isInGroup = shouldSkipAnimation ? false : typeof updateOpenAccordionUuid === 'function';\n\n const isOpen = isInGroup ? openAccordionUuid === uuid : isAccordionOpen;\n\n const isOpenRef = useRef(isOpen);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n const isKeyboardFocusable =\n !isDisabled && (shouldIndex || shouldEnableKeyboardHighlightingEffective);\n\n useFocusRingPortal(accordionRef, {\n isEnabled: shouldShowKeyboardHighlighting && isKeyboardFocusable,\n borderRadius: `${theme.cardBorderRadius}px`,\n });\n\n const isInKeyboardNavigationGroup =\n isKeyboardFocusable &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string';\n\n useEffect(() => {\n if (\n typeof accordionGroupUuid === 'string' &&\n typeof registerAccordionUuid === 'function' &&\n typeof unregisterAccordionUuid === 'function'\n ) {\n registerAccordionUuid(uuid);\n\n return () => {\n unregisterAccordionUuid(uuid);\n };\n }\n\n return undefined;\n }, [accordionGroupUuid, registerAccordionUuid, unregisterAccordionUuid, uuid]);\n\n const isLastAccordion = useMemo(\n () => (accordionUuids ? accordionUuids[accordionUuids.length - 1] === uuid : false),\n [accordionUuids, uuid],\n );\n\n useEffect(() => {\n isOpenRef.current = isOpen;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n const handleHeadClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function') {\n updateActiveAccordionUuid(uuid);\n }\n\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n }\n\n setIsAccordionOpen((currentIsAccordionOpen) => !currentIsAccordionOpen);\n }, [isDisabled, isKeyboardFocusable, updateActiveAccordionUuid, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (isDisabled && isOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n }\n\n setIsAccordionOpen((currentIsAccordionOpen) => !currentIsAccordionOpen);\n }\n }, [isDisabled, isOpen, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });\n } else {\n setIsAccordionOpen(true);\n }\n }\n }, [isDefaultOpen, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (typeof isOpened === 'boolean') {\n if (typeof updateOpenAccordionUuid === 'function' && isOpened !== isOpenRef.current) {\n updateOpenAccordionUuid(uuid);\n } else {\n setIsAccordionOpen(isOpened);\n }\n }\n }, [isOpened, updateOpenAccordionUuid, uuid]);\n\n const accordionContextProviderValue = useMemo(\n () => ({ isWrapped: isWrapped === true }),\n [isWrapped],\n );\n\n const areaContextProviderValue = useMemo(\n () => ({ shouldChangeColor: !shouldHideBackground }),\n [shouldHideBackground],\n );\n\n const accordionWrappedContextProviderValue = useMemo(() => ({ isWrapped: true }), []);\n\n const initialAnimation = useMemo(() => {\n if (shouldSkipAnimation) {\n return { height: 'auto', opacity: 1 };\n }\n\n return isOpen ? { height: 'auto', opacity: 1 } : { height: 0, opacity: 0 };\n }, [isOpen, shouldSkipAnimation]);\n\n const tabIndex = useMemo(() => (isKeyboardFocusable ? 0 : -1), [isKeyboardFocusable]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentAccordionTarget = e.currentTarget === e.target;\n\n if (\n isCurrentAccordionTarget &&\n isInKeyboardNavigationGroup &&\n accordionUuids?.length &&\n (e.key === 'ArrowDown' || e.key === 'ArrowUp')\n ) {\n e.preventDefault();\n const currentIndex = accordionUuids.indexOf(uuid);\n\n if (currentIndex !== -1) {\n const nextIndex =\n e.key === 'ArrowDown'\n ? (currentIndex + 1) % accordionUuids.length\n : (currentIndex - 1 + accordionUuids.length) % accordionUuids.length;\n const nextAccordionUuid = accordionUuids[nextIndex];\n\n if (nextAccordionUuid && nextAccordionUuid !== uuid) {\n const nextAccordionElement = document.querySelector<HTMLDivElement>(\n `[data-uuid=\"${accordionGroupUuid}---${nextAccordionUuid}\"]`,\n );\n\n if (nextAccordionElement) {\n updateActiveAccordionUuid(nextAccordionUuid);\n nextAccordionElement.focus();\n return;\n }\n }\n }\n }\n\n if (\n isCurrentAccordionTarget &&\n (e.key === 'Enter' || e.key === ' ') &&\n isKeyboardFocusable\n ) {\n handleHeadClick();\n }\n\n if (\n isCurrentAccordionTarget &&\n e.key === 'ArrowRight' &&\n isKeyboardFocusable &&\n !isOpen\n ) {\n e.preventDefault();\n handleHeadClick();\n }\n\n if (isCurrentAccordionTarget && (e.key === 'Escape' || e.key === 'ArrowLeft')) {\n if (isOpen && isKeyboardFocusable) {\n e.preventDefault();\n handleHeadClick();\n return;\n }\n\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n e.preventDefault();\n updateActiveAccordionUuid(undefined);\n let parentAccordion =\n e.currentTarget.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n while (parentAccordion) {\n const parentGroupId = parentAccordion\n .getAttribute('data-uuid')\n ?.split('---')[0];\n if (parentGroupId !== accordionGroupUuid) {\n parentAccordion.focus();\n break;\n }\n parentAccordion =\n parentAccordion.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n }\n }\n }\n },\n [\n accordionGroupUuid,\n accordionUuids,\n handleHeadClick,\n isInKeyboardNavigationGroup,\n isKeyboardFocusable,\n isOpen,\n updateActiveAccordionUuid,\n uuid,\n ],\n );\n\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n e.currentTarget === e.target &&\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n setIsGroupFocusWithin(true);\n updateActiveAccordionUuid(uuid);\n }\n },\n [isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string'\n ) {\n const nextFocusedElement = e.relatedTarget as Node | null;\n const currentGroupElement = e.currentTarget as HTMLElement;\n\n if (!nextFocusedElement || !currentGroupElement.contains(nextFocusedElement)) {\n setIsGroupFocusWithin(false);\n updateActiveAccordionUuid(undefined);\n }\n }\n },\n [accordionGroupUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid],\n );\n\n useEffect(() => {\n if (!isInKeyboardNavigationGroup) {\n setIsGroupFocusWithin(false);\n } else if (\n activeAccordionUuid == null &&\n typeof updateActiveAccordionUuid === 'function' &&\n accordionUuids?.[0] === uuid\n ) {\n updateActiveAccordionUuid(uuid);\n }\n }, [\n accordionUuids,\n activeAccordionUuid,\n isInKeyboardNavigationGroup,\n updateActiveAccordionUuid,\n uuid,\n ]);\n\n return (\n <StyledMotionAccordion\n ref={accordionRef}\n animate={{ height: 'auto', opacity: 1 }}\n data-uuid={`${accordionGroupUuid ?? ''}---${uuid}`}\n className=\"beta-chayns-accordion\"\n exit={{ height: 0, opacity: 0 }}\n initial={initialAnimation}\n $isOpen={isOpen}\n tabIndex={tabIndex}\n $shouldShowLines={!isLastAccordion || !isWrapped}\n $isParentWrapped={isParentWrapped}\n $isWrapped={isWrapped}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBackground={shouldHideBackground}\n $shouldHideBottomLine={shouldHideBottomLine}\n $bottomBorderColor={colors?.borderBottomColor}\n $shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onMouseEnter={onHoverStart}\n onMouseLeave={onHoverEnd}\n transition={{ duration: shouldSkipAnimation ? 0 : 0.25 }}\n >\n <AccordionContext.Provider value={accordionContextProviderValue}>\n <MotionConfig transition={{ type: 'tween' }}>\n <AccordionHead\n uuid={uuid}\n icon={icon}\n isOpen={isOpen}\n shouldSkipAnimation={shouldSkipAnimation}\n isFixed={isFixed}\n isTitleGreyed={isTitleGreyed || isDisabled}\n isWrapped={isWrapped === true}\n onClick={handleHeadClick}\n onSearchChange={onSearchChange}\n rightElement={rightElement}\n searchPlaceholder={searchPlaceholder}\n searchValue={searchValue}\n shouldRotateIcon={shouldRotateIcon}\n title={title}\n titleElement={titleElement}\n onTitleInputChange={onTitleInputChange}\n titleInputProps={titleInputProps}\n titleColor={colors?.titleColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n />\n <AnimatePresence initial={false}>\n {(isOpen || shouldRenderClosed) && (\n <AccordionBody\n shouldSkipAnimation={shouldSkipAnimation}\n maxHeight={bodyMaxHeight}\n onScroll={onBodyScroll}\n onAnimationComplete={onBodyAnimationComplete}\n shouldHideBody={shouldRenderClosed && !isOpen}\n >\n <AccordionWrappedContext.Provider\n value={accordionWrappedContextProviderValue}\n >\n <AreaContext.Provider value={areaContextProviderValue}>\n {children}\n </AreaContext.Provider>\n </AccordionWrappedContext.Provider>\n </AccordionBody>\n )}\n </AnimatePresence>\n </MotionConfig>\n </AccordionContext.Provider>\n </StyledMotionAccordion>\n );\n};\n\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,cAAc;AAC5D,OAAOC,KAAK,IAORC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,OAAO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reList":[]}
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":["AnimatePresence","MotionConfig","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useTheme","useUuid","useFocusRingPortal","useKeyboardFocusHighlighting","AreaContext","useColorScheme","AccordionBody","AccordionGroupContext","AccordionHead","AccordionWrappedContext","StyledMotionAccordion","useInitialRenderRef","AccordionContext","createContext","isWrapped","undefined","Accordion","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onHoverEnd","onHoverStart","onOpen","onSearchChange","rightElement","searchPlaceholder","searchValue","shouldForceBackground","shouldForceBottomLine","shouldHideBackground","shouldRenderClosed","shouldRotateIcon","shouldHideBottomLine","title","titleElement","onTitleInputChange","titleInputProps","shouldSkipAnimation","shouldSkipAnimationProp","colors","shouldIndex","onBodyAnimationComplete","shouldEnableKeyboardHighlighting","theme","groupIsWrapped","openAccordionUuid","accordionGroupUuid","accordionUuids","updateOpenAccordionUuid","activeAccordionUuid","updateActiveAccordionUuid","registerAccordionUuid","unregisterAccordionUuid","isParentWrapped","contextIsWrapped","colorScheme","shouldEnableKeyboardHighlightingEffective","isControlled","internalOpen","setInternalOpen","uuid","isInitialRenderRef","accordionRef","initialRenderSkipRef","current","isInGroup","isOpen","isOpenRef","onCloseRef","onOpenRef","shouldShowKeyboardHighlighting","isKeyboardFocusable","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","isLastAccordion","length","handleHeadClick","prev","shouldOnlyOpen","accordionContextProviderValue","areaContextProviderValue","shouldChangeColor","accordionWrappedContextProviderValue","initialAnimation","height","opacity","tabIndex","handleKeyDown","e","isCurrentAccordionTarget","currentTarget","target","key","preventDefault","currentIndex","indexOf","nextIndex","nextAccordionUuid","nextAccordionElement","document","querySelector","focus","parentAccordion","parentElement","closest","parentGroupId","getAttribute","split","handleFocus","handleBlur","nextFocusedElement","relatedTarget","currentGroupElement","contains","createElement","ref","animate","className","exit","initial","$isOpen","$shouldShowLines","$isParentWrapped","$isWrapped","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBackground","$shouldHideBottomLine","$bottomBorderColor","borderBottomColor","$shouldEnableKeyboardHighlighting","$shouldShowKeyboardHighlighting","onKeyDown","onFocus","onBlur","onMouseEnter","onMouseLeave","transition","duration","Provider","value","type","onClick","titleColor","maxHeight","onScroll","onAnimationComplete","shouldHideBody","displayName"],"sources":["../../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import { AnimatePresence, MotionConfig } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n type MouseEventHandler,\n ReactNode,\n UIEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../hooks/uuid';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputProps } from '../input/Input';\nimport AccordionBody from './accordion-body/AccordionBody';\nimport { AccordionGroupContext } from './accordion-group/AccordionGroup';\nimport AccordionHead from './accordion-head/AccordionHead';\nimport { AccordionWrappedContext } from './accordion-provider/AccordionContextProvider';\nimport { StyledMotionAccordion } from './Accordion.styles';\nimport { useInitialRenderRef } from '../../hooks/ref';\n\nexport const AccordionContext = React.createContext<{ isWrapped?: boolean }>({\n isWrapped: undefined,\n});\n\ntype AccordionColors = {\n titleColor?: CSSProperties['color'];\n borderBottomColor?: CSSProperties['borderBottomColor'];\n};\n\nexport type AccordionProps = {\n /**\n * Maximum height of the accordion body element. This automatically makes the content of the\n * body element scrollable.\n */\n bodyMaxHeight?: number;\n /**\n * The content of the accordion body\n */\n children: ReactNode;\n /**\n * The icon that is displayed in front of the title\n */\n icon?: string;\n /**\n * This can be used to automatically expand the Accordion during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This will disable the Accordion so that it cannot be opened and will gray out the title. Does not work with isOpened.\n */\n isDisabled?: boolean;\n /**\n * This can be used so that the Accordion cannot be opened or closed.\n * In addition, in this case the icon is exchanged to mark the Accordions.\n */\n isFixed?: boolean;\n /**\n * This can be used to open the Accordion from the outside\n */\n isOpened?: boolean;\n /**\n * This will gray out the title of the Accordion to indicate hidden content, for example.\n */\n isTitleGreyed?: boolean;\n /**\n * Function that is executed when the accordion body will be scrolled\n */\n onBodyScroll?: (event: UIEvent<HTMLDivElement>) => void;\n /**\n * Function that is executed when the accordion will be closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the accordion is no longer hovered.\n */\n onHoverEnd?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the accordion is hovered.\n */\n onHoverStart?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the accordion will be opened.\n */\n onOpen?: VoidFunction;\n /**\n * Function that is executed when the accordion body is animated\n */\n onBodyAnimationComplete?: VoidFunction;\n /**\n * Function that is executed when the text of the search in the accordion\n * head changes. When this function is given, the search field is displayed\n * in the Accordion Head.\n */\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the search in the accordion\n * title changes. When this function is given, the search field is displayed\n * as the Accordion title.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Content to be displayed on the right side in the head of the Accordion\n */\n rightElement?: ReactNode;\n /**\n * The placeholder to be used for the search\n */\n searchPlaceholder?: string;\n /**\n * The value that is displayed inside the search\n */\n searchValue?: string;\n /**\n * This will force the background color of the accordion to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * This will hide the background color of the accordion\n */\n shouldHideBackground?: boolean;\n /**\n * Whether the bottom line should always be shown, regardless of other line-related props.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * This will render the Accordion closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the icon should be rotating.\n */\n shouldRotateIcon?: boolean;\n /**\n * Whether the animation should be skipped.\n * If 'isDefaultOpen' is true the initial animation will be skipped even this prop is false\n */\n shouldSkipAnimation?: boolean;\n /**\n * Title of the Accordion displayed in the head\n */\n title?: string;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n /**\n * The props of the title Input.\n */\n titleInputProps?: InputProps;\n /**\n * Provide custom colors to the Accordion Component\n */\n colors?: AccordionColors;\n /**\n * Whether the accordion should be indexed.\n */\n shouldIndex?: boolean;\n /**\n * Enables keyboard-only focus highlighting. The highlighting is only visible while the\n * user navigates with the keyboard and is reset on mouse movement or click.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst Accordion: FC<AccordionProps> = ({\n bodyMaxHeight,\n children,\n icon,\n isDefaultOpen = false,\n isDisabled = false,\n isFixed = false,\n isOpened,\n isTitleGreyed = false,\n onBodyScroll,\n onClose,\n onHoverEnd,\n onHoverStart,\n onOpen,\n onSearchChange,\n rightElement,\n searchPlaceholder,\n searchValue,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldHideBackground = false,\n shouldRenderClosed = false,\n shouldRotateIcon = true,\n shouldHideBottomLine = false,\n title,\n titleElement,\n onTitleInputChange,\n titleInputProps,\n shouldSkipAnimation: shouldSkipAnimationProp = false,\n colors,\n shouldIndex = false,\n onBodyAnimationComplete,\n shouldEnableKeyboardHighlighting,\n}) => {\n const theme = useTheme() as Theme;\n const {\n isWrapped: groupIsWrapped,\n openAccordionUuid,\n accordionGroupUuid,\n accordionUuids,\n updateOpenAccordionUuid,\n activeAccordionUuid,\n updateActiveAccordionUuid,\n registerAccordionUuid,\n unregisterAccordionUuid,\n } = useContext(AccordionGroupContext);\n const { isWrapped: isParentWrapped } = useContext(AccordionContext);\n\n const { isWrapped: contextIsWrapped } = useContext(AccordionWrappedContext);\n const colorScheme = useColorScheme();\n const shouldEnableKeyboardHighlightingEffective =\n shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;\n\n const isWrapped = useMemo(\n () => groupIsWrapped ?? contextIsWrapped,\n [contextIsWrapped, groupIsWrapped],\n );\n\n const isControlled = typeof isOpened === 'boolean';\n const [internalOpen, setInternalOpen] = useState<boolean>(isDefaultOpen ?? false);\n\n const uuid = useUuid();\n\n const isInitialRenderRef = useRef(true);\n const accordionRef = useRef<HTMLDivElement>(null);\n\n const initialRenderSkipRef = useInitialRenderRef(true);\n\n const shouldSkipAnimation =\n shouldSkipAnimationProp ?? (initialRenderSkipRef.current && isDefaultOpen);\n\n const isInGroup = shouldSkipAnimation ? false : typeof updateOpenAccordionUuid === 'function';\n\n const isOpen = (() => {\n if (isInGroup) return openAccordionUuid === uuid;\n if (isControlled) return isOpened;\n return internalOpen;\n })();\n\n const isOpenRef = useRef(isOpen);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlightingEffective,\n );\n const isKeyboardFocusable =\n !isDisabled && (shouldIndex || shouldEnableKeyboardHighlightingEffective);\n\n useFocusRingPortal(accordionRef, {\n isEnabled: shouldShowKeyboardHighlighting && isKeyboardFocusable,\n borderRadius: `${theme.cardBorderRadius ?? 0}px`,\n });\n\n const isInKeyboardNavigationGroup =\n isKeyboardFocusable &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string';\n\n useEffect(() => {\n if (\n typeof accordionGroupUuid === 'string' &&\n typeof registerAccordionUuid === 'function' &&\n typeof unregisterAccordionUuid === 'function'\n ) {\n registerAccordionUuid(uuid);\n\n return () => {\n unregisterAccordionUuid(uuid);\n };\n }\n\n return undefined;\n }, [accordionGroupUuid, registerAccordionUuid, unregisterAccordionUuid, uuid]);\n\n const isLastAccordion = useMemo(\n () => (accordionUuids ? accordionUuids[accordionUuids.length - 1] === uuid : false),\n [accordionUuids, uuid],\n );\n\n useEffect(() => {\n isOpenRef.current = isOpen;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n const handleHeadClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function') {\n updateActiveAccordionUuid(uuid);\n }\n\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n } else if (!isControlled) {\n setInternalOpen((prev: boolean) => !prev);\n }\n\n if (isOpen) {\n onClose?.();\n } else {\n onOpen?.();\n }\n }, [\n isDisabled,\n isKeyboardFocusable,\n updateActiveAccordionUuid,\n updateOpenAccordionUuid,\n uuid,\n isOpen,\n onClose,\n onOpen,\n isControlled,\n ]);\n\n useEffect(() => {\n if (isDisabled && isOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n } else if (typeof onClose === 'function') {\n onClose();\n } else {\n // Uncontrolled mode: use the internal state\n setInternalOpen(false);\n }\n }\n }, [isDisabled, isOpen, updateOpenAccordionUuid, uuid, onClose]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (!isControlled && isDefaultOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });\n } else if (typeof onOpen === 'function') {\n onOpen();\n } else {\n setInternalOpen(true);\n }\n }\n }, [isDefaultOpen, updateOpenAccordionUuid, uuid, onOpen, isControlled]);\n\n const accordionContextProviderValue = useMemo(\n () => ({ isWrapped: isWrapped === true }),\n [isWrapped],\n );\n\n const areaContextProviderValue = useMemo(\n () => ({ shouldChangeColor: !shouldHideBackground }),\n [shouldHideBackground],\n );\n\n const accordionWrappedContextProviderValue = useMemo(() => ({ isWrapped: true }), []);\n\n const initialAnimation = useMemo(() => {\n if (shouldSkipAnimation) {\n return { height: 'auto', opacity: 1 };\n }\n\n return isOpen ? { height: 'auto', opacity: 1 } : { height: 0, opacity: 0 };\n }, [isOpen, shouldSkipAnimation]);\n\n const tabIndex = useMemo(() => (isKeyboardFocusable ? 0 : -1), [isKeyboardFocusable]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentAccordionTarget = e.currentTarget === e.target;\n\n if (\n isCurrentAccordionTarget &&\n isInKeyboardNavigationGroup &&\n accordionUuids?.length &&\n (e.key === 'ArrowDown' || e.key === 'ArrowUp')\n ) {\n e.preventDefault();\n const currentIndex = accordionUuids.indexOf(uuid);\n\n if (currentIndex !== -1) {\n const nextIndex =\n e.key === 'ArrowDown'\n ? (currentIndex + 1) % accordionUuids.length\n : (currentIndex - 1 + accordionUuids.length) % accordionUuids.length;\n const nextAccordionUuid = accordionUuids[nextIndex];\n\n if (nextAccordionUuid && nextAccordionUuid !== uuid) {\n const nextAccordionElement = document.querySelector<HTMLDivElement>(\n `[data-uuid=\"${accordionGroupUuid}---${nextAccordionUuid}\"]`,\n );\n\n if (nextAccordionElement) {\n updateActiveAccordionUuid(nextAccordionUuid);\n nextAccordionElement.focus();\n return;\n }\n }\n }\n }\n\n if (\n isCurrentAccordionTarget &&\n (e.key === 'Enter' || e.key === ' ') &&\n isKeyboardFocusable\n ) {\n handleHeadClick();\n }\n\n if (\n isCurrentAccordionTarget &&\n e.key === 'ArrowRight' &&\n isKeyboardFocusable &&\n !isOpen\n ) {\n e.preventDefault();\n handleHeadClick();\n }\n\n if (isCurrentAccordionTarget && (e.key === 'Escape' || e.key === 'ArrowLeft')) {\n if (isOpen && isKeyboardFocusable) {\n e.preventDefault();\n handleHeadClick();\n return;\n }\n\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n e.preventDefault();\n updateActiveAccordionUuid(undefined);\n let parentAccordion =\n e.currentTarget.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n while (parentAccordion) {\n const parentGroupId = parentAccordion\n .getAttribute('data-uuid')\n ?.split('---')[0];\n if (parentGroupId !== accordionGroupUuid) {\n parentAccordion.focus();\n break;\n }\n parentAccordion =\n parentAccordion.parentElement?.closest<HTMLElement>(\n '.beta-chayns-accordion',\n );\n }\n }\n }\n },\n [\n accordionGroupUuid,\n accordionUuids,\n handleHeadClick,\n isInKeyboardNavigationGroup,\n isKeyboardFocusable,\n isOpen,\n updateActiveAccordionUuid,\n uuid,\n ],\n );\n\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n e.currentTarget === e.target &&\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function'\n ) {\n updateActiveAccordionUuid(uuid);\n }\n },\n [isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLDivElement>) => {\n if (\n isInKeyboardNavigationGroup &&\n typeof updateActiveAccordionUuid === 'function' &&\n typeof accordionGroupUuid === 'string'\n ) {\n const nextFocusedElement = e.relatedTarget as Node | null;\n const currentGroupElement = e.currentTarget as HTMLElement;\n\n if (!nextFocusedElement || !currentGroupElement.contains(nextFocusedElement)) {\n updateActiveAccordionUuid(undefined);\n }\n }\n },\n [accordionGroupUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid],\n );\n\n useEffect(() => {\n if (\n activeAccordionUuid == null &&\n typeof updateActiveAccordionUuid === 'function' &&\n accordionUuids?.[0] === uuid\n ) {\n updateActiveAccordionUuid(uuid);\n }\n }, [\n accordionUuids,\n activeAccordionUuid,\n isInKeyboardNavigationGroup,\n updateActiveAccordionUuid,\n uuid,\n ]);\n\n return (\n <StyledMotionAccordion\n ref={accordionRef}\n animate={{ height: 'auto', opacity: 1 }}\n data-uuid={`${accordionGroupUuid ?? ''}---${uuid}`}\n className=\"beta-chayns-accordion\"\n exit={{ height: 0, opacity: 0 }}\n initial={initialAnimation}\n $isOpen={isOpen}\n tabIndex={tabIndex}\n $shouldShowLines={!isLastAccordion || !isWrapped}\n $isParentWrapped={isParentWrapped}\n $isWrapped={isWrapped}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBackground={shouldHideBackground}\n $shouldHideBottomLine={shouldHideBottomLine}\n $bottomBorderColor={colors?.borderBottomColor}\n $shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onMouseEnter={onHoverStart}\n onMouseLeave={onHoverEnd}\n transition={{ duration: shouldSkipAnimation ? 0 : 0.25 }}\n >\n <AccordionContext.Provider value={accordionContextProviderValue}>\n <MotionConfig transition={{ type: 'tween' }}>\n <AccordionHead\n uuid={uuid}\n icon={icon}\n isOpen={isOpen}\n shouldSkipAnimation={shouldSkipAnimation}\n isFixed={isFixed}\n isTitleGreyed={isTitleGreyed || isDisabled}\n isWrapped={isWrapped === true}\n onClick={handleHeadClick}\n onSearchChange={onSearchChange}\n rightElement={rightElement}\n searchPlaceholder={searchPlaceholder}\n searchValue={searchValue}\n shouldRotateIcon={shouldRotateIcon}\n title={title}\n titleElement={titleElement}\n onTitleInputChange={onTitleInputChange}\n titleInputProps={titleInputProps}\n titleColor={colors?.titleColor}\n shouldEnableKeyboardHighlighting={shouldEnableKeyboardHighlightingEffective}\n />\n <AnimatePresence initial={false}>\n {(isOpen || shouldRenderClosed) && (\n <AccordionBody\n shouldSkipAnimation={shouldSkipAnimation}\n maxHeight={bodyMaxHeight}\n onScroll={onBodyScroll}\n onAnimationComplete={onBodyAnimationComplete}\n shouldHideBody={shouldRenderClosed && !isOpen}\n >\n <AccordionWrappedContext.Provider\n value={accordionWrappedContextProviderValue}\n >\n <AreaContext.Provider value={areaContextProviderValue}>\n {children}\n </AreaContext.Provider>\n </AccordionWrappedContext.Provider>\n </AccordionBody>\n )}\n </AnimatePresence>\n </MotionConfig>\n </AccordionContext.Provider>\n </StyledMotionAccordion>\n );\n};\n\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,cAAc;AAC5D,OAAOC,KAAK,IAORC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,4BAA4B,QAAQ,0CAA0C;AACvF,SAASC,WAAW,QAAQ,sCAAsC;AAClE,SAAqBC,cAAc,QAAQ,8CAA8C;AAEzF,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SAASC,uBAAuB,QAAQ,+CAA+C;AACvF,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,mBAAmB,QAAQ,iBAAiB;AAErD,OAAO,MAAMC,gBAAgB,gBAAGnB,KAAK,CAACoB,aAAa,CAA0B;EACzEC,SAAS,EAAEC;AACf,CAAC,CAAC;AAkJF,MAAMC,SAA6B,GAAGA,CAAC;EACnCC,aAAa;EACbC,QAAQ;EACRC,IAAI;EACJC,aAAa,GAAG,KAAK;EACrBC,UAAU,GAAG,KAAK;EAClBC,OAAO,GAAG,KAAK;EACfC,QAAQ;EACRC,aAAa,GAAG,KAAK;EACrBC,YAAY;EACZC,OAAO;EACPC,UAAU;EACVC,YAAY;EACZC,MAAM;EACNC,cAAc;EACdC,YAAY;EACZC,iBAAiB;EACjBC,WAAW;EACXC,qBAAqB,GAAG,KAAK;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AAQ,EAAEjI,YAAa;IACvBkI,mBAAmB,EAAE3G,uBAAwB;IAC7C4G,cAAc,EAAEvH,kBAAkB,IAAI,CAACoC;EAAO,gBAE9ChF,KAAA,CAAAkI,aAAA,CAAClH,uBAAuB,CAAC2I,QAAQ;IAC7BC,KAAK,EAAE1D;EAAqC,gBAE5ClG,KAAA,CAAAkI,aAAA,CAACvH,WAAW,CAACgJ,QAAQ;IAACC,KAAK,EAAE5D;EAAyB,GACjDvE,QACiB,CACQ,CACvB,CAEN,CACP,CACS,CACR,CAAC;AAEhC,CAAC;AAEDF,SAAS,CAAC6I,WAAW,GAAG,WAAW;AAEnC,eAAe7I,SAAS","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;
|
|
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,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} 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,
|
|
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":[]}
|