@chayns-components/core 5.5.24 → 5.5.25

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 (25) hide show
  1. package/AGENTS.md +44 -0
  2. package/lib/cjs/components/copyable-content/CopyableContent.test.js +38 -4
  3. package/lib/cjs/components/copyable-content/CopyableContent.test.js.map +1 -1
  4. package/lib/cjs/components/truncation/Truncation.js +61 -149
  5. package/lib/cjs/components/truncation/Truncation.js.map +1 -1
  6. package/lib/cjs/components/truncation/Truncation.styles.js +3 -4
  7. package/lib/cjs/components/truncation/Truncation.styles.js.map +1 -1
  8. package/lib/cjs/components/truncation/Truncation.test.js +61 -0
  9. package/lib/cjs/components/truncation/Truncation.test.js.map +1 -0
  10. package/lib/esm/components/copyable-content/CopyableContent.test.js +38 -4
  11. package/lib/esm/components/copyable-content/CopyableContent.test.js.map +1 -1
  12. package/lib/esm/components/truncation/Truncation.js +61 -149
  13. package/lib/esm/components/truncation/Truncation.js.map +1 -1
  14. package/lib/esm/components/truncation/Truncation.styles.js +2 -3
  15. package/lib/esm/components/truncation/Truncation.styles.js.map +1 -1
  16. package/lib/esm/components/truncation/Truncation.test.js +58 -0
  17. package/lib/esm/components/truncation/Truncation.test.js.map +1 -0
  18. package/lib/types/components/truncation/Truncation.d.ts +1 -1
  19. package/lib/types/components/truncation/Truncation.styles.d.ts +1 -1
  20. package/package.json +2 -2
  21. package/lib/cjs/utils/truncation.js +0 -42
  22. package/lib/cjs/utils/truncation.js.map +0 -1
  23. package/lib/esm/utils/truncation.js +0 -35
  24. package/lib/esm/utils/truncation.js.map +0 -1
  25. package/lib/types/utils/truncation.d.ts +0 -1
package/AGENTS.md CHANGED
@@ -1497,6 +1497,25 @@ import { CopyableContent } from '@chayns-components/core';
1497
1497
  />
1498
1498
  ```
1499
1499
 
1500
+ #### Collapsed
1501
+
1502
+ ```tsx
1503
+ <CopyableContent
1504
+ collapsedHeight={180}
1505
+ content={Array.from(
1506
+ { length: 12 },
1507
+ (_, index) =>
1508
+ `### Abschnitt ${index + 1}\n\nDas Planungsteam hat die Hinweise aus den Gesprächen aufgenommen und bereitet jetzt die nächsten Schritte vor.`,
1509
+ ).join('\n\n')}
1510
+ />
1511
+ ```
1512
+
1513
+ #### Typewriter Loop
1514
+
1515
+ ```tsx
1516
+ <CopyableContent />
1517
+ ```
1518
+
1500
1519
  #### Markdown
1501
1520
 
1502
1521
  ```tsx
@@ -5075,6 +5094,31 @@ import { Button, Truncation } from '@chayns-components/core';
5075
5094
  </Truncation>
5076
5095
  ```
5077
5096
 
5097
+ #### Typewriter Loop
5098
+
5099
+ ```tsx
5100
+ <Truncation
5101
+ collapsedHeight={100}
5102
+ >
5103
+ {
5104
+ <div>
5105
+ <p id="isPasted">
5106
+ Der legendärste Abend: Homecoming at next! Studenten und Ausreißer, Urlauber und
5107
+ Daheimgebliebene, Partymäuse und Partymuffel – sie alle zieht es am Tag vor Heiligabend
5108
+ in die Heimat an einen zuvor ausgemachten Ort, um all die guten Freunde und alte
5109
+ Bekannte wiederzutreffen.
5110
+ </p>
5111
+ <p>
5112
+ Was damals vor vielen Jahren auf der StattAlm auf dem Campus in Ahaus begann, führen wir
5113
+ bei uns im next fort!&nbsp;
5114
+ </p>
5115
+ <p>Alle Infos und Tickets zum Event in Kürze.&nbsp;</p>
5116
+ <Button onClick={() => alert('hallo')}>test</Button>
5117
+ </div>
5118
+ }
5119
+ </Truncation>
5120
+ ```
5121
+
5078
5122
  #### Small Text
5079
5123
 
5080
5124
  ```tsx
@@ -7,6 +7,37 @@ var _CopyableContent = _interopRequireDefault(require("./CopyableContent"));
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
8
  /* eslint-disable @typescript-eslint/no-unsafe-call */
9
9
 
