2024-12-16 20:19:32 -06:00
'use strict' ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . Dropdown = exports . DraggableAttribute = undefined ;
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 ; } ; } ( ) ;
var _react = require ( 'react' ) ;
var _react2 = _interopRequireDefault ( _react ) ;
var _propTypes = require ( 'prop-types' ) ;
var _propTypes2 = _interopRequireDefault ( _propTypes ) ;
var _immutabilityHelper = require ( 'immutability-helper' ) ;
var _immutabilityHelper2 = _interopRequireDefault ( _immutabilityHelper ) ;
var _Utilities = require ( './Utilities' ) ;
var _PivotTable = require ( './PivotTable' ) ;
var _PivotTable2 = _interopRequireDefault ( _PivotTable ) ;
var _reactSortablejs = require ( 'react-sortablejs' ) ;
var _reactSortablejs2 = _interopRequireDefault ( _reactSortablejs ) ;
var _reactDraggable = require ( 'react-draggable' ) ;
var _reactDraggable2 = _interopRequireDefault ( _reactDraggable ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
function _possibleConstructorReturn ( self , call ) { if ( ! self ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ; }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
/* eslint-disable react/prop-types */
// eslint can't see inherited propTypes!
var DraggableAttribute = exports . DraggableAttribute = function ( _React$Component ) {
_inherits ( DraggableAttribute , _React$Component ) ;
function DraggableAttribute ( props ) {
_classCallCheck ( this , DraggableAttribute ) ;
var _this = _possibleConstructorReturn ( this , ( DraggableAttribute . _ _proto _ _ || Object . getPrototypeOf ( DraggableAttribute ) ) . call ( this , props ) ) ;
2025-02-07 07:50:34 -06:00
_this . state = { open : false , filterText : '' , attrValues : { } } ;
2024-12-16 20:19:32 -06:00
return _this ;
}
_createClass ( DraggableAttribute , [ {
key : 'toggleValue' ,
value : function toggleValue ( value ) {
if ( value in this . props . valueFilter ) {
this . props . removeValuesFromFilter ( this . props . name , [ value ] ) ;
} else {
this . props . addValuesToFilter ( this . props . name , [ value ] ) ;
}
}
2025-02-07 07:50:34 -06:00
} , {
key : 'updateFilterOptions' ,
value : function updateFilterOptions ( ) {
var showAll = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : false ;
var _attrValuesReduced = this . props . getFilterOptions ( showAll ) ;
this . setState ( { attrValues : _attrValuesReduced [ this . props . name ] } ) ;
}
2024-12-16 20:19:32 -06:00
} , {
key : 'matchesFilter' ,
value : function matchesFilter ( x ) {
return x . toLowerCase ( ) . trim ( ) . includes ( this . state . filterText . toLowerCase ( ) . trim ( ) ) ;
}
} , {
key : 'selectOnly' ,
value : function selectOnly ( e , value ) {
e . stopPropagation ( ) ;
this . props . setValuesInFilter ( this . props . name , Object . keys ( this . props . attrValues ) . filter ( function ( y ) {
return y !== value ;
} ) ) ;
}
} , {
key : 'getFilterBox' ,
value : function getFilterBox ( ) {
var _this2 = this ;
2025-01-14 13:14:24 -06:00
// const showMenu = Object.keys(this.props.attrValues).length < this.props.menuLimit;
2025-02-06 17:02:32 -06:00
// const values = Object.keys(this.props.attrValues);
var stringAttr = JSON . stringify ( this . props . attrValues ) ;
2025-02-07 07:50:34 -06:00
var stringAttrReduced = JSON . stringify ( this . state . attrValues ) ;
var values = Object . keys ( this . state . attrValues ) ;
2025-01-14 13:29:07 -06:00
var shown = values . filter ( this . matchesFilter . bind ( this ) ) . sort ( this . props . sorter ) ;
2025-01-14 15:53:49 -06:00
var truncatedShown = values . filter ( this . matchesFilter . bind ( this ) ) . sort ( this . props . sorter ) ;
// .slice(0, this.props.menuLimit);
2024-12-16 20:19:32 -06:00
return _react2 . default . createElement (
_reactDraggable2 . default ,
{ handle : '.pvtDragHandle' } ,
_react2 . default . createElement (
'div' ,
{
className : 'pvtFilterBox' ,
style : {
display : 'block' ,
cursor : 'initial' ,
zIndex : this . props . zIndex
} ,
onClick : function onClick ( ) {
return _this2 . props . moveFilterBoxToTop ( _this2 . props . name ) ;
}
} ,
_react2 . default . createElement (
'a' ,
{ onClick : function onClick ( ) {
return _this2 . setState ( { open : false } ) ;
} , className : 'pvtCloseX' } ,
'\xD7'
) ,
_react2 . default . createElement (
'span' ,
{ className : 'pvtDragHandle' } ,
'\u2630'
) ,
_react2 . default . createElement (
'h4' ,
null ,
this . props . name
) ,
2025-01-14 13:14:24 -06:00
_react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'p' ,
null ,
2025-02-07 09:56:20 -06:00
stringAttr !== stringAttrReduced && _react2 . default . createElement (
2025-02-06 17:02:32 -06:00
'a' ,
{
role : 'button' ,
2025-02-07 09:48:25 -06:00
className : 'pvtButton' ,
2025-02-06 17:02:32 -06:00
onClick : function onClick ( ) {
2025-02-07 07:50:34 -06:00
_this2 . updateFilterOptions ( true ) ;
2025-02-06 17:02:32 -06:00
}
} ,
'Mostrar Todas las Opciones'
) ,
2025-02-07 09:56:20 -06:00
stringAttr !== stringAttrReduced && _react2 . default . createElement ( 'br' , null ) ,
2024-12-16 20:19:32 -06:00
_react2 . default . createElement ( 'input' , {
type : 'text' ,
2025-02-06 17:02:32 -06:00
placeholder : 'Filtrar Opciones' ,
2024-12-16 20:19:32 -06:00
className : 'pvtSearch' ,
value : this . state . filterText ,
onChange : function onChange ( e ) {
return _this2 . setState ( {
filterText : e . target . value
} ) ;
}
} ) ,
_react2 . default . createElement ( 'br' , null ) ,
_react2 . default . createElement (
'a' ,
{
role : 'button' ,
className : 'pvtButton' ,
onClick : function onClick ( ) {
2025-01-14 13:52:23 -06:00
_this2 . props . removeValuesFromFilter ( _this2 . props . name , Object . keys ( _this2 . props . attrValues ) . filter ( _this2 . matchesFilter . bind ( _this2 ) ) ) ;
2024-12-16 20:19:32 -06:00
}
} ,
2025-02-06 17:02:32 -06:00
'Seleccionar ' ,
values . length === shown . length ? 'Todo' : shown . length
2024-12-16 20:19:32 -06:00
) ,
' ' ,
_react2 . default . createElement (
'a' ,
{
role : 'button' ,
className : 'pvtButton' ,
onClick : function onClick ( ) {
return _this2 . props . addValuesToFilter ( _this2 . props . name , Object . keys ( _this2 . props . attrValues ) . filter ( _this2 . matchesFilter . bind ( _this2 ) ) ) ;
}
} ,
2025-02-06 17:02:32 -06:00
'Deseleccionar ' ,
values . length === shown . length ? 'Todo' : shown . length
2024-12-16 20:19:32 -06:00
)
) ,
2025-01-14 13:14:24 -06:00
_react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'div' ,
{ className : 'pvtCheckContainer' } ,
2025-01-14 13:29:07 -06:00
truncatedShown . map ( function ( x ) {
2024-12-16 20:19:32 -06:00
return _react2 . default . createElement (
'p' ,
{
key : x ,
onClick : function onClick ( ) {
return _this2 . toggleValue ( x ) ;
} ,
className : x in _this2 . props . valueFilter ? '' : 'selected'
} ,
_react2 . default . createElement (
'a' ,
{ className : 'pvtOnly' , onClick : function onClick ( e ) {
return _this2 . selectOnly ( e , x ) ;
} } ,
'only'
) ,
_react2 . default . createElement (
'a' ,
{ className : 'pvtOnlySpacer' } ,
'\xA0'
) ,
x === '' ? _react2 . default . createElement (
'em' ,
null ,
'null'
) : x
) ;
} )
)
)
) ;
}
} , {
key : 'toggleFilterBox' ,
value : function toggleFilterBox ( ) {
this . setState ( { open : ! this . state . open } ) ;
this . props . moveFilterBoxToTop ( this . props . name ) ;
2025-02-07 09:48:25 -06:00
this . updateFilterOptions ( ) ;
2024-12-16 20:19:32 -06:00
}
} , {
key : 'render' ,
value : function render ( ) {
var filtered = Object . keys ( this . props . valueFilter ) . length !== 0 ? 'pvtFilteredAttribute' : '' ;
return _react2 . default . createElement (
'li' ,
2025-01-29 12:44:45 -06:00
{ 'data-id' : this . props . name , title : this . props . name } ,
2024-12-16 20:19:32 -06:00
_react2 . default . createElement (
'span' ,
{ className : 'pvtAttr ' + filtered } ,
2025-01-29 12:44:45 -06:00
_react2 . default . createElement (
'span' ,
{ className : 'pvtAttrTitle' } ,
this . props . name
) ,
2024-12-16 20:19:32 -06:00
_react2 . default . createElement (
'span' ,
{
className : 'pvtTriangle' ,
onClick : this . toggleFilterBox . bind ( this )
} ,
' ' ,
'\u25BE'
)
) ,
this . state . open ? this . getFilterBox ( ) : null
) ;
}
} ] ) ;
return DraggableAttribute ;
} ( _react2 . default . Component ) ;
DraggableAttribute . defaultProps = {
valueFilter : { }
} ;
DraggableAttribute . propTypes = {
name : _propTypes2 . default . string . isRequired ,
addValuesToFilter : _propTypes2 . default . func . isRequired ,
removeValuesFromFilter : _propTypes2 . default . func . isRequired ,
attrValues : _propTypes2 . default . objectOf ( _propTypes2 . default . number ) . isRequired ,
valueFilter : _propTypes2 . default . objectOf ( _propTypes2 . default . bool ) ,
moveFilterBoxToTop : _propTypes2 . default . func . isRequired ,
sorter : _propTypes2 . default . func . isRequired ,
menuLimit : _propTypes2 . default . number ,
zIndex : _propTypes2 . default . number
} ;
var Dropdown = exports . Dropdown = function ( _React$PureComponent ) {
_inherits ( Dropdown , _React$PureComponent ) ;
function Dropdown ( ) {
_classCallCheck ( this , Dropdown ) ;
return _possibleConstructorReturn ( this , ( Dropdown . _ _proto _ _ || Object . getPrototypeOf ( Dropdown ) ) . apply ( this , arguments ) ) ;
}
_createClass ( Dropdown , [ {
key : 'render' ,
value : function render ( ) {
var _this4 = this ;
return _react2 . default . createElement (
'div' ,
{ className : 'pvtDropdown' , style : { zIndex : this . props . zIndex } } ,
_react2 . default . createElement (
'div' ,
{
onClick : function onClick ( e ) {
e . stopPropagation ( ) ;
_this4 . props . toggle ( ) ;
} ,
className : 'pvtDropdownValue pvtDropdownCurrent ' + ( this . props . open ? 'pvtDropdownCurrentOpen' : '' ) ,
role : 'button'
} ,
_react2 . default . createElement (
'div' ,
{ className : 'pvtDropdownIcon' } ,
this . props . open ? '× ' : '▾'
) ,
this . props . current || _react2 . default . createElement (
'span' ,
null ,
'\xA0'
)
) ,
this . props . open && _react2 . default . createElement (
'div' ,
{ className : 'pvtDropdownMenu' } ,
this . props . values . map ( function ( r ) {
return _react2 . default . createElement (
'div' ,
{
key : r ,
role : 'button' ,
onClick : function onClick ( e ) {
e . stopPropagation ( ) ;
if ( _this4 . props . current === r ) {
_this4 . props . toggle ( ) ;
} else {
_this4 . props . setValue ( r ) ;
}
} ,
className : 'pvtDropdownValue ' + ( r === _this4 . props . current ? 'pvtDropdownActiveValue' : '' )
} ,
r
) ;
} )
)
) ;
}
} ] ) ;
return Dropdown ;
} ( _react2 . default . PureComponent ) ;
var PivotTableUI = function ( _React$PureComponent2 ) {
_inherits ( PivotTableUI , _React$PureComponent2 ) ;
function PivotTableUI ( props ) {
_classCallCheck ( this , PivotTableUI ) ;
var _this5 = _possibleConstructorReturn ( this , ( PivotTableUI . _ _proto _ _ || Object . getPrototypeOf ( PivotTableUI ) ) . call ( this , props ) ) ;
_this5 . state = {
unusedOrder : [ ] ,
zIndices : { } ,
maxZIndex : 1000 ,
openDropdown : false ,
attrValues : { } ,
2024-12-17 11:59:45 -06:00
materializedInput : [ ] ,
2024-12-20 16:45:50 -06:00
hideConfiguration : false ,
2025-02-17 07:27:18 -06:00
showSubtotales : false ,
2024-12-20 16:45:50 -06:00
headerClass : '' ,
stylesHeaders : { }
2024-12-16 20:19:32 -06:00
} ;
return _this5 ;
}
_createClass ( PivotTableUI , [ {
key : 'componentDidMount' ,
value : function componentDidMount ( ) {
this . materializeInput ( this . props . data ) ;
}
} , {
2025-02-07 07:50:34 -06:00
key : 'getFilterOptions' ,
value : function getFilterOptions ( ) {
2025-02-06 17:02:32 -06:00
var showAll = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : false ;
if ( showAll ) {
2025-02-07 07:50:34 -06:00
var _attrValuesReduced2 = JSON . parse ( JSON . stringify ( this . state . attrValues ) ) ;
return _attrValuesReduced2 ;
2025-02-06 17:02:32 -06:00
}
2025-02-06 13:02:15 -06:00
var _valuefilter = this . props . valueFilter ;
var keysFilter = Object . keys ( _valuefilter ) ;
2025-02-06 12:53:06 -06:00
var filteredData = this . props . data . filter ( function ( row ) {
if ( typeof _valuefilter !== 'undefined' && _valuefilter !== null ) {
2025-02-06 15:09:53 -06:00
for ( var idx = 0 ; idx < keysFilter . length ; idx ++ ) {
var keyF = keysFilter [ idx ] ;
2025-02-06 12:53:06 -06:00
var valsFilter = Object . keys ( _valuefilter [ keyF ] ) ;
2025-02-06 15:09:53 -06:00
for ( var idy = 0 ; idy < valsFilter . length ; idy ++ ) {
var valF = valsFilter [ idy ] ;
2025-02-06 13:11:34 -06:00
if ( typeof row [ keyF ] === 'number' && row [ keyF ] === parseFloat ( valF ) ) {
return false ;
} else if ( String ( row [ keyF ] ) === String ( valF ) ) {
2025-02-06 12:53:06 -06:00
return false ;
}
2025-02-06 15:09:53 -06:00
}
}
2025-02-06 12:53:06 -06:00
}
return true ;
} ) ;
2025-02-07 07:50:34 -06:00
var _attrValuesReduced = { } ;
2025-02-06 17:02:32 -06:00
var recordsProcessed = 0 ;
_Utilities . PivotData . forEachRecord ( filteredData , this . props . derivedAttributes , function ( record ) {
var _iteratorNormalCompletion = true ;
var _didIteratorError = false ;
var _iteratorError = undefined ;
try {
for ( var _iterator = Object . keys ( record ) [ Symbol . iterator ] ( ) , _step ; ! ( _iteratorNormalCompletion = ( _step = _iterator . next ( ) ) . done ) ; _iteratorNormalCompletion = true ) {
var attr = _step . value ;
2025-02-07 07:50:34 -06:00
if ( ! ( attr in _attrValuesReduced ) ) {
_attrValuesReduced [ attr ] = { } ;
2025-02-06 17:02:32 -06:00
if ( recordsProcessed > 0 ) {
2025-02-07 07:50:34 -06:00
_attrValuesReduced [ attr ] . null = recordsProcessed ;
2025-02-06 17:02:32 -06:00
}
}
}
} catch ( err ) {
_didIteratorError = true ;
_iteratorError = err ;
} finally {
try {
if ( ! _iteratorNormalCompletion && _iterator . return ) {
_iterator . return ( ) ;
}
} finally {
if ( _didIteratorError ) {
throw _iteratorError ;
}
}
}
2025-02-07 07:50:34 -06:00
for ( var _attr in _attrValuesReduced ) {
2025-02-06 17:02:32 -06:00
var value = _attr in record ? record [ _attr ] : 'null' ;
2025-02-07 07:50:34 -06:00
if ( ! ( value in _attrValuesReduced [ _attr ] ) ) {
_attrValuesReduced [ _attr ] [ value ] = 0 ;
2025-02-06 17:02:32 -06:00
}
2025-02-07 07:50:34 -06:00
_attrValuesReduced [ _attr ] [ value ] ++ ;
2025-02-06 17:02:32 -06:00
}
recordsProcessed ++ ;
} ) ;
2025-02-07 07:50:34 -06:00
return _attrValuesReduced ;
2025-02-06 17:02:32 -06:00
}
} , {
key : 'componentDidUpdate' ,
value : function componentDidUpdate ( ) {
2024-12-16 20:19:32 -06:00
this . materializeInput ( this . props . data ) ;
}
} , {
key : 'materializeInput' ,
value : function materializeInput ( nextData ) {
if ( this . state . data === nextData ) {
return ;
}
var newState = {
data : nextData ,
attrValues : { } ,
2025-02-17 07:51:51 -06:00
materializedInput : [ ]
2024-12-16 20:19:32 -06:00
} ;
var recordsProcessed = 0 ;
_Utilities . PivotData . forEachRecord ( newState . data , this . props . derivedAttributes , function ( record ) {
newState . materializedInput . push ( record ) ;
2025-02-06 17:02:32 -06:00
var _iteratorNormalCompletion2 = true ;
var _didIteratorError2 = false ;
var _iteratorError2 = undefined ;
2024-12-16 20:19:32 -06:00
try {
2025-02-06 17:02:32 -06:00
for ( var _iterator2 = Object . keys ( record ) [ Symbol . iterator ] ( ) , _step2 ; ! ( _iteratorNormalCompletion2 = ( _step2 = _iterator2 . next ( ) ) . done ) ; _iteratorNormalCompletion2 = true ) {
var attr = _step2 . value ;
2024-12-16 20:19:32 -06:00
if ( ! ( attr in newState . attrValues ) ) {
newState . attrValues [ attr ] = { } ;
if ( recordsProcessed > 0 ) {
newState . attrValues [ attr ] . null = recordsProcessed ;
}
}
}
} catch ( err ) {
2025-02-06 17:02:32 -06:00
_didIteratorError2 = true ;
_iteratorError2 = err ;
2024-12-16 20:19:32 -06:00
} finally {
try {
2025-02-06 17:02:32 -06:00
if ( ! _iteratorNormalCompletion2 && _iterator2 . return ) {
_iterator2 . return ( ) ;
2024-12-16 20:19:32 -06:00
}
} finally {
2025-02-06 17:02:32 -06:00
if ( _didIteratorError2 ) {
throw _iteratorError2 ;
2024-12-16 20:19:32 -06:00
}
}
}
2025-02-06 17:02:32 -06:00
for ( var _attr2 in newState . attrValues ) {
var value = _attr2 in record ? record [ _attr2 ] : 'null' ;
if ( ! ( value in newState . attrValues [ _attr2 ] ) ) {
newState . attrValues [ _attr2 ] [ value ] = 0 ;
2024-12-16 20:19:32 -06:00
}
2025-02-06 17:02:32 -06:00
newState . attrValues [ _attr2 ] [ value ] ++ ;
2024-12-16 20:19:32 -06:00
}
recordsProcessed ++ ;
} ) ;
this . setState ( newState ) ;
}
} , {
key : 'sendPropUpdate' ,
value : function sendPropUpdate ( command ) {
this . props . onChange ( ( 0 , _immutabilityHelper2 . default ) ( this . props , command ) ) ;
}
} , {
key : 'propUpdater' ,
value : function propUpdater ( key ) {
2025-02-06 13:02:15 -06:00
var _this6 = this ;
2024-12-16 20:19:32 -06:00
return function ( value ) {
2025-02-06 13:02:15 -06:00
return _this6 . sendPropUpdate ( _defineProperty ( { } , key , { $set : value } ) ) ;
2024-12-16 20:19:32 -06:00
} ;
}
} , {
key : 'setValuesInFilter' ,
value : function setValuesInFilter ( attribute , values ) {
this . sendPropUpdate ( {
valueFilter : _defineProperty ( { } , attribute , {
$set : values . reduce ( function ( r , v ) {
r [ v ] = true ;
return r ;
} , { } )
} )
} ) ;
}
} , {
key : 'addValuesToFilter' ,
value : function addValuesToFilter ( attribute , values ) {
if ( attribute in this . props . valueFilter ) {
this . sendPropUpdate ( {
valueFilter : _defineProperty ( { } , attribute , values . reduce ( function ( r , v ) {
r [ v ] = { $set : true } ;
return r ;
} , { } ) )
} ) ;
} else {
this . setValuesInFilter ( attribute , values ) ;
}
}
} , {
key : 'removeValuesFromFilter' ,
value : function removeValuesFromFilter ( attribute , values ) {
2025-01-14 14:06:29 -06:00
if ( ! this . props . valueFilter [ attribute ] ) {
return ;
}
2024-12-16 20:19:32 -06:00
this . sendPropUpdate ( {
valueFilter : _defineProperty ( { } , attribute , { $unset : values } )
} ) ;
}
} , {
key : 'moveFilterBoxToTop' ,
value : function moveFilterBoxToTop ( attribute ) {
this . setState ( ( 0 , _immutabilityHelper2 . default ) ( this . state , {
maxZIndex : { $set : this . state . maxZIndex + 1 } ,
zIndices : _defineProperty ( { } , attribute , { $set : this . state . maxZIndex + 1 } )
} ) ) ;
}
} , {
key : 'isOpen' ,
value : function isOpen ( dropdown ) {
return this . state . openDropdown === dropdown ;
}
} , {
key : 'makeDnDCell' ,
2025-02-14 15:37:26 -06:00
value : function makeDnDCell ( items , _onChange , classes , headSlot ) {
2025-02-06 13:02:15 -06:00
var _this7 = this ;
2024-12-16 20:19:32 -06:00
2025-02-14 15:37:26 -06:00
var onChange = function onChange ( newArr ) {
var _resultArr = newArr . filter ( function ( item ) {
return item !== '[:sub-total:]' ;
} ) ;
_onChange ( _resultArr ) ;
} ;
2024-12-16 20:19:32 -06:00
return _react2 . default . createElement (
_reactSortablejs2 . default ,
{
options : {
group : 'shared' ,
ghostClass : 'pvtPlaceholder' ,
2025-02-14 15:37:26 -06:00
filter : '.pvtFilterBox, .pvtSubtotalCheck' ,
2024-12-16 20:19:32 -06:00
preventOnFilter : false
} ,
tag : 'td' ,
className : classes ,
2024-12-20 15:20:21 -06:00
onChange : onChange
2024-12-16 20:19:32 -06:00
} ,
2025-02-14 16:07:53 -06:00
headSlot && typeof headSlot === 'function' && items . length > 1 && headSlot ( ) ,
2024-12-16 20:19:32 -06:00
items . map ( function ( x ) {
return _react2 . default . createElement ( DraggableAttribute , {
name : x ,
key : x ,
2025-02-17 07:38:37 -06:00
attrValues : _this7 . state . attrValues [ x ] || { } ,
2025-02-06 13:02:15 -06:00
valueFilter : _this7 . props . valueFilter [ x ] || { } ,
sorter : ( 0 , _Utilities . getSort ) ( _this7 . props . sorters , x ) ,
menuLimit : _this7 . props . menuLimit ,
setValuesInFilter : _this7 . setValuesInFilter . bind ( _this7 ) ,
addValuesToFilter : _this7 . addValuesToFilter . bind ( _this7 ) ,
moveFilterBoxToTop : _this7 . moveFilterBoxToTop . bind ( _this7 ) ,
removeValuesFromFilter : _this7 . removeValuesFromFilter . bind ( _this7 ) ,
2025-02-06 17:02:32 -06:00
zIndex : _this7 . state . zIndices [ x ] || _this7 . state . maxZIndex ,
2025-02-07 07:50:34 -06:00
getFilterOptions : _this7 . getFilterOptions . bind ( _this7 )
2024-12-16 20:19:32 -06:00
} ) ;
} )
) ;
}
} , {
key : 'render' ,
value : function render ( ) {
2025-02-06 13:02:15 -06:00
var _this8 = this ;
2024-12-16 20:19:32 -06:00
var numValsAllowed = this . props . aggregators [ this . props . aggregatorName ] ( [ ] ) ( ) . numInputs || 0 ;
var aggregatorCellOutlet = this . props . aggregators [ this . props . aggregatorName ] ( [ ] ) ( ) . outlet ;
var rendererName = this . props . rendererName in this . props . renderers ? this . props . rendererName : Object . keys ( this . props . renderers ) [ 0 ] ;
var rendererCell = _react2 . default . createElement (
'td' ,
{ className : 'pvtRenderers' } ,
_react2 . default . createElement ( Dropdown , {
current : rendererName ,
values : Object . keys ( this . props . renderers ) ,
open : this . isOpen ( 'renderer' ) ,
zIndex : this . isOpen ( 'renderer' ) ? this . state . maxZIndex + 1 : 1 ,
toggle : function toggle ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( {
openDropdown : _this8 . isOpen ( 'renderer' ) ? false : 'renderer'
2024-12-16 20:19:32 -06:00
} ) ;
} ,
setValue : this . propUpdater ( 'rendererName' )
} )
) ;
var sortIcons = {
key _a _to _z : {
rowSymbol : '↕' ,
colSymbol : '↔' ,
next : 'value_a_to_z'
} ,
value _a _to _z : {
rowSymbol : '↓' ,
colSymbol : '→' ,
next : 'value_z_to_a'
} ,
value _z _to _a : { rowSymbol : '↑' , colSymbol : '←' , next : 'key_a_to_z' }
} ;
var aggregatorCell = _react2 . default . createElement (
'td' ,
{ className : 'pvtVals' } ,
_react2 . default . createElement ( Dropdown , {
current : this . props . aggregatorName ,
values : Object . keys ( this . props . aggregators ) ,
open : this . isOpen ( 'aggregators' ) ,
zIndex : this . isOpen ( 'aggregators' ) ? this . state . maxZIndex + 1 : 1 ,
toggle : function toggle ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( {
openDropdown : _this8 . isOpen ( 'aggregators' ) ? false : 'aggregators'
2024-12-16 20:19:32 -06:00
} ) ;
} ,
setValue : this . propUpdater ( 'aggregatorName' )
} ) ,
_react2 . default . createElement (
'a' ,
{
role : 'button' ,
className : 'pvtRowOrder' ,
onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . propUpdater ( 'rowOrder' ) ( sortIcons [ _this8 . props . rowOrder ] . next ) ;
2024-12-16 20:19:32 -06:00
}
} ,
sortIcons [ this . props . rowOrder ] . rowSymbol
) ,
_react2 . default . createElement (
'a' ,
{
role : 'button' ,
className : 'pvtColOrder' ,
onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . propUpdater ( 'colOrder' ) ( sortIcons [ _this8 . props . colOrder ] . next ) ;
2024-12-16 20:19:32 -06:00
}
} ,
sortIcons [ this . props . colOrder ] . colSymbol
) ,
numValsAllowed > 0 && _react2 . default . createElement ( 'br' , null ) ,
new Array ( numValsAllowed ) . fill ( ) . map ( function ( n , i ) {
return [ _react2 . default . createElement ( Dropdown , {
key : i ,
2025-02-06 13:02:15 -06:00
current : _this8 . props . vals [ i ] ,
values : Object . keys ( _this8 . state . attrValues ) . filter ( function ( e ) {
return ! _this8 . props . hiddenAttributes . includes ( e ) && ! _this8 . props . hiddenFromAggregators . includes ( e ) ;
2024-12-16 20:19:32 -06:00
} ) ,
2025-02-06 13:02:15 -06:00
open : _this8 . isOpen ( 'val' + i ) ,
zIndex : _this8 . isOpen ( 'val' + i ) ? _this8 . state . maxZIndex + 1 : 1 ,
2024-12-16 20:19:32 -06:00
toggle : function toggle ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( {
openDropdown : _this8 . isOpen ( 'val' + i ) ? false : 'val' + i
2024-12-16 20:19:32 -06:00
} ) ;
} ,
setValue : function setValue ( value ) {
2025-02-06 13:02:15 -06:00
return _this8 . sendPropUpdate ( {
2024-12-16 20:19:32 -06:00
vals : { $splice : [ [ i , 1 , value ] ] }
} ) ;
}
} ) , i + 1 !== numValsAllowed ? _react2 . default . createElement ( 'br' , { key : 'br' + i } ) : null ] ;
} ) ,
aggregatorCellOutlet && aggregatorCellOutlet ( this . props . data )
) ;
var unusedAttrs = Object . keys ( this . state . attrValues ) . filter ( function ( e ) {
2025-02-06 13:02:15 -06:00
return ! _this8 . props . rows . includes ( e ) && ! _this8 . props . cols . includes ( e ) && ! _this8 . props . hiddenAttributes . includes ( e ) && ! _this8 . props . hiddenFromDragDrop . includes ( e ) ;
2024-12-16 20:19:32 -06:00
} ) . sort ( ( 0 , _Utilities . sortAs ) ( this . state . unusedOrder ) ) ;
var unusedLength = unusedAttrs . reduce ( function ( r , e ) {
return r + e . length ;
} , 0 ) ;
var horizUnused = unusedLength < this . props . unusedOrientationCutoff ;
var unusedAttrsCell = this . makeDnDCell ( unusedAttrs , function ( order ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( { unusedOrder : order } ) ;
2024-12-16 20:19:32 -06:00
} , 'pvtAxisContainer pvtUnused ' + ( horizUnused ? 'pvtHorizList' : 'pvtVertList' ) ) ;
var colAttrs = this . props . cols . filter ( function ( e ) {
2025-02-06 13:02:15 -06:00
return ! _this8 . props . hiddenAttributes . includes ( e ) && ! _this8 . props . hiddenFromDragDrop . includes ( e ) ;
2024-12-16 20:19:32 -06:00
} ) ;
var colAttrsCell = this . makeDnDCell ( colAttrs , this . propUpdater ( 'cols' ) , 'pvtAxisContainer pvtHorizList pvtCols' ) ;
var rowAttrs = this . props . rows . filter ( function ( e ) {
2025-02-06 13:02:15 -06:00
return ! _this8 . props . hiddenAttributes . includes ( e ) && ! _this8 . props . hiddenFromDragDrop . includes ( e ) ;
2024-12-16 20:19:32 -06:00
} ) ;
2025-02-14 15:37:26 -06:00
var toggleSubTotales = function toggleSubTotales ( ) {
2025-02-17 07:27:18 -06:00
var _showSubt = _this8 . props . showSubtotales === true ? true : false ;
2025-02-14 15:45:38 -06:00
_this8 . propUpdater ( 'showSubtotales' ) ( ! _showSubt ) ;
2025-02-17 07:38:37 -06:00
// this.setState({ showSubtotales: !_showSubt })
2025-02-14 15:37:26 -06:00
} ;
2025-02-14 12:44:58 -06:00
var renderCheckSubtotal = function renderCheckSubtotal ( ) {
return _react2 . default . createElement (
'li' ,
2025-02-14 15:37:26 -06:00
{ className : 'pvtSubtotalCheck cursor-default' , 'data-id' : '[:sub-total:]' } ,
2025-02-14 12:44:58 -06:00
_react2 . default . createElement (
'span' ,
{ className : 'pvtAttr' } ,
_react2 . default . createElement (
'span' ,
{ className : 'pvtAttrTitle' } ,
2025-02-14 15:37:26 -06:00
'Subtotales'
) ,
_react2 . default . createElement ( 'input' , {
type : 'checkbox' ,
2025-02-17 07:57:07 -06:00
checked : _this8 . props . showSubtotales === true ,
2025-02-14 15:37:26 -06:00
className : 'via-checkbox h-5 w-5 cursor-pointer' ,
2025-02-14 16:07:53 -06:00
onChange : function onChange ( ) {
2025-02-14 15:37:26 -06:00
toggleSubTotales ( ) ;
}
} )
2025-02-14 12:44:58 -06:00
)
) ;
} ;
var rowAttrsCell = this . makeDnDCell ( rowAttrs , this . propUpdater ( 'rows' ) , 'pvtAxisContainer pvtVertList pvtRows' , renderCheckSubtotal ) ;
2024-12-16 20:19:32 -06:00
var outputCell = _react2 . default . createElement (
'td' ,
{ className : 'pvtOutput' } ,
_react2 . default . createElement ( _PivotTable2 . default , ( 0 , _immutabilityHelper2 . default ) ( this . props , {
data : { $set : this . state . materializedInput }
} ) )
) ;
2024-12-17 15:41:48 -06:00
if ( this . props . hideConfiguration ) {
2024-12-17 08:44:26 -06:00
return _react2 . default . createElement (
'table' ,
{ className : 'pvtUi' } ,
_react2 . default . createElement (
'tbody' ,
{ onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( { openDropdown : false } ) ;
2024-12-17 08:44:26 -06:00
} } ,
_react2 . default . createElement (
'tr' ,
null ,
outputCell
)
)
) ;
}
2024-12-16 20:19:32 -06:00
if ( horizUnused ) {
return _react2 . default . createElement (
'table' ,
{ className : 'pvtUi' } ,
2024-12-17 15:41:48 -06:00
this . props . hideConfiguration && _react2 . default . createElement (
2024-12-17 11:37:22 -06:00
'tbody' ,
{ onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( { openDropdown : false } ) ;
2024-12-17 11:37:22 -06:00
} } ,
_react2 . default . createElement (
'tr' ,
null ,
outputCell
)
) ,
2024-12-17 15:41:48 -06:00
! this . props . hideConfiguration && _react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'tbody' ,
{ onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( { openDropdown : false } ) ;
2024-12-16 20:19:32 -06:00
} } ,
2024-12-17 08:44:26 -06:00
_react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'tr' ,
null ,
rendererCell ,
unusedAttrsCell
) ,
2024-12-17 08:44:26 -06:00
_react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'tr' ,
null ,
aggregatorCell ,
colAttrsCell
) ,
_react2 . default . createElement (
'tr' ,
null ,
2024-12-17 08:44:26 -06:00
rowAttrsCell ,
2024-12-16 20:19:32 -06:00
outputCell
)
)
) ;
}
return _react2 . default . createElement (
'table' ,
{ className : 'pvtUi' } ,
2024-12-17 15:41:48 -06:00
this . props . hideConfiguration && _react2 . default . createElement (
2024-12-17 11:37:22 -06:00
'tbody' ,
{ onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( { openDropdown : false } ) ;
2024-12-17 11:37:22 -06:00
} } ,
_react2 . default . createElement (
'tr' ,
null ,
outputCell
)
) ,
2024-12-17 15:41:48 -06:00
! this . props . hideConfiguration && _react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'tbody' ,
{ onClick : function onClick ( ) {
2025-02-06 13:02:15 -06:00
return _this8 . setState ( { openDropdown : false } ) ;
2024-12-16 20:19:32 -06:00
} } ,
2024-12-17 08:44:26 -06:00
_react2 . default . createElement (
2024-12-16 20:19:32 -06:00
'tr' ,
null ,
rendererCell ,
aggregatorCell ,
colAttrsCell
) ,
_react2 . default . createElement (
'tr' ,
null ,
2024-12-17 08:44:26 -06:00
unusedAttrsCell ,
rowAttrsCell ,
2024-12-16 20:19:32 -06:00
outputCell
)
)
) ;
}
} ] ) ;
return PivotTableUI ;
} ( _react2 . default . PureComponent ) ;
PivotTableUI . propTypes = Object . assign ( { } , _PivotTable2 . default . propTypes , {
onChange : _propTypes2 . default . func . isRequired ,
hiddenAttributes : _propTypes2 . default . arrayOf ( _propTypes2 . default . string ) ,
hiddenFromAggregators : _propTypes2 . default . arrayOf ( _propTypes2 . default . string ) ,
hiddenFromDragDrop : _propTypes2 . default . arrayOf ( _propTypes2 . default . string ) ,
unusedOrientationCutoff : _propTypes2 . default . number ,
2024-12-17 15:41:48 -06:00
menuLimit : _propTypes2 . default . number ,
2024-12-20 16:45:50 -06:00
hideConfiguration : _propTypes2 . default . bool ,
2025-02-14 16:07:53 -06:00
showSubtotales : _propTypes2 . default . bool ,
2024-12-20 16:45:50 -06:00
headerClass : _propTypes2 . default . string ,
stylesHeaders : _propTypes2 . default . object
2024-12-16 20:19:32 -06:00
} ) ;
PivotTableUI . defaultProps = Object . assign ( { } , _PivotTable2 . default . defaultProps , {
hiddenAttributes : [ ] ,
hiddenFromAggregators : [ ] ,
hiddenFromDragDrop : [ ] ,
unusedOrientationCutoff : 85 ,
2024-12-17 15:41:48 -06:00
menuLimit : 500 ,
2025-02-14 16:07:53 -06:00
hideConfiguration : true ,
2025-02-14 16:17:18 -06:00
showSubtotales : false
2024-12-16 20:19:32 -06:00
} ) ;
exports . default = PivotTableUI ;
//# sourceMappingURL=PivotTableUI.js.map