@creopse/react 0.0.11 → 0.0.13

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@creopse/react",
3
3
  "description": "Creopse React Toolkit",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "private": false,
6
6
  "author": "Noé Gnanih <noegnanih@gmail.com>",
7
7
  "license": "MIT",
@@ -47,7 +47,8 @@
47
47
  "@vueuse/core": "^14.1.0",
48
48
  "axios": "^1.13.2",
49
49
  "framer-motion": "^12.23.9",
50
- "lodash.clonedeep": "^4.5.0"
50
+ "lodash.clonedeep": "^4.5.0",
51
+ "uuid": "^13.0.0"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@eslint/js": "^9.30.1",
@@ -56,6 +57,7 @@
56
57
  "@types/lodash.clonedeep": "^4.5.9",
57
58
  "@types/react": "^19.1.8",
58
59
  "@types/react-dom": "^19.1.6",
60
+ "@types/uuid": "^11.0.0",
59
61
  "@types/validator": "^13.15.10",
60
62
  "@vitejs/plugin-react": "^4.6.0",
61
63
  "eslint": "^9.30.1",
@@ -1,9 +1,2 @@
1
- import React from 'react';
2
- import { type SectionModel } from '@creopse/utils';
3
- export interface Props {
4
- page: any;
5
- sections: SectionModel[];
6
- components: Record<string, React.ComponentType<any>>;
7
- }
8
- declare const RootContainer: React.FC<Props>;
1
+ declare const RootContainer: () => import("react/jsx-runtime").JSX.Element;
9
2
  export default RootContainer;
@@ -1 +1 @@
1
- export { default as RootContainer, type Props as RootContainerProps, } from './RootContainer';
1
+ export { default as RootContainer } from './RootContainer';
@@ -1,6 +1,6 @@
1
1
  import type { PluginConfig } from '@/types/plugin';
2
2
  import type PropsManager from './props-manager';
3
- declare const PropsContext: import("react").Context<PropsManager | null>;
3
+ declare const PropsContext: import("react").Context<PropsManager<import("@/types/plugin").Props> | null>;
4
4
  declare const ConfigContext: import("react").Context<PluginConfig | null>;
5
5
  declare const RouterContext: import("react").Context<any>;
6
6
  declare const ResolveSectionsContext: import("react").Context<any>;