10
+ _vitest.vi.mock('@chayns-components/textstring', () => ({
11
+ Textstring: ({
12
+ textstring
13
+ }) => textstring.fallback,
14
+ TextstringProvider: ({
15
+ children
16
+ }) => children,
17
+ ttsToITextString: textstring => textstring,
18
+ useTextstringValue: ({
19
+ textstring
20
+ }) => textstring.fallback
21
+ }));
22
+ const resizeObserverCallbacks = [];
23
+ class ResizeObserverMock {
24
+ constructor(callback) {
25
+ resizeObserverCallbacks.push(callback);
26
+ }
27
+ disconnect() {}
28
+ observe() {}
29
+ unobserve() {}
30
+ }
31
+ _vitest.vi.stubGlobal('ResizeObserver', ResizeObserverMock);
32
+ const triggerResize = height => {
33
+ resizeObserverCallbacks.forEach(callback => {
34
+ callback([{
35
+ contentRect: {
36
+ height
37
+ }
38
+ }]);
39
+ });
40
+ };
10
41
  _vitest.vi.mock('../icon/Icon', () => ({
11
42
  default: ({
12
43
  icons
@@ -88,14 +119,17 @@ const readBlob = blob => new Promise((resolve, reject) => {
88
119
  (0, _vitest.expect)(container.querySelector('[data-copy-action="false"]')).toBeInTheDocument();
89
120
  (0, _vitest.expect)(container.querySelector('[data-calling-code-action="false"]')).toBeInTheDocument();
90
121
  });
91
- (0, _vitest.it)('supports collapsed content', () => {
122
+ (0, _vitest.it)('supports collapsed content', async () => {
92
123
  (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_CopyableContent.default, {
93
124
  collapsedHeight: 100,
94
125
  content: Array(20).fill('Long content').join('\n\n')
95
126
  }));
96
- (0, _vitest.expect)(_react.screen.getByRole('button', {
97
- name: 'Mehr anzeigen'
98
- })).toBeInTheDocument();
127
+ triggerResize(240);
128
+ await (0, _react.waitFor)(() => {
129
+ (0, _vitest.expect)(_react.screen.getByRole('button', {
130
+ name: 'Mehr'
131
+ })).toBeInTheDocument();
132
+ });
99
133
  });
100
134
  });
101
135
  //# sourceMappingURL=CopyableContent.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyableContent.test.js","names":["_react","require","_react2","_interopRequireDefault","_vitest","_CopyableContent","e","__esModule","default","vi","mock","icons","createElement","join","children","shouldShowCallingCodeAction","shouldShowCopyAction","importOriginal","createDialog","fn","open","readBlob","blob","Promise","resolve","reject","reader","FileReader","onerror","error","onload","result","readAsText","describe","it","render","content","expect","screen","getByRole","name","toBeInTheDocument","toHaveAttribute","document","querySelector","not","write","spyOn","navigator","clipboard","mockResolvedValue","fireEvent","click","waitFor","toHaveBeenCalled","item","calls","getType","resolves","toBe","container","collapsedHeight","Array","fill"],"sources":["../../../../src/components/copyable-content/CopyableContent.test.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { fireEvent, render, screen, waitFor } from '@testing-library/react';\nimport React from 'react';\nimport { describe, expect, it, vi } from 'vitest';\nimport CopyableContent from './CopyableContent';\n\nvi.mock('../icon/Icon', () => ({\n default: ({ icons }: { icons: string[] }) => <span data-icons={icons.join(' ')} />,\n}));\n\nvi.mock('../sharing-context-menu/SharingContextMenu', () => ({\n default: ({\n children,\n shouldShowCallingCodeAction,\n shouldShowCopyAction,\n }: {\n children: React.ReactNode;\n shouldShowCallingCodeAction?: boolean;\n shouldShowCopyAction?: boolean;\n }) => (\n <div\n data-calling-code-action={shouldShowCallingCodeAction}\n data-copy-action={shouldShowCopyAction}\n >\n {children}\n </div>\n ),\n}));\n\nvi.mock('chayns-api', async (importOriginal) => ({\n ...(await importOriginal<typeof import('chayns-api')>()),\n createDialog: vi.fn(() => ({ open: vi.fn() })),\n}));\n\nconst readBlob = (blob: Blob) =>\n new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () => reject(reader.error);\n reader.onload = () => resolve(reader.result as string);\n reader.readAsText(blob);\n });\n\ndescribe('CopyableContent', () => {\n it('renders formatted markdown without active input HTML', () => {\n render(\n <CopyableContent\n content={\n '# Heading\\n\\n- Entry\\n\\n[Link](https://example.com)\\n<script onload=\"x\">bad</script>'\n }\n />,\n );\n\n expect(screen.getByRole('heading', { name: 'Heading' })).toBeInTheDocument();\n expect(screen.getByRole('link', { name: 'Link' })).toHaveAttribute(\n 'href',\n 'https://example.com',\n );\n expect(document.querySelector('script')).not.toBeInTheDocument();\n expect(document.querySelector('[onload]')).not.toBeInTheDocument();\n });\n\n it('copies content instead of custom children', async () => {\n const write = vi.spyOn(navigator.clipboard, 'write').mockResolvedValue();\n render(<CopyableContent content=\"source markdown\">Visible replacement</CopyableContent>);\n\n fireEvent.click(screen.getByRole('button', { name: 'Kopieren' }));\n\n await waitFor(() => expect(write).toHaveBeenCalled());\n const item = write.mock.calls[0][0][0] as unknown as ClipboardItem;\n await expect(readBlob(await item.getType('text/plain'))).resolves.toBe('source markdown');\n });\n\n it('shows a checkmark after a successful copy', async () => {\n vi.spyOn(navigator.clipboard, 'write').mockResolvedValue();\n const { container } = render(<CopyableContent content=\"source\" />);\n\n fireEvent.click(screen.getByRole('button', { name: 'Kopieren' }));\n\n await waitFor(() => {\n expect(container.querySelector('[data-icons=\"fa fa-check\"]')).toBeInTheDocument();\n });\n });\n\n it('offers sharing actions', () => {\n const { container } = render(<CopyableContent content=\"source\" />);\n\n expect(screen.getByRole('button', { name: 'Teilen' })).toBeInTheDocument();\n expect(container.querySelector('[data-copy-action=\"false\"]')).toBeInTheDocument();\n expect(container.querySelector('[data-calling-code-action=\"false\"]')).toBeInTheDocument();\n });\n\n it('supports collapsed content', () => {\n render(\n <CopyableContent\n collapsedHeight={100}\n content={Array(20).fill('Long content').join('\\n\\n')}\n />,\n );\n\n expect(screen.getByRole('button', { name: 'Mehr anzeigen' })).toBeInTheDocument();\n });\n});\n"],"mappings":";;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAgD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAJhD;;AAMAG,UAAE,CAACC,IAAI,CAAC,cAAc,EAAE,OAAO;EAC3BF,OAAO,EAAEA,CAAC;IAAEG;EAA2B,CAAC,kBAAKT,OAAA,C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AAM;IACnC,IAAAC,aAAM,eACFjC,OAAA,CAAAM,OAAA,CAAAI,aAAA,CAACP,gBAAA,CAAAG,OAAe;MACZqD,eAAe,EAAE,GAAI;MACrBzB,OAAO,EAAE0B,KAAK,CAAC,EAAE,CAAC,CAACC,IAAI,CAAC,cAAc,CAAC,CAAClD,IAAI,CAAC,MAAM;IAAE,CACxD,CACL,CAAC;IAED,IAAAwB,cAAM,EAACC,aAAM,CAACC,SAAS,CAAC,QAAQ,EAAE;MAAEC,IAAI,EAAE;IAAgB,CAAC,CAAC,CAAC,CAACC,iBAAiB,CAAC,CAAC;EACrF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"CopyableContent.test.js","names":["_react","require","_react2","_interopRequireDefault","_vitest","_CopyableContent","e","__esModule","default","vi","mock","Textstring","textstring","fallback","TextstringProvider","children","ttsToITextString","useTextstringValue","resizeObserverCallbacks","ResizeObserverMock","constructor","callback","push","disconnect","observe","unobserve","stubGlobal","triggerResize","height","forEach","contentRect","icons","createElement","join","shouldShowCallingCodeAction","shouldShowCopyAction","importOriginal","createDialog","fn","open","readBlob","blob","Promise","resolve","reject","reader","FileReader","onerror","error","onload","result","readAsText","describe","it","render","content","expect","screen","getByRole","name","toBeInTheDocument","toHaveAttribute","document","querySelector","not","write","spyOn","navigator","clipboard","mockResolvedValue","fireEvent","click","waitFor","toHaveBeenCalled","item","calls","getType","resolves","toBe","container","collapsedHeight","Array","fill"],"sources":["../../../../src/components/copyable-content/CopyableContent.test.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { fireEvent, render, screen, waitFor } from '@testing-library/react';\nimport React from 'react';\nimport { describe, expect, it, vi } from 'vitest';\nimport CopyableContent from './CopyableContent';\n\nvi.mock('@chayns-components/textstring', () => ({\n Textstring: ({ textstring }: { textstring: { fallback: string } }) => textstring.fallback,\n TextstringProvider: ({ children }: { children: React.ReactNode }) => children,\n ttsToITextString: (textstring: { fallback: string }) => textstring,\n useTextstringValue: ({ textstring }: { textstring: { fallback: string } }) =>\n textstring.fallback,\n}));\n\ntype ResizeObserverCallback = (entries: ResizeObserverEntry[]) => void;\n\nconst resizeObserverCallbacks: ResizeObserverCallback[] = [];\n\nclass ResizeObserverMock {\n constructor(callback: ResizeObserverCallback) {\n resizeObserverCallbacks.push(callback);\n }\n\n disconnect() {}\n\n observe() {}\n\n unobserve() {}\n}\n\nvi.stubGlobal('ResizeObserver', ResizeObserverMock);\n\nconst triggerResize = (height: number) => {\n resizeObserverCallbacks.forEach((callback) => {\n callback([\n {\n contentRect: { height } as DOMRectReadOnly,\n } as ResizeObserverEntry,\n ]);\n });\n};\n\nvi.mock('../icon/Icon', () => ({\n default: ({ icons }: { icons: string[] }) => <span data-icons={icons.join(' ')} />,\n}));\n\nvi.mock('../sharing-context-menu/SharingContextMenu', () => ({\n default: ({\n children,\n shouldShowCallingCodeAction,\n shouldShowCopyAction,\n }: {\n children: React.ReactNode;\n shouldShowCallingCodeAction?: boolean;\n shouldShowCopyAction?: boolean;\n }) => (\n <div\n data-calling-code-action={shouldShowCallingCodeAction}\n data-copy-action={shouldShowCopyAction}\n >\n {children}\n </div>\n ),\n}));\n\nvi.mock('chayns-api', async (importOriginal) => ({\n ...(await importOriginal<typeof import('chayns-api')>()),\n createDialog: vi.fn(() => ({ open: vi.fn() })),\n}));\n\nconst readBlob = (blob: Blob) =>\n new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () => reject(reader.error);\n reader.onload = () => resolve(reader.result as string);\n reader.readAsText(blob);\n });\n\ndescribe('CopyableContent', () => {\n it('renders formatted markdown without active input HTML', () => {\n render(\n <CopyableContent\n content={\n '# Heading\\n\\n- Entry\\n\\n[Link](https://example.com)\\n<script onload=\"x\">bad</script>'\n }\n />,\n );\n\n expect(screen.getByRole('heading', { name: 'Heading' })).toBeInTheDocument();\n expect(screen.getByRole('link', { name: 'Link' })).toHaveAttribute(\n 'href',\n 'https://example.com',\n );\n expect(document.querySelector('script')).not.toBeInTheDocument();\n expect(document.querySelector('[onload]')).not.toBeInTheDocument();\n });\n\n it('copies content instead of custom children', async () => {\n const write = vi.spyOn(navigator.clipboard, 'write').mockResolvedValue();\n render(<CopyableContent content=\"source markdown\">Visible replacement</CopyableContent>);\n\n fireEvent.click(screen.getByRole('button', { name: 'Kopieren' }));\n\n await waitFor(() => expect(write).toHaveBeenCalled());\n const item = write.mock.calls[0][0][0] as unknown as ClipboardItem;\n await expect(readBlob(await item.getType('text/plain'))).resolves.toBe('source markdown');\n });\n\n it('shows a checkmark after a successful copy', async () => {\n vi.spyOn(navigator.clipboard, 'write').mockResolvedValue();\n const { container } = render(<CopyableContent content=\"source\" />);\n\n fireEvent.click(screen.getByRole('button', { name: 'Kopieren' }));\n\n await waitFor(() => {\n expect(container.querySelector('[data-icons=\"fa fa-check\"]')).toBeInTheDocument();\n });\n });\n\n it('offers sharing actions', () => {\n const { container } = render(<CopyableContent content=\"source\" />);\n\n expect(screen.getByRole('button', { name: 'Teilen' })).toBeInTheDocument();\n expect(container.querySelector('[data-copy-action=\"false\"]')).toBeInTheDocument();\n expect(container.querySelector('[data-calling-code-action=\"false\"]')).toBeInTheDocument();\n });\n\n it('supports collapsed content', async () => {\n render(\n <CopyableContent\n collapsedHeight={100}\n content={Array(20).fill('Long content').join('\\n\\n')}\n />,\n );\n\n triggerResize(240);\n\n await waitFor(() => {\n expect(screen.getByRole('button', { name: 'Mehr' })).toBeInTheDocument();\n });\n });\n});\n"],"mappings":";;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAgD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAJhD;;AAMAG,UAAE,CAACC,IAA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AAG,CAAC;IAElB,MAAM,IAAA6C,cAAO,EAAC,MAAM;MAChB,IAAAhB,cAAM,EAACC,aAAM,CAACC,SAAS,CAAC,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAO,CAAC,CAAC,CAAC,CAACC,iBAAiB,CAAC,CAAC;IAC5E,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _textstring = require("@chayns-components/textstring");
7
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _useKeyboardFocusHighlighting = require("../../hooks/useKeyboardFocusHighlighting");
10
+ var _textStrings = _interopRequireDefault(require("../../constants/textStrings"));
8
11
  var _truncation = require("../../types/truncation");
9
- var _debounce = require("../../utils/debounce");
10
- var _truncation2 = require("../../utils/truncation");
11
12
  var _Truncation = require("./Truncation.styles");
12
- var _textstring = require("@chayns-components/textstring");
13
- var _textStrings = _interopRequireDefault(require("../../constants/textStrings"));
14
- var _useKeyboardFocusHighlighting = require("../../hooks/useKeyboardFocusHighlighting");
15
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
15
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
@@ -19,47 +17,62 @@ const Truncation = ({
19
17
  collapsedHeight = 150,
20
18
  clampPosition = _truncation.ClampPosition.Right,
21
19
  isOpen,
22
- moreLabel,
23
20
  lessLabel,
21
+ moreLabel,
24
22
  onChange,
25
23
  children,
26
24
  shouldEnableKeyboardHighlighting
27
25
  }) => {
28
26
  const shouldShowKeyboardHighlighting = (0, _useKeyboardFocusHighlighting.useKeyboardFocusHighlighting)(shouldEnableKeyboardHighlighting);
29
- const [internalIsOpen, setInternalIsOpen] = (0, _react.useState)(false);
30
- const [showClamp, setShowClamp] = (0, _react.useState)(true);
31
- const [newCollapsedHeight, setNewCollapsedHeight] = (0, _react.useState)(collapsedHeight);
32
- const [originalHeight, setOriginalHeight] = (0, _react.useState)(0);
33
- const [shouldShowCollapsedElement, setShouldShowCollapsedElement] = (0, _react.useState)(true);
34
- const [hasSizeChanged, setHasSizeChanged] = (0, _react.useState)(false);
35
- const [initialRender, setInitialRender] = (0, _react.useState)(true);
36
- const [shouldSkipChangeCheck, setShouldSkipChangeCheck] = (0, _react.useState)(false);
37
- const [originalSmallHeight, setOriginalSmallHeight] = (0, _react.useState)(0);
38
- const [originalBigHeight, setOriginalBigHeight] = (0, _react.useState)(0);
39
- (0, _react.useEffect)(() => {
40
- setInitialRender(false);
41
- }, []);
42
- const parentRef = (0, _react.useRef)(null);
43
- const pseudoChildrenRef = (0, _react.useRef)(null);
44
- const childrenRef = (0, _react.useRef)(null);
45
- const originalChildrenRef = (0, _react.useRef)(null);
46
- const hasCollapsed = (0, _react.useRef)(false);
47
- const isAnimating = (0, _react.useRef)(false);
48
- const hasSizeRecentlyChanged = (0, _react.useRef)(false);
49
- const canResetSizeChanged = (0, _react.useRef)(true);
27
+ const contentRef = (0, _react.useRef)(null);
28
+ const pendingObservedHeight = (0, _react.useRef)(0);
29
+ const [internalIsOpen, setInternalIsOpen] = (0, _react.useState)(Boolean(isOpen));
30
+ const [contentHeight, setContentHeight] = (0, _react.useState)(0);
50
31
  (0, _react.useEffect)(() => {
51
32
  if (typeof isOpen === 'boolean') {
52
33
  setInternalIsOpen(isOpen);
53
- setShowClamp(!isOpen);
54
34
  }
55
35
  }, [isOpen]);
56
-
57
- // Changes the state of the truncation
36
+ useIsomorphicLayoutEffect(() => {
37
+ if (!contentRef.current) {
38
+ return () => {};
39
+ }
40
+ let frame;
41
+ const updateContentHeight = entries => {
42
+ var _entries$;
43
+ pendingObservedHeight.current = Math.max(pendingObservedHeight.current, (entries === null || entries === void 0 || (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : _entries$.contentRect.height) ?? 0);
44
+ if (frame !== undefined) {
45
+ return;
46
+ }
47
+ frame = window.requestAnimationFrame(() => {
48
+ frame = undefined;
49
+ if (!contentRef.current) {
50
+ return;
51
+ }
52
+ setContentHeight(Math.max(pendingObservedHeight.current, contentRef.current.scrollHeight, contentRef.current.getBoundingClientRect().height));
53
+ pendingObservedHeight.current = 0;
54
+ });
55
+ };
56
+ const resizeObserver = new ResizeObserver(entries => updateContentHeight(entries));
57
+ const mutationObserver = new MutationObserver(() => updateContentHeight());
58
+ resizeObserver.observe(contentRef.current);
59
+ mutationObserver.observe(contentRef.current, {
60
+ characterData: true,
61
+ childList: true,
62
+ subtree: true
63
+ });
64
+ updateContentHeight();
65
+ return () => {
66
+ resizeObserver.disconnect();
67
+ mutationObserver.disconnect();
68
+ if (frame !== undefined) {
69
+ window.cancelAnimationFrame(frame);
70
+ }
71
+ };
72
+ }, [children]);
58
73
  const handleClampClick = (0, _react.useCallback)(event => {
59
74
  setInternalIsOpen(current => {
60
- if (typeof onChange === 'function') {
61
- onChange(event, !current);
62
- }
75
+ onChange === null || onChange === void 0 || onChange(event, !current);
63
76
  return !current;
64
77
  });
65
78
  }, [onChange]);
@@ -69,130 +82,29 @@ const Truncation = ({
69
82
  event.currentTarget.click();
70
83
  }
71
84
  }, []);
72
- (0, _react.useEffect)(() => {
73
- if (children) {
74
- setShouldSkipChangeCheck(true);
75
- window.setTimeout(() => {
76
- setShouldSkipChangeCheck(false);
77
- }, 200);
78
- }
79
- }, [children]);
80
- const handleAnimationEnd = (0, _react.useCallback)(() => {
81
- hasCollapsed.current = true;
82
- isAnimating.current = false;
83
- if (canResetSizeChanged.current) {
84
- setHasSizeChanged(false);
85
- canResetSizeChanged.current = false;
86
- }
87
- window.setTimeout(() => {
88
- hasSizeRecentlyChanged.current = false;
89
- }, 10);
90
- setShouldShowCollapsedElement(!internalIsOpen);
91
- window.setTimeout(() => {
92
- hasCollapsed.current = false;
93
- }, 30);
94
- }, [internalIsOpen]);
95
- (0, _react.useEffect)(() => {
96
- if (!pseudoChildrenRef.current) {
97
- return;
98
- }
99
- setOriginalHeight(pseudoChildrenRef.current.offsetHeight);
100
- setOriginalBigHeight(pseudoChildrenRef.current.offsetHeight);
101
- (0, _truncation2.truncateElement)(pseudoChildrenRef.current, collapsedHeight);
102
- setNewCollapsedHeight(pseudoChildrenRef.current.offsetHeight);
103
- setOriginalSmallHeight(pseudoChildrenRef.current.offsetHeight);
104
- }, [collapsedHeight, pseudoChildrenRef, children]);
105
-
106
- // Checks if the clamp should be shown
107
- (0, _react.useEffect)(() => {
108
- if (pseudoChildrenRef.current && (!hasSizeChanged || shouldSkipChangeCheck) && !initialRender) {
109
- setShowClamp(originalHeight > newCollapsedHeight);
110
- }
111
- }, [shouldSkipChangeCheck, collapsedHeight, hasSizeChanged, initialRender, newCollapsedHeight, originalHeight, children]);
112
- (0, _react.useEffect)(() => {
113
- if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {
114
- var _parentRef$current;
115
- while (childrenRef.current.firstChild) {
116
- childrenRef.current.removeChild(childrenRef.current.firstChild);
117
- }
118
- childrenRef.current.appendChild(shouldShowCollapsedElement && !internalIsOpen ? pseudoChildrenRef.current : originalChildrenRef.current);
119
- (_parentRef$current = parentRef.current) === null || _parentRef$current === void 0 || _parentRef$current.appendChild(shouldShowCollapsedElement && !internalIsOpen ? originalChildrenRef.current : pseudoChildrenRef.current);
120
- childrenRef.current.children[0].style.visibility = 'visible';
121
- }
122
- }, [children, internalIsOpen, shouldShowCollapsedElement]);
123
- useIsomorphicLayoutEffect(() => {
124
- if (originalChildrenRef.current) {
125
- const resizeObserver = new ResizeObserver(entries => {
126
- if (entries && entries[0]) {
127
- const observedHeight = entries[0].contentRect.height;
128
- setOriginalHeight(observedHeight < originalBigHeight ? originalBigHeight : observedHeight);
129
- if (!hasCollapsed.current && !isAnimating.current && !hasSizeRecentlyChanged.current) {
130
- void (0, _debounce.debounce)(() => {
131
- canResetSizeChanged.current = true;
132
- }, 250)();
133
- setHasSizeChanged(true);
134
- hasSizeRecentlyChanged.current = true;
135
- }
136
- }
137
- });
138
- resizeObserver.observe(originalChildrenRef.current);
139
- return () => {
140
- resizeObserver.disconnect();
141
- };
142
- }
143
- return () => {};
144
- }, [originalBigHeight, children]);
145
- useIsomorphicLayoutEffect(() => {
146
- if (pseudoChildrenRef.current) {
147
- const resizeObserver = new ResizeObserver(entries => {
148
- if (entries && entries[0]) {
149
- const observedHeight = entries[0].contentRect.height;
150
- setNewCollapsedHeight(observedHeight < originalSmallHeight ? originalSmallHeight : observedHeight);
151
- if (!hasCollapsed.current && !isAnimating.current && !hasSizeRecentlyChanged.current) {
152
- void (0, _debounce.debounce)(() => {
153
- canResetSizeChanged.current = true;
154
- }, 250)();
155
- setHasSizeChanged(true);
156
- hasSizeRecentlyChanged.current = true;
157
- }
158
- }
159
- });
160
- resizeObserver.observe(pseudoChildrenRef.current);
161
- return () => {
162
- resizeObserver.disconnect();
163
- };
164
- }
165
- return () => {};
166
- }, [originalSmallHeight, children]);
167
- const ts = _textStrings.default.components.truncation;
168
85
  const internalMoreLabel = moreLabel ?? /*#__PURE__*/_react.default.createElement(_textstring.Textstring, {
169
- textstring: (0, _textstring.ttsToITextString)(ts.more)
86
+ textstring: (0, _textstring.ttsToITextString)(_textStrings.default.components.truncation.more)
170
87
  });
171
88
  const internalLessLabel = lessLabel ?? /*#__PURE__*/_react.default.createElement(_textstring.Textstring, {
172
- textstring: (0, _textstring.ttsToITextString)(ts.less)
89
+ textstring: (0, _textstring.ttsToITextString)(_textStrings.default.components.truncation.less)
173
90
  });
174
- return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncation, {
175
- className: "beta-chayns-truncation",
176
- ref: parentRef
177
- }, /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationPseudoContent, {
178
- ref: pseudoChildrenRef
179
- }, children), /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationPseudoContent, {
180
- ref: originalChildrenRef
181
- }, children), /*#__PURE__*/_react.default.createElement(_Truncation.StyledMotionTruncationContent, {
91
+ const hasOverflow = contentHeight > collapsedHeight;
92
+ const collapsedContentHeight = Math.min(contentHeight || collapsedHeight, collapsedHeight);
93
+ const targetHeight = internalIsOpen ? contentHeight || collapsedHeight : collapsedContentHeight;
94
+ return /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncation, {
95
+ className: "beta-chayns-truncation"
96
+ }, /*#__PURE__*/_react.default.createElement(_Truncation.StyledMotionTruncationContent, {
182
97
  animate: {
183
- height: internalIsOpen ? originalHeight : newCollapsedHeight
98
+ height: targetHeight
184
99
  },
185
100
  initial: false,
186
101
  transition: {
187
102
  type: 'tween',
188
- duration: hasSizeChanged ? 0 : 0.2
189
- },
190
- onAnimationComplete: handleAnimationEnd,
191
- onAnimationStart: () => {
192
- isAnimating.current = true;
193
- },
194
- ref: childrenRef
195
- }), showClamp && /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationClampWrapper, {
103
+ duration: 0.2
104
+ }
105
+ }, /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationContent, {
106
+ ref: contentRef
107
+ }, children)), hasOverflow && /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationClampWrapper, {
196
108
  $position: clampPosition
197
109
  }, /*#__PURE__*/_react.default.createElement(_textstring.TextstringProvider, {
198
110
  libraryName: "@chayns-components-core"
@@ -203,7 +115,7 @@ const Truncation = ({
203
115
  onKeyDown: handleClampKeyDown,
204
116
  role: "button",
205
117
  tabIndex: 0
206
- }, internalIsOpen ? internalLessLabel : internalMoreLabel))))), [children, clampPosition, handleAnimationEnd, handleClampClick, handleClampKeyDown, hasSizeChanged, internalIsOpen, lessLabel, moreLabel, newCollapsedHeight, originalHeight, shouldShowKeyboardHighlighting, showClamp]);
118
+ }, internalIsOpen ? internalLessLabel : internalMoreLabel)))));
207
119
  };
