@wavemaker/app-rn-runtime 11.14.1-18.6459 → 11.14.1-19.6462
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/components/basic/bottomsheet/bottomsheet.component.js +0 -12
- package/components/basic/bottomsheet/bottomsheet.component.js.map +1 -1
- package/components/basic/progress-circle/progress-circle.component.js +3 -3
- package/components/basic/progress-circle/progress-circle.component.js.map +1 -1
- package/components/chart/area-chart/area-chart.component.js +9 -26
- package/components/chart/area-chart/area-chart.component.js.map +1 -1
- package/components/chart/bar-chart/bar-chart.component.js +6 -38
- package/components/chart/bar-chart/bar-chart.component.js.map +1 -1
- package/components/chart/bar-chart/bar-chart.props.js +0 -1
- package/components/chart/bar-chart/bar-chart.props.js.map +1 -1
- package/components/chart/basechart.component.js +15 -8
- package/components/chart/basechart.component.js.map +1 -1
- package/components/chart/basechart.props.js +0 -1
- package/components/chart/basechart.props.js.map +1 -1
- package/components/chart/bubble-chart/bubble-chart.component.js +5 -22
- package/components/chart/bubble-chart/bubble-chart.component.js.map +1 -1
- package/components/chart/line-chart/line-chart.component.js +5 -22
- package/components/chart/line-chart/line-chart.component.js.map +1 -1
- package/components/chart/pie-chart/pie-chart.component.js +3 -14
- package/components/chart/pie-chart/pie-chart.component.js.map +1 -1
- package/components/container/tabs/tabs.component.js +29 -62
- package/components/container/tabs/tabs.component.js.map +1 -1
- package/components/container/tabs/tabs.props.js +0 -1
- package/components/container/tabs/tabs.props.js.map +1 -1
- package/components/container/wizard/wizard.component.js +1 -1
- package/components/container/wizard/wizard.component.js.map +1 -1
- package/components/container/wizard/wizard.props.js +1 -0
- package/components/container/wizard/wizard.props.js.map +1 -1
- package/components/container/wizard/wizardstep/wizardstep.component.js +2 -2
- package/components/container/wizard/wizardstep/wizardstep.component.js.map +1 -1
- package/components/data/form/form-field/form-field.component.js +0 -1
- package/components/data/form/form-field/form-field.component.js.map +1 -1
- package/components/data/form/form-field/form-field.props.js +0 -1
- package/components/data/form/form-field/form-field.props.js.map +1 -1
- package/components/data/form/form.component.js +1 -4
- package/components/data/form/form.component.js.map +1 -1
- package/components/dialogs/dialogcontent/dialogcontent.component.js +2 -1
- package/components/dialogs/dialogcontent/dialogcontent.component.js.map +1 -1
- package/components/input/baseinput/baseinput.component.js +3 -21
- package/components/input/baseinput/baseinput.component.js.map +1 -1
- package/components/input/baseinput/baseinput.props.js +0 -1
- package/components/input/baseinput/baseinput.props.js.map +1 -1
- package/components/input/basenumber/basenumber.component.js +3 -18
- package/components/input/basenumber/basenumber.component.js.map +1 -1
- package/components/input/basenumber/basenumber.props.js +0 -1
- package/components/input/basenumber/basenumber.props.js.map +1 -1
- package/components/input/checkboxset/checkboxset.component.js +1 -1
- package/components/input/checkboxset/checkboxset.component.js.map +1 -1
- package/components/input/currency/currency.component.js +0 -2
- package/components/input/currency/currency.component.js.map +1 -1
- package/components/input/currency/currency.styles.js +1 -10
- package/components/input/currency/currency.styles.js.map +1 -1
- package/components/input/number/number.component.js +0 -2
- package/components/input/number/number.component.js.map +1 -1
- package/components/input/number/number.styles.js +0 -4
- package/components/input/number/number.styles.js.map +1 -1
- package/components/input/radioset/radioset.component.js +6 -3
- package/components/input/radioset/radioset.component.js.map +1 -1
- package/components/input/text/text.component.js +0 -2
- package/components/input/text/text.component.js.map +1 -1
- package/components/input/text/text.props.js +1 -0
- package/components/input/text/text.props.js.map +1 -1
- package/components/input/text/text.styles.js +0 -17
- package/components/input/text/text.styles.js.map +1 -1
- package/components/input/textarea/textarea.component.js +0 -1
- package/components/input/textarea/textarea.component.js.map +1 -1
- package/components/input/textarea/textarea.styles.js +0 -4
- package/components/input/textarea/textarea.styles.js.map +1 -1
- package/components/navigation/popover/popover.component.js +3 -3
- package/components/navigation/popover/popover.component.js.map +1 -1
- package/core/AppConfig.js.map +1 -1
- package/core/advanced-promise-rejection-tracker.js +207 -0
- package/core/advanced-promise-rejection-tracker.js.map +1 -0
- package/core/base.component.js +5 -0
- package/core/base.component.js.map +1 -1
- package/core/components/error-fallback/error-fallback.component.js +50 -18
- package/core/components/error-fallback/error-fallback.component.js.map +1 -1
- package/core/components/error-fallback/error-fallback.styles.js +4 -1
- package/core/components/error-fallback/error-fallback.styles.js.map +1 -1
- package/core/components/textinput.component.js +4 -25
- package/core/components/textinput.component.js.map +1 -1
- package/core/error-boundary.component.js +46 -2
- package/core/error-boundary.component.js.map +1 -1
- package/core/fixed-view.component.js +2 -19
- package/core/fixed-view.component.js.map +1 -1
- package/core/global-error-handler.service.js +177 -0
- package/core/global-error-handler.service.js.map +1 -0
- package/core/tappable.component.js +1 -1
- package/core/tappable.component.js.map +1 -1
- package/core/viewport.js +8 -13
- package/core/viewport.js.map +1 -1
- package/gestures/carousel-swipe.animation.js +1 -0
- package/gestures/carousel-swipe.animation.js.map +1 -1
- package/npm-shrinkwrap.json +13 -13
- package/package-lock.json +13 -13
- package/package.json +2 -2
- package/runtime/App.js +174 -12
- package/runtime/App.js.map +1 -1
- package/runtime/base-page.component.js +11 -2
- package/runtime/base-page.component.js.map +1 -1
- package/runtime/navigator/stack.navigator.js +6 -0
- package/runtime/navigator/stack.navigator.js.map +1 -1
- package/styles/theme.js +0 -6
- package/styles/theme.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useRef","useState","Animated","Platform","Text","TextInput","View","isArray","IMask","FloatingLabel","WmCursor","memo","props","opacityAnimation","Value","current","runAnimation","timing","toValue","duration","useNativeDriver","start","createElement","testID","style","backgroundColor","color","width","marginHorizontal","height","opacity","applyAutoCapitalize","text","mode","toUpperCase","replace","c","WMTextInput","forwardRef","ref","_props$customDisplayV","_props$floatingLabel","selectRange","setSelectRange","iMask","setIMask","displayCursor","setDisplayCursor","value","x","forceUpdate","displayValue","setDisplayValue","element","displayformat","MaskedPattern","mask","skipInvalid","lazy","definitions","typedValue","defaultValue","onChangeText","setTimeout","OS","maskchar","_element$current","setSelectionRange","length","onSelectionChange","e","_e$nativeEvent","selection","nativeEvent","allowContentSelection","end","_value","substring","slice","formattedValue","valueExpr","opts","customDisplayValue","textStyle","Object","assign","hideInput","Fragment","background","floatingLabel","moveUp","isInputFocused","label","placeholder","floatingLabelStyle","activeFloatingLabelStyle","inactiveFloatingLabelStyle","editable","_extends","borderColor","zIndex","autoCapitalize","textTransform","placeholderTextColor","selectable","disabled","multiline","numberOfLines","maxLength","undefined","onFocus","_props$onFocus","call","target","onBlur","_props$onBlur","caretHidden","selectionColor","cursorColor","onChange","contextMenuHidden","onLayout","handleLayout","display","flexDirection","alignItems","marginTop","minHeight","padding","fontFamily","fontSize","fontWeight"],"sources":["textinput.component.tsx"],"sourcesContent":["import React, { ForwardedRef, useCallback, useEffect, useRef, useState } from 'react';\nimport { Animated, Platform, Text, TextInput, TextInputProps, TextStyle, View, ViewStyle } from 'react-native';\nimport { isArray } from 'lodash';\nimport IMask from 'imask';\nimport { FloatingLabel } from './floatinglabel.component';\n\ninterface SelectRange {\n start: number,\n end: number\n}\n\nconst WmCursor = React.memo((props: {\n color: string,\n height: number\n}) => {\n const opacityAnimation = useRef(new Animated.Value(0.5)).current;\n const runAnimation = useCallback(() => {\n Animated.timing(opacityAnimation, {\n toValue: 0.2,\n duration: 500,\n useNativeDriver: true\n }).start(() => {\n Animated.timing(opacityAnimation, {\n toValue: 0.6,\n duration: 500,\n useNativeDriver: true\n }).start(runAnimation);\n });\n }, []);\n useEffect(() => {\n runAnimation();\n }, []);\n return (\n <Animated.View \n testID=\"wm-custom-cursor\"\n style={{\n backgroundColor: props.color,\n width: 2,\n marginHorizontal: 1,\n height: props.height,\n opacity: opacityAnimation\n }}></Animated.View>\n );\n});\n\n// TODO: Monika WMS-31071 - Consider these improvements:\n// 1. 'words' mode: Use full Title Case regex: text.replace(/\\b\\w+/g, word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n// 2. 'sentences' mode: Add newline handling with regex: /(^|\\.\\s+|\\!\\s+|\\?\\s+|\\n\\s*)(\\w)/g\n// 3. Add TypeScript type for mode: type AutoCapitalizeMode = 'none' | 'sentences' | 'words' | 'characters'\nconst applyAutoCapitalize = (text: string, mode: string): string => {\n switch (mode) {\n case 'characters':\n return text.toUpperCase();\n case 'words':\n return text.replace(/\\b\\w/g, c => c.toUpperCase());\n case 'sentences':\n return text.replace(/(^\\w|[.!?]\\s+\\w)/g, c => c.toUpperCase());\n default:\n return text;\n }\n};\n\nexport const WMTextInput = React.forwardRef((props: (TextInputProps & \n {allowContentSelection: boolean,\n displayformat: string,\n maskchar: string,\n floatingLabel: string\n floatingLabelStyle: TextStyle & ViewStyle,\n activeFloatingLabelStyle: TextStyle & ViewStyle,\n inactiveFloatingLabelStyle?: TextStyle & ViewStyle,\n customDisplayValue?: string,\n isInputFocused: boolean,\n autoCapitalize?: string,\n background?: React.ReactNode,\n handleLayout?: any,\n style?: ViewStyle\n }), \n ref: ForwardedRef<TextInput>) => {\n const [selectRange, setSelectRange] = useState<SelectRange>(null as any);\n const [iMask, setIMask] = useState(null as any);\n const [displayCursor, setDisplayCursor] = useState(false);\n const value = useRef(props.value || '');\n const [x, forceUpdate] = useState(1);\n const [displayValue, setDisplayValue] = useState('');\n const element = useRef(null as any);\n // iMask initialization\n useEffect(() => {\n const iMask: any = props.displayformat ? new IMask.MaskedPattern({\n mask: props.displayformat,\n skipInvalid: true,\n lazy: false,\n definitions: {\n '9': /\\d/,\n 'A': /[a-zA-Z]/,\n 'a': /[a-z]/,\n '*': /\\w/\n }\n }) : null;\n if (iMask) {\n iMask.typedValue = value;\n setDisplayValue(iMask.displayValue)\n setIMask(iMask);\n }\n },[props.displayformat]);\n // set default value\n useEffect(() => {\n const defaultValue = props.defaultValue || props.value || '';\n if (defaultValue && !value.current) {\n value.current = defaultValue;\n onChangeText(defaultValue);\n }\n },[props.defaultValue, props.value]);\n // set cursor position in windows\n useEffect(() => {\n setTimeout(() => {\n if (Platform.OS === 'web' && (props.displayformat || props.maskchar)) {\n element?.current?.setSelectionRange(value.current.length, value.current.length);\n }\n }, 100);\n }, [value.current, props]);\n const onSelectionChange = useCallback((e: any) => {\n if (Platform.OS !== 'android') {\n return;\n }\n const selection = e?.nativeEvent?.selection;\n if (!props.allowContentSelection\n && selection\n && selection.end - selection.start > 0) {\n setSelectRange({\n start: value.current.length + 2,\n end: value.current.length + 2\n });\n } else if (selectRange && selectRange.end > 0){\n setSelectRange(null as any);\n }\n }, [props.allowContentSelection, value]);\n // when text changes\n const onChangeText = useCallback((text: string) => {\n if (!(iMask || props.maskchar)) {\n value.current = text;\n props.onChangeText && props.onChangeText(text);\n return;\n }\n let _value = value.current || '';\n if (value.current.length - text.length > 0) {\n _value = _value.substring(0, _value.length - (value.current.length - text.length));\n } else if (text.length - value.current.length > 0) {\n _value += text.slice(-1 * (text.length - value.current.length));\n }\n let formattedValue = _value;\n if(props.maskchar) {\n formattedValue = (_value.replace(/./g, props.maskchar));\n }\n if (iMask) {\n iMask.typedValue = _value;\n formattedValue = iMask.displayValue;\n }\n if (formattedValue !== displayValue) {\n value.current = _value;\n props.onChangeText && props.onChangeText(_value);\n }\n forceUpdate(x+ 1);\n setDisplayValue(formattedValue);\n }, [iMask, value, displayValue, props.onChangeText]);\n const valueExpr = Platform.OS === 'web' ? 'value' : 'defaultValue';\n const opts = {} as any;\n opts[valueExpr] = props.customDisplayValue ?? value.current;\n const textStyle = Object.assign({}, ...isArray(props.style) ? props.style: [props.style]);\n const hideInput = props.displayformat || props.maskchar;\n return (\n <>\n {props.background}\n {props.floatingLabel ? (\n <FloatingLabel\n moveUp={!!(value.current || props.isInputFocused || displayValue)}\n label={props.floatingLabel ?? props.placeholder} \n style={{\n ...(props.floatingLabelStyle || []),\n ...(props.isInputFocused \n ? (props.activeFloatingLabelStyle || {}) \n : (value.current || displayValue) \n ? (props.inactiveFloatingLabelStyle || {}) \n : {}\n )\n }}/>\n ) : null}\n {(Platform.OS === 'android' && !props.editable) ? (\n <Text \n style={[\n props.style, hideInput ? {\n color: 'transparent', \n backgroundColor: 'transparent',\n borderColor: 'transparent',\n zIndex: 1\n } : {},\n props.autoCapitalize ? {textTransform: 'capitalize'} : {},\n (!props.defaultValue && props.placeholder) ? { color: props.placeholderTextColor} : {}\n ]}\n selectable={false}\n disabled={true}\n {...(props.multiline) ? {numberOfLines: props.numberOfLines} : {}}\n >{props.defaultValue || props.placeholder}</Text>\n ) :\n (<TextInput\n {...props}\n {...hideInput || props.customDisplayValue ? opts: {}}\n {...((props.maxLength !== null) ? { maxLength: props.maxLength } : { maxLength: undefined })}\n placeholder={props.floatingLabel || displayValue ? '' : props.placeholder }\n style={[props.style, hideInput ? {\n color: 'transparent', \n backgroundColor: 'transparent',\n borderColor: 'transparent',\n zIndex: 1\n } : {}]}\n onFocus={(e) => {\n props.onFocus?.(e);\n setDisplayCursor(true);\n element.current = e.target;\n }}\n onBlur={(e) => {\n props?.onBlur?.(e);\n setDisplayCursor(false);\n }}\n ref={ref}\n selection={selectRange}\n onSelectionChange={onSelectionChange}\n caretHidden={!!selectRange?.end}\n onChangeText={(text) => {\n if(Platform.OS === 'web' && props.autoCapitalize && props.autoCapitalize !== 'none') {\n onChangeText(applyAutoCapitalize(text, props.autoCapitalize));\n return;\n }\n onChangeText(text);\n }}\n {...hideInput ? {\n selectionColor: 'transparent',\n cursorColor: 'transparent',\n onChange : () => {}\n }: {}}\n contextMenuHidden={!props.allowContentSelection}\n autoCapitalize={props.autoCapitalize}\n onLayout={props.handleLayout}\n numberOfLines={1}\n >\n </TextInput>)\n }\n {\n hideInput ? (\n <View style={[props.style, {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n marginTop: -1 * (textStyle.height || textStyle.minHeight || 0)\n + (textStyle.marginTop || 0)}]}>\n <Text style={{ \n width: undefined,\n backgroundColor: 'transparent', \n borderColor: 'transparent',\n padding: 0,\n display: 'flex',\n color: textStyle.color,\n fontFamily: textStyle.fontFamily,\n fontSize: textStyle.fontSize,\n fontWeight: textStyle.fontWeight\n }}>\n {displayValue}\n </Text>\n {\n (displayCursor && !props.displayformat) ? React.createElement(WmCursor, {\n color: textStyle.color || '#000000',\n height: textStyle.fontSize || 14\n }) : null\n }\n </View>\n ) : null\n }\n </>\n );\n});\n"],"mappings":";AAAA,OAAOA,KAAK,IAAkBC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACrF,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAA6BC,IAAI,QAAmB,cAAc;AAC9G,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,2BAA2B;AAOzD,MAAMC,QAAQ,gBAAGb,KAAK,CAACc,IAAI,CAAEC,KAG5B,IAAK;EACJ,MAAMC,gBAAgB,GAAGb,MAAM,CAAC,IAAIE,QAAQ,CAACY,KAAK,CAAC,GAAG,CAAC,CAAC,CAACC,OAAO;EAChE,MAAMC,YAAY,GAAGlB,WAAW,CAAC,MAAM;IACrCI,QAAQ,CAACe,MAAM,CAACJ,gBAAgB,EAAE;MAChCK,OAAO,EAAE,GAAG;MACZC,QAAQ,EAAE,GAAG;MACbC,eAAe,EAAE;IACnB,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM;MACbnB,QAAQ,CAACe,MAAM,CAACJ,gBAAgB,EAAE;QAChCK,OAAO,EAAE,GAAG;QACZC,QAAQ,EAAE,GAAG;QACbC,eAAe,EAAE;MACnB,CAAC,CAAC,CAACC,KAAK,CAACL,YAAY,CAAC;IACxB,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EACNjB,SAAS,CAAC,MAAM;IACdiB,YAAY,CAAC,CAAC;EAChB,CAAC,EAAE,EAAE,CAAC;EACN,oBACEnB,KAAA,CAAAyB,aAAA,CAACpB,QAAQ,CAACI,IAAI;IACdiB,MAAM,EAAC,kBAAkB;IACzBC,KAAK,EAAE;MACLC,eAAe,EAAEb,KAAK,CAACc,KAAK;MAC5BC,KAAK,EAAE,CAAC;M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7Bf,aAAa,EAAE;EAAE,EAER,CAAE,EAGfrB,SAAS,gBACPzF,KAAA,CAAAyB,aAAA,CAAChB,IAAI;IAACkB,KAAK,EAAE,CAACZ,KAAK,CAACY,KAAK,EAAE;MACzBmG,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,UAAU,EAAE,QAAQ;MACpBC,SAAS,EAAE,CAAC,CAAC,IAAI3C,SAAS,CAACtD,MAAM,IAAIsD,SAAS,CAAC4C,SAAS,IAAI,CAAC,CAAC,IACzD5C,SAAS,CAAC2C,SAAS,IAAI,CAAC;IAAC,CAAC;EAAE,gBACjCjI,KAAA,CAAAyB,aAAA,CAAClB,IAAI;IAACoB,KAAK,EAAE;MACXG,KAAK,EAAEkF,SAAS;MAChBpF,eAAe,EAAE,aAAa;MAC9B0E,WAAW,EAAE,aAAa;MAC1B6B,OAAO,EAAE,CAAC;MACVL,OAAO,EAAE,MAAM;MACfjG,KAAK,EAAEyD,SAAS,CAACzD,KAAK;MACtBuG,UAAU,EAAE9C,SAAS,CAAC8C,UAAU;MAChCC,QAAQ,EAAE/C,SAAS,CAAC+C,QAAQ;MAC5BC,UAAU,EAAEhD,SAAS,CAACgD;IACtB;EAAE,GACDhF,YACG,CAAC,EAEJL,aAAa,IAAI,CAAClC,KAAK,CAAC0C,aAAa,gBAAIzD,KAAK,CAACyB,aAAa,CAACZ,QAAQ,EAAE;IACtEgB,KAAK,EAAEyD,SAAS,CAACzD,KAAK,IAAI,SAAS;IACnCG,MAAM,EAAEsD,SAAS,CAAC+C,QAAQ,IAAI;EAChC,CAAC,CAAC,GAAG,IAEH,CAAC,GACL,IAEN,CAAC;AAET,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useRef","useState","Animated","Platform","Text","TextInput","View","isArray","IMask","FloatingLabel","WmCursor","memo","props","opacityAnimation","Value","current","runAnimation","timing","toValue","duration","useNativeDriver","start","createElement","testID","style","backgroundColor","color","width","marginHorizontal","height","opacity","WMTextInput","forwardRef","ref","_props$customDisplayV","_props$floatingLabel","selectRange","setSelectRange","iMask","setIMask","displayCursor","setDisplayCursor","value","x","forceUpdate","displayValue","setDisplayValue","element","displayformat","MaskedPattern","mask","skipInvalid","lazy","definitions","typedValue","defaultValue","onChangeText","setTimeout","OS","maskchar","_element$current","setSelectionRange","length","onSelectionChange","e","_e$nativeEvent","selection","nativeEvent","allowContentSelection","end","text","_value","substring","slice","formattedValue","replace","valueExpr","opts","customDisplayValue","textStyle","Object","assign","hideInput","Fragment","background","floatingLabel","moveUp","isInputFocused","label","placeholder","floatingLabelStyle","activeFloatingLabelStyle","editable","_extends","borderColor","zIndex","autoCapitalize","textTransform","placeholderTextColor","selectable","disabled","multiline","numberOfLines","onFocus","_props$onFocus","call","target","onBlur","_props$onBlur","caretHidden","toUpperCase","selectionColor","cursorColor","onChange","contextMenuHidden","onLayout","handleLayout","display","flexDirection","alignItems","marginTop","minHeight","undefined","padding","fontFamily","fontSize","fontWeight"],"sources":["textinput.component.tsx"],"sourcesContent":["import React, { ForwardedRef, useCallback, useEffect, useRef, useState } from 'react';\nimport { Animated, Platform, Text, TextInput, TextInputProps, TextStyle, View, ViewStyle } from 'react-native';\nimport { isArray } from 'lodash';\nimport IMask from 'imask';\nimport { FloatingLabel } from './floatinglabel.component';\n\ninterface SelectRange {\n start: number,\n end: number\n}\n\nconst WmCursor = React.memo((props: {\n color: string,\n height: number\n}) => {\n const opacityAnimation = useRef(new Animated.Value(0.5)).current;\n const runAnimation = useCallback(() => {\n Animated.timing(opacityAnimation, {\n toValue: 0.2,\n duration: 500,\n useNativeDriver: true\n }).start(() => {\n Animated.timing(opacityAnimation, {\n toValue: 0.6,\n duration: 500,\n useNativeDriver: true\n }).start(runAnimation);\n });\n }, []);\n useEffect(() => {\n runAnimation();\n }, []);\n return (\n <Animated.View \n testID=\"wm-custom-cursor\"\n style={{\n backgroundColor: props.color,\n width: 2,\n marginHorizontal: 1,\n height: props.height,\n opacity: opacityAnimation\n }}></Animated.View>\n );\n});\n\nexport const WMTextInput = React.forwardRef((props: (TextInputProps & \n {allowContentSelection: boolean,\n displayformat: string,\n maskchar: string,\n floatingLabel: string\n floatingLabelStyle: TextStyle & ViewStyle,\n activeFloatingLabelStyle: TextStyle & ViewStyle,\n customDisplayValue?: string,\n isInputFocused: boolean,\n autoCapitalize?: string,\n background?: React.ReactNode,\n handleLayout?: any,\n style?: ViewStyle\n }), \n ref: ForwardedRef<TextInput>) => {\n const [selectRange, setSelectRange] = useState<SelectRange>(null as any);\n const [iMask, setIMask] = useState(null as any);\n const [displayCursor, setDisplayCursor] = useState(false);\n const value = useRef(props.value || '');\n const [x, forceUpdate] = useState(1);\n const [displayValue, setDisplayValue] = useState('');\n const element = useRef(null as any);\n // iMask initialization\n useEffect(() => {\n const iMask: any = props.displayformat ? new IMask.MaskedPattern({\n mask: props.displayformat,\n skipInvalid: true,\n lazy: false,\n definitions: {\n '9': /\\d/,\n 'A': /[a-zA-Z]/,\n 'a': /[a-z]/,\n '*': /\\w/\n }\n }) : null;\n if (iMask) {\n iMask.typedValue = value;\n setDisplayValue(iMask.displayValue)\n setIMask(iMask);\n }\n },[props.displayformat]);\n // set default value\n useEffect(() => {\n const defaultValue = props.defaultValue || props.value || '';\n if (defaultValue && !value.current) {\n value.current = defaultValue;\n onChangeText(defaultValue);\n }\n },[props.defaultValue, props.value]);\n // set cursor position in windows\n useEffect(() => {\n setTimeout(() => {\n if (Platform.OS === 'web' && (props.displayformat || props.maskchar)) {\n element?.current?.setSelectionRange(value.current.length, value.current.length);\n }\n }, 100);\n }, [value.current, props]);\n const onSelectionChange = useCallback((e: any) => {\n if (Platform.OS !== 'android') {\n return;\n }\n const selection = e?.nativeEvent?.selection;\n if (!props.allowContentSelection\n && selection\n && selection.end - selection.start > 0) {\n setSelectRange({\n start: value.current.length + 2,\n end: value.current.length + 2\n });\n } else if (selectRange && selectRange.end > 0){\n setSelectRange(null as any);\n }\n }, [props.allowContentSelection, value]);\n // when text changes\n const onChangeText = useCallback((text: string) => {\n if (!(iMask || props.maskchar)) {\n value.current = text;\n props.onChangeText && props.onChangeText(text);\n return;\n }\n let _value = value.current || '';\n if (value.current.length - text.length > 0) {\n _value = _value.substring(0, _value.length - (value.current.length - text.length));\n } else if (text.length - value.current.length > 0) {\n _value += text.slice(-1 * (text.length - value.current.length));\n }\n let formattedValue = _value;\n if(props.maskchar) {\n formattedValue = (_value.replace(/./g, props.maskchar));\n }\n if (iMask) {\n iMask.typedValue = _value;\n formattedValue = iMask.displayValue;\n }\n if (formattedValue !== displayValue) {\n value.current = _value;\n props.onChangeText && props.onChangeText(_value);\n }\n forceUpdate(x+ 1);\n setDisplayValue(formattedValue);\n }, [iMask, value, displayValue, props.onChangeText]);\n const valueExpr = Platform.OS === 'web' ? 'value' : 'defaultValue';\n const opts = {} as any;\n opts[valueExpr] = props.customDisplayValue ?? value.current;\n const textStyle = Object.assign({}, ...isArray(props.style) ? props.style: [props.style]);\n const hideInput = props.displayformat || props.maskchar;\n return (\n <>\n {props.background}\n {props.floatingLabel ? (\n <FloatingLabel\n moveUp={!!(value.current || props.isInputFocused || displayValue)}\n label={props.floatingLabel ?? props.placeholder} \n style={{\n ...(props.floatingLabelStyle || []),\n ...(props.isInputFocused ? (props.activeFloatingLabelStyle || {}) : {})\n }}/>\n ) : null}\n {(Platform.OS === 'android' && !props.editable) ? (\n <Text \n style={[\n props.style, hideInput ? {\n color: 'transparent', \n backgroundColor: 'transparent',\n borderColor: 'transparent',\n zIndex: 1\n } : {},\n props.autoCapitalize ? {textTransform: 'capitalize'} : {},\n (!props.defaultValue && props.placeholder) ? { color: props.placeholderTextColor} : {}\n ]}\n selectable={false}\n disabled={true}\n {...(props.multiline) ? {numberOfLines: props.numberOfLines} : {}}\n >{props.defaultValue || props.placeholder}</Text>\n ) :\n (<TextInput\n {...props}\n {...hideInput || props.customDisplayValue ? opts: {}}\n placeholder={props.floatingLabel || displayValue ? '' : props.placeholder }\n style={[props.style, hideInput ? {\n color: 'transparent', \n backgroundColor: 'transparent',\n borderColor: 'transparent',\n zIndex: 1\n } : {}]}\n onFocus={(e) => {\n props.onFocus?.(e);\n setDisplayCursor(true);\n element.current = e.target;\n }}\n onBlur={(e) => {\n props?.onBlur?.(e);\n setDisplayCursor(false);\n }}\n ref={ref}\n selection={selectRange}\n onSelectionChange={onSelectionChange}\n caretHidden={!!selectRange?.end}\n onChangeText={(text) => {\n if(props.autoCapitalize && props.autoCapitalize === 'characters') {\n onChangeText(text.toUpperCase());\n return;\n }\n onChangeText(text);\n }}\n {...hideInput ? {\n selectionColor: 'transparent',\n cursorColor: 'transparent',\n onChange : () => {}\n }: {}}\n contextMenuHidden={!props.allowContentSelection}\n autoCapitalize={props.autoCapitalize}\n onLayout={props.handleLayout}\n numberOfLines={1}\n >\n </TextInput>)\n }\n {\n hideInput ? (\n <View style={[props.style, {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n marginTop: -1 * (textStyle.height || textStyle.minHeight || 0)\n + (textStyle.marginTop || 0)}]}>\n <Text style={{ \n width: undefined,\n backgroundColor: 'transparent', \n borderColor: 'transparent',\n padding: 0,\n display: 'flex',\n color: textStyle.color,\n fontFamily: textStyle.fontFamily,\n fontSize: textStyle.fontSize,\n fontWeight: textStyle.fontWeight\n }}>\n {displayValue}\n </Text>\n {\n (displayCursor && !props.displayformat) ? React.createElement(WmCursor, {\n color: textStyle.color || '#000000',\n height: textStyle.fontSize || 14\n }) : null\n }\n </View>\n ) : null\n }\n </>\n );\n});\n"],"mappings":";AAAA,OAAOA,KAAK,IAAkBC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACrF,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAA6BC,IAAI,QAAmB,cAAc;AAC9G,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,2BAA2B;AAO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t; var e =
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import Fallback from './components/error-fallback/error-fallback.component';
|
|
6
6
|
import appModalService from '@wavemaker/app-rn-runtime/runtime/services/app-modal.service';
|
|
7
|
+
import injector from '@wavemaker/app-rn-runtime/core/injector';
|
|
7
8
|
export default class ErrorBoundary extends React.Component {
|
|
8
9
|
constructor(props) {
|
|
9
10
|
super(props);
|
|
@@ -19,11 +20,48 @@ export default class ErrorBoundary extends React.Component {
|
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
static getDerivedStateFromError(error) {
|
|
23
|
+
// Check preferences before setting error state
|
|
24
|
+
const appConfig = injector.get('APP_CONFIG');
|
|
25
|
+
const prefs = appConfig === null || appConfig === void 0 ? void 0 : appConfig.preferences;
|
|
26
|
+
const globalEnabled = (prefs === null || prefs === void 0 ? void 0 : prefs.enableGlobalErrorHandler) === true;
|
|
27
|
+
const renderEnabled = (prefs === null || prefs === void 0 ? void 0 : prefs.enableRenderErrors) !== false;
|
|
28
|
+
|
|
29
|
+
// Only set hasError if error handling is enabled
|
|
30
|
+
if (!globalEnabled || !renderEnabled) {
|
|
31
|
+
return {
|
|
32
|
+
hasError: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
22
35
|
return {
|
|
23
36
|
hasError: true
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
39
|
componentDidCatch(error, info) {
|
|
40
|
+
// Check if error handling is enabled
|
|
41
|
+
const appConfig = injector.get('APP_CONFIG');
|
|
42
|
+
const prefs = appConfig === null || appConfig === void 0 ? void 0 : appConfig.preferences;
|
|
43
|
+
const globalEnabled = (prefs === null || prefs === void 0 ? void 0 : prefs.enableGlobalErrorHandler) === true;
|
|
44
|
+
const renderEnabled = (prefs === null || prefs === void 0 ? void 0 : prefs.enableRenderErrors) !== false;
|
|
45
|
+
|
|
46
|
+
// Only catch if both master switch and render errors are enabled
|
|
47
|
+
if (!globalEnabled || !renderEnabled) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Trigger user error callback if app instance is available
|
|
52
|
+
let appInstance = this.props.app;
|
|
53
|
+
|
|
54
|
+
// Fallback: try to get app instance from injector if prop is not available
|
|
55
|
+
if (!appInstance) {
|
|
56
|
+
appInstance = injector.get('APP_INSTANCE');
|
|
57
|
+
}
|
|
58
|
+
if (appInstance && appInstance.triggerOnError) {
|
|
59
|
+
try {
|
|
60
|
+
appInstance.triggerOnError(error, info, 'render');
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error('Error calling triggerOnError:', e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
27
65
|
if (error && appModalService.modalsOpened.length > 0) {
|
|
28
66
|
appModalService.modalsOpened.pop();
|
|
29
67
|
appModalService.showLastModal();
|
|
@@ -35,11 +73,17 @@ export default class ErrorBoundary extends React.Component {
|
|
|
35
73
|
}
|
|
36
74
|
render() {
|
|
37
75
|
if (this.state.hasError) {
|
|
38
|
-
var _this$state, _this$state2;
|
|
76
|
+
var _appConfig$preference, _this$state, _this$state2;
|
|
77
|
+
const appConfig = injector.get('APP_CONFIG');
|
|
78
|
+
const showFallback = (appConfig === null || appConfig === void 0 || (_appConfig$preference = appConfig.preferences) === null || _appConfig$preference === void 0 ? void 0 : _appConfig$preference.showDefaultErrorFallback) !== false;
|
|
79
|
+
if (!showFallback) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
39
82
|
return /*#__PURE__*/React.createElement(Fallback, {
|
|
40
83
|
error: (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.error,
|
|
41
84
|
info: (_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.info,
|
|
42
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
85
|
+
resetErrorBoundary: this.resetErrorBoundary,
|
|
86
|
+
errorType: this.props.errorType || 'render'
|
|
43
87
|
});
|
|
44
88
|
}
|
|
45
89
|
return this.props.children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fallback","appModalService","ErrorBoundary","Component","constructor","props","_defineProperty","setState","hasError","error","undefined","info","state","getDerivedStateFromError","componentDidCatch","modalsOpened","length","pop","showLastModal","render","_this$state","_this$state2","createElement","resetErrorBoundary","children"],"sources":["error-boundary.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport Fallback from './components/error-fallback/error-fallback.component';\nimport appModalService from '@wavemaker/app-rn-runtime/runtime/services/app-modal.service';\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n info?: any;\n error?: any;\n}\n\ninterface ErrorBoundaryProps {\n currentPage?: any;\n children: React.ReactNode;\n}\n\nexport default class ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n \n constructor(props: any) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: any) {\n return { hasError: true };\n }\n\n resetErrorBoundary = () => {\n this.setState({ hasError: false, error: undefined, info: undefined });\n };\n\n componentDidCatch(error: any, info: any) {\n if(error && appModalService.modalsOpened.length > 0){\n appModalService.modalsOpened.pop();\n (appModalService as any).showLastModal();\n }\n this.setState({ error, info });\n }\n\n render() {\n if (this.state.hasError) {\n return <Fallback error={this.state?.error} info={this.state?.info} resetErrorBoundary={this.resetErrorBoundary} />;\n }\n\n return this.props.children;\n }\n}\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,QAAQ,MAAM,sDAAsD;AAC3E,OAAOC,eAAe,MAAM,8DAA8D;
|
|
1
|
+
{"version":3,"names":["React","Fallback","appModalService","injector","ErrorBoundary","Component","constructor","props","_defineProperty","setState","hasError","error","undefined","info","state","getDerivedStateFromError","appConfig","get","prefs","preferences","globalEnabled","enableGlobalErrorHandler","renderEnabled","enableRenderErrors","componentDidCatch","appInstance","app","triggerOnError","e","console","modalsOpened","length","pop","showLastModal","render","_appConfig$preference","_this$state","_this$state2","showFallback","showDefaultErrorFallback","createElement","resetErrorBoundary","errorType","children"],"sources":["error-boundary.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport Fallback from './components/error-fallback/error-fallback.component';\nimport appModalService from '@wavemaker/app-rn-runtime/runtime/services/app-modal.service';\nimport injector from '@wavemaker/app-rn-runtime/core/injector';\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n info?: any;\n error?: any;\n}\n\ninterface ErrorBoundaryProps {\n currentPage?: any;\n children: React.ReactNode;\n errorType?: 'render' | 'javascript';\n app?: any;\n}\n\nexport default class ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n \n constructor(props: any) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: any) {\n // Check preferences before setting error state\n const appConfig = injector.get<any>('APP_CONFIG');\n const prefs = appConfig?.preferences;\n const globalEnabled = prefs?.enableGlobalErrorHandler === true;\n const renderEnabled = prefs?.enableRenderErrors !== false;\n \n // Only set hasError if error handling is enabled\n if (!globalEnabled || !renderEnabled) {\n return { hasError: false };\n }\n \n return { hasError: true };\n }\n\n resetErrorBoundary = () => {\n this.setState({ hasError: false, error: undefined, info: undefined });\n };\n\n componentDidCatch(error: any, info: any) {\n // Check if error handling is enabled\n const appConfig = injector.get<any>('APP_CONFIG');\n const prefs = appConfig?.preferences;\n const globalEnabled = prefs?.enableGlobalErrorHandler === true;\n const renderEnabled = prefs?.enableRenderErrors !== false;\n \n // Only catch if both master switch and render errors are enabled\n if (!globalEnabled || !renderEnabled) {\n return;\n }\n \n // Trigger user error callback if app instance is available\n let appInstance = this.props.app;\n \n // Fallback: try to get app instance from injector if prop is not available\n if (!appInstance) {\n appInstance = injector.get('APP_INSTANCE');\n }\n \n if (appInstance && appInstance.triggerOnError) {\n try {\n appInstance.triggerOnError(error, info, 'render');\n } catch (e) {\n console.error('Error calling triggerOnError:', e);\n }\n }\n \n if(error && appModalService.modalsOpened.length > 0){\n appModalService.modalsOpened.pop();\n (appModalService as any).showLastModal();\n }\n this.setState({ error, info });\n }\n\n render() {\n if (this.state.hasError) {\n const appConfig = injector.get<any>('APP_CONFIG');\n const showFallback = appConfig?.preferences?.showDefaultErrorFallback !== false;\n \n if (!showFallback) {\n return null;\n }\n \n return <Fallback \n error={this.state?.error} \n info={this.state?.info} \n resetErrorBoundary={this.resetErrorBoundary}\n errorType={this.props.errorType || 'render'}\n />;\n }\n\n return this.props.children;\n }\n}\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,QAAQ,MAAM,sDAAsD;AAC3E,OAAOC,eAAe,MAAM,8DAA8D;AAC1F,OAAOC,QAAQ,MAAM,yCAAyC;AAe9D,eAAe,MAAMC,aAAa,SAASJ,KAAK,CAACK,SAAS,CAGxD;EAEAC,WAAWA,CAACC,KAAU,EAAE;IACtB,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,6BAmBM,MAAM;MACzB,IAAI,CAACC,QAAQ,CAAC;QAAEC,QAAQ,EAAE,KAAK;QAAEC,KAAK,EAAEC,SAAS;QAAEC,IAAI,EAAED;MAAU,CAAC,CAAC;IACvE,CAAC;IApBC,IAAI,CAACE,KAAK,GAAG;MAAEJ,QAAQ,EAAE;IAAM,CAAC;EAClC;EAEA,OAAOK,wBAAwBA,CAACJ,KAAU,EAAE;IAC1C;IACA,MAAMK,SAAS,GAAGb,QAAQ,CAACc,GAAG,CAAM,YAAY,CAAC;IACjD,MAAMC,KAAK,GAAGF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEG,WAAW;IACpC,MAAMC,aAAa,GAAG,CAAAF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEG,wBAAwB,MAAK,IAAI;IAC9D,MAAMC,aAAa,GAAG,CAAAJ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEK,kBAAkB,MAAK,KAAK;;IAEzD;IACA,IAAI,CAACH,aAAa,IAAI,CAACE,aAAa,EAAE;MACpC,OAAO;QAAEZ,QAAQ,EAAE;MAAM,CAAC;IAC5B;IAEA,OAAO;MAAEA,QAAQ,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AC,WAAA,EAAAC,YAAA;MACvB,MAAMrB,SAAS,GAAGb,QAAQ,CAACc,GAAG,CAAM,YAAY,CAAC;MACjD,MAAMqB,YAAY,GAAG,CAAAtB,SAAS,aAATA,SAAS,gBAAAmB,qBAAA,GAATnB,SAAS,CAAEG,WAAW,cAAAgB,qBAAA,uBAAtBA,qBAAA,CAAwBI,wBAAwB,MAAK,KAAK;MAE/E,IAAI,CAACD,YAAY,EAAE;QACjB,OAAO,IAAI;MACb;MAEA,oBAAOtC,KAAA,CAAAwC,aAAA,CAACvC,QAAQ;QACdU,KAAK,GAAAyB,WAAA,GAAE,IAAI,CAACtB,KAAK,cAAAsB,WAAA,uBAAVA,WAAA,CAAYzB,KAAM;QACzBE,IAAI,GAAAwB,YAAA,GAAE,IAAI,CAACvB,KAAK,cAAAuB,YAAA,uBAAVA,YAAA,CAAYxB,IAAK;QACvB4B,kBAAkB,EAAE,IAAI,CAACA,kBAAmB;QAC5CC,SAAS,EAAE,IAAI,CAACnC,KAAK,CAACmC,SAAS,IAAI;MAAS,CAC7C,CAAC;IACJ;IAEA,OAAO,IAAI,CAACnC,KAAK,CAACoC,QAAQ;EAC5B;AACF","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { View, Animated
|
|
5
|
+
import { View, Animated } from "react-native";
|
|
6
6
|
import { ThemeProvider } from "../styles/theme";
|
|
7
7
|
const FixedViewContext = /*#__PURE__*/React.createContext(null);
|
|
8
8
|
export class FixedView extends React.Component {
|
|
@@ -11,22 +11,6 @@ export class FixedView extends React.Component {
|
|
|
11
11
|
_defineProperty(this, "container", null);
|
|
12
12
|
_defineProperty(this, "cachedComponent", void 0);
|
|
13
13
|
_defineProperty(this, "id", FixedView.counter++);
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* Capture the touch before it reaches child Touchables
|
|
17
|
-
*/
|
|
18
|
-
_defineProperty(this, "handleStartShouldSetResponderCapture", event => {
|
|
19
|
-
var _event$nativeEvent;
|
|
20
|
-
const textInputState = TextInput.State;
|
|
21
|
-
const focusedInput = textInputState !== null && textInputState !== void 0 && textInputState.currentlyFocusedInput ? textInputState.currentlyFocusedInput() : null;
|
|
22
|
-
const focusedHandle = focusedInput ? findNodeHandle(focusedInput) : textInputState !== null && textInputState !== void 0 && textInputState.currentlyFocusedInput ? textInputState.currentlyFocusedInput() : null;
|
|
23
|
-
if (focusedHandle && (event === null || event === void 0 || (_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.target) === focusedHandle) {
|
|
24
|
-
// Should not dismiss keyboard if the user presses on the same text input that is already focused
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
Keyboard.dismiss();
|
|
28
|
-
return false; // let the touch reach the child Touchables
|
|
29
|
-
});
|
|
30
14
|
}
|
|
31
15
|
componentWillUnmount() {
|
|
32
16
|
this.container.remove(this);
|
|
@@ -43,8 +27,7 @@ export class FixedView extends React.Component {
|
|
|
43
27
|
style: [{
|
|
44
28
|
position: 'absolute'
|
|
45
29
|
}, this.props.style],
|
|
46
|
-
testID: `${this.props.name}-fixed-view
|
|
47
|
-
onStartShouldSetResponderCapture: this.handleStartShouldSetResponderCapture
|
|
30
|
+
testID: `${this.props.name}-fixed-view`
|
|
48
31
|
}, this.props.children)));
|
|
49
32
|
} else {
|
|
50
33
|
container.remove(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","Animated","
|
|
1
|
+
{"version":3,"names":["React","View","Animated","ThemeProvider","FixedViewContext","createContext","FixedView","Component","constructor","props","_defineProperty","counter","componentWillUnmount","container","remove","render","WrapperView","animated","cachedComponent","usememo","createElement","Consumer","show","add","value","theme","key","id","style","position","testID","name","children","Fragment","Date","now","FixedViewContainer","args","Map","c","n","set","setTimeout","setState","delete","Provider","Array","from","values"],"sources":["fixed-view.component.tsx"],"sourcesContent":["\nimport React from \"react\";\nimport { View, ViewStyle, Animated } from \"react-native\";\nimport { Theme, ThemeProvider } from \"../styles/theme\";\n\nconst FixedViewContext = React.createContext<FixedViewContainer>(null as any);\n\nexport interface FixedViewProps {\n name?: string;\n style?: ViewStyle,\n show?: boolean;\n theme: Theme;\n usememo?: boolean;\n children?: any;\n animated?: boolean;\n}\n\nexport class FixedView extends React.Component<FixedViewProps> {\n static defaultProps = {\n show: true, \n animated: false\n };\n static counter = Date.now();\n container: FixedViewContainer = null as any;\n cachedComponent: React.ReactNode;\n id = FixedView.counter++;\n\n constructor(props: FixedViewProps) {\n super(props);\n }\n\n componentWillUnmount() {\n this.container.remove(this);\n }\n\n render() {\n const WrapperView = this.props.animated ? Animated.View : View\n this.cachedComponent = (this.props.usememo === true && this.cachedComponent ) || (<FixedViewContext.Consumer>\n {(container) => {\n this.container = container;\n if (this.props.show) {\n container.add(this, (\n <ThemeProvider value={this.props.theme} key={this.id}>\n <WrapperView style={[\n {position: 'absolute'},\n this.props.style]}\n testID={`${this.props.name}-fixed-view`}\n >\n {this.props.children}\n </WrapperView>\n </ThemeProvider>\n ));\n } else {\n container.remove(this);\n }\n return <></>;\n }}\n </FixedViewContext.Consumer>);\n return this.cachedComponent;\n }\n}\n\nexport class FixedViewContainer extends React.Component {\n children: Map<FixedView, React.ReactNode> = new Map();\n id = 0;\n\n add(c: FixedView, n : React.ReactNode) {\n this.children.set(c, n);\n setTimeout(() => this.setState({id: ++this.id}));\n }\n\n remove(c: FixedView) {\n this.children.delete(c);\n setTimeout(() => this.setState({id: ++this.id}));\n }\n\n render() {\n return (\n <FixedViewContext.Provider value={this}>\n {(this.props as any).children}\n {Array.from(this.children.values())}\n </FixedViewContext.Provider>\n ) ;\n }\n};"],"mappings":";;;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAaC,QAAQ,QAAQ,cAAc;AACxD,SAAgBC,aAAa,QAAQ,iBAAiB;AAEtD,MAAMC,gBAAgB,gBAAGJ,KAAK,CAACK,aAAa,CAAqB,IAAW,CAAC;AAY7E,OAAO,MAAMC,SAAS,SAASN,KAAK,CAACO,SAAS,CAAiB;EAU3DC,WAAWA,CAACC,KAAqB,EAAE;IAC/B,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBALe,IAAI;IAAAA,eAAA;IAAAA,eAAA,aAE/BJ,SAAS,CAACK,OAAO,EAAE;EAIxB;EAEAC,oBAAoBA,CAAA,EAAG;IACnB,IAAI,CAACC,SAAS,CAACC,MAAM,CAAC,IAAI,CAAC;EAC/B;EAEAC,MAAMA,CAAA,EAAG;IACL,MAAMC,WAAW,GAAG,IAAI,CAACP,KAAK,CAACQ,QAAQ,GAAGf,QAAQ,CAACD,IAAI,GAAGA,IAAI;IAC9D,IAAI,CAACiB,eAAe,GAAI,IAAI,CAACT,KAAK,CAACU,OAAO,KAAK,IAAI,IAAI,IAAI,CAACD,eAAe,iBAAOlB,KAAA,CAAAoB,aAAA,CAAChB,gBAAgB,CAACiB,QAAQ,QACtGR,SAAS,IAAK;MACZ,IAAI,CAACA,SAAS,GAAGA,SAAS;MAC1B,IAAI,IAAI,CAACJ,KAAK,CAACa,IAAI,EAAE;QACjBT,SAAS,CAACU,GAAG,CAAC,IAAI,eACdvB,KAAA,CAAAoB,aAAA,CAACjB,aAAa;UAACqB,KAAK,EAAE,IAAI,CAACf,KAAK,CAACgB,KAAM;UAACC,GAAG,EAAE,IAAI,CAACC;QAAG,gBACjD3B,KAAA,CAAAoB,aAAA,CAACJ,WAAW;UAACY,KAAK,EAAE,CAChB;YAACC,Q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AA,CAAChB,gBAAgB,CAACyC,QAAQ;MAACrB,KAAK,EAAE;IAAK,GACjC,IAAI,CAACf,KAAK,CAASuB,QAAQ,EAC5Bc,KAAK,CAACC,IAAI,CAAC,IAAI,CAACf,QAAQ,CAACgB,MAAM,CAAC,CAAC,CACX,CAAC;EAEpC;AACJ;AAAC","ignoreList":[]}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Error Handler Service for WaveMaker Runtime
|
|
3
|
+
*
|
|
4
|
+
* This service provides comprehensive error handling for React Native applications:
|
|
5
|
+
* 1. JavaScript Error Handling: Uses ErrorUtils.setGlobalHandler for sync errors
|
|
6
|
+
* 2. Promise Rejection Tracking: Multi-engine approach for unhandled promise rejections
|
|
7
|
+
* - Web: Uses browser's 'unhandledrejection' event
|
|
8
|
+
* - Hermes: Uses HermesInternal.enablePromiseRejectionTracker
|
|
9
|
+
* - JSC: Uses React Native's 'promise/setimmediate/rejection-tracking' module
|
|
10
|
+
*
|
|
11
|
+
* Key Features:
|
|
12
|
+
* - Catches ALL API call failures (fetch, axios, any HTTP library)
|
|
13
|
+
* - Handles async function errors and manual Promise.reject calls
|
|
14
|
+
* - Automatic engine detection and optimal method selection
|
|
15
|
+
* - Production-ready with proper cleanup mechanisms
|
|
16
|
+
* - Configurable suppression of React Native's default error screens
|
|
17
|
+
*
|
|
18
|
+
* Research Background:
|
|
19
|
+
* This implementation was developed after extensive research into React Native's
|
|
20
|
+
* error handling mechanisms across different JavaScript engines. It addresses
|
|
21
|
+
* the common problem where API call failures and async errors are not caught
|
|
22
|
+
* by standard error boundaries, providing a unified solution for all error types.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Platform } from 'react-native';
|
|
26
|
+
import { isWebPreviewMode } from './utils';
|
|
27
|
+
import { setupAdvancedPromiseRejectionTracking } from './advanced-promise-rejection-tracker';
|
|
28
|
+
let globalJsErrorHandler = null;
|
|
29
|
+
let promiseRejectionTracker = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Extracts meaningful error message from various error formats
|
|
33
|
+
* Handles WaveMaker API errors, Axios errors, Error instances, and objects
|
|
34
|
+
* @param error The error object/value to extract message from
|
|
35
|
+
* @returns Extracted error message string
|
|
36
|
+
*/
|
|
37
|
+
const extractErrorMessage = error => {
|
|
38
|
+
var _error$details, _error$details2;
|
|
39
|
+
if (typeof error === 'string') return error;
|
|
40
|
+
if (error instanceof Error) return error.message;
|
|
41
|
+
if (!error || typeof error !== 'object') return String(error);
|
|
42
|
+
|
|
43
|
+
// WaveMaker API error format: details.data.errors.error[0]
|
|
44
|
+
if ((_error$details = error.details) !== null && _error$details !== void 0 && (_error$details = _error$details.data) !== null && _error$details !== void 0 && (_error$details = _error$details.errors) !== null && _error$details !== void 0 && _error$details.error && Array.isArray(error.details.data.errors.error)) {
|
|
45
|
+
const firstError = error.details.data.errors.error[0];
|
|
46
|
+
if (firstError && firstError.message) {
|
|
47
|
+
let message = firstError.message;
|
|
48
|
+
|
|
49
|
+
// Interpolate parameters {0}, {1}, etc.
|
|
50
|
+
if (firstError.parameters && Array.isArray(firstError.parameters)) {
|
|
51
|
+
firstError.parameters.forEach((param, index) => {
|
|
52
|
+
message = message.replace(`{${index}}`, String(param));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return message;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Wrapped format: { error: "message" }
|
|
60
|
+
if (error.error && typeof error.error === 'string') {
|
|
61
|
+
return error.error;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Standard format: { message: "..." }
|
|
65
|
+
if (error.message) {
|
|
66
|
+
return error.message;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Nested details message
|
|
70
|
+
if ((_error$details2 = error.details) !== null && _error$details2 !== void 0 && _error$details2.message) {
|
|
71
|
+
return error.details.message;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Last resort - stringify the object
|
|
75
|
+
try {
|
|
76
|
+
return JSON.stringify(error);
|
|
77
|
+
} catch {
|
|
78
|
+
return String(error);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Sets up global JavaScript error handling for sync JS errors and unhandled promise rejections
|
|
84
|
+
* Note: Render errors are handled separately by React ErrorBoundary
|
|
85
|
+
* @param onError Callback function to handle errors
|
|
86
|
+
* @param suppressDefaultErrorScreen Whether to suppress React Native's default error screen
|
|
87
|
+
* @param enableSyncErrors Whether to enable synchronous JavaScript error handling
|
|
88
|
+
* @param enableAsyncErrors Whether to enable asynchronous error handling (promise rejections)
|
|
89
|
+
* @returns Cleanup function to remove the error handlers
|
|
90
|
+
*/
|
|
91
|
+
export const setupGlobalJsErrorHandler = (onError, suppressDefaultErrorScreen = false, enableSyncErrors = true, enableAsyncErrors = true) => {
|
|
92
|
+
let originalHandler = null;
|
|
93
|
+
const ErrorUtilsRef = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ErrorUtils;
|
|
94
|
+
|
|
95
|
+
// Only setup synchronous JavaScript error handler if enabled
|
|
96
|
+
if (ErrorUtilsRef && enableSyncErrors) {
|
|
97
|
+
var _ErrorUtilsRef$getGlo, _ErrorUtilsRef$setGlo;
|
|
98
|
+
// Store the original error handler to restore it later
|
|
99
|
+
originalHandler = ErrorUtilsRef === null || ErrorUtilsRef === void 0 || (_ErrorUtilsRef$getGlo = ErrorUtilsRef.getGlobalHandler) === null || _ErrorUtilsRef$getGlo === void 0 ? void 0 : _ErrorUtilsRef$getGlo.call(ErrorUtilsRef);
|
|
100
|
+
|
|
101
|
+
// Setup synchronous JavaScript error handler
|
|
102
|
+
globalJsErrorHandler = (error, isFatal = false) => {
|
|
103
|
+
const errorInfo = __DEV__ ? `${error.stack || error.toString()}` : 'An unexpected error occurred';
|
|
104
|
+
|
|
105
|
+
// Call our custom error handler
|
|
106
|
+
onError(error, isFatal, errorInfo);
|
|
107
|
+
|
|
108
|
+
// Call the original handler for development/debugging if not suppressed
|
|
109
|
+
// This controls whether React Native's default red error screen is shown
|
|
110
|
+
if (originalHandler && __DEV__ && !suppressDefaultErrorScreen) {
|
|
111
|
+
originalHandler(error, isFatal);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Set our custom global JS error handler
|
|
116
|
+
ErrorUtilsRef === null || ErrorUtilsRef === void 0 || (_ErrorUtilsRef$setGlo = ErrorUtilsRef.setGlobalHandler) === null || _ErrorUtilsRef$setGlo === void 0 || _ErrorUtilsRef$setGlo.call(ErrorUtilsRef, globalJsErrorHandler);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Setup Advanced Promise Rejection Tracking only if async errors are enabled
|
|
120
|
+
// This automatically detects the best method for the current JavaScript engine:
|
|
121
|
+
// - Web: Uses unhandledrejection event for complete coverage
|
|
122
|
+
// - Hermes: Uses HermesInternal.enablePromiseRejectionTracker for native tracking
|
|
123
|
+
// - JSC: Uses promise/setimmediate/rejection-tracking module for comprehensive handling
|
|
124
|
+
if (enableAsyncErrors) {
|
|
125
|
+
promiseRejectionTracker = setupAdvancedPromiseRejectionTracking(error => {
|
|
126
|
+
var _error$config, _error$config2, _error$details3, _error$details4;
|
|
127
|
+
// Skip if this is a service error that was already handled by onServiceError
|
|
128
|
+
// Check multiple locations as error might be wrapped
|
|
129
|
+
const isServiceErrorHandled = (error === null || error === void 0 ? void 0 : error.__wmServiceError) && (error === null || error === void 0 ? void 0 : error.__wmServiceErrorHandled) || (error === null || error === void 0 || (_error$config = error.config) === null || _error$config === void 0 ? void 0 : _error$config.__wmServiceError) && (error === null || error === void 0 || (_error$config2 = error.config) === null || _error$config2 === void 0 ? void 0 : _error$config2.__wmServiceErrorHandled) || (error === null || error === void 0 || (_error$details3 = error.details) === null || _error$details3 === void 0 || (_error$details3 = _error$details3.config) === null || _error$details3 === void 0 ? void 0 : _error$details3.__wmServiceError) && (error === null || error === void 0 || (_error$details4 = error.details) === null || _error$details4 === void 0 || (_error$details4 = _error$details4.config) === null || _error$details4 === void 0 ? void 0 : _error$details4.__wmServiceErrorHandled);
|
|
130
|
+
if (isServiceErrorHandled) {
|
|
131
|
+
if (__DEV__) {
|
|
132
|
+
console.log('[ErrorHandler] Skipping service error, already handled by onServiceError');
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const promiseError = error instanceof Error ? error : new Error(extractErrorMessage(error));
|
|
137
|
+
|
|
138
|
+
// Preserve original error for debugging
|
|
139
|
+
if (!(error instanceof Error)) {
|
|
140
|
+
promiseError.originalError = error;
|
|
141
|
+
}
|
|
142
|
+
const errorInfo = __DEV__ ? `Promise rejection: ${promiseError.stack || promiseError.toString()}` : 'An unexpected error occurred';
|
|
143
|
+
|
|
144
|
+
// Call our custom error handler with promise-specific info
|
|
145
|
+
// This ensures API call failures and async errors trigger the same error flow
|
|
146
|
+
onError(promiseError, false, errorInfo);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return () => {
|
|
150
|
+
// Cleanup function - restores original error handling mechanisms
|
|
151
|
+
if (enableSyncErrors && ErrorUtilsRef) {
|
|
152
|
+
var _ErrorUtilsRef$setGlo2;
|
|
153
|
+
ErrorUtilsRef === null || ErrorUtilsRef === void 0 || (_ErrorUtilsRef$setGlo2 = ErrorUtilsRef.setGlobalHandler) === null || _ErrorUtilsRef$setGlo2 === void 0 || _ErrorUtilsRef$setGlo2.call(ErrorUtilsRef, originalHandler);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Cleanup advanced promise rejection tracking
|
|
157
|
+
if (enableAsyncErrors && promiseRejectionTracker) {
|
|
158
|
+
promiseRejectionTracker.cleanup();
|
|
159
|
+
promiseRejectionTracker = null;
|
|
160
|
+
}
|
|
161
|
+
globalJsErrorHandler = null;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Get current error handling configuration and capabilities
|
|
167
|
+
* Useful for debugging and monitoring the error handling setup
|
|
168
|
+
*/
|
|
169
|
+
export const getErrorHandlingInfo = () => {
|
|
170
|
+
return {
|
|
171
|
+
platform: Platform.OS,
|
|
172
|
+
isWebPreview: isWebPreviewMode(),
|
|
173
|
+
hasPromiseTracking: promiseRejectionTracker !== null,
|
|
174
|
+
hasJavaScriptHandler: globalJsErrorHandler !== null
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=global-error-handler.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","isWebPreviewMode","setupAdvancedPromiseRejectionTracking","globalJsErrorHandler","promiseRejectionTracker","extractErrorMessage","error","_error$details","_error$details2","Error","message","String","details","data","errors","Array","isArray","firstError","parameters","forEach","param","index","replace","JSON","stringify","setupGlobalJsErrorHandler","onError","suppressDefaultErrorScreen","enableSyncErrors","enableAsyncErrors","originalHandler","ErrorUtilsRef","globalThis","ErrorUtils","_ErrorUtilsRef$getGlo","_ErrorUtilsRef$setGlo","getGlobalHandler","call","isFatal","errorInfo","__DEV__","stack","toString","setGlobalHandler","_error$config","_error$config2","_error$details3","_error$details4","isServiceErrorHandled","__wmServiceError","__wmServiceErrorHandled","config","console","log","promiseError","originalError","_ErrorUtilsRef$setGlo2","cleanup","getErrorHandlingInfo","platform","OS","isWebPreview","hasPromiseTracking","hasJavaScriptHandler"],"sources":["global-error-handler.service.ts"],"sourcesContent":["/**\n * Global Error Handler Service for WaveMaker Runtime\n *\n * This service provides comprehensive error handling for React Native applications:\n * 1. JavaScript Error Handling: Uses ErrorUtils.setGlobalHandler for sync errors\n * 2. Promise Rejection Tracking: Multi-engine approach for unhandled promise rejections\n * - Web: Uses browser's 'unhandledrejection' event\n * - Hermes: Uses HermesInternal.enablePromiseRejectionTracker\n * - JSC: Uses React Native's 'promise/setimmediate/rejection-tracking' module\n *\n * Key Features:\n * - Catches ALL API call failures (fetch, axios, any HTTP library)\n * - Handles async function errors and manual Promise.reject calls\n * - Automatic engine detection and optimal method selection\n * - Production-ready with proper cleanup mechanisms\n * - Configurable suppression of React Native's default error screens\n *\n * Research Background:\n * This implementation was developed after extensive research into React Native's\n * error handling mechanisms across different JavaScript engines. It addresses\n * the common problem where API call failures and async errors are not caught\n * by standard error boundaries, providing a unified solution for all error types.\n */\n\nimport { Platform } from 'react-native';\nimport { isWebPreviewMode } from './utils';\nimport {\n setupAdvancedPromiseRejectionTracking,\n AdvancedPromiseRejectionTracker,\n} from './advanced-promise-rejection-tracker';\n\nexport interface GlobalErrorState {\n error: Error;\n errorInfo: string;\n errorType: 'javascript';\n isFatal?: boolean;\n}\n\nexport type GlobalErrorCallback = (\n error: Error,\n isFatal: boolean,\n errorInfo: string\n) => void;\n\nlet globalJsErrorHandler: ((error: any, isFatal?: boolean) => void) | null = null;\nlet promiseRejectionTracker: AdvancedPromiseRejectionTracker | null = null;\n\n/**\n * Extracts meaningful error message from various error formats\n * Handles WaveMaker API errors, Axios errors, Error instances, and objects\n * @param error The error object/value to extract message from\n * @returns Extracted error message string\n */\nconst extractErrorMessage = (error: any): string => {\n if (typeof error === 'string') return error;\n \n if (error instanceof Error) return error.message;\n \n if (!error || typeof error !== 'object') return String(error);\n \n // WaveMaker API error format: details.data.errors.error[0]\n if (error.details?.data?.errors?.error && Array.isArray(error.details.data.errors.error)) {\n const firstError = error.details.data.errors.error[0];\n if (firstError && firstError.message) {\n let message = firstError.message;\n \n // Interpolate parameters {0}, {1}, etc.\n if (firstError.parameters && Array.isArray(firstError.parameters)) {\n firstError.parameters.forEach((param: any, index: number) => {\n message = message.replace(`{${index}}`, String(param));\n });\n }\n \n return message;\n }\n }\n \n // Wrapped format: { error: \"message\" }\n if (error.error && typeof error.error === 'string') {\n return error.error;\n }\n \n // Standard format: { message: \"...\" }\n if (error.message) {\n return error.message;\n }\n \n // Nested details message\n if (error.details?.message) {\n return error.details.message;\n }\n \n // Last resort - stringify the object\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n};\n\n/**\n * Sets up global JavaScript error handling for sync JS errors and unhandled promise rejections\n * Note: Render errors are handled separately by React ErrorBoundary\n * @param onError Callback function to handle errors\n * @param suppressDefaultErrorScreen Whether to suppress React Native's default error screen\n * @param enableSyncErrors Whether to enable synchronous JavaScript error handling\n * @param enableAsyncErrors Whether to enable asynchronous error handling (promise rejections)\n * @returns Cleanup function to remove the error handlers\n */\nexport const setupGlobalJsErrorHandler = (\n onError: GlobalErrorCallback,\n suppressDefaultErrorScreen: boolean = false,\n enableSyncErrors: boolean = true,\n enableAsyncErrors: boolean = true\n): (() => void) => {\n let originalHandler: any = null;\n const ErrorUtilsRef = (globalThis as any)?.ErrorUtils;\n \n // Only setup synchronous JavaScript error handler if enabled\n if (ErrorUtilsRef && enableSyncErrors) {\n // Store the original error handler to restore it later\n originalHandler = ErrorUtilsRef?.getGlobalHandler?.();\n\n // Setup synchronous JavaScript error handler\n globalJsErrorHandler = (error: any, isFatal: boolean = false) => {\n const errorInfo = __DEV__\n ? `${error.stack || error.toString()}`\n : 'An unexpected error occurred';\n\n // Call our custom error handler\n onError(error, isFatal, errorInfo);\n\n // Call the original handler for development/debugging if not suppressed\n // This controls whether React Native's default red error screen is shown\n if (originalHandler && __DEV__ && !suppressDefaultErrorScreen) {\n originalHandler(error, isFatal);\n }\n };\n\n // Set our custom global JS error handler\n ErrorUtilsRef?.setGlobalHandler?.(globalJsErrorHandler);\n }\n\n // Setup Advanced Promise Rejection Tracking only if async errors are enabled\n // This automatically detects the best method for the current JavaScript engine:\n // - Web: Uses unhandledrejection event for complete coverage\n // - Hermes: Uses HermesInternal.enablePromiseRejectionTracker for native tracking\n // - JSC: Uses promise/setimmediate/rejection-tracking module for comprehensive handling\n if (enableAsyncErrors) {\n promiseRejectionTracker = setupAdvancedPromiseRejectionTracking(\n (error: any) => {\n // Skip if this is a service error that was already handled by onServiceError\n // Check multiple locations as error might be wrapped\n const isServiceErrorHandled = \n (error?.__wmServiceError && error?.__wmServiceErrorHandled) ||\n (error?.config?.__wmServiceError && error?.config?.__wmServiceErrorHandled) ||\n (error?.details?.config?.__wmServiceError && error?.details?.config?.__wmServiceErrorHandled);\n \n if (isServiceErrorHandled) {\n if (__DEV__) {\n console.log('[ErrorHandler] Skipping service error, already handled by onServiceError');\n }\n return;\n }\n const promiseError = error instanceof Error ? error : new Error(extractErrorMessage(error));\n\n // Preserve original error for debugging\n if (!(error instanceof Error)) {\n (promiseError as any).originalError = error;\n }\n \n const errorInfo = __DEV__\n ? `Promise rejection: ${promiseError.stack || promiseError.toString()}`\n : 'An unexpected error occurred';\n\n // Call our custom error handler with promise-specific info\n // This ensures API call failures and async errors trigger the same error flow\n onError(promiseError, false, errorInfo);\n }\n );\n }\n\n return () => {\n // Cleanup function - restores original error handling mechanisms\n if (enableSyncErrors && ErrorUtilsRef) {\n ErrorUtilsRef?.setGlobalHandler?.(originalHandler);\n }\n\n // Cleanup advanced promise rejection tracking\n if (enableAsyncErrors && promiseRejectionTracker) {\n promiseRejectionTracker.cleanup();\n promiseRejectionTracker = null;\n }\n\n globalJsErrorHandler = null;\n };\n};\n\n/**\n * Get current error handling configuration and capabilities\n * Useful for debugging and monitoring the error handling setup\n */\nexport const getErrorHandlingInfo = () => {\n return {\n platform: Platform.OS,\n isWebPreview: isWebPreviewMode(),\n hasPromiseTracking: promiseRejectionTracker !== null,\n hasJavaScriptHandler: globalJsErrorHandler !== null,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SACEC,qCAAqC,QAEhC,sCAAsC;AAe7C,IAAIC,oBAAsE,GAAG,IAAI;AACjF,IAAIC,uBAA+D,GAAG,IAAI;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,KAAU,IAAa;EAAA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A;MACF;MACA,MAAMC,YAAY,GAAGhD,KAAK,YAAYG,KAAK,GAAGH,KAAK,GAAG,IAAIG,KAAK,CAACJ,mBAAmB,CAACC,KAAK,CAAC,CAAC;;MAE3F;MACA,IAAI,EAAEA,KAAK,YAAYG,KAAK,CAAC,EAAE;QAC5B6C,YAAY,CAASC,aAAa,GAAGjD,KAAK;MAC7C;MAEA,MAAMiC,SAAS,GAAGC,OAAO,GACrB,sBAAsBc,YAAY,CAACb,KAAK,IAAIa,YAAY,CAACZ,QAAQ,CAAC,CAAC,EAAE,GACrE,8BAA8B;;MAElC;MACA;MACAhB,OAAO,CAAC4B,YAAY,EAAE,KAAK,EAAEf,SAAS,CAAC;IACzC,CACF,CAAC;EACH;EAEA,OAAO,MAAM;IACX;IACA,IAAIX,gBAAgB,IAAIG,aAAa,EAAE;MAAA,IAAAyB,sBAAA;MACrCzB,aAAa,aAAbA,aAAa,gBAAAyB,sBAAA,GAAbzB,aAAa,CAAEY,gBAAgB,cAAAa,sBAAA,eAA/BA,sBAAA,CAAAnB,IAAA,CAAAN,aAAa,EAAqBD,eAAe,CAAC;IACpD;;IAEA;IACA,IAAID,iBAAiB,IAAIzB,uBAAuB,EAAE;MAChDA,uBAAuB,CAACqD,OAAO,CAAC,CAAC;MACjCrD,uBAAuB,GAAG,IAAI;IAChC;IAEAD,oBAAoB,GAAG,IAAI;EAC7B,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMuD,oBAAoB,GAAGA,CAAA,KAAM;EACxC,OAAO;IACLC,QAAQ,EAAE3D,QAAQ,CAAC4D,EAAE;IACrBC,YAAY,EAAE5D,gBAAgB,CAAC,CAAC;IAChC6D,kBAAkB,EAAE1D,uBAAuB,KAAK,IAAI;IACpD2D,oBAAoB,EAAE5D,oBAAoB,KAAK;EACjD,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -114,7 +114,7 @@ export class Tappable extends React.Component {
|
|
|
114
114
|
accessibilityLabel: this.props.testID,
|
|
115
115
|
testID: this.props.testID
|
|
116
116
|
} : {
|
|
117
|
-
|
|
117
|
+
accessible: false,
|
|
118
118
|
testID: this.props.testID
|
|
119
119
|
}),
|
|
120
120
|
...this.props.accessibilityProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Platform","View","TouchableOpacity","get","injector","TouchableRipple","TappableContext","createContext","UIPreferencesConsumer","ParentTappableContext","SyntheticEvent","constructor","_defineProperty","stopPropagation","propagationEnabled","Tappable","Component","props","triggerTap","e","_this$parent","target","onTap","invokeEventCallback","parent","onPress","_this$props$target","lastPress","Date","now","onTouchStart","currentTime","tapDelta","lastTap","isLongTap","_injector$FOCUSED_ELE","FOCUSED_ELEMENT","blur","lastDoubleTap","onDoubleTap","setTimeout","_this$parent2","onLongTap","_this$props$target2","_this$parent3","onPressOut","onTouchEnd","_this$props$target3","_this$parent4","setParent","render","commonProps","OS","accessibilityLabel","testID","accessibilityProps","disabled","proxy","style","styles","_e$target","tagName","onLongPress","onLongtap","onDoubletap","createElement","preferences","enableRipple","Consumer","Provider","value","_extends","rippleColor","disableTouchEffect","borderless","onLayout","Fragment","children","activeOpacity"],"sources":["tappable.component.tsx"],"sourcesContent":["import { BaseComponent } from \"@wavemaker/app-rn-runtime/core/base.component\";\nimport React from \"react\";\nimport { GestureResponderEvent, Platform, View, TouchableOpacity } from \"react-native\";\nimport { get } from \"lodash\";\nimport injector from \"./injector\";\nimport { TouchableRipple } from \"react-native-paper\";\nimport ThemeVariables from \"../styles/theme.variables\";\nimport { isDefined } from \"./utils\";\n\nexport const TappableContext = React.createContext<Tappable>(null as any);\nimport { UIPreferencesConsumer, UI_PREFERENCES } from \"./ui-preferences.context\";\n\nexport const ParentTappableContext = React.createContext<Tappable>(null as any);\ninterface TappableProps {\n testID?: string;\n children?: any\n styles?: any;\n target?: BaseComponent<any, any, any>;\n onTap?: (e: any) => void;\n onLongTap?: (e: any) => void; \n onDoubleTap?: (e: any) => void;\n onTouchStart? : (e: any) => void;\n onTouchEnd? : (e: any) => void;\n rippleColor?: string;\n accessibilityProps?: any;\n disableTouchEffect?:boolean;\n onLayout?: any;\n}\n\nexport class SyntheticEvent {\n // as the event is being used in onPress, onPressOut and onLongTap the TapEvent is renamed to SyntheticEvent\n propagationEnabled = true;\n \n constructor() {\n\n }\n\n stopPropagation() {\n this.propagationEnabled = false;\n }\n}\n\nexport class Tappable extends React.Component<TappableProps, any> {\n private lastPress = 0;\n private lastTap = 0;\n private lastDoubleTap = 0;\n private isLongTap = false;\n private parent:Tappable = null as any;\n \n constructor(props: any) {\n super(props);\n }\n\n async triggerTap(e = new SyntheticEvent()) {\n if (!e.propagationEnabled) {\n return;\n }\n const target = this.props.target;\n if (this.props.onTap) {\n await this.props.onTap(e);\n } else {\n await target?.invokeEventCallback('onTap', [e, target]);\n }\n this.parent?.triggerTap(e);\n }\n\n onPress(e: SyntheticEvent): void { \n this.lastPress = Date.now();\n const target = this.props.target;\n this.props.onTouchStart && this.props.onTouchStart(e);\n this.props.target?.invokeEventCallback('onTouchstart', [e, this.props.target]);\n const currentTime = Date.now();\n const tapDelta = currentTime - this.lastTap;\n if (this.isLongTap) {\n this.isLongTap = false;\n return;\n }\n if (e.propagationEnabled) {\n injector.FOCUSED_ELEMENT.get()?.blur();\n if(this.lastDoubleTap !== this.lastTap \n && tapDelta < 500) {\n this.props.onDoubleTap && this.props.onDoubleTap(e);\n setTimeout(() => {\n target?.invokeEventCallback('onDoubletap', [e, target]);\n }, 200);\n this.lastDoubleTap = currentTime;\n }\n setTimeout(() => {\n if (!e.propagationEnabled) {\n return;\n }\n if (this.props.onTap) {\n this.props.onTap(e);\n } else {\n target?.invokeEventCallback('onTap', [e, target]);\n }\n this.parent?.onPress(e);\n }, 200);\n this.lastTap = currentTime;\n }\n }\n\n onLongTap(e: SyntheticEvent): void {\n if(!e.propagationEnabled){\n return;\n }\n this.props.onLongTap && this.props.onLongTap(e);\n setTimeout(() => {\n this.props.target?.invokeEventCallback('onLongtap', [e, this.props.target]);\n this.parent?.onPressOut(e);\n }, 200);\n this.isLongTap = true;\n }\n \n onPressOut(e: SyntheticEvent): void {\n if(!e.propagationEnabled){\n return;\n } \n this.props.onTouchEnd && this.props.onTouchEnd(e);\n setTimeout(() => {\n this.props.target?.invokeEventCallback('onTouchend', [e, this.props.target]);\n this.parent?.onPressOut(e);\n }, 200);\n this.isLongTap = false;\n }\n private setParent(parent: Tappable) {\n if (parent && this.parent !== parent) {\n this.parent = parent;\n }\n }\n\n render() {\n const target = this.props.target;\n const commonProps = {\n ...(Platform.OS === 'android' || Platform.OS === 'web') ? {\n accessibilityLabel: this.props.testID,\n testID: this.props.testID\n }: {\n // accessible: false,\n testID: this.props.testID\n },\n ...this.props.accessibilityProps,\n disabled:get(target?.proxy, 'disabled'),\n style:this.props.styles,\n onPress:(e?: GestureResponderEvent) => {\n if ((e?.target as any)?.tagName === 'INPUT') {\n return;\n }\n this.onPress(new SyntheticEvent())\n },\n onLongPress:(e?: GestureResponderEvent) => this.onLongTap(new SyntheticEvent()),\n onPressOut:(e?: GestureResponderEvent) => this.onPressOut(new SyntheticEvent())\n };\n if (target?.props.onTap \n || target?.props.onLongtap \n || target?.props.onDoubletap \n || this.props.onTap \n || this.props.onLongTap \n || this.props.onDoubleTap) {\n return (\n <UIPreferencesConsumer>\n {(preferences: UI_PREFERENCES) => {\n return preferences.enableRipple != false ? (\n <ParentTappableContext.Consumer>{(parent) => {\n this.setParent(parent);\n return(\n <ParentTappableContext.Provider value={this}>\n <TouchableRipple \n rippleColor={this.props.disableTouchEffect ? \"transparent\" : this.props.rippleColor} \n borderless={true} \n {...commonProps}\n onLayout={this.props.onLayout}\n >\n <>{this.props.children}</>\n </TouchableRipple>\n </ParentTappableContext.Provider>\n )\n }}</ParentTappableContext.Consumer>): (\n //default value is 0.2\n <TouchableOpacity \n activeOpacity={this.props.disableTouchEffect ? 1 : 0.2} \n onLayout={this.props.onLayout}\n {...commonProps}\n >\n <>{this.props.children}</>\n </TouchableOpacity>);\n }}\n </UIPreferencesConsumer>\n );\n }\n return (\n <View \n style={this.props.styles}\n onLayout={this.props.onLayout}\n {...this.props.accessibilityProps}\n >\n {this.props.children}\n </View>);\n }\n}\n"],"mappings":";;;;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAgCC,QAAQ,EAAEC,IAAI,EAAEC,gBAAgB,QAAQ,cAAc;AACtF,SAASC,GAAG,QAAQ,QAAQ;AAC5B,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,eAAe,QAAQ,oBAAoB;AAIpD,OAAO,MAAMC,eAAe,gBAAGP,KAAK,CAACQ,aAAa,CAAW,IAAW,CAAC;AACzE,SAASC,qBAAqB,QAAwB,0BAA0B;AAEhF,OAAO,MAAMC,qBAAqB,gBAAGV,KAAK,CAACQ,aAAa,CAAW,IAAW,CAAC;AAiB/E,OAAO,MAAMG,cAAc,CAAC;EAIxBC,WAAWA,CAAA,EAAG;IAHd;IAAAC,eAAA,6BACqB,IAAI;EAIzB;EAEAC,eAAeA,CAAA,EAAG;IACd,IAAI,CAACC,kBAAkB,GAAG,KAAK;EACnC;AACJ;AAEA,OAAO,MAAMC,QAAQ,SAAShB,KAAK,CAACiB,SAAS,CAAqB;EAO9DL,WAAWA,CAACM,KAAU,EAAE;IACpB,KAAK,CAACA,KAAK,CAAC;IAACL,eAAA,oBAPG,CAAC;IAAAA,eAAA,kBACH,CAAC;IAAAA,eAAA,wBACK,CAAC;IAAAA,eAAA,oBACL,KAAK;IAAAA,eAAA,iBACC,IAAI;EAI9B;EAEA,MAAMM,UAAUA,CAACC,CAAC,GAAG,IAAIT,cAAc,CAAC,CAAC,EAAE;IAAA,IAAAU,YAAA;IACvC,IAAI,CAACD,CAAC,CAACL,kBAAkB,EAAE;MACvB;IACJ;IACA,MAAMO,MAAM,GAAG,IAAI,CAACJ,KAAK,CAACI,MAAM;IAChC,IAAI,IAAI,CAACJ,KAAK,CAACK,KAAK,EAAE;MAClB,MAAM,IAAI,CAACL,KAAK,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ity","get","injector","TouchableRipple","TappableContext","createContext","UIPreferencesConsumer","ParentTappableContext","SyntheticEvent","constructor","_defineProperty","stopPropagation","propagationEnabled","Tappable","Component","props","triggerTap","e","_this$parent","target","onTap","invokeEventCallback","parent","onPress","_this$props$target","lastPress","Date","now","onTouchStart","currentTime","tapDelta","lastTap","isLongTap","_injector$FOCUSED_ELE","FOCUSED_ELEMENT","blur","lastDoubleTap","onDoubleTap","setTimeout","_this$parent2","onLongTap","_this$props$target2","_this$parent3","onPressOut","onTouchEnd","_this$props$target3","_this$parent4","setParent","render","commonProps","OS","accessibilityLabel","testID","accessible","accessibilityProps","disabled","proxy","style","styles","_e$target","tagName","onLongPress","onLongtap","onDoubletap","createElement","preferences","enableRipple","Consumer","Provider","value","_extends","rippleColor","disableTouchEffect","borderless","onLayout","Fragment","children","activeOpacity"],"sources":["tappable.component.tsx"],"sourcesContent":["import { BaseComponent } from \"@wavemaker/app-rn-runtime/core/base.component\";\nimport React from \"react\";\nimport { GestureResponderEvent, Platform, View, TouchableOpacity } from \"react-native\";\nimport { get } from \"lodash\";\nimport injector from \"./injector\";\nimport { TouchableRipple } from \"react-native-paper\";\nimport ThemeVariables from \"../styles/theme.variables\";\nimport { isDefined } from \"./utils\";\n\nexport const TappableContext = React.createContext<Tappable>(null as any);\nimport { UIPreferencesConsumer, UI_PREFERENCES } from \"./ui-preferences.context\";\n\nexport const ParentTappableContext = React.createContext<Tappable>(null as any);\ninterface TappableProps {\n testID?: string;\n children?: any\n styles?: any;\n target?: BaseComponent<any, any, any>;\n onTap?: (e: any) => void;\n onLongTap?: (e: any) => void; \n onDoubleTap?: (e: any) => void;\n onTouchStart? : (e: any) => void;\n onTouchEnd? : (e: any) => void;\n rippleColor?: string;\n accessibilityProps?: any;\n disableTouchEffect?:boolean;\n onLayout?: any;\n}\n\nexport class SyntheticEvent {\n // as the event is being used in onPress, onPressOut and onLongTap the TapEvent is renamed to SyntheticEvent\n propagationEnabled = true;\n \n constructor() {\n\n }\n\n stopPropagation() {\n this.propagationEnabled = false;\n }\n}\n\nexport class Tappable extends React.Component<TappableProps, any> {\n private lastPress = 0;\n private lastTap = 0;\n private lastDoubleTap = 0;\n private isLongTap = false;\n private parent:Tappable = null as any;\n \n constructor(props: any) {\n super(props);\n }\n\n async triggerTap(e = new SyntheticEvent()) {\n if (!e.propagationEnabled) {\n return;\n }\n const target = this.props.target;\n if (this.props.onTap) {\n await this.props.onTap(e);\n } else {\n await target?.invokeEventCallback('onTap', [e, target]);\n }\n this.parent?.triggerTap(e);\n }\n\n onPress(e: SyntheticEvent): void { \n this.lastPress = Date.now();\n const target = this.props.target;\n this.props.onTouchStart && this.props.onTouchStart(e);\n this.props.target?.invokeEventCallback('onTouchstart', [e, this.props.target]);\n const currentTime = Date.now();\n const tapDelta = currentTime - this.lastTap;\n if (this.isLongTap) {\n this.isLongTap = false;\n return;\n }\n if (e.propagationEnabled) {\n injector.FOCUSED_ELEMENT.get()?.blur();\n if(this.lastDoubleTap !== this.lastTap \n && tapDelta < 500) {\n this.props.onDoubleTap && this.props.onDoubleTap(e);\n setTimeout(() => {\n target?.invokeEventCallback('onDoubletap', [e, target]);\n }, 200);\n this.lastDoubleTap = currentTime;\n }\n setTimeout(() => {\n if (!e.propagationEnabled) {\n return;\n }\n if (this.props.onTap) {\n this.props.onTap(e);\n } else {\n target?.invokeEventCallback('onTap', [e, target]);\n }\n this.parent?.onPress(e);\n }, 200);\n this.lastTap = currentTime;\n }\n }\n\n onLongTap(e: SyntheticEvent): void {\n if(!e.propagationEnabled){\n return;\n }\n this.props.onLongTap && this.props.onLongTap(e);\n setTimeout(() => {\n this.props.target?.invokeEventCallback('onLongtap', [e, this.props.target]);\n this.parent?.onPressOut(e);\n }, 200);\n this.isLongTap = true;\n }\n \n onPressOut(e: SyntheticEvent): void {\n if(!e.propagationEnabled){\n return;\n } \n this.props.onTouchEnd && this.props.onTouchEnd(e);\n setTimeout(() => {\n this.props.target?.invokeEventCallback('onTouchend', [e, this.props.target]);\n this.parent?.onPressOut(e);\n }, 200);\n this.isLongTap = false;\n }\n private setParent(parent: Tappable) {\n if (parent && this.parent !== parent) {\n this.parent = parent;\n }\n }\n\n render() {\n const target = this.props.target;\n const commonProps = {\n ...(Platform.OS === 'android' || Platform.OS === 'web') ? {\n accessibilityLabel: this.props.testID,\n testID: this.props.testID\n }: {\n accessible: false,\n testID: this.props.testID\n },\n ...this.props.accessibilityProps,\n disabled:get(target?.proxy, 'disabled'),\n style:this.props.styles,\n onPress:(e?: GestureResponderEvent) => {\n if ((e?.target as any)?.tagName === 'INPUT') {\n return;\n }\n this.onPress(new SyntheticEvent())\n },\n onLongPress:(e?: GestureResponderEvent) => this.onLongTap(new SyntheticEvent()),\n onPressOut:(e?: GestureResponderEvent) => this.onPressOut(new SyntheticEvent())\n };\n if (target?.props.onTap \n || target?.props.onLongtap \n || target?.props.onDoubletap \n || this.props.onTap \n || this.props.onLongTap \n || this.props.onDoubleTap) {\n return (\n <UIPreferencesConsumer>\n {(preferences: UI_PREFERENCES) => {\n return preferences.enableRipple != false ? (\n <ParentTappableContext.Consumer>{(parent) => {\n this.setParent(parent);\n return(\n <ParentTappableContext.Provider value={this}>\n <TouchableRipple \n rippleColor={this.props.disableTouchEffect ? \"transparent\" : this.props.rippleColor} \n borderless={true} \n {...commonProps}\n onLayout={this.props.onLayout}\n >\n <>{this.props.children}</>\n </TouchableRipple>\n </ParentTappableContext.Provider>\n )\n }}</ParentTappableContext.Consumer>): (\n //default value is 0.2\n <TouchableOpacity \n activeOpacity={this.props.disableTouchEffect ? 1 : 0.2} \n onLayout={this.props.onLayout}\n {...commonProps}\n >\n <>{this.props.children}</>\n </TouchableOpacity>);\n }}\n </UIPreferencesConsumer>\n );\n }\n return (\n <View \n style={this.props.styles}\n onLayout={this.props.onLayout}\n {...this.props.accessibilityProps}\n >\n {this.props.children}\n </View>);\n }\n}\n"],"mappings":";;;;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAgCC,QAAQ,EAAEC,IAA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