@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,12 +7,17 @@ import { WidgetCard } from "../../views/dashboard/widget-card.mjs";
7
7
  import { useServerWidgetData } from "../../hooks/use-server-widget-data.mjs";
8
8
  import { WidgetEmptyState } from "./widget-empty-state.mjs";
9
9
  import { ChartWidgetSkeleton } from "./widget-skeletons.mjs";
10
- import { c } from "react/compiler-runtime";
11
- import "react";
10
+ import * as React from "react";
12
11
  import { jsx, jsxs } from "react/jsx-runtime";
13
12
  import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, Line, LineChart, Pie, PieChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
14
13
 
15
14
  //#region src/client/components/widgets/chart-widget.tsx
15
+ /**
16
+ * Chart Widget
17
+ *
18
+ * Displays data visualization over time.
19
+ * Uses WidgetCard for consistent styling.
20
+ */
16
21
  const CHART_COLORS = [
17
22
  "var(--color-chart-1)",
18
23
  "var(--color-chart-2)",
@@ -23,36 +28,26 @@ const CHART_COLORS = [
23
28
  /**
24
29
  * Custom tooltip component matching shadcn style
25
30
  */
26
- function ChartTooltip(t0) {
27
- const $ = c(7);
28
- const { active, payload, label } = t0;
31
+ function ChartTooltip({ active, payload, label }) {
29
32
  if (!active || !payload?.length) return null;
30
- let t1;
31
- if ($[0] !== label) {
32
- t1 = /* @__PURE__ */ jsx("p", {
33
+ return /* @__PURE__ */ jsxs("div", {
34
+ className: "border-border bg-background border px-3 py-2 text-xs shadow-md",
35
+ children: [/* @__PURE__ */ jsx("p", {
33
36
  className: "text-foreground font-medium",
34
37
  children: label
35
- });
36
- $[0] = label;
37
- $[1] = t1;
38
- } else t1 = $[1];
39
- let t2;
40
- if ($[2] !== payload) {
41
- t2 = payload.map(_temp);
42
- $[2] = payload;
43
- $[3] = t2;
44
- } else t2 = $[3];
45
- let t3;
46
- if ($[4] !== t1 || $[5] !== t2) {
47
- t3 = /* @__PURE__ */ jsxs("div", {
48
- className: "border-border bg-background border px-3 py-2 text-xs shadow-md",
49
- children: [t1, t2]
50
- });
51
- $[4] = t1;
52
- $[5] = t2;
53
- $[6] = t3;
54
- } else t3 = $[6];
55
- return t3;
38
+ }), payload.map((entry) => /* @__PURE__ */ jsxs("p", {
39
+ className: "text-muted-foreground",
40
+ children: [
41
+ entry.name,
42
+ ":",
43
+ " ",
44
+ /* @__PURE__ */ jsx("span", {
45
+ className: "text-foreground font-medium",
46
+ children: entry.value
47
+ })
48
+ ]
49
+ }, String(entry.name)))]
50
+ });
56
51
  }
57
52
  /**
58
53
  * Chart widget component
@@ -62,569 +57,226 @@ function ChartTooltip(t0) {
62
57
  * - Multiple chart types (line, bar, area, pie)
63
58
  * - Configurable time ranges
64
59
  */
65
- function _temp(entry) {
66
- return /* @__PURE__ */ jsxs("p", {
67
- className: "text-muted-foreground",
68
- children: [
69
- entry.name,
70
- ":",
71
- " ",
72
- /* @__PURE__ */ jsx("span", {
73
- className: "text-foreground font-medium",
74
- children: entry.value
75
- })
76
- ]
77
- }, String(entry.name));
78
- }
79
- function ChartWidget(t0) {
80
- const $ = c(63);
81
- const { config } = t0;
60
+ function ChartWidget({ config }) {
82
61
  const resolveText = useResolveText();
83
62
  const { t, locale } = useTranslation();
84
- const { collection, field, chartType: t1, timeRange: t2, label, color: t3, showGrid: t4, realtime, hasLoader, refreshInterval } = config;
85
- const chartType = t1 === void 0 ? "area" : t1;
86
- const timeRange = t2 === void 0 ? "30d" : t2;
87
- const color = t3 === void 0 ? "var(--color-chart-1)" : t3;
88
- const showGrid = t4 === void 0 ? true : t4;
89
- const t5 = !!hasLoader;
90
- let t6;
91
- if ($[0] !== refreshInterval || $[1] !== t5) {
92
- t6 = {
93
- enabled: t5,
94
- refreshInterval
95
- };
96
- $[0] = refreshInterval;
97
- $[1] = t5;
98
- $[2] = t6;
99
- } else t6 = $[2];
100
- const serverQuery = useServerWidgetData(config.id, t6);
101
- const t7 = !!collection && !hasLoader;
102
- let t8;
103
- if ($[3] !== t7) {
104
- t8 = { schemaQueryOptions: { enabled: t7 } };
105
- $[3] = t7;
106
- $[4] = t8;
107
- } else t8 = $[4];
108
- const { fields } = useCollectionFields(collection, t8);
63
+ const { collection, field, chartType = "area", timeRange = "30d", label, color = "var(--color-chart-1)", showGrid = true, realtime, hasLoader, refreshInterval } = config;
64
+ const serverQuery = useServerWidgetData(config.id, {
65
+ enabled: !!hasLoader,
66
+ refreshInterval
67
+ });
68
+ const { fields } = useCollectionFields(collection, { schemaQueryOptions: { enabled: !!collection && !hasLoader } });
109
69
  const fieldDef = fields[field];
110
70
  const fieldType = fieldDef?.name;
111
71
  const selectOptions = fieldDef?.["~options"]?.options;
112
- let t9;
113
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
114
- t9 = { limit: 1e3 };
115
- $[5] = t9;
116
- } else t9 = $[5];
117
- const t10 = !hasLoader;
118
- let t11;
119
- if ($[6] !== t10) {
120
- t11 = { enabled: t10 };
121
- $[6] = t10;
122
- $[7] = t11;
123
- } else t11 = $[7];
124
- let t12;
125
- if ($[8] !== realtime) {
126
- t12 = { realtime };
127
- $[8] = realtime;
128
- $[9] = t12;
129
- } else t12 = $[9];
130
- const collectionQuery = useCollectionList(collection, t9, t11, t12);
72
+ const collectionQuery = useCollectionList(collection, { limit: 1e3 }, { enabled: !hasLoader }, { realtime });
131
73
  const { isLoading, error, refetch, isFetching } = hasLoader ? serverQuery : collectionQuery;
132
- let t13;
133
- bb0: {
134
- if (hasLoader) {
135
- let t14$2;
136
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
137
- t14$2 = [];
138
- $[10] = t14$2;
139
- } else t14$2 = $[10];
140
- t13 = t14$2;
141
- break bb0;
142
- }
143
- let t14$1;
144
- if ($[11] !== collectionQuery.data) {
145
- t14$1 = Array.isArray(collectionQuery.data?.docs) ? collectionQuery.data.docs : [];
146
- $[11] = collectionQuery.data;
147
- $[12] = t14$1;
148
- } else t14$1 = $[12];
149
- t13 = t14$1;
150
- }
151
- const collectionItems = t13;
152
- let t14;
153
- if ($[13] !== collection || $[14] !== config.title || $[15] !== field || $[16] !== label || $[17] !== resolveText) {
154
- t14 = config.title ? resolveText(config.title) : label ? resolveText(label) : `${formatLabel(collection)} by ${field}`;
155
- $[13] = collection;
156
- $[14] = config.title;
157
- $[15] = field;
158
- $[16] = label;
159
- $[17] = resolveText;
160
- $[18] = t14;
161
- } else t14 = $[18];
162
- const displayLabel = t14;
163
- let t15;
164
- bb1: {
165
- if (hasLoader) {
166
- let t16$2;
167
- if ($[19] !== serverQuery.data) {
168
- t16$2 = serverQuery.data ?? [];
169
- $[19] = serverQuery.data;
170
- $[20] = t16$2;
171
- } else t16$2 = $[20];
172
- t15 = t16$2;
173
- break bb1;
174
- }
175
- if (!collectionItems.length) {
176
- let t16$2;
177
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
178
- t16$2 = [];
179
- $[21] = t16$2;
180
- } else t16$2 = $[21];
181
- t15 = t16$2;
182
- break bb1;
183
- }
184
- let t16$1;
185
- if ($[22] !== collectionItems || $[23] !== field || $[24] !== fieldType || $[25] !== locale || $[26] !== resolveText || $[27] !== selectOptions || $[28] !== t || $[29] !== timeRange) {
186
- const grouped = collectionItems.reduce((acc, item) => {
187
- const value = item[field];
188
- if (value === void 0 || value === null) return acc;
189
- let key;
190
- if (fieldType === "select") key = resolveOptionLabelForValue({
191
- value,
192
- options: selectOptions,
193
- resolveText,
194
- t,
195
- locale
196
- });
197
- else if (value instanceof Date || !isNaN(Date.parse(value))) key = formatDateForRange(new Date(value), timeRange);
198
- else key = String(value);
199
- acc[key] = (acc[key] || 0) + 1;
200
- return acc;
201
- }, {});
202
- t16$1 = Object.entries(grouped).map(_temp2).sort(_temp3);
203
- $[22] = collectionItems;
204
- $[23] = field;
205
- $[24] = fieldType;
206
- $[25] = locale;
207
- $[26] = resolveText;
208
- $[27] = selectOptions;
209
- $[28] = t;
210
- $[29] = timeRange;
211
- $[30] = t16$1;
212
- } else t16$1 = $[30];
213
- t15 = t16$1;
214
- }
215
- const chartData = t15;
216
- let t16;
217
- if ($[31] !== t) {
218
- t16 = t("widget.chart.emptyTitle");
219
- $[31] = t;
220
- $[32] = t16;
221
- } else t16 = $[32];
222
- let t17;
223
- if ($[33] !== t) {
224
- t17 = t("widget.chart.emptyDescription");
225
- $[33] = t;
226
- $[34] = t17;
227
- } else t17 = $[34];
228
- let t18;
229
- if ($[35] !== t16 || $[36] !== t17) {
230
- t18 = /* @__PURE__ */ jsx(WidgetEmptyState, {
231
- iconName: "ph:chart-line",
232
- title: t16,
233
- description: t17,
234
- className: "min-h-48"
235
- });
236
- $[35] = t16;
237
- $[36] = t17;
238
- $[37] = t18;
239
- } else t18 = $[37];
240
- const emptyContent = t18;
241
- let t19;
242
- if ($[38] !== chartData || $[39] !== chartType || $[40] !== color || $[41] !== emptyContent || $[42] !== showGrid) {
243
- t19 = chartData.length === 0 ? emptyContent : /* @__PURE__ */ jsx("div", {
244
- className: "h-48 w-full",
245
- children: /* @__PURE__ */ jsx(ResponsiveContainer, {
246
- width: "100%",
247
- height: "100%",
248
- children: /* @__PURE__ */ jsx(ChartRenderer, {
249
- type: chartType,
250
- data: chartData,
251
- color,
252
- showGrid
253
- })
74
+ const collectionItems = React.useMemo(() => {
75
+ if (hasLoader) return [];
76
+ return Array.isArray(collectionQuery.data?.docs) ? collectionQuery.data.docs : [];
77
+ }, [hasLoader, collectionQuery.data]);
78
+ const displayLabel = config.title ? resolveText(config.title) : label ? resolveText(label) : `${formatLabel(collection)} by ${field}`;
79
+ const chartData = React.useMemo(() => {
80
+ if (hasLoader) return serverQuery.data ?? [];
81
+ if (!collectionItems.length) return [];
82
+ const grouped = collectionItems.reduce((acc, item) => {
83
+ const value = item[field];
84
+ if (value === void 0 || value === null) return acc;
85
+ let key;
86
+ if (fieldType === "select") key = resolveOptionLabelForValue({
87
+ value,
88
+ options: selectOptions,
89
+ resolveText,
90
+ t,
91
+ locale
92
+ });
93
+ else if (value instanceof Date || !isNaN(Date.parse(value))) key = formatDateForRange(new Date(value), timeRange);
94
+ else key = String(value);
95
+ acc[key] = (acc[key] || 0) + 1;
96
+ return acc;
97
+ }, {});
98
+ return Object.entries(grouped).map(([name, value]) => ({
99
+ name,
100
+ value
101
+ })).sort((a, b) => a.name.localeCompare(b.name));
102
+ }, [
103
+ hasLoader,
104
+ serverQuery.data,
105
+ collectionItems,
106
+ field,
107
+ fieldType,
108
+ selectOptions,
109
+ resolveText,
110
+ t,
111
+ locale,
112
+ timeRange
113
+ ]);
114
+ const emptyContent = /* @__PURE__ */ jsx(WidgetEmptyState, {
115
+ iconName: "ph:chart-line",
116
+ title: t("widget.chart.emptyTitle"),
117
+ description: t("widget.chart.emptyDescription"),
118
+ className: "min-h-48"
119
+ });
120
+ const chartContent = chartData.length === 0 ? emptyContent : /* @__PURE__ */ jsx("div", {
121
+ className: "h-48 w-full",
122
+ children: /* @__PURE__ */ jsx(ResponsiveContainer, {
123
+ width: "100%",
124
+ height: "100%",
125
+ children: /* @__PURE__ */ jsx(ChartRenderer, {
126
+ type: chartType,
127
+ data: chartData,
128
+ color,
129
+ showGrid
254
130
  })
255
- });
256
- $[38] = chartData;
257
- $[39] = chartType;
258
- $[40] = color;
259
- $[41] = emptyContent;
260
- $[42] = showGrid;
261
- $[43] = t19;
262
- } else t19 = $[43];
263
- const chartContent = t19;
264
- let t20;
265
- if ($[44] !== config.description || $[45] !== resolveText) {
266
- t20 = config.description ? resolveText(config.description) : void 0;
267
- $[44] = config.description;
268
- $[45] = resolveText;
269
- $[46] = t20;
270
- } else t20 = $[46];
271
- const t21 = isFetching && !isLoading;
272
- let t22;
273
- if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
274
- t22 = /* @__PURE__ */ jsx(ChartWidgetSkeleton, {});
275
- $[47] = t22;
276
- } else t22 = $[47];
277
- let t23;
278
- if ($[48] !== error) {
279
- t23 = error instanceof Error ? error : error ? new Error(String(error)) : null;
280
- $[48] = error;
281
- $[49] = t23;
282
- } else t23 = $[49];
283
- let t24;
284
- if ($[50] !== refetch) {
285
- t24 = () => refetch();
286
- $[50] = refetch;
287
- $[51] = t24;
288
- } else t24 = $[51];
289
- let t25;
290
- if ($[52] !== chartContent || $[53] !== config.actions || $[54] !== config.cardVariant || $[55] !== config.className || $[56] !== displayLabel || $[57] !== isLoading || $[58] !== t20 || $[59] !== t21 || $[60] !== t23 || $[61] !== t24) {
291
- t25 = /* @__PURE__ */ jsx(WidgetCard, {
292
- title: displayLabel,
293
- description: t20,
294
- variant: config.cardVariant,
295
- isLoading,
296
- isRefreshing: t21,
297
- loadingSkeleton: t22,
298
- error: t23,
299
- onRefresh: t24,
300
- actions: config.actions,
301
- className: config.className,
302
- children: chartContent
303
- });
304
- $[52] = chartContent;
305
- $[53] = config.actions;
306
- $[54] = config.cardVariant;
307
- $[55] = config.className;
308
- $[56] = displayLabel;
309
- $[57] = isLoading;
310
- $[58] = t20;
311
- $[59] = t21;
312
- $[60] = t23;
313
- $[61] = t24;
314
- $[62] = t25;
315
- } else t25 = $[62];
316
- return t25;
131
+ })
132
+ });
133
+ return /* @__PURE__ */ jsx(WidgetCard, {
134
+ title: displayLabel,
135
+ description: config.description ? resolveText(config.description) : void 0,
136
+ variant: config.cardVariant,
137
+ isLoading,
138
+ isRefreshing: isFetching && !isLoading,
139
+ loadingSkeleton: /* @__PURE__ */ jsx(ChartWidgetSkeleton, {}),
140
+ error: error instanceof Error ? error : error ? new Error(String(error)) : null,
141
+ onRefresh: () => refetch(),
142
+ actions: config.actions,
143
+ className: config.className,
144
+ children: chartContent
145
+ });
317
146
  }
318
147
  /**
319
148
  * Renders the appropriate chart type as a proper component
320
149
  */
321
- function _temp3(a, b) {
322
- return a.name.localeCompare(b.name);
323
- }
324
- function _temp2(t0) {
325
- const [name, value_0] = t0;
326
- return {
327
- name,
328
- value: value_0
329
- };
330
- }
331
- function ChartRenderer(t0) {
332
- const $ = c(46);
333
- const { type, data, color, showGrid } = t0;
334
- let t1;
335
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
336
- t1 = {
150
+ function ChartRenderer({ type, data, color, showGrid }) {
151
+ const commonProps = {
152
+ data,
153
+ margin: {
337
154
  top: 5,
338
155
  right: 5,
339
156
  left: -20,
340
157
  bottom: 5
341
- };
342
- $[0] = t1;
343
- } else t1 = $[0];
344
- let t2;
345
- if ($[1] !== data) {
346
- t2 = {
347
- data,
348
- margin: t1
349
- };
350
- $[1] = data;
351
- $[2] = t2;
352
- } else t2 = $[2];
353
- const commonProps = t2;
354
- let t3;
355
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
356
- t3 = {
357
- fontSize: 10,
358
- fill: "var(--color-muted-foreground)"
359
- };
360
- $[3] = t3;
361
- } else t3 = $[3];
362
- const axisStyle = t3;
158
+ }
159
+ };
160
+ const axisStyle = {
161
+ fontSize: 10,
162
+ fill: "var(--color-muted-foreground)"
163
+ };
363
164
  switch (type) {
364
- case "line": {
365
- let t4;
366
- if ($[4] !== showGrid) {
367
- t4 = showGrid && /* @__PURE__ */ jsx(CartesianGrid, {
165
+ case "line": return /* @__PURE__ */ jsxs(LineChart, {
166
+ ...commonProps,
167
+ children: [
168
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, {
368
169
  strokeDasharray: "3 3",
369
170
  stroke: "var(--color-border)",
370
171
  opacity: .5
371
- });
372
- $[4] = showGrid;
373
- $[5] = t4;
374
- } else t4 = $[5];
375
- let t5;
376
- let t6;
377
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
378
- t5 = /* @__PURE__ */ jsx(XAxis, {
172
+ }),
173
+ /* @__PURE__ */ jsx(XAxis, {
379
174
  dataKey: "name",
380
175
  tick: axisStyle,
381
176
  tickLine: false,
382
177
  axisLine: false
383
- });
384
- t6 = /* @__PURE__ */ jsx(YAxis, {
178
+ }),
179
+ /* @__PURE__ */ jsx(YAxis, {
385
180
  tick: axisStyle,
386
181
  tickLine: false,
387
182
  axisLine: false
388
- });
389
- $[6] = t5;
390
- $[7] = t6;
391
- } else {
392
- t5 = $[6];
393
- t6 = $[7];
394
- }
395
- let t7;
396
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
397
- t7 = /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltip, {}) });
398
- $[8] = t7;
399
- } else t7 = $[8];
400
- let t8;
401
- if ($[9] !== color) {
402
- t8 = /* @__PURE__ */ jsx(Line, {
183
+ }),
184
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltip, {}) }),
185
+ /* @__PURE__ */ jsx(Line, {
403
186
  type: "monotone",
404
187
  dataKey: "value",
405
188
  stroke: color,
406
189
  strokeWidth: 2,
407
190
  dot: false
408
- });
409
- $[9] = color;
410
- $[10] = t8;
411
- } else t8 = $[10];
412
- let t9;
413
- if ($[11] !== commonProps || $[12] !== t4 || $[13] !== t8) {
414
- t9 = /* @__PURE__ */ jsxs(LineChart, {
415
- ...commonProps,
416
- children: [
417
- t4,
418
- t5,
419
- t6,
420
- t7,
421
- t8
422
- ]
423
- });
424
- $[11] = commonProps;
425
- $[12] = t4;
426
- $[13] = t8;
427
- $[14] = t9;
428
- } else t9 = $[14];
429
- return t9;
430
- }
431
- case "bar": {
432
- let t4;
433
- if ($[15] !== showGrid) {
434
- t4 = showGrid && /* @__PURE__ */ jsx(CartesianGrid, {
191
+ })
192
+ ]
193
+ });
194
+ case "bar": return /* @__PURE__ */ jsxs(BarChart, {
195
+ ...commonProps,
196
+ children: [
197
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, {
435
198
  strokeDasharray: "3 3",
436
199
  stroke: "var(--color-border)",
437
200
  opacity: .5
438
- });
439
- $[15] = showGrid;
440
- $[16] = t4;
441
- } else t4 = $[16];
442
- let t5;
443
- let t6;
444
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
445
- t5 = /* @__PURE__ */ jsx(XAxis, {
201
+ }),
202
+ /* @__PURE__ */ jsx(XAxis, {
446
203
  dataKey: "name",
447
204
  tick: axisStyle,
448
205
  tickLine: false,
449
206
  axisLine: false
450
- });
451
- t6 = /* @__PURE__ */ jsx(YAxis, {
207
+ }),
208
+ /* @__PURE__ */ jsx(YAxis, {
452
209
  tick: axisStyle,
453
210
  tickLine: false,
454
211
  axisLine: false
455
- });
456
- $[17] = t5;
457
- $[18] = t6;
458
- } else {
459
- t5 = $[17];
460
- t6 = $[18];
461
- }
462
- let t7;
463
- if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
464
- t7 = /* @__PURE__ */ jsx(Tooltip, {
212
+ }),
213
+ /* @__PURE__ */ jsx(Tooltip, {
465
214
  content: /* @__PURE__ */ jsx(ChartTooltip, {}),
466
215
  cursor: {
467
216
  fill: "var(--color-muted)",
468
217
  opacity: .3
469
218
  }
470
- });
471
- $[19] = t7;
472
- } else t7 = $[19];
473
- let t8;
474
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
475
- t8 = [
476
- 2,
477
- 2,
478
- 0,
479
- 0
480
- ];
481
- $[20] = t8;
482
- } else t8 = $[20];
483
- let t9;
484
- if ($[21] !== color) {
485
- t9 = /* @__PURE__ */ jsx(Bar, {
219
+ }),
220
+ /* @__PURE__ */ jsx(Bar, {
486
221
  dataKey: "value",
487
222
  fill: color,
488
- radius: t8
489
- });
490
- $[21] = color;
491
- $[22] = t9;
492
- } else t9 = $[22];
493
- let t10;
494
- if ($[23] !== commonProps || $[24] !== t4 || $[25] !== t9) {
495
- t10 = /* @__PURE__ */ jsxs(BarChart, {
496
- ...commonProps,
497
- children: [
498
- t4,
499
- t5,
500
- t6,
501
- t7,
502
- t9
223
+ radius: [
224
+ 2,
225
+ 2,
226
+ 0,
227
+ 0
503
228
  ]
504
- });
505
- $[23] = commonProps;
506
- $[24] = t4;
507
- $[25] = t9;
508
- $[26] = t10;
509
- } else t10 = $[26];
510
- return t10;
511
- }
512
- case "pie": {
513
- let t4;
514
- if ($[27] !== data) {
515
- t4 = data.map((entry) => /* @__PURE__ */ jsx(Cell, { fill: CHART_COLORS[data.indexOf(entry) % CHART_COLORS.length] }, `cell-${entry.name}`));
516
- $[27] = data;
517
- $[28] = t4;
518
- } else t4 = $[28];
519
- let t5;
520
- if ($[29] !== data || $[30] !== t4) {
521
- t5 = /* @__PURE__ */ jsx(Pie, {
522
- data,
523
- dataKey: "value",
524
- nameKey: "name",
525
- cx: "50%",
526
- cy: "50%",
527
- outerRadius: 60,
528
- label: _temp4,
529
- labelLine: false,
530
- stroke: "var(--color-background)",
531
- strokeWidth: 2,
532
- children: t4
533
- });
534
- $[29] = data;
535
- $[30] = t4;
536
- $[31] = t5;
537
- } else t5 = $[31];
538
- let t6;
539
- if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
540
- t6 = /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltip, {}) });
541
- $[32] = t6;
542
- } else t6 = $[32];
543
- let t7;
544
- if ($[33] !== t5) {
545
- t7 = /* @__PURE__ */ jsxs(PieChart, { children: [t5, t6] });
546
- $[33] = t5;
547
- $[34] = t7;
548
- } else t7 = $[34];
549
- return t7;
550
- }
229
+ })
230
+ ]
231
+ });
232
+ case "pie": return /* @__PURE__ */ jsxs(PieChart, { children: [/* @__PURE__ */ jsx(Pie, {
233
+ data,
234
+ dataKey: "value",
235
+ nameKey: "name",
236
+ cx: "50%",
237
+ cy: "50%",
238
+ outerRadius: 60,
239
+ label: ({ name }) => name,
240
+ labelLine: false,
241
+ stroke: "var(--color-background)",
242
+ strokeWidth: 2,
243
+ children: data.map((entry) => /* @__PURE__ */ jsx(Cell, { fill: CHART_COLORS[data.indexOf(entry) % CHART_COLORS.length] }, `cell-${entry.name}`))
244
+ }), /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltip, {}) })] });
551
245
  case "area":
