txlemetry-react-native 4.55.1 → 5.0.0
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.
- package/LICENSE +353 -353
- package/dist/TxlemetryContext.d.ts +5 -0
- package/dist/TxlemetryContext.js +1 -0
- package/dist/TxlemetryErrorBoundary.d.ts +27 -0
- package/dist/TxlemetryErrorBoundary.js +1 -0
- package/dist/{PostHogMaskView.d.ts → TxlemetryMaskView.d.ts} +39 -39
- package/dist/TxlemetryMaskView.js +1 -0
- package/dist/TxlemetryProvider.d.ts +100 -0
- package/dist/TxlemetryProvider.js +1 -0
- package/dist/autocapture.d.ts +4 -4
- package/dist/autocapture.js +1 -1
- package/dist/error-tracking/index.d.ts +98 -98
- package/dist/error-tracking/index.js +1 -1
- package/dist/error-tracking/utils.d.ts +5 -5
- package/dist/frameworks/wix-navigation.d.ts +3 -3
- package/dist/frameworks/wix-navigation.js +1 -1
- package/dist/hooks/useFeatureFlag.d.ts +5 -5
- package/dist/hooks/useFeatureFlag.js +1 -1
- package/dist/hooks/useFeatureFlagResult.d.ts +3 -3
- package/dist/hooks/useFeatureFlagResult.js +1 -1
- package/dist/hooks/useFeatureFlags.d.ts +3 -3
- package/dist/hooks/useFeatureFlags.js +1 -1
- package/dist/hooks/useNavigationTracker.d.ts +6 -6
- package/dist/hooks/useNavigationTracker.js +1 -1
- package/dist/hooks/useTxlemetry.d.ts +2 -0
- package/dist/hooks/useTxlemetry.js +1 -0
- package/dist/hooks/utils.d.ts +14 -14
- package/dist/hooks/utils.js +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.js +1 -1
- package/dist/index.txlemetry.d.ts +36 -36
- package/dist/index.txlemetry.js +21 -21
- package/dist/logs-defaults.d.ts +9 -9
- package/dist/native-deps.d.ts +4 -4
- package/dist/native-deps.js +1 -1
- package/dist/optional/OptionalAsyncStorage.d.ts +2 -2
- package/dist/optional/OptionalExpoApplication.d.ts +2 -2
- package/dist/optional/OptionalExpoDevice.d.ts +2 -2
- package/dist/optional/OptionalExpoFileSystem.d.ts +2 -2
- package/dist/optional/OptionalExpoFileSystemLegacy.d.ts +2 -2
- package/dist/optional/OptionalExpoLocalization.d.ts +2 -2
- package/dist/optional/OptionalPlugin.d.ts +20 -20
- package/dist/optional/OptionalReactNativeDeviceInfo.d.ts +2 -2
- package/dist/optional/OptionalReactNativeLocalize.d.ts +13 -13
- package/dist/optional/OptionalReactNativeNavigation.d.ts +2 -2
- package/dist/optional/OptionalReactNativeNavigationWix.d.ts +2 -2
- package/dist/optional/OptionalReactNativeSafeArea.d.ts +2 -2
- package/dist/optional/OptionalReactNativeSvg.d.ts +2 -2
- package/dist/storage.d.ts +41 -41
- package/dist/storage.js +1 -1
- package/dist/surveys/{PostHogSurveyProvider.d.ts → TxlemetrySurveyProvider.d.ts} +23 -23
- package/dist/surveys/TxlemetrySurveyProvider.js +1 -0
- package/dist/surveys/components/BottomSection.d.ts +9 -9
- package/dist/surveys/components/BottomSection.js +1 -1
- package/dist/surveys/components/Cancel.d.ts +5 -5
- package/dist/surveys/components/Cancel.js +1 -1
- package/dist/surveys/components/ConfirmationMessage.d.ts +12 -12
- package/dist/surveys/components/ConfirmationMessage.js +1 -1
- package/dist/surveys/components/QuestionHeader.d.ts +8 -8
- package/dist/surveys/components/QuestionHeader.js +1 -1
- package/dist/surveys/components/QuestionTypes.d.ts +26 -26
- package/dist/surveys/components/QuestionTypes.js +1 -1
- package/dist/surveys/components/SurveyModal.d.ts +11 -11
- package/dist/surveys/components/SurveyModal.js +1 -1
- package/dist/surveys/components/Surveys.d.ts +16 -16
- package/dist/surveys/components/Surveys.js +1 -1
- package/dist/surveys/getActiveMatchingSurveys.d.ts +2 -2
- package/dist/surveys/icons.d.ts +11 -11
- package/dist/surveys/icons.js +1 -1
- package/dist/surveys/index.d.ts +6 -6
- package/dist/surveys/index.js +1 -1
- package/dist/surveys/safeStyleSheet.d.ts +8 -8
- package/dist/surveys/survey-translations.d.ts +7 -7
- package/dist/surveys/survey-translations.js +1 -1
- package/dist/surveys/surveys-utils.d.ts +54 -54
- package/dist/surveys/surveys-utils.js +1 -1
- package/dist/surveys/useActivatedSurveys.d.ts +3 -3
- package/dist/surveys/useActivatedSurveys.js +1 -1
- package/dist/surveys/useSurveyStorage.d.ts +8 -8
- package/dist/surveys/useSurveyStorage.js +1 -1
- package/dist/tooling/expoconfig.d.ts +64 -64
- package/dist/tooling/expoconfig.js +1 -1
- package/dist/tooling/metroconfig.d.ts +21 -21
- package/dist/tooling/metroconfig.js +1 -1
- package/dist/tooling/{posthogMetroSerializer.d.ts → txlemetryMetroSerializer.d.ts} +17 -17
- package/dist/tooling/txlemetryMetroSerializer.js +1 -0
- package/dist/tooling/utils.d.ts +58 -58
- package/dist/tooling/vendor/expo/expoconfig.d.ts +23 -23
- package/dist/tooling/vendor/metro/countLines.d.ts +2 -2
- package/dist/tooling/vendor/metro/utils.d.ts +22 -22
- package/dist/{posthog-rn.d.ts → txlemetry-rn.d.ts} +1096 -1096
- package/dist/txlemetry-rn.js +1 -0
- package/dist/types.d.ts +205 -205
- package/dist/utils.d.ts +25 -25
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +149 -149
- package/tooling/txlemetry-xcode.sh +2 -2
- package/dist/PostHogContext.d.ts +0 -5
- package/dist/PostHogContext.js +0 -1
- package/dist/PostHogErrorBoundary.d.ts +0 -27
- package/dist/PostHogErrorBoundary.js +0 -1
- package/dist/PostHogMaskView.js +0 -1
- package/dist/PostHogProvider.d.ts +0 -100
- package/dist/PostHogProvider.js +0 -1
- package/dist/hooks/usePostHog.d.ts +0 -2
- package/dist/hooks/usePostHog.js +0 -1
- package/dist/posthog-rn.js +0 -1
- package/dist/surveys/PostHogSurveyProvider.js +0 -1
- package/dist/tooling/posthogMetroSerializer.js +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SurveyAppearance } from '@txlemetry/core';
|
|
3
|
-
import {
|
|
4
|
-
export type
|
|
5
|
-
/**
|
|
6
|
-
* The default appearance for surveys when not specified in
|
|
7
|
-
*/
|
|
8
|
-
defaultSurveyAppearance?: SurveyAppearance;
|
|
9
|
-
/**
|
|
10
|
-
* If true, PosHog appearance will be ignored and defaultSurveyAppearance is always used.
|
|
11
|
-
*/
|
|
12
|
-
overrideAppearanceWithDefault?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* The keyboard avoiding behavior for the survey modal (KeyboardAvoidingView), applied only to Android devices.
|
|
15
|
-
* - 'padding': Adds padding to avoid keyboard (recommended)
|
|
16
|
-
* - 'height': Resizes the view height (default, for legacy - may cause flickering on some Android devices)
|
|
17
|
-
* @default 'height'
|
|
18
|
-
*/
|
|
19
|
-
androidKeyboardBehavior?: 'padding' | 'height';
|
|
20
|
-
client?:
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
};
|
|
23
|
-
export declare function
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SurveyAppearance } from '@txlemetry/core';
|
|
3
|
+
import { Txlemetry } from '../txlemetry-rn';
|
|
4
|
+
export type TxlemetrySurveyProviderProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The default appearance for surveys when not specified in Txlemetry.
|
|
7
|
+
*/
|
|
8
|
+
defaultSurveyAppearance?: SurveyAppearance;
|
|
9
|
+
/**
|
|
10
|
+
* If true, PosHog appearance will be ignored and defaultSurveyAppearance is always used.
|
|
11
|
+
*/
|
|
12
|
+
overrideAppearanceWithDefault?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The keyboard avoiding behavior for the survey modal (KeyboardAvoidingView), applied only to Android devices.
|
|
15
|
+
* - 'padding': Adds padding to avoid keyboard (recommended)
|
|
16
|
+
* - 'height': Resizes the view height (default, for legacy - may cause flickering on some Android devices)
|
|
17
|
+
* @default 'height'
|
|
18
|
+
*/
|
|
19
|
+
androidKeyboardBehavior?: 'padding' | 'height';
|
|
20
|
+
client?: Txlemetry;
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
};
|
|
23
|
+
export declare function TxlemetrySurveyProvider(props: TxlemetrySurveyProviderProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.TxlemetrySurveyProvider=TxlemetrySurveyProvider;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _Surveys=require("./components/Surveys");var _getActiveMatchingSurveys=require("./getActiveMatchingSurveys");var _useSurveyStorage2=require("./useSurveyStorage");var _useActivatedSurveys=require("./useActivatedSurveys");var _SurveyModal=require("./components/SurveyModal");var _surveysUtils=require("./surveys-utils");var _core=require("@txlemetry/core");var _useTxlemetry=require("../hooks/useTxlemetry");var _useFeatureFlags=require("../hooks/useFeatureFlags");var _surveyTranslations=require("./survey-translations");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/TxlemetrySurveyProvider.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var ActiveSurveyContext=_react["default"].createContext(undefined);var FeedbackSurveyContext=_react["default"].createContext(undefined);function TxlemetrySurveyProvider(props){var _a;var txlemetryFromHook=(0,_useTxlemetry.useTxlemetry)();var txlemetry=(_a=props.client)!==null&&_a!==void 0?_a:txlemetryFromHook;var _useSurveyStorage=(0,_useSurveyStorage2.useSurveyStorage)(),seenSurveys=_useSurveyStorage.seenSurveys,setSeenSurvey=_useSurveyStorage.setSeenSurvey,setLastSeenSurveyDate=_useSurveyStorage.setLastSeenSurveyDate;var _useState=(0,_react.useState)([]),_useState2=(0,_slicedToArray2["default"])(_useState,2),surveys=_useState2[0],setSurveys=_useState2[1];var _useState3=(0,_react.useState)(undefined),_useState4=(0,_slicedToArray2["default"])(_useState3,2),activeSurvey=_useState4[0],setActiveSurvey=_useState4[1];var activatedSurveys=(0,_useActivatedSurveys.useActivatedSurveys)(txlemetry,surveys);var flags=(0,_useFeatureFlags.useFeatureFlags)(txlemetry);(0,_react.useEffect)(function(){txlemetry.ready().then(function(){return txlemetry._onSurveysReady();}).then(function(){return txlemetry.getSurveys();}).then(setSurveys)["catch"](function(){});},[txlemetry]);(0,_react.useEffect)(function(){if(activeSurvey){return;}var activeSurveys=(0,_getActiveMatchingSurveys.getActiveMatchingSurveys)(surveys,flags!==null&&flags!==void 0?flags:{},seenSurveys,activatedSurveys);var popoverSurveys=activeSurveys.filter(function(survey){return survey.type===_core.SurveyType.Popover;});if(popoverSurveys.length>0){setActiveSurvey(popoverSurveys[0]);}},[activeSurvey,flags,surveys,seenSurveys,activatedSurveys]);var translatedActiveSurvey=(0,_react.useMemo)(function(){return activeSurvey?(0,_surveyTranslations.applySurveyTranslationForUser)(activeSurvey,txlemetry):undefined;},[activeSurvey,txlemetry]);var surveyAppearance=(0,_react.useMemo)(function(){var _a,_b,_c,_d,_e;if(props.overrideAppearanceWithDefault||!translatedActiveSurvey){return _objectSpread(_objectSpread({},_surveysUtils.defaultSurveyAppearance),(_a=props.defaultSurveyAppearance)!==null&&_a!==void 0?_a:{});}return _objectSpread(_objectSpread(_objectSpread(_objectSpread({},_surveysUtils.defaultSurveyAppearance),(_b=props.defaultSurveyAppearance)!==null&&_b!==void 0?_b:{}),(_c=translatedActiveSurvey.survey.appearance)!==null&&_c!==void 0?_c:{}),((_d=translatedActiveSurvey.survey.appearance)===null||_d===void 0?void 0:_d.submitButtonColor)?{submitButtonTextColor:(_e=translatedActiveSurvey.survey.appearance.submitButtonTextColor)!==null&&_e!==void 0?_e:(0,_surveysUtils.getContrastingTextColor)(translatedActiveSurvey.survey.appearance.submitButtonColor)}:{});},[translatedActiveSurvey,props.defaultSurveyAppearance,props.overrideAppearanceWithDefault]);var activeContext=(0,_react.useMemo)(function(){if(!activeSurvey||!translatedActiveSurvey){return undefined;}return{survey:translatedActiveSurvey.survey,surveyLanguage:translatedActiveSurvey.language,onShow:function onShow(){(0,_Surveys.sendSurveyShownEvent)(translatedActiveSurvey.survey,txlemetry,translatedActiveSurvey.language);setLastSeenSurveyDate(new Date());},onClose:function onClose(submitted,responses){setSeenSurvey(activeSurvey.id);setActiveSurvey(undefined);if(!submitted){(0,_Surveys.dismissedSurveyEvent)(translatedActiveSurvey.survey,responses,txlemetry,translatedActiveSurvey.language);}}};},[activeSurvey,txlemetry,setLastSeenSurveyDate,setSeenSurvey,translatedActiveSurvey]);var shouldShowModal=activeContext&&activeContext.survey.type===_core.SurveyType.Popover;return(0,_jsxRuntime.jsx)(ActiveSurveyContext.Provider,{value:activeContext,children:(0,_jsxRuntime.jsxs)(FeedbackSurveyContext.Provider,{value:{surveys:surveys,activeSurvey:activeSurvey,setActiveSurvey:setActiveSurvey},children:[props.children,shouldShowModal&&(0,_jsxRuntime.jsx)(_SurveyModal.SurveyModal,_objectSpread({appearance:surveyAppearance,androidKeyboardBehavior:props.androidKeyboardBehavior},activeContext))]})});}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
-
export declare function BottomSection({ text, submitDisabled, appearance, onSubmit, link, skipSubmitButton, }: {
|
|
3
|
-
text: string;
|
|
4
|
-
submitDisabled: boolean;
|
|
5
|
-
appearance: SurveyAppearanceTheme;
|
|
6
|
-
onSubmit: () => void;
|
|
7
|
-
link?: string | null;
|
|
8
|
-
skipSubmitButton?: boolean;
|
|
9
|
-
}): JSX.Element;
|
|
1
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
+
export declare function BottomSection({ text, submitDisabled, appearance, onSubmit, link, skipSubmitButton, }: {
|
|
3
|
+
text: string;
|
|
4
|
+
submitDisabled: boolean;
|
|
5
|
+
appearance: SurveyAppearanceTheme;
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
link?: string | null;
|
|
8
|
+
skipSubmitButton?: boolean;
|
|
9
|
+
}): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BottomSection=BottomSection;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BottomSection=BottomSection;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/components/BottomSection.js";function BottomSection(_ref){var text=_ref.text,submitDisabled=_ref.submitDisabled,appearance=_ref.appearance,onSubmit=_ref.onSubmit,link=_ref.link,skipSubmitButton=_ref.skipSubmitButton;if(skipSubmitButton){return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{});}return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.bottomSection,children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.button,{backgroundColor:appearance.submitButtonColor},submitDisabled&&styles.buttonDisabled],disabled:submitDisabled,onPress:function onPress(){onSubmit();if(link){_reactNative.Linking.canOpenURL(link).then(function(supported){if(supported){_reactNative.Linking.openURL(link);}});}},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.buttonText,{color:appearance.submitButtonTextColor}],children:text})})});}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({bottomSection:{padding:10},button:{padding:10,borderRadius:5,alignItems:'center'},buttonText:{fontSize:16},buttonDisabled:{opacity:0.5}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
-
export declare function Cancel({ onPress, appearance, }: {
|
|
3
|
-
onPress: () => void;
|
|
4
|
-
appearance: SurveyAppearanceTheme;
|
|
5
|
-
}): JSX.Element;
|
|
1
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
+
export declare function Cancel({ onPress, appearance, }: {
|
|
3
|
+
onPress: () => void;
|
|
4
|
+
appearance: SurveyAppearanceTheme;
|
|
5
|
+
}): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.Cancel=Cancel;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _icons=require("../icons");var _safeStyleSheet=require("../safeStyleSheet");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.Cancel=Cancel;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _icons=require("../icons");var _safeStyleSheet=require("../safeStyleSheet");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/components/Cancel.js";function Cancel(_ref){var onPress=_ref.onPress,appearance=_ref.appearance;return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.cancelBtnWrapper,{borderColor:appearance.borderColor}],onPress:onPress,children:(0,_jsxRuntime.jsx)(_icons.CancelSVG,{})});}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({cancelBtnWrapper:{width:40,height:40,borderRadius:20,borderWidth:1,justifyContent:'center',alignItems:'center',backgroundColor:'white'}});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ViewStyle } from 'react-native';
|
|
2
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
-
import { SurveyQuestionDescriptionContentType } from '@txlemetry/core';
|
|
4
|
-
export declare function ConfirmationMessage({ appearance, header, description, contentType, onClose, styleOverrides, isModal, }: {
|
|
5
|
-
appearance: SurveyAppearanceTheme;
|
|
6
|
-
header: string;
|
|
7
|
-
description: string;
|
|
8
|
-
contentType?: SurveyQuestionDescriptionContentType;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
styleOverrides?: ViewStyle;
|
|
11
|
-
isModal: boolean;
|
|
12
|
-
}): JSX.Element;
|
|
1
|
+
import { ViewStyle } from 'react-native';
|
|
2
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
+
import { SurveyQuestionDescriptionContentType } from '@txlemetry/core';
|
|
4
|
+
export declare function ConfirmationMessage({ appearance, header, description, contentType, onClose, styleOverrides, isModal, }: {
|
|
5
|
+
appearance: SurveyAppearanceTheme;
|
|
6
|
+
header: string;
|
|
7
|
+
description: string;
|
|
8
|
+
contentType?: SurveyQuestionDescriptionContentType;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
styleOverrides?: ViewStyle;
|
|
11
|
+
isModal: boolean;
|
|
12
|
+
}): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ConfirmationMessage=ConfirmationMessage;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _surveysUtils=require("../surveys-utils");var _BottomSection=require("./BottomSection");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ConfirmationMessage=ConfirmationMessage;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _surveysUtils=require("../surveys-utils");var _BottomSection=require("./BottomSection");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/components/ConfirmationMessage.js";function ConfirmationMessage(_ref){var appearance=_ref.appearance,header=_ref.header,description=_ref.description,contentType=_ref.contentType,onClose=_ref.onClose,styleOverrides=_ref.styleOverrides,isModal=_ref.isModal;var textColor=(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styleOverrides,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.thankYouMessageContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.thankYouMessageHeader,{color:textColor}],children:header}),(0,_surveysUtils.shouldRenderDescription)(description,contentType)&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:textColor,opacity:_surveysUtils.defaultDescriptionOpacity},children:description})]}),isModal&&(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:appearance.thankYouMessageCloseButtonText,submitDisabled:false,appearance:appearance,onSubmit:onClose})]});}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({thankYouMessageContainer:{padding:10},thankYouMessageHeader:{fontSize:18,fontWeight:'bold'}});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SurveyQuestionDescriptionContentType } from '@txlemetry/core';
|
|
2
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
-
export declare function QuestionHeader({ question, description, descriptionContentType, appearance, }: {
|
|
4
|
-
question: string;
|
|
5
|
-
description?: string | null;
|
|
6
|
-
descriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
7
|
-
appearance: SurveyAppearanceTheme;
|
|
8
|
-
}): JSX.Element;
|
|
1
|
+
import { SurveyQuestionDescriptionContentType } from '@txlemetry/core';
|
|
2
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
+
export declare function QuestionHeader({ question, description, descriptionContentType, appearance, }: {
|
|
4
|
+
question: string;
|
|
5
|
+
description?: string | null;
|
|
6
|
+
descriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
7
|
+
appearance: SurveyAppearanceTheme;
|
|
8
|
+
}): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.QuestionHeader=QuestionHeader;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _surveysUtils=require("../surveys-utils");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.QuestionHeader=QuestionHeader;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _surveysUtils=require("../surveys-utils");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/components/QuestionHeader.js";function QuestionHeader(_ref){var question=_ref.question,description=_ref.description,descriptionContentType=_ref.descriptionContentType,appearance=_ref.appearance;var _a;var textColor=(_a=appearance.textColor)!==null&&_a!==void 0?_a:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.question,{color:textColor}],children:question}),(0,_surveysUtils.shouldRenderDescription)(description,descriptionContentType)&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.description,{color:textColor,opacity:_surveysUtils.defaultDescriptionOpacity}],children:description})]});}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({container:{padding:10},question:{fontSize:18,fontWeight:'bold'},description:{fontSize:14,marginTop:5}});
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
-
import { SurveyQuestion } from '@txlemetry/core';
|
|
3
|
-
interface QuestionCommonProps {
|
|
4
|
-
question: SurveyQuestion;
|
|
5
|
-
appearance: SurveyAppearanceTheme;
|
|
6
|
-
}
|
|
7
|
-
export declare function OpenTextQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
8
|
-
onSubmit: (text: string) => void;
|
|
9
|
-
}): JSX.Element;
|
|
10
|
-
export declare function LinkQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
11
|
-
onSubmit: (clicked: string) => void;
|
|
12
|
-
}): JSX.Element;
|
|
13
|
-
export declare function RatingQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
14
|
-
onSubmit: (rating: number | null) => void;
|
|
15
|
-
}): JSX.Element;
|
|
16
|
-
export declare function RatingButton({ index, num, active, appearance, setActiveNumber, }: {
|
|
17
|
-
index: number;
|
|
18
|
-
num: number;
|
|
19
|
-
active: boolean;
|
|
20
|
-
appearance: SurveyAppearanceTheme;
|
|
21
|
-
setActiveNumber: (num: number) => void;
|
|
22
|
-
}): JSX.Element;
|
|
23
|
-
export declare function MultipleChoiceQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
24
|
-
onSubmit: (choices: string | string[] | null) => void;
|
|
25
|
-
}): JSX.Element;
|
|
26
|
-
export {};
|
|
1
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
+
import { SurveyQuestion } from '@txlemetry/core';
|
|
3
|
+
interface QuestionCommonProps {
|
|
4
|
+
question: SurveyQuestion;
|
|
5
|
+
appearance: SurveyAppearanceTheme;
|
|
6
|
+
}
|
|
7
|
+
export declare function OpenTextQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
8
|
+
onSubmit: (text: string) => void;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
export declare function LinkQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
11
|
+
onSubmit: (clicked: string) => void;
|
|
12
|
+
}): JSX.Element;
|
|
13
|
+
export declare function RatingQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
14
|
+
onSubmit: (rating: number | null) => void;
|
|
15
|
+
}): JSX.Element;
|
|
16
|
+
export declare function RatingButton({ index, num, active, appearance, setActiveNumber, }: {
|
|
17
|
+
index: number;
|
|
18
|
+
num: number;
|
|
19
|
+
active: boolean;
|
|
20
|
+
appearance: SurveyAppearanceTheme;
|
|
21
|
+
setActiveNumber: (num: number) => void;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
export declare function MultipleChoiceQuestion({ question, appearance, onSubmit, }: QuestionCommonProps & {
|
|
24
|
+
onSubmit: (choices: string | string[] | null) => void;
|
|
25
|
+
}): JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.LinkQuestion=LinkQuestion;exports.MultipleChoiceQuestion=MultipleChoiceQuestion;exports.OpenTextQuestion=OpenTextQuestion;exports.RatingButton=RatingButton;exports.RatingQuestion=RatingQuestion;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _icons=require("../icons");var _surveysUtils=require("../surveys-utils");var _core=require("@txlemetry/core");var _surveys=require("@txlemetry/core/surveys");var _BottomSection=require("./BottomSection");var _QuestionHeader=require("./QuestionHeader");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/surveys/components/QuestionTypes.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function QuestionLayout(_ref){var children=_ref.children,footer=_ref.footer;var _useState=(0,_react.useState)(0),_useState2=(0,_slicedToArray2["default"])(_useState,2),viewportHeight=_useState2[0],setViewportHeight=_useState2[1];var _useState3=(0,_react.useState)(0),_useState4=(0,_slicedToArray2["default"])(_useState3,2),contentHeight=_useState4[0],setContentHeight=_useState4[1];var isOverflowing=contentHeight>viewportHeight+1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:questionLayoutStyles.container,children:[(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:questionLayoutStyles.scroll,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,scrollEnabled:isOverflowing,bounces:isOverflowing,onLayout:function onLayout(e){return setViewportHeight(e.nativeEvent.layout.height);},onContentSizeChange:function onContentSizeChange(_width,height){return setContentHeight(height);},children:children}),footer]});}var questionLayoutStyles=(0,_safeStyleSheet.createSafeStyleSheet)({container:{flexShrink:1},scroll:{flexShrink:1}});function OpenTextQuestion(_ref2){var question=_ref2.question,appearance=_ref2.appearance,onSubmit=_ref2.onSubmit;var _a,_b,_c,_d;var _useState5=(0,_react.useState)(''),_useState6=(0,_slicedToArray2["default"])(_useState5,2),text=_useState6[0],setText=_useState6[1];var validationError=(0,_react.useMemo)(function(){return(0,_surveys.getValidationError)(text,question.validation,question.optional);},[text,question.validation,question.optional]);var minLength=(0,_surveys.getLengthFromRules)(question.validation,_core.SurveyValidationType.MinLength);var maxLength=(0,_surveys.getLengthFromRules)(question.validation,_core.SurveyValidationType.MaxLength);var requirementsHint=(0,_react.useMemo)(function(){return(0,_surveys.getRequirementsHint)(minLength,maxLength);},[minLength,maxLength]);var handleSubmit=function handleSubmit(){if(validationError){return;}onSubmit(text.trim());};return(0,_jsxRuntime.jsxs)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText,submitDisabled:!!validationError,appearance:appearance,onSubmit:handleSubmit}),children:[(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.textInputContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:[styles.textInput,{backgroundColor:appearance.inputBackground,color:(_b=appearance.inputTextColor)!==null&&_b!==void 0?_b:(0,_surveysUtils.getContrastingTextColor)(appearance.inputBackground),borderColor:appearance.borderColor}],multiline:true,numberOfLines:4,placeholder:appearance.placeholder,placeholderTextColor:(0,_surveysUtils.getContrastingTextColor)((_c=appearance.inputTextColor)!==null&&_c!==void 0?_c:(0,_surveysUtils.getContrastingTextColor)(appearance.inputBackground))==='white'?'rgba(0, 0, 0, 0.5)':'rgba(255, 255, 255, 0.5)',onChangeText:setText,value:text}),requirementsHint&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.validationHint,{color:(_d=appearance.textColor)!==null&&_d!==void 0?_d:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor)}],children:requirementsHint})]})]});}function LinkQuestion(_ref3){var question=_ref3.question,appearance=_ref3.appearance,_onSubmit=_ref3.onSubmit;var _a,_b;question=question;return(0,_jsxRuntime.jsx)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_b=(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText)!==null&&_b!==void 0?_b:'Submit',submitDisabled:false,link:question.link,appearance:appearance,onSubmit:function onSubmit(){return _onSubmit('link clicked');}}),children:(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance})});}function RatingQuestion(_ref4){var _this=this;var question=_ref4.question,appearance=_ref4.appearance,_onSubmit2=_ref4.onSubmit;var _a,_b,_c,_d;var _useState7=(0,_react.useState)(null),_useState8=(0,_slicedToArray2["default"])(_useState7,2),rating=_useState8[0],setRating=_useState8[1];question=question;return(0,_jsxRuntime.jsxs)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText,submitDisabled:rating===null&&!question.optional,appearance:appearance,onSubmit:function onSubmit(){return _onSubmit2(rating);},skipSubmitButton:question.skipSubmitButton}),children:[(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.ratingSection,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.ratingOptions,children:[question.display===_core.SurveyRatingDisplay.Emoji&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.ratingOptionsEmoji,children:(_b=emojiScaleLists[question.scale])===null||_b===void 0?void 0:_b.map(function(Emoji,idx){var active=idx+1===rating;return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.ratingsEmoji,onPress:function onPress(){var response=idx+1;setRating(response);if(question.skipSubmitButton){_onSubmit2(response);}},children:(0,_jsxRuntime.jsx)(Emoji,{fill:active?appearance.ratingButtonActiveColor:appearance.ratingButtonColor})},idx);})}),question.display===_core.SurveyRatingDisplay.Number&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ratingOptionsNumber,{borderColor:appearance.borderColor}],children:getScaleNumbers(question.scale).map(function(number,idx){var active=rating===number;return(0,_jsxRuntime.jsx)(RatingButton,{index:idx,active:active,appearance:appearance,num:number,setActiveNumber:function setActiveNumber(response){setRating(response);if(question.skipSubmitButton){_onSubmit2(response);}}},idx);})})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.ratingText,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:(_c=appearance.textColor)!==null&&_c!==void 0?_c:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor),opacity:_surveysUtils.defaultRatingLabelOpacity},children:question.lowerBoundLabel}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:(_d=appearance.textColor)!==null&&_d!==void 0?_d:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor),opacity:_surveysUtils.defaultRatingLabelOpacity},children:question.upperBoundLabel})]})]})]});}function RatingButton(_ref5){var index=_ref5.index,num=_ref5.num,active=_ref5.active,appearance=_ref5.appearance,setActiveNumber=_ref5.setActiveNumber;var _a;var backgroundColor=active?appearance.ratingButtonActiveColor:appearance.ratingButtonColor;var textColor=active?(0,_surveysUtils.getContrastingTextColor)(backgroundColor):(_a=appearance.inputTextColor)!==null&&_a!==void 0?_a:(0,_surveysUtils.getContrastingTextColor)(backgroundColor);return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.ratingsNumber,index===0&&{borderLeftWidth:0},{backgroundColor:backgroundColor,borderColor:appearance.borderColor}],onPress:function onPress(){return setActiveNumber(num);},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:textColor},children:num})});}function MultipleChoiceQuestion(_ref6){var _this2=this;var question=_ref6.question,appearance=_ref6.appearance,_onSubmit3=_ref6.onSubmit;var _a;question=question;var isSingleChoice=question.type===_core.SurveyQuestionType.SingleChoice;var allowMultiple=question.type===_core.SurveyQuestionType.MultipleChoice;var openChoice=question.hasOpenChoice?question.choices[question.choices.length-1]:null;var choices=(0,_react.useMemo)(function(){return(0,_surveysUtils.getDisplayOrderChoices)(question);},[question]);var _useState9=(0,_react.useState)([]),_useState0=(0,_slicedToArray2["default"])(_useState9,2),selectedChoices=_useState0[0],setSelectedChoices=_useState0[1];var _useState1=(0,_react.useState)(''),_useState10=(0,_slicedToArray2["default"])(_useState1,2),openEndedInput=_useState10[0],setOpenEndedInput=_useState10[1];var shouldSkipSubmit=question.skipSubmitButton&&isSingleChoice&&!question.hasOpenChoice;return(0,_jsxRuntime.jsxs)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText,submitDisabled:!question.optional&&(selectedChoices.length===0||openChoice!==null&&selectedChoices.includes(openChoice)&&openEndedInput.length===0),appearance:appearance,onSubmit:function onSubmit(){var result=selectedChoices.map(function(c){return c===openChoice?openEndedInput:c;});_onSubmit3(allowMultiple?result:result[0]);},skipSubmitButton:shouldSkipSubmit}),children:[(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.multipleChoiceOptions,children:choices.map(function(choice,idx){var _a;var isOpenChoice=choice===openChoice;var isSelected=selectedChoices.includes(choice);var choiceTextColor=(_a=appearance.inputTextColor)!==null&&_a!==void 0?_a:(0,_surveysUtils.getContrastingTextColor)(appearance.inputBackground);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{style:[styles.choiceOption,{backgroundColor:appearance.inputBackground},isSelected?{borderColor:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor)}:{}],onPress:function onPress(){if(allowMultiple){setSelectedChoices(isSelected?selectedChoices.filter(function(c){return c!==choice;}):[].concat((0,_toConsumableArray2["default"])(selectedChoices),[choice]));}else{setSelectedChoices([choice]);if(shouldSkipSubmit&&!isOpenChoice){_onSubmit3(choice);}}},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.choiceText,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:{flexGrow:1,color:choiceTextColor},children:[choice,isOpenChoice?':':'']}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rightCheckArea,children:isSelected&&(0,_jsxRuntime.jsx)(_icons.CheckSVG,{})})]}),isOpenChoice&&(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.openEndedInput,onChangeText:function onChangeText(userValue){setOpenEndedInput(userValue);if(!isSelected){setSelectedChoices(allowMultiple?[].concat((0,_toConsumableArray2["default"])(selectedChoices),[choice]):[choice]);}}})]},idx);})})]});}var emojiScaleLists={2:[_icons.ThumbsUpEmoji,_icons.ThumbsDownEmoji],3:[_icons.DissatisfiedEmoji,_icons.NeutralEmoji,_icons.SatisfiedEmoji],5:[_icons.VeryDissatisfiedEmoji,_icons.DissatisfiedEmoji,_icons.NeutralEmoji,_icons.SatisfiedEmoji,_icons.VerySatisfiedEmoji]};var fiveScaleNumbers=[1,2,3,4,5];var sevenScaleNumbers=[1,2,3,4,5,6,7];var tenScaleNumbers=[0,1,2,3,4,5,6,7,8,9,10];function getScaleNumbers(scale){switch(scale){case 5:return fiveScaleNumbers;case 7:return sevenScaleNumbers;case 10:return tenScaleNumbers;default:return fiveScaleNumbers;}}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({textInputContainer:{padding:10},textInput:{borderColor:'#ccc',borderWidth:1,padding:10,marginVertical:10,fontSize:16,height:80,textAlignVertical:'top'},ratingSection:{marginVertical:10},ratingOptions:{flexDirection:'row',justifyContent:'space-between'},ratingOptionsEmoji:{flexDirection:'row',justifyContent:'space-around',flexWrap:'nowrap',flex:1},ratingsEmoji:{padding:4},ratingOptionsNumber:{margin:10,flexGrow:1,flexDirection:'row',justifyContent:'space-between',borderRadius:5,borderWidth:1,overflow:'hidden'},ratingsNumber:{flex:1,paddingVertical:10,alignItems:'center',borderLeftWidth:1},ratingText:{flexDirection:'row',justifyContent:'space-between',padding:10},multipleChoiceOptions:{padding:10},choiceOption:{flexDirection:'column',marginVertical:5,borderWidth:1,borderColor:'grey',borderRadius:5,padding:10},choiceText:{flexDirection:'row'},rightCheckArea:{flexGrow:0},openEndedInput:{padding:5},validationHint:{fontSize:12,opacity:0.7,marginTop:4}});
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.LinkQuestion=LinkQuestion;exports.MultipleChoiceQuestion=MultipleChoiceQuestion;exports.OpenTextQuestion=OpenTextQuestion;exports.RatingButton=RatingButton;exports.RatingQuestion=RatingQuestion;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _safeStyleSheet=require("../safeStyleSheet");var _icons=require("../icons");var _surveysUtils=require("../surveys-utils");var _core=require("@txlemetry/core");var _surveys=require("@txlemetry/core/surveys");var _BottomSection=require("./BottomSection");var _QuestionHeader=require("./QuestionHeader");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/components/QuestionTypes.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function QuestionLayout(_ref){var children=_ref.children,footer=_ref.footer;var _useState=(0,_react.useState)(0),_useState2=(0,_slicedToArray2["default"])(_useState,2),viewportHeight=_useState2[0],setViewportHeight=_useState2[1];var _useState3=(0,_react.useState)(0),_useState4=(0,_slicedToArray2["default"])(_useState3,2),contentHeight=_useState4[0],setContentHeight=_useState4[1];var isOverflowing=contentHeight>viewportHeight+1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:questionLayoutStyles.container,children:[(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:questionLayoutStyles.scroll,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,scrollEnabled:isOverflowing,bounces:isOverflowing,onLayout:function onLayout(e){return setViewportHeight(e.nativeEvent.layout.height);},onContentSizeChange:function onContentSizeChange(_width,height){return setContentHeight(height);},children:children}),footer]});}var questionLayoutStyles=(0,_safeStyleSheet.createSafeStyleSheet)({container:{flexShrink:1},scroll:{flexShrink:1}});function OpenTextQuestion(_ref2){var question=_ref2.question,appearance=_ref2.appearance,onSubmit=_ref2.onSubmit;var _a,_b,_c,_d;var _useState5=(0,_react.useState)(''),_useState6=(0,_slicedToArray2["default"])(_useState5,2),text=_useState6[0],setText=_useState6[1];var validationError=(0,_react.useMemo)(function(){return(0,_surveys.getValidationError)(text,question.validation,question.optional);},[text,question.validation,question.optional]);var minLength=(0,_surveys.getLengthFromRules)(question.validation,_core.SurveyValidationType.MinLength);var maxLength=(0,_surveys.getLengthFromRules)(question.validation,_core.SurveyValidationType.MaxLength);var requirementsHint=(0,_react.useMemo)(function(){return(0,_surveys.getRequirementsHint)(minLength,maxLength);},[minLength,maxLength]);var handleSubmit=function handleSubmit(){if(validationError){return;}onSubmit(text.trim());};return(0,_jsxRuntime.jsxs)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText,submitDisabled:!!validationError,appearance:appearance,onSubmit:handleSubmit}),children:[(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.textInputContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:[styles.textInput,{backgroundColor:appearance.inputBackground,color:(_b=appearance.inputTextColor)!==null&&_b!==void 0?_b:(0,_surveysUtils.getContrastingTextColor)(appearance.inputBackground),borderColor:appearance.borderColor}],multiline:true,numberOfLines:4,placeholder:appearance.placeholder,placeholderTextColor:(0,_surveysUtils.getContrastingTextColor)((_c=appearance.inputTextColor)!==null&&_c!==void 0?_c:(0,_surveysUtils.getContrastingTextColor)(appearance.inputBackground))==='white'?'rgba(0, 0, 0, 0.5)':'rgba(255, 255, 255, 0.5)',onChangeText:setText,value:text}),requirementsHint&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.validationHint,{color:(_d=appearance.textColor)!==null&&_d!==void 0?_d:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor)}],children:requirementsHint})]})]});}function LinkQuestion(_ref3){var question=_ref3.question,appearance=_ref3.appearance,_onSubmit=_ref3.onSubmit;var _a,_b;question=question;return(0,_jsxRuntime.jsx)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_b=(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText)!==null&&_b!==void 0?_b:'Submit',submitDisabled:false,link:question.link,appearance:appearance,onSubmit:function onSubmit(){return _onSubmit('link clicked');}}),children:(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance})});}function RatingQuestion(_ref4){var _this=this;var question=_ref4.question,appearance=_ref4.appearance,_onSubmit2=_ref4.onSubmit;var _a,_b,_c,_d;var _useState7=(0,_react.useState)(null),_useState8=(0,_slicedToArray2["default"])(_useState7,2),rating=_useState8[0],setRating=_useState8[1];question=question;return(0,_jsxRuntime.jsxs)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText,submitDisabled:rating===null&&!question.optional,appearance:appearance,onSubmit:function onSubmit(){return _onSubmit2(rating);},skipSubmitButton:question.skipSubmitButton}),children:[(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.ratingSection,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.ratingOptions,children:[question.display===_core.SurveyRatingDisplay.Emoji&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.ratingOptionsEmoji,children:(_b=emojiScaleLists[question.scale])===null||_b===void 0?void 0:_b.map(function(Emoji,idx){var active=idx+1===rating;return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.ratingsEmoji,onPress:function onPress(){var response=idx+1;setRating(response);if(question.skipSubmitButton){_onSubmit2(response);}},children:(0,_jsxRuntime.jsx)(Emoji,{fill:active?appearance.ratingButtonActiveColor:appearance.ratingButtonColor})},idx);})}),question.display===_core.SurveyRatingDisplay.Number&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ratingOptionsNumber,{borderColor:appearance.borderColor}],children:getScaleNumbers(question.scale).map(function(number,idx){var active=rating===number;return(0,_jsxRuntime.jsx)(RatingButton,{index:idx,active:active,appearance:appearance,num:number,setActiveNumber:function setActiveNumber(response){setRating(response);if(question.skipSubmitButton){_onSubmit2(response);}}},idx);})})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.ratingText,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:(_c=appearance.textColor)!==null&&_c!==void 0?_c:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor),opacity:_surveysUtils.defaultRatingLabelOpacity},children:question.lowerBoundLabel}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:(_d=appearance.textColor)!==null&&_d!==void 0?_d:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor),opacity:_surveysUtils.defaultRatingLabelOpacity},children:question.upperBoundLabel})]})]})]});}function RatingButton(_ref5){var index=_ref5.index,num=_ref5.num,active=_ref5.active,appearance=_ref5.appearance,setActiveNumber=_ref5.setActiveNumber;var _a;var backgroundColor=active?appearance.ratingButtonActiveColor:appearance.ratingButtonColor;var textColor=active?(0,_surveysUtils.getContrastingTextColor)(backgroundColor):(_a=appearance.inputTextColor)!==null&&_a!==void 0?_a:(0,_surveysUtils.getContrastingTextColor)(backgroundColor);return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.ratingsNumber,index===0&&{borderLeftWidth:0},{backgroundColor:backgroundColor,borderColor:appearance.borderColor}],onPress:function onPress(){return setActiveNumber(num);},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:textColor},children:num})});}function MultipleChoiceQuestion(_ref6){var _this2=this;var question=_ref6.question,appearance=_ref6.appearance,_onSubmit3=_ref6.onSubmit;var _a;question=question;var isSingleChoice=question.type===_core.SurveyQuestionType.SingleChoice;var allowMultiple=question.type===_core.SurveyQuestionType.MultipleChoice;var openChoice=question.hasOpenChoice?question.choices[question.choices.length-1]:null;var choices=(0,_react.useMemo)(function(){return(0,_surveysUtils.getDisplayOrderChoices)(question);},[question]);var _useState9=(0,_react.useState)([]),_useState0=(0,_slicedToArray2["default"])(_useState9,2),selectedChoices=_useState0[0],setSelectedChoices=_useState0[1];var _useState1=(0,_react.useState)(''),_useState10=(0,_slicedToArray2["default"])(_useState1,2),openEndedInput=_useState10[0],setOpenEndedInput=_useState10[1];var shouldSkipSubmit=question.skipSubmitButton&&isSingleChoice&&!question.hasOpenChoice;return(0,_jsxRuntime.jsxs)(QuestionLayout,{footer:(0,_jsxRuntime.jsx)(_BottomSection.BottomSection,{text:(_a=question.buttonText)!==null&&_a!==void 0?_a:appearance.submitButtonText,submitDisabled:!question.optional&&(selectedChoices.length===0||openChoice!==null&&selectedChoices.includes(openChoice)&&openEndedInput.length===0),appearance:appearance,onSubmit:function onSubmit(){var result=selectedChoices.map(function(c){return c===openChoice?openEndedInput:c;});_onSubmit3(allowMultiple?result:result[0]);},skipSubmitButton:shouldSkipSubmit}),children:[(0,_jsxRuntime.jsx)(_QuestionHeader.QuestionHeader,{question:question.question,description:question.description,descriptionContentType:question.descriptionContentType,appearance:appearance}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.multipleChoiceOptions,children:choices.map(function(choice,idx){var _a;var isOpenChoice=choice===openChoice;var isSelected=selectedChoices.includes(choice);var choiceTextColor=(_a=appearance.inputTextColor)!==null&&_a!==void 0?_a:(0,_surveysUtils.getContrastingTextColor)(appearance.inputBackground);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{style:[styles.choiceOption,{backgroundColor:appearance.inputBackground},isSelected?{borderColor:(0,_surveysUtils.getContrastingTextColor)(appearance.backgroundColor)}:{}],onPress:function onPress(){if(allowMultiple){setSelectedChoices(isSelected?selectedChoices.filter(function(c){return c!==choice;}):[].concat((0,_toConsumableArray2["default"])(selectedChoices),[choice]));}else{setSelectedChoices([choice]);if(shouldSkipSubmit&&!isOpenChoice){_onSubmit3(choice);}}},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.choiceText,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:{flexGrow:1,color:choiceTextColor},children:[choice,isOpenChoice?':':'']}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rightCheckArea,children:isSelected&&(0,_jsxRuntime.jsx)(_icons.CheckSVG,{})})]}),isOpenChoice&&(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.openEndedInput,onChangeText:function onChangeText(userValue){setOpenEndedInput(userValue);if(!isSelected){setSelectedChoices(allowMultiple?[].concat((0,_toConsumableArray2["default"])(selectedChoices),[choice]):[choice]);}}})]},idx);})})]});}var emojiScaleLists={2:[_icons.ThumbsUpEmoji,_icons.ThumbsDownEmoji],3:[_icons.DissatisfiedEmoji,_icons.NeutralEmoji,_icons.SatisfiedEmoji],5:[_icons.VeryDissatisfiedEmoji,_icons.DissatisfiedEmoji,_icons.NeutralEmoji,_icons.SatisfiedEmoji,_icons.VerySatisfiedEmoji]};var fiveScaleNumbers=[1,2,3,4,5];var sevenScaleNumbers=[1,2,3,4,5,6,7];var tenScaleNumbers=[0,1,2,3,4,5,6,7,8,9,10];function getScaleNumbers(scale){switch(scale){case 5:return fiveScaleNumbers;case 7:return sevenScaleNumbers;case 10:return tenScaleNumbers;default:return fiveScaleNumbers;}}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({textInputContainer:{padding:10},textInput:{borderColor:'#ccc',borderWidth:1,padding:10,marginVertical:10,fontSize:16,height:80,textAlignVertical:'top'},ratingSection:{marginVertical:10},ratingOptions:{flexDirection:'row',justifyContent:'space-between'},ratingOptionsEmoji:{flexDirection:'row',justifyContent:'space-around',flexWrap:'nowrap',flex:1},ratingsEmoji:{padding:4},ratingOptionsNumber:{margin:10,flexGrow:1,flexDirection:'row',justifyContent:'space-between',borderRadius:5,borderWidth:1,overflow:'hidden'},ratingsNumber:{flex:1,paddingVertical:10,alignItems:'center',borderLeftWidth:1},ratingText:{flexDirection:'row',justifyContent:'space-between',padding:10},multipleChoiceOptions:{padding:10},choiceOption:{flexDirection:'column',marginVertical:5,borderWidth:1,borderColor:'grey',borderRadius:5,padding:10},choiceText:{flexDirection:'row'},rightCheckArea:{flexGrow:0},openEndedInput:{padding:5},validationHint:{fontSize:12,opacity:0.7,marginTop:4}});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
-
import { Survey, type SurveyResponses } from '@txlemetry/core';
|
|
3
|
-
export type SurveyModalProps = {
|
|
4
|
-
survey: Survey;
|
|
5
|
-
surveyLanguage: string | null;
|
|
6
|
-
appearance: SurveyAppearanceTheme;
|
|
7
|
-
onShow: () => void;
|
|
8
|
-
onClose: (submitted: boolean, responses: SurveyResponses) => void;
|
|
9
|
-
androidKeyboardBehavior?: 'padding' | 'height';
|
|
10
|
-
};
|
|
11
|
-
export declare function SurveyModal(props: SurveyModalProps): JSX.Element | null;
|
|
1
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
2
|
+
import { Survey, type SurveyResponses } from '@txlemetry/core';
|
|
3
|
+
export type SurveyModalProps = {
|
|
4
|
+
survey: Survey;
|
|
5
|
+
surveyLanguage: string | null;
|
|
6
|
+
appearance: SurveyAppearanceTheme;
|
|
7
|
+
onShow: () => void;
|
|
8
|
+
onClose: (submitted: boolean, responses: SurveyResponses) => void;
|
|
9
|
+
androidKeyboardBehavior?: 'padding' | 'height';
|
|
10
|
+
};
|
|
11
|
+
export declare function SurveyModal(props: SurveyModalProps): JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.SurveyModal=SurveyModal;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _Cancel=require("./Cancel");var _ConfirmationMessage=require("./ConfirmationMessage");var _safeStyleSheet=require("../safeStyleSheet");var _surveysUtils=require("../surveys-utils");var _OptionalReactNativeSafeArea=require("../../optional/OptionalReactNativeSafeArea");var _Surveys=require("./Surveys");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.SurveyModal=SurveyModal;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _Cancel=require("./Cancel");var _ConfirmationMessage=require("./ConfirmationMessage");var _safeStyleSheet=require("../safeStyleSheet");var _surveysUtils=require("../surveys-utils");var _OptionalReactNativeSafeArea=require("../../optional/OptionalReactNativeSafeArea");var _Surveys=require("./Surveys");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="txlemetry-react-native/dist/surveys/components/SurveyModal.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}var VIEWPORT_BUFFER=0;var MODAL_FADE_DURATION_MS=250;var IOS_DISMISS_FALLBACK_MS=1000;function SurveyModal(props){var survey=props.survey,surveyLanguage=props.surveyLanguage,appearance=props.appearance,onShow=props.onShow,onCloseProp=props.onClose,_props$androidKeyboar=props.androidKeyboardBehavior,androidKeyboardBehavior=_props$androidKeyboar===void 0?'height':_props$androidKeyboar;var _useState=(0,_react.useState)(false),_useState2=(0,_slicedToArray2["default"])(_useState,2),isSurveySent=_useState2[0],setIsSurveySent=_useState2[1];var _useState3=(0,_react.useState)({}),_useState4=(0,_slicedToArray2["default"])(_useState3,2),responses=_useState4[0],setResponses=_useState4[1];var _useState5=(0,_react.useState)(true),_useState6=(0,_slicedToArray2["default"])(_useState5,2),isVisible=_useState6[0],setIsVisible=_useState6[1];var _useState7=(0,_react.useState)(true),_useState8=(0,_slicedToArray2["default"])(_useState7,2),contentMounted=_useState8[0],setContentMounted=_useState8[1];var isClosingRef=(0,_react.useRef)(false);var closeNotifiedRef=(0,_react.useRef)(false);var closeTimerRef=(0,_react.useRef)(null);var notifyParentClosed=(0,_react.useCallback)(function(){if(closeNotifiedRef.current)return;closeNotifiedRef.current=true;onCloseProp(isSurveySent,responses);},[isSurveySent,onCloseProp,responses]);var onClose=(0,_react.useCallback)(function(){if(isClosingRef.current)return;isClosingRef.current=true;setContentMounted(false);requestAnimationFrame(function(){setIsVisible(false);var fallbackDelay=_reactNative.Platform.OS==='ios'?IOS_DISMISS_FALLBACK_MS:MODAL_FADE_DURATION_MS;closeTimerRef.current=setTimeout(notifyParentClosed,fallbackDelay);});},[notifyParentClosed]);(0,_react.useEffect)(function(){return function(){if(closeTimerRef.current){clearTimeout(closeTimerRef.current);}};},[]);var insets=(0,_OptionalReactNativeSafeArea.useOptionalSafeAreaInsets)();var _useWindowDimensions=(0,_reactNative.useWindowDimensions)(),windowHeight=_useWindowDimensions.height;var _useState9=(0,_react.useState)(0),_useState0=(0,_slicedToArray2["default"])(_useState9,2),keyboardHeight=_useState0[0],setKeyboardHeight=_useState0[1];var _resolveSurveyAlignme=(0,_surveysUtils.resolveSurveyAlignment)(appearance.position),vertical=_resolveSurveyAlignme.vertical,horizontal=_resolveSurveyAlignme.horizontal;var isBottom=vertical==='flex-end';var shouldShowConfirmation=isSurveySent&&appearance.thankYouMessageHeader;(0,_react.useEffect)(function(){if(isVisible){onShow();}},[isVisible,onShow]);(0,_react.useEffect)(function(){var showEvent=_reactNative.Platform.OS==='ios'?'keyboardWillShow':'keyboardDidShow';var hideEvent=_reactNative.Platform.OS==='ios'?'keyboardWillHide':'keyboardDidHide';var showSub=_reactNative.Keyboard.addListener(showEvent,function(e){return setKeyboardHeight(e.endCoordinates.height);});var hideSub=_reactNative.Keyboard.addListener(hideEvent,function(){return setKeyboardHeight(0);});return function(){showSub.remove();hideSub.remove();};},[]);var maxModalHeight=Math.max(windowHeight-keyboardHeight-insets.top-insets.bottom-VIEWPORT_BUFFER,200);var keyboardBehavior=_reactNative.Platform.OS==='ios'?'padding':androidKeyboardBehavior;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:isVisible,animationType:"fade",transparent:true,onRequestClose:onClose,onDismiss:_reactNative.Platform.OS==='ios'?notifyParentClosed:undefined,statusBarTranslucent:true,children:contentMounted&&(0,_jsxRuntime.jsx)(_reactNative.KeyboardAvoidingView,{behavior:keyboardBehavior,style:styles.fill,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,styles.backdrop,{justifyContent:vertical}],onTouchStart:_reactNative.Keyboard.dismiss,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.modalRow,{justifyContent:horizontal}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.modalContent,pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.modalContentInner,{borderColor:appearance.borderColor,backgroundColor:appearance.backgroundColor,marginTop:vertical==='flex-start'?insets.top+10:0,marginBottom:isBottom?keyboardHeight>0?0:insets.bottom+10:0,marginHorizontal:10,maxHeight:maxModalHeight}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.topIconContainer,children:(0,_jsxRuntime.jsx)(_Cancel.Cancel,{onPress:onClose,appearance:appearance})}),isSurveySent?shouldShowConfirmation?(0,_jsxRuntime.jsx)(_ConfirmationMessage.ConfirmationMessage,{appearance:appearance,header:appearance.thankYouMessageHeader,description:appearance.thankYouMessageDescription,contentType:appearance.thankYouMessageDescriptionContentType,onClose:onClose,isModal:true}):null:(0,_jsxRuntime.jsx)(_Surveys.Questions,{survey:survey,surveyLanguage:surveyLanguage,appearance:appearance,responses:responses,onResponsesChange:setResponses,onSubmit:function onSubmit(){return setIsSurveySent(true);}})]})})})})})});}var styles=(0,_safeStyleSheet.createSafeStyleSheet)({fill:{flex:1},backdrop:{backgroundColor:'rgba(0, 0, 0, 0.32)'},modalRow:{flexDirection:'row'},modalContent:{width:'90%',maxWidth:400},modalContentInner:{borderRadius:10,borderWidth:1,padding:20},topIconContainer:{position:'absolute',right:8,top:8,zIndex:1}});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
-
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
-
import { Survey, type SurveyResponses } from '@txlemetry/core';
|
|
4
|
-
import {
|
|
5
|
-
export declare const sendSurveyShownEvent: (survey: Survey,
|
|
6
|
-
export declare const sendSurveyEvent: (responses: SurveyResponses | undefined, survey: Survey,
|
|
7
|
-
export declare const dismissedSurveyEvent: (survey: Survey, responses: SurveyResponses | undefined,
|
|
8
|
-
export declare function Questions({ survey, surveyLanguage, appearance, styleOverrides, responses, onResponsesChange, onSubmit, }: {
|
|
9
|
-
survey: Survey;
|
|
10
|
-
surveyLanguage?: string | null;
|
|
11
|
-
appearance: SurveyAppearanceTheme;
|
|
12
|
-
styleOverrides?: StyleProp<ViewStyle>;
|
|
13
|
-
responses?: SurveyResponses;
|
|
14
|
-
onResponsesChange?: (responses: SurveyResponses) => void;
|
|
15
|
-
onSubmit: () => void;
|
|
16
|
-
}): JSX.Element;
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
+
import { Survey, type SurveyResponses } from '@txlemetry/core';
|
|
4
|
+
import { Txlemetry } from '../../txlemetry-rn';
|
|
5
|
+
export declare const sendSurveyShownEvent: (survey: Survey, txlemetry: Txlemetry, surveyLanguage?: string | null) => void;
|
|
6
|
+
export declare const sendSurveyEvent: (responses: SurveyResponses | undefined, survey: Survey, txlemetry: Txlemetry, surveyLanguage?: string | null) => void;
|
|
7
|
+
export declare const dismissedSurveyEvent: (survey: Survey, responses: SurveyResponses | undefined, txlemetry: Txlemetry, surveyLanguage?: string | null) => void;
|
|
8
|
+
export declare function Questions({ survey, surveyLanguage, appearance, styleOverrides, responses, onResponsesChange, onSubmit, }: {
|
|
9
|
+
survey: Survey;
|
|
10
|
+
surveyLanguage?: string | null;
|
|
11
|
+
appearance: SurveyAppearanceTheme;
|
|
12
|
+
styleOverrides?: StyleProp<ViewStyle>;
|
|
13
|
+
responses?: SurveyResponses;
|
|
14
|
+
onResponsesChange?: (responses: SurveyResponses) => void;
|
|
15
|
+
onSubmit: () => void;
|
|
16
|
+
}): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.Questions=Questions;exports.sendSurveyShownEvent=exports.sendSurveyEvent=exports.dismissedSurveyEvent=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _surveysUtils=require("../surveys-utils");var _core=require("@txlemetry/core");var _surveys=require("@txlemetry/core/surveys");var _QuestionTypes=require("./QuestionTypes");var
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.Questions=Questions;exports.sendSurveyShownEvent=exports.sendSurveyEvent=exports.dismissedSurveyEvent=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _surveysUtils=require("../surveys-utils");var _core=require("@txlemetry/core");var _surveys=require("@txlemetry/core/surveys");var _QuestionTypes=require("./QuestionTypes");var _useTxlemetry=require("../../hooks/useTxlemetry");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="txlemetry-react-native/dist/surveys/components/Surveys.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var sendSurveyShownEvent=exports.sendSurveyShownEvent=function sendSurveyShownEvent(survey,txlemetry,surveyLanguage){txlemetry.capture('survey shown',_objectSpread(_objectSpread(_objectSpread({$survey_name:survey.name,$survey_id:survey.id},(0,_core.maybeAdd)('$survey_iteration',survey.current_iteration)),(0,_core.maybeAdd)('$survey_iteration_start_date',survey.current_iteration_start_date)),surveyLanguage?(0,_defineProperty2["default"])({},_surveys.SURVEY_LANGUAGE_PROPERTY,surveyLanguage):{}));};var sendSurveyEvent=exports.sendSurveyEvent=function sendSurveyEvent(){var responses=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var survey=arguments.length>1?arguments[1]:undefined;var txlemetry=arguments.length>2?arguments[2]:undefined;var surveyLanguage=arguments.length>3?arguments[3]:undefined;txlemetry.capture('survey sent',_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({$survey_name:survey.name,$survey_id:survey.id},(0,_core.maybeAdd)('$survey_iteration',survey.current_iteration)),(0,_core.maybeAdd)('$survey_iteration_start_date',survey.current_iteration_start_date)),surveyLanguage?(0,_defineProperty2["default"])({},_surveys.SURVEY_LANGUAGE_PROPERTY,surveyLanguage):{}),(0,_surveys.buildSurveyResponseProperties)(responses,survey)),{},{$set:(0,_defineProperty2["default"])({},(0,_surveys.getSurveyInteractionProperty)(survey,'responded'),true)}));};var dismissedSurveyEvent=exports.dismissedSurveyEvent=function dismissedSurveyEvent(survey){var responses=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var txlemetry=arguments.length>2?arguments[2]:undefined;var surveyLanguage=arguments.length>3?arguments[3]:undefined;txlemetry.capture('survey dismissed',_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({$survey_name:survey.name,$survey_id:survey.id},(0,_core.maybeAdd)('$survey_iteration',survey.current_iteration)),(0,_core.maybeAdd)('$survey_iteration_start_date',survey.current_iteration_start_date)),surveyLanguage?(0,_defineProperty2["default"])({},_surveys.SURVEY_LANGUAGE_PROPERTY,surveyLanguage):{}),{},{$survey_partially_completed:(0,_surveys.surveyHasResponses)(responses)},(0,_surveys.buildSurveyResponseProperties)(responses,survey)),{},{$set:(0,_defineProperty2["default"])({},(0,_surveys.getSurveyInteractionProperty)(survey,'dismissed'),true)}));};function Questions(_ref4){var survey=_ref4.survey,surveyLanguage=_ref4.surveyLanguage,appearance=_ref4.appearance,styleOverrides=_ref4.styleOverrides,_ref4$responses=_ref4.responses,responses=_ref4$responses===void 0?{}:_ref4$responses,_ref4$onResponsesChan=_ref4.onResponsesChange,onResponsesChange=_ref4$onResponsesChan===void 0?function(){}:_ref4$onResponsesChan,onSubmit=_ref4.onSubmit;var _useState=(0,_react.useState)(0),_useState2=(0,_slicedToArray2["default"])(_useState,2),currentQuestionIndex=_useState2[0],setCurrentQuestionIndex=_useState2[1];var surveyQuestions=(0,_react.useMemo)(function(){return(0,_surveysUtils.getDisplayOrderQuestions)(survey);},[survey]);var txlemetry=(0,_useTxlemetry.useTxlemetry)();var onNextButtonClick=function onNextButtonClick(_ref5){var res=_ref5.res,originalQuestionIndex=_ref5.originalQuestionIndex,questionId=_ref5.questionId;var responseKey=(0,_surveys.getSurveyResponseKey)(questionId);var allResponses=_objectSpread(_objectSpread({},responses),{},(0,_defineProperty2["default"])({},responseKey,res));onResponsesChange(allResponses);var nextStep=(0,_surveysUtils.getNextSurveyStep)(survey,originalQuestionIndex,res);if(nextStep===_core.SurveyQuestionBranchingType.End){sendSurveyEvent(allResponses,survey,txlemetry,surveyLanguage);onSubmit();}else{setCurrentQuestionIndex(nextStep);}};var question=surveyQuestions[currentQuestionIndex];return getQuestionComponent({question:question,appearance:appearance,styleOverrides:styleOverrides,onSubmit:function onSubmit(res){return onNextButtonClick({res:res,originalQuestionIndex:question.originalQuestionIndex,questionId:question.id});}});}var getQuestionComponent=function getQuestionComponent(props){var questionComponents={open:_QuestionTypes.OpenTextQuestion,link:_QuestionTypes.LinkQuestion,rating:_QuestionTypes.RatingQuestion,multiple_choice:_QuestionTypes.MultipleChoiceQuestion,single_choice:_QuestionTypes.MultipleChoiceQuestion};var Component=questionComponents[props.question.type];return(0,_jsxRuntime.jsx)(Component,_objectSpread({},props),props.question.originalQuestionIndex);};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FeatureFlagValue, Survey } from '@txlemetry/core';
|
|
2
|
-
export declare function getActiveMatchingSurveys(surveys: Survey[], flags: Record<string, FeatureFlagValue>, seenSurveys: string[], activatedSurveys: ReadonlySet<string>): Survey[];
|
|
1
|
+
import { FeatureFlagValue, Survey } from '@txlemetry/core';
|
|
2
|
+
export declare function getActiveMatchingSurveys(surveys: Survey[], flags: Record<string, FeatureFlagValue>, seenSurveys: string[], activatedSurveys: ReadonlySet<string>): Survey[];
|
package/dist/surveys/icons.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { JSX } from 'react';
|
|
2
|
-
import type { SvgProps } from 'react-native-svg';
|
|
3
|
-
export declare const SatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
4
|
-
export declare const NeutralEmoji: (props: SvgProps) => JSX.Element;
|
|
5
|
-
export declare const DissatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
6
|
-
export declare const VeryDissatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
7
|
-
export declare const VerySatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
8
|
-
export declare const ThumbsUpEmoji: (props: SvgProps) => JSX.Element;
|
|
9
|
-
export declare const ThumbsDownEmoji: (props: SvgProps) => JSX.Element;
|
|
10
|
-
export declare const CheckSVG: (props: SvgProps) => JSX.Element;
|
|
11
|
-
export declare const CancelSVG: (props: SvgProps) => JSX.Element;
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import type { SvgProps } from 'react-native-svg';
|
|
3
|
+
export declare const SatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
4
|
+
export declare const NeutralEmoji: (props: SvgProps) => JSX.Element;
|
|
5
|
+
export declare const DissatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
6
|
+
export declare const VeryDissatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
7
|
+
export declare const VerySatisfiedEmoji: (props: SvgProps) => JSX.Element;
|
|
8
|
+
export declare const ThumbsUpEmoji: (props: SvgProps) => JSX.Element;
|
|
9
|
+
export declare const ThumbsDownEmoji: (props: SvgProps) => JSX.Element;
|
|
10
|
+
export declare const CheckSVG: (props: SvgProps) => JSX.Element;
|
|
11
|
+
export declare const CancelSVG: (props: SvgProps) => JSX.Element;
|
package/dist/surveys/icons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.VerySatisfiedEmoji=exports.VeryDissatisfiedEmoji=exports.ThumbsUpEmoji=exports.ThumbsDownEmoji=exports.SatisfiedEmoji=exports.NeutralEmoji=exports.DissatisfiedEmoji=exports.CheckSVG=exports.CancelSVG=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _OptionalReactNativeSvg=require("../optional/OptionalReactNativeSvg");var _safeStyleSheet=require("./safeStyleSheet");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/surveys/icons.js";function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var Svg=_OptionalReactNativeSvg.OptionalReactNativeSvg===null||_OptionalReactNativeSvg.OptionalReactNativeSvg===void 0?void 0:_OptionalReactNativeSvg.OptionalReactNativeSvg.Svg;var Path=_OptionalReactNativeSvg.OptionalReactNativeSvg===null||_OptionalReactNativeSvg.OptionalReactNativeSvg===void 0?void 0:_OptionalReactNativeSvg.OptionalReactNativeSvg.Path;var getFallbackSize=function getFallbackSize(value,fallback){if(typeof value==='number'){return value;}if(typeof value==='string'){var parsed=Number.parseInt(value,10);return Number.isNaN(parsed)?fallback:parsed;}return fallback;};var getFallbackColor=function getFallbackColor(fill){return typeof fill==='string'&&fill!=='none'?fill:'black';};var getFallbackFontSize=function getFallbackFontSize(label,height){return label.length>1?Math.round(height*0.55):height;};var renderFallbackIcon=function renderFallbackIcon(_ref){var label=_ref.label,fill=_ref.fill,height=_ref.height;return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.fallbackIcon,{color:getFallbackColor(fill),fontSize:getFallbackFontSize(label,height),height:height,lineHeight:height,width:height}],children:label});};var renderSvgIcon=function renderSvgIcon(_ref2){var props=_ref2.props,height=_ref2.height,width=_ref2.width,viewBox=_ref2.viewBox,pathProps=_ref2.pathProps,fallback=_ref2.fallback;var _a;if(!Svg||!Path){return renderFallbackIcon({label:fallback,fill:props.fill,height:getFallbackSize((_a=props.height)!==null&&_a!==void 0?_a:height,48)});}return(0,_jsxRuntime.jsx)(Svg,_objectSpread(_objectSpread({height:height,viewBox:viewBox,width:width},props),{},{children:(0,_jsxRuntime.jsx)(Path,_objectSpread({},pathProps))}));};var SatisfiedEmoji=exports.SatisfiedEmoji=function SatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':)',pathProps:{d:'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var NeutralEmoji=exports.NeutralEmoji=function NeutralEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':|',pathProps:{d:'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var DissatisfiedEmoji=exports.DissatisfiedEmoji=function DissatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':(',pathProps:{d:'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var VeryDissatisfiedEmoji=exports.VeryDissatisfiedEmoji=function VeryDissatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:'X(',pathProps:{d:'M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z'}});};var VerySatisfiedEmoji=exports.VerySatisfiedEmoji=function VerySatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':D',pathProps:{d:'M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var ThumbsUpEmoji=exports.ThumbsUpEmoji=function ThumbsUpEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 0 24 24',width:'48',fallback:'+',pathProps:{d:'M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z'}});};var ThumbsDownEmoji=exports.ThumbsDownEmoji=function ThumbsDownEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 0 24 24',width:'48',fallback:'-',pathProps:{d:'M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z'}});};var CheckSVG=exports.CheckSVG=function CheckSVG(props){return renderSvgIcon({props:props,height:'16',viewBox:'0 0 16 12',width:'16',fallback:'v',pathProps:{d:'M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z'}});};var CancelSVG=exports.CancelSVG=function CancelSVG(props){var _a;return renderSvgIcon({props:props,height:'12',viewBox:'0 0 12 12',width:'12',fallback:'x',pathProps:{fillRule:'evenodd',clipRule:'evenodd',d:'M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z',fill:(_a=props.fill)!==null&&_a!==void 0?_a:'black'}});};var styles=(0,_safeStyleSheet.createSafeStyleSheet)({fallbackIcon:{textAlign:'center'}});
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.VerySatisfiedEmoji=exports.VeryDissatisfiedEmoji=exports.ThumbsUpEmoji=exports.ThumbsDownEmoji=exports.SatisfiedEmoji=exports.NeutralEmoji=exports.DissatisfiedEmoji=exports.CheckSVG=exports.CancelSVG=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _OptionalReactNativeSvg=require("../optional/OptionalReactNativeSvg");var _safeStyleSheet=require("./safeStyleSheet");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="txlemetry-react-native/dist/surveys/icons.js";function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var Svg=_OptionalReactNativeSvg.OptionalReactNativeSvg===null||_OptionalReactNativeSvg.OptionalReactNativeSvg===void 0?void 0:_OptionalReactNativeSvg.OptionalReactNativeSvg.Svg;var Path=_OptionalReactNativeSvg.OptionalReactNativeSvg===null||_OptionalReactNativeSvg.OptionalReactNativeSvg===void 0?void 0:_OptionalReactNativeSvg.OptionalReactNativeSvg.Path;var getFallbackSize=function getFallbackSize(value,fallback){if(typeof value==='number'){return value;}if(typeof value==='string'){var parsed=Number.parseInt(value,10);return Number.isNaN(parsed)?fallback:parsed;}return fallback;};var getFallbackColor=function getFallbackColor(fill){return typeof fill==='string'&&fill!=='none'?fill:'black';};var getFallbackFontSize=function getFallbackFontSize(label,height){return label.length>1?Math.round(height*0.55):height;};var renderFallbackIcon=function renderFallbackIcon(_ref){var label=_ref.label,fill=_ref.fill,height=_ref.height;return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.fallbackIcon,{color:getFallbackColor(fill),fontSize:getFallbackFontSize(label,height),height:height,lineHeight:height,width:height}],children:label});};var renderSvgIcon=function renderSvgIcon(_ref2){var props=_ref2.props,height=_ref2.height,width=_ref2.width,viewBox=_ref2.viewBox,pathProps=_ref2.pathProps,fallback=_ref2.fallback;var _a;if(!Svg||!Path){return renderFallbackIcon({label:fallback,fill:props.fill,height:getFallbackSize((_a=props.height)!==null&&_a!==void 0?_a:height,48)});}return(0,_jsxRuntime.jsx)(Svg,_objectSpread(_objectSpread({height:height,viewBox:viewBox,width:width},props),{},{children:(0,_jsxRuntime.jsx)(Path,_objectSpread({},pathProps))}));};var SatisfiedEmoji=exports.SatisfiedEmoji=function SatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':)',pathProps:{d:'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var NeutralEmoji=exports.NeutralEmoji=function NeutralEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':|',pathProps:{d:'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var DissatisfiedEmoji=exports.DissatisfiedEmoji=function DissatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':(',pathProps:{d:'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var VeryDissatisfiedEmoji=exports.VeryDissatisfiedEmoji=function VeryDissatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:'X(',pathProps:{d:'M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z'}});};var VerySatisfiedEmoji=exports.VerySatisfiedEmoji=function VerySatisfiedEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 -960 960 960',width:'48',fallback:':D',pathProps:{d:'M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z'}});};var ThumbsUpEmoji=exports.ThumbsUpEmoji=function ThumbsUpEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 0 24 24',width:'48',fallback:'+',pathProps:{d:'M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z'}});};var ThumbsDownEmoji=exports.ThumbsDownEmoji=function ThumbsDownEmoji(props){return renderSvgIcon({props:props,height:'48',viewBox:'0 0 24 24',width:'48',fallback:'-',pathProps:{d:'M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z'}});};var CheckSVG=exports.CheckSVG=function CheckSVG(props){return renderSvgIcon({props:props,height:'16',viewBox:'0 0 16 12',width:'16',fallback:'v',pathProps:{d:'M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z'}});};var CancelSVG=exports.CancelSVG=function CancelSVG(props){var _a;return renderSvgIcon({props:props,height:'12',viewBox:'0 0 12 12',width:'12',fallback:'x',pathProps:{fillRule:'evenodd',clipRule:'evenodd',d:'M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z',fill:(_a=props.fill)!==null&&_a!==void 0?_a:'black'}});};var styles=(0,_safeStyleSheet.createSafeStyleSheet)({fallbackIcon:{textAlign:'center'}});
|
package/dist/surveys/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
export { SurveyModal } from './components/SurveyModal';
|
|
4
|
-
export type { SurveyModalProps } from './components/SurveyModal';
|
|
5
|
-
export type { Survey, SurveyAppearance } from '@txlemetry/core';
|
|
6
|
-
export { Questions } from './components/Surveys';
|
|
1
|
+
export { TxlemetrySurveyProvider } from './TxlemetrySurveyProvider';
|
|
2
|
+
export type { TxlemetrySurveyProviderProps } from './TxlemetrySurveyProvider';
|
|
3
|
+
export { SurveyModal } from './components/SurveyModal';
|
|
4
|
+
export type { SurveyModalProps } from './components/SurveyModal';
|
|
5
|
+
export type { Survey, SurveyAppearance } from '@txlemetry/core';
|
|
6
|
+
export { Questions } from './components/Surveys';
|
package/dist/surveys/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Questions",{enumerable:true,get:function get(){return _Surveys.Questions;}});Object.defineProperty(exports,"SurveyModal",{enumerable:true,get:function get(){return _SurveyModal.SurveyModal;}});Object.defineProperty(exports,"TxlemetrySurveyProvider",{enumerable:true,get:function get(){return _TxlemetrySurveyProvider.TxlemetrySurveyProvider;}});var _TxlemetrySurveyProvider=require("./TxlemetrySurveyProvider");var _SurveyModal=require("./components/SurveyModal");var _Surveys=require("./components/Surveys");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
/**
|
|
3
|
-
* `StyleSheet.create` that returns the raw style map when the React Native
|
|
4
|
-
* `StyleSheet` runtime is unavailable (e.g. Jest `testEnvironment: node` without
|
|
5
|
-
* the RN preset), instead of throwing at import.
|
|
6
|
-
* See https://github.com/PostHog/posthog-js/issues/3740.
|
|
7
|
-
*/
|
|
8
|
-
export declare const createSafeStyleSheet: <T extends StyleSheet.NamedStyles<T>>(styles: T) => T;
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* `StyleSheet.create` that returns the raw style map when the React Native
|
|
4
|
+
* `StyleSheet` runtime is unavailable (e.g. Jest `testEnvironment: node` without
|
|
5
|
+
* the RN preset), instead of throwing at import.
|
|
6
|
+
* See https://github.com/PostHog/posthog-js/issues/3740.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createSafeStyleSheet: <T extends StyleSheet.NamedStyles<T>>(styles: T) => T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Survey } from '@txlemetry/core';
|
|
2
|
-
import {
|
|
3
|
-
export declare function detectUserLanguage(instance:
|
|
4
|
-
export declare function applySurveyTranslationForUser(survey: Survey, instance:
|
|
5
|
-
survey: Survey;
|
|
6
|
-
language: string | null;
|
|
7
|
-
};
|
|
1
|
+
import { Survey } from '@txlemetry/core';
|
|
2
|
+
import { Txlemetry } from '../txlemetry-rn';
|
|
3
|
+
export declare function detectUserLanguage(instance: Txlemetry): string | null;
|
|
4
|
+
export declare function applySurveyTranslationForUser(survey: Survey, instance: Txlemetry): {
|
|
5
|
+
survey: Survey;
|
|
6
|
+
language: string | null;
|
|
7
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.applySurveyTranslationForUser=applySurveyTranslationForUser;exports.detectUserLanguage=detectUserLanguage;var _core=require("@txlemetry/core");var _surveys=require("@txlemetry/core/surveys");var logger=(0,_core.createLogger)('[SurveyTranslations]');function getLogger(instance){return instance.isDebug?logger:undefined;}function detectUserLanguage(instance){return(0,_surveys.detectSurveyLanguage)({overrideLanguage:instance.getSurveyDisplayLanguageOverride(),storedPersonProperties:instance.getPersistedProperty(_core.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.applySurveyTranslationForUser=applySurveyTranslationForUser;exports.detectUserLanguage=detectUserLanguage;var _core=require("@txlemetry/core");var _surveys=require("@txlemetry/core/surveys");var logger=(0,_core.createLogger)('[SurveyTranslations]');function getLogger(instance){return instance.isDebug?logger:undefined;}function detectUserLanguage(instance){return(0,_surveys.detectSurveyLanguage)({overrideLanguage:instance.getSurveyDisplayLanguageOverride(),storedPersonProperties:instance.getPersistedProperty(_core.TxlemetryPersistedProperty.PersonProperties),locale:instance.getCommonEventProperties().$locale},getLogger(instance));}function applySurveyTranslationForUser(survey,instance){var userLanguage=detectUserLanguage(instance);var logger=getLogger(instance);if(!userLanguage){logger===null||logger===void 0?void 0:logger.info('No user language detected');return{survey:survey,language:null};}var result=(0,_surveys.applySurveyTranslation)(survey,userLanguage,logger);return{survey:result.survey,language:result.matchedKey};}
|