@sitecore-content-sdk/react 2.0.0-canary.2 → 2.0.0-canary.4

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.
Files changed (108) hide show
  1. package/dist/cjs/components/Date.js +13 -11
  2. package/dist/cjs/components/DefaultEmptyFieldEditingComponents.js +2 -1
  3. package/dist/cjs/components/DesignLibrary/DesignLibrary.js +3 -7
  4. package/dist/cjs/components/DesignLibrary/DesignLibraryClientEvents.js +13 -5
  5. package/dist/cjs/components/EditingScripts.js +2 -2
  6. package/dist/cjs/components/ErrorBoundary.js +8 -3
  7. package/dist/cjs/components/File.js +3 -1
  8. package/dist/cjs/components/Form.js +12 -5
  9. package/dist/cjs/components/Image.js +12 -9
  10. package/dist/cjs/components/Link.js +19 -46
  11. package/dist/cjs/components/Placeholder/AppPlaceholder.js +57 -58
  12. package/dist/cjs/components/Placeholder/ClientComponentWrapper.js +5 -9
  13. package/dist/cjs/components/Placeholder/Placeholder.js +21 -93
  14. package/dist/cjs/components/Placeholder/index.js +1 -2
  15. package/dist/cjs/components/Placeholder/placeholder-utils.js +7 -35
  16. package/dist/cjs/components/RichText.js +18 -49
  17. package/dist/cjs/components/SitecoreProvider.js +81 -33
  18. package/dist/cjs/components/Text.js +12 -8
  19. package/dist/cjs/enhancers/withAppPlaceholder.js +6 -0
  20. package/dist/cjs/enhancers/withDatasourceCheck.js +4 -3
  21. package/dist/cjs/enhancers/withEditorChromes.js +50 -15
  22. package/dist/cjs/enhancers/withEmptyFieldEditingComponent.js +8 -38
  23. package/dist/cjs/enhancers/withFieldMetadata.js +9 -39
  24. package/dist/cjs/enhancers/withPlaceholder.js +16 -52
  25. package/dist/cjs/enhancers/withSitecore.js +5 -29
  26. package/dist/cjs/index.js +9 -7
  27. package/dist/cjs/search/utils.js +2 -2
  28. package/dist/esm/components/Date.js +13 -11
  29. package/dist/esm/components/DefaultEmptyFieldEditingComponents.js +2 -1
  30. package/dist/esm/components/DesignLibrary/DesignLibrary.js +3 -7
  31. package/dist/esm/components/DesignLibrary/DesignLibraryClientEvents.js +12 -4
  32. package/dist/esm/components/EditingScripts.js +2 -2
  33. package/dist/esm/components/ErrorBoundary.js +8 -3
  34. package/dist/esm/components/File.js +3 -1
  35. package/dist/esm/components/Form.js +11 -4
  36. package/dist/esm/components/Image.js +12 -9
  37. package/dist/esm/components/Link.js +16 -13
  38. package/dist/esm/components/Placeholder/AppPlaceholder.js +58 -59
  39. package/dist/esm/components/Placeholder/ClientComponentWrapper.js +4 -8
  40. package/dist/esm/components/Placeholder/Placeholder.js +20 -89
  41. package/dist/esm/components/Placeholder/index.js +1 -1
  42. package/dist/esm/components/Placeholder/placeholder-utils.js +5 -32
  43. package/dist/esm/components/RichText.js +15 -16
  44. package/dist/esm/components/SitecoreProvider.js +46 -32
  45. package/dist/esm/components/Text.js +12 -8
  46. package/dist/esm/enhancers/withAppPlaceholder.js +6 -0
  47. package/dist/esm/enhancers/withDatasourceCheck.js +3 -2
  48. package/dist/esm/enhancers/withEditorChromes.js +17 -12
  49. package/dist/esm/enhancers/withEmptyFieldEditingComponent.js +5 -5
  50. package/dist/esm/enhancers/withFieldMetadata.js +6 -6
  51. package/dist/esm/enhancers/withPlaceholder.js +15 -52
  52. package/dist/esm/enhancers/withSitecore.js +6 -29
  53. package/dist/esm/index.js +4 -3
  54. package/dist/esm/search/utils.js +1 -1
  55. package/package.json +5 -5
  56. package/types/components/Date.d.ts.map +1 -1
  57. package/types/components/DefaultEmptyFieldEditingComponents.d.ts.map +1 -1
  58. package/types/components/DesignLibrary/DesignLibrary.d.ts +0 -2
  59. package/types/components/DesignLibrary/DesignLibrary.d.ts.map +1 -1
  60. package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts.map +1 -1
  61. package/types/components/EditingScripts.d.ts +2 -2
  62. package/types/components/EditingScripts.d.ts.map +1 -1
  63. package/types/components/ErrorBoundary.d.ts +2 -2
  64. package/types/components/ErrorBoundary.d.ts.map +1 -1
  65. package/types/components/File.d.ts.map +1 -1
  66. package/types/components/Form.d.ts.map +1 -1
  67. package/types/components/Image.d.ts.map +1 -1
  68. package/types/components/Link.d.ts.map +1 -1
  69. package/types/components/Placeholder/AppPlaceholder.d.ts +1 -1
  70. package/types/components/Placeholder/AppPlaceholder.d.ts.map +1 -1
  71. package/types/components/Placeholder/ClientComponentWrapper.d.ts +2 -2
  72. package/types/components/Placeholder/ClientComponentWrapper.d.ts.map +1 -1
  73. package/types/components/Placeholder/Placeholder.d.ts +4 -19
  74. package/types/components/Placeholder/Placeholder.d.ts.map +1 -1
  75. package/types/components/Placeholder/index.d.ts +1 -1
  76. package/types/components/Placeholder/index.d.ts.map +1 -1
  77. package/types/components/Placeholder/models.d.ts +30 -56
  78. package/types/components/Placeholder/models.d.ts.map +1 -1
  79. package/types/components/Placeholder/placeholder-utils.d.ts +5 -13
  80. package/types/components/Placeholder/placeholder-utils.d.ts.map +1 -1
  81. package/types/components/RichText.d.ts +2 -0
  82. package/types/components/RichText.d.ts.map +1 -1
  83. package/types/components/SitecoreProvider.d.ts +43 -13
  84. package/types/components/SitecoreProvider.d.ts.map +1 -1
  85. package/types/components/Text.d.ts.map +1 -1
  86. package/types/enhancers/withAppPlaceholder.d.ts +6 -0
  87. package/types/enhancers/withAppPlaceholder.d.ts.map +1 -1
  88. package/types/enhancers/withDatasourceCheck.d.ts.map +1 -1
  89. package/types/enhancers/withEditorChromes.d.ts +4 -1
  90. package/types/enhancers/withEditorChromes.d.ts.map +1 -1
  91. package/types/enhancers/withEmptyFieldEditingComponent.d.ts +5 -3
  92. package/types/enhancers/withEmptyFieldEditingComponent.d.ts.map +1 -1
  93. package/types/enhancers/withFieldMetadata.d.ts +4 -2
  94. package/types/enhancers/withFieldMetadata.d.ts.map +1 -1
  95. package/types/enhancers/withPlaceholder.d.ts +14 -32
  96. package/types/enhancers/withPlaceholder.d.ts.map +1 -1
  97. package/types/enhancers/withSitecore.d.ts +8 -50
  98. package/types/enhancers/withSitecore.d.ts.map +1 -1
  99. package/types/index.d.ts +4 -3
  100. package/types/index.d.ts.map +1 -1
  101. package/dist/cjs/enhancers/withComponentMap.js +0 -24
  102. package/dist/cjs/enhancers/withLoadImportMap.js +0 -62
  103. package/dist/esm/enhancers/withComponentMap.js +0 -18
  104. package/dist/esm/enhancers/withLoadImportMap.js +0 -25
  105. package/types/enhancers/withComponentMap.d.ts +0 -13
  106. package/types/enhancers/withComponentMap.d.ts.map +0 -1
  107. package/types/enhancers/withLoadImportMap.d.ts +0 -28
  108. package/types/enhancers/withLoadImportMap.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"placeholder-utils.d.ts","sourceRoot":"","sources":["../../../src/components/Placeholder/placeholder-utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAuD,MAAM,gBAAgB,CAAC;AACnG,OAAO,EACL,kBAAkB,EAClB,SAAS,EAGV,MAAM,sCAAsC,CAAC;AAa9C,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAElB;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,kBAAkB,GAAG,SAAS,EACzC,MAAM,MAAM,EACZ,WAAW,OAAO,yFA2CnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,WAAW,kBAAkB;;CAUzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,EAAE,sBAElF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACpC,kBAAkB,gBAAgB,EAClC,oBAAoB,kBAAkB,EACtC,cAAc,MAAM,KACnB,aAeF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,oBAAoB,EACjE,gBAAgB,EAAE,CAAC,EACnB,kBAAkB,EAAE,kBAAkB,GACrC,iBAAiB,CAYnB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,qBAAqB,kBAAkB,EACvC,iBAAiB,MAAM,EACvB,eAAe,YAAY,EAC3B,2BAA2B,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,EAAE,EAC1D,4BAA4B,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,EAAE,KAC1D,qBA0GF,CAAC"}
