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

@jswork/react-draggable-list

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jswork/react-draggable-list - npm Package Compare versions

Comparing version 1.1.16 to 1.1.17

19

dist/index.cjs.js

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

"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var F=Object.create;var I=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,Y=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var g=(o,t,e)=>t in o?I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,K=(o,t)=>{for(var e in t||(t={}))x.call(t,e)&&g(o,e,t[e]);if(O)for(var e of O(t))_.call(t,e)&&g(o,e,t[e]);return o};var r=(o,t)=>I(o,"name",{value:t,configurable:!0});var P=(o,t)=>{var e={};for(var s in o)x.call(o,s)&&t.indexOf(s)<0&&(e[s]=o[s]);if(o!=null&&O)for(var s of O(o))t.indexOf(s)<0&&_.call(o,s)&&(e[s]=o[s]);return e};var E=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var $=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!x.call(o,n)&&n!==e&&I(o,n,{get:()=>t[n],enumerable:!(s=G(t,n))||s.enumerable});return o};var R=(o,t,e)=>(e=o!=null?F(Y(o)):{},$(t||!o||!o.__esModule?I(e,"default",{value:o,enumerable:!0}):e,o));var l=(o,t,e)=>(g(o,typeof t!="symbol"?t+"":t,e),e);var T=E((f,j)=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});var b=r(function(){},"NOOP"),q="",z=[],D={};j.exports=b;f.default=b;f.NOOP_STRING=q;f.NOOP_ARRAY=z;f.NOOP_OBJECT=D});var U=E((ee,C)=>{(function(){"use strict";var o={}.hasOwnProperty;function t(){for(var e=[],s=0;s<arguments.length;s++){var n=arguments[s];if(n){var a=typeof n;if(a==="string"||a==="number")e.push(n);else if(Array.isArray(n)){if(n.length){var c=t.apply(null,n);c&&e.push(c)}}else if(a==="object")if(n.toString===Object.prototype.toString)for(var m in n)o.call(n,m)&&n[m]&&e.push(m);else e.push(n.toString())}}return e.join(" ")}r(t,"classNames"),typeof C!="undefined"&&C.exports?(t.default=t,C.exports=t):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return t}):window.classNames=t})()});var y=R(T()),B=R(U());var _reactlist = require('@jswork/react-list'); var _reactlist2 = _interopRequireDefault(_reactlist);var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _reactsortablejs = require('react-sortablejs');var _fastdeepequal = require('fast-deep-equal'); var _fastdeepequal2 = _interopRequireDefault(_fastdeepequal);var v="react-draggable-list",W={animation:300,draggable:`.${v}__item`,ghostClass:"react-draggable-list__ghost",chosenClass:"react-draggable-list__chosen",dragClass:"react-draggable-list__drag"},X=r(()=>Math.random().toString(36).substr(2),"randomKey"),i=class i extends _react.Component{constructor(e){super(e);l(this,"cacheKey");l(this,"template",r(({item:e,index:s})=>{let{template:n,rowKey:a}=this.props;return _react2.default.createElement("div",{key:e[a],className:`${v}__item`},n({item:e,index:s}))},"template"));l(this,"handleAdd",r(e=>{let{newIndex:s,oldIndex:n,from:a}=e,c=a.id,m=i.cachedItems[c],h=i.cachedItems[this.cacheKey],{name:d,onChooseDrop:w,rowKey:N}=this.props,p=m[n];h.splice(s,0,p),this.execChange(h),w({target:{value:p[N],name:d}})},"handleAdd"));l(this,"handleRemove",r(e=>{let{oldIndex:s,from:n}=e,a=n.id,c=i.cachedItems[a];c.splice(s,1),this.execChange(c)},"handleRemove"));l(this,"handleUpdate",r(e=>{let{oldIndex:s,newIndex:n}=e,{name:a,onChooseDrop:c,rowKey:m}=this.props,{stateItems:h}=this.state,d=h[s];n<s?(h.splice(s,1),h.splice(n,0,d)):(h.splice(n+1,0,d),h.splice(s,1)),this.execChange(h),c({target:{value:d[m],name:a}})},"handleUpdate"));l(this,"execChange",r(e=>{let{onChange:s,rowKey:n}=this.props,a=e.map(c=>c[n]);this.setState({stateItems:e.slice(0)}),s({target:{value:a}})},"execChange"));let{items:s}=e;this.cacheKey=X(),i.cachedItems[this.cacheKey]=s,this.state={stateItems:s}}shouldComponentUpdate(e){let{items:s}=e,{stateItems:n}=this.state;return _fastdeepequal2.default.call(void 0, s,n)||(i.cachedItems[this.cacheKey]=s,this.execChange(s)),!0}render(){let A=this.props,{name:e,className:s,children:n,template:a,rowKey:c,options:m,onChooseDrop:h,emptySlot:d,onChange:w}=A,N=P(A,["name","className","children","template","rowKey","options","onChooseDrop","emptySlot","onChange"]),{stateItems:p}=this.state,M=p.length===0&&d;return _react2.default.createElement(_reactsortablejs.ReactSortable,K(K({id:this.cacheKey,className:(0,B.default)(v,s),list:p,setList:y.default,onUpdate:this.handleUpdate,onAdd:this.handleAdd,onRemove:this.handleRemove},m),N),_react2.default.createElement(_react2.default.Fragment,null,M&&d,p.length>0&&_react2.default.createElement(_reactlist2.default,{items:p,template:this.template})))}};r(i,"ReactDraggableList"),l(i,"displayName",v),l(i,"defaultProps",{onChange:y.default,onChooseDrop:y.default,items:[],template:y.default,rowKey:"id",options:W}),l(i,"cachedItems",{});var S=i;exports.default = S;
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var ne=Object.create;var b=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,ae=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var P=(s,e,t)=>e in s?b(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,A=(s,e)=>{for(var t in e||(e={}))_.call(e,t)&&P(s,t,e[t]);if(I)for(var t of I(e))M.call(e,t)&&P(s,t,e[t]);return s};var a=(s,e)=>b(s,"name",{value:e,configurable:!0});var G=(s,e)=>{var t={};for(var n in s)_.call(s,n)&&e.indexOf(n)<0&&(t[n]=s[n]);if(s!=null&&I)for(var n of I(s))e.indexOf(n)<0&&M.call(s,n)&&(t[n]=s[n]);return t};var j=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var ie=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of re(e))!_.call(s,o)&&o!==t&&b(s,o,{get:()=>e[o],enumerable:!(n=oe(e,o))||n.enumerable});return s};var x=(s,e,t)=>(t=s!=null?ne(ae(s)):{},ie(e||!s||!s.__esModule?b(t,"default",{value:s,enumerable:!0}):t,s));var m=(s,e,t)=>(P(s,typeof e!="symbol"?e+"":e,t),t);var R=j((h,Y)=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});var L=a(function(){},"NOOP"),ce="",pe=[],le={};Y.exports=L;h.default=L;h.NOOP_STRING=ce;h.NOOP_ARRAY=pe;h.NOOP_OBJECT=le});var $=j((Se,g)=>{(function(){"use strict";var s={}.hasOwnProperty;function e(){for(var o="",r=0;r<arguments.length;r++){var i=arguments[r];i&&(o=n(o,t(i)))}return o}a(e,"classNames");function t(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return e.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var r="";for(var i in o)s.call(o,i)&&o[i]&&(r=n(r,i));return r}a(t,"parseValue");function n(o,r){return r?o?o+" "+r:o+r:o}a(n,"appendClass"),typeof g!="undefined"&&g.exports?(e.default=e,g.exports=e):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return e}):window.classNames=e})()});var ee=j((Ue,S)=>{(function(){"use strict";var s={}.hasOwnProperty;function e(){for(var t=[],n=0;n<arguments.length;n++){var o=arguments[n];if(o){var r=typeof o;if(r==="string"||r==="number")t.push(o);else if(Array.isArray(o)){if(o.length){var i=e.apply(null,o);i&&t.push(i)}}else if(r==="object")if(o.toString===Object.prototype.toString)for(var l in o)s.call(o,l)&&o[l]&&t.push(l);else t.push(o.toString())}}return t.join(" ")}a(e,"classNames"),typeof S!="undefined"&&S.exports?(e.default=e,S.exports=e):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return e}):window.classNames=e})()});var O=x(R());var V=x(R()),Z=x($());var _react = require('react'); var _react2 = _interopRequireDefault(_react);var me="object",fe="function";function U(s,e){s&&(typeof s===me&&(s.current=e),typeof s===fe&&s(e))}a(U,"default");var H=Object.defineProperty,de=Object.defineProperties,he=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,T=a((s,e,t)=>e in s?H(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,"n"),X=a((s,e)=>{for(var t in e||(e={}))Q.call(e,t)&&T(s,t,e[t]);if(w)for(var t of w(e))W.call(e,t)&&T(s,t,e[t]);return s},"m"),ue=a((s,e)=>de(s,he(e)),"g"),D=a((s,e)=>H(s,"name",{value:e,configurable:!0}),"l"),ye=a((s,e)=>{var t={};for(var n in s)Q.call(s,n)&&e.indexOf(n)<0&&(t[n]=s[n]);if(s!=null&&w)for(var n of w(s))e.indexOf(n)<0&&W.call(s,n)&&(t[n]=s[n]);return t},"w"),C=a((s,e,t)=>(T(s,typeof e!="symbol"?e+"":e,t),t),"o"),z="react-list",u,y,Oe=(u=(y=class extends _react.Component{constructor(){super(...arguments),C(this,"handleRef",D(e=>{let{forwardedRef:t}=this.props;U(t,e)},"handleRef"))}get children(){let{items:e,template:t,options:n}=this.props;return e.map((o,r)=>t({items:e,item:o,index:r,options:n}))}get emptyView(){let{items:e,templateEmpty:t,options:n}=this.props;return t({items:e,item:null,index:-1,options:n})}get properties(){let e=this.props,{className:t,as:n,items:o,template:r,templateEmpty:i,sizeKey:l,forwardedRef:c,options:f}=e,N=ye(e,["className","as","items","template","templateEmpty","sizeKey","forwardedRef","options"]);return n===_react.Fragment?null:X({"data-component":z,ref:this.handleRef,className:(0,Z.default)(z,t)},N)}render(){let{as:e,items:t,sizeKey:n}=this.props;return!t||!t[n]?this.emptyView:_react2.default.createElement(e,this.properties,this.children)}},a(y,"i"),y),D(u,"ReactList"),C(u,"displayName",z),C(u,"version","__VERSION__"),C(u,"defaultProps",{items:[],sizeKey:"length",as:_react.Fragment,template:V.default,templateEmpty:V.default}),u),k=_react2.default.forwardRef((s,e)=>_react2.default.createElement(Oe,ue(X({},s),{ref:e})));var te=x(ee());var _reactsortablejs = require('react-sortablejs');var _fastdeepequal = require('fast-deep-equal'); var _fastdeepequal2 = _interopRequireDefault(_fastdeepequal);var K="react-draggable-list",xe={animation:300,draggable:`.${K}__item`,ghostClass:"react-draggable-list__ghost",chosenClass:"react-draggable-list__chosen",dragClass:"react-draggable-list__drag"},ge=a(()=>Math.random().toString(36).substr(2),"randomKey"),p=class p extends _react.Component{constructor(t){super(t);m(this,"cacheKey");m(this,"template",a(({item:t,index:n})=>{let{template:o,rowKey:r}=this.props;return _react2.default.createElement("div",{key:t[r],className:`${K}__item`},o({item:t,index:n}))},"template"));m(this,"handleAdd",a(t=>{let{newIndex:n,oldIndex:o,from:r}=t,i=r.id,l=p.cachedItems[i],c=p.cachedItems[this.cacheKey],{name:f,onChooseDrop:N,rowKey:E}=this.props,d=l[o];c.splice(n,0,d),this.execChange(c),N({target:{value:d[E],name:f}})},"handleAdd"));m(this,"handleRemove",a(t=>{let{oldIndex:n,from:o}=t,r=o.id,i=p.cachedItems[r];i.splice(n,1),this.execChange(i)},"handleRemove"));m(this,"handleUpdate",a(t=>{let{oldIndex:n,newIndex:o}=t,{name:r,onChooseDrop:i,rowKey:l}=this.props,{stateItems:c}=this.state,f=c[n];o<n?(c.splice(n,1),c.splice(o,0,f)):(c.splice(o+1,0,f),c.splice(n,1)),this.execChange(c),i({target:{value:f[l],name:r}})},"handleUpdate"));m(this,"execChange",a(t=>{let{onChange:n,rowKey:o}=this.props,r=t.map(i=>i[o]);this.setState({stateItems:t.slice(0)}),n({target:{value:r}})},"execChange"));let{items:n}=t;this.cacheKey=ge(),p.cachedItems[this.cacheKey]=n,this.state={stateItems:n}}shouldComponentUpdate(t){let{items:n}=t,{stateItems:o}=this.state;return _fastdeepequal2.default.call(void 0, n,o)||(p.cachedItems[this.cacheKey]=n,this.execChange(n)),!0}render(){let J=this.props,{name:t,className:n,children:o,template:r,rowKey:i,options:l,onChooseDrop:c,emptySlot:f,onChange:N}=J,E=G(J,["name","className","children","template","rowKey","options","onChooseDrop","emptySlot","onChange"]),{stateItems:d}=this.state,se=d.length===0&&f;return _react2.default.createElement(_reactsortablejs.ReactSortable,A(A({id:this.cacheKey,className:(0,te.default)(K,n),list:d,setList:O.default,onUpdate:this.handleUpdate,onAdd:this.handleAdd,onRemove:this.handleRemove},l),E),_react2.default.createElement(_react2.default.Fragment,null,se&&f,d.length>0&&_react2.default.createElement(k,{items:d,template:this.template})))}};a(p,"ReactDraggableList"),m(p,"displayName",K),m(p,"defaultProps",{onChange:O.default,onChooseDrop:O.default,items:[],template:O.default,rowKey:"id",options:xe}),m(p,"cachedItems",{});var F=p;exports.default = F;
/*! Bundled license information:

@@ -6,2 +6,9 @@

(*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*)
classnames/index.js:
(*!
Copyright (c) 2018 Jed Watson.

@@ -11,2 +18,12 @@ Licensed under the MIT License (MIT), see

*)
@jswork/class-imperative-handle/dist/esm/index.js:
(*!
* name: @jswork/class-imperative-handle
* description: React `useImperativeHandle` for class component.
* homepage:
* version: 1.0.1
* date: 2021-09-04 23:46:33
* license: MIT
*)
*/

@@ -13,0 +30,0 @@

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

var F=Object.create;var I=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,Y=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var g=(o,t,e)=>t in o?I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,K=(o,t)=>{for(var e in t||(t={}))x.call(t,e)&&g(o,e,t[e]);if(O)for(var e of O(t))_.call(t,e)&&g(o,e,t[e]);return o};var r=(o,t)=>I(o,"name",{value:t,configurable:!0});var P=(o,t)=>{var e={};for(var s in o)x.call(o,s)&&t.indexOf(s)<0&&(e[s]=o[s]);if(o!=null&&O)for(var s of O(o))t.indexOf(s)<0&&_.call(o,s)&&(e[s]=o[s]);return e};var E=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var $=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!x.call(o,n)&&n!==e&&I(o,n,{get:()=>t[n],enumerable:!(s=G(t,n))||s.enumerable});return o};var R=(o,t,e)=>(e=o!=null?F(Y(o)):{},$(t||!o||!o.__esModule?I(e,"default",{value:o,enumerable:!0}):e,o));var l=(o,t,e)=>(g(o,typeof t!="symbol"?t+"":t,e),e);var T=E((f,j)=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});var b=r(function(){},"NOOP"),q="",z=[],D={};j.exports=b;f.default=b;f.NOOP_STRING=q;f.NOOP_ARRAY=z;f.NOOP_OBJECT=D});var U=E((ee,C)=>{(function(){"use strict";var o={}.hasOwnProperty;function t(){for(var e=[],s=0;s<arguments.length;s++){var n=arguments[s];if(n){var a=typeof n;if(a==="string"||a==="number")e.push(n);else if(Array.isArray(n)){if(n.length){var c=t.apply(null,n);c&&e.push(c)}}else if(a==="object")if(n.toString===Object.prototype.toString)for(var m in n)o.call(n,m)&&n[m]&&e.push(m);else e.push(n.toString())}}return e.join(" ")}r(t,"classNames"),typeof C!="undefined"&&C.exports?(t.default=t,C.exports=t):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return t}):window.classNames=t})()});var y=R(T()),B=R(U());import H from"@jswork/react-list";import u,{Component as L}from"react";import{ReactSortable as Q}from"react-sortablejs";import V from"fast-deep-equal";var v="react-draggable-list",W={animation:300,draggable:`.${v}__item`,ghostClass:"react-draggable-list__ghost",chosenClass:"react-draggable-list__chosen",dragClass:"react-draggable-list__drag"},X=r(()=>Math.random().toString(36).substr(2),"randomKey"),i=class i extends L{constructor(e){super(e);l(this,"cacheKey");l(this,"template",r(({item:e,index:s})=>{let{template:n,rowKey:a}=this.props;return u.createElement("div",{key:e[a],className:`${v}__item`},n({item:e,index:s}))},"template"));l(this,"handleAdd",r(e=>{let{newIndex:s,oldIndex:n,from:a}=e,c=a.id,m=i.cachedItems[c],h=i.cachedItems[this.cacheKey],{name:d,onChooseDrop:w,rowKey:N}=this.props,p=m[n];h.splice(s,0,p),this.execChange(h),w({target:{value:p[N],name:d}})},"handleAdd"));l(this,"handleRemove",r(e=>{let{oldIndex:s,from:n}=e,a=n.id,c=i.cachedItems[a];c.splice(s,1),this.execChange(c)},"handleRemove"));l(this,"handleUpdate",r(e=>{let{oldIndex:s,newIndex:n}=e,{name:a,onChooseDrop:c,rowKey:m}=this.props,{stateItems:h}=this.state,d=h[s];n<s?(h.splice(s,1),h.splice(n,0,d)):(h.splice(n+1,0,d),h.splice(s,1)),this.execChange(h),c({target:{value:d[m],name:a}})},"handleUpdate"));l(this,"execChange",r(e=>{let{onChange:s,rowKey:n}=this.props,a=e.map(c=>c[n]);this.setState({stateItems:e.slice(0)}),s({target:{value:a}})},"execChange"));let{items:s}=e;this.cacheKey=X(),i.cachedItems[this.cacheKey]=s,this.state={stateItems:s}}shouldComponentUpdate(e){let{items:s}=e,{stateItems:n}=this.state;return V(s,n)||(i.cachedItems[this.cacheKey]=s,this.execChange(s)),!0}render(){let A=this.props,{name:e,className:s,children:n,template:a,rowKey:c,options:m,onChooseDrop:h,emptySlot:d,onChange:w}=A,N=P(A,["name","className","children","template","rowKey","options","onChooseDrop","emptySlot","onChange"]),{stateItems:p}=this.state,M=p.length===0&&d;return u.createElement(Q,K(K({id:this.cacheKey,className:(0,B.default)(v,s),list:p,setList:y.default,onUpdate:this.handleUpdate,onAdd:this.handleAdd,onRemove:this.handleRemove},m),N),u.createElement(u.Fragment,null,M&&d,p.length>0&&u.createElement(H,{items:p,template:this.template})))}};r(i,"ReactDraggableList"),l(i,"displayName",v),l(i,"defaultProps",{onChange:y.default,onChooseDrop:y.default,items:[],template:y.default,rowKey:"id",options:W}),l(i,"cachedItems",{});var S=i;export{S as default};
var ne=Object.create;var b=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,ae=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var P=(s,e,t)=>e in s?b(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,A=(s,e)=>{for(var t in e||(e={}))_.call(e,t)&&P(s,t,e[t]);if(I)for(var t of I(e))M.call(e,t)&&P(s,t,e[t]);return s};var a=(s,e)=>b(s,"name",{value:e,configurable:!0});var G=(s,e)=>{var t={};for(var n in s)_.call(s,n)&&e.indexOf(n)<0&&(t[n]=s[n]);if(s!=null&&I)for(var n of I(s))e.indexOf(n)<0&&M.call(s,n)&&(t[n]=s[n]);return t};var j=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var ie=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of re(e))!_.call(s,o)&&o!==t&&b(s,o,{get:()=>e[o],enumerable:!(n=oe(e,o))||n.enumerable});return s};var x=(s,e,t)=>(t=s!=null?ne(ae(s)):{},ie(e||!s||!s.__esModule?b(t,"default",{value:s,enumerable:!0}):t,s));var m=(s,e,t)=>(P(s,typeof e!="symbol"?e+"":e,t),t);var R=j((h,Y)=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});var L=a(function(){},"NOOP"),ce="",pe=[],le={};Y.exports=L;h.default=L;h.NOOP_STRING=ce;h.NOOP_ARRAY=pe;h.NOOP_OBJECT=le});var $=j((Se,g)=>{(function(){"use strict";var s={}.hasOwnProperty;function e(){for(var o="",r=0;r<arguments.length;r++){var i=arguments[r];i&&(o=n(o,t(i)))}return o}a(e,"classNames");function t(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return e.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var r="";for(var i in o)s.call(o,i)&&o[i]&&(r=n(r,i));return r}a(t,"parseValue");function n(o,r){return r?o?o+" "+r:o+r:o}a(n,"appendClass"),typeof g!="undefined"&&g.exports?(e.default=e,g.exports=e):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return e}):window.classNames=e})()});var ee=j((Ue,S)=>{(function(){"use strict";var s={}.hasOwnProperty;function e(){for(var t=[],n=0;n<arguments.length;n++){var o=arguments[n];if(o){var r=typeof o;if(r==="string"||r==="number")t.push(o);else if(Array.isArray(o)){if(o.length){var i=e.apply(null,o);i&&t.push(i)}}else if(r==="object")if(o.toString===Object.prototype.toString)for(var l in o)s.call(o,l)&&o[l]&&t.push(l);else t.push(o.toString())}}return t.join(" ")}a(e,"classNames"),typeof S!="undefined"&&S.exports?(e.default=e,S.exports=e):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return e}):window.classNames=e})()});var O=x(R());var V=x(R()),Z=x($());import B,{Component as ve,Fragment as q}from"react";var me="object",fe="function";function U(s,e){s&&(typeof s===me&&(s.current=e),typeof s===fe&&s(e))}a(U,"default");var H=Object.defineProperty,de=Object.defineProperties,he=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,T=a((s,e,t)=>e in s?H(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,"n"),X=a((s,e)=>{for(var t in e||(e={}))Q.call(e,t)&&T(s,t,e[t]);if(w)for(var t of w(e))W.call(e,t)&&T(s,t,e[t]);return s},"m"),ue=a((s,e)=>de(s,he(e)),"g"),D=a((s,e)=>H(s,"name",{value:e,configurable:!0}),"l"),ye=a((s,e)=>{var t={};for(var n in s)Q.call(s,n)&&e.indexOf(n)<0&&(t[n]=s[n]);if(s!=null&&w)for(var n of w(s))e.indexOf(n)<0&&W.call(s,n)&&(t[n]=s[n]);return t},"w"),C=a((s,e,t)=>(T(s,typeof e!="symbol"?e+"":e,t),t),"o"),z="react-list",u,y,Oe=(u=(y=class extends ve{constructor(){super(...arguments),C(this,"handleRef",D(e=>{let{forwardedRef:t}=this.props;U(t,e)},"handleRef"))}get children(){let{items:e,template:t,options:n}=this.props;return e.map((o,r)=>t({items:e,item:o,index:r,options:n}))}get emptyView(){let{items:e,templateEmpty:t,options:n}=this.props;return t({items:e,item:null,index:-1,options:n})}get properties(){let e=this.props,{className:t,as:n,items:o,template:r,templateEmpty:i,sizeKey:l,forwardedRef:c,options:f}=e,N=ye(e,["className","as","items","template","templateEmpty","sizeKey","forwardedRef","options"]);return n===q?null:X({"data-component":z,ref:this.handleRef,className:(0,Z.default)(z,t)},N)}render(){let{as:e,items:t,sizeKey:n}=this.props;return!t||!t[n]?this.emptyView:B.createElement(e,this.properties,this.children)}},a(y,"i"),y),D(u,"ReactList"),C(u,"displayName",z),C(u,"version","__VERSION__"),C(u,"defaultProps",{items:[],sizeKey:"length",as:q,template:V.default,templateEmpty:V.default}),u),k=B.forwardRef((s,e)=>B.createElement(Oe,ue(X({},s),{ref:e})));var te=x(ee());import v,{Component as Ne}from"react";import{ReactSortable as Ie}from"react-sortablejs";import be from"fast-deep-equal";var K="react-draggable-list",xe={animation:300,draggable:`.${K}__item`,ghostClass:"react-draggable-list__ghost",chosenClass:"react-draggable-list__chosen",dragClass:"react-draggable-list__drag"},ge=a(()=>Math.random().toString(36).substr(2),"randomKey"),p=class p extends Ne{constructor(t){super(t);m(this,"cacheKey");m(this,"template",a(({item:t,index:n})=>{let{template:o,rowKey:r}=this.props;return v.createElement("div",{key:t[r],className:`${K}__item`},o({item:t,index:n}))},"template"));m(this,"handleAdd",a(t=>{let{newIndex:n,oldIndex:o,from:r}=t,i=r.id,l=p.cachedItems[i],c=p.cachedItems[this.cacheKey],{name:f,onChooseDrop:N,rowKey:E}=this.props,d=l[o];c.splice(n,0,d),this.execChange(c),N({target:{value:d[E],name:f}})},"handleAdd"));m(this,"handleRemove",a(t=>{let{oldIndex:n,from:o}=t,r=o.id,i=p.cachedItems[r];i.splice(n,1),this.execChange(i)},"handleRemove"));m(this,"handleUpdate",a(t=>{let{oldIndex:n,newIndex:o}=t,{name:r,onChooseDrop:i,rowKey:l}=this.props,{stateItems:c}=this.state,f=c[n];o<n?(c.splice(n,1),c.splice(o,0,f)):(c.splice(o+1,0,f),c.splice(n,1)),this.execChange(c),i({target:{value:f[l],name:r}})},"handleUpdate"));m(this,"execChange",a(t=>{let{onChange:n,rowKey:o}=this.props,r=t.map(i=>i[o]);this.setState({stateItems:t.slice(0)}),n({target:{value:r}})},"execChange"));let{items:n}=t;this.cacheKey=ge(),p.cachedItems[this.cacheKey]=n,this.state={stateItems:n}}shouldComponentUpdate(t){let{items:n}=t,{stateItems:o}=this.state;return be(n,o)||(p.cachedItems[this.cacheKey]=n,this.execChange(n)),!0}render(){let J=this.props,{name:t,className:n,children:o,template:r,rowKey:i,options:l,onChooseDrop:c,emptySlot:f,onChange:N}=J,E=G(J,["name","className","children","template","rowKey","options","onChooseDrop","emptySlot","onChange"]),{stateItems:d}=this.state,se=d.length===0&&f;return v.createElement(Ie,A(A({id:this.cacheKey,className:(0,te.default)(K,n),list:d,setList:O.default,onUpdate:this.handleUpdate,onAdd:this.handleAdd,onRemove:this.handleRemove},l),E),v.createElement(v.Fragment,null,se&&f,d.length>0&&v.createElement(k,{items:d,template:this.template})))}};a(p,"ReactDraggableList"),m(p,"displayName",K),m(p,"defaultProps",{onChange:O.default,onChooseDrop:O.default,items:[],template:O.default,rowKey:"id",options:xe}),m(p,"cachedItems",{});var F=p;export{F as default};
/*! Bundled license information:

@@ -6,2 +6,9 @@

(*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*)
classnames/index.js:
(*!
Copyright (c) 2018 Jed Watson.

@@ -11,3 +18,13 @@ Licensed under the MIT License (MIT), see

*)
@jswork/class-imperative-handle/dist/esm/index.js:
(*!
* name: @jswork/class-imperative-handle
* description: React `useImperativeHandle` for class component.
* homepage:
* version: 1.0.1
* date: 2021-09-04 23:46:33
* license: MIT
*)
*/
//# sourceMappingURL=index.esm.js.map

4

package.json
{
"name": "@jswork/react-draggable-list",
"description": "A simple draggable list component.",
"version": "1.1.16",
"version": "1.1.17",
"main": "dist/index.cjs.js",

@@ -22,2 +22,3 @@ "module": "dist/index.esm.js",

"devDependencies": {
"@jswork/react-list": "^1.2.7",
"@swc/core": "^1.3.93",

@@ -39,3 +40,2 @@ "@types/react": "^18.2.28",

"dependencies": {
"@jswork/react-list": "^1.2.2",
"@types/sortablejs": "^1.15.7",

@@ -42,0 +42,0 @@ "fast-deep-equal": "^3.1.3",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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