@@ -1,13 +1,14 @@
1
- declare class PropsManager {
1
+ import type { Props } from '@/types/plugin';
2
+ declare class PropsManager<T extends Props = Props> {
2
3
  private state;
3
4
  private listeners;
4
- constructor(initialProps: Record<string, any>);
5
- update(payload: Record<string, any>): void;
5
+ constructor(initialProps: T);
6
+ update(payload: T): void;
6
7
  getState(): {
7
- props: Record<string, any>;
8
+ props: T;
8
9
  };
9
- sync(newProps: Record<string, any>): void;
10
- subscribe(callback: (props: Record<string, any>) => void): () => void;
10
+ sync(newProps: T): void;
11
+ subscribe(callback: (props: T) => void): () => void;
11
12
  private notify;
12
13
  private deepMerge;
13
14
  private isObject;
@@ -1,5 +1,4 @@
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';
1
+ import type { AppInformationKey, ContentModelItemModel, ContentModelModel, MenuItemGroupModel, MenuItemModel, MenuModel, NewsArticleModel, NewsCategoryModel, NewsTagModel, PageModel, SettingType, SharedProps } from '@creopse/utils';
3
2
  /**
4
3
  * A hook that provides a set of functions and properties for
5
4
  * easily accessing and manipulating page data, content models, menus,
@@ -16,9 +15,6 @@ export declare const useContent: () => {
16
15
  newsCategory: NewsCategoryModel | undefined;
17
16
  newsTag: NewsTagModel | undefined;
18
17
  contentModelItem: ContentModelItemModel | undefined;
19
- getProps: () => PageProps & SharedProps & {
20
- errors: Errors & ErrorBag;
21
- };
22
18
  getMenu: (name: string, filterByIsActive?: boolean) => MenuModel | undefined;
23
19
  getMenuByLocation: (name: string, filterByIsActive?: boolean) => MenuModel | undefined;
24
20
  getMenuItems: (name: string, filterByIsVisible?: boolean) => MenuItemModel[] | undefined;
@@ -36,10 +32,7 @@ export declare const useContent: () => {
36
32
  getSectionSettingsGroup: (key: string | null | undefined, group: string) => object | any | null;
37
33
  getSectionSetting: (key: string | null | undefined, group: string, name: string) => object | any | null;
38
34
  getAnySectionData: (sectionSlug: string, pageSlug: string, linkId?: string) => Promise<any>;
39
- getSectionsInOrder: () => SectionModel[];
40
- getFinalPageSections: () => SectionModel[];
41
35
  getSectionRootData: (key?: string) => any;
42
- getComponents: () => Record<string, any>;
43
36
  getContentModel: (name: string) => ContentModelModel | undefined;
44
37
  getContentModelItems: (name: string, filterByIsActive?: boolean) => Promise<ContentModelItemModel[]>;
45
38
  getPaginatedContentModelItems: (name: string, pageSize: number, filterByIsActive?: boolean) => Promise<{
@@ -1,9 +1,10 @@
1
+ import type { Props } from '@/types/plugin';
1
2
  /**
2
3
  * A hook that returns the props of the page.
3
4
  *
4
5
  * It subscribes to the PropsManager and updates when props change.
5
6
  *
6
7
  * @throws {Error} if the CreopseProvider is not found in tree
7
- * @returns {Record<string, any>} the props of the page
8
+ * @returns {T} the props of the page
8
9
  */
9
- export declare const useProps: <T = Record<string, any>>() => T;
10
+ export declare const useProps: <T extends Props = Props>() => T;
@@ -0,0 +1,7 @@
1
+ import type { SectionModel } from '@creopse/utils';
2
+ import type { Props } from '../types/plugin';
3
+ export declare const useSetup: () => {
4
+ getComponents: (resolveSections?: () => Record<string, unknown>) => Record<string, any>;
5
+ getSectionsInOrder: <T extends Props = Props>(props: T) => SectionModel[];
6
+ getFinalPageSections: <T extends Props = Props>(props: T) => SectionModel[];
7
+ };
package/types/index.d.ts CHANGED
@@ -13,6 +13,6 @@ export { MountedTeleport, type MountedTeleportProps, } from './components/widget
13
13
  export { ReadMore, type ReadMoreProps } from './components/widgets/ReadMore';
14
14
  export { StickyBottom, type StickyBottomProps, } from './components/widgets/StickyBottom';
15
15
  export { StickyTop, type StickyTopProps } from './components/widgets/StickyTop';
16
- export { RootContainer, type RootContainerProps, } from './components/RootContainer';
16
+ export { RootContainer, } from './components/RootContainer';
17
17
  export type { PropsManager };
18
18
  export type { PluginOptions };
@@ -1,4 +1,9 @@
1
- import type { Router } from '@inertiajs/core';
1
+ import type { SharedProps } from '@creopse/utils';
2
+ import type { ErrorBag, Errors, PageProps, Router } from '@inertiajs/core';
3
+ export type Props = SharedProps & PageProps & {
4
+ errors: Errors & ErrorBag;
5
+ [key: string]: any;
6
+ };
2
7
  export interface PluginConfig {
3
8
  debug: boolean;
4
9
  appUrl: string;
@@ -7,7 +12,7 @@ export interface PluginConfig {
7
12
  langKey: string;
8
13
  }
9
14
  export interface PluginOptions {
10
- initialProps: Record<string, any>;
15
+ initialProps: Props;
11
16
  router?: Router;
12
17
  resolveSections: () => Record<string, unknown>;
13
18
  config: PluginConfig;