1
+ {"version":3,"file":"placeholder-utils.d.ts","sourceRoot":"","sources":["../../../src/components/Placeholder/placeholder-utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAuD,MAAM,gBAAgB,CAAC;AACnG,OAAO,EACL,kBAAkB,EAClB,SAAS,EAGV,MAAM,sCAAsC,CAAC;AAa9C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,kBAAkB,GAAG,SAAS,EACzC,MAAM,MAAM,EACZ,WAAW,OAAO,yFA2CnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,WAAW,kBAAkB;;CAUzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,EAAE,sBAElF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,gBAAgB,EAC/D,gBAAgB,EAAE,CAAC,EACnB,kBAAkB,EAAE,kBAAkB,GACrC,mBAAmB,CAYrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,qBAAqB,kBAAkB,EACvC,iBAAiB,MAAM,EACvB,eAAe,YAAY,EAC3B,2BAA2B,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,EAAE,EAC1D,4BAA4B,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,EAAE,KAC1D,qBA0GF,CAAC"}
@@ -21,6 +21,8 @@ export interface RichTextProps extends EditableFieldProps<RichTextProps> {
21
21
  * @default <div />
22
22
  */
23
23
  tag?: string;
24
+ /** Ref forwarded to the root element. */
25
+ ref?: React.Ref<HTMLElement>;
24
26
  }
25
27
  /**
26
28
  * The RichText component.
@@ -1 +1 @@
1
- {"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../src/components/RichText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmC,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,aAAa,EAAqB,MAAM,sCAAsC,CAAC;AAIxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,kBAAkB,CAAC,aAAa,CAAC;IACtE,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,gCAAgC;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA2B5C,CAAC"}
1
+ {"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../src/components/RichText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAqB,MAAM,sCAAsC,CAAC;AAIxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,kBAAkB,CAAC,aAAa,CAAC;IACtE,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,gCAAgC;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CAC9B;AAsBD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAI5C,CAAC"}
@@ -32,16 +32,34 @@ export interface SitecoreProviderState {
32
32
  * @param {Page} value New page value.
33
33
  * @returns {void}
34
34
  */
35
- setPage: (value: Page) => void;
35
+ setPage?: (value: Page) => void;
36
36
  /**
37
- * The current page.
37
+ * The page data.
38
38
  */
39
39
  page: Page;
40
+ /**
41
+ * The dynamic import for import map to be used in variant generation mode.
42
+ */
43
+ loadImportMap: () => Promise<ImportMapImport>;
44
+ /**
45
+ * The component map to use for rendering components.
46
+ */
47
+ componentMap: ComponentMap;
40
48
  /**
41
49
  * The API configuration defined in the `SitecoreConfig`.
42
50
  */
43
51
  api?: SitecoreProviderProps['api'];
44
52
  }
