@chayns-components/textstring 5.0.0-beta.1000

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 (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/lib/cjs/components/textstring/Textstring.js +63 -0
  4. package/lib/cjs/components/textstring/Textstring.js.map +1 -0
  5. package/lib/cjs/components/textstring/types.js +2 -0
  6. package/lib/cjs/components/textstring/types.js.map +1 -0
  7. package/lib/cjs/components/textstring-provider/TextstringProvider.js +41 -0
  8. package/lib/cjs/components/textstring-provider/TextstringProvider.js.map +1 -0
  9. package/lib/cjs/hooks/useTextstringValue.js +21 -0
  10. package/lib/cjs/hooks/useTextstringValue.js.map +1 -0
  11. package/lib/cjs/index.js +35 -0
  12. package/lib/cjs/index.js.map +1 -0
  13. package/lib/cjs/types/textstring.js +2 -0
  14. package/lib/cjs/types/textstring.js.map +1 -0
  15. package/lib/cjs/utils/textstring.js +53 -0
  16. package/lib/cjs/utils/textstring.js.map +1 -0
  17. package/lib/esm/components/textstring/Textstring.js +56 -0
  18. package/lib/esm/components/textstring/Textstring.js.map +1 -0
  19. package/lib/esm/components/textstring/types.js +2 -0
  20. package/lib/esm/components/textstring/types.js.map +1 -0
  21. package/lib/esm/components/textstring-provider/TextstringProvider.js +34 -0
  22. package/lib/esm/components/textstring-provider/TextstringProvider.js.map +1 -0
  23. package/lib/esm/hooks/useTextstringValue.js +15 -0
  24. package/lib/esm/hooks/useTextstringValue.js.map +1 -0
  25. package/lib/esm/index.js +7 -0
  26. package/lib/esm/index.js.map +1 -0
  27. package/lib/esm/types/textstring.js +2 -0
  28. package/lib/esm/types/textstring.js.map +1 -0
  29. package/lib/esm/utils/textstring.js +46 -0
  30. package/lib/esm/utils/textstring.js.map +1 -0
  31. package/lib/types/components/textstring/Textstring.d.ts +34 -0
  32. package/lib/types/components/textstring/types.d.ts +7 -0
  33. package/lib/types/components/textstring-provider/TextstringProvider.d.ts +19 -0
  34. package/lib/types/hooks/useTextstringValue.d.ts +6 -0
  35. package/lib/types/index.d.ts +5 -0
  36. package/lib/types/types/textstring.d.ts +12 -0
  37. package/lib/types/utils/textstring.d.ts +18 -0
  38. package/package.json +85 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Tobit Laboratories AG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ <div align="center">
2
+ <h1>
3
+ <img src="https://raw.githubusercontent.com/TobitSoftware/chayns-components/master/assets/logo.png" width="600px" alt="chayns-components" />
4
+ </h1>
5
+ <p>A set of beautiful React components for developing your own applications with chayns.</p>
6
+ <div>
7
+ <img src="https://img.shields.io/npm/dm/@chayns-components/core.svg?style=for-the-badge" alt="" />
8
+ <img src="https://img.shields.io/npm/v/@chayns-components/core?style=for-the-badge" alt="" />
9
+ <img src="https://img.shields.io/github/license/TobitSoftware/chayns-components?style=for-the-badge" alt="" />
10
+ <img src="https://img.shields.io/github/contributors/TobitSoftware/chayns-components?style=for-the-badge" alt="" />
11
+ </div>
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ First you need to install the core part of the chayns-components.
19
+
20
+ ```bash
21
+ # NPM
22
+ npm install @chayns-components/textstring
23
+
24
+ # Yarn
25
+ yarn add @chayns-components/textstring
26
+ ```
27
+
28
+ > **Information:** Since the components have now been implemented with the styled-components
29
+ > library, the styles are delivered directly with the components. There is no need to load an extra
30
+ > stylesheet anymore.
31
+
32
+ ## Usage
33
+
34
+ For detailed usage visit the [storybook](https://components.chayns.site/storybook).
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _core = require("@chayns-components/core");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _useTextstringValue = require("../../hooks/useTextstringValue");
10
+ var _textstring = require("../../utils/textstring");
11
+ 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); }
12
+ 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 && {}.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; }
13
+ const Textstring = ({
14
+ children,
15
+ childrenClassName,
16
+ childrenStyles,
17
+ childrenTagName,
18
+ isTextstringHTML,
19
+ replacements,
20
+ textstring
21
+ }) => {
22
+ const text = (0, _useTextstringValue.useTextstringValue)({
23
+ textstring,
24
+ replacements
25
+ });
26
+
27
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
28
+ const childrenOnClickFunction = children === null || children === void 0 ? void 0 : children.props.onClick;
29
+ const handleClick = (0, _react.useCallback)(event => {
30
+ if (event.ctrlKey) {
31
+ void (0, _core.isTobitEmployee)().then(inGroup => {
32
+ if (inGroup) {
33
+ (0, _textstring.selectLanguageToChange)({
34
+ textstringName: textstring.name
35
+ });
36
+ }
37
+ });
38
+ } else if (typeof childrenOnClickFunction === 'function') {
39
+ childrenOnClickFunction(event);
40
+ }
41
+ }, [childrenOnClickFunction, textstring.name]);
42
+ if (children) {
43
+ return /*#__PURE__*/_react.default.cloneElement(children, {
44
+ dangerouslySetInnerHTML: isTextstringHTML ? {
45
+ __html: text
46
+ } : undefined,
47
+ onClick: handleClick
48
+ }, isTextstringHTML ? undefined : text);
49
+ }
50
+
51
+ // eslint-disable-next-line react/no-danger-with-children
52
+ return /*#__PURE__*/_react.default.createElement(childrenTagName || 'span', {
53
+ dangerouslySetInnerHTML: isTextstringHTML ? {
54
+ __html: text
55
+ } : undefined,
56
+ className: `${childrenClassName || ''} notranslate`.trim(),
57
+ onClick: handleClick,
58
+ style: childrenStyles
59
+ }, isTextstringHTML ? undefined : text);
60
+ };
61
+ Textstring.displayName = 'Textstring';
62
+ var _default = exports.default = Textstring;
63
+ //# sourceMappingURL=Textstring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textstring.js","names":["_core","require","_react","_interopRequireWildcard","_useTextstringValue","_textstring","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Textstring","children","childrenClassName","childrenStyles","childrenTagName","isTextstringHTML","replacements","textstring","text","useTextstringValue","childrenOnClickFunction","props","onClick","handleClick","useCallback","event","ctrlKey","isTobitEmployee","then","inGroup","selectLanguageToChange","textstringName","name","React","cloneElement","dangerouslySetInnerHTML","__html","undefined","createElement","className","trim","style","displayName","_default","exports"],"sources":["../../../../src/components/textstring/Textstring.tsx"],"sourcesContent":["import { isTobitEmployee } from '@chayns-components/core';\nimport React, {\n CSSProperties,\n FC,\n MouseEvent,\n ReactHTML,\n useCallback,\n type ReactElement,\n} from 'react';\nimport { useTextstringValue } from '../../hooks/useTextstringValue';\nimport { selectLanguageToChange } from '../../utils/textstring';\nimport type { ITextstring, TextstringReplacement } from './types';\n\nexport type TextstringProps = {\n /**\n * The element that the text should be displayed in.\n */\n children?: ReactElement;\n /**\n * The class name of the HTML element that the text should be displayed in. Only used if `children` is not set.\n */\n childrenClassName?: string;\n /**\n * The styles of the HTML element that the text should be displayed in. Only used if `children` is not set.\n */\n childrenStyles?: CSSProperties;\n /**\n * The tag of the HTML element that the text should be displayed in. Only used if `children` is not set.\n */\n childrenTagName?: keyof ReactHTML;\n /**\n * Whether the textstring contains HTML elements and should be displayed as HTML.\n */\n isTextstringHTML?: boolean;\n /**\n * Replacement values for the textstring.\n */\n replacements?: TextstringReplacement;\n /**\n * The text that should be displayed.\n */\n textstring: ITextstring;\n};\n\nconst Textstring: FC<TextstringProps> = ({\n children,\n childrenClassName,\n childrenStyles,\n childrenTagName,\n isTextstringHTML,\n replacements,\n textstring,\n}) => {\n const text = useTextstringValue({ textstring, replacements });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const childrenOnClickFunction = children?.props.onClick as\n | ((event: MouseEvent<HTMLElement>) => void)\n | undefined;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLElement>) => {\n if (event.ctrlKey) {\n void isTobitEmployee().then((inGroup) => {\n if (inGroup) {\n selectLanguageToChange({\n textstringName: textstring.name,\n });\n }\n });\n } else if (typeof childrenOnClickFunction === 'function') {\n childrenOnClickFunction(event);\n }\n },\n [childrenOnClickFunction, textstring.name],\n );\n\n if (children) {\n return React.cloneElement(\n children,\n {\n dangerouslySetInnerHTML: isTextstringHTML ? { __html: text } : undefined,\n onClick: handleClick,\n },\n isTextstringHTML ? undefined : text,\n );\n }\n\n // eslint-disable-next-line react/no-danger-with-children\n return React.createElement(\n childrenTagName || 'span',\n {\n dangerouslySetInnerHTML: isTextstringHTML ? { __html: text } : undefined,\n className: `${childrenClassName || ''} notranslate`.trim(),\n onClick: handleClick,\n style: childrenStyles,\n },\n isTextstringHTML ? undefined : text,\n );\n};\n\nTextstring.displayName = 'Textstring';\n\nexport default Textstring;\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/textstring/types.ts"],"sourcesContent":["export interface TextstringReplacement {\n [key: string]: string;\n}\n\nexport interface ITextstring {\n fallback: string;\n name: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.TextstringContext = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _textstring = require("../../utils/textstring");
9
+ 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); }
10
+ 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 && {}.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; }
11
+ const TextstringContext = exports.TextstringContext = /*#__PURE__*/(0, _react.createContext)({});
12
+ const TextstringProvider = ({
13
+ children,
14
+ libraryName,
15
+ language
16
+ }) => {
17
+ const [textstrings, setTextstrings] = (0, _react.useState)({});
18
+ (0, _react.useEffect)(() => {
19
+ const loadData = async () => {
20
+ const textstringResult = await (0, _textstring.loadLibrary)({
21
+ libraryName,
22
+ language
23
+ });
24
+ if (textstringResult) {
25
+ const prevTextstrings = window.Textstrings;
26
+ window.Textstrings = {
27
+ ...prevTextstrings,
28
+ [libraryName]: textstringResult
29
+ };
30
+ setTextstrings(textstringResult);
31
+ }
32
+ };
33
+ void loadData();
34
+ }, [language, libraryName]);
35
+ return /*#__PURE__*/_react.default.createElement(TextstringContext.Provider, {
36
+ value: textstrings
37
+ }, children);
38
+ };
39
+ TextstringProvider.displayName = 'TextstringProvider';
40
+ var _default = exports.default = TextstringProvider;
41
+ //# sourceMappingURL=TextstringProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextstringProvider.js","names":["_react","_interopRequireWildcard","require","_textstring","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","TextstringContext","exports","createContext","TextstringProvider","children","libraryName","language","textstrings","setTextstrings","useState","useEffect","loadData","textstringResult","loadLibrary","prevTextstrings","window","Textstrings","createElement","Provider","value","displayName","_default"],"sources":["../../../../src/components/textstring-provider/TextstringProvider.tsx"],"sourcesContent":["import React, { createContext, FC, ReactNode, useEffect, useState } from 'react';\nimport type { TextstringValue } from '../../types/textstring';\nimport { loadLibrary } from '../../utils/textstring';\n\nexport const TextstringContext = createContext<TextstringValue>({});\n\nexport type TextstringProviderProps = {\n /**\n * The element that should use the library.\n */\n children?: ReactNode;\n /**\n * The language that should be used.\n */\n language: string;\n /**\n * The name of the library.\n */\n libraryName: string;\n};\n\nconst TextstringProvider: FC<TextstringProviderProps> = ({ children, libraryName, language }) => {\n const [textstrings, setTextstrings] = useState<TextstringValue>({});\n\n useEffect(() => {\n const loadData = async () => {\n const textstringResult = await loadLibrary({ libraryName, language });\n\n if (textstringResult) {\n const prevTextstrings = window.Textstrings;\n\n window.Textstrings = {\n ...prevTextstrings,\n [libraryName]: textstringResult,\n };\n\n setTextstrings(textstringResult);\n }\n };\n\n void loadData();\n }, [language, libraryName]);\n\n return <TextstringContext.Provider value={textstrings}>{children}</TextstringContext.Provider>;\n};\n\nTextstringProvider.displayName = 'TextstringProvider';\n\nexport default TextstringProvider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAAqD,SAAAE,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,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAE9C,MAAMW,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,gBAAG,IAAAE,oBAAa,EAAkB,CAAC,CAAC,CAAC;AAiBnE,MAAMC,kBAA+C,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,WAAW;EAAEC;AAAS,CAAC,KAAK;EAC7F,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAkB,CAAC,CAAC,CAAC;EAEnE,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,QAAQ,GAAG,MAAAA,CAAA,KAAY;MACzB,MAAMC,gBAAgB,GAAG,MAAM,IAAAC,uBAAW,EAAC;QAAER,WAAW;QAAEC;MAAS,CAAC,CAAC;MAErE,IAAIM,gBAAgB,EAAE;QAClB,MAAME,eAAe,GAAGC,MAAM,CAACC,WAAW;QAE1CD,MAAM,CAACC,WAAW,GAAG;UACjB,GAAGF,eAAe;UAClB,CAACT,WAAW,GAAGO;QACnB,CAAC;QAEDJ,cAAc,CAACI,gBAAgB,CAAC;MACpC;IACJ,CAAC;IAED,KAAKD,QAAQ,CAAC,CAAC;EACnB,CAAC,EAAE,CAACL,QAAQ,EAAED,WAAW,CAAC,CAAC;EAE3B,oBAAO7B,MAAA,CAAAU,OAAA,CAAA+B,aAAA,CAACjB,iBAAiB,CAACkB,QAAQ;IAACC,KAAK,EAAEZ;EAAY,GAAEH,QAAqC,CAAC;AAClG,CAAC;AAEDD,kBAAkB,CAACiB,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAApB,OAAA,CAAAf,OAAA,GAEvCiB,kBAAkB","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTextstringValue = void 0;
7
+ var _react = require("react");
8
+ var _TextstringProvider = require("../components/textstring-provider/TextstringProvider");
9
+ const useTextstringValue = ({
10
+ replacements,
11
+ textstring
12
+ }) => {
13
+ const textstrings = (0, _react.useContext)(_TextstringProvider.TextstringContext);
14
+ const value = textstrings[textstring.name] ?? textstring.fallback;
15
+ if (!replacements) {
16
+ return value;
17
+ }
18
+ return Object.keys(replacements).reduce((current, key) => current.replace(new RegExp(key, 'g'), replacements[key] || ''), value);
19
+ };
20
+ exports.useTextstringValue = useTextstringValue;
21
+ //# sourceMappingURL=useTextstringValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTextstringValue.js","names":["_react","require","_TextstringProvider","useTextstringValue","replacements","textstring","textstrings","useContext","TextstringContext","value","name","fallback","Object","keys","reduce","current","key","replace","RegExp","exports"],"sources":["../../../src/hooks/useTextstringValue.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { TextstringContext } from '../components/textstring-provider/TextstringProvider';\nimport type { ITextstring, TextstringReplacement } from '../components/textstring/types';\n\nexport interface UseTextstringValue {\n textstring: ITextstring;\n replacements?: TextstringReplacement;\n}\n\nexport const useTextstringValue = ({ replacements, textstring }: UseTextstringValue) => {\n const textstrings = useContext(TextstringContext);\n\n const value = textstrings[textstring.name] ?? textstring.fallback;\n\n if (!replacements) {\n return value;\n }\n\n return Object.keys(replacements).reduce(\n (current, key) => current.replace(new RegExp(key, 'g'), <string>replacements[key] || ''),\n value,\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAQO,MAAME,kBAAkB,GAAGA,CAAC;EAAEC,YAAY;EAAEC;AAA+B,CAAC,KAAK;EACpF,MAAMC,WAAW,GAAG,IAAAC,iBAAU,EAACC,qCAAiB,CAAC;EAEjD,MAAMC,KAAK,GAAGH,WAAW,CAACD,UAAU,CAACK,IAAI,CAAC,IAAIL,UAAU,CAACM,QAAQ;EAEjE,IAAI,CAACP,YAAY,EAAE;IACf,OAAOK,KAAK;EAChB;EAEA,OAAOG,MAAM,CAACC,IAAI,CAACT,YAAY,CAAC,CAACU,MAAM,CACnC,CAACC,OAAO,EAAEC,GAAG,KAAKD,OAAO,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,GAAG,EAAE,GAAG,CAAC,EAAUZ,YAAY,CAACY,GAAG,CAAC,IAAI,EAAE,CAAC,EACxFP,KACJ,CAAC;AACL,CAAC;AAACU,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Textstring", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Textstring.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "TextstringProvider", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _TextstringProvider.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "getTextstringValue", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _textstring.getTextstringValue;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "useTextstringValue", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _useTextstringValue.useTextstringValue;
28
+ }
29
+ });
30
+ var _TextstringProvider = _interopRequireDefault(require("./components/textstring-provider/TextstringProvider"));
31
+ var _Textstring = _interopRequireDefault(require("./components/textstring/Textstring"));
32
+ var _useTextstringValue = require("./hooks/useTextstringValue");
33
+ var _textstring = require("./utils/textstring");
34
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_TextstringProvider","_interopRequireDefault","require","_Textstring","_useTextstringValue","_textstring","e","__esModule","default"],"sources":["../../src/index.ts"],"sourcesContent":["// noinspection JSUnusedGlobalSymbols\n\nexport { default as TextstringProvider } from './components/textstring-provider/TextstringProvider';\nexport { default as Textstring } from './components/textstring/Textstring';\nexport type { ITextstring, TextstringReplacement } from './components/textstring/types';\nexport { useTextstringValue } from './hooks/useTextstringValue';\nexport { getTextstringValue } from './utils/textstring';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAAwD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=textstring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textstring.js","names":[],"sources":["../../../src/types/textstring.ts"],"sourcesContent":["declare global {\n interface Window {\n Textstrings: TextstringValues;\n }\n}\n\ntype TextstringValues = {\n [key: string]: TextstringValue;\n};\n\nexport type TextstringValue = {\n [key: string]: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectLanguageToChange = exports.loadLibrary = exports.getTextstringValue = void 0;
7
+ var _chaynsApi = require("chayns-api");
8
+ const loadLibrary = async ({
9
+ language,
10
+ libraryName
11
+ }) => {
12
+ const response = await fetch(`https://webapi.tobit.com/TextstringService/v1.0/LangStrings/${libraryName}?language=${language}`);
13
+ if (response.status !== 200) {
14
+ return null;
15
+ }
16
+ return await response.json();
17
+ };
18
+ exports.loadLibrary = loadLibrary;
19
+ const selectLanguageToChange = ({
20
+ textstringName
21
+ }) => {
22
+ // Note: the page is in v4
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ void _chaynsApi.dialog.iFrame({
26
+ url: 'https://tapp-staging.chayns-static.space/text-string-tapp/v1/iframe-edit.html',
27
+ buttons: [],
28
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
+ // @ts-ignore
30
+ input: {
31
+ textstring: textstringName
32
+ }
33
+ });
34
+ };
35
+ exports.selectLanguageToChange = selectLanguageToChange;
36
+ const getTextstringValue = ({
37
+ libraryName,
38
+ textstring,
39
+ replacements
40
+ }) => {
41
+ var _window$Textstrings;
42
+ const textstrings = typeof window !== 'undefined' ? (_window$Textstrings = window.Textstrings) === null || _window$Textstrings === void 0 ? void 0 : _window$Textstrings[libraryName] : undefined;
43
+ if (!textstrings) {
44
+ return textstring.fallback;
45
+ }
46
+ const value = textstrings[textstring.name] ?? textstring.fallback;
47
+ if (!replacements) {
48
+ return value;
49
+ }
50
+ return Object.keys(replacements).reduce((current, key) => current.replace(new RegExp(key, 'g'), replacements[key] || ''), value);
51
+ };
52
+ exports.getTextstringValue = getTextstringValue;
53
+ //# sourceMappingURL=textstring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textstring.js","names":["_chaynsApi","require","loadLibrary","language","libraryName","response","fetch","status","json","exports","selectLanguageToChange","textstringName","dialog","iFrame","url","buttons","input","textstring","getTextstringValue","replacements","_window$Textstrings","textstrings","window","Textstrings","undefined","fallback","value","name","Object","keys","reduce","current","key","replace","RegExp"],"sources":["../../../src/utils/textstring.ts"],"sourcesContent":["import { dialog } from 'chayns-api';\nimport type { ITextstring, TextstringReplacement } from '../components/textstring/types';\nimport type { TextstringValue } from '../types/textstring';\n\ninterface LoadLibraryOptions {\n libraryName: string;\n language: string;\n}\n\nexport const loadLibrary = async ({ language, libraryName }: LoadLibraryOptions) => {\n const response = await fetch(\n `https://webapi.tobit.com/TextstringService/v1.0/LangStrings/${libraryName}?language=${language}`,\n );\n\n if (response.status !== 200) {\n return null;\n }\n\n return (await response.json()) as TextstringValue;\n};\n\ninterface SelectLanguageToChangeOptions {\n textstringName: string;\n}\n\nexport const selectLanguageToChange = ({ textstringName }: SelectLanguageToChangeOptions) => {\n // Note: the page is in v4\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void dialog.iFrame({\n url: 'https://tapp-staging.chayns-static.space/text-string-tapp/v1/iframe-edit.html',\n buttons: [],\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n input: { textstring: textstringName },\n });\n};\n\ninterface GetTextstringValueOptions {\n textstring: ITextstring;\n libraryName: string;\n replacements?: TextstringReplacement;\n}\n\nexport const getTextstringValue = ({\n libraryName,\n textstring,\n replacements,\n}: GetTextstringValueOptions): string => {\n const textstrings =\n typeof window !== 'undefined' ? window.Textstrings?.[libraryName] : undefined;\n\n if (!textstrings) {\n return textstring.fallback;\n }\n\n const value = textstrings[textstring.name] ?? textstring.fallback;\n\n if (!replacements) {\n return value;\n }\n\n return Object.keys(replacements).reduce(\n (current, key) => current.replace(new RegExp(key, 'g'), <string>replacements[key] || ''),\n value,\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,WAAW,GAAG,MAAAA,CAAO;EAAEC,QAAQ;EAAEC;AAAgC,CAAC,KAAK;EAChF,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CACxB,+DAA+DF,WAAW,aAAaD,QAAQ,EACnG,CAAC;EAED,IAAIE,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IACzB,OAAO,IAAI;EACf;EAEA,OAAQ,MAAMF,QAAQ,CAACG,IAAI,CAAC,CAAC;AACjC,CAAC;AAACC,OAAA,CAAAP,WAAA,GAAAA,WAAA;AAMK,MAAMQ,sBAAsB,GAAGA,CAAC;EAAEC;AAA8C,CAAC,KAAK;EACzF;EACA;EACA;EACA,KAAKC,iBAAM,CAACC,MAAM,CAAC;IACfC,GAAG,EAAE,+EAA+E;IACpFC,OAAO,EAAE,EAAE;IACX;IACA;IACAC,KAAK,EAAE;MAAEC,UAAU,EAAEN;IAAe;EACxC,CAAC,CAAC;AACN,CAAC;AAACF,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAQK,MAAMQ,kBAAkB,GAAGA,CAAC;EAC/Bd,WAAW;EACXa,UAAU;EACVE;AACuB,CAAC,KAAa;EAAA,IAAAC,mBAAA;EACrC,MAAMC,WAAW,GACb,OAAOC,MAAM,KAAK,WAAW,IAAAF,mBAAA,GAAGE,MAAM,CAACC,WAAW,cAAAH,mBAAA,uBAAlBA,mBAAA,CAAqBhB,WAAW,CAAC,GAAGoB,SAAS;EAEjF,IAAI,CAACH,WAAW,EAAE;IACd,OAAOJ,UAAU,CAACQ,QAAQ;EAC9B;EAEA,MAAMC,KAAK,GAAGL,WAAW,CAACJ,UAAU,CAACU,IAAI,CAAC,IAAIV,UAAU,CAACQ,QAAQ;EAEjE,IAAI,CAACN,YAAY,EAAE;IACf,OAAOO,KAAK;EAChB;EAEA,OAAOE,MAAM,CAACC,IAAI,CAACV,YAAY,CAAC,CAACW,MAAM,CACnC,CAACC,OAAO,EAAEC,GAAG,KAAKD,OAAO,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,GAAG,EAAE,GAAG,CAAC,EAAUb,YAAY,CAACa,GAAG,CAAC,IAAI,EAAE,CAAC,EACxFN,KACJ,CAAC;AACL,CAAC;AAACjB,OAAA,CAAAS,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,56 @@
1
+ import { isTobitEmployee } from '@chayns-components/core';
2
+ import React, { useCallback } from 'react';
3
+ import { useTextstringValue } from '../../hooks/useTextstringValue';
4
+ import { selectLanguageToChange } from '../../utils/textstring';
5
+ const Textstring = _ref => {
6
+ let {
7
+ children,
8
+ childrenClassName,
9
+ childrenStyles,
10
+ childrenTagName,
11
+ isTextstringHTML,
12
+ replacements,
13
+ textstring
14
+ } = _ref;
15
+ const text = useTextstringValue({
16
+ textstring,
17
+ replacements
18
+ });
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
+ const childrenOnClickFunction = children?.props.onClick;
22
+ const handleClick = useCallback(event => {
23
+ if (event.ctrlKey) {
24
+ void isTobitEmployee().then(inGroup => {
25
+ if (inGroup) {
26
+ selectLanguageToChange({
27
+ textstringName: textstring.name
28
+ });
29
+ }
30
+ });
31
+ } else if (typeof childrenOnClickFunction === 'function') {
32
+ childrenOnClickFunction(event);
33
+ }
34
+ }, [childrenOnClickFunction, textstring.name]);
35
+ if (children) {
36
+ return /*#__PURE__*/React.cloneElement(children, {
37
+ dangerouslySetInnerHTML: isTextstringHTML ? {
38
+ __html: text
39
+ } : undefined,
40
+ onClick: handleClick
41
+ }, isTextstringHTML ? undefined : text);
42
+ }
43
+
44
+ // eslint-disable-next-line react/no-danger-with-children
45
+ return /*#__PURE__*/React.createElement(childrenTagName || 'span', {
46
+ dangerouslySetInnerHTML: isTextstringHTML ? {
47
+ __html: text
48
+ } : undefined,
49
+ className: `${childrenClassName || ''} notranslate`.trim(),
50
+ onClick: handleClick,
51
+ style: childrenStyles
52
+ }, isTextstringHTML ? undefined : text);
53
+ };
54
+ Textstring.displayName = 'Textstring';
55
+ export default Textstring;
56
+ //# sourceMappingURL=Textstring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textstring.js","names":["isTobitEmployee","React","useCallback","useTextstringValue","selectLanguageToChange","Textstring","_ref","children","childrenClassName","childrenStyles","childrenTagName","isTextstringHTML","replacements","textstring","text","childrenOnClickFunction","props","onClick","handleClick","event","ctrlKey","then","inGroup","textstringName","name","cloneElement","dangerouslySetInnerHTML","__html","undefined","createElement","className","trim","style","displayName"],"sources":["../../../../src/components/textstring/Textstring.tsx"],"sourcesContent":["import { isTobitEmployee } from '@chayns-components/core';\nimport React, {\n CSSProperties,\n FC,\n MouseEvent,\n ReactHTML,\n useCallback,\n type ReactElement,\n} from 'react';\nimport { useTextstringValue } from '../../hooks/useTextstringValue';\nimport { selectLanguageToChange } from '../../utils/textstring';\nimport type { ITextstring, TextstringReplacement } from './types';\n\nexport type TextstringProps = {\n /**\n * The element that the text should be displayed in.\n */\n children?: ReactElement;\n /**\n * The class name of the HTML element that the text should be displayed in. Only used if `children` is not set.\n */\n childrenClassName?: string;\n /**\n * The styles of the HTML element that the text should be displayed in. Only used if `children` is not set.\n */\n childrenStyles?: CSSProperties;\n /**\n * The tag of the HTML element that the text should be displayed in. Only used if `children` is not set.\n */\n childrenTagName?: keyof ReactHTML;\n /**\n * Whether the textstring contains HTML elements and should be displayed as HTML.\n */\n isTextstringHTML?: boolean;\n /**\n * Replacement values for the textstring.\n */\n replacements?: TextstringReplacement;\n /**\n * The text that should be displayed.\n */\n textstring: ITextstring;\n};\n\nconst Textstring: FC<TextstringProps> = ({\n children,\n childrenClassName,\n childrenStyles,\n childrenTagName,\n isTextstringHTML,\n replacements,\n textstring,\n}) => {\n const text = useTextstringValue({ textstring, replacements });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const childrenOnClickFunction = children?.props.onClick as\n | ((event: MouseEvent<HTMLElement>) => void)\n | undefined;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLElement>) => {\n if (event.ctrlKey) {\n void isTobitEmployee().then((inGroup) => {\n if (inGroup) {\n selectLanguageToChange({\n textstringName: textstring.name,\n });\n }\n });\n } else if (typeof childrenOnClickFunction === 'function') {\n childrenOnClickFunction(event);\n }\n },\n [childrenOnClickFunction, textstring.name],\n );\n\n if (children) {\n return React.cloneElement(\n children,\n {\n dangerouslySetInnerHTML: isTextstringHTML ? { __html: text } : undefined,\n onClick: handleClick,\n },\n isTextstringHTML ? undefined : text,\n );\n }\n\n // eslint-disable-next-line react/no-danger-with-children\n return React.createElement(\n childrenTagName || 'span',\n {\n dangerouslySetInnerHTML: isTextstringHTML ? { __html: text } : undefined,\n className: `${childrenClassName || ''} notranslate`.trim(),\n onClick: handleClick,\n style: childrenStyles,\n },\n isTextstringHTML ? undefined : text,\n );\n};\n\nTextstring.displayName = 'Textstring';\n\nexport default Textstring;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,yBAAyB;AACzD,OAAOC,KAAK,IAKRC,WAAW,QAER,OAAO;AACd,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,sBAAsB,QAAQ,wBAAwB;AAkC/D,MAAMC,UAA+B,GAAGC,IAAA,IAQlC;EAAA,IARmC;IACrCC,QAAQ;IACRC,iBAAiB;IACjBC,cAAc;IACdC,eAAe;IACfC,gBAAgB;IAChBC,YAAY;IACZC;EACJ,CAAC,GAAAP,IAAA;EACG,MAAMQ,IAAI,GAAGX,kBAAkB,CAAC;IAAEU,UAAU;IAAED;EAAa,CAAC,CAAC;;EAE7D;EACA,MAAMG,uBAAuB,GAAGR,QAAQ,EAAES,KAAK,CAACC,OAEjC;EAEf,MAAMC,WAAW,GAAGhB,WAAW,CAC1BiB,KAA8B,IAAK;IAChC,IAAIA,KAAK,CAACC,OAAO,EAAE;MACf,KAAKpB,eAAe,CAAC,CAAC,CAACqB,IAAI,CAAEC,OAAO,IAAK;QACrC,IAAIA,OAAO,EAAE;UACTlB,sBAAsB,CAAC;YACnBmB,cAAc,EAAEV,UAAU,CAACW;UAC/B,CAAC,CAAC;QACN;MACJ,CAAC,CAAC;IACN,CAAC,MAAM,IAAI,OAAOT,uBAAuB,KAAK,UAAU,EAAE;MACtDA,uBAAuB,CAACI,KAAK,CAAC;IAClC;EACJ,CAAC,EACD,CAACJ,uBAAuB,EAAEF,UAAU,CAACW,IAAI,CAC7C,CAAC;EAED,IAAIjB,QAAQ,EAAE;IACV,oBAAON,KAAK,CAACwB,YAAY,CACrBlB,QAAQ,EACR;MACImB,uBAAuB,EAAEf,gBAAgB,GAAG;QAAEgB,MAAM,EAAEb;MAAK,CAAC,GAAGc,SAAS;MACxEX,OAAO,EAAEC;IACb,CAAC,EACDP,gBAAgB,GAAGiB,SAAS,GAAGd,IACnC,CAAC;EACL;;EAEA;EACA,oBAAOb,KAAK,CAAC4B,aAAa,CACtBnB,eAAe,IAAI,MAAM,EACzB;IACIgB,uBAAuB,EAAEf,gBAAgB,GAAG;MAAEgB,MAAM,EAAEb;IAAK,CAAC,GAAGc,SAAS;IACxEE,SAAS,EAAE,GAAGtB,iBAAiB,IAAI,EAAE,cAAc,CAACuB,IAAI,CAAC,CAAC;IAC1Dd,OAAO,EAAEC,WAAW;IACpBc,KAAK,EAAEvB;EACX,CAAC,EACDE,gBAAgB,GAAGiB,SAAS,GAAGd,IACnC,CAAC;AACL,CAAC;AAEDT,UAAU,CAAC4B,WAAW,GAAG,YAAY;AAErC,eAAe5B,UAAU","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/textstring/types.ts"],"sourcesContent":["export interface TextstringReplacement {\n [key: string]: string;\n}\n\nexport interface ITextstring {\n fallback: string;\n name: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ import React, { createContext, useEffect, useState } from 'react';
2
+ import { loadLibrary } from '../../utils/textstring';
3
+ export const TextstringContext = /*#__PURE__*/createContext({});
4
+ const TextstringProvider = _ref => {
5
+ let {
6
+ children,
7
+ libraryName,
8
+ language
9
+ } = _ref;
10
+ const [textstrings, setTextstrings] = useState({});
11
+ useEffect(() => {
12
+ const loadData = async () => {
13
+ const textstringResult = await loadLibrary({
14
+ libraryName,
15
+ language
16
+ });
17
+ if (textstringResult) {
18
+ const prevTextstrings = window.Textstrings;
19
+ window.Textstrings = {
20
+ ...prevTextstrings,
21
+ [libraryName]: textstringResult
22
+ };
23
+ setTextstrings(textstringResult);
24
+ }
25
+ };
26
+ void loadData();
27
+ }, [language, libraryName]);
28
+ return /*#__PURE__*/React.createElement(TextstringContext.Provider, {
29
+ value: textstrings
30
+ }, children);
31
+ };
32
+ TextstringProvider.displayName = 'TextstringProvider';
33
+ export default TextstringProvider;
34
+ //# sourceMappingURL=TextstringProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextstringProvider.js","names":["React","createContext","useEffect","useState","loadLibrary","TextstringContext","TextstringProvider","_ref","children","libraryName","language","textstrings","setTextstrings","loadData","textstringResult","prevTextstrings","window","Textstrings","createElement","Provider","value","displayName"],"sources":["../../../../src/components/textstring-provider/TextstringProvider.tsx"],"sourcesContent":["import React, { createContext, FC, ReactNode, useEffect, useState } from 'react';\nimport type { TextstringValue } from '../../types/textstring';\nimport { loadLibrary } from '../../utils/textstring';\n\nexport const TextstringContext = createContext<TextstringValue>({});\n\nexport type TextstringProviderProps = {\n /**\n * The element that should use the library.\n */\n children?: ReactNode;\n /**\n * The language that should be used.\n */\n language: string;\n /**\n * The name of the library.\n */\n libraryName: string;\n};\n\nconst TextstringProvider: FC<TextstringProviderProps> = ({ children, libraryName, language }) => {\n const [textstrings, setTextstrings] = useState<TextstringValue>({});\n\n useEffect(() => {\n const loadData = async () => {\n const textstringResult = await loadLibrary({ libraryName, language });\n\n if (textstringResult) {\n const prevTextstrings = window.Textstrings;\n\n window.Textstrings = {\n ...prevTextstrings,\n [libraryName]: textstringResult,\n };\n\n setTextstrings(textstringResult);\n }\n };\n\n void loadData();\n }, [language, libraryName]);\n\n return <TextstringContext.Provider value={textstrings}>{children}</TextstringContext.Provider>;\n};\n\nTextstringProvider.displayName = 'TextstringProvider';\n\nexport default TextstringProvider;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAiBC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAEhF,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,OAAO,MAAMC,iBAAiB,gBAAGJ,aAAa,CAAkB,CAAC,CAAC,CAAC;AAiBnE,MAAMK,kBAA+C,GAAGC,IAAA,IAAyC;EAAA,IAAxC;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAAH,IAAA;EACxF,MAAM,CAACI,WAAW,EAAEC,cAAc,CAAC,GAAGT,QAAQ,CAAkB,CAAC,CAAC,CAAC;EAEnED,SAAS,CAAC,MAAM;IACZ,MAAMW,QAAQ,GAAG,MAAAA,CAAA,KAAY;MACzB,MAAMC,gBAAgB,GAAG,MAAMV,WAAW,CAAC;QAAEK,WAAW;QAAEC;MAAS,CAAC,CAAC;MAErE,IAAII,gBAAgB,EAAE;QAClB,MAAMC,eAAe,GAAGC,MAAM,CAACC,WAAW;QAE1CD,MAAM,CAACC,WAAW,GAAG;UACjB,GAAGF,eAAe;UAClB,CAACN,WAAW,GAAGK;QACnB,CAAC;QAEDF,cAAc,CAACE,gBAAgB,CAAC;MACpC;IACJ,CAAC;IAED,KAAKD,QAAQ,CAAC,CAAC;EACnB,CAAC,EAAE,CAACH,QAAQ,EAAED,WAAW,CAAC,CAAC;EAE3B,oBAAOT,KAAA,CAAAkB,aAAA,CAACb,iBAAiB,CAACc,QAAQ;IAACC,KAAK,EAAET;EAAY,GAAEH,QAAqC,CAAC;AAClG,CAAC;AAEDF,kBAAkB,CAACe,WAAW,GAAG,oBAAoB;AAErD,eAAef,kBAAkB","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { useContext } from 'react';
2
+ import { TextstringContext } from '../components/textstring-provider/TextstringProvider';
3
+ export const useTextstringValue = _ref => {
4
+ let {
5
+ replacements,
6
+ textstring
7
+ } = _ref;
8
+ const textstrings = useContext(TextstringContext);
9
+ const value = textstrings[textstring.name] ?? textstring.fallback;
10
+ if (!replacements) {
11
+ return value;
12
+ }
13
+ return Object.keys(replacements).reduce((current, key) => current.replace(new RegExp(key, 'g'), replacements[key] || ''), value);
14
+ };
15
+ //# sourceMappingURL=useTextstringValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTextstringValue.js","names":["useContext","TextstringContext","useTextstringValue","_ref","replacements","textstring","textstrings","value","name","fallback","Object","keys","reduce","current","key","replace","RegExp"],"sources":["../../../src/hooks/useTextstringValue.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { TextstringContext } from '../components/textstring-provider/TextstringProvider';\nimport type { ITextstring, TextstringReplacement } from '../components/textstring/types';\n\nexport interface UseTextstringValue {\n textstring: ITextstring;\n replacements?: TextstringReplacement;\n}\n\nexport const useTextstringValue = ({ replacements, textstring }: UseTextstringValue) => {\n const textstrings = useContext(TextstringContext);\n\n const value = textstrings[textstring.name] ?? textstring.fallback;\n\n if (!replacements) {\n return value;\n }\n\n return Object.keys(replacements).reduce(\n (current, key) => current.replace(new RegExp(key, 'g'), <string>replacements[key] || ''),\n value,\n );\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,iBAAiB,QAAQ,sDAAsD;AAQxF,OAAO,MAAMC,kBAAkB,GAAGC,IAAA,IAAsD;EAAA,IAArD;IAAEC,YAAY;IAAEC;EAA+B,CAAC,GAAAF,IAAA;EAC/E,MAAMG,WAAW,GAAGN,UAAU,CAACC,iBAAiB,CAAC;EAEjD,MAAMM,KAAK,GAAGD,WAAW,CAACD,UAAU,CAACG,IAAI,CAAC,IAAIH,UAAU,CAACI,QAAQ;EAEjE,IAAI,CAACL,YAAY,EAAE;IACf,OAAOG,KAAK;EAChB;EAEA,OAAOG,MAAM,CAACC,IAAI,CAACP,YAAY,CAAC,CAACQ,MAAM,CACnC,CAACC,OAAO,EAAEC,GAAG,KAAKD,OAAO,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,GAAG,EAAE,GAAG,CAAC,EAAUV,YAAY,CAACU,GAAG,CAAC,IAAI,EAAE,CAAC,EACxFP,KACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+
3
+ export { default as TextstringProvider } from './components/textstring-provider/TextstringProvider';
4
+ export { default as Textstring } from './components/textstring/Textstring';
5
+ export { useTextstringValue } from './hooks/useTextstringValue';
6
+ export { getTextstringValue } from './utils/textstring';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["default","TextstringProvider","Textstring","useTextstringValue","getTextstringValue"],"sources":["../../src/index.ts"],"sourcesContent":["// noinspection JSUnusedGlobalSymbols\n\nexport { default as TextstringProvider } from './components/textstring-provider/TextstringProvider';\nexport { default as Textstring } from './components/textstring/Textstring';\nexport type { ITextstring, TextstringReplacement } from './components/textstring/types';\nexport { useTextstringValue } from './hooks/useTextstringValue';\nexport { getTextstringValue } from './utils/textstring';\n"],"mappings":"AAAA;;AAEA,SAASA,OAAO,IAAIC,kBAAkB,QAAQ,qDAAqD;AACnG,SAASD,OAAO,IAAIE,UAAU,QAAQ,oCAAoC;AAE1E,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,kBAAkB,QAAQ,oBAAoB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=textstring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textstring.js","names":[],"sources":["../../../src/types/textstring.ts"],"sourcesContent":["declare global {\n interface Window {\n Textstrings: TextstringValues;\n }\n}\n\ntype TextstringValues = {\n [key: string]: TextstringValue;\n};\n\nexport type TextstringValue = {\n [key: string]: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ import { dialog } from 'chayns-api';
2
+ export const loadLibrary = async _ref => {
3
+ let {
4
+ language,
5
+ libraryName
6
+ } = _ref;
7
+ const response = await fetch(`https://webapi.tobit.com/TextstringService/v1.0/LangStrings/${libraryName}?language=${language}`);
8
+ if (response.status !== 200) {
9
+ return null;
10
+ }
11
+ return await response.json();
12
+ };
13
+ export const selectLanguageToChange = _ref2 => {
14
+ let {
15
+ textstringName
16
+ } = _ref2;
17
+ // Note: the page is in v4
18
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
+ // @ts-ignore
20
+ void dialog.iFrame({
21
+ url: 'https://tapp-staging.chayns-static.space/text-string-tapp/v1/iframe-edit.html',
22
+ buttons: [],
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ input: {
26
+ textstring: textstringName
27
+ }
28
+ });
29
+ };
30
+ export const getTextstringValue = _ref3 => {
31
+ let {
32
+ libraryName,
33
+ textstring,
34
+ replacements
35
+ } = _ref3;
36
+ const textstrings = typeof window !== 'undefined' ? window.Textstrings?.[libraryName] : undefined;
37
+ if (!textstrings) {
38
+ return textstring.fallback;
39
+ }
40
+ const value = textstrings[textstring.name] ?? textstring.fallback;
41
+ if (!replacements) {
42
+ return value;
43
+ }
44
+ return Object.keys(replacements).reduce((current, key) => current.replace(new RegExp(key, 'g'), replacements[key] || ''), value);
45
+ };
46
+ //# sourceMappingURL=textstring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textstring.js","names":["dialog","loadLibrary","_ref","language","libraryName","response","fetch","status","json","selectLanguageToChange","_ref2","textstringName","iFrame","url","buttons","input","textstring","getTextstringValue","_ref3","replacements","textstrings","window","Textstrings","undefined","fallback","value","name","Object","keys","reduce","current","key","replace","RegExp"],"sources":["../../../src/utils/textstring.ts"],"sourcesContent":["import { dialog } from 'chayns-api';\nimport type { ITextstring, TextstringReplacement } from '../components/textstring/types';\nimport type { TextstringValue } from '../types/textstring';\n\ninterface LoadLibraryOptions {\n libraryName: string;\n language: string;\n}\n\nexport const loadLibrary = async ({ language, libraryName }: LoadLibraryOptions) => {\n const response = await fetch(\n `https://webapi.tobit.com/TextstringService/v1.0/LangStrings/${libraryName}?language=${language}`,\n );\n\n if (response.status !== 200) {\n return null;\n }\n\n return (await response.json()) as TextstringValue;\n};\n\ninterface SelectLanguageToChangeOptions {\n textstringName: string;\n}\n\nexport const selectLanguageToChange = ({ textstringName }: SelectLanguageToChangeOptions) => {\n // Note: the page is in v4\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void dialog.iFrame({\n url: 'https://tapp-staging.chayns-static.space/text-string-tapp/v1/iframe-edit.html',\n buttons: [],\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n input: { textstring: textstringName },\n });\n};\n\ninterface GetTextstringValueOptions {\n textstring: ITextstring;\n libraryName: string;\n replacements?: TextstringReplacement;\n}\n\nexport const getTextstringValue = ({\n libraryName,\n textstring,\n replacements,\n}: GetTextstringValueOptions): string => {\n const textstrings =\n typeof window !== 'undefined' ? window.Textstrings?.[libraryName] : undefined;\n\n if (!textstrings) {\n return textstring.fallback;\n }\n\n const value = textstrings[textstring.name] ?? textstring.fallback;\n\n if (!replacements) {\n return value;\n }\n\n return Object.keys(replacements).reduce(\n (current, key) => current.replace(new RegExp(key, 'g'), <string>replacements[key] || ''),\n value,\n );\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,YAAY;AASnC,OAAO,MAAMC,WAAW,GAAG,MAAAC,IAAA,IAAyD;EAAA,IAAlD;IAAEC,QAAQ;IAAEC;EAAgC,CAAC,GAAAF,IAAA;EAC3E,MAAMG,QAAQ,GAAG,MAAMC,KAAK,CACxB,+DAA+DF,WAAW,aAAaD,QAAQ,EACnG,CAAC;EAED,IAAIE,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IACzB,OAAO,IAAI;EACf;EAEA,OAAQ,MAAMF,QAAQ,CAACG,IAAI,CAAC,CAAC;AACjC,CAAC;AAMD,OAAO,MAAMC,sBAAsB,GAAGC,KAAA,IAAuD;EAAA,IAAtD;IAAEC;EAA8C,CAAC,GAAAD,KAAA;EACpF;EACA;EACA;EACA,KAAKV,MAAM,CAACY,MAAM,CAAC;IACfC,GAAG,EAAE,+EAA+E;IACpFC,OAAO,EAAE,EAAE;IACX;IACA;IACAC,KAAK,EAAE;MAAEC,UAAU,EAAEL;IAAe;EACxC,CAAC,CAAC;AACN,CAAC;AAQD,OAAO,MAAMM,kBAAkB,GAAGC,KAAA,IAIO;EAAA,IAJN;IAC/Bd,WAAW;IACXY,UAAU;IACVG;EACuB,CAAC,GAAAD,KAAA;EACxB,MAAME,WAAW,GACb,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACC,WAAW,GAAGlB,WAAW,CAAC,GAAGmB,SAAS;EAEjF,IAAI,CAACH,WAAW,EAAE;IACd,OAAOJ,UAAU,CAACQ,QAAQ;EAC9B;EAEA,MAAMC,KAAK,GAAGL,WAAW,CAACJ,UAAU,CAACU,IAAI,CAAC,IAAIV,UAAU,CAACQ,QAAQ;EAEjE,IAAI,CAACL,YAAY,EAAE;IACf,OAAOM,KAAK;EAChB;EAEA,OAAOE,MAAM,CAACC,IAAI,CAACT,YAAY,CAAC,CAACU,MAAM,CACnC,CAACC,OAAO,EAAEC,GAAG,KAAKD,OAAO,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,GAAG,EAAE,GAAG,CAAC,EAAUZ,YAAY,CAACY,GAAG,CAAC,IAAI,EAAE,CAAC,EACxFN,KACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ import { CSSProperties, FC, ReactHTML, type ReactElement } from 'react';
2
+ import type { ITextstring, TextstringReplacement } from './types';
3
+ export type TextstringProps = {
4
+ /**
5
+ * The element that the text should be displayed in.
6
+ */
7
+ children?: ReactElement;
8
+ /**
9
+ * The class name of the HTML element that the text should be displayed in. Only used if `children` is not set.
10
+ */
11
+ childrenClassName?: string;
12
+ /**
13
+ * The styles of the HTML element that the text should be displayed in. Only used if `children` is not set.
14
+ */
15
+ childrenStyles?: CSSProperties;
16
+ /**
17
+ * The tag of the HTML element that the text should be displayed in. Only used if `children` is not set.
18
+ */
19
+ childrenTagName?: keyof ReactHTML;
20
+ /**
21
+ * Whether the textstring contains HTML elements and should be displayed as HTML.
22
+ */
23
+ isTextstringHTML?: boolean;
24
+ /**
25
+ * Replacement values for the textstring.
26
+ */
27
+ replacements?: TextstringReplacement;
28
+ /**
29
+ * The text that should be displayed.
30
+ */
31
+ textstring: ITextstring;
32
+ };
33
+ declare const Textstring: FC<TextstringProps>;
34
+ export default Textstring;
@@ -0,0 +1,7 @@
1
+ export interface TextstringReplacement {
2
+ [key: string]: string;
3
+ }
4
+ export interface ITextstring {
5
+ fallback: string;
6
+ name: string;
7
+ }
@@ -0,0 +1,19 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import type { TextstringValue } from '../../types/textstring';
3
+ export declare const TextstringContext: React.Context<TextstringValue>;
4
+ export type TextstringProviderProps = {
5
+ /**
6
+ * The element that should use the library.
7
+ */
8
+ children?: ReactNode;
9
+ /**
10
+ * The language that should be used.
11
+ */
12
+ language: string;
13
+ /**
14
+ * The name of the library.
15
+ */
16
+ libraryName: string;
17
+ };
18
+ declare const TextstringProvider: FC<TextstringProviderProps>;
19
+ export default TextstringProvider;
@@ -0,0 +1,6 @@
1
+ import type { ITextstring, TextstringReplacement } from '../components/textstring/types';
2
+ export interface UseTextstringValue {
3
+ textstring: ITextstring;
4
+ replacements?: TextstringReplacement;
5
+ }
6
+ export declare const useTextstringValue: ({ replacements, textstring }: UseTextstringValue) => string;
@@ -0,0 +1,5 @@
1
+ export { default as TextstringProvider } from './components/textstring-provider/TextstringProvider';
2
+ export { default as Textstring } from './components/textstring/Textstring';
3
+ export type { ITextstring, TextstringReplacement } from './components/textstring/types';
4
+ export { useTextstringValue } from './hooks/useTextstringValue';
5
+ export { getTextstringValue } from './utils/textstring';
@@ -0,0 +1,12 @@
1
+ declare global {
2
+ interface Window {
3
+ Textstrings: TextstringValues;
4
+ }
5
+ }
6
+ type TextstringValues = {
7
+ [key: string]: TextstringValue;
8
+ };
9
+ export type TextstringValue = {
10
+ [key: string]: string;
11
+ };
12
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { ITextstring, TextstringReplacement } from '../components/textstring/types';
2
+ import type { TextstringValue } from '../types/textstring';
3
+ interface LoadLibraryOptions {
4
+ libraryName: string;
5
+ language: string;
6
+ }
7
+ export declare const loadLibrary: ({ language, libraryName }: LoadLibraryOptions) => Promise<TextstringValue | null>;
8
+ interface SelectLanguageToChangeOptions {
9
+ textstringName: string;
10
+ }
11
+ export declare const selectLanguageToChange: ({ textstringName }: SelectLanguageToChangeOptions) => void;
12
+ interface GetTextstringValueOptions {
13
+ textstring: ITextstring;
14
+ libraryName: string;
15
+ replacements?: TextstringReplacement;
16
+ }
17
+ export declare const getTextstringValue: ({ libraryName, textstring, replacements, }: GetTextstringValueOptions) => string;
18
+ export {};
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@chayns-components/textstring",
3
+ "version": "5.0.0-beta.1000",
4
+ "description": "A set of beautiful React components for developing your own applications with chayns.",
5
+ "sideEffects": false,
6
+ "browserslist": [
7
+ ">0.5%",
8
+ "not dead",
9
+ "not op_mini all",
10
+ "not IE 11"
11
+ ],
12
+ "keywords": [
13
+ "chayns",
14
+ "react",
15
+ "components"
16
+ ],
17
+ "author": "Tobit.Software",
18
+ "homepage": "https://github.com/TobitSoftware/chayns-components/tree/main/packages/textstring#readme",
19
+ "license": "MIT",
20
+ "types": "lib/types/index.d.ts",
21
+ "main": "lib/cjs/index.js",
22
+ "module": "lib/esm/index.js",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./lib/types/index.d.ts",
26
+ "require": "./lib/cjs/index.js",
27
+ "import": "./lib/esm/index.js"
28
+ }
29
+ },
30
+ "directories": {
31
+ "lib": "lib",
32
+ "test": "__tests__"
33
+ },
34
+ "files": [
35
+ "lib"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/TobitSoftware/chayns-components.git"
40
+ },
41
+ "scripts": {
42
+ "build": "npm run build:cjs && npm run build:esm && npm run build:types",
43
+ "build:types": "tsc",
44
+ "build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir lib/cjs --extensions=.ts,.tsx --source-maps --ignore=src/stories",
45
+ "build:esm": "cross-env NODE_ENV=esm babel src --out-dir lib/esm --extensions=.ts,.tsx --source-maps --ignore=src/stories",
46
+ "prepublishOnly": "npm run build",
47
+ "watch:js": "npm run build:esm -- --watch",
48
+ "link": "npm link && npm run watch:js"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/TobitSoftware/chayns-components/issues"
52
+ },
53
+ "devDependencies": {
54
+ "@babel/cli": "^7.26.4",
55
+ "@babel/core": "^7.26.0",
56
+ "@babel/preset-env": "^7.26.0",
57
+ "@babel/preset-react": "^7.26.3",
58
+ "@babel/preset-typescript": "^7.26.0",
59
+ "@types/react": "^18.3.18",
60
+ "@types/react-dom": "^18.3.5",
61
+ "@types/styled-components": "^5.1.34",
62
+ "@types/uuid": "^10.0.0",
63
+ "babel-loader": "^9.2.1",
64
+ "cross-env": "^7.0.3",
65
+ "lerna": "^8.1.9",
66
+ "react": "^18.3.1",
67
+ "react-dom": "^18.3.1",
68
+ "styled-components": "^6.1.14",
69
+ "typescript": "^5.7.3"
70
+ },
71
+ "dependencies": {
72
+ "@chayns-components/core": "^5.0.0-beta.1000"
73
+ },
74
+ "peerDependencies": {
75
+ "chayns-api": ">=2.0.0",
76
+ "framer-motion": ">=10.18.0",
77
+ "react": ">=18.0.0",
78
+ "react-dom": ">=18.0.0",
79
+ "styled-components": ">=5.3.11"
80
+ },
81
+ "publishConfig": {
82
+ "access": "public"
83
+ },
84
+ "gitHead": "d456c0b87862a3be7d764ba0f16e0b96b22ac2a8"
85
+ }