path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
examples/huge-apps/routes/Course/components/Course.js | ThibWeb/react-router | import React from 'react';
import Dashboard from './Dashboard';
import Nav from './Nav';
var styles = {};
styles.sidebar = {
float: 'left',
width: 200,
padding: 20,
borderRight: '1px solid #aaa',
marginRight: 20
};
class Course extends React.Component {
render () {
let { children, params } = this.props;
let course = COURSES[params.courseId];
return (
<div>
<h2>{course.name}</h2>
<Nav course={course} />
{children && children.sidebar && children.main ? (
<div>
<div className="Sidebar" style={styles.sidebar}>
{children.sidebar}
</div>
<div className="Main" style={{padding: 20}}>
{children.main}
</div>
</div>
) : (
<Dashboard />
)}
</div>
);
}
}
export default Course;
|
src/routes.js | toddlemoine/tasks | import React from 'react';
import { IndexRoute, Route } from 'react-router';
import App from './components/App';
import CurrentContainer from './components/CurrentContainer';
import TaskViewerContainer from './components/TaskViewerContainer';
const routes = (
<Route component={App} path="/">
<IndexRoute component={CurrentContainer} />
<Route path="/view/:id" component={TaskViewerContainer} />
</Route>
);
export default routes;
|
node_modules/node_modules/recompose/build/Recompose.js | SerendpityZOEY/Fixr-RelevantCodeSearch | (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["Recompose"] = factory(require("react"));
else
root["Recompose"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_3__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(29);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var createHelper = function createHelper(func, helperName) {
var setDisplayName = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
var noArgs = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
if (false) {
var _ret = function () {
/* eslint-disable global-require */
var wrapDisplayName = require('./wrapDisplayName').default;
/* eslint-enable global-require */
if (noArgs) {
return {
v: function v(BaseComponent) {
var Component = func(BaseComponent);
Component.displayName = wrapDisplayName(BaseComponent, helperName);
return Component;
}
};
}
return {
v: function v() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args.length > func.length) {
/* eslint-disable */
console.error(
/* eslint-enable */
'Too many arguments passed to ' + helperName + '(). It should called ' + ('like so: ' + helperName + '(...args)(BaseComponent).'));
}
return function (BaseComponent) {
var Component = func.apply(undefined, args)(BaseComponent);
Component.displayName = wrapDisplayName(BaseComponent, helperName);
return Component;
};
}
};
}();
if (typeof _ret === "object") return _ret.v;
}
return func;
};
exports.default = createHelper;
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createEagerElementUtil = __webpack_require__(18);
var _createEagerElementUtil2 = _interopRequireDefault(_createEagerElementUtil);
var _isReferentiallyTransparentFunctionComponent = __webpack_require__(16);
var _isReferentiallyTransparentFunctionComponent2 = _interopRequireDefault(_isReferentiallyTransparentFunctionComponent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createFactory = function createFactory(type) {
var isReferentiallyTransparent = (0, _isReferentiallyTransparentFunctionComponent2.default)(type);
return function (p, c) {
return (0, _createEagerElementUtil2.default)(false, isReferentiallyTransparent, type, p, c);
};
};
exports.default = createFactory;
/***/ },
/* 3 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mapProps = function mapProps(propsMapper) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
return function (props) {
return factory(propsMapper(props));
};
};
};
exports.default = (0, _createHelper2.default)(mapProps, 'mapProps');
/***/ },
/* 5 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
var _config = {
fromESObservable: null,
toESObservable: null
};
var configureObservable = function configureObservable(c) {
_config = c;
};
var config = exports.config = {
fromESObservable: function fromESObservable(observable) {
return typeof _config.fromESObservable === 'function' ? _config.fromESObservable(observable) : observable;
},
toESObservable: function toESObservable(stream) {
return typeof _config.toESObservable === 'function' ? _config.toESObservable(stream) : stream;
}
};
exports.default = configureObservable;
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _shallowEqual = __webpack_require__(49);
var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _shallowEqual2.default;
/***/ },
/* 7 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
var getDisplayName = function getDisplayName(Component) {
if (typeof Component === 'string') {
return Component;
}
if (!Component) {
return undefined;
}
return Component.displayName || Component.name || 'Component';
};
exports.default = getDisplayName;
/***/ },
/* 8 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
var isClassComponent = function isClassComponent(Component) {
return Boolean(Component && Component.prototype && typeof Component.prototype.isReactComponent === 'object');
};
exports.default = isClassComponent;
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var setStatic = function setStatic(key, value) {
return function (BaseComponent) {
/* eslint-disable no-param-reassign */
BaseComponent[key] = value;
/* eslint-enable no-param-reassign */
return BaseComponent;
};
};
exports.default = (0, _createHelper2.default)(setStatic, 'setStatic', false);
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(3);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var shouldUpdate = function shouldUpdate(test) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
return function (_Component) {
_inherits(_class, _Component);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
_class.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return test(this.props, nextProps);
};
_class.prototype.render = function render() {
return factory(this.props);
};
return _class;
}(_react.Component);
};
};
exports.default = (0, _createHelper2.default)(shouldUpdate, 'shouldUpdate');
/***/ },
/* 11 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var omit = function omit(obj, keys) {
var rest = _objectWithoutProperties(obj, []);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (rest.hasOwnProperty(key)) {
delete rest[key];
}
}
return rest;
};
exports.default = omit;
/***/ },
/* 12 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
var pick = function pick(obj, keys) {
var result = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (obj.hasOwnProperty(key)) {
result[key] = obj[key];
}
}
return result;
};
exports.default = pick;
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {/* global window */
'use strict';
module.exports = __webpack_require__(51)(global || window || this);
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.componentFromStreamWithConfig = undefined;
var _react = __webpack_require__(3);
var _changeEmitter = __webpack_require__(19);
var _symbolObservable = __webpack_require__(13);
var _symbolObservable2 = _interopRequireDefault(_symbolObservable);
var _setObservableConfig = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var componentFromStreamWithConfig = exports.componentFromStreamWithConfig = function componentFromStreamWithConfig(config) {
return function (propsToVdom) {
return function (_Component) {
_inherits(ComponentFromStream, _Component);
function ComponentFromStream() {
var _config$fromESObserva;
var _temp, _this, _ret;
_classCallCheck(this, ComponentFromStream);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = { vdom: null }, _this.propsEmitter = (0, _changeEmitter.createChangeEmitter)(), _this.props$ = config.fromESObservable((_config$fromESObserva = {
subscribe: function subscribe(observer) {
var unsubscribe = _this.propsEmitter.listen(function (props) {
return observer.next(props);
});
return { unsubscribe: unsubscribe };
}
}, _config$fromESObserva[_symbolObservable2.default] = function () {
return this;
}, _config$fromESObserva)), _this.vdom$ = config.toESObservable(propsToVdom(_this.props$)), _temp), _possibleConstructorReturn(_this, _ret);
}
// Stream of props
// Stream of vdom
ComponentFromStream.prototype.componentWillMount = function componentWillMount() {
var _this2 = this;
// Subscribe to child prop changes so we know when to re-render
this.subscription = this.vdom$.subscribe({
next: function next(vdom) {
_this2.setState({ vdom: vdom });
}
});
this.propsEmitter.emit(this.props);
};
ComponentFromStream.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
// Receive new props from the owner
this.propsEmitter.emit(nextProps);
};
ComponentFromStream.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
return nextState.vdom !== this.state.vdom;
};
ComponentFromStream.prototype.componentWillUnmount = function componentWillUnmount() {
// Clean-up subscription before un-mounting
this.subscription.unsubscribe();
};
ComponentFromStream.prototype.render = function render() {
return this.state.vdom;
};
return ComponentFromStream;
}(_react.Component);
};
};
var componentFromStream = componentFromStreamWithConfig(_setObservableConfig.config);
exports.default = componentFromStream;
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createEagerElementUtil = __webpack_require__(18);
var _createEagerElementUtil2 = _interopRequireDefault(_createEagerElementUtil);
var _isReferentiallyTransparentFunctionComponent = __webpack_require__(16);
var _isReferentiallyTransparentFunctionComponent2 = _interopRequireDefault(_isReferentiallyTransparentFunctionComponent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createEagerElement = function createEagerElement(type, props, children) {
var isReferentiallyTransparent = (0, _isReferentiallyTransparentFunctionComponent2.default)(type);
/* eslint-disable */
var hasKey = props && props.hasOwnProperty('key');
/* eslint-enable */
return (0, _createEagerElementUtil2.default)(hasKey, isReferentiallyTransparent, type, props, children);
};
exports.default = createEagerElement;
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _isClassComponent = __webpack_require__(8);
var _isClassComponent2 = _interopRequireDefault(_isClassComponent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var isReferentiallyTransparentFunctionComponent = function isReferentiallyTransparentFunctionComponent(Component) {
return Boolean(typeof Component === 'function' && !(0, _isClassComponent2.default)(Component) && !Component.defaultProps && !Component.contextTypes && !Component.propTypes);
};
exports.default = isReferentiallyTransparentFunctionComponent;
/***/ },
/* 17 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _shouldUpdate = __webpack_require__(10);
var _shouldUpdate2 = _interopRequireDefault(_shouldUpdate);
var _shallowEqual = __webpack_require__(6);
var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _pick = __webpack_require__(12);
var _pick2 = _interopRequireDefault(_pick);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var onlyUpdateForKeys = function onlyUpdateForKeys(propKeys) {
return (0, _shouldUpdate2.default)(function (props, nextProps) {
return !(0, _shallowEqual2.default)((0, _pick2.default)(nextProps, propKeys), (0, _pick2.default)(props, propKeys));
});
};
exports.default = (0, _createHelper2.default)(onlyUpdateForKeys, 'onlyUpdateForKeys');
/***/ },
/* 18 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _react = __webpack_require__(3);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createEagerElementUtil = function createEagerElementUtil(hasKey, isReferentiallyTransparent, type, props, children) {
if (!hasKey && isReferentiallyTransparent) {
if (children) {
return type(_extends({}, props, { children: children }));
}
return type(props);
}
var Component = type;
if (children) {
return _react2.default.createElement(
Component,
props,
children
);
}
return _react2.default.createElement(Component, props);
};
exports.default = createEagerElementUtil;
/***/ },
/* 19 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var createChangeEmitter = exports.createChangeEmitter = function createChangeEmitter() {
var currentListeners = [];
var nextListeners = currentListeners;
function ensureCanMutateNextListeners() {
if (nextListeners === currentListeners) {
nextListeners = currentListeners.slice();
}
}
function listen(listener) {
if (typeof listener !== 'function') {
throw new Error('Expected listener to be a function.');
}
var isSubscribed = true;
ensureCanMutateNextListeners();
nextListeners.push(listener);
return function () {
if (!isSubscribed) {
return;
}
isSubscribed = false;
ensureCanMutateNextListeners();
var index = nextListeners.indexOf(listener);
nextListeners.splice(index, 1);
};
}
function emit() {
currentListeners = nextListeners;
var listeners = currentListeners;
for (var i = 0; i < listeners.length; i++) {
listeners[i].apply(listeners, arguments);
}
}
return {
listen: listen,
emit: emit
};
};
/***/ },
/* 20 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(3);
var _react2 = _interopRequireDefault(_react);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var branch = function branch(test, left, right) {
return function (BaseComponent) {
return function (_React$Component) {
_inherits(_class2, _React$Component);
function _class2(props, context) {
_classCallCheck(this, _class2);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this.LeftComponent = null;
_this.RightComponent = null;
_this.computeChildComponent(_this.props);
return _this;
}
_class2.prototype.computeChildComponent = function computeChildComponent(props) {
if (test(props)) {
this.leftFactory = this.leftFactory || (0, _createEagerFactory2.default)(left(BaseComponent));
this.factory = this.leftFactory;
} else {
this.rightFactory = this.rightFactory || (0, _createEagerFactory2.default)(right(BaseComponent));
this.factory = this.rightFactory;
}
};
_class2.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
this.computeChildComponent(nextProps);
};
_class2.prototype.render = function render() {
return this.factory(this.props);
};
return _class2;
}(_react2.default.Component);
};
};
exports.default = (0, _createHelper2.default)(branch, 'branch');
/***/ },
/* 21 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _omit = __webpack_require__(11);
var _omit2 = _interopRequireDefault(_omit);
var _createEagerElement = __webpack_require__(15);
var _createEagerElement2 = _interopRequireDefault(_createEagerElement);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var componentFromProp = function componentFromProp(propName) {
var Component = function Component(props) {
return (0, _createEagerElement2.default)(props[propName], (0, _omit2.default)(props, [propName]));
};
Component.displayName = 'componentFromProp(' + propName + ')';
return Component;
};
exports.default = componentFromProp;
/***/ },
/* 22 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
exports.default = compose;
function compose() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
if (funcs.length === 0) {
return function (arg) {
return arg;
};
}
if (funcs.length === 1) {
return funcs[0];
}
var last = funcs[funcs.length - 1];
return function () {
var result = last.apply(undefined, arguments);
for (var i = funcs.length - 2; i >= 0; i--) {
var f = funcs[i];
result = f(result);
}
return result;
};
}
/***/ },
/* 23 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.createEventHandlerWithConfig = undefined;
var _symbolObservable = __webpack_require__(13);
var _symbolObservable2 = _interopRequireDefault(_symbolObservable);
var _changeEmitter = __webpack_require__(19);
var _setObservableConfig = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createEventHandlerWithConfig = exports.createEventHandlerWithConfig = function createEventHandlerWithConfig(config) {
return function () {
var _config$fromESObserva;
var emitter = (0, _changeEmitter.createChangeEmitter)();
var stream = config.fromESObservable((_config$fromESObserva = {
subscribe: function subscribe(observer) {
var unsubscribe = emitter.listen(function (value) {
return observer.next(value);
});
return { unsubscribe: unsubscribe };
}
}, _config$fromESObserva[_symbolObservable2.default] = function () {
return this;
}, _config$fromESObserva));
return {
handler: emitter.emit,
stream: stream
};
};
};
var createEventHandler = createEventHandlerWithConfig(_setObservableConfig.config);
exports.default = createEventHandler;
/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(3);
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 createSink = function createSink(callback) {
return function (_Component) {
_inherits(Sink, _Component);
function Sink() {
_classCallCheck(this, Sink);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
Sink.prototype.componentWillMount = function componentWillMount() {
callback(this.props);
};
Sink.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
callback(nextProps);
};
Sink.prototype.render = function render() {
return null;
};
return Sink;
}(_react.Component);
};
exports.default = createSink;
/***/ },
/* 25 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var defaultProps = function defaultProps(props) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
var DefaultProps = function DefaultProps(ownerProps) {
return factory(ownerProps);
};
DefaultProps.defaultProps = props;
return DefaultProps;
};
};
exports.default = (0, _createHelper2.default)(defaultProps, 'defaultProps');
/***/ },
/* 26 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var flattenProp = function flattenProp(propName) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
return function (props) {
return factory(_extends({}, props, props[propName]));
};
};
};
exports.default = (0, _createHelper2.default)(flattenProp, 'flattenProp');
/***/ },
/* 27 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getContext = function getContext(contextTypes) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
var GetContext = function GetContext(ownerProps, context) {
return factory(_extends({}, ownerProps, context));
};
GetContext.contextTypes = contextTypes;
return GetContext;
};
};
exports.default = (0, _createHelper2.default)(getContext, 'getContext');
/***/ },
/* 28 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _hoistNonReactStatics = __webpack_require__(50);
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var hoistStatics = function hoistStatics(higherOrderComponent) {
return function (BaseComponent) {
var NewComponent = higherOrderComponent(BaseComponent);
(0, _hoistNonReactStatics2.default)(NewComponent, BaseComponent);
return NewComponent;
};
};
exports.default = hoistStatics;
/***/ },
/* 29 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.setObservableConfig = exports.createEventHandler = exports.mapPropsStream = exports.componentFromStream = exports.hoistStatics = exports.nest = exports.componentFromProp = exports.createSink = exports.createEagerFactory = exports.createEagerElement = exports.isClassComponent = exports.shallowEqual = exports.wrapDisplayName = exports.getDisplayName = exports.compose = exports.setDisplayName = exports.setPropTypes = exports.setStatic = exports.toClass = exports.lifecycle = exports.getContext = exports.withContext = exports.onlyUpdateForPropTypes = exports.onlyUpdateForKeys = exports.pure = exports.shouldUpdate = exports.renderNothing = exports.renderComponent = exports.branch = exports.withReducer = exports.withState = exports.flattenProp = exports.renameProps = exports.renameProp = exports.defaultProps = exports.withHandlers = exports.withPropsOnChange = exports.withProps = exports.mapProps = undefined;
var _mapProps2 = __webpack_require__(4);
var _mapProps3 = _interopRequireDefault(_mapProps2);
var _withProps2 = __webpack_require__(44);
var _withProps3 = _interopRequireDefault(_withProps2);
var _withPropsOnChange2 = __webpack_require__(45);
var _withPropsOnChange3 = _interopRequireDefault(_withPropsOnChange2);
var _withHandlers2 = __webpack_require__(43);
var _withHandlers3 = _interopRequireDefault(_withHandlers2);
var _defaultProps2 = __webpack_require__(25);
var _defaultProps3 = _interopRequireDefault(_defaultProps2);
var _renameProp2 = __webpack_require__(35);
var _renameProp3 = _interopRequireDefault(_renameProp2);
var _renameProps2 = __webpack_require__(36);
var _renameProps3 = _interopRequireDefault(_renameProps2);
var _flattenProp2 = __webpack_require__(26);
var _flattenProp3 = _interopRequireDefault(_flattenProp2);
var _withState2 = __webpack_require__(47);
var _withState3 = _interopRequireDefault(_withState2);
var _withReducer2 = __webpack_require__(46);
var _withReducer3 = _interopRequireDefault(_withReducer2);
var _branch2 = __webpack_require__(20);
var _branch3 = _interopRequireDefault(_branch2);
var _renderComponent2 = __webpack_require__(37);
var _renderComponent3 = _interopRequireDefault(_renderComponent2);
var _renderNothing2 = __webpack_require__(38);
var _renderNothing3 = _interopRequireDefault(_renderNothing2);
var _shouldUpdate2 = __webpack_require__(10);
var _shouldUpdate3 = _interopRequireDefault(_shouldUpdate2);
var _pure2 = __webpack_require__(34);
var _pure3 = _interopRequireDefault(_pure2);
var _onlyUpdateForKeys2 = __webpack_require__(17);
var _onlyUpdateForKeys3 = _interopRequireDefault(_onlyUpdateForKeys2);
var _onlyUpdateForPropTypes2 = __webpack_require__(33);
var _onlyUpdateForPropTypes3 = _interopRequireDefault(_onlyUpdateForPropTypes2);
var _withContext2 = __webpack_require__(42);
var _withContext3 = _interopRequireDefault(_withContext2);
var _getContext2 = __webpack_require__(27);
var _getContext3 = _interopRequireDefault(_getContext2);
var _lifecycle2 = __webpack_require__(30);
var _lifecycle3 = _interopRequireDefault(_lifecycle2);
var _toClass2 = __webpack_require__(41);
var _toClass3 = _interopRequireDefault(_toClass2);
var _setStatic2 = __webpack_require__(9);
var _setStatic3 = _interopRequireDefault(_setStatic2);
var _setPropTypes2 = __webpack_require__(40);
var _setPropTypes3 = _interopRequireDefault(_setPropTypes2);
var _setDisplayName2 = __webpack_require__(39);
var _setDisplayName3 = _interopRequireDefault(_setDisplayName2);
var _compose2 = __webpack_require__(22);
var _compose3 = _interopRequireDefault(_compose2);
var _getDisplayName2 = __webpack_require__(7);
var _getDisplayName3 = _interopRequireDefault(_getDisplayName2);
var _wrapDisplayName2 = __webpack_require__(48);
var _wrapDisplayName3 = _interopRequireDefault(_wrapDisplayName2);
var _shallowEqual2 = __webpack_require__(6);
var _shallowEqual3 = _interopRequireDefault(_shallowEqual2);
var _isClassComponent2 = __webpack_require__(8);
var _isClassComponent3 = _interopRequireDefault(_isClassComponent2);
var _createEagerElement2 = __webpack_require__(15);
var _createEagerElement3 = _interopRequireDefault(_createEagerElement2);
var _createEagerFactory2 = __webpack_require__(2);
var _createEagerFactory3 = _interopRequireDefault(_createEagerFactory2);
var _createSink2 = __webpack_require__(24);
var _createSink3 = _interopRequireDefault(_createSink2);
var _componentFromProp2 = __webpack_require__(21);
var _componentFromProp3 = _interopRequireDefault(_componentFromProp2);
var _nest2 = __webpack_require__(32);
var _nest3 = _interopRequireDefault(_nest2);
var _hoistStatics2 = __webpack_require__(28);
var _hoistStatics3 = _interopRequireDefault(_hoistStatics2);
var _componentFromStream2 = __webpack_require__(14);
var _componentFromStream3 = _interopRequireDefault(_componentFromStream2);
var _mapPropsStream2 = __webpack_require__(31);
var _mapPropsStream3 = _interopRequireDefault(_mapPropsStream2);
var _createEventHandler2 = __webpack_require__(23);
var _createEventHandler3 = _interopRequireDefault(_createEventHandler2);
var _setObservableConfig2 = __webpack_require__(5);
var _setObservableConfig3 = _interopRequireDefault(_setObservableConfig2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.mapProps = _mapProps3.default; // Higher-order component helpers
exports.withProps = _withProps3.default;
exports.withPropsOnChange = _withPropsOnChange3.default;
exports.withHandlers = _withHandlers3.default;
exports.defaultProps = _defaultProps3.default;
exports.renameProp = _renameProp3.default;
exports.renameProps = _renameProps3.default;
exports.flattenProp = _flattenProp3.default;
exports.withState = _withState3.default;
exports.withReducer = _withReducer3.default;
exports.branch = _branch3.default;
exports.renderComponent = _renderComponent3.default;
exports.renderNothing = _renderNothing3.default;
exports.shouldUpdate = _shouldUpdate3.default;
exports.pure = _pure3.default;
exports.onlyUpdateForKeys = _onlyUpdateForKeys3.default;
exports.onlyUpdateForPropTypes = _onlyUpdateForPropTypes3.default;
exports.withContext = _withContext3.default;
exports.getContext = _getContext3.default;
exports.lifecycle = _lifecycle3.default;
exports.toClass = _toClass3.default;
// Static property helpers
exports.setStatic = _setStatic3.default;
exports.setPropTypes = _setPropTypes3.default;
exports.setDisplayName = _setDisplayName3.default;
// Composition function
exports.compose = _compose3.default;
// Other utils
exports.getDisplayName = _getDisplayName3.default;
exports.wrapDisplayName = _wrapDisplayName3.default;
exports.shallowEqual = _shallowEqual3.default;
exports.isClassComponent = _isClassComponent3.default;
exports.createEagerElement = _createEagerElement3.default;
exports.createEagerFactory = _createEagerFactory3.default;
exports.createSink = _createSink3.default;
exports.componentFromProp = _componentFromProp3.default;
exports.nest = _nest3.default;
exports.hoistStatics = _hoistStatics3.default;
// Observable helpers
exports.componentFromStream = _componentFromStream3.default;
exports.mapPropsStream = _mapPropsStream3.default;
exports.createEventHandler = _createEventHandler3.default;
exports.setObservableConfig = _setObservableConfig3.default;
/***/ },
/* 30 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _react = __webpack_require__(3);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var lifecycle = function lifecycle(spec) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
if (false) {
console.error('lifecycle() does not support the render method; its behavior is to ' + 'pass all props and state to the base component.');
}
/* eslint-disable react/prefer-es6-class */
return (0, _react.createClass)(_extends({}, spec, {
render: function render() {
return factory(_extends({}, this.props, this.state));
}
}));
/* eslint-enable react/prefer-es6-class */
};
};
exports.default = (0, _createHelper2.default)(lifecycle, 'lifecycle');
/***/ },
/* 31 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.mapPropsStreamWithConfig = undefined;
var _symbolObservable = __webpack_require__(13);
var _symbolObservable2 = _interopRequireDefault(_symbolObservable);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _componentFromStream = __webpack_require__(14);
var _setObservableConfig = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var identity = function identity(t) {
return t;
};
var componentFromStream = (0, _componentFromStream.componentFromStreamWithConfig)({
fromESObservable: identity,
toESObservable: identity
});
var mapPropsStreamWithConfig = exports.mapPropsStreamWithConfig = function mapPropsStreamWithConfig(config) {
return function (transform) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
var fromESObservable = config.fromESObservable;
var toESObservable = config.toESObservable;
return componentFromStream(function (props$) {
var _ref;
return _ref = {
subscribe: function subscribe(observer) {
var subscription = toESObservable(transform(fromESObservable(props$))).subscribe({
next: function next(childProps) {
return observer.next(factory(childProps));
}
});
return {
unsubscribe: function unsubscribe() {
return subscription.unsubscribe();
}
};
}
}, _ref[_symbolObservable2.default] = function () {
return this;
}, _ref;
});
};
};
};
var mapPropsStream = mapPropsStreamWithConfig(_setObservableConfig.config);
exports.default = (0, _createHelper2.default)(mapPropsStream, 'mapPropsStream');
/***/ },
/* 32 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var nest = function nest() {
for (var _len = arguments.length, Components = Array(_len), _key = 0; _key < _len; _key++) {
Components[_key] = arguments[_key];
}
var factories = Components.map(_createEagerFactory2.default);
var Nest = function Nest(_ref) {
var props = _objectWithoutProperties(_ref, []);
var children = _ref.children;
return factories.reduceRight(function (child, factory) {
return factory(props, child);
}, children);
};
if (false) {
/* eslint-disable global-require */
var getDisplayName = require('./getDisplayName').default;
/* eslint-enable global-require */
var displayNames = Components.map(getDisplayName);
Nest.displayName = 'nest(' + displayNames.join(', ') + ')';
}
return Nest;
};
exports.default = nest;
/***/ },
/* 33 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _onlyUpdateForKeys = __webpack_require__(17);
var _onlyUpdateForKeys2 = _interopRequireDefault(_onlyUpdateForKeys);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var onlyUpdateForPropTypes = function onlyUpdateForPropTypes(BaseComponent) {
var propTypes = BaseComponent.propTypes;
if (false) {
/* eslint-disable global-require */
var getDisplayName = require('./getDisplayName').default;
/* eslint-enable global-require */
if (!propTypes) {
/* eslint-disable */
console.error('A component without any `propTypes` was passed to ' + '`onlyUpdateForPropTypes()`. Check the implementation of the ' + ('component with display name "' + getDisplayName(BaseComponent) + '".'));
/* eslint-enable */
}
}
var propKeys = Object.keys(propTypes || {});
var OnlyUpdateForPropTypes = (0, _onlyUpdateForKeys2.default)(propKeys)(BaseComponent);
return OnlyUpdateForPropTypes;
};
exports.default = (0, _createHelper2.default)(onlyUpdateForPropTypes, 'onlyUpdateForPropTypes', true, true);
/***/ },
/* 34 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _shouldUpdate = __webpack_require__(10);
var _shouldUpdate2 = _interopRequireDefault(_shouldUpdate);
var _shallowEqual = __webpack_require__(6);
var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var pure = (0, _shouldUpdate2.default)(function (props, nextProps) {
return !(0, _shallowEqual2.default)(props, nextProps);
});
exports.default = (0, _createHelper2.default)(pure, 'pure', true, true);
/***/ },
/* 35 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _omit = __webpack_require__(11);
var _omit2 = _interopRequireDefault(_omit);
var _mapProps = __webpack_require__(4);
var _mapProps2 = _interopRequireDefault(_mapProps);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var renameProp = function renameProp(oldName, newName) {
return (0, _mapProps2.default)(function (props) {
var _extends2;
return _extends({}, (0, _omit2.default)(props, [oldName]), (_extends2 = {}, _extends2[newName] = props[oldName], _extends2));
});
};
exports.default = (0, _createHelper2.default)(renameProp, 'renameProp');
/***/ },
/* 36 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _omit = __webpack_require__(11);
var _omit2 = _interopRequireDefault(_omit);
var _pick = __webpack_require__(12);
var _pick2 = _interopRequireDefault(_pick);
var _mapProps = __webpack_require__(4);
var _mapProps2 = _interopRequireDefault(_mapProps);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var keys = Object.keys;
var mapKeys = function mapKeys(obj, func) {
return keys(obj).reduce(function (result, key) {
var val = obj[key];
/* eslint-disable no-param-reassign */
result[func(val, key)] = val;
/* eslint-enable no-param-reassign */
return result;
}, {});
};
var renameProps = function renameProps(nameMap) {
return (0, _mapProps2.default)(function (props) {
return _extends({}, (0, _omit2.default)(props, keys(nameMap)), mapKeys((0, _pick2.default)(props, keys(nameMap)), function (_, oldName) {
return nameMap[oldName];
}));
});
};
exports.default = (0, _createHelper2.default)(renameProps, 'renameProps');
/***/ },
/* 37 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// import React from 'react'
var renderComponent = function renderComponent(Component) {
return function (_) {
var factory = (0, _createEagerFactory2.default)(Component);
var RenderComponent = function RenderComponent(props) {
return factory(props);
};
// const RenderComponent = props => <Component {...props} />
if (false) {
/* eslint-disable global-require */
var wrapDisplayName = require('./wrapDisplayName').default;
/* eslint-enable global-require */
RenderComponent.displayName = wrapDisplayName(Component, 'renderComponent');
}
return RenderComponent;
};
};
exports.default = (0, _createHelper2.default)(renderComponent, 'renderComponent', false);
/***/ },
/* 38 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var renderNothing = function renderNothing(_) {
var Nothing = function Nothing() {
return null;
};
Nothing.displayName = 'Nothing';
return Nothing;
};
exports.default = (0, _createHelper2.default)(renderNothing, 'renderNothing', false, true);
/***/ },
/* 39 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _setStatic = __webpack_require__(9);
var _setStatic2 = _interopRequireDefault(_setStatic);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var setDisplayName = function setDisplayName(displayName) {
return (0, _setStatic2.default)('displayName', displayName);
};
exports.default = (0, _createHelper2.default)(setDisplayName, 'setDisplayName', false);
/***/ },
/* 40 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _setStatic = __webpack_require__(9);
var _setStatic2 = _interopRequireDefault(_setStatic);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var setPropTypes = function setPropTypes(propTypes) {
return (0, _setStatic2.default)('propTypes', propTypes);
};
exports.default = (0, _createHelper2.default)(setPropTypes, 'setPropTypes', false);
/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(3);
var _react2 = _interopRequireDefault(_react);
var _getDisplayName = __webpack_require__(7);
var _getDisplayName2 = _interopRequireDefault(_getDisplayName);
var _isClassComponent = __webpack_require__(8);
var _isClassComponent2 = _interopRequireDefault(_isClassComponent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var toClass = function toClass(baseComponent) {
if ((0, _isClassComponent2.default)(baseComponent)) {
return baseComponent;
}
var ToClass = function (_Component) {
_inherits(ToClass, _Component);
function ToClass() {
_classCallCheck(this, ToClass);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
ToClass.prototype.render = function render() {
if (typeof baseComponent === 'string') {
return _react2.default.createElement('baseComponent', this.props);
}
return baseComponent(this.props, this.context);
};
return ToClass;
}(_react.Component);
ToClass.displayName = (0, _getDisplayName2.default)(baseComponent);
ToClass.propTypes = baseComponent.propTypes;
ToClass.contextTypes = baseComponent.contextTypes;
ToClass.defaultProps = baseComponent.defaultProps;
return ToClass;
};
exports.default = toClass;
/***/ },
/* 42 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(3);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var withContext = function withContext(childContextTypes, getChildContext) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
var WithContext = function (_Component) {
_inherits(WithContext, _Component);
function WithContext() {
var _temp, _this, _ret;
_classCallCheck(this, WithContext);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.getChildContext = function () {
return getChildContext(_this.props);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
WithContext.prototype.render = function render() {
return factory(this.props);
};
return WithContext;
}(_react.Component);
WithContext.childContextTypes = childContextTypes;
return WithContext;
};
};
exports.default = (0, _createHelper2.default)(withContext, 'withContext');
/***/ },
/* 43 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _react = __webpack_require__(3);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var mapValues = function mapValues(obj, func) {
var result = [];
var i = 0;
/* eslint-disable no-restricted-syntax */
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
i += 1;
result[key] = func(obj[key], key, i);
}
}
/* eslint-enable no-restricted-syntax */
return result;
};
var withHandlers = function withHandlers(handlers) {
return function (BaseComponent) {
var _class, _temp2, _initialiseProps;
var factory = (0, _createEagerFactory2.default)(BaseComponent);
return _temp2 = _class = function (_Component) {
_inherits(_class, _Component);
function _class() {
var _temp, _this, _ret;
_classCallCheck(this, _class);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), _possibleConstructorReturn(_this, _ret);
}
_class.prototype.componentWillReceiveProps = function componentWillReceiveProps() {
this.cachedHandlers = {};
};
_class.prototype.render = function render() {
return factory(_extends({}, this.props, this.handlers));
};
return _class;
}(_react.Component), _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.cachedHandlers = {};
this.handlers = mapValues(handlers, function (createHandler, handlerName) {
return function () {
var cachedHandler = _this2.cachedHandlers[handlerName];
if (cachedHandler) {
return cachedHandler.apply(undefined, arguments);
}
var handler = createHandler(_this2.props);
_this2.cachedHandlers[handlerName] = handler;
if (false) {
console.error('withHandlers(): Expected a map of higher-order functions. ' + 'Refer to the docs for more info.');
}
return handler.apply(undefined, arguments);
};
});
}, _temp2;
};
};
exports.default = (0, _createHelper2.default)(withHandlers, 'withHandlers');
/***/ },
/* 44 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _mapProps = __webpack_require__(4);
var _mapProps2 = _interopRequireDefault(_mapProps);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var withProps = function withProps(input) {
return (0, _mapProps2.default)(function (props) {
return _extends({}, props, typeof input === 'function' ? input(props) : input);
});
};
exports.default = (0, _createHelper2.default)(withProps, 'withProps');
/***/ },
/* 45 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _react = __webpack_require__(3);
var _pick = __webpack_require__(12);
var _pick2 = _interopRequireDefault(_pick);
var _shallowEqual = __webpack_require__(6);
var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var withPropsOnChange = function withPropsOnChange(shouldMapOrKeys, propsMapper) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
var shouldMap = typeof shouldMapOrKeys === 'function' ? shouldMapOrKeys : function (props, nextProps) {
return !(0, _shallowEqual2.default)((0, _pick2.default)(props, shouldMapOrKeys), (0, _pick2.default)(nextProps, shouldMapOrKeys));
};
return function (_Component) {
_inherits(_class2, _Component);
function _class2() {
var _temp, _this, _ret;
_classCallCheck(this, _class2);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.computedProps = propsMapper(_this.props), _temp), _possibleConstructorReturn(_this, _ret);
}
_class2.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (shouldMap(this.props, nextProps)) {
this.computedProps = propsMapper(nextProps);
}
};
_class2.prototype.render = function render() {
return factory(_extends({}, this.props, this.computedProps));
};
return _class2;
}(_react.Component);
};
};
exports.default = (0, _createHelper2.default)(withPropsOnChange, 'withPropsOnChange');
/***/ },
/* 46 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _react = __webpack_require__(3);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var withReducer = function withReducer(stateName, dispatchName, reducer, initialState) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
return function (_Component) {
_inherits(_class2, _Component);
function _class2() {
var _temp, _this, _ret;
_classCallCheck(this, _class2);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
stateValue: typeof initialState === 'function' ? initialState(_this.props) : initialState
}, _this.dispatch = function (action) {
return _this.setState(function (_ref) {
var stateValue = _ref.stateValue;
return {
stateValue: reducer(stateValue, action)
};
});
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_class2.prototype.render = function render() {
var _extends2;
return factory(_extends({}, this.props, (_extends2 = {}, _extends2[stateName] = this.state.stateValue, _extends2[dispatchName] = this.dispatch, _extends2)));
};
return _class2;
}(_react.Component);
};
};
exports.default = (0, _createHelper2.default)(withReducer, 'withReducer');
/***/ },
/* 47 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _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; };
var _react = __webpack_require__(3);
var _createHelper = __webpack_require__(1);
var _createHelper2 = _interopRequireDefault(_createHelper);
var _createEagerFactory = __webpack_require__(2);
var _createEagerFactory2 = _interopRequireDefault(_createEagerFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var withState = function withState(stateName, stateUpdaterName, initialState) {
return function (BaseComponent) {
var factory = (0, _createEagerFactory2.default)(BaseComponent);
return function (_Component) {
_inherits(_class2, _Component);
function _class2() {
var _temp, _this, _ret;
_classCallCheck(this, _class2);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
stateValue: typeof initialState === 'function' ? initialState(_this.props) : initialState
}, _this.updateStateValue = function (updateFn, callback) {
return _this.setState(function (_ref) {
var stateValue = _ref.stateValue;
return {
stateValue: typeof updateFn === 'function' ? updateFn(stateValue) : updateFn
};
}, callback);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_class2.prototype.render = function render() {
var _extends2;
return factory(_extends({}, this.props, (_extends2 = {}, _extends2[stateName] = this.state.stateValue, _extends2[stateUpdaterName] = this.updateStateValue, _extends2)));
};
return _class2;
}(_react.Component);
};
};
exports.default = (0, _createHelper2.default)(withState, 'withState');
/***/ },
/* 48 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _getDisplayName = __webpack_require__(7);
var _getDisplayName2 = _interopRequireDefault(_getDisplayName);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
return hocName + '(' + (0, _getDisplayName2.default)(BaseComponent) + ')';
};
exports.default = wrapDisplayName;
/***/ },
/* 49 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*
*/
/*eslint-disable no-self-compare */
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
}
/**
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA, objB) {
if (is(objA, objB)) {
return true;
}
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
module.exports = shallowEqual;
/***/ },
/* 50 */
/***/ function(module, exports) {
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
var REACT_STATICS = {
childContextTypes: true,
contextTypes: true,
defaultProps: true,
displayName: true,
getDefaultProps: true,
mixins: true,
propTypes: true,
type: true
};
var KNOWN_STATICS = {
name: true,
length: true,
prototype: true,
caller: true,
arguments: true,
arity: true
};
module.exports = function hoistNonReactStatics(targetComponent, sourceComponent) {
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
var keys = Object.getOwnPropertyNames(sourceComponent);
for (var i=0; i<keys.length; ++i) {
if (!REACT_STATICS[keys[i]] && !KNOWN_STATICS[keys[i]]) {
try {
targetComponent[keys[i]] = sourceComponent[keys[i]];
} catch (error) {
}
}
}
}
return targetComponent;
};
/***/ },
/* 51 */
/***/ function(module, exports) {
'use strict';
module.exports = function symbolObservablePonyfill(root) {
var result;
var Symbol = root.Symbol;
if (typeof Symbol === 'function') {
if (Symbol.observable) {
result = Symbol.observable;
} else {
result = Symbol('observable');
Symbol.observable = result;
}
} else {
result = '@@observable';
}
return result;
};
/***/ }
/******/ ])
});
; |
src/js/routes/login.js | adregan/notes | import React from 'react';
import LoginForm from '../components/loginForm';
import Logo from '../components/logo';
import { startDemo } from '../actions/demo';
import { connect } from 'react-redux';
import history from './history';
const Login = ({dispatch}) => {
return (
<div>
<Logo color="light" className="login-logo"/>
<article className="login">
<p>You must have a <a href="https://keybase.io">Keybase.io</a> account to use this app.</p>
<p>However, you can <a href='/demo' onClick={e => {e.preventDefault(); history.push('/demo/')}}>demo it here</a>.</p>
<LoginForm />
</article>
<ul className="footer">
<li>By <a href="mailto:duncanregan+notes@gmail.com">Duncan Regan</a></li>
<li><a href="https://github.com/adregan/notes#about">About</a></li>
<li><a href="https://github.com/adregan/notes/">Github</a></li>
</ul>
</div>
);
}
export default connect()(Login); |
src/js/modules/ReadingEntitiesD3V4.js | fredyagomez/reactjs-D3-V4-grommet |
import React from 'react';
import * as d3 from 'd3';
import DiagramBox from './DiagramBox';
import DiagramTitle from './DiagramTitle';
import DiagramLine from './DiagramLine';
import DiagramRelationship from './DiagramRelationship';
import DiagramAttribute from './DiagramAttribute';
import Table from 'grommet/components/Table';
import TableRow from 'grommet/components/TableRow';
import Layer from 'grommet/components/Layer';
import Heading from 'grommet/components/Heading';
import ReactTransitionGroup from 'react-addons-transition-group';
export default class ReadingEntitiesD3V4 extends React.Component {
constructor() {
super();
this.parentHandleClick = this.parentHandleClick.bind(this);
this._onClose = this._onClose.bind(this);
this.state = {xaxis: [], xaxis1: [], entity :[], flag_rightTable: false};
}
componentWillMount() {
this.getData();
}
getData() {
let xaxispush1 = [];
this.props.comment.entities.map ((comment, index) => {
let position_list = function() {
this.xpos = comment.x;
this.ypos = comment.y;
this.length = comment.attributes.length;
this.color = comment.color;
this.name = comment.name;
this.attributes = comment.attributes;
this.relationship = comment.relationship;
};
let position = new position_list();
let position_array = new Array(position);
xaxispush1.push(position_array);
});
this.setState({xaxis1: xaxispush1});
}
parentHandleClick () {
this.setState({flag_rightTable: true});
}
_onClose () {
this.setState({flag_rightTable: false});
}
render () {
let search_entity2 = [];
let model = this.props.comment.title;
let diagrambox = this.state.xaxis1.map ((xcomment, xindex) => {
let x_pos;
for(let prop in xcomment) {
x_pos = xcomment[prop];
let entity_list = function() {
this.name = x_pos.name;
this.xpos = x_pos.xpos;
this.ypos = x_pos.ypos;
this.length = x_pos.attributes.length;
};
let entity2 = new entity_list();
search_entity2.push(entity2);
let transition = d3.transition().duration(2050).ease(d3.easeCubicInOut);
return (
<DiagramBox onClick={this.parentHandleClick} model={model} relationship={x_pos.relationship} attributes={x_pos.attributes} entity={x_pos.name} letterx={x_pos.xpos} color={x_pos.color} length={x_pos.length} lettery={x_pos.ypos} i={xindex} key={`letter-${x_pos.x}${xindex}`} transition={transition} search_entity={search_entity2} />
);
}
return true;
});
let diagramtitle = this.state.xaxis1.map ((xcomment, xindex) => {
let x_pos;
for(let prop in xcomment) {
x_pos = xcomment[prop];
let transition = d3.transition().duration(2050).ease(d3.easeCubicInOut);
let y = x_pos.ypos + 20;
let x = x_pos.xpos + 5;
return (
<DiagramTitle model={model} relationship={x_pos.relationship} attributes={x_pos.attributes} entity={x_pos.name} letterx={x} color={x_pos.color} length={x_pos.length} lettery={y} i={xindex} key={`letter-${x_pos.x}${xindex}`} transition={transition}/>
);
}
return true;
});
let diagramattributearray = [];
this.state.xaxis1.map ((comment, index) => {
let x_pos;
for(let prop in comment) {
x_pos = comment[prop];
let y = x_pos.ypos + 28;
let x = x_pos.xpos + 5;
x_pos.attributes.map((xcomment, index) => {
y = y + 18;
let name = xcomment.name;
diagramattributearray.push({x: x, y: y, name: name});
});
}
});
let diagramattribute = diagramattributearray.map ((comment, index) => {
let transition = d3.transition().duration(2050).ease(d3.easeCubicInOut);
return (
<DiagramAttribute x={comment.x} y={comment.y} name={comment.name} i={index} key={`letter-${comment.x}${index}`} transition={transition}/>
);
});
let diagramline = this.state.xaxis1.map ((xcomment, xindex) => {
let x_pos;
for(let prop in xcomment) {
x_pos = xcomment[prop];
let transition = d3.transition().duration(2050).ease(d3.easeCubicInOut);
let lengthString=23;
let NewLengthStringI=23;
let NewLengthStringII;
let NewLengthString;
if (x_pos.name.length > lengthString) {
NewLengthStringII = x_pos.name.length;
}
x_pos.attributes.map ((comment, index) => {
if (comment.name.length > NewLengthStringI) {
NewLengthStringI = comment.name.length;
}
});
if (NewLengthStringII > NewLengthStringI) {
NewLengthString = 5.1765*NewLengthStringII + 56.941;
} else if (NewLengthStringI > NewLengthStringII) {
NewLengthString = 5.1765*NewLengthStringI + 56.941;
} else {
NewLengthString = 210;
}
let y1 = x_pos.ypos + 30;
let x1 = x_pos.xpos;
let y2 = x_pos.ypos + 30;
let x2 = x_pos.xpos+NewLengthString;
return (
<DiagramLine model={model} relationship={x_pos.relationship} attributes={x_pos.attributes} entity={x_pos.name} x1={x1} y1={y1} x2={x2} y2={y2} color={x_pos.color} length={x_pos.length} i={xindex} key={`letter-${x_pos.x}${xindex}`} transition={transition}/>
);
}
return true;
});
let diagramrelationshiparray = [];
this.state.xaxis1.map ((xcomment, xindex) => {
let x_pos;
for(let prop in xcomment) {
x_pos = xcomment[prop];
let entity_list = function() {
this.name = x_pos.name;
this.xpos = x_pos.xpos;
this.ypos = x_pos.ypos;
this.length = x_pos.attributes.length;
};
let entity2 = new entity_list();
search_entity2.push(entity2);
let length = x_pos.length;
let lengthString=23;
let NewLengthStringI=23;
let NewLengthStringII;
let NewLengthString;
if (x_pos.name.length > lengthString) {
NewLengthStringII = x_pos.name.length;
}
x_pos.attributes.map ((comment, index) => {
if (comment.name.length > NewLengthStringI) {
NewLengthStringI = comment.name.length;
}
});
if (NewLengthStringII > NewLengthStringI) {
NewLengthString = 5.1765*NewLengthStringII + 56.941;
} else if (NewLengthStringI > NewLengthStringII) {
NewLengthString = 5.1765*NewLengthStringI + 56.941;
} else {
NewLengthString = 210;
}
let y1 = x_pos.ypos;
let x1 = x_pos.xpos;
let new_x1;
let new_x2;
let new_y1;
let new_y2;
x_pos.relationship.map ((commentI) => {
let to = commentI.to;
let new_x;
let new_y;
let new_length;
search_entity2.map ((commentII) => {
if (to == commentII.name) {
new_x = commentII.xpos;
new_y = commentII.ypos;
new_length = commentII.length;
}
});
if (new_x > x1) {
new_x1 = new_x;
new_y1 = new_y+40;
new_x2 = x1 + NewLengthString;
new_y2 = y1+40;
} else if (new_x == x1 && new_y > y1) {
new_x1 = new_x+90;
new_y1 = new_y;
new_x2 = x1+90;
new_y2 = y1 + 20*length+30;
} else if (new_x == x1 && new_y < y1) {
new_x1 = new_x+90;
new_y1 = new_y+ 20*new_length+30;
new_x2 = x1+90;
new_y2 = y1;
} else if (new_x < x1) {
new_x1 = new_x + NewLengthString;
new_y1 = new_y+40;
new_x2 = x1;
new_y2 = y1+40;
} else {
new_x1 = new_x;
new_y1 = new_y;
new_x2 = x1;
new_y2 = y1;
}
diagramrelationshiparray.push({new_x1: new_x1, new_y1:new_y1, new_x2:new_x2, new_y2:new_y2});
});
}
return true;
});
let diagramrelationship = diagramrelationshiparray.map ((comment, index) => {
let transition = d3.transition().duration(2050).ease(d3.easeCubicInOut);
return (
<DiagramRelationship x1={comment.new_x1} y1={comment.new_y1} x2={comment.new_x2} y2={comment.new_y2} i={index} key={`letter-${comment.new_x1}${index}`} transition={transition}/>
);
});
let entity = "Title";
let rightTable;
if(this.state.flag_rightTable) {
rightTable = (
<Layer closer={true} align="right" onClose={this._onClose}>
<Heading tag="h2">
{entity}
</Heading>
<hr/>
<Table>
<thead>
<tr>
<th><b>Type</b></th>
<th><b>Title</b></th>
<th><b>Organization</b></th>
<th><b>Status</b></th>
<th><b>FullName</b></th>
<th><b>Domain</b></th>
</tr>
</thead>
<tbody>
<TableRow key="Title">
<td>Type</td>
<td>Title</td>
<td>Organization</td>
<td>Status</td>
<td>FullName</td>
<td>Domain</td>
</TableRow>
</tbody>
</Table>
</Layer>
);
}
return (
<g>
{rightTable}
<ReactTransitionGroup component="g">
{diagrambox}
</ReactTransitionGroup>
<ReactTransitionGroup component="g">
{diagramtitle}
</ReactTransitionGroup>
<ReactTransitionGroup component="g">
{diagramline}
</ReactTransitionGroup>
<ReactTransitionGroup component="g">
{diagramrelationship}
</ReactTransitionGroup>
<ReactTransitionGroup component="g">
{diagramattribute}
</ReactTransitionGroup>
</g>
);
}
};
|
app/javascript/mastodon/features/status/components/action_bar.js | mosaxiv/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import IconButton from '../../../components/icon_button';
import ImmutablePropTypes from 'react-immutable-proptypes';
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { defineMessages, injectIntl } from 'react-intl';
import { me } from '../../../initial_state';
const messages = defineMessages({
delete: { id: 'status.delete', defaultMessage: 'Delete' },
redraft: { id: 'status.redraft', defaultMessage: 'Delete & re-draft' },
direct: { id: 'status.direct', defaultMessage: 'Direct message @{name}' },
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
reply: { id: 'status.reply', defaultMessage: 'Reply' },
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
reblog_private: { id: 'status.reblog_private', defaultMessage: 'Boost to original audience' },
cancel_reblog_private: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' },
cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' },
favourite: { id: 'status.favourite', defaultMessage: 'Favourite' },
mute: { id: 'status.mute', defaultMessage: 'Mute @{name}' },
muteConversation: { id: 'status.mute_conversation', defaultMessage: 'Mute conversation' },
unmuteConversation: { id: 'status.unmute_conversation', defaultMessage: 'Unmute conversation' },
block: { id: 'status.block', defaultMessage: 'Block @{name}' },
report: { id: 'status.report', defaultMessage: 'Report @{name}' },
share: { id: 'status.share', defaultMessage: 'Share' },
pin: { id: 'status.pin', defaultMessage: 'Pin on profile' },
unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' },
embed: { id: 'status.embed', defaultMessage: 'Embed' },
});
@injectIntl
export default class ActionBar extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map.isRequired,
onReply: PropTypes.func.isRequired,
onReblog: PropTypes.func.isRequired,
onFavourite: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onDirect: PropTypes.func.isRequired,
onMention: PropTypes.func.isRequired,
onMute: PropTypes.func,
onMuteConversation: PropTypes.func,
onBlock: PropTypes.func,
onReport: PropTypes.func,
onPin: PropTypes.func,
onEmbed: PropTypes.func,
intl: PropTypes.object.isRequired,
};
handleReplyClick = () => {
this.props.onReply(this.props.status);
}
handleReblogClick = (e) => {
this.props.onReblog(this.props.status, e);
}
handleFavouriteClick = () => {
this.props.onFavourite(this.props.status);
}
handleDeleteClick = () => {
this.props.onDelete(this.props.status, this.context.router.history);
}
handleRedraftClick = () => {
this.props.onDelete(this.props.status, this.context.router.history, true);
}
handleDirectClick = () => {
this.props.onDirect(this.props.status.get('account'), this.context.router.history);
}
handleMentionClick = () => {
this.props.onMention(this.props.status.get('account'), this.context.router.history);
}
handleMuteClick = () => {
this.props.onMute(this.props.status.get('account'));
}
handleConversationMuteClick = () => {
this.props.onMuteConversation(this.props.status);
}
handleBlockClick = () => {
this.props.onBlock(this.props.status.get('account'));
}
handleReport = () => {
this.props.onReport(this.props.status);
}
handlePinClick = () => {
this.props.onPin(this.props.status);
}
handleShare = () => {
navigator.share({
text: this.props.status.get('search_index'),
url: this.props.status.get('url'),
});
}
handleEmbed = () => {
this.props.onEmbed(this.props.status);
}
render () {
const { status, intl } = this.props;
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'));
const mutingConversation = status.get('muted');
let menu = [];
if (publicStatus) {
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
menu.push(null);
}
if (me === status.getIn(['account', 'id'])) {
if (publicStatus) {
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
} else {
if (status.get('visibility') === 'private') {
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancel_reblog_private : messages.reblog_private), action: this.handleReblogClick });
}
}
menu.push(null);
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
menu.push(null);
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick });
} else {
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
menu.push({ text: intl.formatMessage(messages.direct, { name: status.getIn(['account', 'username']) }), action: this.handleDirectClick });
menu.push(null);
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
}
const shareButton = ('share' in navigator) && status.get('visibility') === 'public' && (
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.share)} icon='share-alt' onClick={this.handleShare} /></div>
);
let reblogIcon = 'retweet';
if (status.get('visibility') === 'direct') reblogIcon = 'envelope';
else if (status.get('visibility') === 'private') reblogIcon = 'lock';
let reblog_disabled = (status.get('visibility') === 'direct' || status.get('visibility') === 'private');
return (
<div className='detailed-status__action-bar'>
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_id', null) === null ? 'reply' : 'reply-all'} onClick={this.handleReplyClick} /></div>
<div className='detailed-status__button'><IconButton disabled={reblog_disabled} active={status.get('reblogged')} title={reblog_disabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} icon={reblogIcon} onClick={this.handleReblogClick} /></div>
<div className='detailed-status__button'><IconButton className='star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} /></div>
{shareButton}
<div className='detailed-status__action-bar-dropdown'>
<DropdownMenuContainer size={18} icon='ellipsis-h' items={menu} direction='left' title='More' />
</div>
</div>
);
}
}
|
node_modules/react-bootstrap/es/SplitButton.js | xuan6/admin_dashboard_local_dev | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import _extends from 'babel-runtime/helpers/extends';
import React from 'react';
import PropTypes from 'prop-types';
import Button from './Button';
import Dropdown from './Dropdown';
import SplitToggle from './SplitToggle';
import splitComponentProps from './utils/splitComponentProps';
var propTypes = _extends({}, Dropdown.propTypes, {
// Toggle props.
bsStyle: PropTypes.string,
bsSize: PropTypes.string,
href: PropTypes.string,
onClick: PropTypes.func,
/**
* The content of the split button.
*/
title: PropTypes.node.isRequired,
/**
* Accessible label for the toggle; the value of `title` if not specified.
*/
toggleLabel: PropTypes.string,
// Override generated docs from <Dropdown>.
/**
* @private
*/
children: PropTypes.node
});
var SplitButton = function (_React$Component) {
_inherits(SplitButton, _React$Component);
function SplitButton() {
_classCallCheck(this, SplitButton);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
SplitButton.prototype.render = function render() {
var _props = this.props,
bsSize = _props.bsSize,
bsStyle = _props.bsStyle,
title = _props.title,
toggleLabel = _props.toggleLabel,
children = _props.children,
props = _objectWithoutProperties(_props, ['bsSize', 'bsStyle', 'title', 'toggleLabel', 'children']);
var _splitComponentProps = splitComponentProps(props, Dropdown.ControlledComponent),
dropdownProps = _splitComponentProps[0],
buttonProps = _splitComponentProps[1];
return React.createElement(
Dropdown,
_extends({}, dropdownProps, {
bsSize: bsSize,
bsStyle: bsStyle
}),
React.createElement(
Button,
_extends({}, buttonProps, {
disabled: props.disabled,
bsSize: bsSize,
bsStyle: bsStyle
}),
title
),
React.createElement(SplitToggle, {
'aria-label': toggleLabel || title,
bsSize: bsSize,
bsStyle: bsStyle
}),
React.createElement(
Dropdown.Menu,
null,
children
)
);
};
return SplitButton;
}(React.Component);
SplitButton.propTypes = propTypes;
SplitButton.Toggle = SplitToggle;
export default SplitButton; |
docs/src/Code.js | cristovao-trevisan/react-plotter | import React from 'react'
import SyntaxHighlighter from 'react-syntax-highlighter'
import { docco } from 'react-syntax-highlighter/dist/styles'
const Code = ({children}) => {
return (
<div>
<SyntaxHighlighter language='javascript' style={docco}>
{children}
</SyntaxHighlighter>
</div>
)
}
export default Code
|
src/components/wrapper/decorator.js | chuckharmston/testpilot-contribute | import React from 'react';
import { addDecorator } from '@kadira/storybook';
import { Width, Wrapper } from './index';
export const wrapper = (extraClass = 'default', innerStyles = {}) => {
return story => (
<Wrapper extraClass={extraClass} innerStyles={innerStyles}>
{story()}
</Wrapper>
);
};
|
src/modules/about-maizuo/community/index.js | skydaya/react-sell | /**
* Created by dllo on 17/8/29.
*/
import React from 'react'
import ReactDOM from 'react-dom'
import App from './app'
ReactDOM.render(
<App />,
document.getElementById('community')
) |
src/message/MessageListLoading.js | nashvail/zulip-mobile | /* @flow */
import React from 'react';
import { StyleSheet, ScrollView } from 'react-native';
import MessageLoading from '../message/MessageLoading';
const styles = StyleSheet.create({
list: {
flexGrow: 1,
justifyContent: 'space-around',
},
});
export default () => (
<ScrollView contentContainerStyle={styles.list}>
<MessageLoading />
<MessageLoading />
<MessageLoading />
<MessageLoading />
<MessageLoading />
<MessageLoading />
<MessageLoading />
</ScrollView>
);
|
fields/types/localfile/LocalFileField.js | nickhsine/keystone | import Field from '../Field';
import React from 'react';
import ReactDOM from 'react-dom';
import { Button, FormField, FormInput, FormNote } from 'elemental';
module.exports = Field.create({
shouldCollapse () {
return this.props.collapse && !this.hasExisting();
},
fileFieldNode () {
return ReactDOM.findDOMNode(this.refs.fileField);
},
changeFile () {
this.fileFieldNode().click();
},
getFileSource () {
if (this.hasLocal()) {
return this.state.localSource;
} else if (this.hasExisting()) {
return this.props.value.url;
} else {
return null;
}
},
getFileURL () {
if (!this.hasLocal() && this.hasExisting()) {
return this.props.value.url;
}
},
undoRemove () {
this.fileFieldNode().value = '';
this.setState({
removeExisting: false,
localSource: null,
origin: false,
action: null,
});
},
fileChanged (event) { // eslint-disable-line no-unused-vars
this.setState({
origin: 'local',
});
},
removeFile (e) {
var state = {
localSource: null,
origin: false,
};
if (this.hasLocal()) {
this.fileFieldNode().value = '';
} else if (this.hasExisting()) {
state.removeExisting = true;
if (this.props.autoCleanup) {
if (e.altKey) {
state.action = 'reset';
} else {
state.action = 'delete';
}
} else {
if (e.altKey) {
state.action = 'delete';
} else {
state.action = 'reset';
}
}
}
this.setState(state);
},
hasLocal () {
return this.state.origin === 'local';
},
hasFile () {
return this.hasExisting() || this.hasLocal();
},
hasExisting () {
return !!this.props.value.filename;
},
getFilename () {
if (this.hasLocal()) {
return this.fileFieldNode().value.split('\\').pop();
} else {
return this.props.value.filename;
}
},
renderFileDetails (add) {
var values = null;
if (this.hasFile() && !this.state.removeExisting) {
values = (
<div className="file-values">
<FormInput noedit>{this.getFilename()}</FormInput>
</div>
);
}
return (
<div key={this.props.path + '_details'} className="file-details">
{values}
{add}
</div>
);
},
renderAlert () {
if (this.hasLocal()) {
return (
<div className="file-values upload-queued">
<FormInput noedit>File selected - save to upload</FormInput>
</div>
);
} else if (this.state.origin === 'cloudinary') {
return (
<div className="file-values select-queued">
<FormInput noedit>File selected from Cloudinary</FormInput>
</div>
);
} else if (this.state.removeExisting) {
return (
<div className="file-values delete-queued">
<FormInput noedit>File {this.props.autoCleanup ? 'deleted' : 'removed'} - save to confirm</FormInput>
</div>
);
} else {
return null;
}
},
renderClearButton () {
if (this.state.removeExisting) {
return (
<Button type="link" onClick={this.undoRemove}>
Undo Remove
</Button>
);
} else {
var clearText;
if (this.hasLocal()) {
clearText = 'Cancel Upload';
} else {
clearText = (this.props.autoCleanup ? 'Delete File' : 'Remove File');
}
return (
<Button type="link-cancel" onClick={this.removeFile}>
{clearText}
</Button>
);
}
},
renderFileField () {
if (!this.shouldRenderField()) return null;
return <input ref="fileField" type="file" name={this.props.paths.upload} className="field-upload" onChange={this.fileChanged} tabIndex="-1" />;
},
renderFileAction () {
if (!this.shouldRenderField()) return null;
return <input type="hidden" name={this.props.paths.action} className="field-action" value={this.state.action} />;
},
renderFileToolbar () {
return (
<div key={this.props.path + '_toolbar'} className="file-toolbar">
<div className="u-float-left">
<Button onClick={this.changeFile}>
{this.hasFile() ? 'Change' : 'Upload'} File
</Button>
{this.hasFile() && this.renderClearButton()}
</div>
</div>
);
},
renderNote () {
if (!this.props.note) return null;
return <FormNote note={this.props.note} />;
},
renderUI () {
var container = [];
var body = [];
var hasFile = this.hasFile();
if (this.shouldRenderField()) {
if (hasFile) {
container.push(this.renderFileDetails(this.renderAlert()));
}
body.push(this.renderFileToolbar());
} else {
if (hasFile) {
container.push(this.renderFileDetails());
} else {
container.push(<FormInput noedit>no file</FormInput>);
}
}
return (
<FormField label={this.props.label} className="field-type-localfile">
{this.renderFileField()}
{this.renderFileAction()}
<div className="file-container">{container}</div>
{body}
{this.renderNote()}
</FormField>
);
},
});
|
app/components/Gallery.js | cdiezmoran/AlphaStage-desktop | // @flow
import React, { Component } from 'react';
import Slider from 'react-slick';
class Gallery extends Component {
props: {
images: Array<string>,
videos: Array<string>
}
render() {
const { images, videos } = this.props;
if (images.length === 0 && videos.length === 0) {
return <p>Did not find any videos or images</p>;
}
const videosJSX = videos.map((video, i) => {
if (i === 0) {
return (
<div className="" key={`vid${video}`}>
<iframe className="sd-item" src={`${video}?enablejsapi=1`} frameBorder="0" width="100%" height="100%" id={`trailerFrame${i}`} />
</div>
);
}
return (
<div key={`vid${video}`}>
<iframe className="sd-item" src={`${video}?enablejsapi=1`} frameBorder="0" width="100%" height="100%" id={`trailerFrame${i}`} />
</div>
);
});
const imagesJSX = images.map((image) =>
<div key={image}>
<img className="sd-item" src={image} alt="Game screenshot" />
</div>
);
const settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1
};
return (
<Slider {...settings}>
{videosJSX}
{imagesJSX}
</Slider>
);
}
}
export default Gallery;
|
js/src/decorators/HashTag/index.js | understory-dev/react-draft-wysiwyg | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Entity } from 'draft-js';
import classNames from 'classnames';
import styles from './styles.css'; // eslint-disable-line no-unused-vars
class Hashtag {
constructor(config) {
this.className = config.className;
this.hashCharacter = config.hashCharacter || '#';
this.separator = config.separator || ' ';
}
getHashtagComponent = () => {
const className = this.className;
return class HashtagComponent extends Component {
static PropTypes = {
children: PropTypes.object,
}
render() {
const { children } = this.props;
const text = children[0].props.text;
return (
<a href={text} className={classNames('rdw-hashtag-link', className)}>
{children}
</a>
);
}
};
};
findHashtagEntities = (contentBlock, callback) => {
let text = contentBlock.getText();
let startIndex = 0;
let counter = 0;
for (;text.length > 0 && startIndex >= 0;) {
if (text[0] === this.hashCharacter) {
startIndex = 0;
counter = 0;
text = text.substr(this.hashCharacter.length);
} else {
startIndex = text.indexOf(this.separator + this.hashCharacter);
if (startIndex >= 0) {
text = text.substr(startIndex + (this.separator + this.hashCharacter).length);
counter += startIndex + this.separator.length;
}
}
if (startIndex >= 0) {
const endIndex =
text.indexOf(this.separator) >= 0 ? text.indexOf(this.separator) : text.length;
const hashtagText = text.substr(0, endIndex);
if (hashtagText && hashtagText.length > 0) {
callback(counter, counter + hashtagText.length + this.hashCharacter.length);
counter += this.hashCharacter.length;
}
}
}
};
getHashtagDecorator = () => {
return {
strategy: this.findHashtagEntities,
component: this.getHashtagComponent(),
}
};
}
const getDecorator = (config) => (new Hashtag(config)).getHashtagDecorator();
module.exports = getDecorator;
|
ReduxLearn/src/containers/App.js | MisterZhouZhou/ReactNativeLearing | import React, { Component } from 'react';
import {
View,
Text,
Navigator
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import LoginPage from '../pages/LoginPage'
import MainPageView from '../pages/MainPage'
export default RootNavigation = StackNavigator({
Login: {screen: LoginPage},
MainPage: {screen: MainPageView}
})
|
scripts/index.js | JJVvV/reactstart | import React from 'react';
import App from './App';
React.render(<App />, document.getElementById('root'));
|
springboot/GReact/src/main/resources/static/app/routes/forms/containers/BootstrapValidation.js | ezsimple/java | import React from 'react'
import {Stats, BigBreadcrumbs, WidgetGrid, JarvisWidget} from '../../../components'
import MovieForm from '../components/bootstrap-validation/MovieForm'
import TogglingForm from '../components/bootstrap-validation/TogglingForm'
import AttributeForm from '../components/bootstrap-validation/AttributeForm'
import ButtonGroupForm from '../components/bootstrap-validation/ButtonGroupForm'
import ProductForm from '../components/bootstrap-validation/ProductForm'
import ProfileForm from '../components/bootstrap-validation/ProfileForm'
import ContactForm from '../components/bootstrap-validation/ContactForm'
export default class BootstrapValidation extends React.Component {
render() {
return (
<div id="content">
<div className="row">
<BigBreadcrumbs items={['Forms', 'Bootstrap Form Validation']} icon="fa fa-fw fa-pencil-square-o"
className="col-xs-12 col-sm-7 col-md-7 col-lg-4"/>
<Stats />
</div>
{/* widget grid */}
<WidgetGrid>
{/* row */}
<div className="row">
{/* NEW WIDGET ROW START */}
<div className="col-sm-6">
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#movieForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<MovieForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#togglingForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<TogglingForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#attributeForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<AttributeForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
</div>
{/* WIDGET ROW END */}
{/* NEW WIDGET ROW START */}
<div className="col-sm-6">
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#buttonGroupForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<ButtonGroupForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#productForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<ProductForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#profileForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<ProfileForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} deletebutton={false} sortable={false}>
<header>
<h2>#contactForm </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body">
<ContactForm />
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
</div>
{/* WIDGET ROW END */}
</div>
{/* end row */}
</WidgetGrid>
{/* end widget grid */}
</div>
)
}
} |
app/components/navbar/login-modal/SubmitButton.js | OldFresco/web-app-kiwwi | import React, { Component } from 'react';
import FlatButton from 'material-ui/FlatButton';
class SubmitButton extends Component {
constructor(props) {
super(props);
this.muiName = 'FlatButton';
}
render() {
return (
<FlatButton
hoverColor = {'lavenderblush'}
labelStyle={{ color: '#2BC677' }}
label="Submit"
primary={true}
keyboardFocused={true}
onTouchTap={this.props.onLoginRequest}
disabled={this.props.awaitingResponse}
/>
);
}
}
export default SubmitButton; |
techCurriculum/ui/solutions/4.8/src/components/TextInput.js | AnxChow/EngineeringEssentials-group | /**
* Copyright 2017 Goldman Sachs.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
import React from 'react';
class TextInput extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
const value = event.target.value;
this.props.onChange(value);
}
render() {
return (
<div className='form-group'>
<label className='control-label'>{this.props.label}</label>
<input type='text' className='form-control' name={this.props.name} value={this.props.value} onChange={this.handleChange} />
</div>
)
}
}
export default TextInput;
|
test/test_helper.js | chavisclark/ReactReduxMiddlewares | import _$ from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import jsdom from 'jsdom';
import chai, { expect } from 'chai';
import chaiJquery from 'chai-jquery';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from '../src/reducers';
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.window = global.document.defaultView;
global.navigator = global.window.navigator;
const $ = _$(window);
chaiJquery(chai, chai.util, $);
function renderComponent(ComponentClass, props = {}, state = {}) {
const componentInstance = TestUtils.renderIntoDocument(
<Provider store={createStore(reducers, state)}>
<ComponentClass {...props} />
</Provider>
);
return $(ReactDOM.findDOMNode(componentInstance));
}
$.fn.simulate = function(eventName, value) {
if (value) {
this.val(value);
}
TestUtils.Simulate[eventName](this[0]);
};
export {renderComponent, expect};
|
src/docs/examples/Label/ExampleOptional.js | StudentOfJS/ps-react-rod | import React from 'react';
import Label from 'ps-react-rod/Label';
/** Optional label */
export default function ExampleOptional() {
return <Label htmlFor="test" label="test" />
} |
src/js/components/button/index.js | JetMixTech/CallBack | import React from 'react';
import PropTypes from 'prop-types';
import CN from 'classnames';
import styles from 'styles/blocks/button';
import { Icon } from 'js/components/ui';
const Button = ({ icon, text, view, theme, onClick, disabled }) => {
const buttonCN = CN(styles.button, styles[view], styles[theme], {
[styles.button_disabled]: disabled
});
const iconCN = CN(styles.text, {
[styles.text_shifted]: !!icon
});
return (
<button className={ buttonCN } onClick={ onClick } disabled={ disabled }>
<span className={ styles.in }>
{ icon && <Icon view={ icon } /> }
{ text && <span className={ iconCN }>{ text }</span> }
</span>
</button>
);
};
Button.propTypes = {
icon: PropTypes.string,
text: PropTypes.string,
theme: PropTypes.string,
view: PropTypes.string,
onClick: PropTypes.func,
disabled: PropTypes.bool
};
Button.defaultProps = {
theme: 'winter'
};
export default Button;
|
src/docs/examples/TextInput/ExampleOptional.js | chadacious/ps-react-chadacious | import React from 'react';
import TextInput from 'ps-react-chadacious/TextInput';
/** Optional TextBox */
export default class ExampleOptional extends React.Component {
render() {
return (
<TextInput
htmlId="example-optional"
label="First Name"
name="firstname"
onChange={() => {}}
/>
)
}
} |
docs/app/Examples/elements/Image/Variations/index.js | aabustamante/Semantic-UI-React | import React from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
import { Message } from 'semantic-ui-react'
const ImageVariationsExamples = () => (
<ExampleSection title='Variations'>
<ComponentExample
title='Avatar'
description='An image may be formatted to appear inline with text as an avatar.'
examplePath='elements/Image/Variations/ImageExampleAvatar'
/>
<ComponentExample
title='Bordered'
description='An image may include a border to emphasize the edges of white or transparent content.'
examplePath='elements/Image/Variations/ImageExampleBordered'
/>
<ComponentExample
title='Fluid'
description='An image can take up the width of its container.'
examplePath='elements/Image/Variations/ImageExampleFluid'
/>
<ComponentExample
title='Rounded'
description='An image may appear rounded.'
examplePath='elements/Image/Variations/ImageExampleRounded'
/>
<ComponentExample
title='Circular'
description='An image may appear circular.'
examplePath='elements/Image/Variations/ImageExampleCircular'
>
<Message warning>
Perfectly circular images require a perfectly square image file.
</Message>
</ComponentExample>
<ComponentExample
title='Vertically Aligned'
description='An image can specify its vertical alignment.'
examplePath='elements/Image/Variations/ImageExampleVerticallyAligned'
/>
<ComponentExample
title='Centered'
description='An image can appear centered in a content block.'
examplePath='elements/Image/Variations/ImageExampleCentered'
/>
<ComponentExample
title='Spaced'
description='An image can specify that it needs an additional spacing to separate it from nearby content.'
examplePath='elements/Image/Variations/ImageExampleSpaced'
/>
<ComponentExample
title='Floated'
description='An image can appear to the left or right of other content.'
examplePath='elements/Image/Variations/ImageExampleFloated'
/>
<ComponentExample
title='Size'
description='An image may appear at different sizes.'
examplePath='elements/Image/Variations/ImageExampleSize'
/>
</ExampleSection>
)
export default ImageVariationsExamples
|
src/client.js | trueter/react-redux-universal-hot-example | /**
* THIS IS THE ENTRY POINT FOR THE CLIENT, JUST LIKE server.js IS THE ENTRY POINT FOR THE SERVER.
*/
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import createStore from './redux/create';
import ApiClient from './helpers/ApiClient';
import io from 'socket.io-client';
import {Provider} from 'react-redux';
import { Router, browserHistory } from 'react-router';
import { ReduxAsyncConnect } from 'redux-async-connect';
import useScroll from 'scroll-behavior/lib/useStandardScroll';
import getRoutes from './routes';
const client = new ApiClient();
const history = useScroll(() => browserHistory)();
const dest = document.getElementById('content');
const store = createStore(history, client, window.__data);
function initSocket() {
const socket = io('', {path: '/ws'});
socket.on('news', (data) => {
console.log(data);
socket.emit('my other event', { my: 'data from client' });
});
socket.on('msg', (data) => {
console.log(data);
});
return socket;
}
global.socket = initSocket();
const component = (
<Router render={(props) =>
<ReduxAsyncConnect {...props} helpers={{client}} filter={item => !item.deferred} />
} history={history}>
{getRoutes(store)}
</Router>
);
ReactDOM.render(
<Provider store={store} key="provider">
{component}
</Provider>,
dest
);
if (process.env.NODE_ENV !== 'production') {
window.React = React; // enable debugger
if (!dest || !dest.firstChild || !dest.firstChild.attributes || !dest.firstChild.attributes['data-react-checksum']) {
console.error('Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.');
}
}
if (__DEVTOOLS__ && !window.devToolsExtension) {
const DevTools = require('./containers/DevTools/DevTools');
ReactDOM.render(
<Provider store={store} key="provider">
<div>
{component}
<DevTools />
</div>
</Provider>,
dest
);
}
|
client/views/admin/import/ImportOperationSummary.stories.js | VoiSmart/Rocket.Chat | import { Table } from '@rocket.chat/fuselage';
import React from 'react';
import ImportOperationSummary from './ImportOperationSummary';
export default {
title: 'admin/import/ImportOperationSummary',
component: ImportOperationSummary,
decorators: [
(fn) => (
<Table>
<Table.Body>{fn()}</Table.Body>
</Table>
),
],
};
export const _default = () => <ImportOperationSummary />;
export const skeleton = () => <ImportOperationSummary.Skeleton />;
|
examples/src/components/StatesField.js | peterKaleta/react-select | import React from 'react';
import Select from 'react-select';
const STATES = require('../data/states');
var id = 0;
function logChange() {
console.log.apply(console, [].concat(['Select value changed:'], Array.prototype.slice.apply(arguments)));
}
var StatesField = React.createClass({
displayName: 'StatesField',
propTypes: {
label: React.PropTypes.string,
searchable: React.PropTypes.bool,
},
getDefaultProps () {
return {
label: 'States:',
searchable: true,
};
},
getInitialState () {
return {
country: 'AU',
disabled: false,
searchable: this.props.searchable,
id: ++id,
selectValue: 'new-south-wales'
};
},
switchCountry (e) {
var newCountry = e.target.value;
console.log('Country changed to ' + newCountry);
this.setState({
country: newCountry,
selectValue: null
});
},
updateValue (newValue) {
logChange('State changed to ' + newValue);
this.setState({
selectValue: newValue || null
});
},
focusStateSelect () {
this.refs.stateSelect.focus();
},
toggleCheckbox (e) {
let newState = {};
newState[e.target.name] = e.target.checked;
this.setState(newState);
},
render () {
var ops = STATES[this.state.country];
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select ref="stateSelect" options={ops} disabled={this.state.disabled} value={this.state.selectValue} onChange={this.updateValue} searchable={this.state.searchable} />
<div style={{ marginTop: 14 }}>
<button type="button" onClick={this.focusStateSelect}>Focus Select</button>
<label className="checkbox" style={{ marginLeft: 10 }}>
<input type="checkbox" className="checkbox-control" name="searchable" checked={this.state.searchable} onChange={this.toggleCheckbox}/>
<span className="checkbox-label">Searchable</span>
</label>
<label className="checkbox" style={{ marginLeft: 10 }}>
<input type="checkbox" className="checkbox-control" name="disabled" checked={this.state.disabled} onChange={this.toggleCheckbox}/>
<span className="checkbox-label">Disabled</span>
</label>
</div>
<div className="checkbox-list">
<label className="checkbox">
<input type="radio" className="checkbox-control" checked={this.state.country === 'AU'} value="AU" onChange={this.switchCountry}/>
<span className="checkbox-label">Australia</span>
</label>
<label className="checkbox">
<input type="radio" className="checkbox-control" checked={this.state.country === 'US'} value="US" onChange={this.switchCountry}/>
<span className="checkbox-label">United States</span>
</label>
</div>
</div>
);
}
});
module.exports = StatesField;
|
docs/app/Examples/collections/Grid/Variations/GridExampleStretchedEqual.js | Rohanhacker/Semantic-UI-React | import React from 'react'
import { Grid, Image, Segment } from 'semantic-ui-react'
const GridExampleStretchedEqual = () => (
<Grid columns='equal'>
<Grid.Row stretched>
<Grid.Column>
<Segment>1</Segment>
<Segment>2</Segment>
</Grid.Column>
<Grid.Column width={6}>
<Segment>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Segment>
</Grid.Column>
<Grid.Column>
<Segment>1</Segment>
<Segment>2</Segment>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column>
<Segment>1</Segment>
<Segment>2</Segment>
</Grid.Column>
<Grid.Column width={6}>
<Segment>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Segment>
</Grid.Column>
<Grid.Column>
<Segment>1</Segment>
<Segment>2</Segment>
</Grid.Column>
</Grid.Row>
</Grid>
)
export default GridExampleStretchedEqual
|
modules/IndexRoute.js | migolo/react-router | import React from 'react'
import invariant from 'invariant'
import warning from 'warning'
import { createRouteFromReactElement } from './RouteUtils'
import { component, components, falsy } from './PropTypes'
const { bool, func } = React.PropTypes
/**
* An <IndexRoute> is used to specify its parent's <Route indexRoute> in
* a JSX route config.
*/
const IndexRoute = React.createClass({
statics: {
createRouteFromReactElement(element, parentRoute) {
if (parentRoute) {
parentRoute.indexRoute = createRouteFromReactElement(element)
} else {
warning(
false,
'An <IndexRoute> does not make sense at the root of your route config'
)
}
}
},
propTypes: {
path: falsy,
ignoreScrollBehavior: bool,
component,
components,
getComponents: func
},
render() {
invariant(
false,
'<IndexRoute> elements are for router configuration only and should not be rendered'
)
}
})
export default IndexRoute
|
app/javascript/mastodon/features/ui/components/column_link.js | TootCat/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import Link from 'react-router/lib/Link';
const ColumnLink = ({ icon, text, to, href, method, hideOnMobile }) => {
if (href) {
return (
<a href={href} className={`column-link ${hideOnMobile ? 'hidden-on-mobile' : ''}`} data-method={method}>
<i className={`fa fa-fw fa-${icon} column-link__icon`} />
{text}
</a>
);
} else {
return (
<Link to={to} className={`column-link ${hideOnMobile ? 'hidden-on-mobile' : ''}`}>
<i className={`fa fa-fw fa-${icon} column-link__icon`} />
{text}
</Link>
);
}
};
ColumnLink.propTypes = {
icon: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
to: PropTypes.string,
href: PropTypes.string,
method: PropTypes.string,
hideOnMobile: PropTypes.bool,
};
export default ColumnLink;
|
src/mixin.js | btd/react-intl | /* jshint esnext:true */
import React from 'react';
import IntlMessageFormat from 'intl-messageformat';
import IntlRelativeFormat from 'intl-relativeformat';
import createFormatCache from 'intl-format-cache';
// -----------------------------------------------------------------------------
var typesSpec = {
locales: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.array
]),
formats : React.PropTypes.object,
messages: React.PropTypes.object
};
function assertIsDate(date, errMsg) {
// Determine if the `date` is valid by checking if it is finite, which is
// the same way that `Intl.DateTimeFormat#format()` checks.
if (!isFinite(date)) {
throw new TypeError(errMsg);
}
}
export default {
statics: {
filterFormatOptions: function (obj, defaults) {
if (!defaults) { defaults = {}; }
return (this.formatOptions || []).reduce(function (opts, name) {
if (obj.hasOwnProperty(name)) {
opts[name] = obj[name];
} else if (defaults.hasOwnProperty(name)) {
opts[name] = defaults[name];
}
return opts;
}, {});
}
},
propTypes : typesSpec,
contextTypes : typesSpec,
childContextTypes: typesSpec,
getNumberFormat : createFormatCache(Intl.NumberFormat),
getDateTimeFormat: createFormatCache(Intl.DateTimeFormat),
getMessageFormat : createFormatCache(IntlMessageFormat),
getRelativeFormat: createFormatCache(IntlRelativeFormat),
getChildContext: function () {
var context = this.context;
var props = this.props;
return {
locales: props.locales || context.locales,
formats: props.formats || context.formats,
messages: props.messages || context.messages
};
},
formatDate: function (date, options) {
date = new Date(date);
assertIsDate(date, 'A date or timestamp must be provided to formatDate()');
return this._format('date', date, options);
},
formatTime: function (date, options) {
date = new Date(date);
assertIsDate(date, 'A date or timestamp must be provided to formatTime()');
return this._format('time', date, options);
},
formatRelative: function (date, options, formatOptions) {
date = new Date(date);
assertIsDate(date, 'A date or timestamp must be provided to formatRelative()');
return this._format('relative', date, options, formatOptions);
},
formatNumber: function (num, options) {
return this._format('number', num, options);
},
formatMessage: function (message, values) {
var locales = this.props.locales || this.context.locales;
var formats = this.props.formats || this.context.formats;
// When `message` is a function, assume it's an IntlMessageFormat
// instance's `format()` method passed by reference, and call it. This
// is possible because its `this` will be pre-bound to the instance.
if (typeof message === 'function') {
return message(values);
}
if (typeof message === 'string') {
message = this.getMessageFormat(message, locales, formats);
}
return message.format(values);
},
getIntlMessage: function (path) {
var messages = this.props.messages || this.context.messages;
var pathParts = path.split('.');
var message;
try {
message = pathParts.reduce(function (obj, pathPart) {
return obj[pathPart];
}, messages);
} finally {
if (message === undefined) {
throw new ReferenceError('Could not find Intl message: ' + path);
}
}
return message;
},
getNamedFormat: function (type, name) {
var formats = this.props.formats || this.context.formats;
var format = null;
try {
format = formats[type][name];
} finally {
if (!format) {
throw new ReferenceError(
'No ' + type + ' format named: ' + name
);
}
}
return format;
},
_format: function (type, value, options, formatOptions) {
var locales = this.props.locales || this.context.locales;
if (options && typeof options === 'string') {
options = this.getNamedFormat(type, options);
}
switch(type) {
case 'date':
case 'time':
return this.getDateTimeFormat(locales, options).format(value);
case 'number':
return this.getNumberFormat(locales, options).format(value);
case 'relative':
return this.getRelativeFormat(locales, options).format(value, formatOptions);
default:
throw new Error('Unrecognized format type: ' + type);
}
}
};
|
src/components/Types/Text.js | jcgertig/react-struct-editor | import React from 'react'
import BasicType from './BasicType'
import { isString } from 'lodash'
class TextType extends BasicType {
constructor() {
super()
this.type = 'Text'
}
render() {
return (
<div style={{ marginTop: '25px' }}>
<label style={{ marginBottom: 10 }} className={this.props.displayProps.labelClass}>
{this.props.struct.label}
</label>
<div className="Select">
<input
type="text"
autoComplete="off"
value={this.state.value}
onChange={this.updateValue}
className={'Select-control Input ' + this.props.displayProps.inputClass}
/>
</div>
</div>
)
}
}
TextType.checkStruct = function (value) {
return isString(value)
}
export default TextType
|
app/containers/HomePage/index.js | Frai/Events | /*
* HomePage
*
* This is the first thing users see of our App, at the '/' route
*/
import React from 'react';
import Helmet from 'react-helmet';
import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { makeSelectRepos, makeSelectLoading, makeSelectError } from 'containers/App/selectors';
import H2 from 'components/H2';
import ReposList from 'components/ReposList';
import AtPrefix from './AtPrefix';
import CenteredSection from './CenteredSection';
import Form from './Form';
import Input from './Input';
import Section from './Section';
import messages from './messages';
import { loadRepos } from '../App/actions';
import { changeUsername } from './actions';
import { makeSelectUsername } from './selectors';
export class HomePage extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
/**
* when initial state username is not null, submit the form to load repos
*/
componentDidMount() {
if (this.props.username && this.props.username.trim().length > 0) {
this.props.onSubmitForm();
}
}
render() {
const { loading, error, repos } = this.props;
const reposListProps = {
loading,
error,
repos,
};
return (
<article>
<Helmet
title="Home Page"
meta={[
{ name: 'description', content: 'A React.js Boilerplate application homepage' },
]}
/>
<div>
<CenteredSection>
<H2>
<FormattedMessage {...messages.startProjectHeader} />
</H2>
<p>
<FormattedMessage {...messages.startProjectMessage} />
</p>
</CenteredSection>
<Section>
<H2>
<FormattedMessage {...messages.trymeHeader} />
</H2>
<Form onSubmit={this.props.onSubmitForm}>
<label htmlFor="username">
<FormattedMessage {...messages.trymeMessage} />
<AtPrefix>
<FormattedMessage {...messages.trymeAtPrefix} />
</AtPrefix>
<Input
id="username"
type="text"
placeholder="mxstbr"
value={this.props.username}
onChange={this.props.onChangeUsername}
/>
</label>
</Form>
<ReposList {...reposListProps} />
</Section>
</div>
</article>
);
}
}
HomePage.propTypes = {
loading: React.PropTypes.bool,
error: React.PropTypes.oneOfType([
React.PropTypes.object,
React.PropTypes.bool,
]),
repos: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.bool,
]),
onSubmitForm: React.PropTypes.func,
username: React.PropTypes.string,
onChangeUsername: React.PropTypes.func,
};
export function mapDispatchToProps(dispatch) {
return {
onChangeUsername: (evt) => dispatch(changeUsername(evt.target.value)),
onSubmitForm: (evt) => {
if (evt !== undefined && evt.preventDefault) evt.preventDefault();
dispatch(loadRepos());
},
};
}
const mapStateToProps = createStructuredSelector({
repos: makeSelectRepos(),
username: makeSelectUsername(),
loading: makeSelectLoading(),
error: makeSelectError(),
});
// Wrap the component to inject dispatch and state into it
export default connect(mapStateToProps, mapDispatchToProps)(HomePage);
|
shared/containers/userBio.container.js | Mr-Antivirus/Riur | /**
* Copyright 2016-present, Dennis Norton.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule userBio.container
*/
'use strict';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { fromJS, Map } from 'immutable';
class UserBio extends Component {
constructor(props) {
super(props);
}
static fetchData(store) {
// Not needed, but you can dispatch an action for more details
const { auth } = store.getState();
return Promise.resolve(auth.user);
}
render() {
const { user } = this.props;
const name = user.get('facebook') != null ? user.get('facebook').get('name') : user.get('email');
const photo = user.get('facebook') != null ? user.get('facebook').get('photoURL') : '/images/reddit-logo.png';
return (
<div className='row'>
<img src={photo} className='img-responsive img-circle center-block' alt='Profile image' />
<h4 className='text-center'>{'Welcome, ' + name}</h4>
</div>
);
}
};
UserBio.propTypes = {
user: PropTypes.instanceOf(Map).isRequired,
dispatch: PropTypes.func.isRequired
};
function mapStateToProps(state) {
return {
user: fromJS(state.auth.user)
};
}
export default connect(mapStateToProps)(UserBio); |
client/modules/Post/__tests__/components/PostList.spec.js | jotamaggi/react-calendar-app | import React from 'react';
import test from 'ava';
import { shallow } from 'enzyme';
import PostList from '../../components/PostList';
const posts = [
{ name: 'Prashant', title: 'Hello Mern', slug: 'hello-mern', cuid: 'f34gb2bh24b24b2', content: "All cats meow 'mern!'" },
{ name: 'Mayank', title: 'Hi Mern', slug: 'hi-mern', cuid: 'f34gb2bh24b24b3', content: "All dogs bark 'mern!'" },
];
test('renders the list', t => {
const wrapper = shallow(
<PostList posts={posts} handleShowPost={() => {}} handleDeletePost={() => {}} />
);
t.is(wrapper.find('PostListItem').length, 2);
});
|
public/js/components/admin/feedback/timeline.react.js | rajikaimal/Coupley | /**
* Created by Isuru 1 on 07/02/2016.
*/
import React from 'react';
import Table from 'material-ui/lib/table/table';
import TableHeaderColumn from 'material-ui/lib/table/table-header-column';
import TableRow from 'material-ui/lib/table/table-row';
import TableHeader from 'material-ui/lib/table/table-header';
import TableRowColumn from 'material-ui/lib/table/table-row-column';
import TableBody from 'material-ui/lib/table/table-body';
import FeedActions from '../../../actions/admin/FeedbackActions';
import FeedStore from '../../../stores/admin/FeedbackStore';
import Feed from '../feedback/feed.react';
const ELSE = 'No any timeline feeds';
const Tables = React.createClass({
getInitialState: function () {
return {
results: FeedStore.getresults(),
};
},
componentDidMount: function () {
FeedActions.timelineFeeds();
FeedStore.addChangeListener(this._onChange);
},
_onChange: function () {
if (this.isMounted()) {
this.setState({
results: FeedStore.getresults(),
});
}
},
_renderFeedItem: function () {
console.log(this.state.results);
if (this.state.results) {
return this.state.results.map((result) => {
return (<Feed key={result.id} id={result.id} user={result.user} description={result.description} />);
});} else {
return (<div>
No any timeline feeds
</div>);
}
},
render: function () {
return (
<div>
<h1>Timeline Feedback </h1>
<table className="table table-striped table-hover">
<thead>
<tr>
<th><h2>Id</h2></th>
<th><h2>User</h2></th>
<th><h2>Description</h2></th>
</tr>
</thead>
<tbody style={{ fontSize: '18px' }}>
{this._renderFeedItem()}
</tbody>
</table>
</div>
);
},
});
export default Tables;
|
src/svg-icons/social/school.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialSchool = (props) => (
<SvgIcon {...props}>
<path d="M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82zM12 3L1 9l11 6 9-4.91V17h2V9L12 3z"/>
</SvgIcon>
);
SocialSchool = pure(SocialSchool);
SocialSchool.displayName = 'SocialSchool';
SocialSchool.muiName = 'SvgIcon';
export default SocialSchool;
|
views/Login.js | joan17cast/Enigma | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableHighlight,
TextInput
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import * as firebase from 'firebase';
// Initialize Firebase
const firebaseConfig = {
apiKey: "AIzaSyApjVv2fxBkdXmvvfFx8L6YI_RfVAVOCUs",
authDomain: "enigma-ae63b.firebaseapp.com",
databaseURL: "https://enigma-ae63b.firebaseio.com",
storageBucket: "enigma-ae63b.appspot.com",
};
var Enigmas = require('./Enigmas');
class Login extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoading: false,
userLoaded: false,
email: '',
password: '',
response: ''
};
this.getInitialView();
this.getInitialView = this.getInitialView.bind(this);
}
getInitialView(){
firebase.auth().onAuthStateChanged((user) =>{
this.setState({
userLoaded: true,
})
})
this.loadEnigmas();
}
async signUp() {
try {
await firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password);
//TODO: - Alert avisant de que s'ha creat la conta correctament
//TODO: - Falta veure si s'ha de pasar el id de usuari dins de la navegacio
this.props.navigation.navigate('Enigmas');
} catch(error) {
console.log(error);
//TODO: - Alert amb el error
}
}
async logIn() {
try {
await firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password);
//TODO: - Alert avisant de que s'ha creat la conta correctament
//TODO: - Falta veure si s'ha de pasar el id de usuari dins de la navegacio
this.props.navigation.navigate('Enigmas');
} catch(error) {
console.log(error);
//TODO: - Alert amb el error
}
}
loadEnigmas() {
if (this.state.userLoaded == true) {
//TODO: - Falta veure si s'ha de pasar el id de usuari dins de la navegacio
this.props.navigation.navigate('Enigmas');
}
}
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Enigma
</Text>
<TextInput
placeholder="example@mail.com"
style={styles.textsInput}
onChangeText={(email) => this.setState({email})}
/>
<TextInput
placeholder="Password"
secureTextEntry={true}
style={styles.textsInput}
onChangeText={(password) => this.setState({password})}
/>
<TouchableHighlight onPress={this.logIn.bind(this)}>
<Text> Login </Text>
</TouchableHighlight>
<TouchableHighlight onPress={this.signUp.bind(this)}>
<Text> Register </Text>
</TouchableHighlight>
</View>
);
}
}
//TODO Onpres button per anar a la pantalla de Enigmas
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
textsInput: {
width: 250,
}
});
module.exports = Login;
|
app/javascript/mastodon/features/compose/containers/sensitive_button_container.js | mecab/mastodon | import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import TextIconButton from '../components/text_icon_button';
import { changeComposeSensitivity } from '../../../actions/compose';
import Motion from 'react-motion/lib/Motion';
import spring from 'react-motion/lib/spring';
import { injectIntl, defineMessages } from 'react-intl';
const messages = defineMessages({
title: { id: 'compose_form.sensitive', defaultMessage: 'Mark media as sensitive' },
});
const mapStateToProps = state => ({
visible: state.getIn(['compose', 'media_attachments']).size > 0,
active: state.getIn(['compose', 'sensitive']),
});
const mapDispatchToProps = dispatch => ({
onClick () {
dispatch(changeComposeSensitivity());
},
});
class SensitiveButton extends React.PureComponent {
static propTypes = {
visible: PropTypes.bool,
active: PropTypes.bool,
onClick: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
render () {
const { visible, active, onClick, intl } = this.props;
return (
<Motion defaultStyle={{ scale: 0.87 }} style={{ scale: spring(visible ? 1 : 0.87, { stiffness: 200, damping: 3 }) }}>
{({ scale }) =>
<div style={{ display: visible ? 'block' : 'none', transform: `translateZ(0) scale(${scale})` }}>
<TextIconButton onClick={onClick} label='NSFW' title={intl.formatMessage(messages.title)} active={active} />
</div>
}
</Motion>
);
}
}
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(SensitiveButton));
|
client/pages/UserPosts/UserPosts.js | jkettmann/universal-react-relay-starter-kit | import React from 'react'
import PropTypes from 'prop-types'
import { routerShape } from 'found/lib/PropTypes'
import { graphql } from 'react-relay'
import { paginationContainer } from 'relay-compose-test'
import { compose, flattenProp, withHandlers, withProps } from 'recompose'
import PostList from '../../components/PostList'
export const POST_COUNT = 6
const UserPosts = ({ permission, posts, hasMore, loadMore, router }) => {
if (!permission.isLoggedIn) {
router.push('/login')
return <div />
}
if (!permission.canPublish) {
router.push('/')
return <div />
}
return (
<div>
<PostList
posts={posts.edges}
hasMore={hasMore}
onMore={loadMore}
/>
</div>
)
}
UserPosts.propTypes = {
router: routerShape.isRequired,
permission: PropTypes.shape({
isLoggedIn: PropTypes.bool,
canPublish: PropTypes.bool,
}).isRequired,
posts: PropTypes.shape({
edges: PropTypes.array,
}).isRequired,
hasMore: PropTypes.bool.isRequired,
loadMore: PropTypes.func.isRequired,
}
const fragments = graphql`
fragment UserPosts on Query {
permission {
isLoggedIn
canPublish
}
user {
posts (after: $afterCursor first: $count) @connection(key: "UserPosts_posts") {
pageInfo {
hasNextPage
endCursor
},
edges {
node {
id
...PostTeaser_post
}
}
}
}
}
`
const connectionConfig = {
direction: 'forward',
getFragmentVariables(prevVars, totalCount) {
return {
...prevVars,
count: totalCount,
}
},
getVariables(_props, { count, cursor }) {
return {
afterCursor: cursor,
count,
}
},
query: graphql`
query UserPostsPaginationQuery($afterCursor: String, $count: Int!) {
...UserPosts
}
`,
}
const props = withProps(({ relay }) => ({
hasMore: relay.hasMore(),
}))
const handlers = withHandlers({
loadMore: ({ relay }) => () => relay.isLoading() || relay.loadMore(POST_COUNT),
})
const enhance = compose(
paginationContainer(fragments, connectionConfig),
props,
handlers,
flattenProp('data'),
flattenProp('user'),
)
export default enhance(UserPosts)
|
components/catalog-preview.js | sgmap/inspire | import React from 'react'
import PropTypes from 'prop-types'
import {translate} from 'react-i18next'
import {get} from 'lodash'
import WarningIcon from 'react-icons/lib/fa/exclamation-triangle'
import {isObsolete} from '../lib/catalog'
import Link from './link'
import HarvestStatus from './harvest-status'
import Counter from './counter'
import Percent from './percent'
const CatalogPreview = ({catalog, t}) => {
const {metrics} = catalog
const openness = get(metrics, 'datasets.partitions.openness.yes', 0)
const download = get(metrics, 'datasets.partitions.download.yes', 0)
return (
<Link href={`/catalog?cid=${catalog._id}`} as={`/catalogs/${catalog._id}`}>
<a>
{isObsolete(catalog) && (
<span className='obsolete' title={t('catalog.obsolete')}>
<WarningIcon />
</span>
)}
<div className='title'>
<span title={catalog.name}>
{catalog.name}
</span>
</div>
<HarvestStatus harvest={catalog.service.sync} />
<div className='metrics'>
{metrics ? (
<div>
<Percent
value={openness}
total={metrics.datasets.totalCount}
size='small'
label={t('catalog.openData')} />
<Percent
value={download}
total={metrics.datasets.totalCount}
size='small'
label={t('catalog.downloadable')} />
<Counter
value={metrics.records.totalCount}
size='small'
label={t('catalog.records')} />
</div>
) : (
<div>{t('catalog.empty')}</div>
)}
</div>
<style jsx>{`
@import 'colors';
a {
display: block;
padding: 16px 22px;
text-align: left;
position: relative;
color: $darkgrey;
border-radius: 5px;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.4);
background: $white;
background: linear-gradient(180deg, #fdfdf8, $white);
&:hover {
color: inherit;
box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.4);
}
}
.obsolete {
position: absolute;
color: $yellow;
right: 12px;
top: 9px;
font-size: 2em;
}
.title {
font-size: 1.4em;
line-height: 1.2em;
padding-right: 1em;
@media (min-width: 552px) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.metrics > div {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 2.8em;
font-size: 11px;
> div {
margin: 0 0.5em;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
}
}
`}</style>
</a>
</Link>
)
}
CatalogPreview.propTypes = {
catalog: PropTypes.shape({
metrics: PropTypes.shape({
datasets: PropTypes.shape({
totalCount: PropTypes.number.isRequired
}).isRequired,
records: PropTypes.shape({
totalCount: PropTypes.number.isRequired
}).isRequired
}),
service: PropTypes.shape({
sync: PropTypes.object.isRequired
}).isRequired
}).isRequired,
t: PropTypes.func.isRequired
}
export default translate()(CatalogPreview)
|
src/svg-icons/editor/attach-file.js | pradel/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorAttachFile = (props) => (
<SvgIcon {...props}>
<path d="M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"/>
</SvgIcon>
);
EditorAttachFile = pure(EditorAttachFile);
EditorAttachFile.displayName = 'EditorAttachFile';
export default EditorAttachFile;
|
node_modules/react-router/es6/RouterContext.js | CallumRocks/ReduxSimpleStarter | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _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; };
import invariant from 'invariant';
import React from 'react';
import deprecateObjectProperties from './deprecateObjectProperties';
import getRouteParams from './getRouteParams';
import { isReactChildren } from './RouteUtils';
import warning from './routerWarning';
var _React$PropTypes = React.PropTypes;
var array = _React$PropTypes.array;
var func = _React$PropTypes.func;
var object = _React$PropTypes.object;
/**
* A <RouterContext> renders the component tree for a given router state
* and sets the history object and the current location in context.
*/
var RouterContext = React.createClass({
displayName: 'RouterContext',
propTypes: {
history: object,
router: object.isRequired,
location: object.isRequired,
routes: array.isRequired,
params: object.isRequired,
components: array.isRequired,
createElement: func.isRequired
},
getDefaultProps: function getDefaultProps() {
return {
createElement: React.createElement
};
},
childContextTypes: {
history: object,
location: object.isRequired,
router: object.isRequired
},
getChildContext: function getChildContext() {
var _props = this.props;
var router = _props.router;
var history = _props.history;
var location = _props.location;
if (!router) {
process.env.NODE_ENV !== 'production' ? warning(false, '`<RouterContext>` expects a `router` rather than a `history`') : void 0;
router = _extends({}, history, {
setRouteLeaveHook: history.listenBeforeLeavingRoute
});
delete router.listenBeforeLeavingRoute;
}
if (process.env.NODE_ENV !== 'production') {
location = deprecateObjectProperties(location, '`context.location` is deprecated, please use a route component\'s `props.location` instead. http://tiny.cc/router-accessinglocation');
}
return { history: history, location: location, router: router };
},
createElement: function createElement(component, props) {
return component == null ? null : this.props.createElement(component, props);
},
render: function render() {
var _this = this;
var _props2 = this.props;
var history = _props2.history;
var location = _props2.location;
var routes = _props2.routes;
var params = _props2.params;
var components = _props2.components;
var element = null;
if (components) {
element = components.reduceRight(function (element, components, index) {
if (components == null) return element; // Don't create new children; use the grandchildren.
var route = routes[index];
var routeParams = getRouteParams(route, params);
var props = {
history: history,
location: location,
params: params,
route: route,
routeParams: routeParams,
routes: routes
};
if (isReactChildren(element)) {
props.children = element;
} else if (element) {
for (var prop in element) {
if (Object.prototype.hasOwnProperty.call(element, prop)) props[prop] = element[prop];
}
}
if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object') {
var elements = {};
for (var key in components) {
if (Object.prototype.hasOwnProperty.call(components, key)) {
// Pass through the key as a prop to createElement to allow
// custom createElement functions to know which named component
// they're rendering, for e.g. matching up to fetched data.
elements[key] = _this.createElement(components[key], _extends({
key: key }, props));
}
}
return elements;
}
return _this.createElement(components, props);
}, element);
}
!(element === null || element === false || React.isValidElement(element)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The root route must render a single element') : invariant(false) : void 0;
return element;
}
});
export default RouterContext; |
pages/blog/test-article-two.js | b1alpha/sdj | /**
* React Static Boilerplate
* https://github.com/koistya/react-static-boilerplate
* Copyright (c) Konstantin Tarkus (@koistya) | MIT license
*/
import React, { Component } from 'react';
export default class extends Component {
render() {
return (
<div>
<h1>Test Article 2</h1>
<p>Coming soon.</p>
</div>
);
}
}
|
app/main.js | cerebral/cerebral-reference-app | import React from 'react';
import ReactDOM from 'react-dom';
import controller from './controller.js';
import {Container} from 'cerebral-view-react';
import Router from 'cerebral-module-router';
import Http from 'cerebral-module-http';
import Recorder from 'cerebral-module-recorder';
import Devtools from 'cerebral-module-devtools';
import localAssignments from './services/localAssignments';
import localLastCourse from './services/localLastCourse';
import App from './App.js';
import Home from './modules/home';
import Sessions from './modules/sessions';
import Courses from './modules/courses';
import Course from './modules/course';
import TechTree from './modules/techTree';
import MainAssignment from './modules/mainAssignment';
import Descriptions from './modules/descriptions';
import showSnackbar from 'common/factories/actions/showSnackbar.js';
import hideSnackbar from 'common/factories/actions/hideSnackbar.js';
controller.addSignals({
snackbarTimedOut: [
hideSnackbar
],
missingRouteRouted: [
showSnackbar('Denne url-en finnes ikke')
]
});
controller.addServices({
getIframePosition() {
const previewIframe = document.getElementById('previewIframe');
return {
offsetLeft: previewIframe.offsetParent.offsetLeft + previewIframe.offsetLeft,
offsetTop: previewIframe.offsetParent.offsetTop + previewIframe.offsetTop
};
},
localAssignments,
localLastCourse
});
controller.addModules({
home: Home(),
sessions: Sessions(),
courses: Courses(),
course: Course(),
techTree: TechTree(),
mainAssignment: MainAssignment(),
descriptions: Descriptions(),
http: Http(),
recorder: Recorder({
state: {
isEnded: false,
isUploading: false,
hasUpload: false,
hasRecorded: false,
isBuffering: false,
currentSeek: [0, Date.now()],
lastPaused: Date.now()
}
}),
devtools: process.env.NODE_ENV === 'production' ? () => {} : Devtools(),
router: Router({
'/': 'home.opened',
'/courses': 'courses.opened',
'/courses/:courseId/scenes/:sceneIndex': 'course.opened',
'/sessions': 'sessions.opened',
'/techtree': 'techTree.opened',
'/mainassignment/:userId': 'mainAssignment.opened',
'/mainassignment/:userId/:preview': 'mainAssignment.previewOpened',
'*': 'missingRouteRouted'
}, {
onlyHash: true,
mapper: {query: true}
})
});
window.BANAN = () => {
controller.getSignals().home.formSubmitted({
email: 'christianalfoni@gmail.com'
});
};
window.EPLE = () => {
controller.getSignals().home.formSubmitted({
email: 'tommy.ostgaard@gmail.com'
});
};
ReactDOM.render(
<Container controller={controller}>
<App/>
</Container>,
document.getElementById('root'));
|
src/Label.js | jesenko/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import bootstrapUtils, { bsStyles, bsClass } from './utils/bootstrapUtils';
import { State, DEFAULT, PRIMARY } from './styleMaps';
@bsClass('label')
@bsStyles(State.values().concat(DEFAULT, PRIMARY), DEFAULT)
class Label extends React.Component {
render() {
let classes = bootstrapUtils.getClassSet(this.props);
return (
<span {...this.props} className={classNames(this.props.className, classes)}>
{this.props.children}
</span>
);
}
}
export default Label;
|
examples/huge-apps/routes/Calendar/components/Calendar.js | tikotzky/react-router | import React from 'react';
class Calendar extends React.Component {
render () {
return (
<div>
<h2>Calendar</h2>
</div>
);
}
}
export default Calendar;
|
src/js/components/RadioButton/stories/Simple.js | HewlettPackard/grommet | import React from 'react';
import { Box, Button, RadioButton } from 'grommet';
export const Simple = () => {
const [selected, setSelected] = React.useState();
return (
<Box align="center" pad="large" gap="large">
<RadioButton
label="option 1"
name="name"
value="option 1"
checked={selected === 'option 1'}
onChange={(event) => setSelected(event.target.value)}
/>
<Button label="clear" onClick={() => setSelected(undefined)} />
</Box>
);
};
export default {
title: 'Input/RadioButton/Simple',
};
|
src/debug/debug.js | croy-kronos/fna-chrome-plugin | import React from 'react'
import ScriptInjector from '../helpers/Injector';
import { Button, Panel } from 'react-bootstrap';
class DebugComponent extends React.Component {
_toggleDebug() {
const injector = new ScriptInjector();
injector.injectFromFile("./debug/injects/toggleDebug.js");
}
render() {
return (
<Panel header={ <h4>Debug ABF</h4> }>
<Button bsStyle="primary" onClick={() => this._toggleDebug()}>Toggle DEBUG</Button>
</Panel>
);
}
}
export default DebugComponent; |
src/components/Avatar/Avatar.js | Landish/react-spectre-css | import React from 'react';
import classNames from 'classnames';
import { string, oneOf } from 'prop-types';
const Avatar = ({ source, size, icon, initials, color, ...rest }) => {
return (
<figure
style={{ background: color }}
data-initial={initials}
className={classNames({
avatar: true,
'avatar-xl': size === 'large',
'avatar-lg': size === 'normal',
'avatar-sm': size === 'small',
'avatar-xs': size === 'mini'
})}
{...rest}
>
{(!initials || (initials && source)) && <img src={source} />}
{icon && <img src={icon} className="avatar-icon" />}
</figure>
);
};
/***
* Avatar property types
*/
Avatar.propTypes = {
/**
* Avatar source
*/
source: string,
/***
* Avatar size
*/
size: oneOf(['mini', 'small', 'normal', 'large']),
/**
* Url of the icon
*/
icon: string,
/**
* Initials can be displayed, if `source` was not loaded or provided
*/
initials: string,
/**
* Any CSS-valid color value
*/
color: string
};
/**
* Avatar default properties
*/
Avatar.defaultProps = {
source: '',
icon: '',
size: 'small'
};
export default Avatar;
|
src/common/components/Routes.js | 17Q4MX2hmktmpuUKHFuoRmS5MfB5XPbhod/dropzone | import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './App';
import DashboardPage from '../../pages/dashboard/page';
import ListingsPage from '../../pages/listings/page';
import ListingPage from '../../pages/listing/page';
import CreateItemPage from '../../pages/create_item/page';
import SellersPage from '../../pages/sellers/page';
import SellerPage from '../../pages/seller/page';
export default (
<Route path="/" component={App}>
<IndexRoute component={DashboardPage} />
<Route path="home" component={DashboardPage} />
<Route path="listings" component={ListingsPage} />
<Route path="listings/:txId" component={ListingPage}/>
<Route path="create-item" component={CreateItemPage} />
<Route path="sellers" component={SellersPage}/>
<Route path="sellers/:address" component={SellerPage}/>
</Route>
);
|
src/js/modules/popupAnchor/UI/index.js | zacyu/bilibili-helper | /**
* Author: DrowsyFlesh
* Create: 2018/11/7
* Description:
*/
import React from 'react';
import ReactDOM from 'react-dom';
import styled, {createGlobalStyle} from 'styled-components';
import {UI} from 'Libs/UI';
const UIBuilder = () => {
const Main = styled.div.attrs({className: 'bilibili-helper-popup-main'})`
display: flex;
flex-direction: row-reverse;
background-color: rgb(250,250,250);
max-height: 290px;
`;
const GlobalStyle = createGlobalStyle`
body {
margin: 0;
padding: 0;
font-family: -apple-system, Helvetica Neue, Helvetica, Arial, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif;
}
`;
return {Main, GlobalStyle};
}
export class PopupAnchorUI extends UI {
constructor() {
super({
name: 'popup',
});
}
load = () => {
return new Promise(resolve => {
const {Main, GlobalStyle} = UIBuilder();
ReactDOM.render(
<Main>
<GlobalStyle/>
</Main>,
document.getElementById('root'),
() => resolve(document.querySelector('.bilibili-helper-popup-main')),
);
});
};
}
|
lib/components/ReactableUI.js | Centiq/meteor-reactable | import React from 'react';
import createReactClass from 'create-react-class';
ReactableUI = createReactClass({
mixins: [ ReactableClasses ],
shouldComponentUpdate (nextProps) {
// If ready state or stopped state has changed, then update
if (nextProps.ready !== this.props.ready) return true;
if (nextProps.subscribeStopped !== this.props.subscribeStopped) return true;
// Update on any further change, but only if we're ready
return !!nextProps.ready;
},
render () {
const classes = this.getClasses([
'reactable',
this.props.classes,
this.props.subscribeStopped ? 'stopped'
: this.props.ready ? null
: 'loading',
]);
if (this.props.subscribeStopped && this.props.stopped) {
let Component = this.props.stopped.body;
let ComponentProps = this.props.stopped.props;
if (typeof ComponentProps === 'function') {
ComponentProps = ComponentProps.call(this);
}
return (
<div id={ this.props.id } className={ classes }>
<Component { ...this.props } { ...ComponentProps }/>
</div>
);
}
if (this.props.rows.length === 0 && this.props.ready && this.props.empty) {
let Component = this.props.empty.body;
let ComponentProps = this.props.empty.props;
if (typeof ComponentProps === 'function') {
ComponentProps = ComponentProps.call(this);
}
return (
<div id={ this.props.id } className={ classes }>
<Component { ...this.props } { ...ComponentProps }/>
</div>
);
}
return (
<div id={ this.props.id } className={ classes }>
<ReactableTable { ...this.tableProps() }/>
{
this.props.paginate ? (
<ReactableNavigation { ...this.navigationProps() }/>
) : null
}
</div>
)
},
tableProps () {
let props = { ...this.props };
delete props.children;
delete props.id;
delete props.navigation;
props.classes = props.tableClasses;
delete props.tableClasses;
return props;
},
navigationProps () {
let props = { ...this.props.paginate };
props.setPaginate = this.props.onChangePaginate;
return props;
},
});
|
components/Logo.js | feedreaderco/app | import React from 'react';
import {
Image
} from 'react-native';
const uri = '../ios/FeedReader/Images.xcassets/AppIcon.appiconset/Icon-App-40x40.png';
export default () => <Image source={{uri}} />;
|
src/modules/timeline/index.js | zcfreestyle/moment-react | import React from 'react'
import ReactDOM from 'react-dom'
import App from './App' // 引入组件App
import '../../assets/styles/timeline.styl' // 引入css
import '../../assets/styles/read.styl'
import '../../assets/styles/Footer.styl'
import '../../assets/styles/Up.styl'
ReactDOM.render(
<App />,
document.getElementById('app')
)
|
ui/js/simianviz.js | jwatson0/spigo | 'use strict';
import React from 'react';
import Layout from 'layout';
import Toolbar from 'toolbar';
import Chart from 'chart';
export default React.createClass({
render () {
return (
<Layout>
<Toolbar {...this.props} />
<Chart {...this.props} />
</Layout>
);
}
});
|
templates/rubix/demo/src/routes/Editor.js | jeffthemaximum/jeffline | import React from 'react';
import ReactDOM from 'react-dom';
import {
Row,
Col,
Grid,
Panel,
PanelBody,
PanelHeader,
PanelContainer,
} from '@sketchpixy/rubix';
class TrumbowygEditor extends React.Component {
componentDidMount() {
$(ReactDOM.findDOMNode(this._el)).trumbowyg({
autogrow: true,
dir: $('html').attr('dir'),
btns: [
['viewHTML'],
['undo', 'redo'],
['formatting'],
'btnGrp-semantic',
['superscript', 'subscript'],
['link'],
['insertImage'],
'btnGrp-justify',
'btnGrp-lists',
['horizontalRule'],
['removeformat'],
]
}).trumbowyg('html', '<p>Steve Jobs became the greatest business executive of our era, the one most certain to be remembered a century from now. History will place him in the pantheon right next to Edison and Ford. More than anyone else of his time, he made products that were completely innovative, combining the power of poetry and processors.</p><blockquote><p style="margin-bottom: 12.5px;"><span style="font-size: 11pt; line-height: 1.78571;">Some people say, “Give the customers what they want.” But that’s not my approach. Our job is to figure out what they’re going to want before they do. I think Henry Ford once said, <b>“If I’d asked customers what they wanted, they would have told me, ‘A faster horse!’”</b> People don’t know what they want until you show it to them. That’s why I never rely on market research. Our task is to read things that are not yet on the page. </span><br></p><div><span style="font-size: 11pt; line-height: 1.78571;">- Steve Jobs in <i>Steve Jobs by Walter Isaacson</i></span></div></blockquote><p>Was he smart? No, not exceptionally. Instead, he was a <b><i>genius</i></b>. His imaginative leaps were instinctive, unexpected, and at times <b><i>magical</i></b>. He was, indeed, an example of what the mathematician Mark Kac called a magician genius, someone whose insights come out of the blue and require intuition more than mere mental processing power. Like a pathfinder, he could absorb information, sniff the winds, and sense what lay ahead.</p>');
}
render() {
return <div id='trumbowyg-demo' ref={(el) => this._el = el}></div>;
}
}
export default class Editor extends React.Component {
render() {
return (
<div>
<PanelContainer>
<Panel>
<PanelHeader>
<Grid>
<Row>
<Col xs={12}>
<h3 className='text-center'>Trumbowyg Editor</h3>
</Col>
</Row>
</Grid>
</PanelHeader>
<PanelBody>
<TrumbowygEditor />
</PanelBody>
</Panel>
</PanelContainer>
</div>
);
}
}
|
src/components/FacebookTabBar/index.js | r1cebank/EventCore | /* eslint-disable no-underscore-dangle */
import React from 'react';
import {
View,
TouchableOpacity,
Animated
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import Styles from './resources/style';
class FacebookTabBar extends React.Component {
static propTypes = {
goToPage: React.PropTypes.func,
activeTab: React.PropTypes.number,
tabs: React.PropTypes.array,
scrollValue: React.PropTypes.object,
style: View.propTypes.style,
containerWidth: React.PropTypes.number
};
componentDidMount() {
this.setAnimationValue({ value: this.props.activeTab });
this._listener = this.props.scrollValue.addListener(this.setAnimationValue);
}
setAnimationValue = ({ value }) => {
this.tabIcons.forEach((icon, i) => {
const progress = (value - i >= 0 && value - i <= 1) ? value - i : 1;
icon.setNativeProps({
style: {
color: this.iconColor(progress)
}
});
});
}
tabIcons = [];
// color between rgb(59,89,152) and rgb(204,204,204)
iconColor(progress) {
const red = 59 + (204 - 59) * progress;
const green = 89 + (204 - 89) * progress;
const blue = 152 + (204 - 152) * progress;
return `rgb(${red}, ${green}, ${blue})`;
}
render() {
const tabWidth = this.props.containerWidth / this.props.tabs.length;
const left = this.props.scrollValue.interpolate({
inputRange: [0, 1],
outputRange: [0, tabWidth]
});
return (
<View>
<View style={[Styles.tabs, this.props.style]}>
{this.props.tabs.map((tab, i) =>
<TouchableOpacity
key={tab}
onPress={() => this.props.goToPage(i)}
style={Styles.tab}>
<Icon
name={tab}
size={30}
color={this.props.activeTab === i ? 'rgb(59,89,152)' : 'rgb(204,204,204)'}
ref={(icon) => { this.tabIcons[i] = icon; }}
/>
</TouchableOpacity>
)}
</View>
<Animated.View style={[Styles.tabUnderlineStyle, { width: tabWidth }, { left }]} />
</View>
);
}
}
module.exports = FacebookTabBar;
|
definitions/npm/react-navigation_v1.x.x/test_react-navigation.js | orlandoc01/flow-typed | // @flow
import type {
NavigationScreenProp,
} from 'react-navigation';
import {
TabNavigator,
StackNavigator,
DrawerNavigator,
} from 'react-navigation';
import React from 'react';
/**
* Screens
*/
const FunctionalScreenComponent = (
{ navigation }: { navigation: NavigationScreenProp<*> },
) => {
return "Test";
};
TabNavigator({
Test1: { screen: FunctionalScreenComponent },
});
class ClassScreenComponent extends React.Component<*> {
render() {
return "Test";
}
}
StackNavigator({
Test1: { screen: ClassScreenComponent },
});
// $ExpectError numbers can never be components
StackNavigator({
Test1: { screen: 5 },
});
// $ExpectError you need a screen!
TabNavigator({
Test1: { blah: "test" },
});
DrawerNavigator({
Test1: { getScreen: () => FunctionalScreenComponent },
});
/**
* Configs
*/
StackNavigator(
{
Test1: { screen: FunctionalScreenComponent },
},
{
mode: "card",
initialRouteName: "Test1",
},
);
StackNavigator(
{
Test1: { screen: FunctionalScreenComponent },
},
// $ExpectError stack not drawer!
{
initialRouteName: "Test1",
drawerBackgroundColor: "green",
},
);
TabNavigator(
{
Test1: { screen: FunctionalScreenComponent },
},
// $ExpectError tab not drawer!
{
drawerBackgroundColor: "green",
},
);
TabNavigator(
{
Test1: { screen: FunctionalScreenComponent },
},
{
initialRouteName: "Test1",
},
);
DrawerNavigator(
{
Test1: { screen: FunctionalScreenComponent },
},
{
drawerBackgroundColor: "green",
},
);
DrawerNavigator(
{
Test1: { screen: FunctionalScreenComponent },
},
// $ExpectError drawer not tab!
{
tabBarPosition: "top",
},
);
/**
* Nav options
*/
StackNavigator({
Test1: {
screen: FunctionalScreenComponent,
navigationOptions: {
headerTitle: 'Home',
},
},
});
class ComponentWithNavOptions extends React.Component<*> {
static navigationOptions = {
headerTitle: "Home",
};
render() {
return "Test";
}
}
StackNavigator({
Test1: { screen: ComponentWithNavOptions },
});
class ComponentWithFunctionalNavOptions extends React.Component<*> {
static navigationOptions = (
{ navigation }: { navigation: NavigationScreenProp<*> },
) => ({
headerTitle: navigation.state.routeName,
});
render() {
return "Test";
}
}
/**
* Nested
*/
const nestedNavigator = TabNavigator({
Test1: { screen: FunctionalScreenComponent },
});
StackNavigator({
Test2: { screen: nestedNavigator },
Test3: { screen: ClassScreenComponent },
});
|
rojak-ui-web/src/App.js | pyk/rojak | import React from 'react';
import { Provider } from 'react-redux';
import { ReduxRouter } from 'redux-router';
import routes from './routes';
import store from './store';
import createRojakClient from './app/utils/createRojakClient';
class App extends React.Component {
static childContextTypes = {
rojakClient: React.PropTypes.object,
}
getChildContext() {
return {
rojakClient: createRojakClient(process.env.ROJAK_API_ENDPOINT),
}
}
render() {
return (
<Provider store={store}>
<ReduxRouter routes={routes} />
</Provider>
);
}
}
export default App;
|
docs/app/Examples/elements/Loader/States/LoaderExampleIndeterminate.js | koenvg/Semantic-UI-React | import React from 'react'
import { Dimmer, Loader, Image, Segment } from 'semantic-ui-react'
const LoaderExampleIndeterminate = () => (
<div>
<Segment>
<Dimmer active>
<Loader indeterminate>Preparing Files</Loader>
</Dimmer>
<Image src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</Segment>
</div>
)
export default LoaderExampleIndeterminate
|
app/javascript/flavours/glitch/features/compose/components/textarea_icons.js | Kirishima21/mastodon | // Package imports.
import PropTypes from 'prop-types';
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { defineMessages, injectIntl } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
// Components.
import Icon from 'flavours/glitch/components/icon';
// Messages.
const messages = defineMessages({
localOnly: {
defaultMessage: 'This post is local-only',
id: 'advanced_options.local-only.tooltip',
},
threadedMode: {
defaultMessage: 'Threaded mode enabled',
id: 'advanced_options.threaded_mode.tooltip',
},
});
// We use an array of tuples here instead of an object because it
// preserves order.
const iconMap = [
['do_not_federate', 'home', messages.localOnly],
['threaded_mode', 'comments', messages.threadedMode],
];
export default @injectIntl
class TextareaIcons extends ImmutablePureComponent {
static propTypes = {
advancedOptions: ImmutablePropTypes.map,
intl: PropTypes.object.isRequired,
};
render () {
const { advancedOptions, intl } = this.props;
return (
<div className='composer--textarea--icons'>
{advancedOptions ? iconMap.map(
([key, icon, message]) => advancedOptions.get(key) ? (
<span
className='textarea_icon'
key={key}
title={intl.formatMessage(message)}
>
<Icon
fixedWidth
id={icon}
/>
</span>
) : null
) : null}
</div>
);
}
}
|
docs/src/app/components/pages/discover-more/Community.js | mtsandeep/material-ui | import React from 'react';
import Title from 'react-title-component';
import MarkdownElement from '../../MarkdownElement';
import communityText from './community.md';
const Community = () => (
<div>
<Title render={(previousTitle) => `Community - ${previousTitle}`} />
<MarkdownElement text={communityText} />
</div>
);
export default Community;
|
src/docs/components/switcher.js | gabrielcsapo/psychic-ui | import React from 'react';
class Switcher extends React.Component {
changeBrand(e) {
this.props.selected(e.target.value);
}
render() {
const { brands, brand, alternate} = this.props;
const options = brands.map((b, i) => {
if(brand == b) {
return <option value={b} selected> {b} </option>
} else {
return <option value={b}> {b} </option>
}
});
return (
<select onChange={this.changeBrand.bind(this)}>
{ options }
</select>
);
}
}
export default Switcher;
|
src/icons/PictureAsPdfIcon.js | kiloe/ui | import React from 'react';
import Icon from '../Icon';
export default class PictureAsPdfIcon extends Icon {
getSVG(){return <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M40 4H16c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V8c0-2.21-1.79-4-4-4zM23 19c0 1.66-1.34 3-3 3h-2v4h-3V14h5c1.66 0 3 1.34 3 3v2zm10 4c0 1.66-1.34 3-3 3h-5V14h5c1.66 0 3 1.34 3 3v6zm8-6h-3v2h3v3h-3v4h-3V14h6v3zm-23 2h2v-2h-2v2zM8 12H4v28c0 2.21 1.79 4 4 4h28v-4H8V12zm20 11h2v-6h-2v6z"/></svg>;}
}; |
views/main.js | jassyboy/black-screen | import React from 'react';
import _ from 'lodash';
import Rx from 'rx';
import {TerminalLayout} from './compiled/src/views/TerminalLayout.js';
var keys = {
goUp: event => (event.ctrlKey && event.keyCode === 80) || event.keyCode === 38,
goDown: event => (event.ctrlKey && event.keyCode === 78) || event.keyCode === 40,
enter: event => event.keyCode === 13,
tab: event => event.keyCode === 9,
deleteWord: event => event.ctrlKey && event.keyCode === 87
};
function scrollToBottom() {
$('html body').animate({ scrollTop: $(document).height() }, 0);
}
function focusLastInput(event) {
if (_.contains(event.target.classList, 'prompt') || event.metaKey) {
return;
}
var originalEvent = event.originalEvent;
if (isMetaKey(originalEvent)) {
return;
}
var newEvent = new KeyboardEvent("keydown", _.pick(originalEvent, [
'altkey', 'bubbles', 'cancelBubble', 'cancelable', 'charCode',
'ctrlKey', 'keyIdentifier', 'metaKey', 'shiftKey'
]));
var target = _.last(document.getElementsByClassName('prompt'));
target.focus();
withCaret(target, () => target.innerText.length);
target.dispatchEvent(newEvent)
}
function setCaretPosition(node, position) {
var selection = window.getSelection();
var range = document.createRange();
if (node.childNodes.length) {
range.setStart(node.childNodes[0], position);
} else {
range.setStart(node, 0);
}
range.collapse(true);
selection.removeAllRanges();
selection.addRange(range);
}
function withCaret(target, callback) {
var selection = window.getSelection();
var range = document.createRange();
var offset = callback(selection.baseOffset);
if (target.childNodes.length) {
range.setStart(target.childNodes[0], offset);
} else {
range.setStart(target, 0);
}
range.collapse(true);
selection.removeAllRanges();
selection.addRange(range);
}
function isCommandKey(event) {
return _.contains([16, 17, 18], event.keyCode) || event.ctrlKey || event.altKey || event.metaKey;
}
function isMetaKey(event) {
return event.metaKey || _.some([event.key, event.keyIdentifier],
key => _.includes(['Shift', 'Alt', 'Ctrl'], key));
}
const isDefinedKey = _.memoize(event => _.some(_.values(keys), matcher => matcher(event)),
event => [event.ctrlKey, event.keyCode]);
function stopBubblingUp(event) {
event.stopPropagation();
event.preventDefault();
return event;
}
// TODO: Figure out how it works.
function createEventHandler() {
var subject = function() {
subject.onNext.apply(subject, arguments);
};
getEnumerablePropertyNames(Rx.Subject.prototype)
.forEach(function (property) {
subject[property] = Rx.Subject.prototype[property];
});
Rx.Subject.call(subject);
return subject;
}
function getEnumerablePropertyNames(target) {
var result = [];
for (var key in target) {
result.push(key);
}
return result;
}
$(document).ready(() => {
React.render(<TerminalLayout/>, document.getElementById('black-board'));
// TODO: focus the last input of the active terminal.
$(document).keydown(event => focusLastInput(event));
});
|
src/svg-icons/image/healing.js | rhaedes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageHealing = (props) => (
<SvgIcon {...props}>
<path d="M17.73 12.02l3.98-3.98c.39-.39.39-1.02 0-1.41l-4.34-4.34c-.39-.39-1.02-.39-1.41 0l-3.98 3.98L8 2.29C7.8 2.1 7.55 2 7.29 2c-.25 0-.51.1-.7.29L2.25 6.63c-.39.39-.39 1.02 0 1.41l3.98 3.98L2.25 16c-.39.39-.39 1.02 0 1.41l4.34 4.34c.39.39 1.02.39 1.41 0l3.98-3.98 3.98 3.98c.2.2.45.29.71.29.26 0 .51-.1.71-.29l4.34-4.34c.39-.39.39-1.02 0-1.41l-3.99-3.98zM12 9c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-4.71 1.96L3.66 7.34l3.63-3.63 3.62 3.62-3.62 3.63zM10 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm2 2c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm2-4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2.66 9.34l-3.63-3.62 3.63-3.63 3.62 3.62-3.62 3.63z"/>
</SvgIcon>
);
ImageHealing = pure(ImageHealing);
ImageHealing.displayName = 'ImageHealing';
export default ImageHealing;
|
test/integration/jsconfig-paths/components/world.js | zeit/next.js | import React from 'react'
export function World() {
return <>World</>
}
|
src/index.js | SpongeComing/react-demo | import 'core-js/fn/object/assign';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/Main';
// Render the main component into the dom
ReactDOM.render(<App />, document.getElementById('app'));
|
static/src/components/ProtectedView.js | tferreira/piggydime | import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { FormattedMessage } from 'react-intl'
import * as actionCreators from '../actions/user'
import WelcomeTiles from './WelcomeTiles'
function mapStateToProps(state) {
return {
data: state.user.data,
token: state.auth.token,
loaded: state.user.loaded,
isFetching: state.user.isFetching
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(actionCreators, dispatch)
}
@connect(mapStateToProps, mapDispatchToProps)
export default class ProtectedView extends React.Component {
componentDidMount() {
this.fetchData()
}
fetchData() {
const token = this.props.token
this.props.fetchUserData(token)
}
render() {
return (
<div>
{!this.props.loaded
? null
: <div>
<h1>
{
<FormattedMessage
id="home.welcomeBack"
values={{ userName: this.props.userName }}
/>
}
</h1>
<WelcomeTiles />
</div>}
</div>
)
}
}
ProtectedView.propTypes = {
fetchUserData: React.PropTypes.func,
loaded: React.PropTypes.bool,
userName: React.PropTypes.string,
data: React.PropTypes.any,
token: React.PropTypes.string
}
|
docs/src/examples/modules/Tab/Usage/TabExamplePaneShorthand.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { List, Label, Tab } from 'semantic-ui-react'
const panes = [
{
menuItem: 'Tab 1',
pane: { key: 'tab1', content: 'This is a massive tab', size: 'massive' },
},
{
menuItem: 'Tab 2',
pane: {
key: 'tab2',
content: 'This tab has center-aligned text',
textAlign: 'center',
},
},
{
menuItem: 'Tab 3',
pane: {
key: 'tab3',
content: (
<div>
This tab contains a <Label>JSX</Label> element
</div>
),
},
},
{
menuItem: 'Tab 4',
pane: (
<Tab.Pane key='tab4'>
<p>This tab has complex content</p>
<List>
<List.Item>Apples</List.Item>
<List.Item>Pears</List.Item>
<List.Item>Oranges</List.Item>
</List>
</Tab.Pane>
),
},
]
const TabExampleContentShorthand = () => (
<Tab panes={panes} renderActiveOnly={false} />
)
export default TabExampleContentShorthand
|
fixtures/fiber-debugger/src/Editor.js | jordanpapaleo/react | import React, { Component } from 'react';
class Editor extends Component {
constructor(props) {
super(props);
this.state = {
code: props.code
};
}
render() {
return (
<div style={{
height: '100%',
width: '100%'
}}>
<textarea
value={this.state.code}
onChange={e => this.setState({ code: e.target.value })}
style={{
height: '80%',
width: '100%',
fontSize: '15px'
}} />
<div style={{ height: '20%', textAlign: 'center' }}>
<button onClick={() => this.props.onClose(this.state.code)} style={{ fontSize: 'large' }}>
Run
</button>
</div>
</div>
)
}
}
export default Editor;
|
src/components/Header/Header.js | dannyrdalton/example_react_redux_form_builder | import React from 'react'
import { IndexLink, Link } from 'react-router'
import './Header.scss'
export const Header = () => (
<div>
<h1>React Redux Starter Kit</h1>
<IndexLink to='/' activeClassName='route--active'>
Home
</IndexLink>
{' · '}
<Link to='/form-builder' activeClassName='route--active'>
Form Builder
</Link>
</div>
)
export default Header
|
src/components/Forms/AddConfigForm.js | TheModevShop/craft-app | import React from 'react';
import {Link} from 'react-router';
import forms from 'newforms';
import formIsComplete from 'utility/formIsComplete';
import _ from 'lodash';
const distributionPlatforms = [['', 'Distribution Platform'], 'encompass', 'vip'];
const AddConfigForm = forms.Form.extend({
distribution_platform: forms.ChoiceField({choices: distributionPlatforms, required: true}),
report_name: forms.CharField({required: true}),
report_url: forms.CharField({required: false}),
config_expiration: forms.CharField({required: false}),
vip_id: forms.CharField({required: false}),
email: forms.CharField({required: false, validation: {on: 'blur'}}),
password: forms.CharField({required: false, validation: {on: 'onChange blur', onChangeDelay: 100}, widget: forms.PasswordInput}),
labelSuffix: '',
requiredCssClass: 'required',
optionalCssClass: 'optional',
errorCssClass: 'error',
validCssClass: 'valid',
render(props, state, error, togglePasswordVisibility) {
const fields = this.boundFieldsObj();
const isValid = formIsComplete(this);
const awaitingSave = _.get(state, 'loading');
return (
<div className="form-container">
<div className={fields.report_name.cssClasses() + ` ${this.data.report_name ? 'active-data' : ''} field-group`}>
{fields.report_name.render({attrs: {placeholder: 'Report name', autoComplete: false}})}
</div>
<div className={fields.distribution_platform.cssClasses() + ' select-wrapper ' + ` ${this.data.distribution_platform ? 'active-data' : ''} field-group`}>
{fields.distribution_platform.render({attrs: {placeholder: 'Distribution platform (encompass, csi)', autoComplete: false}})}
</div>
{
false ?
<div className={fields.email.cssClasses() + ` ${this.data.email ? 'active-data' : ''} field-group`}>
{fields.email.render({attrs: {placeholder: 'Platform email / username', autoComplete: false}})}
</div> : null
}
{
false ?
<div className={fields.password.cssClasses() + ` ${this.data.password ? 'active-data' : ''} field-group`}>
{fields.password.render({attrs: {placeholder: 'Platform password', autoComplete: false}})}
</div> : null
}
{
this.data.distribution_platform === 'vip' ?
<div className={fields.vip_id.cssClasses() + ` ${this.data.vip_id ? 'active-data' : ''} field-group`}>
{fields.vip_id.render({attrs: {placeholder: 'VIP Id', autoComplete: false}})}
</div> : null
}
{
this.data.distribution_platform === 'encompass' ?
<div className={fields.report_url.cssClasses() + ` ${this.data.report_url ? 'active-data' : ''} field-group`}>
{fields.report_url.render({attrs: {placeholder: 'Report url', autoComplete: false}})}
</div> : null
}
{
this.data.distribution_platform === 'encompass' ?
<div className={fields.config_expiration.cssClasses() + ` ${this.data.config_expiration ? 'active-data' : ''} field-group`}>
{fields.config_expiration.render({attrs: {type: 'date', placeholder: 'Report Expiration', autoComplete: false}})}
</div> : null
}
<div className="button-wrapper split">
<button className="primary-btn-large" disabled={awaitingSave || !isValid}>
{
awaitingSave ?
<div>loading</div> : <div>Add Report Configuration</div>
}
</button>
</div>
{
error ?
<div className="error">
<span className="note">{error}</span>
</div> : null
}
</div>
);
}
});
export default AddConfigForm; |
app/src/components/Results/index.js | kshvmdn/github-list | import React, { Component } from 'react';
import './index.css';
import RepoCard from './../RepoCard';
class Results extends Component {
constructor() {
super();
this.state = {
repos: []
};
}
componentDidMount() {
this.setState({ repos: this.props.response.data.data })
}
render() {
return (
<div className="app--results">
{this.state.repos.map((repo, i) => (
<RepoCard key={i} repo={repo}/>
))}
</div>
);
}
}
export default Results;
|
src/js/components/Location.js | grommet/grommet-people-finder | // (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { headers, buildQuery, processStatus } from 'grommet/utils/Rest';
import Header from 'grommet/components/Header';
import Heading from 'grommet/components/Heading';
import Title from 'grommet/components/Title';
import Article from 'grommet/components/Article';
import Section from 'grommet/components/Section';
import Paragraph from 'grommet/components/Paragraph';
import Button from 'grommet/components/Button';
import Anchor from 'grommet/components/Anchor';
import SearchIcon from 'grommet/components/icons/base/Search';
import LocationsIcon from './icons/LocationsIcon';
import Map from './Map';
import config from '../config';
export default class LocationComponent extends Component {
constructor() {
super();
this.state = { location: {}, scope: config.scopes.locations };
}
componentDidMount() {
this.getLocation(this.props.id);
}
componentWillReceiveProps(nextProps) {
if (nextProps.id !== this.props.id) {
this.getLocation(nextProps.id);
}
}
getLocation(id) {
const params = {
url: config.ldapBaseUrl,
base: `ou=${this.state.scope.ou},o=${config.organization}`,
scope: 'sub',
filter: `(${config.scopes.locations.attributes.id}=${id})`,
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(result => this.setState({ location: result[0], error: undefined }))
.catch(error => this.setState({ location: {}, error }));
}
render() {
const appTitle = (
<FormattedMessage
id='Locations Finder'
defaultMessage='Locations Finder'
/>
);
const loc = this.state.location;
let address;
const postalAddress = loc[config.scopes.locations.attributes.address];
if (postalAddress) {
address = postalAddress.split(/ \$ /).map(e => (<div key={e}>{e}</div>));
}
let map;
if (loc[config.scopes.locations.attributes.country]) {
map = (
<Map
title={
loc[config.scopes.locations.attributes.category] ||
loc[config.scopes.locations.attributes.name]
}
street={loc[config.scopes.locations.attributes.street]}
city={loc[config.scopes.locations.attributes.city]}
state={loc[config.scopes.locations.attributes.state]}
postalCode={loc[config.scopes.locations.attributes.postalCode]}
country={loc[config.scopes.locations.attributes.country]}
/>
);
}
// NOTE: ED latitude and longitude aren't accurate.
// Removed the following from Map use:
// latitude={loc.latitude} longitude={loc.longitude}
return (
<Article>
<Header
size='large'
pad={{ horizontal: 'medium' }}
separator='bottom'
justify='between'
>
<Title onClick={this.props.onClose} responsive={false}>
<LocationsIcon />
{appTitle}
</Title>
<Button icon={<SearchIcon />} onClick={this.props.onClose} />
</Header>
<Section pad='medium'>
<Header justify='between'>
<Heading tag='h1'>
{loc[config.scopes.locations.attributes.name]}
</Heading>
<Heading tag='h1' className='secondary'>
{loc[config.scopes.locations.attributes.id]}
</Heading>
</Header>
<address>{address}</address>
<Heading tag='h3'>
<Anchor
href={`tel:${loc[config.scopes.locations.attributes.telephoneNumber]}`}
>
{loc[config.scopes.locations.attributes.telephoneNumber]}
</Anchor>
</Heading>
<Paragraph>
{loc[config.scopes.locations.attributes.category]}
</Paragraph>
</Section>
{map}
</Article>
);
}
}
LocationComponent.propTypes = {
id: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
};
|
Server/app/assets/javascripts/components/PageToolbarComponent.js | codemeow5/Carnival | import React from 'react';
export default React.createClass({
render: function(){
return (
<div className="page-toolbar">
<div className="btn-group btn-theme-panel">
<a href="javascript:;" className="btn dropdown-toggle" data-toggle="dropdown">
<i className="icon-settings"></i>
</a>
<div className="dropdown-menu theme-panel pull-right dropdown-custom hold-on-click">
<div className="row">
<div className="col-md-4 col-sm-4 col-xs-12">
<h3>HEADER</h3>
<ul className="theme-colors">
<li className="theme-color theme-color-default active" data-theme="default">
<span className="theme-color-view"></span>
<span className="theme-color-name">Dark Header</span>
</li>
<li className="theme-color theme-color-light " data-theme="light">
<span className="theme-color-view"></span>
<span className="theme-color-name">Light Header</span>
</li>
</ul>
</div>
<div className="col-md-8 col-sm-8 col-xs-12 seperator">
<h3>LAYOUT</h3>
<ul className="theme-settings">
<li> Layout
<select className="layout-option form-control input-small input-sm" defaultValue="fluid">
<option value="fluid">Fluid</option>
<option value="boxed">Boxed</option>
</select>
</li>
<li> Header
<select className="page-header-option form-control input-small input-sm" defaultValue="fixed">
<option value="fixed">Fixed</option>
<option value="default">Default</option>
</select>
</li>
<li> Top Dropdowns
<select className="page-header-top-dropdown-style-option form-control input-small input-sm" defaultValue="dark">
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</li>
<li> Sidebar Mode
<select className="sidebar-option form-control input-small input-sm" defaultValue="default">
<option value="fixed">Fixed</option>
<option value="default">Default</option>
</select>
</li>
<li> Sidebar Menu
<select className="sidebar-menu-option form-control input-small input-sm" defaultValue="accordion">
<option value="accordion">Accordion</option>
<option value="hover">Hover</option>
</select>
</li>
<li> Sidebar Position
<select className="sidebar-pos-option form-control input-small input-sm" defaultValue="left">
<option value="left">Left</option>
<option value="right">Right</option>
</select>
</li>
<li> Footer
<select className="page-footer-option form-control input-small input-sm" defaultValue="default">
<option value="fixed">Fixed</option>
<option value="default">Default</option>
</select>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
);
}
}); |
src/views/icons/CameraIcon.js | physiii/open-automation | import React from 'react';
import IconBase from './IconBase.js';
export const CameraIcon = (props) => (
<IconBase {...props} viewBox="0 0 40 24">
<path d="M0 5.002A4.997 4.997 0 0 1 5.004 0h19.992A4.998 4.998 0 0 1 30 4.994V7l6.717-4.247C37.629 2.423 40 2.16 40 5.25v13.5c0 3.08-2.337 2.897-3.283 2.36L30 17v2.006A4.993 4.993 0 0 1 24.996 24H5.004A5.001 5.001 0 0 1 0 18.998V5.002z" fillRule="evenodd" />
</IconBase>
);
export default CameraIcon;
|
js/example-work.js | chrisdodds/serverless_practice | import React from 'react';
import ExampleWorkModal from './example-work-modal';
class ExampleWork extends React.Component {
constructor(props){
super(props);
this.state = {
'modalOpen': false,
'selectedExample': this.props.work[0]
};
this.openModal = this.openModal.bind(this);
this.closeModal = this.closeModal.bind(this);
}
openModal(evt, example) {
this.setState({
'modalOpen': true,
'selectedExample': example
});
}
closeModal(evt) {
this.setState ({
'modalOpen':false
});
}
render() {
return (
<span>
<section className="section section--alignCentered section--description">
{ this.props.work.map( (example, idx) => {
return (
<ExampleWorkBubble example={example} key={idx} openModal={this.openModal} />
)
})}
</section>
<ExampleWorkModal example={this.state.selectedExample} open={this.state.modalOpen} closeModal={this.closeModal}/>
</span>
)
}
}
class ExampleWorkBubble extends React.Component {
render() {
let example = this.props.example;
return (
<div className="section__exampleWrapper" onClick={ (evt) => this.props.openModal(evt, example)}>
<div className="section__example">
<img alt={ example.image.desc }
className="section__exampleImage"
src={ example.image.src }/>
<dl className="color--cloud">
<dt className="section__exampleTitle section__text--centered">
{ example.title }
</dt>
<dd></dd>
</dl>
</div>
</div>
)
}
}
export default ExampleWork; |
node_modules/react-bootstrap/es/MenuItem.js | chenjic215/search-doctor | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import all from 'prop-types-extra/lib/all';
import SafeAnchor from './SafeAnchor';
import { bsClass, prefix, splitBsPropsAndOmit } from './utils/bootstrapUtils';
import createChainedFunction from './utils/createChainedFunction';
var propTypes = {
/**
* Highlight the menu item as active.
*/
active: PropTypes.bool,
/**
* Disable the menu item, making it unselectable.
*/
disabled: PropTypes.bool,
/**
* Styles the menu item as a horizontal rule, providing visual separation between
* groups of menu items.
*/
divider: all(PropTypes.bool, function (_ref) {
var divider = _ref.divider,
children = _ref.children;
return divider && children ? new Error('Children will not be rendered for dividers') : null;
}),
/**
* Value passed to the `onSelect` handler, useful for identifying the selected menu item.
*/
eventKey: PropTypes.any,
/**
* Styles the menu item as a header label, useful for describing a group of menu items.
*/
header: PropTypes.bool,
/**
* HTML `href` attribute corresponding to `a.href`.
*/
href: PropTypes.string,
/**
* Callback fired when the menu item is clicked.
*/
onClick: PropTypes.func,
/**
* Callback fired when the menu item is selected.
*
* ```js
* (eventKey: any, event: Object) => any
* ```
*/
onSelect: PropTypes.func
};
var defaultProps = {
divider: false,
disabled: false,
header: false
};
var MenuItem = function (_React$Component) {
_inherits(MenuItem, _React$Component);
function MenuItem(props, context) {
_classCallCheck(this, MenuItem);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this.handleClick = _this.handleClick.bind(_this);
return _this;
}
MenuItem.prototype.handleClick = function handleClick(event) {
var _props = this.props,
href = _props.href,
disabled = _props.disabled,
onSelect = _props.onSelect,
eventKey = _props.eventKey;
if (!href || disabled) {
event.preventDefault();
}
if (disabled) {
return;
}
if (onSelect) {
onSelect(eventKey, event);
}
};
MenuItem.prototype.render = function render() {
var _props2 = this.props,
active = _props2.active,
disabled = _props2.disabled,
divider = _props2.divider,
header = _props2.header,
onClick = _props2.onClick,
className = _props2.className,
style = _props2.style,
props = _objectWithoutProperties(_props2, ['active', 'disabled', 'divider', 'header', 'onClick', 'className', 'style']);
var _splitBsPropsAndOmit = splitBsPropsAndOmit(props, ['eventKey', 'onSelect']),
bsProps = _splitBsPropsAndOmit[0],
elementProps = _splitBsPropsAndOmit[1];
if (divider) {
// Forcibly blank out the children; separators shouldn't render any.
elementProps.children = undefined;
return React.createElement('li', _extends({}, elementProps, {
role: 'separator',
className: classNames(className, 'divider'),
style: style
}));
}
if (header) {
return React.createElement('li', _extends({}, elementProps, {
role: 'heading',
className: classNames(className, prefix(bsProps, 'header')),
style: style
}));
}
return React.createElement(
'li',
{
role: 'presentation',
className: classNames(className, { active: active, disabled: disabled }),
style: style
},
React.createElement(SafeAnchor, _extends({}, elementProps, {
role: 'menuitem',
tabIndex: '-1',
onClick: createChainedFunction(onClick, this.handleClick)
}))
);
};
return MenuItem;
}(React.Component);
MenuItem.propTypes = propTypes;
MenuItem.defaultProps = defaultProps;
export default bsClass('dropdown', MenuItem); |
src/index.js | nadzins/riepas-react-redux | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import {Router, browserHistory} from 'react-router';
import routes from './routes';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware()(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<Router history={browserHistory} routes={routes}/>
</Provider>
, document.querySelector('.container'));
|
app/scripts/components/kuchyne/kitchen_h.js | kroupaTomass/Rondo-kuchyne | import React from 'react';
import { Link } from 'react-router';
class Kitchen_h extends React.Component {
constructor(props, context) {
super(props);
}
render() {
return (
<div className="col-md-4 no_padding">
<div className="single_image">
<a id="kitchen_h" href="#animatedModal_h"><img src="images/kitchen/img/08/01.jpg" alt="" /></a>
</div>
<div id="animatedModal_h">
<div className="close-animatedModal_h" id="closebt-container">
<img className="closebt" src="images/closebt.svg" />
</div>
<div className="modal-content div-kitchen-content">
<h4>Koupelna</h4>
<div className="row">
<div className="col-md-4">
</div>
<div className="col-md-4">
<img src="images/kitchen/img/08/02.jpg" alt="" />
</div>
<div className="col-md-4">
<img src="images/kitchen/img/08/04.jpg" alt="" />
</div>
</div>
<div className="row">
<div className="col-md-4">
<img src="images/kitchen/img/08/03.jpg" alt="" />
</div>
<div className="col-md-4">
<img src="images/kitchen/img/08/01.jpg" alt="" />
</div>
</div>
</div>
</div>
<h2>Koupelna</h2>
<h4>Kompletní vybavení vaší koupelny</h4>
</div>
);
}
}
export default Kitchen_h;
|
admin/client/App/components/Navigation/Secondary/index.js | cermati/keystone | /**
* The secondary navigation links to inidvidual lists of a section
*/
import React from 'react';
import { connect } from 'react-redux';
import { Container } from '../../../elemental';
import {
setActiveList,
} from '../../../screens/List/actions/active';
import SecondaryNavItem from './NavItem';
var SecondaryNavigation = React.createClass({
displayName: 'SecondaryNavigation',
propTypes: {
currentListKey: React.PropTypes.string,
lists: React.PropTypes.array.isRequired,
},
getInitialState () {
return {};
},
// Handle resizing and hide this nav on mobile (i.e. < 768px) screens
componentDidMount () {
this.handleResize();
window.addEventListener('resize', this.handleResize);
},
componentWillUnmount () {
window.removeEventListener('resize', this.handleResize);
},
handleResize () {
this.setState({
navIsVisible: this.props.lists && Object.keys(this.props.lists).length > 0 && window.innerWidth >= 768,
});
},
// Render the navigation
renderNavigation (lists) {
const navigation = Object.keys(lists).map((key) => {
const list = lists[key];
// Get the link and the classname
const href = list.external ? list.path : `${Keystone.adminPath}/${list.path}`;
const isActive = this.props.currentListKey && this.props.currentListKey === list.path;
const className = isActive ? 'active' : null;
const onClick = (evt) => {
// If it's the currently active navigation item and we're not on the item view,
// clear the query params on click
if (isActive && !this.props.itemId) {
evt.preventDefault();
this.props.dispatch(
setActiveList(this.props.currentList, this.props.currentListKey)
);
}
};
return (
<SecondaryNavItem
key={list.path}
path={list.path}
className={className}
href={href}
onClick={onClick}
>
{list.label}
</SecondaryNavItem>
);
});
return (
<ul className="app-nav app-nav--secondary app-nav--left">
{navigation}
</ul>
);
},
render () {
if (!this.state.navIsVisible) return null;
return (
<nav className="secondary-navbar">
<Container clearFloatingChildren>
{this.renderNavigation(this.props.lists)}
</Container>
</nav>
);
},
});
module.exports = connect((state) => {
return {
currentList: state.lists.currentList,
};
})(SecondaryNavigation);
|
fields/types/localfiles/LocalFilesField.js | kumo/keystone | import _ from 'underscore';
import bytes from 'bytes';
import Field from '../Field';
import React from 'react';
import { Button, FormField, FormInput, FormNote } from 'elemental';
/**
* TODO:
* - Remove dependency on underscore
*/
const ICON_EXTS = [
'aac', 'ai', 'aiff', 'avi', 'bmp', 'c', 'cpp', 'css', 'dat', 'dmg', 'doc', 'dotx', 'dwg', 'dxf', 'eps', 'exe', 'flv', 'gif', 'h',
'hpp', 'html', 'ics', 'iso', 'java', 'jpg', 'js', 'key', 'less', 'mid', 'mp3', 'mp4', 'mpg', 'odf', 'ods', 'odt', 'otp', 'ots',
'ott', 'pdf', 'php', 'png', 'ppt', 'psd', 'py', 'qt', 'rar', 'rb', 'rtf', 'sass', 'scss', 'sql', 'tga', 'tgz', 'tiff', 'txt',
'wav', 'xls', 'xlsx', 'xml', 'yml', 'zip'
];
var LocalFilesFieldItem = React.createClass({
propTypes: {
deleted: React.PropTypes.bool,
filename: React.PropTypes.string,
isQueued: React.PropTypes.bool,
key: React.PropTypes.number,
size: React.PropTypes.number,
toggleDelete: React.PropTypes.func,
},
renderActionButton () {
if (!this.props.shouldRenderActionButton || this.props.isQueued) return null;
var buttonLabel = this.props.deleted ? 'Undo' : 'Remove';
var buttonType = this.props.deleted ? 'link' : 'link-cancel';
return <Button key="action-button" type={buttonType} onClick={this.props.toggleDelete}>{buttonLabel}</Button>;
},
render () {
let { filename } = this.props;
let ext = filename.split('.').pop();
let iconName = '_blank';
if (_.contains(ICON_EXTS, ext)) iconName = ext;
let note;
if (this.props.deleted) {
note = <FormInput key="delete-note" noedit className="field-type-localfiles__note field-type-localfiles__note--delete">save to delete</FormInput>;
} else if (this.props.isQueued) {
note = <FormInput key="upload-note" noedit className="field-type-localfiles__note field-type-localfiles__note--upload">save to upload</FormInput>;
}
return (
<FormField>
<img key="file-type-icon" className="file-icon" src={'/keystone/images/icons/32/' + iconName + '.png'} />
<FormInput key="file-name" noedit className="field-type-localfiles__filename">
{filename}
{this.props.size ? ' (' + bytes(this.props.size) + ')' : null}
</FormInput>
{note}
{this.renderActionButton()}
</FormField>
);
}
});
module.exports = Field.create({
getInitialState () {
var items = [];
var self = this;
_.each(this.props.value, function (item) {
self.pushItem(item, items);
});
return { items: items };
},
removeItem (i) {
var thumbs = this.state.items;
var thumb = thumbs[i];
if (thumb.props.isQueued) {
thumbs[i] = null;
} else {
thumb.props.deleted = !thumb.props.deleted;
}
this.setState({ items: thumbs });
},
pushItem (args, thumbs) {
thumbs = thumbs || this.state.items;
var i = thumbs.length;
args.toggleDelete = this.removeItem.bind(this, i);
args.shouldRenderActionButton = this.shouldRenderField();
thumbs.push(<LocalFilesFieldItem key={i} {...args} />);
},
fileFieldNode () {
return this.refs.fileField.getDOMNode();
},
renderFileField () {
return <input ref="fileField" type="file" name={this.props.paths.upload} multiple className="field-upload" onChange={this.uploadFile} tabIndex="-1" />;
},
clearFiles () {
this.fileFieldNode().value = '';
this.setState({
items: this.state.items.filter(function (thumb) {
return !thumb.props.isQueued;
})
});
},
uploadFile (event) {
var self = this;
var files = event.target.files;
_.each(files, function (f) {
self.pushItem({ isQueued: true, filename: f.name });
self.forceUpdate();
});
},
changeFiles () {
this.fileFieldNode().click();
},
hasFiles () {
return this.refs.fileField && this.fileFieldNode().value;
},
renderToolbar () {
if (!this.shouldRenderField()) return null;
var clearFilesButton;
if (this.hasFiles()) {
clearFilesButton = <Button type="link-cancel" className="ml-5" onClick={this.clearFiles}>Clear Uploads</Button>;
}
return (
<div className="files-toolbar">
<Button onClick={this.changeFiles}>Upload</Button>
{clearFilesButton}
</div>
);
},
renderPlaceholder () {
return (
<div className="file-field file-upload" onClick={this.changeFiles}>
<div className="file-preview">
<span className="file-thumbnail">
<span className="file-dropzone" />
<div className="ion-picture file-uploading" />
</span>
</div>
<div className="file-details">
<span className="file-message">Click to upload</span>
</div>
</div>
);
},
renderContainer () {
return (
<div className="files-container clearfix">
{this.state.items}
</div>
);
},
renderFieldAction () {
var value = '';
var remove = [];
_.each(this.state.items, function (thumb) {
if (thumb && thumb.props.deleted) remove.push(thumb.props._id);
});
if (remove.length) value = 'delete:' + remove.join(',');
return <input ref="action" className="field-action" type="hidden" value={value} name={this.props.paths.action} />;
},
renderUploadsField () {
return <input ref="uploads" className="field-uploads" type="hidden" name={this.props.paths.uploads} />;
},
renderNote: function() {
if (!this.props.note) return null;
return <FormNote note={this.props.note} />;
},
renderUI () {
return (
<FormField label={this.props.label} className="field-type-localfiles">
{this.renderFieldAction()}
{this.renderUploadsField()}
{this.renderFileField()}
{this.renderContainer()}
{this.renderToolbar()}
{this.renderNote()}
</FormField>
);
}
});
|
src/client/todos/newtodo.react.js | sljuka/portfulio | import * as actions from './actions';
import Component from '../components/component.react';
import React from 'react';
import immutable from 'immutable';
import {msg} from '../intl/store';
class NewTodo extends Component {
static propTypes = {
todo: React.PropTypes.instanceOf(immutable.Record)
};
addTodoOnEnter(e) {
if (e.key === 'Enter')
actions.addTodo(this.props.todo);
}
render() {
return (
<input
autoFocus
className="new-todo"
name="title"
onChange={actions.onNewTodoFieldChange}
onKeyDown={(e) => this.addTodoOnEnter(e)}
placeholder={msg('todos.newTodoPlaceholder')}
value={this.props.todo.title}
/>
);
}
}
export default NewTodo;
|
app/javascript/mastodon/features/ui/components/upload_area.js | ashfurrow/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import Motion from '../../ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
import { FormattedMessage } from 'react-intl';
export default class UploadArea extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
onClose: PropTypes.func,
};
handleKeyUp = (e) => {
const keyCode = e.keyCode;
if (this.props.active) {
switch(keyCode) {
case 27:
e.preventDefault();
e.stopPropagation();
this.props.onClose();
break;
}
}
}
componentDidMount () {
window.addEventListener('keyup', this.handleKeyUp, false);
}
componentWillUnmount () {
window.removeEventListener('keyup', this.handleKeyUp);
}
render () {
const { active } = this.props;
return (
<Motion defaultStyle={{ backgroundOpacity: 0, backgroundScale: 0.95 }} style={{ backgroundOpacity: spring(active ? 1 : 0, { stiffness: 150, damping: 15 }), backgroundScale: spring(active ? 1 : 0.95, { stiffness: 200, damping: 3 }) }}>
{({ backgroundOpacity, backgroundScale }) => (
<div className='upload-area' style={{ visibility: active ? 'visible' : 'hidden', opacity: backgroundOpacity }}>
<div className='upload-area__drop'>
<div className='upload-area__background' style={{ transform: `scale(${backgroundScale})` }} />
<div className='upload-area__content'><FormattedMessage id='upload_area.title' defaultMessage='Drag & drop to upload' /></div>
</div>
</div>
)}
</Motion>
);
}
}
|
src/svg-icons/action/theaters.js | ruifortes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionTheaters = (props) => (
<SvgIcon {...props}>
<path d="M18 3v2h-2V3H8v2H6V3H4v18h2v-2h2v2h8v-2h2v2h2V3h-2zM8 17H6v-2h2v2zm0-4H6v-2h2v2zm0-4H6V7h2v2zm10 8h-2v-2h2v2zm0-4h-2v-2h2v2zm0-4h-2V7h2v2z"/>
</SvgIcon>
);
ActionTheaters = pure(ActionTheaters);
ActionTheaters.displayName = 'ActionTheaters';
ActionTheaters.muiName = 'SvgIcon';
export default ActionTheaters;
|
modules/Link.js | ustccjw/react-router | import React from 'react'
import warning from 'warning'
const { bool, object, string, func } = React.PropTypes
function isLeftClickEvent(event) {
return event.button === 0
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
}
function isEmptyObject(object) {
for (const p in object)
if (object.hasOwnProperty(p))
return false
return true
}
/**
* A <Link> is used to create an <a> element that links to a route.
* When that route is active, the link gets an "active" class name
* (or the value of its `activeClassName` prop).
*
* For example, assuming you have the following route:
*
* <Route path="/posts/:postID" component={Post} />
*
* You could use the following component to link to that route:
*
* <Link to={`/posts/${post.id}`} />
*
* Links may pass along location state and/or query string parameters
* in the state/query props, respectively.
*
* <Link ... query={{ show: true }} state={{ the: 'state' }} />
*/
const Link = React.createClass({
contextTypes: {
history: object
},
propTypes: {
activeStyle: object,
activeClassName: string,
onlyActiveOnIndex: bool.isRequired,
to: string.isRequired,
query: object,
state: object,
onClick: func
},
getDefaultProps() {
return {
onlyActiveOnIndex: false,
className: '',
style: {}
}
},
handleClick(event) {
let allowTransition = true, clickResult
if (this.props.onClick)
clickResult = this.props.onClick(event)
if (isModifiedEvent(event) || !isLeftClickEvent(event))
return
if (clickResult === false || event.defaultPrevented === true)
allowTransition = false
event.preventDefault()
if (allowTransition)
this.context.history.pushState(this.props.state, this.props.to, this.props.query)
},
componentWillMount() {
warning(
this.context.history,
'A <Link> should not be rendered outside the context of history ' +
'some features including real hrefs, active styling, and navigation ' +
'will not function correctly'
)
},
render() {
const { history } = this.context
const { activeClassName, activeStyle, onlyActiveOnIndex, to, query, state, onClick, ...props } = this.props
props.onClick = this.handleClick
// Ignore if rendered outside the context
// of history, simplifies unit testing.
if (history) {
props.href = history.createHref(to, query)
if (activeClassName || (activeStyle != null && !isEmptyObject(activeStyle))) {
if (history.isActive(to, query, onlyActiveOnIndex)) {
if (activeClassName)
props.className += props.className === '' ? activeClassName : ` ${activeClassName}`
if (activeStyle)
props.style = { ...props.style, ...activeStyle }
}
}
}
return React.createElement('a', props)
}
})
export default Link
|
web/src/main/client/src/components/filterbar/FilterBar.js | BakkerTom/happy-news | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './FilterBar.css';
class FilterBar extends Component {
constructor(props) {
super(props);
this.state = {
flaggedContent: this.props.filtered
}
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState({
flaggedContent: !this.state.flaggedContent
}, () => {
this.props.handler("FLAGGED", this.state.flaggedContent);
});
}
render(){
return (
<div className='filter-bar'>
<span>Filter:</span>
<a className={'filter-btn ' + (this.state.flaggedContent ? 'toggled' : '')}
onClick={this.handleClick}>Flagged Content</a>
</div>
);
}
}
FilterBar.propTypes = {
handler: PropTypes.func.isRequired,
filtered: PropTypes.bool.isRequired
}
export default FilterBar; |
anubis/frontend/src/components/TokenField/symbol_token.js | cmspsgp31/anubis | // Copyright © 2016, Ugo Pozo
// 2016, Câmara Municipal de São Paulo
// symbol_token.js - tokens representing connecting symbols.
// This file is part of Anubis.
// Anubis is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Anubis is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from 'react';
import * as Colors from 'material-ui/styles/colors';
import Token, {makeDraggable} from './token';
class SymbolToken extends Token {
repr = null;
color = null;
get keyCodes() {
return [];
}
get baseStyle() {
return Object.assign({}, super.baseStyle, this.uppercaseStyle, {
backgroundColor: this.color,
});
}
renderContents() {
return <p style={{display: "inline-block"}}>{this.repr}</p>;
}
}
@makeDraggable
class AndToken extends SymbolToken {
repr = "E";
color = Colors.cyan600;
}
@makeDraggable
class OrToken extends SymbolToken {
repr = "OU";
color = Colors.teal400;
}
@makeDraggable
class NotToken extends SymbolToken {
repr = "NÃO";
color = Colors.red400;
}
@makeDraggable
class LeftParensToken extends SymbolToken {
repr = "(";
color = Colors.orange800;
}
@makeDraggable
class RightParensToken extends SymbolToken {
repr = ")";
color = Colors.orange800;
}
export default {
"__AND__": AndToken,
"__OR__": OrToken,
"__NOT__": NotToken,
"__LPARENS__": LeftParensToken,
"__RPARENS__": RightParensToken,
};
|
examples/todomvc/containers/TodoApp.js | kennetpostigo/redux | import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import Header from '../components/Header';
import MainSection from '../components/MainSection';
import * as TodoActions from '../actions/todos';
class TodoApp extends Component {
render() {
const { todos, dispatch } = this.props;
const actions = bindActionCreators(TodoActions, dispatch);
return (
<div>
<Header addTodo={actions.addTodo} />
<MainSection todos={todos} actions={actions} />
</div>
);
}
}
function select(state) {
return {
todos: state.todos
};
}
export default connect(select)(TodoApp);
|
packages/material-ui-icons/src/GpsNotFixed.js | AndriusBil/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let GpsNotFixed = props =>
<SvgIcon {...props}>
<path d="M20.94 11c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z" />
</SvgIcon>;
GpsNotFixed = pure(GpsNotFixed);
GpsNotFixed.muiName = 'SvgIcon';
export default GpsNotFixed;
|
js/webui/src/setting_editor.js | hyperblast/beefweb | import React from 'react'
import PropTypes from 'prop-types'
import objectValues from 'lodash/values'
import SettingsModel, { SettingType } from './settings_model'
import ServiceContext from './service_context';
class BoolSettingEditor extends React.PureComponent
{
constructor(props, context)
{
super(props, context);
this.state = this.getStateFromModel();
this.handleUpdate = () => this.setState(this.getStateFromModel());
this.handleInput = this.handleInput.bind(this);
}
componentDidMount()
{
this.context.settingsModel.on(this.props.settingKey + 'Change', this.handleUpdate);
}
componentWillUnmount()
{
this.context.settingsModel.off(this.props.settingKey + 'Change', this.handleUpdate);
}
getStateFromModel()
{
const { settingKey } = this.props;
const { settingsModel } = this.context;
return {
value: settingsModel[settingKey],
metadata: settingsModel.metadata[settingKey]
};
}
handleInput(e)
{
const { settingKey } = this.props;
const { settingsModel } = this.context;
settingsModel[settingKey] = e.target.checked;
}
render()
{
const { value, metadata } = this.state;
const { disabled } = this.props;
return (
<label className='setting-editor setting-editor-bool'>
<input type='checkbox' checked={value} onChange={this.handleInput} disabled={disabled} />
<span>{metadata.title}</span>
</label>
);
}
}
BoolSettingEditor.propTypes = {
settingKey: PropTypes.string.isRequired,
disabled: PropTypes.bool
};
BoolSettingEditor.contextType = ServiceContext;
class EnumSettingEditor extends React.PureComponent
{
constructor(props, context)
{
super(props, context);
this.state = this.getStateFromModel();
this.handleUpdate = () => this.setState(this.getStateFromModel());
this.handleInput = this.handleInput.bind(this);
}
componentDidMount()
{
this.context.settingsModel.on(this.props.settingKey + 'Change', this.handleUpdate);
}
componentWillUnmount()
{
this.context.settingsModel.off(this.props.settingKey + 'Change', this.handleUpdate);
}
getStateFromModel()
{
const { settingKey } = this.props;
const { settingsModel } = this.context;
return {
value: settingsModel[settingKey],
metadata:settingsModel.metadata[settingKey]
};
}
handleInput(e)
{
const { settingKey } = this.props;
const { settingsModel } = this.context;
settingsModel[settingKey] = e.target.value;
}
render()
{
const { value, metadata } = this.state;
const { disabled } = this.props;
const options = objectValues(metadata.enumKeys).map(value => {
return (
<option key={value} value={value}>
{ metadata.enumNames[value] }
</option>
);
});
return (
<label className='setting-editor setting-editor-enum'>
<span>{metadata.title + ':'}</span>
<select value={value} onChange={this.handleInput} disabled={disabled}>{ options }</select>
</label>
);
}
}
EnumSettingEditor.propTypes = {
settingKey: PropTypes.string.isRequired,
disabled: PropTypes.bool
};
EnumSettingEditor.contextType = ServiceContext;
class TextSettingEditor extends React.PureComponent
{
constructor(props, context)
{
super(props, context);
this.state = this.getStateFromModel();
this.handleUpdate = () => this.setState(this.getStateFromModel());
this.handleInput = this.handleInput.bind(this);
}
componentDidMount()
{
this.context.settingsModel.on(this.props.settingKey + 'Change', this.handleUpdate);
}
componentWillUnmount()
{
this.context.settingsModel.off(this.props.settingKey + 'Change', this.handleUpdate);
}
getStateFromModel()
{
const { settingKey } = this.props;
const { settingsModel } = this.context;
return {
value: settingsModel[settingKey],
metadata: settingsModel.metadata[settingKey]
};
}
handleInput(e)
{
const { settingKey } = this.props;
const { settingsModel } = this.context;
settingsModel[settingKey] = e.target.value;
}
render()
{
const { value, metadata } = this.state;
const { disabled } = this.props;
return (
<label className='setting-editor setting-editor-text'>
<span>{metadata.title + ':'}</span>
<input value={value} onChange={this.handleInput} disabled={disabled} />
</label>
);
}
}
TextSettingEditor.propTypes = {
settingKey: PropTypes.string.isRequired,
disabled: PropTypes.bool
};
TextSettingEditor.contextType = ServiceContext;
const editorComponents = Object.freeze({
[SettingType.bool]: BoolSettingEditor,
[SettingType.enum]: EnumSettingEditor,
[SettingType.string]: TextSettingEditor,
});
export default class SettingEditor extends React.PureComponent
{
render()
{
const { settingKey, disabled } = this.props;
const { settingsModel } = this.context;
const { type } = settingsModel.metadata[settingKey];
const Editor = editorComponents[type];
if (!Editor)
throw new Error(`Setting property '${settingKey}' has unsupported type '${type}'.`);
return <Editor settingKey={settingKey} disabled={disabled} />;
}
}
SettingEditor.contextType = ServiceContext;
SettingEditor.propTypes = {
settingKey: PropTypes.string.isRequired,
disabled: PropTypes.bool
};
|
src/components/Core.js | eko/king | import React from 'react';
import Link from 'react-router/lib/Link';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import { MuiThemeProvider, getMuiTheme } from 'material-ui/styles';
import { NavigationMenu, NavigationClose } from 'material-ui/svg-icons/navigation/close';
import {
AppBar
} from 'material-ui';
const Core = ({ children }) => {
return (<MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}>
<div>
<AppBar title="King" />
<main>
{ children }
</main>
</div>
</MuiThemeProvider>);
};
export default Core;
|
src/docs/examples/TextInputBEM/ExampleError.js | alexcondorachi/ps-react-alexc | import React from 'react';
import TextInputBEM from 'ps-react/TextInputBEM';
/** Required TextBox with error */
export default class ExampleError extends React.Component {
render() {
return (
<TextInputBEM
htmlId="example-optional"
label="First Name"
name="firstname"
onChange={() => {}}
required
error="First name is required."
/>
)
}
}
|
frontend/src/components/toolbar/invitations-toolbar.js | miurahr/seahub | import React from 'react';
import PropTypes from 'prop-types';
import CommonToolbar from './common-toolbar';
import { Button } from 'reactstrap';
import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
const propTypes = {
onShowSidePanel: PropTypes.func.isRequired,
onSearchedClick: PropTypes.func.isRequired,
toggleInvitePeopleDialog: PropTypes.func.isRequired,
};
class InvitationsToolbar extends React.Component {
constructor(props) {
super(props);
}
render() {
let { onShowSidePanel, onSearchedClick, toggleInvitePeopleDialog } = this.props;
return (
<div className="main-panel-north border-left-show">
<div className="cur-view-toolbar">
<span title="Side Nav Menu" onClick={onShowSidePanel} className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none">
</span>
{Utils.isDesktop() ? (
<div className="operation">
<Button color="btn btn-secondary operation-item" onClick={toggleInvitePeopleDialog}>
<i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('Invite Guest')}
</Button>
</div>
) : (
<span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('Invite Guest')} onClick={toggleInvitePeopleDialog}></span>
)}
</div>
<CommonToolbar searchPlaceholder={this.props.searchPlaceholder} onSearchedClick={onSearchedClick}/>
</div>
);
}
}
InvitationsToolbar.propTypes = propTypes;
export default InvitationsToolbar;
|
src/app/components/LoginForm/index.js | mahimaag/react-web-boilerplate | import React from 'react';
import PropTypes from 'prop-types';
import { FormGroup, ControlLabel, HelpBlock, FormControl, Checkbox, Button } from 'react-bootstrap';
import {LoginFormFields} from '../../../constants/index';
import AwareXButton from '../AwareXButton'
import styles from './style.scss';
import AXLink from '../AXLink';
const InitialState = Object.freeze({
email: '',
password: '',
rememberMe: false
});
export default class LoginForm extends React.Component {
constructor(props) {
super(props);
this.state = { ...InitialState };
}
getValidationState = () => {
const length = this.state.value.length;
if (length > 10) return 'success';
else if (length > 5) return 'warning';
else if (length > 0) return 'error';
}
handleChange = (e) => {
if(e.target){
switch (e.target.type){
case LoginFormFields.email:
this.setState({email: e.target.value});
break;
case LoginFormFields.password:
this.setState({password: e.target.value});
break;
case LoginFormFields.checkbox:
this.setState({rememberMe: e.target.checked});
break;
default:
break;
}
}
console.log(this.state);
};
render() {
return (
<form className="customFormContainer">
<div className="col-md-offset-4 col-md-6 customWrapper">
<div className="row">
<div className="col-md-7">
<h1 className="loginHeading">LOG IN</h1>
<FormGroup controlId="formControlsEmail" className="customFormGroup">
<ControlLabel className="custom-label">Email/Username</ControlLabel>
<FormControl id="formControlsEmail" className="customFormControl" type="email" label="Email address"
value={this.state.email} placeholder="Enter email" onChange={(e) => this.handleChange(e)}/>
</FormGroup>
<FormGroup controlId="formControlsPassword" className="customFormGroup">
<ControlLabel className="custom-label">Password</ControlLabel>
<FormControl id="formControlsPassword" className="customFormControl" type="password" label="Password" value={this.state.password} placeholder="Password" onChange={(e) => this.handleChange(e)}/>
</FormGroup>
<Checkbox checked={this.state.rememberMe} label="ememberMe" onChange={(e) => this.handleChange(e, 'rememberMe')} id="rememberMe" className="custom-checkbox">
<label htmlFor="rememberMe"> Remember Me </label>
</Checkbox>
<AwareXButton type="btn-custom" text="Login" onClick={() => this.props.onLogin(this.state)}/>
<AXLink text="Register Now"/>
<AXLink text="Forgot Password?"/>
</div>
<div className="col-md-2 customImageContainer">
<img src={`/images/login_right_img.png`}/>
</div>
</div>
</div>
</form>
);
}
}
LoginForm.PropTypes = {
onLogin: PropTypes.func.isRequired
}; |
app/javascript/mastodon/features/notifications/index.js | mimumemo/mastodon | import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Column from '../../components/column';
import ColumnHeader from '../../components/column_header';
import { expandNotifications, scrollTopNotifications } from '../../actions/notifications';
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import NotificationContainer from './containers/notification_container';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ColumnSettingsContainer from './containers/column_settings_container';
import FilterBarContainer from './containers/filter_bar_container';
import { createSelector } from 'reselect';
import { List as ImmutableList } from 'immutable';
import { debounce } from 'lodash';
import ScrollableList from '../../components/scrollable_list';
import LoadGap from '../../components/load_gap';
const messages = defineMessages({
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
});
const getNotifications = createSelector([
state => state.getIn(['settings', 'notifications', 'quickFilter', 'show']),
state => state.getIn(['settings', 'notifications', 'quickFilter', 'active']),
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
state => state.getIn(['notifications', 'items']),
], (showFilterBar, allowedType, excludedTypes, notifications) => {
if (!showFilterBar || allowedType === 'all') {
// used if user changed the notification settings after loading the notifications from the server
// otherwise a list of notifications will come pre-filtered from the backend
// we need to turn it off for FilterBar in order not to block ourselves from seeing a specific category
return notifications.filterNot(item => item !== null && excludedTypes.includes(item.get('type')));
}
return notifications.filter(item => item !== null && allowedType === item.get('type'));
});
const mapStateToProps = state => ({
showFilterBar: state.getIn(['settings', 'notifications', 'quickFilter', 'show']),
notifications: getNotifications(state),
isLoading: state.getIn(['notifications', 'isLoading'], true),
isUnread: state.getIn(['notifications', 'unread']) > 0,
hasMore: state.getIn(['notifications', 'hasMore']),
});
export default @connect(mapStateToProps)
@injectIntl
class Notifications extends React.PureComponent {
static propTypes = {
columnId: PropTypes.string,
notifications: ImmutablePropTypes.list.isRequired,
showFilterBar: PropTypes.bool.isRequired,
dispatch: PropTypes.func.isRequired,
shouldUpdateScroll: PropTypes.func,
intl: PropTypes.object.isRequired,
isLoading: PropTypes.bool,
isUnread: PropTypes.bool,
multiColumn: PropTypes.bool,
hasMore: PropTypes.bool,
};
static defaultProps = {
trackScroll: true,
};
componentWillUnmount () {
this.handleLoadOlder.cancel();
this.handleScrollToTop.cancel();
this.handleScroll.cancel();
this.props.dispatch(scrollTopNotifications(false));
}
handleLoadGap = (maxId) => {
this.props.dispatch(expandNotifications({ maxId }));
};
handleLoadOlder = debounce(() => {
const last = this.props.notifications.last();
this.props.dispatch(expandNotifications({ maxId: last && last.get('id') }));
}, 300, { leading: true });
handleScrollToTop = debounce(() => {
this.props.dispatch(scrollTopNotifications(true));
}, 100);
handleScroll = debounce(() => {
this.props.dispatch(scrollTopNotifications(false));
}, 100);
handlePin = () => {
const { columnId, dispatch } = this.props;
if (columnId) {
dispatch(removeColumn(columnId));
} else {
dispatch(addColumn('NOTIFICATIONS', {}));
}
}
handleMove = (dir) => {
const { columnId, dispatch } = this.props;
dispatch(moveColumn(columnId, dir));
}
handleHeaderClick = () => {
this.column.scrollTop();
}
setColumnRef = c => {
this.column = c;
}
handleMoveUp = id => {
const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1;
this._selectChild(elementIndex);
}
handleMoveDown = id => {
const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1;
this._selectChild(elementIndex);
}
_selectChild (index) {
const element = this.column.node.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
if (element) {
element.focus();
}
}
render () {
const { intl, notifications, shouldUpdateScroll, isLoading, isUnread, columnId, multiColumn, hasMore, showFilterBar } = this.props;
const pinned = !!columnId;
const emptyMessage = <FormattedMessage id='empty_column.notifications' defaultMessage="You don't have any notifications yet. Interact with others to start the conversation." />;
let scrollableContent = null;
const filterBarContainer = showFilterBar
? (<FilterBarContainer />)
: null;
if (isLoading && this.scrollableContent) {
scrollableContent = this.scrollableContent;
} else if (notifications.size > 0 || hasMore) {
scrollableContent = notifications.map((item, index) => item === null ? (
<LoadGap
key={'gap:' + notifications.getIn([index + 1, 'id'])}
disabled={isLoading}
maxId={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
onClick={this.handleLoadGap}
/>
) : (
<NotificationContainer
key={item.get('id')}
notification={item}
accountId={item.get('account')}
onMoveUp={this.handleMoveUp}
onMoveDown={this.handleMoveDown}
/>
));
} else {
scrollableContent = null;
}
this.scrollableContent = scrollableContent;
const scrollContainer = (
<ScrollableList
scrollKey={`notifications-${columnId}`}
trackScroll={!pinned}
isLoading={isLoading}
showLoading={isLoading && notifications.size === 0}
hasMore={hasMore}
emptyMessage={emptyMessage}
onLoadMore={this.handleLoadOlder}
onScrollToTop={this.handleScrollToTop}
onScroll={this.handleScroll}
shouldUpdateScroll={shouldUpdateScroll}
>
{scrollableContent}
</ScrollableList>
);
return (
<Column ref={this.setColumnRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader
icon='bell'
active={isUnread}
title={intl.formatMessage(messages.title)}
onPin={this.handlePin}
onMove={this.handleMove}
onClick={this.handleHeaderClick}
pinned={pinned}
multiColumn={multiColumn}
>
<ColumnSettingsContainer />
</ColumnHeader>
{filterBarContainer}
{scrollContainer}
</Column>
);
}
}
|
node_modules/react-dropzone/src/index.js | premcool/getmydeal | /* eslint prefer-template: 0 */
import React from 'react';
import accepts from 'attr-accept';
import { deprecate } from 'react-is-deprecated';
import getDataTransferItems from './getDataTransferItems';
const supportMultiple = (typeof document !== 'undefined' && document && document.createElement) ?
'multiple' in document.createElement('input') :
true;
class Dropzone extends React.Component {
static renderChildren(children, isDragActive, isDragReject) {
if (typeof children === 'function') {
return children({ isDragActive, isDragReject });
}
return children;
}
constructor(props, context) {
super(props, context);
this.onClick = this.onClick.bind(this);
this.onDragStart = this.onDragStart.bind(this);
this.onDragEnter = this.onDragEnter.bind(this);
this.onDragLeave = this.onDragLeave.bind(this);
this.onDragOver = this.onDragOver.bind(this);
this.onDrop = this.onDrop.bind(this);
this.onFileDialogCancel = this.onFileDialogCancel.bind(this);
this.fileAccepted = this.fileAccepted.bind(this);
this.isFileDialogActive = false;
this.state = {
isDragActive: false
};
}
componentDidMount() {
this.enterCounter = 0;
// Tried implementing addEventListener, but didn't work out
document.body.onfocus = this.onFileDialogCancel;
}
componentWillUnmount() {
// Can be replaced with removeEventListener, if addEventListener works
document.body.onfocus = null;
}
onDragStart(e) {
if (this.props.onDragStart) {
this.props.onDragStart.call(this, e);
}
}
onDragEnter(e) {
e.preventDefault();
// Count the dropzone and any children that are entered.
++this.enterCounter;
const allFilesAccepted = this.allFilesAccepted(getDataTransferItems(e, this.props.multiple));
this.setState({
isDragActive: allFilesAccepted,
isDragReject: !allFilesAccepted
});
if (this.props.onDragEnter) {
this.props.onDragEnter.call(this, e);
}
}
onDragOver(e) { // eslint-disable-line class-methods-use-this
e.preventDefault();
e.stopPropagation();
try {
e.dataTransfer.dropEffect = 'copy'; // eslint-disable-line no-param-reassign
} catch (err) {
// continue regardless of error
}
if (this.props.onDragOver) {
this.props.onDragOver.call(this, e);
}
return false;
}
onDragLeave(e) {
e.preventDefault();
// Only deactivate once the dropzone and all children was left.
if (--this.enterCounter > 0) {
return;
}
this.setState({
isDragActive: false,
isDragReject: false
});
if (this.props.onDragLeave) {
this.props.onDragLeave.call(this, e);
}
}
onDrop(e) {
const { onDrop, onDropAccepted, onDropRejected, multiple, disablePreview } = this.props;
const fileList = getDataTransferItems(e, multiple);
const acceptedFiles = [];
const rejectedFiles = [];
// Stop default browser behavior
e.preventDefault();
// Reset the counter along with the drag on a drop.
this.enterCounter = 0;
this.isFileDialogActive = false;
fileList.forEach((file) => {
if (!disablePreview) {
file.preview = window.URL.createObjectURL(file); // eslint-disable-line no-param-reassign
}
if (this.fileAccepted(file) && this.fileMatchSize(file)) {
acceptedFiles.push(file);
} else {
rejectedFiles.push(file);
}
});
if (onDrop) {
onDrop.call(this, acceptedFiles, rejectedFiles, e);
}
if (rejectedFiles.length > 0 && onDropRejected) {
onDropRejected.call(this, rejectedFiles, e);
}
if (acceptedFiles.length > 0 && onDropAccepted) {
onDropAccepted.call(this, acceptedFiles, e);
}
// Reset drag state
this.setState({
isDragActive: false,
isDragReject: false
});
}
onClick(e) {
const { onClick, disableClick } = this.props;
if (!disableClick) {
e.stopPropagation();
this.open();
if (onClick) {
onClick.call(this, e);
}
}
}
onFileDialogCancel() {
// timeout will not recognize context of this method
const { onFileDialogCancel } = this.props;
const { fileInputEl } = this;
let { isFileDialogActive } = this;
// execute the timeout only if the onFileDialogCancel is defined and FileDialog
// is opened in the browser
if (onFileDialogCancel && isFileDialogActive) {
setTimeout(() => {
// Returns an object as FileList
const FileList = fileInputEl.files;
if (!FileList.length) {
isFileDialogActive = false;
onFileDialogCancel();
}
}, 300);
}
}
fileAccepted(file) {
return accepts(file, this.props.accept);
}
fileMatchSize(file) {
return file.size <= this.props.maxSize && file.size >= this.props.minSize;
}
allFilesAccepted(files) {
return files.every(this.fileAccepted);
}
open() {
this.isFileDialogActive = true;
this.fileInputEl.value = null;
this.fileInputEl.click();
}
render() {
const {
accept,
activeClassName,
inputProps,
multiple,
name,
rejectClassName,
children,
...rest
} = this.props;
let {
activeStyle,
className,
rejectStyle,
style,
...props // eslint-disable-line prefer-const
} = rest;
const { isDragActive, isDragReject } = this.state;
className = className || '';
if (isDragActive && activeClassName) {
className += ' ' + activeClassName;
}
if (isDragReject && rejectClassName) {
className += ' ' + rejectClassName;
}
if (!className && !style && !activeStyle && !rejectStyle) {
style = {
width: 200,
height: 200,
borderWidth: 2,
borderColor: '#666',
borderStyle: 'dashed',
borderRadius: 5
};
activeStyle = {
borderStyle: 'solid',
backgroundColor: '#eee'
};
rejectStyle = {
borderStyle: 'solid',
backgroundColor: '#ffdddd'
};
}
let appliedStyle;
if (activeStyle && isDragActive) {
appliedStyle = {
...style,
...activeStyle
};
} else if (rejectStyle && isDragReject) {
appliedStyle = {
...style,
...rejectStyle
};
} else {
appliedStyle = {
...style
};
}
const inputAttributes = {
accept,
type: 'file',
style: { display: 'none' },
multiple: supportMultiple && multiple,
ref: el => this.fileInputEl = el, // eslint-disable-line
onChange: this.onDrop
};
if (name && name.length) {
inputAttributes.name = name;
}
// Remove custom properties before passing them to the wrapper div element
const customProps = [
'acceptedFiles',
'disablePreview',
'disableClick',
'onDropAccepted',
'onDropRejected',
'onFileDialogCancel',
'maxSize',
'minSize'
];
const divProps = { ...props };
customProps.forEach(prop => delete divProps[prop]);
return (
<div
className={className}
style={appliedStyle}
{...divProps/* expand user provided props first so event handlers are never overridden */}
onClick={this.onClick}
onDragStart={this.onDragStart}
onDragEnter={this.onDragEnter}
onDragOver={this.onDragOver}
onDragLeave={this.onDragLeave}
onDrop={this.onDrop}
>
{Dropzone.renderChildren(children, isDragActive, isDragReject)}
<input
{...inputProps/* expand user provided inputProps first so inputAttributes override them */}
{...inputAttributes}
/>
</div>
);
}
}
Dropzone.defaultProps = {
disablePreview: false,
disableClick: false,
multiple: true,
maxSize: Infinity,
minSize: 0
};
Dropzone.propTypes = {
onClick: React.PropTypes.func,
onDrop: React.PropTypes.func,
onDropAccepted: React.PropTypes.func,
onDropRejected: React.PropTypes.func,
onDragStart: React.PropTypes.func,
onDragEnter: React.PropTypes.func,
onDragOver: React.PropTypes.func,
onDragLeave: React.PropTypes.func,
// Contents of the dropzone
children: React.PropTypes.oneOfType([
React.PropTypes.node,
React.PropTypes.func
]),
// CSS styles to apply
style: deprecate(
React.PropTypes.object,
'Prop style is deprecated. Use function as children to style dropzone and its contents.'
),
// CSS styles to apply when drop will be accepted
activeStyle: deprecate(
React.PropTypes.object,
'Prop activeStyle is deprecated. Use function as children to style dropzone and its contents.'
),
// CSS styles to apply when drop will be rejected
rejectStyle: deprecate(
React.PropTypes.object,
'Prop rejectStyle is deprecated. Use function as children to style dropzone and its contents.'
),
// Optional className
className: deprecate(
React.PropTypes.string,
'Prop className is deprecated. Use function as children to style dropzone and its contents.'
),
// className for accepted state
activeClassName: deprecate(
React.PropTypes.string,
'Prop activeClassName is deprecated. Use function as children to style dropzone and its contents.'
),
// className for rejected state
rejectClassName: deprecate(
React.PropTypes.string,
'Prop rejectClassName is deprecated. Use function as children to style dropzone and its contents.'
),
disablePreview: React.PropTypes.bool, // Enable/disable preview generation
disableClick: React.PropTypes.bool, // Disallow clicking on the dropzone container to open file dialog
onFileDialogCancel: React.PropTypes.func, // Provide a callback on clicking the cancel button of the file dialog
inputProps: React.PropTypes.object, // Pass additional attributes to the <input type="file"/> tag
multiple: React.PropTypes.bool, // Allow dropping multiple files
accept: React.PropTypes.string, // Allow specific types of files. See https://github.com/okonet/attr-accept for more information
name: React.PropTypes.string, // name attribute for the input tag
maxSize: deprecate(
React.PropTypes.number,
'Prop maxSize is deprecated and will be removed in the next major release'
),
minSize: deprecate(
React.PropTypes.number,
'Prop minSize is deprecated and will be removed in the next major release'
)
};
export default Dropzone;
|
front/src/IngredientPage.js | miyef/onboard-fridge | import React, { Component } from 'react';
import Fuse from 'fuse.js';
import moment from 'moment';
import FilterBar from './FilterBar';
import IngredientItem from './IngredientItem';
import AddButton from './AddButton';
import SortBar from './SortBar';
// For fuse
const options = {
shouldSort: false,
threshold: 0.4,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: ['name', 'tags'],
};
const sort = (array, property, reverse) => {
if (reverse) {
array = array.sort((val1, val2) => val1[property] > val2[property]);
} else {
array = array.sort((val1, val2) => val1[property] < val2[property]);
}
return array;
};
class IngredientPage extends Component {
constructor(props) {
super(props);
this.state = {
ingredients: [
{
name: 'Olives',
tags: ['Pizza', 'Snack'],
date: moment([2012, 4, 7]),
},
{
name: 'Apple',
tags: ['Fruit', 'Dessert'],
date: moment([2012, 0, 31]),
},
{
name: 'Banana',
tags: ['Fruit', 'Dessert'],
date: moment([2017, 11, 31]),
},
{
name: 'Pizza Crust',
tags: ['Pizza', 'Main'],
date: moment([2012, 0, 11]),
},
],
filter: '',
sortBy: null,
};
}
render() {
return (
<div>
<div
style={{
margin: 'auto',
width: '70%',
textAlign: 'center',
marginTop: '30px',
}}
className="vertical-align"
>
<FilterBar updateFilter={this.updateFilter} />
<AddButton nav={this.props.nav} />
</div>
<div className="ingredient-list">
<SortBar
toggleSort={this.toggleSort}
sortBy={this.state.sortBy}
/>
{this.displayIngredients(this.state.filter)}
</div>
</div>
);
}
displayIngredients = filter => {
// do filtering with fuse based on state.filter
const fuse = new Fuse(this.state.ingredients, options);
// if no filter specified simply display the ingredients as in state.ingredients
// we use .slice() to copy the array, copy which will be sorted (you don't want to modify the state).
const result = filter !== ''
? fuse.search(this.state.filter)
: this.state.ingredients.slice();
switch (this.state.sortBy) {
case 'nameup':
sort(result, 'name', false);
break;
case 'namedown':
sort(result, 'name', true);
break;
case 'dateup':
sort(result, 'date', false);
break;
case 'datedown':
sort(result, 'date', true);
break;
default:
break;
}
if (result.length > 0) {
return result.map(ingredient => (
<IngredientItem ingredient={ingredient} key={ingredient.name} />
));
}
return (
<p style={{ padding: '20px' }}> No ingredients found, sorry. </p>
);
};
updateFilter = filter => {
this.setState({ filter });
};
toggleSort = e => {
const property = e.target.getAttribute('property');
const className = e.target.className;
const sortBy = property + className;
if (this.state.sortBy === sortBy) {
this.setState({ sortBy: null });
} else {
this.setState({ sortBy });
}
};
}
export default IngredientPage;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.