Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-swipeable-list

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-swipeable-list - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

127

dist/module.d.ts

@@ -1,2 +0,7 @@

import { CSSProperties, FunctionComponent, PureComponent, ReactNode } from 'react';
import {
CSSProperties,
FunctionComponent,
PureComponent,
ReactNode,
} from 'react';

@@ -18,7 +23,7 @@ /**

*/
MS
MS,
}
interface SwipeActionProps {
children: ReactNode,
children: ReactNode;
/**

@@ -29,13 +34,13 @@ * default: `false`

*/
destructive?: boolean,
destructive?: boolean;
/**
* Callback function that should be call after swipe action is triggered.
*/
onClick: () => void,
onClick: () => void;
/**
* default: `span`
*
*
* HTML tag that is used to create this component.
*/
Tag?: string,
Tag?: string;
}

@@ -46,3 +51,3 @@

interface LeadingActionsProps {
children: ReactNode
children: ReactNode;
}

@@ -53,3 +58,3 @@

interface TrailingActionsProps {
children: ReactNode
children: ReactNode;
}

@@ -60,60 +65,60 @@

interface SwipeableListProps {
children: ReactNode,
children: ReactNode;
/**
* default: `false`
*
*
* Changes behavior of `IOS` list type.
* When `true` and swipe is done beyond `threshold` and released the action is triggered.
*/
fullSwipe?: boolean,
fullSwipe?: boolean;
/**
* default: `1000`
*
*
* Time in milliseconds after which swipe action should be called for `destructive` swipe action (item deletion)
*
*
* It can be set for the whole list or for every item. See `destructiveCallbackDelay` for `SwipeableListItem`. Value from the `SwipeableListItem` takes precedence.
*/
destructiveCallbackDelay?: number,
destructiveCallbackDelay?: number;
/**
* default: `undefined`
*
*
* Additional styles for list tag.
*/
style?: CSSProperties,
style?: CSSProperties;
/**
* default: `ANDROID`
*
*
* Changes behavior of swipeable items.
*/
type?: Type,
type?: Type;
/**
* default: `div`
*
*
* HTML tag that is used to create this component.
*/
Tag?: string,
Tag?: string;
/**
* default: `10`
*
*
* How far in pixels scroll needs to be done to block swiping. After scrolling is started and goes beyond the threshold, swiping is blocked.
*
*
* It can be set for the whole list or for every item. See `scrollStartThreshold` for `SwipeableListItem`. Value from the `SwipeableListItem` takes precedence.
*/
scrollStartThreshold?: number,
scrollStartThreshold?: number;
/**
* default: `10`
*
*
* How far in pixels swipe needs to be done to start swiping on list item. After a swipe is started and goes beyond the threshold, scrolling is blocked.
*
*
* It can be set for the whole list or for every item. See `swipeStartThreshold` for `SwipeableListItem`. Value from the `SwipeableListItem` takes precedence.
*/
swipeStartThreshold?: number,
swipeStartThreshold?: number;
/**
* default: `0.5`
*
*
* How far swipe needs to be done to trigger attached action. `0.5` means that item needs to be swiped to half of its width, `0.25` - one-quarter of width.
*
*
* It can be set for the whole list or for every item. See `threshold` for `SwipeableListItem`. Value from the `SwipeableListItem` takes precedence.
*/
threshold?: number,
threshold?: number;
}

@@ -126,54 +131,58 @@

