@cerebral/inferno
Advanced tools
Comparing version 4.0.0-1521140905511 to 4.0.0-1525724201307
@@ -1,16 +0,22 @@ | ||
import { InfernoChildren, VNode, Component } from 'inferno'; | ||
import { InfernoChildren, VNode, Component } from 'inferno' | ||
/* eslint-disable-next-line no-unused-vars */ | ||
import { BaseControllerClass, Sequence } from 'cerebral' | ||
// TODO: Replace these type with Inferno JSX support | ||
type ComponentState = {}; | ||
type Validator<T> = (object: T, key: string, componentName: string, ...rest: any[]) => Error | null; | ||
type ValidationMap<T> = {[K in keyof T]?: Validator<T> }; | ||
type ComponentState = {} | ||
type Validator<T> = ( | ||
object: T, | ||
key: string, | ||
componentName: string, | ||
...rest: any[] | ||
) => Error | null | ||
type ValidationMap<T> = { [K in keyof T]?: Validator<T> } | ||
interface ComponentClass<P = {}> { | ||
new (props?: P, context?: any): Component<P, ComponentState>; | ||
propTypes?: ValidationMap<P>; | ||
contextTypes?: ValidationMap<any>; | ||
childContextTypes?: ValidationMap<any>; | ||
defaultProps?: Partial<P>; | ||
displayName?: string; | ||
new (props?: P, context?: any): Component<P, ComponentState> | ||
propTypes?: ValidationMap<P> | ||
contextTypes?: ValidationMap<any> | ||
childContextTypes?: ValidationMap<any> | ||
defaultProps?: Partial<P> | ||
displayName?: string | ||
} | ||
@@ -20,19 +26,21 @@ | ||
interface StatelessComponent<P = {}> { | ||
(props: P & { children?: InfernoChildren }, context?: any): InfernoJSXElement<any> | null; | ||
propTypes?: ValidationMap<P>; | ||
contextTypes?: ValidationMap<any>; | ||
defaultProps?: Partial<P>; | ||
displayName?: string; | ||
(props: P & { children?: InfernoChildren }, context?: any): InfernoJSXElement< | ||
any | ||
> | null | ||
propTypes?: ValidationMap<P> | ||
contextTypes?: ValidationMap<any> | ||
defaultProps?: Partial<P> | ||
displayName?: string | ||
} | ||
type ComponentType<P = {}> = ComponentClass<P> | StatelessComponent<P>; | ||
type ComponentType<P = {}> = ComponentClass<P> | StatelessComponent<P> | ||
declare global { | ||
namespace JSX { | ||
interface Element extends InfernoJSXElement<any> {} | ||
namespace JSX { | ||
interface Element extends InfernoJSXElement<any> {} | ||
interface IntrinsicElements { | ||
[elemName: string]: any; | ||
} | ||
interface IntrinsicElements { | ||
[elemName: string]: any | ||
} | ||
} | ||
} | ||
@@ -42,13 +50,17 @@ | ||
interface SignalsMap { | ||
[signalName: string]: Sequence | ||
[signalName: string]: Sequence | ||
} | ||
export const StateContainer: ComponentClass<{state: any, signals: SignalsMap}> | ||
export const Container: ComponentClass<{controller: BaseControllerClass}> | ||
export const StateContainer: ComponentClass<{ state: any; signals: SignalsMap }> | ||
export const Container: ComponentClass<{ controller: BaseControllerClass }> | ||
/* eslint-disable-next-line no-unused-vars */ | ||
type PropsMap<T> = { | ||
[P in keyof T]: any; // TODO: use correct type than Tag<any> | ||
[P in keyof T]: any // TODO: use correct type than Tag<any> | ||
} | ||
// Props are signal/state props, EProps are external props | ||
export function connect<Props, EProps = {}>(props: Props, comp: ComponentType<PropsMap<Props> & EProps>): ComponentClass<EProps> | ||
export function connect<Props, EProps = {}>( | ||
props: Props, | ||
comp: ComponentType<PropsMap<Props> & EProps> | ||
): ComponentClass<EProps> |
@@ -125,3 +125,5 @@ 'use strict'; | ||
value: function render() { | ||
return (0, _infernoCreateElement.createElement)(Component, this.view.getProps(this.props)); | ||
return this.view.render(this.props, function (componentProps) { | ||
return (0, _infernoCreateElement.createElement)(Component, componentProps); | ||
}); | ||
} | ||
@@ -128,0 +130,0 @@ }]); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.decorator = exports.connect = exports.StateContainer = exports.Container = undefined; | ||
exports.decorator = exports.connect = exports.Container = undefined; | ||
@@ -18,11 +18,2 @@ var _Container = require('./Container'); | ||
var _StateContainer = require('./StateContainer'); | ||
Object.defineProperty(exports, 'StateContainer', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_StateContainer).default; | ||
} | ||
}); | ||
var _Hoc = require('./Hoc'); | ||
@@ -29,0 +20,0 @@ |
{ | ||
"name": "@cerebral/inferno", | ||
"version": "4.0.0-1521140905511", | ||
"version": "4.0.0-1525724201307", | ||
"description": "Inferno view for Cerebral", | ||
@@ -16,5 +16,4 @@ "main": "index.js", | ||
"homepage": "http://cerebral.github.io/cerebral-website", | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"cerebral": "^5.0.0-1521140905511" | ||
"cerebral": "^5.0.0-1525724201307" | ||
}, | ||
@@ -25,3 +24,3 @@ "scripts": { | ||
"prepublish": "npm run build", | ||
"test": "mocha -r test/setup --compilers js:babel-register \"src/**/*.test.js\" \"test/**/*.test.js\"", | ||
"test": "mocha -r test/setup --require babel-register \"src/**/*.test.js\" \"test/**/*.test.js\"", | ||
"test:watch": "npm run test -- --watch" | ||
@@ -28,0 +27,0 @@ }, |
@@ -10,6 +10,7 @@ # @cerebral/inferno | ||
## Container | ||
```js | ||
import { render } from 'inferno' | ||
import {Controller} from 'cerebral' | ||
import {Container} from '@cerebral/inferno' | ||
import { Controller } from 'cerebral' | ||
import { Container } from '@cerebral/inferno' | ||
import App from './App' | ||
@@ -26,10 +27,12 @@ | ||
render(( | ||
render( | ||
<Container controller={controller}> | ||
<App /> | ||
</Container> | ||
), document.querySelector('#app')) | ||
</Container>, | ||
document.querySelector('#app') | ||
) | ||
``` | ||
## connect | ||
```js | ||
@@ -36,0 +39,0 @@ import { Component } from 'inferno' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63
20082
12
253