@creopse/vue 0.0.14 → 0.0.15

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/style.css CHANGED
@@ -1 +1 @@
1
- .reset-styles[data-v-f40657c2]{all:unset!important}.fade-enter-active[data-v-30b5e62e],.fade-leave-active[data-v-30b5e62e]{transition:opacity .5s ease}.fade-enter-from[data-v-30b5e62e],.fade-leave-to[data-v-30b5e62e]{opacity:0}.slide-fade-enter-active[data-v-30b5e62e]{transition:all .3s ease-out}.slide-fade-leave-active[data-v-30b5e62e]{transition:all .8s cubic-bezier(1,.5,.8,1)}.slide-fade-enter-from[data-v-30b5e62e],.slide-fade-leave-to[data-v-30b5e62e]{transform:translate(20px);opacity:0}.bounce-enter-active[data-v-30b5e62e]{animation:bounce-in-30b5e62e .5s}.bounce-leave-active[data-v-30b5e62e]{animation:bounce-in-30b5e62e .5s reverse}@keyframes bounce-in-30b5e62e{0%{transform:scale(0)}50%{transform:scale(1.25)}to{transform:scale(1)}}
1
+ .reset-styles[data-v-9e4f90fa]{all:unset!important}.fade-enter-active[data-v-30b5e62e],.fade-leave-active[data-v-30b5e62e]{transition:opacity .5s ease}.fade-enter-from[data-v-30b5e62e],.fade-leave-to[data-v-30b5e62e]{opacity:0}.slide-fade-enter-active[data-v-30b5e62e]{transition:all .3s ease-out}.slide-fade-leave-active[data-v-30b5e62e]{transition:all .8s cubic-bezier(1,.5,.8,1)}.slide-fade-enter-from[data-v-30b5e62e],.slide-fade-leave-to[data-v-30b5e62e]{transform:translate(20px);opacity:0}.bounce-enter-active[data-v-30b5e62e]{animation:bounce-in-30b5e62e .5s}.bounce-leave-active[data-v-30b5e62e]{animation:bounce-in-30b5e62e .5s reverse}@keyframes bounce-in-30b5e62e{0%{transform:scale(0)}50%{transform:scale(1.25)}to{transform:scale(1)}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@creopse/vue",
3
3
  "description": "Creopse Vue Toolkit",
4
- "version": "0.0.14",
4
+ "version": "0.0.15",
5
5
  "private": false,
6
6
  "author": "Noé Gnanih <noegnanih@gmail.com>",
7
7
  "license": "MIT",
@@ -32,12 +32,19 @@
32
32
  "lint": "eslint 'src/**/*.{ts,vue}'"
33
33
  },
34
34
  "peerDependencies": {
35
+ "@inertiajs/core": "^2.0.0",
36
+ "@inertiajs/vue3": "^2.0.0",
35
37
  "vue": "^3.5.17"
36
38
  },
37
39
  "dependencies": {
38
- "@creopse/utils": "^0.0.10"
40
+ "@creopse/utils": "^0.0.11",
41
+ "@vueuse/core": "^14.1.0",
42
+ "lodash.clonedeep": "^4.5.0"
39
43
  },
40
44
  "devDependencies": {
45
+ "@inertiajs/core": "^2.1.6",
46
+ "@inertiajs/vue3": "^2.1.6",
47
+ "@types/lodash.clonedeep": "^4.5.9",
41
48
  "@vitejs/plugin-vue": "^6.0.0",
42
49
  "@vue/eslint-config-prettier": "^7.1.0",
43
50
  "@vue/eslint-config-typescript": "^11.0.3",
@@ -50,6 +57,7 @@
50
57
  "unplugin-auto-import": "^19.3.0",
51
58
  "unplugin-vue-components": "^28.8.0",
52
59
  "vite": "^7.0.4",
60
+ "vue": "^3.5.21",
53
61
  "vue-tsc": "^2.2.12"
54
62
  },
