@payloadcms/ui 3.24.0-canary.f229d8d → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/Autosave/index.d.ts.map +1 -1
- package/dist/elements/Autosave/index.js +143 -108
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +22 -20
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/Button/index.d.ts.map +1 -1
- package/dist/elements/Button/index.js +1 -0
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/Button/index.scss +21 -5
- package/dist/elements/ConfirmationModal/index.d.ts +16 -0
- package/dist/elements/ConfirmationModal/index.d.ts.map +1 -0
- package/dist/elements/ConfirmationModal/index.js +158 -0
- package/dist/elements/ConfirmationModal/index.js.map +1 -0
- package/dist/elements/{GenerateConfirmation → ConfirmationModal}/index.scss +1 -1
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +2 -0
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/types.d.ts +1 -0
- package/dist/elements/DatePicker/types.d.ts.map +1 -1
- package/dist/elements/DatePicker/types.js.map +1 -1
- package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
- package/dist/elements/DeleteDocument/index.js +31 -79
- package/dist/elements/DeleteDocument/index.js.map +1 -1
- package/dist/elements/DeleteDocument/index.scss +0 -29
- package/dist/elements/DeleteMany/index.d.ts.map +1 -1
- package/dist/elements/DeleteMany/index.js +16 -43
- package/dist/elements/DeleteMany/index.js.map +1 -1
- package/dist/elements/DeleteMany/index.scss +0 -29
- package/dist/elements/DocumentControls/index.d.ts.map +1 -1
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DuplicateDocument/index.d.ts +0 -1
- package/dist/elements/DuplicateDocument/index.d.ts.map +1 -1
- package/dist/elements/DuplicateDocument/index.js +25 -54
- package/dist/elements/DuplicateDocument/index.js.map +1 -1
- package/dist/elements/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/EditMany/DrawerContent.js +3 -2
- package/dist/elements/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts +1 -0
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.js +19 -17
- package/dist/elements/FileDetails/DraggableFileDetails/index.js.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.d.ts +1 -0
- package/dist/elements/FileDetails/StaticFileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.js +2 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.js.map +1 -1
- package/dist/elements/FileDetails/index.d.ts +1 -0
- package/dist/elements/FileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/index.js.map +1 -1
- package/dist/elements/GenerateConfirmation/index.d.ts +1 -2
- package/dist/elements/GenerateConfirmation/index.d.ts.map +1 -1
- package/dist/elements/GenerateConfirmation/index.js +23 -47
- package/dist/elements/GenerateConfirmation/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.d.ts +0 -1
- package/dist/elements/LeaveWithoutSaving/index.d.ts.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +56 -113
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/elements/ListControls/index.d.ts +1 -0
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +14 -0
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListControls/index.scss +5 -0
- package/dist/elements/Localizer/LocalizerLabel/index.d.ts.map +1 -1
- package/dist/elements/Localizer/LocalizerLabel/index.js +11 -8
- package/dist/elements/Localizer/LocalizerLabel/index.js.map +1 -1
- package/dist/elements/Localizer/index.d.ts.map +1 -1
- package/dist/elements/Localizer/index.js +2 -0
- package/dist/elements/Localizer/index.js.map +1 -1
- package/dist/elements/Popup/index.d.ts +1 -0
- package/dist/elements/Popup/index.d.ts.map +1 -1
- package/dist/elements/Popup/index.js +2 -0
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PreviewButton/index.d.ts +2 -1
- package/dist/elements/PreviewButton/index.d.ts.map +1 -1
- package/dist/elements/PreviewButton/index.js +2 -2
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.d.ts +1 -2
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts +2 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +6 -2
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts +2 -3
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +20 -17
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/PublishMany/index.d.ts +0 -1
- package/dist/elements/PublishMany/index.d.ts.map +1 -1
- package/dist/elements/PublishMany/index.js +19 -45
- package/dist/elements/PublishMany/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts +7 -2
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +69 -23
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.scss +6 -0
- package/dist/elements/SaveButton/index.d.ts +2 -3
- package/dist/elements/SaveButton/index.d.ts.map +1 -1
- package/dist/elements/SaveButton/index.js +3 -3
- package/dist/elements/SaveButton/index.js.map +1 -1
- package/dist/elements/SaveDraftButton/index.d.ts +2 -1
- package/dist/elements/SaveDraftButton/index.d.ts.map +1 -1
- package/dist/elements/SaveDraftButton/index.js +2 -2
- package/dist/elements/SaveDraftButton/index.js.map +1 -1
- package/dist/elements/Status/index.d.ts.map +1 -1
- package/dist/elements/Status/index.js +173 -154
- package/dist/elements/Status/index.js.map +1 -1
- package/dist/elements/Status/index.scss +0 -41
- package/dist/elements/StayLoggedIn/index.d.ts +0 -1
- package/dist/elements/StayLoggedIn/index.d.ts.map +1 -1
- package/dist/elements/StayLoggedIn/index.js +45 -77
- package/dist/elements/StayLoggedIn/index.js.map +1 -1
- package/dist/elements/Table/index.d.ts +1 -9
- package/dist/elements/Table/index.d.ts.map +1 -1
- package/dist/elements/Table/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts +1 -2
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/TableColumns/buildPolymorphicColumnState.d.ts +20 -0
- package/dist/elements/TableColumns/buildPolymorphicColumnState.d.ts.map +1 -0
- package/dist/elements/TableColumns/buildPolymorphicColumnState.js +200 -0
- package/dist/elements/TableColumns/buildPolymorphicColumnState.js.map +1 -0
- package/dist/elements/TableColumns/index.d.ts +2 -3
- package/dist/elements/TableColumns/index.d.ts.map +1 -1
- package/dist/elements/TableColumns/index.js +4 -3
- package/dist/elements/TableColumns/index.js.map +1 -1
- package/dist/elements/UnpublishMany/index.d.ts +1 -2
- package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/index.js +14 -42
- package/dist/elements/UnpublishMany/index.js.map +1 -1
- package/dist/elements/Upload/index.d.ts.map +1 -1
- package/dist/elements/Upload/index.js +5 -1
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/ViewDescription/index.d.ts +2 -5
- package/dist/elements/ViewDescription/index.d.ts.map +1 -1
- package/dist/elements/ViewDescription/index.js +2 -2
- package/dist/elements/ViewDescription/index.js.map +1 -1
- package/dist/exports/client/CodeEditor-L6GW2VQ6.js.map +0 -1
- package/dist/exports/client/{DatePicker-THCU4KZJ.js → DatePicker-HHQ6TPOW.js} +2 -2
- package/dist/exports/client/{DatePicker-THCU4KZJ.js.map → DatePicker-HHQ6TPOW.js.map} +0 -1
- package/dist/exports/client/chunk-5LKBKI4T.js.map +0 -1
- package/dist/exports/client/{chunk-EG3ZOHFS.js → chunk-IMEQ6NKQ.js} +2 -2
- package/dist/exports/client/{chunk-EG3ZOHFS.js.map → chunk-IMEQ6NKQ.js.map} +3 -4
- package/dist/exports/client/chunk-ZZDNSFEW.js.map +0 -1
- package/dist/exports/client/index.d.ts +46 -4
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +23 -23
- package/dist/exports/client/index.js.map +4 -5
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +24 -6
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +8 -3
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Select/Input.d.ts.map +1 -1
- package/dist/fields/Select/Input.js +2 -0
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Tabs/Tab/index.scss +2 -1
- package/dist/fields/Upload/Input.d.ts +1 -0
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +19 -8
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/initContextState.d.ts.map +1 -1
- package/dist/forms/Form/initContextState.js +2 -0
- package/dist/forms/Form/initContextState.js.map +1 -1
- package/dist/forms/Form/types.d.ts +6 -0
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/icons/Dots/index.d.ts +7 -0
- package/dist/icons/Dots/index.d.ts.map +1 -0
- package/dist/icons/Dots/index.js +12 -0
- package/dist/icons/Dots/index.js.map +1 -0
- package/dist/icons/Dots/index.scss +27 -0
- package/dist/providers/Selection/index.d.ts.map +1 -1
- package/dist/providers/Selection/index.js +5 -6
- package/dist/providers/Selection/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildTableState.d.ts +1 -2
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +72 -20
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/copyDataFromLocale.d.ts.map +1 -1
- package/dist/utilities/copyDataFromLocale.js +20 -14
- package/dist/utilities/copyDataFromLocale.js.map +1 -1
- package/dist/utilities/handleFormStateLocking.d.ts.map +1 -1
- package/dist/utilities/handleFormStateLocking.js +3 -6
- package/dist/utilities/handleFormStateLocking.js.map +1 -1
- package/dist/utilities/renderTable.d.ts +6 -4
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +49 -17
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/views/Edit/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Auth/index.js +56 -55
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/Edit/index.d.ts +2 -2
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +3 -3
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/List/index.d.ts +2 -25
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +6 -3
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/types.d.ts +1 -18
- package/dist/views/List/types.d.ts.map +1 -1
- package/dist/views/List/types.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/DuplicateDocument/index.scss +0 -42
- package/dist/elements/LeaveWithoutSaving/index.scss +0 -39
- package/dist/elements/PublishMany/index.scss +0 -39
- package/dist/elements/StayLoggedIn/index.scss +0 -40
- package/dist/elements/UnpublishMany/index.scss +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Autosave/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Autosave/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIzE,OAAO,KAAwD,MAAM,OAAO,CAAA;AAe5E,OAAO,cAAc,CAAA;AAUrB,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,CAAC,EAAE,sBAAsB,CAAA;IACnC,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAqTpC,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { dequal } from 'dequal/lite';
|
|
5
|
+
import { reduceFieldsToValues, versionDefaults } from 'payload/shared';
|
|
6
|
+
import React, { useDeferredValue, useEffect, useRef, useState } from 'react';
|
|
6
7
|
import { toast } from 'sonner';
|
|
7
8
|
import { useAllFormFields, useForm, useFormModified, useFormSubmitted } from '../../forms/Form/context.js';
|
|
8
9
|
import { useDebounce } from '../../hooks/useDebounce.js';
|
|
@@ -11,10 +12,11 @@ import { useConfig } from '../../providers/Config/index.js';
|
|
|
11
12
|
import { useDocumentEvents } from '../../providers/DocumentEvents/index.js';
|
|
12
13
|
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
|
|
13
14
|
import { useLocale } from '../../providers/Locale/index.js';
|
|
14
|
-
import { useTranslation } from '../../providers/Translation/index.js';
|
|
15
15
|
import './index.scss';
|
|
16
|
+
import { useTranslation } from '../../providers/Translation/index.js';
|
|
16
17
|
import { formatTimeToNow } from '../../utilities/formatDate.js';
|
|
17
18
|
import { reduceFieldsToValuesWithValidation } from '../../utilities/reduceFieldsToValuesWithValidation.js';
|
|
19
|
+
import { LeaveWithoutSaving } from '../LeaveWithoutSaving/index.js';
|
|
18
20
|
const baseClass = 'autosave';
|
|
19
21
|
// The minimum time the saving state should be shown
|
|
20
22
|
const minimumAnimationTime = 1000;
|
|
@@ -48,12 +50,13 @@ export const Autosave = ({
|
|
|
48
50
|
} = useDocumentEvents();
|
|
49
51
|
const {
|
|
50
52
|
dispatchFields,
|
|
53
|
+
isValid,
|
|
54
|
+
setIsValid,
|
|
51
55
|
setSubmitted
|
|
52
56
|
} = useForm();
|
|
53
|
-
const submitted = useFormSubmitted();
|
|
54
|
-
const versionsConfig = docConfig?.versions;
|
|
55
57
|
const [fields] = useAllFormFields();
|
|
56
58
|
const modified = useFormModified();
|
|
59
|
+
const submitted = useFormSubmitted();
|
|
57
60
|
const {
|
|
58
61
|
code: locale
|
|
59
62
|
} = useLocale();
|
|
@@ -61,17 +64,23 @@ export const Autosave = ({
|
|
|
61
64
|
i18n,
|
|
62
65
|
t
|
|
63
66
|
} = useTranslation();
|
|
67
|
+
const versionsConfig = docConfig?.versions;
|
|
64
68
|
let interval = versionDefaults.autosaveInterval;
|
|
65
69
|
if (versionsConfig.drafts && versionsConfig.drafts.autosave) {
|
|
66
70
|
interval = versionsConfig.drafts.autosave.interval;
|
|
67
71
|
}
|
|
68
|
-
const
|
|
72
|
+
const validateOnDraft = Boolean(docConfig?.versions?.drafts && docConfig?.versions?.drafts.validate);
|
|
73
|
+
const [_saving, setSaving] = useState(false);
|
|
74
|
+
const saving = useDeferredValue(_saving);
|
|
69
75
|
const debouncedFields = useDebounce(fields, interval);
|
|
70
76
|
const fieldRef = useRef(fields);
|
|
71
77
|
const modifiedRef = useRef(modified);
|
|
72
78
|
const localeRef = useRef(locale);
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Track the validation internally so Autosave can determine when to run queue processing again
|
|
81
|
+
* Helps us prevent infinite loops when the queue is processing and the form is invalid
|
|
82
|
+
*/
|
|
83
|
+
const isValidRef = useRef(isValid);
|
|
75
84
|
// Store fields in ref so the autosave func
|
|
76
85
|
// can always retrieve the most to date copies
|
|
77
86
|
// after the timeout has executed
|
|
@@ -87,6 +96,13 @@ export const Autosave = ({
|
|
|
87
96
|
if (isProcessingRef.current || queueRef.current.length === 0) {
|
|
88
97
|
return;
|
|
89
98
|
}
|
|
99
|
+
if (!isValidRef.current) {
|
|
100
|
+
// Clear queue so we don't end up in an infinite loop
|
|
101
|
+
queueRef.current = [];
|
|
102
|
+
// Reset internal validation state so queue processing can run again
|
|
103
|
+
isValidRef.current = true;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
90
106
|
isProcessingRef.current = true;
|
|
91
107
|
const latestAction = queueRef.current[queueRef.current.length - 1];
|
|
92
108
|
queueRef.current = [];
|
|
@@ -99,12 +115,22 @@ export const Autosave = ({
|
|
|
99
115
|
}
|
|
100
116
|
}
|
|
101
117
|
}, []);
|
|
118
|
+
const autosaveTimeoutRef = useRef(null);
|
|
102
119
|
const handleAutosave = useEffectEvent(() => {
|
|
103
|
-
|
|
104
|
-
let autosaveTimeout = undefined;
|
|
120
|
+
autosaveTimeoutRef.current = undefined;
|
|
105
121
|
// We need to log the time in order to figure out if we need to trigger the state off later
|
|
106
122
|
let startTimestamp = undefined;
|
|
107
123
|
let endTimestamp = undefined;
|
|
124
|
+
const hideIndicator = () => {
|
|
125
|
+
// If request was faster than minimum animation time, animate the difference
|
|
126
|
+
if (endTimestamp - startTimestamp < minimumAnimationTime) {
|
|
127
|
+
autosaveTimeoutRef.current = setTimeout(() => {
|
|
128
|
+
setSaving(false);
|
|
129
|
+
}, minimumAnimationTime - (endTimestamp - startTimestamp));
|
|
130
|
+
} else {
|
|
131
|
+
stopAutoSaveIndicator();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
108
134
|
const autosave = async () => {
|
|
109
135
|
if (modified) {
|
|
110
136
|
startTimestamp = new Date().getTime();
|
|
@@ -127,88 +153,86 @@ export const Autosave = ({
|
|
|
127
153
|
const {
|
|
128
154
|
data,
|
|
129
155
|
valid
|
|
130
|
-
} =
|
|
131
|
-
...reduceFieldsToValuesWithValidation(fieldRef.current, true)
|
|
132
|
-
};
|
|
156
|
+
} = reduceFieldsToValuesWithValidation(fieldRef.current, true);
|
|
133
157
|
data._status = 'draft';
|
|
134
158
|
const skipSubmission = submitted && !valid && versionsConfig?.drafts && versionsConfig?.drafts?.validate;
|
|
135
|
-
if (!skipSubmission) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
'
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
if (!skipSubmission && isValidRef.current) {
|
|
160
|
+
let res;
|
|
161
|
+
try {
|
|
162
|
+
res = await fetch(url, {
|
|
163
|
+
body: JSON.stringify(data),
|
|
164
|
+
credentials: 'include',
|
|
165
|
+
headers: {
|
|
166
|
+
'Accept-Language': i18n.language,
|
|
167
|
+
'Content-Type': 'application/json'
|
|
168
|
+
},
|
|
169
|
+
method
|
|
170
|
+
});
|
|
171
|
+
} catch (error) {
|
|
172
|
+
// Swallow Error
|
|
173
|
+
}
|
|
174
|
+
const newDate = new Date();
|
|
175
|
+
// We need to log the time in order to figure out if we need to trigger the state off later
|
|
176
|
+
endTimestamp = newDate.getTime();
|
|
177
|
+
if (res.status === 200) {
|
|
178
|
+
setLastUpdateTime(newDate.getTime());
|
|
179
|
+
reportUpdate({
|
|
180
|
+
id,
|
|
181
|
+
entitySlug,
|
|
182
|
+
updatedAt: newDate.toISOString()
|
|
183
|
+
});
|
|
184
|
+
if (!mostRecentVersionIsAutosaved) {
|
|
185
|
+
incrementVersionCount();
|
|
186
|
+
setMostRecentVersionIsAutosaved(true);
|
|
187
|
+
setUnpublishedVersionCount(prev => prev + 1);
|
|
161
188
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const document = json?.doc || json?.result;
|
|
197
|
-
// Manually update the data since this function doesn't fire the `submit` function from useForm
|
|
198
|
-
if (document) {
|
|
199
|
-
updateSavedDocumentData(document);
|
|
200
|
-
}
|
|
189
|
+
}
|
|
190
|
+
const json = await res.json();
|
|
191
|
+
if (versionsConfig?.drafts && versionsConfig?.drafts?.validate && json?.errors) {
|
|
192
|
+
if (Array.isArray(json.errors)) {
|
|
193
|
+
const [fieldErrors, nonFieldErrors] = json.errors.reduce(([fieldErrs, nonFieldErrs], err) => {
|
|
194
|
+
const newFieldErrs = [];
|
|
195
|
+
const newNonFieldErrs = [];
|
|
196
|
+
if (err?.message) {
|
|
197
|
+
newNonFieldErrs.push(err);
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(err?.data)) {
|
|
200
|
+
err.data.forEach(dataError => {
|
|
201
|
+
if (dataError?.field) {
|
|
202
|
+
newFieldErrs.push(dataError);
|
|
203
|
+
} else {
|
|
204
|
+
newNonFieldErrs.push(dataError);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return [[...fieldErrs, ...newFieldErrs], [...nonFieldErrs, ...newNonFieldErrs]];
|
|
209
|
+
}, [[], []]);
|
|
210
|
+
dispatchFields({
|
|
211
|
+
type: 'ADD_SERVER_ERRORS',
|
|
212
|
+
errors: fieldErrors
|
|
213
|
+
});
|
|
214
|
+
nonFieldErrors.forEach(err_0 => {
|
|
215
|
+
toast.error(err_0.message || i18n.t('error:unknown'));
|
|
216
|
+
});
|
|
217
|
+
// Set valid to false internally so the queue doesn't process
|
|
218
|
+
isValidRef.current = false;
|
|
219
|
+
setIsValid(false);
|
|
220
|
+
setSubmitted(true);
|
|
221
|
+
hideIndicator();
|
|
222
|
+
return;
|
|
201
223
|
}
|
|
202
|
-
}
|
|
203
|
-
// If
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
224
|
+
} else {
|
|
225
|
+
// If it's not an error then we can update the document data inside the context
|
|
226
|
+
const document = json?.doc || json?.result;
|
|
227
|
+
// Manually update the data since this function doesn't fire the `submit` function from useForm
|
|
228
|
+
if (document) {
|
|
229
|
+
setIsValid(true);
|
|
230
|
+
// Reset internal state allowing the queue to process
|
|
231
|
+
isValidRef.current = true;
|
|
232
|
+
updateSavedDocumentData(document);
|
|
210
233
|
}
|
|
211
|
-
}
|
|
234
|
+
}
|
|
235
|
+
hideIndicator();
|
|
212
236
|
}
|
|
213
237
|
}
|
|
214
238
|
}
|
|
@@ -216,34 +240,45 @@ export const Autosave = ({
|
|
|
216
240
|
};
|
|
217
241
|
queueRef.current.push(autosave);
|
|
218
242
|
void processQueue();
|
|
219
|
-
return {
|
|
220
|
-
abortController,
|
|
221
|
-
autosaveTimeout
|
|
222
|
-
};
|
|
223
243
|
});
|
|
244
|
+
const didMount = useRef(false);
|
|
245
|
+
const previousDebouncedFieldValues = useRef(reduceFieldsToValues(debouncedFields));
|
|
224
246
|
// When debounced fields change, autosave
|
|
225
247
|
useEffect(() => {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Ensure autosave doesn't run on mount
|
|
250
|
+
*/
|
|
251
|
+
if (!didMount.current) {
|
|
252
|
+
didMount.current = true;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Ensure autosave only runs if the form data changes, not every time the entire form state changes
|
|
257
|
+
*/
|
|
258
|
+
const debouncedFieldValues = reduceFieldsToValues(debouncedFields);
|
|
259
|
+
if (dequal(debouncedFieldValues, previousDebouncedFieldValues)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
previousDebouncedFieldValues.current = debouncedFieldValues;
|
|
263
|
+
handleAutosave();
|
|
264
|
+
}, [debouncedFields]);
|
|
265
|
+
/**
|
|
266
|
+
* If component unmounts, clear the autosave timeout
|
|
267
|
+
*/
|
|
268
|
+
useEffect(() => {
|
|
230
269
|
return () => {
|
|
231
|
-
|
|
232
|
-
clearTimeout(autosaveTimeout_0);
|
|
233
|
-
}
|
|
234
|
-
if (abortController_0.signal) {
|
|
235
|
-
try {
|
|
236
|
-
abortController_0.abort('Autosave closed early.');
|
|
237
|
-
} catch (error) {
|
|
238
|
-
// swallow error
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
setSaving(false);
|
|
270
|
+
stopAutoSaveIndicator();
|
|
242
271
|
};
|
|
243
|
-
}, [
|
|
272
|
+
}, []);
|
|
273
|
+
const stopAutoSaveIndicator = useEffectEvent(() => {
|
|
274
|
+
if (autosaveTimeoutRef.current) {
|
|
275
|
+
clearTimeout(autosaveTimeoutRef.current);
|
|
276
|
+
}
|
|
277
|
+
setSaving(false);
|
|
278
|
+
});
|
|
244
279
|
return /*#__PURE__*/_jsxs("div", {
|
|
245
280
|
className: baseClass,
|
|
246
|
-
children: [saving && t('general:saving'), !saving && Boolean(lastUpdateTime) && /*#__PURE__*/_jsx(React.Fragment, {
|
|
281
|
+
children: [validateOnDraft && !isValid && /*#__PURE__*/_jsx(LeaveWithoutSaving, {}), saving && t('general:saving'), !saving && Boolean(lastUpdateTime) && /*#__PURE__*/_jsx(React.Fragment, {
|
|
247
282
|
children: t('version:lastSavedAgo', {
|
|
248
283
|
distance: formatTimeToNow({
|
|
249
284
|
date: lastUpdateTime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["versionDefaults","React","useEffect","useRef","useState","toast","useAllFormFields","useForm","useFormModified","useFormSubmitted","useDebounce","useEffectEvent","useConfig","useDocumentEvents","useDocumentInfo","useLocale","useTranslation","formatTimeToNow","reduceFieldsToValuesWithValidation","baseClass","minimumAnimationTime","Autosave","id","collection","global","globalDoc","config","routes","api","serverURL","docConfig","incrementVersionCount","lastUpdateTime","mostRecentVersionIsAutosaved","setLastUpdateTime","setMostRecentVersionIsAutosaved","setUnpublishedVersionCount","updateSavedDocumentData","queueRef","isProcessingRef","reportUpdate","dispatchFields","setSubmitted","submitted","versionsConfig","versions","fields","modified","code","locale","i18n","t","interval","autosaveInterval","drafts","autosave","saving","setSaving","debouncedFields","fieldRef","modifiedRef","localeRef","debouncedRef","current","processQueue","useCallback","length","latestAction","handleAutosave","abortController","AbortController","autosaveTimeout","undefined","startTimestamp","endTimestamp","Date","getTime","url","method","entitySlug","slug","data","valid","_status","skipSubmission","validate","fetch","body","JSON","stringify","credentials","headers","language","signal","then","res","newDate","status","updatedAt","toISOString","prev","json","errors","Array","isArray","fieldErrors","nonFieldErrors","reduce","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","message","push","forEach","dataError","field","type","error","document","doc","result","setTimeout","clearTimeout","abort","_jsxs","className","Boolean","_jsx","Fragment","distance","date"],"sources":["../../../src/elements/Autosave/index.tsx"],"sourcesContent":["'use client'\n// TODO: abstract the `next/navigation` dependency out from this component\nimport type { ClientCollectionConfig, ClientGlobalConfig } from 'payload'\n\nimport { versionDefaults } from 'payload/shared'\nimport React, { useEffect, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport {\n useAllFormFields,\n useForm,\n useFormModified,\n useFormSubmitted,\n} from '../../forms/Form/context.js'\nimport { useDebounce } from '../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentEvents } from '../../providers/DocumentEvents/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport './index.scss'\nimport { formatTimeToNow } from '../../utilities/formatDate.js'\nimport { reduceFieldsToValuesWithValidation } from '../../utilities/reduceFieldsToValuesWithValidation.js'\n\nconst baseClass = 'autosave'\n// The minimum time the saving state should be shown\nconst minimumAnimationTime = 1000\n\nexport type Props = {\n collection?: ClientCollectionConfig\n global?: ClientGlobalConfig\n id?: number | string\n publishedDocUpdatedAt: string\n}\n\nexport const Autosave: React.FC<Props> = ({ id, collection, global: globalDoc }) => {\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const {\n docConfig,\n incrementVersionCount,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n updateSavedDocumentData,\n } = useDocumentInfo()\n const queueRef = useRef([])\n const isProcessingRef = useRef(false)\n\n const { reportUpdate } = useDocumentEvents()\n const { dispatchFields, setSubmitted } = useForm()\n const submitted = useFormSubmitted()\n const versionsConfig = docConfig?.versions\n\n const [fields] = useAllFormFields()\n const modified = useFormModified()\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n\n let interval = versionDefaults.autosaveInterval\n if (versionsConfig.drafts && versionsConfig.drafts.autosave) {\n interval = versionsConfig.drafts.autosave.interval\n }\n\n const [saving, setSaving] = useState(false)\n const debouncedFields = useDebounce(fields, interval)\n const fieldRef = useRef(fields)\n const modifiedRef = useRef(modified)\n const localeRef = useRef(locale)\n const debouncedRef = useRef(debouncedFields)\n\n debouncedRef.current = debouncedFields\n\n // Store fields in ref so the autosave func\n // can always retrieve the most to date copies\n // after the timeout has executed\n fieldRef.current = fields\n\n // Store modified in ref so the autosave func\n // can bail out if modified becomes false while\n // timing out during autosave\n modifiedRef.current = modified\n\n // Store locale in ref so the autosave func\n // can always retrieve the most to date locale\n localeRef.current = locale\n\n const processQueue = React.useCallback(async () => {\n if (isProcessingRef.current || queueRef.current.length === 0) {\n return\n }\n\n isProcessingRef.current = true\n const latestAction = queueRef.current[queueRef.current.length - 1]\n queueRef.current = []\n\n try {\n await latestAction()\n } finally {\n isProcessingRef.current = false\n if (queueRef.current.length > 0) {\n await processQueue()\n }\n }\n }, [])\n\n const handleAutosave = useEffectEvent(() => {\n const abortController = new AbortController()\n let autosaveTimeout = undefined\n // We need to log the time in order to figure out if we need to trigger the state off later\n let startTimestamp = undefined\n let endTimestamp = undefined\n\n const autosave = async () => {\n if (modified) {\n startTimestamp = new Date().getTime()\n\n setSaving(true)\n\n let url: string\n let method: string\n let entitySlug: string\n\n if (collection && id) {\n entitySlug = collection.slug\n url = `${serverURL}${api}/${entitySlug}/${id}?draft=true&autosave=true&locale=${localeRef.current}`\n method = 'PATCH'\n }\n\n if (globalDoc) {\n entitySlug = globalDoc.slug\n url = `${serverURL}${api}/globals/${entitySlug}?draft=true&autosave=true&locale=${localeRef.current}`\n method = 'POST'\n }\n\n if (url) {\n if (modifiedRef.current) {\n const { data, valid } = {\n ...reduceFieldsToValuesWithValidation(fieldRef.current, true),\n }\n data._status = 'draft'\n const skipSubmission =\n submitted && !valid && versionsConfig?.drafts && versionsConfig?.drafts?.validate\n\n if (!skipSubmission) {\n await fetch(url, {\n body: JSON.stringify(data),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n method,\n signal: abortController.signal,\n })\n .then((res) => {\n const newDate = new Date()\n // We need to log the time in order to figure out if we need to trigger the state off later\n endTimestamp = newDate.getTime()\n\n if (res.status === 200) {\n setLastUpdateTime(newDate.getTime())\n\n reportUpdate({\n id,\n entitySlug,\n updatedAt: newDate.toISOString(),\n })\n\n if (!mostRecentVersionIsAutosaved) {\n incrementVersionCount()\n setMostRecentVersionIsAutosaved(true)\n setUnpublishedVersionCount((prev) => prev + 1)\n }\n }\n\n return res.json()\n })\n .then((json) => {\n if (versionsConfig?.drafts && versionsConfig?.drafts?.validate && json?.errors) {\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data)) {\n err.data.forEach((dataError) => {\n if (dataError?.field) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n toast.error(err.message || i18n.t('error:unknown'))\n })\n\n setSubmitted(true)\n setSaving(false)\n return\n }\n } else {\n // If it's not an error then we can update the document data inside the context\n const document = json?.doc || json?.result\n\n // Manually update the data since this function doesn't fire the `submit` function from useForm\n if (document) {\n updateSavedDocumentData(document)\n }\n }\n })\n .then(() => {\n // If request was faster than minimum animation time, animate the difference\n if (endTimestamp - startTimestamp < minimumAnimationTime) {\n autosaveTimeout = setTimeout(\n () => {\n setSaving(false)\n },\n minimumAnimationTime - (endTimestamp - startTimestamp),\n )\n } else {\n setSaving(false)\n }\n })\n }\n }\n }\n }\n }\n\n queueRef.current.push(autosave)\n void processQueue()\n\n return { abortController, autosaveTimeout }\n })\n\n // When debounced fields change, autosave\n useEffect(() => {\n const { abortController, autosaveTimeout } = handleAutosave()\n\n return () => {\n if (autosaveTimeout) {\n clearTimeout(autosaveTimeout)\n }\n if (abortController.signal) {\n try {\n abortController.abort('Autosave closed early.')\n } catch (error) {\n // swallow error\n }\n }\n setSaving(false)\n }\n }, [debouncedFields])\n\n return (\n <div className={baseClass}>\n {saving && t('general:saving')}\n {!saving && Boolean(lastUpdateTime) && (\n <React.Fragment>\n {t('version:lastSavedAgo', {\n distance: formatTimeToNow({ date: lastUpdateTime, i18n }),\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,OAAOC,KAAA,IAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACnD,SAASC,KAAK,QAAQ;AAEtB,SACEC,gBAAgB,EAChBC,OAAO,EACPC,eAAe,EACfC,gBAAgB,QACX;AACP,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AACP,SAASC,eAAe,QAAQ;AAChC,SAASC,kCAAkC,QAAQ;AAEnD,MAAMC,SAAA,GAAY;AAClB;AACA,MAAMC,oBAAA,GAAuB;AAS7B,OAAO,MAAMC,QAAA,GAA4BA,CAAC;EAAEC,EAAE;EAAEC,UAAU;EAAEC,MAAA,EAAQC;AAAS,CAAE;EAC7E,MAAM;IACJC,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC;MAAG,CAAE;MACfC;IAAS;EACV,CACF,GAAGjB,SAAA;EACJ,MAAM;IACJkB,SAAS;IACTC,qBAAqB;IACrBC,c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
|
|
1
|
+
{"version":3,"file":"index.js","names":["dequal","reduceFieldsToValues","versionDefaults","React","useDeferredValue","useEffect","useRef","useState","toast","useAllFormFields","useForm","useFormModified","useFormSubmitted","useDebounce","useEffectEvent","useConfig","useDocumentEvents","useDocumentInfo","useLocale","useTranslation","formatTimeToNow","reduceFieldsToValuesWithValidation","LeaveWithoutSaving","baseClass","minimumAnimationTime","Autosave","id","collection","global","globalDoc","config","routes","api","serverURL","docConfig","incrementVersionCount","lastUpdateTime","mostRecentVersionIsAutosaved","setLastUpdateTime","setMostRecentVersionIsAutosaved","setUnpublishedVersionCount","updateSavedDocumentData","queueRef","isProcessingRef","reportUpdate","dispatchFields","isValid","setIsValid","setSubmitted","fields","modified","submitted","code","locale","i18n","t","versionsConfig","versions","interval","autosaveInterval","drafts","autosave","validateOnDraft","Boolean","validate","_saving","setSaving","saving","debouncedFields","fieldRef","modifiedRef","localeRef","isValidRef","current","processQueue","useCallback","length","latestAction","autosaveTimeoutRef","handleAutosave","undefined","startTimestamp","endTimestamp","hideIndicator","setTimeout","stopAutoSaveIndicator","Date","getTime","url","method","entitySlug","slug","data","valid","_status","skipSubmission","res","fetch","body","JSON","stringify","credentials","headers","language","error","newDate","status","updatedAt","toISOString","prev","json","errors","Array","isArray","fieldErrors","nonFieldErrors","reduce","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","message","push","forEach","dataError","field","type","document","doc","result","didMount","previousDebouncedFieldValues","debouncedFieldValues","clearTimeout","_jsxs","className","_jsx","Fragment","distance","date"],"sources":["../../../src/elements/Autosave/index.tsx"],"sourcesContent":["'use client'\n// TODO: abstract the `next/navigation` dependency out from this component\nimport type { ClientCollectionConfig, ClientGlobalConfig } from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { reduceFieldsToValues, versionDefaults } from 'payload/shared'\nimport React, { useDeferredValue, useEffect, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport {\n useAllFormFields,\n useForm,\n useFormModified,\n useFormSubmitted,\n} from '../../forms/Form/context.js'\nimport { useDebounce } from '../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentEvents } from '../../providers/DocumentEvents/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport './index.scss'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { formatTimeToNow } from '../../utilities/formatDate.js'\nimport { reduceFieldsToValuesWithValidation } from '../../utilities/reduceFieldsToValuesWithValidation.js'\nimport { LeaveWithoutSaving } from '../LeaveWithoutSaving/index.js'\n\nconst baseClass = 'autosave'\n// The minimum time the saving state should be shown\nconst minimumAnimationTime = 1000\n\nexport type Props = {\n collection?: ClientCollectionConfig\n global?: ClientGlobalConfig\n id?: number | string\n publishedDocUpdatedAt: string\n}\n\nexport const Autosave: React.FC<Props> = ({ id, collection, global: globalDoc }) => {\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const {\n docConfig,\n incrementVersionCount,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n updateSavedDocumentData,\n } = useDocumentInfo()\n const queueRef = useRef([])\n const isProcessingRef = useRef(false)\n\n const { reportUpdate } = useDocumentEvents()\n const { dispatchFields, isValid, setIsValid, setSubmitted } = useForm()\n\n const [fields] = useAllFormFields()\n const modified = useFormModified()\n const submitted = useFormSubmitted()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n\n const versionsConfig = docConfig?.versions\n let interval = versionDefaults.autosaveInterval\n\n if (versionsConfig.drafts && versionsConfig.drafts.autosave) {\n interval = versionsConfig.drafts.autosave.interval\n }\n\n const validateOnDraft = Boolean(\n docConfig?.versions?.drafts && docConfig?.versions?.drafts.validate,\n )\n\n const [_saving, setSaving] = useState(false)\n const saving = useDeferredValue(_saving)\n const debouncedFields = useDebounce(fields, interval)\n const fieldRef = useRef(fields)\n const modifiedRef = useRef(modified)\n const localeRef = useRef(locale)\n /**\n * Track the validation internally so Autosave can determine when to run queue processing again\n * Helps us prevent infinite loops when the queue is processing and the form is invalid\n */\n const isValidRef = useRef(isValid)\n\n // Store fields in ref so the autosave func\n // can always retrieve the most to date copies\n // after the timeout has executed\n fieldRef.current = fields\n\n // Store modified in ref so the autosave func\n // can bail out if modified becomes false while\n // timing out during autosave\n modifiedRef.current = modified\n\n // Store locale in ref so the autosave func\n // can always retrieve the most to date locale\n localeRef.current = locale\n\n const processQueue = React.useCallback(async () => {\n if (isProcessingRef.current || queueRef.current.length === 0) {\n return\n }\n\n if (!isValidRef.current) {\n // Clear queue so we don't end up in an infinite loop\n queueRef.current = []\n // Reset internal validation state so queue processing can run again\n isValidRef.current = true\n return\n }\n isProcessingRef.current = true\n\n const latestAction = queueRef.current[queueRef.current.length - 1]\n queueRef.current = []\n\n try {\n await latestAction()\n } finally {\n isProcessingRef.current = false\n if (queueRef.current.length > 0) {\n await processQueue()\n }\n }\n }, [])\n\n const autosaveTimeoutRef = useRef<NodeJS.Timeout | null>(null)\n\n const handleAutosave = useEffectEvent(() => {\n autosaveTimeoutRef.current = undefined\n // We need to log the time in order to figure out if we need to trigger the state off later\n let startTimestamp = undefined\n let endTimestamp = undefined\n\n const hideIndicator = () => {\n // If request was faster than minimum animation time, animate the difference\n if (endTimestamp - startTimestamp < minimumAnimationTime) {\n autosaveTimeoutRef.current = setTimeout(\n () => {\n setSaving(false)\n },\n minimumAnimationTime - (endTimestamp - startTimestamp),\n )\n } else {\n stopAutoSaveIndicator()\n }\n }\n\n const autosave = async () => {\n if (modified) {\n startTimestamp = new Date().getTime()\n\n setSaving(true)\n\n let url: string\n let method: string\n let entitySlug: string\n\n if (collection && id) {\n entitySlug = collection.slug\n url = `${serverURL}${api}/${entitySlug}/${id}?draft=true&autosave=true&locale=${localeRef.current}`\n method = 'PATCH'\n }\n\n if (globalDoc) {\n entitySlug = globalDoc.slug\n url = `${serverURL}${api}/globals/${entitySlug}?draft=true&autosave=true&locale=${localeRef.current}`\n method = 'POST'\n }\n\n if (url) {\n if (modifiedRef.current) {\n const { data, valid } = reduceFieldsToValuesWithValidation(fieldRef.current, true)\n\n data._status = 'draft'\n\n const skipSubmission =\n submitted && !valid && versionsConfig?.drafts && versionsConfig?.drafts?.validate\n\n if (!skipSubmission && isValidRef.current) {\n let res\n try {\n res = await fetch(url, {\n body: JSON.stringify(data),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n method,\n })\n } catch (error) {\n // Swallow Error\n }\n\n const newDate = new Date()\n // We need to log the time in order to figure out if we need to trigger the state off later\n endTimestamp = newDate.getTime()\n\n if (res.status === 200) {\n setLastUpdateTime(newDate.getTime())\n\n reportUpdate({\n id,\n entitySlug,\n updatedAt: newDate.toISOString(),\n })\n\n if (!mostRecentVersionIsAutosaved) {\n incrementVersionCount()\n setMostRecentVersionIsAutosaved(true)\n setUnpublishedVersionCount((prev) => prev + 1)\n }\n }\n const json = await res.json()\n\n if (versionsConfig?.drafts && versionsConfig?.drafts?.validate && json?.errors) {\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data)) {\n err.data.forEach((dataError) => {\n if (dataError?.field) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n toast.error(err.message || i18n.t('error:unknown'))\n })\n\n // Set valid to false internally so the queue doesn't process\n isValidRef.current = false\n setIsValid(false)\n setSubmitted(true)\n hideIndicator()\n return\n }\n } else {\n // If it's not an error then we can update the document data inside the context\n const document = json?.doc || json?.result\n\n // Manually update the data since this function doesn't fire the `submit` function from useForm\n if (document) {\n setIsValid(true)\n\n // Reset internal state allowing the queue to process\n isValidRef.current = true\n updateSavedDocumentData(document)\n }\n }\n\n hideIndicator()\n }\n }\n }\n }\n }\n\n queueRef.current.push(autosave)\n void processQueue()\n })\n\n const didMount = useRef(false)\n const previousDebouncedFieldValues = useRef(reduceFieldsToValues(debouncedFields))\n // When debounced fields change, autosave\n useEffect(() => {\n /**\n * Ensure autosave doesn't run on mount\n */\n if (!didMount.current) {\n didMount.current = true\n return\n }\n\n /**\n * Ensure autosave only runs if the form data changes, not every time the entire form state changes\n */\n const debouncedFieldValues = reduceFieldsToValues(debouncedFields)\n if (dequal(debouncedFieldValues, previousDebouncedFieldValues)) {\n return\n }\n\n previousDebouncedFieldValues.current = debouncedFieldValues\n\n handleAutosave()\n }, [debouncedFields])\n\n /**\n * If component unmounts, clear the autosave timeout\n */\n useEffect(() => {\n return () => {\n stopAutoSaveIndicator()\n }\n }, [])\n\n const stopAutoSaveIndicator = useEffectEvent(() => {\n if (autosaveTimeoutRef.current) {\n clearTimeout(autosaveTimeoutRef.current)\n }\n\n setSaving(false)\n })\n\n return (\n <div className={baseClass}>\n {validateOnDraft && !isValid && <LeaveWithoutSaving />}\n {saving && t('general:saving')}\n {!saving && Boolean(lastUpdateTime) && (\n <React.Fragment>\n {t('version:lastSavedAgo', {\n distance: formatTimeToNow({ date: lastUpdateTime, i18n }),\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,MAAM,QAAQ;AACvB,SAASC,oBAAoB,EAAEC,eAAe,QAAQ;AACtD,OAAOC,KAAA,IAASC,gBAAgB,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACrE,SAASC,KAAK,QAAQ;AAEtB,SACEC,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C,MAAA,IAAUZ,CAAA,CAAE,mBACZ,CAACY,MAAA,IAAUJ,OAAA,CAAQ3B,cAAA,kBAClBqG,IAAA,CAACtI,KAAA,CAAMuI,QAAQ;gBACZnF,CAAA,CAAE,wBAAwB;QACzBoF,QAAA,EAAUvH,eAAA,CAAgB;UAAEwH,IAAA,EAAMxG,cAAA;UAAgBkB;QAAK;MACzD;;;AAKV","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../../src/elements/BulkUpload/EditMany/DrawerContent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAuB,MAAM,SAAS,CAAA;AAI1E,OAAO,KAAgC,MAAM,OAAO,CAAA;AAGpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAWvD,OAAO,EAAa,KAAK,wBAAwB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CACrD;IACE,UAAU,EAAE,sBAAsB,CAAA;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CACtB,GAAG,wBAAwB,
|
|
1
|
+
{"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../../src/elements/BulkUpload/EditMany/DrawerContent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAuB,MAAM,SAAS,CAAA;AAI1E,OAAO,KAAgC,MAAM,OAAO,CAAA;AAGpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAWvD,OAAO,EAAa,KAAK,wBAAwB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CACrD;IACE,UAAU,EAAE,sBAAsB,CAAA;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;CACtB,GAAG,wBAAwB,CA2E7B,CAAA"}
|
|
@@ -17,7 +17,7 @@ import { useFormsManager } from '../FormsManager/index.js';
|
|
|
17
17
|
import { baseClass } from './index.js';
|
|
18
18
|
import './index.scss';
|
|
19
19
|
export const EditManyBulkUploadsDrawerContent = props => {
|
|
20
|
-
const $ = _c(
|
|
20
|
+
const $ = _c(24);
|
|
21
21
|
const {
|
|
22
22
|
collection: t0,
|
|
23
23
|
drawerSlug,
|
|
@@ -37,7 +37,8 @@ export const EditManyBulkUploadsDrawerContent = props => {
|
|
|
37
37
|
labels: t2
|
|
38
38
|
} = t1;
|
|
39
39
|
const {
|
|
40
|
-
plural
|
|
40
|
+
plural,
|
|
41
|
+
singular
|
|
41
42
|
} = t2;
|
|
42
43
|
const {
|
|
43
44
|
permissions
|
|
@@ -62,10 +63,10 @@ export const EditManyBulkUploadsDrawerContent = props => {
|
|
|
62
63
|
const [selectedFields, setSelectedFields] = useState(t3);
|
|
63
64
|
const collectionPermissions = permissions?.collections?.[slug];
|
|
64
65
|
let t4;
|
|
65
|
-
if ($[3] !== bulkUpdateForm || $[4] !== closeModal || $[5] !== collectionPermissions?.fields || $[6] !== drawerSlug || $[7] !== fields || $[8] !== forms.length || $[9] !== i18n || $[10] !== plural || $[11] !== selectedFields || $[12] !==
|
|
66
|
+
if ($[3] !== bulkUpdateForm || $[4] !== closeModal || $[5] !== collectionPermissions?.fields || $[6] !== drawerSlug || $[7] !== fields || $[8] !== forms.length || $[9] !== i18n || $[10] !== plural || $[11] !== selectedFields || $[12] !== singular || $[13] !== slug || $[14] !== t) {
|
|
66
67
|
const filteredFields = filterOutUploadFields(fields);
|
|
67
68
|
let t5;
|
|
68
|
-
if ($[
|
|
69
|
+
if ($[16] !== bulkUpdateForm || $[17] !== closeModal || $[18] !== drawerSlug || $[19] !== selectedFields) {
|
|
69
70
|
t5 = formState => {
|
|
70
71
|
const pairedData = selectedFields.reduce((acc, field) => {
|
|
71
72
|
const {
|
|
@@ -78,23 +79,23 @@ export const EditManyBulkUploadsDrawerContent = props => {
|
|
|
78
79
|
}, {});
|
|
79
80
|
bulkUpdateForm(pairedData, () => closeModal(drawerSlug));
|
|
80
81
|
};
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
82
|
+
$[16] = bulkUpdateForm;
|
|
83
|
+
$[17] = closeModal;
|
|
84
|
+
$[18] = drawerSlug;
|
|
85
|
+
$[19] = selectedFields;
|
|
86
|
+
$[20] = t5;
|
|
86
87
|
} else {
|
|
87
|
-
t5 = $[
|
|
88
|
+
t5 = $[20];
|
|
88
89
|
}
|
|
89
90
|
const handleSubmit = t5;
|
|
90
91
|
let t6;
|
|
91
|
-
if ($[
|
|
92
|
+
if ($[21] !== closeModal || $[22] !== drawerSlug) {
|
|
92
93
|
t6 = () => closeModal(drawerSlug);
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
94
|
+
$[21] = closeModal;
|
|
95
|
+
$[22] = drawerSlug;
|
|
96
|
+
$[23] = t6;
|
|
96
97
|
} else {
|
|
97
|
-
t6 = $[
|
|
98
|
+
t6 = $[23];
|
|
98
99
|
}
|
|
99
100
|
t4 = _jsxs("div", {
|
|
100
101
|
className: `${baseClass}__main`,
|
|
@@ -104,7 +105,7 @@ export const EditManyBulkUploadsDrawerContent = props => {
|
|
|
104
105
|
className: `${baseClass}__header__title`,
|
|
105
106
|
children: t("general:editingLabel", {
|
|
106
107
|
count: forms.length,
|
|
107
|
-
label: getTranslation(plural, i18n)
|
|
108
|
+
label: getTranslation(forms.length > 1 ? plural : singular, i18n)
|
|
108
109
|
})
|
|
109
110
|
}), _jsx("button", {
|
|
110
111
|
"aria-label": t("general:close"),
|
|
@@ -155,11 +156,12 @@ export const EditManyBulkUploadsDrawerContent = props => {
|
|
|
155
156
|
$[9] = i18n;
|
|
156
157
|
$[10] = plural;
|
|
157
158
|
$[11] = selectedFields;
|
|
158
|
-
$[12] =
|
|
159
|
-
$[13] =
|
|
160
|
-
$[14] =
|
|
159
|
+
$[12] = singular;
|
|
160
|
+
$[13] = slug;
|
|
161
|
+
$[14] = t;
|
|
162
|
+
$[15] = t4;
|
|
161
163
|
} else {
|
|
162
|
-
t4 = $[
|
|
164
|
+
t4 = $[15];
|
|
163
165
|
}
|
|
164
166
|
return t4;
|
|
165
167
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerContent.js","names":["c","_c","useModal","getTranslation","React","useCallback","useState","Button","Form","RenderFields","XIcon","useAuth","useTranslation","filterOutUploadFields","FieldSelect","useFormsManager","baseClass","EditManyBulkUploadsDrawerContent","props","$","collection","t0","drawerSlug","forms","t1","undefined","slug","fields","labels","t2","plural","permissions","i18n","t","closeModal","bulkUpdateForm","t3","Symbol","for","selectedFields","setSelectedFields","collectionPermissions","collections","t4","length","filteredFields","t5","formState","pairedData","reduce","acc","field","path","value","handleSubmit","t6","_jsxs","className","children","_jsx","count","label","id","onClick","type","initialState","onSubmit","setSelected","parentIndexPath","parentPath","parentSchemaPath","readOnly"],"sources":["../../../../src/elements/BulkUpload/EditMany/DrawerContent.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, FieldWithPathClient } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useState } from 'react'\n\nimport type { FormProps } from '../../../forms/Form/index.js'\nimport type { State } from '../FormsManager/reducer.js'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { Form } from '../../../forms/Form/index.js'\nimport { RenderFields } from '../../../forms/RenderFields/index.js'\nimport { XIcon } from '../../../icons/X/index.js'\nimport { useAuth } from '../../../providers/Auth/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { filterOutUploadFields } from '../../../utilities/filterOutUploadFields.js'\nimport { FieldSelect } from '../../FieldSelect/index.js'\nimport { useFormsManager } from '../FormsManager/index.js'\nimport { baseClass, type EditManyBulkUploadsProps } from './index.js'\nimport './index.scss'\n\nexport const EditManyBulkUploadsDrawerContent: React.FC<\n {\n collection: ClientCollectionConfig\n drawerSlug: string\n forms: State['forms']\n } & EditManyBulkUploadsProps\n> = (props) => {\n const {
|
|
1
|
+
{"version":3,"file":"DrawerContent.js","names":["c","_c","useModal","getTranslation","React","useCallback","useState","Button","Form","RenderFields","XIcon","useAuth","useTranslation","filterOutUploadFields","FieldSelect","useFormsManager","baseClass","EditManyBulkUploadsDrawerContent","props","$","collection","t0","drawerSlug","forms","t1","undefined","slug","fields","labels","t2","plural","singular","permissions","i18n","t","closeModal","bulkUpdateForm","t3","Symbol","for","selectedFields","setSelectedFields","collectionPermissions","collections","t4","length","filteredFields","t5","formState","pairedData","reduce","acc","field","path","value","handleSubmit","t6","_jsxs","className","children","_jsx","count","label","id","onClick","type","initialState","onSubmit","setSelected","parentIndexPath","parentPath","parentSchemaPath","readOnly"],"sources":["../../../../src/elements/BulkUpload/EditMany/DrawerContent.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, FieldWithPathClient } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useState } from 'react'\n\nimport type { FormProps } from '../../../forms/Form/index.js'\nimport type { State } from '../FormsManager/reducer.js'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { Form } from '../../../forms/Form/index.js'\nimport { RenderFields } from '../../../forms/RenderFields/index.js'\nimport { XIcon } from '../../../icons/X/index.js'\nimport { useAuth } from '../../../providers/Auth/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { filterOutUploadFields } from '../../../utilities/filterOutUploadFields.js'\nimport { FieldSelect } from '../../FieldSelect/index.js'\nimport { useFormsManager } from '../FormsManager/index.js'\nimport { baseClass, type EditManyBulkUploadsProps } from './index.js'\nimport './index.scss'\n\nexport const EditManyBulkUploadsDrawerContent: React.FC<\n {\n collection: ClientCollectionConfig\n drawerSlug: string\n forms: State['forms']\n } & EditManyBulkUploadsProps\n> = (props) => {\n const {\n collection: { slug, fields, labels: { plural, singular } } = {},\n drawerSlug,\n forms,\n } = props\n\n const { permissions } = useAuth()\n const { i18n, t } = useTranslation()\n const { closeModal } = useModal()\n const { bulkUpdateForm } = useFormsManager()\n\n const [selectedFields, setSelectedFields] = useState<FieldWithPathClient[]>([])\n const collectionPermissions = permissions?.collections?.[slug]\n const filteredFields = filterOutUploadFields(fields)\n\n const handleSubmit: FormProps['onSubmit'] = useCallback(\n (formState) => {\n const pairedData = selectedFields.reduce((acc, field) => {\n const { path } = field\n if (formState[path]) {\n acc[path] = formState[path].value\n }\n return acc\n }, {})\n\n void bulkUpdateForm(pairedData, () => closeModal(drawerSlug))\n },\n [closeModal, drawerSlug, bulkUpdateForm, selectedFields],\n )\n\n return (\n <div className={`${baseClass}__main`}>\n <div className={`${baseClass}__header`}>\n <h2 className={`${baseClass}__header__title`}>\n {t('general:editingLabel', {\n count: forms.length,\n label: getTranslation(forms.length > 1 ? plural : singular, i18n),\n })}\n </h2>\n <button\n aria-label={t('general:close')}\n className={`${baseClass}__header__close`}\n id={`close-drawer__${drawerSlug}`}\n onClick={() => closeModal(drawerSlug)}\n type=\"button\"\n >\n <XIcon />\n </button>\n </div>\n <Form className={`${baseClass}__form`} initialState={{}} onSubmit={handleSubmit}>\n <FieldSelect fields={filteredFields} setSelected={setSelectedFields} />\n {selectedFields.length === 0 ? null : (\n <RenderFields\n fields={selectedFields}\n parentIndexPath=\"\"\n parentPath=\"\"\n parentSchemaPath={slug}\n permissions={collectionPermissions?.fields}\n readOnly={false}\n />\n )}\n <div className={`${baseClass}__sidebar-wrap`}>\n <div className={`${baseClass}__sidebar`}>\n <div className={`${baseClass}__sidebar-sticky-wrap`}>\n <div className={`${baseClass}__document-actions`}>\n <Button type=\"submit\">{t('general:appl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AAnD,YAAA;UAAAkB,MAAA,EACUa,cAAA;UAAA6B,eAAA,EACQ;UAAAC,UAAA,EACL;UAAAC,gBAAA,EACO7C,IAAA;UAAAM,WAAA,EACLU,qBAAA,EAAAf,MAAA;UAAA6C,QAAA;QAAA,C,GAIjBZ,IAAA,CAAC;UAAAF,SAAA,EAAe,GAAA1C,SAAA,gBAA4B;UAAA2C,QAAA,EAC1CC,IAAA,CAAC;YAAAF,SAAA,EAAe,GAAA1C,SAAA,WAAuB;YAAA2C,QAAA,EACrCC,IAAA,CAAC;cAAAF,SAAA,EAAe,GAAA1C,SAAA,uBAAmC;cAAA2C,QAAA,EACjDC,IAAA,CAAC;gBAAAF,SAAA,EAAe,GAAA1C,SAAA,oBAAgC;gBAAA2C,QAAA,EAC9CC,IAAA,CAAArD,MAAA;kBAAA0D,IAAA,EAAa;kBAAAN,QAAA,EAAUzB,CAAA,CAAE;gBAAA,C;;;;;;;;;;;;;;;;;;;;;;;SAlCrCU,E;CA0CJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmC,MAAM,OAAO,CAAA;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAWvC,OAAO,cAAc,CAAA;AAarB,eAAO,MAAM,cAAc;;;;;uBAqB1B,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmC,MAAM,OAAO,CAAA;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAWvC,OAAO,cAAc,CAAA;AAarB,eAAO,MAAM,cAAc;;;;;uBAqB1B,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAoJlC,CAAA"}
|
|
@@ -161,6 +161,7 @@ export const Button = props => {
|
|
|
161
161
|
className: disabled && !enableSubMenu ? `${baseClass}--popup-disabled` : '',
|
|
162
162
|
disabled: disabled && !enableSubMenu,
|
|
163
163
|
horizontalAlign: "right",
|
|
164
|
+
id: `${id}-popup`,
|
|
164
165
|
noBackground: true,
|
|
165
166
|
render: ({
|
|
166
167
|
close
|