@sitecore-jss/sitecore-jss-react 23.0.0-canary.7 → 23.0.0-canary.8
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.
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -90,7 +79,7 @@ class PlaceholderCommon extends react_1.default.Component {
|
|
|
90
79
|
}
|
|
91
80
|
getComponentsForRenderingData(placeholderData) {
|
|
92
81
|
var _a;
|
|
93
|
-
const
|
|
82
|
+
const { name, fields: placeholderFields, params: placeholderParams, missingComponentComponent, hiddenRenderingComponent, passThroughComponentProps, modifyComponentProps, } = this.props;
|
|
94
83
|
const transformedComponents = placeholderData
|
|
95
84
|
.map((rendering, index) => {
|
|
96
85
|
var _a, _b;
|
|
@@ -137,12 +126,16 @@ class PlaceholderCommon extends react_1.default.Component {
|
|
|
137
126
|
component = missingComponentComponent !== null && missingComponentComponent !== void 0 ? missingComponentComponent : MissingComponent_1.MissingComponent;
|
|
138
127
|
isEmpty = true;
|
|
139
128
|
}
|
|
140
|
-
|
|
129
|
+
// Only pass rendering data props to child components.
|
|
130
|
+
// Internal Placeholder/SitecoreContext props are excluded.
|
|
131
|
+
const childProps = Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), ((placeholderFields || componentRendering.fields) && {
|
|
141
132
|
fields: Object.assign(Object.assign({}, placeholderFields), componentRendering.fields),
|
|
142
133
|
})), ((placeholderParams || componentRendering.params) && {
|
|
143
134
|
params: Object.assign(Object.assign(Object.assign({}, placeholderParams), componentRendering.params), this.getSXAParams(componentRendering)),
|
|
144
135
|
})), { rendering: componentRendering });
|
|
145
|
-
|
|
136
|
+
const modifiedProps = modifyComponentProps ? modifyComponentProps(childProps) : childProps;
|
|
137
|
+
const finalProps = Object.assign(Object.assign({}, modifiedProps), passThroughComponentProps);
|
|
138
|
+
let rendered = react_1.default.createElement(component, finalProps);
|
|
146
139
|
if (!isEmpty) {
|
|
147
140
|
// assign type based on passed element - type='text/sitecore' should be ignored when renderEach Placeholder prop function is being used
|
|
148
141
|
const type = rendered.props.type === 'text/sitecore' ? rendered.props.type : '';
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import React from 'react';
|
|
13
2
|
import { MissingComponent } from './MissingComponent';
|
|
14
3
|
import { EditMode, isDynamicPlaceholder, getDynamicPlaceholderPattern, } from '@sitecore-jss/sitecore-jss/layout';
|
|
@@ -84,7 +73,7 @@ export class PlaceholderCommon extends React.Component {
|
|
|
84
73
|
}
|
|
85
74
|
getComponentsForRenderingData(placeholderData) {
|
|
86
75
|
var _a;
|
|
87
|
-
const
|
|
76
|
+
const { name, fields: placeholderFields, params: placeholderParams, missingComponentComponent, hiddenRenderingComponent, passThroughComponentProps, modifyComponentProps, } = this.props;
|
|
88
77
|
const transformedComponents = placeholderData
|
|
89
78
|
.map((rendering, index) => {
|
|
90
79
|
var _a, _b;
|
|
@@ -131,12 +120,16 @@ export class PlaceholderCommon extends React.Component {
|
|
|
131
120
|
component = missingComponentComponent !== null && missingComponentComponent !== void 0 ? missingComponentComponent : MissingComponent;
|
|
132
121
|
isEmpty = true;
|
|
133
122
|
}
|
|
134
|
-
|
|
123
|
+
// Only pass rendering data props to child components.
|
|
124
|
+
// Internal Placeholder/SitecoreContext props are excluded.
|
|
125
|
+
const childProps = Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), ((placeholderFields || componentRendering.fields) && {
|
|
135
126
|
fields: Object.assign(Object.assign({}, placeholderFields), componentRendering.fields),
|
|
136
127
|
})), ((placeholderParams || componentRendering.params) && {
|
|
137
128
|
params: Object.assign(Object.assign(Object.assign({}, placeholderParams), componentRendering.params), this.getSXAParams(componentRendering)),
|
|
138
129
|
})), { rendering: componentRendering });
|
|
139
|
-
|
|
130
|
+
const modifiedProps = modifyComponentProps ? modifyComponentProps(childProps) : childProps;
|
|
131
|
+
const finalProps = Object.assign(Object.assign({}, modifiedProps), passThroughComponentProps);
|
|
132
|
+
let rendered = React.createElement(component, finalProps);
|
|
140
133
|
if (!isEmpty) {
|
|
141
134
|
// assign type based on passed element - type='text/sitecore' should be ignored when renderEach Placeholder prop function is being used
|
|
142
135
|
const type = rendered.props.type === 'text/sitecore' ? rendered.props.type : '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "23.0.0-canary.
|
|
3
|
+
"version": "23.0.0-canary.8",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"react-dom": "^19.1.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sitecore-jss/sitecore-jss": "23.0.0-canary.
|
|
64
|
+
"@sitecore-jss/sitecore-jss": "23.0.0-canary.8",
|
|
65
65
|
"fast-deep-equal": "^3.1.3",
|
|
66
66
|
"style-attr": "^1.3.0"
|
|
67
67
|
},
|
|
68
68
|
"description": "",
|
|
69
69
|
"types": "types/index.d.ts",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "5290a2b2dcb1c0c0dc11f1b9cf97803dcd93441a",
|
|
71
71
|
"files": [
|
|
72
72
|
"dist",
|
|
73
73
|
"types"
|
|
@@ -43,6 +43,13 @@ export interface PlaceholderProps {
|
|
|
43
43
|
* @returns {ComponentProps} modified or initial props
|
|
44
44
|
*/
|
|
45
45
|
modifyComponentProps?: (componentProps: ComponentProps) => ComponentProps;
|
|
46
|
+
/**
|
|
47
|
+
* An alternative to `modifyComponentProps` that allows passing additional props to rendered
|
|
48
|
+
* components without forwarding Placeholder/SitecoreContext internal props.
|
|
49
|
+
*/
|
|
50
|
+
passThroughComponentProps?: {
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
};
|
|
46
53
|
/**
|
|
47
54
|
* A component that is rendered in place of any components that are in this placeholder,
|
|
48
55
|
* but do not have a definition in the componentFactory (i.e. don't have a React implementation)
|