@questpie/admin 3.2.3 → 3.2.5

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.
Files changed (244) hide show
  1. package/dist/client/blocks/block-renderer.d.mts +2 -2
  2. package/dist/client/blocks/block-renderer.mjs +164 -339
  3. package/dist/client/components/actions/action-button.mjs +9 -9
  4. package/dist/client/components/actions/action-dialog.mjs +195 -493
  5. package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
  6. package/dist/client/components/actions/header-actions.mjs +73 -165
  7. package/dist/client/components/admin-link.d.mts +2 -2
  8. package/dist/client/components/admin-link.mjs +40 -126
  9. package/dist/client/components/auth/auth-loading.mjs +9 -44
  10. package/dist/client/components/blocks/block-canvas.mjs +31 -95
  11. package/dist/client/components/blocks/block-editor-context.mjs +13 -57
  12. package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
  13. package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
  14. package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
  15. package/dist/client/components/blocks/block-insert-button.mjs +49 -165
  16. package/dist/client/components/blocks/block-item-menu.mjs +102 -301
  17. package/dist/client/components/blocks/block-item.mjs +136 -370
  18. package/dist/client/components/blocks/block-library-sidebar.mjs +106 -220
  19. package/dist/client/components/blocks/block-tree.mjs +12 -68
  20. package/dist/client/components/blocks/block-type-icon.mjs +14 -56
  21. package/dist/client/components/brand-logo.mjs +35 -149
  22. package/dist/client/components/component-renderer.mjs +42 -118
  23. package/dist/client/components/error-boundary.mjs +14 -58
  24. package/dist/client/components/fields/array-field.mjs +209 -521
  25. package/dist/client/components/fields/asset-preview-field.mjs +41 -141
  26. package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
  27. package/dist/client/components/fields/boolean-field.mjs +29 -59
  28. package/dist/client/components/fields/date-field.mjs +7 -37
  29. package/dist/client/components/fields/datetime-field.mjs +7 -38
  30. package/dist/client/components/fields/email-field.mjs +25 -54
  31. package/dist/client/components/fields/field-wrapper.mjs +30 -105
  32. package/dist/client/components/fields/json-field.mjs +107 -313
  33. package/dist/client/components/fields/locale-badge.mjs +6 -15
  34. package/dist/client/components/fields/number-field.mjs +27 -60
  35. package/dist/client/components/fields/object-array-field.mjs +283 -659
  36. package/dist/client/components/fields/object-field.mjs +165 -633
  37. package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
  38. package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
  39. package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
  40. package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
  41. package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
  42. package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
  43. package/dist/client/components/fields/relation-field.mjs +10 -66
  44. package/dist/client/components/fields/relation-picker.mjs +18 -18
  45. package/dist/client/components/fields/relation-select.mjs +12 -12
  46. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -182
  47. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +8 -19
  48. package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
  49. package/dist/client/components/fields/rich-text-editor/index.mjs +196 -530
  50. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
  51. package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
  52. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
  53. package/dist/client/components/fields/rich-text-field.mjs +14 -53
  54. package/dist/client/components/fields/select-field.mjs +39 -74
  55. package/dist/client/components/fields/text-field.mjs +26 -59
  56. package/dist/client/components/fields/textarea-field.mjs +26 -58
  57. package/dist/client/components/fields/time-field.mjs +7 -35
  58. package/dist/client/components/fields/upload-field.mjs +47 -165
  59. package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
  60. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
  61. package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
  62. package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
  63. package/dist/client/components/history-sidebar.mjs +306 -611
  64. package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
  65. package/dist/client/components/locale-switcher.mjs +106 -228
  66. package/dist/client/components/media/media-grid.mjs +84 -273
  67. package/dist/client/components/media/media-picker-dialog.mjs +177 -494
  68. package/dist/client/components/preview/live-preview-mode.mjs +240 -438
  69. package/dist/client/components/preview/preview-pane.mjs +22 -22
  70. package/dist/client/components/primitives/asset-preview.mjs +290 -666
  71. package/dist/client/components/primitives/checkbox-input.mjs +9 -35
  72. package/dist/client/components/primitives/date-input.mjs +109 -327
  73. package/dist/client/components/primitives/dropzone.mjs +209 -336
  74. package/dist/client/components/primitives/field-select-control.mjs +12 -80
  75. package/dist/client/components/primitives/number-input.mjs +4 -4
  76. package/dist/client/components/primitives/select-multi.mjs +200 -559
  77. package/dist/client/components/primitives/select-single.mjs +165 -499
  78. package/dist/client/components/primitives/time-input.mjs +43 -117
  79. package/dist/client/components/primitives/toggle-input.mjs +9 -29
  80. package/dist/client/components/sheets/resource-sheet.mjs +61 -70
  81. package/dist/client/components/ui/accordion.mjs +35 -155
  82. package/dist/client/components/ui/alert.mjs +13 -68
  83. package/dist/client/components/ui/badge.mjs +9 -51
  84. package/dist/client/components/ui/button.mjs +8 -54
  85. package/dist/client/components/ui/card.mjs +37 -193
  86. package/dist/client/components/ui/checkbox.mjs +12 -68
  87. package/dist/client/components/ui/command.mjs +48 -219
  88. package/dist/client/components/ui/dialog.mjs +50 -262
  89. package/dist/client/components/ui/drawer.mjs +55 -259
  90. package/dist/client/components/ui/dropdown-menu.mjs +86 -427
  91. package/dist/client/components/ui/empty-state.mjs +28 -98
  92. package/dist/client/components/ui/field.mjs +73 -309
  93. package/dist/client/components/ui/input-group.mjs +42 -167
  94. package/dist/client/components/ui/input.mjs +7 -37
  95. package/dist/client/components/ui/kbd.mjs +6 -36
  96. package/dist/client/components/ui/label.mjs +7 -37
  97. package/dist/client/components/ui/popover.mjs +34 -169
  98. package/dist/client/components/ui/responsive-dialog.mjs +67 -273
  99. package/dist/client/components/ui/scroll-fade.mjs +63 -158
  100. package/dist/client/components/ui/search-input.mjs +33 -100
  101. package/dist/client/components/ui/select.mjs +72 -393
  102. package/dist/client/components/ui/separator.mjs +7 -38
  103. package/dist/client/components/ui/sheet.mjs +49 -269
  104. package/dist/client/components/ui/sidebar.mjs +171 -690
  105. package/dist/client/components/ui/skeleton.mjs +7 -38
  106. package/dist/client/components/ui/sonner.mjs +11 -42
  107. package/dist/client/components/ui/switch.mjs +9 -45
  108. package/dist/client/components/ui/table.mjs +48 -266
  109. package/dist/client/components/ui/tabs.mjs +26 -139
  110. package/dist/client/components/ui/textarea.mjs +6 -32
  111. package/dist/client/components/ui/tooltip.mjs +27 -129
  112. package/dist/client/components/widgets/chart-widget.mjs +174 -522
  113. package/dist/client/components/widgets/progress-widget.mjs +66 -172
  114. package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
  115. package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
  116. package/dist/client/components/widgets/stats-widget.mjs +41 -175
  117. package/dist/client/components/widgets/table-widget.mjs +9 -9
  118. package/dist/client/components/widgets/timeline-widget.mjs +86 -226
  119. package/dist/client/components/widgets/value-widget.mjs +74 -381
  120. package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
  121. package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
  122. package/dist/client/contexts/focus-context.d.mts +4 -0
  123. package/dist/client/contexts/focus-context.mjs +87 -150
  124. package/dist/client/hooks/typed-hooks.mjs +241 -701
  125. package/dist/client/hooks/use-action.mjs +62 -198
  126. package/dist/client/hooks/use-admin-config.mjs +5 -35
  127. package/dist/client/hooks/use-admin-preferences.mjs +16 -88
  128. package/dist/client/hooks/use-admin-routes.mjs +22 -56
  129. package/dist/client/hooks/use-audit-history.mjs +21 -69
  130. package/dist/client/hooks/use-brand.mjs +1 -9
  131. package/dist/client/hooks/use-collection-fields.mjs +17 -57
  132. package/dist/client/hooks/use-collection-meta.mjs +12 -44
  133. package/dist/client/hooks/use-collection-schema.mjs +10 -33
  134. package/dist/client/hooks/use-collection-validation.mjs +23 -53
  135. package/dist/client/hooks/use-collection.mjs +194 -614
  136. package/dist/client/hooks/use-current-user.mjs +0 -1
  137. package/dist/client/hooks/use-field-hooks.mjs +10 -10
  138. package/dist/client/hooks/use-field-options.mjs +61 -202
  139. package/dist/client/hooks/use-global-fields.mjs +14 -46
  140. package/dist/client/hooks/use-global-meta.mjs +9 -30
  141. package/dist/client/hooks/use-global-schema.mjs +9 -30
  142. package/dist/client/hooks/use-global.mjs +63 -219
  143. package/dist/client/hooks/use-locks.mjs +117 -325
  144. package/dist/client/hooks/use-media-query.mjs +16 -36
  145. package/dist/client/hooks/use-prefill-params.mjs +0 -1
  146. package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
  147. package/dist/client/hooks/use-reactive-fields.mjs +1 -1
  148. package/dist/client/hooks/use-reactive-prop.mjs +65 -223
  149. package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
  150. package/dist/client/hooks/use-saved-views.mjs +22 -103
  151. package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
  152. package/dist/client/hooks/use-search.mjs +31 -143
  153. package/dist/client/hooks/use-server-actions.mjs +18 -50
  154. package/dist/client/hooks/use-server-validation.mjs +72 -166
  155. package/dist/client/hooks/use-server-widget-data.mjs +7 -33
  156. package/dist/client/hooks/use-setup-status.mjs +12 -25
  157. package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
  158. package/dist/client/hooks/use-transition-stage.mjs +8 -38
  159. package/dist/client/hooks/use-upload.mjs +54 -152
  160. package/dist/client/hooks/use-validation-error-map.mjs +6 -26
  161. package/dist/client/hooks/use-view-state.mjs +187 -437
  162. package/dist/client/i18n/hooks.mjs +65 -197
  163. package/dist/client/lib/render-profiler.mjs +14 -41
  164. package/dist/client/preview/block-scope-context.d.mts +2 -2
  165. package/dist/client/preview/block-scope-context.mjs +14 -36
  166. package/dist/client/preview/diff.mjs +110 -0
  167. package/dist/client/preview/preview-banner.mjs +42 -108
  168. package/dist/client/preview/preview-field.d.mts +4 -4
  169. package/dist/client/preview/preview-field.mjs +166 -409
  170. package/dist/client/preview/use-collection-preview.mjs +135 -201
  171. package/dist/client/runtime/content-locales-provider.mjs +31 -83
  172. package/dist/client/runtime/locale-scope.mjs +22 -63
  173. package/dist/client/runtime/provider.mjs +100 -255
  174. package/dist/client/runtime/translations-provider.mjs +41 -107
  175. package/dist/client/scope/picker.d.mts +2 -2
  176. package/dist/client/scope/picker.mjs +86 -321
  177. package/dist/client/scope/provider.d.mts +2 -2
  178. package/dist/client/scope/provider.mjs +8 -17
  179. package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
  180. package/dist/client/views/auth/accept-invite-form.mjs +121 -412
  181. package/dist/client/views/auth/auth-layout.d.mts +3 -3
  182. package/dist/client/views/auth/auth-layout.mjs +104 -284
  183. package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
  184. package/dist/client/views/auth/forgot-password-form.mjs +94 -325
  185. package/dist/client/views/auth/invite-form.mjs +107 -442
  186. package/dist/client/views/auth/login-form.d.mts +2 -2
  187. package/dist/client/views/auth/login-form.mjs +116 -337
  188. package/dist/client/views/auth/reset-password-form.mjs +128 -453
  189. package/dist/client/views/auth/setup-form.mjs +140 -478
  190. package/dist/client/views/collection/auto-form-fields.mjs +243 -615
  191. package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -400
  192. package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
  193. package/dist/client/views/collection/cells/primitive-cells.mjs +109 -363
  194. package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
  195. package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
  196. package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
  197. package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
  198. package/dist/client/views/collection/columns/build-columns.mjs +8 -48
  199. package/dist/client/views/collection/field-renderer.mjs +11 -24
  200. package/dist/client/views/collection/form-view.mjs +288 -560
  201. package/dist/client/views/collection/table-view.mjs +239 -469
  202. package/dist/client/views/collection/view-skeletons.mjs +112 -237
  203. package/dist/client/views/common/global-search.mjs +241 -543
  204. package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
  205. package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
  206. package/dist/client/views/dashboard/widget-card.mjs +61 -269
  207. package/dist/client/views/globals/global-form-view.mjs +478 -1298
  208. package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
  209. package/dist/client/views/layout/admin-layout.mjs +83 -246
  210. package/dist/client/views/layout/admin-router.mjs +457 -1289
  211. package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
  212. package/dist/client/views/layout/admin-theme.mjs +30 -64
  213. package/dist/client/views/layout/admin-view-layout.mjs +40 -144
  214. package/dist/client/views/pages/accept-invite-page.mjs +95 -290
  215. package/dist/client/views/pages/dashboard-page.mjs +11 -57
  216. package/dist/client/views/pages/forgot-password-page.mjs +31 -83
  217. package/dist/client/views/pages/invite-page.mjs +35 -90
  218. package/dist/client/views/pages/login-page.mjs +41 -121
  219. package/dist/client/views/pages/reset-password-page.d.mts +2 -2
  220. package/dist/client/views/pages/reset-password-page.mjs +46 -173
  221. package/dist/client/views/pages/setup-page.d.mts +2 -2
  222. package/dist/client/views/pages/setup-page.mjs +33 -95
  223. package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
  224. package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
  225. package/dist/server/modules/admin/collections/account.d.mts +50 -50
  226. package/dist/server/modules/admin/collections/admin-locks.d.mts +54 -54
  227. package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
  228. package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
  229. package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
  230. package/dist/server/modules/admin/collections/assets.d.mts +34 -34
  231. package/dist/server/modules/admin/collections/session.d.mts +42 -42
  232. package/dist/server/modules/admin/collections/user.d.mts +53 -53
  233. package/dist/server/modules/admin/collections/verification.d.mts +36 -36
  234. package/dist/server/modules/admin/index.d.mts +21 -20
  235. package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
  236. package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
  237. package/dist/server/modules/admin/routes/locales.d.mts +2 -2
  238. package/dist/server/modules/admin/routes/preview.d.mts +11 -11
  239. package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
  240. package/dist/server/modules/admin/routes/setup.d.mts +7 -7
  241. package/dist/server/modules/admin/routes/translations.d.mts +4 -4
  242. package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
  243. package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +27 -27
  244. package/package.json +3 -5
