@bulmil/react
Advanced tools
Comparing version
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -13,11 +32,10 @@ var t = {}; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createReactComponent = void 0; | ||
const react_1 = __importDefault(require("react")); | ||
const react_1 = __importStar(require("react")); | ||
const utils_1 = require("./utils"); | ||
const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, customElement) => { | ||
(0, utils_1.defineCustomElement)(tagName, customElement); | ||
const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => { | ||
if (defineCustomElement !== undefined) { | ||
defineCustomElement(); | ||
} | ||
const displayName = (0, utils_1.dashToPascalCase)(tagName); | ||
@@ -55,3 +73,10 @@ const ReactComponent = class extends react_1.default.Component { | ||
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: (0, utils_1.mergeRefs)(forwardedRef, this.setComponentElRef), style }); | ||
return react_1.default.createElement(tagName, newProps, children); | ||
/** | ||
* We use createElement here instead of | ||
* React.createElement to work around a | ||
* bug in Vite (https://github.com/vitejs/vite/issues/6104). | ||
* React.createElement causes all elements to be rendered | ||
* as <tagname> instead of the actual Web Component. | ||
*/ | ||
return (0, react_1.createElement)(tagName, newProps, children); | ||
} | ||
@@ -58,0 +83,0 @@ static get displayName() { |
@@ -12,6 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
}; | ||
import React from 'react'; | ||
import { attachProps, createForwardRef, dashToPascalCase, defineCustomElement, isCoveredByReact, mergeRefs, } from './utils'; | ||
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, customElement) => { | ||
defineCustomElement(tagName, customElement); | ||
import React, { createElement } from 'react'; | ||
import { attachProps, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs, } from './utils'; | ||
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => { | ||
if (defineCustomElement !== undefined) { | ||
defineCustomElement(); | ||
} | ||
const displayName = dashToPascalCase(tagName); | ||
@@ -49,3 +51,10 @@ const ReactComponent = class extends React.Component { | ||
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style }); | ||
return React.createElement(tagName, newProps, children); | ||
/** | ||
* We use createElement here instead of | ||
* React.createElement to work around a | ||
* bug in Vite (https://github.com/vitejs/vite/issues/6104). | ||
* React.createElement causes all elements to be rendered | ||
* as <tagname> instead of the actual Web Component. | ||
*/ | ||
return createElement(tagName, newProps, children); | ||
} | ||
@@ -52,0 +61,0 @@ static get displayName() { |
@@ -9,3 +9,3 @@ import React from 'react'; | ||
} | ||
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, customElement?: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & import("./interfaces").StyleReactProps> & React.RefAttributes<ElementType>>; | ||
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & import("./interfaces").StyleReactProps> & React.RefAttributes<ElementType>>; | ||
export {}; |
{ | ||
"name": "@bulmil/react", | ||
"sideEffects": false, | ||
"version": "0.24.1", | ||
"version": "0.25.0", | ||
"author": "Gomah", | ||
@@ -44,3 +44,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@bulmil/core": "0.24.1" | ||
"@bulmil/core": "0.25.0" | ||
}, | ||
@@ -51,3 +51,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "8d02e9e894e587bab36b2aad5f91b1c1be2cb409" | ||
"gitHead": "f96a60c226e8ce629e3f7726c536100da9872914" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
114027
1.37%1349
2.59%+ Added
- Removed
Updated