@pepperi-addons/ngx-lib-react 0.5.3 → 0.5.5

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,5 +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';
package/index.js CHANGED
@@ -26,7 +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';
31
+ export { PepRichHtmlTextarea } from './pep-rich-html-textarea.js';
30
32
  // Export all service helpers (bridge-based access to Angular services)
31
33
  export * from './services.js';
32
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.3",
3
+ "version": "0.5.5",
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",
@@ -26,6 +26,7 @@
26
26
  "*.js",
27
27
  "*.d.ts",
28
28
  "README.md",
29
+ "SERVICES.md",
29
30
  "elements/*"
30
31
  ]
31
32
  ,
package/pep-dialog.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef } from 'react';
3
- export const PepDialog = ({ title, showClose, showHeader, showFooter, onClose, ...rest }) => {
3
+ export const PepDialog = ({ title, showClose, showHeader, showFooter, onClose, children, ...rest }) => {
4
4
  const ref = useRef(null);
5
5
  // Sync inputs as properties on the custom element
6
6
  useEffect(() => {
@@ -29,6 +29,6 @@ export const PepDialog = ({ title, showClose, showHeader, showFooter, onClose, .
29
29
  handlers.forEach(([n, h]) => el.addEventListener(n, h));
30
30
  return () => handlers.forEach(([n, h]) => el.removeEventListener(n, h));
31
31
  }, [onClose]);
32
- return _jsx("pep-dialog-element", { ref: ref, ...rest });
32
+ return (_jsx("pep-dialog-element", { ref: ref, ...rest, children: children }));
33
33
  };
34
34
  //# sourceMappingURL=pep-dialog.js.map
@@ -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,6 +14,7 @@
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
+ /// <reference types="react" />
17
18
  export interface PepHttpServiceBridge {
18
19
  getHttpCall(url: string, httpOptions?: any): any;
19
20
  postHttpCall(url: string, body: any | null, httpOptions?: any): any;
@@ -22,7 +23,50 @@ export interface PepHttpServiceBridge {
22
23
  getPapiApiCall(url: string, httpOptions?: any): any;
23
24
  postPapiApiCall(url: string, body: any | null, httpOptions?: any): any;
24
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
+ }
25
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;
26
70
  export interface PepSessionServiceBridge {
27
71
  getIdpToken(): string | null;
28
72
  getWapiBaseUrl(): string | null;
@@ -44,13 +88,32 @@ export interface PepCustomizationServiceBridge {
44
88
  hideSettings(): void;
45
89
  showSettings(): void;
46
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
+ }
47
103
  export interface PepperiServicesBridge {
48
104
  http?: PepHttpServiceBridge;
49
105
  session?: PepSessionServiceBridge;
50
106
  customization?: PepCustomizationServiceBridge;
107
+ translate?: PepTranslateServiceBridge;
108
+ addon?: PepAddonServiceBridge;
109
+ color?: PepColorServiceBridge;
110
+ loader?: PepLoaderServiceBridge;
111
+ dialog?: PepDialogServiceBridge;
51
112
  }
52
113
  export declare function getPepHttpService(): PepHttpServiceBridge | undefined;
53
114
  export declare function getPepSessionService(): PepSessionServiceBridge | undefined;
115
+ export declare function getPepTranslateService(): PepTranslateServiceBridge | undefined;
116
+ export declare function getPepDialogService(): PepDialogServiceBridge | undefined;
54
117
  export declare function pepHttpGetViaService<T = any>(url: string, httpOptions?: any): Promise<T>;
55
118
  export declare function pepHttpPostViaService<T = any>(url: string, body: any | null, httpOptions?: any): Promise<T>;
56
119
  export declare function pepHttpGetWapi<T = any>(relativeUrl: string, httpOptions?: any): Promise<T>;
@@ -74,3 +137,30 @@ export declare function pepHideFooter(): void;
74
137
  export declare function pepShowFooter(): void;
75
138
  export declare function pepHideSettings(): void;
76
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>;
package/services.js CHANGED
@@ -14,6 +14,9 @@
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
+ import React from 'react';
18
+ import * as ReactDOM from 'react-dom';
19
+ import { PepDialog } from './pep-dialog.js';
17
20
  export function getPepCustomizationService() {
18
21
  try {
19
22
  return getPepperiServicesOrThrow().customization;
@@ -22,6 +25,30 @@ export function getPepCustomizationService() {
22
25
  return undefined;
23
26
  }
24
27
  }
28
+ export function getPepAddonService() {
29
+ try {
30
+ return getPepperiServicesOrThrow().addon;
31
+ }
32
+ catch {
33
+ return undefined;
34
+ }
35
+ }
36
+ export function getPepColorService() {
37
+ try {
38
+ return getPepperiServicesOrThrow().color;
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
44
+ export function getPepLoaderService() {
45
+ try {
46
+ return getPepperiServicesOrThrow().loader;
47
+ }
48
+ catch {
49
+ return undefined;
50
+ }
51
+ }
25
52
  function getPepperiServicesOrThrow() {
26
53
  const w = (typeof window !== 'undefined' ? window : globalThis);
27
54
  const pep = w === null || w === void 0 ? void 0 : w.pepperi;
@@ -50,6 +77,22 @@ export function getPepSessionService() {
50
77
  return undefined;
51
78
  }
52
79
  }
80
+ export function getPepTranslateService() {
81
+ try {
82
+ return getPepperiServicesOrThrow().translate;
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ }
88
+ export function getPepDialogService() {
89
+ try {
90
+ return getPepperiServicesOrThrow().dialog;
91
+ }
92
+ catch {
93
+ return undefined;
94
+ }
95
+ }
53
96
  function requirePepHttpService() {
54
97
  const http = getPepHttpService();
55
98
  if (!http) {
@@ -71,6 +114,41 @@ function requirePepCustomizationService() {
71
114
  }
72
115
  return customization;
73
116
  }
117
+ function requirePepTranslateService() {
118
+ const translate = getPepTranslateService();
119
+ if (!translate) {
120
+ throw new Error('PepTranslateService is not available on window.pepperi.services.translate. Ensure Elements bundle is loaded and services bridge is initialized.');
121
+ }
122
+ return translate;
123
+ }
124
+ function requirePepAddonService() {
125
+ const addon = getPepAddonService();
126
+ if (!addon) {
127
+ throw new Error('PepAddonService is not available on window.pepperi.services.addon. Ensure Elements bundle is loaded and services bridge is initialized.');
128
+ }
129
+ return addon;
130
+ }
131
+ function requirePepColorService() {
132
+ const color = getPepColorService();
133
+ if (!color) {
134
+ throw new Error('PepColorService is not available on window.pepperi.services.color. Ensure Elements bundle is loaded and services bridge is initialized.');
135
+ }
136
+ return color;
137
+ }
138
+ function requirePepLoaderService() {
139
+ const loader = getPepLoaderService();
140
+ if (!loader) {
141
+ throw new Error('PepLoaderService is not available on window.pepperi.services.loader. Ensure Elements bundle is loaded and services bridge is initialized.');
142
+ }
143
+ return loader;
144
+ }
145
+ function requirePepDialogService() {
146
+ const dialog = getPepDialogService();
147
+ if (!dialog) {
148
+ throw new Error('PepDialogService is not available on window.pepperi.services.dialog. Ensure Elements bundle is loaded and services bridge is initialized.');
149
+ }
150
+ return dialog;
151
+ }
74
152
  // -----------------------------------------------------------------------------
75
153
  // Internal: convert RxJS-like Observable to Promise without importing rxjs
76
154
  // -----------------------------------------------------------------------------
@@ -186,4 +264,155 @@ export function pepHideSettings() {
186
264
  export function pepShowSettings() {
187
265
  requirePepCustomizationService().showSettings();
188
266
  }
267
+ // -----------------------------------------------------------------------------
268
+ // Convenience helpers for PepTranslateService (i18n)
269
+ // -----------------------------------------------------------------------------
270
+ export function pepTranslateInstant(key, interpolateParams) {
271
+ return requirePepTranslateService().instant(key, interpolateParams);
272
+ }
273
+ export async function pepTranslateGet(key, interpolateParams) {
274
+ const translate = requirePepTranslateService();
275
+ return observableToPromise(translate.get(key, interpolateParams));
276
+ }
277
+ export async function pepTranslateUse(lang) {
278
+ const translate = requirePepTranslateService();
279
+ await observableToPromise(translate.use(lang));
280
+ }
281
+ export function pepTranslateGetDefaultLang() {
282
+ return requirePepTranslateService().getDefaultLang();
283
+ }
284
+ export function pepTranslateGetCurrentLang() {
285
+ return requirePepTranslateService().getCurrentLang();
286
+ }
287
+ // -----------------------------------------------------------------------------
288
+ // Convenience helpers for PepAddonService (addons & CPI)
289
+ // -----------------------------------------------------------------------------
290
+ export async function pepAddonGetApi(addonUUID, fileName, functionName, httpOptions, isAsync) {
291
+ const addon = requirePepAddonService();
292
+ return observableToPromise(addon.getAddonApiCall(addonUUID, fileName, functionName, httpOptions, isAsync));
293
+ }
294
+ export async function pepAddonPostApi(addonUUID, fileName, functionName, body, httpOptions, isAsync) {
295
+ const addon = requirePepAddonService();
296
+ return observableToPromise(addon.postAddonApiCall(addonUUID, fileName, functionName, body, httpOptions, isAsync));
297
+ }
298
+ export function pepAddonGetCpi(addonUUID, url) {
299
+ const addon = requirePepAddonService();
300
+ return addon.getAddonCPICall(addonUUID, url);
301
+ }
302
+ export function pepAddonPostCpi(addonUUID, url, body) {
303
+ const addon = requirePepAddonService();
304
+ return addon.postAddonCPICall(addonUUID, url, body);
305
+ }
306
+ export function pepAddonGetServerBaseUrl(addonUUID, fileName, isAsync, localhostPort) {
307
+ return requirePepAddonService().getServerBaseUrl(addonUUID, fileName, isAsync, localhostPort);
308
+ }
309
+ export function pepAddonGetStaticFolder(addonUUID) {
310
+ return requirePepAddonService().getAddonStaticFolder(addonUUID);
311
+ }
312
+ export function pepAddonSetStaticFolder(path, addonUUID) {
313
+ requirePepAddonService().setAddonStaticFolder(path, addonUUID);
314
+ }
315
+ // -----------------------------------------------------------------------------
316
+ // Convenience helpers for PepColorService (color utilities)
317
+ // -----------------------------------------------------------------------------
318
+ export function pepFindClosestAccessibleColor(adjustableColor, otherColor, contrastRatio) {
319
+ return requirePepColorService().findClosestAccessibleColor(adjustableColor, otherColor, contrastRatio);
320
+ }
321
+ export function pepLightOrDark(color) {
322
+ return requirePepColorService().lightOrDark(color);
323
+ }
324
+ // -----------------------------------------------------------------------------
325
+ // Convenience helpers for PepLoaderService (global loader)
326
+ // -----------------------------------------------------------------------------
327
+ export function pepLoaderShow() {
328
+ requirePepLoaderService().show();
329
+ }
330
+ export function pepLoaderHide() {
331
+ requirePepLoaderService().hide();
332
+ }
333
+ // -----------------------------------------------------------------------------
334
+ // Convenience helpers for PepDialogService (dialogs)
335
+ // -----------------------------------------------------------------------------
336
+ export async function pepOpenDefaultDialog(options) {
337
+ const dialog = requirePepDialogService();
338
+ const ref = dialog.openDefaultDialog(options);
339
+ if (!ref || typeof ref.afterClosed !== 'function') {
340
+ throw new Error('PepDialogService bridge did not return a dialogRef with afterClosed(). Ensure Elements bundle is loaded and dialog bridge is initialized.');
341
+ }
342
+ return observableToPromise(ref.afterClosed());
343
+ }
344
+ export async function pepOpenColorPickerDialog(options) {
345
+ const dialog = requirePepDialogService();
346
+ if (!dialog.openColorPicker) {
347
+ throw new Error('PepDialogService bridge does not expose openColorPicker.');
348
+ }
349
+ const ref = dialog.openColorPicker(options);
350
+ if (!ref || typeof ref.afterClosed !== 'function') {
351
+ throw new Error('PepDialogService color picker bridge did not return a dialogRef with afterClosed(). Ensure Elements bundle is loaded and dialog bridge is initialized.');
352
+ }
353
+ return observableToPromise(ref.afterClosed());
354
+ }
355
+ export function openReactPepDialog(options) {
356
+ if (typeof document === 'undefined') {
357
+ return Promise.reject(new Error('openReactPepDialog can only be used in a browser environment.'));
358
+ }
359
+ const host = document.createElement('div');
360
+ document.body.appendChild(host);
361
+ const useCreateRoot = typeof ReactDOM.createRoot === 'function';
362
+ let root = null;
363
+ return new Promise((resolve) => {
364
+ var _a, _b, _c;
365
+ const close = (result) => {
366
+ try {
367
+ if (useCreateRoot && root && typeof root.unmount === 'function') {
368
+ root.unmount();
369
+ }
370
+ else if (!useCreateRoot &&
371
+ typeof ReactDOM.unmountComponentAtNode === 'function') {
372
+ ReactDOM.unmountComponentAtNode(host);
373
+ }
374
+ }
375
+ catch {
376
+ // noop
377
+ }
378
+ if (host.parentNode) {
379
+ host.parentNode.removeChild(host);
380
+ }
381
+ resolve(result);
382
+ };
383
+ const overlay = React.createElement('div', {
384
+ style: {
385
+ position: 'fixed',
386
+ inset: 0,
387
+ background: 'rgba(0, 0, 0, 0.4)',
388
+ display: 'flex',
389
+ alignItems: 'center',
390
+ justifyContent: 'center',
391
+ zIndex: 1100,
392
+ },
393
+ }, React.createElement('div', {
394
+ className: 'cdk-overlay-pane pep-dialog',
395
+ }, React.createElement('div', {
396
+ className: 'mat-dialog-container pep-dialog' +
397
+ ((options === null || options === void 0 ? void 0 : options.size) ? ` ${options.size}` : ''),
398
+ }, React.createElement(PepDialog, {
399
+ title: options === null || options === void 0 ? void 0 : options.title,
400
+ showHeader: (_a = options === null || options === void 0 ? void 0 : options.showHeader) !== null && _a !== void 0 ? _a : true,
401
+ showFooter: (_b = options === null || options === void 0 ? void 0 : options.showFooter) !== null && _b !== void 0 ? _b : true,
402
+ showClose: (_c = options === null || options === void 0 ? void 0 : options.showClose) !== null && _c !== void 0 ? _c : true,
403
+ onClose: () => close(undefined),
404
+ }, (options === null || options === void 0 ? void 0 : options.renderContent) ? options.renderContent(close) : null))));
405
+ if (useCreateRoot) {
406
+ root = ReactDOM.createRoot(host);
407
+ root.render(overlay);
408
+ }
409
+ else if (typeof ReactDOM.render === 'function') {
410
+ ReactDOM.render(overlay, host);
411
+ }
412
+ else {
413
+ // If we cannot render the overlay for some reason, resolve immediately.
414
+ close(undefined);
415
+ }
416
+ });
417
+ }
189
418
  //# sourceMappingURL=services.js.map