korok-react
Advanced tools
Comparing version 0.0.3 to 0.0.4
/*! | ||
* Korok React (version 0.0.3) - Configurable Components System | ||
* Korok React (version 0.0.4) - Configurable Components System | ||
* | ||
@@ -126,4 +126,5 @@ * Will Wen Gunn(iwillwen) and other contributors | ||
exports.setupKorok = setupKorok; | ||
function registerKorok(key) { | ||
var decorate = function (component) { | ||
function registerKorok(key, options) { | ||
if (options === void 0) { options = {}; } | ||
function decorate(component) { | ||
if (!Korok) { | ||
@@ -154,12 +155,14 @@ throw new Error('not apply `setupKorok(Korok)` yet'); | ||
Korok.register(key, component); | ||
if (options.props && Object.keys(options.props).length > 0) { | ||
for (var propKey in options.props) { | ||
Korok.registerProp(key, propKey, options.props[propKey]); | ||
} | ||
} | ||
if (options.params && Object.keys(options.params).length > 0) { | ||
for (var paramKey in options.params) { | ||
Korok.registerParam(key, paramKey, options.params[paramKey]); | ||
} | ||
} | ||
return component; | ||
}; | ||
decorate.registerParam = function (paramKey, options) { | ||
Korok.registerParam(key, paramKey, options); | ||
return decorate; | ||
}; | ||
decorate.registerProp = function (propKey, options) { | ||
Korok.registerProp(key, propKey, options); | ||
return decorate; | ||
}; | ||
} | ||
return decorate; | ||
@@ -166,0 +169,0 @@ } |
{ | ||
"name": "korok-react", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Korok React Enhancer", | ||
@@ -5,0 +5,0 @@ "main": "dist/korok-react.js", |
@@ -14,12 +14,15 @@ import { patch } from './util' | ||
interface IDecorateFunc { | ||
(component: React.ComponentClass): React.ComponentClass | ||
registerParam?(key: string, options?: IKorokParam): IDecorateFunc | ||
registerProp?(key: string, options?: IKorokProp): IDecorateFunc | ||
interface IRegisterOptions { | ||
props?: { | ||
[key: string]: IKorokProp | ||
} | ||
params?: { | ||
[key: string]: IKorokParam | ||
} | ||
} | ||
export function registerKorok(key: string) { | ||
const decorate: IDecorateFunc = function(component: React.ComponentClass): React.ComponentClass { | ||
export function registerKorok(key: string, options: IRegisterOptions = {}) { | ||
function decorate<P>(component: React.StatelessComponent<P>): React.ComponentClass<P> | ||
function decorate<P, TFunction extends React.ComponentClass<P>>(component: TFunction): TFunction | ||
function decorate<P>(component: any) { | ||
if (!Korok) { | ||
@@ -55,19 +58,19 @@ throw new Error('not apply `setupKorok(Korok)` yet') | ||
Korok.register(key, component) | ||
if (options.props && Object.keys(options.props).length > 0) { | ||
for (const propKey in options.props) { | ||
Korok.registerProp(key, propKey, options.props[propKey]) | ||
} | ||
} | ||
if (options.params && Object.keys(options.params).length > 0) { | ||
for (const paramKey in options.params) { | ||
Korok.registerParam(key, paramKey, options.params[paramKey]) | ||
} | ||
} | ||
return component | ||
} | ||
decorate.registerParam = function(paramKey: string, options?: IKorokParam) { | ||
Korok.registerParam(key, paramKey, options) | ||
return decorate | ||
} | ||
decorate.registerProp = function(propKey: string, options?: IKorokParam) { | ||
Korok.registerProp(key, propKey, options) | ||
return decorate | ||
} | ||
return decorate | ||
} |
/// <reference types="react" /> | ||
import { default as KorokClass, IKorokParam, IKorokProp } from 'korok-core'; | ||
export declare function setupKorok(korok: typeof KorokClass): void; | ||
interface IDecorateFunc { | ||
(component: React.ComponentClass): React.ComponentClass; | ||
registerParam?(key: string, options?: IKorokParam): IDecorateFunc; | ||
registerProp?(key: string, options?: IKorokProp): IDecorateFunc; | ||
interface IRegisterOptions { | ||
props?: { | ||
[key: string]: IKorokProp; | ||
}; | ||
params?: { | ||
[key: string]: IKorokParam; | ||
}; | ||
} | ||
export declare function registerKorok(key: string): IDecorateFunc; | ||
export declare function registerKorok(key: string, options?: IRegisterOptions): { | ||
<P>(component: import("react").StatelessComponent<P>): import("react").ComponentClass<P, any>; | ||
<P, TFunction extends import("react").ComponentClass<P, any>>(component: TFunction): TFunction; | ||
}; | ||
export {}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
125000
519
0