@questpie/admin 3.2.4 → 3.2.6
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/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +94 -296
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +61 -72
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +285 -605
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +176 -476
- package/dist/client/components/preview/live-preview-mode.mjs +233 -458
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +229 -572
- package/dist/client/components/primitives/select-single.mjs +179 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.mjs +63 -146
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +167 -348
- package/dist/client/preview/use-collection-preview.mjs +121 -215
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/utils/build-field-definitions-from-schema.mjs +4 -2
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -379
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +116 -356
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +58 -182
- package/dist/client/views/collection/form-view.mjs +284 -518
- package/dist/client/views/collection/table-view.mjs +231 -463
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -560
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +477 -1301
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +458 -1274
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.d.mts +2 -2
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/adapters/index.d.mts +2 -0
- package/dist/server/adapters/nextjs.d.mts +1 -0
- package/dist/server/auth-helpers.d.mts +1 -0
- package/dist/server/modules/admin/.generated/module.d.mts +1 -0
- package/dist/server/modules/admin/collections/account.d.mts +46 -46
- package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +39 -39
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +62 -62
- package/dist/server/modules/admin/collections/verification.d.mts +23 -23
- package/dist/server/modules/admin/index.d.mts +20 -19
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
- package/dist/server/modules/audit/.generated/module.d.mts +6 -6
- package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
- package/dist/server.d.mts +2 -0
- package/package.json +3 -5
|
@@ -10,7 +10,6 @@ import { useUpload } from "../../hooks/use-upload.mjs";
|
|
|
10
10
|
import { AssetPreview } from "../primitives/asset-preview.mjs";
|
|
11
11
|
import { MediaPickerDialog } from "../media/media-picker-dialog.mjs";
|
|
12
12
|
import { Dropzone } from "../primitives/dropzone.mjs";
|
|
13
|
-
import { c } from "react/compiler-runtime";
|
|
14
13
|
import * as React from "react";
|
|
15
14
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
16
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -59,96 +58,31 @@ function normalizeAccept(accept) {
|
|
|
59
58
|
if (Array.isArray(accept)) return accept;
|
|
60
59
|
return [accept];
|
|
61
60
|
}
|
|
62
|
-
function SortableAssetItem(
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
$[0] = id;
|
|
69
|
-
$[1] = t1;
|
|
70
|
-
} else t1 = $[1];
|
|
71
|
-
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable(t1);
|
|
72
|
-
let t2;
|
|
73
|
-
if ($[2] !== transform) {
|
|
74
|
-
t2 = CSS.Transform.toString(transform);
|
|
75
|
-
$[2] = transform;
|
|
76
|
-
$[3] = t2;
|
|
77
|
-
} else t2 = $[3];
|
|
78
|
-
let t3;
|
|
79
|
-
if ($[4] !== t2 || $[5] !== transition) {
|
|
80
|
-
t3 = {
|
|
81
|
-
transform: t2,
|
|
61
|
+
function SortableAssetItem({ id, asset, loading, progress, disabled, variant, orderable, editable, href, onRemove, onEdit }) {
|
|
62
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id });
|
|
63
|
+
return /* @__PURE__ */ jsx("div", {
|
|
64
|
+
ref: setNodeRef,
|
|
65
|
+
style: {
|
|
66
|
+
transform: CSS.Transform.toString(transform),
|
|
82
67
|
transition
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} else t3 = $[6];
|
|
88
|
-
const style = t3;
|
|
89
|
-
const t4 = isDragging ? "opacity-50" : "";
|
|
90
|
-
let t5;
|
|
91
|
-
if ($[7] !== asset || $[8] !== id) {
|
|
92
|
-
t5 = asset || { id };
|
|
93
|
-
$[7] = asset;
|
|
94
|
-
$[8] = id;
|
|
95
|
-
$[9] = t5;
|
|
96
|
-
} else t5 = $[9];
|
|
97
|
-
const t6 = orderable && !disabled;
|
|
98
|
-
let t7;
|
|
99
|
-
if ($[10] !== attributes || $[11] !== listeners || $[12] !== orderable) {
|
|
100
|
-
t7 = orderable ? {
|
|
101
|
-
...attributes,
|
|
102
|
-
...listeners
|
|
103
|
-
} : void 0;
|
|
104
|
-
$[10] = attributes;
|
|
105
|
-
$[11] = listeners;
|
|
106
|
-
$[12] = orderable;
|
|
107
|
-
$[13] = t7;
|
|
108
|
-
} else t7 = $[13];
|
|
109
|
-
const t8 = disabled ? void 0 : onRemove;
|
|
110
|
-
const t9 = editable && !disabled ? onEdit : void 0;
|
|
111
|
-
let t10;
|
|
112
|
-
if ($[14] !== disabled || $[15] !== href || $[16] !== loading || $[17] !== progress || $[18] !== t5 || $[19] !== t6 || $[20] !== t7 || $[21] !== t8 || $[22] !== t9 || $[23] !== variant) {
|
|
113
|
-
t10 = /* @__PURE__ */ jsx(AssetPreview, {
|
|
114
|
-
asset: t5,
|
|
68
|
+
},
|
|
69
|
+
className: isDragging ? "opacity-50" : "",
|
|
70
|
+
children: /* @__PURE__ */ jsx(AssetPreview, {
|
|
71
|
+
asset: asset || { id },
|
|
115
72
|
loading,
|
|
116
73
|
progress,
|
|
117
74
|
disabled,
|
|
118
75
|
variant,
|
|
119
|
-
showDragHandle:
|
|
120
|
-
dragHandleProps:
|
|
76
|
+
showDragHandle: orderable && !disabled,
|
|
77
|
+
dragHandleProps: orderable ? {
|
|
78
|
+
...attributes,
|
|
79
|
+
...listeners
|
|
80
|
+
} : void 0,
|
|
121
81
|
href,
|
|
122
|
-
onRemove:
|
|
123
|
-
onEdit:
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
$[15] = href;
|
|
127
|
-
$[16] = loading;
|
|
128
|
-
$[17] = progress;
|
|
129
|
-
$[18] = t5;
|
|
130
|
-
$[19] = t6;
|
|
131
|
-
$[20] = t7;
|
|
132
|
-
$[21] = t8;
|
|
133
|
-
$[22] = t9;
|
|
134
|
-
$[23] = variant;
|
|
135
|
-
$[24] = t10;
|
|
136
|
-
} else t10 = $[24];
|
|
137
|
-
let t11;
|
|
138
|
-
if ($[25] !== setNodeRef || $[26] !== style || $[27] !== t10 || $[28] !== t4) {
|
|
139
|
-
t11 = /* @__PURE__ */ jsx("div", {
|
|
140
|
-
ref: setNodeRef,
|
|
141
|
-
style,
|
|
142
|
-
className: t4,
|
|
143
|
-
children: t10
|
|
144
|
-
});
|
|
145
|
-
$[25] = setNodeRef;
|
|
146
|
-
$[26] = style;
|
|
147
|
-
$[27] = t10;
|
|
148
|
-
$[28] = t4;
|
|
149
|
-
$[29] = t11;
|
|
150
|
-
} else t11 = $[29];
|
|
151
|
-
return t11;
|
|
82
|
+
onRemove: disabled ? void 0 : onRemove,
|
|
83
|
+
onEdit: editable && !disabled ? onEdit : void 0
|
|
84
|
+
})
|
|
85
|
+
});
|
|
152
86
|
}
|
|
153
87
|
function SingleUploadInner({ field, error, collection, unresolvedCollectionMessage, accept, maxSize, showPreview, editable, previewVariant, disabled, placeholder, onUploadStart, onUploadComplete, onUploadError, className }) {
|
|
154
88
|
"use no memo";
|
|
@@ -333,9 +267,9 @@ function MultipleUploadInner({ field, collection, unresolvedCollectionMessage, a
|
|
|
333
267
|
const sanitizedName = sanitizeFilename(file.name);
|
|
334
268
|
return new File([file], sanitizedName, { type: file.type });
|
|
335
269
|
});
|
|
336
|
-
setPendingUploads(sanitizedFiles.map((
|
|
270
|
+
setPendingUploads(sanitizedFiles.map((file, index) => ({
|
|
337
271
|
id: `pending-${Date.now()}-${index}`,
|
|
338
|
-
file
|
|
272
|
+
file
|
|
339
273
|
})));
|
|
340
274
|
if (onUploadStart) onUploadStart();
|
|
341
275
|
uploadMany(sanitizedFiles, { to: collection }).then((uploadedAssets) => {
|
|
@@ -361,8 +295,8 @@ function MultipleUploadInner({ field, collection, unresolvedCollectionMessage, a
|
|
|
361
295
|
const handleRemove = (idToRemove) => {
|
|
362
296
|
field.onChange(assetIds.filter((id) => id !== idToRemove));
|
|
363
297
|
};
|
|
364
|
-
const handleEdit = (
|
|
365
|
-
setEditAssetId(
|
|
298
|
+
const handleEdit = (id) => {
|
|
299
|
+
setEditAssetId(id);
|
|
366
300
|
};
|
|
367
301
|
const handleDragEnd = (event) => {
|
|
368
302
|
const { active, over } = event;
|
|
@@ -383,14 +317,14 @@ function MultipleUploadInner({ field, collection, unresolvedCollectionMessage, a
|
|
|
383
317
|
toast.error(unresolvedCollectionMessage || t("error.noUploadCollection"));
|
|
384
318
|
return;
|
|
385
319
|
}
|
|
386
|
-
const
|
|
387
|
-
const totalAfterAdd = assetIds.length +
|
|
320
|
+
const newIds = Array.isArray(ids) ? ids : [ids];
|
|
321
|
+
const totalAfterAdd = assetIds.length + newIds.length;
|
|
388
322
|
if (maxItems && totalAfterAdd > maxItems) {
|
|
389
323
|
toast.warning(t("error.maxItemsAllowed", { max: maxItems }));
|
|
390
|
-
const
|
|
391
|
-
const idsToAdd =
|
|
324
|
+
const remainingSlots = maxItems - assetIds.length;
|
|
325
|
+
const idsToAdd = newIds.slice(0, remainingSlots);
|
|
392
326
|
field.onChange([...assetIds, ...idsToAdd]);
|
|
393
|
-
} else field.onChange([...assetIds, ...
|
|
327
|
+
} else field.onChange([...assetIds, ...newIds]);
|
|
394
328
|
};
|
|
395
329
|
const hintText = React.useMemo(() => {
|
|
396
330
|
const parts = [];
|
|
@@ -401,7 +335,7 @@ function MultipleUploadInner({ field, collection, unresolvedCollectionMessage, a
|
|
|
401
335
|
if (type.startsWith("audio/")) return t("dropzone.typeAudio");
|
|
402
336
|
if (type === "application/pdf") return t("dropzone.typePDF");
|
|
403
337
|
return type;
|
|
404
|
-
}).filter((v, i,
|
|
338
|
+
}).filter((v, i, a) => a.indexOf(v) === i);
|
|
405
339
|
parts.push(types.join(", "));
|
|
406
340
|
}
|
|
407
341
|
if (maxSize) {
|
|
@@ -434,23 +368,23 @@ function MultipleUploadInner({ field, collection, unresolvedCollectionMessage, a
|
|
|
434
368
|
disabled: !orderable,
|
|
435
369
|
children: /* @__PURE__ */ jsxs("div", {
|
|
436
370
|
className: layout === "grid" ? "mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4" : "mb-3 space-y-2",
|
|
437
|
-
children: [assetIds.map((
|
|
438
|
-
id
|
|
439
|
-
asset: fetchedAssetsMap.get(
|
|
371
|
+
children: [assetIds.map((id) => /* @__PURE__ */ jsx(SortableAssetItem, {
|
|
372
|
+
id,
|
|
373
|
+
asset: fetchedAssetsMap.get(id) || null,
|
|
440
374
|
disabled,
|
|
441
375
|
variant: previewVariant,
|
|
442
376
|
orderable,
|
|
443
377
|
editable,
|
|
444
|
-
onRemove: () => handleRemove(
|
|
445
|
-
onEdit: () => handleEdit(
|
|
446
|
-
},
|
|
447
|
-
asset: { filename:
|
|
448
|
-
pendingFile:
|
|
378
|
+
onRemove: () => handleRemove(id),
|
|
379
|
+
onEdit: () => handleEdit(id)
|
|
380
|
+
}, id)), pendingUploads.map((pending, index) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AssetPreview, {
|
|
381
|
+
asset: { filename: pending.file.name },
|
|
382
|
+
pendingFile: pending.file,
|
|
449
383
|
loading: true,
|
|
450
|
-
progress: Math.min(100, Math.max(0, progress -
|
|
384
|
+
progress: Math.min(100, Math.max(0, progress - index / pendingUploads.length * 100) * (pendingUploads.length / (pendingUploads.length - index))),
|
|
451
385
|
disabled: true,
|
|
452
386
|
variant: previewVariant
|
|
453
|
-
}) },
|
|
387
|
+
}) }, pending.id))]
|
|
454
388
|
})
|
|
455
389
|
})
|
|
456
390
|
}),
|
|
@@ -500,32 +434,18 @@ function MultipleUploadInner({ field, collection, unresolvedCollectionMessage, a
|
|
|
500
434
|
]
|
|
501
435
|
});
|
|
502
436
|
}
|
|
503
|
-
function UploadField(
|
|
504
|
-
const $ = c(32);
|
|
505
|
-
const { name, label, description, placeholder, required, disabled, localized, locale, control, className, to, accept, maxSize, showPreview: t1, editable: t2, previewVariant, onUploadStart, onUploadComplete, onUploadError, multiple: t3, maxItems, orderable: t4, layout: t5 } = t0;
|
|
506
|
-
const showPreview = t1 === void 0 ? true : t1;
|
|
507
|
-
const editable = t2 === void 0 ? true : t2;
|
|
508
|
-
const multiple = t3 === void 0 ? false : t3;
|
|
509
|
-
const orderable = t4 === void 0 ? false : t4;
|
|
510
|
-
const layout = t5 === void 0 ? "grid" : t5;
|
|
437
|
+
function UploadField({ name, label, description, placeholder, required, disabled, localized, locale, control, className, to, accept, maxSize, showPreview = true, editable = true, previewVariant, onUploadStart, onUploadComplete, onUploadError, multiple = false, maxItems, orderable = false, layout = "grid" }) {
|
|
511
438
|
const resolveText = useResolveText();
|
|
512
439
|
const resolvedControl = useResolvedControl(control);
|
|
513
440
|
const { collection: resolvedUploadCollection, collections: availableUploadCollections } = useUploadCollection(to);
|
|
514
441
|
const collection = resolvedUploadCollection || "";
|
|
515
|
-
|
|
516
|
-
if ($[0] !== availableUploadCollections || $[1] !== resolvedUploadCollection) {
|
|
517
|
-
t6 = !resolvedUploadCollection ? availableUploadCollections.length > 1 ? `Multiple upload collections are available (${availableUploadCollections.join(", ")}). Configure the field with \`to\` to choose one.` : "No upload collection is configured for this field." : void 0;
|
|
518
|
-
$[0] = availableUploadCollections;
|
|
519
|
-
$[1] = resolvedUploadCollection;
|
|
520
|
-
$[2] = t6;
|
|
521
|
-
} else t6 = $[2];
|
|
522
|
-
const unresolvedCollectionMessage = t6;
|
|
442
|
+
const unresolvedCollectionMessage = !resolvedUploadCollection ? availableUploadCollections.length > 1 ? `Multiple upload collections are available (${availableUploadCollections.join(", ")}). Configure the field with \`to\` to choose one.` : "No upload collection is configured for this field." : void 0;
|
|
523
443
|
const fieldDisabled = disabled || !!unresolvedCollectionMessage;
|
|
524
444
|
const effectivePreviewVariant = previewVariant ?? (multiple ? layout === "grid" ? "thumbnail" : "compact" : "compact");
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
445
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
446
|
+
name,
|
|
447
|
+
control: resolvedControl,
|
|
448
|
+
render: ({ field, fieldState }) => {
|
|
529
449
|
const assetIds = multiple ? field.value || [] : [];
|
|
530
450
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
531
451
|
name,
|
|
@@ -571,46 +491,8 @@ function UploadField(t0) {
|
|
|
571
491
|
className: cn("qa-upload-field", className)
|
|
572
492
|
})
|
|
573
493
|
});
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
$[4] = className;
|
|
577
|
-
$[5] = collection;
|
|
578
|
-
$[6] = description;
|
|
579
|
-
$[7] = editable;
|
|
580
|
-
$[8] = effectivePreviewVariant;
|
|
581
|
-
$[9] = fieldDisabled;
|
|
582
|
-
$[10] = label;
|
|
583
|
-
$[11] = layout;
|
|
584
|
-
$[12] = locale;
|
|
585
|
-
$[13] = localized;
|
|
586
|
-
$[14] = maxItems;
|
|
587
|
-
$[15] = maxSize;
|
|
588
|
-
$[16] = multiple;
|
|
589
|
-
$[17] = name;
|
|
590
|
-
$[18] = onUploadComplete;
|
|
591
|
-
$[19] = onUploadError;
|
|
592
|
-
$[20] = onUploadStart;
|
|
593
|
-
$[21] = orderable;
|
|
594
|
-
$[22] = placeholder;
|
|
595
|
-
$[23] = required;
|
|
596
|
-
$[24] = resolveText;
|
|
597
|
-
$[25] = showPreview;
|
|
598
|
-
$[26] = unresolvedCollectionMessage;
|
|
599
|
-
$[27] = t7;
|
|
600
|
-
} else t7 = $[27];
|
|
601
|
-
let t8;
|
|
602
|
-
if ($[28] !== name || $[29] !== resolvedControl || $[30] !== t7) {
|
|
603
|
-
t8 = /* @__PURE__ */ jsx(Controller, {
|
|
604
|
-
name,
|
|
605
|
-
control: resolvedControl,
|
|
606
|
-
render: t7
|
|
607
|
-
});
|
|
608
|
-
$[28] = name;
|
|
609
|
-
$[29] = resolvedControl;
|
|
610
|
-
$[30] = t7;
|
|
611
|
-
$[31] = t8;
|
|
612
|
-
} else t8 = $[31];
|
|
613
|
-
return t8;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
614
496
|
}
|
|
615
497
|
|
|
616
498
|
//#endregion
|