@fluentui/react-jsx-runtime
Advanced tools
Comparing version 9.0.0-alpha.1 to 9.0.0-alpha.2
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Mon, 17 Apr 2023 17:50:02 GMT", | ||
"date": "Mon, 24 Apr 2023 08:09:12 GMT", | ||
"tag": "@fluentui/react-jsx-runtime_v9.0.0-alpha.2", | ||
"version": "9.0.0-alpha.2", | ||
"comments": { | ||
"prerelease": [ | ||
{ | ||
"author": "bernardo.sunderhus@gmail.com", | ||
"package": "@fluentui/react-jsx-runtime", | ||
"commit": "391878bf4d8a8210a8279a6ced8bf9a64daf4c64", | ||
"comment": "chore: simplify createElement method" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Mon, 17 Apr 2023 17:53:51 GMT", | ||
"tag": "@fluentui/react-jsx-runtime_v9.0.0-alpha.1", | ||
@@ -8,0 +23,0 @@ "version": "9.0.0-alpha.1", |
# Change Log - @fluentui/react-jsx-runtime | ||
This log was last generated on Mon, 17 Apr 2023 17:50:02 GMT and should not be manually modified. | ||
This log was last generated on Mon, 24 Apr 2023 08:09:12 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## [9.0.0-alpha.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-jsx-runtime_v9.0.0-alpha.2) | ||
Mon, 24 Apr 2023 08:09:12 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-jsx-runtime_v9.0.0-alpha.1..@fluentui/react-jsx-runtime_v9.0.0-alpha.2) | ||
### Changes | ||
- chore: simplify createElement method ([PR #27573](https://github.com/microsoft/fluentui/pull/27573) by bernardo.sunderhus@gmail.com) | ||
## [9.0.0-alpha.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-jsx-runtime_v9.0.0-alpha.1) | ||
Mon, 17 Apr 2023 17:50:02 GMT | ||
Mon, 17 Apr 2023 17:53:51 GMT | ||
@@ -11,0 +20,0 @@ ### Changes |
@@ -13,3 +13,3 @@ "use strict"; | ||
createElement: ()=>createElement, | ||
isSlotComponent: ()=>isSlotComponent | ||
hasRenderFunction: ()=>hasRenderFunction | ||
}); | ||
@@ -20,21 +20,12 @@ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default; | ||
function createElement(type, props, ...children) { | ||
if (!isSlotComponent(props)) { | ||
return /*#__PURE__*/ _react.createElement(type, props, ...children); | ||
return hasRenderFunction(props) ? createElementFromRenderFunction(type, props, children) : /*#__PURE__*/ _react.createElement(type, props, ...children); | ||
} | ||
function createElementFromRenderFunction(type, props, overrideChildren) { | ||
const { [_reactUtilities.SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction , ...renderProps } = props; | ||
if (overrideChildren.length > 0) { | ||
renderProps.children = /*#__PURE__*/ _react.createElement(_react.Fragment, {}, ...overrideChildren); | ||
} | ||
const result = normalizeRenderFunction(props, children); | ||
return /*#__PURE__*/ _react.createElement(_react.Fragment, {}, result.renderFunction(type, { | ||
...result.props, | ||
children: result.children | ||
})); | ||
return /*#__PURE__*/ _react.createElement(_react.Fragment, {}, renderFunction(type, renderProps)); | ||
} | ||
function normalizeRenderFunction(propsWithMetadata, overrideChildren) { | ||
const { [_reactUtilities.SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction , children: externalChildren , ...props } = propsWithMetadata; | ||
const children = Array.isArray(overrideChildren) && overrideChildren.length > 0 ? /*#__PURE__*/ _react.createElement(_react.Fragment, {}, ...overrideChildren) : externalChildren; | ||
return { | ||
children, | ||
renderFunction, | ||
props: props | ||
}; | ||
} | ||
function isSlotComponent(props) { | ||
function hasRenderFunction(props) { | ||
return Boolean(props === null || props === void 0 ? void 0 : props.hasOwnProperty(_reactUtilities.SLOT_RENDER_FUNCTION_SYMBOL)); | ||
@@ -41,0 +32,0 @@ } //# sourceMappingURL=createElement.js.map |
import * as React from 'react'; | ||
import { SLOT_RENDER_FUNCTION_SYMBOL } from '@fluentui/react-utilities'; | ||
export function createElement(type, props, ...children) { | ||
if (!isSlotComponent(props)) { | ||
return /*#__PURE__*/React.createElement(type, props, ...children); | ||
} | ||
const result = normalizeRenderFunction(props, children); | ||
return /*#__PURE__*/React.createElement(React.Fragment, {}, result.renderFunction(type, { | ||
...result.props, | ||
children: result.children | ||
})); | ||
return hasRenderFunction(props) ? createElementFromRenderFunction(type, props, children) : /*#__PURE__*/React.createElement(type, props, ...children); | ||
} | ||
function normalizeRenderFunction(propsWithMetadata, overrideChildren) { | ||
function createElementFromRenderFunction(type, props, overrideChildren) { | ||
const { | ||
[SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction, | ||
children: externalChildren, | ||
...props | ||
} = propsWithMetadata; | ||
const children = Array.isArray(overrideChildren) && overrideChildren.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, {}, ...overrideChildren) : externalChildren; | ||
return { | ||
children, | ||
renderFunction, | ||
props: props | ||
}; | ||
...renderProps | ||
} = props; | ||
if (overrideChildren.length > 0) { | ||
renderProps.children = /*#__PURE__*/React.createElement(React.Fragment, {}, ...overrideChildren); | ||
} | ||
return /*#__PURE__*/React.createElement(React.Fragment, {}, renderFunction(type, renderProps)); | ||
} | ||
export function isSlotComponent(props) { | ||
export function hasRenderFunction(props) { | ||
return Boolean(props === null || props === void 0 ? void 0 : props.hasOwnProperty(SLOT_RENDER_FUNCTION_SYMBOL)); | ||
} | ||
//# sourceMappingURL=createElement.js.map |
{ | ||
"name": "@fluentui/react-jsx-runtime", | ||
"version": "9.0.0-alpha.1", | ||
"version": "9.0.0-alpha.2", | ||
"description": "React components for building web experiences", | ||
@@ -5,0 +5,0 @@ "main": "lib-commonjs/index.js", |
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
14075
113