@pepperi-addons/ngx-composite-lib-react 0.0.4 → 0.5.1
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/README.md +129 -0
- package/elements/971.js +1 -1
- package/elements/index.html +5 -5
- package/elements/main.js +1 -1
- package/elements/polyfills.js +1 -1
- package/elements/runtime.js +1 -1
- package/elements/styles.css +16 -1
- package/index.d.ts +16 -19
- package/index.js +16 -19
- package/package.json +24 -23
- package/pep-color-settings.d.ts +17 -4
- package/pep-color-settings.js +33 -2
- package/pep-data-view-builder.d.ts +28 -4
- package/pep-data-view-builder.js +41 -2
- package/pep-file-status-panel.d.ts +18 -4
- package/pep-file-status-panel.js +28 -2
- package/pep-flow-picker-button.d.ts +13 -4
- package/pep-flow-picker-button.js +29 -2
- package/pep-generic-fields-builder.d.ts +33 -0
- package/pep-generic-fields-builder.js +57 -0
- package/pep-generic-form.d.ts +52 -4
- package/pep-generic-form.js +46 -2
- package/pep-generic-list.d.ts +70 -4
- package/pep-generic-list.js +126 -2
- package/pep-group-buttons-settings.d.ts +25 -4
- package/pep-group-buttons-settings.js +72 -2
- package/pep-icon-picker.d.ts +18 -4
- package/pep-icon-picker.js +39 -2
- package/pep-manage-parameters.d.ts +31 -4
- package/pep-manage-parameters.js +39 -2
- package/pep-mapping-parameters.d.ts +17 -4
- package/pep-mapping-parameters.js +31 -2
- package/pep-menu-data-view.d.ts +18 -0
- package/pep-menu-data-view.js +36 -0
- package/pep-padding-settings.d.ts +12 -4
- package/pep-padding-settings.js +23 -2
- package/pep-rich-text.d.ts +47 -4
- package/pep-rich-text.js +76 -2
- package/pep-shadow-settings.d.ts +15 -4
- package/pep-shadow-settings.js +22 -2
- package/pep-show-if-badge.d.ts +10 -4
- package/pep-show-if-badge.js +16 -2
- package/components/PepGroupButtonsSettings.d.ts +0 -14
- package/components/PepGroupButtonsSettings.js +0 -19
- package/components/PepGroupButtonsSettingsReact.d.ts +0 -14
- package/components/PepGroupButtonsSettingsReact.js +0 -104
- package/elements/register.auto.d.ts +0 -1
- package/elements/register.auto.js +0 -1
- package/elements/register.d.ts +0 -1
- package/elements/register.js +0 -1
- package/elements/register.polyfills.js +0 -1
- package/elements/register.runtime.js +0 -1
- package/pep-field-container.d.ts +0 -4
- package/pep-field-container.js +0 -3
- package/pep-group-buttons-settings-react.d.ts +0 -14
- package/pep-group-buttons-settings-react.js +0 -62
- package/pep-layout-builder-editor.d.ts +0 -4
- package/pep-layout-builder-editor.js +0 -3
- package/pep-layout-builder.d.ts +0 -4
- package/pep-layout-builder.js +0 -3
- package/pep-layout.d.ts +0 -4
- package/pep-layout.js +0 -3
- package/utils/create-wrapper.d.ts +0 -7
- package/utils/create-wrapper.js +0 -46
package/index.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export * from './pep-flow-picker-button.js';
|
|
18
|
-
export { PepGroupButtonsSettingsReact } from './components/PepGroupButtonsSettingsReact.js';
|
|
19
|
-
export { PepGroupButtonsSettings as PepGroupButtonsSettingsWC } from './pep-group-buttons-settings.js';
|
|
1
|
+
export { PepColorSettings } from './pep-color-settings.js';
|
|
2
|
+
export { PepGroupButtonsSettings } from './pep-group-buttons-settings.js';
|
|
3
|
+
export { PepFlowPickerButton } from './pep-flow-picker-button.js';
|
|
4
|
+
export { PepIconPicker } from './pep-icon-picker.js';
|
|
5
|
+
export { PepPaddingSettings } from './pep-padding-settings.js';
|
|
6
|
+
export { PepShadowSettings } from './pep-shadow-settings.js';
|
|
7
|
+
export { PepRichText } from './pep-rich-text.js';
|
|
8
|
+
export { PepShowIfBadge } from './pep-show-if-badge.js';
|
|
9
|
+
export { PepGenericList } from './pep-generic-list.js';
|
|
10
|
+
export { PepFileStatusPanel } from './pep-file-status-panel.js';
|
|
11
|
+
export { PepGenericForm } from './pep-generic-form.js';
|
|
12
|
+
export { PepDataViewBuilder } from './pep-data-view-builder.js';
|
|
13
|
+
export { PepMenuDataView } from './pep-menu-data-view.js';
|
|
14
|
+
export { PepManageParameters } from './pep-manage-parameters.js';
|
|
15
|
+
export { PepMappingParameters } from './pep-mapping-parameters.js';
|
|
16
|
+
export { PepGenericFieldsBuilder } from './pep-generic-fields-builder.js';
|
package/index.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export * from './pep-flow-picker-button.js';
|
|
18
|
-
export { PepGroupButtonsSettingsReact } from './components/PepGroupButtonsSettingsReact.js';
|
|
19
|
-
export { PepGroupButtonsSettings as PepGroupButtonsSettingsWC } from './pep-group-buttons-settings.js';
|
|
1
|
+
export { PepColorSettings } from './pep-color-settings.js';
|
|
2
|
+
export { PepGroupButtonsSettings } from './pep-group-buttons-settings.js';
|
|
3
|
+
export { PepFlowPickerButton } from './pep-flow-picker-button.js';
|
|
4
|
+
export { PepIconPicker } from './pep-icon-picker.js';
|
|
5
|
+
export { PepPaddingSettings } from './pep-padding-settings.js';
|
|
6
|
+
export { PepShadowSettings } from './pep-shadow-settings.js';
|
|
7
|
+
export { PepRichText } from './pep-rich-text.js';
|
|
8
|
+
export { PepShowIfBadge } from './pep-show-if-badge.js';
|
|
9
|
+
export { PepGenericList } from './pep-generic-list.js';
|
|
10
|
+
export { PepFileStatusPanel } from './pep-file-status-panel.js';
|
|
11
|
+
export { PepGenericForm } from './pep-generic-form.js';
|
|
12
|
+
export { PepDataViewBuilder } from './pep-data-view-builder.js';
|
|
13
|
+
export { PepMenuDataView } from './pep-menu-data-view.js';
|
|
14
|
+
export { PepManageParameters } from './pep-manage-parameters.js';
|
|
15
|
+
export { PepMappingParameters } from './pep-mapping-parameters.js';
|
|
16
|
+
export { PepGenericFieldsBuilder } from './pep-generic-fields-builder.js';
|
|
20
17
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pepperi-addons/ngx-composite-lib-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React wrappers for
|
|
5
|
-
"
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "React wrappers for Pepperi ngx-composite-lib Angular Elements.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Pepperi",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://example.com/repo.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"pepperi",
|
|
13
|
+
"react",
|
|
14
|
+
"angular-elements",
|
|
15
|
+
"web-components",
|
|
16
|
+
"composite"
|
|
17
|
+
],
|
|
6
18
|
"main": "index.js",
|
|
7
19
|
"module": "index.js",
|
|
8
20
|
"types": "index.d.ts",
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=17",
|
|
23
|
+
"react-dom": ">=17"
|
|
24
|
+
},
|
|
9
25
|
"files": [
|
|
10
26
|
"*.js",
|
|
11
27
|
"*.d.ts",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"utils/*.js",
|
|
15
|
-
"utils/*.d.ts",
|
|
16
|
-
"elements/*",
|
|
17
|
-
"README.md"
|
|
28
|
+
"README.md",
|
|
29
|
+
"elements/*"
|
|
18
30
|
],
|
|
19
31
|
"exports": {
|
|
20
32
|
".": {
|
|
21
33
|
"types": "./index.d.ts",
|
|
22
34
|
"default": "./index.js"
|
|
23
35
|
},
|
|
24
|
-
"./components/PepGroupButtonsSettingsReact.js": "./components/PepGroupButtonsSettingsReact.js",
|
|
25
|
-
"./elements/register.js": "./elements/register.js",
|
|
26
|
-
"./elements/register.auto.js": "./elements/register.auto.js",
|
|
27
36
|
"./elements/styles.css": "./elements/styles.css",
|
|
28
|
-
"./elements/
|
|
29
|
-
"./elements/
|
|
30
|
-
|
|
31
|
-
"peerDependencies": {
|
|
32
|
-
"react": ">=17",
|
|
33
|
-
"react-dom": ">=17",
|
|
34
|
-
"@pepperi-addons/ngx-lib-react": ">=0.0.0"
|
|
35
|
-
},
|
|
36
|
-
"sideEffects": false,
|
|
37
|
-
"publishConfig": {
|
|
38
|
-
"access": "public"
|
|
37
|
+
"./elements/main.js": "./elements/main.js",
|
|
38
|
+
"./elements/runtime.js": "./elements/runtime.js",
|
|
39
|
+
"./elements/polyfills.js": "./elements/polyfills.js"
|
|
39
40
|
}
|
|
40
41
|
}
|
package/pep-color-settings.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface PepColorSettingsValue {
|
|
3
|
+
value?: string;
|
|
4
|
+
opacity?: number;
|
|
5
|
+
use?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface PepColorSettingsProps {
|
|
8
|
+
title?: string;
|
|
9
|
+
checkAAComplient?: boolean;
|
|
10
|
+
showAAComplient?: boolean;
|
|
11
|
+
titleSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | string;
|
|
12
|
+
color?: PepColorSettingsValue;
|
|
13
|
+
onColorChange?: (value: PepColorSettingsValue) => void;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export declare const PepColorSettings: React.FC<PepColorSettingsProps>;
|
package/pep-color-settings.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const PepColorSettings =
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
export const PepColorSettings = ({ title, checkAAComplient, showAAComplient, titleSize, color, onColorChange, className, style, }) => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
// Apply inputs as element properties (preferred for Angular Elements)
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const el = ref.current;
|
|
7
|
+
if (!el)
|
|
8
|
+
return;
|
|
9
|
+
if (title !== undefined)
|
|
10
|
+
el.title = title;
|
|
11
|
+
if (checkAAComplient !== undefined)
|
|
12
|
+
el.checkAAComplient = checkAAComplient;
|
|
13
|
+
if (showAAComplient !== undefined)
|
|
14
|
+
el.showAAComplient = showAAComplient;
|
|
15
|
+
if (titleSize !== undefined)
|
|
16
|
+
el.titleSize = titleSize;
|
|
17
|
+
if (color !== undefined)
|
|
18
|
+
el.color = color;
|
|
19
|
+
}, [title, checkAAComplient, showAAComplient, titleSize, color]);
|
|
20
|
+
// Wire outputs
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const el = ref.current;
|
|
23
|
+
if (!el)
|
|
24
|
+
return;
|
|
25
|
+
const handler = (e) => {
|
|
26
|
+
const ce = e;
|
|
27
|
+
onColorChange?.(ce.detail ?? el.color);
|
|
28
|
+
};
|
|
29
|
+
el.addEventListener('colorChange', handler);
|
|
30
|
+
return () => el.removeEventListener('colorChange', handler);
|
|
31
|
+
}, [onColorChange]);
|
|
32
|
+
return React.createElement('pep-color-settings-element', { ref, class: className, style });
|
|
33
|
+
};
|
|
3
34
|
//# sourceMappingURL=pep-color-settings.js.map
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IPepDraggableItem {
|
|
3
|
+
data: {
|
|
4
|
+
key: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
title: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface BaseDataView {
|
|
12
|
+
Type: string;
|
|
13
|
+
Fields?: any[];
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export declare type PepDataViewBuilderType = 'menu' | 'list' | 'card' | 'not-supported';
|
|
17
|
+
export interface PepDataViewBuilderProps {
|
|
18
|
+
builderTitle?: string;
|
|
19
|
+
builderTitleHint?: string;
|
|
20
|
+
showAddSeparator?: boolean;
|
|
21
|
+
itemKeyLabel?: string;
|
|
22
|
+
itemTitleLabel?: string;
|
|
23
|
+
availableFields?: IPepDraggableItem[];
|
|
24
|
+
dataView?: BaseDataView;
|
|
25
|
+
onDataViewChange?: (event: CustomEvent<BaseDataView>) => void;
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
export declare const PepDataViewBuilder: React.FC<PepDataViewBuilderProps>;
|
package/pep-data-view-builder.js
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const PepDataViewBuilder =
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
export const PepDataViewBuilder = ({ builderTitle = '', builderTitleHint = '', showAddSeparator = true, itemKeyLabel = '', itemTitleLabel = '', availableFields = [], dataView, onDataViewChange, children }) => {
|
|
3
|
+
const elementRef = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const element = elementRef.current;
|
|
6
|
+
if (!element)
|
|
7
|
+
return;
|
|
8
|
+
// Use setTimeout to ensure the element is fully initialized
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
// Reflect props to custom element
|
|
11
|
+
element.builderTitle = builderTitle;
|
|
12
|
+
element.builderTitleHint = builderTitleHint;
|
|
13
|
+
element.showAddSeparator = showAddSeparator;
|
|
14
|
+
element.itemKeyLabel = itemKeyLabel;
|
|
15
|
+
element.itemTitleLabel = itemTitleLabel;
|
|
16
|
+
// Set availableFields first, then dataView to trigger proper initialization
|
|
17
|
+
if (availableFields !== undefined) {
|
|
18
|
+
element.availableFields = availableFields;
|
|
19
|
+
}
|
|
20
|
+
if (dataView !== undefined) {
|
|
21
|
+
element.dataView = dataView;
|
|
22
|
+
}
|
|
23
|
+
}, 0);
|
|
24
|
+
}, [builderTitle, builderTitleHint, showAddSeparator, itemKeyLabel, itemTitleLabel, availableFields, dataView]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const element = elementRef.current;
|
|
27
|
+
if (!element)
|
|
28
|
+
return;
|
|
29
|
+
const handleDataViewChange = (event) => {
|
|
30
|
+
if (onDataViewChange)
|
|
31
|
+
onDataViewChange(event);
|
|
32
|
+
};
|
|
33
|
+
// Add event listeners
|
|
34
|
+
element.addEventListener('dataViewChange', handleDataViewChange);
|
|
35
|
+
// Cleanup
|
|
36
|
+
return () => {
|
|
37
|
+
element.removeEventListener('dataViewChange', handleDataViewChange);
|
|
38
|
+
};
|
|
39
|
+
}, [onDataViewChange]);
|
|
40
|
+
return React.createElement('pep-data-view-builder-element', { ref: elementRef }, children);
|
|
41
|
+
};
|
|
3
42
|
//# sourceMappingURL=pep-data-view-builder.js.map
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface PepSnackBarData {
|
|
3
|
+
title?: string;
|
|
4
|
+
content?: Array<{
|
|
5
|
+
key?: number;
|
|
6
|
+
name?: string;
|
|
7
|
+
status?: string;
|
|
8
|
+
statusMessage?: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface PepFileStatusPanelProps {
|
|
12
|
+
panelData?: PepSnackBarData;
|
|
13
|
+
openAsSnackBar?: boolean;
|
|
14
|
+
closeClick?: () => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
export declare const PepFileStatusPanel: React.FC<PepFileStatusPanelProps>;
|
package/pep-file-status-panel.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const PepFileStatusPanel =
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
export const PepFileStatusPanel = (props) => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const el = ref.current;
|
|
6
|
+
if (!el)
|
|
7
|
+
return;
|
|
8
|
+
if (props.panelData !== undefined)
|
|
9
|
+
el.panelData = props.panelData;
|
|
10
|
+
if (props.openAsSnackBar !== undefined)
|
|
11
|
+
el.openAsSnackBar = props.openAsSnackBar;
|
|
12
|
+
}, [props.panelData, props.openAsSnackBar]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const el = ref.current;
|
|
15
|
+
if (!el)
|
|
16
|
+
return;
|
|
17
|
+
const bind = (name, cb) => {
|
|
18
|
+
if (!cb)
|
|
19
|
+
return () => { };
|
|
20
|
+
const handler = () => cb();
|
|
21
|
+
el.addEventListener(name, handler);
|
|
22
|
+
return () => el.removeEventListener(name, handler);
|
|
23
|
+
};
|
|
24
|
+
const unsubs = [bind('closeClick', props.closeClick)];
|
|
25
|
+
return () => { unsubs.forEach((u) => u()); };
|
|
26
|
+
}, [props.closeClick]);
|
|
27
|
+
return React.createElement('pep-file-status-panel-element', { ref, class: props.className, style: props.style });
|
|
28
|
+
};
|
|
3
29
|
//# sourceMappingURL=pep-file-status-panel.js.map
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type PepStyleType = 'weak' | 'regular' | 'strong' | string;
|
|
3
|
+
export declare type PepDialogSizeType = 'regular' | 'full-screen' | 'medium' | 'large' | string;
|
|
4
|
+
export interface PepFlowPickerButtonProps {
|
|
5
|
+
flowHostObject?: any;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
styleType?: PepStyleType;
|
|
8
|
+
flowDlgSize?: PepDialogSizeType;
|
|
9
|
+
onFlowChange?: (data: any) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
export declare const PepFlowPickerButton: React.FC<PepFlowPickerButtonProps>;
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const PepFlowPickerButton =
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
export const PepFlowPickerButton = ({ flowHostObject, disabled, styleType, flowDlgSize, onFlowChange, className, style, }) => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const el = ref.current;
|
|
6
|
+
if (!el)
|
|
7
|
+
return;
|
|
8
|
+
if (flowHostObject !== undefined)
|
|
9
|
+
el.flowHostObject = flowHostObject;
|
|
10
|
+
if (disabled !== undefined)
|
|
11
|
+
el.disabled = disabled;
|
|
12
|
+
if (styleType !== undefined)
|
|
13
|
+
el.styleType = styleType;
|
|
14
|
+
if (flowDlgSize !== undefined)
|
|
15
|
+
el.flowDlgSize = flowDlgSize;
|
|
16
|
+
}, [flowHostObject, disabled, styleType, flowDlgSize]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const el = ref.current;
|
|
19
|
+
if (!el)
|
|
20
|
+
return;
|
|
21
|
+
const handler = (e) => {
|
|
22
|
+
const ce = e;
|
|
23
|
+
onFlowChange?.(ce.detail);
|
|
24
|
+
};
|
|
25
|
+
el.addEventListener('flowChange', handler);
|
|
26
|
+
return () => el.removeEventListener('flowChange', handler);
|
|
27
|
+
}, [onFlowChange]);
|
|
28
|
+
return React.createElement('pep-flow-picker-button-element', { ref, class: className, style });
|
|
29
|
+
};
|
|
3
30
|
//# sourceMappingURL=pep-flow-picker-button.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IPepDraggableItemData {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface IPepDraggableItem {
|
|
6
|
+
title: string;
|
|
7
|
+
data: IPepDraggableItemData;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface IPepGenericField {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
draggableItemData: IPepDraggableItemData;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export interface IPepGenericFieldAddedEvent {
|
|
17
|
+
field: IPepGenericField;
|
|
18
|
+
index: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PepGenericFieldsBuilderProps {
|
|
21
|
+
builderTitle?: string;
|
|
22
|
+
builderTitleHint?: string;
|
|
23
|
+
showAddSeparator?: boolean;
|
|
24
|
+
itemKeyLabel?: string;
|
|
25
|
+
itemTitleLabel?: string;
|
|
26
|
+
availableFields?: IPepDraggableItem[];
|
|
27
|
+
fields?: IPepGenericField[];
|
|
28
|
+
onFieldsChange?: (fields: IPepGenericField[]) => void;
|
|
29
|
+
onFieldAdd?: (event: IPepGenericFieldAddedEvent) => void;
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: React.CSSProperties;
|
|
32
|
+
}
|
|
33
|
+
export declare const PepGenericFieldsBuilder: React.FC<PepGenericFieldsBuilderProps>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
export const PepGenericFieldsBuilder = ({ builderTitle, builderTitleHint, showAddSeparator, itemKeyLabel, itemTitleLabel, availableFields, fields, onFieldsChange, onFieldAdd, className, style, }) => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
// Apply inputs as element properties
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const el = ref.current;
|
|
7
|
+
if (!el)
|
|
8
|
+
return;
|
|
9
|
+
// Wait for custom element to be defined and connected
|
|
10
|
+
const setPropertiesWhenReady = async () => {
|
|
11
|
+
await customElements.whenDefined('pep-generic-fields-builder-element');
|
|
12
|
+
// Wait for multiple animation frames to ensure Angular is fully initialized
|
|
13
|
+
await new Promise(resolve => requestAnimationFrame(() => {
|
|
14
|
+
requestAnimationFrame(() => {
|
|
15
|
+
requestAnimationFrame(resolve);
|
|
16
|
+
});
|
|
17
|
+
}));
|
|
18
|
+
if (builderTitle !== undefined)
|
|
19
|
+
el.builderTitle = builderTitle;
|
|
20
|
+
if (builderTitleHint !== undefined)
|
|
21
|
+
el.builderTitleHint = builderTitleHint;
|
|
22
|
+
if (showAddSeparator !== undefined)
|
|
23
|
+
el.showAddSeparator = showAddSeparator;
|
|
24
|
+
if (itemKeyLabel !== undefined)
|
|
25
|
+
el.itemKeyLabel = itemKeyLabel;
|
|
26
|
+
if (itemTitleLabel !== undefined)
|
|
27
|
+
el.itemTitleLabel = itemTitleLabel;
|
|
28
|
+
if (availableFields !== undefined)
|
|
29
|
+
el.availableFields = availableFields;
|
|
30
|
+
if (fields !== undefined)
|
|
31
|
+
el.fields = fields;
|
|
32
|
+
};
|
|
33
|
+
setPropertiesWhenReady();
|
|
34
|
+
}, [builderTitle, builderTitleHint, showAddSeparator, itemKeyLabel, itemTitleLabel, availableFields, fields]);
|
|
35
|
+
// Wire outputs
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const el = ref.current;
|
|
38
|
+
if (!el)
|
|
39
|
+
return;
|
|
40
|
+
const fieldsChangeHandler = (e) => {
|
|
41
|
+
const ce = e;
|
|
42
|
+
onFieldsChange?.(ce.detail ?? ref.current?.fields ?? []);
|
|
43
|
+
};
|
|
44
|
+
const fieldAddHandler = (e) => {
|
|
45
|
+
const ce = e;
|
|
46
|
+
onFieldAdd?.(ce.detail);
|
|
47
|
+
};
|
|
48
|
+
el.addEventListener('fieldsChange', fieldsChangeHandler);
|
|
49
|
+
el.addEventListener('fieldAdd', fieldAddHandler);
|
|
50
|
+
return () => {
|
|
51
|
+
el.removeEventListener('fieldsChange', fieldsChangeHandler);
|
|
52
|
+
el.removeEventListener('fieldAdd', fieldAddHandler);
|
|
53
|
+
};
|
|
54
|
+
}, [onFieldsChange, onFieldAdd]);
|
|
55
|
+
return React.createElement('pep-generic-fields-builder-element', { ref, class: className, style });
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=pep-generic-fields-builder.js.map
|
package/pep-generic-form.d.ts
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IPepGenericFormDataView {
|
|
3
|
+
UID?: string;
|
|
4
|
+
Fields: IPepGenericFormDataViewField[];
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export interface IPepGenericFormDataViewField {
|
|
8
|
+
FieldID: string;
|
|
9
|
+
OptionalValues: Array<{
|
|
10
|
+
Key: string;
|
|
11
|
+
Value: string;
|
|
12
|
+
}>;
|
|
13
|
+
AdditionalProps: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
export interface IPepGenericFormValueChange {
|
|
19
|
+
UID: string;
|
|
20
|
+
ApiName: string;
|
|
21
|
+
Value: any;
|
|
22
|
+
}
|
|
23
|
+
export interface IPepGenericFormFieldUpdate {
|
|
24
|
+
FieldId: string;
|
|
25
|
+
Params: IPepGenericFormDataParams;
|
|
26
|
+
}
|
|
27
|
+
export interface IPepGenericFormDataParams {
|
|
28
|
+
Value?: any;
|
|
29
|
+
Visible?: boolean;
|
|
30
|
+
Enabled?: boolean;
|
|
31
|
+
BackgroundColor?: string;
|
|
32
|
+
TextColor?: string;
|
|
33
|
+
Highlighted?: boolean;
|
|
34
|
+
OptionalValues?: Array<{
|
|
35
|
+
Key: string;
|
|
36
|
+
Value: string;
|
|
37
|
+
}>;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
export interface PepGenericFormProps {
|
|
41
|
+
dataSource?: any;
|
|
42
|
+
dataView?: IPepGenericFormDataView;
|
|
43
|
+
isLocked?: boolean;
|
|
44
|
+
inline?: boolean;
|
|
45
|
+
showTopBar?: boolean;
|
|
46
|
+
addPadding?: boolean;
|
|
47
|
+
onValueChange?: (event: CustomEvent<IPepGenericFormValueChange>) => void;
|
|
48
|
+
onFieldClick?: (event: CustomEvent<IPepGenericFormValueChange>) => void;
|
|
49
|
+
onFormValidationChange?: (event: CustomEvent<boolean>) => void;
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
export declare const PepGenericForm: React.FC<PepGenericFormProps>;
|
package/pep-generic-form.js
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const PepGenericForm =
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
export const PepGenericForm = ({ dataSource, dataView, isLocked = false, inline = false, showTopBar = false, addPadding = false, onValueChange, onFieldClick, onFormValidationChange, children }) => {
|
|
3
|
+
const elementRef = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const element = elementRef.current;
|
|
6
|
+
if (!element)
|
|
7
|
+
return;
|
|
8
|
+
// Reflect props to custom element
|
|
9
|
+
if (dataSource !== undefined)
|
|
10
|
+
element.dataSource = dataSource;
|
|
11
|
+
if (dataView !== undefined)
|
|
12
|
+
element.dataView = dataView;
|
|
13
|
+
element.isLocked = isLocked;
|
|
14
|
+
element.inline = inline;
|
|
15
|
+
element.showTopBar = showTopBar;
|
|
16
|
+
element.addPadding = addPadding;
|
|
17
|
+
}, [dataSource, dataView, isLocked, inline, showTopBar, addPadding]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const element = elementRef.current;
|
|
20
|
+
if (!element)
|
|
21
|
+
return;
|
|
22
|
+
const handleValueChange = (event) => {
|
|
23
|
+
if (onValueChange)
|
|
24
|
+
onValueChange(event);
|
|
25
|
+
};
|
|
26
|
+
const handleFieldClick = (event) => {
|
|
27
|
+
if (onFieldClick)
|
|
28
|
+
onFieldClick(event);
|
|
29
|
+
};
|
|
30
|
+
const handleFormValidationChange = (event) => {
|
|
31
|
+
if (onFormValidationChange)
|
|
32
|
+
onFormValidationChange(event);
|
|
33
|
+
};
|
|
34
|
+
// Add event listeners
|
|
35
|
+
element.addEventListener('valueChange', handleValueChange);
|
|
36
|
+
element.addEventListener('fieldClick', handleFieldClick);
|
|
37
|
+
element.addEventListener('formValidationChange', handleFormValidationChange);
|
|
38
|
+
// Cleanup
|
|
39
|
+
return () => {
|
|
40
|
+
element.removeEventListener('valueChange', handleValueChange);
|
|
41
|
+
element.removeEventListener('fieldClick', handleFieldClick);
|
|
42
|
+
element.removeEventListener('formValidationChange', handleFormValidationChange);
|
|
43
|
+
};
|
|
44
|
+
}, [onValueChange, onFieldClick, onFormValidationChange]);
|
|
45
|
+
return React.createElement('pep-generic-form-element', { ref: elementRef }, children);
|
|
46
|
+
};
|
|
3
47
|
//# sourceMappingURL=pep-generic-form.js.map
|