@@ -7,7 +7,6 @@ import { useCollectionList } from "../../hooks/use-collection.mjs";
7
7
  import { useUploadCollection } from "../../hooks/use-upload-collection.mjs";
8
8
  import { AssetPreview } from "../primitives/asset-preview.mjs";
9
9
  import { MediaGrid } from "./media-grid.mjs";
10
- import { c } from "react/compiler-runtime";
11
10
  import { Icon } from "@iconify/react";
12
11
  import * as React from "react";
13
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -64,511 +63,195 @@ const MIME_TYPE_FILTERS = [
64
63
  mimePattern: "application/pdf"
65
64
  }
66
65
  ];
67
- function MediaPickerDialog(t0) {
68
- const $ = c(116);
69
- const { open, onOpenChange, mode: t1, accept, onSelect, maxItems, collection } = t0;
70
- const mode = t1 === void 0 ? "single" : t1;
66
+ function MediaPickerDialog({ open, onOpenChange, mode = "single", accept, onSelect, maxItems, collection }) {
71
67
  const { t } = useTranslation();
72
68
  const { collection: resolvedCollection, collections: availableUploadCollections } = useUploadCollection(collection);
73
- let t2;
74
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
75
- t2 = /* @__PURE__ */ new Set();
76
- $[0] = t2;
77
- } else t2 = $[0];
78
- const [selectedIds, setSelectedIds] = React.useState(t2);
69
+ const [selectedIds, setSelectedIds] = React.useState(/* @__PURE__ */ new Set());
79
70
  const [searchQuery, setSearchQuery] = React.useState("");
80
71
  const [mimeFilter, setMimeFilter] = React.useState("all");
81
72
  const [previewAssetId, setPreviewAssetId] = React.useState(null);
82
- let t3;
83
- bb0: {
84
- let andConditions;
85
- if ($[1] !== accept || $[2] !== mimeFilter) {
86
- andConditions = [];
87
- let t4$2;
88
- if ($[4] !== mimeFilter) {
89
- t4$2 = MIME_TYPE_FILTERS.find((f) => f.value === mimeFilter);
90
- $[4] = mimeFilter;
91
- $[5] = t4$2;
92
- } else t4$2 = $[5];
93
- const selectedFilter = t4$2;
94
- if (selectedFilter?.mimePattern) {
95
- let t5$1;
96
- if ($[6] !== selectedFilter.mimePattern) {
97
- t5$1 = { mimeType: { startsWith: selectedFilter.mimePattern } };
98
- $[6] = selectedFilter.mimePattern;
99
- $[7] = t5$1;
100
- } else t5$1 = $[7];
101
- andConditions.push(t5$1);
102
- }
103
- if (accept && accept.length > 0) {
104
- let t5$1;
105
- if ($[8] !== accept) {
106
- t5$1 = accept.map(_temp);
107
- $[8] = accept;
108
- $[9] = t5$1;
109
- } else t5$1 = $[9];
110
- const acceptPatterns = t5$1;
111
- if (acceptPatterns.length === 1) andConditions.push(acceptPatterns[0]);
112
- else {
113
- let t6$1;
114
- if ($[10] !== acceptPatterns) {
115
- t6$1 = { OR: acceptPatterns };
116
- $[10] = acceptPatterns;
117
- $[11] = t6$1;
118
- } else t6$1 = $[11];
119
- andConditions.push(t6$1);
120
- }
121
- }
122
- $[1] = accept;
123
- $[2] = mimeFilter;
124
- $[3] = andConditions;
125
- } else andConditions = $[3];
126
- if (andConditions.length === 0) {
127
- t3 = void 0;
128
- break bb0;
73
+ const where = React.useMemo(() => {
74
+ const andConditions = [];
75
+ const selectedFilter = MIME_TYPE_FILTERS.find((f) => f.value === mimeFilter);
76
+ if (selectedFilter?.mimePattern) andConditions.push({ mimeType: { startsWith: selectedFilter.mimePattern } });
77
+ if (accept && accept.length > 0) {
78
+ const acceptPatterns = accept.map((pattern) => {
79
+ if (pattern.startsWith(".")) return { filename: { endsWith: pattern } };
80
+ if (pattern.endsWith("/*")) return { mimeType: { startsWith: pattern.slice(0, -1) } };
81
+ return { mimeType: pattern };
82
+ });
83
+ if (acceptPatterns.length === 1) andConditions.push(acceptPatterns[0]);
84
+ else andConditions.push({ OR: acceptPatterns });
129
85
  }
130
- if (andConditions.length === 1) {
131
- t3 = andConditions[0];
132
- break bb0;
86
+ if (andConditions.length === 0) return void 0;
87
+ if (andConditions.length === 1) return andConditions[0];
88
+ return { AND: andConditions };
89
+ }, [mimeFilter, accept]);
90
+ const trimmedSearch = searchQuery.trim();
91
+ const { data, isLoading } = useCollectionList(resolvedCollection || "", {
92
+ where,
93
+ search: trimmedSearch || void 0,
94
+ limit: 50,
95
+ orderBy: { createdAt: "desc" }
96
+ }, { enabled: open && !!resolvedCollection });
97
+ const assets = React.useMemo(() => data?.docs || [], [data?.docs]);
98
+ const previewAsset = React.useMemo(() => {
99
+ if (!open || assets.length === 0) return null;
100
+ return assets.find((asset) => asset.id === previewAssetId) ?? assets[0];
101
+ }, [
102
+ assets,
103
+ open,
104
+ previewAssetId
105
+ ]);
106
+ const selectedMimeFilterLabel = React.useMemo(() => {
107
+ return t((MIME_TYPE_FILTERS.find((filter) => filter.value === mimeFilter) ?? MIME_TYPE_FILTERS[0]).labelKey);
108
+ }, [mimeFilter, t]);
109
+ const resetPickerState = React.useCallback(() => {
110
+ setSelectedIds(/* @__PURE__ */ new Set());
111
+ setSearchQuery("");
112
+ setMimeFilter("all");
113
+ setPreviewAssetId(null);
114
+ }, []);
115
+ const handleOpenChange = React.useCallback((nextOpen) => {
116
+ if (!nextOpen) resetPickerState();
117
+ onOpenChange(nextOpen);
118
+ }, [onOpenChange, resetPickerState]);
119
+ const handleSelectionChange = (ids) => {
120
+ if (mode === "multiple" && maxItems && ids.size > maxItems) {
121
+ toast.warning(t("error.maxItemsAllowed", { max: maxItems }));
122
+ return;
133
123
  }
134
- let t4$1;
135
- if ($[12] !== andConditions) {
136
- t4$1 = { AND: andConditions };
137
- $[12] = andConditions;
138
- $[13] = t4$1;
139
- } else t4$1 = $[13];
140
- t3 = t4$1;
141
- }
142
- const where = t3;
143
- let t4;
144
- if ($[14] !== searchQuery) {
145
- t4 = searchQuery.trim();
146
- $[14] = searchQuery;
147
- $[15] = t4;
148
- } else t4 = $[15];
149
- const t5 = t4 || void 0;
150
- let t6;
151
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
152
- t6 = { createdAt: "desc" };
153
- $[16] = t6;
154
- } else t6 = $[16];
155
- let t7;
156
- if ($[17] !== t5 || $[18] !== where) {
157
- t7 = {
158
- where,
159
- search: t5,
160
- limit: 50,
161
- orderBy: t6
162
- };
163
- $[17] = t5;
164
- $[18] = where;
165
- $[19] = t7;
166
- } else t7 = $[19];
167
- const t8 = open && !!resolvedCollection;
168
- let t9;
169
- if ($[20] !== t8) {
170
- t9 = { enabled: t8 };
171
- $[20] = t8;
172
- $[21] = t9;
173
- } else t9 = $[21];
174
- const { data, isLoading } = useCollectionList(resolvedCollection || "", t7, t9);
175
- data?.docs;
176
- let t10;
177
- if ($[22] !== data?.docs) {
178
- t10 = data?.docs || [];
179
- $[22] = data?.docs;
180
- $[23] = t10;
181
- } else t10 = $[23];
182
- const assets = t10;
183
- let t11;
184
- if ($[24] !== assets || $[25] !== previewAssetId) {
185
- t11 = assets.find((asset) => asset.id === previewAssetId) ?? null;
186
- $[24] = assets;
187
- $[25] = previewAssetId;
188
- $[26] = t11;
189
- } else t11 = $[26];
190
- const previewAsset = t11;
191
- let t12;
192
- if ($[27] !== mimeFilter || $[28] !== t) {
193
- t12 = t((MIME_TYPE_FILTERS.find((filter) => filter.value === mimeFilter) ?? MIME_TYPE_FILTERS[0]).labelKey);
194
- $[27] = mimeFilter;
195
- $[28] = t;
196
- $[29] = t12;
197
- } else t12 = $[29];
198
- const selectedMimeFilterLabel = t12;
199
- let t13;
200
- let t14;
201
- if ($[30] !== open) {
202
- t13 = () => {
203
- if (!open) {
204
- setSelectedIds(/* @__PURE__ */ new Set());
205
- setSearchQuery("");
206
- setMimeFilter("all");
207
- setPreviewAssetId(null);
208
- return;
209
- }
210
- };
211
- t14 = [open];
212
- $[30] = open;
213
- $[31] = t13;
214
- $[32] = t14;
215
- } else {
216
- t13 = $[31];
217
- t14 = $[32];
218
- }
219
- React.useEffect(t13, t14);
220
- let t15;
221
- let t16;
222
- if ($[33] !== assets || $[34] !== open || $[35] !== previewAssetId) {
223
- t15 = () => {
224
- if (!open || assets.length === 0) return;
225
- if (!previewAssetId) {
226
- setPreviewAssetId(assets[0].id);
227
- return;
228
- }
229
- if (!assets.some((asset_0) => asset_0.id === previewAssetId)) setPreviewAssetId(assets[0].id);
230
- };
231
- t16 = [
232
- open,
233
- assets,
234
- previewAssetId
235
- ];
236
- $[33] = assets;
237
- $[34] = open;
238
- $[35] = previewAssetId;
239
- $[36] = t15;
240
- $[37] = t16;
241
- } else {
242
- t15 = $[36];
243
- t16 = $[37];
244
- }
245
- React.useEffect(t15, t16);
246
- let t17;
247
- if ($[38] !== maxItems || $[39] !== mode || $[40] !== t) {
248
- t17 = (ids) => {
249
- if (mode === "multiple" && maxItems && ids.size > maxItems) {
250
- toast.warning(t("error.maxItemsAllowed", { max: maxItems }));
251
- return;
252
- }
253
- setSelectedIds(ids);
254
- };
255
- $[38] = maxItems;
256
- $[39] = mode;
257
- $[40] = t;
258
- $[41] = t17;
259
- } else t17 = $[41];
260
- const handleSelectionChange = t17;
261
- let t18;
262
- if ($[42] !== availableUploadCollections || $[43] !== mode || $[44] !== onOpenChange || $[45] !== onSelect || $[46] !== resolvedCollection || $[47] !== selectedIds || $[48] !== t) {
263
- t18 = () => {
264
- if (!resolvedCollection) {
265
- toast.error(availableUploadCollections.length > 1 ? `Multiple upload collections are available (${availableUploadCollections.join(", ")}). Specify the collection for MediaPickerDialog.` : "No upload collection is configured for media library.");
266
- return;
267
- }
268
- if (selectedIds.size === 0) {
269
- toast.error(t("error.selectAtLeastOne"));
270
- return;
271
- }
272
- if (mode === "single") {
273
- const [id] = Array.from(selectedIds);
274
- onSelect(id);
275
- } else onSelect(Array.from(selectedIds));
276
- onOpenChange(false);
277
- };
278
- $[42] = availableUploadCollections;
279
- $[43] = mode;
280
- $[44] = onOpenChange;
281
- $[45] = onSelect;
282
- $[46] = resolvedCollection;
283
- $[47] = selectedIds;
284
- $[48] = t;
285
- $[49] = t18;
286
- } else t18 = $[49];
287
- const handleSelect = t18;
288
- let t19;
289
- if ($[50] !== onOpenChange) {
290
- t19 = () => {
291
- onOpenChange(false);
292
- };
293
- $[50] = onOpenChange;
294
- $[51] = t19;
295
- } else t19 = $[51];
296
- const handleCancel = t19;
297
- let t20;
298
- if ($[52] !== t) {
299
- t20 = t("media.browseLibrary");
300
- $[52] = t;
301
- $[53] = t20;
302
- } else t20 = $[53];
303
- let t21;
304
- if ($[54] !== t20) {
305
- t21 = /* @__PURE__ */ jsx(SheetTitle, { children: t20 });
306
- $[54] = t20;
307
- $[55] = t21;
308
- } else t21 = $[55];
309
- const t22 = mode === "single" ? "Select an asset from your library" : `Select up to ${maxItems || "multiple"} assets`;
310
- let t23;
311
- if ($[56] !== t22) {
312
- t23 = /* @__PURE__ */ jsx(SheetDescription, { children: t22 });
313
- $[56] = t22;
314
- $[57] = t23;
315
- } else t23 = $[57];
316
- let t24;
317
- if ($[58] !== t21 || $[59] !== t23) {
318
- t24 = /* @__PURE__ */ jsxs(SheetHeader, {
319
- className: "px-6 pt-6",
320
- children: [t21, t23]
321
- });
322
- $[58] = t21;
323
- $[59] = t23;
324
- $[60] = t24;
325
- } else t24 = $[60];
326
- let t25;
327
- if ($[61] !== availableUploadCollections || $[62] !== resolvedCollection) {
328
- t25 = !resolvedCollection && /* @__PURE__ */ jsx("div", {
329
- className: "border-warning/40 bg-warning/5 text-warning border p-3 text-sm",
330
- children: availableUploadCollections.length > 1 ? `Multiple upload collections are available (${availableUploadCollections.join(", ")}). Pass the collection prop to choose one.` : "No upload collection is configured for media library."
331
- });
332
- $[61] = availableUploadCollections;
333
- $[62] = resolvedCollection;
334
- $[63] = t25;
335
- } else t25 = $[63];
336
- let t26;
337
- if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
338
- t26 = /* @__PURE__ */ jsx(Icon, {
339
- icon: "ph:magnifying-glass-bold",
340
- className: "text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"
341
- });
342
- $[64] = t26;
343
- } else t26 = $[64];
344
- let t27;
345
- if ($[65] !== t) {
346
- t27 = t("media.searchPlaceholder");
347
- $[65] = t;
348
- $[66] = t27;
349
- } else t27 = $[66];
350
- let t28;
351
- if ($[67] === Symbol.for("react.memo_cache_sentinel")) {
352
- t28 = (e) => setSearchQuery(e.target.value);
353
- $[67] = t28;
354
- } else t28 = $[67];
355
- let t29;
356
- if ($[68] !== searchQuery || $[69] !== t27) {
357
- t29 = /* @__PURE__ */ jsxs("div", {
358
- className: "relative flex-1",
359
- children: [t26, /* @__PURE__ */ jsx(Input, {
360
- type: "text",
361
- placeholder: t27,
362
- value: searchQuery,
363
- onChange: t28,
364
- className: "pl-9"
365
- })]
366
- });
367
- $[68] = searchQuery;
368
- $[69] = t27;
369
- $[70] = t29;
370
- } else t29 = $[70];
371
- let t30;
372
- if ($[71] !== accept || $[72] !== mimeFilter || $[73] !== selectedMimeFilterLabel || $[74] !== t) {
373
- t30 = !accept && /* @__PURE__ */ jsxs(Select, {
374
- value: mimeFilter,
375
- onValueChange: (value) => setMimeFilter(value || "all"),
376
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
377
- className: "w-full sm:w-[180px]",
378
- children: /* @__PURE__ */ jsxs("div", {
379
- className: "flex items-center gap-2",
380
- children: [/* @__PURE__ */ jsx(Icon, {
381
- icon: "ph:funnel-simple-bold",
382
- className: "size-4"
383
- }), /* @__PURE__ */ jsx(SelectValue, { children: selectedMimeFilterLabel })]
384
- })
385
- }), /* @__PURE__ */ jsx(SelectContent, { children: MIME_TYPE_FILTERS.map((filter_0) => /* @__PURE__ */ jsx(SelectItem, {
386
- value: filter_0.value,
387
- children: t(filter_0.labelKey)
388
- }, filter_0.value)) })]
389
- });
390
- $[71] = accept;
391
- $[72] = mimeFilter;
392
- $[73] = selectedMimeFilterLabel;
393
- $[74] = t;
394
- $[75] = t30;
395
- } else t30 = $[75];
396
- let t31;
397
- if ($[76] !== t29 || $[77] !== t30) {
398
- t31 = /* @__PURE__ */ jsxs("div", {
399
- className: "flex flex-col gap-3 border-b pb-4 sm:flex-row",
400
- children: [t29, t30]
401
- });
402
- $[76] = t29;
403
- $[77] = t30;
404
- $[78] = t31;
405
- } else t31 = $[78];
406
- let t32;
407
- if ($[79] === Symbol.for("react.memo_cache_sentinel")) {
408
- t32 = (asset_1) => setPreviewAssetId(asset_1.id);
409
- $[79] = t32;
410
- } else t32 = $[79];
411
- let t33;
412
- if ($[80] !== assets || $[81] !== handleSelectionChange || $[82] !== isLoading || $[83] !== mode || $[84] !== selectedIds) {
413
- t33 = /* @__PURE__ */ jsx("div", {
414
- className: "flex-1 overflow-y-auto pr-1",
415
- children: /* @__PURE__ */ jsx(MediaGrid, {
416
- assets,
417
- selectedIds,
418
- onSelectionChange: handleSelectionChange,
419
- selectionMode: mode,
420
- loading: isLoading,
421
- columns: 5,
422
- className: "gap-2",
423
- onAssetClick: t32
424
- })
425
- });
426
- $[80] = assets;
427
- $[81] = handleSelectionChange;
428
- $[82] = isLoading;
429
- $[83] = mode;
430
- $[84] = selectedIds;
431
- $[85] = t33;
432
- } else t33 = $[85];
433
- let t34;
434
- if ($[86] === Symbol.for("react.memo_cache_sentinel")) {
435
- t34 = /* @__PURE__ */ jsx("p", {
436
- className: "text-muted-foreground font-chrome chrome-meta text-xs font-medium",
437
- children: "Preview"
438
- });
439
- $[86] = t34;
440
- } else t34 = $[86];
441
- let t35;
442
- if ($[87] !== previewAsset) {
443
- t35 = /* @__PURE__ */ jsxs("div", {
444
- className: "border-border hidden w-80 shrink-0 flex-col gap-3 border-l pl-4 lg:flex xl:w-96",
445
- children: [t34, previewAsset ? /* @__PURE__ */ jsx(AssetPreview, {
446
- asset: previewAsset,
447
- variant: "card"
448
- }) : /* @__PURE__ */ jsx("div", {
449
- className: "text-muted-foreground flex min-h-24 items-center justify-center p-4 text-sm",
450
- children: "Select an asset to preview"
451
- })]
452
- });
453
- $[87] = previewAsset;
454
- $[88] = t35;
455
- } else t35 = $[88];
456
- let t36;
457
- if ($[89] !== t33 || $[90] !== t35) {
458
- t36 = /* @__PURE__ */ jsxs("div", {
459
- className: "flex flex-1 gap-4 overflow-hidden",
460
- children: [t33, t35]
461
- });
462
- $[89] = t33;
463
- $[90] = t35;
464
- $[91] = t36;
465
- } else t36 = $[91];
466
- let t37;
467
- if ($[92] !== previewAsset) {
468
- t37 = /* @__PURE__ */ jsx("div", {
469
- className: "border-t pt-4 lg:hidden",
470
- children: previewAsset ? /* @__PURE__ */ jsx(AssetPreview, {
471
- asset: previewAsset,
472
- variant: "compact"
473
- }) : /* @__PURE__ */ jsx("div", {
474
- className: "text-muted-foreground flex min-h-16 items-center justify-center p-2 text-sm",
475
- children: "Select an asset to preview"
476
- })
477
- });
478
- $[92] = previewAsset;
479
- $[93] = t37;
480
- } else t37 = $[93];
481
- let t38;
482
- if ($[94] !== t25 || $[95] !== t31 || $[96] !== t36 || $[97] !== t37) {
483
- t38 = /* @__PURE__ */ jsxs("div", {
484
- className: "flex flex-1 flex-col gap-4 overflow-hidden px-6 pb-6",
485
- children: [
486
- t25,
487
- t31,
488
- t36,
489
- t37
490
- ]
491
- });
492
- $[94] = t25;
493
- $[95] = t31;
494
- $[96] = t36;
495
- $[97] = t37;
496
- $[98] = t38;
497
- } else t38 = $[98];
498
- let t39;
499
- if ($[99] !== handleCancel) {
500
- t39 = /* @__PURE__ */ jsx(Button, {
501
- variant: "outline",
502
- onClick: handleCancel,
503
- children: "Cancel"
504
- });
505
- $[99] = handleCancel;
506
- $[100] = t39;
507
- } else t39 = $[100];
508
- const t40 = selectedIds.size === 0 || isLoading;
509
- const t41 = selectedIds.size > 0 && `(${selectedIds.size})`;
510
- let t42;
511
- if ($[101] !== handleSelect || $[102] !== t40 || $[103] !== t41) {
512
- t42 = /* @__PURE__ */ jsxs(Button, {
513
- className: "tabular-nums",
514
- onClick: handleSelect,
515
- disabled: t40,
516
- children: ["Select ", t41]
517
- });
518
- $[101] = handleSelect;
519
- $[102] = t40;
520
- $[103] = t41;
521
- $[104] = t42;
522
- } else t42 = $[104];
523
- let t43;
524
- if ($[105] !== t39 || $[106] !== t42) {
525
- t43 = /* @__PURE__ */ jsx(SheetFooter, {
526
- className: "border-t px-6 py-4",
527
- children: /* @__PURE__ */ jsxs("div", {
528
- className: "flex w-full justify-end gap-2",
529
- children: [t39, t42]
530
- })
531
- });
532
- $[105] = t39;
533
- $[106] = t42;
534
- $[107] = t43;
535
- } else t43 = $[107];
536
- let t44;
537
- if ($[108] !== t24 || $[109] !== t38 || $[110] !== t43) {
538
- t44 = /* @__PURE__ */ jsxs(SheetContent, {
124
+ setSelectedIds(ids);
125
+ };
126
+ const handleSelect = () => {
127
+ if (!resolvedCollection) {
128
+ toast.error(availableUploadCollections.length > 1 ? `Multiple upload collections are available (${availableUploadCollections.join(", ")}). Specify the collection for MediaPickerDialog.` : "No upload collection is configured for media library.");
129
+ return;
130
+ }
131
+ if (selectedIds.size === 0) {
132
+ toast.error(t("error.selectAtLeastOne"));
133
+ return;
134
+ }
135
+ if (mode === "single") {
136
+ const [id] = Array.from(selectedIds);
137
+ onSelect(id, assets.find((candidate) => candidate.id === id));
138
+ } else onSelect(Array.from(selectedIds), assets.filter((asset) => selectedIds.has(asset.id)));
139
+ handleOpenChange(false);
140
+ };
141
+ const handleCancel = () => {
142
+ handleOpenChange(false);
143
+ };
144
+ return /* @__PURE__ */ jsx(Sheet, {
145
+ open,
146
+ onOpenChange: handleOpenChange,
147
+ modal: false,
148
+ children: /* @__PURE__ */ jsxs(SheetContent, {
539
149
  side: "right",
540
150
  showOverlay: false,
541
151
  className: "qa-media-picker w-full p-0 data-[side=right]:sm:max-w-6xl",
542
152
  children: [
543
- t24,
544
- t38,
545
- t43
153
+ /* @__PURE__ */ jsxs(SheetHeader, {
154
+ className: "px-6 pt-6",
155
+ children: [/* @__PURE__ */ jsx(SheetTitle, { children: t("media.browseLibrary") }), /* @__PURE__ */ jsx(SheetDescription, { children: mode === "single" ? "Select an asset from your library" : `Select up to ${maxItems || "multiple"} assets` })]
156
+ }),
157
+ /* @__PURE__ */ jsxs("div", {
158
+ className: "flex flex-1 flex-col gap-4 overflow-hidden px-6 pb-6",
159
+ children: [
160
+ !resolvedCollection && /* @__PURE__ */ jsx("div", {
161
+ className: "border-warning/40 bg-warning/5 text-warning border p-3 text-sm",
162
+ children: availableUploadCollections.length > 1 ? `Multiple upload collections are available (${availableUploadCollections.join(", ")}). Pass the collection prop to choose one.` : "No upload collection is configured for media library."
163
+ }),
164
+ /* @__PURE__ */ jsxs("div", {
165
+ className: "flex flex-col gap-3 border-b pb-4 sm:flex-row",
166
+ children: [/* @__PURE__ */ jsxs("div", {
167
+ className: "relative flex-1",
168
+ children: [/* @__PURE__ */ jsx(Icon, {
169
+ icon: "ph:magnifying-glass-bold",
170
+ className: "text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"
171
+ }), /* @__PURE__ */ jsx(Input, {
172
+ type: "text",
173
+ placeholder: t("media.searchPlaceholder"),
174
+ value: searchQuery,
175
+ onChange: (e) => setSearchQuery(e.target.value),
176
+ className: "pl-9"
177
+ })]
178
+ }), !accept && /* @__PURE__ */ jsxs(Select, {
179
+ value: mimeFilter,
180
+ onValueChange: (value) => setMimeFilter(value || "all"),
181
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
182
+ className: "w-full sm:w-[180px]",
183
+ children: /* @__PURE__ */ jsxs("div", {
184
+ className: "flex items-center gap-2",
185
+ children: [/* @__PURE__ */ jsx(Icon, {
186
+ icon: "ph:funnel-simple-bold",
187
+ className: "size-4"
188
+ }), /* @__PURE__ */ jsx(SelectValue, { children: selectedMimeFilterLabel })]
189
+ })
190
+ }), /* @__PURE__ */ jsx(SelectContent, { children: MIME_TYPE_FILTERS.map((filter) => /* @__PURE__ */ jsx(SelectItem, {
191
+ value: filter.value,
192
+ children: t(filter.labelKey)
193
+ }, filter.value)) })]
194
+ })]
195
+ }),
196
+ /* @__PURE__ */ jsxs("div", {
197
+ className: "flex flex-1 gap-4 overflow-hidden",
198
+ children: [/* @__PURE__ */ jsx("div", {
199
+ className: "flex-1 overflow-y-auto pr-1",
200
+ children: /* @__PURE__ */ jsx(MediaGrid, {
201
+ assets,
202
+ selectedIds,
203
+ onSelectionChange: handleSelectionChange,
204
+ selectionMode: mode,
205
+ loading: isLoading,
206
+ columns: 5,
207
+ className: "gap-2",
208
+ onAssetClick: (asset) => setPreviewAssetId(asset.id)
209
+ })
210
+ }), /* @__PURE__ */ jsxs("div", {
211
+ className: "border-border hidden w-80 shrink-0 flex-col gap-3 border-l pl-4 lg:flex xl:w-96",
212
+ children: [/* @__PURE__ */ jsx("p", {
213
+ className: "text-muted-foreground font-chrome chrome-meta text-xs font-medium",
214
+ children: "Preview"
215
+ }), previewAsset ? /* @__PURE__ */ jsx(AssetPreview, {
216
+ asset: previewAsset,
217
+ variant: "card"
218
+ }) : /* @__PURE__ */ jsx("div", {
219
+ className: "text-muted-foreground flex min-h-24 items-center justify-center p-4 text-sm",
220
+ children: "Select an asset to preview"
221
+ })]
222
+ })]
223
+ }),
224
+ /* @__PURE__ */ jsx("div", {
225
+ className: "border-t pt-4 lg:hidden",
226
+ children: previewAsset ? /* @__PURE__ */ jsx(AssetPreview, {
227
+ asset: previewAsset,
228
+ variant: "compact"
229
+ }) : /* @__PURE__ */ jsx("div", {
230
+ className: "text-muted-foreground flex min-h-16 items-center justify-center p-2 text-sm",
231
+ children: "Select an asset to preview"
232
+ })
233
+ })
234
+ ]
235
+ }),
236
+ /* @__PURE__ */ jsx(SheetFooter, {
237
+ className: "border-t px-6 py-4",
238
+ children: /* @__PURE__ */ jsxs("div", {
239
+ className: "flex w-full justify-end gap-2",
240
+ children: [/* @__PURE__ */ jsx(Button, {
241
+ variant: "outline",
242
+ onClick: handleCancel,
243
+ children: "Cancel"
244
+ }), /* @__PURE__ */ jsxs(Button, {
245
+ className: "tabular-nums",
246
+ onClick: handleSelect,
247
+ disabled: selectedIds.size === 0 || isLoading,
248
+ children: ["Select ", selectedIds.size > 0 && `(${selectedIds.size})`]
249
+ })]
250
+ })
251
+ })
546
252
  ]
547
- });
548
- $[108] = t24;
549
- $[109] = t38;
550
- $[110] = t43;
551
- $[111] = t44;
552
- } else t44 = $[111];
553
- let t45;
554
- if ($[112] !== onOpenChange || $[113] !== open || $[114] !== t44) {
555
- t45 = /* @__PURE__ */ jsx(Sheet, {
556
- open,
557
- onOpenChange,
558
- modal: false,
559
- children: t44
560
- });
561
- $[112] = onOpenChange;
562
- $[113] = open;
563
- $[114] = t44;
564
- $[115] = t45;
565
- } else t45 = $[115];
566
- return t45;
567
- }
568
- function _temp(pattern) {
569
- if (pattern.startsWith(".")) return { filename: { endsWith: pattern } };
570
- if (pattern.endsWith("/*")) return { mimeType: { startsWith: pattern.slice(0, -1) } };
571
- return { mimeType: pattern };
253
+ })
254
+ });
572
255
  }
573
256
 
574
257
  //#endregion