@edifice.io/react 2.2.11-develop-pedago.20250708131559 → 2.2.11-develop-pedago.20250710120949
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.
|
@@ -21,7 +21,7 @@ function useEdificeIcons() {
|
|
|
21
21
|
};
|
|
22
22
|
function getIconCode(app) {
|
|
23
23
|
let appCode = "";
|
|
24
|
-
switch (typeof app == "string" ? appCode = app : appCode = (app == null ? void 0 : app.icon) !== void 0 ? app == null ? void 0 : app.icon.trim().toLowerCase() : "placeholder", appCode && appCode.length > 0 ? appCode.endsWith("-large") && (appCode = appCode.replace("-large", "")) : typeof app == "object" && (appCode = (app == null ? void 0 : app.displayName) !== void 0 ? app == null ? void 0 : app.displayName.trim().toLowerCase() : ""), appCode) {
|
|
24
|
+
switch (typeof app == "string" ? appCode = app : appCode = (app == null ? void 0 : app.icon) !== void 0 ? app == null ? void 0 : app.icon.trim().toLowerCase() : "placeholder", appCode && appCode.length > 0 ? appCode.endsWith("-large") && (appCode = appCode.replace("-large", "")) : typeof app == "object" && (appCode = (app == null ? void 0 : app.displayName) !== void 0 ? app == null ? void 0 : app.displayName.trim().toLowerCase() : ""), console.log(appCode), appCode) {
|
|
25
25
|
case "admin.title":
|
|
26
26
|
appCode = "admin";
|
|
27
27
|
break;
|
|
@@ -34,6 +34,9 @@ function useEdificeIcons() {
|
|
|
34
34
|
case "communautés":
|
|
35
35
|
appCode = "community";
|
|
36
36
|
break;
|
|
37
|
+
case "communities":
|
|
38
|
+
appCode = "community";
|
|
39
|
+
break;
|
|
37
40
|
case "directory.user":
|
|
38
41
|
appCode = "userbook";
|
|
39
42
|
break;
|
|
@@ -7,13 +7,53 @@ export interface FormInputs {
|
|
|
7
7
|
enablePublic: boolean;
|
|
8
8
|
formSlug: string;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Custom translations interface for overriding default translations
|
|
12
|
+
*/
|
|
13
|
+
export interface ResourceModalTranslations {
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
cancel?: string;
|
|
17
|
+
create?: string;
|
|
18
|
+
save?: string;
|
|
19
|
+
header?: {
|
|
20
|
+
create?: string;
|
|
21
|
+
edit?: string;
|
|
22
|
+
};
|
|
23
|
+
heading?: {
|
|
24
|
+
general?: string;
|
|
25
|
+
access?: string;
|
|
26
|
+
};
|
|
27
|
+
placeholder?: {
|
|
28
|
+
title?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
};
|
|
31
|
+
imagepicker?: {
|
|
32
|
+
add?: string;
|
|
33
|
+
delete?: string;
|
|
34
|
+
};
|
|
35
|
+
success?: {
|
|
36
|
+
created?: string;
|
|
37
|
+
updated?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
10
40
|
interface BaseProps {
|
|
41
|
+
/** Controls modal visibility */
|
|
11
42
|
isOpen: boolean;
|
|
43
|
+
/** Custom content to be displayed after the form fields */
|
|
12
44
|
children?: ReactNode | ((...props: any) => ReactNode);
|
|
45
|
+
/** Maximum length for the title input */
|
|
13
46
|
inputMaxLength?: number;
|
|
47
|
+
/** Maximum length for the description textarea */
|
|
14
48
|
textareaMaxLength?: number;
|
|
15
|
-
|
|
49
|
+
/** Callback when operation succeeds, with operation result as parameter */
|
|
50
|
+
onSuccess: (result: CreateResult | UpdateResult) => void;
|
|
51
|
+
/** Callback when operation is cancelled */
|
|
16
52
|
onCancel: () => void;
|
|
53
|
+
/** Override application code (uses EdificeClient context by default) */
|
|
54
|
+
appCode?: string;
|
|
55
|
+
/** Custom translations for the modal */
|
|
56
|
+
translations?: ResourceModalTranslations;
|
|
17
57
|
}
|
|
18
58
|
interface CreateProps extends BaseProps {
|
|
19
59
|
mode: 'create';
|
|
@@ -26,5 +66,20 @@ interface UpdateProps extends BaseProps {
|
|
|
26
66
|
resourceId: ID;
|
|
27
67
|
}
|
|
28
68
|
type Props = CreateProps | UpdateProps;
|
|
29
|
-
|
|
69
|
+
/**
|
|
70
|
+
* ResourceModal component for creating or updating resources
|
|
71
|
+
*
|
|
72
|
+
* @component
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* <ResourceModal
|
|
76
|
+
* mode="create"
|
|
77
|
+
* isOpen={true}
|
|
78
|
+
* onCancel={() => setOpen(false)}
|
|
79
|
+
* onSuccess={(result) => console.log('Resource created:', result)}
|
|
80
|
+
* currentFolder={{ id: 'default' }}
|
|
81
|
+
* />
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const ResourceModal: ({ isOpen, onCancel, onSuccess, children, appCode: customAppCode, translations: customT, inputMaxLength, textareaMaxLength, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
30
85
|
export default ResourceModal;
|
|
@@ -25,14 +25,17 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
|
|
|
25
25
|
onCancel,
|
|
26
26
|
onSuccess,
|
|
27
27
|
children,
|
|
28
|
+
appCode: customAppCode,
|
|
29
|
+
translations: customT = {},
|
|
28
30
|
inputMaxLength = DEFAULT_INPUT_MAX_LENGTH,
|
|
29
31
|
textareaMaxLength = DEFAULT_TEXTAREA_MAX_LENGTH,
|
|
30
32
|
...props
|
|
31
33
|
}) => {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
35
|
const {
|
|
33
|
-
appCode:
|
|
36
|
+
appCode: contextAppCode,
|
|
34
37
|
currentApp
|
|
35
|
-
} = useEdificeClient(), {
|
|
38
|
+
} = useEdificeClient(), application = customAppCode || contextAppCode, {
|
|
36
39
|
t
|
|
37
40
|
} = useTranslation(), {
|
|
38
41
|
mode
|
|
@@ -65,7 +68,7 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
|
|
|
65
68
|
isUpdating,
|
|
66
69
|
selectedResource: isUpdating ? resource : void 0
|
|
67
70
|
}), watchedDescription = watch("description"), onSubmit = async function(formData) {
|
|
68
|
-
var
|
|
71
|
+
var _a2, _b2;
|
|
69
72
|
try {
|
|
70
73
|
const data = {
|
|
71
74
|
description: formData.description || "",
|
|
@@ -74,21 +77,22 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
|
|
|
74
77
|
slug: formData.enablePublic && formData.formSlug || "",
|
|
75
78
|
thumbnail
|
|
76
79
|
};
|
|
80
|
+
let result;
|
|
77
81
|
if (isCreating) {
|
|
78
82
|
const createParams = {
|
|
79
83
|
...data,
|
|
80
84
|
folder: props.currentFolder === void 0 || // Fix #WB2-1296: when searching, currentFolder is undefined
|
|
81
|
-
((
|
|
85
|
+
((_a2 = props.currentFolder) == null ? void 0 : _a2.id) === "default" ? void 0 : parseInt(((_b2 = props.currentFolder) == null ? void 0 : _b2.id) || ""),
|
|
82
86
|
application
|
|
83
87
|
};
|
|
84
|
-
props.createResource ? await props.createResource.mutateAsync(createParams) : await odeServices.resource(application).create(createParams);
|
|
88
|
+
props.createResource ? result = await props.createResource.mutateAsync(createParams) : result = await odeServices.resource(application).create(createParams);
|
|
85
89
|
} else {
|
|
86
90
|
const updateParams = {
|
|
87
91
|
...data,
|
|
88
92
|
entId: resource.assetId,
|
|
89
93
|
trashed: resource.trashed
|
|
90
94
|
};
|
|
91
|
-
props.updateResource ? await props.updateResource.mutateAsync(updateParams) : await odeServices.resource(application).update(updateParams);
|
|
95
|
+
props.updateResource ? result = await props.updateResource.mutateAsync(updateParams) : result = await odeServices.resource(application).update(updateParams);
|
|
92
96
|
}
|
|
93
97
|
toast.success(/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
98
|
/* @__PURE__ */ jsx("strong", { children: t(isCreating ? "explorer.resource.created" : "explorer.resource.updated") }),
|
|
@@ -106,21 +110,21 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
|
|
|
106
110
|
"Public:",
|
|
107
111
|
formData.enablePublic ? t("explorer.enable.public.yes") : t("explorer.enable.public.no")
|
|
108
112
|
] })
|
|
109
|
-
] })), onSuccess();
|
|
113
|
+
] })), onSuccess(result);
|
|
110
114
|
} catch (e) {
|
|
111
115
|
console.error(e);
|
|
112
116
|
}
|
|
113
117
|
};
|
|
114
118
|
return isUpdating && !resource ? /* @__PURE__ */ jsx(LoadingScreen, {}) : /* @__PURE__ */ createPortal(/* @__PURE__ */ jsxs(Modal, { id: `${mode}-resource`, size: "lg", isOpen, onModalClose: onCancel, children: [
|
|
115
|
-
/* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t(`explorer.resource.editModal.header.${isCreating ? "create" : "edit"}`) }),
|
|
119
|
+
/* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: ((_a = customT.header) == null ? void 0 : _a[isCreating ? "create" : "edit"]) ?? t(`explorer.resource.editModal.header.${isCreating ? "create" : "edit"}`) }),
|
|
116
120
|
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
|
117
|
-
/* @__PURE__ */ jsx(Heading, { headingStyle: "h4", level: "h3", className: "mb-16", children: t("explorer.resource.editModal.heading.general") }),
|
|
121
|
+
/* @__PURE__ */ jsx(Heading, { headingStyle: "h4", level: "h3", className: "mb-16", children: ((_b = customT.heading) == null ? void 0 : _b.general) ?? t("explorer.resource.editModal.heading.general") }),
|
|
118
122
|
/* @__PURE__ */ jsxs("form", { id: formId, onSubmit: handleSubmit(onSubmit), children: [
|
|
119
123
|
/* @__PURE__ */ jsxs("div", { className: "d-block d-md-flex gap-16 mb-24", children: [
|
|
120
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ImagePicker, { app: currentApp, src: isUpdating && (resource == null ? void 0 : resource.thumbnail) || "", addButtonLabel: t("explorer.imagepicker.button.add"), deleteButtonLabel: t("explorer.imagepicker.button.delete"), onUploadImage: handleUploadImage, onDeleteImage: handleDeleteImage, className: "align-self-center mt-8", libraryMedia, mediaLibraryRef }) }),
|
|
124
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ImagePicker, { app: currentApp, src: isUpdating && (resource == null ? void 0 : resource.thumbnail) || "", addButtonLabel: ((_c = customT.imagepicker) == null ? void 0 : _c.add) ?? t("explorer.imagepicker.button.add"), deleteButtonLabel: ((_d = customT.imagepicker) == null ? void 0 : _d.delete) ?? t("explorer.imagepicker.button.delete"), onUploadImage: handleUploadImage, onDeleteImage: handleDeleteImage, className: "align-self-center mt-8", libraryMedia, mediaLibraryRef }) }),
|
|
121
125
|
/* @__PURE__ */ jsxs("div", { className: "col", children: [
|
|
122
126
|
/* @__PURE__ */ jsxs(FormControl, { id: "title", className: "mb-16", isRequired: !0, children: [
|
|
123
|
-
/* @__PURE__ */ jsx(Label, { children: t("title") }),
|
|
127
|
+
/* @__PURE__ */ jsx(Label, { children: customT.title ?? t("title") }),
|
|
124
128
|
/* @__PURE__ */ jsx(Input, { type: "text", defaultValue: isUpdating ? resource == null ? void 0 : resource.name : "", ...register("title", {
|
|
125
129
|
required: !0,
|
|
126
130
|
maxLength: inputMaxLength,
|
|
@@ -128,14 +132,14 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
|
|
|
128
132
|
value: /[^ ]/,
|
|
129
133
|
message: "invalid title"
|
|
130
134
|
}
|
|
131
|
-
}), placeholder: t("explorer.resource.editModal.title.placeholder"), size: "md", "aria-required": !0, maxLength: inputMaxLength })
|
|
135
|
+
}), placeholder: ((_e = customT.placeholder) == null ? void 0 : _e.title) ?? t("explorer.resource.editModal.title.placeholder"), size: "md", "aria-required": !0, maxLength: inputMaxLength })
|
|
132
136
|
] }),
|
|
133
137
|
/* @__PURE__ */ jsxs(FormControl, { id: "description", isOptional: !0, children: [
|
|
134
|
-
/* @__PURE__ */ jsx(Label, { children: t("description") }),
|
|
138
|
+
/* @__PURE__ */ jsx(Label, { children: customT.description ?? t("description") }),
|
|
135
139
|
/* @__PURE__ */ jsx(TextArea, { defaultValue: (resource == null ? void 0 : resource.description) || "", ...register("description", {
|
|
136
140
|
required: !1,
|
|
137
141
|
maxLength: textareaMaxLength
|
|
138
|
-
}), placeholder: t("explorer.resource.editModal.description.placeholder"), size: "md", maxLength: textareaMaxLength }),
|
|
142
|
+
}), placeholder: ((_f = customT.placeholder) == null ? void 0 : _f.description) ?? t("explorer.resource.editModal.description.placeholder"), size: "md", maxLength: textareaMaxLength }),
|
|
139
143
|
watchedDescription && /* @__PURE__ */ jsx(TextareaCounter, { content: watchedDescription, maxLength: textareaMaxLength })
|
|
140
144
|
] })
|
|
141
145
|
] })
|
|
@@ -144,8 +148,8 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
|
|
|
144
148
|
] })
|
|
145
149
|
] }),
|
|
146
150
|
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
147
|
-
/* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("explorer.cancel") }),
|
|
148
|
-
/* @__PURE__ */ jsx(Button, { form: formId, type: "submit", color: "primary", isLoading: isSubmitting, variant: "filled", disabled: !isValid || isSubmitting, children:
|
|
151
|
+
/* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: customT.cancel ?? t("explorer.cancel") }),
|
|
152
|
+
/* @__PURE__ */ jsx(Button, { form: formId, type: "submit", color: "primary", isLoading: isSubmitting, variant: "filled", disabled: !isValid || isSubmitting, children: isCreating ? customT.create ?? t("explorer.create") : customT.save ?? t("save") })
|
|
149
153
|
] }),
|
|
150
154
|
/* @__PURE__ */ jsx(MediaLibrary, { appCode: application, ref: mediaLibraryRef, multiple: !1, visibility: "protected", ...mediaLibraryHandlers })
|
|
151
155
|
] }), document.getElementById("portal"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.2.11-develop-pedago.
|
|
3
|
+
"version": "2.2.11-develop-pedago.20250710120949",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -130,9 +130,9 @@
|
|
|
130
130
|
"react-slugify": "^3.0.3",
|
|
131
131
|
"swiper": "^10.1.0",
|
|
132
132
|
"ua-parser-js": "^1.0.36",
|
|
133
|
-
"@edifice.io/
|
|
134
|
-
"@edifice.io/
|
|
135
|
-
"@edifice.io/utilities": "2.2.11-develop-pedago.
|
|
133
|
+
"@edifice.io/bootstrap": "2.2.11-develop-pedago.20250710120949",
|
|
134
|
+
"@edifice.io/tiptap-extensions": "2.2.11-develop-pedago.20250710120949",
|
|
135
|
+
"@edifice.io/utilities": "2.2.11-develop-pedago.20250710120949"
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
138
|
"@babel/plugin-transform-react-pure-annotations": "^7.23.3",
|
|
@@ -163,8 +163,8 @@
|
|
|
163
163
|
"vite": "^5.4.11",
|
|
164
164
|
"vite-plugin-dts": "^4.1.0",
|
|
165
165
|
"vite-tsconfig-paths": "^5.0.1",
|
|
166
|
-
"@edifice.io/client": "2.2.11-develop-pedago.
|
|
167
|
-
"@edifice.io/config": "2.2.11-develop-pedago.
|
|
166
|
+
"@edifice.io/client": "2.2.11-develop-pedago.20250710120949",
|
|
167
|
+
"@edifice.io/config": "2.2.11-develop-pedago.20250710120949"
|
|
168
168
|
},
|
|
169
169
|
"peerDependencies": {
|
|
170
170
|
"@react-spring/web": "^9.7.5",
|