@dashadmin/dash-utils 1.3.73 → 1.3.74-srcfree.2
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/dist/components/LazyAppLoader.d.ts +17 -0
- package/dist/components/MinimalLayout.d.ts +6 -0
- package/dist/components/RouterComponent.d.ts +22 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/contexts/IPCMessageBrokerContext.d.ts +42 -0
- package/dist/hooks/useCapacitorAppStateRefresh.d.ts +2 -0
- package/dist/hooks/useCapacitorKeyboard.d.ts +19 -0
- package/dist/hooks/useDeviceStorageSync.d.ts +4 -0
- package/dist/hooks/useDraggable.d.ts +24 -0
- package/dist/hooks/useMenuStateInit.d.ts +10 -0
- package/dist/hooks/useMobileDetection.d.ts +20 -0
- package/dist/hooks/useNotifications.d.ts +51 -0
- package/dist/hooks/useQuickSearch.d.ts +6 -0
- package/dist/hooks/useWindowSize.d.ts +6 -0
- package/dist/index.d.ts +30 -0
- package/dist/utils/authProviderUtils.d.ts +37 -0
- package/dist/utils/dashBootstrapApp.d.ts +9 -0
- package/dist/utils/dashDtorage.d.ts +8 -0
- package/dist/utils/dashIPCService.d.ts +93 -0
- package/dist/utils/dataProviderUtils.d.ts +44 -0
- package/dist/utils/electronStoreSync.d.ts +3 -0
- package/dist/utils/envUtils.d.ts +1 -0
- package/dist/utils/environmentBodyClasses.d.ts +11 -0
- package/dist/utils/isDev.d.ts +5 -0
- package/dist/utils/notificationPermission.d.ts +5 -0
- package/dist/utils/platformDetection.d.ts +13 -0
- package/dist/utils/priceFormatter.d.ts +2 -0
- package/dist/utils/resourceLoader.d.ts +8 -0
- package/dist/utils/speechService.d.ts +7 -0
- package/dist/utils/storedTheme.d.ts +11 -0
- package/dist/utils/updateDomCssVariables.d.ts +6 -0
- package/dist/utils/validation.d.ts +12 -0
- package/package.json +13 -10
- package/src/components/LazyAppLoader.tsx +0 -143
- package/src/components/MinimalLayout.tsx +0 -22
- package/src/components/RouterComponent.tsx +0 -169
- package/src/components/index.ts +0 -16
- package/src/contexts/IPCMessageBrokerContext.tsx +0 -303
- package/src/hooks/useCapacitorAppStateRefresh.ts +0 -34
- package/src/hooks/useCapacitorKeyboard.ts +0 -213
- package/src/hooks/useDeviceStorageSync.ts +0 -70
- package/src/hooks/useDraggable.ts +0 -133
- package/src/hooks/useMenuStateInit.ts +0 -85
- package/src/hooks/useMobileDetection.ts +0 -165
- package/src/hooks/useNotifications.ts +0 -220
- package/src/hooks/useQuickSearch.ts +0 -42
- package/src/hooks/useWindowSize.tsx +0 -36
- package/src/index.ts +0 -202
- package/src/utils/authProviderUtils.ts +0 -170
- package/src/utils/dashBootstrapApp.ts +0 -104
- package/src/utils/dashDtorage.tsx +0 -51
- package/src/utils/dashDtorage.tsx.old +0 -78
- package/src/utils/dashIPCService.ts +0 -204
- package/src/utils/dataProviderUtils.ts +0 -221
- package/src/utils/electronStoreSync.ts +0 -34
- package/src/utils/envUtils.tsx +0 -27
- package/src/utils/environmentBodyClasses.ts +0 -72
- package/src/utils/isDev.ts +0 -65
- package/src/utils/notificationPermission.ts +0 -57
- package/src/utils/platformDetection.ts +0 -98
- package/src/utils/priceFormatter.ts +0 -36
- package/src/utils/resourceLoader.ts +0 -107
- package/src/utils/speechService.ts +0 -112
- package/src/utils/storedTheme.ts +0 -60
- package/src/utils/updateDomCssVariables.tsx +0 -181
- package/src/utils/validation.ts +0 -147
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface LazyAppLoaderConfig {
|
|
3
|
+
importFn: () => Promise<{
|
|
4
|
+
default: React.ComponentType<any>;
|
|
5
|
+
}>;
|
|
6
|
+
initDelay?: number;
|
|
7
|
+
fallbackComponent?: React.ComponentType<any>;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const DefaultLoadFailedComponent: React.FC<{
|
|
11
|
+
message?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const createLazyAppComponent: (config: LazyAppLoaderConfig) => React.LazyExoticComponent<React.ComponentType<any>>;
|
|
14
|
+
export declare const createSimpleLazyApp: (importFn: () => Promise<{
|
|
15
|
+
default: React.ComponentType<any>;
|
|
16
|
+
}>, initDelay?: number) => React.LazyExoticComponent<React.ComponentType<any>>;
|
|
17
|
+
export default createLazyAppComponent;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DashRouterComponentProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
forceType?: 'hash' | 'browser';
|
|
5
|
+
basename?: string;
|
|
6
|
+
platformType?: string;
|
|
7
|
+
platform?: string;
|
|
8
|
+
loader?: React.ReactNode;
|
|
9
|
+
publicRoutes?: React.ReactNode | (() => React.ReactNode);
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export type RouterComponentProps = DashRouterComponentProps;
|
|
13
|
+
export declare const shouldUseHashRouter: (platformType?: string, platform?: string) => boolean;
|
|
14
|
+
export declare const DashRouterComponent: React.FC<DashRouterComponentProps>;
|
|
15
|
+
export declare const createRouterComponent: (envVars: {
|
|
16
|
+
PLATFORM_TYPE?: string;
|
|
17
|
+
PLATFORM?: string;
|
|
18
|
+
}) => React.FC<{
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const RouterComponent: React.FC<DashRouterComponentProps>;
|
|
22
|
+
export default DashRouterComponent;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DashIPCServiceType } from "../utils/dashIPCService";
|
|
2
|
+
export interface LogMessage {
|
|
3
|
+
level: string;
|
|
4
|
+
message: string;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SubprocessOutput {
|
|
8
|
+
type: string;
|
|
9
|
+
message: string;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
pid?: number;
|
|
12
|
+
exitCode?: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface IPCMessageBrokerContextType {
|
|
16
|
+
lastMessage: string | undefined;
|
|
17
|
+
idleStatus: boolean;
|
|
18
|
+
logMessages: LogMessage[];
|
|
19
|
+
subprocessOutputs: SubprocessOutput[];
|
|
20
|
+
isElectronAvailable: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface IPCMessageBrokerConfig {
|
|
23
|
+
idleTime?: number;
|
|
24
|
+
resuscitationTime?: number;
|
|
25
|
+
maxLogMessages?: number;
|
|
26
|
+
maxSubprocessOutputs?: number;
|
|
27
|
+
maxInitAttempts?: number;
|
|
28
|
+
initRetryDelay?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare const IPCMessageBrokerContext: import("react").Context<IPCMessageBrokerContextType>;
|
|
31
|
+
export declare const useIPCMessageBroker: () => IPCMessageBrokerContextType;
|
|
32
|
+
declare global {
|
|
33
|
+
interface Window {
|
|
34
|
+
DashIPCService?: DashIPCServiceType;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
interface IPCMessageBrokerProviderProps {
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
config?: IPCMessageBrokerConfig;
|
|
40
|
+
}
|
|
41
|
+
export declare const IPCMessageBrokerProvider: ({ children, config: userConfig }: IPCMessageBrokerProviderProps) => import("react").JSX.Element;
|
|
42
|
+
export default IPCMessageBrokerProvider;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface KeyboardState {
|
|
2
|
+
isKeyboardOpen: boolean;
|
|
3
|
+
keyboardHeight: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UseCapacitorKeyboardOptions {
|
|
6
|
+
disableAccessoryBar?: boolean;
|
|
7
|
+
resizeMode?: 'body' | 'ionic' | 'native' | 'none';
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const isCapacitorKeyboardAvailable: () => boolean;
|
|
11
|
+
export declare const getCapacitorKeyboard: () => any;
|
|
12
|
+
export declare const useCapacitorKeyboard: (options?: UseCapacitorKeyboardOptions) => {
|
|
13
|
+
hideKeyboard: () => Promise<void>;
|
|
14
|
+
showKeyboard: () => Promise<void>;
|
|
15
|
+
isCapacitorAvailable: boolean;
|
|
16
|
+
isKeyboardOpen: boolean;
|
|
17
|
+
keyboardHeight: number;
|
|
18
|
+
};
|
|
19
|
+
export default useCapacitorKeyboard;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface DraggablePosition {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UseDraggableOptions {
|
|
6
|
+
initialPosition?: DraggablePosition;
|
|
7
|
+
minX?: number;
|
|
8
|
+
minY?: number;
|
|
9
|
+
maxX?: number;
|
|
10
|
+
maxY?: number;
|
|
11
|
+
elementWidth?: number;
|
|
12
|
+
elementHeight?: number;
|
|
13
|
+
onPositionChange?: (position: DraggablePosition) => void;
|
|
14
|
+
onDragStart?: () => void;
|
|
15
|
+
onDragEnd?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export interface UseDraggableReturn {
|
|
18
|
+
position: DraggablePosition;
|
|
19
|
+
isDragging: boolean;
|
|
20
|
+
handleMouseDown: (e: React.MouseEvent) => void;
|
|
21
|
+
setPosition: (position: DraggablePosition) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const useDraggable: (options?: UseDraggableOptions) => UseDraggableReturn;
|
|
24
|
+
export default useDraggable;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface UseMenuStateInitOptions {
|
|
2
|
+
navExpandedKey?: string;
|
|
3
|
+
navSizeKey?: string;
|
|
4
|
+
setNavExpandedAction?: (isExpanded: boolean) => any;
|
|
5
|
+
setNavSizeAction?: (size: string) => any;
|
|
6
|
+
}
|
|
7
|
+
export declare const useMenuStateInit: (options?: UseMenuStateInitOptions) => void;
|
|
8
|
+
export declare const getInitialMenuState: (navExpandedKey?: string) => boolean;
|
|
9
|
+
export declare const getInitialNavSize: (navSizeKey?: string) => any;
|
|
10
|
+
export default useMenuStateInit;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface MobileDetectionState {
|
|
2
|
+
isMobile: boolean;
|
|
3
|
+
isAndroid: boolean;
|
|
4
|
+
isIOS: boolean;
|
|
5
|
+
isWebView: boolean;
|
|
6
|
+
screenWidth: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UseMobileDetectionOptions {
|
|
9
|
+
mobileBreakpoint?: number;
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const checkMobileDevice: (mobileBreakpoint?: number) => boolean;
|
|
13
|
+
export declare const isWebView: () => boolean;
|
|
14
|
+
export declare const isAndroid: () => boolean;
|
|
15
|
+
export declare const isIOS: () => boolean;
|
|
16
|
+
export declare const isWindows: () => boolean;
|
|
17
|
+
export declare const isMacOS: () => boolean;
|
|
18
|
+
export declare const isLinux: () => boolean;
|
|
19
|
+
export declare const useMobileDetection: (options?: UseMobileDetectionOptions) => MobileDetectionState;
|
|
20
|
+
export default useMobileDetection;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface ProcessedNotification {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
message: string;
|
|
5
|
+
customer?: string;
|
|
6
|
+
store?: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
isRead: boolean;
|
|
9
|
+
data?: any;
|
|
10
|
+
severity?: 'info' | 'warning' | 'error' | 'success';
|
|
11
|
+
}
|
|
12
|
+
export interface ToastNotification {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
message: string;
|
|
16
|
+
severity: 'info' | 'warning' | 'error' | 'success';
|
|
17
|
+
}
|
|
18
|
+
export interface DialogNotification extends ProcessedNotification {
|
|
19
|
+
position: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
zIndex: number;
|
|
24
|
+
}
|
|
25
|
+
export interface UseNotificationsOptions {
|
|
26
|
+
maxNotifications?: number;
|
|
27
|
+
initialZIndex?: number;
|
|
28
|
+
toastAutoDismiss?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface UseNotificationsReturn {
|
|
31
|
+
notifications: ProcessedNotification[];
|
|
32
|
+
toastNotifications: ToastNotification[];
|
|
33
|
+
dialogNotifications: DialogNotification[];
|
|
34
|
+
unreadCount: number;
|
|
35
|
+
addNotification: (notification: Omit<ProcessedNotification, 'id' | 'timestamp' | 'isRead'>) => ProcessedNotification;
|
|
36
|
+
addToast: (toast: Omit<ToastNotification, 'id'>) => string;
|
|
37
|
+
addDialogNotification: (notification: Omit<ProcessedNotification, 'id' | 'timestamp' | 'isRead'>) => DialogNotification;
|
|
38
|
+
markAsRead: (notificationId: string) => void;
|
|
39
|
+
markAllAsRead: () => void;
|
|
40
|
+
removeNotification: (notificationId: string) => void;
|
|
41
|
+
clearAllNotifications: () => void;
|
|
42
|
+
removeToast: (toastId: string) => void;
|
|
43
|
+
removeDialogNotification: (notificationId: string) => void;
|
|
44
|
+
bringDialogToFront: (notificationId: string) => void;
|
|
45
|
+
updateDialogPosition: (notificationId: string, position: {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
}) => void;
|
|
49
|
+
}
|
|
50
|
+
export declare const useNotifications: (options?: UseNotificationsOptions) => UseNotificationsReturn;
|
|
51
|
+
export default useNotifications;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface UseQuickSearchReturn {
|
|
2
|
+
quickSearchUseState: [string | null, React.Dispatch<React.SetStateAction<string | null>>];
|
|
3
|
+
sendQuickSearchEvent: (quickSearchString: string) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const useQuickSearch: () => UseQuickSearchReturn;
|
|
6
|
+
export default useQuickSearch;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { useWindowSize } from './hooks/useWindowSize';
|
|
2
|
+
export { useCapacitorAppStateRefresh } from './hooks/useCapacitorAppStateRefresh';
|
|
3
|
+
export { useDeviceStorageSync } from './hooks/useDeviceStorageSync';
|
|
4
|
+
export { useCapacitorKeyboard, isCapacitorKeyboardAvailable, getCapacitorKeyboard, type KeyboardState, type UseCapacitorKeyboardOptions } from './hooks/useCapacitorKeyboard';
|
|
5
|
+
export { useMobileDetection, checkMobileDevice, isWebView, isAndroid, isIOS, isWindows, isMacOS, isLinux, type MobileDetectionState, type UseMobileDetectionOptions } from './hooks/useMobileDetection';
|
|
6
|
+
export { useDraggable, type DraggablePosition, type UseDraggableOptions, type UseDraggableReturn } from './hooks/useDraggable';
|
|
7
|
+
export { useNotifications, type ProcessedNotification, type ToastNotification, type DialogNotification, type UseNotificationsOptions, type UseNotificationsReturn } from './hooks/useNotifications';
|
|
8
|
+
export { useQuickSearch, type UseQuickSearchReturn } from './hooks/useQuickSearch';
|
|
9
|
+
export { useMenuStateInit, getInitialMenuState, getInitialNavSize, type UseMenuStateInitOptions } from './hooks/useMenuStateInit';
|
|
10
|
+
export { updateDomCssVariables } from './utils/updateDomCssVariables';
|
|
11
|
+
export { getEnv } from './utils/envUtils';
|
|
12
|
+
export { dashStorage } from './utils/dashDtorage';
|
|
13
|
+
export { EMAIL_REGEX, PHONE_REGEX, URL_REGEX, validateEmail, validatePhone, validateUrl, validateRequired, validateMinLength, validateMaxLength, validateRut, checkPasswordStrength, type PasswordStrength } from './utils/validation';
|
|
14
|
+
export { isDashIPCServiceAvailable, isElectron, getDashIPCService, windowControl, startWindowDrag, executeIPCAction, onIPCStdout, useDashIPCService, type DashIPCServiceType } from './utils/dashIPCService';
|
|
15
|
+
export { speak, speakAsync } from './utils/speechService';
|
|
16
|
+
export { getStoredTheme, setStoredTheme, initializeStoredTheme, clearStoredTheme } from './utils/storedTheme';
|
|
17
|
+
export { isDev, isProd, isTest, getEnvironment } from './utils/isDev';
|
|
18
|
+
export { setupEnvironmentBodyClasses, useEnvironmentBodyClasses, type EnvironmentVars } from './utils/environmentBodyClasses';
|
|
19
|
+
export { isWebView as isWebViewPlatform, isAndroid as isAndroidPlatform, isIOS as isIOSPlatform, isWindows as isWindowsPlatform, applyPlatformBodyClasses } from './utils/platformDetection';
|
|
20
|
+
export { syncElectronStore, hasElectronStore } from './utils/electronStoreSync';
|
|
21
|
+
export { requestNotificationPermission, isNotificationSupported, hasNotificationPermission, isNotificationDenied, getNotificationPermission } from './utils/notificationPermission';
|
|
22
|
+
export { dashInitializeApp, dashBootstrapApp, type DashInitializeAppConfig } from './utils/dashBootstrapApp';
|
|
23
|
+
export { createResourceLoader, createSimpleResourceLoader } from './utils/resourceLoader';
|
|
24
|
+
export { createLogoutFromStorage, isUserAuthenticated, getCurrentUser, getAuthToken, getTenantId, getUserRoles, setAuthData, type LogoutConfig } from './utils/authProviderUtils';
|
|
25
|
+
export { getResourceConfigManager, setResourceConfigs, getResourceConfig, processPostData, processFormData, buildQueryString, isFormDataResource, type IResourceConfig } from './utils/dataProviderUtils';
|
|
26
|
+
export { MinimalLayout, type MinimalLayoutProps } from './components/MinimalLayout';
|
|
27
|
+
export { DashRouterComponent, RouterComponent, shouldUseHashRouter, createRouterComponent, type DashRouterComponentProps, type RouterComponentProps } from './components/RouterComponent';
|
|
28
|
+
export { IPCMessageBrokerContext, IPCMessageBrokerProvider, useIPCMessageBroker, type LogMessage, type SubprocessOutput, type IPCMessageBrokerContextType, type IPCMessageBrokerConfig } from './contexts/IPCMessageBrokerContext';
|
|
29
|
+
export { createLazyAppComponent, createSimpleLazyApp, DefaultLoadFailedComponent, type LazyAppLoaderConfig } from './components/LazyAppLoader';
|
|
30
|
+
export { priceFormatter } from "./utils/priceFormatter";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface LogoutConfig {
|
|
2
|
+
clearAuthPersistence?: () => void;
|
|
3
|
+
syncToDeviceStore?: () => Promise<void>;
|
|
4
|
+
removeCookies?: (names: string[]) => void;
|
|
5
|
+
additionalKeys?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const createLogoutFromStorage: (config?: LogoutConfig) => (reason?: string) => Promise<void>;
|
|
8
|
+
export declare const isUserAuthenticated: () => boolean;
|
|
9
|
+
export declare const getCurrentUser: <T = any>() => T | null;
|
|
10
|
+
export declare const getAuthToken: () => string | null;
|
|
11
|
+
export declare const getTenantId: () => string | null;
|
|
12
|
+
export declare const getUserRoles: <T = any>() => T[];
|
|
13
|
+
export declare const setAuthData: (data: {
|
|
14
|
+
token?: string;
|
|
15
|
+
user?: any;
|
|
16
|
+
roles?: any[];
|
|
17
|
+
authenticated?: boolean;
|
|
18
|
+
tenant_id?: string;
|
|
19
|
+
user_id?: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
declare const _default: {
|
|
22
|
+
createLogoutFromStorage: (config?: LogoutConfig) => (reason?: string) => Promise<void>;
|
|
23
|
+
isUserAuthenticated: () => boolean;
|
|
24
|
+
getCurrentUser: <T = any>() => T | null;
|
|
25
|
+
getAuthToken: () => string | null;
|
|
26
|
+
getTenantId: () => string | null;
|
|
27
|
+
getUserRoles: <T = any>() => T[];
|
|
28
|
+
setAuthData: (data: {
|
|
29
|
+
token?: string;
|
|
30
|
+
user?: any;
|
|
31
|
+
roles?: any[];
|
|
32
|
+
authenticated?: boolean;
|
|
33
|
+
tenant_id?: string;
|
|
34
|
+
user_id?: string;
|
|
35
|
+
}) => void;
|
|
36
|
+
};
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface DashInitializeAppConfig {
|
|
2
|
+
defaultTheme?: string;
|
|
3
|
+
requestNotifications?: boolean;
|
|
4
|
+
syncElectron?: boolean;
|
|
5
|
+
applyPlatformClasses?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const dashInitializeApp: (config?: DashInitializeAppConfig) => Promise<void>;
|
|
8
|
+
export declare const dashBootstrapApp: () => void;
|
|
9
|
+
export default dashBootstrapApp;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class dashStorage {
|
|
2
|
+
private static localLayer;
|
|
3
|
+
private static get layer();
|
|
4
|
+
static getItem<T = any>(key: string): T | null;
|
|
5
|
+
static setItem<T = any>(key: string, value: T): void;
|
|
6
|
+
static removeItem(key: string): void;
|
|
7
|
+
static clear(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export interface SpeechPayload {
|
|
2
|
+
message: string;
|
|
3
|
+
lang?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SubprocessOutput {
|
|
6
|
+
type: 'stdout' | 'stderr' | 'exit' | 'error' | 'print-stdout' | 'print-stderr';
|
|
7
|
+
message: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
pid?: number;
|
|
10
|
+
exitCode?: number;
|
|
11
|
+
error?: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ElectronLogData {
|
|
15
|
+
level: 'info' | 'error' | 'warn' | 'debug' | 'verbose';
|
|
16
|
+
message: string;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DashIPCServiceType {
|
|
20
|
+
runPythonScript: (filePath: string, scriptPath: string, args: string[]) => void;
|
|
21
|
+
action: (action: string, payload: any) => void;
|
|
22
|
+
speak: (payload: string | SpeechPayload) => void;
|
|
23
|
+
playSound: (soundName: string) => void;
|
|
24
|
+
stopSound: () => void;
|
|
25
|
+
notify: (title: string, message: string) => void;
|
|
26
|
+
onPythonOutput: (callback: (data: any) => void) => void;
|
|
27
|
+
onServiceMessage: (callback: (data: any) => void) => void;
|
|
28
|
+
onStdout: (callback: (data: string) => void) => void;
|
|
29
|
+
onElectronLog: (callback: (logData: ElectronLogData) => void) => void;
|
|
30
|
+
onSubprocessOutput: (callback: (data: SubprocessOutput) => void) => void;
|
|
31
|
+
windowControls: (action: 'minimize' | 'maximize' | 'close') => void;
|
|
32
|
+
startDrag: () => void;
|
|
33
|
+
print: (urlOrTest: string) => Promise<any>;
|
|
34
|
+
send?: (channel: string, data?: any) => void;
|
|
35
|
+
invoke?: (channel: string, data?: any) => Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
export interface ElectronStoreType {
|
|
38
|
+
get: (key: string) => Promise<any>;
|
|
39
|
+
set: (key: string, value: any) => Promise<void>;
|
|
40
|
+
delete: (key: string) => Promise<void>;
|
|
41
|
+
clear: () => Promise<void>;
|
|
42
|
+
getAll: () => Promise<Record<string, any>>;
|
|
43
|
+
syncToLocalStorage: () => Promise<Record<string, any>>;
|
|
44
|
+
}
|
|
45
|
+
declare global {
|
|
46
|
+
interface Window {
|
|
47
|
+
DashIPCService?: DashIPCServiceType;
|
|
48
|
+
electronStore?: ElectronStoreType;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export declare const isDashIPCServiceAvailable: () => boolean;
|
|
52
|
+
export declare const isElectron: () => boolean;
|
|
53
|
+
export declare const getDashIPCService: () => DashIPCServiceType | undefined;
|
|
54
|
+
export declare const windowControl: (action: "minimize" | "maximize" | "close") => boolean;
|
|
55
|
+
export declare const startWindowDrag: () => boolean;
|
|
56
|
+
export declare const executeIPCAction: (action: string, payload: any) => boolean;
|
|
57
|
+
export declare const onIPCStdout: (callback: (data: string) => void) => boolean;
|
|
58
|
+
export declare const onElectronLog: (callback: (logData: ElectronLogData) => void) => boolean;
|
|
59
|
+
export declare const onSubprocessOutput: (callback: (data: SubprocessOutput) => void) => boolean;
|
|
60
|
+
export declare const useDashIPCService: () => {
|
|
61
|
+
isAvailable: boolean;
|
|
62
|
+
isElectron: boolean;
|
|
63
|
+
service: DashIPCServiceType;
|
|
64
|
+
windowControl: (action: "minimize" | "maximize" | "close") => boolean;
|
|
65
|
+
startWindowDrag: () => boolean;
|
|
66
|
+
executeAction: (action: string, payload: any) => boolean;
|
|
67
|
+
onStdout: (callback: (data: string) => void) => boolean;
|
|
68
|
+
onElectronLog: (callback: (logData: ElectronLogData) => void) => boolean;
|
|
69
|
+
onSubprocessOutput: (callback: (data: SubprocessOutput) => void) => boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const _default: {
|
|
72
|
+
isDashIPCServiceAvailable: () => boolean;
|
|
73
|
+
isElectron: () => boolean;
|
|
74
|
+
getDashIPCService: () => DashIPCServiceType | undefined;
|
|
75
|
+
windowControl: (action: "minimize" | "maximize" | "close") => boolean;
|
|
76
|
+
startWindowDrag: () => boolean;
|
|
77
|
+
executeIPCAction: (action: string, payload: any) => boolean;
|
|
78
|
+
onIPCStdout: (callback: (data: string) => void) => boolean;
|
|
79
|
+
onElectronLog: (callback: (logData: ElectronLogData) => void) => boolean;
|
|
80
|
+
onSubprocessOutput: (callback: (data: SubprocessOutput) => void) => boolean;
|
|
81
|
+
useDashIPCService: () => {
|
|
82
|
+
isAvailable: boolean;
|
|
83
|
+
isElectron: boolean;
|
|
84
|
+
service: DashIPCServiceType;
|
|
85
|
+
windowControl: (action: "minimize" | "maximize" | "close") => boolean;
|
|
86
|
+
startWindowDrag: () => boolean;
|
|
87
|
+
executeAction: (action: string, payload: any) => boolean;
|
|
88
|
+
onStdout: (callback: (data: string) => void) => boolean;
|
|
89
|
+
onElectronLog: (callback: (logData: ElectronLogData) => void) => boolean;
|
|
90
|
+
onSubprocessOutput: (callback: (data: SubprocessOutput) => void) => boolean;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface IResourceConfig {
|
|
2
|
+
model?: string;
|
|
3
|
+
isFormData?: boolean;
|
|
4
|
+
dataTransform?: (data: Record<string, any>, operation: string) => Record<string, any>;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
declare class ResourceConfigManager<T extends IResourceConfig = IResourceConfig> {
|
|
8
|
+
private configs;
|
|
9
|
+
setConfigs(configs: T[]): void;
|
|
10
|
+
getConfigs(): T[];
|
|
11
|
+
getConfig(resource: string): T | undefined;
|
|
12
|
+
clear(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const getResourceConfigManager: <T extends IResourceConfig = IResourceConfig>() => ResourceConfigManager<T>;
|
|
15
|
+
export declare const setResourceConfigs: <T extends IResourceConfig = IResourceConfig>(configs: T[]) => void;
|
|
16
|
+
export declare const getResourceConfig: <T extends IResourceConfig = IResourceConfig>(resource: string) => T | undefined;
|
|
17
|
+
export declare const processPostData: <T extends IResourceConfig = IResourceConfig>(resource: string, data: Record<string, any>, operation: "create" | "update" | "getList" | "import" | string) => Record<string, any>;
|
|
18
|
+
export declare const processFormData: (resource: string, data: Record<string, any>) => FormData;
|
|
19
|
+
export declare const buildQueryString: (params: Record<string, any>) => string;
|
|
20
|
+
export declare const isFormDataResource: <T extends IResourceConfig = IResourceConfig>(resource: string, params?: {
|
|
21
|
+
data?: {
|
|
22
|
+
isFormData?: boolean;
|
|
23
|
+
};
|
|
24
|
+
meta?: {
|
|
25
|
+
isFormData?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}) => boolean;
|
|
28
|
+
declare const _default: {
|
|
29
|
+
getResourceConfigManager: <T extends IResourceConfig = IResourceConfig>() => ResourceConfigManager<T>;
|
|
30
|
+
setResourceConfigs: <T extends IResourceConfig = IResourceConfig>(configs: T[]) => void;
|
|
31
|
+
getResourceConfig: <T extends IResourceConfig = IResourceConfig>(resource: string) => T | undefined;
|
|
32
|
+
processPostData: <T extends IResourceConfig = IResourceConfig>(resource: string, data: Record<string, any>, operation: "create" | "update" | "getList" | "import" | string) => Record<string, any>;
|
|
33
|
+
processFormData: (resource: string, data: Record<string, any>) => FormData;
|
|
34
|
+
buildQueryString: (params: Record<string, any>) => string;
|
|
35
|
+
isFormDataResource: <T extends IResourceConfig = IResourceConfig>(resource: string, params?: {
|
|
36
|
+
data?: {
|
|
37
|
+
isFormData?: boolean;
|
|
38
|
+
};
|
|
39
|
+
meta?: {
|
|
40
|
+
isFormData?: boolean;
|
|
41
|
+
};
|
|
42
|
+
}) => boolean;
|
|
43
|
+
};
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getEnv: (key: string) => any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface EnvironmentVars {
|
|
2
|
+
PLATFORM_TYPE?: string;
|
|
3
|
+
IS_ELECTRON?: boolean;
|
|
4
|
+
IS_MAC?: boolean;
|
|
5
|
+
IS_WINDOWS?: boolean;
|
|
6
|
+
IS_LINUX?: boolean;
|
|
7
|
+
PLATFORM?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const setupEnvironmentBodyClasses: (envVars: EnvironmentVars) => (() => void);
|
|
10
|
+
export declare const useEnvironmentBodyClasses: (envVars: EnvironmentVars) => void;
|
|
11
|
+
export default setupEnvironmentBodyClasses;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const requestNotificationPermission: () => Promise<NotificationPermission | null>;
|
|
2
|
+
export declare const isNotificationSupported: () => boolean;
|
|
3
|
+
export declare const hasNotificationPermission: () => boolean;
|
|
4
|
+
export declare const isNotificationDenied: () => boolean;
|
|
5
|
+
export declare const getNotificationPermission: () => NotificationPermission | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const isWebView: () => boolean;
|
|
2
|
+
export declare const isAndroid: () => boolean;
|
|
3
|
+
export declare const isIOS: () => boolean;
|
|
4
|
+
export declare const isWindows: () => boolean;
|
|
5
|
+
export declare const applyPlatformBodyClasses: () => void;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
isWebView: () => boolean;
|
|
8
|
+
isAndroid: () => boolean;
|
|
9
|
+
isIOS: () => boolean;
|
|
10
|
+
isWindows: () => boolean;
|
|
11
|
+
applyPlatformBodyClasses: () => void;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const createResourceLoader: <T>(loadFn: () => Promise<T[]>) => {
|
|
2
|
+
getResources: () => Promise<T[]>;
|
|
3
|
+
resources: T[];
|
|
4
|
+
clearCache: () => void;
|
|
5
|
+
isLoaded: () => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const createSimpleResourceLoader: <T>(loadFn: () => Promise<T[]>) => (() => Promise<T[]>);
|
|
8
|
+
export default createResourceLoader;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const speak: (text: string, lang?: string) => void;
|
|
2
|
+
export declare const speakAsync: (text: string, lang?: string) => Promise<void>;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
speak: (text: string, lang?: string) => void;
|
|
5
|
+
speakAsync: (text: string, lang?: string) => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const getStoredTheme: () => string | null;
|
|
2
|
+
export declare const setStoredTheme: (theme: string) => void;
|
|
3
|
+
export declare const initializeStoredTheme: (defaultTheme: string) => string;
|
|
4
|
+
export declare const clearStoredTheme: () => void;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
getStoredTheme: () => string | null;
|
|
7
|
+
setStoredTheme: (theme: string) => void;
|
|
8
|
+
initializeStoredTheme: (defaultTheme: string) => string;
|
|
9
|
+
clearStoredTheme: () => void;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const EMAIL_REGEX: RegExp;
|
|
2
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
3
|
+
export declare const PHONE_REGEX: RegExp;
|
|
4
|
+
export declare const validatePhone: (phone: string) => boolean;
|
|
5
|
+
export declare const URL_REGEX: RegExp;
|
|
6
|
+
export declare const validateUrl: (url: string) => boolean;
|
|
7
|
+
export type PasswordStrength = 'weak' | 'fair' | 'good' | 'strong';
|
|
8
|
+
export declare const checkPasswordStrength: (password: string) => PasswordStrength;
|
|
9
|
+
export declare const validateRequired: (value: any) => boolean;
|
|
10
|
+
export declare const validateMinLength: (value: string, minLength: number) => boolean;
|
|
11
|
+
export declare const validateMaxLength: (value: string, maxLength: number) => boolean;
|
|
12
|
+
export declare const validateRut: (rut: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashadmin/dash-utils",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.74-srcfree.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@mui/material": "^9.3.0",
|
|
29
|
-
"@dashadmin/dash-constants": "1.3.
|
|
29
|
+
"@dashadmin/dash-constants": "1.3.74-srcfree.2"
|
|
30
30
|
},
|
|
31
31
|
"module": "dist/index.js",
|
|
32
|
-
"types": "./
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
33
|
"exports": {
|
|
34
34
|
".": "./dist/index.js",
|
|
35
35
|
"./components": "./dist/components/index.js",
|
|
@@ -42,22 +42,25 @@
|
|
|
42
42
|
"registry": "https://registry.npmjs.org"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"build": "tsup"
|
|
45
|
+
"build": "tsup && pnpm run build:types",
|
|
46
|
+
"build:types": "../../node_modules/.bin/tsc -p tsconfig.json --declaration --emitDeclarationOnly --noEmit false --outDir dist --rootDir src --skipLibCheck; test -f dist/index.d.ts"
|
|
46
47
|
},
|
|
47
48
|
"type": "module",
|
|
48
49
|
"files": [
|
|
49
|
-
"dist"
|
|
50
|
-
"src"
|
|
50
|
+
"dist"
|
|
51
51
|
],
|
|
52
52
|
"typesVersions": {
|
|
53
53
|
"*": {
|
|
54
|
+
"dist/*": [
|
|
55
|
+
"dist/*"
|
|
56
|
+
],
|
|
54
57
|
"src/*": [
|
|
55
|
-
"
|
|
56
|
-
"
|
|
58
|
+
"dist/*",
|
|
59
|
+
"dist/*/index"
|
|
57
60
|
],
|
|
58
61
|
"*": [
|
|
59
|
-
"
|
|
60
|
-
"
|
|
62
|
+
"dist/*",
|
|
63
|
+
"dist/*/index"
|
|
61
64
|
]
|
|
62
65
|
}
|
|
63
66
|
}
|