@pepperi-addons/ngx-lib-react 0.5.2 → 0.5.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.
package/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export { PepPageLayout } from './pep-page-layout.js';
26
26
  export { PepCarousel } from './pep-carousel.js';
27
27
  export { PepIcon } from './pep-icon.js';
28
28
  export { PepAddress } from './pep-address.js';
29
+ export { PepTopBar } from './pep-top-bar.js';
29
30
  export * from './pep-color-picker.js';
31
+ export { PepRichHtmlTextarea } from './pep-rich-html-textarea.js';
30
32
  export * from './services.js';
31
- export * from './http-helpers.js';
package/index.js CHANGED
@@ -26,9 +26,9 @@ export { PepPageLayout } from './pep-page-layout.js';
26
26
  export { PepCarousel } from './pep-carousel.js';
27
27
  export { PepIcon } from './pep-icon.js';
28
28
  export { PepAddress } from './pep-address.js';
29
+ export { PepTopBar } from './pep-top-bar.js';
29
30
  export * from './pep-color-picker.js';
30
- // Export all services
31
+ export { PepRichHtmlTextarea } from './pep-rich-html-textarea.js';
32
+ // Export all service helpers (bridge-based access to Angular services)
31
33
  export * from './services.js';
32
- // Export HTTP helper functions
33
- export * from './http-helpers.js';
34
34
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pepperi-addons/ngx-lib-react",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Thin React wrappers for Pepperi Angular Elements (Web Components) to improve DX in React.",
5
5
  "license": "MIT",
6
6
  "author": "Pepperi",
