@chayns-components/core 5.5.36 → 5.5.37

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 (42) hide show
  1. package/lib/cjs/components/copyable-content/CopyableContent.js +12 -11
  2. package/lib/cjs/components/copyable-content/CopyableContent.js.map +1 -1
  3. package/lib/cjs/components/copyable-content/CopyableContent.test.js +4 -11
  4. package/lib/cjs/components/copyable-content/CopyableContent.test.js.map +1 -1
  5. package/lib/cjs/components/file-list/FileList.js +4 -3
  6. package/lib/cjs/components/file-list/FileList.js.map +1 -1
  7. package/lib/cjs/components/file-list/file-item/FileItem.js +6 -7
  8. package/lib/cjs/components/file-list/file-item/FileItem.js.map +1 -1
  9. package/lib/cjs/components/filter/filter-content/FilterContent.js +8 -7
  10. package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
  11. package/lib/cjs/components/filter-buttons/FilterButtons.js +5 -3
  12. package/lib/cjs/components/filter-buttons/FilterButtons.js.map +1 -1
  13. package/lib/cjs/components/filter-buttons/all-button/AllButton.js +5 -4
  14. package/lib/cjs/components/filter-buttons/all-button/AllButton.js.map +1 -1
  15. package/lib/cjs/components/truncation/Truncation.js +8 -7
  16. package/lib/cjs/components/truncation/Truncation.js.map +1 -1
  17. package/lib/cjs/components/truncation/Truncation.test.js +4 -5
  18. package/lib/cjs/components/truncation/Truncation.test.js.map +1 -1
  19. package/lib/cjs/constants/textStrings.js +29 -29
  20. package/lib/cjs/constants/textStrings.js.map +1 -1
  21. package/lib/esm/components/copyable-content/CopyableContent.js +12 -11
  22. package/lib/esm/components/copyable-content/CopyableContent.js.map +1 -1
  23. package/lib/esm/components/copyable-content/CopyableContent.test.js +4 -11
  24. package/lib/esm/components/copyable-content/CopyableContent.test.js.map +1 -1
  25. package/lib/esm/components/file-list/FileList.js +4 -3
  26. package/lib/esm/components/file-list/FileList.js.map +1 -1
  27. package/lib/esm/components/file-list/file-item/FileItem.js +6 -7
  28. package/lib/esm/components/file-list/file-item/FileItem.js.map +1 -1
  29. package/lib/esm/components/filter/filter-content/FilterContent.js +8 -7
  30. package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
  31. package/lib/esm/components/filter-buttons/FilterButtons.js +5 -3
  32. package/lib/esm/components/filter-buttons/FilterButtons.js.map +1 -1
  33. package/lib/esm/components/filter-buttons/all-button/AllButton.js +5 -4
  34. package/lib/esm/components/filter-buttons/all-button/AllButton.js.map +1 -1
  35. package/lib/esm/components/truncation/Truncation.js +8 -7
  36. package/lib/esm/components/truncation/Truncation.js.map +1 -1
  37. package/lib/esm/components/truncation/Truncation.test.js +4 -5
  38. package/lib/esm/components/truncation/Truncation.test.js.map +1 -1
  39. package/lib/esm/constants/textStrings.js +29 -29
  40. package/lib/esm/constants/textStrings.js.map +1 -1
  41. package/lib/types/constants/textStrings.d.ts +29 -29
  42. package/package.json +3 -3
@@ -7,14 +7,15 @@ exports.AllButton = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _FilterButton = _interopRequireDefault(require("../filter-button/FilterButton"));
9
9
  var _filterButtons = require("../../../types/filterButtons");