55
63
  "repository": {
@@ -0,0 +1,23 @@
1
+ import type { CSSProperties } from 'vue';
2
+ 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?: CSSProperties;
10
+ size?: 'small' | 'medium' | 'large' | 'original';
11
+ sync?: boolean;
12
+ }
13
+ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
14
+ size: "small" | "medium" | "large" | "original";
15
+ style: CSSProperties;
16
+ title: string;
17
+ alt: string;
18
+ width: string | number;
19
+ height: string | number;
20
+ loading: "lazy" | "eager";
21
+ sync: boolean;
22
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import type { Payload } from '@/types/api';
2
+ /**
3
+ * This composable 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) => Promise<any>;
17
+ getItem: (payload: Payload) => Promise<{
18
+ success: boolean;
19
+ failure: boolean;
20
+ result: any;
21
+ error: any;
22
+ }>;
23
+ addItem: (payload: Payload) => Promise<{
24
+ success: boolean;
25
+ failure: boolean;
26
+ result: any;
27
+ error: any;
28
+ }>;
29
+ updateItem: (payload: Payload) => Promise<{
30
+ success: boolean;
31
+ failure: boolean;
32
+ result: any;
33
+ error: any;
34
+ }>;
35
+ deleteItem: (payload: Payload) => Promise<{
36
+ success: boolean;
37
+ failure: boolean;
38
+ result: any;
39
+ error: any;
40
+ }>;
41
+ getAllItems: (payload: Payload) => Promise<{
42
+ success: boolean;
43
+ failure: boolean;
44
+ result: any;
45
+ error: any;
46
+ }>;
47
+ handleError: (error: any) => void;
48
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the plugin configuration object.
3
+ *
4
+ * This composable is used to inject the plugin configuration
5
+ * into your Vue components.
6
+ *
7
+ * @returns {PluginConfig} the plugin configuration object
8
+ * @throws {Error} if the plugin is not installed
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
+ langKey: string;
21
+ };
@@ -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 composable 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: globalThis.ComputedRef<string>;
12
+ icon: globalThis.ComputedRef<string>;
13
+ page: import("@inertiajs/core").Page<SharedProps & PageProps>;
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: globalThis.ComputedRef<string>;
52
+ appPrimaryColor: globalThis.ComputedRef<string>;
53
+ appSecondaryColor: globalThis.ComputedRef<string>;
54
+ };
@@ -0,0 +1,32 @@
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: globalThis.ComputedRef<boolean>;
9
+ isXlScreen: globalThis.ComputedRef<boolean>;
10
+ isLgScreen: globalThis.ComputedRef<boolean>;
11
+ isMdScreen: globalThis.ComputedRef<boolean>;
12
+ isSmScreen: globalThis.ComputedRef<boolean>;
13
+ getTranslation: (data: any) => string;
14
+ getLangageLabel: (value: string) => string | undefined;
15
+ getLanguageValue: (label: string) => string | undefined;
16
+ getLinkCursorClass: (url: string) => "tw:cursor-default" | "tw:cursor-pointer";
17
+ ckEditorToolbarItems: string[];
18
+ displayFormErrors: (errors: any, displayError: (message: string) => void) => void;
19
+ resolveHtmlLinks: (data: string | null | undefined) => string;
20
+ pickByTheme: (lightVal: string | number | null, darkVal: string | number | null) => string | number | null;
21
+ resolveUrl: (path: string) => string;
22
+ updateLang: (val: string, reload?: boolean, updateUserPrefs?: boolean) => Promise<void>;
23
+ languages: Language[];
24
+ getImage: (path: string, size?: "small" | "medium" | "large" | "original") => Promise<string>;
25
+ fileUrl: (path: string) => string;
26
+ currentRoutePath: globalThis.ComputedRef<string>;
27
+ openLink: (str: string) => void;
28
+ openMenu: (menu?: MenuItemModel) => void;
29
+ getMenuHref: (menu: MenuItemModel) => string;
30
+ rHtml: (data: string | null | undefined) => string;
31
+ tr: (data: any) => string;
32
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A composable 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) | undefined, errorCallback?: ((errorData: any) => void) | undefined) => Promise<void>;
27
+ subscribeEmail: (email: string, successCallback?: (() => void) | undefined, errorCallback?: ((errorData: any) => void) | undefined) => Promise<void>;
28
+ isLoading: globalThis.Ref<boolean, boolean>;
29
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A composable that returns the props of the page.
3
+ *
4
+ * It injects the PropsManager symbol and returns the props of the page.
5
+ *
6
+ * @throws {Error} if the plugin is not installed
7
+ * @returns {Record<string, any>} the props of the page
8
+ */
9
+ export declare const useProps: () => {
10
+ readonly [x: string]: any;
11
+ };
@@ -0,0 +1,26 @@
1
+ import { Bool, type UserPrefs } from '@creopse/utils';
2
+ /**
3
+ * A composable that exposes the default user preferences.
4
+ *
5
+ * @returns An object containing the `defaultPrefs` property, which is a reactive
6
+ * ref to the default user preferences.
7
+ *
8
+ * The `defaultPrefs` object contains the following properties:
9
+ *
10
+ * - `inAppNotifEnabled`: A boolean indicating whether in-app notifications are
11
+ * enabled by default.
12
+ * - `emailNotifEnabled`: A boolean indicating whether email notifications are
13
+ * enabled by default.
14
+ * - `locale`: The user's preferred locale.
15
+ */
16
+ export declare const useUserPreference: () => {
17
+ defaultPrefs: globalThis.Ref<{
18
+ inAppNotifEnabled?: Bool | undefined;
19
+ emailNotifEnabled?: Bool | undefined;
20
+ locale?: string | undefined;
21
+ }, UserPrefs | {
22
+ inAppNotifEnabled?: Bool | undefined;
23
+ emailNotifEnabled?: Bool | undefined;
24
+ locale?: string | undefined;
25
+ }>;
26
+ };
@@ -0,0 +1,14 @@
1
+ declare class PropsManager {
2
+ private state;
3
+ constructor(initialProps: Record<string, any>);
4
+ update(payload: Record<string, any>): void;
5
+ getState(): {
6
+ readonly props: {
7
+ readonly [x: string]: any;
8
+ };
9
+ };
10
+ sync(newProps: Record<string, any>): void;
11
+ private deepMerge;
12
+ private isObject;
13
+ }
14
+ export default PropsManager;
@@ -0,0 +1,4 @@
1
+ declare const PropsSymbol: unique symbol;
2
+ declare const ConfigSymbol: unique symbol;
3
+ declare const ResolveSectionsSymbol: unique symbol;
4
+ export { PropsSymbol, ConfigSymbol, ResolveSectionsSymbol };
package/types/index.d.ts CHANGED
@@ -1,13 +1,25 @@
1
1
  import type { App } from 'vue';
