@chayns-components/core 5.0.0-beta.314 → 5.0.0-beta.320

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 (57) hide show
  1. package/lib/components/code-highlighter/CodeHighlighter.d.ts +27 -0
  2. package/lib/components/code-highlighter/CodeHighlighter.js +70 -0
  3. package/lib/components/code-highlighter/CodeHighlighter.js.map +1 -0
  4. package/lib/components/code-highlighter/CodeHighlighter.styles.d.ts +16 -0
  5. package/lib/components/code-highlighter/CodeHighlighter.styles.js +84 -0
  6. package/lib/components/code-highlighter/CodeHighlighter.styles.js.map +1 -0
  7. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.d.ts +8 -0
  8. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.js +38 -0
  9. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.js.map +1 -0
  10. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.d.ts +274 -0
  11. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.js +10 -0
  12. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.js.map +1 -0
  13. package/lib/components/file-input/FileInput.d.ts +21 -0
  14. package/lib/components/file-input/FileInput.js +104 -0
  15. package/lib/components/file-input/FileInput.js.map +1 -0
  16. package/lib/components/file-input/FileInput.styles.d.ts +546 -0
  17. package/lib/components/file-input/FileInput.styles.js +35 -0
  18. package/lib/components/file-input/FileInput.styles.js.map +1 -0
  19. package/lib/components/file-input/file-list/FileListItem.d.ts +9 -0
  20. package/lib/components/file-input/file-list/FileListItem.js +36 -0
  21. package/lib/components/file-input/file-list/FileListItem.js.map +1 -0
  22. package/lib/components/file-input/file-list/FileListItem.styles.d.ts +274 -0
  23. package/lib/components/file-input/file-list/FileListItem.styles.js +10 -0
  24. package/lib/components/file-input/file-list/FileListItem.styles.js.map +1 -0
  25. package/lib/components/setup-wizard/SetupWizard.d.ts +23 -0
  26. package/lib/components/setup-wizard/SetupWizard.js +79 -0
  27. package/lib/components/setup-wizard/SetupWizard.js.map +1 -0
  28. package/lib/components/setup-wizard/SetupWizard.styles.d.ts +274 -0
  29. package/lib/components/setup-wizard/SetupWizard.styles.js +10 -0
  30. package/lib/components/setup-wizard/SetupWizard.styles.js.map +1 -0
  31. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.d.ts +25 -0
  32. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +60 -0
  33. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -0
  34. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.d.ts +546 -0
  35. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.js +14 -0
  36. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.js.map +1 -0
  37. package/lib/components/text-area/TextArea.styles.js +3 -3
  38. package/lib/components/text-area/TextArea.styles.js.map +1 -1
  39. package/lib/components/truncation/Truncation.d.ts +25 -0
  40. package/lib/components/truncation/Truncation.js +76 -0
  41. package/lib/components/truncation/Truncation.js.map +1 -0
  42. package/lib/components/truncation/Truncation.styles.d.ts +820 -0
  43. package/lib/components/truncation/Truncation.styles.js +18 -0
  44. package/lib/components/truncation/Truncation.styles.js.map +1 -0
  45. package/lib/index.d.ts +7 -0
  46. package/lib/index.js +35 -0
  47. package/lib/index.js.map +1 -1
  48. package/lib/types/codeHighlighter.d.ts +10 -0
  49. package/lib/types/codeHighlighter.js +12 -0
  50. package/lib/types/codeHighlighter.js.map +1 -0
  51. package/lib/utils/file.d.ts +363 -0
  52. package/lib/utils/file.js +402 -0
  53. package/lib/utils/file.js.map +1 -0
  54. package/lib/utils/truncation.d.ts +1 -0
  55. package/lib/utils/truncation.js +34 -0
  56. package/lib/utils/truncation.js.map +1 -0
  57. package/package.json +4 -2
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _truncation = require("../../utils/truncation");
9
+ var _Truncation = require("./Truncation.styles");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ const Truncation = _ref => {
13
+ let {
14
+ collapsedHeight = 150,
15
+ moreLabel = 'Mehr',
16
+ lessLabel = 'Weniger',
17
+ onChange,
18
+ children
19
+ } = _ref;
20
+ const childrenContainerRef = (0, _react.useRef)(null);
21
+ const truncatedContentRef = (0, _react.useRef)(null);
22
+ const contentRef = (0, _react.useRef)(null);
23
+ const [childrenContainerHeight, setChildrenContainerHeight] = (0, _react.useState)();
24
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
25
+ const [showClamp, setShowClamp] = (0, _react.useState)(true);
26
+
27
+ // updates the content of the children container on animation completion
28
+ const handleAnimationComplete = (0, _react.useCallback)(() => {
29
+ if (childrenContainerRef.current) {
30
+ childrenContainerRef.current.innerHTML = isOpen ? contentRef.current?.innerHTML ?? '' : truncatedContentRef.current?.innerHTML ?? '';
31
+ }
32
+ }, [isOpen]);
33
+
34
+ // changes the state of the truncation
35
+ const handleClampClick = (0, _react.useCallback)(event => {
36
+ setIsOpen(current => {
37
+ onChange?.(event, !current);
38
+ return !current;
39
+ });
40
+ }, [onChange]);
41
+
42
+ // initialization logic
43
+ // set the height of the children container to the collapsed height
44
+ (0, _react.useEffect)(() => {
45
+ if (isOpen || !!truncatedContentRef.current || !childrenContainerRef.current) {
46
+ return;
47
+ }
48
+ setChildrenContainerHeight(childrenContainerRef.current.scrollHeight);
49
+ contentRef.current = childrenContainerRef.current.cloneNode(true);
50
+ (0, _truncation.truncateElement)(childrenContainerRef.current, collapsedHeight);
51
+ truncatedContentRef.current = childrenContainerRef.current.cloneNode(true);
52
+ }, [collapsedHeight, isOpen]);
53
+
54
+ // If truncated content is the same as the content, don't show the clamp because it's not needed
55
+ (0, _react.useEffect)(() => {
56
+ setShowClamp(contentRef.current?.innerHTML !== truncatedContentRef.current?.innerHTML);
57
+ }, []);
58
+ const height = isOpen ? childrenContainerHeight ?? 'auto' : `${collapsedHeight}px`;
59
+ return /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncation, {
60
+ className: "beta-chayns-truncation"
61
+ }, /*#__PURE__*/_react.default.createElement(_Truncation.StyledMotionTruncationContent, {
62
+ animate: {
63
+ height
64
+ },
65
+ initial: false,
66
+ onAnimationComplete: handleAnimationComplete,
67
+ ref: childrenContainerRef,
68
+ transition: {
69
+ type: 'tween'
70
+ }
71
+ }, children), showClamp && /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncationClamp, {
72
+ onClick: handleClampClick
73
+ }, isOpen ? lessLabel : moreLabel));
74
+ };
75
+ var _default = exports.default = Truncation;
76
+ //# sourceMappingURL=Truncation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Truncation.js","names":["_react","_interopRequireWildcard","require","_truncation","_Truncation","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Truncation","_ref","collapsedHeight","moreLabel","lessLabel","onChange","children","childrenContainerRef","useRef","truncatedContentRef","contentRef","childrenContainerHeight","setChildrenContainerHeight","useState","isOpen","setIsOpen","showClamp","setShowClamp","handleAnimationComplete","useCallback","current","innerHTML","handleClampClick","event","useEffect","scrollHeight","cloneNode","truncateElement","height","createElement","StyledTruncation","className","StyledMotionTruncationContent","animate","initial","onAnimationComplete","ref","transition","type","StyledTruncationClamp","onClick","_default","exports"],"sources":["../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { truncateElement } from '../../utils/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\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 height of the children Element in it`s collapsed state.\n */\n collapsedHeight?: number;\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\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n moreLabel = 'Mehr',\n lessLabel = 'Weniger',\n onChange,\n children,\n}) => {\n const childrenContainerRef = useRef<HTMLDivElement | null>(null);\n const truncatedContentRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLElement | null>(null);\n\n const [childrenContainerHeight, setChildrenContainerHeight] = useState<number>();\n const [isOpen, setIsOpen] = useState(false);\n const [showClamp, setShowClamp] = useState(true);\n\n // updates the content of the children container on animation completion\n const handleAnimationComplete = useCallback(() => {\n if (childrenContainerRef.current) {\n childrenContainerRef.current.innerHTML = isOpen\n ? contentRef.current?.innerHTML ?? ''\n : truncatedContentRef.current?.innerHTML ?? '';\n }\n }, [isOpen]);\n\n // changes the state of the truncation\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setIsOpen((current) => {\n onChange?.(event, !current);\n\n return !current;\n });\n },\n [onChange],\n );\n\n // initialization logic\n // set the height of the children container to the collapsed height\n useEffect(() => {\n if (isOpen || !!truncatedContentRef.current || !childrenContainerRef.current) {\n return;\n }\n\n setChildrenContainerHeight(childrenContainerRef.current.scrollHeight);\n\n contentRef.current = childrenContainerRef.current.cloneNode(true) as HTMLElement;\n\n truncateElement(childrenContainerRef.current, collapsedHeight);\n\n truncatedContentRef.current = childrenContainerRef.current.cloneNode(true) as HTMLElement;\n }, [collapsedHeight, isOpen]);\n\n // If truncated content is the same as the content, don't show the clamp because it's not needed\n useEffect(() => {\n setShowClamp(contentRef.current?.innerHTML !== truncatedContentRef.current?.innerHTML);\n }, []);\n\n const height = isOpen ? childrenContainerHeight ?? 'auto' : `${collapsedHeight}px`;\n\n return (\n <StyledTruncation className=\"beta-chayns-truncation\">\n <StyledMotionTruncationContent\n animate={{ height }}\n initial={false}\n onAnimationComplete={handleAnimationComplete}\n ref={childrenContainerRef}\n transition={{ type: 'tween' }}\n >\n {children}\n </StyledMotionTruncationContent>\n {showClamp && (\n <StyledTruncationClamp onClick={handleClampClick}>\n {isOpen ? lessLabel : moreLabel}\n </StyledTruncationClamp>\n )}\n </StyledTruncation>\n );\n};\n\nexport default Truncation;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAUA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAI6B,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL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