208
120
  var _default = exports.default = Truncation;
209
121
  //# sourceMappingURL=Truncation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Truncation.js","names":["_react","_interopRequireWildcard","require","_truncation","_debounce","_truncation2","_Truncation","_textstring","_textStrings","_interopRequireDefault","_useKeyboardFocusHighlighting","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","Truncation","collapsedHeight","clampPosition","ClampPosition","Right","isOpen","moreLabel","lessLabel","onChange","children","shouldEnableKeyboardHighlighting","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","internalIsOpen","setInternalIsOpen","useState","showClamp","setShowClamp","newCollapsedHeight","setNewCollapsedHeight","originalHeight","setOriginalHeight","shouldShowCollapsedElement","setShouldShowCollapsedElement","hasSizeChanged","setHasSizeChanged","initialRender","setInitialRender","shouldSkipChangeCheck","setShouldSkipChangeCheck","originalSmallHeight","setOriginalSmallHeight","originalBigHeight","setOriginalBigHeight","parentRef","useRef","pseudoChildrenRef","childrenRef","originalChildrenRef","hasCollapsed","isAnimating","hasSizeRecentlyChanged","canResetSizeChanged","handleClampClick","useCallback","event","current","handleClampKeyDown","key","preventDefault","currentTarget","click","setTimeout","handleAnimationEnd","offsetHeight","truncateElement","_parentRef$current","firstChild","removeChild","appendChild","style","visibility","resizeObserver","ResizeObserver","entries","observedHeight","contentRect","height","debounce","observe","disconnect","ts","textStrings","components","truncation","internalMoreLabel","createElement","Textstring","textstring","ttsToITextString","more","internalLessLabel","less","useMemo","StyledTruncation","className","ref","StyledTruncationPseudoContent","StyledMotionTruncationContent","animate","initial","transition","type","duration","onAnimationComplete","onAnimationStart","StyledTruncationClampWrapper","$position","TextstringProvider","libraryName","StyledTruncationClampFocusWrapper","$shouldShowKeyboardHighlighting","StyledTruncationClamp","onClick","onKeyDown","role","tabIndex","_default","exports"],"sources":["../../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import React, {\n FC,\n KeyboardEventHandler,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { ClampPosition } from '../../types/truncation';\nimport { debounce } from '../../utils/debounce';\nimport { truncateElement } from '../../utils/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\n StyledTruncationClampFocusWrapper,\n StyledTruncationClampWrapper,\n StyledTruncationPseudoContent,\n} from './Truncation.styles';\nimport { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';\nimport textStrings from '../../constants/textStrings';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\n\nexport type TruncationProps = {\n /**\n * The elements that should be expanding or collapsing.\n */\n children: ReactElement;\n /**\n * The position of the clamp.\n */\n clampPosition?: ClampPosition;\n /**\n * The height of the children Element in it`s collapsed state.\n */\n collapsedHeight?: number;\n /**\n * If set to true, the content is exposed.\n */\n isOpen?: boolean;\n /**\n * A text that should be displayed if the content is expanded.\n */\n lessLabel?: string;\n /**\n * A text that should be displayed if the content is collapsed.\n */\n moreLabel?: string;\n /**\n * Function to be executed when the component is expanding or collapsing.\n */\n onChange?: (event: MouseEvent<HTMLAnchorElement>, isOpen: boolean) => void;\n /**\n * Enables keyboard-only focus highlighting.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n clampPosition = ClampPosition.Right,\n isOpen,\n moreLabel,\n lessLabel,\n onChange,\n children,\n shouldEnableKeyboardHighlighting,\n}) => {\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const [showClamp, setShowClamp] = useState(true);\n const [newCollapsedHeight, setNewCollapsedHeight] = useState(collapsedHeight);\n const [originalHeight, setOriginalHeight] = useState(0);\n const [shouldShowCollapsedElement, setShouldShowCollapsedElement] = useState(true);\n const [hasSizeChanged, setHasSizeChanged] = useState(false);\n const [initialRender, setInitialRender] = useState(true);\n const [shouldSkipChangeCheck, setShouldSkipChangeCheck] = useState(false);\n\n const [originalSmallHeight, setOriginalSmallHeight] = useState(0);\n const [originalBigHeight, setOriginalBigHeight] = useState(0);\n\n useEffect(() => {\n setInitialRender(false);\n }, []);\n\n const parentRef = useRef<HTMLDivElement>(null);\n const pseudoChildrenRef = useRef<HTMLDivElement>(null);\n const childrenRef = useRef<HTMLDivElement>(null);\n const originalChildrenRef = useRef<HTMLDivElement>(null);\n const hasCollapsed = useRef(false);\n const isAnimating = useRef(false);\n const hasSizeRecentlyChanged = useRef(false);\n const canResetSizeChanged = useRef(true);\n\n useEffect(() => {\n if (typeof isOpen === 'boolean') {\n setInternalIsOpen(isOpen);\n setShowClamp(!isOpen);\n }\n }, [isOpen]);\n\n // Changes the state of the truncation\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setInternalIsOpen((current) => {\n if (typeof onChange === 'function') {\n onChange(event, !current);\n }\n\n return !current;\n });\n },\n [onChange],\n );\n\n const handleClampKeyDown = useCallback<KeyboardEventHandler<HTMLAnchorElement>>((event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n event.currentTarget.click();\n }\n }, []);\n\n useEffect(() => {\n if (children) {\n setShouldSkipChangeCheck(true);\n\n window.setTimeout(() => {\n setShouldSkipChangeCheck(false);\n }, 200);\n }\n }, [children]);\n\n const handleAnimationEnd = useCallback(() => {\n hasCollapsed.current = true;\n isAnimating.current = false;\n\n if (canResetSizeChanged.current) {\n setHasSizeChanged(false);\n canResetSizeChanged.current = false;\n }\n\n window.setTimeout(() => {\n hasSizeRecentlyChanged.current = false;\n }, 10);\n\n setShouldShowCollapsedElement(!internalIsOpen);\n\n window.setTimeout(() => {\n hasCollapsed.current = false;\n }, 30);\n }, [internalIsOpen]);\n\n useEffect(() => {\n if (!pseudoChildrenRef.current) {\n return;\n }\n\n setOriginalHeight(pseudoChildrenRef.current.offsetHeight);\n setOriginalBigHeight(pseudoChildrenRef.current.offsetHeight);\n\n truncateElement(pseudoChildrenRef.current, collapsedHeight);\n\n setNewCollapsedHeight(pseudoChildrenRef.current.offsetHeight);\n setOriginalSmallHeight(pseudoChildrenRef.current.offsetHeight);\n }, [collapsedHeight, pseudoChildrenRef, children]);\n\n // Checks if the clamp should be shown\n useEffect(() => {\n if (\n pseudoChildrenRef.current &&\n (!hasSizeChanged || shouldSkipChangeCheck) &&\n !initialRender\n ) {\n setShowClamp(originalHeight > newCollapsedHeight);\n }\n }, [\n shouldSkipChangeCheck,\n collapsedHeight,\n hasSizeChanged,\n initialRender,\n newCollapsedHeight,\n originalHeight,\n children,\n ]);\n\n useEffect(() => {\n if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {\n while (childrenRef.current.firstChild) {\n childrenRef.current.removeChild(childrenRef.current.firstChild);\n }\n\n childrenRef.current.appendChild(\n shouldShowCollapsedElement && !internalIsOpen\n ? pseudoChildrenRef.current\n : originalChildrenRef.current,\n );\n\n parentRef.current?.appendChild(\n shouldShowCollapsedElement && !internalIsOpen\n ? originalChildrenRef.current\n : pseudoChildrenRef.current,\n );\n\n (childrenRef.current.children[0] as HTMLDivElement).style.visibility = 'visible';\n }\n }, [children, internalIsOpen, shouldShowCollapsedElement]);\n\n useIsomorphicLayoutEffect(() => {\n if (originalChildrenRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedHeight = entries[0].contentRect.height;\n\n setOriginalHeight(\n observedHeight < originalBigHeight ? originalBigHeight : observedHeight,\n );\n\n if (\n !hasCollapsed.current &&\n !isAnimating.current &&\n !hasSizeRecentlyChanged.current\n ) {\n void debounce(() => {\n canResetSizeChanged.current = true;\n }, 250)();\n\n setHasSizeChanged(true);\n hasSizeRecentlyChanged.current = true;\n }\n }\n });\n\n resizeObserver.observe(originalChildrenRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, [originalBigHeight, children]);\n\n useIsomorphicLayoutEffect(() => {\n if (pseudoChildrenRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedHeight = entries[0].contentRect.height;\n\n setNewCollapsedHeight(\n observedHeight < originalSmallHeight ? originalSmallHeight : observedHeight,\n );\n\n if (\n !hasCollapsed.current &&\n !isAnimating.current &&\n !hasSizeRecentlyChanged.current\n ) {\n void debounce(() => {\n canResetSizeChanged.current = true;\n }, 250)();\n\n setHasSizeChanged(true);\n hasSizeRecentlyChanged.current = true;\n }\n }\n });\n\n resizeObserver.observe(pseudoChildrenRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, [originalSmallHeight, children]);\n\n const ts = textStrings.components.truncation;\n\n const internalMoreLabel = moreLabel ?? <Textstring textstring={ttsToITextString(ts.more)} />;\n const internalLessLabel = lessLabel ?? <Textstring textstring={ttsToITextString(ts.less)} />;\n\n return useMemo(\n () => (\n <StyledTruncation className=\"beta-chayns-truncation\" ref={parentRef}>\n <StyledTruncationPseudoContent ref={pseudoChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledTruncationPseudoContent ref={originalChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledMotionTruncationContent\n animate={{ height: internalIsOpen ? originalHeight : newCollapsedHeight }}\n initial={false}\n transition={{ type: 'tween', duration: hasSizeChanged ? 0 : 0.2 }}\n onAnimationComplete={handleAnimationEnd}\n onAnimationStart={() => {\n isAnimating.current = true;\n }}\n ref={childrenRef}\n />\n {showClamp && (\n <StyledTruncationClampWrapper $position={clampPosition}>\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledTruncationClampFocusWrapper\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n >\n <StyledTruncationClamp\n onClick={handleClampClick}\n onKeyDown={handleClampKeyDown}\n role=\"button\"\n tabIndex={0}\n >\n {internalIsOpen ? internalLessLabel : internalMoreLabel}\n </StyledTruncationClamp>\n </StyledTruncationClampFocusWrapper>\n </TextstringProvider>\n </StyledTruncationClampWrapper>\n )}\n </StyledTruncation>\n ),\n [\n children,\n clampPosition,\n handleAnimationEnd,\n handleClampClick,\n handleClampKeyDown,\n hasSizeChanged,\n internalIsOpen,\n lessLabel,\n moreLabel,\n newCollapsedHeight,\n originalHeight,\n shouldShowKeyboardHighlighting,\n showClamp,\n ],\n );\n};\n\nexport default Truncation;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAaA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAQA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,6BAAA,GAAAR,OAAA;AAAwF,SAAAO,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAAAA,CAAAU,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA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CAAE;IAClEsE,mBAAmB,EAAEzC,kBAAmB;IACxC0C,gBAAgB,EAAEA,CAAA,KAAM;MACpBvD,WAAW,CAACM,OAAO,GAAG,IAAI;IAC9B,CAAE;IACFwC,GAAG,EAAEjD;EAAY,CACpB,CAAC,EACDrB,SAAS,iBACNlD,MAAA,CAAAa,OAAA,CAAAiG,aAAA,CAACxG,WAAA,CAAA4H,4BAA4B;IAACC,SAAS,EAAE/F;EAAc,gBACnDpC,MAAA,CAAAa,OAAA,CAAAiG,aAAA,CAACvG,WAAA,CAAA6H,kBAAkB;IAACC,WAAW,EAAC;EAAyB,gBACrDrI,MAAA,CAAAa,OAAA,CAAAiG,aAAA,CAACxG,WAAA,CAAAgI,iCAAiC;IAC9BC,+BAA+B,EAAE1F;EAA+B,gBAEhE7C,MAAA,CAAAa,OAAA,CAAAiG,aAAA,CAACxG,WAAA,CAAAkI,qBAAqB;IAClBC,OAAO,EAAE5D,gBAAiB;IAC1B6D,SAAS,EAAEzD,kBAAmB;IAC9B0D,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE;EAAE,GAEX7F,cAAc,GAAGoE,iBAAiB,GAAGN,iBACnB,CACQ,CACnB,CACM,CAEpB,CACrB,EACD,CACIlE,QAAQ,EACRP,aAAa,EACbmD,kBAAkB,EAClBV,gBAAgB,EAChBI,kBAAkB,EAClBvB,cAAc,EACdX,cAAc,EACdN,SAAS,EACTD,SAAS,EACTY,kBAAkB,EAClBE,cAAc,EACdT,8BAA8B,EAC9BK,SAAS,CAEjB,CAAC;AACL,CAAC;AAAC,IAAA2F,QAAA,GAAAC,OAAA,CAAAjI,OAAA,GAEaqB,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"Truncation.js","names":["_textstring","require","_react","_interopRequireWildcard","_useKeyboardFocusHighlighting","_textStrings","_interopRequireDefault","_truncation","_Truncation","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","Truncation","collapsedHeight","clampPosition","ClampPosition","Right","isOpen","lessLabel","moreLabel","onChange","children","shouldEnableKeyboardHighlighting","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","contentRef","useRef","pendingObservedHeight","internalIsOpen","setInternalIsOpen","useState","Boolean","contentHeight","setContentHeight","current","frame","updateContentHeight","entries","_entries$","Math","max","contentRect","height","undefined","requestAnimationFrame","scrollHeight","getBoundingClientRect","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","characterData","childList","subtree","disconnect","cancelAnimationFrame","handleClampClick","useCallback","event","handleClampKeyDown","key","preventDefault","currentTarget","click","internalMoreLabel","createElement","Textstring","textstring","ttsToITextString","textStrings","components","truncation","more","internalLessLabel","less","hasOverflow","collapsedContentHeight","min","targetHeight","StyledTruncation","className","StyledMotionTruncationContent","animate","initial","transition","type","duration","StyledTruncationContent","ref","StyledTruncationClampWrapper","$position","TextstringProvider","libraryName","StyledTruncationClampFocusWrapper","$shouldShowKeyboardHighlighting","StyledTruncationClamp","onClick","onKeyDown","role","tabIndex","_default","exports"],"sources":["../../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';\nimport React, {\n FC,\n KeyboardEventHandler,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\nimport textStrings from '../../constants/textStrings';\nimport { ClampPosition } from '../../types/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\n StyledTruncationClampFocusWrapper,\n StyledTruncationClampWrapper,\n StyledTruncationContent,\n} from './Truncation.styles';\n\nexport type TruncationProps = {\n /**\n * The elements that should be expanding or collapsing.\n */\n children: ReactElement;\n /**\n * The position of the clamp.\n */\n clampPosition?: ClampPosition;\n /**\n * The height of the children element in its collapsed state.\n */\n collapsedHeight?: number;\n /**\n * If set to true, the content is exposed.\n */\n isOpen?: boolean;\n /**\n * A text that should be displayed if the content is expanded.\n */\n lessLabel?: string;\n /**\n * A text that should be displayed if the content is collapsed.\n */\n moreLabel?: string;\n /**\n * Function to be executed when the component is expanding or collapsing.\n */\n onChange?: (event: MouseEvent<HTMLAnchorElement>, isOpen: boolean) => void;\n /**\n * Enables keyboard-only focus highlighting.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n clampPosition = ClampPosition.Right,\n isOpen,\n lessLabel,\n moreLabel,\n onChange,\n children,\n shouldEnableKeyboardHighlighting,\n}) => {\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n const contentRef = useRef<HTMLDivElement>(null);\n const pendingObservedHeight = useRef(0);\n const [internalIsOpen, setInternalIsOpen] = useState(Boolean(isOpen));\n const [contentHeight, setContentHeight] = useState(0);\n\n useEffect(() => {\n if (typeof isOpen === 'boolean') {\n setInternalIsOpen(isOpen);\n }\n }, [isOpen]);\n\n useIsomorphicLayoutEffect(() => {\n if (!contentRef.current) {\n return () => {};\n }\n\n let frame: number | undefined;\n const updateContentHeight = (entries?: ResizeObserverEntry[]) => {\n pendingObservedHeight.current = Math.max(\n pendingObservedHeight.current,\n entries?.[0]?.contentRect.height ?? 0,\n );\n\n if (frame !== undefined) {\n return;\n }\n\n frame = window.requestAnimationFrame(() => {\n frame = undefined;\n\n if (!contentRef.current) {\n return;\n }\n\n setContentHeight(\n Math.max(\n pendingObservedHeight.current,\n contentRef.current.scrollHeight,\n contentRef.current.getBoundingClientRect().height,\n ),\n );\n pendingObservedHeight.current = 0;\n });\n };\n\n const resizeObserver = new ResizeObserver((entries) => updateContentHeight(entries));\n const mutationObserver = new MutationObserver(() => updateContentHeight());\n\n resizeObserver.observe(contentRef.current);\n mutationObserver.observe(contentRef.current, {\n characterData: true,\n childList: true,\n subtree: true,\n });\n updateContentHeight();\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n\n if (frame !== undefined) {\n window.cancelAnimationFrame(frame);\n }\n };\n }, [children]);\n\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setInternalIsOpen((current) => {\n onChange?.(event, !current);\n return !current;\n });\n },\n [onChange],\n );\n\n const handleClampKeyDown = useCallback<KeyboardEventHandler<HTMLAnchorElement>>((event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n event.currentTarget.click();\n }\n }, []);\n\n const internalMoreLabel = moreLabel ?? (\n <Textstring textstring={ttsToITextString(textStrings.components.truncation.more)} />\n );\n const internalLessLabel = lessLabel ?? (\n <Textstring textstring={ttsToITextString(textStrings.components.truncation.less)} />\n );\n const hasOverflow = contentHeight > collapsedHeight;\n const collapsedContentHeight = Math.min(contentHeight || collapsedHeight, collapsedHeight);\n const targetHeight = internalIsOpen ? contentHeight || collapsedHeight : collapsedContentHeight;\n\n return (\n <StyledTruncation className=\"beta-chayns-truncation\">\n <StyledMotionTruncationContent\n animate={{ height: targetHeight }}\n initial={false}\n transition={{ type: 'tween', duration: 0.2 }}\n >\n <StyledTruncationContent ref={contentRef}>{children}</StyledTruncationContent>\n </StyledMotionTruncationContent>\n {hasOverflow && (\n <StyledTruncationClampWrapper $position={clampPosition}>\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledTruncationClampFocusWrapper\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n >\n <StyledTruncationClamp\n onClick={handleClampClick}\n onKeyDown={handleClampKeyDown}\n role=\"button\"\n tabIndex={0}\n >\n {internalIsOpen ? internalLessLabel : internalMoreLabel}\n </StyledTruncationClamp>\n </StyledTruncationClampFocusWrapper>\n </TextstringProvider>\n </StyledTruncationClampWrapper>\n )}\n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EAAC;EAAwB,gBAChDnG,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC9E,WAAA,CAAA8F,6BAA6B;IAC1BC,OAAO,EAAE;MAAEzC,MAAM,EAAEqC;IAAa,CAAE;IAClCK,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,IAAI,EAAE,OAAO;MAAEC,QAAQ,EAAE;IAAI;EAAE,gBAE7CzG,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC9E,WAAA,CAAAoG,uBAAuB;IAACC,GAAG,EAAEhE;EAAW,GAAEJ,QAAkC,CAClD,CAAC,EAC/BuD,WAAW,iBACR9F,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC9E,WAAA,CAAAsG,4BAA4B;IAACC,SAAS,EAAE7E;EAAc,gBACnDhC,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAACtF,WAAA,CAAAgH,kBAAkB;IAACC,WAAW,EAAC;EAAyB,gBACrD/G,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC9E,WAAA,CAAA0G,iCAAiC;IAC9BC,+BAA+B,EAAExE;EAA+B,gBAEhEzC,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC9E,WAAA,CAAA4G,qBAAqB;IAClBC,OAAO,EAAExC,gBAAiB;IAC1ByC,SAAS,EAAEtC,kBAAmB;IAC9BuC,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE;EAAE,GAEXxE,cAAc,GAAG8C,iBAAiB,GAAGT,iBACnB,CACQ,CACnB,CACM,CAEpB,CAAC;AAE3B,CAAC;AAAC,IAAAoC,QAAA,GAAAC,OAAA,CAAA/G,OAAA,GAEaqB,UAAU","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledTruncationPseudoContent = exports.StyledTruncationClampWrapper = exports.StyledTruncationClampFocusWrapper = exports.StyledTruncationClamp = exports.StyledTruncation = exports.StyledMotionTruncationContent = void 0;