2
- import RootContainer from './components/core/RootContainer.vue';
2
+ import RootContainer from './components/RootContainer.vue';
3
3
  import AsyncImg from './components/widgets/AsyncImg.vue';
4
4
  import CustomTransition from './components/widgets/CustomTransition.vue';
5
+ import Image from './components/widgets/Image.vue';
5
6
  import MountedTeleport from './components/widgets/MountedTeleport.vue';
6
7
  import ReadMore from './components/widgets/ReadMore.vue';
7
8
  import StickyBottom from './components/widgets/StickyBottom.vue';
8
9
  import StickyTop from './components/widgets/StickyTop.vue';
10
+ import PropsManager from './core/props-manager';
11
+ import type { PluginOptions } from './types/plugin';
9
12
  declare const plugin: {
10
- install(app: App): void;
13
+ install(app: App, options: PluginOptions): void;
11
14
  };
12
- export { RootContainer, CustomTransition, MountedTeleport, StickyBottom, StickyTop, ReadMore, AsyncImg, };
15
+ export { useApi } from './composables/api';
16
+ export { useProps } from './composables/props';
17
+ export { useConfig } from './composables/config';
18
+ export { useHelper } from './composables/helper';
19
+ export { useContent } from './composables/content';
20
+ export { useNewsletter } from './composables/newsletter';
21
+ export { useUserPreference } from './composables/user-preference';
22
+ export type { PropsManager };
23
+ export { RootContainer, CustomTransition, MountedTeleport, StickyBottom, StickyTop, ReadMore, AsyncImg, Image, };
24
+ export type { PluginOptions };
13
25
  export default plugin;
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,15 @@
1
+ export interface PluginConfig {
2
+ debug: boolean;
3
+ appUrl: string;
4
+ xApiKey: string;
5
+ encryptionKey: string;
6
+ langKey: string;
7
+ }
8
+ export interface PluginOptions {
9
+ initialProps: Record<string, any>;
10
+ router?: {
11
+ on: (event: string, callback: (e: any) => void) => void;
12
+ };
13
+ resolveSections: () => Record<string, unknown>;
14
+ config: PluginConfig;
15
+ }