@wavemaker/app-rn-runtime 12.0.0-next.140535 → 12.0.0-next.140537

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. app-rn-runtime/components/advanced/carousel/carousel.component.js +7 -7
  2. app-rn-runtime/components/advanced/carousel/carousel.component.js.map +1 -1
  3. app-rn-runtime/components/advanced/carousel/carousel.styles.js +3 -3
  4. app-rn-runtime/components/advanced/carousel/carousel.styles.js.map +1 -1
  5. app-rn-runtime/components/basic/audio/audio.component.js +9 -2
  6. app-rn-runtime/components/basic/audio/audio.component.js.map +1 -1
  7. app-rn-runtime/components/basic/audio/audio.styles.js +7 -0
  8. app-rn-runtime/components/basic/audio/audio.styles.js.map +1 -1
  9. app-rn-runtime/components/basic/custom/custom.component.js +1 -1
  10. app-rn-runtime/components/basic/custom/custom.component.js.map +1 -1
  11. app-rn-runtime/components/basic/lottie/lottie.component.js +3 -1
  12. app-rn-runtime/components/basic/lottie/lottie.component.js.map +1 -1
  13. app-rn-runtime/components/basic/search/search.component.js +6 -9
  14. app-rn-runtime/components/basic/search/search.component.js.map +1 -1
  15. app-rn-runtime/components/basic/search/search.props.js +1 -0
  16. app-rn-runtime/components/basic/search/search.props.js.map +1 -1
  17. app-rn-runtime/components/basic/search/search.styles.js +1 -2
  18. app-rn-runtime/components/basic/search/search.styles.js.map +1 -1
  19. app-rn-runtime/components/basic/skeleton/skeleton.component.js +2 -0
  20. app-rn-runtime/components/basic/skeleton/skeleton.component.js.map +1 -1
  21. app-rn-runtime/components/basic/video/video.component.js +6 -0
  22. app-rn-runtime/components/basic/video/video.component.js.map +1 -1
  23. app-rn-runtime/components/basic/video/video.styles.js +7 -1
  24. app-rn-runtime/components/basic/video/video.styles.js.map +1 -1
  25. app-rn-runtime/components/chart/area-chart/area-chart.component.js +2 -1
  26. app-rn-runtime/components/chart/area-chart/area-chart.component.js.map +1 -1
  27. app-rn-runtime/components/chart/pie-chart/pie-chart.component.js +2 -1
  28. app-rn-runtime/components/chart/pie-chart/pie-chart.component.js.map +1 -1
  29. app-rn-runtime/components/container/accordion/accordion.component.js +14 -7
  30. app-rn-runtime/components/container/accordion/accordion.component.js.map +1 -1
  31. app-rn-runtime/components/container/accordion/accordionpane/accordionpane.component.js +7 -0
  32. app-rn-runtime/components/container/accordion/accordionpane/accordionpane.component.js.map +1 -1
  33. app-rn-runtime/components/container/container.component.js +8 -1
  34. app-rn-runtime/components/container/container.component.js.map +1 -1
  35. app-rn-runtime/components/container/container.props.js +1 -0
  36. app-rn-runtime/components/container/container.props.js.map +1 -1
  37. app-rn-runtime/components/container/layoutgrid/layoutgrid.component.js +2 -1
  38. app-rn-runtime/components/container/layoutgrid/layoutgrid.component.js.map +1 -1
  39. app-rn-runtime/components/container/panel/panel.component.js +2 -1
  40. app-rn-runtime/components/container/panel/panel.component.js.map +1 -1
  41. app-rn-runtime/components/container/tabs/tabpane/tabpane.component.js +7 -0
  42. app-rn-runtime/components/container/tabs/tabpane/tabpane.component.js.map +1 -1
  43. app-rn-runtime/components/container/tabs/tabpane/tabpane.props.js +1 -0
  44. app-rn-runtime/components/container/tabs/tabpane/tabpane.props.js.map +1 -1
  45. app-rn-runtime/components/container/tabs/tabs.component.js +14 -4
  46. app-rn-runtime/components/container/tabs/tabs.component.js.map +1 -1
  47. app-rn-runtime/components/container/tile/tile.component.js +5 -1
  48. app-rn-runtime/components/container/tile/tile.component.js.map +1 -1
  49. app-rn-runtime/components/container/wizard/wizard.component.js +12 -4
  50. app-rn-runtime/components/container/wizard/wizard.component.js.map +1 -1
  51. app-rn-runtime/components/container/wizard/wizardstep/wizardstep.component.js +4 -0
  52. app-rn-runtime/components/container/wizard/wizardstep/wizardstep.component.js.map +1 -1
  53. app-rn-runtime/components/data/card/card.styles.js.map +1 -1
  54. app-rn-runtime/components/data/form/form-field/form-field.component.js +2 -1
  55. app-rn-runtime/components/data/form/form-field/form-field.component.js.map +1 -1
  56. app-rn-runtime/components/data/list/list-template/list-template.styles.js +1 -1
  57. app-rn-runtime/components/data/list/list-template/list-template.styles.js.map +1 -1
  58. app-rn-runtime/components/input/baseinput/baseinput.component.js +46 -10
  59. app-rn-runtime/components/input/baseinput/baseinput.component.js.map +1 -1
  60. app-rn-runtime/components/input/basenumber/basenumber.component.js +19 -6
  61. app-rn-runtime/components/input/basenumber/basenumber.component.js.map +1 -1
  62. app-rn-runtime/components/input/calendar/calendar.component.js +25 -0
  63. app-rn-runtime/components/input/calendar/calendar.component.js.map +1 -1
  64. app-rn-runtime/components/input/calendar/calendar.styles.js +19 -0
  65. app-rn-runtime/components/input/calendar/calendar.styles.js.map +1 -1
  66. app-rn-runtime/components/input/checkbox/checkbox.component.js +23 -3
  67. app-rn-runtime/components/input/checkbox/checkbox.component.js.map +1 -1
  68. app-rn-runtime/components/input/checkbox/checkbox.styles.js +19 -2
  69. app-rn-runtime/components/input/checkbox/checkbox.styles.js.map +1 -1
  70. app-rn-runtime/components/input/checkboxset/checkboxset.component.js +1 -1
  71. app-rn-runtime/components/input/checkboxset/checkboxset.component.js.map +1 -1
  72. app-rn-runtime/components/input/checkboxset/checkboxset.styles.js +1 -0
  73. app-rn-runtime/components/input/checkboxset/checkboxset.styles.js.map +1 -1
  74. app-rn-runtime/components/input/chips/chips.component.js +16 -2
  75. app-rn-runtime/components/input/chips/chips.component.js.map +1 -1
  76. app-rn-runtime/components/input/chips/chips.styles.js +8 -0
  77. app-rn-runtime/components/input/chips/chips.styles.js.map +1 -1
  78. app-rn-runtime/components/input/currency/currency.component.js +14 -4
  79. app-rn-runtime/components/input/currency/currency.component.js.map +1 -1
  80. app-rn-runtime/components/input/currency/currency.styles.js +43 -1
  81. app-rn-runtime/components/input/currency/currency.styles.js.map +1 -1
  82. app-rn-runtime/components/input/epoch/base-datetime.component.js +26 -5
  83. app-rn-runtime/components/input/epoch/base-datetime.component.js.map +1 -1
  84. app-rn-runtime/components/input/epoch/datetime/datetime.props.js +6 -0
  85. app-rn-runtime/components/input/epoch/datetime/datetime.props.js.map +1 -1
  86. app-rn-runtime/components/input/epoch/datetime/datetime.styles.js +13 -0
  87. app-rn-runtime/components/input/epoch/datetime/datetime.styles.js.map +1 -1
  88. app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.component.js +7 -4
  89. app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.component.js.map +1 -1
  90. app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.props.js +3 -0
  91. app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.props.js.map +1 -1
  92. app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.component.js +7 -4
  93. app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.component.js.map +1 -1
  94. app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.props.js +3 -0
  95. app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.props.js.map +1 -1
  96. app-rn-runtime/components/input/number/number.component.js +17 -3
  97. app-rn-runtime/components/input/number/number.component.js.map +1 -1
  98. app-rn-runtime/components/input/number/number.styles.js +24 -1
  99. app-rn-runtime/components/input/number/number.styles.js.map +1 -1
  100. app-rn-runtime/components/input/radioset/radioset.component.js +13 -8
  101. app-rn-runtime/components/input/radioset/radioset.component.js.map +1 -1
  102. app-rn-runtime/components/input/radioset/radioset.props.js +1 -0
  103. app-rn-runtime/components/input/radioset/radioset.props.js.map +1 -1
  104. app-rn-runtime/components/input/radioset/radioset.styles.js +7 -0
  105. app-rn-runtime/components/input/radioset/radioset.styles.js.map +1 -1
  106. app-rn-runtime/components/input/select/select.component.js +11 -3
  107. app-rn-runtime/components/input/select/select.component.js.map +1 -1
  108. app-rn-runtime/components/input/select/select.styles.js +24 -0
  109. app-rn-runtime/components/input/select/select.styles.js.map +1 -1
  110. app-rn-runtime/components/input/switch/switch.component.js +13 -3
  111. app-rn-runtime/components/input/switch/switch.component.js.map +1 -1
  112. app-rn-runtime/components/input/switch/switch.styles.js +15 -0
  113. app-rn-runtime/components/input/switch/switch.styles.js.map +1 -1
  114. app-rn-runtime/components/input/text/text.component.js +5 -2
  115. app-rn-runtime/components/input/text/text.component.js.map +1 -1
  116. app-rn-runtime/components/input/text/text.props.js +1 -0
  117. app-rn-runtime/components/input/text/text.props.js.map +1 -1
  118. app-rn-runtime/components/input/text/text.styles.js +3 -0
  119. app-rn-runtime/components/input/text/text.styles.js.map +1 -1
  120. app-rn-runtime/components/input/textarea/textarea.component.js +3 -1
  121. app-rn-runtime/components/input/textarea/textarea.component.js.map +1 -1
  122. app-rn-runtime/components/input/textarea/textarea.styles.js +3 -0
  123. app-rn-runtime/components/input/textarea/textarea.styles.js.map +1 -1
  124. app-rn-runtime/components/input/toggle/toggle.component.js +6 -0
  125. app-rn-runtime/components/input/toggle/toggle.component.js.map +1 -1
  126. app-rn-runtime/components/input/toggle/toggle.props.js +2 -0
  127. app-rn-runtime/components/input/toggle/toggle.props.js.map +1 -1
  128. app-rn-runtime/components/input/toggle/toggle.styles.js +7 -0
  129. app-rn-runtime/components/input/toggle/toggle.styles.js.map +1 -1
  130. app-rn-runtime/components/page/content/content.component.js.map +1 -1
  131. app-rn-runtime/components/page/left-panel/left-panel.component.js +4 -1
  132. app-rn-runtime/components/page/left-panel/left-panel.component.js.map +1 -1
  133. app-rn-runtime/components/page/page-content/page-content.component.js +43 -12
  134. app-rn-runtime/components/page/page-content/page-content.component.js.map +1 -1
  135. app-rn-runtime/components/page/partial/partial.component.js +6 -1
  136. app-rn-runtime/components/page/partial/partial.component.js.map +1 -1
  137. app-rn-runtime/components/page/partial/partial.styles.js.map +1 -1
  138. app-rn-runtime/components/prefab/prefab-container.component.js +5 -1
  139. app-rn-runtime/components/prefab/prefab-container.component.js.map +1 -1
  140. app-rn-runtime/core/AppConfig.js.map +1 -1
  141. app-rn-runtime/core/base.component.js +31 -5
  142. app-rn-runtime/core/base.component.js.map +1 -1
  143. app-rn-runtime/core/components/textinput.component.js +9 -7
  144. app-rn-runtime/core/components/textinput.component.js.map +1 -1
  145. app-rn-runtime/core/props.provider.js +0 -1
  146. app-rn-runtime/core/props.provider.js.map +1 -1
  147. app-rn-runtime/core/storage.service.js +15 -0
  148. app-rn-runtime/core/storage.service.js.map +1 -1
  149. app-rn-runtime/core/tappable.component.js +10 -4
  150. app-rn-runtime/core/tappable.component.js.map +1 -1
  151. app-rn-runtime/core/wm-component-tree.js +58 -0
  152. app-rn-runtime/core/wm-component-tree.js.map +1 -0
  153. app-rn-runtime/package.json +13 -6
  154. app-rn-runtime/runtime/App.js +23 -9
  155. app-rn-runtime/runtime/App.js.map +1 -1
  156. app-rn-runtime/runtime/App.navigator.js +1 -0
  157. app-rn-runtime/runtime/App.navigator.js.map +1 -1
  158. app-rn-runtime/runtime/base-fragment.component.js +18 -0
  159. app-rn-runtime/runtime/base-fragment.component.js.map +1 -1
  160. app-rn-runtime/runtime/base-page.component.js +38 -2
  161. app-rn-runtime/runtime/base-page.component.js.map +1 -1
  162. app-rn-runtime/runtime/base-partial.component.js +3 -0
  163. app-rn-runtime/runtime/base-partial.component.js.map +1 -1
  164. app-rn-runtime/runtime/navigator/drawer.navigator.js +19 -10
  165. app-rn-runtime/runtime/navigator/drawer.navigator.js.map +1 -1
  166. app-rn-runtime/runtime/services/app-modal.service.js +4 -4
  167. app-rn-runtime/runtime/services/app-modal.service.js.map +1 -1
  168. app-rn-runtime/runtime/services/app-security.service.js +17 -1
  169. app-rn-runtime/runtime/services/app-security.service.js.map +1 -1
  170. app-rn-runtime/styles/theme.js +10 -0
  171. app-rn-runtime/styles/theme.js.map +1 -1
  172. app-rn-runtime/styles/theme.variables.js +1 -1
  173. app-rn-runtime/styles/theme.variables.js.map +1 -1
  174. app-rn-runtime/variables/http.service.js +5 -1
  175. app-rn-runtime/variables/http.service.js.map +1 -1
  176. app-rn-runtime/variables/live-variable.js +14 -0
  177. app-rn-runtime/variables/live-variable.js.map +1 -1