53
+ /**
54
+ * The options for the useSitecore hook.
55
+ * @public
56
+ */
57
+ export interface UseSitecoreOptions {
58
+ /**
59
+ * If set to true, the `updateContext` method will be injected into the component props.
60
+ */
61
+ updatable?: boolean;
62
+ }
45
63
  /**
46
64
  * The context for the SitecoreProvider component.
47
65
  * @public
@@ -51,17 +69,29 @@ export declare const ComponentMapReactContext: React.Context<ComponentMap>;
51
69
  export declare const ImportMapReactContext: React.Context<(() => Promise<ImportMapImport>) | undefined>;
52
70
  /**
53
71
  * The SitecoreProvider component.
72
+ * @param {SitecoreProviderProps} props - The props for the SitecoreProvider component.
73
+ * @param {SitecoreProviderProps['api']} props.api - The API configuration.
74
+ * @param {SitecoreProviderProps['page']} props.page - The page data.
75
+ * @param {SitecoreProviderProps['componentMap']} props.componentMap - The component map.
76
+ * @param {SitecoreProviderProps['loadImportMap']} props.loadImportMap - The function to load the import map.
77
+ * @param {React.ReactNode} props.children - The children to render.
78
+ * @returns {React.ReactNode} The SitecoreProvider component.
54
79
  * @public
55
80
  */
56
- export declare class SitecoreProvider extends React.Component<SitecoreProviderProps, SitecoreProviderState> {
57
- static displayName: string;
58
- constructor(props: SitecoreProviderProps);
59
- componentDidUpdate(prevProps: SitecoreProviderProps): void;
60
- /**
61
- * Update page state.
62
- * @param {Page} value New page value
63
- */
64
- setPage: (value: Page) => void;
65
- render(): React.JSX.Element;
66
- }
81
+ export declare const SitecoreProvider: {
82
+ (props: SitecoreProviderProps): React.JSX.Element;
83
+ displayName: string;
84
+ };
85
+ /**
86
+ * This hook grants acсess to the current Sitecore page and api.
87
+ * @param {UseSitecoreOptions} [options] hook options
88
+ * @example
89
+ * const EditMode = () => {
90
+ * const { page } = useSitecore();
91
+ * return <span>Edit Mode is {page.mode.isEditing ? 'active' : 'inactive'}</span>
92
+ * }
93
+ * @returns {SitecoreProviderState} The current Sitecore context, including the page and api.
94
+ * @public
95
+ */
96
+ export declare function useSitecore(options?: UseSitecoreOptions): SitecoreProviderState;
67
97
  //# sourceMappingURL=SitecoreProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SitecoreProvider.d.ts","sourceRoot":"","sources":["../../src/components/SitecoreProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,GAAG,EAAE,cAAc,CA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AO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAU,SAAQ,kBAAkB,CAAC,SAAS,CAAC;IAC9D,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAiEpC,CAAC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/components/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAqB,MAAM,sCAAsC,CAAC;AAIxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAU,SAAQ,kBAAkB,CAAC,SAAS,CAAC;IAC9D,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAkED;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIpC,CAAC"}
@@ -12,5 +12,11 @@ export type WrapperProps = {
12
12
  page: Page;
13
13
  componentMap: ComponentMap;
14
14
  };
