@ray-js/components 0.5.8-beta-1 → 0.5.9-beta-1
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/lib/Button/Button.thing.js +0 -2
- package/lib/CheckboxGroup/CheckboxGroup.js +0 -1
- package/lib/CheckboxGroup/CheckboxGroup.thing.js +0 -1
- package/lib/CheckboxGroup/CheckboxGroup.wechat.js +0 -1
- package/lib/Icon/Icon.thing.js +0 -2
- package/lib/Input/Input.thing.js +0 -3
- package/lib/Input/Input.wechat.js +0 -1
- package/lib/RadioGroup/RadioGroup.thing.js +0 -1
- package/lib/RadioGroup/RadioGroup.wechat.js +0 -1
- package/lib/ScrollView/ScrollView.thing.js +0 -2
- package/lib/Swiper/Swiper.thing.d.ts +0 -3
- package/lib/Swiper/Swiper.thing.js +1 -2
- package/lib/Textarea/Textarea.thing.js +0 -1
- package/lib/Textarea/Textarea.wechat.js +0 -1
- package/lib/View/View.thing.js +0 -2
- package/lib/utils/handleProps.js +0 -1
- package/lib/utils/index.d.ts +1 -2
- package/package.json +4 -4
- package/lib/Button/Button.native.d.ts +0 -29
- package/lib/Button/Button.native.js +0 -229
- package/lib/Checkbox/Checkbox.native.d.ts +0 -28
- package/lib/Checkbox/Checkbox.native.js +0 -118
- package/lib/CheckboxGroup/CheckboxGroup.native.d.ts +0 -18
- package/lib/CheckboxGroup/CheckboxGroup.native.js +0 -99
- package/lib/ClickableSimplified/index.native.d.ts +0 -42
- package/lib/ClickableSimplified/index.native.js +0 -166
- package/lib/DatePicker/DatePicker.native.d.ts +0 -34
- package/lib/DatePicker/DatePicker.native.js +0 -449
- package/lib/Form/Form.native.d.ts +0 -4
- package/lib/Form/Form.native.js +0 -8
- package/lib/Icon/Icon.native.d.ts +0 -15
- package/lib/Icon/Icon.native.js +0 -48
- package/lib/Image/Image.native.d.ts +0 -28
- package/lib/Image/Image.native.js +0 -219
- package/lib/Input/Input.native.d.ts +0 -32
- package/lib/Input/Input.native.js +0 -212
- package/lib/Label/Label.native.d.ts +0 -4
- package/lib/Label/Label.native.js +0 -29
- package/lib/LinearGradient/LinearGradient.native.d.ts +0 -16
- package/lib/LinearGradient/LinearGradient.native.js +0 -60
- package/lib/Modal/Modal.native.d.ts +0 -24
- package/lib/Modal/Modal.native.js +0 -98
- package/lib/Motion/Fade/index.native.d.ts +0 -2
- package/lib/Motion/Fade/index.native.js +0 -3
- package/lib/Motion/PullUp/index.native.d.ts +0 -2
- package/lib/Motion/PullUp/index.native.js +0 -3
- package/lib/Motion/PushDown/index.native.d.ts +0 -2
- package/lib/Motion/PushDown/index.native.js +0 -3
- package/lib/Motion/ScaleFadeIn/index.native.d.ts +0 -2
- package/lib/Motion/ScaleFadeIn/index.native.js +0 -3
- package/lib/Motion/ScalePullDown/index.native.d.ts +0 -2
- package/lib/Motion/ScalePullDown/index.native.js +0 -3
- package/lib/Picker/Picker.native.d.ts +0 -22
- package/lib/Picker/Picker.native.js +0 -181
- package/lib/PickerView/PickerView.native.d.ts +0 -31
- package/lib/PickerView/PickerView.native.js +0 -175
- package/lib/PickerViewColumn/PickerViewColumn.native.d.ts +0 -31
- package/lib/PickerViewColumn/PickerViewColumn.native.js +0 -175
- package/lib/RadialGradient/RadialGradient.native.d.ts +0 -17
- package/lib/RadialGradient/RadialGradient.native.js +0 -52
- package/lib/Radio/Radio.native.d.ts +0 -30
- package/lib/Radio/Radio.native.js +0 -132
- package/lib/RadioGroup/RadioGroup.native.d.ts +0 -18
- package/lib/RadioGroup/RadioGroup.native.js +0 -99
- package/lib/ScrollView/ScrollView.native.d.ts +0 -57
- package/lib/ScrollView/ScrollView.native.js +0 -283
- package/lib/Slider/Slider.native.d.ts +0 -21
- package/lib/Slider/Slider.native.js +0 -114
- package/lib/Swiper/Swiper.native.d.ts +0 -6
- package/lib/Swiper/Swiper.native.js +0 -68
- package/lib/Switch/Switch.native.d.ts +0 -25
- package/lib/Switch/Switch.native.js +0 -128
- package/lib/Text/Text.native.d.ts +0 -8
- package/lib/Text/Text.native.js +0 -37
- package/lib/Textarea/Textarea.native.d.ts +0 -4
- package/lib/Textarea/Textarea.native.js +0 -26
- package/lib/TimePicker/TimePicker.native.d.ts +0 -39
- package/lib/TimePicker/TimePicker.native.js +0 -319
- package/lib/View/View.native.d.ts +0 -2
- package/lib/View/View.native.js +0 -35
@@ -1,52 +0,0 @@
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
-
import "core-js/modules/es.object.to-string.js";
|
3
|
-
import "core-js/modules/es.regexp.to-string.js";
|
4
|
-
import "core-js/modules/es.array.map.js";
|
5
|
-
import React from 'react';
|
6
|
-
import { View } from 'react-native';
|
7
|
-
import Svg, { RadialGradient as Gradient, Defs, Stop, Rect } from 'react-native-svg';
|
8
|
-
import { defaultRadialGradient } from './props';
|
9
|
-
|
10
|
-
var RadialGradient = function (props) {
|
11
|
-
var width = props.width,
|
12
|
-
height = props.height,
|
13
|
-
style = props.style,
|
14
|
-
rx = props.rx,
|
15
|
-
ry = props.ry,
|
16
|
-
fx = props.fx,
|
17
|
-
fy = props.fy,
|
18
|
-
stops = props.stops,
|
19
|
-
children = props.children;
|
20
|
-
var gradientId = Math.random().toString(36).substring(7);
|
21
|
-
return /*#__PURE__*/React.createElement(View, {
|
22
|
-
style: [style, {
|
23
|
-
width: width,
|
24
|
-
height: height
|
25
|
-
}]
|
26
|
-
}, /*#__PURE__*/React.createElement(Svg, {
|
27
|
-
height: height,
|
28
|
-
style: style,
|
29
|
-
width: width
|
30
|
-
}, /*#__PURE__*/React.createElement(Defs, null, /*#__PURE__*/React.createElement(Gradient, {
|
31
|
-
id: gradientId,
|
32
|
-
cx: fx,
|
33
|
-
cy: fy,
|
34
|
-
fx: fx,
|
35
|
-
fy: fy,
|
36
|
-
rx: rx,
|
37
|
-
ry: ry
|
38
|
-
}, stops.map(function (x) {
|
39
|
-
return /*#__PURE__*/React.createElement(Stop, _extends({
|
40
|
-
key: x.offset
|
41
|
-
}, x));
|
42
|
-
}))), /*#__PURE__*/React.createElement(Rect, {
|
43
|
-
fill: "url(#".concat(gradientId, ")"),
|
44
|
-
height: height,
|
45
|
-
width: width,
|
46
|
-
x: "0",
|
47
|
-
y: "0"
|
48
|
-
}), /*#__PURE__*/React.isValidElement(children) && children));
|
49
|
-
};
|
50
|
-
|
51
|
-
RadialGradient.defaultProps = defaultRadialGradient;
|
52
|
-
export default RadialGradient;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { TouchableWithoutFeedback, GestureResponderEvent, ViewStyle, StyleProp } from 'react-native';
|
3
|
-
import { RadioProps } from './props';
|
4
|
-
export interface RadioState {
|
5
|
-
checked: boolean;
|
6
|
-
}
|
7
|
-
interface IProps extends Omit<RadioProps, 'style'> {
|
8
|
-
onChange?: (event: {
|
9
|
-
value: string;
|
10
|
-
type: 'change';
|
11
|
-
checked: boolean;
|
12
|
-
}) => void;
|
13
|
-
style: StyleProp<ViewStyle>;
|
14
|
-
}
|
15
|
-
declare class _Radio extends React.Component<IProps, RadioState> {
|
16
|
-
static displayName: string;
|
17
|
-
static defaultProps: {
|
18
|
-
value: string;
|
19
|
-
color: string;
|
20
|
-
checked: boolean;
|
21
|
-
disabled: boolean;
|
22
|
-
};
|
23
|
-
componentDidUpdate(prevProps: IProps): void;
|
24
|
-
$touchable: React.RefObject<TouchableWithoutFeedback>;
|
25
|
-
state: RadioState;
|
26
|
-
_simulateNativePress: (evt: GestureResponderEvent) => void;
|
27
|
-
onPress: () => void;
|
28
|
-
render(): JSX.Element;
|
29
|
-
}
|
30
|
-
export default _Radio;
|
@@ -1,132 +0,0 @@
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
7
|
-
import "core-js/modules/es.array.concat.js";
|
8
|
-
import * as React from 'react';
|
9
|
-
import { TouchableWithoutFeedback, View, StyleSheet } from 'react-native';
|
10
|
-
import Icon from '../Icon';
|
11
|
-
|
12
|
-
var _Radio = /*#__PURE__*/function (_React$Component) {
|
13
|
-
_inherits(_Radio, _React$Component);
|
14
|
-
|
15
|
-
var _super = _createSuper(_Radio);
|
16
|
-
|
17
|
-
function _Radio() {
|
18
|
-
var _this;
|
19
|
-
|
20
|
-
_classCallCheck(this, _Radio);
|
21
|
-
|
22
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
23
|
-
args[_key] = arguments[_key];
|
24
|
-
}
|
25
|
-
|
26
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
27
|
-
|
28
|
-
_defineProperty(_assertThisInitialized(_this), "$touchable", /*#__PURE__*/React.createRef());
|
29
|
-
|
30
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
31
|
-
checked: _this.props.checked
|
32
|
-
});
|
33
|
-
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "_simulateNativePress", function (evt) {
|
35
|
-
var node = _this.$touchable.current;
|
36
|
-
node && node.props.onPress && node.props.onPress(evt);
|
37
|
-
});
|
38
|
-
|
39
|
-
_defineProperty(_assertThisInitialized(_this), "onPress", function () {
|
40
|
-
var _this$props = _this.props,
|
41
|
-
disabled = _this$props.disabled,
|
42
|
-
onChange = _this$props.onChange,
|
43
|
-
value = _this$props.value;
|
44
|
-
if (disabled) return;
|
45
|
-
typeof onChange === 'function' && onChange({
|
46
|
-
value: value,
|
47
|
-
checked: !_this.state.checked,
|
48
|
-
type: 'change'
|
49
|
-
});
|
50
|
-
|
51
|
-
_this.setState({
|
52
|
-
checked: !_this.state.checked
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
return _this;
|
57
|
-
}
|
58
|
-
|
59
|
-
_createClass(_Radio, [{
|
60
|
-
key: "componentDidUpdate",
|
61
|
-
value: function componentDidUpdate(prevProps) {
|
62
|
-
if (prevProps.checked !== this.props.checked) {
|
63
|
-
this.setState({
|
64
|
-
checked: this.props.checked
|
65
|
-
});
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}, {
|
69
|
-
key: "render",
|
70
|
-
value: function render() {
|
71
|
-
var _this$props2 = this.props,
|
72
|
-
style = _this$props2.style,
|
73
|
-
color = _this$props2.color,
|
74
|
-
disabled = _this$props2.disabled;
|
75
|
-
var checked = this.state.checked;
|
76
|
-
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
|
77
|
-
onPress: this.onPress,
|
78
|
-
ref: this.$touchable
|
79
|
-
}, /*#__PURE__*/React.createElement(View, {
|
80
|
-
style: styles.container
|
81
|
-
}, /*#__PURE__*/React.createElement(View, {
|
82
|
-
style: [styles.wrapper, {
|
83
|
-
backgroundColor: disabled ? 'rgba(0,0,0,0.2)' : checked ? '#007AFF' : '#FFF',
|
84
|
-
borderColor: disabled ? 'rgba(0,0,0,0.2)' : checked ? '#007AFF' : 'rgba(0,0,0,0.2)'
|
85
|
-
}, style]
|
86
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
87
|
-
type: "success_no_circle",
|
88
|
-
size: 12,
|
89
|
-
color: color,
|
90
|
-
style: [styles.wrapperIcon, checked && styles.wrapperCheckedIcon]
|
91
|
-
})), /*#__PURE__*/React.createElement(View, {
|
92
|
-
style: {
|
93
|
-
flexGrow: 0
|
94
|
-
}
|
95
|
-
}, this.props.children)));
|
96
|
-
}
|
97
|
-
}]);
|
98
|
-
|
99
|
-
return _Radio;
|
100
|
-
}(React.Component);
|
101
|
-
|
102
|
-
_defineProperty(_Radio, "displayName", '_Radio');
|
103
|
-
|
104
|
-
_defineProperty(_Radio, "defaultProps", {
|
105
|
-
value: '',
|
106
|
-
color: '#FFF',
|
107
|
-
checked: false,
|
108
|
-
disabled: false
|
109
|
-
});
|
110
|
-
|
111
|
-
export default _Radio;
|
112
|
-
var styles = StyleSheet.create({
|
113
|
-
wrapper: {
|
114
|
-
alignItems: 'center',
|
115
|
-
justifyContent: 'center',
|
116
|
-
width: 18,
|
117
|
-
height: 18,
|
118
|
-
borderWidth: 1,
|
119
|
-
borderRadius: 9,
|
120
|
-
overflow: 'hidden'
|
121
|
-
},
|
122
|
-
wrapperIcon: {
|
123
|
-
opacity: 0
|
124
|
-
},
|
125
|
-
wrapperCheckedIcon: {
|
126
|
-
opacity: 1
|
127
|
-
},
|
128
|
-
container: {
|
129
|
-
flexDirection: 'row',
|
130
|
-
alignItems: 'center'
|
131
|
-
}
|
132
|
-
});
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { ViewStyle, StyleProp } from 'react-native';
|
3
|
-
import { RadioGroupProps, RadioGroupOption } from './props';
|
4
|
-
export interface IProps extends Omit<RadioGroupProps, 'style'> {
|
5
|
-
style?: StyleProp<ViewStyle>;
|
6
|
-
}
|
7
|
-
export interface IState {
|
8
|
-
options: RadioGroupOption[];
|
9
|
-
}
|
10
|
-
export default class RadioGroup extends React.Component<IProps, IState> {
|
11
|
-
constructor(props: IProps);
|
12
|
-
getValueData: (options: RadioGroupOption[]) => string[];
|
13
|
-
_handleChange: (event: {
|
14
|
-
value: string;
|
15
|
-
checked: boolean;
|
16
|
-
}, index: number) => void;
|
17
|
-
render(): JSX.Element;
|
18
|
-
}
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
6
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
7
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
9
|
-
import "core-js/modules/es.array.map.js";
|
10
|
-
import "core-js/modules/es.array.filter.js";
|
11
|
-
import "core-js/modules/es.object.to-string.js";
|
12
|
-
import "core-js/modules/es.array.concat.js";
|
13
|
-
import React from 'react';
|
14
|
-
import { View, Text } from 'react-native';
|
15
|
-
import Radio from '../Radio';
|
16
|
-
|
17
|
-
var RadioGroup = /*#__PURE__*/function (_React$Component) {
|
18
|
-
_inherits(RadioGroup, _React$Component);
|
19
|
-
|
20
|
-
var _super = _createSuper(RadioGroup);
|
21
|
-
|
22
|
-
function RadioGroup(props) {
|
23
|
-
var _this;
|
24
|
-
|
25
|
-
_classCallCheck(this, RadioGroup);
|
26
|
-
|
27
|
-
_this = _super.call(this, props);
|
28
|
-
|
29
|
-
_defineProperty(_assertThisInitialized(_this), "getValueData", function (options) {
|
30
|
-
return options.filter(function (item) {
|
31
|
-
return item.checked;
|
32
|
-
}).map(function (item) {
|
33
|
-
return item.value;
|
34
|
-
});
|
35
|
-
});
|
36
|
-
|
37
|
-
_defineProperty(_assertThisInitialized(_this), "_handleChange", function (event, index) {
|
38
|
-
var onChange = _this.props.onChange;
|
39
|
-
var options = _this.state.options;
|
40
|
-
var newOptions = options.concat([]);
|
41
|
-
newOptions[index] = _objectSpread(_objectSpread({}, newOptions[index]), event);
|
42
|
-
|
43
|
-
_this.setState({
|
44
|
-
options: newOptions
|
45
|
-
});
|
46
|
-
|
47
|
-
typeof onChange === 'function' && onChange({
|
48
|
-
type: 'change',
|
49
|
-
value: _this.getValueData(newOptions)
|
50
|
-
});
|
51
|
-
});
|
52
|
-
|
53
|
-
_this.state = {
|
54
|
-
options: props.options
|
55
|
-
};
|
56
|
-
return _this;
|
57
|
-
}
|
58
|
-
|
59
|
-
_createClass(RadioGroup, [{
|
60
|
-
key: "render",
|
61
|
-
value: function render() {
|
62
|
-
var _this2 = this;
|
63
|
-
|
64
|
-
var _this$props = this.props,
|
65
|
-
style = _this$props.style,
|
66
|
-
disabled = _this$props.disabled;
|
67
|
-
var options = this.state.options;
|
68
|
-
return /*#__PURE__*/React.createElement(View, {
|
69
|
-
style: [{
|
70
|
-
flexDirection: 'row'
|
71
|
-
}, style]
|
72
|
-
}, options.length && options.map(function (item, index) {
|
73
|
-
var data = disabled ? _objectSpread(_objectSpread({}, item), {}, {
|
74
|
-
disabled: disabled
|
75
|
-
}) : item;
|
76
|
-
return /*#__PURE__*/React.createElement(View, {
|
77
|
-
style: {
|
78
|
-
flexDirection: 'row',
|
79
|
-
alignItems: 'center',
|
80
|
-
paddingLeft: index ? 5 : 0
|
81
|
-
},
|
82
|
-
key: Math.random()
|
83
|
-
}, /*#__PURE__*/React.createElement(Radio, _extends({}, data, {
|
84
|
-
onChange: function onChange(event) {
|
85
|
-
return _this2._handleChange(event, index);
|
86
|
-
}
|
87
|
-
})), item.label && /*#__PURE__*/React.createElement(Text, {
|
88
|
-
style: {
|
89
|
-
marginLeft: 5
|
90
|
-
}
|
91
|
-
}, item.label));
|
92
|
-
}));
|
93
|
-
}
|
94
|
-
}]);
|
95
|
-
|
96
|
-
return RadioGroup;
|
97
|
-
}(React.Component);
|
98
|
-
|
99
|
-
export { RadioGroup as default };
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent } from 'react-native';
|
3
|
-
import { ScrollViewProps } from './Props';
|
4
|
-
export declare type ScrollMetrics = {
|
5
|
-
contentLength: number;
|
6
|
-
dOffset: number;
|
7
|
-
dt: number;
|
8
|
-
offset: number;
|
9
|
-
offsetX: number;
|
10
|
-
offsetY: number;
|
11
|
-
timestamp: number;
|
12
|
-
velocity: number;
|
13
|
-
visibleLength: number;
|
14
|
-
};
|
15
|
-
export interface ScrollViewState {
|
16
|
-
snapScrollTop: number;
|
17
|
-
snapScrollLeft: number;
|
18
|
-
}
|
19
|
-
declare class _ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
|
20
|
-
static defaultProps: {
|
21
|
-
upperThreshold: number;
|
22
|
-
lowerThreshold: number;
|
23
|
-
scrollX: boolean;
|
24
|
-
};
|
25
|
-
static getDerivedStateFromProps(props: ScrollViewProps, state: ScrollViewState): ScrollViewState | null;
|
26
|
-
state: ScrollViewState;
|
27
|
-
_scrollMetrics: ScrollMetrics;
|
28
|
-
$scrollView: React.RefObject<any>;
|
29
|
-
_hasDataChangedSinceEndReached: boolean;
|
30
|
-
_sentEndForContentLength: number;
|
31
|
-
_scrollEventThrottle: number;
|
32
|
-
_hasCallScrollToUpperInRange: boolean;
|
33
|
-
_hasCallScrollToLowerInRange: boolean;
|
34
|
-
_initialScrollIndexTimeout: any;
|
35
|
-
_selectLength: (metrics: {
|
36
|
-
height: number;
|
37
|
-
width: number;
|
38
|
-
}) => number;
|
39
|
-
_selectOffset: (metrics: {
|
40
|
-
x: number;
|
41
|
-
y: number;
|
42
|
-
}) => number;
|
43
|
-
_maybeCallOnStartReached: (e: any) => void;
|
44
|
-
_maybeCallOnEndReached: (e: any) => void;
|
45
|
-
_onContentSizeChange: (width: number, height: number) => void;
|
46
|
-
_onScrollEndDrag: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
47
|
-
_onMomentumScrollEnd: () => void;
|
48
|
-
_onLayout: (e: LayoutChangeEvent) => void;
|
49
|
-
_onScroll: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
50
|
-
scrollToOffset: (x?: number, y?: number) => void;
|
51
|
-
componentDidMount(): void;
|
52
|
-
getSnapshotBeforeUpdate(prevProps: ScrollViewProps, prevState: ScrollViewState): boolean;
|
53
|
-
componentDidUpdate(prevProps: ScrollViewProps, prevState: ScrollViewState, snapshot: boolean): void;
|
54
|
-
componentWillUnmount(): void;
|
55
|
-
render(): JSX.Element;
|
56
|
-
}
|
57
|
-
export default _ScrollView;
|
@@ -1,283 +0,0 @@
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
6
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
8
|
-
import "core-js/modules/es.array.concat.js";
|
9
|
-
import * as React from 'react';
|
10
|
-
import { ScrollView, StyleSheet } from 'react-native';
|
11
|
-
import { omit } from '../utils';
|
12
|
-
|
13
|
-
var _ScrollView = /*#__PURE__*/function (_React$Component) {
|
14
|
-
_inherits(_ScrollView, _React$Component);
|
15
|
-
|
16
|
-
var _super = _createSuper(_ScrollView);
|
17
|
-
|
18
|
-
function _ScrollView() {
|
19
|
-
var _this;
|
20
|
-
|
21
|
-
_classCallCheck(this, _ScrollView);
|
22
|
-
|
23
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
24
|
-
args[_key] = arguments[_key];
|
25
|
-
}
|
26
|
-
|
27
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
28
|
-
|
29
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
30
|
-
snapScrollTop: 0,
|
31
|
-
snapScrollLeft: 0
|
32
|
-
});
|
33
|
-
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "_scrollMetrics", {
|
35
|
-
contentLength: 0,
|
36
|
-
dOffset: 0,
|
37
|
-
dt: 10,
|
38
|
-
offset: 0,
|
39
|
-
offsetX: 0,
|
40
|
-
offsetY: 0,
|
41
|
-
timestamp: 0,
|
42
|
-
velocity: 0,
|
43
|
-
visibleLength: 0
|
44
|
-
});
|
45
|
-
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "$scrollView", /*#__PURE__*/React.createRef());
|
47
|
-
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "_sentEndForContentLength", 0);
|
49
|
-
|
50
|
-
_defineProperty(_assertThisInitialized(_this), "_scrollEventThrottle", 50);
|
51
|
-
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "_hasCallScrollToUpperInRange", true);
|
53
|
-
|
54
|
-
_defineProperty(_assertThisInitialized(_this), "_hasCallScrollToLowerInRange", false);
|
55
|
-
|
56
|
-
_defineProperty(_assertThisInitialized(_this), "_selectLength", function (metrics) {
|
57
|
-
var scrollX = _this.props.scrollX;
|
58
|
-
return !scrollX ? metrics.height : metrics.width;
|
59
|
-
});
|
60
|
-
|
61
|
-
_defineProperty(_assertThisInitialized(_this), "_selectOffset", function (metrics) {
|
62
|
-
var scrollX = _this.props.scrollX;
|
63
|
-
return !scrollX ? metrics.y : metrics.x;
|
64
|
-
});
|
65
|
-
|
66
|
-
_defineProperty(_assertThisInitialized(_this), "_maybeCallOnStartReached", function (e) {
|
67
|
-
var _this$props = _this.props,
|
68
|
-
onScrollToUpper = _this$props.onScrollToUpper,
|
69
|
-
upperThreshold = _this$props.upperThreshold,
|
70
|
-
scrollX = _this$props.scrollX;
|
71
|
-
var offset = _this._scrollMetrics.offset;
|
72
|
-
|
73
|
-
if (onScrollToUpper && offset <= upperThreshold) {
|
74
|
-
if (!_this._hasCallScrollToUpperInRange) {
|
75
|
-
typeof onScrollToUpper === 'function' && onScrollToUpper({
|
76
|
-
type: 'scrolltoupper',
|
77
|
-
direction: scrollX ? 'left' : 'top',
|
78
|
-
// distanceFromTop: offset,
|
79
|
-
origin: e
|
80
|
-
});
|
81
|
-
_this._hasCallScrollToUpperInRange = true;
|
82
|
-
}
|
83
|
-
} else {
|
84
|
-
_this._hasCallScrollToUpperInRange = false;
|
85
|
-
}
|
86
|
-
});
|
87
|
-
|
88
|
-
_defineProperty(_assertThisInitialized(_this), "_maybeCallOnEndReached", function (e) {
|
89
|
-
var _this$props2 = _this.props,
|
90
|
-
onScrollToLower = _this$props2.onScrollToLower,
|
91
|
-
lowerThreshold = _this$props2.lowerThreshold,
|
92
|
-
scrollX = _this$props2.scrollX;
|
93
|
-
var _this$_scrollMetrics = _this._scrollMetrics,
|
94
|
-
contentLength = _this$_scrollMetrics.contentLength,
|
95
|
-
visibleLength = _this$_scrollMetrics.visibleLength,
|
96
|
-
offset = _this$_scrollMetrics.offset;
|
97
|
-
|
98
|
-
if (onScrollToLower && contentLength - visibleLength - offset < lowerThreshold) {
|
99
|
-
if (!_this._hasCallScrollToLowerInRange) {
|
100
|
-
_this._hasDataChangedSinceEndReached = false;
|
101
|
-
_this._hasCallScrollToLowerInRange = true;
|
102
|
-
_this._sentEndForContentLength = _this._scrollMetrics.contentLength;
|
103
|
-
typeof onScrollToLower === 'function' && onScrollToLower({
|
104
|
-
type: 'scrolltolower',
|
105
|
-
direction: scrollX ? 'right' : 'bottom',
|
106
|
-
// distanceFromEnd,
|
107
|
-
origin: e
|
108
|
-
});
|
109
|
-
}
|
110
|
-
} else {
|
111
|
-
_this._hasCallScrollToLowerInRange = false;
|
112
|
-
}
|
113
|
-
});
|
114
|
-
|
115
|
-
_defineProperty(_assertThisInitialized(_this), "_onContentSizeChange", function (width, height) {
|
116
|
-
_this._scrollMetrics.contentLength = _this._selectLength({
|
117
|
-
height: height,
|
118
|
-
width: width
|
119
|
-
});
|
120
|
-
});
|
121
|
-
|
122
|
-
_defineProperty(_assertThisInitialized(_this), "_onScrollEndDrag", function (e) {
|
123
|
-
var velocity = e.nativeEvent.velocity;
|
124
|
-
|
125
|
-
if (velocity) {
|
126
|
-
_this._scrollMetrics.velocity = _this._selectOffset(velocity);
|
127
|
-
}
|
128
|
-
});
|
129
|
-
|
130
|
-
_defineProperty(_assertThisInitialized(_this), "_onMomentumScrollEnd", function () {
|
131
|
-
_this._scrollMetrics.velocity = 0;
|
132
|
-
});
|
133
|
-
|
134
|
-
_defineProperty(_assertThisInitialized(_this), "_onLayout", function (e) {
|
135
|
-
_this._scrollMetrics.visibleLength = _this._selectLength(e.nativeEvent.layout);
|
136
|
-
});
|
137
|
-
|
138
|
-
_defineProperty(_assertThisInitialized(_this), "_onScroll", function (e) {
|
139
|
-
var onScroll = _this.props.onScroll;
|
140
|
-
var scrollLeft = e.nativeEvent.contentOffset.x;
|
141
|
-
var scrollTop = e.nativeEvent.contentOffset.y;
|
142
|
-
var scrollHeight = e.nativeEvent.contentSize.height;
|
143
|
-
var scrollWidth = e.nativeEvent.contentSize.width;
|
144
|
-
typeof onScroll === 'function' && onScroll({
|
145
|
-
type: 'scroll',
|
146
|
-
scrollLeft: scrollLeft,
|
147
|
-
scrollTop: scrollTop,
|
148
|
-
scrollHeight: scrollHeight,
|
149
|
-
scrollWidth: scrollWidth,
|
150
|
-
deltaX: scrollLeft - _this._scrollMetrics.offsetX,
|
151
|
-
deltaY: scrollTop - _this._scrollMetrics.offsetY,
|
152
|
-
origin: e
|
153
|
-
});
|
154
|
-
var timestamp = e.timeStamp;
|
155
|
-
|
156
|
-
var visibleLength = _this._selectLength(e.nativeEvent.layoutMeasurement);
|
157
|
-
|
158
|
-
var contentLength = _this._selectLength(e.nativeEvent.contentSize);
|
159
|
-
|
160
|
-
var offset = _this._selectOffset(e.nativeEvent.contentOffset);
|
161
|
-
|
162
|
-
var dt = Math.max(1, timestamp - _this._scrollMetrics.timestamp);
|
163
|
-
var dOffset = offset - _this._scrollMetrics.offset;
|
164
|
-
_this._scrollMetrics = {
|
165
|
-
contentLength: contentLength,
|
166
|
-
dt: dt,
|
167
|
-
dOffset: dOffset,
|
168
|
-
offset: offset,
|
169
|
-
offsetX: scrollLeft,
|
170
|
-
offsetY: scrollTop,
|
171
|
-
timestamp: timestamp,
|
172
|
-
velocity: dOffset / dt,
|
173
|
-
visibleLength: visibleLength
|
174
|
-
};
|
175
|
-
|
176
|
-
_this._maybeCallOnStartReached(e);
|
177
|
-
|
178
|
-
_this._maybeCallOnEndReached(e);
|
179
|
-
});
|
180
|
-
|
181
|
-
_defineProperty(_assertThisInitialized(_this), "scrollToOffset", function () {
|
182
|
-
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
183
|
-
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
184
|
-
var node = _this.$scrollView.current;
|
185
|
-
|
186
|
-
if (node) {
|
187
|
-
node.scrollTo({
|
188
|
-
x: x,
|
189
|
-
y: y,
|
190
|
-
animated: !!_this.props.scrollWithAnimation
|
191
|
-
});
|
192
|
-
}
|
193
|
-
});
|
194
|
-
|
195
|
-
return _this;
|
196
|
-
}
|
197
|
-
|
198
|
-
_createClass(_ScrollView, [{
|
199
|
-
key: "componentDidMount",
|
200
|
-
value: function componentDidMount() {
|
201
|
-
var _this2 = this;
|
202
|
-
|
203
|
-
if (this.state.snapScrollTop || this.state.snapScrollLeft) {
|
204
|
-
this._initialScrollIndexTimeout = setTimeout(function () {
|
205
|
-
_this2.scrollToOffset(_this2.state.snapScrollLeft, _this2.state.snapScrollTop);
|
206
|
-
}, 0);
|
207
|
-
}
|
208
|
-
}
|
209
|
-
}, {
|
210
|
-
key: "getSnapshotBeforeUpdate",
|
211
|
-
value: function getSnapshotBeforeUpdate(prevProps, prevState) {
|
212
|
-
if (prevProps.scrollTop !== undefined) {
|
213
|
-
return this._scrollMetrics.offsetY !== this.state.snapScrollTop || this._scrollMetrics.offsetX !== this.state.snapScrollLeft;
|
214
|
-
}
|
215
|
-
|
216
|
-
return prevState.snapScrollTop !== this.state.snapScrollTop || prevState.snapScrollLeft !== this.state.snapScrollLeft;
|
217
|
-
}
|
218
|
-
}, {
|
219
|
-
key: "componentDidUpdate",
|
220
|
-
value: function componentDidUpdate(prevProps, prevState, snapshot) {
|
221
|
-
if (snapshot) {
|
222
|
-
this.scrollToOffset(this.state.snapScrollLeft, this.state.snapScrollTop);
|
223
|
-
}
|
224
|
-
}
|
225
|
-
}, {
|
226
|
-
key: "componentWillUnmount",
|
227
|
-
value: function componentWillUnmount() {
|
228
|
-
this._initialScrollIndexTimeout && clearTimeout(this._initialScrollIndexTimeout);
|
229
|
-
}
|
230
|
-
}, {
|
231
|
-
key: "render",
|
232
|
-
value: function render() {
|
233
|
-
var _this$props3 = this.props,
|
234
|
-
children = _this$props3.children,
|
235
|
-
style = _this$props3.style,
|
236
|
-
scrollX = _this$props3.scrollX;
|
237
|
-
var flattenStyle = StyleSheet.flatten(style);
|
238
|
-
var wrapperStyle = omit(flattenStyle, ['alignItems', 'justifyContent']);
|
239
|
-
var _contentContainerStyle = {};
|
240
|
-
|
241
|
-
if (flattenStyle) {
|
242
|
-
flattenStyle.alignItems && (_contentContainerStyle.alignItems = flattenStyle.alignItems);
|
243
|
-
flattenStyle.justifyContent && (_contentContainerStyle.justifyContent = flattenStyle.justifyContent);
|
244
|
-
}
|
245
|
-
|
246
|
-
var scrollElementProps = _objectSpread(_objectSpread({
|
247
|
-
horizontal: scrollX,
|
248
|
-
onContentSizeChange: this._onContentSizeChange,
|
249
|
-
onLayout: this._onLayout,
|
250
|
-
onScroll: this._onScroll,
|
251
|
-
onScrollEndDrag: this._onScrollEndDrag,
|
252
|
-
onMomentumScrollEnd: this._onMomentumScrollEnd,
|
253
|
-
scrollEventThrottle: this._scrollEventThrottle,
|
254
|
-
style: wrapperStyle,
|
255
|
-
contentContainerStyle: [_contentContainerStyle]
|
256
|
-
}, omit(this.props, [// props
|
257
|
-
'style', 'scrollX', 'upperThreshold', 'lowerThreshold', 'scrollTop', 'scrollLeft', 'scrollWithAnimation', 'onScrollToUpper', 'onScrollToLower', 'onScroll', 'contentContainerStyle', // SProps
|
258
|
-
'horizontal', 'onContentSizeChange', 'onLayout', 'onScroll', 'onScrollEndDrag', 'onMomentumScrollEnd', 'scrollEventThrottle', 'scrollsToTop', 'style', 'contentContainerStyle', 'data', 'renderItem', 'keyExtractor'])), {}, {
|
259
|
-
ref: this.$scrollView
|
260
|
-
});
|
261
|
-
|
262
|
-
return /*#__PURE__*/React.createElement(ScrollView, scrollElementProps, children);
|
263
|
-
}
|
264
|
-
}], [{
|
265
|
-
key: "getDerivedStateFromProps",
|
266
|
-
value: function getDerivedStateFromProps(props, state) {
|
267
|
-
return state.snapScrollTop !== props.scrollTop || state.snapScrollLeft !== props.scrollLeft ? {
|
268
|
-
snapScrollTop: props.scrollTop || 0,
|
269
|
-
snapScrollLeft: props.scrollLeft || 0
|
270
|
-
} : null;
|
271
|
-
}
|
272
|
-
}]);
|
273
|
-
|
274
|
-
return _ScrollView;
|
275
|
-
}(React.Component);
|
276
|
-
|
277
|
-
_defineProperty(_ScrollView, "defaultProps", {
|
278
|
-
upperThreshold: 50,
|
279
|
-
lowerThreshold: 50,
|
280
|
-
scrollX: false
|
281
|
-
});
|
282
|
-
|
283
|
-
export default _ScrollView;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { SliderProps } from './props';
|
3
|
-
export default class Slider extends React.Component<SliderProps> {
|
4
|
-
static defaultProps: {
|
5
|
-
blockSize: number;
|
6
|
-
activeColor: string;
|
7
|
-
backgroundColor: string;
|
8
|
-
blockColor: string;
|
9
|
-
min: number;
|
10
|
-
max: number;
|
11
|
-
disabled: boolean;
|
12
|
-
value: number;
|
13
|
-
step: number;
|
14
|
-
};
|
15
|
-
constructor(props: SliderProps);
|
16
|
-
componentDidUpdate(prevProps: SliderProps): void;
|
17
|
-
state: {
|
18
|
-
currentValue: number;
|
19
|
-
};
|
20
|
-
render(): JSX.Element;
|
21
|
-
}
|