* default: `false`
*
*
* If set to `true` all defined swipe actions are blocked.
*/
blockSwipe?: boolean,
children?: ReactNode,
blockSwipe?: boolean;
children?: ReactNode;
/**
* default: `1000`
*
*
* Time in milliseconds after which swipe action should be called for `destructive` swipe action (item deletion).
*
*
* It can be set for the whole list or for single item. See `destructiveCallbackDelay` for `SwipeableList`. Value from the `SwipeableListItem` takes precedence.
*/
destructiveCallbackDelay?: number,
destructiveCallbackDelay?: number;
/**
* default: `false`
*
*
* Changes behavior of `IOS` list type.
* When `true` and swipe is done beyond `threshold` and released the action is triggered.
* When set to `false` actions are only opened and they need to be clicked to trigger action.
*
* It can be set for the whole list or for single item. See `fullSwipe` for `SwipeableList`. Value from the `SwipeableListItem` takes precedence.
*
* It can be set for the whole list or for single item. See `fullSwipe` for `SwipeableList`. Value from the `SwipeableListItem` takes precedence.
*/
fullSwipe?: boolean,
fullSwipe?: boolean;
/**
* default: `undefined`
*
*
* `LeadingActions` component. See `LeadingActions`.
*/
leadingActions?: ReactNode,
leadingActions?: ReactNode;
/**
* default: `ANDROID`
*
*
* Changes behavior of swipeable items.
*
* It can be set for the whole list or for single item. See `type` for `SwipeableList`. Value from the `SwipeableListItem` takes precedence.
*
* It can be set for the whole list or for single item. See `type` for `SwipeableList`. Value from the `SwipeableListItem` takes precedence.
*/
listType?: Type,
listType?: Type;
/**
* Fired when item is clicked.
*/
onClick?: () => void;
/**
* Fired after swipe has ended.
*/
onSwipeEnd?: () => void,
onSwipeEnd?: () => void;
/**
* Fired every time swipe progress changes. The reported `progress` value is always an integer in range 0 to 100 inclusive.
*/
onSwipeProgress?: () => void,
onSwipeProgress?: () => void;
/**
* Fired after swipe has started (after drag gesture passes the `swipeStartThreshold` distance in pixels).
*/
onSwipeStart?: () => void,
onSwipeStart?: () => void;
/**
* default: `10`
*
*
* How far in pixels scroll needs to be done to block swiping. After scrolling is started and goes beyond the threshold, swiping is blocked.

@@ -183,27 +192,27 @@ *

*/
scrollStartThreshold?: number,
scrollStartThreshold?: number;
/**
* default: `10`
*
*
* How far in pixels swipe needs to be done to start swiping on list item. After a swipe is started and goes beyond the threshold, scrolling is blocked.
*
*
* It can be set for the whole list or for every item. See `swipeStartThreshold` for `SwipeableListItem`. Value from the `SwipeableListItem` takes precedence.
*/
swipeStartThreshold?: number,
swipeStartThreshold?: number;
/**
* default: `0.5`
*
*
* How far swipe needs to be done to trigger action. `0.5` means that item needs to be swiped to half of its width, `0.25` - one-quarter of width.
*
*
* It can be set for the whole list or for every item. See `threshold` for `SwipeableListItem`. Value from the `SwipeableListItem` takes precedence.
*/
threshold?: number,
threshold?: number;
/**
* default: `undefined`
*
*
* `TrailingActions` component. See `TrailingActions`.
*/
trailingActions?: ReactNode,
trailingActions?: ReactNode;
}
export class SwipeableListItem extends PureComponent<SwipeableListItemProps> {}

@@ -21,4 +21,4 @@ 'use strict';