15
+ /**
16
+ * Provides a slot-like functionality by wrapping a component and rendering placeholders defined in the layout data.
17
+ * @param {ComponentType<T>} Component - The component to be wrapped around placeholders.
18
+ * @returns {React.ReactNode} A new component that renders the original component with placeholders.
19
+ * @public
20
+ */
15
21
  export declare const withAppPlaceholder: <T extends ComponentProps, W extends T & WrapperProps>(Component: ComponentType<T>) => (props: W) => React.JSX.Element;
16
22
  //# sourceMappingURL=withAppPlaceholder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withAppPlaceholder.d.ts","sourceRoot":"","sources":["../../src/enhancers/withAppPlaceholder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,CAAC,GAAG,YAAY,EACrF,WAAW,aAAa,CAAC,CAAC,CAAC,MAEnB,OAAO,CAAC,sBAoBjB,CAAC"}
1
+ {"version":3,"file":"withAppPlaceholder.d.ts","sourceRoot":"","sources":["../../src/enhancers/withAppPlaceholder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA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,cAAc,SAAS,wBAAwB,EACpF,WAAW,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,MAEV,OAAO,cAAc,wBAc5D"}
1
+ {"version":3,"file":"withDatasourceCheck.d.ts","sourceRoot":"","sources":["../../src/enhancers/withDatasourceCheck.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,eAAO,MAAM,mBAAmB,QAAO,GAAG,CAAC,OAI1C,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;CAC3E;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,0BAA0B,IAC/B,cAAc,SAAS,wBAAwB,EACpF,WAAW,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,MAEtC,OAAO,cAAc,wBAchC"}
@@ -4,5 +4,8 @@ import React from 'react';
4
4
  * @param {React.ComponentClass<unknown> | React.FC<unknown>} WrappedComponent - The component to wrap.
5
5
  * @public
6
6
  */
7
- export declare const withEditorChromes: (WrappedComponent: React.ComponentClass<unknown> | React.FC<unknown>) => React.ComponentClass;
7
+ export declare const withEditorChromes: (WrappedComponent: React.ComponentClass<unknown> | React.FC<unknown>) => {
8
+ (props: Record<string, unknown>): React.JSX.Element;
9
+ displayName: string;
10
+ };
8
11
  //# sourceMappingURL=withEditorChromes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withEditorChromes.d.ts","sourceRoot":"","sources":["../../src/enhancers/withEditorChromes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAG7C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,kBAAkB,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAehD,KAAK,CAAC,cAC1B,CAAC"}
1
+ {"version":3,"file":"withEditorChromes.d.ts","sourceRoot":"","sources":["../../src/enhancers/withEditorChromes.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAGhE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,kBAAkB,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC;YAE1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAoBjD,CAAC"}
@@ -9,7 +9,7 @@ export interface WithEmptyFieldEditingComponentOptions {
9
9
  */
10
10
  defaultEmptyFieldEditingComponent: React.FC;
11
11
  /**
12
- * 'true' if forward reference is needed
12
+ * 'true' if the ref prop should be explicitly accepted and forwarded
13
13
  */
14
14
  isForwardRef?: boolean;
15
15
  }
@@ -21,9 +21,11 @@ interface WithEmptyFieldEditingComponentProps<Props> {
21
21
  /**
22
22
  * Returns the passed field component or default component in case field value is empty and edit mode is 'metadata'
23
23
  * @param {ComponentType<FieldComponentProps>} FieldComponent the field component
24
- * @param {WithEmptyFieldEditingComponentProps} options the options of the HOC;
24
+ * @param {WithEmptyFieldEditingComponentOptions} options the options of the HOC;
25
25
  * @public
26
26
  */
27
- export declare function withEmptyFieldEditingComponent<FieldComponentProps extends WithEmptyFieldEditingComponentProps<FieldComponentProps>, RefElementType = HTMLElement>(FieldComponent: ComponentType<FieldComponentProps>, options: WithEmptyFieldEditingComponentOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<FieldComponentProps> & React.RefAttributes<RefElementType>> | ((props: FieldComponentProps) => React.JSX.Element);
27
+ export declare function withEmptyFieldEditingComponent<FieldComponentProps extends WithEmptyFieldEditingComponentProps<FieldComponentProps>, RefElementType = HTMLElement>(FieldComponent: ComponentType<FieldComponentProps>, options: WithEmptyFieldEditingComponentOptions): (props: FieldComponentProps & {
28
+ ref?: React.Ref<RefElementType>;
29
+ }) => React.JSX.Element;
28
30
  export {};
29
31
  //# sourceMappingURL=withEmptyFieldEditingComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withEmptyFieldEditingComponent.d.ts","sourceRoot":"","sources":["../../src/enhancers/withEmptyFieldEditingComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAc,MAAM,OAAO,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,KAAK,EAEL,aAAa,EACd,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,qCAAqC;IACpD;;OAEG;IACH,iCAAiC,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5C;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAKD,UAAU,mCAAmC,CAAC,KAAK;IAEjD,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,GAAG,aAAa,CAAC;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0BAA0B,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;CAC5E;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,mBAAmB,SAAS,mCAAmC,CAAC,mBAAmB,CAAC,EACpF,cAAc,GAAG,WAAW,EAE5B,cAAc,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAClD,OAAO,EAAE,qCAAqC,gIAwC/B,mBAAmB,wBAKnC"}
1
+ {"version":3,"file":"withEmptyFieldEditingComponent.d.ts","sourceRoot":"","sources":["../../src/enhancers/withEmptyFieldEditingComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,KAAK,EAEL,aAAa,EACd,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,qCAAqC;IACpD;;OAEG;IACH,iCAAiC,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5C;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAKD,UAAU,mCAAmC,CAAC,KAAK;IAEjD,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,GAAG,aAAa,CAAC;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0BAA0B,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;CAC5E;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,mBAAmB,SAAS,mCAAmC,CAAC,mBAAmB,CAAC,EACpF,cAAc,GAAG,WAAW,EAE5B,cAAc,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAClD,OAAO,EAAE,qCAAqC,WA2B7B,mBAAmB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;CAAE,uBAgB3E"}
@@ -10,9 +10,11 @@ interface WithMetadataProps {
10
10
  /**
11
11
  * Wraps the field component with metadata markup intended to be used for chromes hydration in Pages
12
12
  * @param {ComponentType<FieldComponentProps>} FieldComponent the field component
13
- * @param {boolean} isForwardRef set to 'true' if forward reference is needed
13
+ * @param {boolean} isForwardRef set to 'true' if the ref prop should be explicitly accepted and forwarded
14
14
  * @public
15
15
  */
16
- export declare function withFieldMetadata<FieldComponentProps extends WithMetadataProps, RefElementType = HTMLElement>(FieldComponent: ComponentType<FieldComponentProps>, isForwardRef?: boolean): React.ForwardRefExoticComponent<React.PropsWithoutRef<FieldComponentProps> & React.RefAttributes<RefElementType>> | ((props: FieldComponentProps) => React.JSX.Element);
16
+ export declare function withFieldMetadata<FieldComponentProps extends WithMetadataProps, RefElementType = HTMLElement>(FieldComponent: ComponentType<FieldComponentProps>, isForwardRef?: boolean): (props: FieldComponentProps & {
17
+ ref?: React.Ref<RefElementType>;
18
+ }) => React.JSX.Element;
17
19
  export {};
18
20
  //# sourceMappingURL=withFieldMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withFieldMetadata.d.ts","sourceRoot":"","sources":["../../src/enhancers/withFieldMetadata.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAc,MAAM,OAAO,CAAC;AAGzD,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;KACvC,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,mBAAmB,SAAS,iBAAiB,EAC7C,cAAc,GAAG,WAAW,EAC5B,cAAc,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,YAAY,UAAQ,gIAkBzD,mBAAmB,wBAcnC"}
1
+ {"version":3,"file":"withFieldMetadata.d.ts","sourceRoot":"","sources":["../../src/enhancers/withFieldMetadata.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG7C,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;KACvC,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,mBAAmB,SAAS,iBAAiB,EAC7C,cAAc,GAAG,WAAW,EAC5B,cAAc,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,YAAY,UAAQ,WAEvD,mBAAmB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;CAAE,uBA8B3E"}
@@ -1,37 +1,19 @@
1
1
  import React from 'react';
2
- import { ComponentRendering, RouteData } from '@sitecore-content-sdk/content/layout';
3
- import { PlaceholderProps } from '../components/Placeholder';
4
- export interface WithPlaceholderOptions {
5
- /**
6
- * Function to map incoming placeholder props into rendering data to use for the placeholder data.
7
- * Normally in a Content SDK component, props.rendering is passed the component data, and that is the default.
8
- * However, if your component data is in a different prop, like say 'route' in a sample app,
9
- * this lets you map that.
10
- */
11
- resolvePlaceholderDataFromProps?: (props: unknown) => ComponentRendering | RouteData;
12
- /**
13
- * Function to alter the placeholder props from within the HOC. Enables the props to be
14
- * transformed before being used by the placeholder/HOC, for example to customize the
15
- * error or missing component display
16
- */
17
- propsTransformer?: (props: PlaceholderProps) => PlaceholderProps;
18
- }
19
- export interface PlaceholderToPropMapping {
20
- /**
21
- * The name of the placeholder this component will expose
22
- */
23
- placeholder: string;
24
- /**
25
- * The name of the prop on your wrapped component that you would like the placeholder data injected on
26
- */
27
- prop: string;
28
- }
29
- export type WithPlaceholderSpec = (string | PlaceholderToPropMapping) | (string | PlaceholderToPropMapping)[];
2
+ import { ComponentType } from 'react';
3
+ import { ComponentRendering } from '@sitecore-content-sdk/content/layout';
4
+ import { Page } from '@sitecore-content-sdk/content/client';
5
+ import { ComponentMap } from '../components/sharedTypes';
6
+ import { ComponentProps } from './withAppPlaceholder';
7
+ export type WrapperProps = {
8
+ rendering: ComponentRendering;
9
+ page?: Page;
10
+ componentMap?: ComponentMap;
11
+ };
30
12
  /**
31
- * HOC to provide client-side placeholder functionality to a component.
32
- * @param {WithPlaceholderSpec} placeholders
33
- * @param {WithPlaceholderOptions} [options]
13
+ * Provides a slot-like functionality by wrapping a component in client/SSR context and rendering placeholders defined in the layout data.
14
+ * @param {ComponentType<T>} Component - The component to be wrapped around placeholders.
15
+ * @returns {React.ReactNode} A new component that renders the original component with placeholders.
34
16
  * @public
35
17
  */
36
- export declare function withPlaceholder(placeholders: WithPlaceholderSpec, options?: WithPlaceholderOptions): (WrappedComponent: React.ComponentClass<PlaceholderProps> | React.FunctionComponent<PlaceholderProps>) => (props: import("@sitecore-content-sdk/core/tools").EnhancedOmit<PlaceholderProps, keyof import("./withSitecore").WithSitecoreProps>) => React.JSX.Element;
18
+ export declare const withPlaceholder: <T extends ComponentProps, W extends T & WrapperProps>(Component: ComponentType<T>) => (props: W) => React.JSX.Element;
37
19
  //# sourceMappingURL=withPlaceholder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withPlaceholder.d.ts","sourceRoot":"","sources":["../../src/enhancers/withPlaceholder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGrF,OAAO,EAEL,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,+BAA+B,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,kBAAkB,GAAG,SAAS,CAAC;IACrF;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,gBAAgB,CAAC;CAClE;AAED,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,GAC3B,CAAC,MAAM,GAAG,wBAAwB,CAAC,GACnC,CAAC,MAAM,GAAG,wBAAwB,CAAC,EAAE,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,sBAAsB,IAG9B,kBACI,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,GACtC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,+JAmEhD"}
1
+ {"version":3,"file":"withPlaceholder.d.ts","sourceRoot":"","sources":["../../src/enhancers/withPlaceholder.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,CAAC,GAAG,YAAY,EAClF,WAAW,aAAa,CAAC,CAAC,CAAC,MAEnB,OAAO,CAAC,sBAmBjB,CAAC"}
@@ -1,63 +1,21 @@
1
1
  import React from 'react';
2
2
  import { EnhancedOmit } from '@sitecore-content-sdk/core/tools';
3
- import { SitecoreProviderState } from '../components/SitecoreProvider';
4
- import { Page } from '@sitecore-content-sdk/content/client';
3
+ import { SitecoreProviderState, UseSitecoreOptions } from '../components/SitecoreProvider';
5
4
  /**
6
- * The options for the withSitecore HOC.
5
+ * The props that HOC will inject into the wrapped component — the full Sitecore context state.
7
6
  * @public
8
7
  */
9
- export interface WithSitecoreOptions {
10
- /**
11
- * If set to true, the `updateContext` method will be injected into the component props.
12
- */
13
- updatable?: boolean;
14
- }
8
+ export type WithSitecoreProps = SitecoreProviderState;
15
9
  /**
16
- * The props that HOC will inject.
17
- * @public
18
- */
19
- export interface WithSitecoreProps {
20
- /**
21
- * The current page context.
22
- */
23
- page: Page;
24
- /**
25
- * The API configuration defined in the `SitecoreConfig`.
26
- */
27
- api?: SitecoreProviderState['api'];
28
- /**
29
- * Method to update the page. This is only available if `updatable` is set to true.
30
- * @param {Page} value New page value.
31
- * @returns {void}
32
- */
33
- updatePage?: ((value: Page) => void) | false;
34
- }
35
- /**
36
- * The type of the props that HOC will receive.
10
+ * The type of the props that the HOC-wrapped component will receive (injected props omitted).
37
11
  * @public
38
12
  */
39
13
  export type WithSitecoreHocProps<ComponentProps> = EnhancedOmit<ComponentProps, keyof WithSitecoreProps>;
40
14
  /**
41
- * @param {WithSitecoreProviderOptions} [options]
42
- * @public
43
- */
44
- export declare function withSitecore(options?: WithSitecoreOptions): <ComponentProps extends WithSitecoreProps>(Component: React.ComponentType<ComponentProps>) => (props: WithSitecoreHocProps<ComponentProps>) => React.JSX.Element;
45
- /**
46
- * This hook grants acсess to the current Sitecore page and api.
47
- * @param {WithSitecoreOptions} [options] hook options
48
- * @example
49
- * const EditMode = () => {
50
- * const { page } = useSitecore();
51
- * return <span>Edit Mode is {page.mode.isEditing ? 'active' : 'inactive'}</span>
52
- * }
53
- * @example
54
- * const EditMode = () => {
55
- * const { page, updatePage } = useSitecore({ updatable: true });
56
- * const onClick = () => updatePage({ itemId: '123' });
57
- * return <span onClick={onClick}>Item id is {page.itemId}</span>
58
- * }
59
- * @returns {object} { api, page, updatePage }
15
+ * @deprecated `useSitecore` hook is a better practice for consuming Sitecore context in components
16
+ * @param {UseSitecoreOptions} [options] - Options for whether return page context update method alongside the rest of context
17
+ * @returns A higher-order component that injects Sitecore context into the wrapped component.
60
18
  * @public
61
19
  */
62
- export declare function useSitecore(options?: WithSitecoreOptions): WithSitecoreProps;
20
+ export declare function withSitecore(options?: UseSitecoreOptions): <ComponentProps extends Partial<SitecoreProviderState> & Pick<SitecoreProviderState, "page">>(Component: React.ComponentType<ComponentProps>) => (props: WithSitecoreHocProps<ComponentProps>) => React.JSX.Element;
63
21
  //# sourceMappingURL=withSitecore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withSitecore.d.ts","sourceRoot":"","sources":["../../src/enhancers/withSitecore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAEL,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,cAAc,IAAI,YAAY,CAC7D,cAAc,EACd,MAAM,iBAAiB,CACxB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,IAChB,cAAc,SAAS,iBAAiB,EAC9E,WAAW,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,MAET,OAAO,oBAAoB,CAAC,cAAc,CAAC,uBAenF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CAS5E"}
1
+ {"version":3,"file":"withSitecore.d.ts","sourceRoot":"","sources":["../../src/enhancers/withSitecore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACL,qBAAqB,EAErB,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,cAAc,IAAI,YAAY,CAC7D,cAAc,EACd,MAAM,iBAAiB,CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,kBAAkB,IAErD,cAAc,SAAS,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,EAC3F,WAAW,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,MACT,OAAO,oBAAoB,CAAC,cAAc,CAAC,uBAcnF"}
package/types/index.d.ts CHANGED
@@ -17,13 +17,14 @@ export { DesignLibrary, DesignLibraryApp } from './components/DesignLibrary';
17
17
  export {} from './components/FEaaS/BYOCComponent';
18
18
  export { Link, LinkField, LinkFieldValue, LinkProps } from './components/Link';
19
19
  export { File, FileField } from './components/File';
20
- export { SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, } from './components/SitecoreProvider';
21
- export { withSitecore, useSitecore, WithSitecoreOptions, WithSitecoreProps, WithSitecoreHocProps, } from './enhancers/withSitecore';
20
+ export { SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, useSitecore, } from './components/SitecoreProvider';
22
21
  export { withEditorChromes } from './enhancers/withEditorChromes';
23
- export { withPlaceholder } from './enhancers/withPlaceholder';
22
+ export { withSitecore } from './enhancers/withSitecore';
24
23
  export { withDatasourceCheck } from './enhancers/withDatasourceCheck';
25
24
  export { withFieldMetadata } from './enhancers/withFieldMetadata';
26
25
  export { withEmptyFieldEditingComponent } from './enhancers/withEmptyFieldEditingComponent';
26
+ export { withAppPlaceholder } from './enhancers/withAppPlaceholder';
27
+ export { withPlaceholder } from './enhancers/withPlaceholder';
27
28
  export { EditingScripts } from './components/EditingScripts';
28
29
  export { DefaultEmptyFieldEditingComponentText, DefaultEmptyFieldEditingComponentImage, } from './components/DefaultEmptyFieldEditingComponents';
29
30
  export { ClientEditingChromesUpdate } from './components/ClientEditingChromesUpdate';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,SAAS,EACT,KAAK,EACL,IAAI,EACJ,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,QAAQ,GACT,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,iCAAiC,EACjC,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACT,IAAI,GACL,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,gBAAgB,IAAI,yBAAyB,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EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withComponentMap = withComponentMap;
7
- const react_1 = __importDefault(require("react"));
8
- const SitecoreProvider_1 = require("../components/SitecoreProvider");
9
- const react_2 = require("react");
10
- /**
11
- * @param {React.ComponentClass<T> | React.FC<T>} Component
12
- */
13
- function withComponentMap(Component) {
14
- /**
15
- * @param {T} props - props to pass to the wrapped component
16
- * @returns {JSX.Element} - the rendered component
17
- */
18
- function WithComponentMap(props) {
19
- const context = (0, react_2.useContext)(SitecoreProvider_1.ComponentMapReactContext);
20
- return react_1.default.createElement(Component, Object.assign({}, props, { componentMap: props.componentMap || context }));
21
- }
22
- WithComponentMap.displayName = `withComponentMap(${Component.displayName || Component.name || 'Anonymous'})`;
23
- return WithComponentMap;
24
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.useLoadImportMap = useLoadImportMap;
37
- exports.withLoadImportMap = withLoadImportMap;
38
- const react_1 = __importStar(require("react"));
39
- const SitecoreProvider_1 = require("../components/SitecoreProvider");
40
- /**
41
- * Hook that retrieves the loadImportMap function from context.
42
- * @returns {() => Promise<ImportMapImport> | undefined} The loadImportMap function from context, or undefined if not available.
43
- * @public
44
- */
45
- function useLoadImportMap() {
46
- return (0, react_1.useContext)(SitecoreProvider_1.ImportMapReactContext);
47
- }
48
- /**
49
- * Higher-order component that injects the loadImportMap function from context into component props.
50
- * If the component already receives loadImportMap via props, the prop value takes precedence.
51
- * @param {React.ComponentClass<T> | React.FC<T>} Component - The component to enhance.
52
- * @returns {React.ComponentClass<T> | React.FC<T>} The enhanced component with loadImportMap injected.
53
- */
54
- function withLoadImportMap(Component) {
55
- const WithLoadImportMap = (props) => {
56
- const loadImportMapContext = useLoadImportMap();
57
- const loadClientImportMap = props.loadImportMap || loadImportMapContext;
58
- return react_1.default.createElement(Component, Object.assign({}, props, { loadImportMap: loadClientImportMap }));
59
- };
60
- WithLoadImportMap.displayName = `withLoadImportMap(${Component.displayName || Component.name || 'Component'})`;
61
- return WithLoadImportMap;
62
- }
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { ComponentMapReactContext } from '../components/SitecoreProvider';
3
- import { useContext } from 'react';
4
- /**
5
- * @param {React.ComponentClass<T> | React.FC<T>} Component
6
- */
7
- export function withComponentMap(Component) {
8
- /**
9
- * @param {T} props - props to pass to the wrapped component
10
- * @returns {JSX.Element} - the rendered component
11
- */
12
- function WithComponentMap(props) {
13
- const context = useContext(ComponentMapReactContext);
14
- return React.createElement(Component, Object.assign({}, props, { componentMap: props.componentMap || context }));
15
- }
16
- WithComponentMap.displayName = `withComponentMap(${Component.displayName || Component.name || 'Anonymous'})`;
17
- return WithComponentMap;
18
- }
@@ -1,25 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import { ImportMapReactContext } from '../components/SitecoreProvider';
3
- /**
4
- * Hook that retrieves the loadImportMap function from context.
5
- * @returns {() => Promise<ImportMapImport> | undefined} The loadImportMap function from context, or undefined if not available.
6
- * @public
7
- */
8
- export function useLoadImportMap() {
9
- return useContext(ImportMapReactContext);
10
- }
11
- /**
12
- * Higher-order component that injects the loadImportMap function from context into component props.
13
- * If the component already receives loadImportMap via props, the prop value takes precedence.
14
- * @param {React.ComponentClass<T> | React.FC<T>} Component - The component to enhance.
15
- * @returns {React.ComponentClass<T> | React.FC<T>} The enhanced component with loadImportMap injected.
16
- */
17
- export function withLoadImportMap(Component) {
18
- const WithLoadImportMap = (props) => {
19
- const loadImportMapContext = useLoadImportMap();
20
- const loadClientImportMap = props.loadImportMap || loadImportMapContext;
21
- return React.createElement(Component, Object.assign({}, props, { loadImportMap: loadClientImportMap }));
22
- };
23
- WithLoadImportMap.displayName = `withLoadImportMap(${Component.displayName || Component.name || 'Component'})`;
24
- return WithLoadImportMap;
25
- }
@@ -1,13 +0,0 @@
1
- import React, { JSX } from 'react';
2
- import { ComponentMap } from '../components/sharedTypes';
3
- export interface WithComponentMapProps {
4
- componentMap?: ComponentMap;
5
- }
6
- /**
7
- * @param {React.ComponentClass<T> | React.FC<T>} Component
8
- */
9
- export declare function withComponentMap<T extends WithComponentMapProps>(Component: React.ComponentClass<T> | React.FC<T>): {
10
- (props: T): JSX.Element;
11
- displayName: string;
12
- };
13
- //# sourceMappingURL=withComponentMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withComponentMap.d.ts","sourceRoot":"","sources":["../../src/enhancers/withComponentMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAC9D,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAMf,CAAC,GAAG,GAAG,CAAC,OAAO;;EAWjD"}
@@ -1,28 +0,0 @@
1
- import React, { JSX } from 'react';
2
- import { ImportMapImport } from '../components/DesignLibrary/models';
3
- /**
4
- * Props that include the loadImportMap function from context.
5
- */
6
- export interface WithLoadImportMapProps {
7
- /**
8
- * The dynamic import for import map to be used in variant generation mode.
9
- */
10
- loadImportMap?: () => Promise<ImportMapImport>;
11
- }
12
- /**
13
- * Hook that retrieves the loadImportMap function from context.
14
- * @returns {() => Promise<ImportMapImport> | undefined} The loadImportMap function from context, or undefined if not available.
15
- * @public
16
- */
17
- export declare function useLoadImportMap(): (() => Promise<ImportMapImport>) | undefined;
18
- /**
19
- * Higher-order component that injects the loadImportMap function from context into component props.
20
- * If the component already receives loadImportMap via props, the prop value takes precedence.
21
- * @param {React.ComponentClass<T> | React.FC<T>} Component - The component to enhance.
22
- * @returns {React.ComponentClass<T> | React.FC<T>} The enhanced component with loadImportMap injected.
23
- */
24
- export declare function withLoadImportMap<T extends WithLoadImportMapProps>(Component: React.ComponentClass<T> | React.FC<T>): {
25
- (props: T): JSX.Element;
26
- displayName: string;
27
- };
28
- //# sourceMappingURL=withLoadImportMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withLoadImportMap.d.ts","sourceRoot":"","sources":["../../src/enhancers/withLoadImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,GAAG,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,CAAC,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,SAAS,CAE/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,sBAAsB,EAChE,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAEd,CAAC,GAAG,GAAG,CAAC,OAAO;;EAWlD"}