forked from react-recompose/react-recompose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1001a0a
commit c08394b
Showing
60 changed files
with
5,333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/**/__tests__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
See README.md in the root of this project | ||
|
||
<!-- ORIGINAL CONTENT HIDDEN: | ||
recompose | ||
========= | ||
[![npm version](https://img.shields.io/npm/v/recompose.svg?style=flat-square)](https://www.npmjs.com/package/recompose) | ||
Recompose is a React utility belt for function components and higher-order components. See the [GitHub project page](https://github.com/acdlite/recompose) for more information. | ||
- --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var _symbolObservable = _interopRequireDefault(require("symbol-observable")); | ||
var Bacon = _interopRequireWildcard(require("baconjs")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var config = { | ||
fromESObservable: function fromESObservable(observable) { | ||
return Bacon.fromBinder(function (sink) { | ||
var _observable$subscribe = observable.subscribe({ | ||
next: function next(val) { | ||
return sink(new Bacon.Next(val)); | ||
}, | ||
error: function error(err) { | ||
return sink(new Bacon.Error(err)); | ||
}, | ||
complete: function complete() { | ||
return sink(new Bacon.End()); | ||
} | ||
}), | ||
unsubscribe = _observable$subscribe.unsubscribe; | ||
return unsubscribe; | ||
}); | ||
}, | ||
toESObservable: function toESObservable(stream) { | ||
var _ref; | ||
return _ref = { | ||
subscribe: function subscribe(observer) { | ||
var unsubscribe = stream.subscribe(function (event) { | ||
if (event.hasValue) { | ||
observer.next(event.value); | ||
} else if (event.isError) { | ||
observer.error(event.error); | ||
} else if (event.isEnd) { | ||
observer.complete(); | ||
} | ||
}); | ||
return { | ||
unsubscribe: unsubscribe | ||
}; | ||
} | ||
}, _ref[_symbolObservable["default"]] = function () { | ||
return this; | ||
}, _ref; | ||
} | ||
}; | ||
var _default = config; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var _createFactory = _interopRequireDefault(require("./utils/createFactory")); | ||
var _setDisplayName = _interopRequireDefault(require("./setDisplayName")); | ||
var _wrapDisplayName = _interopRequireDefault(require("./wrapDisplayName")); | ||
var identity = function identity(Component) { | ||
return Component; | ||
}; | ||
var branch = function branch(test, left, right) { | ||
if (right === void 0) { | ||
right = identity; | ||
} | ||
return function (BaseComponent) { | ||
var leftFactory; | ||
var rightFactory; | ||
var Branch = function Branch(props) { | ||
if (test(props)) { | ||
leftFactory = leftFactory || (0, _createFactory["default"])(left(BaseComponent)); | ||
return leftFactory(props); | ||
} | ||
rightFactory = rightFactory || (0, _createFactory["default"])(right(BaseComponent)); | ||
return rightFactory(props); | ||
}; | ||
if (process.env.NODE_ENV !== 'production') { | ||
return (0, _setDisplayName["default"])((0, _wrapDisplayName["default"])(BaseComponent, 'branch'))(Branch); | ||
} | ||
return Branch; | ||
}; | ||
}; | ||
var _default = branch; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var _react = require("react"); | ||
var _omit = _interopRequireDefault(require("./utils/omit")); | ||
var componentFromProp = function componentFromProp(propName) { | ||
function Component(props) { | ||
return /*#__PURE__*/(0, _react.createElement)(props[propName], (0, _omit["default"])(props, [propName])); | ||
} | ||
Component.displayName = "componentFromProp(" + propName + ")"; | ||
return Component; | ||
}; | ||
var _default = componentFromProp; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = exports.componentFromStreamWithConfig = void 0; | ||
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")); | ||
var _react = require("react"); | ||
var _changeEmitter = require("change-emitter"); | ||
var _symbolObservable = _interopRequireDefault(require("symbol-observable")); | ||
var _setObservableConfig = require("./setObservableConfig"); | ||
var componentFromStreamWithConfig = function componentFromStreamWithConfig(config) { | ||
return function (propsToVdom) { | ||
return /*#__PURE__*/function (_Component) { | ||
(0, _inheritsLoose2["default"])(ComponentFromStream, _Component); | ||
function ComponentFromStream() { | ||
var _config$fromESObserva; | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_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) { | ||
if (props) { | ||
observer.next(props); | ||
} else { | ||
observer.complete(); | ||
} | ||
}); | ||
return { | ||
unsubscribe: unsubscribe | ||
}; | ||
} | ||
}, _config$fromESObserva[_symbolObservable["default"]] = function () { | ||
return this; | ||
}, _config$fromESObserva)); | ||
_this.vdom$ = config.toESObservable(propsToVdom(_this.props$)); | ||
return _this; | ||
} | ||
var _proto = ComponentFromStream.prototype; | ||
_proto.UNSAFE_componentWillMount = function UNSAFE_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); | ||
}; | ||
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) { | ||
// Receive new props from the owner | ||
this.propsEmitter.emit(nextProps); | ||
}; | ||
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { | ||
return nextState.vdom !== this.state.vdom; | ||
}; | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
// Call without arguments to complete stream | ||
this.propsEmitter.emit(); | ||
|
||
// Clean-up subscription before un-mounting | ||
this.subscription.unsubscribe(); | ||
}; | ||
_proto.render = function render() { | ||
return this.state.vdom; | ||
}; | ||
return ComponentFromStream; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.componentFromStreamWithConfig = componentFromStreamWithConfig; | ||
var componentFromStream = function componentFromStream(propsToVdom) { | ||
return componentFromStreamWithConfig(_setObservableConfig.config)(propsToVdom); | ||
}; | ||
var _default = componentFromStream; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var compose = function compose() { | ||
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
return funcs.reduce(function (a, b) { | ||
return function () { | ||
return a(b.apply(void 0, arguments)); | ||
}; | ||
}, function (arg) { | ||
return arg; | ||
}); | ||
}; | ||
var _default = compose; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = exports.createEventHandlerWithConfig = void 0; | ||
var _symbolObservable = _interopRequireDefault(require("symbol-observable")); | ||
var _changeEmitter = require("change-emitter"); | ||
var _setObservableConfig = require("./setObservableConfig"); | ||
var 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[_symbolObservable["default"]] = function () { | ||
return this; | ||
}, _config$fromESObserva)); | ||
return { | ||
handler: emitter.emit, | ||
stream: stream | ||
}; | ||
}; | ||
}; | ||
exports.createEventHandlerWithConfig = createEventHandlerWithConfig; | ||
var createEventHandler = createEventHandlerWithConfig(_setObservableConfig.config); | ||
var _default = createEventHandler; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")); | ||
var _react = require("react"); | ||
var _reactLifecyclesCompat = require("react-lifecycles-compat"); | ||
var createSink = function createSink(callback) { | ||
var Sink = /*#__PURE__*/function (_Component) { | ||
(0, _inheritsLoose2["default"])(Sink, _Component); | ||
function Sink() { | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _Component.call.apply(_Component, [this].concat(args)) || this; | ||
_this.state = {}; | ||
return _this; | ||
} | ||
Sink.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps) { | ||
callback(nextProps); | ||
return null; | ||
}; | ||
var _proto = Sink.prototype; | ||
_proto.render = function render() { | ||
return null; | ||
}; | ||
return Sink; | ||
}(_react.Component); | ||
(0, _reactLifecyclesCompat.polyfill)(Sink); | ||
return Sink; | ||
}; | ||
var _default = createSink; | ||
exports["default"] = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
var _createFactory = _interopRequireDefault(require("./utils/createFactory")); | ||
var _setDisplayName = _interopRequireDefault(require("./setDisplayName")); | ||
var _wrapDisplayName = _interopRequireDefault(require("./wrapDisplayName")); | ||
var defaultProps = function defaultProps(props) { | ||
return function (BaseComponent) { | ||
var factory = (0, _createFactory["default"])(BaseComponent); | ||
function DefaultProps(ownerProps) { | ||
return factory(ownerProps); | ||
} | ||
DefaultProps.defaultProps = props; | ||
if (process.env.NODE_ENV !== 'production') { | ||
return (0, _setDisplayName["default"])((0, _wrapDisplayName["default"])(BaseComponent, 'defaultProps'))(DefaultProps); | ||
} | ||
return DefaultProps; | ||
}; | ||
}; | ||
var _default = defaultProps; | ||
exports["default"] = _default; |
Oops, something went wrong.