Skip to content

Instantly share code, notes, and snippets.

@atooni
Last active April 16, 2018 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atooni/6e201502ed5d8ae30a234676799ca846 to your computer and use it in GitHub Desktop.
Save atooni/6e201502ed5d8ae30a234676799ca846 to your computer and use it in GitHub Desktop.
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /home/andreas/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /andreas/projects/sjscomponents/project
[info] Loading settings from build.sbt ...
[info] Set current project to scalajs-react-components (in build file:/andreas/projects/sjscomponents/)
[info] Running com.olvind.sui.SuiRunner /andreas/projects/sjscomponents/gen/target/scala-2.12/scalajs-bundler/main/node_modules/semantic-ui-react/dist/commonjs /andreas/projects/sjscomponents/core/target/scala-2.12/src_managed/main
[info] Running com.olvind.mui.MuiRunner /andreas/projects/sjscomponents/gen/target/scala-2.12/scalajs-bundler/main/node_modules/material-ui /andreas/projects/sjscomponents/core/target/scala-2.12/src_managed/main
[info] Running com.olvind.eui.EuiRunner /andreas/projects/sjscomponents/gen/target/scala-2.12/scalajs-bundler/main/node_modules/elemental /andreas/projects/sjscomponents/core/target/scala-2.12/src_managed/main
{U%}Glyph
{U%}Dropzone
{U%}Radio
{U%}Container
{U%}Checkbox
ParsedFile(/andreas/projects/sjscomponents/gen/target/scala-2.12/scalajs-bundler/main/node_modules/semantic-ui-react/dist/commonjs/lib/AutoControlledComponent.js,'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAutoControlledStateValue = undefined;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _difference2 = require('lodash/difference');
var _difference3 = _interopRequireDefault(_difference2);
var _isUndefined2 = require('lodash/isUndefined');
var _isUndefined3 = _interopRequireDefault(_isUndefined2);
var _startsWith2 = require('lodash/startsWith');
var _startsWith3 = _interopRequireDefault(_startsWith2);
var _filter2 = require('lodash/filter');
var _filter3 = _interopRequireDefault(_filter2);
var _isEmpty2 = require('lodash/isEmpty');
var _isEmpty3 = _interopRequireDefault(_isEmpty2);
var _keys2 = require('lodash/keys');
var _keys3 = _interopRequireDefault(_keys2);
var _intersection2 = require('lodash/intersection');
var _intersection3 = _interopRequireDefault(_intersection2);
var _has2 = require('lodash/has');
var _has3 = _interopRequireDefault(_has2);
var _each2 = require('lodash/each');
var _each3 = _interopRequireDefault(_each2);
var _invoke2 = require('lodash/invoke');
var _invoke3 = _interopRequireDefault(_invoke2);
var _react = require('react');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getDefaultPropName = function getDefaultPropName(prop) {
return 'default' + (prop[0].toUpperCase() + prop.slice(1));
};
/**
* Return the auto controlled state value for a give prop. The initial value is chosen in this order:
* - regular props
* - then, default props
* - then, initial state
* - then, `checked` defaults to false
* - then, `value` defaults to '' or [] if props.multiple
* - else, undefined
*
* @param {string} propName A prop name
* @param {object} [props] A props object
* @param {object} [state] A state object
* @param {boolean} [includeDefaults=false] Whether or not to heed the default props or initial state
*/
/* eslint-disable no-console */
/**
* Why choose inheritance over a HOC? Multiple advantages for this particular use case.
* In short, we need identical functionality to setState(), unless there is a prop defined
* for the state key. Also:
*
* 1. Single Renders
* Calling trySetState() in constructor(), componentWillMount(), or componentWillReceiveProps()
* does not cause two renders. Consumers and tests do not have to wait two renders to get state.
* See www.react.run/4kJFdKoxb/27 for an example of this issue.
*
* 2. Simple Testing
* Using a HOC means you must either test the undecorated component or test through the decorator.
* Testing the undecorated component means you must mock the decorator functionality.
* Testing through the HOC means you can not simply shallow render your component.
*
* 3. Statics
* HOC wrap instances, so statics are no longer accessible. They can be hoisted, but this is more
* looping over properties and storing references. We rely heavily on statics for testing and sub
* components.
*
* 4. Instance Methods
* Some instance methods may be exposed to users via refs. Again, these are lost with HOC unless
* hoisted and exposed by the HOC.
*/
var getAutoControlledStateValue = exports.getAutoControlledStateValue = function getAutoControlledStateValue(propName, props, state) {
var includeDefaults = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var propValue = props[propName];
if (propValue !== undefined) return propValue;
if (includeDefaults) {
var defaultProp = props[getDefaultPropName(propName)];
if (defaultProp !== undefined) return defaultProp;
if (state) {
var initialState = state[propName];
if (initialState !== undefined) return initialState;
}
}
if (propName === 'checked') return false;
if (propName === 'value') return props.multiple ? [] : '';
};
var AutoControlledComponent = function (_Component) {
(0, _inherits3.default)(AutoControlledComponent, _Component);
function AutoControlledComponent() {
var _ref;
(0, _classCallCheck3.default)(this, AutoControlledComponent);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = (0, _possibleConstructorReturn3.default)(this, (_ref = AutoControlledComponent.__proto__ || Object.getPrototypeOf(AutoControlledComponent)).call.apply(_ref, [this].concat(args)));
_initialiseProps.call(_this);
var autoControlledProps = _this.constructor.autoControlledProps;
var state = (0, _invoke3.default)(_this, 'getInitialAutoControlledState', _this.props) || {};
if (process.env.NODE_ENV !== 'production') {
var _this$constructor = _this.constructor,
defaultProps = _this$constructor.defaultProps,
name = _this$constructor.name,
propTypes = _this$constructor.propTypes;
if (!autoControlledProps) {
console.error('Auto controlled ' + name + ' must specify a static autoControlledProps array.');
}
(0, _each3.default)(autoControlledProps, function (prop) {
var defaultProp = getDefaultPropName(prop);
if (!(0, _has3.default)(propTypes, defaultProp)) {
console.error(name + ' is missing "' + defaultProp + '" propTypes validation for auto controlled prop "' + prop + '".');
}
if (!(0, _has3.default)(propTypes, prop)) {
console.error(name + ' is missing propTypes validation for auto controlled prop "' + prop + '".');
}
});
var illegalDefaults = (0, _intersection3.default)(autoControlledProps, (0, _keys3.default)(defaultProps));
if (!(0, _isEmpty3.default)(illegalDefaults)) {
console.error(['Do not set defaultProps for autoControlledProps. You can set defaults by', 'setting state in the constructor or using an ES7 property initializer', '(https:
}
var illegalAutoControlled = (0, _filter3.default)(autoControlledProps, function (prop) {
return (0, _startsWith3.default)(prop, 'default');
});
if (!(0, _isEmpty3.default)(illegalAutoControlled)) {
console.error(['Do not add default props to autoControlledProps.', 'Default props are automatically handled.', 'See ' + name + ' autoControlledProps: "' + illegalAutoControlled + '".'].join(' '));
}
}
var initialAutoControlledState = autoControlledProps.reduce(function (acc, prop) {
acc[prop] = getAutoControlledStateValue(prop, _this.props, state, true);
if (process.env.NODE_ENV !== 'production') {
var defaultPropName = getDefaultPropName(prop);
var _name = _this.constructor.name;
if (!(0, _isUndefined3.default)(_this.props[defaultPropName]) && !(0, _isUndefined3.default)(_this.props[prop])) {
console.error(_name + ' prop "' + prop + '" is auto controlled. Specify either ' + defaultPropName + ' or ' + prop + ', but not both.');
}
}
return acc;
}, {});
_this.state = (0, _extends3.default)({}, state, initialAutoControlledState);
return _this;
}
(0, _createClass3.default)(AutoControlledComponent, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
var _this2 = this;
var autoControlledProps = this.constructor.autoControlledProps;
var newState = autoControlledProps.reduce(function (acc, prop) {
var isNextUndefined = (0, _isUndefined3.default)(nextProps[prop]);
var propWasRemoved = !(0, _isUndefined3.default)(_this2.props[prop]) && isNextUndefined;
if (!isNextUndefined) acc[prop] = nextProps[prop];
else if (propWasRemoved) acc[prop] = getAutoControlledStateValue(prop, nextProps);
return acc;
}, {});
if (Object.keys(newState).length > 0) this.setState(newState);
}
/**
* Safely attempt to set state for props that might be controlled by the user.
* Second argument is a state object that is always passed to setState.
* @param {object} maybeState State that corresponds to controlled props.
* @param {object} [state] Actual state, useful when you also need to setState.
*/
}]);
return AutoControlledComponent;
}(_react.Component);
var _initialiseProps = function _initialiseProps() {
var _this3 = this;
this.trySetState = function (maybeState, state) {
var autoControlledProps = _this3.constructor.autoControlledProps;
if (process.env.NODE_ENV !== 'production') {
var name = _this3.constructor.name;
var illegalKeys = (0, _difference3.default)((0, _keys3.default)(maybeState), autoControlledProps);
if (!(0, _isEmpty3.default)(illegalKeys)) {
console.error([name + ' called trySetState() with controlled props: "' + illegalKeys + '".', 'State will not be set.', 'Only props in static autoControlledProps will be set on state.'].join(' '));
}
}
var newState = Object.keys(maybeState).reduce(function (acc, prop) {
if (_this3.props[prop] !== undefined) return acc;
if (autoControlledProps.indexOf(prop) === -1) return acc;
acc[prop] = maybeState[prop];
return acc;
}, {});
if (state) newState = (0, _extends3.default)({}, newState, state);
if (Object.keys(newState).length > 0) _this3.setState(newState);
};
};
exports.default = AutoControlledComponent;,null)
missing types for method: (Dropdown,0,getDropdownMenuAriaOptions)
missing types for method: (Dropdown,0,getInitialAutoControlledState)
case ("FormField","type","_lib.customevery([_lib.customdemand(['control'])]
)") => Normal("js.Any") //TODO write this Missing in TypeMapper
missing types for method: (Icon,0,getIconAriaOptions)
missing types for method: (Menu,0,renderItems)
missing types for method: (Popup,1,computePopupStyle)
missing types for method: (Popup,0,getPortalProps)
missing types for method: (Popup,1,isStyleInViewport)
missing types for method: (Popup,0,setPopupStyle)
[info] Compiling 122 Scala sources to /andreas/projects/sjscomponents/demo/target/scala-2.12/classes ...
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/ReactPopoverDemo.scala:37:84: value value is not a member of japgolly.scalajs.react.Ref.ToScalaComponent[chandu0101.scalajs.react.components.ReactPopOver.Props,chandu0101.scalajs.react.components.ReactPopOver.State,chandu0101.scalajs.react.components.ReactPopOver.Backend,japgolly.scalajs.react.CtorType.PropsAndChildren]
[error] LocalDemoButton(name = "Top Button", onButtonClick = toggleCB(topRef.value))
[error] ^
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/ReactPopoverDemo.scala:41:86: value value is not a member of japgolly.scalajs.react.Ref.ToScalaComponent[chandu0101.scalajs.react.components.ReactPopOver.Props,chandu0101.scalajs.react.components.ReactPopOver.State,chandu0101.scalajs.react.components.ReactPopOver.Backend,japgolly.scalajs.react.CtorType.PropsAndChildren]
[error] LocalDemoButton(name = "Left Button", onButtonClick = toggleCB(leftRef.value))
[error] ^
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/ReactPopoverDemo.scala:45:88: value value is not a member of japgolly.scalajs.react.Ref.ToScalaComponent[chandu0101.scalajs.react.components.ReactPopOver.Props,chandu0101.scalajs.react.components.ReactPopOver.State,chandu0101.scalajs.react.components.ReactPopOver.Backend,japgolly.scalajs.react.CtorType.PropsAndChildren]
[error] LocalDemoButton(name = "Right Button", onButtonClick = toggleCB(rightRef.value))
[error] ^
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/ReactPopoverDemo.scala:49:90: value value is not a member of japgolly.scalajs.react.Ref.ToScalaComponent[chandu0101.scalajs.react.components.ReactPopOver.Props,chandu0101.scalajs.react.components.ReactPopOver.State,chandu0101.scalajs.react.components.ReactPopOver.Backend,japgolly.scalajs.react.CtorType.PropsAndChildren]
[error] LocalDemoButton(name = "Bottom Button", onButtonClick = toggleCB(bottomRef.value))
[error] ^
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/elementalui/EuiMiscDemo.scala:27:18: missing argument list for method identity in object Predef
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] You can make this conversion explicit by writing `identity _` or `identity(_)` instead of `identity`.
[error] $.modState(identity)
[error] ^
[warn] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/materialui/MuiMenuDemo.scala:38:23: non-variable type argument demo.components.materialui.MuiMenuDemo.Value in type pattern scala.scalajs.js.Array[demo.components.materialui.MuiMenuDemo.Value] is unchecked since it is eliminated by erasure
[warn] case vs: js.Array[Value] => $.modState(_.copy(values = vs))
[warn] ^
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/materialui/MuiPopoverDemo.scala:76:23: type mismatch;
[error] found : scala.scalajs.js.UndefOr[org.scalajs.dom.html.Div]
[error] (which expands to) scala.scalajs.js.UndefOr[org.scalajs.dom.raw.HTMLDivElement]
[error] required: japgolly.scalajs.react.Ref[?, _]
[error] ).withRef(ref),
[error] ^
[warn] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/reacttable/ReactTableBasic.scala:28:22: inferred existential type japgolly.scalajs.react.component.Generic.MountedWithRoot[japgolly.scalajs.react.CallbackTo,_$1,_$2,_$1,_$2] forSome { type _$1; type _$2 }, which cannot be expressed by wildcards, should be enabled
[warn] by making the implicit value scala.language.existentials visible.
[warn] This can be achieved by adding the import clause 'import scala.language.existentials'
[warn] or by setting the compiler option -language:existentials.
[warn] See the Scaladoc for value scala.language.existentials for a discussion
[warn] why the feature should be explicitly enabled.
[warn] case class Backend($ : BackendScope[_, _]) {
[warn] ^
[warn] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/reacttable/ReactTableCustomCell.scala:17:22: inferred existential type japgolly.scalajs.react.component.Generic.MountedWithRoot[japgolly.scalajs.react.CallbackTo,_$1,_$2,_$1,_$2] forSome { type _$1; type _$2 }, which cannot be expressed by wildcards, should be enabled
[warn] by making the implicit value scala.language.existentials visible.
[warn] case class Backend($ : BackendScope[_, _]) {
[warn] ^
[warn] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/reacttable/ReactTableCustomColumnSize.scala:18:22: inferred existential type japgolly.scalajs.react.component.Generic.MountedWithRoot[japgolly.scalajs.react.CallbackTo,_$1,_$2,_$1,_$2] forSome { type _$1; type _$2 }, which cannot be expressed by wildcards, should be enabled
[warn] by making the implicit value scala.language.existentials visible.
[warn] case class Backend($ : BackendScope[_, _]) {
[warn] ^
[error] /andreas/projects/sjscomponents/demo/src/main/scala/demo/components/semanticui/SuiGridDemo.scala:20:20: not found: value src
[error] SuiImage(src = "http://semantic-ui.com/images/wireframe/image.png")()).vdomElement))
[error] ^
[warn] /andreas/projects/sjscomponents/demo/src/main/scala/demo/pages/ReactSplitPanePage.scala:10:22: inferred existential type japgolly.scalajs.react.component.Generic.MountedWithRoot[japgolly.scalajs.react.CallbackTo,_$1,_$2,_$1,_$2] forSome { type _$1; type _$2 }, which cannot be expressed by wildcards, should be enabled
[warn] by making the implicit value scala.language.existentials visible.
[warn] case class Backend($ : BackendScope[_, _]) {
[warn] ^
[warn] 5 warnings found
[error] 7 errors found
[error] (demo / Compile / compileIncremental) Compilation failed
[error] Total time: 21 s, completed Apr 16, 2018 8:17:52 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment