@entur-partner/legacy
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -6,2 +6,6 @@ # Change Log | ||
## [1.0.4](https://bitbucket.org/enturas/entur-partner-packages/compare/@entur-partner/legacy@1.0.3...@entur-partner/legacy@1.0.4) (2022-02-10) | ||
**Note:** Version bump only for package @entur-partner/legacy | ||
## [1.0.3](https://bitbucket.org/enturas/entur-partner-packages/compare/@entur-partner/legacy@1.0.2...@entur-partner/legacy@1.0.3) (2022-02-07) | ||
@@ -8,0 +12,0 @@ |
@@ -5,8 +5,5 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var cx = _interopDefault(require('classnames')); | ||
var PropTypes = require('prop-types'); | ||
var cx = require('classnames'); | ||
var icons = require('@entur/icons'); | ||
@@ -17,2 +14,8 @@ var legacy = require('@entur-partner/legacy'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx); | ||
function _extends() { | ||
@@ -39,5 +42,15 @@ _extends = Object.assign || function (target) { | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
@@ -103,3 +116,3 @@ if (source == null) return {}; | ||
style = _this$props.style; | ||
var classNames = cx('popover', className); | ||
var classNames = cx__default["default"]('popover', className); | ||
@@ -110,3 +123,3 @@ if (!open) { | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
style: style, | ||
@@ -121,6 +134,6 @@ className: classNames, | ||
Popover.propTypes = { | ||
open: PropTypes.bool.isRequired, | ||
onRequestClose: PropTypes.func, | ||
style: PropTypes.object, | ||
className: PropTypes.string | ||
open: PropTypes__default["default"].bool.isRequired, | ||
onRequestClose: PropTypes__default["default"].func, | ||
style: PropTypes__default["default"].object, | ||
className: PropTypes__default["default"].string | ||
}; | ||
@@ -142,4 +155,4 @@ | ||
style = _this$props.style; | ||
var classNames = cx('menu', className); | ||
return /*#__PURE__*/React__default.createElement("div", _extends({ | ||
var classNames = cx__default["default"]('menu', className); | ||
return /*#__PURE__*/React__default["default"].createElement("div", _extends({ | ||
className: classNames | ||
@@ -196,3 +209,3 @@ }, style), children); | ||
var handleOnClick = hasMenuItems ? this.toggleActive : onClick; | ||
var menuItemClasses = cx('menu-item', { | ||
var menuItemClasses = cx__default["default"]('menu-item', { | ||
active: active, | ||
@@ -211,6 +224,6 @@ disabled: disabled, | ||
}; | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
"data-testid": "menu-item-wrapper", | ||
className: "menu-item-wrapper" | ||
}, /*#__PURE__*/React__default.createElement("div", { | ||
}, /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: menuItemClasses, | ||
@@ -225,5 +238,5 @@ onClick: handleOnClick, | ||
} | ||
}, children, hasMenuItems && /*#__PURE__*/React__default.createElement(icons.RightArrowIcon, { | ||
}, children, hasMenuItems && /*#__PURE__*/React__default["default"].createElement(icons.RightArrowIcon, { | ||
size: 16 | ||
})), showSubItems && /*#__PURE__*/React__default.createElement("div", { | ||
})), showSubItems && /*#__PURE__*/React__default["default"].createElement("div", { | ||
style: childPositionStyle, | ||
@@ -237,6 +250,6 @@ className: "menu-item-nested" | ||
MenuItem.propTypes = { | ||
disabled: PropTypes.bool, | ||
onClick: PropTypes.func, | ||
menuItems: /*#__PURE__*/PropTypes.arrayOf(PropTypes.node), | ||
childrenLeft: PropTypes.bool | ||
disabled: PropTypes__default["default"].bool, | ||
onClick: PropTypes__default["default"].func, | ||
menuItems: /*#__PURE__*/PropTypes__default["default"].arrayOf(PropTypes__default["default"].node), | ||
childrenLeft: PropTypes__default["default"].bool | ||
}; | ||
@@ -248,3 +261,3 @@ MenuItem.defaultProps = { | ||
var Divider = function Divider(props) { | ||
return /*#__PURE__*/React__default.createElement("hr", _extends({}, props, { | ||
return /*#__PURE__*/React__default["default"].createElement("hr", _extends({}, props, { | ||
className: "divider" | ||
@@ -257,3 +270,3 @@ })); | ||
children = _ref.children; | ||
var childrenArray = React__default.Children.toArray(children); | ||
var childrenArray = React__default["default"].Children.toArray(children); | ||
var TableHeaderCells = childrenArray.filter(function (child) { | ||
@@ -265,7 +278,9 @@ return child.type.displayName === 'TableHeaderCell'; | ||
}); | ||
return /*#__PURE__*/React__default.createElement("table", { | ||
return /*#__PURE__*/React__default["default"].createElement("table", { | ||
className: className | ||
}, /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, TableHeaderCells)), /*#__PURE__*/React__default.createElement("tbody", null, TableRows)); | ||
}, /*#__PURE__*/React__default["default"].createElement("thead", null, /*#__PURE__*/React__default["default"].createElement("tr", null, TableHeaderCells)), /*#__PURE__*/React__default["default"].createElement("tbody", null, TableRows)); | ||
}; | ||
var _excluded$3 = ["children"]; | ||
var TableRow = /*#__PURE__*/function (_Component) { | ||
@@ -283,8 +298,8 @@ _inheritsLoose(TableRow, _Component); | ||
children = _this$props.children, | ||
rest = _objectWithoutPropertiesLoose(_this$props, ["children"]); | ||
rest = _objectWithoutPropertiesLoose(_this$props, _excluded$3); | ||
var Cells = React__default.Children.toArray(children).filter(function (child) { | ||
var Cells = React__default["default"].Children.toArray(children).filter(function (child) { | ||
return child.type.displayName === 'TableRowCell'; | ||
}); | ||
return /*#__PURE__*/React__default.createElement("tr", rest, Cells); | ||
return /*#__PURE__*/React__default["default"].createElement("tr", rest, Cells); | ||
}; | ||
@@ -298,5 +313,5 @@ | ||
var RadioButton = function RadioButton(props) { | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: "radio-button-icon" | ||
}, props.checked && /*#__PURE__*/React__default.createElement("div", { | ||
}, props.checked && /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: "checked" | ||
@@ -306,7 +321,7 @@ })); | ||
PropTypes.defaultProps = { | ||
PropTypes__default["default"].defaultProps = { | ||
checked: false | ||
}; | ||
PropTypes.propTypes = { | ||
checked: PropTypes.bool | ||
PropTypes__default["default"].propTypes = { | ||
checked: PropTypes__default["default"].bool | ||
}; | ||
@@ -330,17 +345,17 @@ | ||
var sortConfigProps = /*#__PURE__*/PropTypes.shape({ | ||
type: /*#__PURE__*/PropTypes.oneOf( /*#__PURE__*/getTypes()), | ||
fieldName: PropTypes.string, | ||
direction: /*#__PURE__*/PropTypes.oneOf( /*#__PURE__*/getSortDirectionValues()), | ||
onSort: PropTypes.func, | ||
isSorting: PropTypes.bool | ||
var sortConfigProps = /*#__PURE__*/PropTypes__default["default"].shape({ | ||
type: /*#__PURE__*/PropTypes__default["default"].oneOf( /*#__PURE__*/getTypes()), | ||
fieldName: PropTypes__default["default"].string, | ||
direction: /*#__PURE__*/PropTypes__default["default"].oneOf( /*#__PURE__*/getSortDirectionValues()), | ||
onSort: PropTypes__default["default"].func, | ||
isSorting: PropTypes__default["default"].bool | ||
}); | ||
var filterConfigProps = /*#__PURE__*/PropTypes.shape({ | ||
filterMap: PropTypes.object.isRequired, | ||
fieldName: PropTypes.string, | ||
onFilter: PropTypes.func, | ||
onClearFilter: PropTypes.func, | ||
dataSource: /*#__PURE__*/PropTypes.arrayOf( /*#__PURE__*/PropTypes.shape({ | ||
value: PropTypes.string.isRequired, | ||
label: PropTypes.string.isRequired | ||
var filterConfigProps = /*#__PURE__*/PropTypes__default["default"].shape({ | ||
filterMap: PropTypes__default["default"].object.isRequired, | ||
fieldName: PropTypes__default["default"].string, | ||
onFilter: PropTypes__default["default"].func, | ||
onClearFilter: PropTypes__default["default"].func, | ||
dataSource: /*#__PURE__*/PropTypes__default["default"].arrayOf( /*#__PURE__*/PropTypes__default["default"].shape({ | ||
value: PropTypes__default["default"].string.isRequired, | ||
label: PropTypes__default["default"].string.isRequired | ||
})) | ||
@@ -366,3 +381,3 @@ }); | ||
var i18n = simpleFormat(this.props.intl.formatMessage); | ||
return /*#__PURE__*/React__default.createElement(WrappedComponent, _extends({ | ||
return /*#__PURE__*/React__default["default"].createElement(WrappedComponent, _extends({ | ||
i18n: i18n | ||
@@ -391,2 +406,4 @@ }, this.props)); | ||
var _excluded$2 = ["filterConfig", "sortConfig"]; | ||
var hasFilter = function hasFilter(fieldName, filterMap) { | ||
@@ -451,3 +468,3 @@ if (!filterMap) { | ||
if (fieldHasFilters(filterConfig) && onClearFilter) { | ||
return /*#__PURE__*/React__default.createElement(legacy.MenuItem, { | ||
return /*#__PURE__*/React__default["default"].createElement(legacy.MenuItem, { | ||
onClick: function onClick() { | ||
@@ -489,3 +506,3 @@ return onClearFilter(fieldName); | ||
var isChecked = !filterMap[fieldName] ? false : (filterMap[fieldName] || []).indexOf(item.value) > -1; | ||
return /*#__PURE__*/React__default.createElement(legacy.MenuItem, { | ||
return /*#__PURE__*/React__default["default"].createElement(legacy.MenuItem, { | ||
key: item.value, | ||
@@ -495,5 +512,5 @@ onClick: function onClick() { | ||
} | ||
}, /*#__PURE__*/React__default.createElement("div", { | ||
}, /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: "icon-container" | ||
}, /*#__PURE__*/React__default.createElement(form.Checkbox, { | ||
}, /*#__PURE__*/React__default["default"].createElement(form.Checkbox, { | ||
checked: isChecked, | ||
@@ -506,3 +523,3 @@ className: "menu-item-checkbox", | ||
}); | ||
return /*#__PURE__*/React__default.createElement(legacy.MenuItem, { | ||
return /*#__PURE__*/React__default["default"].createElement(legacy.MenuItem, { | ||
menuItems: filterOptions | ||
@@ -530,3 +547,3 @@ }, this.props.i18n('sorting.filter_by')); | ||
return /*#__PURE__*/React__default.createElement(legacy.MenuItem, { | ||
return /*#__PURE__*/React__default["default"].createElement(legacy.MenuItem, { | ||
key: itemDirection, | ||
@@ -536,5 +553,5 @@ onClick: function onClick() { | ||
} | ||
}, /*#__PURE__*/React__default.createElement("div", { | ||
}, /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: "icon-container" | ||
}, /*#__PURE__*/React__default.createElement(RadioButton, { | ||
}, /*#__PURE__*/React__default["default"].createElement(RadioButton, { | ||
checked: isChecked | ||
@@ -548,3 +565,3 @@ })), _this2.props.i18n(messageId)); | ||
sortConfig = props.sortConfig, | ||
restProps = _objectWithoutPropertiesLoose(props, ["filterConfig", "sortConfig"]); | ||
restProps = _objectWithoutPropertiesLoose(props, _excluded$2); | ||
@@ -555,5 +572,5 @@ var sortMenuItems = this.getSortMenuItems(sortConfig); | ||
var ClearFiltersMenuItem = this.getClearFiltersMenuItem(filterConfig); | ||
return /*#__PURE__*/React__default.createElement(legacy.Menu, _extends({ | ||
return /*#__PURE__*/React__default["default"].createElement(legacy.Menu, _extends({ | ||
className: "sort-filter-menu" | ||
}, restProps), sortMenuItems, showDivider && /*#__PURE__*/React__default.createElement(legacy.Divider, null), filterMenu, ClearFiltersMenuItem); | ||
}, restProps), sortMenuItems, showDivider && /*#__PURE__*/React__default["default"].createElement(legacy.Divider, null), filterMenu, ClearFiltersMenuItem); | ||
}; | ||
@@ -574,12 +591,12 @@ | ||
var direction = sortConfig ? sortConfig.direction : null; | ||
var arrowClassNames = cx('arrow', { | ||
var arrowClassNames = cx__default["default"]('arrow', { | ||
hidden: !isSorting | ||
}); | ||
var showFilterIcon = fieldHasFilters(this.props.filterConfig); | ||
return /*#__PURE__*/React__default.createElement("div", { | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
onBlur: this.handleCollapse, | ||
tabIndex: 0 | ||
}, /*#__PURE__*/React__default.createElement("div", { | ||
}, /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: "sort-filter-arrow" | ||
}, showFilterIcon && /*#__PURE__*/React__default.createElement("svg", { | ||
}, showFilterIcon && /*#__PURE__*/React__default["default"].createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
@@ -590,12 +607,12 @@ height: 12, | ||
transform: "scale(1.7)" | ||
}, /*#__PURE__*/React__default.createElement("path", { | ||
}, /*#__PURE__*/React__default["default"].createElement("path", { | ||
d: "M4.66666667,8 L7.33333333,8 L7.33333333,6.66666667 L4.66666667,6.66666667 L4.66666667,8 Z M0,0 L0,1.33333333 L12,1.33333333 L12,0 L0,0 Z M2,4.66666667 L10,4.66666667 L10,3.33333333 L2,3.33333333 L2,4.66666667 Z", | ||
id: "Shape" | ||
})), isSorting && direction === SortDirection.ASC ? /*#__PURE__*/React__default.createElement(icons.UpwardIcon, { | ||
})), isSorting && direction === SortDirection.ASC ? /*#__PURE__*/React__default["default"].createElement(icons.UpwardIcon, { | ||
size: 20, | ||
className: arrowClassNames | ||
}) : /*#__PURE__*/React__default.createElement(icons.DownwardIcon, { | ||
}) : /*#__PURE__*/React__default["default"].createElement(icons.DownwardIcon, { | ||
size: 20, | ||
className: arrowClassNames | ||
}), /*#__PURE__*/React__default.createElement(icons.DownArrowIcon, { | ||
}), /*#__PURE__*/React__default["default"].createElement(icons.DownArrowIcon, { | ||
size: 20, | ||
@@ -609,3 +626,3 @@ onMouseDown: this.handleExpand | ||
PropTypes.propTypes = { | ||
PropTypes__default["default"].propTypes = { | ||
sortConfig: sortConfigProps, | ||
@@ -616,2 +633,4 @@ filterConfig: filterConfigProps | ||
var _excluded$1 = ["label", "filterConfig", "sortConfig", "mini"]; | ||
var TableHeaderCell = function TableHeaderCell(_ref) { | ||
@@ -622,6 +641,6 @@ var label = _ref.label, | ||
mini = _ref.mini, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["label", "filterConfig", "sortConfig", "mini"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1); | ||
var allowsUserInteraction = !!(sortConfig || filterConfig); | ||
var wrapperClassNames = cx({ | ||
var wrapperClassNames = cx__default["default"]({ | ||
mini: mini | ||
@@ -631,7 +650,7 @@ }); | ||
if (allowsUserInteraction) { | ||
return /*#__PURE__*/React__default.createElement("th", _extends({ | ||
return /*#__PURE__*/React__default["default"].createElement("th", _extends({ | ||
className: wrapperClassNames | ||
}, rest), /*#__PURE__*/React__default.createElement("div", { | ||
}, rest), /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: "sortable" | ||
}, label, /*#__PURE__*/React__default.createElement(TableHeaderFilter$1, { | ||
}, label, /*#__PURE__*/React__default["default"].createElement(TableHeaderFilter$1, { | ||
filterConfig: filterConfig, | ||
@@ -642,3 +661,3 @@ sortConfig: sortConfig | ||
return /*#__PURE__*/React__default.createElement("th", _extends({ | ||
return /*#__PURE__*/React__default["default"].createElement("th", _extends({ | ||
className: wrapperClassNames | ||
@@ -650,6 +669,6 @@ }, rest), label); | ||
TableHeaderCell.propTypes = { | ||
label: PropTypes.node, | ||
label: PropTypes__default["default"].node, | ||
sortConfig: sortConfigProps, | ||
filterConfig: filterConfigProps, | ||
mini: PropTypes.bool | ||
mini: PropTypes__default["default"].bool | ||
}; | ||
@@ -660,7 +679,9 @@ TableHeaderCell.defaultProps = { | ||
var _excluded = ["children"]; | ||
var TableRowCell = function TableRowCell(_ref) { | ||
var children = _ref.children, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["children"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
return /*#__PURE__*/React__default.createElement("td", rest, children); | ||
return /*#__PURE__*/React__default["default"].createElement("td", rest, children); | ||
}; | ||
@@ -667,0 +688,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=e(require("prop-types")),i=e(require("classnames")),o=require("@entur/icons"),a=require("@entur-partner/legacy"),l=require("@entur/form"),s=require("react-intl");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function p(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}var f=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).handleClickOutside=function(e){if(t.wrapperRef&&!t.wrapperRef.contains(e.target)){var n=t.props.onRequestClose;"function"==typeof n&&n(e)}},t.setWrapperRef=function(e){t.wrapperRef=e},t}u(t,e);var r=t.prototype;return r.componentDidMount=function(){document.addEventListener("click",this.handleClickOutside)},r.componentWillUnmount=function(){document.removeEventListener("click",this.handleClickOutside)},r.render=function(){var e=this.props,t=e.children,r=e.open,o=e.style,a=i("popover",e.className);return r?n.createElement("div",{style:o,className:a,ref:this.setWrapperRef},t):null},t}(t.Component);f.propTypes={open:r.bool.isRequired,onRequestClose:r.func,style:r.object,className:r.string};var m=function(e){function t(){return e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this.props,t=e.children,r=e.style,o=i("menu",e.className);return n.createElement("div",c({className:o},r),t)},t}(t.Component),d=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).state={active:!1,position:null},t.toggleActive=function(){t.setState((function(e){return{active:!e.active}}))},t}return u(t,e),t.prototype.render=function(){var e=this,t=this.props,r=t.children,a=t.menuItems,l=t.childrenLeft,s=this.state,c=s.active,u=s.position,p=a&&a.length>0,f=p&&c,m=p?this.toggleActive:t.onClick,d=i("menu-item",{active:c,disabled:t.disabled,"space-between":p,"bold-text":p}),h={left:(u?u.width+15:0)*(l?-1:1),bottom:u?u.top+Math.ceil(u.height/2)+12:0};return n.createElement("div",{"data-testid":"menu-item-wrapper",className:"menu-item-wrapper"},n.createElement("div",{className:d,onClick:m,ref:function(t){t&&null===u&&e.setState({position:t.getBoundingClientRect()})}},r,p&&n.createElement(o.RightArrowIcon,{size:16})),f&&n.createElement("div",{style:h,className:"menu-item-nested"},a))},t}(t.Component);d.propTypes={disabled:r.bool,onClick:r.func,menuItems:r.arrayOf(r.node),childrenLeft:r.bool},d.defaultProps={childrenLeft:!1};var h=function(e){function t(){return e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this.props,t=e.children,r=p(e,["children"]),i=n.Children.toArray(t).filter((function(e){return"TableRowCell"===e.type.displayName}));return n.createElement("tr",r,i)},t}(t.Component);h.displayName="TableRow";var v=function(e){return n.createElement("div",{className:"radio-button-icon"},e.checked&&n.createElement("div",{className:"checked"}))};r.defaultProps={checked:!1},r.propTypes={checked:r.bool};var g=Object.freeze({ASC:"ASC",DESC:"DESC"}),C=Object.freeze({STRING:"STRING",DATE:"DATE",NUMBER:"NUMBER"}),y=function(){return Object.values(g)},b=r.shape({type:r.oneOf(function(){return Object.values(C)}()),fieldName:r.string,direction:r.oneOf(y()),onSort:r.func,isSorting:r.bool}),E=r.shape({filterMap:r.object.isRequired,fieldName:r.string,onFilter:r.func,onClearFilter:r.func,dataSource:r.arrayOf(r.shape({value:r.string.isRequired,label:r.string.isRequired}))}),N=function(e){return e.displayName||e.name||"Component"};function w(e){return function(r){var i=function(t){function i(){return t.apply(this,arguments)||this}return u(i,t),i.prototype.render=function(){var t=e(this.props.intl.formatMessage);return n.createElement(r,c({i18n:t},this.props))},i}(t.Component);return i.WrappedComponent=r,i.displayName="WithI18n("+N(r)+")",s.injectIntl(i)}}var M=w((function(e){return function(t,n){return e({id:t},n)}})),I=function(e){return!!e&&!!(t=e.filterMap)&&(t[e.fieldName]||[]).length>0;var t},R=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).state={isOpen:!1},t.handleCollapse=function(){t.setState({isOpen:!1})},t.handleExpand=function(){t.setState({isOpen:!0})},t}u(t,e);var r=t.prototype;return r.getClearFiltersMenuItem=function(e){if(!e)return null;var t=e.onClearFilter,r=e.fieldName;return I(e)&&t?n.createElement(a.MenuItem,{onClick:function(){return t(r)}},this.props.i18n("common.clear_filters")):null},r.getMessageId=function(e,t){switch(e){case C.STRING:return t===g.ASC?"common.sorting.string_asc":"common.sorting.string_desc";case C.NUMBER:return t===g.ASC?"common.sorting.number_asc":"common.sorting.number_desc";case C.DATE:return t===g.ASC?"common.sorting.date_asc":"common.sorting.date_desc";default:return"common.sorting.invalid_parameter"}},r.getFilterMenu=function(e){if(!e)return[];var t=e.onFilter,r=e.fieldName,i=e.filterMap,o=e.dataSource.map((function(e){var o=!!i[r]&&(i[r]||[]).indexOf(e.value)>-1;return n.createElement(a.MenuItem,{key:e.value,onClick:function(){t(r,e.value)}},n.createElement("div",{className:"icon-container"},n.createElement(l.Checkbox,{checked:o,className:"menu-item-checkbox",onChange:function(){t(r,e.value)}})),e.label)}));return n.createElement(a.MenuItem,{menuItems:o},this.props.i18n("sorting.filter_by"))},r.getSortMenuItems=function(e){var t=this;if(!e)return[];var r=e.fieldName,i=e.direction,o=e.onSort,l=e.isSorting,s=e.type;return y().map((function(e){var c=e===i&&l,u=t.getMessageId(s,e);return n.createElement(a.MenuItem,{key:e,onClick:function(){o(r,e)}},n.createElement("div",{className:"icon-container"},n.createElement(v,{checked:c})),t.props.i18n(u))}))},r.renderMenu=function(e){var t=e.filterConfig,r=e.sortConfig,i=p(e,["filterConfig","sortConfig"]),o=this.getSortMenuItems(r),l=this.getFilterMenu(t),s=o.length>0&&t,u=this.getClearFiltersMenuItem(t);return n.createElement(a.Menu,c({className:"sort-filter-menu"},i),o,s&&n.createElement(a.Divider,null),l,u)},r.render=function(){var e=this.props,t=e.sortConfig;if(!t&&!e.filterConfig)return null;var r=this.state.isOpen?this.renderMenu(this.props):null,a=!!t&&t.isSorting,l=t?t.direction:null,s=i("arrow",{hidden:!a}),c=I(this.props.filterConfig);return n.createElement("div",{onBlur:this.handleCollapse,tabIndex:0},n.createElement("div",{className:"sort-filter-arrow"},c&&n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:12,width:8,viewBox:"0 0 12 8",transform:"scale(1.7)"},n.createElement("path",{d:"M4.66666667,8 L7.33333333,8 L7.33333333,6.66666667 L4.66666667,6.66666667 L4.66666667,8 Z M0,0 L0,1.33333333 L12,1.33333333 L12,0 L0,0 Z M2,4.66666667 L10,4.66666667 L10,3.33333333 L2,3.33333333 L2,4.66666667 Z",id:"Shape"})),n.createElement(a&&l===g.ASC?o.UpwardIcon:o.DownwardIcon,{size:20,className:s}),n.createElement(o.DownArrowIcon,{size:20,onMouseDown:this.handleExpand})),r)},t}(t.Component);r.propTypes={sortConfig:b,filterConfig:E};var S=M(R),O=function(e){var t=e.label,r=e.filterConfig,o=e.sortConfig,a=e.mini,l=p(e,["label","filterConfig","sortConfig","mini"]),s=!(!o&&!r),u=i({mini:a});return n.createElement("th",c({className:u},l),s?n.createElement("div",{className:"sortable"},t,n.createElement(S,{filterConfig:r,sortConfig:o})):t)};O.displayName="TableHeaderCell",O.propTypes={label:r.node,sortConfig:b,filterConfig:E,mini:r.bool},O.defaultProps={label:""};var k=function(e){var t=e.children,r=p(e,["children"]);return n.createElement("td",r,t)};k.displayName="TableRowCell",exports.Divider=function(e){return n.createElement("hr",c({},e,{className:"divider"}))},exports.Menu=m,exports.MenuItem=d,exports.Popover=f,exports.Table=function(e){var t=e.className,r=n.Children.toArray(e.children),i=r.filter((function(e){return"TableHeaderCell"===e.type.displayName})),o=r.filter((function(e){return"TableRow"===e.type.displayName}));return n.createElement("table",{className:t},n.createElement("thead",null,n.createElement("tr",null,i)),n.createElement("tbody",null,o))},exports.TableHeaderCell=O,exports.TableRow=h,exports.TableRowCell=k,exports.componentDisplayName=N,exports.createWithI18n=w; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("prop-types"),n=require("classnames"),r=require("@entur/icons"),a=require("@entur-partner/legacy"),l=require("@entur/form"),i=require("react-intl");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(e),c=o(t),s=o(n);function f(){return f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f.apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t)}function p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(e,t)}function m(e,t){if(null==e)return{};var n,r,a={},l=Object.keys(e);for(r=0;r<l.length;r++)t.indexOf(n=l[r])>=0||(a[n]=e[n]);return a}var h=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).handleClickOutside=function(e){if(t.wrapperRef&&!t.wrapperRef.contains(e.target)){var n=t.props.onRequestClose;"function"==typeof n&&n(e)}},t.setWrapperRef=function(e){t.wrapperRef=e},t}d(t,e);var n=t.prototype;return n.componentDidMount=function(){document.addEventListener("click",this.handleClickOutside)},n.componentWillUnmount=function(){document.removeEventListener("click",this.handleClickOutside)},n.render=function(){var e=this.props,t=e.children,n=e.open,r=e.style,a=s.default("popover",e.className);return n?u.default.createElement("div",{style:r,className:a,ref:this.setWrapperRef},t):null},t}(e.Component);h.propTypes={open:c.default.bool.isRequired,onRequestClose:c.default.func,style:c.default.object,className:c.default.string};var v=function(e){function t(){return e.apply(this,arguments)||this}return d(t,e),t.prototype.render=function(){var e=this.props,t=e.children,n=e.style,r=s.default("menu",e.className);return u.default.createElement("div",f({className:r},n),t)},t}(e.Component),g=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).state={active:!1,position:null},t.toggleActive=function(){t.setState((function(e){return{active:!e.active}}))},t}return d(t,e),t.prototype.render=function(){var e=this,t=this.props,n=t.children,a=t.menuItems,l=t.childrenLeft,i=this.state,o=i.active,c=i.position,f=a&&a.length>0,d=f&&o,p=f?this.toggleActive:t.onClick,m=s.default("menu-item",{active:o,disabled:t.disabled,"space-between":f,"bold-text":f}),h={left:(c?c.width+15:0)*(l?-1:1),bottom:c?c.top+Math.ceil(c.height/2)+12:0};return u.default.createElement("div",{"data-testid":"menu-item-wrapper",className:"menu-item-wrapper"},u.default.createElement("div",{className:m,onClick:p,ref:function(t){t&&null===c&&e.setState({position:t.getBoundingClientRect()})}},n,f&&u.default.createElement(r.RightArrowIcon,{size:16})),d&&u.default.createElement("div",{style:h,className:"menu-item-nested"},a))},t}(e.Component);g.propTypes={disabled:c.default.bool,onClick:c.default.func,menuItems:c.default.arrayOf(c.default.node),childrenLeft:c.default.bool},g.defaultProps={childrenLeft:!1};var C=["children"],y=function(e){function t(){return e.apply(this,arguments)||this}return d(t,e),t.prototype.render=function(){var e=this.props,t=e.children,n=m(e,C),r=u.default.Children.toArray(t).filter((function(e){return"TableRowCell"===e.type.displayName}));return u.default.createElement("tr",n,r)},t}(e.Component);y.displayName="TableRow";var b=function(e){return u.default.createElement("div",{className:"radio-button-icon"},e.checked&&u.default.createElement("div",{className:"checked"}))};c.default.defaultProps={checked:!1},c.default.propTypes={checked:c.default.bool};var E=Object.freeze({ASC:"ASC",DESC:"DESC"}),N=Object.freeze({STRING:"STRING",DATE:"DATE",NUMBER:"NUMBER"}),w=function(){return Object.values(E)},M=c.default.shape({type:c.default.oneOf(function(){return Object.values(N)}()),fieldName:c.default.string,direction:c.default.oneOf(w()),onSort:c.default.func,isSorting:c.default.bool}),I=c.default.shape({filterMap:c.default.object.isRequired,fieldName:c.default.string,onFilter:c.default.func,onClearFilter:c.default.func,dataSource:c.default.arrayOf(c.default.shape({value:c.default.string.isRequired,label:c.default.string.isRequired}))}),O=function(e){return e.displayName||e.name||"Component"};function R(t){return function(n){var r=function(e){function r(){return e.apply(this,arguments)||this}return d(r,e),r.prototype.render=function(){var e=t(this.props.intl.formatMessage);return u.default.createElement(n,f({i18n:e},this.props))},r}(e.Component);return r.WrappedComponent=n,r.displayName="WithI18n("+O(n)+")",i.injectIntl(r)}}var S=R((function(e){return function(t,n){return e({id:t},n)}})),k=["filterConfig","sortConfig"],x=function(e){return!!e&&!!(t=e.filterMap)&&(t[e.fieldName]||[]).length>0;var t},T=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).state={isOpen:!1},t.handleCollapse=function(){t.setState({isOpen:!1})},t.handleExpand=function(){t.setState({isOpen:!0})},t}d(t,e);var n=t.prototype;return n.getClearFiltersMenuItem=function(e){if(!e)return null;var t=e.onClearFilter,n=e.fieldName;return x(e)&&t?u.default.createElement(a.MenuItem,{onClick:function(){return t(n)}},this.props.i18n("common.clear_filters")):null},n.getMessageId=function(e,t){switch(e){case N.STRING:return t===E.ASC?"common.sorting.string_asc":"common.sorting.string_desc";case N.NUMBER:return t===E.ASC?"common.sorting.number_asc":"common.sorting.number_desc";case N.DATE:return t===E.ASC?"common.sorting.date_asc":"common.sorting.date_desc";default:return"common.sorting.invalid_parameter"}},n.getFilterMenu=function(e){if(!e)return[];var t=e.onFilter,n=e.fieldName,r=e.filterMap,i=e.dataSource.map((function(e){var i=!!r[n]&&(r[n]||[]).indexOf(e.value)>-1;return u.default.createElement(a.MenuItem,{key:e.value,onClick:function(){t(n,e.value)}},u.default.createElement("div",{className:"icon-container"},u.default.createElement(l.Checkbox,{checked:i,className:"menu-item-checkbox",onChange:function(){t(n,e.value)}})),e.label)}));return u.default.createElement(a.MenuItem,{menuItems:i},this.props.i18n("sorting.filter_by"))},n.getSortMenuItems=function(e){var t=this;if(!e)return[];var n=e.fieldName,r=e.direction,l=e.onSort,i=e.isSorting,o=e.type;return w().map((function(e){var c=e===r&&i,s=t.getMessageId(o,e);return u.default.createElement(a.MenuItem,{key:e,onClick:function(){l(n,e)}},u.default.createElement("div",{className:"icon-container"},u.default.createElement(b,{checked:c})),t.props.i18n(s))}))},n.renderMenu=function(e){var t=e.filterConfig,n=e.sortConfig,r=m(e,k),l=this.getSortMenuItems(n),i=this.getFilterMenu(t),o=l.length>0&&t,c=this.getClearFiltersMenuItem(t);return u.default.createElement(a.Menu,f({className:"sort-filter-menu"},r),l,o&&u.default.createElement(a.Divider,null),i,c)},n.render=function(){var e=this.props,t=e.sortConfig;if(!t&&!e.filterConfig)return null;var n=this.state.isOpen?this.renderMenu(this.props):null,a=!!t&&t.isSorting,l=t?t.direction:null,i=s.default("arrow",{hidden:!a}),o=x(this.props.filterConfig);return u.default.createElement("div",{onBlur:this.handleCollapse,tabIndex:0},u.default.createElement("div",{className:"sort-filter-arrow"},o&&u.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:12,width:8,viewBox:"0 0 12 8",transform:"scale(1.7)"},u.default.createElement("path",{d:"M4.66666667,8 L7.33333333,8 L7.33333333,6.66666667 L4.66666667,6.66666667 L4.66666667,8 Z M0,0 L0,1.33333333 L12,1.33333333 L12,0 L0,0 Z M2,4.66666667 L10,4.66666667 L10,3.33333333 L2,3.33333333 L2,4.66666667 Z",id:"Shape"})),u.default.createElement(a&&l===E.ASC?r.UpwardIcon:r.DownwardIcon,{size:20,className:i}),u.default.createElement(r.DownArrowIcon,{size:20,onMouseDown:this.handleExpand})),n)},t}(e.Component);c.default.propTypes={sortConfig:M,filterConfig:I};var A=S(T),L=["label","filterConfig","sortConfig","mini"],_=function(e){var t=e.label,n=e.filterConfig,r=e.sortConfig,a=e.mini,l=m(e,L),i=!(!r&&!n),o=s.default({mini:a});return u.default.createElement("th",f({className:o},l),i?u.default.createElement("div",{className:"sortable"},t,u.default.createElement(A,{filterConfig:n,sortConfig:r})):t)};_.displayName="TableHeaderCell",_.propTypes={label:c.default.node,sortConfig:M,filterConfig:I,mini:c.default.bool},_.defaultProps={label:""};var j=["children"],q=function(e){var t=e.children,n=m(e,j);return u.default.createElement("td",n,t)};q.displayName="TableRowCell",exports.Divider=function(e){return u.default.createElement("hr",f({},e,{className:"divider"}))},exports.Menu=v,exports.MenuItem=g,exports.Popover=h,exports.Table=function(e){var t=e.className,n=u.default.Children.toArray(e.children),r=n.filter((function(e){return"TableHeaderCell"===e.type.displayName})),a=n.filter((function(e){return"TableRow"===e.type.displayName}));return u.default.createElement("table",{className:t},u.default.createElement("thead",null,u.default.createElement("tr",null,r)),u.default.createElement("tbody",null,a))},exports.TableHeaderCell=_,exports.TableRow=y,exports.TableRowCell=q,exports.componentDisplayName=O,exports.createWithI18n=R; | ||
//# sourceMappingURL=legacy.cjs.production.min.js.map |
@@ -30,5 +30,15 @@ import React, { Component } from 'react'; | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
@@ -251,2 +261,4 @@ if (source == null) return {}; | ||
var _excluded$3 = ["children"]; | ||
var TableRow = /*#__PURE__*/function (_Component) { | ||
@@ -264,3 +276,3 @@ _inheritsLoose(TableRow, _Component); | ||
children = _this$props.children, | ||
rest = _objectWithoutPropertiesLoose(_this$props, ["children"]); | ||
rest = _objectWithoutPropertiesLoose(_this$props, _excluded$3); | ||
@@ -368,2 +380,4 @@ var Cells = React.Children.toArray(children).filter(function (child) { | ||
var _excluded$2 = ["filterConfig", "sortConfig"]; | ||
var hasFilter = function hasFilter(fieldName, filterMap) { | ||
@@ -519,3 +533,3 @@ if (!filterMap) { | ||
sortConfig = props.sortConfig, | ||
restProps = _objectWithoutPropertiesLoose(props, ["filterConfig", "sortConfig"]); | ||
restProps = _objectWithoutPropertiesLoose(props, _excluded$2); | ||
@@ -583,2 +597,4 @@ var sortMenuItems = this.getSortMenuItems(sortConfig); | ||
var _excluded$1 = ["label", "filterConfig", "sortConfig", "mini"]; | ||
var TableHeaderCell = function TableHeaderCell(_ref) { | ||
@@ -589,3 +605,3 @@ var label = _ref.label, | ||
mini = _ref.mini, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["label", "filterConfig", "sortConfig", "mini"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1); | ||
@@ -624,5 +640,7 @@ var allowsUserInteraction = !!(sortConfig || filterConfig); | ||
var _excluded = ["children"]; | ||
var TableRowCell = function TableRowCell(_ref) { | ||
var children = _ref.children, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["children"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
@@ -629,0 +647,0 @@ return /*#__PURE__*/React.createElement("td", rest, children); |
@@ -7,9 +7,9 @@ export class MenuItem extends React.Component<any, any, any> { | ||
export namespace MenuItem { | ||
export namespace propTypes { | ||
export const disabled: PropTypes.Requireable<boolean>; | ||
export const onClick: PropTypes.Requireable<(...args: any[]) => any>; | ||
export const menuItems: PropTypes.Requireable<PropTypes.ReactNodeLike[]>; | ||
export const childrenLeft: PropTypes.Requireable<boolean>; | ||
namespace propTypes { | ||
const disabled: PropTypes.Requireable<boolean>; | ||
const onClick: PropTypes.Requireable<(...args: any[]) => any>; | ||
const menuItems: PropTypes.Requireable<PropTypes.ReactNodeLike[]>; | ||
const childrenLeft: PropTypes.Requireable<boolean>; | ||
} | ||
export namespace defaultProps { | ||
namespace defaultProps { | ||
const childrenLeft_1: boolean; | ||
@@ -16,0 +16,0 @@ export { childrenLeft_1 as childrenLeft }; |
@@ -9,7 +9,7 @@ export class Popover extends React.Component<any, any, any> { | ||
export namespace Popover { | ||
export namespace propTypes { | ||
export const open: propTypes.Validator<boolean>; | ||
export const onRequestClose: propTypes.Requireable<(...args: any[]) => any>; | ||
export const style: propTypes.Requireable<object>; | ||
export const className: propTypes.Requireable<string>; | ||
namespace propTypes { | ||
const open: propTypes.Validator<boolean>; | ||
const onRequestClose: propTypes.Requireable<(...args: any[]) => any>; | ||
const style: propTypes.Requireable<object>; | ||
const className: propTypes.Requireable<string>; | ||
} | ||
@@ -16,0 +16,0 @@ } |
@@ -10,4 +10,4 @@ export default TableHeaderCell; | ||
declare namespace TableHeaderCell { | ||
export const displayName: string; | ||
export namespace propTypes { | ||
const displayName: string; | ||
namespace propTypes { | ||
export const label: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
@@ -18,3 +18,3 @@ export { sortConfigProps as sortConfig }; | ||
} | ||
export namespace defaultProps { | ||
namespace defaultProps { | ||
const label_1: string; | ||
@@ -21,0 +21,0 @@ export { label_1 as label }; |
@@ -7,4 +7,4 @@ export default TableRow; | ||
declare namespace TableRow { | ||
export const displayName: string; | ||
const displayName: string; | ||
} | ||
import React from "react"; |
@@ -7,3 +7,3 @@ export default TableRowCell; | ||
declare namespace TableRowCell { | ||
export const displayName: string; | ||
const displayName: string; | ||
} |
{ | ||
"name": "@entur-partner/legacy", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "EUPL-1.2", | ||
@@ -20,6 +20,6 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"watch": "tsdx watch --noClean --verbose", | ||
"build": "tsdx build", | ||
"test": "tsdx test --env=jsdom --passWithNoTests", | ||
"lint": "tsdx lint" | ||
"watch": "dts watch --noClean --verbose", | ||
"build": "dts build", | ||
"test": "dts test --env=jsdom --passWithNoTests", | ||
"lint": "dts lint" | ||
}, | ||
@@ -52,3 +52,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "a762828a4ff18043452ca99795216925bf6a8936" | ||
"gitHead": "ba34d91c553fbd985db00d3c8a4ea4d4dca75564" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
146821
1495