if (Array.isArray(children)) {
return React__default['default'].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default['default'].cloneElement(child, {
return React__default["default"].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default["default"].cloneElement(child, {
leading: true,

@@ -30,3 +30,3 @@ main: index === 0

return /*#__PURE__*/React__default['default'].cloneElement(children, {
return /*#__PURE__*/React__default["default"].cloneElement(children, {
leading: true,

@@ -101,13 +101,13 @@ main: true

threshold = _ref$threshold === void 0 ? 0.5 : _ref$threshold;
return /*#__PURE__*/React__default['default'].createElement(Tag, {
return /*#__PURE__*/React__default["default"].createElement(Tag, {
className: clsx('swipeable-list', className),
style: style
}, React__default['default'].Children.map(children, function (child) {
return /*#__PURE__*/React__default['default'].cloneElement(child, {
destructiveCallbackDelay,
fullSwipe,
}, React__default["default"].Children.map(children, function (child) {
return /*#__PURE__*/React__default["default"].cloneElement(child, {
destructiveCallbackDelay: destructiveCallbackDelay,
fullSwipe: fullSwipe,
listType: type,
scrollStartThreshold,
swipeStartThreshold,
threshold
scrollStartThreshold: scrollStartThreshold,
swipeStartThreshold: swipeStartThreshold,
threshold: threshold
});

@@ -118,12 +118,12 @@ }));

SwipeableList.propTypes = {
children: PropTypes__default['default'].node,
className: PropTypes__default['default'].string,
fullSwipe: PropTypes__default['default'].bool,
destructiveCallbackDelay: PropTypes__default['default'].number,
style: PropTypes__default['default'].object,
type: PropTypes__default['default'].oneOf(Object.values(Type)),
Tag: PropTypes__default['default'].string,
scrollStartThreshold: PropTypes__default['default'].number,
swipeStartThreshold: PropTypes__default['default'].number,
threshold: PropTypes__default['default'].number
children: PropTypes__default["default"].node,
className: PropTypes__default["default"].string,
fullSwipe: PropTypes__default["default"].bool,
destructiveCallbackDelay: PropTypes__default["default"].number,
style: PropTypes__default["default"].object,
type: PropTypes__default["default"].oneOf(Object.values(Type)),
Tag: PropTypes__default["default"].string,
scrollStartThreshold: PropTypes__default["default"].number,
swipeStartThreshold: PropTypes__default["default"].number,
threshold: PropTypes__default["default"].number
};

@@ -150,2 +150,5 @@

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;

@@ -174,8 +177,11 @@ }

subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
Object.defineProperty(subClass, "prototype", {
value: Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
}),
writable: false
});

@@ -225,2 +231,4 @@ if (superClass) _setPrototypeOf(subClass, superClass);

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -250,3 +258,3 @@

var ItemContext = /*#__PURE__*/React__default['default'].createContext();
var ItemContext = /*#__PURE__*/React__default["default"].createContext();
var ActionAnimation = {

@@ -517,11 +525,11 @@ RETURN: Symbol('Return'),

_this.playReturnAnimationForTrailingActions({
to,
isIosType,
playMsReturnAnimation
to: to,
isIosType: isIosType,
playMsReturnAnimation: playMsReturnAnimation
});
} else {
_this.playReturnAnimationForLeadingActions({
to,
isIosType,
playMsReturnAnimation
to: to,
isIosType: isIosType,
playMsReturnAnimation: playMsReturnAnimation
});

@@ -555,4 +563,4 @@ }

_this.setState({
leadingFullSwipe,
trailingFullSwipe
leadingFullSwipe: leadingFullSwipe,
trailingFullSwipe: trailingFullSwipe
});

@@ -865,19 +873,17 @@

var scaled = listType === Type.MS && (scaleLeading && type === 'leading' || scaleTrailing && type === 'trailing');
return /*#__PURE__*/React__default['default'].createElement("div", {
className: clsx("swipeable-list-item__".concat(type, "-actions"), {
["swipeable-list-item__".concat(type, "-actions--scaled")]: scaled
}),
return /*#__PURE__*/React__default["default"].createElement("div", {
className: clsx("swipeable-list-item__".concat(type, "-actions"), _defineProperty({}, "swipeable-list-item__".concat(type, "-actions--scaled"), scaled)),
"data-testid": "".concat(type, "-actions"),
ref: binder
}, /*#__PURE__*/React__default['default'].createElement(ItemContext.Provider, {
}, /*#__PURE__*/React__default["default"].createElement(ItemContext.Provider, {
value: {
destructiveCallbackDelay,
listType,
leadingFullSwipe,
onActionTriggered,
scaleLeading,
scaleTrailing,
setLeadingFullSwipeAction,
setTrailingFullSwipeAction,
trailingFullSwipe
destructiveCallbackDelay: destructiveCallbackDelay,
listType: listType,
leadingFullSwipe: leadingFullSwipe,
onActionTriggered: onActionTriggered,
scaleLeading: scaleLeading,
scaleTrailing: scaleTrailing,
setLeadingFullSwipeAction: setLeadingFullSwipeAction,
setTrailingFullSwipeAction: setTrailingFullSwipeAction,
trailingFullSwipe: trailingFullSwipe
}

@@ -985,7 +991,9 @@ }, actions));

leadingActions = _this$props4.leadingActions,
trailingActions = _this$props4.trailingActions;
return /*#__PURE__*/React__default['default'].createElement("div", {
trailingActions = _this$props4.trailingActions,
onClick = _this$props4.onClick;
return /*#__PURE__*/React__default["default"].createElement("div", {
className: clsx('swipeable-list-item', className),
ref: this.bindWrapperElement
}, leadingActions && this.renderActions(leadingActions, 'leading', this.bindLeadingActionsElement), /*#__PURE__*/React__default['default'].createElement("div", {
ref: this.bindWrapperElement,
onClick: this.leadingActionsOpened || this.trailingActionsOpened ? undefined : onClick
}, leadingActions && this.renderActions(leadingActions, 'leading', this.bindLeadingActionsElement), /*#__PURE__*/React__default["default"].createElement("div", {
className: "swipeable-list-item__content",

@@ -1002,16 +1010,17 @@ "data-testid": "content",

SwipeableListItem.propTypes = {
blockSwipe: PropTypes__default['default'].bool,
children: PropTypes__default['default'].node,
className: PropTypes__default['default'].string,
destructiveCallbackDelay: PropTypes__default['default'].number,
fullSwipe: PropTypes__default['default'].bool,
leadingActions: PropTypes__default['default'].node,
listType: PropTypes__default['default'].oneOf(Object.values(Type)),
onSwipeEnd: PropTypes__default['default'].func,
onSwipeProgress: PropTypes__default['default'].func,
onSwipeStart: PropTypes__default['default'].func,
scrollStartThreshold: PropTypes__default['default'].number,
swipeStartThreshold: PropTypes__default['default'].number,
threshold: PropTypes__default['default'].number,
trailingActions: PropTypes__default['default'].node
blockSwipe: PropTypes__default["default"].bool,
children: PropTypes__default["default"].node,
className: PropTypes__default["default"].string,
destructiveCallbackDelay: PropTypes__default["default"].number,
fullSwipe: PropTypes__default["default"].bool,
leadingActions: PropTypes__default["default"].node,
listType: PropTypes__default["default"].oneOf(Object.values(Type)),
onClick: PropTypes__default["default"].func,
onSwipeEnd: PropTypes__default["default"].func,
onSwipeProgress: PropTypes__default["default"].func,
onSwipeStart: PropTypes__default["default"].func,
scrollStartThreshold: PropTypes__default["default"].number,
swipeStartThreshold: PropTypes__default["default"].number,
threshold: PropTypes__default["default"].number,
trailingActions: PropTypes__default["default"].node
};

@@ -1032,3 +1041,3 @@

var _React$useContext = React__default['default'].useContext(ItemContext),
var _React$useContext = React__default["default"].useContext(ItemContext),
destructiveCallbackDelay = _React$useContext.destructiveCallbackDelay,

@@ -1044,3 +1053,3 @@ leadingFullSwipe = _React$useContext.leadingFullSwipe,

var onHandleClick = React__default['default'].useCallback(function () {
var onHandleClick = React__default["default"].useCallback(function () {
onActionTriggered(destructive);

@@ -1056,3 +1065,3 @@

}, [destructive, destructiveCallbackDelay, onActionTriggered, onClick]);
React__default['default'].useEffect(function () {
React__default["default"].useEffect(function () {
if (leading && main) {

@@ -1062,3 +1071,3 @@ setLeadingFullSwipeAction(onHandleClick);

}, [leading, main, onHandleClick, setLeadingFullSwipeAction]);
React__default['default'].useEffect(function () {
React__default["default"].useEffect(function () {
if (trailing && main) {

@@ -1068,3 +1077,3 @@ setTrailingFullSwipeAction(onHandleClick);

}, [trailing, main, onHandleClick, setTrailingFullSwipeAction]);
return /*#__PURE__*/React__default['default'].createElement(Tag, {
return /*#__PURE__*/React__default["default"].createElement(Tag, {
className: clsx('swipe-action', {

@@ -1084,10 +1093,10 @@ 'swipe-action__leading': leading,

SwipeAction.propTypes = {
children: PropTypes__default['default'].node.isRequired,
className: PropTypes__default['default'].string,
destructive: PropTypes__default['default'].bool,
main: PropTypes__default['default'].bool,
leading: PropTypes__default['default'].bool,
onClick: PropTypes__default['default'].func.isRequired,
trailing: PropTypes__default['default'].bool,
Tag: PropTypes__default['default'].string
children: PropTypes__default["default"].node.isRequired,
className: PropTypes__default["default"].string,
destructive: PropTypes__default["default"].bool,
main: PropTypes__default["default"].bool,
leading: PropTypes__default["default"].bool,
onClick: PropTypes__default["default"].func.isRequired,
trailing: PropTypes__default["default"].bool,
Tag: PropTypes__default["default"].string
};

@@ -1103,4 +1112,4 @@

if (Array.isArray(children)) {
return React__default['default'].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default['default'].cloneElement(child, {
return React__default["default"].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default["default"].cloneElement(child, {
main: index === children.length - 1,

@@ -1112,3 +1121,3 @@ trailing: true

return /*#__PURE__*/React__default['default'].cloneElement(children, {
return /*#__PURE__*/React__default["default"].cloneElement(children, {
main: true,

@@ -1115,0 +1124,0 @@ trailing: true

@@ -95,8 +95,8 @@ import React, { PureComponent } from 'react';

return /*#__PURE__*/React.cloneElement(child, {
destructiveCallbackDelay,
fullSwipe,
destructiveCallbackDelay: destructiveCallbackDelay,
fullSwipe: fullSwipe,
listType: type,
scrollStartThreshold,
swipeStartThreshold,
threshold
scrollStartThreshold: scrollStartThreshold,
swipeStartThreshold: swipeStartThreshold,
threshold: threshold
});

@@ -138,2 +138,5 @@ }));

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;

@@ -162,8 +165,11 @@ }

subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
Object.defineProperty(subClass, "prototype", {
value: Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
}),
writable: false
});

@@ -213,2 +219,4 @@ if (superClass) _setPrototypeOf(subClass, superClass);

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -504,11 +512,11 @@

_this.playReturnAnimationForTrailingActions({
to,
isIosType,
playMsReturnAnimation
to: to,
isIosType: isIosType,
playMsReturnAnimation: playMsReturnAnimation
});
} else {
_this.playReturnAnimationForLeadingActions({
to,
isIosType,
playMsReturnAnimation
to: to,
isIosType: isIosType,
playMsReturnAnimation: playMsReturnAnimation
});

@@ -542,4 +550,4 @@ }

_this.setState({
leadingFullSwipe,
trailingFullSwipe
leadingFullSwipe: leadingFullSwipe,
trailingFullSwipe: trailingFullSwipe
});

@@ -853,5 +861,3 @@

return /*#__PURE__*/React.createElement("div", {
className: clsx("swipeable-list-item__".concat(type, "-actions"), {
["swipeable-list-item__".concat(type, "-actions--scaled")]: scaled
}),
className: clsx("swipeable-list-item__".concat(type, "-actions"), _defineProperty({}, "swipeable-list-item__".concat(type, "-actions--scaled"), scaled)),
"data-testid": "".concat(type, "-actions"),

@@ -861,11 +867,11 @@ ref: binder

value: {
destructiveCallbackDelay,
listType,
leadingFullSwipe,
onActionTriggered,
scaleLeading,
scaleTrailing,
setLeadingFullSwipeAction,
setTrailingFullSwipeAction,
trailingFullSwipe
destructiveCallbackDelay: destructiveCallbackDelay,
listType: listType,
leadingFullSwipe: leadingFullSwipe,
onActionTriggered: onActionTriggered,
scaleLeading: scaleLeading,
scaleTrailing: scaleTrailing,
setLeadingFullSwipeAction: setLeadingFullSwipeAction,
setTrailingFullSwipeAction: setTrailingFullSwipeAction,
trailingFullSwipe: trailingFullSwipe
}

@@ -973,6 +979,8 @@ }, actions));

leadingActions = _this$props4.leadingActions,
trailingActions = _this$props4.trailingActions;
trailingActions = _this$props4.trailingActions,
onClick = _this$props4.onClick;
return /*#__PURE__*/React.createElement("div", {
className: clsx('swipeable-list-item', className),
ref: this.bindWrapperElement
ref: this.bindWrapperElement,
onClick: this.leadingActionsOpened || this.trailingActionsOpened ? undefined : onClick
}, leadingActions && this.renderActions(leadingActions, 'leading', this.bindLeadingActionsElement), /*#__PURE__*/React.createElement("div", {

@@ -997,2 +1005,3 @@ className: "swipeable-list-item__content",

listType: PropTypes.oneOf(Object.values(Type)),
onClick: PropTypes.func,
onSwipeEnd: PropTypes.func,

@@ -999,0 +1008,0 @@ onSwipeProgress: PropTypes.func,

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['react-swipeable-list'] = {}, global.React, global.PropTypes));
}(this, (function (exports, React, PropTypes) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["react-swipeable-list"] = {}, global.React, global.PropTypes));
})(this, (function (exports, React, PropTypes) { 'use strict';

@@ -20,4 +20,4 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

if (Array.isArray(children)) {
return React__default['default'].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default['default'].cloneElement(child, {
return React__default["default"].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default["default"].cloneElement(child, {
leading: true,

@@ -29,3 +29,3 @@ main: index === 0

return /*#__PURE__*/React__default['default'].cloneElement(children, {
return /*#__PURE__*/React__default["default"].cloneElement(children, {
leading: true,

@@ -100,13 +100,13 @@ main: true

threshold = _ref$threshold === void 0 ? 0.5 : _ref$threshold;
return /*#__PURE__*/React__default['default'].createElement(Tag, {
return /*#__PURE__*/React__default["default"].createElement(Tag, {
className: clsx('swipeable-list', className),
style: style
}, React__default['default'].Children.map(children, function (child) {
return /*#__PURE__*/React__default['default'].cloneElement(child, {
destructiveCallbackDelay,
fullSwipe,
}, React__default["default"].Children.map(children, function (child) {
return /*#__PURE__*/React__default["default"].cloneElement(child, {
destructiveCallbackDelay: destructiveCallbackDelay,
fullSwipe: fullSwipe,
listType: type,
scrollStartThreshold,
swipeStartThreshold,
threshold
scrollStartThreshold: scrollStartThreshold,
swipeStartThreshold: swipeStartThreshold,
threshold: threshold
});

@@ -117,12 +117,12 @@ }));

SwipeableList.propTypes = {
children: PropTypes__default['default'].node,
className: PropTypes__default['default'].string,
fullSwipe: PropTypes__default['default'].bool,
destructiveCallbackDelay: PropTypes__default['default'].number,
style: PropTypes__default['default'].object,
type: PropTypes__default['default'].oneOf(Object.values(Type)),
Tag: PropTypes__default['default'].string,
scrollStartThreshold: PropTypes__default['default'].number,
swipeStartThreshold: PropTypes__default['default'].number,
threshold: PropTypes__default['default'].number
children: PropTypes__default["default"].node,
className: PropTypes__default["default"].string,
fullSwipe: PropTypes__default["default"].bool,
destructiveCallbackDelay: PropTypes__default["default"].number,
style: PropTypes__default["default"].object,
type: PropTypes__default["default"].oneOf(Object.values(Type)),
Tag: PropTypes__default["default"].string,
scrollStartThreshold: PropTypes__default["default"].number,
swipeStartThreshold: PropTypes__default["default"].number,
threshold: PropTypes__default["default"].number
};

@@ -149,2 +149,5 @@

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;

@@ -173,8 +176,11 @@ }

subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
Object.defineProperty(subClass, "prototype", {
value: Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
}),
writable: false
});

@@ -224,2 +230,4 @@ if (superClass) _setPrototypeOf(subClass, superClass);

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -249,3 +257,3 @@

var ItemContext = /*#__PURE__*/React__default['default'].createContext();
var ItemContext = /*#__PURE__*/React__default["default"].createContext();
var ActionAnimation = {

@@ -516,11 +524,11 @@ RETURN: Symbol('Return'),

_this.playReturnAnimationForTrailingActions({
to,
isIosType,
playMsReturnAnimation
to: to,
isIosType: isIosType,
playMsReturnAnimation: playMsReturnAnimation
});
} else {
_this.playReturnAnimationForLeadingActions({
to,
isIosType,
playMsReturnAnimation
to: to,
isIosType: isIosType,
playMsReturnAnimation: playMsReturnAnimation
});

@@ -554,4 +562,4 @@ }

_this.setState({
leadingFullSwipe,
trailingFullSwipe
leadingFullSwipe: leadingFullSwipe,
trailingFullSwipe: trailingFullSwipe
});

@@ -864,19 +872,17 @@

var scaled = listType === Type.MS && (scaleLeading && type === 'leading' || scaleTrailing && type === 'trailing');
return /*#__PURE__*/React__default['default'].createElement("div", {
className: clsx("swipeable-list-item__".concat(type, "-actions"), {
["swipeable-list-item__".concat(type, "-actions--scaled")]: scaled
}),
return /*#__PURE__*/React__default["default"].createElement("div", {
className: clsx("swipeable-list-item__".concat(type, "-actions"), _defineProperty({}, "swipeable-list-item__".concat(type, "-actions--scaled"), scaled)),
"data-testid": "".concat(type, "-actions"),
ref: binder
}, /*#__PURE__*/React__default['default'].createElement(ItemContext.Provider, {
}, /*#__PURE__*/React__default["default"].createElement(ItemContext.Provider, {
value: {
destructiveCallbackDelay,
listType,
leadingFullSwipe,
onActionTriggered,
scaleLeading,
scaleTrailing,
setLeadingFullSwipeAction,
setTrailingFullSwipeAction,
trailingFullSwipe
destructiveCallbackDelay: destructiveCallbackDelay,
listType: listType,
leadingFullSwipe: leadingFullSwipe,
onActionTriggered: onActionTriggered,
scaleLeading: scaleLeading,
scaleTrailing: scaleTrailing,
setLeadingFullSwipeAction: setLeadingFullSwipeAction,
setTrailingFullSwipeAction: setTrailingFullSwipeAction,
trailingFullSwipe: trailingFullSwipe
}

@@ -984,7 +990,9 @@ }, actions));

leadingActions = _this$props4.leadingActions,
trailingActions = _this$props4.trailingActions;
return /*#__PURE__*/React__default['default'].createElement("div", {
trailingActions = _this$props4.trailingActions,
onClick = _this$props4.onClick;
return /*#__PURE__*/React__default["default"].createElement("div", {
className: clsx('swipeable-list-item', className),
ref: this.bindWrapperElement
}, leadingActions && this.renderActions(leadingActions, 'leading', this.bindLeadingActionsElement), /*#__PURE__*/React__default['default'].createElement("div", {
ref: this.bindWrapperElement,
onClick: this.leadingActionsOpened || this.trailingActionsOpened ? undefined : onClick
}, leadingActions && this.renderActions(leadingActions, 'leading', this.bindLeadingActionsElement), /*#__PURE__*/React__default["default"].createElement("div", {
className: "swipeable-list-item__content",

@@ -1001,16 +1009,17 @@ "data-testid": "content",

SwipeableListItem.propTypes = {
blockSwipe: PropTypes__default['default'].bool,
children: PropTypes__default['default'].node,
className: PropTypes__default['default'].string,
destructiveCallbackDelay: PropTypes__default['default'].number,
fullSwipe: PropTypes__default['default'].bool,
leadingActions: PropTypes__default['default'].node,
listType: PropTypes__default['default'].oneOf(Object.values(Type)),
onSwipeEnd: PropTypes__default['default'].func,
onSwipeProgress: PropTypes__default['default'].func,
onSwipeStart: PropTypes__default['default'].func,
scrollStartThreshold: PropTypes__default['default'].number,
swipeStartThreshold: PropTypes__default['default'].number,
threshold: PropTypes__default['default'].number,
trailingActions: PropTypes__default['default'].node
blockSwipe: PropTypes__default["default"].bool,
children: PropTypes__default["default"].node,
className: PropTypes__default["default"].string,
destructiveCallbackDelay: PropTypes__default["default"].number,
fullSwipe: PropTypes__default["default"].bool,
leadingActions: PropTypes__default["default"].node,
listType: PropTypes__default["default"].oneOf(Object.values(Type)),
onClick: PropTypes__default["default"].func,
onSwipeEnd: PropTypes__default["default"].func,
onSwipeProgress: PropTypes__default["default"].func,
onSwipeStart: PropTypes__default["default"].func,
scrollStartThreshold: PropTypes__default["default"].number,
swipeStartThreshold: PropTypes__default["default"].number,
threshold: PropTypes__default["default"].number,
trailingActions: PropTypes__default["default"].node
};

@@ -1031,3 +1040,3 @@

var _React$useContext = React__default['default'].useContext(ItemContext),
var _React$useContext = React__default["default"].useContext(ItemContext),
destructiveCallbackDelay = _React$useContext.destructiveCallbackDelay,

@@ -1043,3 +1052,3 @@ leadingFullSwipe = _React$useContext.leadingFullSwipe,

var onHandleClick = React__default['default'].useCallback(function () {
var onHandleClick = React__default["default"].useCallback(function () {
onActionTriggered(destructive);

@@ -1055,3 +1064,3 @@

}, [destructive, destructiveCallbackDelay, onActionTriggered, onClick]);
React__default['default'].useEffect(function () {
React__default["default"].useEffect(function () {
if (leading && main) {

@@ -1061,3 +1070,3 @@ setLeadingFullSwipeAction(onHandleClick);

}, [leading, main, onHandleClick, setLeadingFullSwipeAction]);
React__default['default'].useEffect(function () {
React__default["default"].useEffect(function () {
if (trailing && main) {

@@ -1067,3 +1076,3 @@ setTrailingFullSwipeAction(onHandleClick);

}, [trailing, main, onHandleClick, setTrailingFullSwipeAction]);
return /*#__PURE__*/React__default['default'].createElement(Tag, {
return /*#__PURE__*/React__default["default"].createElement(Tag, {
className: clsx('swipe-action', {

@@ -1083,10 +1092,10 @@ 'swipe-action__leading': leading,

SwipeAction.propTypes = {
children: PropTypes__default['default'].node.isRequired,
className: PropTypes__default['default'].string,
destructive: PropTypes__default['default'].bool,
main: PropTypes__default['default'].bool,
leading: PropTypes__default['default'].bool,
onClick: PropTypes__default['default'].func.isRequired,
trailing: PropTypes__default['default'].bool,
Tag: PropTypes__default['default'].string
children: PropTypes__default["default"].node.isRequired,
className: PropTypes__default["default"].string,
destructive: PropTypes__default["default"].bool,
main: PropTypes__default["default"].bool,
leading: PropTypes__default["default"].bool,
onClick: PropTypes__default["default"].func.isRequired,
trailing: PropTypes__default["default"].bool,
Tag: PropTypes__default["default"].string
};

@@ -1102,4 +1111,4 @@

if (Array.isArray(children)) {
return React__default['default'].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default['default'].cloneElement(child, {
return React__default["default"].Children.map(children, function (child, index) {
return /*#__PURE__*/React__default["default"].cloneElement(child, {
main: index === children.length - 1,

@@ -1111,3 +1120,3 @@ trailing: true

return /*#__PURE__*/React__default['default'].cloneElement(children, {
return /*#__PURE__*/React__default["default"].cloneElement(children, {
main: true,

@@ -1127,2 +1136,2 @@ trailing: true

})));
}));
{
"name": "react-swipeable-list",
"description": "Swipeable list component for React",
"version": "1.4.0",
"version": "1.5.0",
"author": {

@@ -33,44 +33,41 @@ "name": "Marek Rozmus",

"browser": "dist/react-swipeable-list.umd.js",
"peerDependencies": {
"prop-types": "^15.7.2",
"react": "^16.12.0 || ^17",
"react-dom": "^16.12.0 || ^17"
},
"devDependencies": {
"@babel/core": "7.13.15",
"@babel/eslint-parser": "7.13.14",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-transform-modules-commonjs": "7.13.8",
"@babel/preset-env": "7.13.15",
"@babel/preset-react": "7.13.13",
"@babel/core": "7.16.5",
"@babel/eslint-parser": "7.16.5",
"@babel/plugin-proposal-class-properties": "7.16.5",
"@babel/plugin-transform-modules-commonjs": "7.16.5",
"@babel/plugin-transform-runtime": "^7.16.5",
"@babel/preset-env": "7.16.5",
"@babel/preset-react": "7.16.5",
"@rollup/plugin-babel": "5.3.0",
"@rollup/plugin-commonjs": "18.0.0",
"@rollup/plugin-node-resolve": "11.2.1",
"@testing-library/jest-dom": "5.11.10",
"@testing-library/react": "11.2.6",
"autoprefixer": "9.8.6",
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-node-resolve": "13.1.1",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"autoprefixer": "10.4.0",
"clsx": "1.1.1",
"cz-conventional-changelog": "3.3.0",
"eslint": "7.24.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-prettier": "3.3.1",
"eslint-plugin-react": "7.23.2",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-testing-library": "3.10.2",
"husky": "6.0.0",
"eslint": "8.5.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jest-dom": "3.9.2",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react": "7.28.0",
"eslint-plugin-react-hooks": "4.3.0",
"eslint-plugin-testing-library": "5.0.1",
"husky": "^7.0.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.3",
"lint-staged": "10.5.4",
"postcss": "8.2.9",
"prettier": "2.2.1",
"prop-types": "15.7.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"rollup": "2.45.1",
"jest": "27.4.5",
"lint-staged": "12.1.4",
"postcss": "8.4.5",
"prettier": "2.5.1",
"prop-types": "15.8.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"rollup": "2.62.0",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-local-resolve": "1.0.7",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-postcss": "4.0.0",
"stylelint": "13.12.0",
"stylelint-config-standard": "21.0.0"
"rollup-plugin-postcss": "4.0.2",
"stylelint": "14.2.0",
"stylelint-config-standard": "24.0.0"
},

@@ -84,3 +81,4 @@ "scripts": {

"prettier": "prettier src/**/*.js examples/**/*.js --check",
"test": "jest --no-cache"
"test": "jest --no-cache",
"test:watch": "jest --watch"
},

@@ -87,0 +85,0 @@ "types": "dist/module.d.ts",

@@ -186,2 +186,8 @@ <h1 align="center">react-swipeable-list</h1>

### onClick
Type: `function` (optional)
Callback function that should be call after list item is clicked.
### onSwipeStart

@@ -188,0 +194,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc