@edifice.io/react 2.0.1-develop-hotfix.1736862374617 → 2.1.0-develop-enabling.0

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.
@@ -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);
@@ -10,9 +10,7 @@ const useConversation = () => {
10
10
  try {
11
11
  const {
12
12
  count
13
- } = await odeServices.withBaseUrl("").withHeaders({
14
- "Content-Type": "application/json"
15
- }).http().get(url, {
13
+ } = await odeServices.http().get(url, {
16
14
  queryParams
17
15
  });
18
16
  setMessages(count ?? 0);
@@ -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
  };
@@ -1,9 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useRef, useEffect } from "react";
3
- import { odeServices } from "@edifice.io/client";
4
3
  import { NodeViewWrapper } from "@tiptap/react";
5
4
  import { useTranslation } from "react-i18next";
6
- import useBrowserInfo from "../../../../hooks/useBrowserInfo/useBrowserInfo.js";
7
5
  import { useResizeMedia } from "../../hooks/useResizeMedia.js";
8
6
  import Image from "../../../../components/Image/Image.js";
9
7
  const MediaRenderer = (props) => {
@@ -11,10 +9,7 @@ const MediaRenderer = (props) => {
11
9
  node
12
10
  } = props, {
13
11
  t
14
- } = useTranslation(), {
15
- browser,
16
- device
17
- } = useBrowserInfo(navigator.userAgent), resizableMedia = useRef(null), {
12
+ } = useTranslation(), resizableMedia = useRef(null), {
18
13
  startVerticalResize,
19
14
  stopVerticalResize,
20
15
  isVerticalResizeActive
@@ -41,10 +36,7 @@ const MediaRenderer = (props) => {
41
36
  return {};
42
37
  }
43
38
  }, onVideoPlay = () => {
44
- if (resizableMedia.current instanceof HTMLVideoElement) {
45
- const videoElement = resizableMedia.current, videoId = videoElement.dataset.documentId, isCaptation = (videoElement.dataset.documentIsCaptation || "false") == "true";
46
- videoId && odeServices.data().trackVideoRead(videoId, isCaptation, window.location.hostname, `${browser.name} ${browser.version}`, device.type);
47
- }
39
+ resizableMedia.current instanceof HTMLVideoElement;
48
40
  };
49
41
  return useEffect(() => {
50
42
  if (!resizableMedia.current) return;
@@ -1,11 +1,9 @@
1
1
  import { useState } from "react";
2
- import { odeServices } from "@edifice.io/client";
3
2
  const useSpeechRecognition = (editor) => {
4
3
  const [isActive, setActive] = useState(!1), toggle = () => {
5
4
  if (isActive)
6
5
  editor == null || editor.commands.stopSpeechRecognition(), setActive(!1);
7
6
  else {
8
- odeServices.data().trackSpeechAndText("STT");
9
7
  const started = (editor == null ? void 0 : editor.commands.startSpeechRecognition()) || !1;
10
8
  setActive(started);
11
9
  }
@@ -1,11 +1,9 @@
1
1
  import { useState, useCallback } from "react";
2
- import { odeServices } from "@edifice.io/client";
3
2
  const useSpeechSynthetisis = (editor) => {
4
3
  const [isActivated, setActivated] = useState(!1), toggle = useCallback(() => {
5
4
  if (isActivated)
6
5
  return editor == null || editor.commands.stopSpeechSynthesis(), setActivated(!1), !1;
7
6
  {
8
- odeServices.data().trackSpeechAndText("TTS");
9
7
  const speech = (editor == null ? void 0 : editor.commands.startSpeechSynthesis()) || !1;
10
8
  return setActivated(speech), speech;
11
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.0.1-develop-hotfix.1736862374617",
3
+ "version": "2.1.0-develop-enabling.0",
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/tiptap-extensions": "2.0.1-develop-hotfix.1736862374617",
123
- "@edifice.io/utilities": "2.0.0",
124
- "@edifice.io/bootstrap": "2.0.1-develop-hotfix.1736862374617"
122
+ "@edifice.io/utilities": "2.1.0-develop-enabling.0",
123
+ "@edifice.io/bootstrap": "2.1.0-develop-enabling.0",
124
+ "@edifice.io/tiptap-extensions": "2.1.0-develop-enabling.0"
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": "catalog:",
149
149
  "vite-plugin-dts": "catalog:",
150
- "@edifice.io/client": "2.0.1-develop-hotfix.1736862374617"
150
+ "@edifice.io/client": "2.1.0-develop-enabling.0"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "@react-spring/web": "catalog:",
@@ -1 +0,0 @@
1
- export { default as useHttpErrorToast } from './useHttpErrorToast';
@@ -1,3 +0,0 @@
1
- import { CustomToastOptions } from '../../hooks/useToast/useToast';
2
- declare const useHttpErrorToast: (options?: CustomToastOptions) => string | undefined;
3
- export default useHttpErrorToast;
@@ -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
- };