@itable/core
Advanced tools
Comparing version 1.3.4 to 2.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _styledComponents = _interopRequireDefault(require("styled-components")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["\n cursor: pointer;\n display: inline-block;\n vertical-align: middle;\n \n &:before, &:after {\n content: \"\";\n display: block;\n margin: 5px;\n border: solid transparent;\n border-width: 3px 4px;\n border-right-color: #979CA4;\n }\n \n &:before {\n transform: rotate(90deg);\n }\n \n &:after {\n transform: rotate(-90deg);\n }\n \n ", "\n"]); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
var SortIcon = _styledComponents.default.div(_templateObject(), function (_ref) { | ||
var isSorted = _ref.isSorted, | ||
sortOrder = _ref.sortOrder; | ||
return isSorted && "\n ".concat(sortOrder === 'ASC' ? "\n &:before {\n margin-top: 4px;\n border-width: 4px 5px;\n border-right-color: #2F394A;\n }\n " : "\n &:after {\n margin-bottom: 4px;\n border-width: 4px 5px;\n border-right-color: #2F394A;\n }\n ", "\n "); | ||
}); | ||
var _default = SortIcon; | ||
exports.default = _default; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const styled_components_1 = require("styled-components"); | ||
const SortIcon = styled_components_1.default.div ` | ||
cursor: pointer; | ||
display: inline-block; | ||
vertical-align: middle; | ||
&:before, &:after { | ||
content: ""; | ||
display: block; | ||
margin: 5px; | ||
border: solid transparent; | ||
border-width: 3px 4px; | ||
border-right-color: #979CA4; | ||
} | ||
&:before { | ||
transform: rotate(90deg); | ||
} | ||
&:after { | ||
transform: rotate(-90deg); | ||
} | ||
${({ isSorted, sortOrder }) => isSorted && ` | ||
${sortOrder === 'ASC' ? ` | ||
&:before { | ||
margin-top: 4px; | ||
border-width: 4px 5px; | ||
border-right-color: #2F394A; | ||
} | ||
` : ` | ||
&:after { | ||
margin-bottom: 4px; | ||
border-width: 4px 5px; | ||
border-right-color: #2F394A; | ||
} | ||
`} | ||
`} | ||
`; | ||
exports.default = SortIcon; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TableRowContext = exports.TableHeadContext = exports.TableContext = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var TableContext = _react.default.createContext(null); | ||
exports.TableContext = TableContext; | ||
var TableHeadContext = _react.default.createContext(null); | ||
exports.TableHeadContext = TableHeadContext; | ||
var TableRowContext = _react.default.createContext(null); | ||
exports.TableRowContext = TableRowContext; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
exports.TableContext = React.createContext({}); | ||
exports.TableHeadContext = React.createContext({}); | ||
exports.TableRowContext = React.createContext({}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _withTable = _interopRequireDefault(require("./withTable")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var emptyCaptionEnhancer = function emptyCaptionEnhancer(Component) { | ||
return ( | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(EmptyCaption, _React$Component); | ||
function EmptyCaption() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, EmptyCaption); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const withTable_1 = require("./withTable"); | ||
function emptyCaptionEnhancer(Component) { | ||
return class EmptyCaption extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.renderEmptyCaption = () => { | ||
const { tableContext, ...props } = this.props; | ||
return (React.createElement(Component, Object.assign({}, props))); | ||
}; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(EmptyCaption)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderEmptyCaption", function () { | ||
var _this$props = _this.props, | ||
tableContext = _this$props.tableContext, | ||
props = _objectWithoutProperties(_this$props, ["tableContext"]); | ||
return _react.default.createElement(Component, props); | ||
}); | ||
return _this; | ||
} | ||
_createClass(EmptyCaption, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.props.tableContext.setEmptyCaptionRenderer(this.renderEmptyCaption); | ||
componentDidMount() { | ||
this.props.tableContext.setEmptyCaptionRenderer(this.renderEmptyCaption); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return null; | ||
render() { | ||
return null; | ||
} | ||
}]); | ||
return EmptyCaption; | ||
}(_react.default.Component) | ||
); | ||
}; | ||
var _default = function _default(Component) { | ||
return (0, _withTable.default)(emptyCaptionEnhancer(Component)); | ||
}; | ||
exports.default = _default; | ||
}; | ||
} | ||
function default_1(Component) { | ||
return withTable_1.default(emptyCaptionEnhancer(Component)); | ||
} | ||
exports.default = default_1; | ||
; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var _default = function _default(Component) { | ||
return ( | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(Table, _React$Component); | ||
function Table() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, Table); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function table(Component) { | ||
return (class Table extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.setEmptyCaptionRenderer = (method) => { | ||
this.setState({ emptyCaptionRenderer: method }); | ||
}; | ||
this.registerHeaderProps = (props) => { | ||
this.setState(({ headerProps }) => ({ | ||
headerProps: headerProps.concat(props), | ||
})); | ||
}; | ||
this.state = { | ||
data: null, | ||
headerProps: [], | ||
registerHeaderProps: this.registerHeaderProps, | ||
emptyCaptionRenderer: () => null, | ||
setEmptyCaptionRenderer: this.setEmptyCaptionRenderer, | ||
}; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Table)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setEmptyCaptionRenderer", function (method) { | ||
_this.setState({ | ||
emptyCaptionRenderer: method | ||
}); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "registerHeaderProps", function (props) { | ||
_this.setState(function (_ref) { | ||
var headerProps = _ref.headerProps; | ||
return { | ||
headerProps: headerProps.concat(props) | ||
}; | ||
}); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
headerProps: [], | ||
registerHeaderProps: _this.registerHeaderProps, | ||
emptyCaptionRenderer: function emptyCaptionRenderer() { | ||
static getDerivedStateFromProps(nextProps, state) { | ||
if (nextProps.data !== state.data) { | ||
return { data: nextProps.data }; | ||
} | ||
return null; | ||
}, | ||
setEmptyCaptionRenderer: _this.setEmptyCaptionRenderer | ||
}); | ||
return _this; | ||
} | ||
_createClass(Table, [{ | ||
key: "render", | ||
value: function render() { | ||
var state = this.state; | ||
var _this$props = this.props, | ||
data = _this$props.data, | ||
rest = _objectWithoutProperties(_this$props, ["data"]); | ||
return _react.default.createElement(_contexts.TableContext.Provider, { | ||
value: state | ||
}, _react.default.createElement(Component, rest)); | ||
} | ||
}], [{ | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(nextProps, state) { | ||
if (nextProps.data !== state.data) { | ||
return { | ||
data: nextProps.data | ||
}; | ||
} | ||
return null; | ||
render() { | ||
const state = this.state; | ||
const { data, ...rest } = this.props; | ||
return (React.createElement(contexts_1.TableContext.Provider, { value: state }, | ||
React.createElement(Component, Object.assign({}, rest)))); | ||
} | ||
}]); | ||
return Table; | ||
}(_react.default.Component) | ||
); | ||
}; | ||
exports.default = _default; | ||
}); | ||
} | ||
exports.default = table; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function reactChildrenToArray(children) { | ||
return Array.isArray(children) ? children : [children]; | ||
return Array.isArray(children) ? children : [children]; | ||
} | ||
var _default = function _default(Component) { | ||
var TableBody = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(TableBody, _React$Component); | ||
function TableBody() { | ||
_classCallCheck(this, TableBody); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(TableBody).apply(this, arguments)); | ||
function default_1(Component) { | ||
class TableBody extends React.Component { | ||
render() { | ||
const { children, forwardedRef, ...rest } = this.props; | ||
const arrayChildren = reactChildrenToArray(children); | ||
return ( | ||
// TODO temp ref implementation for styled component | ||
React.createElement(Component, Object.assign({ ref: forwardedRef }, rest), | ||
React.createElement(contexts_1.TableContext.Consumer, null, ({ data, emptyCaptionRenderer }) => (arrayChildren.map((child) => { | ||
if (typeof child === 'function') { | ||
return data.length === 0 ? emptyCaptionRenderer() : data.map(child); | ||
} | ||
return child; | ||
}))))); | ||
} | ||
} | ||
_createClass(TableBody, [{ | ||
key: "render", | ||
value: function render() { | ||
var _this$props = this.props, | ||
children = _this$props.children, | ||
forwardedRef = _this$props.forwardedRef, | ||
rest = _objectWithoutProperties(_this$props, ["children", "forwardedRef"]); | ||
var arrayChildren = reactChildrenToArray(children); | ||
return (// TODO temp ref implementation for styled component | ||
_react.default.createElement(Component, _extends({ | ||
innerRef: forwardedRef | ||
}, rest), _react.default.createElement(_contexts.TableContext.Consumer, null, function (_ref) { | ||
var data = _ref.data, | ||
emptyCaptionRenderer = _ref.emptyCaptionRenderer; | ||
return arrayChildren.map(function (child) { | ||
if (typeof child === 'function') { | ||
return data.length === 0 ? emptyCaptionRenderer() : data.map(child); | ||
} | ||
return child; | ||
}); | ||
})) | ||
); | ||
} | ||
}]); | ||
return TableBody; | ||
}(_react.default.Component); | ||
return _react.default.forwardRef(function (props, ref) { | ||
return _react.default.createElement(TableBody, _extends({ | ||
forwardedRef: ref | ||
}, props)); | ||
}); | ||
}; | ||
exports.default = _default; | ||
const Factory = (props, ref) => (React.createElement(TableBody, Object.assign({ forwardedRef: ref }, props))); | ||
return React.forwardRef(Factory); | ||
} | ||
exports.default = default_1; | ||
; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _withTableRow = _interopRequireDefault(require("./withTableRow")); | ||
var _withTable = _interopRequireDefault(require("./withTable")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var tableDataEnhancer = function tableDataEnhancer(Component) { | ||
return ( | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(TableRow, _React$Component); | ||
function TableRow() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, TableRow); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const withTableRow_1 = require("./withTableRow"); | ||
const withTable_1 = require("./withTable"); | ||
function tableDataEnhancer(Component) { | ||
return class TableRow extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.state = { | ||
index: null, | ||
}; | ||
this.registerTableDataCallback = (index) => { | ||
this.setState({ index }); | ||
}; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TableRow)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "tableRow", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
index: null | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "registerTableDataCallback", function (index) { | ||
_this.setState({ | ||
index: index | ||
}); | ||
}); | ||
return _this; | ||
} | ||
_createClass(TableRow, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.props.tableRowContext.registerTableDataComponentIndex(this.registerTableDataCallback); | ||
componentDidMount() { | ||
this.props.tableRowContext.registerTableDataComponentIndex(this.registerTableDataCallback); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var props = this.props; | ||
var sharedPropsFromHeader = this.sharedPropsFromHeader; | ||
return _react.default.createElement(Component, _extends({}, sharedPropsFromHeader, props)); | ||
get sharedPropsFromHeader() { | ||
const { index } = this.state; | ||
const { tableContext } = this.props; | ||
if (typeof index === 'number' && tableContext.headerProps[index]) { | ||
const { width } = tableContext.headerProps[index]; | ||
return { width }; | ||
} | ||
return {}; | ||
} | ||
}, { | ||
key: "sharedPropsFromHeader", | ||
get: function get() { | ||
var index = this.state.index; | ||
var tableContext = this.props.tableContext; | ||
if (typeof index === 'number' && tableContext.headerProps[index]) { | ||
var width = tableContext.headerProps[index].width; | ||
return { | ||
width: width | ||
}; | ||
} | ||
return {}; | ||
render() { | ||
const props = this.props; | ||
const sharedPropsFromHeader = this.sharedPropsFromHeader; | ||
return (React.createElement(Component, Object.assign({}, sharedPropsFromHeader, props))); | ||
} | ||
}]); | ||
return TableRow; | ||
}(_react.default.Component) | ||
); | ||
}; | ||
var _default = function _default(Component) { | ||
return (0, _withTable.default)((0, _withTableRow.default)(tableDataEnhancer(Component))); | ||
}; | ||
exports.default = _default; | ||
}; | ||
} | ||
function default_1(Component) { | ||
return withTable_1.default(withTableRow_1.default(tableDataEnhancer(Component))); | ||
} | ||
exports.default = default_1; | ||
; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var _default = function _default(Component) { | ||
return ( | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(TableHead, _React$Component); | ||
function TableHead(props) { | ||
var _this; | ||
_classCallCheck(this, TableHead); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(TableHead).call(this, props)); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getCurrentSorOrder", function () { | ||
var sortOrder = _this.state.sortOrder; | ||
return sortOrder === 'ASC' ? 'DESC' : 'ASC'; | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSort", function (sortByKey) { | ||
var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)), | ||
getCurrentSorOrder = _assertThisInitialize.getCurrentSorOrder; | ||
var sortBy = _this.state.sortBy; | ||
var onSort = _this.props.onSort; | ||
var newSortOrder = sortBy === sortByKey ? getCurrentSorOrder() : 'ASC'; | ||
if (!onSort) throw new Error('💩 TableHead: I need "onSort" property to handle sorting'); | ||
onSort(sortByKey, newSortOrder); | ||
}); | ||
_this.state = { | ||
sortBy: null, | ||
sortOrder: null, | ||
handleSort: _this.handleSort | ||
}; | ||
return _this; | ||
} | ||
_createClass(TableHead, [{ | ||
key: "render", | ||
value: function render() { | ||
var state = this.state; | ||
var _this$props = this.props, | ||
onSort = _this$props.onSort, | ||
sortBy = _this$props.sortBy, | ||
rest = _objectWithoutProperties(_this$props, ["onSort", "sortBy"]); | ||
return _react.default.createElement(_contexts.TableHeadContext.Provider, { | ||
value: state | ||
}, _react.default.createElement(Component, rest)); | ||
} | ||
}], [{ | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(props, state) { | ||
if (props.sortBy !== state.sortBy || props.sortOrder !== state.sortOrder) { | ||
return { | ||
sortBy: props.sortBy, | ||
sortOrder: props.sortOrder | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function default_1(Component) { | ||
return class TableHead extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.getCurrentSorOrder = () => { | ||
const { sortOrder } = this.state; | ||
return (sortOrder === 'ASC') ? 'DESC' : 'ASC'; | ||
}; | ||
} | ||
return null; | ||
this.handleSort = (sortByKey) => { | ||
const { getCurrentSorOrder } = this; | ||
const { sortBy } = this.state; | ||
const { onSort } = this.props; | ||
const newSortOrder = sortBy === sortByKey ? getCurrentSorOrder() : 'ASC'; | ||
if (!onSort) | ||
throw new Error('💩 TableHead: I need "onSort" property to handle sorting'); | ||
onSort(sortByKey, newSortOrder); | ||
}; | ||
this.state = { | ||
sortBy: null, | ||
sortOrder: null, | ||
handleSort: this.handleSort, | ||
}; | ||
} | ||
}]); | ||
return TableHead; | ||
}(_react.default.Component) | ||
); | ||
}; | ||
exports.default = _default; | ||
static getDerivedStateFromProps(props, state) { | ||
if (props.sortBy !== state.sortBy || | ||
props.sortOrder !== state.sortOrder) { | ||
return { | ||
sortBy: props.sortBy, | ||
sortOrder: props.sortOrder, | ||
}; | ||
} | ||
return null; | ||
} | ||
render() { | ||
const state = this.state; | ||
const { onSort, sortBy, ...rest } = this.props; | ||
return (React.createElement(contexts_1.TableHeadContext.Provider, { value: state }, | ||
React.createElement(Component, Object.assign({}, rest)))); | ||
} | ||
}; | ||
} | ||
exports.default = default_1; | ||
; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _SortIcon = _interopRequireDefault(require("../components/SortIcon")); | ||
var _withTableHead = _interopRequireDefault(require("./withTableHead")); | ||
var _withTable = _interopRequireDefault(require("./withTable")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
var tableHeader = function tableHeader(Component) { | ||
var _class, _temp; | ||
return _temp = _class = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(TableHeader, _React$Component); | ||
function TableHeader() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, TableHeader); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TableHeader)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleOnClick", function (event) { | ||
var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)), | ||
isSortable = _assertThisInitialize.isSortable; | ||
var _this$props = _this.props, | ||
tableHeadContext = _this$props.tableHeadContext, | ||
onClick = _this$props.onClick, | ||
sortByKey = _this$props.sortByKey; | ||
if (onClick) onClick(event); | ||
if (isSortable && !event.defaultPrevented) { | ||
tableHeadContext.handleSort(sortByKey); | ||
} | ||
}); | ||
return _this; | ||
} | ||
_createClass(TableHeader, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var _this$props2 = this.props, | ||
tableHeadContext = _this$props2.tableHeadContext, | ||
tableContext = _this$props2.tableContext, | ||
rest = _objectWithoutProperties(_this$props2, ["tableHeadContext", "tableContext"]); | ||
if (tableHeadContext) { | ||
tableContext.registerHeaderProps(rest); | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var handleOnClick = this.handleOnClick, | ||
isSortable = this.isSortable; | ||
var _this$props3 = this.props, | ||
onClick = _this$props3.onClick, | ||
sortByKey = _this$props3.sortByKey, | ||
children = _this$props3.children, | ||
tableHeadContext = _this$props3.tableHeadContext, | ||
rest = _objectWithoutProperties(_this$props3, ["onClick", "sortByKey", "children", "tableHeadContext"]); | ||
if (!tableHeadContext) { | ||
return _react.default.createElement(Component, _extends({ | ||
onClick: handleOnClick | ||
}, rest), children); | ||
} | ||
var sortBy = tableHeadContext.sortBy, | ||
sortOrder = tableHeadContext.sortOrder; | ||
return _react.default.createElement(Component, _extends({ | ||
onClick: handleOnClick | ||
}, rest), children, isSortable && _react.default.createElement(_SortIcon.default, { | ||
isSorted: sortByKey === sortBy, | ||
sortOrder: sortOrder | ||
})); | ||
} | ||
}, { | ||
key: "isSortable", | ||
get: function get() { | ||
var _this$props4 = this.props, | ||
disableSort = _this$props4.disableSort, | ||
sortByKey = _this$props4.sortByKey; | ||
return disableSort ? false : Boolean(sortByKey); | ||
} | ||
}]); | ||
return TableHeader; | ||
}(_react.default.Component), _defineProperty(_class, "defaultProps", { | ||
sortByKey: null, | ||
disableSort: false | ||
}), _temp; | ||
}; | ||
var _default = function _default(Component) { | ||
return (0, _withTable.default)((0, _withTableHead.default)(tableHeader(Component))); | ||
}; | ||
exports.default = _default; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const SortIcon_1 = require("../components/SortIcon"); | ||
const withTableHead_1 = require("./withTableHead"); | ||
const withTable_1 = require("./withTable"); | ||
function tableHeader(Component) { | ||
var _a; | ||
return _a = class TableHeader extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.handleOnClick = (event) => { | ||
const { isSortable } = this; | ||
const { tableHeadContext, onClick, sortByKey } = this.props; | ||
if (onClick) | ||
onClick(event); | ||
if (isSortable && !event.defaultPrevented) { | ||
tableHeadContext.handleSort(sortByKey); | ||
} | ||
}; | ||
} | ||
get isSortable() { | ||
const { disableSort, sortByKey } = this.props; | ||
return disableSort ? false : Boolean(sortByKey); | ||
} | ||
componentDidMount() { | ||
const { tableHeadContext, tableContext, ...rest } = this.props; | ||
if (tableHeadContext) { | ||
tableContext.registerHeaderProps(rest); | ||
} | ||
} | ||
render() { | ||
const { handleOnClick, isSortable } = this; | ||
const { onClick, sortByKey, children, tableHeadContext, disableSort, tableContext, ...rest } = this.props; | ||
const props = { onClick: handleOnClick, ...rest }; | ||
if (!tableHeadContext) { | ||
return ( | ||
// @ts-ignore | ||
React.createElement(Component, Object.assign({}, props), children)); | ||
} | ||
const { sortBy, sortOrder } = tableHeadContext; | ||
return ( | ||
// @ts-ignore | ||
React.createElement(Component, Object.assign({}, props), | ||
React.createElement(React.Fragment, null, | ||
children, | ||
isSortable && | ||
React.createElement(SortIcon_1.default, { isSorted: sortByKey === sortBy, sortOrder: sortOrder })))); | ||
} | ||
}, | ||
_a.defaultProps = { | ||
disableSort: false, | ||
}, | ||
_a; | ||
} | ||
function default_1(Component) { | ||
// @ts-ignore | ||
return withTable_1.default(withTableHead_1.default(tableHeader(Component))); | ||
} | ||
exports.default = default_1; | ||
; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function random() { | ||
return Math.random().toString(16).substr(2, 10); | ||
return Math.random().toString(16).substr(2, 10); | ||
} | ||
var tableRowEnhancer = function tableRowEnhancer(Component) { | ||
return ( | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(TableRow, _React$Component); | ||
function TableRow() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, TableRow); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
function tableRowEnhancer(Component) { | ||
return class TableRow extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.rowDataList = []; | ||
this.registerTableDataComponentIndex = (callback) => { | ||
const uid = random(); | ||
this.rowDataList.push(uid); | ||
callback(this.rowDataList.indexOf(uid)); | ||
}; | ||
this.state = { | ||
registerTableDataComponentIndex: this.registerTableDataComponentIndex, | ||
}; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TableRow)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "rowDataList", []); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "registerTableDataComponentIndex", function (callback) { | ||
var uid = random(); | ||
_this.rowDataList.push(uid); | ||
callback(_this.rowDataList.indexOf(uid)); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
registerTableDataComponentIndex: _this.registerTableDataComponentIndex | ||
}); | ||
return _this; | ||
} | ||
_createClass(TableRow, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() {} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var state = this.state; | ||
var props = this.props; | ||
return _react.default.createElement(_contexts.TableRowContext.Provider, { | ||
value: state | ||
}, _react.default.createElement(Component, props)); | ||
render() { | ||
const state = this.state; | ||
const props = this.props; | ||
return (React.createElement(contexts_1.TableRowContext.Provider, { value: state }, | ||
React.createElement(Component, Object.assign({}, props)))); | ||
} | ||
}]); | ||
return TableRow; | ||
}(_react.default.Component) | ||
); | ||
}; | ||
var _default = function _default(Component) { | ||
return tableRowEnhancer(Component); | ||
}; | ||
exports.default = _default; | ||
}; | ||
} | ||
function default_1(Component) { | ||
return tableRowEnhancer(Component); | ||
} | ||
exports.default = default_1; | ||
; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var withTable = function withTable(Component) { | ||
return function (props) { | ||
return _react.default.createElement(_contexts.TableContext.Consumer, null, function (value) { | ||
return _react.default.createElement(Component, _extends({}, props, { | ||
tableContext: value | ||
})); | ||
}); | ||
}; | ||
}; | ||
var _default = withTable; | ||
exports.default = _default; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function withTable(Component) { | ||
return (props) => { | ||
return (React.createElement(contexts_1.TableContext.Consumer, null, (value) => React.createElement(Component, Object.assign({}, props, { tableContext: value })))); | ||
}; | ||
} | ||
exports.default = withTable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var withTableHead = function withTableHead(Component) { | ||
return function (props) { | ||
return _react.default.createElement(_contexts.TableHeadContext.Consumer, null, function (value) { | ||
return _react.default.createElement(Component, _extends({}, props, { | ||
tableHeadContext: value | ||
})); | ||
}); | ||
}; | ||
}; | ||
var _default = withTableHead; | ||
exports.default = _default; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function withTableHead(Component) { | ||
return (props) => { | ||
return (React.createElement(contexts_1.TableHeadContext.Consumer, null, (value) => React.createElement(Component, Object.assign({}, props, { tableHeadContext: value })))); | ||
}; | ||
} | ||
exports.default = withTableHead; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _contexts = require("../contexts"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var withTableRow = function withTableRow(Component) { | ||
return function (props) { | ||
return _react.default.createElement(_contexts.TableRowContext.Consumer, null, function (value) { | ||
return _react.default.createElement(Component, _extends({}, props, { | ||
tableRowContext: value | ||
})); | ||
}); | ||
}; | ||
}; | ||
var _default = withTableRow; | ||
exports.default = _default; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const contexts_1 = require("../contexts"); | ||
function withTableRow(Component) { | ||
return (props) => { | ||
return (React.createElement(contexts_1.TableRowContext.Consumer, null, (value) => React.createElement(Component, Object.assign({}, props, { tableRowContext: value })))); | ||
}; | ||
} | ||
exports.default = withTableRow; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "tableHeader", { | ||
enumerable: true, | ||
get: function get() { | ||
return _tableHeader.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "tableHead", { | ||
enumerable: true, | ||
get: function get() { | ||
return _tableHead.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "tableBody", { | ||
enumerable: true, | ||
get: function get() { | ||
return _tableBody.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "tableData", { | ||
enumerable: true, | ||
get: function get() { | ||
return _tableData.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "tableRow", { | ||
enumerable: true, | ||
get: function get() { | ||
return _tableRow.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "table", { | ||
enumerable: true, | ||
get: function get() { | ||
return _table.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "emptyCaption", { | ||
enumerable: true, | ||
get: function get() { | ||
return _emptyCaption.default; | ||
} | ||
}); | ||
var _tableHeader = _interopRequireDefault(require("./enhancers/tableHeader")); | ||
var _tableHead = _interopRequireDefault(require("./enhancers/tableHead")); | ||
var _tableBody = _interopRequireDefault(require("./enhancers/tableBody")); | ||
var _tableData = _interopRequireDefault(require("./enhancers/tableData")); | ||
var _tableRow = _interopRequireDefault(require("./enhancers/tableRow")); | ||
var _table = _interopRequireDefault(require("./enhancers/table")); | ||
var _emptyCaption = _interopRequireDefault(require("./enhancers/emptyCaption")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tableHeader_1 = require("./enhancers/tableHeader"); | ||
exports.tableHeader = tableHeader_1.default; | ||
var tableHead_1 = require("./enhancers/tableHead"); | ||
exports.tableHead = tableHead_1.default; | ||
var tableBody_1 = require("./enhancers/tableBody"); | ||
exports.tableBody = tableBody_1.default; | ||
var tableData_1 = require("./enhancers/tableData"); | ||
exports.tableData = tableData_1.default; | ||
var tableRow_1 = require("./enhancers/tableRow"); | ||
exports.tableRow = tableRow_1.default; | ||
var table_1 = require("./enhancers/table"); | ||
exports.table = table_1.default; | ||
var emptyCaption_1 = require("./enhancers/emptyCaption"); | ||
exports.emptyCaption = emptyCaption_1.default; |
{ | ||
"name": "@itable/core", | ||
"version": "1.3.4", | ||
"version": "2.0.0", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "babel lib -d dist" | ||
"build": "tsc" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "454f64298a59d3a3a79f22f17943c6b1e8815206" | ||
"gitHead": "b78098407915073a3db2cc30d6ec5a71f3dad8b5" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
41
44232
896
1