@wavemaker/app-rn-runtime 11.11.7-rc.6211 → 11.12.0-next.28188
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/advanced/carousel/carousel.component.js +4 -2
- package/components/advanced/carousel/carousel.component.js.map +1 -1
- package/components/basic/anchor/anchor.component.js +11 -5
- package/components/basic/anchor/anchor.component.js.map +1 -1
- package/components/basic/anchor/anchor.props.js +1 -0
- package/components/basic/anchor/anchor.props.js.map +1 -1
- package/components/basic/audio/audio.component.js +52 -47
- package/components/basic/audio/audio.component.js.map +1 -1
- package/components/basic/bottomsheet/bottomsheet.component.js +94 -48
- package/components/basic/bottomsheet/bottomsheet.component.js.map +1 -1
- package/components/basic/bottomsheet/bottomsheet.props.js +1 -0
- package/components/basic/bottomsheet/bottomsheet.props.js.map +1 -1
- package/components/basic/button/button.component.js +2 -1
- package/components/basic/button/button.component.js.map +1 -1
- package/components/basic/button/button.props.js +1 -0
- package/components/basic/button/button.props.js.map +1 -1
- package/components/basic/label/label.component.js.map +1 -1
- package/components/basic/label/label.props.js +1 -0
- package/components/basic/label/label.props.js.map +1 -1
- package/components/basic/message/message.component.js +15 -7
- package/components/basic/message/message.component.js.map +1 -1
- package/components/basic/message/message.props.js +1 -0
- package/components/basic/message/message.props.js.map +1 -1
- package/components/basic/picture/picture.component.js +2 -2
- package/components/basic/picture/picture.component.js.map +1 -1
- package/components/basic/video/video.component.js +69 -42
- package/components/basic/video/video.component.js.map +1 -1
- package/components/chart/basechart.props.js +1 -0
- package/components/chart/basechart.props.js.map +1 -1
- package/components/container/container.component.js +107 -27
- package/components/container/container.component.js.map +1 -1
- package/components/container/container.props.js +3 -1
- package/components/container/container.props.js.map +1 -1
- package/components/container/container.styles.js +1 -3
- package/components/container/container.styles.js.map +1 -1
- package/components/container/layoutgrid/gridcolumn/gridcolumn.component.js +6 -1
- package/components/container/layoutgrid/gridcolumn/gridcolumn.component.js.map +1 -1
- package/components/container/linearlayout/linearlayoutitem/linearlayoutitem.component.js +2 -2
- package/components/container/linearlayout/linearlayoutitem/linearlayoutitem.component.js.map +1 -1
- package/components/container/tabs/tabheader/tabheader.component.js +11 -2
- package/components/container/tabs/tabheader/tabheader.component.js.map +1 -1
- package/components/container/tabs/tabheader/tabheader.props.js +1 -0
- package/components/container/tabs/tabheader/tabheader.props.js.map +1 -1
- package/components/container/tabs/tabpane/tabpane.props.js +3 -0
- package/components/container/tabs/tabpane/tabpane.props.js.map +1 -1
- package/components/container/tabs/tabs.component.js +11 -2
- package/components/container/tabs/tabs.component.js.map +1 -1
- package/components/container/wizard/wizard.component.js +1 -0
- package/components/container/wizard/wizard.component.js.map +1 -1
- package/components/data/list/list.component.js +23 -13
- package/components/data/list/list.component.js.map +1 -1
- package/components/device/barcodescanner/barcodescanner.component.js +33 -18
- package/components/device/barcodescanner/barcodescanner.component.js.map +1 -1
- package/components/device/barcodescanner/barcodescanner.props.js +2 -1
- package/components/device/barcodescanner/barcodescanner.props.js.map +1 -1
- package/components/device/camera/camera.component.js +35 -22
- package/components/device/camera/camera.component.js.map +1 -1
- package/components/device/camera/camera.props.js +2 -1
- package/components/device/camera/camera.props.js.map +1 -1
- package/components/input/basedataset/basedataset.props.js +1 -0
- package/components/input/basedataset/basedataset.props.js.map +1 -1
- package/components/input/calendar/calendar.component.js +12 -4
- package/components/input/calendar/calendar.component.js.map +1 -1
- package/components/input/calendar/views/month-view.js +9 -2
- package/components/input/calendar/views/month-view.js.map +1 -1
- package/components/input/checkbox/checkbox.component.js +5 -5
- package/components/input/checkbox/checkbox.component.js.map +1 -1
- package/components/input/checkboxset/checkboxset.component.js +15 -11
- package/components/input/checkboxset/checkboxset.component.js.map +1 -1
- package/components/input/chips/chips.component.js +25 -12
- package/components/input/chips/chips.component.js.map +1 -1
- package/components/input/currency/currency.component.js +5 -2
- package/components/input/currency/currency.component.js.map +1 -1
- package/components/input/epoch/base-datetime.component.js +9 -9
- package/components/input/epoch/base-datetime.component.js.map +1 -1
- package/components/input/epoch/datetime/datetime.props.js +1 -0
- package/components/input/epoch/datetime/datetime.props.js.map +1 -1
- package/components/input/epoch/wheelpicker/wheelpicker.component.js +8 -3
- package/components/input/epoch/wheelpicker/wheelpicker.component.js.map +1 -1
- package/components/input/epoch/wheelpickermodal/date/date-picker-modal.component.js +8 -3
- package/components/input/epoch/wheelpickermodal/date/date-picker-modal.component.js.map +1 -1
- package/components/input/epoch/wheelpickermodal/time/time-picker-modal.component.js +8 -3
- package/components/input/epoch/wheelpickermodal/time/time-picker-modal.component.js.map +1 -1
- package/components/input/fileupload/fileupload.component.js +23 -14
- package/components/input/fileupload/fileupload.component.js.map +1 -1
- package/components/input/fileupload/fileupload.props.js +2 -0
- package/components/input/fileupload/fileupload.props.js.map +1 -1
- package/components/input/radioset/radioset.component.js +15 -5
- package/components/input/radioset/radioset.component.js.map +1 -1
- package/components/input/rating/rating.component.js +11 -3
- package/components/input/rating/rating.component.js.map +1 -1
- package/components/input/rating/rating.props.js +4 -0
- package/components/input/rating/rating.props.js.map +1 -1
- package/components/input/select/select.component.js +7 -5
- package/components/input/select/select.component.js.map +1 -1
- package/components/input/slider/slider.component.js +2 -1
- package/components/input/slider/slider.component.js.map +1 -1
- package/components/input/switch/switch.component.js +11 -9
- package/components/input/switch/switch.component.js.map +1 -1
- package/components/input/toggle/toggle.component.js +8 -4
- package/components/input/toggle/toggle.component.js.map +1 -1
- package/components/input/toggle/toggle.props.js +1 -0
- package/components/input/toggle/toggle.props.js.map +1 -1
- package/components/navigation/appnavbar/appnavbar.component.js +19 -61
- package/components/navigation/appnavbar/appnavbar.component.js.map +1 -1
- package/components/navigation/navitem/navitem.component.js +3 -1
- package/components/navigation/navitem/navitem.component.js.map +1 -1
- package/components/navigation/popover/popover.component.js +2 -1
- package/components/navigation/popover/popover.component.js.map +1 -1
- package/components/navigation/popover/popover.props.js +2 -1
- package/components/navigation/popover/popover.props.js.map +1 -1
- package/components/page/page-content/page-content.component.js +74 -20
- package/components/page/page-content/page-content.component.js.map +1 -1
- package/components/page/page-content/page-content.props.js +1 -0
- package/components/page/page-content/page-content.props.js.map +1 -1
- package/components/page/page.component.js +29 -44
- package/components/page/page.component.js.map +1 -1
- package/components/page/page.props.js +4 -2
- package/components/page/page.props.js.map +1 -1
- package/components/page/tabbar/tabbar.component.js +24 -13
- package/components/page/tabbar/tabbar.component.js.map +1 -1
- package/core/AppConfig.js.map +1 -1
- package/core/accessibility.js +51 -32
- package/core/accessibility.js.map +1 -1
- package/core/base.component.js.map +1 -1
- package/core/components/error-fallback/error-fallback.component.js +140 -0
- package/core/components/error-fallback/error-fallback.component.js.map +1 -0
- package/core/components/error-fallback/error-fallback.styles.js +224 -0
- package/core/components/error-fallback/error-fallback.styles.js.map +1 -0
- package/core/components/sticky-base.component.js +54 -0
- package/core/components/sticky-base.component.js.map +1 -0
- package/core/components/sticky-container.component.js +34 -0
- package/core/components/sticky-container.component.js.map +1 -0
- package/core/components/sticky-container.styles.js +98 -0
- package/core/components/sticky-container.styles.js.map +1 -0
- package/core/components/sticky-nav.component.js +28 -0
- package/core/components/sticky-nav.component.js.map +1 -0
- package/core/device/av-service.js +8 -0
- package/core/device/av-service.js.map +1 -0
- package/core/device/calendar-service.js +7 -1
- package/core/device/calendar-service.js.map +1 -1
- package/core/device/camera-service.js +6 -0
- package/core/device/camera-service.js.map +1 -1
- package/core/device/contacts-service.js +7 -1
- package/core/device/contacts-service.js.map +1 -1
- package/core/device/fileupload-service.js +8 -0
- package/core/device/fileupload-service.js.map +1 -0
- package/core/device/location-service.js +7 -1
- package/core/device/location-service.js.map +1 -1
- package/core/device/scan-service.js +6 -0
- package/core/device/scan-service.js.map +1 -1
- package/core/error-boundary.component.js +1 -1
- package/core/error-boundary.component.js.map +1 -1
- package/core/event-notifier.js +4 -3
- package/core/event-notifier.js.map +1 -1
- package/core/fixed-view.component.js +2 -1
- package/core/fixed-view.component.js.map +1 -1
- package/core/responsive.utils.js +8 -5
- package/core/responsive.utils.js.map +1 -1
- package/core/sticky-view.component.js +50 -0
- package/core/sticky-view.component.js.map +1 -0
- package/core/sticky-wrapper.js +129 -0
- package/core/sticky-wrapper.js.map +1 -0
- package/core/utils.js +0 -6
- package/core/utils.js.map +1 -1
- package/npm-shrinkwrap.json +48 -47
- package/package-lock.json +48 -47
- package/package.json +2 -2
- package/runtime/App.js +3 -5
- package/runtime/App.js.map +1 -1
- package/runtime/services/device/calendar-service.js +9 -5
- package/runtime/services/device/calendar-service.js.map +1 -1
- package/runtime/services/device/camera-service.js +39 -22
- package/runtime/services/device/camera-service.js.map +1 -1
- package/runtime/services/device/contacts-service.js +6 -5
- package/runtime/services/device/contacts-service.js.map +1 -1
- package/runtime/services/device/location-service.js +4 -4
- package/runtime/services/device/location-service.js.map +1 -1
- package/runtime/services/device/permission-service.js +5 -0
- package/runtime/services/device/permission-service.js.map +1 -0
- package/runtime/services/device/permissions.js +34 -39
- package/runtime/services/device/permissions.js.map +1 -1
- package/runtime/services/device/scan-service.js +4 -3
- package/runtime/services/device/scan-service.js.map +1 -1
- package/styles/theme.js +24 -18
- package/styles/theme.js.map +1 -1
- package/variables/device/calendar/create-event.operation.js +12 -1
- package/variables/device/calendar/create-event.operation.js.map +1 -1
- package/variables/device/calendar/delete-event.operation.js +12 -1
- package/variables/device/calendar/delete-event.operation.js.map +1 -1
- package/variables/device/calendar/get-events.operation.js +12 -1
- package/variables/device/calendar/get-events.operation.js.map +1 -1
- package/variables/device/camera/capture-image.operation.js +8 -1
- package/variables/device/camera/capture-image.operation.js.map +1 -1
- package/variables/device/camera/capture-video.operation.js +7 -1
- package/variables/device/camera/capture-video.operation.js.map +1 -1
- package/variables/device/contacts/get-contacts.operation.js +12 -1
- package/variables/device/contacts/get-contacts.operation.js.map +1 -1
- package/variables/device/device/current-geo-position.operation.js +12 -1
- package/variables/device/device/current-geo-position.operation.js.map +1 -1
- package/variables/device/file/upload-file.operation.js +17 -3
- package/variables/device/file/upload-file.operation.js.map +1 -1
- package/variables/device/scan/scan.operation.js +12 -1
- package/variables/device/scan/scan.operation.js.map +1 -1
- package/variables/http.service.js +6 -1
- package/variables/http.service.js.map +1 -1
- package/core/components/error-fallback.component.js +0 -264
- package/core/components/error-fallback.component.js.map +0 -1
- package/core/sticky-container.component.js +0 -175
- package/core/sticky-container.component.js.map +0 -1
@@ -1,175 +0,0 @@
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
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
|
-
import React, { Component } from "react";
|
5
|
-
import { Animated, View, Platform } from "react-native";
|
6
|
-
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
7
|
-
import { ThemeProvider } from "@wavemaker/app-rn-runtime/styles/theme";
|
8
|
-
import injector from '@wavemaker/app-rn-runtime/core/injector';
|
9
|
-
const StickyViewContext = /*#__PURE__*/React.createContext(null);
|
10
|
-
export class StickyViewState {
|
11
|
-
constructor() {
|
12
|
-
_defineProperty(this, "isStickyVisible", false);
|
13
|
-
}
|
14
|
-
}
|
15
|
-
export class StickyView extends Component {
|
16
|
-
constructor(props) {
|
17
|
-
super(props);
|
18
|
-
_defineProperty(this, "container", null);
|
19
|
-
_defineProperty(this, "cachedComponent", void 0);
|
20
|
-
_defineProperty(this, "id", StickyView.counter++);
|
21
|
-
_defineProperty(this, "destroyScrollListner", null);
|
22
|
-
_defineProperty(this, "insets", null);
|
23
|
-
_defineProperty(this, "refScrollPosition", 0);
|
24
|
-
_defineProperty(this, "lastScrollDirection", 1);
|
25
|
-
_defineProperty(this, "appConfig", injector.get('APP_CONFIG'));
|
26
|
-
_defineProperty(this, "scrolled", false);
|
27
|
-
this.state = new StickyViewState();
|
28
|
-
this.listenScrollEvent();
|
29
|
-
}
|
30
|
-
componentWillUnmount() {
|
31
|
-
var _this$container;
|
32
|
-
(_this$container = this.container) === null || _this$container === void 0 || _this$container.remove(this);
|
33
|
-
this.destroyScrollListner && this.destroyScrollListner();
|
34
|
-
}
|
35
|
-
listenScrollEvent() {
|
36
|
-
this.destroyScrollListner && this.destroyScrollListner();
|
37
|
-
const component = this.props.component;
|
38
|
-
let yPosition;
|
39
|
-
this.destroyScrollListner = component.subscribe('scroll', e => {
|
40
|
-
var _component$getLayout, _this$insets, _component$getLayout2;
|
41
|
-
const height = (_component$getLayout = component.getLayout()) === null || _component$getLayout === void 0 ? void 0 : _component$getLayout.height;
|
42
|
-
const topInsetsInYposition = Platform.OS == 'ios' ? ((_this$insets = this.insets) === null || _this$insets === void 0 ? void 0 : _this$insets.top) || 0 : 0;
|
43
|
-
yPosition = yPosition || yPosition == 0 ? yPosition : (component === null || component === void 0 || (_component$getLayout2 = component.getLayout()) === null || _component$getLayout2 === void 0 ? void 0 : _component$getLayout2.py) - topInsetsInYposition;
|
44
|
-
const scrollPosition = e.nativeEvent.contentOffset.y;
|
45
|
-
let isStickyVisible = false;
|
46
|
-
const {
|
47
|
-
containerHeight = 0,
|
48
|
-
hiddenHeight = 0
|
49
|
-
} = this.container || {};
|
50
|
-
const containerHeightVal = Math.abs(containerHeight + hiddenHeight);
|
51
|
-
if (!this.scrolled) this.scrolled = true;
|
52
|
-
if (e.scrollDirection) {
|
53
|
-
if (this.lastScrollDirection !== e.scrollDirection) {
|
54
|
-
this.refScrollPosition = scrollPosition;
|
55
|
-
}
|
56
|
-
this.lastScrollDirection = e.scrollDirection;
|
57
|
-
}
|
58
|
-
|
59
|
-
// based on scrollDirection checking for stickyVisibility
|
60
|
-
if (e.scrollDirection <= 0) {
|
61
|
-
isStickyVisible = scrollPosition > 10 // scroll threshold value of 10
|
62
|
-
&& scrollPosition + containerHeightVal + this.appConfig.pageScrollTopThreshold >= yPosition + height;
|
63
|
-
} else {
|
64
|
-
isStickyVisible = scrollPosition + this.appConfig.pageScrollTopThreshold >= yPosition + (this.props.slide ? height : 0);
|
65
|
-
}
|
66
|
-
if (this.state.isStickyVisible !== isStickyVisible) {
|
67
|
-
this.setState({
|
68
|
-
isStickyVisible: isStickyVisible
|
69
|
-
}, () => {
|
70
|
-
if (isStickyVisible && this.props.slide) {
|
71
|
-
var _this$container2;
|
72
|
-
(_this$container2 = this.container) === null || _this$container2 === void 0 || _this$container2.slideBy(-1 * height);
|
73
|
-
} else {
|
74
|
-
var _this$container3;
|
75
|
-
(_this$container3 = this.container) === null || _this$container3 === void 0 || _this$container3.slideBy(this.refScrollPosition - scrollPosition);
|
76
|
-
}
|
77
|
-
});
|
78
|
-
} else {
|
79
|
-
var _this$container4;
|
80
|
-
(_this$container4 = this.container) === null || _this$container4 === void 0 || _this$container4.slideBy(this.refScrollPosition - scrollPosition);
|
81
|
-
}
|
82
|
-
});
|
83
|
-
}
|
84
|
-
render() {
|
85
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SafeAreaInsetsContext.Consumer, null, (insets = {
|
86
|
-
top: 0,
|
87
|
-
bottom: 0,
|
88
|
-
left: 0,
|
89
|
-
right: 0
|
90
|
-
}) => {
|
91
|
-
this.insets = insets;
|
92
|
-
return /*#__PURE__*/React.createElement(StickyViewContext.Consumer, null, container => {
|
93
|
-
this.container = container;
|
94
|
-
if (!this.scrolled) return /*#__PURE__*/React.createElement(React.Fragment, null);
|
95
|
-
if (this.state.isStickyVisible && this.container) {
|
96
|
-
var _this$container5;
|
97
|
-
if (!((_this$container5 = this.container) !== null && _this$container5 !== void 0 && (_this$container5 = _this$container5.children) !== null && _this$container5 !== void 0 && _this$container5.has(this))) {
|
98
|
-
this.container.add(this, /*#__PURE__*/React.createElement(ThemeProvider, {
|
99
|
-
value: this.props.theme,
|
100
|
-
key: this.id
|
101
|
-
}, /*#__PURE__*/React.createElement(View, {
|
102
|
-
style: [this.props.style]
|
103
|
-
}, this.props.children)));
|
104
|
-
}
|
105
|
-
} else {
|
106
|
-
var _this$container6;
|
107
|
-
(_this$container6 = this.container) === null || _this$container6 === void 0 || _this$container6.remove(this);
|
108
|
-
}
|
109
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
110
|
-
});
|
111
|
-
}), /*#__PURE__*/React.createElement(View, {
|
112
|
-
style: {
|
113
|
-
opacity: this.state.isStickyVisible ? 0 : 1
|
114
|
-
}
|
115
|
-
}, this.props.children));
|
116
|
-
}
|
117
|
-
}
|
118
|
-
_defineProperty(StickyView, "defaultProps", {
|
119
|
-
slide: false
|
120
|
-
});
|
121
|
-
_defineProperty(StickyView, "counter", Date.now());
|
122
|
-
export class StickyViewContainer extends React.Component {
|
123
|
-
constructor(...args) {
|
124
|
-
super(...args);
|
125
|
-
_defineProperty(this, "children", new Map());
|
126
|
-
_defineProperty(this, "id", 0);
|
127
|
-
_defineProperty(this, "translateY", new Animated.Value(0));
|
128
|
-
_defineProperty(this, "topSlideHeight", 0);
|
129
|
-
_defineProperty(this, "hiddenHeight", 0);
|
130
|
-
_defineProperty(this, "containerHeight", 0);
|
131
|
-
_defineProperty(this, "appConfig", injector.get('APP_CONFIG'));
|
132
|
-
}
|
133
|
-
add(c, n) {
|
134
|
-
var _c$props$component$ge;
|
135
|
-
const h = Math.max(((_c$props$component$ge = c.props.component.getLayout()) === null || _c$props$component$ge === void 0 ? void 0 : _c$props$component$ge.height) || 0, 0);
|
136
|
-
this.containerHeight += h;
|
137
|
-
this.topSlideHeight += c.props.slide ? h : 0;
|
138
|
-
this.children.set(c, n);
|
139
|
-
setTimeout(() => this.setState({
|
140
|
-
id: ++this.id
|
141
|
-
}));
|
142
|
-
}
|
143
|
-
remove(c) {
|
144
|
-
var _c$props$component$ge2;
|
145
|
-
const h = Math.max(((_c$props$component$ge2 = c.props.component.getLayout()) === null || _c$props$component$ge2 === void 0 ? void 0 : _c$props$component$ge2.height) || 0, 0);
|
146
|
-
this.containerHeight -= h;
|
147
|
-
this.topSlideHeight -= c.props.slide ? h : 0;
|
148
|
-
this.containerHeight = Math.max(this.containerHeight, 0);
|
149
|
-
this.topSlideHeight = Math.max(this.topSlideHeight, 0);
|
150
|
-
this.children.delete(c);
|
151
|
-
setTimeout(() => this.setState({
|
152
|
-
id: ++this.id
|
153
|
-
}));
|
154
|
-
}
|
155
|
-
slideBy(value) {
|
156
|
-
this.hiddenHeight = Math.max(Math.min(0, this.translateY._value + value), -1 * this.topSlideHeight);
|
157
|
-
this.translateY.setValue(this.hiddenHeight);
|
158
|
-
}
|
159
|
-
render() {
|
160
|
-
return /*#__PURE__*/React.createElement(StickyViewContext.Provider, {
|
161
|
-
value: this
|
162
|
-
}, this.props.children, /*#__PURE__*/React.createElement(Animated.View, {
|
163
|
-
style: {
|
164
|
-
position: 'absolute',
|
165
|
-
top: this.appConfig.pageScrollTopThreshold || 0,
|
166
|
-
width: '100%',
|
167
|
-
transform: [{
|
168
|
-
translateY: this.translateY
|
169
|
-
}]
|
170
|
-
}
|
171
|
-
}, Array.from(this.children.values())));
|
172
|
-
}
|
173
|
-
}
|
174
|
-
;
|
175
|
-
//# sourceMappingURL=sticky-container.component.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","Component","Animated","View","Platform","SafeAreaInsetsContext","ThemeProvider","injector","StickyViewContext","createContext","StickyViewState","constructor","_defineProperty","StickyView","props","counter","get","state","listenScrollEvent","componentWillUnmount","_this$container","container","remove","destroyScrollListner","component","yPosition","subscribe","e","_component$getLayout","_this$insets","_component$getLayout2","height","getLayout","topInsetsInYposition","OS","insets","top","py","scrollPosition","nativeEvent","contentOffset","y","isStickyVisible","containerHeight","hiddenHeight","containerHeightVal","Math","abs","scrolled","scrollDirection","lastScrollDirection","refScrollPosition","appConfig","pageScrollTopThreshold","slide","setState","_this$container2","slideBy","_this$container3","_this$container4","render","createElement","Fragment","Consumer","bottom","left","right","_this$container5","children","has","add","value","theme","key","id","style","_this$container6","opacity","Date","now","StickyViewContainer","args","Map","Value","c","n","_c$props$component$ge","h","max","topSlideHeight","set","setTimeout","_c$props$component$ge2","delete","min","translateY","_value","setValue","Provider","position","width","transform","Array","from","values"],"sources":["sticky-container.component.tsx"],"sourcesContent":["\nimport React, { Component } from \"react\";\nimport { ViewStyle, Animated, Easing, View, Platform} from \"react-native\";\nimport { SafeAreaInsetsContext } from \"react-native-safe-area-context\";\nimport { Theme, ThemeProvider } from \"@wavemaker/app-rn-runtime/styles/theme\";\nimport { BaseComponent } from \"./base.component\";\nimport injector from '@wavemaker/app-rn-runtime/core/injector';\nimport AppConfig from '@wavemaker/app-rn-runtime/core/AppConfig';\n\nconst StickyViewContext = React.createContext<StickyViewContainer>(null as any);\n\nexport interface StickyViewProps {\n style?: ViewStyle,\n theme: Theme;\n children?: any;\n slide?: boolean;\n component: BaseComponent<any, any, any>;\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport class StickyViewState {\n isStickyVisible = false;\n}\n\nexport class StickyView extends Component<StickyViewProps, StickyViewState, any> {\n static defaultProps = {\n slide: false\n };\n static counter = Date.now();\n container?: StickyViewContainer = null as any;\n cachedComponent: React.ReactNode;\n id = StickyView.counter++;\n destroyScrollListner: Function = null as any;\n insets: any = null;\n refScrollPosition = 0;\n lastScrollDirection = 1;\n appConfig = injector.get<AppConfig>('APP_CONFIG');\n scrolled: boolean = false;\n\n constructor(props: StickyViewProps) {\n super(props);\n this.state = new StickyViewState();\n this.listenScrollEvent();\n }\n\n componentWillUnmount() {\n this.container?.remove(this);\n this.destroyScrollListner && this.destroyScrollListner();\n }\n\n listenScrollEvent(): void {\n this.destroyScrollListner && this.destroyScrollListner();\n const component = this.props.component;\n let yPosition: number;\n this.destroyScrollListner = component.subscribe('scroll', (e: any) => {\n const height = component.getLayout()?.height;\n const topInsetsInYposition = Platform.OS == 'ios' ? this.insets?.top || 0 : 0;\n yPosition = (yPosition || yPosition == 0) ? yPosition : component?.getLayout()?.py - topInsetsInYposition;\n const scrollPosition = e.nativeEvent.contentOffset.y;\n let isStickyVisible = false ;\n\n const {containerHeight = 0, hiddenHeight = 0} = this.container || {}\n const containerHeightVal = Math.abs(containerHeight + hiddenHeight) ;\n if(!this.scrolled) this.scrolled = true;\n \n if (e.scrollDirection) {\n if (this.lastScrollDirection !== e.scrollDirection) {\n this.refScrollPosition = scrollPosition;\n }\n this.lastScrollDirection = e.scrollDirection;\n }\n\n // based on scrollDirection checking for stickyVisibility\n if(e.scrollDirection <= 0){\n isStickyVisible = scrollPosition > 10 // scroll threshold value of 10\n && ((scrollPosition + containerHeightVal + this.appConfig.pageScrollTopThreshold ) >= (yPosition + height));\n } else {\n isStickyVisible = ((scrollPosition + this.appConfig.pageScrollTopThreshold) >= \n (yPosition + (this.props.slide ? height: 0)));\n }\n\n if (this.state.isStickyVisible !== isStickyVisible) {\n this.setState({ \n isStickyVisible : isStickyVisible\n }, () => {\n if (isStickyVisible && this.props.slide) {\n this.container?.slideBy(-1 * height);\n } else {\n this.container?.slideBy(this.refScrollPosition - scrollPosition);\n }\n })\n } else {\n this.container?.slideBy(this.refScrollPosition - scrollPosition);\n }\n })\n }\n\n render() {\n return (\n <>\n <SafeAreaInsetsContext.Consumer>\n {(insets = { top: 0, bottom: 0, left: 0, right: 0 }) => {\n this.insets = insets;\n return <StickyViewContext.Consumer>\n {(container) => {\n this.container = container;\n if(!this.scrolled) return <></>\n if (this.state.isStickyVisible && this.container) {\n if(!this.container?.children?.has(this)){\n this.container.add(this, (\n <ThemeProvider value={this.props.theme} key={this.id}>\n <View style={[this.props.style]}>\n {this.props.children}\n </View>\n </ThemeProvider>\n ));\n }\n } else {\n this.container?.remove(this);\n }\n return <></>;\n }}\n </StickyViewContext.Consumer>}}\n </SafeAreaInsetsContext.Consumer>\n <View style={{opacity: this.state.isStickyVisible ? 0 : 1}}>\n {this.props.children}\n </View>\n </>\n );\n }\n}\n\nexport class StickyViewContainer extends React.Component {\n public children: Map<StickyView, React.ReactNode> = new Map();\n private id = 0;\n public translateY: Animated.Value = new Animated.Value(0);\n public topSlideHeight = 0;\n public hiddenHeight: number = 0;\n public containerHeight: number = 0;\n private appConfig = injector.get<AppConfig>('APP_CONFIG');\n\n add(c: StickyView, n : React.ReactNode) {\n const h = Math.max(c.props.component.getLayout()?.height || 0, 0);\n this.containerHeight += h;\n this.topSlideHeight += (c.props.slide ? h : 0);\n this.children.set(c, n);\n setTimeout(() => this.setState({id: ++this.id}));\n }\n\n remove(c: StickyView) {\n const h = Math.max(c.props.component.getLayout()?.height || 0, 0);\n this.containerHeight -= h;\n this.topSlideHeight -= (c.props.slide ? h : 0);\n this.containerHeight = Math.max(this.containerHeight, 0);\n this.topSlideHeight = Math.max(this.topSlideHeight, 0);\n this.children.delete(c);\n setTimeout(() => this.setState({id: ++this.id}));\n }\n\n public slideBy(value: number) {\n this.hiddenHeight = Math.max(\n Math.min(0, (this.translateY as any)._value + value), \n -1 * this.topSlideHeight);\n \n this.translateY.setValue(this.hiddenHeight);\n }\n\n render() {\n return (\n <StickyViewContext.Provider value={this}>\n {(this.props as any).children}\n <Animated.View style={{\n position: 'absolute', top: this.appConfig.pageScrollTopThreshold || 0, width: '100%',\n transform: [{ translateY: this.translateY }]\n }}>\n {Array.from(this.children.values())}\n </Animated.View>\n </StickyViewContext.Provider>\n );\n }\n};"],"mappings":";;;AACA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAAoBC,QAAQ,EAAUC,IAAI,EAAEC,QAAQ,QAAO,cAAc;AACzE,SAASC,qBAAqB,QAAQ,gCAAgC;AACtE,SAAgBC,aAAa,QAAQ,wCAAwC;AAE7E,OAAOC,QAAQ,MAAM,yCAAyC;AAG9D,MAAMC,iBAAiB,gBAAGR,KAAK,CAACS,aAAa,CAAsB,IAAW,CAAC;AAW/E,OAAO,MAAMC,eAAe,CAAC;EAAAC,YAAA;IAAAC,eAAA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