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

@bosket/core

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bosket/core - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

2

bundle/core.umd.min.js

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

!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("@bosket/tools")):"function"==typeof define&&define.amd?define(["@bosket/tools"],n):"object"==typeof exports?exports["bosket-core"]=n(require("@bosket/tools")):t["bosket-core"]=n(t["bosket-tools"])}(this,function(t){return function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=18)}([,function(n,e){n.exports=t},,,,,,,,,,function(t,n,e){"use strict";function r(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)}e.d(n,"a",function(){return s}),e.d(n,"c",function(){return u}),e.d(n,"b",function(){return f}),e.d(n,"d",function(){return d});var i=e(1),o=(e.n(i),Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}),s={selection:function(t,n){return{draggable:!0,droppable:!0,drag:function(t,n,e){n.dataTransfer&&n.dataTransfer.setData("application/json",JSON.stringify(e.selection))},guard:function(t,n,e){if(n&&n.dataTransfer&&n.dataTransfer.types.indexOf("application/json")<0)return!1;return function(){return t&&Object(i.array)(e.selection).contains(t)}()||function(){return e.ancestors&&e.ancestors.reduce(function(t,n){return t||Object(i.array)(e.selection).contains(n)},!1)}()},drop:function(e,o,s){var a=Object(i.tree)(t(),s.category).filter(function(t){return s.selection.indexOf(t)<0}),u=e?e[s.category]&&e[s.category]instanceof Array?e:Object(i.array)(s.ancestors).last():null;u?u[s.category]=[].concat(r(u[s.category]),r(s.selection)):a=[].concat(r(a),r(s.selection)),n(a)}}},pluck:function(t,n){return{draggable:!0,backup:[],drag:function(e,r,o){a=JSON.stringify(t()),r.dataTransfer&&r.dataTransfer.setData("application/json",JSON.stringify(e)),setTimeout(function(){return n(Object(i.tree)(t(),o.category).filter(function(t){return t!==e}))},20)},cancel:function(){n(JSON.parse(a))}}},paste:function(t,n){return{droppable:!0,drop:function(e,o,s){if(o.dataTransfer&&o.dataTransfer.types.indexOf("application/json")>-1){var a=JSON.parse(o.dataTransfer.getData("application/json")),u=[].concat(r(t())),c=e?e[s.category]&&e[s.category]instanceof Array?e:Object(i.array)(s.ancestors).last():null;c?c[s.category]=[].concat(r(c[s.category]),[a]):u=[].concat(r(u),[a]),n(u)}}}}},a="[]",u={filesystem:function(t){var n=t.dataTransfer?t.dataTransfer.items:null;if(n&&n.length>0&&"file"===n[0].kind){for(var e=[],r=0;r<n.length;r++){var i=n[r].webkitGetAsEntry()||n[r].getAsFile();i&&e.push(i)}return e}return null}},c={itemRef:void 0,guardCheck:!1},f={onDragStart:function(t){return function(n){n.stopPropagation(),this.inputs.get().dragndrop.onDrag(t,n,this.inputs.get())}},onDragOver:function(t){return function(n){n.preventDefault(),n.stopPropagation();var e=c.itemRef===t?c.guardCheck:this.inputs.get().dragndrop.guard&&this.inputs.get().dragndrop.guard(t,n,this.inputs.get());e?(n.dataTransfer&&(n.dataTransfer.dropEffect="none"),i.css.addClass(n.currentTarget,this.mixCss("nodrop"))):(n.dataTransfer&&(n.dataTransfer.dropEffect="copy"),i.css.addClass(n.currentTarget,this.mixCss("dragover"))),c.itemRef=t,c.guardCheck=e,this.inputs.get().dragndrop.onOver(t,n,this.inputs.get())}},onDragEnter:function(t){return function(n){if(n.preventDefault(),n.stopPropagation(),t&&(this.hasChildren(t)||this.isAsync(t))&&i.css.hasClass(n.target,this.mixCss("opener"))){var e=this.state.get().unfolded.filter(function(n){return n!==t});e.push(t),this.state.set({unfolded:e})}this.inputs.get().dragndrop.onEnter(t,n,this.inputs.get())}},onDragLeave:function(t){return function(n){n.stopPropagation(),i.css.removeClass(n.currentTarget,this.mixCss("dragover")),i.css.removeClass(n.currentTarget,this.mixCss("nodrop")),this.inputs.get().dragndrop.onLeave(t,n,this.inputs.get())}},onDrop:function(t){return function(n){n.stopPropagation(),i.css.removeClass(n.currentTarget,this.mixCss("dragover")),i.css.removeClass(n.currentTarget,this.mixCss("nodrop")),this.inputs.get().dragndrop.guard&&this.inputs.get().dragndrop.guard(t,n,this.inputs.get())||this.inputs.get().dragndrop.onDrop(t,n,this.inputs.get())}},onDragEnd:function(t){return function(n){n.stopPropagation(),n.dataTransfer&&"none"===n.dataTransfer.dropEffect&&this.inputs.get().dragndrop.onCancel(t,n,this.inputs.get())}}},d=function(){var t=this;return o({},this.inputs.get().dragndrop,{onDrag:function(n,e,r){Object(i.array)(t.inputs.get().selection).contains(n)||t.onSelect(n,r.ancestors,r.neighbours),t.outputs.onDrag&&t.outputs.onDrag(n,e,r)},onOver:function(n,e,r){t.outputs.onOver&&t.outputs.onOver(n,e,r)},onEnter:function(n,e,r){t.outputs.onEnter&&t.outputs.onEnter(n,e,r)},onLeave:function(n,e,r){t.outputs.onLeave&&t.outputs.onLeave(n,e,r)},onDrop:function(n,e,r){e.preventDefault(),t.outputs.onDrop&&t.outputs.onDrop(n,e,r)},onCancel:function(n,e,r){e.preventDefault(),e.dataTransfer&&"none"===e.dataTransfer.dropEffect&&t.outputs.onCancel&&t.outputs.onCancel(n,e,r)}})}},function(t,n,e){"use strict";function r(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)}e.d(n,"c",function(){return u}),e.d(n,"a",function(){return c}),e.d(n,"b",function(){return f});var i=e(1),o=(e.n(i),function(){function t(t,n){var e=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(e.push(s.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()),s=function(t,n,e,r){return Object(i.array)(n).contains(t)?[]:[t]},a=function(t,n,e,r){var o=!1,s=n.filter(function(n){return o||(o=n===t),n!==t&&r.indexOf(n)<0});return!o&&t[this.inputs.get().category]&&t[this.inputs.get().category]instanceof Array&&Object(i.tree)(t[this.inputs.get().category],this.inputs.get().category).visit(function(t){s=Object(i.array)(s).notIn(t)}),o||s.push(t),s},u={single:s,multiple:a,modifiers:function(t,n,e,u){var c=this;if(this.modifiers.control||this.modifiers.meta)return this.lastSelection=t,delete this.lastIndex,delete this.lastPivot,a.bind(this)(t,n,e,u);if(this.modifiers.shift){if(!this.lastSelection)return n;var f=e.indexOf(this.lastSelection);if(f<0)return n;var d=n.slice(),p=e.indexOf(t);if(f>=0){var l;if(this.lastPivot){var g=e.indexOf(this.lastPivot),h=f>g?[g,f]:[f,g],y=o(h,2),b=y[0],v=y[1],m=e.slice(b,v+1);d=Object(i.array)(d).notIn(m)}this.lastPivot=t;var O=f>p?[p,f]:[f,p],D=o(O,2),x=D[0],j=D[1],C=this.inputs.get().disabled?e.slice(x,j+1).filter(function(t){return!c.inputs.get().disabled(t)}):e.slice(x,j+1);d=Object(i.array)(d).notIn(C),(l=d).push.apply(l,r(C))}return d}return this.lastSelection=t,delete this.lastIndex,delete this.lastPivot,s.bind(this)(t,n.length>1?[]:n,e,u)},ancestors:function(t){function n(n,e,r,i){return t.apply(this,arguments)}return n.toString=function(){return t.toString()},n}(function(t,n,e,o){return 0===n.length?[t]:Object(i.array)(n).contains(t)?[].concat(r(o)):[].concat(r(o),[t])})},c={"unfold-on-selection":function(t){if(!this.isSelected(t)){var n=this.state.get().unfolded.filter(function(n){return n!==t});n.push(t),this.state.set({unfolded:n})}},"toggle-fold":function(t){var n=this.state.get().unfolded.filter(function(n){return n!==t});n.length===this.state.get().unfolded.length&&n.push(t),this.state.set({unfolded:n})}},f={"opener-control":function(t){return!Object(i.array)(this.state.get().unfolded).contains(t)},"not-selected":function(t){return!this.isSelected(t)},"no-child-selection":function(t){var n=this;return!function t(e){return n.isSelected(e)||e[n.inputs.get().category]&&e[n.inputs.get().category]instanceof Array&&e[n.inputs.get().category].some(t)}(t)},"max-depth":function(){return!(!this.inputs.get().maxDepth||isNaN(parseInt(this.inputs.get().maxDepth,10)))&&this.inputs.get().depth>=parseInt(this.inputs.get().maxDepth,10)}}},function(t,n,e){"use strict";e.d(n,"a",function(){return r});var r={labels:{"search.placeholder":"Search ..."},css:{TreeView:"TreeView",opener:"opener",depth:"depth",selected:"selected",category:"category",folded:"folded",disabled:"disabled",async:"async",loading:"loading",nodrop:"nodrop",dragover:"dragover",search:"search",item:"item"},strategies:{selection:["single"],click:[],fold:["not-selected","no-child-selection"]},display:function(t){return t.toString()},async:function(t){return t()},openerOpts:{position:"right"},dragndrop:{draggable:!1,droppable:!1}}},,,,,function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e(19);e.d(n,"TreeNode",function(){return r.b}),e.d(n,"RootNode",function(){return r.a});var i=e(12);e.d(n,"selectionStrategies",function(){return i.c}),e.d(n,"clickStrategies",function(){return i.a}),e.d(n,"foldStrategies",function(){return i.b});var o=e(13);e.d(n,"defaults",function(){return o.a});var s=e(11);e.d(n,"dragndrop",function(){return s.a}),e.d(n,"utils",function(){return s.c}),e.d(n,"nodeEvents",function(){return s.b}),e.d(n,"wrapEvents",function(){return s.d})},function(t,n,e){"use strict";function r(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function i(t,n){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?t:n}function o(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(t,n):t.__proto__=n)}function s(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}e.d(n,"b",function(){return l}),e.d(n,"a",function(){return g});var a=e(1),u=(e.n(a),e(11)),c=e(12),f=e(13),d=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}(),p=function t(n,e,r,i){s(this,t),this.inputs=n,this.outputs=e,this.state=r,this.refresh=i},l=function(t){function n(){var t,e,o,d;s(this,n);for(var p=arguments.length,l=Array(p),g=0;g<p;g++)l[g]=arguments[g];return e=o=i(this,(t=n.__proto__||Object.getPrototypeOf(n)).call.apply(t,[this].concat(l))),o.isSelected=function(t){return Object(a.array)(o.inputs.get().selection).contains(t)},o.isFolded=function(t){var n=o.inputs.get().strategies;return(!o.inputs.get().searched||o.isAsync(t))&&(n&&n.fold||[]).map(function(t){return(c.b[t]||t).bind(o)}).reduce(function(n,e){return n&&e(t,n)},!0)},o.hasChildren=function(t){return t[o.inputs.get().category]&&t[o.inputs.get().category]instanceof Array},o.isAsync=function(t){return!!t&&[o.inputs.get().category]&&"function"==typeof t[o.inputs.get().category]},o.isDisabled=function(t){var n=o.inputs.get().disabled;return!!n&&n(t)},o.isDraggable=function(t){return t&&o.inputs.get().dragndrop.draggable&&("function"!=typeof o.inputs.get().dragndrop.draggable||o.inputs.get().dragndrop.draggable(t))},o.isDroppable=function(t){return o.inputs.get().dragndrop.droppable&&("function"!=typeof o.inputs.get().dragndrop.droppable||o.inputs.get().dragndrop.droppable(t))},o.mixCss=function(t){return o.inputs.get().css[t]||f.a.css[t]},o.ulCss=function(){return a.css.classes(r({},o.mixCss("depth")+"-"+(o.inputs.get().depth||0),!0))},o.liCss=function(t){var n;return a.css.classes((n={},r(n,o.mixCss("selected"),o.isSelected(t)),r(n,o.mixCss("category"),o.hasChildren(t)||o.isAsync(t)),r(n,o.mixCss("folded"),o.hasChildren(t)||o.isAsync(t)?o.isFolded(t):null),r(n,o.mixCss("disabled"),o.isDisabled(t)),r(n,o.mixCss("async"),o.isAsync(t)&&o.isFolded(t)),r(n,o.mixCss("loading"),o.isAsync(t)&&!o.isFolded(t)),n))},o.pending=[],o.unwrapPromise=function(t){o.pending.push(t);var n=o.inputs.get().async;return n?n(t[o.inputs.get().category]).then(function(n){t[o.inputs.get().category]=n,o.refresh()}).catch(function(t){throw t}).then(function(){return o.pending=o.pending.filter(function(n){return n!==t})}):Promise.reject(new Error("Missing async function."))},o.onClick=function(t){return function(n){if(!o.isDisabled(t)){var e=o.inputs.get().strategies;(e&&e.click||[]).map(function(t){return(c.a[t]||t).bind(o)}).forEach(function(e){return e(t,n,o.inputs.get().ancestors,o.inputs.get().model)}),o.inputs.get().onSelect(t,o.inputs.get().ancestors,o.inputs.get().model),n.stopPropagation()}}},o.getDragEvents=function(t){if(arguments.length>1&&void 0!==arguments[1]&&!arguments[1])return{};var n={draggable:o.isDraggable(t),onDragStart:o.isDraggable(t)&&u.b.onDragStart(t).bind(o),onDragOver:o.isDroppable(t)&&u.b.onDragOver(t).bind(o),onDragEnter:o.isDroppable(t)&&u.b.onDragEnter(t).bind(o),onDragLeave:o.isDroppable(t)&&u.b.onDragLeave(t).bind(o),onDrop:o.isDroppable(t)&&u.b.onDrop(t).bind(o),onDragEnd:o.isDraggable(t)&&u.b.onDragEnd(t).bind(o)};for(var e in n)n[e]||delete n[e];return n},d=e,i(o,d)}return o(n,t),d(n,[{key:"onOpener",value:function(t){var n=this;return function(e){var r=n.state.get().unfolded.filter(function(n){return n!==t});r.length===n.state.get().unfolded.length&&r.push(t),n.state.set({unfolded:r}),e.stopPropagation()}}}]),n}(p),g=function(t){function n(){var t,e,r,o;s(this,n);for(var d=arguments.length,p=Array(d),l=0;l<d;l++)p[l]=arguments[l];return e=r=i(this,(t=n.__proto__||Object.getPrototypeOf(n)).call.apply(t,[this].concat(p))),r.modifiers={},r.onKey=function(t){r.modifiers={control:t.getModifierState("Control"),meta:t.getModifierState("Meta"),shift:t.getModifierState("Shift")}},r.onSelect=function(t,n,e){var i=r.inputs.get().strategies.selection||[],o=i.map(function(t){return(c.c[t]||t).bind(r)}).reduce(function(r,i){return i(t,r,e,n)},r.inputs.get().selection);return r.outputs.onSelect(o,t,n,e),o},r.wrapDragNDrop=u.d.bind(r),r.mixCss=function(t){return r.inputs.get().css[t]||f.a.css[t]},r.filterTree=function(t){var n=r.inputs.get().search;return n&&t.trim()?Object(a.tree)(r.inputs.get().model,r.inputs.get().category).filterMap(n(t.trim())):null},o=e,i(r,o)}return o(n,t),n}(p)}])});
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("@bosket/tools")):"function"==typeof define&&define.amd?define(["@bosket/tools"],n):"object"==typeof exports?exports["bosket-core"]=n(require("@bosket/tools")):t["bosket-core"]=n(t["bosket-tools"])}(this,function(t){return function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=18)}([,function(n,e){n.exports=t},,,,,,,,,,function(t,n,e){"use strict";function r(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)}e.d(n,"a",function(){return s}),e.d(n,"c",function(){return u}),e.d(n,"b",function(){return f}),e.d(n,"d",function(){return d});var i=e(1),o=(e.n(i),Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}),s={selection:function(t,n){return{draggable:!0,droppable:!0,drag:function(t,n,e){n.dataTransfer&&n.dataTransfer.setData("application/json",JSON.stringify(e.selection))},guard:function(t,n,e){if(n&&n.dataTransfer&&n.dataTransfer.types.indexOf("application/json")<0)return!1;return function(){return t&&Object(i.array)(e.selection).contains(t)}()||function(){return e.ancestors&&e.ancestors.reduce(function(t,n){return t||Object(i.array)(e.selection).contains(n)},!1)}()},drop:function(e,o,s){var a=Object(i.tree)(t(),s.category).filter(function(t){return s.selection.indexOf(t)<0}),u=e?e[s.category]&&e[s.category]instanceof Array?e:Object(i.array)(s.ancestors).last():null;u?u[s.category]=[].concat(r(u[s.category]),r(s.selection)):a=[].concat(r(a),r(s.selection)),n(a)}}},pluck:function(t,n){return{draggable:!0,backup:[],drag:function(e,r,o){a=JSON.stringify(t()),r.dataTransfer&&r.dataTransfer.setData("application/json",JSON.stringify(e)),setTimeout(function(){return n(Object(i.tree)(t(),o.category).filter(function(t){return t!==e}))},20)},cancel:function(){n(JSON.parse(a))}}},paste:function(t,n){return{droppable:!0,drop:function(e,o,s){if(o.dataTransfer&&o.dataTransfer.types.indexOf("application/json")>-1){var a=JSON.parse(o.dataTransfer.getData("application/json")),u=[].concat(r(t())),c=e?e[s.category]&&e[s.category]instanceof Array?e:Object(i.array)(s.ancestors).last():null;c?c[s.category]=[].concat(r(c[s.category]),[a]):u=[].concat(r(u),[a]),n(u)}}}}},a="[]",u={filesystem:function(t){var n=t.dataTransfer?t.dataTransfer.items:null;if(n&&n.length>0&&"file"===n[0].kind){for(var e=[],r=0;r<n.length;r++){var i=n[r].webkitGetAsEntry()||n[r].getAsFile();i&&e.push(i)}return e}return null}},c={itemRef:void 0,guardCheck:!1},f={onDragStart:function(t){return function(n){n.stopPropagation(),this.inputs.get().dragndrop.onDrag(t,n,this.inputs.get())}},onDragOver:function(t){return function(n){n.preventDefault(),n.stopPropagation();var e=c.itemRef===t?c.guardCheck:this.inputs.get().dragndrop.guard&&this.inputs.get().dragndrop.guard(t,n,this.inputs.get());e?(n.dataTransfer&&(n.dataTransfer.dropEffect="none"),i.css.addClass(n.currentTarget,this.mixCss("nodrop"))):(n.dataTransfer&&(n.dataTransfer.dropEffect="copy"),i.css.addClass(n.currentTarget,this.mixCss("dragover"))),c.itemRef=t,c.guardCheck=e,this.inputs.get().dragndrop.onOver(t,n,this.inputs.get())}},onDragEnter:function(t){return function(n){if(n.preventDefault(),n.stopPropagation(),t&&(this.hasChildren(t)||this.isAsync(t))&&i.css.hasClass(n.target,this.mixCss("opener"))){var e=this.state.get().unfolded.filter(function(n){return n!==t});e.push(t),this.state.set({unfolded:e})}this.inputs.get().dragndrop.onEnter(t,n,this.inputs.get())}},onDragLeave:function(t){return function(n){n.stopPropagation(),i.css.removeClass(n.currentTarget,this.mixCss("dragover")),i.css.removeClass(n.currentTarget,this.mixCss("nodrop")),this.inputs.get().dragndrop.onLeave(t,n,this.inputs.get())}},onDrop:function(t){return function(n){n.stopPropagation(),i.css.removeClass(n.currentTarget,this.mixCss("dragover")),i.css.removeClass(n.currentTarget,this.mixCss("nodrop")),this.inputs.get().dragndrop.guard&&this.inputs.get().dragndrop.guard(t,n,this.inputs.get())||this.inputs.get().dragndrop.onDrop(t,n,this.inputs.get())}},onDragEnd:function(t){return function(n){n.stopPropagation(),n.dataTransfer&&"none"===n.dataTransfer.dropEffect&&this.inputs.get().dragndrop.onCancel(t,n,this.inputs.get())}}},d=function(){var t=this;return o({},this.inputs.get().dragndrop,{onDrag:function(n,e,r){Object(i.array)(t.inputs.get().selection).contains(n)||t.onSelect(n,r.ancestors,r.neighbours),t.outputs.onDrag&&t.outputs.onDrag(n,e,r)},onOver:function(n,e,r){t.outputs.onOver&&t.outputs.onOver(n,e,r)},onEnter:function(n,e,r){t.outputs.onEnter&&t.outputs.onEnter(n,e,r)},onLeave:function(n,e,r){t.outputs.onLeave&&t.outputs.onLeave(n,e,r)},onDrop:function(n,e,r){e.preventDefault(),t.outputs.onDrop&&t.outputs.onDrop(n,e,r)},onCancel:function(n,e,r){e.preventDefault(),e.dataTransfer&&"none"===e.dataTransfer.dropEffect&&t.outputs.onCancel&&t.outputs.onCancel(n,e,r)}})}},function(t,n,e){"use strict";function r(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)}e.d(n,"c",function(){return u}),e.d(n,"a",function(){return c}),e.d(n,"b",function(){return f});var i=e(1),o=(e.n(i),function(){function t(t,n){var e=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(e.push(s.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()),s=function(t,n,e,r){return Object(i.array)(n).contains(t)?[]:[t]},a=function(t,n,e,r){var o=!1,s=n.filter(function(n){return o||(o=n===t),n!==t&&r.indexOf(n)<0});return!o&&t[this.inputs.get().category]&&t[this.inputs.get().category]instanceof Array&&Object(i.tree)(t[this.inputs.get().category],this.inputs.get().category).visit(function(t){s=Object(i.array)(s).notIn(t)}),o||s.push(t),s},u={single:s,multiple:a,modifiers:function(t,n,e,u){var c=this;if(this.modifiers.control||this.modifiers.meta)return this.lastSelection=t,delete this.lastIndex,delete this.lastPivot,a.bind(this)(t,n,e,u);if(this.modifiers.shift){if(!this.lastSelection)return n;var f=e.indexOf(this.lastSelection);if(f<0)return n;var d=n.slice(),p=e.indexOf(t);if(f>=0){var l;if(this.lastPivot){var g=e.indexOf(this.lastPivot),h=f>g?[g,f]:[f,g],y=o(h,2),b=y[0],v=y[1],m=e.slice(b,v+1);d=Object(i.array)(d).notIn(m)}this.lastPivot=t;var O=f>p?[p,f]:[f,p],D=o(O,2),x=D[0],j=D[1],C=this.inputs.get().disabled?e.slice(x,j+1).filter(function(t){return!c.inputs.get().disabled(t)}):e.slice(x,j+1);d=Object(i.array)(d).notIn(C),(l=d).push.apply(l,r(C))}return d}return this.lastSelection=t,delete this.lastIndex,delete this.lastPivot,s.bind(this)(t,n.length>1?[]:n,e,u)},ancestors:function(t){function n(n,e,r,i){return t.apply(this,arguments)}return n.toString=function(){return t.toString()},n}(function(t,n,e,o){return 0===n.length?[t]:Object(i.array)(n).contains(t)?[].concat(r(o)):[].concat(r(o),[t])})},c={select:function(t){this.inputs.get().onSelect(t,this.inputs.get().ancestors,this.inputs.get().model)},"unfold-on-selection":function(t){if(!this.isSelected(t)){var n=this.state.get().unfolded.filter(function(n){return n!==t});n.push(t),this.state.set({unfolded:n})}},"toggle-fold":function(t){var n=this.state.get().unfolded.filter(function(n){return n!==t});n.length===this.state.get().unfolded.length&&n.push(t),this.state.set({unfolded:n})}},f={"opener-control":function(t){return!Object(i.array)(this.state.get().unfolded).contains(t)},"not-selected":function(t){return!this.isSelected(t)},"no-child-selection":function(t){var n=this;return!function t(e){return n.isSelected(e)||e[n.inputs.get().category]&&e[n.inputs.get().category]instanceof Array&&e[n.inputs.get().category].some(t)}(t)},"max-depth":function(){return!(!this.inputs.get().maxDepth||isNaN(parseInt(this.inputs.get().maxDepth,10)))&&this.inputs.get().depth>=parseInt(this.inputs.get().maxDepth,10)}}},function(t,n,e){"use strict";e.d(n,"a",function(){return r});var r={labels:{"search.placeholder":"Search ..."},css:{TreeView:"TreeView",opener:"opener",depth:"depth",selected:"selected",category:"category",folded:"folded",disabled:"disabled",async:"async",loading:"loading",nodrop:"nodrop",dragover:"dragover",search:"search",item:"item"},strategies:{selection:["single"],click:["select"],fold:["not-selected","no-child-selection"]},display:function(t){return t.toString()},async:function(t){return t()},openerOpts:{position:"right"},dragndrop:{draggable:!1,droppable:!1}}},,,,,function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e(19);e.d(n,"TreeNode",function(){return r.b}),e.d(n,"RootNode",function(){return r.a});var i=e(12);e.d(n,"selectionStrategies",function(){return i.c}),e.d(n,"clickStrategies",function(){return i.a}),e.d(n,"foldStrategies",function(){return i.b});var o=e(13);e.d(n,"defaults",function(){return o.a});var s=e(11);e.d(n,"dragndrop",function(){return s.a}),e.d(n,"utils",function(){return s.c}),e.d(n,"nodeEvents",function(){return s.b}),e.d(n,"wrapEvents",function(){return s.d})},function(t,n,e){"use strict";function r(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function i(t,n){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?t:n}function o(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(t,n):t.__proto__=n)}function s(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}e.d(n,"b",function(){return l}),e.d(n,"a",function(){return g});var a=e(1),u=(e.n(a),e(11)),c=e(12),f=e(13),d=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}(),p=function t(n,e,r,i){s(this,t),this.inputs=n,this.outputs=e,this.state=r,this.refresh=i},l=function(t){function n(){var t,e,o,d;s(this,n);for(var p=arguments.length,l=Array(p),g=0;g<p;g++)l[g]=arguments[g];return e=o=i(this,(t=n.__proto__||Object.getPrototypeOf(n)).call.apply(t,[this].concat(l))),o.isSelected=function(t){return Object(a.array)(o.inputs.get().selection).contains(t)},o.isFolded=function(t){var n=o.inputs.get().strategies;return(!o.inputs.get().searched||o.isAsync(t))&&(n&&n.fold||[]).map(function(t){return(c.b[t]||t).bind(o)}).reduce(function(n,e){return n&&e(t,n)},!0)},o.hasChildren=function(t){return t[o.inputs.get().category]&&t[o.inputs.get().category]instanceof Array},o.isAsync=function(t){return!!t&&[o.inputs.get().category]&&"function"==typeof t[o.inputs.get().category]},o.isDisabled=function(t){var n=o.inputs.get().disabled;return!!n&&n(t)},o.isDraggable=function(t){return t&&o.inputs.get().dragndrop.draggable&&("function"!=typeof o.inputs.get().dragndrop.draggable||o.inputs.get().dragndrop.draggable(t))},o.isDroppable=function(t){return o.inputs.get().dragndrop.droppable&&("function"!=typeof o.inputs.get().dragndrop.droppable||o.inputs.get().dragndrop.droppable(t))},o.mixCss=function(t){return o.inputs.get().css[t]||f.a.css[t]},o.ulCss=function(){return a.css.classes(r({},o.mixCss("depth")+"-"+(o.inputs.get().depth||0),!0))},o.liCss=function(t){var n;return a.css.classes((n={},r(n,o.mixCss("selected"),o.isSelected(t)),r(n,o.mixCss("category"),o.hasChildren(t)||o.isAsync(t)),r(n,o.mixCss("folded"),o.hasChildren(t)||o.isAsync(t)?o.isFolded(t):null),r(n,o.mixCss("disabled"),o.isDisabled(t)),r(n,o.mixCss("async"),o.isAsync(t)&&o.isFolded(t)),r(n,o.mixCss("loading"),o.isAsync(t)&&!o.isFolded(t)),n))},o.pending=[],o.unwrapPromise=function(t){o.pending.push(t);var n=o.inputs.get().async;return n?n(t[o.inputs.get().category]).then(function(n){t[o.inputs.get().category]=n,o.refresh()}).catch(function(t){throw t}).then(function(){return o.pending=o.pending.filter(function(n){return n!==t})}):Promise.reject(new Error("Missing async function."))},o.onClick=function(t){return function(n){if(!o.isDisabled(t)){var e=o.inputs.get().strategies;(e&&e.click||[]).map(function(t){return(c.a[t]||t).bind(o)}).forEach(function(e){return e(t,n,o.inputs.get().ancestors,o.inputs.get().model)}),n.stopPropagation()}}},o.getDragEvents=function(t){if(arguments.length>1&&void 0!==arguments[1]&&!arguments[1])return{};var n={draggable:o.isDraggable(t),onDragStart:o.isDraggable(t)&&u.b.onDragStart(t).bind(o),onDragOver:o.isDroppable(t)&&u.b.onDragOver(t).bind(o),onDragEnter:o.isDroppable(t)&&u.b.onDragEnter(t).bind(o),onDragLeave:o.isDroppable(t)&&u.b.onDragLeave(t).bind(o),onDrop:o.isDroppable(t)&&u.b.onDrop(t).bind(o),onDragEnd:o.isDraggable(t)&&u.b.onDragEnd(t).bind(o)};for(var e in n)n[e]||delete n[e];return n},d=e,i(o,d)}return o(n,t),d(n,[{key:"onOpener",value:function(t){var n=this;return function(e){var r=n.state.get().unfolded.filter(function(n){return n!==t});r.length===n.state.get().unfolded.length&&r.push(t),n.state.set({unfolded:r}),e.stopPropagation()}}}]),n}(p),g=function(t){function n(){var t,e,r,o;s(this,n);for(var d=arguments.length,p=Array(d),l=0;l<d;l++)p[l]=arguments[l];return e=r=i(this,(t=n.__proto__||Object.getPrototypeOf(n)).call.apply(t,[this].concat(p))),r.modifiers={},r.onKey=function(t){r.modifiers={control:t.getModifierState("Control"),meta:t.getModifierState("Meta"),shift:t.getModifierState("Shift")}},r.onSelect=function(t,n,e){var i=r.inputs.get().strategies.selection||[],o=i.map(function(t){return(c.c[t]||t).bind(r)}).reduce(function(r,i){return i(t,r,e,n)},r.inputs.get().selection);return r.outputs.onSelect(o,t,n,e),o},r.wrapDragNDrop=u.d.bind(r),r.mixCss=function(t){return r.inputs.get().css[t]||f.a.css[t]},r.filterTree=function(t){var n=r.inputs.get().search;return n&&t.trim()?Object(a.tree)(r.inputs.get().model,r.inputs.get().category).filterMap(n(t.trim())):null},o=e,i(r,o)}return o(n,t),n}(p)}])});
//# sourceMappingURL=core.umd.min.js.map

@@ -22,3 +22,3 @@ export var defaults = {

selection: ["single"],
click: [],
click: ["select"],
fold: ["not-selected", "no-child-selection"]

@@ -25,0 +25,0 @@ },

@@ -97,3 +97,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

});
_this.inputs.get().onSelect(item, _this.inputs.get().ancestors, _this.inputs.get().model);
// this.inputs.get().onSelect(item, this.inputs.get().ancestors, this.inputs.get().model)
event.stopPropagation();

@@ -100,0 +100,0 @@ };

{
"name": "@bosket/core",
"version": "0.3.2",
"version": "0.4.0",
"description": "A collection of tree views.",

@@ -27,4 +27,4 @@ "keywords": [

"peerDependencies": {
"@bosket/tools": "^0.3.2"
"@bosket/tools": "^0.4.0"
}
}

@@ -110,2 +110,6 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

};export var clickStrategies = {
// Selects on click
select: function select(item) {
this.inputs.get().onSelect(item, this.inputs.get().ancestors, this.inputs.get().model);
},
// Unfold an item when selecting it. Pair it with the "opener-control" fold strategy.

@@ -112,0 +116,0 @@ "unfold-on-selection": function unfoldOnSelection(item) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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