@sitecore-jss/sitecore-jss-react 22.2.0-canary.3 → 22.2.0-canary.5
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/dist/cjs/components/PlaceholderCommon.js +6 -22
- package/dist/cjs/components/PlaceholderMetadata.js +3 -3
- package/dist/esm/components/PlaceholderCommon.js +4 -18
- package/dist/esm/components/PlaceholderMetadata.js +1 -1
- package/package.json +3 -3
- package/types/components/PlaceholderCommon.d.ts +0 -12
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PlaceholderCommon =
|
|
17
|
+
exports.PlaceholderCommon = void 0;
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
20
20
|
const MissingComponent_1 = require("./MissingComponent");
|
|
@@ -28,22 +28,6 @@ const BYOCComponent_1 = require("./BYOCComponent");
|
|
|
28
28
|
const BYOCWrapper_1 = require("./BYOCWrapper");
|
|
29
29
|
const PlaceholderMetadata_1 = require("./PlaceholderMetadata");
|
|
30
30
|
const ErrorBoundary_1 = __importDefault(require("./ErrorBoundary"));
|
|
31
|
-
/**
|
|
32
|
-
* Returns a regular expression pattern for a dynamic placeholder name.
|
|
33
|
-
* @param {string} placeholder Placeholder name with a dynamic segment (e.g. 'main-{*}')
|
|
34
|
-
* @returns Regular expression pattern for the dynamic segment
|
|
35
|
-
*/
|
|
36
|
-
const getDynamicPlaceholderPattern = (placeholder) => {
|
|
37
|
-
return new RegExp(`^${placeholder.replace(/\{\*\}+/i, '\\d+')}$`);
|
|
38
|
-
};
|
|
39
|
-
exports.getDynamicPlaceholderPattern = getDynamicPlaceholderPattern;
|
|
40
|
-
/**
|
|
41
|
-
* Checks if the placeholder name is dynamic.
|
|
42
|
-
* @param {string} placeholder Placeholder name
|
|
43
|
-
* @returns True if the placeholder name is dynamic
|
|
44
|
-
*/
|
|
45
|
-
const isDynamicPlaceholder = (placeholder) => placeholder.indexOf('{*}') !== -1;
|
|
46
|
-
exports.isDynamicPlaceholder = isDynamicPlaceholder;
|
|
47
31
|
class PlaceholderCommon extends react_1.default.Component {
|
|
48
32
|
constructor(props) {
|
|
49
33
|
super(props);
|
|
@@ -57,14 +41,14 @@ class PlaceholderCommon extends react_1.default.Component {
|
|
|
57
41
|
let result;
|
|
58
42
|
let phName = name.slice();
|
|
59
43
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
44
|
+
* Process (SXA) dynamic placeholders
|
|
45
|
+
* Find and replace the matching dynamic placeholder e.g 'nameOfContainer-{*}' with the requested e.g. 'nameOfContainer-1'.
|
|
46
|
+
* For Metadata EditMode, we need to keep the raw placeholder name in place.
|
|
63
47
|
*/
|
|
64
48
|
if (rendering === null || rendering === void 0 ? void 0 : rendering.placeholders) {
|
|
65
49
|
Object.keys(rendering.placeholders).forEach((placeholder) => {
|
|
66
|
-
const patternPlaceholder = (0,
|
|
67
|
-
? (0,
|
|
50
|
+
const patternPlaceholder = (0, layout_1.isDynamicPlaceholder)(placeholder)
|
|
51
|
+
? (0, layout_1.getDynamicPlaceholderPattern)(placeholder)
|
|
68
52
|
: null;
|
|
69
53
|
if (patternPlaceholder && patternPlaceholder.test(phName)) {
|
|
70
54
|
if (editMode === layout_1.EditMode.Metadata) {
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PlaceholderMetadata = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
8
|
+
const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
|
|
9
9
|
/**
|
|
10
10
|
* default value of uid for root placeholder when uid is not present.
|
|
11
11
|
*/
|
|
@@ -41,8 +41,8 @@ const PlaceholderMetadata = ({ rendering, placeholderName, children, }) => {
|
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
// Check if the placeholder is a dynamic placeholder
|
|
44
|
-
if ((0,
|
|
45
|
-
const pattern = (0,
|
|
44
|
+
if ((0, layout_1.isDynamicPlaceholder)(placeholder)) {
|
|
45
|
+
const pattern = (0, layout_1.getDynamicPlaceholderPattern)(placeholder);
|
|
46
46
|
// Check if the placeholder matches the dynamic placeholder pattern
|
|
47
47
|
if (pattern.test(placeholderName)) {
|
|
48
48
|
phId = id ? `${placeholder}_${id}` : `${placeholder}_${DEFAULT_PLACEHOLDER_UID}`;
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import { MissingComponent } from './MissingComponent';
|
|
15
|
-
import { EditMode, } from '@sitecore-jss/sitecore-jss/layout';
|
|
15
|
+
import { EditMode, isDynamicPlaceholder, getDynamicPlaceholderPattern, } from '@sitecore-jss/sitecore-jss/layout';
|
|
16
16
|
import { constants } from '@sitecore-jss/sitecore-jss';
|
|
17
17
|
import { convertAttributesToReactProps } from '../utils';
|
|
18
18
|
import { HiddenRendering } from './HiddenRendering';
|
|
@@ -22,20 +22,6 @@ import { BYOCComponent, BYOC_COMPONENT_RENDERING_NAME } from './BYOCComponent';
|
|
|
22
22
|
import { BYOCWrapper, BYOC_WRAPPER_RENDERING_NAME } from './BYOCWrapper';
|
|
23
23
|
import { PlaceholderMetadata } from './PlaceholderMetadata';
|
|
24
24
|
import ErrorBoundary from './ErrorBoundary';
|
|
25
|
-
/**
|
|
26
|
-
* Returns a regular expression pattern for a dynamic placeholder name.
|
|
27
|
-
* @param {string} placeholder Placeholder name with a dynamic segment (e.g. 'main-{*}')
|
|
28
|
-
* @returns Regular expression pattern for the dynamic segment
|
|
29
|
-
*/
|
|
30
|
-
export const getDynamicPlaceholderPattern = (placeholder) => {
|
|
31
|
-
return new RegExp(`^${placeholder.replace(/\{\*\}+/i, '\\d+')}$`);
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Checks if the placeholder name is dynamic.
|
|
35
|
-
* @param {string} placeholder Placeholder name
|
|
36
|
-
* @returns True if the placeholder name is dynamic
|
|
37
|
-
*/
|
|
38
|
-
export const isDynamicPlaceholder = (placeholder) => placeholder.indexOf('{*}') !== -1;
|
|
39
25
|
export class PlaceholderCommon extends React.Component {
|
|
40
26
|
constructor(props) {
|
|
41
27
|
super(props);
|
|
@@ -49,9 +35,9 @@ export class PlaceholderCommon extends React.Component {
|
|
|
49
35
|
let result;
|
|
50
36
|
let phName = name.slice();
|
|
51
37
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
38
|
+
* Process (SXA) dynamic placeholders
|
|
39
|
+
* Find and replace the matching dynamic placeholder e.g 'nameOfContainer-{*}' with the requested e.g. 'nameOfContainer-1'.
|
|
40
|
+
* For Metadata EditMode, we need to keep the raw placeholder name in place.
|
|
55
41
|
*/
|
|
56
42
|
if (rendering === null || rendering === void 0 ? void 0 : rendering.placeholders) {
|
|
57
43
|
Object.keys(rendering.placeholders).forEach((placeholder) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { getDynamicPlaceholderPattern, isDynamicPlaceholder } from '
|
|
2
|
+
import { getDynamicPlaceholderPattern, isDynamicPlaceholder, } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
3
|
/**
|
|
4
4
|
* default value of uid for root placeholder when uid is not present.
|
|
5
5
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "22.2.0-canary.
|
|
3
|
+
"version": "22.2.0-canary.5",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"react-dom": "^18.2.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sitecore-jss/sitecore-jss": "^22.2.0-canary.
|
|
64
|
+
"@sitecore-jss/sitecore-jss": "^22.2.0-canary.5",
|
|
65
65
|
"fast-deep-equal": "^3.1.3",
|
|
66
66
|
"prop-types": "^15.8.1",
|
|
67
67
|
"style-attr": "^1.3.0"
|
|
68
68
|
},
|
|
69
69
|
"description": "",
|
|
70
70
|
"types": "types/index.d.ts",
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "a37f9a68fe0447aed16ae317d1881ac9209c3c22",
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|
|
74
74
|
"types"
|
|
@@ -12,18 +12,6 @@ export type ComponentProps = {
|
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
rendering: ComponentRendering;
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
16
|
-
* Returns a regular expression pattern for a dynamic placeholder name.
|
|
17
|
-
* @param {string} placeholder Placeholder name with a dynamic segment (e.g. 'main-{*}')
|
|
18
|
-
* @returns Regular expression pattern for the dynamic segment
|
|
19
|
-
*/
|
|
20
|
-
export declare const getDynamicPlaceholderPattern: (placeholder: string) => RegExp;
|
|
21
|
-
/**
|
|
22
|
-
* Checks if the placeholder name is dynamic.
|
|
23
|
-
* @param {string} placeholder Placeholder name
|
|
24
|
-
* @returns True if the placeholder name is dynamic
|
|
25
|
-
*/
|
|
26
|
-
export declare const isDynamicPlaceholder: (placeholder: string) => boolean;
|
|
27
15
|
export interface PlaceholderProps {
|
|
28
16
|
[key: string]: unknown;
|
|
29
17
|
/** Name of the placeholder to render. */
|