intact-react
Advanced tools
Comparing version 3.0.10 to 3.0.11
@@ -5,2 +5,3 @@ import { ComponentFunction, VNodeComponentClass, Props } from 'intact'; | ||
(props: Props<P, any>, isReact?: boolean): VNodeComponentClass | VNodeComponentClass[]; | ||
events?: Record<string, boolean>; | ||
}; | ||
@@ -7,0 +8,0 @@ export declare const cid = "IntactReactFunctional"; |
@@ -453,3 +453,3 @@ 'use strict'; | ||
// invoked by React | ||
var vNodes = Component(normalizeProps(props), true); | ||
var vNodes = Component(normalizeProps(props, Component.events), true); | ||
if (isArray(vNodes)) { | ||
@@ -499,8 +499,9 @@ return react.createElement(react.Fragment, null, vNodes.map(function (vNode, index) { | ||
var key = vNode.key; | ||
var props = normalizeProps(vNode.props); | ||
var type = vNode.type; | ||
var tag = type.$cid === cid ? type._$type : type; | ||
var props = normalizeProps(vNode.props, tag.events); | ||
if (!isNullOrUndefined(key)) { | ||
props.key = key; | ||
} | ||
return intact.createComponentVNode(4, type.$cid === cid ? type._$type : type, props, key, normalizeRef(vNode.ref)); | ||
return intact.createComponentVNode(4, tag, props, key, normalizeRef(vNode.ref)); | ||
} | ||
@@ -536,3 +537,3 @@ if (vNode.type === react.Fragment) { | ||
} | ||
function normalizeProps(props) { | ||
function normalizeProps(props, events) { | ||
// if (!props) return null; | ||
@@ -547,3 +548,3 @@ var blocks = null; | ||
} | ||
else if (tmp = getEventName(key)) { | ||
else if (tmp = getEventName(key, events)) { | ||
normalizedProps[tmp] = value; | ||
@@ -572,3 +573,3 @@ } | ||
} | ||
function getEventName(propName) { | ||
function getEventName(propName, events) { | ||
var third = propName[2]; | ||
@@ -596,4 +597,9 @@ if (!third) | ||
else { | ||
// e.g. onClick | ||
return "ev-".concat(lowerFirst(eventName.replace(/-/g, ':'))); | ||
// e.g. onClick -> ev-click; onKeyPress -> ev-keypress | ||
var loweredFirst = lowerFirst(eventName.replace(/-/g, ':')); | ||
if (!events || !events[loweredFirst]) { | ||
// is native event | ||
loweredFirst = loweredFirst.toLowerCase(); | ||
} | ||
return "ev-".concat(loweredFirst); | ||
} | ||
@@ -645,4 +651,6 @@ } | ||
else { | ||
// super(null, null as any, false, [], null); | ||
// Intact component in React | ||
var normalizedProps = normalizeProps(props); | ||
// @ts-ignore | ||
var normalizedProps = normalizeProps(props, _this.constructor.events); | ||
var parent_1 = $vNodeOrContext; | ||
@@ -746,3 +754,3 @@ var mountedQueue = getMountedQueue(parent_1); | ||
Component.prototype.componentDidUpdate = function () { | ||
var normalizedProps = normalizeProps(this.props); | ||
var normalizedProps = normalizeProps(this.props, this.constructor.events); | ||
var vNode = intact.createComponentVNode(4, this.constructor, normalizedProps); | ||
@@ -749,0 +757,0 @@ { |
@@ -436,3 +436,3 @@ 'use strict'; | ||
// invoked by React | ||
var vNodes = Component(normalizeProps(props), true); | ||
var vNodes = Component(normalizeProps(props, Component.events), true); | ||
if (isArray(vNodes)) { | ||
@@ -482,8 +482,9 @@ return react.createElement(react.Fragment, null, vNodes.map(function (vNode, index) { | ||
var key = vNode.key; | ||
var props = normalizeProps(vNode.props); | ||
var type = vNode.type; | ||
var tag = type.$cid === cid ? type._$type : type; | ||
var props = normalizeProps(vNode.props, tag.events); | ||
if (!isNullOrUndefined(key)) { | ||
props.key = key; | ||
} | ||
return intact.createComponentVNode(4, type.$cid === cid ? type._$type : type, props, key, normalizeRef(vNode.ref)); | ||
return intact.createComponentVNode(4, tag, props, key, normalizeRef(vNode.ref)); | ||
} | ||
@@ -519,3 +520,3 @@ if (vNode.type === react.Fragment) { | ||
} | ||
function normalizeProps(props) { | ||
function normalizeProps(props, events) { | ||
// if (!props) return null; | ||
@@ -530,3 +531,3 @@ var blocks = null; | ||
} | ||
else if (tmp = getEventName(key)) { | ||
else if (tmp = getEventName(key, events)) { | ||
normalizedProps[tmp] = value; | ||
@@ -555,3 +556,3 @@ } | ||
} | ||
function getEventName(propName) { | ||
function getEventName(propName, events) { | ||
var third = propName[2]; | ||
@@ -579,4 +580,9 @@ if (!third) | ||
else { | ||
// e.g. onClick | ||
return "ev-".concat(lowerFirst(eventName.replace(/-/g, ':'))); | ||
// e.g. onClick -> ev-click; onKeyPress -> ev-keypress | ||
var loweredFirst = lowerFirst(eventName.replace(/-/g, ':')); | ||
if (!events || !events[loweredFirst]) { | ||
// is native event | ||
loweredFirst = loweredFirst.toLowerCase(); | ||
} | ||
return "ev-".concat(loweredFirst); | ||
} | ||
@@ -624,4 +630,6 @@ } | ||
else { | ||
// super(null, null as any, false, [], null); | ||
// Intact component in React | ||
var normalizedProps = normalizeProps(props); | ||
// @ts-ignore | ||
var normalizedProps = normalizeProps(props, _this.constructor.events); | ||
var parent_1 = $vNodeOrContext; | ||
@@ -722,3 +730,3 @@ var mountedQueue = getMountedQueue(parent_1); | ||
Component.prototype.componentDidUpdate = function () { | ||
var normalizedProps = normalizeProps(this.props); | ||
var normalizedProps = normalizeProps(this.props, this.constructor.events); | ||
var vNode = intact.createComponentVNode(4, this.constructor, normalizedProps); | ||
@@ -725,0 +733,0 @@ vNode.children = this; |
@@ -450,3 +450,3 @@ import { __spreadArray, __assign, __extends } from 'tslib'; | ||
// invoked by React | ||
var vNodes = Component(normalizeProps(props), true); | ||
var vNodes = Component(normalizeProps(props, Component.events), true); | ||
if (isArray(vNodes)) { | ||
@@ -496,8 +496,9 @@ return createElement(Fragment, null, vNodes.map(function (vNode, index) { | ||
var key = vNode.key; | ||
var props = normalizeProps(vNode.props); | ||
var type = vNode.type; | ||
var tag = type.$cid === cid ? type._$type : type; | ||
var props = normalizeProps(vNode.props, tag.events); | ||
if (!isNullOrUndefined(key)) { | ||
props.key = key; | ||
} | ||
return createComponentVNode(4, type.$cid === cid ? type._$type : type, props, key, normalizeRef(vNode.ref)); | ||
return createComponentVNode(4, tag, props, key, normalizeRef(vNode.ref)); | ||
} | ||
@@ -533,3 +534,3 @@ if (vNode.type === Fragment) { | ||
} | ||
function normalizeProps(props) { | ||
function normalizeProps(props, events) { | ||
// if (!props) return null; | ||
@@ -544,3 +545,3 @@ var blocks = null; | ||
} | ||
else if (tmp = getEventName(key)) { | ||
else if (tmp = getEventName(key, events)) { | ||
normalizedProps[tmp] = value; | ||
@@ -569,3 +570,3 @@ } | ||
} | ||
function getEventName(propName) { | ||
function getEventName(propName, events) { | ||
var third = propName[2]; | ||
@@ -593,4 +594,9 @@ if (!third) | ||
else { | ||
// e.g. onClick | ||
return "ev-".concat(lowerFirst(eventName.replace(/-/g, ':'))); | ||
// e.g. onClick -> ev-click; onKeyPress -> ev-keypress | ||
var loweredFirst = lowerFirst(eventName.replace(/-/g, ':')); | ||
if (!events || !events[loweredFirst]) { | ||
// is native event | ||
loweredFirst = loweredFirst.toLowerCase(); | ||
} | ||
return "ev-".concat(loweredFirst); | ||
} | ||
@@ -642,4 +648,6 @@ } | ||
else { | ||
// super(null, null as any, false, [], null); | ||
// Intact component in React | ||
var normalizedProps = normalizeProps(props); | ||
// @ts-ignore | ||
var normalizedProps = normalizeProps(props, _this.constructor.events); | ||
var parent_1 = $vNodeOrContext; | ||
@@ -743,3 +751,3 @@ var mountedQueue = getMountedQueue(parent_1); | ||
Component.prototype.componentDidUpdate = function () { | ||
var normalizedProps = normalizeProps(this.props); | ||
var normalizedProps = normalizeProps(this.props, this.constructor.events); | ||
var vNode = createComponentVNode(4, this.constructor, normalizedProps); | ||
@@ -746,0 +754,0 @@ if (process.env.NODE_ENV !== 'production') { |
@@ -6,3 +6,3 @@ import { VNode } from 'intact'; | ||
export declare function normalizeChildren(vNodes: ReactNode): VNodeAtom | VNodeAtom[]; | ||
export declare function normalizeProps<P>(props: P): P; | ||
export declare function normalizeProps<P>(props: P, events: Record<string, boolean> | undefined): P; | ||
export declare function normalizeRef(ref: ReactRef<any>): ((i: any) => void) | null; |
@@ -5,2 +5,3 @@ import { ComponentFunction, VNodeComponentClass, Props } from 'intact'; | ||
(props: Props<P, any>, isReact?: boolean): VNodeComponentClass | VNodeComponentClass[]; | ||
events?: Record<string, boolean>; | ||
}; | ||
@@ -7,0 +8,0 @@ export declare const cid = "IntactReactFunctional"; |
@@ -6,3 +6,3 @@ import { VNode } from 'intact'; | ||
export declare function normalizeChildren(vNodes: ReactNode): VNodeAtom | VNodeAtom[]; | ||
export declare function normalizeProps<P>(props: P): P; | ||
export declare function normalizeProps<P>(props: P, events: Record<string, boolean> | undefined): P; | ||
export declare function normalizeRef(ref: ReactRef<any>): ((i: any) => void) | null; |
{ | ||
"name": "intact-react", | ||
"version": "3.0.10", | ||
"version": "3.0.11", | ||
"description": "A compatibility layer for running intact component in React@17", | ||
@@ -32,5 +32,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"intact": "^3.0.10", | ||
"intact": "^3.0.11", | ||
"tslib": "^2.3.1" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1002841
23823
Updatedintact@^3.0.11