@creopse/react 0.0.24 → 0.0.26
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/{content-Cgzd1E-Q.cjs → content-DKqcW0Dp.cjs} +51 -12
- package/dist/{content-DP8wQsOf.js → content-YRSMxojU.js} +51 -12
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/types/hooks/content.d.ts +4 -5
- package/types/types/content.d.ts +11 -0
|
@@ -6791,6 +6791,9 @@ var ProfileType;
|
|
|
6791
6791
|
var ResponseErrorCode;
|
|
6792
6792
|
(function(ResponseErrorCode2) {
|
|
6793
6793
|
ResponseErrorCode2["FORM_INVALID_DATA"] = "form/invalid_data";
|
|
6794
|
+
ResponseErrorCode2["REQUEST_PARAMS_MISSING"] = "request/params_missing";
|
|
6795
|
+
ResponseErrorCode2["REQUEST_DATA_RETRIEVAL_FAILED"] = "request/data_retrieval_failed";
|
|
6796
|
+
ResponseErrorCode2["REQUEST_DATA_ALREADY_EXISTS"] = "request/data_already_exists";
|
|
6794
6797
|
ResponseErrorCode2["AUTH_LOGIN_FAILED"] = "auth/login_failed";
|
|
6795
6798
|
ResponseErrorCode2["AUTH_REGISTRATION_FAILED"] = "auth/registration_failed";
|
|
6796
6799
|
ResponseErrorCode2["AUTH_MISSING_DATA"] = "auth/missing_data";
|
|
@@ -7943,9 +7946,25 @@ const useContent = () => {
|
|
|
7943
7946
|
[request, formatContentModelItemData]
|
|
7944
7947
|
);
|
|
7945
7948
|
const getPaginatedContentModelItems = React.useCallback(
|
|
7946
|
-
async (name, pageSize, filterByIsActive = true) => {
|
|
7949
|
+
async (name, page2, pageSize, filterByIsActive = true, query, dataFilters) => {
|
|
7950
|
+
const params = new URLSearchParams({
|
|
7951
|
+
page: String(page2),
|
|
7952
|
+
pageSize: String(pageSize),
|
|
7953
|
+
contentModelName: name
|
|
7954
|
+
});
|
|
7955
|
+
if (filterByIsActive) params.append("isActive", "true");
|
|
7956
|
+
if (query) params.append("query", query);
|
|
7957
|
+
if (dataFilters?.length) {
|
|
7958
|
+
dataFilters.forEach((filter2, index) => {
|
|
7959
|
+
params.append(`dataFilters[${index}][key]`, filter2.key);
|
|
7960
|
+
params.append(`dataFilters[${index}][value]`, filter2.value);
|
|
7961
|
+
if (filter2.operator) {
|
|
7962
|
+
params.append(`dataFilters[${index}][operator]`, filter2.operator);
|
|
7963
|
+
}
|
|
7964
|
+
});
|
|
7965
|
+
}
|
|
7947
7966
|
const task = await request({
|
|
7948
|
-
url: `content-model/items
|
|
7967
|
+
url: `content-model/items?${params.toString()}`
|
|
7949
7968
|
});
|
|
7950
7969
|
if (task.success && task.result) {
|
|
7951
7970
|
const items = (task.result.data?.items || []).map(
|
|
@@ -7953,17 +7972,9 @@ const useContent = () => {
|
|
|
7953
7972
|
);
|
|
7954
7973
|
const total = task.result.data?.meta?.total || 0;
|
|
7955
7974
|
const currentPage = task.result.data?.meta?.currentPage || 1;
|
|
7956
|
-
return {
|
|
7957
|
-
items,
|
|
7958
|
-
total,
|
|
7959
|
-
currentPage
|
|
7960
|
-
};
|
|
7975
|
+
return { items, total, currentPage };
|
|
7961
7976
|
}
|
|
7962
|
-
return {
|
|
7963
|
-
items: [],
|
|
7964
|
-
total: 0,
|
|
7965
|
-
currentPage: 1
|
|
7966
|
-
};
|
|
7977
|
+
return { items: [], total: 0, currentPage: 1 };
|
|
7967
7978
|
},
|
|
7968
7979
|
[request, formatContentModelItemData]
|
|
7969
7980
|
);
|
|
@@ -7990,6 +8001,32 @@ const useContent = () => {
|
|
|
7990
8001
|
},
|
|
7991
8002
|
[request]
|
|
7992
8003
|
);
|
|
8004
|
+
const getContentPath = React.useCallback(
|
|
8005
|
+
(name, item) => {
|
|
8006
|
+
const permalinks = props?.permalinks || [];
|
|
8007
|
+
switch (name) {
|
|
8008
|
+
case "news-article":
|
|
8009
|
+
case "news-category":
|
|
8010
|
+
case "news-tag": {
|
|
8011
|
+
const permalink = permalinks?.find((p) => p.contentType === name);
|
|
8012
|
+
if (!permalink) {
|
|
8013
|
+
return "";
|
|
8014
|
+
}
|
|
8015
|
+
return `${permalink.pathPrefix}/${permalink.contentParam ? item[permalink.contentParam] : item.id}`;
|
|
8016
|
+
}
|
|
8017
|
+
default: {
|
|
8018
|
+
const permalink = permalinks?.find(
|
|
8019
|
+
(p) => p.content?.name === name
|
|
8020
|
+
);
|
|
8021
|
+
if (!permalink) {
|
|
8022
|
+
return "";
|
|
8023
|
+
}
|
|
8024
|
+
return `${permalink.pathPrefix}/${permalink.contentParam ? item?.data[permalink.contentParam] : item.id}`;
|
|
8025
|
+
}
|
|
8026
|
+
}
|
|
8027
|
+
},
|
|
8028
|
+
[props?.permalinks]
|
|
8029
|
+
);
|
|
7993
8030
|
const getMenu = React.useCallback(
|
|
7994
8031
|
(name, filterByIsActive = true) => {
|
|
7995
8032
|
const menu = cloneDeep(props?.menus?.find((menu2) => menu2.name === name));
|
|
@@ -8163,11 +8200,13 @@ const useContent = () => {
|
|
|
8163
8200
|
getSectionSetting,
|
|
8164
8201
|
getAnySectionData,
|
|
8165
8202
|
getSectionRootData,
|
|
8203
|
+
getContentPath,
|
|
8166
8204
|
getContentModel,
|
|
8167
8205
|
getContentModelItems,
|
|
8168
8206
|
getPaginatedContentModelItems,
|
|
8169
8207
|
getAppInformationValue,
|
|
8170
8208
|
submitUserContentModelItem,
|
|
8209
|
+
formatContentModelItemData,
|
|
8171
8210
|
appAccentColor,
|
|
8172
8211
|
appPrimaryColor,
|
|
8173
8212
|
appSecondaryColor
|
|
@@ -6790,6 +6790,9 @@ var ProfileType;
|
|
|
6790
6790
|
var ResponseErrorCode;
|
|
6791
6791
|
(function(ResponseErrorCode2) {
|
|
6792
6792
|
ResponseErrorCode2["FORM_INVALID_DATA"] = "form/invalid_data";
|
|
6793
|
+
ResponseErrorCode2["REQUEST_PARAMS_MISSING"] = "request/params_missing";
|
|
6794
|
+
ResponseErrorCode2["REQUEST_DATA_RETRIEVAL_FAILED"] = "request/data_retrieval_failed";
|
|
6795
|
+
ResponseErrorCode2["REQUEST_DATA_ALREADY_EXISTS"] = "request/data_already_exists";
|
|
6793
6796
|
ResponseErrorCode2["AUTH_LOGIN_FAILED"] = "auth/login_failed";
|
|
6794
6797
|
ResponseErrorCode2["AUTH_REGISTRATION_FAILED"] = "auth/registration_failed";
|
|
6795
6798
|
ResponseErrorCode2["AUTH_MISSING_DATA"] = "auth/missing_data";
|
|
@@ -7942,9 +7945,25 @@ const useContent = () => {
|
|
|
7942
7945
|
[request, formatContentModelItemData]
|
|
7943
7946
|
);
|
|
7944
7947
|
const getPaginatedContentModelItems = useCallback(
|
|
7945
|
-
async (name, pageSize, filterByIsActive = true) => {
|
|
7948
|
+
async (name, page2, pageSize, filterByIsActive = true, query, dataFilters) => {
|
|
7949
|
+
const params = new URLSearchParams({
|
|
7950
|
+
page: String(page2),
|
|
7951
|
+
pageSize: String(pageSize),
|
|
7952
|
+
contentModelName: name
|
|
7953
|
+
});
|
|
7954
|
+
if (filterByIsActive) params.append("isActive", "true");
|
|
7955
|
+
if (query) params.append("query", query);
|
|
7956
|
+
if (dataFilters?.length) {
|
|
7957
|
+
dataFilters.forEach((filter2, index) => {
|
|
7958
|
+
params.append(`dataFilters[${index}][key]`, filter2.key);
|
|
7959
|
+
params.append(`dataFilters[${index}][value]`, filter2.value);
|
|
7960
|
+
if (filter2.operator) {
|
|
7961
|
+
params.append(`dataFilters[${index}][operator]`, filter2.operator);
|
|
7962
|
+
}
|
|
7963
|
+
});
|
|
7964
|
+
}
|
|
7946
7965
|
const task = await request({
|
|
7947
|
-
url: `content-model/items
|
|
7966
|
+
url: `content-model/items?${params.toString()}`
|
|
7948
7967
|
});
|
|
7949
7968
|
if (task.success && task.result) {
|
|
7950
7969
|
const items = (task.result.data?.items || []).map(
|
|
@@ -7952,17 +7971,9 @@ const useContent = () => {
|
|
|
7952
7971
|
);
|
|
7953
7972
|
const total = task.result.data?.meta?.total || 0;
|
|
7954
7973
|
const currentPage = task.result.data?.meta?.currentPage || 1;
|
|
7955
|
-
return {
|
|
7956
|
-
items,
|
|
7957
|
-
total,
|
|
7958
|
-
currentPage
|
|
7959
|
-
};
|
|
7974
|
+
return { items, total, currentPage };
|
|
7960
7975
|
}
|
|
7961
|
-
return {
|
|
7962
|
-
items: [],
|
|
7963
|
-
total: 0,
|
|
7964
|
-
currentPage: 1
|
|
7965
|
-
};
|
|
7976
|
+
return { items: [], total: 0, currentPage: 1 };
|
|
7966
7977
|
},
|
|
7967
7978
|
[request, formatContentModelItemData]
|
|
7968
7979
|
);
|
|
@@ -7989,6 +8000,32 @@ const useContent = () => {
|
|
|
7989
8000
|
},
|
|
7990
8001
|
[request]
|
|
7991
8002
|
);
|
|
8003
|
+
const getContentPath = useCallback(
|
|
8004
|
+
(name, item) => {
|
|
8005
|
+
const permalinks = props?.permalinks || [];
|
|
8006
|
+
switch (name) {
|
|
8007
|
+
case "news-article":
|
|
8008
|
+
case "news-category":
|
|
8009
|
+
case "news-tag": {
|
|
8010
|
+
const permalink = permalinks?.find((p) => p.contentType === name);
|
|
8011
|
+
if (!permalink) {
|
|
8012
|
+
return "";
|
|
8013
|
+
}
|
|
8014
|
+
return `${permalink.pathPrefix}/${permalink.contentParam ? item[permalink.contentParam] : item.id}`;
|
|
8015
|
+
}
|
|
8016
|
+
default: {
|
|
8017
|
+
const permalink = permalinks?.find(
|
|
8018
|
+
(p) => p.content?.name === name
|
|
8019
|
+
);
|
|
8020
|
+
if (!permalink) {
|
|
8021
|
+
return "";
|
|
8022
|
+
}
|
|
8023
|
+
return `${permalink.pathPrefix}/${permalink.contentParam ? item?.data[permalink.contentParam] : item.id}`;
|
|
8024
|
+
}
|
|
8025
|
+
}
|
|
8026
|
+
},
|
|
8027
|
+
[props?.permalinks]
|
|
8028
|
+
);
|
|
7992
8029
|
const getMenu = useCallback(
|
|
7993
8030
|
(name, filterByIsActive = true) => {
|
|
7994
8031
|
const menu = cloneDeep(props?.menus?.find((menu2) => menu2.name === name));
|
|
@@ -8162,11 +8199,13 @@ const useContent = () => {
|
|
|
8162
8199
|
getSectionSetting,
|
|
8163
8200
|
getAnySectionData,
|
|
8164
8201
|
getSectionRootData,
|
|
8202
|
+
getContentPath,
|
|
8165
8203
|
getContentModel,
|
|
8166
8204
|
getContentModelItems,
|
|
8167
8205
|
getPaginatedContentModelItems,
|
|
8168
8206
|
getAppInformationValue,
|
|
8169
8207
|
submitUserContentModelItem,
|
|
8208
|
+
formatContentModelItemData,
|
|
8170
8209
|
appAccentColor,
|
|
8171
8210
|
appPrimaryColor,
|
|
8172
8211
|
appSecondaryColor
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const content = require("../content-
|
|
3
|
+
const content = require("../content-DKqcW0Dp.cjs");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const articlesUrlBuilder = (p) => {
|
|
6
6
|
const searchParams = new URLSearchParams();
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as useApi } from "../content-
|
|
2
|
-
import { f, a, u, b } from "../content-
|
|
1
|
+
import { e as useApi } from "../content-YRSMxojU.js";
|
|
2
|
+
import { f, a, u, b } from "../content-YRSMxojU.js";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
4
|
const articlesUrlBuilder = (p) => {
|
|
5
5
|
const searchParams = new URLSearchParams();
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const content = require("./content-
|
|
4
|
+
const content = require("./content-DKqcW0Dp.cjs");
|
|
5
5
|
const react = require("@inertiajs/react");
|
|
6
6
|
const reactDom = require("react-dom");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React__default, { useState, useEffect, createContext, useRef, useLayoutEffect, useId, useContext, useInsertionEffect, useMemo, useCallback, Children, isValidElement, Fragment, createElement, forwardRef, Component } from "react";
|
|
3
|
-
import { u as useHelper, a as useContent, b as useProps, P as PropsContext, R as ResolveSectionsContext, c as cloneDeep, s as slideToId, E as EditorMessageType, d as RouterContext, C as ConfigContext } from "./content-
|
|
3
|
+
import { u as useHelper, a as useContent, b as useProps, P as PropsContext, R as ResolveSectionsContext, c as cloneDeep, s as slideToId, E as EditorMessageType, d as RouterContext, C as ConfigContext } from "./content-YRSMxojU.js";
|
|
4
4
|
import { router } from "@inertiajs/react";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
var jsxRuntime = { exports: {} };
|
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.26",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Noé Gnanih <noegnanih@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-dom": "^19.1.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@creopse/utils": "^0.0.
|
|
46
|
+
"@creopse/utils": "^0.0.15",
|
|
47
47
|
"@vueuse/core": "^14.1.0",
|
|
48
48
|
"axios": "^1.13.2",
|
|
49
49
|
"framer-motion": "^12.23.9",
|
package/types/hooks/content.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Response } from '@/types/api';
|
|
2
|
+
import type { DataFilter, PaginatedContentModelItems } from '@/types/content';
|
|
2
3
|
import type { AppInformationKey, ContentModelItemModel, ContentModelModel, MenuItemGroupModel, MenuItemModel, MenuModel, NewsArticleModel, NewsCategoryModel, NewsTagModel, PageModel, SettingType, SharedProps } from '@creopse/utils';
|
|
3
4
|
/**
|
|
4
5
|
* A hook that provides a set of functions and properties for
|
|
@@ -34,15 +35,13 @@ export declare const useContent: () => {
|
|
|
34
35
|
getSectionSetting: (key: string | null | undefined, group: string, name: string) => object | any | null;
|
|
35
36
|
getAnySectionData: (sectionSlug: string, pageSlug: string, linkId?: string) => Promise<any>;
|
|
36
37
|
getSectionRootData: (key?: string) => any;
|
|
38
|
+
getContentPath: (name: "news-article" | "news-category" | "news-tag" | string, item: ContentModelItemModel | any) => string;
|
|
37
39
|
getContentModel: (name: string) => ContentModelModel | undefined;
|
|
38
40
|
getContentModelItems: (name: string, filterByIsActive?: boolean) => Promise<ContentModelItemModel[]>;
|
|
39
|
-
getPaginatedContentModelItems: (name: string, pageSize: number, filterByIsActive?: boolean) => Promise<
|
|
40
|
-
items: ContentModelItemModel[];
|
|
41
|
-
total: number;
|
|
42
|
-
currentPage: number;
|
|
43
|
-
}>;
|
|
41
|
+
getPaginatedContentModelItems: (name: string, page: number, pageSize: number, filterByIsActive?: boolean, query?: string, dataFilters?: DataFilter[]) => Promise<PaginatedContentModelItems>;
|
|
44
42
|
getAppInformationValue: (key: AppInformationKey, type?: SettingType) => any;
|
|
45
43
|
submitUserContentModelItem: (title: string, contentModelId: string, singletonsData?: any, collectionsData?: any, successCallback?: () => void, errorCallback?: (errorData: any) => void) => Promise<Response<any>>;
|
|
44
|
+
formatContentModelItemData: (item: ContentModelItemModel) => object;
|
|
46
45
|
appAccentColor: string;
|
|
47
46
|
appPrimaryColor: string;
|
|
48
47
|
appSecondaryColor: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ContentModelItemModel } from '@creopse/utils';
|
|
2
|
+
export type DataFilter = {
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
operator?: '=' | '!=' | '>' | '>=' | '<' | '<=' | 'like' | 'json_contains';
|
|
6
|
+
};
|
|
7
|
+
export interface PaginatedContentModelItems {
|
|
8
|
+
items: ContentModelItemModel[];
|
|
9
|
+
total: number;
|
|
10
|
+
currentPage: number;
|
|
11
|
+
}
|