@edifice.io/react 2.0.0-develop-pedago.20250108152614 → 2.0.0-develop-b2school.20250108160141

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.
@@ -5,6 +5,10 @@ export type ListProps<T> = {
5
5
  * Toolbar data items
6
6
  */
7
7
  items?: ToolbarItem[];
8
+ /**
9
+ * Checkable list
10
+ */
11
+ isCheckable?: boolean;
8
12
  /**
9
13
  * Generic data
10
14
  */
@@ -20,4 +24,4 @@ export type ListProps<T> = {
20
24
  };
21
25
  export declare const List: <T extends {
22
26
  _id: string;
23
- }>({ items, data, renderNode, onSelectedItems, }: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
27
+ }>({ items, isCheckable, data, renderNode, onSelectedItems, }: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -7,6 +7,7 @@ import Checkbox from "../Checkbox/Checkbox.js";
7
7
  import { Toolbar } from "../Toolbar/Toolbar.js";
8
8
  const List = ({
9
9
  items,
10
+ isCheckable = !1,
10
11
  data,
11
12
  renderNode,
12
13
  onSelectedItems
@@ -21,9 +22,10 @@ const List = ({
21
22
  return useEffect(() => {
22
23
  selectedItems && (onSelectedItems == null || onSelectedItems(selectedItems));
23
24
  }, [onSelectedItems, selectedItems]), /* @__PURE__ */ jsxs(Fragment, { children: [
24
- items && /* @__PURE__ */ jsxs(Fragment, { children: [
25
+ (items || isCheckable) && /* @__PURE__ */ jsxs(Fragment, { children: [
25
26
  /* @__PURE__ */ jsx("div", { className: clsx("d-flex align-items-center gap-8", {
26
- "px-12": items
27
+ "px-12": items,
28
+ "px-12 py-12": !(items != null && items.length)
27
29
  }), children: /* @__PURE__ */ jsxs(Fragment, { children: [
28
30
  /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-8", children: [
29
31
  /* @__PURE__ */ jsx(Checkbox, { checked: allItemsSelected, indeterminate: isIndeterminate, onChange: () => handleOnSelectAllItems(allItemsSelected) }),
@@ -33,7 +35,7 @@ const List = ({
33
35
  ")"
34
36
  ] })
35
37
  ] }),
36
- /* @__PURE__ */ jsx(Toolbar, { items, isBlock: !0, align: "left", variant: "no-shadow", className: clsx("gap-4 py-4", {
38
+ items && /* @__PURE__ */ jsx(Toolbar, { items, isBlock: !0, align: "left", variant: "no-shadow", className: clsx("gap-4 py-4", {
37
39
  "px-0 ms-auto": !isDesktopDevice
38
40
  }) })
39
41
  ] }) }),
@@ -20,7 +20,7 @@ const Root = /* @__PURE__ */ forwardRef((props, ref) => {
20
20
  scrollable = !1,
21
21
  focusId,
22
22
  children
23
- } = props, ariaLabelId = `aria_label_${id}`, ariaDescriptionId = `aria_desc_${id}`, modalRef = useClickOutside(onModalClose), trapRef = useTrapFocus(isOpen);
23
+ } = props, ariaLabelId = `aria_label_${id}`, ariaDescriptionId = `aria_desc_${id}`, modalRef = useClickOutside(onModalClose), trapRef = useTrapFocus();
24
24
  useKeyPress(onModalClose, ["Escape"]), useEffect(() => {
25
25
  if (isOpen && (document.body.style.overflow = "hidden", focusId)) {
26
26
  const elem = document.getElementById(focusId);
@@ -1 +1 @@
1
- export default function useTrapFocus(isActive?: boolean): import('react').MutableRefObject<HTMLElement | null>;
1
+ export default function useTrapFocus(): import('react').MutableRefObject<HTMLElement | null>;
@@ -1,8 +1,7 @@
1
1
  import { useRef, useEffect } from "react";
2
- function useTrapFocus(isActive) {
2
+ function useTrapFocus() {
3
3
  const ref = useRef(null), focusableElements = 'button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
4
4
  return useEffect(() => {
5
- if (!isActive) return;
6
5
  const node = ref.current, firstFocusableElement = node.querySelectorAll(focusableElements)[0], focusableContent = node.querySelectorAll(focusableElements), lastFocusableElement = ref && (focusableContent == null ? void 0 : focusableContent[focusableContent.length - 1]), handleKeydown = (event) => {
7
6
  event.key === "Tab" && (event.shiftKey ? document.activeElement === firstFocusableElement && (lastFocusableElement.focus(), event.preventDefault()) : document.activeElement === lastFocusableElement && (firstFocusableElement.focus(), event.preventDefault()));
8
7
  };
@@ -10,7 +9,7 @@ function useTrapFocus(isActive) {
10
9
  return node.addEventListener("keydown", handleKeydown), () => {
11
10
  node.removeEventListener("keydown", handleKeydown);
12
11
  };
13
- }, [isActive]), ref;
12
+ }, []), ref;
14
13
  }
15
14
  export {
16
15
  useTrapFocus as default
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { useState, Suspense, lazy } from "react";
2
+ import { useState } from "react";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import SvgIconSave from "../../icons/components/IconSave.js";
5
5
  import { useAutosizeTextarea } from "../hooks/useAutosizeTextarea.js";
@@ -10,8 +10,7 @@ import { CommentDate } from "./CommentDate.js";
10
10
  import { CommentTitle } from "./CommentTitle.js";
11
11
  import { TextCounter } from "./TextCounter.js";
12
12
  import Button from "../../../components/Button/Button.js";
13
- import LoadingScreen from "../../../components/LoadingScreen/LoadingScreen.js";
14
- const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comment = ({
13
+ const Comment = ({
15
14
  comment,
16
15
  userId,
17
16
  profile
@@ -23,13 +22,12 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
23
22
  createdAt,
24
23
  updatedAt,
25
24
  comment: content
26
- } = comment, [ref, onFocus, resizeTextarea] = useAutosizeTextarea(!0), [isDeleteModalOpen, setIsDeleteModalOpen] = useState(!1), {
25
+ } = comment, [ref, onFocus, resizeTextarea] = useAutosizeTextarea(!0), {
27
26
  t
28
27
  } = useTranslation(), {
29
28
  editCommentId,
30
29
  options,
31
30
  type,
32
- userRights,
33
31
  handleDeleteComment: onDeleteComment,
34
32
  handleModifyComment,
35
33
  handleReset,
@@ -59,15 +57,14 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
59
57
  ] })
60
58
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
61
59
  /* @__PURE__ */ jsx("div", { className: "mt-8 mb-4", children: content }),
62
- type === "edit" && /* @__PURE__ */ jsxs("div", { className: "ms-n8", children: [
63
- userId === authorId && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => {
60
+ userId === authorId && type === "edit" && /* @__PURE__ */ jsxs("div", { className: "ms-n8", children: [
61
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => {
64
62
  handleModifyComment(comment.id), setValue(content);
65
63
  }, children: t("comment.edit") }),
66
- (userId === authorId || (userRights == null ? void 0 : userRights.manager)) && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => setIsDeleteModalOpen(!0), children: t("comment.remove") })
64
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => onDeleteComment(id), children: t("comment.remove") })
67
65
  ] })
68
66
  ] })
69
- ] }),
70
- /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, { position: !1 }), children: isDeleteModalOpen && /* @__PURE__ */ jsx(DeleteModal, { isOpen: isDeleteModalOpen, onCancel: () => setIsDeleteModalOpen(!1), onSuccess: () => onDeleteComment(id) }) })
67
+ ] })
71
68
  ] }, id);
72
69
  };
73
70
  export {
@@ -1,4 +1,3 @@
1
- import { RightRole } from '@edifice.io/client';
2
1
  import { CommentOptions, CommentProps, CommentType, UserProfileResult } from '../types';
3
2
  export declare const CommentContext: import('react').Context<{
4
3
  comments: CommentProps[] | undefined;
@@ -7,7 +6,6 @@ export declare const CommentContext: import('react').Context<{
7
6
  profiles: (UserProfileResult | undefined)[];
8
7
  options: Partial<CommentOptions>;
9
8
  type: CommentType;
10
- userRights?: Record<RightRole, boolean>;
11
9
  setEditCommentId: (value: string | null) => void;
12
10
  handleModifyComment: (commentId: string) => void;
13
11
  handleChangeContent: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
@@ -24,6 +24,6 @@ export declare const useComments: ({ defaultComments, options, type, callbacks,
24
24
  handleDeleteComment: (id: string) => void;
25
25
  handleCreateComment: (content: string) => void;
26
26
  handleModifyComment: (commentId: string) => void;
27
- handleUpdateComment: (comment: string) => Promise<void>;
27
+ handleUpdateComment: (comment: string) => void;
28
28
  handleReset: () => void;
29
29
  };
@@ -50,7 +50,7 @@ const useComments = ({
50
50
  handleModifyComment: (commentId) => {
51
51
  setEditCommentId(commentId);
52
52
  },
53
- handleUpdateComment: async (comment) => {
53
+ handleUpdateComment: (comment) => {
54
54
  editCommentId && (type === "edit" && (callbacks == null || callbacks.put({
55
55
  comment,
56
56
  commentId: editCommentId
@@ -5,7 +5,6 @@ export declare const useCommentsContext: () => {
5
5
  profiles: (import('../types').UserProfileResult | undefined)[];
6
6
  options: Partial<import('../types').CommentOptions>;
7
7
  type: import('../types').CommentType;
8
- userRights?: Record<import('@edifice.io/client').RightRole, boolean>;
9
8
  setEditCommentId: (value: string | null) => void;
10
9
  handleModifyComment: (commentId: string) => void;
11
10
  handleChangeContent: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
@@ -46,7 +46,7 @@ const CommentProvider = ({
46
46
  defaultComments,
47
47
  callbacks: type == "edit" ? props.callbacks : null,
48
48
  options
49
- }), userRights = type === "edit" ? props.rights : void 0, values = useMemo(
49
+ }), values = useMemo(
50
50
  () => ({
51
51
  comments,
52
52
  content,
@@ -54,7 +54,6 @@ const CommentProvider = ({
54
54
  editCommentId,
55
55
  options,
56
56
  type,
57
- userRights,
58
57
  setEditCommentId,
59
58
  handleCreateComment,
60
59
  handleModifyComment,
@@ -1,4 +1,4 @@
1
- import { RightRole, UserProfile } from '@edifice.io/client';
1
+ import { UserProfile } from '@edifice.io/client';
2
2
  export interface CommentProps {
3
3
  /**
4
4
  * Comment Id
@@ -61,10 +61,6 @@ interface EditRootProps extends BaseProps {
61
61
  * Callbacks to perform CRUD on comment
62
62
  */
63
63
  callbacks: CommentCallbacks;
64
- /**
65
- * Rights to perform CRUD on comment
66
- */
67
- rights?: Record<RightRole, boolean>;
68
64
  }
69
65
  interface ReadRootProps extends BaseProps {
70
66
  type: 'read';
@@ -12,12 +12,11 @@ const AttachmentRenderer = (props) => {
12
12
  const {
13
13
  t
14
14
  } = useTranslation(), {
15
- node,
16
- editor
15
+ node
17
16
  } = props, {
18
17
  editable
19
- } = useEditorContext(), [attachmentArrayAttrs, setAttachmentArrayAttrs] = useState(node.attrs.links), handleDelete = (index, documentId) => {
20
- editor.commands.unsetAttachment(documentId), setAttachmentArrayAttrs((oldAttachments) => oldAttachments.filter((_, i) => i !== index));
18
+ } = useEditorContext(), [attachmentArrayAttrs, setAttachmentArrayAttrs] = useState(node.attrs.links), handleDelete = (index) => {
19
+ setAttachmentArrayAttrs((oldAttachments) => oldAttachments.filter((_, i) => i !== index));
21
20
  };
22
21
  return attachmentArrayAttrs.length !== 0 && /* @__PURE__ */ jsx(NodeViewWrapper, { children: /* @__PURE__ */ jsxs("div", { style: {
23
22
  backgroundColor: "#F2F2F2",
@@ -27,7 +26,7 @@ const AttachmentRenderer = (props) => {
27
26
  /* @__PURE__ */ jsx("p", { className: "m-12 mt-0", children: t("tiptap.attachments.bloc") }),
28
27
  /* @__PURE__ */ jsx(Grid, { children: attachmentArrayAttrs == null ? void 0 : attachmentArrayAttrs.map((attachment, index) => /* @__PURE__ */ jsx(Grid.Col, { sm: "6", children: /* @__PURE__ */ jsx(Attachment, { name: attachment.name, options: /* @__PURE__ */ jsxs(Fragment, { children: [
29
28
  /* @__PURE__ */ jsx("a", { href: attachment.href, download: !0, children: /* @__PURE__ */ jsx(IconButton, { "aria-label": t("tiptap.attachments.download"), color: "tertiary", type: "button", icon: /* @__PURE__ */ jsx(SvgIconDownload, {}), variant: "ghost" }) }),
30
- editable && /* @__PURE__ */ jsx(IconButton, { "aria-label": t("tiptap.attachments.delete"), color: "danger", type: "button", icon: /* @__PURE__ */ jsx(SvgIconDelete, {}), variant: "ghost", onClick: () => handleDelete(index, attachment.documentId) })
29
+ editable && /* @__PURE__ */ jsx(IconButton, { "aria-label": t("tiptap.attachments.delete"), color: "danger", type: "button", icon: /* @__PURE__ */ jsx(SvgIconDelete, {}), variant: "ghost", onClick: () => handleDelete(index) })
31
30
  ] }) }) }, index)) })
32
31
  ] }) });
33
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.0.0-develop-pedago.20250108152614",
3
+ "version": "2.0.0-develop-b2school.20250108160141",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -119,9 +119,9 @@
119
119
  "react-slugify": "^3.0.3",
120
120
  "swiper": "^10.1.0",
121
121
  "ua-parser-js": "^1.0.36",
122
- "@edifice.io/bootstrap": "2.0.0-develop-pedago.20250108152614",
123
- "@edifice.io/utilities": "2.0.0-develop-pedago.20250108152614",
124
- "@edifice.io/tiptap-extensions": "2.0.0-develop-pedago.20250108152614"
122
+ "@edifice.io/bootstrap": "2.0.0-develop-b2school.20250108160141",
123
+ "@edifice.io/utilities": "2.0.0-develop-b2school.20250108160141",
124
+ "@edifice.io/tiptap-extensions": "2.0.0-develop-b2school.20250108160141"
125
125
  },
126
126
  "devDependencies": {
127
127
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -147,7 +147,7 @@
147
147
  "typescript-eslint": "^8.8.1",
148
148
  "vite": "^5.4.11",
149
149
  "vite-plugin-dts": "^4.1.0",
150
- "@edifice.io/client": "2.0.0-develop-pedago.20250108152614"
150
+ "@edifice.io/client": "2.0.0-develop-b2school.20250108160141"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "@react-spring/web": "^9.7.5",
@@ -1,7 +0,0 @@
1
- interface DeleteModalProps {
2
- isOpen: boolean;
3
- onCancel: () => void;
4
- onSuccess: () => void;
5
- }
6
- export declare const DeleteModal: ({ isOpen, onCancel, onSuccess, }: DeleteModalProps) => import("react/jsx-runtime").JSX.Element;
7
- export default DeleteModal;
@@ -1,19 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import Modal from "../../../components/Modal/Modal.js";
3
- import Button from "../../../components/Button/Button.js";
4
- const DeleteModal = ({
5
- isOpen,
6
- onCancel,
7
- onSuccess
8
- }) => /* @__PURE__ */ jsxs(Modal, { isOpen, onModalClose: onCancel, id: "delete-comment-modal", children: [
9
- /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: "Suppression de commentaire" }),
10
- /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx("p", { children: "Voulez-vous vraiment supprimer ce commentaire ?" }) }),
11
- /* @__PURE__ */ jsxs(Modal.Footer, { children: [
12
- /* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: "Annuler" }),
13
- /* @__PURE__ */ jsx(Button, { color: "danger", onClick: onSuccess, type: "button", variant: "filled", children: "Supprimer le commentaire" })
14
- ] })
15
- ] });
16
- export {
17
- DeleteModal,
18
- DeleteModal as default
19
- };