@pepperi-addons/ngx-composite-lib-react 0.0.3 → 0.0.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface PepGroupButtonsSettingsReactProps {
|
|
3
3
|
pepResetConfigurationField?: string;
|
|
4
4
|
hideReset?: boolean;
|
|
@@ -11,4 +11,4 @@ export interface PepGroupButtonsSettingsReactProps {
|
|
|
11
11
|
btnsArray?: any[];
|
|
12
12
|
onBtnKeyChange?: (e: any) => void;
|
|
13
13
|
}
|
|
14
|
-
export declare function PepGroupButtonsSettingsReact(props: PepGroupButtonsSettingsReactProps):
|
|
14
|
+
export declare function PepGroupButtonsSettingsReact(props: PepGroupButtonsSettingsReactProps): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { PepGroupButtons } from '@pepperi-addons/ngx-lib-react';
|
|
4
2
|
export function PepGroupButtonsSettingsReact(props) {
|
|
5
3
|
const { pepResetConfigurationField, hideReset, resetHostEvents, groupType, subHeader, btnKey, useNone, excludeKeys, btnsArray, onBtnKeyChange, } = props;
|
|
6
4
|
const onReset = React.useCallback(() => {
|
|
@@ -12,7 +10,7 @@ export function PepGroupButtonsSettingsReact(props) {
|
|
|
12
10
|
});
|
|
13
11
|
}
|
|
14
12
|
}, [pepResetConfigurationField, resetHostEvents]);
|
|
15
|
-
// Build items for the
|
|
13
|
+
// Build items for the settings element (we will pass as custom group)
|
|
16
14
|
const computedItems = React.useMemo(() => {
|
|
17
15
|
const arr = [];
|
|
18
16
|
switch (groupType) {
|
|
@@ -58,6 +56,49 @@ export function PepGroupButtonsSettingsReact(props) {
|
|
|
58
56
|
}
|
|
59
57
|
return filtered;
|
|
60
58
|
}, [groupType, btnsArray, excludeKeys, useNone]);
|
|
61
|
-
|
|
59
|
+
const hostRef = React.useRef(null);
|
|
60
|
+
const elRef = React.useRef(null);
|
|
61
|
+
React.useLayoutEffect(() => {
|
|
62
|
+
const host = hostRef.current;
|
|
63
|
+
if (!host)
|
|
64
|
+
return () => { };
|
|
65
|
+
let el = elRef.current;
|
|
66
|
+
if (!el) {
|
|
67
|
+
el = document.createElement('pep-group-buttons-settings');
|
|
68
|
+
elRef.current = el;
|
|
69
|
+
}
|
|
70
|
+
const listeners = [];
|
|
71
|
+
// Set properties BEFORE connecting to the DOM
|
|
72
|
+
const propsToSet = {
|
|
73
|
+
pepResetConfigurationField,
|
|
74
|
+
hideReset,
|
|
75
|
+
resetHostEvents,
|
|
76
|
+
groupType: 'custom',
|
|
77
|
+
subHeader,
|
|
78
|
+
btnKey,
|
|
79
|
+
useNone,
|
|
80
|
+
excludeKeys,
|
|
81
|
+
btnsArray: computedItems,
|
|
82
|
+
};
|
|
83
|
+
Object.entries(propsToSet).forEach(([k, v]) => {
|
|
84
|
+
if (typeof v === 'undefined')
|
|
85
|
+
return;
|
|
86
|
+
try {
|
|
87
|
+
el[k] = v;
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
});
|
|
91
|
+
if (typeof onBtnKeyChange === 'function') {
|
|
92
|
+
const handler = (e) => onBtnKeyChange(e);
|
|
93
|
+
el.addEventListener('btnkeyChange', handler);
|
|
94
|
+
listeners.push(['btnkeyChange', handler]);
|
|
95
|
+
}
|
|
96
|
+
if (!el.isConnected)
|
|
97
|
+
host.appendChild(el);
|
|
98
|
+
return () => {
|
|
99
|
+
listeners.forEach(([n, h]) => el.removeEventListener(n, h));
|
|
100
|
+
};
|
|
101
|
+
}, [pepResetConfigurationField, hideReset, resetHostEvents, subHeader, btnKey, useNone, excludeKeys, computedItems, onBtnKeyChange]);
|
|
102
|
+
return React.createElement('div', { ref: hostRef });
|
|
62
103
|
}
|
|
63
104
|
//# sourceMappingURL=PepGroupButtonsSettingsReact.js.map
|
package/package.json
CHANGED