@@ -36,7 +36,6 @@ const WmCursor = /*#__PURE__*/React.memo(props => {
36
36
  export const WMTextInput = /*#__PURE__*/React.forwardRef((props, ref) => {
37
37
  var _props$customDisplayV, _props$floatingLabel;
38
38
  const [selectRange, setSelectRange] = useState(null);
39
- const [isInputFocused, setIsInputFocused] = useState(false);
40
39
  const [iMask, setIMask] = useState(null);
41
40
  const [displayCursor, setDisplayCursor] = useState(false);
42
41
  const value = useRef(props.value || '');
@@ -127,12 +126,12 @@ export const WMTextInput = /*#__PURE__*/React.forwardRef((props, ref) => {
127
126
  opts[valueExpr] = (_props$customDisplayV = props.customDisplayValue) !== null && _props$customDisplayV !== void 0 ? _props$customDisplayV : value.current;
128
127
  const textStyle = Object.assign({}, ...(isArray(props.style) ? props.style : [props.style]));
129
128
  const hideInput = props.displayformat || props.maskchar;
130
- return /*#__PURE__*/React.createElement(React.Fragment, null, props.floatingLabel ? /*#__PURE__*/React.createElement(FloatingLabel, {
131
- moveUp: !!(value.current || isInputFocused || displayValue),
129
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.background, props.floatingLabel ? /*#__PURE__*/React.createElement(FloatingLabel, {
130
+ moveUp: !!(value.current || props.isInputFocused || displayValue),
132
131
  label: (_props$floatingLabel = props.floatingLabel) !== null && _props$floatingLabel !== void 0 ? _props$floatingLabel : props.placeholder,
133
132
  style: {
134
133
  ...(props.floatingLabelStyle || []),
135
- ...(isInputFocused ? props.activeFloatingLabelStyle || {} : {})
134
+ ...(props.isInputFocused ? props.activeFloatingLabelStyle || {} : {})
136
135
  }
137
136
  }) : null, /*#__PURE__*/React.createElement(TextInput, _extends({}, props, hideInput || props.customDisplayValue ? opts : {}, {
138
137
  placeholder: props.floatingLabel || displayValue ? '' : props.placeholder,
@@ -145,14 +144,12 @@ export const WMTextInput = /*#__PURE__*/React.forwardRef((props, ref) => {
145
144
  onFocus: e => {
146
145
  var _props$onFocus;
147
146
  (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, e);
148
- setIsInputFocused(true);
149
147
  setDisplayCursor(true);
150
148
  element.current = e.target;
151
149
  },
152
150
  onBlur: e => {
153
151
  var _props$onBlur;
154
152
  props === null || props === void 0 || (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, e);
155
- setIsInputFocused(false);
156
153
  setDisplayCursor(false);
157
154
  },
158
155
  ref: ref,
@@ -160,6 +157,10 @@ export const WMTextInput = /*#__PURE__*/React.forwardRef((props, ref) => {
160
157
  onSelectionChange: onSelectionChange,
161
158
  caretHidden: !!(selectRange !== null && selectRange !== void 0 && selectRange.end),
162
159
  onChangeText: text => {
160
+ if (props.autoCapitalize && props.autoCapitalize === 'characters') {
161
+ onChangeText(text.toUpperCase());
162
+ return;
163
+ }
163
164
  onChangeText(text);
164
165
  }
165
166
  }, hideInput ? {
@@ -167,7 +168,8 @@ export const WMTextInput = /*#__PURE__*/React.forwardRef((props, ref) => {
167
168
  cursorColor: 'transparent',
168
169
  onChange: () => {}
169
170
  } : {}, {
170
- contextMenuHidden: !props.allowContentSelection
171
+ contextMenuHidden: !props.allowContentSelection,
172
+ autoCapitalize: props.autoCapitalize
171
173
  })), hideInput ? /*#__PURE__*/React.createElement(View, {
172
174
  style: [props.style, {
173
175
  display: 'flex',
@@ -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","WMTextInput","forwardRef","ref","_props$customDisplayV","_props$floatingLabel","selectRange","setSelectRange","isInputFocused","setIsInputFocused","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","floatingLabel","moveUp","label","placeholder","floatingLabelStyle","activeFloatingLabelStyle","_extends","borderColor","zIndex","onFocus","_props$onFocus","call","target","onBlur","_props$onBlur","caretHidden","selectionColor","cursorColor","onChange","contextMenuHidden","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 } 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,\n activeFloatingLabelStyle: TextStyle,\n customDisplayValue?: string\n }), \n ref: ForwardedRef<TextInput>) => {\n const [selectRange, setSelectRange] = useState<SelectRange>(null as any);\n const [isInputFocused, setIsInputFocused] = useState(false);\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.floatingLabel ? (\n <FloatingLabel\n moveUp={!!(value.current || isInputFocused || displayValue)}\n label={props.floatingLabel ?? props.placeholder} \n style={{\n ...(props.floatingLabelStyle || []),\n ...(isInputFocused ? (props.activeFloatingLabelStyle || {}) : {})\n }}/>\n ) : null}\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 setIsInputFocused(true);\n setDisplayCursor(true);\n element.current = e.target;\n }}\n onBlur={(e) => {\n props?.onBlur?.(e);\n setIsInputFocused(false);\n setDisplayCursor(false);\n }}\n ref={ref}\n selection={selectRange}\n onSelectionChange={onSelectionChange}\n caretHidden={!!selectRange?.end}\n onChangeText={(text) => {\n onChangeText(text);\n }}\n {...hideInput ? {\n selectionColor: 'transparent',\n cursorColor: 'transparent',\n onChange : () => {}\n }: {}}\n contextMenuHidden={!props.allowContentSelection}\n ></TextInput>\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.fontS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9BoE,WAAW,EAAE,aAAa;MAC1BmB,OAAO,EAAE,CAAC;MACVN,OAAO,EAAE,MAAM;MACfhF,KAAK,EAAEuD,SAAS,CAACvD,KAAK;MACtBuF,UAAU,EAAEhC,SAAS,CAACgC,UAAU;MAChCC,QAAQ,EAAEjC,SAAS,CAACiC,QAAQ;MAC5BC,UAAU,EAAElC,SAAS,CAACkC;IACtB;EAAE,GACDpE,YACG,CAAC,EAEJL,aAAa,IAAI,CAAC9B,KAAK,CAACsC,aAAa,gBAAIrD,KAAK,CAACyB,aAAa,CAACZ,QAAQ,EAAE;IACtEgB,KAAK,EAAEuD,SAAS,CAACvD,KAAK,IAAI,SAAS;IACnCG,MAAM,EAAEoD,SAAS,CAACiC,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","_extends","borderColor","zIndex","onFocus","_props$onFocus","call","target","onBlur","_props$onBlur","caretHidden","autoCapitalize","toUpperCase","selectionColor","cursorColor","onChange","contextMenuHidden","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 } 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,\n activeFloatingLabelStyle: TextStyle,\n customDisplayValue?: string,\n isInputFocused: boolean\n autoCapitalize?: string,\n background?: React.ReactNode\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 <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 ></TextInput>\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});"],"mappings":";AAAA,OAAOA,KAA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EAAEsF,SAAS;MAChBxF,eAAe,EAAE,aAAa;MAC9BoE,WAAW,EAAE,aAAa;MAC1BqB,OAAO,EAAE,CAAC;MACVN,OAAO,EAAE,MAAM;MACflF,KAAK,EAAEqD,SAAS,CAACrD,KAAK;MACtByF,UAAU,EAAEpC,SAAS,CAACoC,UAAU;MAChCC,QAAQ,EAAErC,SAAS,CAACqC,QAAQ;MAC5BC,UAAU,EAAEtC,SAAS,CAACsC;IACtB;EAAE,GACDxE,YACG,CAAC,EAEJL,aAAa,IAAI,CAAC5B,KAAK,CAACoC,aAAa,gBAAInD,KAAK,CAACyB,aAAa,CAACZ,QAAQ,EAAE;IACtEgB,KAAK,EAAEqD,SAAS,CAACrD,KAAK,IAAI,SAAS;IACnCG,MAAM,EAAEkD,SAAS,CAACqC,QAAQ,IAAI;EAChC,CAAC,CAAC,GAAG,IAEH,CAAC,GACL,IAEN,CAAC;AAET,CAAC,CAAC","ignoreList":[]}
@@ -72,7 +72,6 @@ export class PropsProvider {
72
72
 
73
73
  // sets the property. But, value gets overriden when the original prop changes.
74
74
  set(name, value) {
75
- this.oldProps[name] = value;
76
75
  const oldValue = this.oldProps[name];
77
76
  if (oldValue !== value) {
78
77
  this.oldProps[name] = value;
@@ -1 +1 @@
1
- {"version":3,"names":["assign","isNil","PropsProvider","constructor","defaultProps","initprops","onChange","name","$new","$old","_defineProperty","Object","keys","forEach","k","propertyNames","propsProxy","Proxy","get","target","prop","receiver","propName","toString","value","overriddenProps","hasOwnProperty","oldProps","set","has","isDirty","oldValue","setDefault","overrideProp","check","nextProps","result","reduce","b","flag"],"sources":["props.provider.ts"],"sourcesContent":["import { assign, isNil } from \"lodash-es\";\nimport { BaseProps } from \"./base.component\";\n\nexport class PropsProvider<T extends BaseProps> {\n private oldProps: any = {};\n private overriddenProps: any = {};\n private propsProxy: T;\n private isDirty = false;\n private propertyNames = {} as any;\n\n constructor(private defaultProps: T, private initprops: T, private onChange = (name: string, $new: any, $old: any) => {}) {\n this.initprops = this.initprops || {};\n Object.keys(defaultProps).forEach(k => this.propertyNames[k] = true);\n Object.keys(initprops).forEach(k => this.propertyNames[k] = true);\n //@ts-ignore\n this.propsProxy = (new Proxy({}, {\n get: (target, prop, receiver): any => {\n const propName = prop.toString();\n let value = (this.defaultProps as any)[propName];\n if (this.overriddenProps.hasOwnProperty(propName)) {\n value = this.overriddenProps[propName];\n } else if (this.oldProps.hasOwnProperty(propName)) {\n value = this.oldProps[propName];\n }\n return value;\n },\n set: (target: any, prop, value: any): any => {\n const propName = prop.toString();\n if (!this.has(propName)) {\n return true;\n }\n this.isDirty = this.isDirty || this.overriddenProps[propName] !== value;\n this.overriddenProps[propName] = value;\n if (this.oldProps[propName] !== value) {\n const oldValue = this.oldProps[propName];\n this.onChange(propName, value, oldValue);\n this.oldProps[propName] = value;\n }\n return true;\n }\n }));\n }\n\n setDefault(propName: string, value: any) {\n (this.defaultProps as any)[propName] = value;\n }\n overrideProp(propName: string, value: any) {\n (this.overriddenProps as any)[propName] = value;\n this.isDirty = true;\n }\n\n check(nextProps?: T) {\n if (!nextProps) {\n nextProps = assign({}, this.defaultProps, this.initprops);\n }\n const result = Object.keys(nextProps).reduce((b, k) => {\n let flag = false;\n //@ts-ignore\n const value = nextProps[k];\n const oldValue = this.oldProps[k];\n if (isNil(this.overriddenProps[k])\n && (!this.oldProps.hasOwnProperty(k)\n || this.oldProps[k] !== value)) {\n this.oldProps[k] = value;\n this.onChange(k, value, oldValue);\n flag = true;\n }\n return b || flag;\n }, false) || this.isDirty;\n\n this.isDirty = false;\n return result;\n }\n\n // sets the property. But, value gets overriden when the original prop changes.\n set(name: string, value: any) {\n this.oldProps[name] = value;\n const oldValue = this.oldProps[name];\n if(oldValue !== value) {\n this.oldProps[name] = value;\n this.onChange(name, value, oldValue);\n }\n }\n\n has(propName: string) {\n return !!this.propertyNames[propName];\n }\n\n get() {\n return this.propsProxy;\n }\n}\n"],"mappings":";;;AAAA,SAASA,MAAM,EAAEC,KAAK,QAAQ,WAA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,CAACF,UAAU;EAC1B;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["assign","isNil","PropsProvider","constructor","defaultProps","initprops","onChange","name","$new","$old","_defineProperty","Object","keys","forEach","k","propertyNames","propsProxy","Proxy","get","target","prop","receiver","propName","toString","value","overriddenProps","hasOwnProperty","oldProps","set","has","isDirty","oldValue","setDefault","overrideProp","check","nextProps","result","reduce","b","flag"],"sources":["props.provider.ts"],"sourcesContent":["import { assign, isNil } from \"lodash-es\";\nimport { BaseProps } from \"./base.component\";\n\nexport class PropsProvider<T extends BaseProps> {\n private oldProps: any = {};\n private overriddenProps: any = {};\n private propsProxy: T;\n private isDirty = false;\n private propertyNames = {} as any;\n\n constructor(private defaultProps: T, private initprops: T, private onChange = (name: string, $new: any, $old: any) => {}) {\n this.initprops = this.initprops || {};\n Object.keys(defaultProps).forEach(k => this.propertyNames[k] = true);\n Object.keys(initprops).forEach(k => this.propertyNames[k] = true);\n //@ts-ignore\n this.propsProxy = (new Proxy({}, {\n get: (target, prop, receiver): any => {\n const propName = prop.toString();\n let value = (this.defaultProps as any)[propName];\n if (this.overriddenProps.hasOwnProperty(propName)) {\n value = this.overriddenProps[propName];\n } else if (this.oldProps.hasOwnProperty(propName)) {\n value = this.oldProps[propName];\n }\n return value;\n },\n set: (target: any, prop, value: any): any => {\n const propName = prop.toString();\n if (!this.has(propName)) {\n return true;\n }\n this.isDirty = this.isDirty || this.overriddenProps[propName] !== value;\n this.overriddenProps[propName] = value;\n if (this.oldProps[propName] !== value) {\n const oldValue = this.oldProps[propName];\n this.onChange(propName, value, oldValue);\n this.oldProps[propName] = value;\n }\n return true;\n }\n }));\n }\n\n setDefault(propName: string, value: any) {\n (this.defaultProps as any)[propName] = value;\n }\n overrideProp(propName: string, value: any) {\n (this.overriddenProps as any)[propName] = value;\n this.isDirty = true;\n }\n\n check(nextProps?: T) {\n if (!nextProps) {\n nextProps = assign({}, this.defaultProps, this.initprops);\n }\n const result = Object.keys(nextProps).reduce((b, k) => {\n let flag = false;\n //@ts-ignore\n const value = nextProps[k];\n const oldValue = this.oldProps[k];\n if (isNil(this.overriddenProps[k])\n && (!this.oldProps.hasOwnProperty(k)\n || this.oldProps[k] !== value)) {\n this.oldProps[k] = value;\n this.onChange(k, value, oldValue);\n flag = true;\n }\n return b || flag;\n }, false) || this.isDirty;\n\n this.isDirty = false;\n return result;\n }\n\n // sets the property. But, value gets overriden when the original prop changes.\n set(name: string, value: any) {\n const oldValue = this.oldProps[name];\n if(oldValue !== value) {\n this.oldProps[name] = value;\n this.onChange(name, value, oldValue);\n }\n }\n\n has(propName: string) {\n return !!this.propertyNames[propName];\n }\n\n get() {\n return this.propsProxy;\n }\n}\n"],"mappings":";;;AAAA,SAASA,MAAM,EAAEC,KAAK,QAAQ,WAAW;AAGzC,OAAO,MAAMC,aAAa,CAAsB;EAO5CC,WAAWA,CAASC,YAAe,EAAUC,SAAY,EAAUC,QAAQ,GAAGA,CAACC,IAAY,EAAEC,IAAS,EAAEC,IAAS,KAAK,CAAC,CAAC,EAAE;IAAA,KAAtGL,YAAe,GAAfA,YAAe;IAAA,KAAUC,SAAY,GAAZA,SAAY;IAAA,KAAUC,QAAQ,GAARA,QAAQ;IAAAI,eAAA,mBANnD,CAAC,CAAC;IAAAA,eAAA,0BACK,CAAC,CAAC;IAAAA,eAAA;IAAAA,eAAA,kBAEf,KAAK;IAAAA,eAAA,wBACC,CAAC,CAAC;IAGtB,IAAI,CAACL,SAAS,GAAG,IAAI,CAACA,SAAS,IAAI,CAAC,CAAC;IACrCM,MAAM,CAACC,IAAI,CAACR,YAAY,CAAC,CAACS,OAAO,CAACC,CAAC,IAAI,IAAI,CAACC,aAAa,CAACD,CAAC,CAAC,GAAG,IAAI,CAAC;IACpEH,MAAM,CAACC,IAAI,CAACP,SAAS,CAAC,CAACQ,OAAO,CAACC,CAAC,IAAI,IAAI,CAACC,aAAa,CAACD,CAAC,CAAC,GAAG,IAAI,CAAC;IACjE;IACA,IAAI,CAACE,UAAU,GAAI,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AAEiB,KAAU,EAAE;IAC1B,MAAMO,QAAQ,GAAG,IAAI,CAACJ,QAAQ,CAACpB,IAAI,CAAC;IACpC,IAAGwB,QAAQ,KAAKP,KAAK,EAAE;MACnB,IAAI,CAACG,QAAQ,CAACpB,IAAI,CAAC,GAAGiB,KAAK;MAC3B,IAAI,CAAClB,QAAQ,CAACC,IAAI,EAAEiB,KAAK,EAAEO,QAAQ,CAAC;IACxC;EACJ;EAEAF,GAAGA,CAACP,QAAgB,EAAE;IAClB,OAAO,CAAC,CAAC,IAAI,CAACP,aAAa,CAACO,QAAQ,CAAC;EACzC;EAEAJ,GAAGA,CAAA,EAAG;IACF,OAAO,IAAI,CAACF,UAAU;EAC1B;AACJ","ignoreList":[]}
@@ -18,6 +18,21 @@ export class StorageService {
18
18
  removeItem(key, callback) {
19
19
  return AsyncStorage.removeItem(this.getKey(key), callback);
20
20
  }
21
+ async getAll() {
22
+ const keys = await AsyncStorage.getAllKeys();
23
+ const entries = await Promise.all(keys.map(async k => {
24
+ const v = await AsyncStorage.getItem(k);
25
+ return {
26
+ key: k,
27
+ value: v
28
+ };
29
+ }));
30
+ const o = {};
31
+ entries.forEach(e => {
32
+ o[e.key] = e.value;
33
+ });
34
+ return o;
35
+ }
21
36
  }
22
37
  export default new StorageService();
23
38
  //# sourceMappingURL=storage.service.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AsyncStorage","StorageService","constructor","_defineProperty","getKey","key","target","getItem","callback","setItem","value","removeItem"],"sources":["storage.service.ts"],"sourcesContent":["import AsyncStorage from '@react-native-async-storage/async-storage';\n\nexport class StorageService {\n public target = 'GLOBAL';\n\n private getKey(key: string) {\n return `${this.target}_${key}`;\n }\n \n getItem(key: string, callback?: (error?: Error | null, result?: string | null) => void): Promise<string | null> {\n return AsyncStorage.getItem(this.getKey(key), callback);\n }\n setItem(key: string, value: string, callback?: (error?: Error | null) => void): Promise<void> {\n return AsyncStorage.setItem(this.getKey(key), value, callback);\n }\n removeItem(key: string, callback?: (error?: Error | null) => void): Promise<void> {\n return AsyncStorage.removeItem(this.getKey(key), callback);\n }\n}\n\nexport default new StorageService();\n"],"mappings":";;;AAAA,OAAOA,YAAY,MAAM,2CAA2C;AAEpE,OAAO,MAAMC,cAAc,CAAC;EAAAC,YAAA;IAAAC,eAAA,iBACV,QAAQ;EAAA;EAEhBC,MAAMA,CAACC,GAAW,EAAE;IAC1B,OAAO,GAAG,IAAI,CAACC,MAAM,IAAID,GAAG,EAAE;EAChC;EAEAE,OAAOA,CAACF,GAAW,EAAEG,QAAiE,EAA0B;IAC9G,OAAOR,YAAY,CAACO,OAAO,CAAC,IAAI,CAACH,MAAM,CAACC,GAAG,CAAC,EAAEG,QAAQ,CAAC;EACzD;EACAC,OAAOA,CAACJ,GAAW,EAAEK,KAAa,EAAEF,QAAyC,EAAiB;IAC5F,OAAOR,YAAY,CAACS,OAAO,CAAC,IAAI,CAACL,MAAM,CAACC,GAAG,CAAC,EAAEK,KAAK,EAAEF,QAAQ,CAAC;EAChE;EACAG,UAAUA,CAACN,GAAW,EAAEG,QAAyC,EAAiB;IAChF,OAAOR,YAAY,CAACW,UAAU,CAAC,IAAI,CAACP,MAAM,CAACC,GAAG,CAAC,EAAEG,QAAQ,CAAC;EAC5D;AACF;AAEA,eAAe,IAAIP,cAAc,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["AsyncStorage","StorageService","constructor","_defineProperty","getKey","key","target","getItem","callback","setItem","value","removeItem","getAll","keys","getAllKeys","entries","Promise","all","map","k","v","o","forEach","e"],"sources":["storage.service.ts"],"sourcesContent":["import AsyncStorage from '@react-native-async-storage/async-storage';\n\nexport class StorageService {\n public target = 'GLOBAL';\n\n private getKey(key: string) {\n return `${this.target}_${key}`;\n }\n \n getItem(key: string, callback?: (error?: Error | null, result?: string | null) => void): Promise<string | null> {\n return AsyncStorage.getItem(this.getKey(key), callback);\n }\n setItem(key: string, value: string, callback?: (error?: Error | null) => void): Promise<void> {\n return AsyncStorage.setItem(this.getKey(key), value, callback);\n }\n removeItem(key: string, callback?: (error?: Error | null) => void): Promise<void> {\n return AsyncStorage.removeItem(this.getKey(key), callback);\n }\n\n async getAll() {\n const keys = await AsyncStorage.getAllKeys();\n const entries = await Promise.all(keys.map(async k => {\n const v = await AsyncStorage.getItem(k);\n return {\n key: k,\n value: v\n };\n }));\n const o = {} as any;\n entries.forEach((e) => {\n o[e.key] = e.value;\n });\n return o;\n }\n}\n\nexport default new StorageService();\n"],"mappings":";;;AAAA,OAAOA,YAAY,MAAM,2CAA2C;AAEpE,OAAO,MAAMC,cAAc,CAAC;EAAAC,YAAA;IAAAC,eAAA,iBACV,QAAQ;EAAA;EAEhBC,MAAMA,CAACC,GAAW,EAAE;IAC1B,OAAO,GAAG,IAAI,CAACC,MAAM,IAAID,GAAG,EAAE;EAChC;EAEAE,OAAOA,CAACF,GAAW,EAAEG,QAAiE,EAA0B;IAC9G,OAAOR,YAAY,CAACO,OAAO,CAAC,IAAI,CAACH,MAAM,CAACC,GAAG,CAAC,EAAEG,QAAQ,CAAC;EACzD;EACAC,OAAOA,CAACJ,GAAW,EAAEK,KAAa,EAAEF,QAAyC,EAAiB;IAC5F,OAAOR,YAAY,CAACS,OAAO,CAAC,IAAI,CAACL,MAAM,CAACC,GAAG,CAAC,EAAEK,KAAK,EAAEF,QAAQ,CAAC;EAChE;EACAG,UAAUA,CAACN,GAAW,EAAEG,QAAyC,EAAiB;IAChF,OAAOR,YAAY,CAACW,UAAU,CAAC,IAAI,CAACP,MAAM,CAACC,GAAG,CAAC,EAAEG,QAAQ,CAAC;EAC5D;EAEA,MAAMI,MAAMA,CAAA,EAAG;IACb,MAAMC,IAAI,GAAG,MAAMb,YAAY,CAACc,UAAU,CAAC,CAAC;IAC5C,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAACJ,IAAI,CAACK,GAAG,CAAC,MAAMC,CAAC,IAAI;MACpD,MAAMC,CAAC,GAAG,MAAMpB,YAAY,CAACO,OAAO,CAACY,CAAC,CAAC;MACvC,OAAO;QACLd,GAAG,EAAEc,CAAC;QACNT,KAAK,EAAEU;MACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAMC,CAAC,GAAG,CAAC,CAAQ;IACnBN,OAAO,CAACO,OAAO,CAAEC,CAAC,IAAK;MACrBF,CAAC,CAACE,CAAC,CAAClB,GAAG,CAAC,GAAGkB,CAAC,CAACb,KAAK;IACpB,CAAC,CAAC;IACF,OAAOW,CAAC;EACV;AACF;AAEA,eAAe,IAAIpB,cAAc,CAAC,CAAC","ignoreList":[]}
@@ -9,6 +9,7 @@ import injector from "./injector";
9
9
  import { TouchableRipple } from "react-native-paper";
10
10
  export const TappableContext = /*#__PURE__*/React.createContext(null);
11
11
  import { UIPreferencesConsumer } from "./ui-preferences.context";
12
+ export const ParentTappableContext = /*#__PURE__*/React.createContext(null);
12
13
  export class SyntheticEvent {
13
14
  constructor() {
14
15
  // as the event is being used in onPress, onPressOut and onLongTap the TapEvent is renamed to SyntheticEvent
@@ -131,10 +132,15 @@ export class Tappable extends React.Component {
131
132
  };
132
133
  if (target !== null && target !== void 0 && target.props.onTap || target !== null && target !== void 0 && target.props.onLongtap || target !== null && target !== void 0 && target.props.onDoubletap || this.props.onTap || this.props.onLongTap || this.props.onDoubleTap) {
133
134
  return /*#__PURE__*/React.createElement(UIPreferencesConsumer, null, preferences => {
134
- return preferences.enableRipple != false ? /*#__PURE__*/React.createElement(TouchableRipple, _extends({
135
- rippleColor: this.props.rippleColor,
136
- borderless: true
137
- }, commonProps), /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children)) : /*#__PURE__*/React.createElement(TouchableOpacity, commonProps, /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children));
135
+ return preferences.enableRipple != false ? /*#__PURE__*/React.createElement(ParentTappableContext.Consumer, null, parent => {
136
+ this.setParent(parent);
137
+ return /*#__PURE__*/React.createElement(ParentTappableContext.Provider, {
138
+ value: this
139
+ }, /*#__PURE__*/React.createElement(TouchableRipple, _extends({
140
+ rippleColor: this.props.rippleColor,
141
+ borderless: true
142
+ }, commonProps), /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children)));
143
+ }) : /*#__PURE__*/React.createElement(TouchableOpacity, commonProps, /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children));
138
144
  });
139
145
  }
140
146
  return /*#__PURE__*/React.createElement(View, {
@@ -1 +1 @@
1
- {"version":3,"names":["React","Platform","View","TouchableOpacity","get","injector","TouchableRipple","TappableContext","createContext","UIPreferencesConsumer","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","_extends","rippleColor","borderless","Fragment","children"],"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\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}\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 <TouchableRipple rippleColor={this.props.rippleColor} borderless={true} {...commonProps}>\n <>{this.props.children}</>\n </TouchableRipple>): (\n <TouchableOpacity {...commonProps}>\n <>{this.props.children}</>\n </TouchableOpacity>);\n }}\n </UIPreferencesConsumer>\n );\n }\n return (<View style={this.props.styles}>{this.props.children}</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,OA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,aAAA,CAAC/D,IAAI;MAACwD,KAAK,EAAE,IAAI,CAACzC,KAAK,CAAC0C;IAAO,GAAE,IAAI,CAAC1C,KAAK,CAACuD,QAAe,CAAC;EACxE;AACJ","ignoreList":[]}
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","borderless","Fragment","children"],"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}\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( <ParentTappableContext.Provider value={this}>\n <TouchableRipple rippleColor={this.props.rippleColor} borderless={true} {...commonProps}>\n <>{this.props.children}</>\n </TouchableRipple>\n </ParentTappableContext.Provider>)}}</ParentTappableContext.Consumer>): (\n <TouchableOpacity {...commonProps}>\n <>{this.props.children}</>\n </TouchableOpacity>);\n }}\n </UIPreferencesConsumer>\n );\n }\n return (<View style={this.props.styles}>{this.props.children}</View>);\n }\n}\n"],"mappings":";;;;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAgCC,QAAQ,EAAEC,IAAI,EAAEC,gBAAgB,QAAQ,cAAc;AACtF,SAASC,GAAG,QAAQ,QAAQ;AAC5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,UAAU,EAAE;UAAK,GAAKtB,WAAW,gBACnFpD,KAAA,CAAAkE,aAAA,CAAAlE,KAAA,CAAA2E,QAAA,QAAG,IAAI,CAACzD,KAAK,CAAC0D,QAAW,CACZ,CACe,CAAC;QAAC,CAAkC,CAAC,gBACrE5E,KAAA,CAAAkE,aAAA,CAAC/D,gBAAgB,EAAKiD,WAAW,eAC7BpD,KAAA,CAAAkE,aAAA,CAAAlE,KAAA,CAAA2E,QAAA,QAAG,IAAI,CAACzD,KAAK,CAAC0D,QAAW,CACX,CAAE;MACxB,CACmB,CAAC;IAE5B;IACA,oBAAQ5E,KAAA,CAAAkE,aAAA,CAAChE,IAAI;MAACyD,KAAK,EAAE,IAAI,CAACzC,KAAK,CAAC0C;IAAO,GAAE,IAAI,CAAC1C,KAAK,CAAC0D,QAAe,CAAC;EACxE;AACJ","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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
+ let id = 0;
5
+ export class WmComponentNode {
6
+ constructor(args) {
7
+ var _args$children;
8
+ _defineProperty(this, "type", void 0);
9
+ _defineProperty(this, "_classnameMap", new Map());
10
+ _defineProperty(this, "id", ++id);
11
+ _defineProperty(this, "_classnameVal", '');
12
+ _defineProperty(this, "parent", void 0);
13
+ _defineProperty(this, "children", []);
14
+ _defineProperty(this, "instance", void 0);
15
+ this.type = args.type;
16
+ this.instance = args.instance;
17
+ (_args$children = args.children) === null || _args$children === void 0 || _args$children.forEach(c => this.add(c));
18
+ }
19
+ refresh(only) {
20
+ if (!only || only(this)) {
21
+ var _this$instance;
22
+ (_this$instance = this.instance) === null || _this$instance === void 0 || _this$instance.refresh();
23
+ }
24
+ if (only) {
25
+ var _this$children;
26
+ (_this$children = this.children) === null || _this$children === void 0 || _this$children.forEach(c => {
27
+ c === null || c === void 0 || c.refresh(only);
28
+ });
29
+ }
30
+ }
31
+ get classname() {
32
+ return this._classnameVal;
33
+ }
34
+ hasClass(name) {
35
+ return this._classnameMap.has(name);
36
+ }
37
+ add(node) {
38
+ if (node.parent !== this) {
39
+ var _node$parent;
40
+ (_node$parent = node.parent) === null || _node$parent === void 0 || _node$parent.remove(this);
41
+ this.children.push(node);
42
+ node.parent = this;
43
+ node.refresh();
44
+ }
45
+ }
46
+ remove(node) {
47
+ const i = this.children.findIndex(n => n === node);
48
+ if (i >= 0) {
49
+ var _this$children2;
50
+ this.children.splice(i, 1);
51
+ node.parent = undefined;
52
+ (_this$children2 = this.children) === null || _this$children2 === void 0 || _this$children2.forEach(c => {
53
+ c.refresh();
54
+ });
55
+ }
56
+ }
57
+ }
58
+ //# sourceMappingURL=wm-component-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["id","WmComponentNode","constructor","args","_args$children","_defineProperty","Map","type","instance","children","forEach","c","add","refresh","only","_this$instance","_this$children","classname","_classnameVal","hasClass","name","_classnameMap","has","node","parent","_node$parent","remove","push","i","findIndex","n","_this$children2","splice","undefined"],"sources":["wm-component-tree.ts"],"sourcesContent":["import { BaseComponent } from \"./base.component\";\n\nlet id = 0;\n\nexport class WmComponentNode {\n type?: string;\n private _classnameMap: Map<string, boolean> = new Map();\n private id = ++id;\n private _classnameVal = '';\n parent?: WmComponentNode;\n readonly children: WmComponentNode[] = [];\n instance?: BaseComponent<any, any, any>;\n \n\n public constructor(args: {\n type?: string,\n classname?: string,\n children?: WmComponentNode[],\n instance?: BaseComponent<any, any, any>\n }) {\n this.type = args.type;\n this.instance = args.instance;\n args.children?.forEach(c => this.add(c));\n }\n\n private refresh(only?: (node: WmComponentNode) => boolean) {\n if (!only || only(this)) {\n this.instance?.refresh();\n }\n if (only) {\n this.children?.forEach((c) => {\n c?.refresh(only);\n });\n }\n }\n\n get classname() {\n return this._classnameVal;\n }\n\n hasClass(name: string) {\n return this._classnameMap.has(name);\n }\n\n add(node: WmComponentNode) {\n if (node.parent !== this) {\n node.parent?.remove(this);\n this.children.push(node);\n node.parent = this;\n node.refresh();\n }\n }\n\n remove(node: WmComponentNode) {\n const i = this.children.findIndex((n) => n === node);\n if (i >= 0) {\n this.children.splice(i, 1);\n node.parent = undefined;\n this.children?.forEach((c) => {\n c.refresh();\n });\n }\n }\n}"],"mappings":";;;AAEA,IAAIA,EAAE,GAAG,CAAC;AAEV,OAAO,MAAMC,eAAe,CAAC;EAUlBC,WAAWA,CAACC,IAKlB,EAAE;IAAA,IAAAC,cAAA;IAAAC,eAAA;IAAAA,eAAA,wBAb2C,IAAIC,GAAG,CAAC,CAAC;IAAAD,eAAA,aAC1C,EAAEL,EAAE;IAAAK,eAAA,wBACO,EAAE;IAAAA,eAAA;IAAAA,eAAA,mBAEa,EAAE;IAAAA,eAAA;IAUrC,IAAI,CAACE,IAAI,GAAGJ,IAAI,CAACI,IAAI;IACrB,IAAI,CAACC,QAAQ,GAAGL,IAAI,CAACK,QAAQ;IAC7B,CAAAJ,cAAA,GAAAD,IAAI,CAACM,QAAQ,cAAAL,cAAA,eAAbA,cAAA,CAAeM,OAAO,CAACC,CAAC,IAAI,IAAI,CAACC,GAAG,CAACD,CAAC,CAAC,CAAC;EAC5C;EAEQE,OAAOA,CAACC,IAAyC,EAAE;IACvD,IAAI,CAACA,IAAI,IAAIA,IAAI,CAAC,IAAI,CAAC,EAAE;MAAA,IAAAC,cAAA;MACrB,CAAAA,cAAA,OAAI,CAACP,QAAQ,cAAAO,cAAA,eAAbA,cAAA,CAAeF,OAAO,CAAC,CAAC;IAC5B;IACA,IAAIC,IAAI,EAAE;MAAA,IAAA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1
  {
2
2
  "name": "@wavemaker/app-rn-runtime",
3
- "version": "12.0.0-next.140535",
3
+ "version": "12.0.0-next.140537",
4
4
  "description": "''",
5
5
  "main": "index",
6
6
  "module": "index",
@@ -11,7 +11,7 @@
11
11
  "./": "./"
12
12
  },
13
13
  "scripts": {
14
- "test": "jest -u --coverage",
14
+ "test": "jest --coverage",
15
15
  "test:theme": "jest \"test/styles/theme.spec.ts\"",
16
16
  "typescript": "tsc --noEmit",
17
17
  "copy-resources": "mkdir -p ./dist && cp -r ./lib/module ./dist && cp ./package.json ./dist/module",
@@ -22,7 +22,8 @@
22
22
  "example": "yarn --cwd example",
23
23
  "pods": "cd example && pod-install --quiet",
24
24
  "bootstrap": "yarn example && yarn && yarn pods",
25
- "watch": "npm-watch build"
25
+ "watch": "npm-watch build",
26
+ "test:coverage": "jest --coverage --forceExit; node scripts/combineCoverageHtmlCSS.js"
26
27
  },
27
28
  "keywords": [
28
29
  "react-native",
@@ -50,7 +51,7 @@
50
51
  "@react-navigation/drawer": "6.6.3",
51
52
  "@react-navigation/native": "6.1.7",
52
53
  "@react-navigation/stack": "6.3.29",
53
- "@wavemaker/variables": "12.0.0-next.140535",
54
+ "@wavemaker/variables": "12.0.0-next.140537",
54
55
  "axios": "1.6.8",
55
56
  "color": "4.2.3",
56
57
  "cross-env": "7.0.3",
@@ -141,7 +142,7 @@
141
142
  "typescript": "5.1.3",
142
143
  "victory-native": "36.6.11",
143
144
  "yargs": "16.2.0",
144
- "@wavemaker/variables": "12.0.0-next.140535"
145
+ "@wavemaker/variables": "12.0.0-next.140537"
145
146
  },
146
147
  "jest": {
147
148
  "preset": "jest-expo",
@@ -156,10 +157,16 @@
156
157
  "collectCoverageFrom": [
157
158
  "**/*.{js,jsx,ts,tsx}",
158
159
  "!**/coverage/**",
160
+ "!**/.yalc/**",
159
161
  "!**/node_modules/**",
160
162
  "!**/babel.config.js",
161
163
  "!**/jest.setup.js",
162
- "!**/dist/**"
164
+ "!**/dist/**",
165
+ "!**/scripts/**",
166
+ "!**/typings/**",
167
+ "!**/src/variables/**",
168
+ "!**/src/actions/**",
169
+ "!**/src/runtime/**"
163
170
  ],
164
171
  "coverageDirectory": "./dist/reports/coverage",
165
172
  "transform": {
@@ -3,7 +3,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
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
5
  import axios from 'axios';
6
- import { Platform, TouchableOpacity, View, StatusBar, KeyboardAvoidingView } from 'react-native';
6
+ import { Platform, TouchableOpacity, View, StatusBar } from 'react-native';
7
7
  import { GestureHandlerRootView } from 'react-native-gesture-handler';
8
8
  import ProtoTypes from 'prop-types';
9
9
  import { SafeAreaProvider, SafeAreaInsetsContext, SafeAreaView } from 'react-native-safe-area-context';
@@ -50,6 +50,7 @@ import { getValidJSON, parseErrors } from '@wavemaker/app-rn-runtime/variables/u
50
50
  import MaterialCommunityIconsFont from '@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf';
51
51
  import * as SplashScreen from 'expo-splash-screen';
52
52
  import { WmMemo } from './memo.component';
53
+ import { VariableEvents } from '../variables/base-variable';
53
54
  //some old react libraries need this
54
55
  View['propTypes'] = {
55
56
  style: ProtoTypes.any
@@ -83,6 +84,7 @@ const SUPPORTED_SERVICES = {
83
84
  AppDisplayManagerService: AppDisplayManagerService,
84
85
  i18nService: AppI18nService
85
86
  };
87
+ global['axios'] = axios;
86
88
  export default class BaseApp extends React.Component {
87
89
  constructor(props) {
88
90
  super(props);
@@ -173,6 +175,10 @@ export default class BaseApp extends React.Component {
173
175
  var _this$commonPartial2;
174
176
  return (_this$commonPartial2 = this.commonPartial) === null || _this$commonPartial2 === void 0 ? void 0 : _this$commonPartial2.Widgets;
175
177
  }
178
+ async onBeforePageLeave(currentPage, nextPage) {
179
+ //method can be override by the user from studio;
180
+ return true;
181
+ }
176
182
  goToPage(pageName, params) {
177
183
  var _this$appConfig$curre2;
178
184
  return (_this$appConfig$curre2 = this.appConfig.currentPage) === null || _this$appConfig$curre2 === void 0 ? void 0 : _this$appConfig$curre2.goToPage(pageName, params);
@@ -242,9 +248,11 @@ export default class BaseApp extends React.Component {
242
248
  config.headers = config.headers || {};
243
249
  config.headers['X-Requested-With'] = 'XMLHttpRequest';
244
250
  console.log('onBeforeService call invoked on ' + config.url);
251
+ this.notify('beforeServiceCall', config);
245
252
  return this.onBeforeServiceCall(config);
246
253
  }), axios.interceptors.response.use(response => {
247
254
  this.onServiceSuccess(response.data, response);
255
+ this.notify('afterServiceCall', response.config, response);
248
256
  return response;
249
257
  }, error => {
250
258
  var _errorDetails, _errorDetails2, _error$response, _error$response2, _error$response3, _error$response4;
@@ -263,6 +271,7 @@ export default class BaseApp extends React.Component {
263
271
  var _this$appConfig$curre5, _this$appConfig$curre6;
264
272
  ((_this$appConfig$curre5 = this.appConfig.currentPage) === null || _this$appConfig$curre5 === void 0 ? void 0 : _this$appConfig$curre5.pageName) !== 'Login' && ((_this$appConfig$curre6 = this.appConfig.currentPage) === null || _this$appConfig$curre6 === void 0 ? void 0 : _this$appConfig$curre6.goToPage('Login'));
265
273
  }
274
+ this.notify('afterServiceCall', error.config, error);
266
275
  return Promise.reject(error);
267
276
  })];
268
277
  }
@@ -284,12 +293,22 @@ export default class BaseApp extends React.Component {
284
293
  AppSpinnerService.show({
285
294
  spinner: this.appConfig.spinner
286
295
  });
287
- this.triggerStartUpVariables().then(() => {
296
+ this.cleanup.push(...Object.values(this.Variables).map(v => {
297
+ return v.subscribe(VariableEvents.BEFORE_INVOKE, () => {
298
+ this.notify(VariableEvents.BEFORE_INVOKE, v);
299
+ });
300
+ }));
301
+ this.cleanup.push(...Object.values(this.Variables).map(v => {
302
+ return v.subscribe(VariableEvents.AFTER_INVOKE, () => {
303
+ this.notify(VariableEvents.AFTER_INVOKE, v);
304
+ });
305
+ }));
306
+ this.startUpActions.map(a => this.Actions[a] && this.Actions[a].invoke());
307
+ return this.triggerStartUpVariables().then(() => {
288
308
  this.onAppVariablesReady();
289
309
  this.isStarted = true;
290
310
  this.forceUpdate();
291
311
  }, () => {});
292
- this.startUpActions.map(a => this.Actions[a] && this.Actions[a].invoke());
293
312
  }
294
313
  componentWillUnmount() {
295
314
  this.axiosInterceptorIds.map(id => {
@@ -451,11 +470,6 @@ export default class BaseApp extends React.Component {
451
470
  }
452
471
  }, /*#__PURE__*/React.createElement(StatusBar, null), /*#__PURE__*/React.createElement(ThemeProvider, {
453
472
  value: this.appConfig.theme
454
- }, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
455
- behavior: Platform.OS === "ios" ? "padding" : undefined,
456
- style: {
457
- flex: 1
458
- }
459
473
  }, /*#__PURE__*/React.createElement(FixedViewContainer, null, /*#__PURE__*/React.createElement(View, {
460
474
  style: styles.container
461
475
  }, /*#__PURE__*/React.createElement(GestureHandlerRootView, {
@@ -469,7 +483,7 @@ export default class BaseApp extends React.Component {
469
483
  drawerAnimation: (_this$appConfig$drawe2 = this.appConfig.drawer) === null || _this$appConfig$drawe2 === void 0 ? void 0 : _this$appConfig$drawe2.getAnimation()
470
484
  }), commonPartial)), this.appConfig.url ? /*#__PURE__*/React.createElement(WmNetworkInfoToaster, {
471
485
  appLocale: this.appConfig.appLocale
472
- }) : null), this.renderToasters(), this.renderDialogs(), this.renderDisplayManager()))));
486
+ }) : null), this.renderToasters(), this.renderDialogs(), this.renderDisplayManager())));
473
487
  }))));
474
488
  }
475
489
  }