@pepperi-addons/ngx-lib-react 0.5.13 → 0.5.14
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/elements/main.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/pep-addon-block-loader.d.ts +15 -0
- package/pep-addon-block-loader.js +40 -0
package/index.d.ts
CHANGED
|
@@ -31,5 +31,6 @@ export { PepListChooser } from './pep-list-chooser.js';
|
|
|
31
31
|
export * from './pep-color-picker.js';
|
|
32
32
|
export * from './pep-query-builder.js';
|
|
33
33
|
export * from './pep-remote-loader.js';
|
|
34
|
+
export * from './pep-addon-block-loader.js';
|
|
34
35
|
export { PepRichHtmlTextarea } from './pep-rich-html-textarea.js';
|
|
35
36
|
export * from './services.js';
|
package/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export { PepListChooser } from './pep-list-chooser.js';
|
|
|
31
31
|
export * from './pep-color-picker.js';
|
|
32
32
|
export * from './pep-query-builder.js';
|
|
33
33
|
export * from './pep-remote-loader.js';
|
|
34
|
+
export * from './pep-addon-block-loader.js';
|
|
34
35
|
export { PepRichHtmlTextarea } from './pep-rich-html-textarea.js';
|
|
35
36
|
// Export all service helpers (bridge-based access to Angular services)
|
|
36
37
|
export * from './services.js';
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type PepAddonBlockLoaderRemoteLoaderOptions = Record<string, unknown>;
|
|
3
|
+
export interface PepAddonBlockLoaderProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
keyProp?: string;
|
|
5
|
+
addonId?: string;
|
|
6
|
+
remoteEntry?: string;
|
|
7
|
+
slugName?: string;
|
|
8
|
+
blockType?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
hostObject?: unknown;
|
|
11
|
+
remoteLoaderOptions?: PepAddonBlockLoaderRemoteLoaderOptions;
|
|
12
|
+
onHostEvents?: (event: any) => void;
|
|
13
|
+
onBlockLoad?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const PepAddonBlockLoader: React.FC<PepAddonBlockLoaderProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
export const PepAddonBlockLoader = ({ keyProp, addonId, remoteEntry, slugName, blockType, name, hostObject, remoteLoaderOptions, onHostEvents, onBlockLoad, ...rest }) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const el = ref.current;
|
|
7
|
+
if (!el)
|
|
8
|
+
return;
|
|
9
|
+
if (typeof addonId !== 'undefined')
|
|
10
|
+
el.addonId = addonId;
|
|
11
|
+
if (typeof remoteEntry !== 'undefined')
|
|
12
|
+
el.remoteEntry = remoteEntry;
|
|
13
|
+
if (typeof slugName !== 'undefined')
|
|
14
|
+
el.slugName = slugName;
|
|
15
|
+
if (typeof blockType !== 'undefined')
|
|
16
|
+
el.blockType = blockType;
|
|
17
|
+
if (typeof name !== 'undefined')
|
|
18
|
+
el.name = name;
|
|
19
|
+
if (typeof hostObject !== 'undefined')
|
|
20
|
+
el.hostObject = hostObject;
|
|
21
|
+
if (typeof remoteLoaderOptions !== 'undefined')
|
|
22
|
+
el.remoteLoaderOptions = remoteLoaderOptions;
|
|
23
|
+
}, [addonId, remoteEntry, slugName, blockType, name, hostObject, remoteLoaderOptions]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const el = ref.current;
|
|
26
|
+
if (!el)
|
|
27
|
+
return;
|
|
28
|
+
const handlers = [];
|
|
29
|
+
if (onHostEvents) {
|
|
30
|
+
handlers.push(['hostEvents', (e) => { var _a; return onHostEvents((_a = e.detail) !== null && _a !== void 0 ? _a : e); }]);
|
|
31
|
+
}
|
|
32
|
+
if (onBlockLoad) {
|
|
33
|
+
handlers.push(['blockLoad', () => onBlockLoad()]);
|
|
34
|
+
}
|
|
35
|
+
handlers.forEach(([n, h]) => el.addEventListener(n, h));
|
|
36
|
+
return () => handlers.forEach(([n, h]) => el.removeEventListener(n, h));
|
|
37
|
+
}, [onHostEvents, onBlockLoad]);
|
|
38
|
+
return _jsx("pep-addon-block-loader-element", { ref: ref, ...rest }, keyProp);
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=pep-addon-block-loader.js.map
|