@@ -0,0 +1,42 @@
1
+ /// <reference types="react" />
2
+ export interface PepRichHtmlTextareaToolbarOptions {
3
+ font?: unknown;
4
+ size?: unknown;
5
+ header?: unknown;
6
+ bold?: unknown;
7
+ italic?: unknown;
8
+ underline?: unknown;
9
+ strike?: unknown;
10
+ link?: unknown;
11
+ image?: unknown;
12
+ ordered?: unknown;
13
+ bullet?: unknown;
14
+ color?: unknown;
15
+ background?: unknown;
16
+ align?: unknown;
17
+ }
18
+ export interface PepRichHtmlTextareaProps extends React.HTMLAttributes<HTMLElement> {
19
+ keyProp?: string;
20
+ value?: string;
21
+ label?: string;
22
+ mandatory?: boolean;
23
+ disabled?: boolean;
24
+ readonly?: boolean;
25
+ maxFieldCharacters?: number;
26
+ xAlignment?: string;
27
+ sanitize?: boolean;
28
+ rowSpan?: number;
29
+ visible?: boolean;
30
+ form?: unknown;
31
+ isActive?: boolean;
32
+ showTitle?: boolean;
33
+ renderTitle?: boolean;
34
+ renderEnlargeButton?: boolean;
35
+ layoutType?: string;
36
+ inlineMode?: boolean;
37
+ toolbarOptions?: PepRichHtmlTextareaToolbarOptions;
38
+ onValueChange?: (value: string) => void;
39
+ onEditorCreated?: (editor: unknown) => void;
40
+ onValidationChange?: (isValid: boolean) => void;
41
+ }
42
+ export declare const PepRichHtmlTextarea: React.FC<PepRichHtmlTextareaProps>;
@@ -0,0 +1,128 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ export const PepRichHtmlTextarea = ({ keyProp, value, label, mandatory, disabled, readonly, maxFieldCharacters, xAlignment, sanitize, rowSpan, visible, form, isActive, showTitle, renderTitle, renderEnlargeButton, layoutType, inlineMode, toolbarOptions, onValueChange, onEditorCreated, onValidationChange, className, ...rest }) => {
4
+ const elementRef = useRef(null);
5
+ useEffect(() => {
6
+ const element = elementRef.current;
7
+ if (!element) {
8
+ return;
9
+ }
10
+ if (typeof value !== 'undefined') {
11
+ element.value = value;
12
+ }
13
+ if (typeof label !== 'undefined') {
14
+ element.label = label;
15
+ }
16
+ if (typeof mandatory !== 'undefined') {
17
+ element.mandatory = mandatory;
18
+ }
19
+ if (typeof disabled !== 'undefined') {
20
+ element.disabled = disabled;
21
+ }
22
+ if (typeof readonly !== 'undefined') {
23
+ element.readonly = readonly;
24
+ }
25
+ if (typeof maxFieldCharacters !== 'undefined') {
26
+ element.maxFieldCharacters = maxFieldCharacters;
27
+ }
28
+ if (typeof xAlignment !== 'undefined') {
29
+ element.xAlignment = xAlignment;
30
+ }
31
+ if (typeof sanitize !== 'undefined') {
32
+ element.sanitize = sanitize;
33
+ }
34
+ if (typeof rowSpan !== 'undefined') {
35
+ element.rowSpan = rowSpan;
36
+ }
37
+ if (typeof visible !== 'undefined') {
38
+ element.visible = visible;
39
+ }
40
+ if (typeof form !== 'undefined') {
41
+ element.form = form;
42
+ }
43
+ if (typeof isActive !== 'undefined') {
44
+ element.isActive = isActive;
45
+ }
46
+ if (typeof showTitle !== 'undefined') {
47
+ element.showTitle = showTitle;
48
+ }
49
+ if (typeof renderTitle !== 'undefined') {
50
+ element.renderTitle = renderTitle;
51
+ }
52
+ if (typeof renderEnlargeButton !== 'undefined') {
53
+ element.renderEnlargeButton = renderEnlargeButton;
54
+ }
55
+ if (typeof layoutType !== 'undefined') {
56
+ element.layoutType = layoutType;
57
+ }
58
+ if (typeof inlineMode !== 'undefined') {
59
+ element.inlineMode = inlineMode;
60
+ }
61
+ if (typeof toolbarOptions !== 'undefined') {
62
+ element.toolbarOptions = toolbarOptions;
63
+ }
64
+ }, [
65
+ value,
66
+ label,
67
+ mandatory,
68
+ disabled,
69
+ readonly,
70
+ maxFieldCharacters,
71
+ xAlignment,
72
+ sanitize,
73
+ rowSpan,
74
+ visible,
75
+ form,
76
+ isActive,
77
+ showTitle,
78
+ renderTitle,
79
+ renderEnlargeButton,
80
+ layoutType,
81
+ inlineMode,
82
+ toolbarOptions,
83
+ ]);
84
+ useEffect(() => {
85
+ const element = elementRef.current;
86
+ if (!element) {
87
+ return;
88
+ }
89
+ const handlers = [];
90
+ if (onValueChange) {
91
+ handlers.push([
92
+ 'valueChange',
93
+ (event) => {
94
+ var _a, _b, _c;
95
+ const customEvent = event;
96
+ const nextValue = (_c = (_a = customEvent.detail) !== null && _a !== void 0 ? _a : (_b = event.target) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '';
97
+ onValueChange(nextValue);
98
+ },
99
+ ]);
100
+ }
101
+ if (onEditorCreated) {
102
+ handlers.push([
103
+ 'editorCreated',
104
+ (event) => {
105
+ const customEvent = event;
106
+ onEditorCreated(customEvent.detail);
107
+ },
108
+ ]);
109
+ }
110
+ if (onValidationChange) {
111
+ handlers.push([
112
+ 'validationChange',
113
+ (event) => {
114
+ var _a, _b;
115
+ const customEvent = event;
116
+ const isValid = (_a = customEvent.detail) !== null && _a !== void 0 ? _a : !!((_b = event.target) === null || _b === void 0 ? void 0 : _b.value);
117
+ onValidationChange(isValid);
118
+ },
119
+ ]);
120
+ }
121
+ handlers.forEach(([name, handler]) => element.addEventListener(name, handler));
122
+ return () => {
123
+ handlers.forEach(([name, handler]) => element.removeEventListener(name, handler));
124
+ };
125
+ }, [onValueChange, onEditorCreated, onValidationChange]);
126
+ return (_jsx("pep-rich-html-textarea-element", { ref: elementRef, className: className, value: value, label: label, ...rest }, keyProp));
127
+ };
128
+ //# sourceMappingURL=pep-rich-html-textarea.js.map
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ export declare type PepFooterStateType = 'visible' | 'hidden';
3
+ export interface PepFooterStateChangeEvent {
4
+ state: PepFooterStateType;
5
+ }
6
+ export interface PepTopBarProps {
7
+ inline?: boolean;
8
+ title?: string;
9
+ headerStartContent?: React.ReactNode;
10
+ headerEndContent?: React.ReactNode;
11
+ footerStartContent?: React.ReactNode;
12
+ footerEndContent?: React.ReactNode;
13
+ children?: React.ReactNode;
14
+ onFooterStateChange?: (event: PepFooterStateChangeEvent) => void;
15
+ }
16
+ export declare const PepTopBar: React.FC<PepTopBarProps>;
package/pep-top-bar.js ADDED
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ export const PepTopBar = ({ inline, title, headerStartContent, headerEndContent, footerStartContent, footerEndContent, children, onFooterStateChange, }) => {
4
+ const elementRef = useRef(null);
5
+ useEffect(() => {
6
+ const element = elementRef.current;
7
+ if (!element) {
8
+ return;
9
+ }
10
+ // Defer property setting to ensure Angular component initialization completes
11
+ const applyProps = () => {
12
+ try {
13
+ if (!element) {
14
+ return;
15
+ }
16
+ if (inline !== undefined) {
17
+ element.inline = inline;
18
+ }
19
+ if (title !== undefined) {
20
+ element.title = title;
21
+ }
22
+ }
23
+ catch (error) {
24
+ // eslint-disable-next-line no-console
25
+ console.error('Error setting PepTopBar properties:', error);
26
+ }
27
+ };
28
+ const timeoutId = window.setTimeout(applyProps, 0);
29
+ return () => {
30
+ window.clearTimeout(timeoutId);
31
+ };
32
+ }, [inline, title]);
33
+ useEffect(() => {
34
+ const element = elementRef.current;
35
+ if (!element) {
36
+ return;
37
+ }
38
+ const handleFooterStateChange = (event) => {
39
+ const customEvent = event;
40
+ onFooterStateChange === null || onFooterStateChange === void 0 ? void 0 : onFooterStateChange(customEvent.detail);
41
+ };
42
+ element.addEventListener('footerStateChange', handleFooterStateChange);
43
+ return () => {
44
+ element.removeEventListener('footerStateChange', handleFooterStateChange);
45
+ };
46
+ }, [onFooterStateChange]);
47
+ return (_jsxs("pep-top-bar-element", { ref: elementRef, children: [headerStartContent && (_jsx("div", { "header-start-content": "", children: headerStartContent })), headerEndContent && (_jsx("div", { "header-end-content": "", children: headerEndContent })), footerStartContent && (_jsx("div", { "footer-start-content": "", children: footerStartContent })), footerEndContent && (_jsx("div", { "footer-end-content": "", children: footerEndContent })), children] }));
48
+ };
49
+ //# sourceMappingURL=pep-top-bar.js.map
package/services.d.ts CHANGED
@@ -14,4 +14,153 @@
14
14
  * If you absolutely need Angular service functionality, you must use the Angular library
15
15
  * directly in an Angular application, not in a React application.
16
16
  */
17
- export {};
17
+ /// <reference types="react" />
18
+ export interface PepHttpServiceBridge {
19
+ getHttpCall(url: string, httpOptions?: any): any;
20
+ postHttpCall(url: string, body: any | null, httpOptions?: any): any;
21
+ getWapiApiCall(url: string, httpOptions?: any): any;
22
+ postWapiApiCall(url: string, body: any | null, httpOptions?: any): any;
23
+ getPapiApiCall(url: string, httpOptions?: any): any;
24
+ postPapiApiCall(url: string, body: any | null, httpOptions?: any): any;
25
+ }
26
+ export interface PepTranslateServiceBridge {
27
+ instant(key: string | string[], interpolateParams?: Record<string, unknown>): string | any;
28
+ get(key: string | string[], interpolateParams?: Record<string, unknown>): any;
29
+ use(lang: string): any;
30
+ getDefaultLang(): string;
31
+ getCurrentLang(): string | undefined;
32
+ }
33
+ export declare type PepDialogActionsType = 'close' | 'cancel-continue' | 'cancel-ok' | 'cancel-delete' | 'custom';
34
+ export declare type PepDialogSizeType = 'inline' | 'small' | 'regular' | 'large' | 'full-screen';
35
+ export interface PepDialogActionButtonConfig {
36
+ title: string;
37
+ className?: string;
38
+ callback?: () => void;
39
+ }
40
+ export interface PepDialogDefaultOptions {
41
+ title?: string;
42
+ content?: string;
43
+ showClose?: boolean;
44
+ showHeader?: boolean;
45
+ showFooter?: boolean;
46
+ actionsType?: PepDialogActionsType;
47
+ actionButtons?: PepDialogActionButtonConfig[];
48
+ size?: PepDialogSizeType;
49
+ disableClose?: boolean;
50
+ hasBackdrop?: boolean;
51
+ height?: string;
52
+ minWidth?: string;
53
+ maxWidth?: string;
54
+ maxHeight?: string;
55
+ panelClass?: string;
56
+ }
57
+ export interface PepAddonServiceBridge {
58
+ getAddonApiCall(addonUUID: string, fileName: string, functionName: string, httpOptions?: any, isAsync?: boolean): any;
59
+ postAddonApiCall(addonUUID: string, fileName: string, functionName: string, body?: any, httpOptions?: any, isAsync?: boolean): any;
60
+ getAddonCPICall(addonUUID: string, url: string): Promise<any>;
61
+ postAddonCPICall(addonUUID: string, url: string, body: any): Promise<any>;
62
+ getServerBaseUrl(addonUUID: string, fileName?: string, isAsync?: boolean, localhostPort?: number): string;
63
+ getAddonStaticFolder(addonUUID: string): string;
64
+ setAddonStaticFolder(path: string, addonUUID: string): void;
65
+ }
66
+ export declare function getPepCustomizationService(): PepCustomizationServiceBridge | undefined;
67
+ export declare function getPepAddonService(): PepAddonServiceBridge | undefined;
68
+ export declare function getPepColorService(): PepColorServiceBridge | undefined;
69
+ export declare function getPepLoaderService(): PepLoaderServiceBridge | undefined;
70
+ export interface PepSessionServiceBridge {
71
+ getIdpToken(): string | null;
72
+ getWapiBaseUrl(): string | null;
73
+ getPapiBaseUrl(): string | null;
74
+ getObject<T = any>(key: string): T | null;
75
+ setObject<T>(key: string, object: T): void;
76
+ removeObject(key: string): void;
77
+ }
78
+ export interface PepCustomizationServiceBridge {
79
+ getThemeVariables(): any;
80
+ setThemeVariables(themeVariablesToSet?: any): void;
81
+ getThemeVariable(key: string): string;
82
+ getBrandingTheme(): string;
83
+ getLoadingSpinnerColor(): string;
84
+ getBrandingMainColor(): string;
85
+ getTopBarHeight(): number;
86
+ hideFooter(): void;
87
+ showFooter(): void;
88
+ hideSettings(): void;
89
+ showSettings(): void;
90
+ }
91
+ export interface PepColorServiceBridge {
92
+ findClosestAccessibleColor(adjustableColor: string, otherColor: string, contrastRatio: number): string | null;
93
+ lightOrDark(color: any): 'light' | 'dark';
94
+ }
95
+ export interface PepLoaderServiceBridge {
96
+ show(): void;
97
+ hide(): void;
98
+ }
99
+ export interface PepDialogServiceBridge {
100
+ openDefaultDialog(options: PepDialogDefaultOptions): any;
101
+ openColorPicker?(options: any): any;
102
+ }
103
+ export interface PepperiServicesBridge {
104
+ http?: PepHttpServiceBridge;
105
+ session?: PepSessionServiceBridge;
106
+ customization?: PepCustomizationServiceBridge;
107
+ translate?: PepTranslateServiceBridge;
108
+ addon?: PepAddonServiceBridge;
109
+ color?: PepColorServiceBridge;
110
+ loader?: PepLoaderServiceBridge;
111
+ dialog?: PepDialogServiceBridge;
112
+ }
113
+ export declare function getPepHttpService(): PepHttpServiceBridge | undefined;
114
+ export declare function getPepSessionService(): PepSessionServiceBridge | undefined;
115
+ export declare function getPepTranslateService(): PepTranslateServiceBridge | undefined;
116
+ export declare function getPepDialogService(): PepDialogServiceBridge | undefined;
117
+ export declare function pepHttpGetViaService<T = any>(url: string, httpOptions?: any): Promise<T>;
118
+ export declare function pepHttpPostViaService<T = any>(url: string, body: any | null, httpOptions?: any): Promise<T>;
119
+ export declare function pepHttpGetWapi<T = any>(relativeUrl: string, httpOptions?: any): Promise<T>;
120
+ export declare function pepHttpPostWapi<T = any>(relativeUrl: string, body: any | null, httpOptions?: any): Promise<T>;
121
+ export declare function pepHttpGetPapi<T = any>(relativeUrl: string, httpOptions?: any): Promise<T>;
122
+ export declare function pepHttpPostPapi<T = any>(relativeUrl: string, body: any | null, httpOptions?: any): Promise<T>;
123
+ export declare function pepGetIdpToken(): string | null;
124
+ export declare function pepGetWapiBaseUrl(): string | null;
125
+ export declare function pepGetPapiBaseUrl(): string | null;
126
+ export declare function pepSessionGetObject<T = any>(key: string): T | null;
127
+ export declare function pepSessionSetObject<T>(key: string, object: T): void;
128
+ export declare function pepSessionRemoveObject(key: string): void;
129
+ export declare function pepGetBrandingTheme(): string;
130
+ export declare function pepGetThemeVariables(): any;
131
+ export declare function pepSetThemeVariables(themeVariablesToSet?: any): void;
132
+ export declare function pepGetThemeVariable(key: string): string;
133
+ export declare function pepGetLoadingSpinnerColor(): string;
134
+ export declare function pepGetBrandingMainColor(): string;
135
+ export declare function pepGetTopBarHeight(): number;
136
+ export declare function pepHideFooter(): void;
137
+ export declare function pepShowFooter(): void;
138
+ export declare function pepHideSettings(): void;
139
+ export declare function pepShowSettings(): void;
140
+ export declare function pepTranslateInstant(key: string | string[], interpolateParams?: Record<string, unknown>): string | any;
141
+ export declare function pepTranslateGet<T = any>(key: string | string[], interpolateParams?: Record<string, unknown>): Promise<T>;
142
+ export declare function pepTranslateUse(lang: string): Promise<void>;
143
+ export declare function pepTranslateGetDefaultLang(): string;
144
+ export declare function pepTranslateGetCurrentLang(): string | undefined;
145
+ export declare function pepAddonGetApi<T = any>(addonUUID: string, fileName: string, functionName: string, httpOptions?: any, isAsync?: boolean): Promise<T>;
146
+ export declare function pepAddonPostApi<T = any>(addonUUID: string, fileName: string, functionName: string, body?: any, httpOptions?: any, isAsync?: boolean): Promise<T>;
147
+ export declare function pepAddonGetCpi<T = any>(addonUUID: string, url: string): Promise<T>;
148
+ export declare function pepAddonPostCpi<T = any>(addonUUID: string, url: string, body: any): Promise<T>;
149
+ export declare function pepAddonGetServerBaseUrl(addonUUID: string, fileName?: string, isAsync?: boolean, localhostPort?: number): string;
150
+ export declare function pepAddonGetStaticFolder(addonUUID: string): string;
151
+ export declare function pepAddonSetStaticFolder(path: string, addonUUID: string): void;
152
+ export declare function pepFindClosestAccessibleColor(adjustableColor: string, otherColor: string, contrastRatio: number): string | null;
153
+ export declare function pepLightOrDark(color: any): 'light' | 'dark';
154
+ export declare function pepLoaderShow(): void;
155
+ export declare function pepLoaderHide(): void;
156
+ export declare function pepOpenDefaultDialog<T = any>(options: PepDialogDefaultOptions): Promise<T | undefined>;
157
+ export declare function pepOpenColorPickerDialog<T = any>(options: any): Promise<T | undefined>;
158
+ export interface OpenReactPepDialogOptions<T = any> {
159
+ title?: string;
160
+ showHeader?: boolean;
161
+ showFooter?: boolean;
162
+ showClose?: boolean;
163
+ size?: PepDialogSizeType;
164
+ renderContent?: (close: (result?: T) => void) => React.ReactNode;
165
+ }
166
+ export declare function openReactPepDialog<T = any>(options: OpenReactPepDialogOptions<T>): Promise<T | undefined>;