6
+ exports.StyledTruncationContent = exports.StyledTruncationClampWrapper = exports.StyledTruncationClampFocusWrapper = exports.StyledTruncationClamp = exports.StyledTruncation = exports.StyledMotionTruncationContent = void 0;
7
7
  var _react = require("motion/react");
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
  var _truncation = require("../../types/truncation");
@@ -19,9 +19,8 @@ const StyledMotionTruncationContent = exports.StyledMotionTruncationContent = (0
19
19
  overflow: hidden;
20
20
  position: relative;
21
21
  `;
22
- const StyledTruncationPseudoContent = exports.StyledTruncationPseudoContent = _styledComponents.default.div`
23
- visibility: hidden;
24
- position: absolute;
22
+ const StyledTruncationContent = exports.StyledTruncationContent = _styledComponents.default.div`
23
+ min-width: 0;
25
24
  width: 100%;
26
25
  `;
27
26
  const StyledTruncationClampWrapper = exports.StyledTruncationClampWrapper = _styledComponents.default.div`
@@ -1 +1 @@
1
- {"version":3,"file":"Truncation.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_truncation","_keyboardFocusHighlighting","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledTruncation","exports","styled","div","StyledMotionTruncationContent","motion","StyledTruncationPseudoContent","StyledTruncationClampWrapper","$position","ClampPosition","Left","css","Middle","StyledTruncationClampFocusWrapper","$shouldShowKeyboardHighlighting","keyboardFocusHighlightingRingCss","StyledTruncationClamp","a"],"sources":["../../../../src/components/truncation/Truncation.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { ClampPosition } from '../../types/truncation';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';\n\nexport const StyledTruncation = styled.div`\n position: relative;\n overflow: hidden;\n`;\n\n// Fix framer-motion bug\nexport const StyledMotionTruncationContent = styled(motion.div)`\n overflow: hidden;\n position: relative;\n`;\n\nexport const StyledTruncationPseudoContent = styled.div`\n visibility: hidden;\n position: absolute;\n width: 100%;\n`;\n\ntype StyledTruncationClampWrapperProps = WithTheme<{ $position: ClampPosition }>;\n\nexport const StyledTruncationClampWrapper = styled.div<StyledTruncationClampWrapperProps>`\n display: flex;\n\n ${({ $position }) => {\n switch ($position) {\n case ClampPosition.Left:\n return css`\n justify-content: left;\n `;\n case ClampPosition.Middle:\n return css`\n justify-content: center;\n `;\n default:\n return css`\n justify-content: right;\n `;\n }\n }}\n`;\n\ntype StyledTruncationClampProps = {\n $shouldShowKeyboardHighlighting: boolean;\n};\n\nexport const StyledTruncationClampFocusWrapper = styled.div<StyledTruncationClampProps>`\n display: inline-block;\n border-radius: 3px;\n\n ${({ $shouldShowKeyboardHighlighting }) =>\n $shouldShowKeyboardHighlighting &&\n css`\n &:focus-within {\n transition: none;\n ${keyboardFocusHighlightingRingCss};\n color: inherit;\n }\n `}\n`;\n\nexport const StyledTruncationClamp = styled.a`\n cursor: pointer;\n z-index: 2;\n display: inline-block;\n line-height: 1.2;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,0BAAA,GAAAJ,OAAA;AAAgG,SAAAE,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CA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;AACJ,CAAC;AACL,CAAC;AAMM,MAAME,iCAAiC,GAAAZ,OAAA,CAAAY,iCAAA,GAAGX,yBAAM,CAACC,GAA+B;AACvF;AACA;AACA;AACA,MAAM,CAAC;EAAEW;AAAgC,CAAC,KAClCA,+BAA+B,IAC/B,IAAAH,qBAAG;AACX;AACA;AACA,kBAAkBI,2DAAgC;AAClD;AACA;AACA,SAAS;AACT,CAAC;AAEM,MAAMC,qBAAqB,GAAAf,OAAA,CAAAe,qBAAA,GAAGd,yBAAM,CAACe,CAAC;AAC7C;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Truncation.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_truncation","_keyboardFocusHighlighting","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledTruncation","exports","styled","div","StyledMotionTruncationContent","motion","StyledTruncationContent","StyledTruncationClampWrapper","$position","ClampPosition","Left","css","Middle","StyledTruncationClampFocusWrapper","$shouldShowKeyboardHighlighting","keyboardFocusHighlightingRingCss","StyledTruncationClamp","a"],"sources":["../../../../src/components/truncation/Truncation.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { ClampPosition } from '../../types/truncation';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';\n\nexport const StyledTruncation = styled.div`\n position: relative;\n overflow: hidden;\n`;\n\n// Fix framer-motion bug\nexport const StyledMotionTruncationContent = styled(motion.div)`\n overflow: hidden;\n position: relative;\n`;\n\nexport const StyledTruncationContent = styled.div`\n min-width: 0;\n width: 100%;\n`;\n\ntype StyledTruncationClampWrapperProps = WithTheme<{ $position: ClampPosition }>;\n\nexport const StyledTruncationClampWrapper = styled.div<StyledTruncationClampWrapperProps>`\n display: flex;\n\n ${({ $position }) => {\n switch ($position) {\n case ClampPosition.Left:\n return css`\n justify-content: left;\n `;\n case ClampPosition.Middle:\n return css`\n justify-content: center;\n `;\n default:\n return css`\n justify-content: right;\n `;\n }\n }}\n`;\n\ntype StyledTruncationClampProps = {\n $shouldShowKeyboardHighlighting: boolean;\n};\n\nexport const StyledTruncationClampFocusWrapper = styled.div<StyledTruncationClampProps>`\n display: inline-block;\n border-radius: 3px;\n\n ${({ $shouldShowKeyboardHighlighting }) =>\n $shouldShowKeyboardHighlighting &&\n css`\n &:focus-within {\n transition: none;\n ${keyboardFocusHighlightingRingCss};\n color: inherit;\n }\n `}\n`;\n\nexport const StyledTruncationClamp = styled.a`\n cursor: pointer;\n z-index: 2;\n display: inline-block;\n line-height: 1.2;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,0BAAA,GAAAJ,OAAA;AAAgG,SAAAE,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,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kBAAkBI,2DAAgC;AAClD;AACA;AACA,SAAS;AACT,CAAC;AAEM,MAAMC,qBAAqB,GAAAf,OAAA,CAAAe,qBAAA,GAAGd,yBAAM,CAACe,CAAC;AAC7C;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var _react = require("@testing-library/react");
4
+ var _react2 = _interopRequireDefault(require("react"));
5
+ var _vitest = require("vitest");
6
+ var _Truncation = _interopRequireDefault(require("./Truncation"));
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ _vitest.vi.mock('@chayns-components/textstring', () => ({
9
+ Textstring: () => 'Mehr anzeigen',
10
+ TextstringProvider: ({
11
+ children
12
+ }) => children,
13
+ ttsToITextString: _vitest.vi.fn()
14
+ }));
15
+ const resizeObserverCallbacks = [];
16
+ class ResizeObserverMock {
17
+ constructor(callback) {
18
+ resizeObserverCallbacks.push(callback);
19
+ }
20
+ disconnect() {}
21
+ observe() {}
22
+ unobserve() {}
23
+ }
24
+ _vitest.vi.stubGlobal('ResizeObserver', ResizeObserverMock);
25
+ const triggerResize = height => {
26
+ resizeObserverCallbacks.forEach(callback => {
27
+ callback([{
28
+ contentRect: {
29
+ height
30
+ }
31
+ }]);
32
+ });
33
+ };
34
+ (0, _vitest.afterEach)(() => {
35
+ resizeObserverCallbacks.length = 0;
36
+ });
37
+ (0, _vitest.describe)('Truncation', () => {
38
+ (0, _vitest.it)('shows the more action when content exceeds the collapsed height', async () => {
39
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_Truncation.default, {
40
+ collapsedHeight: 100
41
+ }, /*#__PURE__*/_react2.default.createElement("div", null, "Long content")));
42
+ triggerResize(240);
43
+ await (0, _react.waitFor)(() => {
44
+ (0, _vitest.expect)(_react.screen.getByRole('button', {
45
+ name: 'Mehr anzeigen'
46
+ })).toBeInTheDocument();
47
+ });
48
+ });
49
+ (0, _vitest.it)('keeps short content expanded without a more action', async () => {
50
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_Truncation.default, {
51
+ collapsedHeight: 100
52
+ }, /*#__PURE__*/_react2.default.createElement("div", null, "Short content")));
53
+ triggerResize(64);
54
+ await (0, _react.waitFor)(() => {
55
+ (0, _vitest.expect)(_react.screen.queryByRole('button', {
56
+ name: 'Mehr anzeigen'
57
+ })).not.toBeInTheDocument();
58
+ });
59
+ });
60
+ });
61
+ //# sourceMappingURL=Truncation.test.js.map