@pepperi-addons/ngx-composite-lib-react 0.5.8 → 0.5.10
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-layout-builder.d.ts +1 -0
- package/pep-layout-builder.js +4 -1
- package/pep-layout.d.ts +50 -0
- package/pep-layout.js +70 -0
package/index.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ export { PepMappingParameters } from './pep-mapping-parameters.js';
|
|
|
16
16
|
export { PepGenericFieldsBuilder } from './pep-generic-fields-builder.js';
|
|
17
17
|
export { PepAssetPickerButton } from './pep-asset-picker-button.js';
|
|
18
18
|
export { PepLayoutBuilder } from './pep-layout-builder.js';
|
|
19
|
+
export { PepLayout } from './pep-layout.js';
|
package/index.js
CHANGED
|
@@ -16,4 +16,5 @@ export { PepMappingParameters } from './pep-mapping-parameters.js';
|
|
|
16
16
|
export { PepGenericFieldsBuilder } from './pep-generic-fields-builder.js';
|
|
17
17
|
export { PepAssetPickerButton } from './pep-asset-picker-button.js';
|
|
18
18
|
export { PepLayoutBuilder } from './pep-layout-builder.js';
|
|
19
|
+
export { PepLayout } from './pep-layout.js';
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
package/pep-layout-builder.d.ts
CHANGED
package/pep-layout-builder.js
CHANGED
|
@@ -68,7 +68,7 @@ export class PepLayoutBuilder extends React.Component {
|
|
|
68
68
|
this.unsubs = [];
|
|
69
69
|
}
|
|
70
70
|
render() {
|
|
71
|
-
const { layoutEditorTopContent, headerEndContent, blockEditorContent, layoutContent, className, style, } = this.props;
|
|
71
|
+
const { layoutEditorTopContent, headerEndContent, blockEditorContent, layoutContent, layoutSlot, className, style, } = this.props;
|
|
72
72
|
const children = [];
|
|
73
73
|
if (layoutEditorTopContent) {
|
|
74
74
|
children.push(React.createElement('div', { ['layout-editor-top-content']: '' }, layoutEditorTopContent));
|
|
@@ -82,6 +82,9 @@ export class PepLayoutBuilder extends React.Component {
|
|
|
82
82
|
if (layoutContent) {
|
|
83
83
|
children.push(React.createElement('div', { ['layout-content']: '' }, layoutContent));
|
|
84
84
|
}
|
|
85
|
+
if (layoutSlot) {
|
|
86
|
+
children.push(React.createElement('div', { key: 'layout-content', 'layout-content': '' }, layoutSlot));
|
|
87
|
+
}
|
|
85
88
|
return React.createElement('pep-layout-builder-element', { ref: this.elementRef, class: className, style }, children.length > 0 ? children : undefined);
|
|
86
89
|
}
|
|
87
90
|
}
|
package/pep-layout.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type PepLayoutSizeType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
|
+
export interface PepLayoutSection {
|
|
4
|
+
Key: string;
|
|
5
|
+
Name?: string;
|
|
6
|
+
Split?: string;
|
|
7
|
+
Height?: number;
|
|
8
|
+
CollapseOnTablet?: boolean;
|
|
9
|
+
FillHeight?: boolean;
|
|
10
|
+
Hide?: unknown[];
|
|
11
|
+
Columns: Array<{
|
|
12
|
+
BlockContainer?: {
|
|
13
|
+
BlockKey: string;
|
|
14
|
+
Hide?: unknown[];
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export interface PepLayoutView {
|
|
19
|
+
Layout: {
|
|
20
|
+
MaxWidth?: number;
|
|
21
|
+
VerticalSpacing?: PepLayoutSizeType;
|
|
22
|
+
HorizontalSpacing?: PepLayoutSizeType;
|
|
23
|
+
SectionsGap?: PepLayoutSizeType;
|
|
24
|
+
ColumnsGap?: PepLayoutSizeType;
|
|
25
|
+
Sections: PepLayoutSection[];
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface PepLayoutProps {
|
|
29
|
+
editorMode?: boolean;
|
|
30
|
+
layoutView?: PepLayoutView;
|
|
31
|
+
renderSkeleton?: boolean;
|
|
32
|
+
showSkeleton?: boolean;
|
|
33
|
+
onLayoutViewChange?: (layoutView: PepLayoutView) => void;
|
|
34
|
+
onScreenTypeChange?: (screenType: string) => void;
|
|
35
|
+
blockTemplate?: React.ReactNode;
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
}
|
|
40
|
+
export declare class PepLayout extends React.Component<PepLayoutProps> {
|
|
41
|
+
private readonly elementRef;
|
|
42
|
+
private unsubs;
|
|
43
|
+
componentDidMount(): void;
|
|
44
|
+
componentDidUpdate(prevProps: PepLayoutProps): void;
|
|
45
|
+
componentWillUnmount(): void;
|
|
46
|
+
private applyPropsToElement;
|
|
47
|
+
private bindEvents;
|
|
48
|
+
private unbindEvents;
|
|
49
|
+
render(): React.ReactNode;
|
|
50
|
+
}
|
package/pep-layout.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export class PepLayout extends React.Component {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.elementRef = React.createRef();
|
|
6
|
+
this.unsubs = [];
|
|
7
|
+
}
|
|
8
|
+
componentDidMount() {
|
|
9
|
+
this.applyPropsToElement();
|
|
10
|
+
this.bindEvents();
|
|
11
|
+
}
|
|
12
|
+
componentDidUpdate(prevProps) {
|
|
13
|
+
this.applyPropsToElement();
|
|
14
|
+
const handlersChanged = prevProps.onLayoutViewChange !== this.props.onLayoutViewChange ||
|
|
15
|
+
prevProps.onScreenTypeChange !== this.props.onScreenTypeChange;
|
|
16
|
+
if (handlersChanged) {
|
|
17
|
+
this.unbindEvents();
|
|
18
|
+
this.bindEvents();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
componentWillUnmount() {
|
|
22
|
+
this.unbindEvents();
|
|
23
|
+
}
|
|
24
|
+
applyPropsToElement() {
|
|
25
|
+
const el = this.elementRef.current;
|
|
26
|
+
if (!el)
|
|
27
|
+
return;
|
|
28
|
+
const { editorMode, layoutView, renderSkeleton, showSkeleton, } = this.props;
|
|
29
|
+
if (editorMode !== undefined)
|
|
30
|
+
el.editorMode = editorMode;
|
|
31
|
+
if (layoutView !== undefined)
|
|
32
|
+
el.layoutView = layoutView;
|
|
33
|
+
if (renderSkeleton !== undefined)
|
|
34
|
+
el.renderSkeleton = renderSkeleton;
|
|
35
|
+
if (showSkeleton !== undefined)
|
|
36
|
+
el.showSkeleton = showSkeleton;
|
|
37
|
+
}
|
|
38
|
+
bindEvents() {
|
|
39
|
+
const el = this.elementRef.current;
|
|
40
|
+
if (!el)
|
|
41
|
+
return;
|
|
42
|
+
const bind = (name, cb) => {
|
|
43
|
+
if (!cb)
|
|
44
|
+
return () => { };
|
|
45
|
+
const handler = (e) => cb(e.detail);
|
|
46
|
+
el.addEventListener(name, handler);
|
|
47
|
+
return () => el.removeEventListener(name, handler);
|
|
48
|
+
};
|
|
49
|
+
this.unsubs = [
|
|
50
|
+
bind('layoutViewChange', this.props.onLayoutViewChange),
|
|
51
|
+
bind('screenTypeChange', this.props.onScreenTypeChange),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
unbindEvents() {
|
|
55
|
+
this.unsubs.forEach((u) => u());
|
|
56
|
+
this.unsubs = [];
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
const { blockTemplate, children, className, style } = this.props;
|
|
60
|
+
const childElements = [];
|
|
61
|
+
if (blockTemplate) {
|
|
62
|
+
childElements.push(React.createElement('div', { key: 'block-template', slot: 'block-template' }, blockTemplate));
|
|
63
|
+
}
|
|
64
|
+
if (children) {
|
|
65
|
+
childElements.push(children);
|
|
66
|
+
}
|
|
67
|
+
return React.createElement('pep-layout', { ref: this.elementRef, class: className, style }, childElements.length > 0 ? childElements : undefined);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=pep-layout.js.map
|