@creopse/react 0.0.8 → 0.0.10
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/hooks/index.cjs +438 -0
- package/dist/hooks/index.mjs +439 -0
- package/dist/index-4XGApE5d.js +7789 -0
- package/dist/index-ZewuA4XM.cjs +7787 -0
- package/dist/index.cjs +345 -4471
- package/dist/index.mjs +335 -4461
- package/package.json +19 -3
- package/types/components/widgets/Image/Image.d.ts +14 -0
- package/types/components/widgets/Image/index.d.ts +1 -0
- package/types/core/contexts.d.ts +7 -0
- package/types/core/props-manager.d.ts +15 -0
- package/types/hooks/api.d.ts +23 -0
- package/types/hooks/config.d.ts +20 -0
- package/types/hooks/content.d.ts +54 -0
- package/types/hooks/helper.d.ts +30 -0
- package/types/hooks/index.d.ts +6 -0
- package/types/hooks/newsletter.d.ts +29 -0
- package/types/hooks/props.d.ts +9 -0
- package/types/index.d.ts +12 -1
- package/types/types/api.d.ts +15 -0
- package/types/types/plugin.d.ts +13 -0
- package/dist/index.js +0 -12398
- /package/types/components/{core/RootContainer → RootContainer}/RootContainer.d.ts +0 -0
- /package/types/components/{core/RootContainer → RootContainer}/index.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creopse/react",
|
|
3
3
|
"description": "Creopse React Toolkit",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Noé Gnanih <noegnanih@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"import": "./dist/index.mjs",
|
|
15
15
|
"require": "./dist/index.cjs"
|
|
16
16
|
},
|
|
17
|
+
"./hooks": {
|
|
18
|
+
"types": "./types/hooks/index.d.ts",
|
|
19
|
+
"import": "./dist/hooks/index.mjs",
|
|
20
|
+
"require": "./dist/hooks/index.cjs"
|
|
21
|
+
},
|
|
17
22
|
"./*": "./*"
|
|
18
23
|
},
|
|
19
24
|
"typings": "types/index.d.ts",
|
|
@@ -32,22 +37,33 @@
|
|
|
32
37
|
"preview": "vite preview"
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|
|
40
|
+
"@inertiajs/core": "^2.0.0",
|
|
41
|
+
"@inertiajs/react": "^2.0.0",
|
|
35
42
|
"react": "^19.1.0",
|
|
36
43
|
"react-dom": "^19.1.0"
|
|
37
44
|
},
|
|
38
45
|
"dependencies": {
|
|
39
|
-
"@creopse/utils": "^0.0.
|
|
40
|
-
"
|
|
46
|
+
"@creopse/utils": "^0.0.11",
|
|
47
|
+
"@vueuse/core": "^14.1.0",
|
|
48
|
+
"axios": "^1.13.2",
|
|
49
|
+
"framer-motion": "^12.23.9",
|
|
50
|
+
"lodash.clonedeep": "^4.5.0"
|
|
41
51
|
},
|
|
42
52
|
"devDependencies": {
|
|
43
53
|
"@eslint/js": "^9.30.1",
|
|
54
|
+
"@inertiajs/core": "^2.1.6",
|
|
55
|
+
"@inertiajs/react": "^2.1.6",
|
|
56
|
+
"@types/lodash.clonedeep": "^4.5.9",
|
|
44
57
|
"@types/react": "^19.1.8",
|
|
45
58
|
"@types/react-dom": "^19.1.6",
|
|
59
|
+
"@types/validator": "^13.15.10",
|
|
46
60
|
"@vitejs/plugin-react": "^4.6.0",
|
|
47
61
|
"eslint": "^9.30.1",
|
|
48
62
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
49
63
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
50
64
|
"globals": "^16.3.0",
|
|
65
|
+
"react": "^19.1.0",
|
|
66
|
+
"react-dom": "^19.1.0",
|
|
51
67
|
"typescript": "~5.8.3",
|
|
52
68
|
"typescript-eslint": "^8.35.1",
|
|
53
69
|
"vite": "^7.0.4"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface Props {
|
|
3
|
+
src: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
height?: string | number;
|
|
7
|
+
title?: string;
|
|
8
|
+
loading?: 'lazy' | 'eager';
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
size?: 'small' | 'medium' | 'large' | 'original';
|
|
11
|
+
sync?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const Image: React.FC<Props>;
|
|
14
|
+
export default Image;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Image, type Props as ImageProps } from './Image';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginConfig } from '@/types/plugin';
|
|
2
|
+
import type PropsManager from './props-manager';
|
|
3
|
+
declare const PropsContext: import("react").Context<PropsManager | null>;
|
|
4
|
+
declare const ConfigContext: import("react").Context<PluginConfig | null>;
|
|
5
|
+
declare const RouterContext: import("react").Context<any>;
|
|
6
|
+
declare const ResolveSectionsContext: import("react").Context<any>;
|
|
7
|
+
export { PropsContext, ConfigContext, RouterContext, ResolveSectionsContext };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class PropsManager {
|
|
2
|
+
private state;
|
|
3
|
+
private listeners;
|
|
4
|
+
constructor(initialProps: Record<string, any>);
|
|
5
|
+
update(payload: Record<string, any>): void;
|
|
6
|
+
getState(): {
|
|
7
|
+
props: Record<string, any>;
|
|
8
|
+
};
|
|
9
|
+
sync(newProps: Record<string, any>): void;
|
|
10
|
+
subscribe(callback: (props: Record<string, any>) => void): () => void;
|
|
11
|
+
private notify;
|
|
12
|
+
private deepMerge;
|
|
13
|
+
private isObject;
|
|
14
|
+
}
|
|
15
|
+
export default PropsManager;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ApiResponse, Payload } from '@/types/api';
|
|
2
|
+
/**
|
|
3
|
+
* This hook is used to make API requests.
|
|
4
|
+
*
|
|
5
|
+
* @function useApi
|
|
6
|
+
* @returns {Object} An object containing the following methods:
|
|
7
|
+
* - `request`: Makes an API request with the given payload.
|
|
8
|
+
* - `addItem`: Adds an item to the API.
|
|
9
|
+
* - `deleteItem`: Deletes an item from the API.
|
|
10
|
+
* - `updateItem`: Updates an item in the API.
|
|
11
|
+
* - `getAllItems`: Gets all items from the API.
|
|
12
|
+
* - `getItem`: Gets an item from the API.
|
|
13
|
+
* - `handleError`: Handles an error from the API.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useApi: () => {
|
|
16
|
+
request: (payload: Payload, accessToken?: string, accessForbiddenCallback?: () => void) => Promise<ApiResponse>;
|
|
17
|
+
getItem: (payload: Payload) => Promise<ApiResponse>;
|
|
18
|
+
addItem: (payload: Payload) => Promise<ApiResponse>;
|
|
19
|
+
updateItem: (payload: Payload) => Promise<ApiResponse>;
|
|
20
|
+
deleteItem: (payload: Payload) => Promise<ApiResponse>;
|
|
21
|
+
getAllItems: (payload: Payload) => Promise<ApiResponse>;
|
|
22
|
+
handleError: (error: any) => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the plugin configuration object.
|
|
3
|
+
*
|
|
4
|
+
* This hook is used to access the plugin configuration
|
|
5
|
+
* in your React components.
|
|
6
|
+
*
|
|
7
|
+
* @returns {PluginConfig} the plugin configuration object
|
|
8
|
+
* @throws {Error} if the CreopseProvider is not found in tree
|
|
9
|
+
*/
|
|
10
|
+
export declare const useConfig: () => {
|
|
11
|
+
apiBaseUrl: string;
|
|
12
|
+
apiUrl: string;
|
|
13
|
+
apiRequestHeaders: {
|
|
14
|
+
'X-API-Key': string;
|
|
15
|
+
};
|
|
16
|
+
debug: boolean;
|
|
17
|
+
appUrl: string;
|
|
18
|
+
xApiKey: string;
|
|
19
|
+
encryptionKey: string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AppInformationKey, ContentModelItemModel, ContentModelModel, MenuItemGroupModel, MenuItemModel, MenuModel, NewsArticleModel, NewsCategoryModel, NewsTagModel, PageModel, SectionModel, SettingType, SharedProps } from '@creopse/utils';
|
|
2
|
+
import type { ErrorBag, Errors, PageProps } from '@inertiajs/core';
|
|
3
|
+
/**
|
|
4
|
+
* A hook that provides a set of functions and properties for
|
|
5
|
+
* easily accessing and manipulating page data, content models, menus,
|
|
6
|
+
* menu items, and more.
|
|
7
|
+
*
|
|
8
|
+
* @returns {Object}
|
|
9
|
+
*/
|
|
10
|
+
export declare const useContent: () => {
|
|
11
|
+
logo: string;
|
|
12
|
+
icon: string;
|
|
13
|
+
page: import("@inertiajs/core").Page<SharedProps>;
|
|
14
|
+
pageData: PageModel | null;
|
|
15
|
+
newsArticle: NewsArticleModel | undefined;
|
|
16
|
+
newsCategory: NewsCategoryModel | undefined;
|
|
17
|
+
newsTag: NewsTagModel | undefined;
|
|
18
|
+
contentModelItem: ContentModelItemModel | undefined;
|
|
19
|
+
getProps: () => PageProps & SharedProps & {
|
|
20
|
+
errors: Errors & ErrorBag;
|
|
21
|
+
};
|
|
22
|
+
getMenu: (name: string, filterByIsActive?: boolean) => MenuModel | undefined;
|
|
23
|
+
getMenuByLocation: (name: string, filterByIsActive?: boolean) => MenuModel | undefined;
|
|
24
|
+
getMenuItems: (name: string, filterByIsVisible?: boolean) => MenuItemModel[] | undefined;
|
|
25
|
+
getMenuItemById: (id: number) => MenuItemModel | undefined;
|
|
26
|
+
getMenuItemsByLocation: (name: string, filterByIsVisible?: boolean) => MenuItemModel[] | undefined;
|
|
27
|
+
getMenuGroups: (name: string, byLocation?: boolean, filterByIsVisible?: boolean) => MenuItemGroupModel[];
|
|
28
|
+
getMenuItemsByGroup: (name: string, groupId: number, byLocation?: boolean, filterByIsVisible?: boolean) => MenuItemModel[] | undefined;
|
|
29
|
+
getMenuGroupedItems: (name: string, byLocation?: boolean, filterByIsVisible?: boolean) => {
|
|
30
|
+
group: MenuItemGroupModel;
|
|
31
|
+
items: MenuItemModel[] | undefined;
|
|
32
|
+
}[];
|
|
33
|
+
getMenuUngroupedItems: (name: string, byLocation?: boolean, filterByIsVisible?: boolean) => MenuItemModel[] | undefined;
|
|
34
|
+
getSectionData: (key?: string) => object | any | null;
|
|
35
|
+
getSectionSettings: (key: string | null | undefined) => object | any | null;
|
|
36
|
+
getSectionSettingsGroup: (key: string | null | undefined, group: string) => object | any | null;
|
|
37
|
+
getSectionSetting: (key: string | null | undefined, group: string, name: string) => object | any | null;
|
|
38
|
+
getAnySectionData: (sectionSlug: string, pageSlug: string, linkId?: string) => Promise<any>;
|
|
39
|
+
getSectionsInOrder: () => SectionModel[];
|
|
40
|
+
getFinalPageSections: () => SectionModel[];
|
|
41
|
+
getSectionRootData: (key?: string) => any;
|
|
42
|
+
getComponents: () => Record<string, any>;
|
|
43
|
+
getContentModel: (name: string) => ContentModelModel | undefined;
|
|
44
|
+
getContentModelItems: (name: string, filterByIsActive?: boolean) => Promise<ContentModelItemModel[]>;
|
|
45
|
+
getPaginatedContentModelItems: (name: string, pageSize: number, filterByIsActive?: boolean) => Promise<{
|
|
46
|
+
items: ContentModelItemModel[];
|
|
47
|
+
total: number;
|
|
48
|
+
currentPage: number;
|
|
49
|
+
}>;
|
|
50
|
+
getAppInformationValue: (key: AppInformationKey, type?: SettingType) => any;
|
|
51
|
+
appAccentColor: string;
|
|
52
|
+
appPrimaryColor: string;
|
|
53
|
+
appSecondaryColor: string;
|
|
54
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Language, MenuItemModel } from '@creopse/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a collection of helper functions and values.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Object}
|
|
6
|
+
*/
|
|
7
|
+
export declare const useHelper: () => {
|
|
8
|
+
is2XlScreen: boolean;
|
|
9
|
+
isXlScreen: boolean;
|
|
10
|
+
isLgScreen: boolean;
|
|
11
|
+
isMdScreen: boolean;
|
|
12
|
+
isSmScreen: boolean;
|
|
13
|
+
getTranslation: (data: any, lang: string) => string;
|
|
14
|
+
getLangageLabel: (value: string) => string | undefined;
|
|
15
|
+
getLanguageValue: (label: string) => string | undefined;
|
|
16
|
+
ckEditorToolbarItems: string[];
|
|
17
|
+
displayFormErrors: (errors: any, displayError: (message: string) => void) => void;
|
|
18
|
+
resolveHtmlLinks: (data: string | null | undefined, lang: string) => string;
|
|
19
|
+
resolveUrl: (path: string) => string;
|
|
20
|
+
updateUserLang: (val: string, reload?: boolean, updateUserPrefs?: boolean) => Promise<void>;
|
|
21
|
+
languages: Language[];
|
|
22
|
+
getImage: (path: string, size?: "small" | "medium" | "large" | "original") => Promise<string>;
|
|
23
|
+
fileUrl: (path: string) => string;
|
|
24
|
+
currentRoutePath: string;
|
|
25
|
+
openLink: (str: string) => void;
|
|
26
|
+
openMenu: (menu?: MenuItemModel) => void;
|
|
27
|
+
getMenuHref: (menu: MenuItemModel) => string;
|
|
28
|
+
rHtml: (data: string | null | undefined, lang: string) => string;
|
|
29
|
+
tr: (data: any, lang: string) => string;
|
|
30
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook that exposes functions to subscribe the user to the newsletter using
|
|
3
|
+
* email or phone.
|
|
4
|
+
*
|
|
5
|
+
* @returns An object containing the subscribeEmail, subscribePhone, and isLoading
|
|
6
|
+
* properties.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The subscribeEmail and subscribePhone functions are asynchronous and return nothing.
|
|
10
|
+
* The isLoading property is a boolean that indicates whether a subscription request is
|
|
11
|
+
* being processed.
|
|
12
|
+
*
|
|
13
|
+
* The subscribeEmail function takes an email address and an optional success callback.
|
|
14
|
+
* The subscribePhone function takes a phone number and an optional success callback.
|
|
15
|
+
*
|
|
16
|
+
* If the request is successful, the user will be subscribed to the newsletter and the
|
|
17
|
+
* success callback will be called. If the request fails, an appropriate error message
|
|
18
|
+
* will be displayed to the user.
|
|
19
|
+
*
|
|
20
|
+
* The error messages are as follows:
|
|
21
|
+
* - If the request is invalid, the form errors will be displayed.
|
|
22
|
+
* - If the request is valid but results in an error, a generic error message will be
|
|
23
|
+
* displayed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const useNewsletter: () => {
|
|
26
|
+
subscribePhone: (phone: string, successCallback?: () => void, errorCallback?: (errorData: any) => void) => Promise<void>;
|
|
27
|
+
subscribeEmail: (email: string, successCallback?: () => void, errorCallback?: (errorData: any) => void) => Promise<void>;
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook that returns the props of the page.
|
|
3
|
+
*
|
|
4
|
+
* It subscribes to the PropsManager and updates when props change.
|
|
5
|
+
*
|
|
6
|
+
* @throws {Error} if the CreopseProvider is not found in tree
|
|
7
|
+
* @returns {Record<string, any>} the props of the page
|
|
8
|
+
*/
|
|
9
|
+
export declare const useProps: <T = Record<string, any>>() => T;
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import PropsManager from './core/props-manager';
|
|
3
|
+
import type { PluginOptions } from './types/plugin';
|
|
4
|
+
interface CreopseProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
options: PluginOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function CreopseProvider({ children, options }: CreopseProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { Image, type ImageProps } from './components/widgets/Image';
|
|
1
10
|
export { AsyncImg, type AsyncImgProps } from './components/widgets/AsyncImg';
|
|
2
11
|
export { CustomTransition, type CustomTransitionProps, } from './components/widgets/CustomTransition';
|
|
3
12
|
export { MountedTeleport, type MountedTeleportProps, } from './components/widgets/MountedTeleport';
|
|
4
13
|
export { ReadMore, type ReadMoreProps } from './components/widgets/ReadMore';
|
|
5
14
|
export { StickyBottom, type StickyBottomProps, } from './components/widgets/StickyBottom';
|
|
6
15
|
export { StickyTop, type StickyTopProps } from './components/widgets/StickyTop';
|
|
7
|
-
export { RootContainer, type RootContainerProps, } from './components/
|
|
16
|
+
export { RootContainer, type RootContainerProps, } from './components/RootContainer';
|
|
17
|
+
export type { PropsManager };
|
|
18
|
+
export type { PluginOptions };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Method = 'get' | 'post' | 'put' | 'delete';
|
|
2
|
+
export interface Payload {
|
|
3
|
+
method?: Method;
|
|
4
|
+
routeBase?: string;
|
|
5
|
+
params?: object;
|
|
6
|
+
data?: object;
|
|
7
|
+
url?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiResponse {
|
|
11
|
+
success: boolean;
|
|
12
|
+
failure: boolean;
|
|
13
|
+
result: any;
|
|
14
|
+
error: any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Router } from '@inertiajs/core';
|
|
2
|
+
export interface PluginConfig {
|
|
3
|
+
debug: boolean;
|
|
4
|
+
appUrl: string;
|
|
5
|
+
xApiKey: string;
|
|
6
|
+
encryptionKey: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginOptions {
|
|
9
|
+
initialProps: Record<string, any>;
|
|
10
|
+
router?: Router;
|
|
11
|
+
resolveSections: () => Record<string, unknown>;
|
|
12
|
+
config: PluginConfig;
|
|
13
|
+
}
|