@veltdev/react
Advanced tools
+22
-2
@@ -92,6 +92,6 @@ 'use strict'; | ||
| var VELT_SDK_VERSION = '1.0.15'; | ||
| var VELT_SDK_VERSION = '1.0.16'; | ||
| var SnippylyProvider = function (props) { | ||
| var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, onClientLoad = props.onClientLoad, children = props.children; | ||
| var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, language = props.language, translations = props.translations, autoTranslation = props.autoTranslation, onClientLoad = props.onClientLoad, children = props.children; | ||
| var _a = React.useState(null), client = _a[0], setClient = _a[1]; | ||
@@ -127,2 +127,22 @@ React.useEffect(function () { | ||
| case 4: | ||
| // Set language | ||
| if (language && (velt === null || velt === void 0 ? void 0 : velt.setLanguage)) { | ||
| velt === null || velt === void 0 ? void 0 : velt.setLanguage(language); | ||
| } | ||
| // Set translations | ||
| if (translations && (velt === null || velt === void 0 ? void 0 : velt.setTranslations)) { | ||
| if (typeof translations === 'object') { | ||
| Object.keys(translations).forEach(function (languageCode) { | ||
| velt === null || velt === void 0 ? void 0 : velt.setTranslations(languageCode, translations[languageCode] || {}); | ||
| }); | ||
| } | ||
| } | ||
| if ([true, false].includes(autoTranslation)) { | ||
| if (autoTranslation && (velt === null || velt === void 0 ? void 0 : velt.enableAutoTranslation)) { | ||
| velt === null || velt === void 0 ? void 0 : velt.enableAutoTranslation(); | ||
| } | ||
| else if (!autoTranslation && (velt === null || velt === void 0 ? void 0 : velt.disableAutoTranslation)) { | ||
| velt === null || velt === void 0 ? void 0 : velt.disableAutoTranslation(); | ||
| } | ||
| } | ||
| if (velt === null || velt === void 0 ? void 0 : velt.st) { | ||
@@ -129,0 +149,0 @@ velt === null || velt === void 0 ? void 0 : velt.st('react'); |
@@ -8,2 +8,9 @@ import React from 'react'; | ||
| documentId?: string; | ||
| language?: string; | ||
| translations?: { | ||
| [languageCode: string]: { | ||
| [input: string]: string; | ||
| }; | ||
| }; | ||
| autoTranslation?: boolean; | ||
| onClientLoad?: (veltClient?: Velt) => any; | ||
@@ -10,0 +17,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| export declare const VELT_SDK_VERSION = "1.0.15"; | ||
| export declare const VELT_SDK_VERSION = "1.0.16"; |
+22
-2
@@ -84,6 +84,6 @@ import React, { createContext, useContext, useState, useEffect, useRef } from 'react'; | ||
| var VELT_SDK_VERSION = '1.0.15'; | ||
| var VELT_SDK_VERSION = '1.0.16'; | ||
| var SnippylyProvider = function (props) { | ||
| var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, onClientLoad = props.onClientLoad, children = props.children; | ||
| var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, language = props.language, translations = props.translations, autoTranslation = props.autoTranslation, onClientLoad = props.onClientLoad, children = props.children; | ||
| var _a = useState(null), client = _a[0], setClient = _a[1]; | ||
@@ -119,2 +119,22 @@ useEffect(function () { | ||
| case 4: | ||
| // Set language | ||
| if (language && (velt === null || velt === void 0 ? void 0 : velt.setLanguage)) { | ||
| velt === null || velt === void 0 ? void 0 : velt.setLanguage(language); | ||
| } | ||
| // Set translations | ||
| if (translations && (velt === null || velt === void 0 ? void 0 : velt.setTranslations)) { | ||
| if (typeof translations === 'object') { | ||
| Object.keys(translations).forEach(function (languageCode) { | ||
| velt === null || velt === void 0 ? void 0 : velt.setTranslations(languageCode, translations[languageCode] || {}); | ||
| }); | ||
| } | ||
| } | ||
| if ([true, false].includes(autoTranslation)) { | ||
| if (autoTranslation && (velt === null || velt === void 0 ? void 0 : velt.enableAutoTranslation)) { | ||
| velt === null || velt === void 0 ? void 0 : velt.enableAutoTranslation(); | ||
| } | ||
| else if (!autoTranslation && (velt === null || velt === void 0 ? void 0 : velt.disableAutoTranslation)) { | ||
| velt === null || velt === void 0 ? void 0 : velt.disableAutoTranslation(); | ||
| } | ||
| } | ||
| if (velt === null || velt === void 0 ? void 0 : velt.st) { | ||
@@ -121,0 +141,0 @@ velt === null || velt === void 0 ? void 0 : velt.st('react'); |
@@ -8,2 +8,9 @@ import React from 'react'; | ||
| documentId?: string; | ||
| language?: string; | ||
| translations?: { | ||
| [languageCode: string]: { | ||
| [input: string]: string; | ||
| }; | ||
| }; | ||
| autoTranslation?: boolean; | ||
| onClientLoad?: (veltClient?: Velt) => any; | ||
@@ -10,0 +17,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| export declare const VELT_SDK_VERSION = "1.0.15"; | ||
| export declare const VELT_SDK_VERSION = "1.0.16"; |
+7
-0
@@ -10,2 +10,9 @@ /// <reference types="react" /> | ||
| documentId?: string; | ||
| language?: string; | ||
| translations?: { | ||
| [languageCode: string]: { | ||
| [input: string]: string; | ||
| }; | ||
| }; | ||
| autoTranslation?: boolean; | ||
| onClientLoad?: (veltClient?: Velt) => any; | ||
@@ -12,0 +19,0 @@ } |
+1
-1
| { | ||
| "name": "@veltdev/react", | ||
| "version": "1.0.12", | ||
| "version": "1.0.13", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
219953
4.31%1822
3.46%