@edifice.io/react 2.0.0-develop-rc.3 → 2.0.0-develop-rc.4

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.
Files changed (204) hide show
  1. package/dist/components/ActionBar/ActionBar.d.ts +1 -1
  2. package/dist/components/ActionBar/ActionBar.js +3 -2
  3. package/dist/components/ActionBar/index.d.ts +0 -1
  4. package/dist/components/Alert/Alert.d.ts +1 -1
  5. package/dist/components/Alert/Alert.js +2 -1
  6. package/dist/components/Alert/index.d.ts +0 -1
  7. package/dist/components/AppHeader/AppHeader.d.ts +1 -1
  8. package/dist/components/AppHeader/AppHeader.js +3 -2
  9. package/dist/components/AppHeader/index.d.ts +0 -1
  10. package/dist/components/AppIcon/AppIcon.js +1 -1
  11. package/dist/components/Attachment/Attachment.d.ts +1 -1
  12. package/dist/components/Attachment/Attachment.js +3 -2
  13. package/dist/components/Attachment/index.d.ts +0 -1
  14. package/dist/components/Avatar/Avatar.d.ts +1 -1
  15. package/dist/components/Avatar/Avatar.js +4 -3
  16. package/dist/components/Avatar/index.d.ts +0 -1
  17. package/dist/components/Badge/Badge.d.ts +1 -1
  18. package/dist/components/Badge/Badge.js +3 -2
  19. package/dist/components/Badge/index.d.ts +0 -1
  20. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  21. package/dist/components/Button/Button.d.ts +1 -1
  22. package/dist/components/Button/Button.js +4 -3
  23. package/dist/components/Button/IconButton.d.ts +1 -1
  24. package/dist/components/Button/IconButton.js +4 -3
  25. package/dist/components/Button/SearchButton.d.ts +1 -1
  26. package/dist/components/Button/SearchButton.js +4 -3
  27. package/dist/components/Button/index.d.ts +0 -3
  28. package/dist/components/Card/Card.d.ts +1 -1
  29. package/dist/components/Card/Card.js +3 -2
  30. package/dist/components/Card/CardHeader.js +1 -1
  31. package/dist/components/Card/CardImage.js +1 -1
  32. package/dist/components/Card/CardUser.js +1 -1
  33. package/dist/components/Card/index.d.ts +0 -1
  34. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  35. package/dist/components/Checkbox/Checkbox.js +3 -2
  36. package/dist/components/Checkbox/index.d.ts +0 -1
  37. package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
  38. package/dist/components/ColorPicker/ColorPicker.js +5 -4
  39. package/dist/components/ColorPicker/ColorPickerItem.d.ts +1 -1
  40. package/dist/components/ColorPicker/ColorPickerItem.js +3 -2
  41. package/dist/components/ColorPicker/index.d.ts +1 -3
  42. package/dist/components/Combobox/Combobox.d.ts +1 -1
  43. package/dist/components/Combobox/Combobox.js +4 -4
  44. package/dist/components/Combobox/ComboboxTrigger.js +2 -2
  45. package/dist/components/Combobox/index.d.ts +0 -1
  46. package/dist/components/Dropdown/Dropdown.d.ts +1 -1
  47. package/dist/components/Dropdown/Dropdown.js +4 -3
  48. package/dist/components/Dropdown/DropdownCheckboxItem.js +1 -1
  49. package/dist/components/Dropdown/DropdownRadioItem.js +1 -1
  50. package/dist/components/Dropdown/index.d.ts +0 -1
  51. package/dist/components/Dropzone/Dropzone.d.ts +1 -1
  52. package/dist/components/Dropzone/Dropzone.js +2 -2
  53. package/dist/components/Dropzone/DropzoneFile.js +1 -1
  54. package/dist/components/Dropzone/DropzoneImport.js +1 -1
  55. package/dist/components/Dropzone/index.d.ts +0 -1
  56. package/dist/components/EmptyScreen/EmptyScreen.d.ts +1 -1
  57. package/dist/components/EmptyScreen/EmptyScreen.js +4 -3
  58. package/dist/components/EmptyScreen/index.d.ts +0 -1
  59. package/dist/components/FileCard/FileCard.d.ts +1 -1
  60. package/dist/components/FileCard/FileCard.js +4 -3
  61. package/dist/components/FileCard/index.d.ts +0 -1
  62. package/dist/components/Form/FormControl.d.ts +1 -1
  63. package/dist/components/Form/FormControl.js +6 -5
  64. package/dist/components/Form/FormText.d.ts +1 -1
  65. package/dist/components/Form/FormText.js +3 -2
  66. package/dist/components/Form/index.d.ts +1 -2
  67. package/dist/components/Heading/Heading.d.ts +1 -1
  68. package/dist/components/Heading/Heading.js +3 -2
  69. package/dist/components/Heading/index.d.ts +0 -1
  70. package/dist/components/Image/Image.d.ts +1 -1
  71. package/dist/components/Image/Image.js +3 -2
  72. package/dist/components/Image/index.d.ts +0 -1
  73. package/dist/components/ImagePicker/ImagePicker.js +4 -4
  74. package/dist/components/Input/Input.d.ts +1 -1
  75. package/dist/components/Input/Input.js +3 -2
  76. package/dist/components/Input/index.d.ts +0 -1
  77. package/dist/components/Label/Label.d.ts +1 -1
  78. package/dist/components/Label/Label.js +3 -2
  79. package/dist/components/Label/index.d.ts +0 -1
  80. package/dist/components/Loading/Loading.d.ts +1 -1
  81. package/dist/components/Loading/Loading.js +3 -2
  82. package/dist/components/Loading/index.d.ts +0 -1
  83. package/dist/components/LoadingScreen/LoadingScreen.d.ts +1 -1
  84. package/dist/components/LoadingScreen/LoadingScreen.js +3 -2
  85. package/dist/components/LoadingScreen/index.d.ts +1 -1
  86. package/dist/components/Logo/Logo.d.ts +1 -1
  87. package/dist/components/Logo/Logo.js +3 -2
  88. package/dist/components/Logo/index.d.ts +0 -1
  89. package/dist/components/Menu/MenuButton.js +1 -1
  90. package/dist/components/Modal/Modal.d.ts +1 -1
  91. package/dist/components/Modal/Modal.js +3 -2
  92. package/dist/components/Modal/ModalHeader.js +1 -1
  93. package/dist/components/Modal/index.d.ts +0 -1
  94. package/dist/components/Radio/Radio.d.ts +1 -1
  95. package/dist/components/Radio/Radio.js +3 -2
  96. package/dist/components/Radio/index.d.ts +0 -1
  97. package/dist/components/SearchBar/SearchBar.d.ts +1 -1
  98. package/dist/components/SearchBar/SearchBar.js +5 -4
  99. package/dist/components/SearchBar/index.d.ts +0 -1
  100. package/dist/components/Select/Select.d.ts +1 -1
  101. package/dist/components/Select/Select.js +4 -3
  102. package/dist/components/Select/SelectTrigger.js +1 -1
  103. package/dist/components/Select/index.d.ts +0 -1
  104. package/dist/components/Table/TableExplorer.d.ts +1 -1
  105. package/dist/components/Table/TableExplorer.js +3 -2
  106. package/dist/components/Table/index.d.ts +0 -1
  107. package/dist/components/Tabs/Tabs.d.ts +1 -1
  108. package/dist/components/Tabs/Tabs.js +2 -2
  109. package/dist/components/Tabs/TabsList.js +1 -1
  110. package/dist/components/Tabs/index.d.ts +0 -1
  111. package/dist/components/TextArea/TextArea.d.ts +1 -1
  112. package/dist/components/TextArea/TextArea.js +3 -2
  113. package/dist/components/TextArea/index.d.ts +0 -1
  114. package/dist/components/Toolbar/Toolbar.d.ts +1 -1
  115. package/dist/components/Toolbar/Toolbar.js +7 -6
  116. package/dist/components/Toolbar/index.d.ts +0 -1
  117. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  118. package/dist/components/Tooltip/Tooltip.js +3 -2
  119. package/dist/components/Tooltip/index.d.ts +0 -1
  120. package/dist/components/TreeView/TreeView.d.ts +1 -1
  121. package/dist/components/TreeView/TreeView.js +3 -2
  122. package/dist/components/TreeView/index.d.ts +0 -1
  123. package/dist/components/UploadCard/UploadCard.js +6 -6
  124. package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +1 -1
  125. package/dist/components/VisuallyHidden/VisuallyHidden.js +3 -2
  126. package/dist/components/VisuallyHidden/index.d.ts +1 -1
  127. package/dist/core/useAvatar/useAvatar.js +1 -1
  128. package/dist/index.js +98 -98
  129. package/dist/modals.js +12 -14
  130. package/dist/modules/audience/ReactionChoice.js +3 -3
  131. package/dist/modules/audience/ReactionModal.Card.js +1 -1
  132. package/dist/modules/audience/ReactionModal.js +3 -3
  133. package/dist/modules/audience/ReactionSummary.js +1 -1
  134. package/dist/modules/audience/ViewsCounter.js +1 -1
  135. package/dist/modules/audience/ViewsModal.js +2 -2
  136. package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +1 -1
  137. package/dist/modules/editor/components/Editor/Editor.js +1 -1
  138. package/dist/modules/editor/components/Editor/MathsModal.js +2 -2
  139. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.DropdownMenu.js +3 -3
  140. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Emoji.js +3 -3
  141. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.HighlightColor.js +4 -4
  142. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.PlusMenu.js +1 -1
  143. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextColor.js +4 -4
  144. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextSize.js +3 -3
  145. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -3
  146. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +1 -1
  147. package/dist/modules/editor/components/Renderer/AttachmentRenderer.js +2 -2
  148. package/dist/modules/editor/components/Renderer/LinkerRenderer.js +1 -1
  149. package/dist/modules/editor/components/Renderer/MediaRenderer.js +1 -1
  150. package/dist/modules/editor/components/Toolbar/LinkToolbar.js +1 -1
  151. package/dist/modules/editor/components/Toolbar/TableToolbar.AddMenu.js +2 -2
  152. package/dist/modules/editor/components/Toolbar/TableToolbar.CellColor.js +4 -4
  153. package/dist/modules/editor/components/Toolbar/TableToolbar.DelMenu.js +2 -2
  154. package/dist/modules/editor/components/Toolbar/TableToolbar.js +1 -1
  155. package/dist/modules/modals/OnboardingModal/OnboardingModal.js +3 -3
  156. package/dist/modules/modals/PublishModal/PublishModal.js +8 -8
  157. package/dist/modules/modals/PublishModal/components/ActivitiesDropdown.js +1 -1
  158. package/dist/modules/modals/PublishModal/components/AgeSelect.js +1 -1
  159. package/dist/modules/modals/PublishModal/components/LangSelect.js +1 -1
  160. package/dist/modules/modals/PublishModal/components/SubjectsDropdown.js +1 -1
  161. package/dist/modules/modals/ResourceModal/ResourceModal.d.ts +1 -1
  162. package/dist/modules/modals/ResourceModal/ResourceModal.js +11 -10
  163. package/dist/modules/modals/ResourceModal/apps/BlogPublic.d.ts +1 -1
  164. package/dist/modules/modals/ResourceModal/apps/BlogPublic.js +8 -7
  165. package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.d.ts +1 -1
  166. package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.js +3 -2
  167. package/dist/modules/modals/ResourceModal/index.d.ts +3 -3
  168. package/dist/modules/modals/ShareModal/apps/ShareBlog.d.ts +2 -1
  169. package/dist/modules/modals/ShareModal/apps/ShareBlog.js +3 -2
  170. package/dist/modules/modals/ShareModal/hooks/useShareMutation.d.ts +1 -1
  171. package/dist/modules/modals/ShareModal/hooks/useShareMutation.js +3 -2
  172. package/dist/modules/modals/ShareModal/index.d.ts +3 -3
  173. package/dist/modules/multimedia/AudioRecorder/AudioRecorder.js +3 -3
  174. package/dist/modules/multimedia/Embed/Embed.js +2 -2
  175. package/dist/modules/multimedia/ImageEditor/components/ImageEditor.js +6 -6
  176. package/dist/modules/multimedia/ImageEditor/components/ImageEditorToolbar.js +1 -1
  177. package/dist/modules/multimedia/ImagePickerWorkspace/ImagePickerWorkspace.js +2 -2
  178. package/dist/modules/multimedia/Linker/ExternalLinker.js +4 -4
  179. package/dist/modules/multimedia/Linker/InternalLinker.js +4 -4
  180. package/dist/modules/multimedia/LinkerCard/LinkerCard.d.ts +1 -1
  181. package/dist/modules/multimedia/LinkerCard/LinkerCard.js +5 -4
  182. package/dist/modules/multimedia/LinkerCard/index.d.ts +0 -1
  183. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +3 -3
  184. package/dist/modules/multimedia/MediaLibrary/innertabs/InternalLink.js +1 -1
  185. package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +1 -1
  186. package/dist/modules/multimedia/VideoEmbed/VideoEmbed.js +5 -5
  187. package/dist/modules/multimedia/VideoRecorder/VideoRecorder.js +5 -5
  188. package/dist/modules/multimedia/Workspace/Workspace.js +6 -6
  189. package/dist/multimedia.js +8 -8
  190. package/dist/portal/Header/Header.js +3 -3
  191. package/dist/portal/Header/NavLink.js +1 -1
  192. package/dist/portal/Help/Help.js +1 -1
  193. package/dist/portal/Help/hooks/useHelp.js +1 -1
  194. package/dist/portal/Layout/Layout.js +1 -1
  195. package/dist/portal/SearchEngine/SearchEngine.js +2 -2
  196. package/package.json +2 -2
  197. package/dist/modules/modals/ShareModal/ShareBookmark.js +0 -22
  198. package/dist/modules/modals/ShareModal/ShareBookmarkLine.js +0 -42
  199. package/dist/modules/modals/ShareModal/ShareModal.js +0 -128
  200. package/dist/modules/modals/ShareModal/hooks/useSearch.js +0 -178
  201. package/dist/modules/modals/ShareModal/hooks/useShare.js +0 -192
  202. package/dist/modules/modals/ShareModal/hooks/useShareBookmark.js +0 -67
  203. package/dist/modules/modals/ShareModal/utils/hasRight.js +0 -4
  204. package/dist/modules/modals/ShareModal/utils/showShareRightLine.js +0 -4
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
- import VisuallyHidden from "../../components/VisuallyHidden/VisuallyHidden.js";
3
+ import { VisuallyHidden } from "../../components/VisuallyHidden/VisuallyHidden.js";
4
4
  function NavLink({
5
5
  link,
6
6
  className,
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { createPortal } from "react-dom";
3
3
  import { useTranslation } from "react-i18next";
4
- import Modal from "../../components/Modal/Modal.js";
4
+ import { Modal } from "../../components/Modal/Modal.js";
5
5
  function Help({
6
6
  isHelpOpen,
7
7
  setIsHelpOpen,
@@ -1,9 +1,9 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
3
  import parse, { domToReact, attributesToProps } from "html-react-parser";
4
- import Button from "../../../components/Button/Button.js";
5
4
  import { useOdeClient } from "../../../core/OdeClientProvider/OdeClientProvider.js";
6
5
  import { useOdeTheme } from "../../../core/ThemeProvider/ThemeProvider.js";
6
+ import { Button } from "../../../components/Button/Button.js";
7
7
  import { Icon } from "../../../components/Icon/Icon.js";
8
8
  function useHelp() {
9
9
  var _a, _b, _c, _d, _e;
@@ -3,7 +3,7 @@ import clsx from "clsx";
3
3
  import { Toaster } from "react-hot-toast";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import Alert from "../../components/Alert/Alert.js";
6
- import Button from "../../components/Button/Button.js";
6
+ import { Button } from "../../components/Button/Button.js";
7
7
  import useCookiesConsent from "../../core/useCookiesConsent/useCookiesConsent.js";
8
8
  import Header from "../Header/Header.js";
9
9
  import useZendeskGuide from "../../core/useZendeskGuide/useZendeskGuide.js";
@@ -4,9 +4,9 @@ import { useTranslation } from "react-i18next";
4
4
  import { NavItem } from "../Header/NavItem.js";
5
5
  import useHover from "../../hooks/useHover/useHover.js";
6
6
  import { Popover } from "../../components/Popover/Popover.js";
7
- import FormControl from "../../components/Form/FormControl.js";
8
- import SearchButton from "../../components/Button/SearchButton.js";
9
7
  import { Icon } from "../../components/Icon/Icon.js";
8
+ import { FormControl } from "../../components/Form/FormControl.js";
9
+ import { SearchButton } from "../../components/Button/SearchButton.js";
10
10
  const SearchEngine = () => {
11
11
  const [searchRef, isSearchHovered] = useHover(), inputRef = useRef(null), popoverSearchId = useId(), {
12
12
  t
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.0.0-develop-rc.3",
3
+ "version": "2.0.0-develop-rc.4",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -130,5 +130,5 @@
130
130
  "publishConfig": {
131
131
  "access": "public"
132
132
  },
133
- "gitHead": "ef4e098394d60081f2d68d7387a1ae85f616ed3f"
133
+ "gitHead": "429683536a07d7c85155027f4f41d8b3c5323c02"
134
134
  }
@@ -1,22 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useTranslation } from "react-i18next";
3
- import FormControl from "../../../components/Form/FormControl.js";
4
- import Button from "../../../components/Button/Button.js";
5
- import { Icon } from "../../../components/Icon/Icon.js";
6
- const ShareBookmark = ({
7
- bookmark,
8
- refBookmark,
9
- onBookmarkChange,
10
- onSave
11
- }) => {
12
- const {
13
- t
14
- } = useTranslation();
15
- return /* @__PURE__ */ jsx("div", { className: "mt-16", children: /* @__PURE__ */ jsxs(FormControl, { id: "bookmarkName", className: "d-flex flex-wrap align-items-center gap-16", children: [
16
- /* @__PURE__ */ jsx("div", { className: "flex-fill", children: /* @__PURE__ */ jsx(FormControl.Input, { ref: refBookmark, onChange: onBookmarkChange, placeholder: t("explorer.modal.share.sharebookmark.placeholder"), size: "sm", type: "text" }, bookmark.id) }),
17
- /* @__PURE__ */ jsx(Button, { type: "button", color: "primary", variant: "ghost", disabled: bookmark.name.length === 0, leftIcon: /* @__PURE__ */ jsx(Icon, { name: "save" }), onClick: onSave, className: "text-nowrap", children: t("explorer.modal.share.sharebookmark.save") })
18
- ] }) });
19
- };
20
- export {
21
- ShareBookmark
22
- };
@@ -1,42 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useTranslation } from "react-i18next";
3
- import { hasRight } from "./utils/hasRight.js";
4
- import { showShareRightLine } from "./utils/showShareRightLine.js";
5
- import Avatar from "../../../components/Avatar/Avatar.js";
6
- import { Icon } from "../../../components/Icon/Icon.js";
7
- import Button from "../../../components/Button/Button.js";
8
- import Checkbox from "../../../components/Checkbox/Checkbox.js";
9
- import IconButton from "../../../components/Button/IconButton.js";
10
- const ShareBookmarkLine = ({
11
- shareRights,
12
- showBookmark,
13
- toggleBookmark,
14
- shareRightActions,
15
- toggleRight,
16
- onDeleteRow
17
- }) => {
18
- const {
19
- t
20
- } = useTranslation();
21
- return shareRights == null ? void 0 : shareRights.rights.map((shareRight) => showShareRightLine(shareRight, showBookmark) && /* @__PURE__ */ jsxs("tr", { className: shareRight.isBookmarkMember ? "bg-light" : "", children: [
22
- /* @__PURE__ */ jsxs("td", { children: [
23
- shareRight.type !== "sharebookmark" && /* @__PURE__ */ jsx(Avatar, { alt: t("explorer.modal.share.avatar.shared.alt"), size: "xs", src: shareRight.avatarUrl, variant: "circle" }),
24
- shareRight.type === "sharebookmark" && /* @__PURE__ */ jsx(Icon, { name: "bookmark" })
25
- ] }),
26
- /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", { className: "d-flex", children: [
27
- shareRight.type === "sharebookmark" && /* @__PURE__ */ jsx(Button, { color: "tertiary", rightIcon: /* @__PURE__ */ jsx(Icon, { name: "rafter-down", className: "w-16 min-w-0", style: {
28
- transition: "rotate 0.2s ease-out",
29
- rotate: showBookmark ? "-180deg" : "0deg"
30
- } }), type: "button", variant: "ghost", className: "fw-normal ps-0", onClick: toggleBookmark, children: shareRight.displayName }),
31
- shareRight.type !== "sharebookmark" && shareRight.displayName,
32
- shareRight.type === "user" && ` (${t(shareRight.profile || "")})`
33
- ] }) }),
34
- shareRightActions.map((shareRightAction) => /* @__PURE__ */ jsx("td", { style: {
35
- width: "80px"
36
- }, className: "text-center text-white", children: /* @__PURE__ */ jsx(Checkbox, { checked: hasRight(shareRight, shareRightAction), onChange: () => toggleRight(shareRight, shareRightAction.id) }) }, shareRightAction.displayName)),
37
- /* @__PURE__ */ jsx("td", { children: !shareRight.isBookmarkMember && /* @__PURE__ */ jsx(IconButton, { "aria-label": t("close"), color: "tertiary", icon: /* @__PURE__ */ jsx(Icon, { name: "close" }), type: "button", variant: "ghost", title: t("close"), onClick: () => onDeleteRow(shareRight) }) })
38
- ] }, shareRight.id));
39
- };
40
- export {
41
- ShareBookmarkLine
42
- };
@@ -1,128 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { createPortal } from "react-dom";
4
- import { useTranslation } from "react-i18next";
5
- import { ShareBookmark } from "./ShareBookmark.js";
6
- import { ShareBookmarkLine } from "./ShareBookmarkLine.js";
7
- import { useSearch } from "./hooks/useSearch.js";
8
- import useShare from "./hooks/useShare.js";
9
- import { useShareBookmark } from "./hooks/useShareBookmark.js";
10
- import Combobox from "../../../components/Combobox/Combobox.js";
11
- import Modal from "../../../components/Modal/Modal.js";
12
- import Heading from "../../../components/Heading/Heading.js";
13
- import LoadingScreen from "../../../components/LoadingScreen/LoadingScreen.js";
14
- import VisuallyHidden from "../../../components/VisuallyHidden/VisuallyHidden.js";
15
- import Avatar from "../../../components/Avatar/Avatar.js";
16
- import Checkbox from "../../../components/Checkbox/Checkbox.js";
17
- import Button from "../../../components/Button/Button.js";
18
- import { Icon } from "../../../components/Icon/Icon.js";
19
- import Tooltip from "../../../components/Tooltip/Tooltip.js";
20
- function ShareResourceModal({
21
- isOpen,
22
- shareOptions,
23
- shareResource,
24
- children,
25
- onSuccess,
26
- onCancel
27
- }) {
28
- const {
29
- resourceId,
30
- resourceCreatorId,
31
- resourceRights
32
- } = shareOptions, [isLoading, setIsLoading] = useState(!0), {
33
- state: {
34
- isSharing,
35
- shareRights,
36
- shareRightActions
37
- },
38
- dispatch: shareDispatch,
39
- myAvatar,
40
- currentIsAuthor,
41
- handleShare,
42
- toggleRight,
43
- handleDeleteRow
44
- } = useShare({
45
- resourceId,
46
- resourceCreatorId,
47
- resourceRights,
48
- shareResource,
49
- setIsLoading,
50
- onSuccess
51
- }), {
52
- state: {
53
- searchResults,
54
- searchInputValue
55
- },
56
- showSearchAdmlHint,
57
- showSearchLoading,
58
- showSearchNoResults,
59
- getSearchMinLength,
60
- handleSearchInputChange,
61
- handleSearchResultsChange
62
- } = useSearch({
63
- resourceId,
64
- resourceCreatorId,
65
- shareRights,
66
- shareDispatch
67
- }), {
68
- refBookmark,
69
- showBookmark,
70
- handleBookmarkChange,
71
- toggleBookmark,
72
- bookmark,
73
- handleOnSave,
74
- showBookmarkInput,
75
- toggleBookmarkInput
76
- } = useShareBookmark({
77
- shareRights,
78
- shareDispatch
79
- }), {
80
- t
81
- } = useTranslation(), searchPlaceholder = showSearchAdmlHint() ? t("explorer.search.adml.hint") : t("explorer.modal.share.search.placeholder");
82
- return /* @__PURE__ */ createPortal(/* @__PURE__ */ jsxs(Modal, { id: "share_modal", size: "lg", isOpen, onModalClose: onCancel, children: [
83
- /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t("share.title") }),
84
- /* @__PURE__ */ jsxs(Modal.Body, { children: [
85
- /* @__PURE__ */ jsx(Heading, { headingStyle: "h4", level: "h3", className: "mb-16", children: t("explorer.modal.share.usersWithAccess") }),
86
- /* @__PURE__ */ jsx("div", { className: "table-responsive", children: isLoading ? /* @__PURE__ */ jsx(LoadingScreen, {}) : /* @__PURE__ */ jsxs("table", { className: "table border align-middle mb-0", children: [
87
- /* @__PURE__ */ jsx("thead", { className: "bg-secondary", children: /* @__PURE__ */ jsxs("tr", { children: [
88
- /* @__PURE__ */ jsx("th", { scope: "col", className: "w-32", children: /* @__PURE__ */ jsx(VisuallyHidden, { children: t("explorer.modal.share.avatar.shared.alt") }) }),
89
- /* @__PURE__ */ jsx("th", { scope: "col", children: /* @__PURE__ */ jsx(VisuallyHidden, { children: t("explorer.modal.share.search.placeholder") }) }),
90
- shareRightActions.map((shareRightAction) => /* @__PURE__ */ jsx("th", { scope: "col", className: "text-center text-white", children: t(shareRightAction.displayName) }, shareRightAction.displayName)),
91
- /* @__PURE__ */ jsx("th", { scope: "col", children: /* @__PURE__ */ jsx(VisuallyHidden, { children: t("close") }) })
92
- ] }) }),
93
- /* @__PURE__ */ jsxs("tbody", { children: [
94
- currentIsAuthor() && /* @__PURE__ */ jsxs("tr", { children: [
95
- /* @__PURE__ */ jsx("th", { scope: "row", children: /* @__PURE__ */ jsx(Avatar, { alt: t("explorer.modal.share.avatar.me.alt"), size: "xs", src: myAvatar, variant: "circle" }) }),
96
- /* @__PURE__ */ jsx("td", { children: t("share.me") }),
97
- shareRightActions.map((shareRightAction) => /* @__PURE__ */ jsx("td", { style: {
98
- width: "80px"
99
- }, className: "text-center text-white", children: /* @__PURE__ */ jsx(Checkbox, { checked: !0, disabled: !0 }) }, shareRightAction.displayName)),
100
- /* @__PURE__ */ jsx("td", {})
101
- ] }),
102
- /* @__PURE__ */ jsx(ShareBookmarkLine, { showBookmark, shareRightActions, shareRights, onDeleteRow: handleDeleteRow, toggleRight, toggleBookmark })
103
- ] })
104
- ] }) }),
105
- /* @__PURE__ */ jsxs("div", { className: "mt-16", children: [
106
- /* @__PURE__ */ jsx(Button, { color: "tertiary", leftIcon: /* @__PURE__ */ jsx(Icon, { name: "bookmark" }), rightIcon: /* @__PURE__ */ jsx(Icon, { name: "rafter-down", className: "w-16 min-w-0", style: {
107
- transition: "rotate 0.2s ease-out",
108
- rotate: showBookmarkInput ? "-180deg" : "0deg"
109
- } }), type: "button", variant: "ghost", className: "fw-normal", onClick: () => toggleBookmarkInput(!showBookmarkInput), children: t("share.save.sharebookmark") }),
110
- showBookmarkInput && /* @__PURE__ */ jsx(ShareBookmark, { refBookmark, bookmark, onBookmarkChange: handleBookmarkChange, onSave: handleOnSave })
111
- ] }),
112
- /* @__PURE__ */ jsx("hr", {}),
113
- /* @__PURE__ */ jsxs(Heading, { headingStyle: "h4", level: "h3", className: "mb-16 d-flex align-items-center", children: [
114
- /* @__PURE__ */ jsx("div", { className: "me-8", children: t("explorer.modal.share.search") }),
115
- /* @__PURE__ */ jsx(Tooltip, { message: "Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.", placement: "top", children: /* @__PURE__ */ jsx(Icon, { name: "info-circle", className: "c-pointer", size: "18" }) })
116
- ] }),
117
- /* @__PURE__ */ jsx("div", { className: "row", children: /* @__PURE__ */ jsx("div", { className: "col-10", children: /* @__PURE__ */ jsx(Combobox, { value: searchInputValue, placeholder: searchPlaceholder, isLoading: showSearchLoading(), noResult: showSearchNoResults(), options: searchResults, searchMinLength: getSearchMinLength(), onSearchInputChange: handleSearchInputChange, onSearchResultsChange: handleSearchResultsChange }) }) }),
118
- children
119
- ] }),
120
- /* @__PURE__ */ jsxs(Modal.Footer, { children: [
121
- /* @__PURE__ */ jsx(Button, { type: "button", color: "tertiary", variant: "ghost", onClick: onCancel, children: t("explorer.cancel") }),
122
- /* @__PURE__ */ jsx(Button, { type: "button", color: "primary", variant: "filled", isLoading: isSharing, onClick: handleShare, disabled: isSharing, children: t("share") })
123
- ] })
124
- ] }), document.getElementById("portal"));
125
- }
126
- export {
127
- ShareResourceModal as default
128
- };
@@ -1,178 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useReducer, useEffect } from "react";
3
- import { odeServices } from "edifice-ts-client";
4
- import { useTranslation } from "react-i18next";
5
- import useDebounce from "../../../../hooks/useDebounce/useDebounce.js";
6
- import useIsAdml from "../../../../core/useIsAdml/useIsAdml.js";
7
- import { useOdeClient } from "../../../../core/OdeClientProvider/OdeClientProvider.js";
8
- import { Icon } from "../../../../components/Icon/Icon.js";
9
- const initialState = {
10
- searchInputValue: "",
11
- searchResults: [],
12
- searchAPIResults: [],
13
- isSearching: !1
14
- };
15
- function reducer(state, action) {
16
- switch (action.type) {
17
- case "onChange":
18
- return {
19
- ...state,
20
- searchInputValue: action.payload
21
- };
22
- case "isSearching":
23
- return {
24
- ...state,
25
- isSearching: action.payload
26
- };
27
- case "addResult":
28
- return {
29
- ...state,
30
- searchResults: action.payload
31
- };
32
- case "addApiResult":
33
- return {
34
- ...state,
35
- searchAPIResults: action.payload
36
- };
37
- case "updateSearchResult":
38
- return {
39
- ...state,
40
- searchResults: action.payload
41
- };
42
- case "emptyResult":
43
- return {
44
- ...state,
45
- searchResults: action.payload
46
- };
47
- default:
48
- throw new Error("Unhandled action type");
49
- }
50
- }
51
- const defaultActions = [{
52
- id: "read",
53
- displayName: "read"
54
- }, {
55
- id: "comment",
56
- displayName: "comment"
57
- }], useSearch = ({
58
- resourceId,
59
- resourceCreatorId,
60
- shareRights,
61
- shareDispatch
62
- }) => {
63
- const [state, dispatch] = useReducer(reducer, initialState), debouncedSearchInputValue = useDebounce(state.searchInputValue, 500), {
64
- isAdml
65
- } = useIsAdml(), {
66
- appCode
67
- } = useOdeClient(), {
68
- t
69
- } = useTranslation();
70
- useEffect(() => {
71
- search(debouncedSearchInputValue);
72
- }, [debouncedSearchInputValue]);
73
- const handleSearchInputChange = (event) => {
74
- const value = event.target.value;
75
- dispatch({
76
- type: "onChange",
77
- payload: value
78
- });
79
- }, search = async (debouncedSearchInputValue2) => {
80
- if (resourceId) {
81
- if (dispatch({
82
- type: "isSearching",
83
- payload: !0
84
- }), !isAdml && debouncedSearchInputValue2.length >= 1 || isAdml && debouncedSearchInputValue2.length >= 3) {
85
- const resSearchShareSubjects = await odeServices.share().searchShareSubjects(appCode, resourceId, debouncedSearchInputValue2);
86
- dispatch({
87
- type: "addApiResult",
88
- payload: resSearchShareSubjects
89
- });
90
- const adaptedResults = resSearchShareSubjects.filter((right) => !shareRights.rights.find((shareRight) => shareRight.id === right.id)).filter((right) => !(right.type === "user" && right.id === resourceCreatorId)).map((searchResult) => {
91
- let label = searchResult.displayName;
92
- return searchResult.type === "user" && searchResult.profile ? label = `${label} (${t(searchResult.profile)})` : searchResult.type === "group" && searchResult.structureName && (label = `${label} (${searchResult.structureName})`), {
93
- value: searchResult.id,
94
- label,
95
- icon: searchResult.type === "sharebookmark" ? /* @__PURE__ */ jsx(Icon, { name: "bookmark" }) : null
96
- };
97
- });
98
- dispatch({
99
- type: "addResult",
100
- payload: adaptedResults
101
- });
102
- } else
103
- dispatch({
104
- type: "emptyResult",
105
- payload: []
106
- }), Promise.resolve();
107
- dispatch({
108
- type: "isSearching",
109
- payload: !1
110
- });
111
- }
112
- };
113
- return {
114
- state,
115
- showSearchAdmlHint: () => isAdml && state.searchInputValue.length < 3,
116
- showSearchLoading: () => state.isSearching,
117
- showSearchNoResults: () => !state.isSearching && !isAdml && debouncedSearchInputValue.length > 0 && state.searchResults.length === 0 || !state.isSearching && isAdml && debouncedSearchInputValue.length > 3 && state.searchResults.length === 0,
118
- getSearchMinLength: () => isAdml ? 3 : 1,
119
- handleSearchInputChange,
120
- handleSearchResultsChange: async (model) => {
121
- const shareSubject = state.searchAPIResults.find((searchAPIResult) => searchAPIResult.id === model[0]);
122
- if (shareSubject) {
123
- let rightsToAdd = [];
124
- if (shareSubject.type === "sharebookmark") {
125
- const bookmarkRes = await odeServices.directory().getBookMarkById(shareSubject.id);
126
- rightsToAdd.push({
127
- ...bookmarkRes,
128
- type: "sharebookmark",
129
- avatarUrl: "",
130
- directoryUrl: "",
131
- actions: defaultActions
132
- }), bookmarkRes == null || bookmarkRes.users.filter((user) => !shareRights.rights.find((right) => right.id === user.id)).forEach((user) => {
133
- rightsToAdd.push({
134
- ...user,
135
- type: "user",
136
- avatarUrl: "",
137
- directoryUrl: "",
138
- actions: defaultActions,
139
- isBookmarkMember: !0
140
- });
141
- }), bookmarkRes.groups.filter((group) => !shareRights.rights.find((right) => right.id === group.id)).forEach((group) => {
142
- rightsToAdd.push({
143
- ...group,
144
- type: "group",
145
- avatarUrl: "",
146
- directoryUrl: "",
147
- actions: defaultActions,
148
- isBookmarkMember: !0
149
- });
150
- });
151
- } else
152
- rightsToAdd = [{
153
- ...shareSubject,
154
- actions: [{
155
- id: "read",
156
- displayName: "read"
157
- }, {
158
- id: "comment",
159
- displayName: "comment"
160
- }]
161
- }];
162
- shareDispatch({
163
- type: "updateShareRights",
164
- payload: {
165
- ...shareRights,
166
- rights: [...shareRights.rights, ...rightsToAdd]
167
- }
168
- }), dispatch({
169
- type: "updateSearchResult",
170
- payload: state.searchResults.filter((result) => result.value !== model[0])
171
- });
172
- }
173
- }
174
- };
175
- };
176
- export {
177
- useSearch
178
- };
@@ -1,192 +0,0 @@
1
- import { useReducer, useEffect } from "react";
2
- import { odeServices } from "edifice-ts-client";
3
- import { useTranslation } from "react-i18next";
4
- import useUser from "../../../../core/useUser/useUser.js";
5
- import useToast from "../../../../hooks/useToast/useToast.js";
6
- import { useOdeClient } from "../../../../core/OdeClientProvider/OdeClientProvider.js";
7
- const initialState = {
8
- isSharing: !1,
9
- shareRights: {
10
- rights: [],
11
- visibleBookmarks: [],
12
- visibleGroups: [],
13
- visibleUsers: []
14
- },
15
- shareRightActions: []
16
- };
17
- function reducer(state, action) {
18
- switch (action.type) {
19
- case "init":
20
- return {
21
- ...state,
22
- ...action.payload
23
- };
24
- case "deleteRow":
25
- return {
26
- ...state,
27
- shareRights: action.payload
28
- };
29
- case "updateShareRights":
30
- return {
31
- ...state,
32
- shareRights: action.payload
33
- };
34
- case "toggleRight":
35
- return {
36
- ...state,
37
- shareRights: action.payload
38
- };
39
- case "isSharing":
40
- return {
41
- ...state,
42
- isSharing: action.payload
43
- };
44
- default:
45
- throw new Error("Unhandled action type");
46
- }
47
- }
48
- function useShare({
49
- resourceId,
50
- resourceRights,
51
- resourceCreatorId,
52
- shareResource,
53
- setIsLoading,
54
- onSuccess
55
- }) {
56
- const {
57
- appCode
58
- } = useOdeClient(), {
59
- user,
60
- avatar
61
- } = useUser(), toast = useToast(), {
62
- t
63
- } = useTranslation(), [state, dispatch] = useReducer(reducer, initialState);
64
- useEffect(() => {
65
- resourceId && (async () => {
66
- try {
67
- const [shareRightActions, shareRights] = await Promise.all([odeServices.share().getActionsForApp(appCode), odeServices.share().getRightsForResource(appCode, resourceId)]);
68
- dispatch({
69
- type: "init",
70
- payload: {
71
- shareRightActions,
72
- shareRights
73
- }
74
- });
75
- } catch (error) {
76
- console.error(error);
77
- }
78
- setIsLoading(!1);
79
- })();
80
- }, [resourceId]);
81
- const toggleRight = (shareRight, actionName) => {
82
- var _a, _b;
83
- const {
84
- rights,
85
- ...props
86
- } = state.shareRights, newShareRights = [...rights], index = newShareRights.findIndex((x) => x.id === shareRight.id), actionObject = state.shareRightActions.filter((shareRightAction) => shareRightAction.id === actionName)[0];
87
- if (newShareRights[index].actions.findIndex((action) => action.id === actionName) > -1) {
88
- let updatedActions = newShareRights[index].actions.filter((action) => action.id !== actionName);
89
- const requiredActions = state.shareRightActions.filter((shareRightAction) => {
90
- var _a2;
91
- return (_a2 = shareRightAction.requires) == null ? void 0 : _a2.includes(actionName);
92
- });
93
- updatedActions = updatedActions.filter((action) => !requiredActions.find((requiredAction) => requiredAction.id === action.id)), newShareRights[index] = {
94
- ...newShareRights[index],
95
- actions: updatedActions
96
- };
97
- } else {
98
- const requiredActions = state.shareRightActions.filter((shareRightAction) => {
99
- var _a2;
100
- return ((_a2 = actionObject.requires) == null ? void 0 : _a2.includes(shareRightAction.id)) && !newShareRights[index].actions.find((action) => action.id === shareRightAction.id);
101
- });
102
- newShareRights[index] = {
103
- ...newShareRights[index],
104
- actions: [...newShareRights[index].actions, actionObject, ...requiredActions]
105
- };
106
- }
107
- shareRight.type === "sharebookmark" && ((_a = newShareRights[index].users) == null || _a.forEach((user2) => {
108
- const userIndex = newShareRights.findIndex((item) => item.id === user2.id);
109
- newShareRights[userIndex] = {
110
- ...newShareRights[userIndex],
111
- actions: newShareRights[index].actions
112
- };
113
- }), (_b = newShareRights[index].groups) == null || _b.forEach((user2) => {
114
- const userIndex = newShareRights.findIndex((item) => item.id === user2.id);
115
- newShareRights[userIndex] = {
116
- ...newShareRights[userIndex],
117
- actions: newShareRights[index].actions
118
- };
119
- })), dispatch({
120
- type: "toggleRight",
121
- payload: {
122
- rights: newShareRights,
123
- ...props
124
- }
125
- });
126
- }, notifySuccess = (value) => {
127
- Object.keys(value)[0] === "error" ? (toast.error(t("explorer.shared.status.error")), console.error("Failed to save share", value)) : toast.success(t("explorer.shared.status.saved"));
128
- };
129
- return {
130
- state,
131
- dispatch,
132
- currentIsAuthor: () => resourceCreatorId === (user == null ? void 0 : user.userId),
133
- myAvatar: avatar,
134
- handleDeleteRow: (shareRight) => {
135
- dispatch({
136
- type: "deleteRow",
137
- payload: {
138
- ...state.shareRights,
139
- rights: state.shareRights.rights.filter((right) => {
140
- var _a, _b;
141
- return right.id !== shareRight.id && !((_a = shareRight.users) != null && _a.find((user2) => user2.id === right.id)) && !((_b = shareRight.groups) != null && _b.find((group) => group.id === right.id));
142
- })
143
- }
144
- });
145
- },
146
- handleShare: async () => {
147
- dispatch({
148
- type: "isSharing",
149
- payload: !0
150
- });
151
- try {
152
- const myRights = resourceRights.filter((right) => user && right.includes(`user:${user.userId}`)).map((right) => right.split(":")[2]).filter((right) => !!right), shares = [...state.shareRights.rights];
153
- if (myRights.length > 0) {
154
- const actions = myRights.map((right) => ({
155
- displayName: right,
156
- id: right
157
- }));
158
- shares.push({
159
- actions,
160
- avatarUrl: "",
161
- directoryUrl: "",
162
- displayName: user.username,
163
- id: user.userId,
164
- type: "user"
165
- });
166
- }
167
- if (shareResource) {
168
- const result = await shareResource.mutateAsync({
169
- resourceId,
170
- rights: shares
171
- });
172
- notifySuccess(result);
173
- } else {
174
- const result = await odeServices.share().saveRights(appCode, resourceId, shares);
175
- notifySuccess(result);
176
- }
177
- onSuccess();
178
- } catch (error) {
179
- typeof error == "string" && toast.error(t("explorer.shared.status.error")), console.error("Failed to save share", error);
180
- } finally {
181
- dispatch({
182
- type: "isSharing",
183
- payload: !1
184
- });
185
- }
186
- },
187
- toggleRight
188
- };
189
- }
190
- export {
191
- useShare as default
192
- };