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.
package/lib/AppAction.js CHANGED
@@ -1,47 +1,34 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { Suspense, lazy } from "react";
3
- import { Plus } from "@edifice-ui/icons";
4
- import { useToggle, useOdeClient, Button, LoadingScreen } from "@edifice-ui/react";
5
- import { useTranslation } from "react-i18next";
6
- import { u as useStoreActions, a as useActions, b as useCurrentFolder, c as useCreateResource } from "./index2.js";
1
+ import { jsxs as d, Fragment as p, jsx as e } from "react/jsx-runtime";
2
+ import { Suspense as f, lazy as C } from "react";
3
+ import { Plus as g } from "@edifice-ui/icons";
4
+ import { useToggle as R, useOdeClient as S, Button as h, LoadingScreen as O } from "@edifice-ui/react";
5
+ import { useTranslation as x } from "react-i18next";
6
+ import { u as y, a as A, b, c as F } from "./index2.js";
7
7
  import "edifice-ts-client";
8
8
  import "i18next";
9
9
  import "zustand";
10
10
  import "@tanstack/react-query";
11
- const CreateModal = /* @__PURE__ */ lazy(async () => {
12
- const module = await import("@edifice-ui/react");
13
- return {
14
- default: module.ResourceModal
15
- };
16
- });
17
- function AppAction() {
18
- const [isCreateResourceOpen, toggle] = useToggle();
19
- const {
20
- appCode
21
- } = useOdeClient();
22
- const {
23
- t
24
- } = useTranslation(appCode);
25
- const {
26
- clearSelectedItems,
27
- clearSelectedIds
28
- } = useStoreActions();
29
- const {
30
- data: actions
31
- } = useActions();
32
- const canCreate = actions == null ? void 0 : actions.find((action) => action.id === "create");
33
- const currentFolder = useCurrentFolder();
34
- const createResource = useCreateResource();
35
- const handleOnResourceCreate = () => {
36
- clearSelectedItems();
37
- clearSelectedIds();
38
- toggle();
39
- };
40
- return canCreate ? /* @__PURE__ */ jsxs(Fragment, { children: [
41
- /* @__PURE__ */ jsx(Button, { type: "button", color: "primary", variant: "filled", leftIcon: /* @__PURE__ */ jsx(Plus, {}), className: "ms-auto", onClick: handleOnResourceCreate, children: t("explorer.create.title") }),
42
- /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: isCreateResourceOpen && /* @__PURE__ */ jsx(CreateModal, { mode: "create", actions, currentFolder, createResource, isOpen: isCreateResourceOpen, onSuccess: toggle, onCancel: toggle }) })
11
+ const I = /* @__PURE__ */ C(async () => ({
12
+ default: (await import("@edifice-ui/react")).ResourceModal
13
+ }));
14
+ function q() {
15
+ const [o, r] = R(), {
16
+ appCode: n
17
+ } = S(), {
18
+ t: s
19
+ } = x(n), {
20
+ clearSelectedItems: a,
21
+ clearSelectedIds: c
22
+ } = y(), {
23
+ data: t
24
+ } = A(), l = t == null ? void 0 : t.find((m) => m.id === "create"), i = b(), u = F();
25
+ return l ? /* @__PURE__ */ d(p, { children: [
26
+ /* @__PURE__ */ e(h, { type: "button", color: "primary", variant: "filled", leftIcon: /* @__PURE__ */ e(g, {}), className: "ms-auto", onClick: () => {
27
+ a(), c(), r();
28
+ }, children: s("explorer.create.title") }),
29
+ /* @__PURE__ */ e(f, { fallback: /* @__PURE__ */ e(O, {}), children: o && /* @__PURE__ */ e(I, { mode: "create", actions: t, currentFolder: i, createResource: u, isOpen: o, onSuccess: r, onCancel: r }) })
43
30
  ] }) : null;
44
31
  }
45
32
  export {
46
- AppAction as default
33
+ q as default
47
34
  };
@@ -1,60 +1,52 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Modal, Button } from "@edifice-ui/react";
3
- import { createPortal } from "react-dom";
4
- import { useTranslation } from "react-i18next";
5
- import { q as useDelete, r as useTrash, d as useIsTrash } from "./index2.js";
1
+ import { jsxs as s, jsx as l } from "react/jsx-runtime";
2
+ import { Modal as a, Button as d } from "@edifice-ui/react";
3
+ import { createPortal as m } from "react-dom";
4
+ import { useTranslation as p } from "react-i18next";
5
+ import { q as c, r as h, d as u } from "./index2.js";
6
6
  import "react";
7
7
  import "@edifice-ui/icons";
8
8
  import "edifice-ts-client";
9
9
  import "i18next";
10
10
  import "zustand";
11
11
  import "@tanstack/react-query";
12
- function useDeleteModal({
13
- onSuccess
12
+ function f({
13
+ onSuccess: t
14
14
  }) {
15
- const deleteItem = useDelete();
16
- const trashItem = useTrash();
17
- const isTrashFolder = useIsTrash();
18
- async function onDelete() {
15
+ const i = c(), r = h(), e = u();
16
+ async function o() {
19
17
  try {
20
- if (isTrashFolder) {
21
- await deleteItem.mutate();
22
- } else {
23
- await trashItem.mutate();
24
- }
25
- onSuccess == null ? void 0 : onSuccess();
26
- } catch (e) {
27
- console.error(e);
18
+ e ? await i.mutate() : await r.mutate(), t == null || t();
19
+ } catch (n) {
20
+ console.error(n);
28
21
  }
29
22
  }
30
23
  return {
31
- isTrashFolder,
32
- onDelete
24
+ isTrashFolder: e,
25
+ onDelete: o
33
26
  };
34
27
  }
35
- function DeleteModal({
36
- isOpen,
37
- onSuccess = () => ({}),
38
- onCancel = () => ({})
28
+ function k({
29
+ isOpen: t,
30
+ onSuccess: i = () => ({}),
31
+ onCancel: r = () => ({})
39
32
  }) {
40
33
  const {
41
- t
42
- } = useTranslation();
43
- const {
44
- isTrashFolder,
45
- onDelete
46
- } = useDeleteModal({
47
- onSuccess
34
+ t: e
35
+ } = p(), {
36
+ isTrashFolder: o,
37
+ onDelete: n
38
+ } = f({
39
+ onSuccess: i
48
40
  });
49
- return /* @__PURE__ */ createPortal(/* @__PURE__ */ jsxs(Modal, { isOpen, onModalClose: onCancel, id: "deleteModal", children: [
50
- /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t(isTrashFolder ? "explorer.delete.title" : "explorer.trash.title") }),
51
- /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx("p", { className: "body", children: t(isTrashFolder ? "explorer.delete.subtitle" : "explorer.trash.subtitle") }) }),
52
- /* @__PURE__ */ jsxs(Modal.Footer, { children: [
53
- /* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("explorer.cancel") }),
54
- /* @__PURE__ */ jsx(Button, { color: "danger", onClick: onDelete, type: "button", variant: "filled", children: t(isTrashFolder ? "explorer.delete" : "explorer.trash") })
41
+ return /* @__PURE__ */ m(/* @__PURE__ */ s(a, { isOpen: t, onModalClose: r, id: "deleteModal", children: [
42
+ /* @__PURE__ */ l(a.Header, { onModalClose: r, children: e(o ? "explorer.delete.title" : "explorer.trash.title") }),
43
+ /* @__PURE__ */ l(a.Body, { children: /* @__PURE__ */ l("p", { className: "body", children: e(o ? "explorer.delete.subtitle" : "explorer.trash.subtitle") }) }),
44
+ /* @__PURE__ */ s(a.Footer, { children: [
45
+ /* @__PURE__ */ l(d, { color: "tertiary", onClick: r, type: "button", variant: "ghost", children: e("explorer.cancel") }),
46
+ /* @__PURE__ */ l(d, { color: "danger", onClick: n, type: "button", variant: "filled", children: e(o ? "explorer.delete" : "explorer.trash") })
55
47
  ] })
56
48
  ] }), document.getElementById("portal"));
57
49
  }
58
50
  export {
59
- DeleteModal as default
51
+ k as default
60
52
  };
@@ -1,20 +1,20 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Modal, Button } from "@edifice-ui/react";
3
- import { createPortal } from "react-dom";
4
- import { useTranslation } from "react-i18next";
5
- function ActionResourceDisableModal({
6
- isOpen,
7
- onCancel = () => ({})
1
+ import { jsxs as a, jsx as o } from "react/jsx-runtime";
2
+ import { Modal as r, Button as i } from "@edifice-ui/react";
3
+ import { createPortal as n } from "react-dom";
4
+ import { useTranslation as d } from "react-i18next";
5
+ function u({
6
+ isOpen: l,
7
+ onCancel: t = () => ({})
8
8
  }) {
9
9
  const {
10
- t
11
- } = useTranslation();
12
- return /* @__PURE__ */ createPortal(/* @__PURE__ */ jsxs(Modal, { isOpen, onModalClose: onCancel, id: "trash_action_disable_resource", children: [
13
- /* @__PURE__ */ jsx(Modal.Header, { onModalClose: () => onCancel(), children: t("explorer.trash.action.modal.title") }),
14
- /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx("p", { className: "body", children: t("explorer.trash.action.modal.text") }) }),
15
- /* @__PURE__ */ jsx(Modal.Footer, { children: /* @__PURE__ */ jsx(Button, { color: "primary", onClick: onCancel, type: "button", variant: "outline", children: t("close") }) })
10
+ t: e
11
+ } = d();
12
+ return /* @__PURE__ */ n(/* @__PURE__ */ a(r, { isOpen: l, onModalClose: t, id: "trash_action_disable_resource", children: [
13
+ /* @__PURE__ */ o(r.Header, { onModalClose: () => t(), children: e("explorer.trash.action.modal.title") }),
14
+ /* @__PURE__ */ o(r.Body, { children: /* @__PURE__ */ o("p", { className: "body", children: e("explorer.trash.action.modal.text") }) }),
15
+ /* @__PURE__ */ o(r.Footer, { children: /* @__PURE__ */ o(i, { color: "primary", onClick: t, type: "button", variant: "outline", children: e("close") }) })
16
16
  ] }), document.getElementById("portal"));
17
17
  }
18
18
  export {
19
- ActionResourceDisableModal as default
19
+ u as default
20
20
  };
@@ -1,53 +1,37 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useOdeClient, useOdeTheme, usePaths, EmptyScreen } from "@edifice-ui/react";
3
- import { useTranslation } from "react-i18next";
4
- import { a as useActions } from "./index2.js";
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { useOdeClient as m, useOdeTheme as a, usePaths as c, EmptyScreen as u } from "@edifice-ui/react";
3
+ import { useTranslation as d } from "react-i18next";
4
+ import { a as x } from "./index2.js";
5
5
  import "react";
6
6
  import "@edifice-ui/icons";
7
7
  import "edifice-ts-client";
8
8
  import "i18next";
9
9
  import "zustand";
10
10
  import "@tanstack/react-query";
11
- function EmptyScreenApp() {
11
+ function P() {
12
12
  const {
13
- appCode
14
- } = useOdeClient();
15
- const {
16
- theme
17
- } = useOdeTheme();
18
- const [imagePath] = usePaths();
19
- const {
20
- t
21
- } = useTranslation();
22
- const {
23
- data: actions
24
- } = useActions();
25
- const canCreate = actions == null ? void 0 : actions.find((action) => action.id === "create");
26
- const labelEmptyScreenApp = () => {
27
- if ((canCreate == null ? void 0 : canCreate.available) && (theme == null ? void 0 : theme.is1d)) {
28
- return t("explorer.emptyScreen.txt1d.create", {
29
- ns: appCode
30
- });
31
- } else if ((canCreate == null ? void 0 : canCreate.available) && !(theme == null ? void 0 : theme.is1d)) {
32
- return t("explorer.emptyScreen.txt2d.create", {
33
- ns: appCode
34
- });
35
- } else if (!(canCreate == null ? void 0 : canCreate.available) && (theme == null ? void 0 : theme.is1d)) {
36
- return t("explorer.emptyScreen.txt1d.consultation", {
37
- ns: appCode
38
- });
39
- } else {
40
- return t("explorer.emptyScreen.txt2d.consultation", {
41
- ns: appCode
42
- });
43
- }
44
- };
45
- return /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: `${imagePath}/emptyscreen/illu-${appCode}.svg`, imageAlt: t("explorer.emptyScreen.app.alt", {
46
- ns: appCode
47
- }), title: `${(canCreate == null ? void 0 : canCreate.available) ? t("explorer.emptyScreen.title.create", {
48
- ns: appCode
49
- }) : t("explorer.emptyScreen.title.consultation")}`, text: labelEmptyScreenApp() });
13
+ appCode: r
14
+ } = m(), {
15
+ theme: t
16
+ } = a(), [i] = c(), {
17
+ t: o
18
+ } = d(), {
19
+ data: p
20
+ } = x(), e = p == null ? void 0 : p.find((s) => s.id === "create"), n = () => e != null && e.available && (t != null && t.is1d) ? o("explorer.emptyScreen.txt1d.create", {
21
+ ns: r
22
+ }) : e != null && e.available && !(t != null && t.is1d) ? o("explorer.emptyScreen.txt2d.create", {
23
+ ns: r
24
+ }) : !(e != null && e.available) && (t != null && t.is1d) ? o("explorer.emptyScreen.txt1d.consultation", {
25
+ ns: r
26
+ }) : o("explorer.emptyScreen.txt2d.consultation", {
27
+ ns: r
28
+ });
29
+ return /* @__PURE__ */ l(u, { imageSrc: `${i}/emptyscreen/illu-${r}.svg`, imageAlt: o("explorer.emptyScreen.app.alt", {
30
+ ns: r
31
+ }), title: `${e != null && e.available ? o("explorer.emptyScreen.title.create", {
32
+ ns: r
33
+ }) : o("explorer.emptyScreen.title.consultation")}`, text: n() });
50
34
  }
51
35
  export {
52
- EmptyScreenApp as default
36
+ P as default
53
37
  };
@@ -1,13 +1,12 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { usePaths, EmptyScreen } from "@edifice-ui/react";
3
- import { useTranslation } from "react-i18next";
4
- function EmptyScreenError() {
5
- const [imagePath] = usePaths();
6
- const {
7
- t
8
- } = useTranslation();
9
- return /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: `${imagePath}/emptyscreen/illu-error.svg`, imageAlt: t("explorer.emptyScreen.error.alt"), text: "explorer.emptyScreen.error.text" });
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { usePaths as o, EmptyScreen as m } from "@edifice-ui/react";
3
+ import { useTranslation as n } from "react-i18next";
4
+ function c() {
5
+ const [r] = o(), {
6
+ t: e
7
+ } = n();
8
+ return /* @__PURE__ */ t(m, { imageSrc: `${r}/emptyscreen/illu-error.svg`, imageAlt: e("explorer.emptyScreen.error.alt"), text: "explorer.emptyScreen.error.text" });
10
9
  }
11
10
  export {
12
- EmptyScreenError as default
11
+ c as default
13
12
  };
@@ -1,20 +1,18 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { usePaths, useOdeClient, EmptyScreen } from "@edifice-ui/react";
3
- import { useTranslation } from "react-i18next";
4
- function EmptyScreenNoContentInFolder() {
5
- const [imagePath] = usePaths();
6
- const {
7
- appCode
8
- } = useOdeClient();
9
- const {
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { usePaths as o, useOdeClient as m, EmptyScreen as l } from "@edifice-ui/react";
3
+ import { useTranslation as p } from "react-i18next";
4
+ function i() {
5
+ const [n] = o(), {
6
+ appCode: e
7
+ } = m(), {
10
8
  t
11
- } = useTranslation();
12
- return /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: `${imagePath}/emptyscreen/illu-no-content-in-folder.svg`, imageAlt: t("explorer.emptyScreen.folder.empty.alt", {
13
- ns: appCode
9
+ } = p();
10
+ return /* @__PURE__ */ r(l, { imageSrc: `${n}/emptyscreen/illu-no-content-in-folder.svg`, imageAlt: t("explorer.emptyScreen.folder.empty.alt", {
11
+ ns: e
14
12
  }), text: t("explorer.emptyScreen.label", {
15
- ns: appCode
13
+ ns: e
16
14
  }) });
17
15
  }
18
16
  export {
19
- EmptyScreenNoContentInFolder as default
17
+ i as default
20
18
  };
@@ -1,20 +1,18 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useOdeClient, usePaths, EmptyScreen } from "@edifice-ui/react";
3
- import { useTranslation } from "react-i18next";
4
- function EmptyScreenSearch() {
5
- const {
6
- appCode
7
- } = useOdeClient();
8
- const [imagePath] = usePaths();
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useOdeClient as n, usePaths as a, EmptyScreen as o } from "@edifice-ui/react";
3
+ import { useTranslation as c } from "react-i18next";
4
+ function l() {
9
5
  const {
6
+ appCode: e
7
+ } = n(), [r] = a(), {
10
8
  t
11
- } = useTranslation();
12
- return /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: `${imagePath}/emptyscreen/illu-search.svg`, imageAlt: t("explorer.emptyScreen.search.alt", {
13
- ns: appCode
9
+ } = c();
10
+ return /* @__PURE__ */ s(o, { imageSrc: `${r}/emptyscreen/illu-search.svg`, imageAlt: t("explorer.emptyScreen.search.alt", {
11
+ ns: e
14
12
  }), text: t("explorer.emptyScreen.search.text", {
15
- ns: appCode
13
+ ns: e
16
14
  }) });
17
15
  }
18
16
  export {
19
- EmptyScreenSearch as default
17
+ l as default
20
18
  };
@@ -1,18 +1,16 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useOdeClient, usePaths, EmptyScreen } from "@edifice-ui/react";
3
- import { useTranslation } from "react-i18next";
4
- function EmptyScreenTrash() {
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useOdeClient as a, usePaths as m, EmptyScreen as n } from "@edifice-ui/react";
3
+ import { useTranslation as o } from "react-i18next";
4
+ function c() {
5
5
  const {
6
- appCode
7
- } = useOdeClient();
8
- const [imagePath] = usePaths();
9
- const {
10
- t
11
- } = useTranslation();
12
- return /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: `${imagePath}/emptyscreen/illu-trash.svg`, imageAlt: t("explorer.emptyScreen.trash.alt"), title: t("explorer.emptyScreen.trash.title"), text: t("explorer.emptyScreen.trash.empty", {
13
- ns: appCode
6
+ appCode: t
7
+ } = a(), [r] = m(), {
8
+ t: e
9
+ } = o();
10
+ return /* @__PURE__ */ s(n, { imageSrc: `${r}/emptyscreen/illu-trash.svg`, imageAlt: e("explorer.emptyScreen.trash.alt"), title: e("explorer.emptyScreen.trash.title"), text: e("explorer.emptyScreen.trash.empty", {
11
+ ns: t
14
12
  }) });
15
13
  }
16
14
  export {
17
- EmptyScreenTrash as default
15
+ c as default
18
16
  };
@@ -1,138 +1,119 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useId, useEffect } from "react";
3
- import { Modal, FormControl, Label, Input, Button } from "@edifice-ui/react";
4
- import { createPortal } from "react-dom";
5
- import { useTranslation } from "react-i18next";
6
- import { FOLDER } from "edifice-ts-client";
7
- import { useForm } from "react-hook-form";
8
- import { h as useSelectedFolders, b as useCurrentFolder, o as useCreateFolder, p as useUpdatefolder } from "./index2.js";
1
+ import { jsxs as b, jsx as a } from "react/jsx-runtime";
2
+ import { useId as B, useEffect as L } from "react";
3
+ import { Modal as m, FormControl as j, Label as w, Input as R, Button as I } from "@edifice-ui/react";
4
+ import { createPortal as T } from "react-dom";
5
+ import { useTranslation as U } from "react-i18next";
6
+ import { FOLDER as V } from "edifice-ts-client";
7
+ import { useForm as _ } from "react-hook-form";
8
+ import { h as k, b as z, o as A, p as H } from "./index2.js";
9
9
  import "@edifice-ui/icons";
10
10
  import "i18next";
11
11
  import "zustand";
12
12
  import "@tanstack/react-query";
13
- function useFolderModal({
14
- edit,
15
- onSuccess,
16
- onClose
13
+ function P({
14
+ edit: o,
15
+ onSuccess: e,
16
+ onClose: s
17
17
  }) {
18
- var _a;
19
- const selectedFolders = useSelectedFolders();
20
- const currentFolder = useCurrentFolder();
21
- const createFolder = useCreateFolder();
22
- const updatefolder = useUpdatefolder();
23
- const name = edit ? (_a = selectedFolders[0]) == null ? void 0 : _a.name : void 0;
24
- const {
25
- reset,
26
- register,
27
- handleSubmit,
28
- setFocus,
18
+ var x;
19
+ const l = k(), r = z(), c = A(), f = H(), u = o ? (x = l[0]) == null ? void 0 : x.name : void 0, {
20
+ reset: t,
21
+ register: p,
22
+ handleSubmit: n,
23
+ setFocus: h,
29
24
  formState: {
30
- errors,
31
- isSubmitting,
32
- isDirty,
33
- isValid
25
+ errors: F,
26
+ isSubmitting: d,
27
+ isDirty: g,
28
+ isValid: v
34
29
  }
35
- } = useForm({
30
+ } = _({
36
31
  mode: "onChange",
37
32
  values: {
38
- name: name || ""
33
+ name: u || ""
39
34
  }
40
- });
41
- const id = useId();
42
- const onSubmit = async function({
43
- name: name2
35
+ }), M = B(), D = async function({
36
+ name: y
44
37
  }) {
45
- var _a2;
38
+ var C;
46
39
  try {
47
- if (edit) {
48
- const parentId = (_a2 = selectedFolders[0]) == null ? void 0 : _a2.parentId;
49
- const folder = selectedFolders[0];
50
- const folderId = folder.id;
51
- await updatefolder.mutate({
52
- folderId,
53
- parentId,
54
- name: name2
55
- });
56
- reset();
57
- onSuccess == null ? void 0 : onSuccess();
40
+ if (o) {
41
+ const i = (C = l[0]) == null ? void 0 : C.parentId, q = l[0].id;
42
+ await f.mutate({
43
+ folderId: q,
44
+ parentId: i,
45
+ name: y
46
+ }), t(), e == null || e();
58
47
  } else {
59
- const parentId = (currentFolder == null ? void 0 : currentFolder.id) || FOLDER.DEFAULT;
60
- await createFolder.mutate({
61
- name: name2,
62
- parentId
63
- });
64
- reset();
65
- onSuccess == null ? void 0 : onSuccess();
48
+ const i = (r == null ? void 0 : r.id) || V.DEFAULT;
49
+ await c.mutate({
50
+ name: y,
51
+ parentId: i
52
+ }), t(), e == null || e();
66
53
  }
67
- } catch (e) {
68
- console.error(e);
54
+ } catch (i) {
55
+ console.error(i);
69
56
  }
70
57
  };
71
- function onCancel() {
72
- reset();
73
- onClose();
58
+ function E() {
59
+ t(), s();
74
60
  }
75
- const formId = `createModal_${id}`;
76
61
  return {
77
- formId,
78
- errors,
79
- isSubmitting,
80
- isDirty,
81
- isValid,
82
- register,
83
- setFocus,
84
- handleSubmit,
85
- onCancel,
86
- onSubmit
62
+ formId: `createModal_${M}`,
63
+ errors: F,
64
+ isSubmitting: d,
65
+ isDirty: g,
66
+ isValid: v,
67
+ register: p,
68
+ setFocus: h,
69
+ handleSubmit: n,
70
+ onCancel: E,
71
+ onSubmit: D
87
72
  };
88
73
  }
89
- function FolderModal({
90
- isOpen,
91
- edit,
92
- onSuccess,
93
- onCancel: onClose
74
+ function oe({
75
+ isOpen: o,
76
+ edit: e,
77
+ onSuccess: s,
78
+ onCancel: l
94
79
  }) {
95
80
  const {
96
- t
97
- } = useTranslation();
98
- const {
99
- isDirty,
100
- isValid,
101
- isSubmitting,
102
- formId,
103
- onSubmit,
104
- onCancel,
105
- handleSubmit,
106
- register,
107
- setFocus
108
- } = useFolderModal({
109
- edit,
110
- onSuccess,
111
- onClose
81
+ t: r
82
+ } = U(), {
83
+ isDirty: c,
84
+ isValid: f,
85
+ isSubmitting: u,
86
+ formId: t,
87
+ onSubmit: p,
88
+ onCancel: n,
89
+ handleSubmit: h,
90
+ register: F,
91
+ setFocus: d
92
+ } = P({
93
+ edit: e,
94
+ onSuccess: s,
95
+ onClose: l
112
96
  });
113
- useEffect(() => {
114
- if (isOpen) {
115
- setFocus("name");
116
- }
117
- }, [isOpen, setFocus]);
118
- return isOpen ? /* @__PURE__ */ createPortal(/* @__PURE__ */ jsxs(Modal, { isOpen, onModalClose: onCancel, id: "modal_" + formId, children: [
119
- /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t(edit ? "explorer.rename.folder" : "explorer.create.folder") }),
120
- /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx("form", { id: formId, onSubmit: handleSubmit(onSubmit), children: /* @__PURE__ */ jsxs(FormControl, { id: "nameFolder", isRequired: true, children: [
121
- /* @__PURE__ */ jsx(Label, { children: t("explorer.create.folder.name") }),
122
- /* @__PURE__ */ jsx(Input, { type: "text", ...register("name", {
123
- required: true,
97
+ return L(() => {
98
+ o && d("name");
99
+ }, [o, d]), o ? /* @__PURE__ */ T(/* @__PURE__ */ b(m, { isOpen: o, onModalClose: n, id: "modal_" + t, children: [
100
+ /* @__PURE__ */ a(m.Header, { onModalClose: n, children: r(e ? "explorer.rename.folder" : "explorer.create.folder") }),
101
+ /* @__PURE__ */ a(m.Body, { children: /* @__PURE__ */ a("form", { id: t, onSubmit: h(p), children: /* @__PURE__ */ b(j, { id: "nameFolder", isRequired: !0, children: [
102
+ /* @__PURE__ */ a(w, { children: r("explorer.create.folder.name") }),
103
+ /* @__PURE__ */ a(R, { type: "text", ...F("name", {
104
+ required: !0,
124
105
  pattern: {
125
106
  value: /[^ ]/,
126
107
  message: "invalid title"
127
108
  }
128
- }), placeholder: t("explorer.create.folder.name"), size: "md", "aria-required": true })
109
+ }), placeholder: r("explorer.create.folder.name"), size: "md", "aria-required": !0 })
129
110
  ] }) }) }),
130
- /* @__PURE__ */ jsxs(Modal.Footer, { children: [
131
- /* @__PURE__ */ jsx(Button, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("explorer.cancel") }),
132
- /* @__PURE__ */ jsx(Button, { form: formId, type: "submit", color: "primary", variant: "filled", disabled: !isDirty || !isValid || isSubmitting, children: t(edit ? "explorer.rename" : "explorer.create") })
111
+ /* @__PURE__ */ b(m.Footer, { children: [
112
+ /* @__PURE__ */ a(I, { color: "tertiary", onClick: n, type: "button", variant: "ghost", children: r("explorer.cancel") }),
113
+ /* @__PURE__ */ a(I, { form: t, type: "submit", color: "primary", variant: "filled", disabled: !c || !f || u, children: r(e ? "explorer.rename" : "explorer.create") })
133
114
  ] })
134
115
  ] }), document.getElementById("portal")) : null;
135
116
  }
136
117
  export {
137
- FolderModal as default
118
+ oe as default
138
119
  };