react-swipeable-list
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -35,98 +35,2 @@ 'use strict'; | ||
function toVal(mix) { | ||
var k, y, str=''; | ||
if (typeof mix === 'string' || typeof mix === 'number') { | ||
str += mix; | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
for (k=0; k < mix.length; k++) { | ||
if (mix[k]) { | ||
if (y = toVal(mix[k])) { | ||
str && (str += ' '); | ||
str += y; | ||
} | ||
} | ||
} | ||
} else { | ||
for (k in mix) { | ||
if (mix[k]) { | ||
str && (str += ' '); | ||
str += k; | ||
} | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
function clsx () { | ||
var i=0, tmp, x, str=''; | ||
while (i < arguments.length) { | ||
if (tmp = arguments[i++]) { | ||
if (x = toVal(tmp)) { | ||
str && (str += ' '); | ||
str += x; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
var Type = { | ||
ANDROID: Symbol('ANDROID'), | ||
IOS: Symbol('IOS'), | ||
MS: Symbol('MS') | ||
}; | ||
var SwipeableList = function SwipeableList(_ref) { | ||
var _ref$actionDelay = _ref.actionDelay, | ||
actionDelay = _ref$actionDelay === void 0 ? 0 : _ref$actionDelay, | ||
children = _ref.children, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? '' : _ref$className, | ||
_ref$fullSwipe = _ref.fullSwipe, | ||
fullSwipe = _ref$fullSwipe === void 0 ? false : _ref$fullSwipe, | ||
_ref$destructiveCallb = _ref.destructiveCallbackDelay, | ||
destructiveCallbackDelay = _ref$destructiveCallb === void 0 ? 1000 : _ref$destructiveCallb, | ||
style = _ref.style, | ||
_ref$type = _ref.type, | ||
type = _ref$type === void 0 ? Type.ANDROID : _ref$type, | ||
_ref$Tag = _ref.Tag, | ||
Tag = _ref$Tag === void 0 ? 'div' : _ref$Tag, | ||
scrollStartThreshold = _ref.scrollStartThreshold, | ||
swipeStartThreshold = _ref.swipeStartThreshold, | ||
_ref$threshold = _ref.threshold, | ||
threshold = _ref$threshold === void 0 ? 0.5 : _ref$threshold; | ||
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, { | ||
actionDelay: actionDelay, | ||
destructiveCallbackDelay: destructiveCallbackDelay, | ||
fullSwipe: fullSwipe, | ||
listType: type, | ||
scrollStartThreshold: scrollStartThreshold, | ||
swipeStartThreshold: swipeStartThreshold, | ||
threshold: threshold | ||
}); | ||
})); | ||
}; | ||
SwipeableList.propTypes = { | ||
actionDelay: 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 | ||
}; | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -256,2 +160,139 @@ if (!(instance instanceof Constructor)) { | ||
function toVal(mix) { | ||
var k, y, str=''; | ||
if (typeof mix === 'string' || typeof mix === 'number') { | ||
str += mix; | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
for (k=0; k < mix.length; k++) { | ||
if (mix[k]) { | ||
if (y = toVal(mix[k])) { | ||
str && (str += ' '); | ||
str += y; | ||
} | ||
} | ||
} | ||
} else { | ||
for (k in mix) { | ||
if (mix[k]) { | ||
str && (str += ' '); | ||
str += k; | ||
} | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
function clsx () { | ||
var i=0, tmp, x, str=''; | ||
while (i < arguments.length) { | ||
if (tmp = arguments[i++]) { | ||
if (x = toVal(tmp)) { | ||
str && (str += ' '); | ||
str += x; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
var Type = { | ||
ANDROID: Symbol('ANDROID'), | ||
IOS: Symbol('IOS'), | ||
MS: Symbol('MS') | ||
}; | ||
var SwipeableList = /*#__PURE__*/function (_PureComponent) { | ||
_inherits(SwipeableList, _PureComponent); | ||
var _super = _createSuper(SwipeableList); | ||
function SwipeableList(props) { | ||
var _this; | ||
_classCallCheck(this, SwipeableList); | ||
_this = _super.call(this, props); | ||
_this.itemsMap = {}; | ||
_this.clickedItem = _this.clickedItem.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
} | ||
_createClass(SwipeableList, [{ | ||
key: "clickedItem", | ||
value: function clickedItem(itemId) { | ||
var _this2 = this; | ||
Object.keys(this.itemsMap).forEach(function (listItem) { | ||
if (listItem !== itemId) { | ||
_this2.itemsMap[listItem](); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _this$props = this.props, | ||
_this$props$actionDel = _this$props.actionDelay, | ||
actionDelay = _this$props$actionDel === void 0 ? 0 : _this$props$actionDel, | ||
children = _this$props.children, | ||
_this$props$className = _this$props.className, | ||
className = _this$props$className === void 0 ? '' : _this$props$className, | ||
_this$props$fullSwipe = _this$props.fullSwipe, | ||
fullSwipe = _this$props$fullSwipe === void 0 ? false : _this$props$fullSwipe, | ||
_this$props$destructi = _this$props.destructiveCallbackDelay, | ||
destructiveCallbackDelay = _this$props$destructi === void 0 ? 1000 : _this$props$destructi, | ||
style = _this$props.style, | ||
_this$props$type = _this$props.type, | ||
type = _this$props$type === void 0 ? Type.ANDROID : _this$props$type, | ||
_this$props$Tag = _this$props.Tag, | ||
Tag = _this$props$Tag === void 0 ? 'div' : _this$props$Tag, | ||
scrollStartThreshold = _this$props.scrollStartThreshold, | ||
swipeStartThreshold = _this$props.swipeStartThreshold, | ||
_this$props$threshold = _this$props.threshold, | ||
threshold = _this$props$threshold === void 0 ? 0.5 : _this$props$threshold; | ||
return /*#__PURE__*/React__default["default"].createElement(Tag, { | ||
className: clsx('swipeable-list', className), | ||
style: style | ||
}, React__default["default"].Children.map(children, function (child, index) { | ||
return /*#__PURE__*/React__default["default"].cloneElement(child, { | ||
actionDelay: actionDelay, | ||
destructiveCallbackDelay: destructiveCallbackDelay, | ||
fullSwipe: fullSwipe, | ||
listType: type, | ||
scrollStartThreshold: scrollStartThreshold, | ||
swipeStartThreshold: swipeStartThreshold, | ||
threshold: threshold, | ||
clickedCallback: _this3.clickedItem, | ||
id: "listItem-".concat(index), | ||
resetState: function resetState(func) { | ||
_this3.itemsMap["listItem-".concat(index)] = func; | ||
} | ||
}); | ||
})); | ||
} | ||
}]); | ||
return SwipeableList; | ||
}(React.PureComponent); | ||
SwipeableList.propTypes = { | ||
actionDelay: 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 | ||
}; | ||
var ItemContext = /*#__PURE__*/React__default["default"].createContext(); | ||
@@ -345,2 +386,6 @@ var ActionAnimation = { | ||
if (_this.props.clickedCallback) { | ||
_this.props.clickedCallback(_this.props.id); | ||
} | ||
if (!_this.leadingActionsOpened && !_this.trailingActionsOpened) { | ||
@@ -496,2 +541,6 @@ _this.resetState(); | ||
if (_this.left === 0) { | ||
return; | ||
} | ||
var _assertThisInitialize = _assertThisInitialized(_this), | ||
@@ -905,2 +954,3 @@ listElement = _assertThisInitialize.listElement; | ||
_this.trailingFullSwipeAction = null; | ||
_this.id = props.id; | ||
@@ -959,2 +1009,6 @@ _this.resetState(); | ||
} | ||
if (this.props.resetState) { | ||
this.props.resetState(this.playReturnAnimation); | ||
} | ||
} | ||
@@ -1027,3 +1081,6 @@ }, { | ||
threshold: PropTypes__default["default"].number, | ||
trailingActions: PropTypes__default["default"].node | ||
trailingActions: PropTypes__default["default"].node, | ||
clickedCallback: PropTypes__default["default"].func, | ||
id: PropTypes__default["default"].string, | ||
resetState: PropTypes__default["default"].func | ||
}; | ||
@@ -1030,0 +1087,0 @@ |
@@ -26,98 +26,2 @@ import React, { PureComponent } from 'react'; | ||
function toVal(mix) { | ||
var k, y, str=''; | ||
if (typeof mix === 'string' || typeof mix === 'number') { | ||
str += mix; | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
for (k=0; k < mix.length; k++) { | ||
if (mix[k]) { | ||
if (y = toVal(mix[k])) { | ||
str && (str += ' '); | ||
str += y; | ||
} | ||
} | ||
} | ||
} else { | ||
for (k in mix) { | ||
if (mix[k]) { | ||
str && (str += ' '); | ||
str += k; | ||
} | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
function clsx () { | ||
var i=0, tmp, x, str=''; | ||
while (i < arguments.length) { | ||
if (tmp = arguments[i++]) { | ||
if (x = toVal(tmp)) { | ||
str && (str += ' '); | ||
str += x; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
var Type = { | ||
ANDROID: Symbol('ANDROID'), | ||
IOS: Symbol('IOS'), | ||
MS: Symbol('MS') | ||
}; | ||
var SwipeableList = function SwipeableList(_ref) { | ||
var _ref$actionDelay = _ref.actionDelay, | ||
actionDelay = _ref$actionDelay === void 0 ? 0 : _ref$actionDelay, | ||
children = _ref.children, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? '' : _ref$className, | ||
_ref$fullSwipe = _ref.fullSwipe, | ||
fullSwipe = _ref$fullSwipe === void 0 ? false : _ref$fullSwipe, | ||
_ref$destructiveCallb = _ref.destructiveCallbackDelay, | ||
destructiveCallbackDelay = _ref$destructiveCallb === void 0 ? 1000 : _ref$destructiveCallb, | ||
style = _ref.style, | ||
_ref$type = _ref.type, | ||
type = _ref$type === void 0 ? Type.ANDROID : _ref$type, | ||
_ref$Tag = _ref.Tag, | ||
Tag = _ref$Tag === void 0 ? 'div' : _ref$Tag, | ||
scrollStartThreshold = _ref.scrollStartThreshold, | ||
swipeStartThreshold = _ref.swipeStartThreshold, | ||
_ref$threshold = _ref.threshold, | ||
threshold = _ref$threshold === void 0 ? 0.5 : _ref$threshold; | ||
return /*#__PURE__*/React.createElement(Tag, { | ||
className: clsx('swipeable-list', className), | ||
style: style | ||
}, React.Children.map(children, function (child) { | ||
return /*#__PURE__*/React.cloneElement(child, { | ||
actionDelay: actionDelay, | ||
destructiveCallbackDelay: destructiveCallbackDelay, | ||
fullSwipe: fullSwipe, | ||
listType: type, | ||
scrollStartThreshold: scrollStartThreshold, | ||
swipeStartThreshold: swipeStartThreshold, | ||
threshold: threshold | ||
}); | ||
})); | ||
}; | ||
SwipeableList.propTypes = { | ||
actionDelay: PropTypes.number, | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
fullSwipe: PropTypes.bool, | ||
destructiveCallbackDelay: PropTypes.number, | ||
style: PropTypes.object, | ||
type: PropTypes.oneOf(Object.values(Type)), | ||
Tag: PropTypes.string, | ||
scrollStartThreshold: PropTypes.number, | ||
swipeStartThreshold: PropTypes.number, | ||
threshold: PropTypes.number | ||
}; | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -247,2 +151,139 @@ if (!(instance instanceof Constructor)) { | ||
function toVal(mix) { | ||
var k, y, str=''; | ||
if (typeof mix === 'string' || typeof mix === 'number') { | ||
str += mix; | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
for (k=0; k < mix.length; k++) { | ||
if (mix[k]) { | ||
if (y = toVal(mix[k])) { | ||
str && (str += ' '); | ||
str += y; | ||
} | ||
} | ||
} | ||
} else { | ||
for (k in mix) { | ||
if (mix[k]) { | ||
str && (str += ' '); | ||
str += k; | ||
} | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
function clsx () { | ||
var i=0, tmp, x, str=''; | ||
while (i < arguments.length) { | ||
if (tmp = arguments[i++]) { | ||
if (x = toVal(tmp)) { | ||
str && (str += ' '); | ||
str += x; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
var Type = { | ||
ANDROID: Symbol('ANDROID'), | ||
IOS: Symbol('IOS'), | ||
MS: Symbol('MS') | ||
}; | ||
var SwipeableList = /*#__PURE__*/function (_PureComponent) { | ||
_inherits(SwipeableList, _PureComponent); | ||
var _super = _createSuper(SwipeableList); | ||
function SwipeableList(props) { | ||
var _this; | ||
_classCallCheck(this, SwipeableList); | ||
_this = _super.call(this, props); | ||
_this.itemsMap = {}; | ||
_this.clickedItem = _this.clickedItem.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
} | ||
_createClass(SwipeableList, [{ | ||
key: "clickedItem", | ||
value: function clickedItem(itemId) { | ||
var _this2 = this; | ||
Object.keys(this.itemsMap).forEach(function (listItem) { | ||
if (listItem !== itemId) { | ||
_this2.itemsMap[listItem](); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _this$props = this.props, | ||
_this$props$actionDel = _this$props.actionDelay, | ||
actionDelay = _this$props$actionDel === void 0 ? 0 : _this$props$actionDel, | ||
children = _this$props.children, | ||
_this$props$className = _this$props.className, | ||
className = _this$props$className === void 0 ? '' : _this$props$className, | ||
_this$props$fullSwipe = _this$props.fullSwipe, | ||
fullSwipe = _this$props$fullSwipe === void 0 ? false : _this$props$fullSwipe, | ||
_this$props$destructi = _this$props.destructiveCallbackDelay, | ||
destructiveCallbackDelay = _this$props$destructi === void 0 ? 1000 : _this$props$destructi, | ||
style = _this$props.style, | ||
_this$props$type = _this$props.type, | ||
type = _this$props$type === void 0 ? Type.ANDROID : _this$props$type, | ||
_this$props$Tag = _this$props.Tag, | ||
Tag = _this$props$Tag === void 0 ? 'div' : _this$props$Tag, | ||
scrollStartThreshold = _this$props.scrollStartThreshold, | ||
swipeStartThreshold = _this$props.swipeStartThreshold, | ||
_this$props$threshold = _this$props.threshold, | ||
threshold = _this$props$threshold === void 0 ? 0.5 : _this$props$threshold; | ||
return /*#__PURE__*/React.createElement(Tag, { | ||
className: clsx('swipeable-list', className), | ||
style: style | ||
}, React.Children.map(children, function (child, index) { | ||
return /*#__PURE__*/React.cloneElement(child, { | ||
actionDelay: actionDelay, | ||
destructiveCallbackDelay: destructiveCallbackDelay, | ||
fullSwipe: fullSwipe, | ||
listType: type, | ||
scrollStartThreshold: scrollStartThreshold, | ||
swipeStartThreshold: swipeStartThreshold, | ||
threshold: threshold, | ||
clickedCallback: _this3.clickedItem, | ||
id: "listItem-".concat(index), | ||
resetState: function resetState(func) { | ||
_this3.itemsMap["listItem-".concat(index)] = func; | ||
} | ||
}); | ||
})); | ||
} | ||
}]); | ||
return SwipeableList; | ||
}(PureComponent); | ||
SwipeableList.propTypes = { | ||
actionDelay: PropTypes.number, | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
fullSwipe: PropTypes.bool, | ||
destructiveCallbackDelay: PropTypes.number, | ||
style: PropTypes.object, | ||
type: PropTypes.oneOf(Object.values(Type)), | ||
Tag: PropTypes.string, | ||
scrollStartThreshold: PropTypes.number, | ||
swipeStartThreshold: PropTypes.number, | ||
threshold: PropTypes.number | ||
}; | ||
var ItemContext = /*#__PURE__*/React.createContext(); | ||
@@ -336,2 +377,6 @@ var ActionAnimation = { | ||
if (_this.props.clickedCallback) { | ||
_this.props.clickedCallback(_this.props.id); | ||
} | ||
if (!_this.leadingActionsOpened && !_this.trailingActionsOpened) { | ||
@@ -487,2 +532,6 @@ _this.resetState(); | ||
if (_this.left === 0) { | ||
return; | ||
} | ||
var _assertThisInitialize = _assertThisInitialized(_this), | ||
@@ -896,2 +945,3 @@ listElement = _assertThisInitialize.listElement; | ||
_this.trailingFullSwipeAction = null; | ||
_this.id = props.id; | ||
@@ -950,2 +1000,6 @@ _this.resetState(); | ||
} | ||
if (this.props.resetState) { | ||
this.props.resetState(this.playReturnAnimation); | ||
} | ||
} | ||
@@ -1018,3 +1072,6 @@ }, { | ||
threshold: PropTypes.number, | ||
trailingActions: PropTypes.node | ||
trailingActions: PropTypes.node, | ||
clickedCallback: PropTypes.func, | ||
id: PropTypes.string, | ||
resetState: PropTypes.func | ||
}; | ||
@@ -1021,0 +1078,0 @@ |
@@ -34,98 +34,2 @@ (function (global, factory) { | ||
function toVal(mix) { | ||
var k, y, str=''; | ||
if (typeof mix === 'string' || typeof mix === 'number') { | ||
str += mix; | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
for (k=0; k < mix.length; k++) { | ||
if (mix[k]) { | ||
if (y = toVal(mix[k])) { | ||
str && (str += ' '); | ||
str += y; | ||
} | ||
} | ||
} | ||
} else { | ||
for (k in mix) { | ||
if (mix[k]) { | ||
str && (str += ' '); | ||
str += k; | ||
} | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
function clsx () { | ||
var i=0, tmp, x, str=''; | ||
while (i < arguments.length) { | ||
if (tmp = arguments[i++]) { | ||
if (x = toVal(tmp)) { | ||
str && (str += ' '); | ||
str += x; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
var Type = { | ||
ANDROID: Symbol('ANDROID'), | ||
IOS: Symbol('IOS'), | ||
MS: Symbol('MS') | ||
}; | ||
var SwipeableList = function SwipeableList(_ref) { | ||
var _ref$actionDelay = _ref.actionDelay, | ||
actionDelay = _ref$actionDelay === void 0 ? 0 : _ref$actionDelay, | ||
children = _ref.children, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? '' : _ref$className, | ||
_ref$fullSwipe = _ref.fullSwipe, | ||
fullSwipe = _ref$fullSwipe === void 0 ? false : _ref$fullSwipe, | ||
_ref$destructiveCallb = _ref.destructiveCallbackDelay, | ||
destructiveCallbackDelay = _ref$destructiveCallb === void 0 ? 1000 : _ref$destructiveCallb, | ||
style = _ref.style, | ||
_ref$type = _ref.type, | ||
type = _ref$type === void 0 ? Type.ANDROID : _ref$type, | ||
_ref$Tag = _ref.Tag, | ||
Tag = _ref$Tag === void 0 ? 'div' : _ref$Tag, | ||
scrollStartThreshold = _ref.scrollStartThreshold, | ||
swipeStartThreshold = _ref.swipeStartThreshold, | ||
_ref$threshold = _ref.threshold, | ||
threshold = _ref$threshold === void 0 ? 0.5 : _ref$threshold; | ||
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, { | ||
actionDelay: actionDelay, | ||
destructiveCallbackDelay: destructiveCallbackDelay, | ||
fullSwipe: fullSwipe, | ||
listType: type, | ||
scrollStartThreshold: scrollStartThreshold, | ||
swipeStartThreshold: swipeStartThreshold, | ||
threshold: threshold | ||
}); | ||
})); | ||
}; | ||
SwipeableList.propTypes = { | ||
actionDelay: 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 | ||
}; | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -255,2 +159,139 @@ if (!(instance instanceof Constructor)) { | ||
function toVal(mix) { | ||
var k, y, str=''; | ||
if (typeof mix === 'string' || typeof mix === 'number') { | ||
str += mix; | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
for (k=0; k < mix.length; k++) { | ||
if (mix[k]) { | ||
if (y = toVal(mix[k])) { | ||
str && (str += ' '); | ||
str += y; | ||
} | ||
} | ||
} | ||
} else { | ||
for (k in mix) { | ||
if (mix[k]) { | ||
str && (str += ' '); | ||
str += k; | ||
} | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
function clsx () { | ||
var i=0, tmp, x, str=''; | ||
while (i < arguments.length) { | ||
if (tmp = arguments[i++]) { | ||
if (x = toVal(tmp)) { | ||
str && (str += ' '); | ||
str += x; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
var Type = { | ||
ANDROID: Symbol('ANDROID'), | ||
IOS: Symbol('IOS'), | ||
MS: Symbol('MS') | ||
}; | ||
var SwipeableList = /*#__PURE__*/function (_PureComponent) { | ||
_inherits(SwipeableList, _PureComponent); | ||
var _super = _createSuper(SwipeableList); | ||
function SwipeableList(props) { | ||
var _this; | ||
_classCallCheck(this, SwipeableList); | ||
_this = _super.call(this, props); | ||
_this.itemsMap = {}; | ||
_this.clickedItem = _this.clickedItem.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
} | ||
_createClass(SwipeableList, [{ | ||
key: "clickedItem", | ||
value: function clickedItem(itemId) { | ||
var _this2 = this; | ||
Object.keys(this.itemsMap).forEach(function (listItem) { | ||
if (listItem !== itemId) { | ||
_this2.itemsMap[listItem](); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _this$props = this.props, | ||
_this$props$actionDel = _this$props.actionDelay, | ||
actionDelay = _this$props$actionDel === void 0 ? 0 : _this$props$actionDel, | ||
children = _this$props.children, | ||
_this$props$className = _this$props.className, | ||
className = _this$props$className === void 0 ? '' : _this$props$className, | ||
_this$props$fullSwipe = _this$props.fullSwipe, | ||
fullSwipe = _this$props$fullSwipe === void 0 ? false : _this$props$fullSwipe, | ||
_this$props$destructi = _this$props.destructiveCallbackDelay, | ||
destructiveCallbackDelay = _this$props$destructi === void 0 ? 1000 : _this$props$destructi, | ||
style = _this$props.style, | ||
_this$props$type = _this$props.type, | ||
type = _this$props$type === void 0 ? Type.ANDROID : _this$props$type, | ||
_this$props$Tag = _this$props.Tag, | ||
Tag = _this$props$Tag === void 0 ? 'div' : _this$props$Tag, | ||
scrollStartThreshold = _this$props.scrollStartThreshold, | ||
swipeStartThreshold = _this$props.swipeStartThreshold, | ||
_this$props$threshold = _this$props.threshold, | ||
threshold = _this$props$threshold === void 0 ? 0.5 : _this$props$threshold; | ||
return /*#__PURE__*/React__default["default"].createElement(Tag, { | ||
className: clsx('swipeable-list', className), | ||
style: style | ||
}, React__default["default"].Children.map(children, function (child, index) { | ||
return /*#__PURE__*/React__default["default"].cloneElement(child, { | ||
actionDelay: actionDelay, | ||
destructiveCallbackDelay: destructiveCallbackDelay, | ||
fullSwipe: fullSwipe, | ||
listType: type, | ||
scrollStartThreshold: scrollStartThreshold, | ||
swipeStartThreshold: swipeStartThreshold, | ||
threshold: threshold, | ||
clickedCallback: _this3.clickedItem, | ||
id: "listItem-".concat(index), | ||
resetState: function resetState(func) { | ||
_this3.itemsMap["listItem-".concat(index)] = func; | ||
} | ||
}); | ||
})); | ||
} | ||
}]); | ||
return SwipeableList; | ||
}(React.PureComponent); | ||
SwipeableList.propTypes = { | ||
actionDelay: 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 | ||
}; | ||
var ItemContext = /*#__PURE__*/React__default["default"].createContext(); | ||
@@ -344,2 +385,6 @@ var ActionAnimation = { | ||
if (_this.props.clickedCallback) { | ||
_this.props.clickedCallback(_this.props.id); | ||
} | ||
if (!_this.leadingActionsOpened && !_this.trailingActionsOpened) { | ||
@@ -495,2 +540,6 @@ _this.resetState(); | ||
if (_this.left === 0) { | ||
return; | ||
} | ||
var _assertThisInitialize = _assertThisInitialized(_this), | ||
@@ -904,2 +953,3 @@ listElement = _assertThisInitialize.listElement; | ||
_this.trailingFullSwipeAction = null; | ||
_this.id = props.id; | ||
@@ -958,2 +1008,6 @@ _this.resetState(); | ||
} | ||
if (this.props.resetState) { | ||
this.props.resetState(this.playReturnAnimation); | ||
} | ||
} | ||
@@ -1026,3 +1080,6 @@ }, { | ||
threshold: PropTypes__default["default"].number, | ||
trailingActions: PropTypes__default["default"].node | ||
trailingActions: PropTypes__default["default"].node, | ||
clickedCallback: PropTypes__default["default"].func, | ||
id: PropTypes__default["default"].string, | ||
resetState: PropTypes__default["default"].func | ||
}; | ||
@@ -1029,0 +1086,0 @@ |
{ | ||
"name": "react-swipeable-list", | ||
"description": "Swipeable list component for React", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Marek Rozmus", |
146864
3318