10
- var _textstring = require("@chayns-components/textstring");
10
+ var _textstrings = require("@chayns/textstrings");
11
11
  var _textStrings = _interopRequireDefault(require("../../../constants/textStrings"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
14
14
  const AllButton = props => {
15
- const allText = (0, _textstring.useTextstringValue)({
16
- textstring: (0, _textstring.ttsToITextString)(_textStrings.default.components.filterButtons.all)
17
- });
15
+ const {
16
+ t
17
+ } = (0, _textstrings.useTranslation)();
18
+ const allText = t(_textStrings.default.components.filterButtons.all);
18
19
  return /*#__PURE__*/_react.default.createElement(_FilterButton.default, _extends({
19
20
  shape: _filterButtons.FilterButtonItemShape.Rectangular,
20
21
  text: allText,
@@ -1 +1 @@
1
- {"version":3,"file":"AllButton.js","names":["_react","_interopRequireDefault","require","_FilterButton","_filterButtons","_textstring","_textStrings","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","AllButton","props","allText","useTextstringValue","textstring","ttsToITextString","textStrings","components","filterButtons","all","createElement","shape","FilterButtonItemShape","Rectangular","text","id","key","exports"],"sources":["../../../../../src/components/filter-buttons/all-button/AllButton.tsx"],"sourcesContent":["import React from 'react';\nimport FilterButton, { FilterButtonProps } from '../filter-button/FilterButton';\nimport { FilterButtonItemShape } from '../../../types/filterButtons';\nimport { ttsToITextString, useTextstringValue } from '@chayns-components/textstring';\nimport textStrings from '../../../constants/textStrings';\n\nexport const AllButton = (props: Omit<FilterButtonProps, 'shape' | 'id' | 'text'>) => {\n const allText = useTextstringValue({\n textstring: ttsToITextString(textStrings.components.filterButtons.all),\n });\n return (\n <FilterButton\n shape={FilterButtonItemShape.Rectangular}\n text={allText}\n id=\"all\"\n key=\"all\"\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...props}\n />\n );\n};\n"],"mappings":";;;;;;AAAC,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACD,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAyD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAC,CAAA,MAAAJ,CAAA,CAAAI,CAAA,IAAAD,CAAA,CAAAC,CAAA,aAAAJ,CAAA,KAAAJ,QAAA,CAAAW,KAAA,OAAAN,SAAA;AAElD,MAAMO,SAAS,GAAIC,KAAuD,IAAK;EAClF,MAAMC,OAAO,GAAG,IAAAC,8BAAkB,EAAC;IAC/BC,UAAU,EAAE,IAAAC,4BAAgB,EAACC,oBAAW,CAACC,UAAU,CAACC,aAAa,CAACC,GAAG;EACzE,CAAC,CAAC;EACF,oBACI/B,MAAA,CAAAS,OAAA,CAAAuB,aAAA,CAAC7B,aAAA,CAAAM,OAAY,EAAAC,QAAA;IACTuB,KAAK,EAAEC,oCAAqB,CAACC,WAAY;IACzCC,IAAI,EAAEZ,OAAQ;IACda,EAAE,EAAC,KAAK;IACRC,GAAG,EAAC;IACJ;EAAA,GACIf,KAAK,CACZ,CAAC;AAEV,CAAC;AAACgB,OAAA,CAAAjB,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"AllButton.js","names":["_react","_interopRequireDefault","require","_FilterButton","_filterButtons","_textstrings","_textStrings","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","AllButton","props","useTranslation","allText","textStrings","components","filterButtons","all","createElement","shape","FilterButtonItemShape","Rectangular","text","id","key","exports"],"sources":["../../../../../src/components/filter-buttons/all-button/AllButton.tsx"],"sourcesContent":["import React from 'react';\nimport FilterButton, { FilterButtonProps } from '../filter-button/FilterButton';\nimport { FilterButtonItemShape } from '../../../types/filterButtons';\nimport { useTranslation } from '@chayns/textstrings';\nimport textStrings from '../../../constants/textStrings';\n\nexport const AllButton = (props: Omit<FilterButtonProps, 'shape' | 'id' | 'text'>) => {\n const { t } = useTranslation();\n const allText = t(textStrings.components.filterButtons.all);\n return (\n <FilterButton\n shape={FilterButtonItemShape.Rectangular}\n text={allText}\n id=\"all\"\n key=\"all\"\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...props}\n />\n );\n};\n"],"mappings":";;;;;;AAAC,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACD,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAyD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAC,CAAA,MAAAJ,CAAA,CAAAI,CAAA,IAAAD,CAAA,CAAAC,CAAA,aAAAJ,CAAA,KAAAJ,QAAA,CAAAW,KAAA,OAAAN,SAAA;AAElD,MAAMO,SAAS,GAAIC,KAAuD,IAAK;EAClF,MAAM;IAAEN;EAAE,CAAC,GAAG,IAAAO,2BAAc,EAAC,CAAC;EAC9B,MAAMC,OAAO,GAAGR,CAAC,CAACS,oBAAW,CAACC,UAAU,CAACC,aAAa,CAACC,GAAG,CAAC;EAC3D,oBACI7B,MAAA,CAAAS,OAAA,CAAAqB,aAAA,CAAC3B,aAAA,CAAAM,OAAY,EAAAC,QAAA;IACTqB,KAAK,EAAEC,oCAAqB,CAACC,WAAY;IACzCC,IAAI,EAAET,OAAQ;IACdU,EAAE,EAAC,KAAK;IACRC,GAAG,EAAC;IACJ;EAAA,GACIb,KAAK,CACZ,CAAC;AAEV,CAAC;AAACc,OAAA,CAAAf,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _textstring = require("@chayns-components/textstring");
7
+ var _textstrings = require("@chayns/textstrings");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _textStrings = _interopRequireDefault(require("../../constants/textStrings"));
10
10
  var _useFocusRingPortal = require("../../hooks/useFocusRingPortal");
@@ -88,11 +88,11 @@ const Truncation = ({
88
88
  event.currentTarget.click();
89
89
  }
90
90
  }, []);
91
- const internalMoreLabel = moreLabel ?? /*#__PURE__*/_react.default.createElement(_textstring.Textstring, {
92
- textstring: (0, _textstring.ttsToITextString)(_textStrings.default.components.truncation.more)
91
+ const internalMoreLabel = moreLabel ?? /*#__PURE__*/_react.default.createElement(_textstrings.Translation, {
92
+ textString: _textStrings.default.components.truncation.more
93
93
  });
94
- const internalLessLabel = lessLabel ?? /*#__PURE__*/_react.default.createElement(_textstring.Textstring, {
95
- textstring: (0, _textstring.ttsToITextString)(_textStrings.default.components.truncation.less)
94
+ const internalLessLabel = lessLabel ?? /*#__PURE__*/_react.default.createElement(_textstrings.Translation, {
95
+ textString: _textStrings.default.components.truncation.less
96
96
  });
97
97
  const collapsedContentHeight = Math.min(contentHeight || collapsedHeight, collapsedHeight);
98
98
  const targetHeight = internalIsOpen ? contentHeight || collapsedHeight : collapsedContentHeight;
@@ -111,8 +111,9 @@ const Truncation = ({
111
111
  ref: contentRef
112
112
  }, children)), hasOverflow && /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationClampWrapper, {
113
113
  $position: clampPosition
114
- }, /*#__PURE__*/_react.default.createElement(_textstring.TextstringProvider, {
115
- libraryName: "@chayns-components-core"
114
+ }, /*#__PURE__*/_react.default.createElement(_textstrings.TextStringProviderSSR, {
115
+ libraries: "chayns-components-v5-core",
116
+ id: "truncation"
116
117
  }, /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationClampFocusWrapper, null, /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationClamp, {
117
118
  ref: clampRef,
118
119
  onClick: handleClampClick,
@@ -1 +1 @@
1
- {"version":3,"file":"Truncation.js","names":["_textstring","require","_react","_interopRequireWildcard","_textStrings","_interopRequireDefault","_useFocusRingPortal","_useKeyboardFocusHighlighting","_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","clampRef","pendingObservedHeight","internalIsOpen","setInternalIsOpen","useState","Boolean","contentHeight","setContentHeight","hasOverflow","useFocusRingPortal","isEnabled","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","collapsedContentHeight","min","targetHeight","StyledTruncation","className","StyledMotionTruncationContent","animate","initial","transition","type","duration","StyledTruncationContent","ref","StyledTruncationClampWrapper","$position","TextstringProvider","libraryName","StyledTruncationClampFocusWrapper","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 textStrings from '../../constants/textStrings';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\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 clampRef = useRef<HTMLAnchorElement>(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 const hasOverflow = contentHeight > collapsedHeight;\n\n useFocusRingPortal(clampRef, {\n isEnabled: shouldShowKeyboardHighlighting && hasOverflow,\n });\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 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 <StyledTruncationClamp\n ref={clampRef}\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\nexport default Truncation;\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAYA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AACA,IAAAM,6BAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAO6B,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAO,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,C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AA,CAAC3F,WAAA,CAAAoH,kBAAkB;IAACC,WAAW,EAAC;EAAyB,gBACrDnH,MAAA,CAAAU,OAAA,CAAA+E,aAAA,CAAClF,WAAA,CAAA6G,iCAAiC,qBAC9BpH,MAAA,CAAAU,OAAA,CAAA+E,aAAA,CAAClF,WAAA,CAAA8G,qBAAqB;IAClBN,GAAG,EAAEjE,QAAS;IACdwE,OAAO,EAAEtC,gBAAiB;IAC1BuC,SAAS,EAAEpC,kBAAmB;IAC9BqC,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE;EAAE,GAEXzE,cAAc,GAAGiD,iBAAiB,GAAGT,iBACnB,CACQ,CACnB,CACM,CAEpB,CAAC;AAE3B,CAAC;AAAC,IAAAkC,QAAA,GAAAC,OAAA,CAAAjH,OAAA,GAEaqB,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"Truncation.js","names":["_textstrings","require","_react","_interopRequireWildcard","_textStrings","_interopRequireDefault","_useFocusRingPortal","_useKeyboardFocusHighlighting","_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","clampRef","pendingObservedHeight","internalIsOpen","setInternalIsOpen","useState","Boolean","contentHeight","setContentHeight","hasOverflow","useFocusRingPortal","isEnabled","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","Translation","textString","textStrings","components","truncation","more","internalLessLabel","less","collapsedContentHeight","min","targetHeight","StyledTruncation","className","StyledMotionTruncationContent","animate","initial","transition","type","duration","StyledTruncationContent","ref","StyledTruncationClampWrapper","$position","TextStringProviderSSR","libraries","id","StyledTruncationClampFocusWrapper","StyledTruncationClamp","onClick","onKeyDown","role","tabIndex","_default","exports"],"sources":["../../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import { TextStringProviderSSR, Translation } from '@chayns/textstrings';\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 textStrings from '../../constants/textStrings';\nimport { useFocusRingPortal } from '../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\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 clampRef = useRef<HTMLAnchorElement>(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 const hasOverflow = contentHeight > collapsedHeight;\n\n useFocusRingPortal(clampRef, {\n isEnabled: shouldShowKeyboardHighlighting && hasOverflow,\n });\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 <Translation textString={textStrings.components.truncation.more} />\n );\n const internalLessLabel = lessLabel ?? (\n <Translation textString={textStrings.components.truncation.less} />\n );\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 <TextStringProviderSSR libraries=\"chayns-components-v5-core\" id=\"truncation\">\n <StyledTruncationClampFocusWrapper>\n <StyledTruncationClamp\n ref={clampRef}\n onClick={handleClampClick}\n onKeyDown={handleClampKeyDown}\n role=\"button\"\n tabIndex={0}\n >\n {internalIsOpen ? internalLessLabel : internalMoreLabel}\n </StyledTruncationClamp>\n </StyledTruncationClampFocusWrapper>\n </TextStringProviderSSR>\n </StyledTruncationClampWrapper>\n )}\n </StyledTruncation>\n );\n};\n\nexport default Truncation;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAYA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AACA,IAAAM,6BAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAO6B,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA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,OAAA,CAAA+E,aAAA,CAAClF,WAAA,CAAAsG,uBAAuB;IAACC,GAAG,EAAElE;EAAW,GAAEJ,QAAkC,CAClD,CAAC,EAC/Bc,WAAW,iBACRtD,MAAA,CAAAU,OAAA,CAAA+E,aAAA,CAAClF,WAAA,CAAAwG,4BAA4B;IAACC,SAAS,EAAE/E;EAAc,gBACnDjC,MAAA,CAAAU,OAAA,CAAA+E,aAAA,CAAC3F,YAAA,CAAAmH,qBAAqB;IAACC,SAAS,EAAC,2BAA2B;IAACC,EAAE,EAAC;EAAY,gBACxEnH,MAAA,CAAAU,OAAA,CAAA+E,aAAA,CAAClF,WAAA,CAAA6G,iCAAiC,qBAC9BpH,MAAA,CAAAU,OAAA,CAAA+E,aAAA,CAAClF,WAAA,CAAA8G,qBAAqB;IAClBP,GAAG,EAAEhE,QAAS;IACdwE,OAAO,EAAEtC,gBAAiB;IAC1BuC,SAAS,EAAEpC,kBAAmB;IAC9BqC,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE;EAAE,GAEXzE,cAAc,GAAGgD,iBAAiB,GAAGR,iBACnB,CACQ,CAChB,CACG,CAEpB,CAAC;AAE3B,CAAC;AAAC,IAAAkC,QAAA,GAAAC,OAAA,CAAAjH,OAAA,GAEaqB,UAAU","ignoreList":[]}
@@ -5,12 +5,11 @@ var _react2 = _interopRequireDefault(require("react"));
5
5
  var _vitest = require("vitest");
6
6
  var _Truncation = _interopRequireDefault(require("./Truncation"));
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
- _vitest.vi.mock('@chayns-components/textstring', () => ({
9
- Textstring: () => 'Mehr anzeigen',
10
- TextstringProvider: ({
8
+ _vitest.vi.mock('@chayns/textstrings', () => ({
9
+ Translation: () => 'Mehr anzeigen',
10
+ TextStringProvider: ({
11
11
  children
12
- }) => children,
13
- ttsToITextString: _vitest.vi.fn()
12
+ }) => children
14
13
  }));
15
14
  const resizeObserverCallbacks = [];
16
15
  class ResizeObserverMock {
@@ -1 +1 @@
1
- {"version":3,"file":"Truncation.test.js","names":["_react","require","_react2","_interopRequireDefault","_vitest","_Truncation","e","__esModule","default","vi","mock","Textstring","TextstringProvider","children","ttsToITextString","fn","resizeObserverCallbacks","ResizeObserverMock","constructor","callback","push","disconnect","observe","unobserve","stubGlobal","triggerResize","height","forEach","contentRect","afterEach","length","describe","it","render","createElement","collapsedHeight","waitFor","expect","screen","getByRole","name","toBeInTheDocument","queryByRole","not"],"sources":["../../../../src/components/truncation/Truncation.test.tsx"],"sourcesContent":["import { render, screen, waitFor } from '@testing-library/react';\nimport React from 'react';\nimport { afterEach, describe, expect, it, vi } from 'vitest';\nimport Truncation from './Truncation';\n\nvi.mock('@chayns-components/textstring', () => ({\n Textstring: () => 'Mehr anzeigen',\n TextstringProvider: ({ children }: { children: React.ReactNode }) => children,\n ttsToITextString: vi.fn(),\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\nafterEach(() => {\n resizeObserverCallbacks.length = 0;\n});\n\ndescribe('Truncation', () => {\n it('shows the more action when content exceeds the collapsed height', async () => {\n render(\n <Truncation collapsedHeight={100}>\n <div>Long content</div>\n </Truncation>,\n );\n\n triggerResize(240);\n\n await waitFor(() => {\n expect(screen.getByRole('button', { name: 'Mehr anzeigen' })).toBeInTheDocument();\n });\n });\n\n it('keeps short content expanded without a more action', async () => {\n render(\n <Truncation collapsedHeight={100}>\n <div>Short content</div>\n </Truncation>,\n );\n\n triggerResize(64);\n\n await waitF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AAAC,UAAE,EAAC,iEAAiE,EAAE,YAAY;IAC9E,IAAAC,aAAM,eACF/B,OAAA,CAAAM,OAAA,CAAA0B,aAAA,CAAC7B,WAAA,CAAAG,OAAU;MAAC2B,eAAe,EAAE;IAAI,gBAC7BjC,OAAA,CAAAM,OAAA,CAAA0B,aAAA,cAAK,cAAiB,CACd,CAChB,CAAC;IAEDT,aAAa,CAAC,GAAG,CAAC;IAElB,MAAM,IAAAW,cAAO,EAAC,MAAM;MAChB,IAAAC,cAAM,EAACC,aAAM,CAACC,SAAS,CAAC,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAgB,CAAC,CAAC,CAAC,CAACC,iBAAiB,CAAC,CAAC;IACrF,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,IAAAT,UAAE,EAAC,oDAAoD,EAAE,YAAY;IACjE,IAAAC,aAAM,eACF/B,OAAA,CAAAM,OAAA,CAAA0B,aAAA,CAAC7B,WAAA,CAAAG,OAAU;MAAC2B,eAAe,EAAE;IAAI,gBAC7BjC,OAAA,CAAAM,OAAA,CAAA0B,aAAA,cAAK,eAAkB,CACf,CAChB,CAAC;IAEDT,aAAa,CAAC,EAAE,CAAC;IAEjB,MAAM,IAAAW,cAAO,EAAC,MAAM;MAChB,IAAAC,cAAM,EAACC,aAAM,CAACI,WAAW,CAAC,QAAQ,EAAE;QAAEF,IAAI,EAAE;MAAgB,CAAC,CAAC,CAAC,CAACG,GAAG,CAACF,iBAAiB,CAAC,CAAC;IAC3F,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Truncation.test.js","names":["_react","require","_react2","_interopRequireDefault","_vitest","_Truncation","e","__esModule","default","vi","mock","Translation","TextStringProvider","children","resizeObserverCallbacks","ResizeObserverMock","constructor","callback","push","disconnect","observe","unobserve","stubGlobal","triggerResize","height","forEach","contentRect","afterEach","length","describe","it","render","createElement","collapsedHeight","waitFor","expect","screen","getByRole","name","toBeInTheDocument","queryByRole","not"],"sources":["../../../../src/components/truncation/Truncation.test.tsx"],"sourcesContent":["import { render, screen, waitFor } from '@testing-library/react';\nimport React from 'react';\nimport { afterEach, describe, expect, it, vi } from 'vitest';\nimport Truncation from './Truncation';\n\nvi.mock('@chayns/textstrings', () => ({\n Translation: () => 'Mehr anzeigen',\n TextStringProvider: ({ children }: { children: React.ReactNode }) => children,\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\nafterEach(() => {\n resizeObserverCallbacks.length = 0;\n});\n\ndescribe('Truncation', () => {\n it('shows the more action when content exceeds the collapsed height', async () => {\n render(\n <Truncation collapsedHeight={100}>\n <div>Long content</div>\n </Truncation>,\n );\n\n triggerResize(240);\n\n await waitFor(() => {\n expect(screen.getByRole('button', { name: 'Mehr anzeigen' })).toBeInTheDocument();\n });\n });\n\n it('keeps short content expanded without a more action', async () => {\n render(\n <Truncation collapsedHeight={100}>\n <div>Short content</div>\n </Truncation>,\n );\n\n triggerResize(64);\n\n await waitFor(() => {\n expect(screen.queryByRole('button', { name: 'Mehr anzeigen' })).not.toBeInTheDocument();\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAsC,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAA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E;QAAEC,IAAI,EAAE;MAAgB,CAAC,CAAC,CAAC,CAACC,iBAAiB,CAAC,CAAC;IACrF,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,IAAAT,UAAE,EAAC,oDAAoD,EAAE,YAAY;IACjE,IAAAC,aAAM,eACF7B,OAAA,CAAAM,OAAA,CAAAwB,aAAA,CAAC3B,WAAA,CAAAG,OAAU;MAACyB,eAAe,EAAE;IAAI,gBAC7B/B,OAAA,CAAAM,OAAA,CAAAwB,aAAA,cAAK,eAAkB,CACf,CAChB,CAAC;IAEDT,aAAa,CAAC,EAAE,CAAC;IAEjB,MAAM,IAAAW,cAAO,EAAC,MAAM;MAChB,IAAAC,cAAM,EAACC,aAAM,CAACI,WAAW,CAAC,QAAQ,EAAE;QAAEF,IAAI,EAAE;MAAgB,CAAC,CAAC,CAAC,CAACG,GAAG,CAACF,iBAAiB,CAAC,CAAC;IAC3F,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -6,59 +6,59 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _default = exports.default = {
8
8
  components: {
9
+ copyableContent: {
10
+ copy: {
11
+ stringName: 'txt_chayns_components_v5_core_components_copyableContent_copy',
12
+ fallback: 'Kopieren'
13
+ },
14
+ copyFailed: {
15
+ stringName: 'txt_chayns_components_v5_core_components_copyableContent_copyFailed',
16
+ fallback: 'Kopieren fehlgeschlagen'
17
+ },
18
+ share: {
19
+ stringName: 'txt_chayns_components_v5_core_components_copyableContent_share',
20
+ fallback: 'Teilen'
21
+ }
22
+ },
23
+ fileItem: {
24
+ download: {
25
+ stringName: 'txt_chayns_components_v5_core_components_fileItem_download',
26
+ fallback: 'Download'
27
+ },
28
+ remove: {
29
+ stringName: 'txt_chayns_components_v5_core_components_fileItem_remove',
30
+ fallback: 'Entfernen'
31
+ }
32
+ },
9
33
  filter: {
10
34
  filterContent: {
11
35
  input: {
12
36
  placeholder: {
13
- stringName: 'txt_chayns_components_core_components_filter_filterContent_input_placeholder',
37
+ stringName: 'txt_chayns_components_v5_core_components_filter_filterContent_input_placeholder',
14
38
  fallback: 'Suche'
15
39
  }
16
40
  },
17
41
  sort: {
18
- stringName: 'txt_chayns_components_core_components_filter_filterContent_sort',
42
+ stringName: 'txt_chayns_components_v5_core_components_filter_filterContent_sort',
19
43
  fallback: 'Sortierung'
20
44
  }
21
45
  }
22
46
  },
23
47
  filterButtons: {
24
48
  all: {
25
- stringName: 'txt_chayns_components_core_components_filterButtons_all',
49
+ stringName: 'txt_chayns_components_v5_core_components_filterButtons_all',
26
50
  fallback: 'Alle'
27
51
  }
28
52
  },
29
53
  truncation: {
30
54
  less: {
31
- stringName: 'txt_chayns_components_core_components_truncation_less',
55
+ stringName: 'txt_chayns_components_v5_core_components_truncation_less',
32
56
  fallback: 'Weniger'
33
57
  },
34
58
  more: {
35
- stringName: 'txt_chayns_components_core_components_truncation_more',
59
+ stringName: 'txt_chayns_components_v5_core_components_truncation_more',
36
60
  fallback: 'Mehr'
37
61
  }
38
- },
39
- fileItem: {
40
- download: {
41
- stringName: 'txt_chayns_components_core_components_fileItem_download',
42
- fallback: 'Download'
43
- },
44
- remove: {
45
- stringName: 'txt_chayns_components_core_components_fileItem_remove',
46
- fallback: 'Entfernen'
47
- }
48
- },
49
- copyableContent: {
50
- copy: {
51
- stringName: 'txt_chayns_components_core_components_copyableContent_copy',
52
- fallback: 'Kopieren'
53
- },
54
- share: {
55
- stringName: 'txt_chayns_components_core_components_copyableContent_share',
56
- fallback: 'Teilen'
57
- },
58
- copyFailed: {
59
- stringName: 'txt_chayns_components_core_components_copyableContent_copyFailed',
60
- fallback: 'Kopieren fehlgeschlagen'
61
- }
62
62
  }
63
63
  }
64
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"textStrings.js","names":["components","filter","filterContent","input","placeholder","stringName","fallback","sort","filterButtons","all","truncation","less","more","fileItem","download","remove","copyableContent","copy","share","copyFailed"],"sources":["../../../src/constants/textStrings.ts"],"sourcesContent":["export default {\n components: {\n filter: {\n filterContent: {\n input: {\n placeholder: {\n stringName:\n 'txt_chayns_components_core_components_filter_filterContent_input_placeholder',\n fallback: 'Suche',\n },\n },\n sort: {\n stringName: 'txt_chayns_components_core_components_filter_filterContent_sort',\n fallback: 'Sortierung',\n },\n },\n },\n filterButtons: {\n all: {\n stringName: 'txt_chayns_components_core_components_filterButtons_all',\n fallback: 'Alle',\n },\n },\n truncation: {\n less: {\n stringName: 'txt_chayns_components_core_components_truncation_less',\n fallback: 'Weniger',\n },\n more: {\n stringName: 'txt_chayns_components_core_components_truncation_more',\n fallback: 'Mehr',\n },\n },\n fileItem: {\n download: {\n stringName: 'txt_chayns_components_core_components_fileItem_download',\n fallback: 'Download',\n },\n remove: {\n stringName: 'txt_chayns_components_core_components_fileItem_remove',\n fallback: 'Entfernen',\n },\n },\n copyableContent: {\n copy: {\n stringName: 'txt_chayns_components_core_components_copyableContent_copy',\n fallback: 'Kopieren',\n },\n share: {\n stringName: 'txt_chayns_components_core_components_copyableContent_share',\n fallback: 'Teilen',\n },\n copyFailed: {\n stringName: 'txt_chayns_components_core_components_copyableContent_copyFailed',\n fallback: 'Kopieren fehlgeschlagen',\n },\n },\n },\n} as const;\n"],"mappings":";;;;;;iCAAe;EACXA,UAAU,EAAE;IACRC,MAAM,EAAE;MACJC,aAAa,EAAE;QACXC,KAAK,EAAE;UACHC,WAAW,EAAE;YACTC,UAAU,EACN,8EAA8E;YAClFC,QAAQ,EAAE;UACd;QACJ,CAAC;QACDC,IAAI,EAAE;UACFF,UAAU,EAAE,iEAAiE;UAC7EC,QAAQ,EAAE;QACd;MACJ;IACJ,CAAC;IACDE,aAAa,EAAE;MACXC,GAAG,EAAE;QACDJ,UAAU,EAAE,yDAAyD;QACrEC,QAAQ,EAAE;MACd;IACJ,CAAC;IACDI,UAAU,EAAE;MACRC,IAAI,EAAE;QACFN,UAAU,EAAE,uDAAuD;QACnEC,QAAQ,EAAE;MACd,CAAC;MACDM,IAAI,EAAE;QACFP,UAAU,EAAE,uDAAuD;QACnEC,QAAQ,EAAE;MACd;IACJ,CAAC;IACDO,QAAQ,EAAE;MACNC,QAAQ,EAAE;QACNT,UAAU,EAAE,yDAAyD;QACrEC,QAAQ,EAAE;MACd,CAAC;MACDS,MAAM,EAAE;QACJV,UAAU,EAAE,uDAAuD;QACnEC,QAAQ,EAAE;MACd;IACJ,CAAC;IACDU,eAAe,EAAE;MACbC,IAAI,EAAE;QACFZ,UAAU,EAAE,4DAA4D;QACxEC,QAAQ,EAAE;MACd,CAAC;MACDY,KAAK,EAAE;QACHb,UAAU,EAAE,6DAA6D;QACzEC,QAAQ,EAAE;MACd,CAAC;MACDa,UAAU,EAAE;QACRd,UAAU,EAAE,kEAAkE;QAC9EC,QAAQ,EAAE;MACd;IACJ;EACJ;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"textStrings.js","names":["components","copyableContent","copy","stringName","fallback","copyFailed","share","fileItem","download","remove","filter","filterContent","input","placeholder","sort","filterButtons","all","truncation","less","more"],"sources":["../../../src/constants/textStrings.ts"],"sourcesContent":["export default {\n components: {\n copyableContent: {\n copy: {\n stringName: 'txt_chayns_components_v5_core_components_copyableContent_copy',\n fallback: 'Kopieren',\n },\n copyFailed: {\n stringName: 'txt_chayns_components_v5_core_components_copyableContent_copyFailed',\n fallback: 'Kopieren fehlgeschlagen',\n },\n share: {\n stringName: 'txt_chayns_components_v5_core_components_copyableContent_share',\n fallback: 'Teilen',\n },\n },\n fileItem: {\n download: {\n stringName: 'txt_chayns_components_v5_core_components_fileItem_download',\n fallback: 'Download',\n },\n remove: {\n stringName: 'txt_chayns_components_v5_core_components_fileItem_remove',\n fallback: 'Entfernen',\n },\n },\n filter: {\n filterContent: {\n input: {\n placeholder: {\n stringName:\n 'txt_chayns_components_v5_core_components_filter_filterContent_input_placeholder',\n fallback: 'Suche',\n },\n },\n sort: {\n stringName:\n 'txt_chayns_components_v5_core_components_filter_filterContent_sort',\n fallback: 'Sortierung',\n },\n },\n },\n filterButtons: {\n all: {\n stringName: 'txt_chayns_components_v5_core_components_filterButtons_all',\n fallback: 'Alle',\n },\n },\n truncation: {\n less: {\n stringName: 'txt_chayns_components_v5_core_components_truncation_less',\n fallback: 'Weniger',\n },\n more: {\n stringName: 'txt_chayns_components_v5_core_components_truncation_more',\n fallback: 'Mehr',\n },\n },\n },\n} as const;\n"],"mappings":";;;;;;iCAAe;EACXA,UAAU,EAAE;IACRC,eAAe,EAAE;MACbC,IAAI,EAAE;QACFC,UAAU,EAAE,+DAA+D;QAC3EC,QAAQ,EAAE;MACd,CAAC;MACDC,UAAU,EAAE;QACRF,UAAU,EAAE,qEAAqE;QACjFC,QAAQ,EAAE;MACd,CAAC;MACDE,KAAK,EAAE;QACHH,UAAU,EAAE,gEAAgE;QAC5EC,QAAQ,EAAE;MACd;IACJ,CAAC;IACDG,QAAQ,EAAE;MACNC,QAAQ,EAAE;QACNL,UAAU,EAAE,4DAA4D;QACxEC,QAAQ,EAAE;MACd,CAAC;MACDK,MAAM,EAAE;QACJN,UAAU,EAAE,0DAA0D;QACtEC,QAAQ,EAAE;MACd;IACJ,CAAC;IACDM,MAAM,EAAE;MACJC,aAAa,EAAE;QACXC,KAAK,EAAE;UACHC,WAAW,EAAE;YACTV,UAAU,EACN,iFAAiF;YACrFC,QAAQ,EAAE;UACd;QACJ,CAAC;QACDU,IAAI,EAAE;UACFX,UAAU,EACN,oEAAoE;UACxEC,QAAQ,EAAE;QACd;MACJ;IACJ,CAAC;IACDW,aAAa,EAAE;MACXC,GAAG,EAAE;QACDb,UAAU,EAAE,4DAA4D;QACxEC,QAAQ,EAAE;MACd;IACJ,CAAC;IACDa,UAAU,EAAE;MACRC,IAAI,EAAE;QACFf,UAAU,EAAE,0DAA0D;QACtEC,QAAQ,EAAE;MACd,CAAC;MACDe,IAAI,EAAE;QACFhB,UAAU,EAAE,0DAA0D;QACtEC,QAAQ,EAAE;MACd;IACJ;EACJ;AACJ,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { formatStringToHtml } from '@chayns-components/format';
2
- import { ttsToITextString, useTextstringValue } from '@chayns-components/textstring';
2
+ import { TextStringProviderSSR, useTranslation } from '@chayns/textstrings';
3
3
  import { createDialog, DialogType, ToastType } from 'chayns-api';
4
4
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import textStrings from '../../constants/textStrings';
@@ -12,7 +12,7 @@ import { CopyableContentColorMode, StyledCopyableContent, StyledCopyableContentA
12
12
  import { CopyableContentAppearance } from './CopyableContent.types';
13
13
  import { copyableContentToClipboard } from './copyableContentClipboard';
14
14
  const COPY_FEEDBACK_DURATION = 1500;
15
- const CopyableContent = ({
15
+ const CopyableContentContent = ({
16
16
  appearance = CopyableContentAppearance.Default,
17
17
  content,
18
18
  children,
@@ -28,15 +28,12 @@ const CopyableContent = ({
28
28
  const [hasCopied, setHasCopied] = useState(false);
29
29
  const colorScheme = useColorScheme();
30
30
  const colorMode = colorScheme?.theme.colorMode === 'dark' ? CopyableContentColorMode.Dark : CopyableContentColorMode.Light;
31
- const defaultCopyButtonText = useTextstringValue({
32
- textstring: ttsToITextString(textStrings.components.copyableContent.copy)
33
- });
34
- const defaultCopyFailedMessage = useTextstringValue({
35
- textstring: ttsToITextString(textStrings.components.copyableContent.copyFailed)
36
- });
37
- const shareText = useTextstringValue({
38
- textstring: ttsToITextString(textStrings.components.copyableContent.share)
39
- });
31
+ const {
32
+ t
33
+ } = useTranslation();
34
+ const defaultCopyButtonText = t(textStrings.components.copyableContent.copy);
35
+ const defaultCopyFailedMessage = t(textStrings.components.copyableContent.copyFailed);
36
+ const shareText = t(textStrings.components.copyableContent.share);
40
37
  const html = useMemo(() => formatStringToHtml(content).html, [content]);
41
38
  useEffect(() => () => {
42
39
  window.clearTimeout(copyFeedbackTimeoutRef.current);
@@ -113,6 +110,10 @@ const CopyableContent = ({
113
110
  }
114
111
  })));
115
112
  };
113
+ const CopyableContent = props => /*#__PURE__*/React.createElement(TextStringProviderSSR, {
114
+ libraries: "chayns-components-v5-core",
115
+ id: "copyable-content"
116
+ }, /*#__PURE__*/React.createElement(CopyableContentContent, props));
116
117
  CopyableContent.displayName = 'CopyableContent';
117
118
  export default CopyableContent;
118
119
  export { CopyableContentAppearance } from './CopyableContent.types';
@@ -1 +1 @@
1
- {"version":3,"file":"CopyableContent.js","names":["formatStringToHtml","ttsToITextString","useTextstringValue","createDialog","DialogType","ToastType","React","useCallback","useEffect","useMemo","useRef","useState","textStrings","useStickyActionState","useColorScheme","SharingContextMenu","Icon","Truncation","CopyableContentColorMode","StyledCopyableContent","StyledCopyableContentActionGroup","StyledCopyableContentActions","StyledCopyableContentBody","StyledCopyableContentButton","StyledCopyableContentTruncation","CopyableContentAppearance","copyableContentToClipboard","COPY_FEEDBACK_DURATION","CopyableContent","appearance","Default","content","children","copyFailedMessage","collapsedHeight","isDisabled","transformClipboardHtml","rootRef","actionGroupRef","copyFeedbackTimeoutRef","isActionGroupSticky","hasCopied","setHasCopied","colorScheme","colorMode","theme","Dark","Light","defaultCopyButtonText","textstring","components","copyableContent","copy","defaultCopyFailedMessage","copyFailed","shareText","share","html","window","clearTimeout","current","showCopyFeedback","setTimeout","handleCopy","showCloseIcon","text","toastType","ERROR","type","TOAST","open","createElement","$appearance","$colorMode","className","ref","$isSticky","disabled","onClick","icons","link","shouldDisableClick","shouldShowCallingCodeAction","shouldShowCopyAction","shouldUseDefaultTriggerStyles","$shouldShowPadding","dangerouslySetInnerHTML","__html","displayName"],"sources":["../../../../src/components/copyable-content/CopyableContent.tsx"],"sourcesContent":["import { formatStringToHtml } from '@chayns-components/format';\nimport { ttsToITextString, useTextstringValue } from '@chayns-components/textstring';\nimport { createDialog, DialogType, ToastType } from 'chayns-api';\nimport React, { FC, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport textStrings from '../../constants/textStrings';\nimport { useStickyActionState } from '../../hooks/useStickyActionState';\nimport { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport SharingContextMenu from '../sharing-context-menu/SharingContextMenu';\nimport Icon from '../icon/Icon';\nimport Truncation from '../truncation/Truncation';\nimport {\n CopyableContentColorMode,\n StyledCopyableContent,\n StyledCopyableContentActionGroup,\n StyledCopyableContentActions,\n StyledCopyableContentBody,\n StyledCopyableContentButton,\n StyledCopyableContentTruncation,\n} from './CopyableContent.styles';\nimport { CopyableContentAppearance } from './CopyableContent.types';\nimport { copyableContentToClipboard } from './copyableContentClipboard';\n\nconst COPY_FEEDBACK_DURATION = 1500;\n\nexport type CopyableContentProps = {\n /**\n * Controls the visual surface of the content block.\n */\n appearance?: CopyableContentAppearance;\n /**\n * Markdown source used for rendering and clipboard data.\n */\n content: string;\n /**\n * Disables the copy and share actions.\n */\n isDisabled?: boolean;\n /**\n * Replaces only the visible rendered content and never the copied source.\n */\n children?: ReactNode;\n /**\n * Replaces the localized error message shown when copying fails.\n */\n copyFailedMessage?: string;\n /**\n * The height of the content in its collapsed state.\n */\n collapsedHeight?: number;\n /**\n * Transforms the generated HTML before it is written to the clipboard.\n */\n transformClipboardHtml?: (html: string) => string;\n};\n\nconst CopyableContent: FC<CopyableContentProps> = ({\n appearance = CopyableContentAppearance.Default,\n content,\n children,\n copyFailedMessage,\n collapsedHeight,\n isDisabled = false,\n transformClipboardHtml,\n}) => {\n const rootRef = useRef<HTMLElement>(null);\n const actionGroupRef = useRef<HTMLDivElement>(null);\n const copyFeedbackTimeoutRef = useRef<number>();\n const isActionGroupSticky = useStickyActionState(rootRef, actionGroupRef);\n const [hasCopied, setHasCopied] = useState(false);\n\n const colorScheme = useColorScheme();\n const colorMode =\n colorScheme?.theme.colorMode === 'dark'\n ? CopyableContentColorMode.Dark\n : CopyableContentColorMode.Light;\n\n const defaultCopyButtonText = useTextstringValue({\n textstring: ttsToITextString(textStrings.components.copyableContent.copy),\n });\n const defaultCopyFailedMessage = useTextstringValue({\n textstring: ttsToITextString(textStrings.components.copyableContent.copyFailed),\n });\n const shareText = useTextstringValue({\n textstring: ttsToITextString(textStrings.components.copyableContent.share),\n });\n\n const html = useMemo(() => formatStringToHtml(content).html, [content]);\n\n useEffect(\n () => () => {\n window.clearTimeout(copyFeedbackTimeoutRef.current);\n },\n [],\n );\n\n const showCopyFeedback = useCallback(() => {\n window.clearTimeout(copyFeedbackTimeoutRef.current);\n setHasCopied(true);\n\n copyFeedbackTimeoutRef.current = window.setTimeout(() => {\n setHasCopied(false);\n }, COPY_FEEDBACK_DURATION);\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (isDisabled) {\n return;\n }\n\n try {\n await copyableContentToClipboard(content, transformClipboardHtml);\n showCopyFeedback();\n } catch {\n void createDialog({\n showCloseIcon: true,\n text: copyFailedMessage ?? defaultCopyFailedMessage,\n toastType: ToastType.ERROR,\n type: DialogType.TOAST,\n }).open();\n }\n }, [\n content,\n defaultCopyFailedMessage,\n isDisabled,\n copyFailedMessage,\n showCopyFeedback,\n transformClipboardHtml,\n ]);\n\n return (\n <StyledCopyableContent\n $appearance={appearance}\n $colorMode={colorMode}\n className=\"copyable-content\"\n ref={rootRef}\n >\n <StyledCopyableContentActions ref={actionGroupRef}>\n <StyledCopyableContentActionGroup>\n <StyledCopyableContentButton\n $colorMode={colorMode}\n $isSticky={isActionGroupSticky}\n aria-label={defaultCopyButtonText}\n disabled={isDisabled}\n onClick={() => {\n void handleCopy();\n }}\n type=\"button\"\n >\n <Icon icons={hasCopied ? ['fa fa-check'] : ['fa-light fa-copy']} />\n </StyledCopyableContentButton>\n <SharingContextMenu\n link={content}\n shouldDisableClick={isDisabled}\n shouldShowCallingCodeAction={false}\n shouldShowCopyAction={false}\n shouldUseDefaultTriggerStyles={false}\n >\n <StyledCopyableContentButton\n $colorMode={colorMode}\n $isSticky={isActionGroupSticky}\n aria-label={shareText}\n disabled={isDisabled}\n type=\"button\"\n >\n <Icon icons={['fa fa-share-nodes']} />\n </StyledCopyableContentButton>\n </SharingContextMenu>\n </StyledCopyableContentActionGroup>\n </StyledCopyableContentActions>\n {typeof collapsedHeight === 'number' ? (\n <StyledCopyableContentTruncation>\n <Truncation collapsedHeight={collapsedHeight}>\n <StyledCopyableContentBody\n $colorMode={colorMode}\n $shouldShowPadding={false}\n >\n {children ?? <div dangerouslySetInnerHTML={{ __html: html }} />}\n </StyledCopyableContentBody>\n </Truncation>\n </StyledCopyableContentTruncation>\n ) : (\n <StyledCopyableContentBody $colorMode={colorMode}>\n {children ?? <div dangerouslySetInnerHTML={{ __html: html }} />}\n </StyledCopyableContentBody>\n )}\n </StyledCopyableContent>\n );\n};\n\nCopyableContent.displayName = 'CopyableContent';\n\nexport default CopyableContent;\n\nexport { CopyableContentAppearance } from './CopyableContent.types';\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2BAA2B;AAC9D,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,+BAA+B;AACpF,SAASC,YAAY,EAAEC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AAChE,OAAOC,KAAK,IAAmBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/F,OAAOC,WAAW,MAAM,6BAA6B;AACrD,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,cAAc,QAAQ,8CAA8C;AAC7E,OAAOC,kBAAkB,MAAM,4CAA4C;AAC3E,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,UAAU,MAAM,0BAA0B;AACjD,SACIC,wBAAwB,EACxBC,qBAAqB,EACrBC,gCAAgC,EAChCC,4BAA4B,EAC5BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,+BAA+B,QAC5B,0BAA0B;AACjC,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,0BAA0B,QAAQ,4BAA4B;AAEvE,MAAMC,sBAAsB,GAAG,IAAI;AAiCnC,MAAMC,eAAyC,GAAGA,CAAC;EAC/CC,UAAU,GAAGJ,yBAAyB,CAACK,OAAO;EAC9CC,OAAO;EACPC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A,CAACjD,yBAAyB;IAACmD,UAAU,EAAE7B;EAAU,GAC5CZ,QAAQ,iBAAI1B,KAAA,CAAAiE,aAAA;IAAKe,uBAAuB,EAAE;MAAEC,MAAM,EAAE9B;IAAK;EAAE,CAAE,CACvC,CAEZ,CAAC;AAEhC,CAAC;AAED7B,eAAe,CAAC4D,WAAW,GAAG,iBAAiB;AAE/C,eAAe5D,eAAe;AAE9B,SAASH,yBAAyB,QAAQ,yBAAyB","ignoreList":[]}
1
+ {"version":3,"file":"CopyableContent.js","names":["formatStringToHtml","TextStringProviderSSR","useTranslation","createDialog","DialogType","ToastType","React","useCallback","useEffect","useMemo","useRef","useState","textStrings","useStickyActionState","useColorScheme","SharingContextMenu","Icon","Truncation","CopyableContentColorMode","StyledCopyableContent","StyledCopyableContentActionGroup","StyledCopyableContentActions","StyledCopyableContentBody","StyledCopyableContentButton","StyledCopyableContentTruncation","CopyableContentAppearance","copyableContentToClipboard","COPY_FEEDBACK_DURATION","CopyableContentContent","appearance","Default","content","children","copyFailedMessage","collapsedHeight","isDisabled","transformClipboardHtml","rootRef","actionGroupRef","copyFeedbackTimeoutRef","isActionGroupSticky","hasCopied","setHasCopied","colorScheme","colorMode","theme","Dark","Light","t","defaultCopyButtonText","components","copyableContent","copy","defaultCopyFailedMessage","copyFailed","shareText","share","html","window","clearTimeout","current","showCopyFeedback","setTimeout","handleCopy","showCloseIcon","text","toastType","ERROR","type","TOAST","open","createElement","$appearance","$colorMode","className","ref","$isSticky","disabled","onClick","icons","link","shouldDisableClick","shouldShowCallingCodeAction","shouldShowCopyAction","shouldUseDefaultTriggerStyles","$shouldShowPadding","dangerouslySetInnerHTML","__html","CopyableContent","props","libraries","id","displayName"],"sources":["../../../../src/components/copyable-content/CopyableContent.tsx"],"sourcesContent":["import { formatStringToHtml } from '@chayns-components/format';\nimport { TextStringProviderSSR, useTranslation } from '@chayns/textstrings';\nimport { createDialog, DialogType, ToastType } from 'chayns-api';\nimport React, { FC, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport textStrings from '../../constants/textStrings';\nimport { useStickyActionState } from '../../hooks/useStickyActionState';\nimport { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport SharingContextMenu from '../sharing-context-menu/SharingContextMenu';\nimport Icon from '../icon/Icon';\nimport Truncation from '../truncation/Truncation';\nimport {\n CopyableContentColorMode,\n StyledCopyableContent,\n StyledCopyableContentActionGroup,\n StyledCopyableContentActions,\n StyledCopyableContentBody,\n StyledCopyableContentButton,\n StyledCopyableContentTruncation,\n} from './CopyableContent.styles';\nimport { CopyableContentAppearance } from './CopyableContent.types';\nimport { copyableContentToClipboard } from './copyableContentClipboard';\n\nconst COPY_FEEDBACK_DURATION = 1500;\n\nexport type CopyableContentProps = {\n /**\n * Controls the visual surface of the content block.\n */\n appearance?: CopyableContentAppearance;\n /**\n * Markdown source used for rendering and clipboard data.\n */\n content: string;\n /**\n * Disables the copy and share actions.\n */\n isDisabled?: boolean;\n /**\n * Replaces only the visible rendered content and never the copied source.\n */\n children?: ReactNode;\n /**\n * Replaces the localized error message shown when copying fails.\n */\n copyFailedMessage?: string;\n /**\n * The height of the content in its collapsed state.\n */\n collapsedHeight?: number;\n /**\n * Transforms the generated HTML before it is written to the clipboard.\n */\n transformClipboardHtml?: (html: string) => string;\n};\n\nconst CopyableContentContent: FC<CopyableContentProps> = ({\n appearance = CopyableContentAppearance.Default,\n content,\n children,\n copyFailedMessage,\n collapsedHeight,\n isDisabled = false,\n transformClipboardHtml,\n}) => {\n const rootRef = useRef<HTMLElement>(null);\n const actionGroupRef = useRef<HTMLDivElement>(null);\n const copyFeedbackTimeoutRef = useRef<number>();\n const isActionGroupSticky = useStickyActionState(rootRef, actionGroupRef);\n const [hasCopied, setHasCopied] = useState(false);\n\n const colorScheme = useColorScheme();\n const colorMode =\n colorScheme?.theme.colorMode === 'dark'\n ? CopyableContentColorMode.Dark\n : CopyableContentColorMode.Light;\n\n const { t } = useTranslation();\n const defaultCopyButtonText = t(textStrings.components.copyableContent.copy);\n const defaultCopyFailedMessage = t(textStrings.components.copyableContent.copyFailed);\n const shareText = t(textStrings.components.copyableContent.share);\n\n const html = useMemo(() => formatStringToHtml(content).html, [content]);\n\n useEffect(\n () => () => {\n window.clearTimeout(copyFeedbackTimeoutRef.current);\n },\n [],\n );\n\n const showCopyFeedback = useCallback(() => {\n window.clearTimeout(copyFeedbackTimeoutRef.current);\n setHasCopied(true);\n\n copyFeedbackTimeoutRef.current = window.setTimeout(() => {\n setHasCopied(false);\n }, COPY_FEEDBACK_DURATION);\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (isDisabled) {\n return;\n }\n\n try {\n await copyableContentToClipboard(content, transformClipboardHtml);\n showCopyFeedback();\n } catch {\n void createDialog({\n showCloseIcon: true,\n text: copyFailedMessage ?? defaultCopyFailedMessage,\n toastType: ToastType.ERROR,\n type: DialogType.TOAST,\n }).open();\n }\n }, [\n content,\n defaultCopyFailedMessage,\n isDisabled,\n copyFailedMessage,\n showCopyFeedback,\n transformClipboardHtml,\n ]);\n\n return (\n <StyledCopyableContent\n $appearance={appearance}\n $colorMode={colorMode}\n className=\"copyable-content\"\n ref={rootRef}\n >\n <StyledCopyableContentActions ref={actionGroupRef}>\n <StyledCopyableContentActionGroup>\n <StyledCopyableContentButton\n $colorMode={colorMode}\n $isSticky={isActionGroupSticky}\n aria-label={defaultCopyButtonText}\n disabled={isDisabled}\n onClick={() => {\n void handleCopy();\n }}\n type=\"button\"\n >\n <Icon icons={hasCopied ? ['fa fa-check'] : ['fa-light fa-copy']} />\n </StyledCopyableContentButton>\n <SharingContextMenu\n link={content}\n shouldDisableClick={isDisabled}\n shouldShowCallingCodeAction={false}\n shouldShowCopyAction={false}\n shouldUseDefaultTriggerStyles={false}\n >\n <StyledCopyableContentButton\n $colorMode={colorMode}\n $isSticky={isActionGroupSticky}\n aria-label={shareText}\n disabled={isDisabled}\n type=\"button\"\n >\n <Icon icons={['fa fa-share-nodes']} />\n </StyledCopyableContentButton>\n </SharingContextMenu>\n </StyledCopyableContentActionGroup>\n </StyledCopyableContentActions>\n {typeof collapsedHeight === 'number' ? (\n <StyledCopyableContentTruncation>\n <Truncation collapsedHeight={collapsedHeight}>\n <StyledCopyableContentBody\n $colorMode={colorMode}\n $shouldShowPadding={false}\n >\n {children ?? <div dangerouslySetInnerHTML={{ __html: html }} />}\n </StyledCopyableContentBody>\n </Truncation>\n </StyledCopyableContentTruncation>\n ) : (\n <StyledCopyableContentBody $colorMode={colorMode}>\n {children ?? <div dangerouslySetInnerHTML={{ __html: html }} />}\n </StyledCopyableContentBody>\n )}\n </StyledCopyableContent>\n );\n};\n\nconst CopyableContent: FC<CopyableContentProps> = (props) => (\n <TextStringProviderSSR libraries=\"chayns-components-v5-core\" id=\"copyable-content\">\n <CopyableContentContent {...props} />\n </TextStringProviderSSR>\n);\n\nCopyableContent.displayName = 'CopyableContent';\n\nexport default CopyableContent;\n\nexport { CopyableContentAppearance } from './CopyableContent.types';\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2BAA2B;AAC9D,SAASC,qBAAqB,EAAEC,cAAc,QAAQ,qBAAqB;AAC3E,SAASC,YAAY,EAAEC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AAChE,OAAOC,KAAK,IAAmBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/F,OAAOC,WAAW,MAAM,6BAA6B;AACrD,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,cAAc,QAAQ,8CAA8C;AAC7E,OAAOC,kBAAkB,MAAM,4CAA4C;AAC3E,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,UAAU,MAAM,0BAA0B;AACjD,SACIC,wBAAwB,EACxBC,qBAAqB,EACrBC,gCAAgC,EAChCC,4BAA4B,EAC5BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,+BAA+B,QAC5B,0BAA0B;AACjC,SAASC,yBAAyB,QAAQ,y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AM,EAAE9B;IAAK;EAAE,CAAE,CACvC,CACnB,CACiB,CAAC,gBAElCnD,KAAA,CAAAiE,aAAA,CAACjD,yBAAyB;IAACmD,UAAU,EAAE7B;EAAU,GAC5CZ,QAAQ,iBAAI1B,KAAA,CAAAiE,aAAA;IAAKe,uBAAuB,EAAE;MAAEC,MAAM,EAAE9B;IAAK;EAAE,CAAE,CACvC,CAEZ,CAAC;AAEhC,CAAC;AAED,MAAM+B,eAAyC,GAAIC,KAAK,iBACpDnF,KAAA,CAAAiE,aAAA,CAACtE,qBAAqB;EAACyF,SAAS,EAAC,2BAA2B;EAACC,EAAE,EAAC;AAAkB,gBAC9ErF,KAAA,CAAAiE,aAAA,CAAC3C,sBAAsB,EAAK6D,KAAQ,CACjB,CAC1B;AAEDD,eAAe,CAACI,WAAW,GAAG,iBAAiB;AAE/C,eAAeJ,eAAe;AAE9B,SAAS/D,yBAAyB,QAAQ,yBAAyB","ignoreList":[]}
@@ -3,17 +3,10 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
3
  import React from 'react';
4
4
  import { describe, expect, it, vi } from 'vitest';
5
5
  import CopyableContent from './CopyableContent';
6
- vi.mock('@chayns-components/textstring', () => ({
7
- Textstring: ({
8
- textstring
9
- }) => textstring.fallback,
10
- TextstringProvider: ({
11
- children
12
- }) => children,
13
- ttsToITextString: textstring => textstring,
14
- useTextstringValue: ({
15
- textstring
16
- }) => textstring.fallback
6
+ vi.mock('@chayns/textstrings', () => ({
7
+ useTranslation: () => ({
8
+ t: textString => typeof textString === 'string' ? textString : textString.fallback
9
+ })
17
10
  }));
18
11
  const resizeObserverCallbacks = [];
19
12
  class ResizeObserverMock {
@@ -1 +1 @@
1
- {"version":3,"file":"CopyableContent.test.js","names":["fireEvent","render","screen","waitFor","React","describe","expect","it","vi","CopyableContent","mock","Textstring","textstring","fallback","TextstringProvider","children","ttsToITextString","useTextstringValue","resizeObserverCallbacks","ResizeObserverMock","constructor","callback","push","disconnect","observe","unobserve","stubGlobal","triggerResize","height","forEach","contentRect","default","icons","createElement","join","shouldShowCallingCodeAction","shouldShowCopyAction","importOriginal","createDialog","fn","open","readBlob","blob","Promise","resolve","reject","reader","FileReader","onerror","error","onload","result","readAsText","content","getByRole","name","toBeInTheDocument","toHaveAttribute","document","querySelector","not","write","spyOn","navigator","clipboard","mockResolvedValue","click","toHaveBeenCalled","item","calls","getType","resolves","toBe","transformClipboardHtml","html","toHaveBeenCalledOnce","toContain","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('passes the clipboard HTML transformer to the copy action', async () => {\n const write = vi.spyOn(navigator.clipboard, 'write').mockResolvedValue();\n const transformClipboardHtml = vi.fn((html: string) => `${html}<p>Styled</p>`);\n\n render(\n <CopyableContent\n content=\"source markdown\"\n transformClipboardHtml={transformClipboardHtml}\n />,\n );\n\n fireEvent.click(screen.getByRole('button', { name: 'Kopieren' }));\n\n await waitFor(() => expect(transformClipboardHtml).toHaveBeenCalledOnce());\n const item = write.mock.calls[0][0][0];\n\n await expect(readBlob(await item.getType('text/html'))).resolves.toContain('<p>Styled</p>');\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":"AAAA;AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,QAAQ,wBAAwB;AAC3E,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACjD,OAAOC,eAAe,MAAM,mBAAmB;AAE/CD,EAAE,CAACE,IAAI,CAAC,+BAA+B,EAAE,OAAO;EAC5CC,UAAU,EAAEA,CAAC;IAAEC;EAAiD,CAAC,KAAKA,UAAU,CAACC,QAAQ;EACzFC,kBAAkB,EAAEA,CAAC;IAAEC;EAAwC,CAAC,KAAKA,QAAQ;EAC7EC,gBAAgB,EAAGJ,UAAgC,IAAKA,UAAU;EAClEK,kBAAkB,EAAEA,CAAC;IAAEL;EAAiD,CAAC,KACrEA,UAAU,CAACC;AACnB,CAAC,CAAC,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C;EAC7F,CAAC,CAAC;EAEFjD,EAAE,CAAC,4BAA4B,EAAE,YAAY;IACzCN,MAAM,cACFG,KAAA,CAAA6B,aAAA,CAACxB,eAAe;MACZqE,eAAe,EAAE,GAAI;MACrBzB,OAAO,EAAE0B,KAAK,CAAC,EAAE,CAAC,CAACC,IAAI,CAAC,cAAc,CAAC,CAAC9C,IAAI,CAAC,MAAM;IAAE,CACxD,CACL,CAAC;IAEDP,aAAa,CAAC,GAAG,CAAC;IAElB,MAAMxB,OAAO,CAAC,MAAM;MAChBG,MAAM,CAACJ,MAAM,CAACoD,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":[]}
1
+ {"version":3,"file":"CopyableContent.test.js","names":["fireEvent","render","screen","waitFor","React","describe","expect","it","vi","CopyableContent","mock","useTranslation","t","textString","fallback","resizeObserverCallbacks","ResizeObserverMock","constructor","callback","push","disconnect","observe","unobserve","stubGlobal","triggerResize","height","forEach","contentRect","default","icons","createElement","join","children","shouldShowCallingCodeAction","shouldShowCopyAction","importOriginal","createDialog","fn","open","readBlob","blob","Promise","resolve","reject","reader","FileReader","onerror","error","onload","result","readAsText","content","getByRole","name","toBeInTheDocument","toHaveAttribute","document","querySelector","not","write","spyOn","navigator","clipboard","mockResolvedValue","click","toHaveBeenCalled","item","calls","getType","resolves","toBe","transformClipboardHtml","html","toHaveBeenCalledOnce","toContain","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/textstrings', () => ({\n useTranslation: () => ({\n t: (textString: { fallback?: string } | string) =>\n typeof textString === 'string' ? textString : textString.fallback,\n }),\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('passes the clipboard HTML transformer to the copy action', async () => {\n const write = vi.spyOn(navigator.clipboard, 'write').mockResolvedValue();\n const transformClipboardHtml = vi.fn((html: string) => `${html}<p>Styled</p>`);\n\n render(\n <CopyableContent\n content=\"source markdown\"\n transformClipboardHtml={transformClipboardHtml}\n />,\n );\n\n fireEvent.click(screen.getByRole('button', { name: 'Kopieren' }));\n\n await waitFor(() => expect(transformClipboardHtml).toHaveBeenCalledOnce());\n const item = write.mock.calls[0][0][0];\n\n await expect(readBlob(await item.getType('text/html'))).resolves.toContain('<p>Styled</p>');\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: '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AwB,EAAE,MAAM;IAC/B,MAAM;MAAEoE;IAAU,CAAC,GAAG1E,MAAM,cAACG,KAAA,CAAA0B,aAAA,CAACrB,eAAe;MAAC0C,OAAO,EAAC;IAAQ,CAAE,CAAC,CAAC;IAElE7C,MAAM,CAACJ,MAAM,CAACkD,SAAS,CAAC,QAAQ,EAAE;MAAEC,IAAI,EAAE;IAAS,CAAC,CAAC,CAAC,CAACC,iBAAiB,CAAC,CAAC;IAC1EhD,MAAM,CAACqE,SAAS,CAAClB,aAAa,CAAC,4BAA4B,CAAC,CAAC,CAACH,iBAAiB,CAAC,CAAC;IACjFhD,MAAM,CAACqE,SAAS,CAAClB,aAAa,CAAC,oCAAoC,CAAC,CAAC,CAACH,iBAAiB,CAAC,CAAC;EAC7F,CAAC,CAAC;EAEF/C,EAAE,CAAC,4BAA4B,EAAE,YAAY;IACzCN,MAAM,cACFG,KAAA,CAAA0B,aAAA,CAACrB,eAAe;MACZmE,eAAe,EAAE,GAAI;MACrBzB,OAAO,EAAE0B,KAAK,CAAC,EAAE,CAAC,CAACC,IAAI,CAAC,cAAc,CAAC,CAAC/C,IAAI,CAAC,MAAM;IAAE,CACxD,CACL,CAAC;IAEDP,aAAa,CAAC,GAAG,CAAC;IAElB,MAAMrB,OAAO,CAAC,MAAM;MAChBG,MAAM,CAACJ,MAAM,CAACkD,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":[]}
@@ -1,5 +1,5 @@
1
1
  import React, { useMemo } from 'react';
2
- import { TextstringProvider } from '@chayns-components/textstring';
2
+ import { TextStringProviderSSR } from '@chayns/textstrings';
3
3
  import List from '../list/List';
4
4
  import { StyledFileList } from './FileList.styles';
5
5
  import FileItem from './file-item/FileItem';
@@ -24,8 +24,9 @@ const FileList = ({
24
24
  onRemove: onRemove,
25
25
  shouldAllowDownload: shouldAllowDownload
26
26
  })), [files, onRemove, shouldAllowDownload]);
27
- return useMemo(() => /*#__PURE__*/React.createElement(TextstringProvider, {
28
- libraryName: "@chayns-components-core"
27
+ return useMemo(() => /*#__PURE__*/React.createElement(TextStringProviderSSR, {
28
+ libraries: "chayns-components-v5-core",
29
+ id: "file-list"
29
30
  }, /*#__PURE__*/React.createElement(StyledFileList, null, /*#__PURE__*/React.createElement(List, null, content))), [content]);
30
31
  };
31
32
  FileList.displayName = 'FileList';
@@ -1 +1 @@
1
- {"version":3,"file":"FileList.js","names":["React","useMemo","TextstringProvider","List","StyledFileList","FileItem","FileList","files","onRemove","shouldAllowDownload","content","map","mimeType","size","name","id","source","createElement","key","libraryName","displayName"],"sources":["../../../../src/components/file-list/FileList.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport { TextstringProvider } from '@chayns-components/textstring';\nimport List from '../list/List';\nimport { StyledFileList } from './FileList.styles';\nimport FileItem from './file-item/FileItem';\n\nexport interface IFileItem {\n id: string;\n name: string;\n size?: number;\n mimeType: string;\n source?: string | File;\n}\n\nexport type FileListProps = {\n /**\n * Already uploaded files to display.\n */\n files?: IFileItem[];\n /**\n * A function to be executed when a file is removed.\n */\n onRemove?: (id: IFileItem['id']) => void;\n /**\n * Whether to show a download icon for files that have a `source` set.\n */\n shouldAllowDownload?: boolean;\n};\n\nconst FileList: FC<FileListProps> = ({ files, onRemove, shouldAllowDownload }) => {\n const content = useMemo(\n () =>\n files?.map(({ mimeType, size, name, id, source }) => (\n <FileItem\n key={id}\n id={id}\n name={name}\n size={size}\n mimeType={mimeType}\n source={source}\n onRemove={onRemove}\n shouldAllowDownload={shouldAllowDownload}\n />\n )),\n [files, onRemove, shouldAllowDownload],\n );\n\n return useMemo(\n () => (\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledFileList>\n <List>{content}</List>\n </StyledFileList>\n </TextstringProvider>\n ),\n [content],\n );\n};\n\nFileList.displayName = 'FileList';\n\nexport default FileList;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,OAAO,QAAQ,OAAO;AAC1C,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,OAAOC,IAAI,MAAM,cAAc;AAC/B,SAASC,cAAc,QAAQ,mBAAmB;AAClD,OAAOC,QAAQ,MAAM,sBAAsB;AAyB3C,MAAMC,QAA2B,GAAGA,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAoB,CAAC,KAAK;EAC9E,MAAMC,OAAO,GAAGT,OAAO,CACnB,MACIM,KAAK,EAAEI,GAAG,CAAC,CAAC;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAEC;EAAO,CAAC,kBAC5ChB,KAAA,CAAAiB,aAAA,CAACZ,QAAQ;IACLa,GAAG,EAAEH,EAAG;IACRA,EAAE,EAAEA,EAAG;IACPD,IAAI,EAAEA,IAAK;IACXD,IAAI,EAAEA,IAAK;IACXD,QAAQ,EAAEA,QAAS;IACnBI,MAAM,EAAEA,MAAO;IACfR,QAAQ,EAAEA,QAAS;IACnBC,mBAAmB,EAAEA;EAAoB,CAC5C,CACJ,CAAC,EACN,CAACF,KAAK,EAAEC,QAAQ,EAAEC,mBAAmB,CACzC,CAAC;EAED,OAAOR,OAAO,CACV,mBACID,KAAA,CAAAiB,aAAA,CAACf,kBAAkB;IAACiB,WAAW,EAAC;EAAyB,gBACrDnB,KAAA,CAAAiB,aAAA,CAACb,cAAc,qBACXJ,KAAA,CAAAiB,aAAA,CAACd,IAAI,QAAEO,OAAc,CACT,CACA,CACvB,EACD,CAACA,OAAO,CACZ,CAAC;AACL,CAAC;AAEDJ,QAAQ,CAACc,WAAW,GAAG,UAAU;AAEjC,eAAed,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"FileList.js","names":["React","useMemo","TextStringProviderSSR","List","StyledFileList","FileItem","FileList","files","onRemove","shouldAllowDownload","content","map","mimeType","size","name","id","source","createElement","key","libraries","displayName"],"sources":["../../../../src/components/file-list/FileList.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport { TextStringProviderSSR } from '@chayns/textstrings';\nimport List from '../list/List';\nimport { StyledFileList } from './FileList.styles';\nimport FileItem from './file-item/FileItem';\n\nexport interface IFileItem {\n id: string;\n name: string;\n size?: number;\n mimeType: string;\n source?: string | File;\n}\n\nexport type FileListProps = {\n /**\n * Already uploaded files to display.\n */\n files?: IFileItem[];\n /**\n * A function to be executed when a file is removed.\n */\n onRemove?: (id: IFileItem['id']) => void;\n /**\n * Whether to show a download icon for files that have a `source` set.\n */\n shouldAllowDownload?: boolean;\n};\n\nconst FileList: FC<FileListProps> = ({ files, onRemove, shouldAllowDownload }) => {\n const content = useMemo(\n () =>\n files?.map(({ mimeType, size, name, id, source }) => (\n <FileItem\n key={id}\n id={id}\n name={name}\n size={size}\n mimeType={mimeType}\n source={source}\n onRemove={onRemove}\n shouldAllowDownload={shouldAllowDownload}\n />\n )),\n [files, onRemove, shouldAllowDownload],\n );\n\n return useMemo(\n () => (\n <TextStringProviderSSR libraries=\"chayns-components-v5-core\" id=\"file-list\">\n <StyledFileList>\n <List>{content}</List>\n </StyledFileList>\n </TextStringProviderSSR>\n ),\n [content],\n );\n};\n\nFileList.displayName = 'FileList';\n\nexport default FileList;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,OAAO,QAAQ,OAAO;AAC1C,SAASC,qBAAqB,QAAQ,qBAAqB;AAC3D,OAAOC,IAAI,MAAM,cAAc;AAC/B,SAASC,cAAc,QAAQ,mBAAmB;AAClD,OAAOC,QAAQ,MAAM,sBAAsB;AAyB3C,MAAMC,QAA2B,GAAGA,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAoB,CAAC,KAAK;EAC9E,MAAMC,OAAO,GAAGT,OAAO,CACnB,MACIM,KAAK,EAAEI,GAAG,CAAC,CAAC;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAEC;EAAO,CAAC,kBAC5ChB,KAAA,CAAAiB,aAAA,CAACZ,QAAQ;IACLa,GAAG,EAAEH,EAAG;IACRA,EAAE,EAAEA,EAAG;IACPD,IAAI,EAAEA,IAAK;IACXD,IAAI,EAAEA,IAAK;IACXD,QAAQ,EAAEA,QAAS;IACnBI,MAAM,EAAEA,MAAO;IACfR,QAAQ,EAAEA,QAAS;IACnBC,mBAAmB,EAAEA;EAAoB,CAC5C,CACJ,CAAC,EACN,CAACF,KAAK,EAAEC,QAAQ,EAAEC,mBAAmB,CACzC,CAAC;EAED,OAAOR,OAAO,CACV,mBACID,KAAA,CAAAiB,aAAA,CAACf,qBAAqB;IAACiB,SAAS,EAAC,2BAA2B;IAACJ,EAAE,EAAC;EAAW,gBACvEf,KAAA,CAAAiB,aAAA,CAACb,cAAc,qBACXJ,KAAA,CAAAiB,aAAA,CAACd,IAAI,QAAEO,OAAc,CACT,CACG,CAC1B,EACD,CAACA,OAAO,CACZ,CAAC;AACL,CAAC;AAEDJ,QAAQ,CAACc,WAAW,GAAG,UAAU;AAEjC,eAAed,QAAQ","ignoreList":[]}
@@ -4,7 +4,7 @@ import Icon from '../../icon/Icon';
4
4
  import ContextMenu from '../../context-menu/ContextMenu';
5
5
  import ListItem from '../../list/list-item/ListItem';
6
6
  import { StyledFileItem, StyledFileItemKeyboardWrapper, StyledFileItemIcon } from './FileItem.styles';
7
- import { ttsToITextString, useTextstringValue } from '@chayns-components/textstring';
7
+ import { useTranslation } from '@chayns/textstrings';
8
8
  import textStrings from '../../../constants/textStrings';
9
9
  import { useFocusRingPortal } from '../../../hooks/useFocusRingPortal';
10
10
  import { useKeyboardFocusHighlighting } from '../../../hooks/useKeyboardFocusHighlighting';
@@ -89,12 +89,11 @@ const FileItem = ({
89
89
  });
90
90
  }
91
91
  }, [name, source]);
92
- const downloadText = useTextstringValue({
93
- textstring: ttsToITextString(textStrings.components.fileItem.download)
94
- });
95
- const removeText = useTextstringValue({
96
- textstring: ttsToITextString(textStrings.components.fileItem.remove)
97
- });
92
+ const {
93
+ t
94
+ } = useTranslation();
95
+ const downloadText = t(textStrings.components.fileItem.download);
96
+ const removeText = t(textStrings.components.fileItem.remove);
98
97
  const rightElement = useMemo(() => {
99
98
  if (!canDownload && !canRemove) return undefined;
100
99
  // Both actions available → show as ContextMenu