@arelstone/react-native-swipe-button
Advanced tools
Comparing version 0.2.6 to 0.3.0
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -10,5 +14,5 @@ if (k2 === undefined) k2 = k; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./SwipeButton"), exports); |
@@ -0,1 +1,2 @@ | ||
import { FC } from 'react'; | ||
import { StyleProp, ViewStyle } from 'react-native'; | ||
@@ -62,4 +63,3 @@ import { SwipeButtonCircleProps } from './SwipeButtonCircle'; | ||
}; | ||
export declare const DEFAULT_HEIGHT = 70; | ||
export declare const SwipeButton: ({ height, width, borderRadius, title, titleContainerProps, titleProps, titleContainerStyle, titleStyle, completeThresholdPercentage, underlayStyle, disabled, Icon, containerStyle, circleBackgroundColor, goBackToStart, onComplete, onSwipeEnd, onSwipeStart, }: SwipeButtonProps) => JSX.Element; | ||
export declare const SwipeButton: FC<SwipeButtonProps>; | ||
export {}; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -26,17 +30,13 @@ return result; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SwipeButton = exports.DEFAULT_HEIGHT = void 0; | ||
exports.SwipeButton = void 0; | ||
const react_1 = __importStar(require("react")); | ||
const react_native_1 = require("react-native"); | ||
const constants_1 = require("./constants"); | ||
const SwipeButtonCircle_1 = require("./SwipeButtonCircle"); | ||
const SwipeButtonText_1 = __importDefault(require("./SwipeButtonText")); | ||
exports.DEFAULT_HEIGHT = 70; | ||
const DEFAULT_WIDTH = react_native_1.Dimensions.get('window').width * 0.9; | ||
const DEFAULT_BORDER_RRADIUS = exports.DEFAULT_HEIGHT / 2; | ||
const DEFAULT_COMPLETE_THRESHOLD_PERCENTAGE = 70; | ||
const DEFAULT_GO_BACK_TO_START = false; | ||
exports.SwipeButton = ({ height = exports.DEFAULT_HEIGHT, width = DEFAULT_WIDTH, borderRadius = DEFAULT_BORDER_RRADIUS, title, titleContainerProps, titleProps, titleContainerStyle, titleStyle, completeThresholdPercentage = DEFAULT_COMPLETE_THRESHOLD_PERCENTAGE, underlayStyle, disabled, Icon, containerStyle, circleBackgroundColor, goBackToStart = DEFAULT_GO_BACK_TO_START, onComplete, onSwipeEnd = () => { }, onSwipeStart = () => { }, }) => { | ||
const [endReached, setEndReached] = react_1.useState(false); | ||
const SwipeButton = ({ height = constants_1.DEFAULT_HEIGHT, width = constants_1.DEFAULT_WIDTH, borderRadius = constants_1.DEFAULT_BORDER_RRADIUS, title, titleContainerProps, titleProps, titleContainerStyle, titleStyle, completeThresholdPercentage = constants_1.DEFAULT_COMPLETE_THRESHOLD_PERCENTAGE, underlayStyle, disabled, Icon, containerStyle, circleBackgroundColor, goBackToStart = constants_1.DEFAULT_GO_BACK_TO_START, onComplete, onSwipeEnd = () => { }, onSwipeStart = () => { }, }) => { | ||
const [endReached, setEndReached] = (0, react_1.useState)(false); | ||
const opacity = disabled ? 0.5 : 1; | ||
const opacityStyle = { opacity }; | ||
const [translateX] = react_1.useState(new react_native_1.Animated.Value(0)); | ||
const [translateX] = (0, react_1.useState)(new react_native_1.Animated.Value(0)); | ||
const scrollDistance = width - (completeThresholdPercentage / 100) - height; | ||
@@ -73,4 +73,2 @@ const completeThreshold = scrollDistance * (completeThresholdPercentage / 100); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error ignore this | ||
const isCompleted = translateX._value >= completeThreshold; | ||
@@ -107,2 +105,3 @@ return isCompleted | ||
}; | ||
exports.SwipeButton = SwipeButton; | ||
const styles = react_native_1.StyleSheet.create({ | ||
@@ -109,0 +108,0 @@ container: { |
@@ -0,1 +1,2 @@ | ||
import { FC } from 'react'; | ||
import { GestureResponderHandlers, Animated } from 'react-native'; | ||
@@ -25,2 +26,2 @@ import { SwipeButtonCommonProps } from './SwipeButton'; | ||
} | ||
export declare const SwipeButtonCircle: ({ Icon, opacity, panHandlers, translateX, height, borderRadius, circleBackgroundColor, }: SwipeButtonCircleProps) => JSX.Element; | ||
export declare const SwipeButtonCircle: FC<SwipeButtonCircleProps>; |
@@ -9,3 +9,3 @@ "use strict"; | ||
const react_native_1 = require("react-native"); | ||
exports.SwipeButtonCircle = ({ Icon, opacity, panHandlers, translateX, height, borderRadius, circleBackgroundColor, }) => { | ||
const SwipeButtonCircle = ({ Icon, opacity, panHandlers, translateX, height, borderRadius, circleBackgroundColor, }) => { | ||
return (react_1.default.createElement(react_native_1.Animated.View, Object.assign({ testID: "Button" }, panHandlers, { style: [ | ||
@@ -32,2 +32,3 @@ styles.iconContainer, | ||
}; | ||
exports.SwipeButtonCircle = SwipeButtonCircle; | ||
const styles = react_native_1.StyleSheet.create({ | ||
@@ -34,0 +35,0 @@ iconContainer: { |
@@ -0,1 +1,2 @@ | ||
import { FC } from 'react'; | ||
import { TextProps, StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native'; | ||
@@ -25,3 +26,3 @@ import { SwipeButtonCommonProps } from './SwipeButton'; | ||
} | ||
declare const SwipeButtonText: ({ title, titleStyle, titleContainerProps, titleContainerStyle, titleProps, height, }: SwipeButtonTextProps) => JSX.Element; | ||
declare const SwipeButtonText: FC<SwipeButtonTextProps>; | ||
export default SwipeButtonText; |
@@ -8,4 +8,4 @@ "use strict"; | ||
const react_native_1 = require("react-native"); | ||
const SwipeButton_1 = require("./SwipeButton"); | ||
const SwipeButtonText = ({ title, titleStyle, titleContainerProps, titleContainerStyle, titleProps, height = SwipeButton_1.DEFAULT_HEIGHT, }) => { | ||
const constants_1 = require("./constants"); | ||
const SwipeButtonText = ({ title, titleStyle, titleContainerProps, titleContainerStyle, titleProps, height = constants_1.DEFAULT_HEIGHT, }) => { | ||
return (react_1.default.createElement(react_native_1.View, Object.assign({ testID: "TitleContainer", style: [ | ||
@@ -12,0 +12,0 @@ styles.titleContainer, |
@@ -5,6 +5,7 @@ "use strict"; | ||
const react_native_1 = require("react-native"); | ||
exports.findElementByTestId = (Component, testID, wrapper) => { | ||
const findElementByTestId = (Component, testID, wrapper) => { | ||
return wrapper.find(Component).findWhere((n) => n.prop('testID') === testID); | ||
}; | ||
exports.testId = (value = '') => { | ||
exports.findElementByTestId = findElementByTestId; | ||
const testId = (value = '') => { | ||
return react_native_1.Platform.OS === 'ios' | ||
@@ -19,1 +20,2 @@ ? { | ||
}; | ||
exports.testId = testId; |
{ | ||
"name": "@arelstone/react-native-swipe-button", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"description": "A UI component for displaying a button that can be swiped.", | ||
@@ -52,3 +52,3 @@ "main": "dist/index.js", | ||
"ts-jest": "^25.2.1", | ||
"typescript": "^3.8.2" | ||
"typescript": "^4.6.3" | ||
}, | ||
@@ -55,0 +55,0 @@ "jest": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19671
16
381
0