552
- default: {
553
- let t4;
554
- if ($[35] !== showGrid) {
555
- t4 = showGrid && /* @__PURE__ */ jsx(CartesianGrid, {
246
+ default: return /* @__PURE__ */ jsxs(AreaChart, {
247
+ ...commonProps,
248
+ children: [
249
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, {
556
250
  strokeDasharray: "3 3",
557
251
  stroke: "var(--color-border)",
558
252
  opacity: .5
559
- });
560
- $[35] = showGrid;
561
- $[36] = t4;
562
- } else t4 = $[36];
563
- let t5;
564
- let t6;
565
- if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
566
- t5 = /* @__PURE__ */ jsx(XAxis, {
253
+ }),
254
+ /* @__PURE__ */ jsx(XAxis, {
567
255
  dataKey: "name",
568
256
  tick: axisStyle,
569
257
  tickLine: false,
570
258
  axisLine: false
571
- });
572
- t6 = /* @__PURE__ */ jsx(YAxis, {
259
+ }),
260
+ /* @__PURE__ */ jsx(YAxis, {
573
261
  tick: axisStyle,
574
262
  tickLine: false,
575
263
  axisLine: false
576
- });
577
- $[37] = t5;
578
- $[38] = t6;
579
- } else {
580
- t5 = $[37];
581
- t6 = $[38];
582
- }
583
- let t7;
584
- if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
585
- t7 = /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltip, {}) });
586
- $[39] = t7;
587
- } else t7 = $[39];
588
- let t8;
589
- if ($[40] !== color) {
590
- t8 = /* @__PURE__ */ jsx(Area, {
264
+ }),
265
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltip, {}) }),
266
+ /* @__PURE__ */ jsx(Area, {
591
267
  type: "monotone",
592
268
  dataKey: "value",
593
269
  stroke: color,
594
270
  fill: color,
595
271
  fillOpacity: .15
596
- });
597
- $[40] = color;
598
- $[41] = t8;
599
- } else t8 = $[41];
600
- let t9;
601
- if ($[42] !== commonProps || $[43] !== t4 || $[44] !== t8) {
602
- t9 = /* @__PURE__ */ jsxs(AreaChart, {
603
- ...commonProps,
604
- children: [
605
- t4,
606
- t5,
607
- t6,
608
- t7,
609
- t8
610
- ]
611
- });
612
- $[42] = commonProps;
613
- $[43] = t4;
614
- $[44] = t8;
615
- $[45] = t9;
616
- } else t9 = $[45];
617
- return t9;
618
- }
272
+ })
273
+ ]
274
+ });
619
275
  }
620
276
  }
621
277
  /**
622
278
  * Format date based on time range for grouping
623
279
  */
624
- function _temp4(t0) {
625
- const { name } = t0;
626
- return name;
627
- }
628
280
  function formatDateForRange(date, timeRange) {
629
281
  const months = [
630
282
  "Jan",