@fluentui/react-jsx-runtime 9.0.0-alpha.1 → 9.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +11 -2
- package/lib/createElement.js +9 -19
- package/lib/createElement.js.map +1 -1
- package/lib-commonjs/createElement.js +9 -18
- package/lib-commonjs/createElement.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui/react-jsx-runtime",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Mon,
|
|
5
|
+
"date": "Mon, 24 Apr 2023 08:09:12 GMT",
|
|
6
|
+
"tag": "@fluentui/react-jsx-runtime_v9.0.0-alpha.2",
|
|
7
|
+
"version": "9.0.0-alpha.2",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
12
|
+
"package": "@fluentui/react-jsx-runtime",
|
|
13
|
+
"commit": "391878bf4d8a8210a8279a6ced8bf9a64daf4c64",
|
|
14
|
+
"comment": "chore: simplify createElement method"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 17 Apr 2023 17:53:51 GMT",
|
|
6
21
|
"tag": "@fluentui/react-jsx-runtime_v9.0.0-alpha.1",
|
|
7
22
|
"version": "9.0.0-alpha.1",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-jsx-runtime
|
|
2
2
|
|
|
3
|
-
This log was last generated on Mon,
|
|
3
|
+
This log was last generated on Mon, 24 Apr 2023 08:09:12 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-alpha.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-jsx-runtime_v9.0.0-alpha.2)
|
|
8
|
+
|
|
9
|
+
Mon, 24 Apr 2023 08:09:12 GMT
|
|
10
|
+
[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)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- chore: simplify createElement method ([PR #27573](https://github.com/microsoft/fluentui/pull/27573) by bernardo.sunderhus@gmail.com)
|
|
15
|
+
|
|
7
16
|
## [9.0.0-alpha.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-jsx-runtime_v9.0.0-alpha.1)
|
|
8
17
|
|
|
9
|
-
Mon, 17 Apr 2023 17:
|
|
18
|
+
Mon, 17 Apr 2023 17:53:51 GMT
|
|
10
19
|
|
|
11
20
|
### Changes
|
|
12
21
|
|
package/lib/createElement.js
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SLOT_RENDER_FUNCTION_SYMBOL } from '@fluentui/react-utilities';
|
|
3
3
|
export function createElement(type, props, ...children) {
|
|
4
|
-
|
|
5
|
-
return /*#__PURE__*/React.createElement(type, props, ...children);
|
|
6
|
-
}
|
|
7
|
-
const result = normalizeRenderFunction(props, children);
|
|
8
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {}, result.renderFunction(type, {
|
|
9
|
-
...result.props,
|
|
10
|
-
children: result.children
|
|
11
|
-
}));
|
|
4
|
+
return hasRenderFunction(props) ? createElementFromRenderFunction(type, props, children) : /*#__PURE__*/React.createElement(type, props, ...children);
|
|
12
5
|
}
|
|
13
|
-
function
|
|
6
|
+
function createElementFromRenderFunction(type, props, overrideChildren) {
|
|
14
7
|
const {
|
|
15
8
|
[SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
renderFunction,
|
|
23
|
-
props: props
|
|
24
|
-
};
|
|
9
|
+
...renderProps
|
|
10
|
+
} = props;
|
|
11
|
+
if (overrideChildren.length > 0) {
|
|
12
|
+
renderProps.children = /*#__PURE__*/React.createElement(React.Fragment, {}, ...overrideChildren);
|
|
13
|
+
}
|
|
14
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {}, renderFunction(type, renderProps));
|
|
25
15
|
}
|
|
26
|
-
export function
|
|
16
|
+
export function hasRenderFunction(props) {
|
|
27
17
|
return Boolean(props === null || props === void 0 ? void 0 : props.hasOwnProperty(SLOT_RENDER_FUNCTION_SYMBOL));
|
|
28
18
|
}
|
|
29
19
|
//# sourceMappingURL=createElement.js.map
|
package/lib/createElement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SLOT_RENDER_FUNCTION_SYMBOL","createElement","type","props","children","
|
|
1
|
+
{"version":3,"names":["React","SLOT_RENDER_FUNCTION_SYMBOL","createElement","type","props","children","hasRenderFunction","createElementFromRenderFunction","overrideChildren","renderFunction","renderProps","length","Fragment","Boolean","hasOwnProperty"],"sources":["../src/createElement.ts"],"sourcesContent":["import * as React from 'react';\nimport { SlotRenderFunction, UnknownSlotProps, SLOT_RENDER_FUNCTION_SYMBOL } from '@fluentui/react-utilities';\n\ntype WithMetadata<Props extends {}> = Props & {\n [SLOT_RENDER_FUNCTION_SYMBOL]: SlotRenderFunction<Props>;\n};\n\nexport function createElement<P extends {}>(\n type: React.ElementType<P>,\n props?: P | null,\n ...children: React.ReactNode[]\n): React.ReactElement<P> | null {\n return hasRenderFunction(props)\n ? createElementFromRenderFunction(type, props, children)\n : React.createElement(type, props, ...children);\n}\n\nfunction createElementFromRenderFunction<P extends UnknownSlotProps>(\n type: React.ElementType<P>,\n props: WithMetadata<P>,\n overrideChildren: React.ReactNode[],\n): React.ReactElement<P> | null {\n const { [SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction, ...renderProps } = props;\n\n if (overrideChildren.length > 0) {\n renderProps.children = React.createElement(React.Fragment, {}, ...overrideChildren);\n }\n\n return React.createElement(\n React.Fragment,\n {},\n renderFunction(type, renderProps as UnknownSlotProps as P),\n ) as React.ReactElement<P>;\n}\n\nexport function hasRenderFunction<Props extends {}>(props?: Props | null): props is WithMetadata<Props> {\n return Boolean(props?.hasOwnProperty(SLOT_RENDER_FUNCTION_SYMBOL));\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAA+CC,2BAA2B,QAAQ;AAMlF,OAAO,SAASC,cACdC,IAA0B,EAC1BC,KAAgB,EAChB,GAAGC,QAA2B,EACA;EAC9B,OAAOC,iBAAA,CAAkBF,KAAA,IACrBG,+BAAA,CAAgCJ,IAAA,EAAMC,KAAA,EAAOC,QAAA,iBAC7CL,KAAA,CAAME,aAAa,CAACC,IAAA,EAAMC,KAAA,KAAUC,QAAA,CAAS;AACnD;AAEA,SAASE,gCACPJ,IAA0B,EAC1BC,KAAsB,EACtBI,gBAAmC,EACL;EAC9B,MAAM;IAAE,CAACP,2BAAA,GAA8BQ,cAAA;IAAgB,GAAGC;EAAA,CAAa,GAAGN,KAAA;EAE1E,IAAII,gBAAA,CAAiBG,MAAM,GAAG,GAAG;IAC/BD,WAAA,CAAYL,QAAQ,gBAAGL,KAAA,CAAME,aAAa,CAACF,KAAA,CAAMY,QAAQ,EAAE,CAAC,MAAMJ,gBAAA;EACpE;EAEA,oBAAOR,KAAA,CAAME,aAAa,CACxBF,KAAA,CAAMY,QAAQ,EACd,CAAC,GACDH,cAAA,CAAeN,IAAA,EAAMO,WAAA;AAEzB;AAEA,OAAO,SAASJ,kBAAoCF,KAAoB,EAAgC;EACtG,OAAOS,OAAA,CAAQT,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAOU,cAAc,CAACb,2BAAA;AACvC"}
|
|
@@ -10,31 +10,22 @@ function _export(target, all) {
|
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
12
|
createElement: ()=>createElement,
|
|
13
|
-
|
|
13
|
+
hasRenderFunction: ()=>hasRenderFunction
|
|
14
14
|
});
|
|
15
15
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
16
16
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
17
17
|
const _reactUtilities = require("@fluentui/react-utilities");
|
|
18
18
|
function createElement(type, props, ...children) {
|
|
19
|
-
|
|
20
|
-
return /*#__PURE__*/ _react.createElement(type, props, ...children);
|
|
21
|
-
}
|
|
22
|
-
const result = normalizeRenderFunction(props, children);
|
|
23
|
-
return /*#__PURE__*/ _react.createElement(_react.Fragment, {}, result.renderFunction(type, {
|
|
24
|
-
...result.props,
|
|
25
|
-
children: result.children
|
|
26
|
-
}));
|
|
19
|
+
return hasRenderFunction(props) ? createElementFromRenderFunction(type, props, children) : /*#__PURE__*/ _react.createElement(type, props, ...children);
|
|
27
20
|
}
|
|
28
|
-
function
|
|
29
|
-
const { [_reactUtilities.SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction ,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
props: props
|
|
35
|
-
};
|
|
21
|
+
function createElementFromRenderFunction(type, props, overrideChildren) {
|
|
22
|
+
const { [_reactUtilities.SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction , ...renderProps } = props;
|
|
23
|
+
if (overrideChildren.length > 0) {
|
|
24
|
+
renderProps.children = /*#__PURE__*/ _react.createElement(_react.Fragment, {}, ...overrideChildren);
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/ _react.createElement(_react.Fragment, {}, renderFunction(type, renderProps));
|
|
36
27
|
}
|
|
37
|
-
function
|
|
28
|
+
function hasRenderFunction(props) {
|
|
38
29
|
return Boolean(props === null || props === void 0 ? void 0 : props.hasOwnProperty(_reactUtilities.SLOT_RENDER_FUNCTION_SYMBOL));
|
|
39
30
|
} //# sourceMappingURL=createElement.js.map
|
|
40
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/createElement.js"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '@fluentui/react-utilities';\nexport function createElement(type, props, ...children) {\n
|
|
1
|
+
{"version":3,"sources":["../lib/createElement.js"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '@fluentui/react-utilities';\nexport function createElement(type, props, ...children) {\n return hasRenderFunction(props) ? createElementFromRenderFunction(type, props, children) : /*#__PURE__*/React.createElement(type, props, ...children);\n}\nfunction createElementFromRenderFunction(type, props, overrideChildren) {\n const {\n [SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction,\n ...renderProps\n } = props;\n if (overrideChildren.length > 0) {\n renderProps.children = /*#__PURE__*/React.createElement(React.Fragment, {}, ...overrideChildren);\n }\n return /*#__PURE__*/React.createElement(React.Fragment, {}, renderFunction(type, renderProps));\n}\nexport function hasRenderFunction(props) {\n return Boolean(props === null || props === void 0 ? void 0 : props.hasOwnProperty(SLOT_RENDER_FUNCTION_SYMBOL));\n}\n//# sourceMappingURL=createElement.js.map"],"names":["createElement","hasRenderFunction","type","props","children","createElementFromRenderFunction","React","overrideChildren","SLOT_RENDER_FUNCTION_SYMBOL","renderFunction","renderProps","length","Fragment","Boolean","hasOwnProperty"],"mappings":";;;;;;;;;;;IAEgBA,aAAa,MAAbA;IAaAC,iBAAiB,MAAjBA;;;6DAfO;gCACqB;AACrC,SAASD,cAAcE,IAAI,EAAEC,KAAK,EAAE,GAAGC,QAAQ,EAAE;IACtD,OAAOH,kBAAkBE,SAASE,gCAAgCH,MAAMC,OAAOC,YAAY,WAAW,GAAEE,OAAMN,aAAa,CAACE,MAAMC,UAAUC,SAAS;AACvJ;AACA,SAASC,gCAAgCH,IAAI,EAAEC,KAAK,EAAEI,gBAAgB,EAAE;IACtE,MAAM,EACJ,CAACC,2CAA2B,CAAC,EAAEC,eAAc,EAC7C,GAAGC,aACJ,GAAGP;IACJ,IAAII,iBAAiBI,MAAM,GAAG,GAAG;QAC/BD,YAAYN,QAAQ,GAAG,WAAW,GAAEE,OAAMN,aAAa,CAACM,OAAMM,QAAQ,EAAE,CAAC,MAAML;IACjF,CAAC;IACD,OAAO,WAAW,GAAED,OAAMN,aAAa,CAACM,OAAMM,QAAQ,EAAE,CAAC,GAAGH,eAAeP,MAAMQ;AACnF;AACO,SAAST,kBAAkBE,KAAK,EAAE;IACvC,OAAOU,QAAQV,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMW,cAAc,CAACN,2CAA2B,CAAC;AAChH,EACA,yCAAyC"}
|