選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

162 行
4.7 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends2 = require('babel-runtime/helpers/extends');
  6. var _extends3 = _interopRequireDefault(_extends2);
  7. var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
  8. var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
  9. var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  10. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  11. var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  12. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  13. var _createClass2 = require('babel-runtime/helpers/createClass');
  14. var _createClass3 = _interopRequireDefault(_createClass2);
  15. var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  16. var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  17. var _inherits2 = require('babel-runtime/helpers/inherits');
  18. var _inherits3 = _interopRequireDefault(_inherits2);
  19. var _simpleAssign = require('simple-assign');
  20. var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
  21. var _react = require('react');
  22. var _react2 = _interopRequireDefault(_react);
  23. var _propTypes = require('prop-types');
  24. var _propTypes2 = _interopRequireDefault(_propTypes);
  25. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26. var getStyles = function getStyles(_ref, _ref2) {
  27. var index = _ref.index;
  28. var stepper = _ref2.stepper;
  29. var orientation = stepper.orientation;
  30. var styles = {
  31. root: {
  32. flex: '0 0 auto'
  33. }
  34. };
  35. if (index > 0) {
  36. if (orientation === 'horizontal') {
  37. styles.root.marginLeft = -6;
  38. } else if (orientation === 'vertical') {
  39. styles.root.marginTop = -14;
  40. }
  41. }
  42. return styles;
  43. };
  44. var Step = function (_Component) {
  45. (0, _inherits3.default)(Step, _Component);
  46. function Step() {
  47. var _ref3;
  48. var _temp, _this, _ret;
  49. (0, _classCallCheck3.default)(this, Step);
  50. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  51. args[_key] = arguments[_key];
  52. }
  53. return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref3 = Step.__proto__ || (0, _getPrototypeOf2.default)(Step)).call.apply(_ref3, [this].concat(args))), _this), _this.renderChild = function (child) {
  54. var _this$props = _this.props,
  55. active = _this$props.active,
  56. completed = _this$props.completed,
  57. disabled = _this$props.disabled,
  58. index = _this$props.index,
  59. last = _this$props.last;
  60. var icon = index + 1;
  61. return _react2.default.cloneElement(child, (0, _simpleAssign2.default)({ active: active, completed: completed, disabled: disabled, icon: icon, last: last }, child.props));
  62. }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  63. }
  64. (0, _createClass3.default)(Step, [{
  65. key: 'render',
  66. value: function render() {
  67. var _props = this.props,
  68. active = _props.active,
  69. completed = _props.completed,
  70. disabled = _props.disabled,
  71. index = _props.index,
  72. last = _props.last,
  73. children = _props.children,
  74. style = _props.style,
  75. other = (0, _objectWithoutProperties3.default)(_props, ['active', 'completed', 'disabled', 'index', 'last', 'children', 'style']);
  76. var prepareStyles = this.context.muiTheme.prepareStyles;
  77. var styles = getStyles(this.props, this.context);
  78. return _react2.default.createElement(
  79. 'div',
  80. (0, _extends3.default)({ style: prepareStyles((0, _simpleAssign2.default)(styles.root, style)) }, other),
  81. _react2.default.Children.map(children, this.renderChild)
  82. );
  83. }
  84. }]);
  85. return Step;
  86. }(_react.Component);
  87. Step.contextTypes = {
  88. muiTheme: _propTypes2.default.object.isRequired,
  89. stepper: _propTypes2.default.object
  90. };
  91. Step.propTypes = process.env.NODE_ENV !== "production" ? {
  92. /**
  93. * Sets the step as active. Is passed to child components.
  94. */
  95. active: _propTypes2.default.bool,
  96. /**
  97. * Should be `Step` sub-components such as `StepLabel`.
  98. */
  99. children: _propTypes2.default.node,
  100. /**
  101. * Mark the step as completed. Is passed to child components.
  102. */
  103. completed: _propTypes2.default.bool,
  104. /**
  105. * Mark the step as disabled, will also disable the button if
  106. * `StepButton` is a child of `Step`. Is passed to child components.
  107. */
  108. disabled: _propTypes2.default.bool,
  109. /**
  110. * @ignore
  111. * Used internally for numbering.
  112. */
  113. index: _propTypes2.default.number,
  114. /**
  115. * @ignore
  116. */
  117. last: _propTypes2.default.bool,
  118. /**
  119. * Override the inline-style of the root element.
  120. */
  121. style: _propTypes2.default.object
  122. } : {};
  123. exports.default = Step;