@edifice.io/react 2.6.5-develop-b2school.20260914145143 → 2.6.5-develop.20260915174032
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/dist/components/Form/FormText.js +6 -11
- package/dist/components/Input/Input.d.ts +2 -11
- package/dist/components/Input/Input.js +21 -38
- package/dist/components/Label/Label.js +4 -4
- package/dist/components/Table/components/Table.d.ts +2 -2
- package/dist/components/Table/components/TableTd.d.ts +1 -1
- package/dist/components/Table/components/TableTh.d.ts +1 -1
- package/dist/components/index.d.ts +0 -2
- package/dist/homepage.js +1 -12
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +1 -1
- package/dist/hooks/useClickOutside/useClickOutside.js +2 -3
- package/dist/hooks/useUploadFiles/index.d.ts +1 -0
- package/dist/hooks/useUploadFiles/useUploadFiles.d.ts +11 -1
- package/dist/hooks/useUploadFiles/useUploadFiles.js +12 -7
- package/dist/index.js +160 -166
- package/dist/modules/homepage/components/Header/Header.js +4 -11
- package/dist/modules/homepage/components/UserSpace/hooks/useProfileLinks.js +8 -18
- package/dist/modules/homepage/components/index.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +34 -7
- package/dist/modules/multimedia/UploadFiles/UploadFiles.d.ts +2 -1
- package/package.json +6 -6
- package/dist/components/LinkPill/LinkPill.d.ts +0 -45
- package/dist/components/LinkPill/LinkPill.js +0 -27
- package/dist/components/LinkPill/index.d.ts +0 -2
- package/dist/components/ModalBeta/ModalBeta.d.ts +0 -47
- package/dist/components/ModalBeta/ModalBeta.js +0 -62
- package/dist/components/ModalBeta/ModalBetaBody.d.ts +0 -19
- package/dist/components/ModalBeta/ModalBetaBody.js +0 -15
- package/dist/components/ModalBeta/ModalBetaContext.d.ts +0 -7
- package/dist/components/ModalBeta/ModalBetaContext.js +0 -15
- package/dist/components/ModalBeta/ModalBetaFooter.d.ts +0 -13
- package/dist/components/ModalBeta/ModalBetaFooter.js +0 -7
- package/dist/components/ModalBeta/ModalBetaHeader.d.ts +0 -23
- package/dist/components/ModalBeta/ModalBetaHeader.js +0 -31
- package/dist/components/ModalBeta/index.d.ts +0 -2
- package/dist/hooks/useUserPreferences/index.d.ts +0 -1
- package/dist/hooks/useUserPreferences/useUserPreferences.d.ts +0 -9
- package/dist/hooks/useUserPreferences/useUserPreferences.js +0 -39
- package/dist/modules/homepage/components/UsefulLinks/LinkForm.d.ts +0 -13
- package/dist/modules/homepage/components/UsefulLinks/LinkForm.js +0 -67
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinks.d.ts +0 -6
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinks.js +0 -29
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksContainer.d.ts +0 -1
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksContainer.js +0 -40
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksModal.d.ts +0 -11
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksModal.js +0 -65
- package/dist/modules/homepage/components/UsefulLinks/hooks/useUsefulLinksContainer.d.ts +0 -19
- package/dist/modules/homepage/components/UsefulLinks/hooks/useUsefulLinksContainer.js +0 -26
- package/dist/modules/homepage/components/UsefulLinks/index.d.ts +0 -5
- package/dist/modules/homepage/components/UsefulLinks/services/api/index.d.ts +0 -6
- package/dist/modules/homepage/components/UsefulLinks/services/api/index.js +0 -5
- package/dist/modules/homepage/components/UsefulLinks/services/api/usefulLinksService.d.ts +0 -31
- package/dist/modules/homepage/components/UsefulLinks/services/api/usefulLinksService.js +0 -50
- package/dist/modules/homepage/components/UsefulLinks/services/queries/usefulLinks.d.ts +0 -20
- package/dist/modules/homepage/components/UsefulLinks/services/queries/usefulLinks.js +0 -65
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
-
import SvgIconError from "../../modules/icons/components/IconError.js";
|
|
4
|
-
import SvgIconSuccessOutline from "../../modules/icons/components/IconSuccessOutline.js";
|
|
5
3
|
import { useFormControl } from "./FormContext.js";
|
|
6
4
|
const FormText = ({
|
|
7
5
|
children
|
|
8
6
|
}) => {
|
|
9
7
|
const {
|
|
10
8
|
status
|
|
11
|
-
} = useFormControl(), classes = clsx("
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
Icon && /* @__PURE__ */ jsx(Icon, { className: "input-message__icon", "aria-hidden": "true" }),
|
|
17
|
-
children
|
|
18
|
-
] });
|
|
9
|
+
} = useFormControl(), classes = clsx("form-text", {
|
|
10
|
+
"is-invalid": status === "invalid",
|
|
11
|
+
valid: status === "valid"
|
|
12
|
+
});
|
|
13
|
+
return /* @__PURE__ */ jsx("p", { className: classes, children: /* @__PURE__ */ jsx("em", { children }) });
|
|
19
14
|
};
|
|
20
15
|
export {
|
|
21
16
|
FormText as default
|
|
@@ -2,8 +2,7 @@ import { Size } from '../../types';
|
|
|
2
2
|
export type OmitInputProps = 'disabled' | 'required' | 'size' | 'id' | 'readOnly';
|
|
3
3
|
export interface InputProps extends Omit<React.ComponentPropsWithRef<'input'>, OmitInputProps> {
|
|
4
4
|
/**
|
|
5
|
-
* Control size of input
|
|
6
|
-
* ("Medium" in the design system); only `lg` ("Big") differs.
|
|
5
|
+
* Control size of input
|
|
7
6
|
*/
|
|
8
7
|
size: Size;
|
|
9
8
|
/**
|
|
@@ -19,8 +18,7 @@ export interface InputProps extends Omit<React.ComponentPropsWithRef<'input'>, O
|
|
|
19
18
|
*/
|
|
20
19
|
disabled?: boolean;
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
* this prop has no effect and will be removed in a future major version.
|
|
21
|
+
* Remove validation icon
|
|
24
22
|
*/
|
|
25
23
|
noValidationIcon?: boolean;
|
|
26
24
|
/**
|
|
@@ -35,13 +33,6 @@ export interface InputProps extends Omit<React.ComponentPropsWithRef<'input'>, O
|
|
|
35
33
|
* Browser autocomplete feature
|
|
36
34
|
*/
|
|
37
35
|
autoComplete?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Show a built-in clear (×) button while the field is focused. Opt-in:
|
|
40
|
-
* several consumers render their own clear affordance already (e.g.
|
|
41
|
-
* `SearchBar`), and a broad audit of every `Input` usage hasn't been done
|
|
42
|
-
* yet — see INPUT-MIGRATION-PLAN.md §07.
|
|
43
|
-
*/
|
|
44
|
-
clearable?: boolean;
|
|
45
36
|
}
|
|
46
37
|
/**
|
|
47
38
|
* Input Form Component
|
|
@@ -1,57 +1,40 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef,
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
import SvgIconClose from "../../modules/icons/components/IconClose.js";
|
|
6
4
|
import { useFormControl } from "../Form/FormContext.js";
|
|
5
|
+
import Textcounter from "../TextCounter/TextCounter.js";
|
|
7
6
|
const Input = /* @__PURE__ */ forwardRef(({
|
|
7
|
+
noValidationIcon,
|
|
8
8
|
placeholder,
|
|
9
9
|
size = "md",
|
|
10
10
|
type = "text",
|
|
11
11
|
className,
|
|
12
12
|
showCounter = !1,
|
|
13
13
|
autoComplete = "off",
|
|
14
|
-
clearable = !1,
|
|
15
|
-
noValidationIcon: _noValidationIcon,
|
|
16
14
|
...restProps
|
|
17
|
-
},
|
|
15
|
+
}, ref) => {
|
|
18
16
|
var _a;
|
|
19
17
|
const {
|
|
20
18
|
id,
|
|
21
19
|
isRequired,
|
|
22
20
|
isReadOnly,
|
|
23
21
|
status
|
|
24
|
-
} = useFormControl(), {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
}, className)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const nativeSetter = (_a2 = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")) == null ? void 0 : _a2.set;
|
|
41
|
-
nativeSetter == null || nativeSetter.call(node, ""), node.dispatchEvent(new Event("input", {
|
|
42
|
-
bubbles: !0
|
|
43
|
-
})), node.focus();
|
|
44
|
-
}, maxLength = restProps.maxLength ?? 0;
|
|
45
|
-
return /* @__PURE__ */ jsxs("div", { className: wrapperClasses, children: [
|
|
46
|
-
/* @__PURE__ */ jsx("input", { ref: setRefs, id, className: "input__field", type, placeholder, required: isRequired, readOnly: isReadOnly, ...restProps, onChange: handleChange, autoComplete }),
|
|
47
|
-
clearable && !isReadOnly && /* @__PURE__ */ jsx("button", { type: "button", className: "input__clear", onClick: handleClear, "aria-label": t("clear"), children: /* @__PURE__ */ jsx(SvgIconClose, {}) }),
|
|
48
|
-
showCounter && /* @__PURE__ */ jsxs("span", { className: clsx("input__counter", {
|
|
49
|
-
"input__counter--max": currentLength === maxLength
|
|
50
|
-
}), children: [
|
|
51
|
-
currentLength,
|
|
52
|
-
" / ",
|
|
53
|
-
maxLength
|
|
54
|
-
] })
|
|
22
|
+
} = useFormControl(), [currentLength, setCurrentLength] = useState(((_a = restProps.defaultValue) == null ? void 0 : _a.toString().length) || 0), classes = clsx({
|
|
23
|
+
"form-control": !isReadOnly,
|
|
24
|
+
"form-control-lg": size === "lg",
|
|
25
|
+
"form-control-sm": size === "sm",
|
|
26
|
+
"is-invalid": status === "invalid",
|
|
27
|
+
"is-valid": status === "valid",
|
|
28
|
+
"form-control-plaintext": isReadOnly,
|
|
29
|
+
"no-validation-icon": noValidationIcon,
|
|
30
|
+
"pe-64": showCounter && !status
|
|
31
|
+
}, className);
|
|
32
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
|
+
/* @__PURE__ */ jsx("input", { ref, id, className: classes, type, placeholder, required: isRequired, readOnly: isReadOnly, ...restProps, onChange: (e) => {
|
|
34
|
+
var _a2;
|
|
35
|
+
setCurrentLength(e.target.value.length), (_a2 = restProps.onChange) == null || _a2.call(restProps, e);
|
|
36
|
+
}, autoComplete }),
|
|
37
|
+
showCounter && !status && /* @__PURE__ */ jsx(Textcounter, { currentLength, maxLength: restProps.maxLength ?? 0 })
|
|
55
38
|
] });
|
|
56
39
|
});
|
|
57
40
|
export {
|
|
@@ -16,8 +16,8 @@ const Label = /* @__PURE__ */ forwardRef(({
|
|
|
16
16
|
isRequired
|
|
17
17
|
} = useFormControl(), {
|
|
18
18
|
t
|
|
19
|
-
} = useTranslation(), classes = clsx("
|
|
20
|
-
"
|
|
19
|
+
} = useTranslation(), classes = clsx("form-label", {
|
|
20
|
+
"has-icon": leftIcon
|
|
21
21
|
}, className), optionalState = isOptional && !isRequired, requiredState = isRequired && !isOptional;
|
|
22
22
|
return useEffect(() => {
|
|
23
23
|
if (isOptional && isRequired)
|
|
@@ -25,11 +25,11 @@ const Label = /* @__PURE__ */ forwardRef(({
|
|
|
25
25
|
}, [isOptional, isRequired]), /* @__PURE__ */ jsxs("label", { ref, htmlFor: id, className: classes, children: [
|
|
26
26
|
leftIcon,
|
|
27
27
|
children,
|
|
28
|
-
optionalState && /* @__PURE__ */ jsxs("em", { className: "
|
|
28
|
+
optionalState && /* @__PURE__ */ jsxs("em", { className: "optional", children: [
|
|
29
29
|
"- ",
|
|
30
30
|
optionalText ?? t("explorer.optional")
|
|
31
31
|
] }),
|
|
32
|
-
requiredState && /* @__PURE__ */ jsx("em", { className: "
|
|
32
|
+
requiredState && /* @__PURE__ */ jsx("em", { className: "required", children: requiredText })
|
|
33
33
|
] });
|
|
34
34
|
});
|
|
35
35
|
export {
|
|
@@ -13,7 +13,7 @@ declare const Table: import('react').ForwardRefExoticComponent<{
|
|
|
13
13
|
displayName: string;
|
|
14
14
|
};
|
|
15
15
|
Th: {
|
|
16
|
-
(props: React.
|
|
16
|
+
(props: React.HTMLAttributes<HTMLTableCellElement>): import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
displayName: string;
|
|
18
18
|
};
|
|
19
19
|
Tbody: {
|
|
@@ -25,7 +25,7 @@ declare const Table: import('react').ForwardRefExoticComponent<{
|
|
|
25
25
|
displayName: string;
|
|
26
26
|
};
|
|
27
27
|
Td: {
|
|
28
|
-
(props: React.
|
|
28
|
+
(props: React.HTMLAttributes<HTMLTableCellElement>): import("react/jsx-runtime").JSX.Element;
|
|
29
29
|
displayName: string;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
@@ -28,7 +28,6 @@ export * from './Image';
|
|
|
28
28
|
export * from './Input';
|
|
29
29
|
export * from './Label';
|
|
30
30
|
export * from './Layout';
|
|
31
|
-
export * from './LinkPill';
|
|
32
31
|
export * from './List';
|
|
33
32
|
export * from './Loading';
|
|
34
33
|
export * from './LoadingScreen';
|
|
@@ -37,7 +36,6 @@ export * from './LogoBeta';
|
|
|
37
36
|
export * from './MediaViewer';
|
|
38
37
|
export * from './Menu';
|
|
39
38
|
export * from './Modal';
|
|
40
|
-
export * from './ModalBeta';
|
|
41
39
|
export * from './PageLayout';
|
|
42
40
|
export * from './Pagination';
|
|
43
41
|
export * from './Popover';
|
package/dist/homepage.js
CHANGED
|
@@ -12,13 +12,8 @@ import { Favorites } from "./modules/homepage/components/Favorites/Favorites.js"
|
|
|
12
12
|
import { FavoritesContainer } from "./modules/homepage/components/Favorites/FavoritesContainer.js";
|
|
13
13
|
import { LastInfosContainer } from "./modules/homepage/components/LastInfos/LastInfosContainer.js";
|
|
14
14
|
import { LastInfosList } from "./modules/homepage/components/LastInfos/LastInfosList.js";
|
|
15
|
-
import { LinkForm } from "./modules/homepage/components/UsefulLinks/LinkForm.js";
|
|
16
|
-
import { MAX_USEFUL_LINKS, useUsefulLinksContainer } from "./modules/homepage/components/UsefulLinks/hooks/useUsefulLinksContainer.js";
|
|
17
15
|
import { MessageFlashListContainer } from "./modules/homepage/components/MessageFlashList/MessageFlashListContainer.js";
|
|
18
16
|
import { SchoolSpaceContainer } from "./modules/homepage/components/SchoolSpace/SchoolSpaceContainer.js";
|
|
19
|
-
import { UsefulLinks } from "./modules/homepage/components/UsefulLinks/UsefulLinks.js";
|
|
20
|
-
import { UsefulLinksContainer } from "./modules/homepage/components/UsefulLinks/UsefulLinksContainer.js";
|
|
21
|
-
import { UsefulLinksModal } from "./modules/homepage/components/UsefulLinks/UsefulLinksModal.js";
|
|
22
17
|
import { UserSpaceContainer } from "./modules/homepage/components/UserSpace/UserSpaceContainer.js";
|
|
23
18
|
export {
|
|
24
19
|
Favorites,
|
|
@@ -28,8 +23,6 @@ export {
|
|
|
28
23
|
default4 as LastInfos,
|
|
29
24
|
LastInfosContainer,
|
|
30
25
|
LastInfosList,
|
|
31
|
-
LinkForm,
|
|
32
|
-
MAX_USEFUL_LINKS,
|
|
33
26
|
default5 as MessageFlash,
|
|
34
27
|
default6 as MessageFlashList,
|
|
35
28
|
MessageFlashListContainer,
|
|
@@ -38,10 +31,6 @@ export {
|
|
|
38
31
|
NotificationListContainer,
|
|
39
32
|
default9 as SchoolSpace,
|
|
40
33
|
SchoolSpaceContainer,
|
|
41
|
-
UsefulLinks,
|
|
42
|
-
UsefulLinksContainer,
|
|
43
|
-
UsefulLinksModal,
|
|
44
34
|
default10 as UserSpace,
|
|
45
|
-
UserSpaceContainer
|
|
46
|
-
useUsefulLinksContainer
|
|
35
|
+
UserSpaceContainer
|
|
47
36
|
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export * from './useUiOverride';
|
|
|
34
34
|
export * from './useUpload';
|
|
35
35
|
export * from './useUploadFiles';
|
|
36
36
|
export * from './useUser';
|
|
37
|
-
export * from './useUserPreferences';
|
|
38
37
|
export * from './useWorkspaceFile';
|
|
39
38
|
export * from './useWorkspaceFolders';
|
|
40
39
|
export * from './useWorkspaceSearch';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useClickOutside<T extends HTMLElement = any>(handler: () => void, events?: string[] | null, nodes?: Array<HTMLElement | null
|
|
1
|
+
export default function useClickOutside<T extends HTMLElement = any>(handler: () => void, events?: string[] | null, nodes?: Array<HTMLElement | null>): import('react').MutableRefObject<T | null>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useRef, useEffect } from "react";
|
|
2
2
|
const DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
3
|
-
function useClickOutside(handler, events, nodes
|
|
3
|
+
function useClickOutside(handler, events, nodes) {
|
|
4
4
|
const ref = useRef(null);
|
|
5
5
|
return useEffect(() => {
|
|
6
|
-
if (!enabled) return;
|
|
7
6
|
const listener = (event) => {
|
|
8
7
|
const {
|
|
9
8
|
target
|
|
@@ -20,7 +19,7 @@ function useClickOutside(handler, events, nodes, enabled = !0) {
|
|
|
20
19
|
document.removeEventListener(fn, listener);
|
|
21
20
|
});
|
|
22
21
|
};
|
|
23
|
-
}, [ref, handler, nodes, events
|
|
22
|
+
}, [ref, handler, nodes, events]), ref;
|
|
24
23
|
}
|
|
25
24
|
export {
|
|
26
25
|
useClickOutside as default
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { WorkspaceElement, WorkspaceVisibility } from '@edifice.io/client';
|
|
2
|
+
/**
|
|
3
|
+
* Snapshot of a source file taken at upload time, so the upload result can be
|
|
4
|
+
* re-ordered later on against the original file metadata.
|
|
5
|
+
*/
|
|
6
|
+
export interface UploadSourceFileInfo {
|
|
7
|
+
/** Original file name. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** `File.lastModified` of the source file (ms since epoch). */
|
|
10
|
+
lastModified: number;
|
|
11
|
+
}
|
|
2
12
|
declare const useUploadFiles: ({ handleOnChange, visibility, application, }: {
|
|
3
|
-
handleOnChange: (uploadedFiles: WorkspaceElement[]) => void;
|
|
13
|
+
handleOnChange: (uploadedFiles: WorkspaceElement[], sourceFilesInfo: Record<string, UploadSourceFileInfo>) => void;
|
|
4
14
|
visibility?: WorkspaceVisibility;
|
|
5
15
|
application?: string;
|
|
6
16
|
}) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from "react";
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from "react";
|
|
2
2
|
import { ImageResizer, addTimestampToImageUrl } from "@edifice.io/utilities";
|
|
3
3
|
import { useDropzoneContext } from "../../components/Dropzone/DropzoneContext.js";
|
|
4
4
|
import useWorkspaceFile from "../useWorkspaceFile/useWorkspaceFile.js";
|
|
@@ -8,7 +8,7 @@ const useUploadFiles = ({
|
|
|
8
8
|
visibility,
|
|
9
9
|
application
|
|
10
10
|
}) => {
|
|
11
|
-
const [uploadedFiles, setUploadedFiles] = useState([]), [editingImage, setEditingImage] = useState(void 0), {
|
|
11
|
+
const [uploadedFiles, setUploadedFiles] = useState([]), sourceFilesInfoRef = useRef({}), [editingImage, setEditingImage] = useState(void 0), {
|
|
12
12
|
files,
|
|
13
13
|
deleteFile,
|
|
14
14
|
replaceFileAt,
|
|
@@ -34,7 +34,10 @@ const useUploadFiles = ({
|
|
|
34
34
|
} catch (err) {
|
|
35
35
|
console.error(err);
|
|
36
36
|
}
|
|
37
|
-
!resource && !replacement && (resource = await uploadFile(file)), resource ?
|
|
37
|
+
!resource && !replacement && (resource = await uploadFile(file)), resource ? (resource._id && (sourceFilesInfoRef.current[resource._id] = {
|
|
38
|
+
name: file.name,
|
|
39
|
+
lastModified: file.lastModified
|
|
40
|
+
}), setUploadedFiles((prevFiles) => [...prevFiles, resource])) : resetInputValue();
|
|
38
41
|
});
|
|
39
42
|
}, [uploadAlternateFile, uploadFile, replaceFileAt]);
|
|
40
43
|
useEffect(() => {
|
|
@@ -47,15 +50,17 @@ const useUploadFiles = ({
|
|
|
47
50
|
newFiles.forEach((file) => file && setUploadStatus(file, "idle")), tryUploading(newFiles);
|
|
48
51
|
}, [files, uploadedFiles, getUploadStatus, setUploadStatus, tryUploading]), useEffect(() => {
|
|
49
52
|
const sortedUploadedFiles = sortUploadedFiles(files, uploadedFiles);
|
|
50
|
-
handleOnChange(sortedUploadedFiles
|
|
53
|
+
handleOnChange(sortedUploadedFiles, {
|
|
54
|
+
...sourceFilesInfoRef.current
|
|
55
|
+
});
|
|
51
56
|
}, [uploadedFiles]);
|
|
52
57
|
const sortUploadedFiles = (filesArray, uploadedFilesArray) => {
|
|
53
|
-
const orderMap = filesArray.reduce((acc, item, index) => (acc[item.name] = index, acc), {});
|
|
54
|
-
return uploadedFilesArray.sort((a, b) => orderMap[a.name] - orderMap[b.name]);
|
|
58
|
+
const orderMap = filesArray.reduce((acc, item, index) => (item.name in acc || (acc[item.name] = index), acc), {});
|
|
59
|
+
return [...uploadedFilesArray].sort((a, b) => (orderMap[a.name] ?? Number.MAX_SAFE_INTEGER) - (orderMap[b.name] ?? Number.MAX_SAFE_INTEGER));
|
|
55
60
|
};
|
|
56
61
|
async function removeFile(file) {
|
|
57
62
|
const resource = uploadedFiles.find((uploadedFile) => uploadedFile.name === file.name);
|
|
58
|
-
resource && (await remove(resource), clearUploadStatus(file), setUploadedFiles((prevFiles) => prevFiles.filter((prevFile) => prevFile.name !== (resource == null ? void 0 : resource.name)))), deleteFile(file), resetInputValue();
|
|
63
|
+
resource && (await remove(resource), clearUploadStatus(file), resource._id && delete sourceFilesInfoRef.current[resource._id], setUploadedFiles((prevFiles) => prevFiles.filter((prevFile) => prevFile.name !== (resource == null ? void 0 : resource.name)))), deleteFile(file), resetInputValue();
|
|
59
64
|
}
|
|
60
65
|
async function updateImage({
|
|
61
66
|
blob,
|