@gsretail.com/gui-core
Version:
A skeleton to create your own React component library using Rollup, TypeScript, Sass and Storybook
2 lines (1 loc) • 1.6 kB
JavaScript
import{__spreadArray as e}from"../../../node_modules/tslib/tslib.es6.js";function t(e,t,n){return t[n]<e[n]?-1:t[n]>e[n]?1:0}function n(e,n){return"desc"===e?function(e,r){return t(e,r,n)}:function(e,r){return-t(e,r,n)}}function r(e,t,r){var o=e.map((function(e,t){return[e,t]}));return o.sort((function(e,o){var u=n(t,r)(e[0],o[0]);return 0!==u?u:e[1]-o[1]})),o.map((function(e){return e[0]}))}var o=function(){var t=this;this.createdRows=[],this.updatedRows=[],this.deletedRows=[],this.getRows=function(){return{createdRows:e([],t.createdRows,!0),updatedRows:e([],t.updatedRows,!0),deletedRows:e([],t.deletedRows,!0)}},this.clearRow=function(){t.createdRows=[],t.updatedRows=[],t.deletedRows=[]},this.createRow=function(e){t.createdRows.push(e)},this.updateRow=function(e,n){var r=t.createdRows.findIndex((function(t){return n.every((function(n){return t[n]===e[n]}))}));if(-1===r){var o=t.updatedRows.findIndex((function(t){return n.every((function(n){return t[n]===e[n]}))}));-1===o?t.updatedRows.push(e):t.updatedRows[o]=e}else t.createdRows[r]=e},this.deleteRow=function(n,r){var o=t.createdRows.findIndex((function(e){return r.every((function(t){return e[t]===n[t]}))}));if(-1===o){var u=t.updatedRows.findIndex((function(e){return r.every((function(t){return e[t]===n[t]}))}));-1!==u&&(t.updatedRows=e(e([],t.updatedRows.slice(0,u),!0),t.updatedRows.slice(u+1),!0)),t.deletedRows.push(n)}else t.createdRows=e(e([],t.createdRows.slice(0,o),!0),t.createdRows.slice(o+1),!0)}};function u(){return new o}export{t as descendingComparator,n as getComparator,u as getGuiTableController,r as stableSort};