@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
@@ -1,7 +1,6 @@
1
1
  import { useTranslation } from "../../i18n/hooks.mjs";
2
2
  import { cn } from "../../lib/utils.mjs";
3
3
  import { Button } from "../ui/button.mjs";
4
- import { c } from "react/compiler-runtime";
5
4
  import { Icon } from "@iconify/react";
6
5
  import * as React from "react";
7
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -47,354 +46,228 @@ function formatFileSize(bytes) {
47
46
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
48
47
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
49
48
  }
50
- function Dropzone(t0) {
51
- const $ = c(70);
52
- const { onDrop, accept, maxSize, multiple: t1, disabled: t2, loading: t3, progress, variant: t4, label, hint, error, className, children, action, onValidationError } = t0;
53
- const multiple = t1 === void 0 ? false : t1;
54
- const disabled = t2 === void 0 ? false : t2;
55
- const loading = t3 === void 0 ? false : t3;
56
- const variant = t4 === void 0 ? "panel" : t4;
49
+ function Dropzone({ onDrop, accept, maxSize, multiple = false, disabled = false, loading = false, progress, variant = "panel", label, hint, error, className, children, action, onValidationError }) {
57
50
  const { t } = useTranslation();
58
51
  const [isDragging, setIsDragging] = React.useState(false);
59
52
  const inputRef = React.useRef(null);
60
53
  const dragCounterRef = React.useRef(0);
61
- let t5;
62
- if ($[0] !== accept || $[1] !== maxSize || $[2] !== t) {
63
- t5 = (files) => {
64
- const valid = [];
65
- const errors = [];
66
- for (const file of files) {
67
- if (!matchesAccept(file, accept)) {
68
- errors.push({
69
- file,
70
- type: "type",
71
- message: t("dropzone.invalidType", { name: file.name })
72
- });
73
- continue;
74
- }
75
- if (maxSize && file.size > maxSize) {
76
- errors.push({
77
- file,
78
- type: "size",
79
- message: t("dropzone.tooLarge", {
80
- name: file.name,
81
- maxSize: formatFileSize(maxSize)
82
- })
83
- });
84
- continue;
85
- }
86
- valid.push(file);
54
+ /**
55
+ * Validate files and return valid ones + errors
56
+ */
57
+ const validateFiles = React.useCallback((files) => {
58
+ const valid = [];
59
+ const errors = [];
60
+ for (const file of files) {
61
+ if (!matchesAccept(file, accept)) {
62
+ errors.push({
63
+ file,
64
+ type: "type",
65
+ message: t("dropzone.invalidType", { name: file.name })
66
+ });
67
+ continue;
87
68
  }
88
- return {
89
- valid,
90
- errors
91
- };
92
- };
93
- $[0] = accept;
94
- $[1] = maxSize;
95
- $[2] = t;
96
- $[3] = t5;
97
- } else t5 = $[3];
98
- const validateFiles = t5;
99
- let t6;
100
- if ($[4] !== disabled || $[5] !== loading || $[6] !== multiple || $[7] !== onDrop || $[8] !== onValidationError || $[9] !== validateFiles) {
101
- t6 = (files_0) => {
102
- if (disabled || loading) return;
103
- const fileArray = Array.from(files_0);
104
- const { valid: valid_0, errors: errors_0 } = validateFiles(multiple ? fileArray : fileArray.slice(0, 1));
105
- if (errors_0.length > 0) onValidationError?.(errors_0);
106
- if (valid_0.length > 0) onDrop(valid_0);
107
- };
108
- $[4] = disabled;
109
- $[5] = loading;
110
- $[6] = multiple;
111
- $[7] = onDrop;
112
- $[8] = onValidationError;
113
- $[9] = validateFiles;
114
- $[10] = t6;
115
- } else t6 = $[10];
116
- const handleFiles = t6;
117
- let t7;
118
- if ($[11] !== disabled || $[12] !== loading) {
119
- t7 = (e) => {
120
- e.preventDefault();
121
- e.stopPropagation();
122
- dragCounterRef.current = dragCounterRef.current + 1;
123
- if (e.dataTransfer.items.length > 0 && !disabled && !loading) setIsDragging(true);
124
- };
125
- $[11] = disabled;
126
- $[12] = loading;
127
- $[13] = t7;
128
- } else t7 = $[13];
129
- const handleDragEnter = t7;
130
- let t8;
131
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
132
- t8 = (e_0) => {
133
- e_0.preventDefault();
134
- e_0.stopPropagation();
135
- dragCounterRef.current = dragCounterRef.current - 1;
136
- if (dragCounterRef.current === 0) setIsDragging(false);
137
- };
138
- $[14] = t8;
139
- } else t8 = $[14];
140
- const handleDragLeave = t8;
141
- const handleDragOver = _temp;
142
- let t9;
143
- if ($[15] !== handleFiles) {
144
- t9 = (e_2) => {
145
- e_2.preventDefault();
146
- e_2.stopPropagation();
147
- dragCounterRef.current = 0;
148
- setIsDragging(false);
149
- if (e_2.dataTransfer.files.length > 0) handleFiles(e_2.dataTransfer.files);
150
- };
151
- $[15] = handleFiles;
152
- $[16] = t9;
153
- } else t9 = $[16];
154
- const handleDrop = t9;
155
- let t10;
156
- if ($[17] !== disabled || $[18] !== loading) {
157
- t10 = () => {
158
- if (disabled || loading) return;
159
- inputRef.current?.click();
160
- };
161
- $[17] = disabled;
162
- $[18] = loading;
163
- $[19] = t10;
164
- } else t10 = $[19];
165
- const handleClick = t10;
166
- let t11;
167
- if ($[20] !== handleFiles) {
168
- t11 = (e_3) => {
169
- if (e_3.target.files && e_3.target.files.length > 0) handleFiles(e_3.target.files);
170
- e_3.target.value = "";
69
+ if (maxSize && file.size > maxSize) {
70
+ errors.push({
71
+ file,
72
+ type: "size",
73
+ message: t("dropzone.tooLarge", {
74
+ name: file.name,
75
+ maxSize: formatFileSize(maxSize)
76
+ })
77
+ });
78
+ continue;
79
+ }
80
+ valid.push(file);
81
+ }
82
+ return {
83
+ valid,
84
+ errors
171
85
  };
172
- $[20] = handleFiles;
173
- $[21] = t11;
174
- } else t11 = $[21];
175
- const handleInputChange = t11;
176
- let t12;
177
- if ($[22] !== accept) {
178
- t12 = accept?.join(",") || void 0;
179
- $[22] = accept;
180
- $[23] = t12;
181
- } else t12 = $[23];
182
- const acceptString = t12;
86
+ }, [
87
+ accept,
88
+ maxSize,
89
+ t
90
+ ]);
91
+ /**
92
+ * Handle file selection
93
+ */
94
+ const handleFiles = React.useCallback((files) => {
95
+ if (disabled || loading) return;
96
+ const fileArray = Array.from(files);
97
+ const { valid, errors } = validateFiles(multiple ? fileArray : fileArray.slice(0, 1));
98
+ if (errors.length > 0) onValidationError?.(errors);
99
+ if (valid.length > 0) onDrop(valid);
100
+ }, [
101
+ disabled,
102
+ loading,
103
+ multiple,
104
+ validateFiles,
105
+ onDrop,
106
+ onValidationError
107
+ ]);
108
+ /**
109
+ * Handle drag events
110
+ */
111
+ const handleDragEnter = React.useCallback((e) => {
112
+ e.preventDefault();
113
+ e.stopPropagation();
114
+ dragCounterRef.current += 1;
115
+ if (e.dataTransfer.items.length > 0 && !disabled && !loading) setIsDragging(true);
116
+ }, [disabled, loading]);
117
+ const handleDragLeave = React.useCallback((e) => {
118
+ e.preventDefault();
119
+ e.stopPropagation();
120
+ dragCounterRef.current -= 1;
121
+ if (dragCounterRef.current === 0) setIsDragging(false);
122
+ }, []);
123
+ const handleDragOver = React.useCallback((e) => {
124
+ e.preventDefault();
125
+ e.stopPropagation();
126
+ }, []);
127
+ const handleDrop = React.useCallback((e) => {
128
+ e.preventDefault();
129
+ e.stopPropagation();
130
+ dragCounterRef.current = 0;
131
+ setIsDragging(false);
132
+ if (e.dataTransfer.files.length > 0) handleFiles(e.dataTransfer.files);
133
+ }, [handleFiles]);
134
+ /**
135
+ * Handle click to open file dialog
136
+ */
137
+ const handleClick = React.useCallback(() => {
138
+ if (disabled || loading) return;
139
+ inputRef.current?.click();
140
+ }, [disabled, loading]);
141
+ /**
142
+ * Handle file input change
143
+ */
144
+ const handleInputChange = React.useCallback((e) => {
145
+ if (e.target.files && e.target.files.length > 0) handleFiles(e.target.files);
146
+ e.target.value = "";
147
+ }, [handleFiles]);
148
+ /**
149
+ * Build accept string for input
150
+ */
151
+ const acceptString = accept?.join(",") || void 0;
183
152
  const isCompact = variant === "compact";
184
- let t13;
185
- bb0: {
186
- if (hint) {
187
- t13 = hint;
188
- break bb0;
153
+ /**
154
+ * Build hint text
155
+ */
156
+ const hintText = React.useMemo(() => {
157
+ if (hint) return hint;
158
+ const parts = [];
159
+ if (accept && accept.length > 0) {
160
+ const types = accept.map((mimeType) => {
161
+ if (mimeType.startsWith("image/")) return t("dropzone.typeImages");
162
+ if (mimeType.startsWith("video/")) return t("dropzone.typeVideos");
163
+ if (mimeType.startsWith("audio/")) return t("dropzone.typeAudio");
164
+ if (mimeType === "application/pdf") return t("dropzone.typePDF");
165
+ if (mimeType.startsWith(".")) return mimeType.toUpperCase();
166
+ return mimeType;
167
+ }).filter((v, i, a) => a.indexOf(v) === i);
168
+ parts.push(types.join(", "));
189
169
  }
190
- let parts;
191
- if ($[24] !== accept || $[25] !== maxSize || $[26] !== t) {
192
- parts = [];
193
- if (accept && accept.length > 0) {
194
- let t14$1;
195
- if ($[28] !== t) {
196
- t14$1 = (mimeType) => {
197
- if (mimeType.startsWith("image/")) return t("dropzone.typeImages");
198
- if (mimeType.startsWith("video/")) return t("dropzone.typeVideos");
199
- if (mimeType.startsWith("audio/")) return t("dropzone.typeAudio");
200
- if (mimeType === "application/pdf") return t("dropzone.typePDF");
201
- if (mimeType.startsWith(".")) return mimeType.toUpperCase();
202
- return mimeType;
203
- };
204
- $[28] = t;
205
- $[29] = t14$1;
206
- } else t14$1 = $[29];
207
- const types = accept.map(t14$1).filter(_temp2);
208
- parts.push(types.join(", "));
209
- }
210
- if (maxSize) {
211
- let t14$1;
212
- if ($[30] !== maxSize) {
213
- t14$1 = formatFileSize(maxSize);
214
- $[30] = maxSize;
215
- $[31] = t14$1;
216
- } else t14$1 = $[31];
217
- parts.push(`Max ${t14$1}`);
218
- }
219
- $[24] = accept;
220
- $[25] = maxSize;
221
- $[26] = t;
222
- $[27] = parts;
223
- } else parts = $[27];
224
- t13 = parts.length > 0 ? parts.join(" • ") : void 0;
225
- }
226
- const hintText = t13;
227
- const t14 = disabled || loading ? -1 : 0;
228
- let t15;
229
- if ($[32] !== handleClick) {
230
- t15 = (e_4) => {
231
- if (e_4.key === "Enter" || e_4.key === " ") {
232
- e_4.preventDefault();
170
+ if (maxSize) parts.push(`Max ${formatFileSize(maxSize)}`);
171
+ return parts.length > 0 ? parts.join(" ") : void 0;
172
+ }, [
173
+ hint,
174
+ accept,
175
+ maxSize,
176
+ t
177
+ ]);
178
+ return /* @__PURE__ */ jsxs("div", {
179
+ role: "button",
180
+ tabIndex: disabled || loading ? -1 : 0,
181
+ onClick: handleClick,
182
+ onKeyDown: (e) => {
183
+ if (e.key === "Enter" || e.key === " ") {
184
+ e.preventDefault();
233
185
  handleClick();
234
186
  }
235
- };
236
- $[32] = handleClick;
237
- $[33] = t15;
238
- } else t15 = $[33];
239
- const t16 = isCompact ? "min-h-16 flex-row items-center justify-start gap-3 border border-dashed p-3 text-left" : "min-h-[120px] flex-col items-center justify-center gap-2 border-2 p-6 text-center";
240
- const t17 = isDragging && "border-border-strong bg-surface-high";
241
- const t18 = error && "border-destructive/50 bg-destructive/5";
242
- const t19 = (disabled || loading) && "pointer-events-none opacity-60";
243
- let t20;
244
- if ($[34] !== className || $[35] !== t16 || $[36] !== t17 || $[37] !== t18 || $[38] !== t19) {
245
- t20 = cn("qa-dropzone control-surface relative flex cursor-pointer hover:bg-muted/40 rounded-lg border transition-colors", t16, t17, t18, t19, className);
246
- $[34] = className;
247
- $[35] = t16;
248
- $[36] = t17;
249
- $[37] = t18;
250
- $[38] = t19;
251
- $[39] = t20;
252
- } else t20 = $[39];
253
- const t21 = disabled || loading;
254
- const t22 = isDragging || void 0;
255
- const t23 = disabled || loading;
256
- let t24;
257
- if ($[40] !== acceptString || $[41] !== handleInputChange || $[42] !== multiple || $[43] !== t23) {
258
- t24 = /* @__PURE__ */ jsx("input", {
259
- ref: inputRef,
260
- type: "file",
261
- accept: acceptString,
262
- multiple,
263
- onChange: handleInputChange,
264
- className: "sr-only",
265
- disabled: t23,
266
- tabIndex: -1
267
- });
268
- $[40] = acceptString;
269
- $[41] = handleInputChange;
270
- $[42] = multiple;
271
- $[43] = t23;
272
- $[44] = t24;
273
- } else t24 = $[44];
274
- let t25;
275
- if ($[45] !== action || $[46] !== children || $[47] !== disabled || $[48] !== hintText || $[49] !== isCompact || $[50] !== isDragging || $[51] !== label || $[52] !== loading || $[53] !== progress || $[54] !== t) {
276
- t25 = children || /* @__PURE__ */ jsxs(Fragment, { children: [
277
- /* @__PURE__ */ jsx("div", {
278
- className: cn("flex shrink-0 items-center justify-center", isCompact && "bg-background/70 border-border-subtle size-9 rounded border"),
279
- children: loading ? /* @__PURE__ */ jsxs("div", {
280
- className: "relative",
281
- children: [/* @__PURE__ */ jsx(Icon, {
282
- icon: "ph:spinner-gap",
283
- className: cn("text-muted-foreground animate-spin", isCompact ? "size-5" : "size-10")
284
- }), typeof progress === "number" && /* @__PURE__ */ jsxs("span", {
285
- className: cn("text-muted-foreground absolute inset-0 flex items-center justify-center font-medium tabular-nums", isCompact ? "text-[9px]" : "text-xs"),
286
- children: [progress, "%"]
287
- })]
288
- }) : /* @__PURE__ */ jsx(Icon, {
289
- icon: "ph:cloud-arrow-up",
290
- className: cn("transition-colors", isCompact ? "size-5" : "size-10", isDragging ? "text-foreground" : "text-muted-foreground")
291
- })
187
+ },
188
+ onDragEnter: handleDragEnter,
189
+ onDragLeave: handleDragLeave,
190
+ onDragOver: handleDragOver,
191
+ onDrop: handleDrop,
192
+ className: cn("qa-dropzone control-surface relative flex cursor-pointer hover:bg-muted/40 rounded-lg border transition-colors", isCompact ? "min-h-16 flex-row items-center justify-start gap-3 border border-dashed p-3 text-left" : "min-h-[120px] flex-col items-center justify-center gap-2 border-2 p-6 text-center", isDragging && "border-border-strong bg-surface-high", error && "border-destructive/50 bg-destructive/5", (disabled || loading) && "pointer-events-none opacity-60", className),
193
+ "aria-disabled": disabled || loading,
194
+ "data-dragging": isDragging || void 0,
195
+ children: [
196
+ /* @__PURE__ */ jsx("input", {
197
+ ref: inputRef,
198
+ type: "file",
199
+ accept: acceptString,
200
+ multiple,
201
+ onChange: handleInputChange,
202
+ className: "sr-only",
203
+ disabled: disabled || loading,
204
+ tabIndex: -1
292
205
  }),
293
- /* @__PURE__ */ jsxs("div", {
294
- className: cn("min-w-0 space-y-1", isCompact && "flex-1"),
295
- children: [
296
- /* @__PURE__ */ jsx("p", {
297
- className: cn("text-foreground text-sm font-medium", isCompact && "truncate"),
298
- children: loading ? t("dropzone.uploading") : label || t("dropzone.label")
299
- }),
300
- hintText && !loading && /* @__PURE__ */ jsx("p", {
301
- className: cn("text-muted-foreground text-xs", isCompact && "truncate"),
302
- children: hintText
303
- }),
304
- loading && typeof progress === "number" && /* @__PURE__ */ jsx("div", {
305
- className: cn("bg-muted mt-2 h-1.5 overflow-hidden rounded-full", isCompact ? "w-full" : "mx-auto w-32"),
306
- children: /* @__PURE__ */ jsx("div", {
307
- className: "bg-primary h-full rounded-full transition-[width] duration-300",
308
- style: { width: `${progress}%` }
309
- })
206
+ children || /* @__PURE__ */ jsxs(Fragment, { children: [
207
+ /* @__PURE__ */ jsx("div", {
208
+ className: cn("flex shrink-0 items-center justify-center", isCompact && "bg-background/70 border-border-subtle size-9 rounded border"),
209
+ children: loading ? /* @__PURE__ */ jsxs("div", {
210
+ className: "relative",
211
+ children: [/* @__PURE__ */ jsx(Icon, {
212
+ icon: "ph:spinner-gap",
213
+ className: cn("text-muted-foreground animate-spin", isCompact ? "size-5" : "size-10")
214
+ }), typeof progress === "number" && /* @__PURE__ */ jsxs("span", {
215
+ className: cn("text-muted-foreground absolute inset-0 flex items-center justify-center font-medium tabular-nums", isCompact ? "text-[9px]" : "text-xs"),
216
+ children: [progress, "%"]
217
+ })]
218
+ }) : /* @__PURE__ */ jsx(Icon, {
219
+ icon: "ph:cloud-arrow-up",
220
+ className: cn("transition-colors", isCompact ? "size-5" : "size-10", isDragging ? "text-foreground" : "text-muted-foreground")
310
221
  })
311
- ]
312
- }),
313
- action && !loading && !disabled && /* @__PURE__ */ jsxs(Button, {
314
- type: "button",
315
- variant: "outline",
316
- size: "sm",
317
- disabled: action.disabled,
318
- onClick: (e_5) => {
319
- e_5.stopPropagation();
320
- action.onClick();
321
- },
322
- onKeyDown: _temp3,
323
- className: cn("shrink-0", isCompact && "max-w-[45%] px-2.5"),
324
- children: [action.icon && /* @__PURE__ */ jsx(Icon, {
325
- icon: action.icon,
326
- className: "size-4 shrink-0"
327
- }), /* @__PURE__ */ jsx("span", {
328
- className: "truncate",
329
- children: action.label
330
- })]
222
+ }),
223
+ /* @__PURE__ */ jsxs("div", {
224
+ className: cn("min-w-0 space-y-1", isCompact && "flex-1"),
225
+ children: [
226
+ /* @__PURE__ */ jsx("p", {
227
+ className: cn("text-foreground text-sm font-medium", isCompact && "truncate"),
228
+ children: loading ? t("dropzone.uploading") : label || t("dropzone.label")
229
+ }),
230
+ hintText && !loading && /* @__PURE__ */ jsx("p", {
231
+ className: cn("text-muted-foreground text-xs", isCompact && "truncate"),
232
+ children: hintText
233
+ }),
234
+ loading && typeof progress === "number" && /* @__PURE__ */ jsx("div", {
235
+ className: cn("bg-muted mt-2 h-1.5 overflow-hidden rounded-full", isCompact ? "w-full" : "mx-auto w-32"),
236
+ children: /* @__PURE__ */ jsx("div", {
237
+ className: "bg-primary h-full rounded-full transition-[width] duration-300",
238
+ style: { width: `${progress}%` }
239
+ })
240
+ })
241
+ ]
242
+ }),
243
+ action && !loading && !disabled && /* @__PURE__ */ jsxs(Button, {
244
+ type: "button",
245
+ variant: "outline",
246
+ size: "sm",
247
+ disabled: action.disabled,
248
+ onClick: (e) => {
249
+ e.stopPropagation();
250
+ action.onClick();
251
+ },
252
+ onKeyDown: (e) => {
253
+ e.stopPropagation();
254
+ },
255
+ className: cn("shrink-0", isCompact && "max-w-[45%] px-2.5"),
256
+ children: [action.icon && /* @__PURE__ */ jsx(Icon, {
257
+ icon: action.icon,
258
+ className: "size-4 shrink-0"
259
+ }), /* @__PURE__ */ jsx("span", {
260
+ className: "truncate",
261
+ children: action.label
262
+ })]
263
+ })
264
+ ] }),
265
+ error && /* @__PURE__ */ jsx("p", {
266
+ className: "text-destructive absolute right-0 bottom-2 left-0 text-center text-xs",
267
+ children: error
331
268
  })
332
- ] });
333
- $[45] = action;
334
- $[46] = children;
335
- $[47] = disabled;
336
- $[48] = hintText;
337
- $[49] = isCompact;
338
- $[50] = isDragging;
339
- $[51] = label;
340
- $[52] = loading;
341
- $[53] = progress;
342
- $[54] = t;
343
- $[55] = t25;
344
- } else t25 = $[55];
345
- let t26;
346
- if ($[56] !== error) {
347
- t26 = error && /* @__PURE__ */ jsx("p", {
348
- className: "text-destructive absolute right-0 bottom-2 left-0 text-center text-xs",
349
- children: error
350
- });
351
- $[56] = error;
352
- $[57] = t26;
353
- } else t26 = $[57];
354
- let t27;
355
- if ($[58] !== handleClick || $[59] !== handleDragEnter || $[60] !== handleDrop || $[61] !== t14 || $[62] !== t15 || $[63] !== t20 || $[64] !== t21 || $[65] !== t22 || $[66] !== t24 || $[67] !== t25 || $[68] !== t26) {
356
- t27 = /* @__PURE__ */ jsxs("div", {
357
- role: "button",
358
- tabIndex: t14,
359
- onClick: handleClick,
360
- onKeyDown: t15,
361
- onDragEnter: handleDragEnter,
362
- onDragLeave: handleDragLeave,
363
- onDragOver: handleDragOver,
364
- onDrop: handleDrop,
365
- className: t20,
366
- "aria-disabled": t21,
367
- "data-dragging": t22,
368
- children: [
369
- t24,
370
- t25,
371
- t26
372
- ]
373
- });
374
- $[58] = handleClick;
375
- $[59] = handleDragEnter;
376
- $[60] = handleDrop;
377
- $[61] = t14;
378
- $[62] = t15;
379
- $[63] = t20;
380
- $[64] = t21;
381
- $[65] = t22;
382
- $[66] = t24;
383
- $[67] = t25;
384
- $[68] = t26;
385
- $[69] = t27;
386
- } else t27 = $[69];
387
- return t27;
388
- }
389
- function _temp3(e_6) {
390
- e_6.stopPropagation();
391
- }
392
- function _temp2(v, i, a) {
393
- return a.indexOf(v) === i;
394
- }
395
- function _temp(e_1) {
396
- e_1.preventDefault();
397
- e_1.stopPropagation();
269
+ ]
270
+ });
398
271
  }
399
272
 
400
273
  //#endregion
@@ -3,90 +3,22 @@
3
3
  import { cn } from "../../lib/utils.mjs";
4
4
  import { Button } from "../ui/button.mjs";
5
5
  import { InputGroup } from "../ui/input-group.mjs";
6
- import { c } from "react/compiler-runtime";
7
6
  import { jsx } from "react/jsx-runtime";
8
7
 
9
8
  //#region src/client/components/primitives/field-select-control.tsx
10
- function FieldSelectTrigger(t0) {
11
- const $ = c(13);
12
- let asInputGroupControl;
13
- let className;
14
- let hasValue;
15
- let props;
16
- if ($[0] !== t0) {
17
- ({className, hasValue, asInputGroupControl, ...props} = t0);
18
- $[0] = t0;
19
- $[1] = asInputGroupControl;
20
- $[2] = className;
21
- $[3] = hasValue;
22
- $[4] = props;
23
- } else {
24
- asInputGroupControl = $[1];
25
- className = $[2];
26
- hasValue = $[3];
27
- props = $[4];
28
- }
29
- const t1 = asInputGroupControl ? "input-group-control" : void 0;
30
- const t2 = !hasValue && "text-muted-foreground";
31
- const t3 = asInputGroupControl && "h-full min-w-0 flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0";
32
- let t4;
33
- if ($[5] !== className || $[6] !== t2 || $[7] !== t3) {
34
- t4 = cn("qa-field-select-control qa-select-single control-surface w-full justify-between px-3 py-2 font-normal", "hover:bg-surface-low focus-visible:border-border-strong focus-visible:ring-ring/20 aria-expanded:border-border-strong aria-expanded:ring-ring/20 focus-visible:ring-[3px] aria-expanded:ring-[3px]", t2, t3, className);
35
- $[5] = className;
36
- $[6] = t2;
37
- $[7] = t3;
38
- $[8] = t4;
39
- } else t4 = $[8];
40
- let t5;
41
- if ($[9] !== props || $[10] !== t1 || $[11] !== t4) {
42
- t5 = /* @__PURE__ */ jsx(Button, {
43
- variant: "outline",
44
- "data-slot": t1,
45
- className: t4,
46
- ...props
47
- });
48
- $[9] = props;
49
- $[10] = t1;
50
- $[11] = t4;
51
- $[12] = t5;
52
- } else t5 = $[12];
53
- return t5;
9
+ function FieldSelectTrigger({ className, hasValue, asInputGroupControl, ...props }) {
10
+ return /* @__PURE__ */ jsx(Button, {
11
+ variant: "outline",
12
+ "data-slot": asInputGroupControl ? "input-group-control" : void 0,
13
+ className: cn("qa-field-select-control qa-select-single control-surface w-full justify-between px-3 py-2 font-normal", "hover:bg-surface-low focus-visible:border-border-strong focus-visible:ring-ring/20 aria-expanded:border-border-strong aria-expanded:ring-ring/20 focus-visible:ring-[3px] aria-expanded:ring-[3px]", !hasValue && "text-muted-foreground", asInputGroupControl && "h-full min-w-0 flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0", className),
14
+ ...props
15
+ });
54
16
  }
55
- function FieldSelectActionGroup(t0) {
56
- const $ = c(10);
57
- let className;
58
- let error;
59
- let props;
60
- if ($[0] !== t0) {
61
- ({className, error, ...props} = t0);
62
- $[0] = t0;
63
- $[1] = className;
64
- $[2] = error;
65
- $[3] = props;
66
- } else {
67
- className = $[1];
68
- error = $[2];
69
- props = $[3];
70
- }
71
- const t1 = error && "border-destructive ring-destructive/20 ring-[2px]";
72
- let t2;
73
- if ($[4] !== className || $[5] !== t1) {
74
- t2 = cn("qa-field-select-action-group control-surface overflow-hidden p-0", t1, className);
75
- $[4] = className;
76
- $[5] = t1;
77
- $[6] = t2;
78
- } else t2 = $[6];
79
- let t3;
80
- if ($[7] !== props || $[8] !== t2) {
81
- t3 = /* @__PURE__ */ jsx(InputGroup, {
82
- className: t2,
83
- ...props
84
- });
85
- $[7] = props;
86
- $[8] = t2;
87
- $[9] = t3;
88
- } else t3 = $[9];
89
- return t3;
17
+ function FieldSelectActionGroup({ className, error, ...props }) {
18
+ return /* @__PURE__ */ jsx(InputGroup, {
19
+ className: cn("qa-field-select-action-group control-surface overflow-hidden p-0", error && "border-destructive ring-destructive/20 ring-[2px]", className),
20
+ ...props
21
+ });
90
22
  }
91
23
 
92
24
  //#endregion