react-expand
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -565,2 +565,316 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/***/ "./src/Components/Tabs/Header.tsx": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Header = undefined; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = __webpack_require__("react"); | ||
var React = _interopRequireWildcard(_react); | ||
var _TabsProps = __webpack_require__("./src/Components/Tabs/TabsProps.ts"); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var __rest = undefined && undefined.__rest || function (s, e) { | ||
var t = {}; | ||
for (var p in s) { | ||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; | ||
}return t; | ||
}; | ||
var Header = exports.Header = function (_React$Component) { | ||
_inherits(Header, _React$Component); | ||
function Header() { | ||
_classCallCheck(this, Header); | ||
var _this = _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments)); | ||
_this.handleTabActivate = function (event) { | ||
_this.props.onClick && _this.props.onClick(event); | ||
if (!event.defaultPrevented) { | ||
_this.context.changeActiveTab(_this.props.tabId); | ||
} | ||
}; | ||
return _this; | ||
} | ||
_createClass(Header, [{ | ||
key: "render", | ||
value: function render() { | ||
var _a = this.props, | ||
tabId = _a.tabId, | ||
childProps = __rest(_a, ["tabId"]); | ||
return React.createElement("div", Object.assign({}, childProps, { onClick: this.handleTabActivate, "data-expand-keep": tabId, className: "header" }), this.props.children); | ||
} | ||
}]); | ||
return Header; | ||
}(React.Component); | ||
Header.contextTypes = _TabsProps.TabsContextTypes; | ||
Header.propTypes = _TabsProps.TabElementPropTypes; | ||
/***/ }), | ||
/***/ "./src/Components/Tabs/Tab.tsx": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Tab = undefined; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = __webpack_require__("react"); | ||
var React = _interopRequireWildcard(_react); | ||
var _ExpandController = __webpack_require__("./src/Components/ExpandController/index.ts"); | ||
var _TabsProps = __webpack_require__("./src/Components/Tabs/TabsProps.ts"); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var __rest = undefined && undefined.__rest || function (s, e) { | ||
var t = {}; | ||
for (var p in s) { | ||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; | ||
}return t; | ||
}; | ||
var Tab = exports.Tab = function (_React$Component) { | ||
_inherits(Tab, _React$Component); | ||
function Tab() { | ||
_classCallCheck(this, Tab); | ||
return _possibleConstructorReturn(this, (Tab.__proto__ || Object.getPrototypeOf(Tab)).apply(this, arguments)); | ||
} | ||
_createClass(Tab, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.context.registerTab(this.props.tabId); | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
this.context.unregisterTab(this.props.tabId); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _a = this.props, | ||
tabId = _a.tabId, | ||
childProps = __rest(_a, ["tabId"]); | ||
return React.createElement("div", Object.assign({}, childProps, { className: "tab", "data-expand-keep": tabId }), this.context.isExpanded(tabId) && this.props.children); | ||
} | ||
}]); | ||
return Tab; | ||
}(React.Component); | ||
Tab.contextTypes = Object.assign({}, _ExpandController.ExpandContextTypes, _TabsProps.TabsContextTypes); | ||
Tab.propTypes = _TabsProps.TabElementPropTypes; | ||
/***/ }), | ||
/***/ "./src/Components/Tabs/TabsController.tsx": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TabsController = undefined; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = __webpack_require__("react"); | ||
var React = _interopRequireWildcard(_react); | ||
var _ExpandController = __webpack_require__("./src/Components/ExpandController/index.ts"); | ||
var _TabsProps = __webpack_require__("./src/Components/Tabs/TabsProps.ts"); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var TabsController = exports.TabsController = function (_React$Component) { | ||
_inherits(TabsController, _React$Component); | ||
function TabsController(props) { | ||
_classCallCheck(this, TabsController); | ||
var _this = _possibleConstructorReturn(this, (TabsController.__proto__ || Object.getPrototypeOf(TabsController)).call(this, props)); | ||
_this.changeActiveTab = function (id) { | ||
_this.state.tabs.forEach(function (tabId) { | ||
return _this.context.isExpanded(tabId) && _this.context.changeExpandState(tabId, false)(); | ||
}); | ||
_this.context.changeExpandState(id, true)(); | ||
}; | ||
_this.unregisterTab = function (id) { | ||
return _this.state.tabs.delete(id); | ||
}; | ||
_this.registerTab = function (id) { | ||
_this.state.tabs.add(id); | ||
_this.changeActiveTab(id); | ||
}; | ||
_this.state = { | ||
tabs: new Set() | ||
}; | ||
return _this; | ||
} | ||
_createClass(TabsController, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
changeActiveTab: this.changeActiveTab, | ||
unregisterTab: this.unregisterTab, | ||
registerTab: this.registerTab | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return this.props.children; | ||
} | ||
}]); | ||
return TabsController; | ||
}(React.Component); | ||
TabsController.childContextTypes = _TabsProps.TabsContextTypes; | ||
TabsController.contextTypes = _ExpandController.ExpandContextTypes; | ||
/***/ }), | ||
/***/ "./src/Components/Tabs/TabsProps.ts": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TabsContextTypes = exports.TabElementPropTypes = undefined; | ||
var _propTypes = __webpack_require__("prop-types"); | ||
var PropTypes = _interopRequireWildcard(_propTypes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var TabElementPropTypes = exports.TabElementPropTypes = { | ||
tabId: PropTypes.string.isRequired | ||
}; | ||
var TabsContextTypes = exports.TabsContextTypes = { | ||
changeActiveTab: PropTypes.func.isRequired, | ||
unregisterTab: PropTypes.func.isRequired, | ||
registerTab: PropTypes.func.isRequired | ||
}; | ||
/***/ }), | ||
/***/ "./src/Components/Tabs/index.ts": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _TabsController = __webpack_require__("./src/Components/Tabs/TabsController.tsx"); | ||
Object.keys(_TabsController).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _TabsController[key]; | ||
} | ||
}); | ||
}); | ||
var _TabsProps = __webpack_require__("./src/Components/Tabs/TabsProps.ts"); | ||
Object.keys(_TabsProps).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _TabsProps[key]; | ||
} | ||
}); | ||
}); | ||
var _Header = __webpack_require__("./src/Components/Tabs/Header.tsx"); | ||
Object.keys(_Header).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _Header[key]; | ||
} | ||
}); | ||
}); | ||
var _Tab = __webpack_require__("./src/Components/Tabs/Tab.tsx"); | ||
Object.keys(_Tab).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _Tab[key]; | ||
} | ||
}); | ||
}); | ||
/***/ }), | ||
/***/ "./src/index.ts": | ||
@@ -612,2 +926,14 @@ /***/ (function(module, exports, __webpack_require__) { | ||
var _Tabs = __webpack_require__("./src/Components/Tabs/index.ts"); | ||
Object.keys(_Tabs).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _Tabs[key]; | ||
} | ||
}); | ||
}); | ||
/***/ }), | ||
@@ -614,0 +940,0 @@ |
export * from "./Components/ExpandController"; | ||
export * from "./Components/Collapse"; | ||
export * from "./Components/Modal"; | ||
export * from "./Components/Tabs"; |
{ | ||
"name": "react-expand", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Simple element expand state controlling", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
92364
21
1835