ode-explorer 1.3.2-dev.202401091744 → 1.3.2-dev.202401101530

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.
@@ -1,77 +1,64 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Card, useOdeClient, useScrollToTop } from "@edifice-ui/react";
3
- import { useSpring, animated } from "@react-spring/web";
4
- import { Files } from "@edifice-ui/icons";
5
- import { h as useSelectedFolders, i as useFolderIds, u as useStoreActions } from "./index2.js";
1
+ import { jsx as i, jsxs as y } from "react/jsx-runtime";
2
+ import { Card as d, useOdeClient as C, useScrollToTop as T } from "@edifice-ui/react";
3
+ import { useSpring as I, animated as a } from "@react-spring/web";
4
+ import { Files as N } from "@edifice-ui/icons";
5
+ import { h as x, i as j, u as A } from "./index2.js";
6
6
  import "react";
7
7
  import "react-i18next";
8
8
  import "edifice-ts-client";
9
9
  import "i18next";
10
10
  import "zustand";
11
11
  import "@tanstack/react-query";
12
- const FolderCard = ({
13
- app,
14
- name,
15
- isSelected = false,
16
- isSelectable = true,
17
- onClick,
18
- onSelect
12
+ const g = ({
13
+ app: s,
14
+ name: n,
15
+ isSelected: l = !1,
16
+ isSelectable: o = !0,
17
+ onClick: t,
18
+ onSelect: c
19
+ }) => /* @__PURE__ */ i(d, { app: s, isSelectable: o, isSelected: l, onClick: t, onSelect: c, children: (p) => /* @__PURE__ */ y(d.Body, { children: [
20
+ /* @__PURE__ */ i(N, { width: "48", height: "48", className: `color-app-${p}` }),
21
+ /* @__PURE__ */ i(d.Title, { children: n })
22
+ ] }) });
23
+ g.displayName = "FolderCard";
24
+ const E = ({
25
+ data: s
19
26
  }) => {
20
- return /* @__PURE__ */ jsx(Card, { app, isSelectable, isSelected, onClick, onSelect, children: (appCode) => /* @__PURE__ */ jsxs(Card.Body, { children: [
21
- /* @__PURE__ */ jsx(Files, { width: "48", height: "48", className: `color-app-${appCode}` }),
22
- /* @__PURE__ */ jsx(Card.Title, { children: name })
23
- ] }) });
24
- };
25
- FolderCard.displayName = "FolderCard";
26
- const FoldersList = ({
27
- data
28
- }) => {
29
- var _a, _b;
27
+ var m, u;
30
28
  const {
31
- currentApp
32
- } = useOdeClient();
33
- const selectedFolders = useSelectedFolders();
34
- const folderIds = useFolderIds();
35
- const {
36
- setSelectedFolders,
37
- setFolderIds,
38
- openFolder
39
- } = useStoreActions();
40
- function toggleSelect(folder) {
41
- if (folderIds.includes(folder.id)) {
42
- setFolderIds(folderIds.filter((selectedFolder) => selectedFolder !== folder.id));
43
- setSelectedFolders(selectedFolders.filter((selectedFolder) => selectedFolder.id !== folder.id));
44
- } else {
45
- setFolderIds([...folderIds, folder.id]);
46
- setSelectedFolders([...selectedFolders, folder]);
47
- }
29
+ currentApp: n
30
+ } = C(), l = x(), o = j(), {
31
+ setSelectedFolders: t,
32
+ setFolderIds: c,
33
+ openFolder: p
34
+ } = A();
35
+ function h(e) {
36
+ o.includes(e.id) ? (c(o.filter((r) => r !== e.id)), t(l.filter((r) => r.id !== e.id))) : (c([...o, e.id]), t([...l, e]));
48
37
  }
49
- const springs = useSpring({
38
+ const F = I({
50
39
  from: {
51
40
  opacity: 0
52
41
  },
53
42
  to: {
54
43
  opacity: 1
55
44
  }
56
- });
57
- const scrollToTop = useScrollToTop();
58
- return ((_a = data == null ? void 0 : data.pages[0]) == null ? void 0 : _a.folders.length) ? /* @__PURE__ */ jsx(animated.ul, { className: "grid ps-0 list-unstyled mb-24", children: (_b = data == null ? void 0 : data.pages[0]) == null ? void 0 : _b.folders.map((folder) => {
45
+ }), f = T();
46
+ return (m = s == null ? void 0 : s.pages[0]) != null && m.folders.length ? /* @__PURE__ */ i(a.ul, { className: "grid ps-0 list-unstyled mb-24", children: (u = s == null ? void 0 : s.pages[0]) == null ? void 0 : u.folders.map((e) => {
59
47
  const {
60
- id,
61
- name
62
- } = folder;
63
- return /* @__PURE__ */ jsx(animated.li, { className: "g-col-4 z-1", style: {
48
+ id: r,
49
+ name: S
50
+ } = e;
51
+ return /* @__PURE__ */ i(a.li, { className: "g-col-4 z-1", style: {
64
52
  position: "relative",
65
- ...springs
66
- }, children: /* @__PURE__ */ jsx(FolderCard, { name, app: currentApp, isSelected: folderIds.includes(folder.id), onClick: () => {
67
- scrollToTop();
68
- openFolder({
69
- folder,
70
- folderId: folder.id
53
+ ...F
54
+ }, children: /* @__PURE__ */ i(g, { name: S, app: n, isSelected: o.includes(e.id), onClick: () => {
55
+ f(), p({
56
+ folder: e,
57
+ folderId: e.id
71
58
  });
72
- }, onSelect: () => toggleSelect(folder) }) }, id);
59
+ }, onSelect: () => h(e) }) }, r);
73
60
  }) }) : null;
74
61
  };
75
62
  export {
76
- FoldersList as default
63
+ E as default
77
64
  };
package/lib/Library.js CHANGED
@@ -1,19 +1,16 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useOdeTheme, useLibraryUrl, usePaths, Library as Library$1 } from "@edifice-ui/react";
3
- import { useTranslation } from "react-i18next";
4
- const Library = () => {
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { useOdeTheme as i, useLibraryUrl as s, usePaths as l, Library as b } from "@edifice-ui/react";
3
+ import { useTranslation as n } from "react-i18next";
4
+ const u = () => {
5
5
  const {
6
- t
7
- } = useTranslation();
8
- const {
9
- theme
10
- } = useOdeTheme();
11
- const {
12
- libraryUrl
13
- } = useLibraryUrl();
14
- const [imagePath] = usePaths();
15
- return /* @__PURE__ */ jsx(Library$1, { src: `${imagePath}/${theme == null ? void 0 : theme.bootstrapVersion}/image-library.svg`, url: libraryUrl, alt: t("explorer.libray.img.alt"), text: t("explorer.libray.title"), textButton: t("explorer.libray.btn") });
6
+ t: r
7
+ } = n(), {
8
+ theme: t
9
+ } = i(), {
10
+ libraryUrl: a
11
+ } = s(), [e] = l();
12
+ return /* @__PURE__ */ o(b, { src: `${e}/${t == null ? void 0 : t.bootstrapVersion}/image-library.svg`, url: a, alt: r("explorer.libray.img.alt"), text: r("explorer.libray.title"), textButton: r("explorer.libray.btn") });
16
13
  };
17
14
  export {
18
- Library as default
15
+ u as default
19
16
  };
package/lib/MoveModal.js CHANGED
@@ -1,94 +1,78 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Modal, TreeView, Button } from "@edifice-ui/react";
3
- import { createPortal } from "react-dom";
4
- import { useTranslation } from "react-i18next";
5
- import { useState } from "react";
6
- import { useQueryClient } from "@tanstack/react-query";
7
- import { s as useMoveItem, h as useSelectedFolders, g as useSelectedResources, u as useStoreActions, t as useTreeData } from "./index2.js";
1
+ import { jsxs as h, jsx as l } from "react/jsx-runtime";
2
+ import { Modal as a, TreeView as T, Button as I } from "@edifice-ui/react";
3
+ import { createPortal as M } from "react-dom";
4
+ import { useTranslation as y } from "react-i18next";
5
+ import { useState as b } from "react";
6
+ import { useQueryClient as F } from "@tanstack/react-query";
7
+ import { s as x, h as S, g as w, u as g, t as B } from "./index2.js";
8
8
  import "@edifice-ui/icons";
9
9
  import "edifice-ts-client";
10
10
  import "i18next";
11
11
  import "zustand";
12
- function useMoveModal({
13
- onSuccess
12
+ function C({
13
+ onSuccess: n
14
14
  }) {
15
- const [selectedFolder, setSelectedFolder] = useState();
16
- const moveItem = useMoveItem();
17
- const selectedFolders = useSelectedFolders();
18
- const selectedResources = useSelectedResources();
19
- const {
20
- foldTreeItem,
21
- unfoldTreeItem
22
- } = useStoreActions();
23
- const queryclient = useQueryClient();
24
- async function onMove() {
15
+ const [d, t] = b(), r = x(), i = S(), m = w(), {
16
+ foldTreeItem: s,
17
+ unfoldTreeItem: c
18
+ } = g(), f = F();
19
+ async function u() {
25
20
  try {
26
- if (!selectedFolder)
21
+ if (!d)
27
22
  throw new Error("explorer.move.selection.empty");
28
- await moveItem.mutate(selectedFolder);
29
- await (onSuccess == null ? void 0 : onSuccess());
23
+ await r.mutate(d), await (n == null ? void 0 : n());
30
24
  } catch (e) {
31
25
  console.error(e);
32
26
  }
33
27
  }
34
- const canMove = (destination) => {
35
- var _a;
36
- for (const selectedFolder2 of selectedFolders) {
37
- if (destination === selectedFolder2.id || destination === selectedFolder2.parentId) {
38
- return false;
39
- }
40
- }
41
- for (const selectedResource of selectedResources) {
42
- if (destination === ((selectedResource == null ? void 0 : selectedResource.folderIds) && selectedResource.folderIds[0]) || ((_a = selectedResource == null ? void 0 : selectedResource.folderIds) == null ? void 0 : _a.length) === 0 && destination === "default") {
43
- return false;
44
- }
45
- }
46
- return true;
28
+ const v = (e) => {
29
+ var p;
30
+ for (const o of i)
31
+ if (e === o.id || e === o.parentId)
32
+ return !1;
33
+ for (const o of m)
34
+ if (e === ((o == null ? void 0 : o.folderIds) && o.folderIds[0]) || ((p = o == null ? void 0 : o.folderIds) == null ? void 0 : p.length) === 0 && e === "default")
35
+ return !1;
36
+ return !0;
47
37
  };
48
38
  return {
49
- disableSubmit: !selectedFolder,
50
- handleTreeItemSelect: (folderId) => {
51
- if (canMove(folderId)) {
52
- setSelectedFolder(folderId);
53
- } else {
54
- setSelectedFolder(void 0);
55
- }
39
+ disableSubmit: !d,
40
+ handleTreeItemSelect: (e) => {
41
+ v(e) ? t(e) : t(void 0);
56
42
  },
57
- handleTreeItemFold: foldTreeItem,
58
- handleTreeItemUnfold: async (folderId) => await unfoldTreeItem(folderId, queryclient),
43
+ handleTreeItemFold: s,
44
+ handleTreeItemUnfold: async (e) => await c(e, f),
59
45
  onMove: () => {
60
- onMove();
46
+ u();
61
47
  }
62
48
  };
63
49
  }
64
- function MoveModal({
65
- isOpen,
66
- onSuccess,
67
- onCancel
50
+ function z({
51
+ isOpen: n,
52
+ onSuccess: d,
53
+ onCancel: t
68
54
  }) {
69
55
  const {
70
- t
71
- } = useTranslation();
72
- const {
73
- handleTreeItemFold,
74
- handleTreeItemSelect,
75
- handleTreeItemUnfold,
76
- onMove,
77
- disableSubmit
78
- } = useMoveModal({
79
- onSuccess
80
- });
81
- const treeData = useTreeData();
82
- return /* @__PURE__ */ createPortal(/* @__PURE__ */ jsxs(Modal, { isOpen, onModalClose: onCancel, id: "moveModal", children: [
83
- /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t("explorer.move.title") }),
84
- /* @__PURE__ */ jsx(Modal.Subtitle, { children: t("explorer.move.subtitle") }),
85
- /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx(TreeView, { data: treeData, onTreeItemSelect: handleTreeItemSelect, onTreeItemFold: handleTreeItemFold, onTreeItemUnfold: handleTreeItemUnfold }) }),
86
- /* @__PURE__ */ jsxs(Modal.Footer, { children: [
87
- /* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("explorer.cancel") }),
88
- /* @__PURE__ */ jsx(Button, { color: "primary", onClick: onMove, type: "button", variant: "filled", disabled: disableSubmit, children: t("explorer.move") })
56
+ t: r
57
+ } = y(), {
58
+ handleTreeItemFold: i,
59
+ handleTreeItemSelect: m,
60
+ handleTreeItemUnfold: s,
61
+ onMove: c,
62
+ disableSubmit: f
63
+ } = C({
64
+ onSuccess: d
65
+ }), u = B();
66
+ return /* @__PURE__ */ M(/* @__PURE__ */ h(a, { isOpen: n, onModalClose: t, id: "moveModal", children: [
67
+ /* @__PURE__ */ l(a.Header, { onModalClose: t, children: r("explorer.move.title") }),
68
+ /* @__PURE__ */ l(a.Subtitle, { children: r("explorer.move.subtitle") }),
69
+ /* @__PURE__ */ l(a.Body, { children: /* @__PURE__ */ l(T, { data: u, onTreeItemSelect: m, onTreeItemFold: i, onTreeItemUnfold: s }) }),
70
+ /* @__PURE__ */ h(a.Footer, { children: [
71
+ /* @__PURE__ */ l(I, { color: "tertiary", onClick: t, type: "button", variant: "ghost", children: r("explorer.cancel") }),
72
+ /* @__PURE__ */ l(I, { color: "primary", onClick: c, type: "button", variant: "filled", disabled: f, children: r("explorer.move") })
89
73
  ] })
90
74
  ] }), document.getElementById("portal"));
91
75
  }
92
76
  export {
93
- MoveModal as default
77
+ z as default
94
78
  };