@sitecore-content-sdk/react 1.1.0-canary.22 → 1.1.0-canary.24

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.
@@ -20,7 +20,9 @@ const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
20
20
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
21
21
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
22
22
  const layout_1 = require("@sitecore-content-sdk/core/layout");
23
- exports.DateField = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)((_a) => {
23
+ exports.DateField = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
24
+ // eslint-disable-next-line no-unused-vars
25
+ (_a) => {
24
26
  var { field, tag, editable = true, render } = _a, otherProps = __rest(_a, ["field", "tag", "editable", "render"]);
25
27
  if ((0, layout_1.isFieldValueEmpty)(field)) {
26
28
  return null;
@@ -70,10 +70,7 @@ const Preview = () => {
70
70
  // useEffect may execute multiple times on single render (i.e. in dev) - but we only want to fire ready event once
71
71
  let componentReady = false;
72
72
  // have an up-to-date layout state between re-renders (SSR re-render excluded)
73
- const persistedRoot = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [
74
- rootComponent,
75
- rootUpdate,
76
- ]);
73
+ const persistedRoot = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [rootComponent, rootUpdate]);
77
74
  route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER][0] = persistedRoot;
78
75
  (0, react_1.useEffect)(() => {
79
76
  // useEffect will fire when components are ready - and we inform the whole wide world of it too
@@ -141,6 +138,7 @@ const VariantGeneration = (props) => {
141
138
  if (!rendering) {
142
139
  return react_1.default.createElement("div", null, "No component found in layout data. Please check your layout data.");
143
140
  }
141
+ // eslint-disable-next-line react-hooks/rules-of-hooks
144
142
  (0, react_1.useEffect)(() => {
145
143
  let cancelled = false;
146
144
  // since import map is loaded lazily, we only need to add preview event handler once the import map is loaded
@@ -119,8 +119,7 @@ function fetchComponentTemplate(src, params, revisionFallback) {
119
119
  return template;
120
120
  }
121
121
  catch (error) {
122
- console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision ||
123
- revisionFallback}" is present`);
122
+ console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision || revisionFallback}" is present`);
124
123
  throw error;
125
124
  }
126
125
  });
@@ -24,9 +24,7 @@ const File = (_a) => {
24
24
  return null;
25
25
  }
26
26
  // handle link directly on field for forgetful devs
27
- const file = (dynamicField.src
28
- ? field
29
- : dynamicField.value);
27
+ const file = (dynamicField.src ? field : dynamicField.value);
30
28
  if (!file) {
31
29
  return null;
32
30
  }
@@ -15,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Image = void 0;
18
+ /* eslint-disable no-unused-vars */
18
19
  const media_1 = require("@sitecore-content-sdk/core/media");
19
20
  const react_1 = __importDefault(require("react"));
20
21
  const utils_1 = require("../utils");
@@ -45,14 +45,15 @@ var __rest = (this && this.__rest) || function (s, e) {
45
45
  };
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
47
  exports.Link = void 0;
48
+ /* eslint-disable no-unused-expressions, @typescript-eslint/no-unused-expressions */
48
49
  const react_1 = __importStar(require("react"));
49
50
  const layout_1 = require("@sitecore-content-sdk/core/layout");
50
51
  const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
51
52
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
52
53
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
53
- exports.Link = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
54
- // eslint-disable-next-line react/display-name
55
- (0, react_1.forwardRef)((_a, ref) => {
54
+ exports.Link = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)((0, react_1.forwardRef)(
55
+ // eslint-disable-next-line no-unused-vars
56
+ (_a, ref) => {
56
57
  var { field, editable = true, showLinkTextWithChildrenPresent } = _a, otherProps = __rest(_a, ["field", "editable", "showLinkTextWithChildrenPresent"]);
57
58
  const children = otherProps.children;
58
59
  const dynamicField = field;
@@ -50,10 +50,14 @@ const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
50
50
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
51
51
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
52
52
  const layout_1 = require("@sitecore-content-sdk/core/layout");
53
- exports.RichText = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
54
- // eslint-disable-next-line react/display-name
55
- (0, react_1.forwardRef)((_a, ref) => {
56
- var { field, tag = 'div', editable = true } = _a, otherProps = __rest(_a, ["field", "tag", "editable"]);
53
+ exports.RichText = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)((0, react_1.forwardRef)((
54
+ // eslint-disable-next-line no-unused-vars
55
+ _a, ref) => {
56
+ var
57
+ // eslint-disable-next-line no-unused-vars
58
+ { field, tag = 'div', editable = true } = _a, otherProps = __rest(_a,
59
+ // eslint-disable-next-line no-unused-vars
60
+ ["field", "tag", "editable"]);
57
61
  if ((0, layout_1.isFieldValueEmpty)(field)) {
58
62
  return null;
59
63
  }
@@ -27,7 +27,7 @@ exports.Text = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEdit
27
27
  }
28
28
  // can't use editable value if we want to output unencoded
29
29
  if (!encode) {
30
- // eslint-disable-next-line no-param-reassign
30
+ // eslint-disable-next-line no-param-reassign, no-unused-vars
31
31
  editable = false;
32
32
  }
33
33
  let output = field.value === undefined ? '' : field.value;
@@ -19,8 +19,6 @@ function withComponentMap(Component) {
19
19
  const context = (0, react_2.useContext)(SitecoreProvider_1.ComponentMapReactContext);
20
20
  return react_1.default.createElement(Component, Object.assign({}, props, { componentMap: props.componentMap || context }));
21
21
  }
22
- WithComponentMap.displayName = `withComponentMap(${Component.displayName ||
23
- Component.name ||
24
- 'Anonymous'})`;
22
+ WithComponentMap.displayName = `withComponentMap(${Component.displayName || Component.name || 'Anonymous'})`;
25
23
  return WithComponentMap;
26
24
  }
@@ -51,13 +51,11 @@ function withEmptyFieldEditingComponent(FieldComponent, options) {
51
51
  return null;
52
52
  };
53
53
  if (options.isForwardRef) {
54
- // eslint-disable-next-line react/display-name
55
54
  return (0, react_1.forwardRef)((props, ref) => {
56
55
  const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
57
56
  return (react_1.default.createElement(react_1.default.Fragment, null, (EmptyFieldEditingComponent && react_1.default.createElement(EmptyFieldEditingComponent, null)) || (react_1.default.createElement(FieldComponent, Object.assign({}, props, { ref: ref })))));
58
57
  });
59
58
  }
60
- // eslint-disable-next-line react/display-name
61
59
  return (props) => {
62
60
  const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
63
61
  return (react_1.default.createElement(react_1.default.Fragment, null, (EmptyFieldEditingComponent && react_1.default.createElement(EmptyFieldEditingComponent, null)) || (react_1.default.createElement(FieldComponent, Object.assign({}, props)))));
@@ -43,7 +43,6 @@ const FieldMetadata_1 = require("../components/FieldMetadata");
43
43
  */
44
44
  function withFieldMetadata(FieldComponent, isForwardRef = false) {
45
45
  if (isForwardRef) {
46
- // eslint-disable-next-line react/display-name
47
46
  return (0, react_1.forwardRef)((props, ref) => {
48
47
  var _a;
49
48
  const { editable = true } = props;
@@ -55,7 +54,6 @@ function withFieldMetadata(FieldComponent, isForwardRef = false) {
55
54
  react_1.default.createElement(FieldComponent, Object.assign({}, props, { ref: ref }))));
56
55
  });
57
56
  }
58
- // eslint-disable-next-line react/display-name
59
57
  return (props) => {
60
58
  var _a;
61
59
  const { editable = true } = props;
@@ -50,7 +50,8 @@ function withPlaceholder(placeholders, options) {
50
50
  else {
51
51
  placeholderData = PlaceholderCommon_1.PlaceholderCommon.getPlaceholderDataFromRenderingData(renderingData, placeholder, childProps.page.mode.isEditing);
52
52
  if (placeholderData) {
53
- childProps[placeholder] = this.getComponentsForRenderingData(placeholderData);
53
+ childProps[placeholder] =
54
+ this.getComponentsForRenderingData(placeholderData);
54
55
  }
55
56
  }
56
57
  });
@@ -14,7 +14,9 @@ import { withFieldMetadata } from '../enhancers/withFieldMetadata';
14
14
  import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
15
15
  import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
16
16
  import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
17
- export const DateField = withFieldMetadata(withEmptyFieldEditingComponent((_a) => {
17
+ export const DateField = withFieldMetadata(withEmptyFieldEditingComponent(
18
+ // eslint-disable-next-line no-unused-vars
19
+ (_a) => {
18
20
  var { field, tag, editable = true, render } = _a, otherProps = __rest(_a, ["field", "tag", "editable", "render"]);
19
21
  if (isFieldValueEmpty(field)) {
20
22
  return null;
@@ -33,10 +33,7 @@ const Preview = () => {
33
33
  // useEffect may execute multiple times on single render (i.e. in dev) - but we only want to fire ready event once
34
34
  let componentReady = false;
35
35
  // have an up-to-date layout state between re-renders (SSR re-render excluded)
36
- const persistedRoot = useMemo(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [
37
- rootComponent,
38
- rootUpdate,
39
- ]);
36
+ const persistedRoot = useMemo(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [rootComponent, rootUpdate]);
40
37
  route.placeholders[EDITING_COMPONENT_PLACEHOLDER][0] = persistedRoot;
41
38
  useEffect(() => {
42
39
  // useEffect will fire when components are ready - and we inform the whole wide world of it too
@@ -104,6 +101,7 @@ export const VariantGeneration = (props) => {
104
101
  if (!rendering) {
105
102
  return React.createElement("div", null, "No component found in layout data. Please check your layout data.");
106
103
  }
104
+ // eslint-disable-next-line react-hooks/rules-of-hooks
107
105
  useEffect(() => {
108
106
  let cancelled = false;
109
107
  // since import map is loaded lazily, we only need to add preview event handler once the import map is loaded
@@ -78,8 +78,7 @@ function fetchComponentTemplate(src, params, revisionFallback) {
78
78
  return template;
79
79
  }
80
80
  catch (error) {
81
- console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision ||
82
- revisionFallback}" is present`);
81
+ console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision || revisionFallback}" is present`);
83
82
  throw error;
84
83
  }
85
84
  });
@@ -18,9 +18,7 @@ export const File = (_a) => {
18
18
  return null;
19
19
  }
20
20
  // handle link directly on field for forgetful devs
21
- const file = (dynamicField.src
22
- ? field
23
- : dynamicField.value);
21
+ const file = (dynamicField.src ? field : dynamicField.value);
24
22
  if (!file) {
25
23
  return null;
26
24
  }
@@ -9,6 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ /* eslint-disable no-unused-vars */
12
13
  import { mediaApi } from '@sitecore-content-sdk/core/media';
13
14
  import React from 'react';
14
15
  import { addClassName } from '../utils';
@@ -9,14 +9,15 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ /* eslint-disable no-unused-expressions, @typescript-eslint/no-unused-expressions */
12
13
  import React, { forwardRef } from 'react';
13
14
  import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
14
15
  import { withFieldMetadata } from '../enhancers/withFieldMetadata';
15
16
  import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
16
17
  import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
17
- export const Link = withFieldMetadata(withEmptyFieldEditingComponent(
18
- // eslint-disable-next-line react/display-name
19
- forwardRef((_a, ref) => {
18
+ export const Link = withFieldMetadata(withEmptyFieldEditingComponent(forwardRef(
19
+ // eslint-disable-next-line no-unused-vars
20
+ (_a, ref) => {
20
21
  var { field, editable = true, showLinkTextWithChildrenPresent } = _a, otherProps = __rest(_a, ["field", "editable", "showLinkTextWithChildrenPresent"]);
21
22
  const children = otherProps.children;
22
23
  const dynamicField = field;
@@ -14,10 +14,14 @@ import { withFieldMetadata } from '../enhancers/withFieldMetadata';
14
14
  import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
15
15
  import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
16
16
  import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
17
- export const RichText = withFieldMetadata(withEmptyFieldEditingComponent(
18
- // eslint-disable-next-line react/display-name
19
- forwardRef((_a, ref) => {
20
- var { field, tag = 'div', editable = true } = _a, otherProps = __rest(_a, ["field", "tag", "editable"]);
17
+ export const RichText = withFieldMetadata(withEmptyFieldEditingComponent(forwardRef((
18
+ // eslint-disable-next-line no-unused-vars
19
+ _a, ref) => {
20
+ var
21
+ // eslint-disable-next-line no-unused-vars
22
+ { field, tag = 'div', editable = true } = _a, otherProps = __rest(_a,
23
+ // eslint-disable-next-line no-unused-vars
24
+ ["field", "tag", "editable"]);
21
25
  if (isFieldValueEmpty(field)) {
22
26
  return null;
23
27
  }
@@ -21,7 +21,7 @@ export const Text = withFieldMetadata(withEmptyFieldEditingComponent((_a) => {
21
21
  }
22
22
  // can't use editable value if we want to output unencoded
23
23
  if (!encode) {
24
- // eslint-disable-next-line no-param-reassign
24
+ // eslint-disable-next-line no-param-reassign, no-unused-vars
25
25
  editable = false;
26
26
  }
27
27
  let output = field.value === undefined ? '' : field.value;
@@ -13,8 +13,6 @@ export function withComponentMap(Component) {
13
13
  const context = useContext(ComponentMapReactContext);
14
14
  return React.createElement(Component, Object.assign({}, props, { componentMap: props.componentMap || context }));
15
15
  }
16
- WithComponentMap.displayName = `withComponentMap(${Component.displayName ||
17
- Component.name ||
18
- 'Anonymous'})`;
16
+ WithComponentMap.displayName = `withComponentMap(${Component.displayName || Component.name || 'Anonymous'})`;
19
17
  return WithComponentMap;
20
18
  }
@@ -15,13 +15,11 @@ export function withEmptyFieldEditingComponent(FieldComponent, options) {
15
15
  return null;
16
16
  };
17
17
  if (options.isForwardRef) {
18
- // eslint-disable-next-line react/display-name
19
18
  return forwardRef((props, ref) => {
20
19
  const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
21
20
  return (React.createElement(React.Fragment, null, (EmptyFieldEditingComponent && React.createElement(EmptyFieldEditingComponent, null)) || (React.createElement(FieldComponent, Object.assign({}, props, { ref: ref })))));
22
21
  });
23
22
  }
24
- // eslint-disable-next-line react/display-name
25
23
  return (props) => {
26
24
  const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
27
25
  return (React.createElement(React.Fragment, null, (EmptyFieldEditingComponent && React.createElement(EmptyFieldEditingComponent, null)) || (React.createElement(FieldComponent, Object.assign({}, props)))));
@@ -7,7 +7,6 @@ import { FieldMetadata } from '../components/FieldMetadata';
7
7
  */
8
8
  export function withFieldMetadata(FieldComponent, isForwardRef = false) {
9
9
  if (isForwardRef) {
10
- // eslint-disable-next-line react/display-name
11
10
  return forwardRef((props, ref) => {
12
11
  var _a;
13
12
  const { editable = true } = props;
@@ -19,7 +18,6 @@ export function withFieldMetadata(FieldComponent, isForwardRef = false) {
19
18
  React.createElement(FieldComponent, Object.assign({}, props, { ref: ref }))));
20
19
  });
21
20
  }
22
- // eslint-disable-next-line react/display-name
23
21
  return (props) => {
24
22
  var _a;
25
23
  const { editable = true } = props;
@@ -44,7 +44,8 @@ export function withPlaceholder(placeholders, options) {
44
44
  else {
45
45
  placeholderData = PlaceholderCommon.getPlaceholderDataFromRenderingData(renderingData, placeholder, childProps.page.mode.isEditing);
46
46
  if (placeholderData) {
47
- childProps[placeholder] = this.getComponentsForRenderingData(placeholderData);
47
+ childProps[placeholder] =
48
+ this.getComponentsForRenderingData(placeholderData);
48
49
  }
49
50
  }
50
51
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/react",
3
- "version": "1.1.0-canary.22",
3
+ "version": "1.1.0-canary.24",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@sitecore-feaas/clientside": "^0.6.0",
34
+ "@stylistic/eslint-plugin": "^5.2.2",
34
35
  "@testing-library/dom": "^10.4.0",
35
36
  "@testing-library/react": "^16.3.0",
36
37
  "@types/chai": "^5.2.2",
@@ -41,14 +42,22 @@
41
42
  "@types/react-dom": "^19.1.3",
42
43
  "@types/sinon": "^17.0.4",
43
44
  "@types/sinon-chai": "^4.0.0",
45
+ "@typescript-eslint/eslint-plugin": "8.39.0",
46
+ "@typescript-eslint/parser": "8.39.0",
44
47
  "chai": "^4.3.7",
45
48
  "chai-string": "^1.6.0",
46
49
  "del-cli": "^6.0.0",
47
- "eslint": "^8.56.0",
48
- "eslint-plugin-react": "^7.37.5",
50
+ "eslint": "^9.32.0",
51
+ "eslint-config-prettier": "^10.1.8",
52
+ "eslint-plugin-import": "2.32.0",
53
+ "eslint-plugin-jsdoc": "52.0.3",
54
+ "eslint-plugin-prettier": "^4.0.0",
55
+ "eslint-plugin-react": "7.37.5",
56
+ "eslint-plugin-react-hooks": "5.2.0",
49
57
  "jsdom": "^26.1.0",
50
58
  "mocha": "^11.2.2",
51
59
  "nyc": "^17.1.0",
60
+ "prettier": "^2.8.0",
52
61
  "react": "^19.1.0",
53
62
  "react-dom": "^19.1.0",
54
63
  "sinon": "^20.0.0",
@@ -63,12 +72,12 @@
63
72
  "react-dom": "^19.1.0"
64
73
  },
65
74
  "dependencies": {
66
- "@sitecore-content-sdk/core": "1.1.0-canary.22",
75
+ "@sitecore-content-sdk/core": "1.1.0-canary.24",
67
76
  "fast-deep-equal": "^3.1.3"
68
77
  },
69
78
  "description": "",
70
79
  "types": "types/index.d.ts",
71
- "gitHead": "96b2770210d5294a54b8c0ea0a0994c7f7149727",
80
+ "gitHead": "306a6a5d07f5fb08a45da6cd78438b269ca92d02",
72
81
  "files": [
73
82
  "dist",
74
83
  "types"