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