@questpie/admin 3.2.4 → 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 (248) 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.mjs +40 -126
  8. package/dist/client/components/auth/auth-loading.mjs +9 -44
  9. package/dist/client/components/blocks/block-canvas.mjs +31 -95
  10. package/dist/client/components/blocks/block-editor-context.mjs +13 -57
  11. package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
  12. package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
  13. package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
  14. package/dist/client/components/blocks/block-insert-button.mjs +49 -165
  15. package/dist/client/components/blocks/block-item-menu.mjs +102 -301
  16. package/dist/client/components/blocks/block-item.mjs +136 -370
  17. package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
  18. package/dist/client/components/blocks/block-tree.mjs +12 -68
  19. package/dist/client/components/blocks/block-type-icon.mjs +14 -56
  20. package/dist/client/components/brand-logo.mjs +35 -149
  21. package/dist/client/components/component-renderer.mjs +42 -118
  22. package/dist/client/components/error-boundary.mjs +14 -58
  23. package/dist/client/components/fields/array-field.mjs +209 -521
  24. package/dist/client/components/fields/asset-preview-field.mjs +41 -141
  25. package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
  26. package/dist/client/components/fields/boolean-field.mjs +29 -59
  27. package/dist/client/components/fields/date-field.mjs +7 -37
  28. package/dist/client/components/fields/datetime-field.mjs +7 -38
  29. package/dist/client/components/fields/email-field.mjs +25 -54
  30. package/dist/client/components/fields/field-wrapper.mjs +30 -105
  31. package/dist/client/components/fields/json-field.mjs +94 -296
  32. package/dist/client/components/fields/locale-badge.mjs +6 -15
  33. package/dist/client/components/fields/number-field.mjs +27 -60
  34. package/dist/client/components/fields/object-array-field.mjs +283 -659
  35. package/dist/client/components/fields/object-field.mjs +165 -633
  36. package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
  37. package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
  38. package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
  39. package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
  40. package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
  41. package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
  42. package/dist/client/components/fields/relation-field.mjs +10 -66
  43. package/dist/client/components/fields/relation-picker.mjs +18 -18
  44. package/dist/client/components/fields/relation-select.mjs +12 -12
  45. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
  46. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
  47. package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
  48. package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
  49. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
  50. package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
  51. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
  52. package/dist/client/components/fields/rich-text-field.mjs +14 -53
  53. package/dist/client/components/fields/select-field.mjs +39 -74
  54. package/dist/client/components/fields/text-field.mjs +26 -59
  55. package/dist/client/components/fields/textarea-field.mjs +26 -58
  56. package/dist/client/components/fields/time-field.mjs +7 -35
  57. package/dist/client/components/fields/upload-field.mjs +47 -165
  58. package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
  59. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
  60. package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
  61. package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
  62. package/dist/client/components/history-sidebar.mjs +285 -605
  63. package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
  64. package/dist/client/components/locale-switcher.mjs +106 -228
  65. package/dist/client/components/media/media-grid.mjs +84 -273
  66. package/dist/client/components/media/media-picker-dialog.mjs +176 -476
  67. package/dist/client/components/preview/live-preview-mode.mjs +233 -458
  68. package/dist/client/components/preview/preview-pane.mjs +22 -22
  69. package/dist/client/components/primitives/asset-preview.mjs +290 -666
  70. package/dist/client/components/primitives/checkbox-input.mjs +9 -35
  71. package/dist/client/components/primitives/date-input.mjs +109 -327
  72. package/dist/client/components/primitives/dropzone.mjs +209 -336
  73. package/dist/client/components/primitives/field-select-control.mjs +12 -80
  74. package/dist/client/components/primitives/number-input.mjs +4 -4
  75. package/dist/client/components/primitives/select-multi.mjs +200 -559
  76. package/dist/client/components/primitives/select-single.mjs +165 -499
  77. package/dist/client/components/primitives/time-input.mjs +43 -117
  78. package/dist/client/components/primitives/toggle-input.mjs +9 -29
  79. package/dist/client/components/sheets/resource-sheet.mjs +61 -70
  80. package/dist/client/components/ui/accordion.mjs +35 -155
  81. package/dist/client/components/ui/alert.mjs +13 -68
  82. package/dist/client/components/ui/badge.mjs +9 -51
  83. package/dist/client/components/ui/button.mjs +8 -54
  84. package/dist/client/components/ui/card.mjs +37 -193
  85. package/dist/client/components/ui/checkbox.mjs +12 -68
  86. package/dist/client/components/ui/command.mjs +48 -219
  87. package/dist/client/components/ui/dialog.mjs +50 -262
  88. package/dist/client/components/ui/drawer.mjs +55 -259
  89. package/dist/client/components/ui/dropdown-menu.mjs +86 -427
  90. package/dist/client/components/ui/empty-state.mjs +28 -98
  91. package/dist/client/components/ui/field.mjs +73 -309
  92. package/dist/client/components/ui/input-group.mjs +42 -167
  93. package/dist/client/components/ui/input.mjs +7 -37
  94. package/dist/client/components/ui/kbd.mjs +6 -36
  95. package/dist/client/components/ui/label.mjs +7 -37
  96. package/dist/client/components/ui/popover.mjs +34 -169
  97. package/dist/client/components/ui/responsive-dialog.mjs +67 -273
  98. package/dist/client/components/ui/scroll-fade.mjs +63 -158
  99. package/dist/client/components/ui/search-input.mjs +33 -100
  100. package/dist/client/components/ui/select.mjs +72 -393
  101. package/dist/client/components/ui/separator.mjs +7 -38
  102. package/dist/client/components/ui/sheet.mjs +49 -269
  103. package/dist/client/components/ui/sidebar.mjs +171 -690
  104. package/dist/client/components/ui/skeleton.mjs +7 -38
  105. package/dist/client/components/ui/sonner.mjs +11 -42
  106. package/dist/client/components/ui/switch.mjs +9 -45
  107. package/dist/client/components/ui/table.mjs +48 -266
  108. package/dist/client/components/ui/tabs.mjs +26 -139
  109. package/dist/client/components/ui/textarea.mjs +6 -32
  110. package/dist/client/components/ui/tooltip.mjs +27 -129
  111. package/dist/client/components/widgets/chart-widget.mjs +174 -522
  112. package/dist/client/components/widgets/progress-widget.mjs +66 -172
  113. package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
  114. package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
  115. package/dist/client/components/widgets/stats-widget.mjs +41 -175
  116. package/dist/client/components/widgets/table-widget.mjs +9 -9
  117. package/dist/client/components/widgets/timeline-widget.mjs +86 -226
  118. package/dist/client/components/widgets/value-widget.mjs +74 -381
  119. package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
  120. package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
  121. package/dist/client/contexts/focus-context.mjs +63 -146
  122. package/dist/client/hooks/typed-hooks.mjs +241 -701
  123. package/dist/client/hooks/use-action.mjs +62 -198
  124. package/dist/client/hooks/use-admin-config.mjs +5 -35
  125. package/dist/client/hooks/use-admin-preferences.mjs +16 -88
  126. package/dist/client/hooks/use-admin-routes.mjs +22 -56
  127. package/dist/client/hooks/use-audit-history.mjs +21 -69
  128. package/dist/client/hooks/use-brand.mjs +1 -9
  129. package/dist/client/hooks/use-collection-fields.mjs +17 -57
  130. package/dist/client/hooks/use-collection-meta.mjs +12 -44
  131. package/dist/client/hooks/use-collection-schema.mjs +10 -33
  132. package/dist/client/hooks/use-collection-validation.mjs +23 -53
  133. package/dist/client/hooks/use-collection.mjs +194 -614
  134. package/dist/client/hooks/use-current-user.mjs +0 -1
  135. package/dist/client/hooks/use-field-hooks.mjs +10 -10
  136. package/dist/client/hooks/use-field-options.mjs +61 -202
  137. package/dist/client/hooks/use-global-fields.mjs +14 -46
  138. package/dist/client/hooks/use-global-meta.mjs +9 -30
  139. package/dist/client/hooks/use-global-schema.mjs +9 -30
  140. package/dist/client/hooks/use-global.mjs +63 -219
  141. package/dist/client/hooks/use-locks.mjs +117 -325
  142. package/dist/client/hooks/use-media-query.mjs +16 -36
  143. package/dist/client/hooks/use-prefill-params.mjs +0 -1
  144. package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
  145. package/dist/client/hooks/use-reactive-fields.mjs +1 -1
  146. package/dist/client/hooks/use-reactive-prop.mjs +65 -223
  147. package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
  148. package/dist/client/hooks/use-saved-views.mjs +22 -103
  149. package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
  150. package/dist/client/hooks/use-search.mjs +31 -143
  151. package/dist/client/hooks/use-server-actions.mjs +18 -50
  152. package/dist/client/hooks/use-server-validation.mjs +72 -166
  153. package/dist/client/hooks/use-server-widget-data.mjs +7 -33
  154. package/dist/client/hooks/use-setup-status.mjs +12 -25
  155. package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
  156. package/dist/client/hooks/use-transition-stage.mjs +8 -38
  157. package/dist/client/hooks/use-upload.mjs +54 -152
  158. package/dist/client/hooks/use-validation-error-map.mjs +6 -26
  159. package/dist/client/hooks/use-view-state.mjs +187 -437
  160. package/dist/client/i18n/hooks.mjs +65 -197
  161. package/dist/client/lib/render-profiler.mjs +14 -41
  162. package/dist/client/preview/block-scope-context.d.mts +2 -2
  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.d.mts +2 -2
  174. package/dist/client/scope/picker.mjs +86 -321
  175. package/dist/client/scope/provider.d.mts +2 -2
  176. package/dist/client/scope/provider.mjs +8 -17
  177. package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
  178. package/dist/client/views/auth/accept-invite-form.mjs +121 -412
  179. package/dist/client/views/auth/auth-layout.d.mts +3 -3
  180. package/dist/client/views/auth/auth-layout.mjs +104 -284
  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 +109 -363
  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.mjs +41 -121
  222. package/dist/client/views/pages/reset-password-page.mjs +46 -173
  223. package/dist/client/views/pages/setup-page.mjs +33 -95
  224. package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
  225. package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
  226. package/dist/server/modules/admin/collections/account.d.mts +46 -46
  227. package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
  228. package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
  229. package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
  230. package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
  231. package/dist/server/modules/admin/collections/assets.d.mts +39 -39
  232. package/dist/server/modules/admin/collections/session.d.mts +41 -41
  233. package/dist/server/modules/admin/collections/user.d.mts +63 -63
  234. package/dist/server/modules/admin/collections/verification.d.mts +36 -36
  235. package/dist/server/modules/admin/index.d.mts +20 -19
  236. package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
  237. package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
  238. package/dist/server/modules/admin/routes/locales.d.mts +2 -2
  239. package/dist/server/modules/admin/routes/preview.d.mts +11 -11
  240. package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
  241. package/dist/server/modules/admin/routes/setup.d.mts +7 -7
  242. package/dist/server/modules/admin/routes/translations.d.mts +4 -4
  243. package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
  244. package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
  245. package/dist/server/modules/audit/.generated/module.d.mts +6 -6
  246. package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
  247. package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
  248. package/package.json +3 -5
@@ -9,9 +9,8 @@ import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.mjs";
9
9
  import { useIsMobile } from "../../hooks/use-media-query.mjs";
10
10
  import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../ui/command.mjs";
11
11
  import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from "../ui/drawer.mjs";
12
- import { c } from "react/compiler-runtime";
13
12
  import { Icon } from "@iconify/react";
14
- import { useDeferredValue, useId, useState } from "react";
13
+ import { useCallback, useDeferredValue, useId, useMemo, useState } from "react";
15
14
  import { useQuery } from "@tanstack/react-query";
16
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
16
 
@@ -41,297 +40,148 @@ const EMPTY_OPTIONS = [];
41
40
  * />
42
41
  * ```
43
42
  */
44
- function SelectMulti(t0) {
45
- const $ = c(160);
46
- const { value, onChange, options: staticOptions, loadOptions, queryKey, prefetchOnMount: t1, maxSelections, loading: t2, emptyMessage: t3, placeholder: t4, disabled, className, id, "aria-invalid": ariaInvalid, drawerTitle: t5, maxVisibleChips: t6 } = t0;
47
- const prefetchOnMount = t1 === void 0 ? false : t1;
48
- const externalLoading = t2 === void 0 ? false : t2;
49
- const emptyMessage = t3 === void 0 ? "No options found" : t3;
50
- const placeholder = t4 === void 0 ? "Select..." : t4;
51
- const drawerTitle = t5 === void 0 ? "Select options" : t5;
52
- const maxVisibleChips = t6 === void 0 ? 3 : t6;
43
+ function SelectMulti({ value, onChange, options: staticOptions, loadOptions, queryKey, prefetchOnMount = false, maxSelections, loading: externalLoading = false, emptyMessage = "No options found", placeholder = "Select...", disabled, className, id, "aria-invalid": ariaInvalid, drawerTitle = "Select options", maxVisibleChips = 3 }) {
53
44
  const resolvedValue = value ?? EMPTY_VALUE;
54
45
  const resolvedStaticOptions = staticOptions ?? EMPTY_OPTIONS;
55
46
  const resolveText = useResolveText();
56
47
  const i18n = useSafeI18n();
57
- let t7;
58
- if ($[0] !== i18n) {
59
- t7 = (key) => i18n?.t(key) ?? key;
60
- $[0] = i18n;
61
- $[1] = t7;
62
- } else t7 = $[1];
63
- const translate = t7;
48
+ const translate = useCallback((key) => i18n?.t(key) ?? key, [i18n]);
64
49
  const locale = i18n?.locale ?? "en";
65
- let t8;
66
- if ($[2] !== translate) {
67
- t8 = (key_0, fallback) => {
68
- const message = translate(key_0);
69
- return message && message !== key_0 ? message : fallback;
70
- };
71
- $[2] = translate;
72
- $[3] = t8;
73
- } else t8 = $[3];
74
- const t = t8;
75
- let t9;
76
- if ($[4] !== placeholder || $[5] !== resolveText) {
77
- t9 = resolveText(placeholder);
78
- $[4] = placeholder;
79
- $[5] = resolveText;
80
- $[6] = t9;
81
- } else t9 = $[6];
82
- const resolvedPlaceholder = t9;
83
- let t10;
84
- if ($[7] !== emptyMessage || $[8] !== resolveText) {
85
- t10 = resolveText(emptyMessage);
86
- $[7] = emptyMessage;
87
- $[8] = resolveText;
88
- $[9] = t10;
89
- } else t10 = $[9];
90
- const resolvedEmptyMessage = t10;
91
- let t11;
92
- if ($[10] !== drawerTitle || $[11] !== resolveText) {
93
- t11 = resolveText(drawerTitle);
94
- $[10] = drawerTitle;
95
- $[11] = resolveText;
96
- $[12] = t11;
97
- } else t11 = $[12];
98
- const resolvedDrawerTitle = t11;
50
+ const t = (key, fallback) => {
51
+ const message = translate(key);
52
+ return message && message !== key ? message : fallback;
53
+ };
54
+ const resolvedPlaceholder = resolveText(placeholder);
55
+ const resolvedEmptyMessage = resolveText(emptyMessage);
56
+ const resolvedDrawerTitle = resolveText(drawerTitle);
99
57
  const [open, setOpen] = useState(false);
100
58
  const [search, setSearch] = useState("");
101
59
  const instanceId = useId();
102
60
  const deferredSearch = useDeferredValue(search);
103
61
  const isMobile = useIsMobile();
104
- let t12;
105
- if ($[13] !== resolvedStaticOptions) {
106
- t12 = flattenOptions(resolvedStaticOptions);
107
- $[13] = resolvedStaticOptions;
108
- $[14] = t12;
109
- } else t12 = $[14];
110
- const flatStaticOptions = t12;
111
- let t13;
112
- if ($[15] !== deferredSearch || $[16] !== instanceId || $[17] !== queryKey) {
113
- t13 = queryKey ? queryKey(deferredSearch) : [
62
+ const flatStaticOptions = useMemo(() => flattenOptions(resolvedStaticOptions), [resolvedStaticOptions]);
63
+ const { data: dynamicOptions = [], isFetching } = useQuery({
64
+ queryKey: useMemo(() => queryKey ? queryKey(deferredSearch) : [
114
65
  "select-multi",
115
66
  instanceId,
116
67
  deferredSearch
117
- ];
118
- $[15] = deferredSearch;
119
- $[16] = instanceId;
120
- $[17] = queryKey;
121
- $[18] = t13;
122
- } else t13 = $[18];
123
- const loadOptionsKey = t13;
124
- let t14;
125
- if ($[19] !== deferredSearch || $[20] !== loadOptions) {
126
- t14 = () => loadOptions?.(deferredSearch) ?? Promise.resolve([]);
127
- $[19] = deferredSearch;
128
- $[20] = loadOptions;
129
- $[21] = t14;
130
- } else t14 = $[21];
131
- const t15 = !!loadOptions && (open || prefetchOnMount);
132
- let t16;
133
- if ($[22] !== loadOptionsKey || $[23] !== t14 || $[24] !== t15) {
134
- t16 = {
135
- queryKey: loadOptionsKey,
136
- queryFn: t14,
137
- enabled: t15,
138
- staleTime: 3e4,
139
- gcTime: 3e5
140
- };
141
- $[22] = loadOptionsKey;
142
- $[23] = t14;
143
- $[24] = t15;
144
- $[25] = t16;
145
- } else t16 = $[25];
146
- const { data: t17, isFetching } = useQuery(t16);
147
- let t18;
148
- if ($[26] !== t17) {
149
- t18 = t17 === void 0 ? [] : t17;
150
- $[26] = t17;
151
- $[27] = t18;
152
- } else t18 = $[27];
153
- const dynamicOptions = t18;
154
- let t19;
155
- bb0: {
156
- if (!loadOptions) {
157
- t19 = flatStaticOptions;
158
- break bb0;
159
- }
160
- if (flatStaticOptions.length === 0) {
161
- t19 = dynamicOptions;
162
- break bb0;
163
- }
164
- let t20$1;
165
- if ($[28] !== dynamicOptions || $[29] !== flatStaticOptions) {
166
- const mergedMap = [...flatStaticOptions, ...dynamicOptions].reduce(_temp, /* @__PURE__ */ new Map());
167
- t20$1 = Array.from(mergedMap.values());
168
- $[28] = dynamicOptions;
169
- $[29] = flatStaticOptions;
170
- $[30] = t20$1;
171
- } else t20$1 = $[30];
172
- t19 = t20$1;
173
- }
174
- const allOptions = t19;
175
- let t20;
176
- if ($[31] !== locale || $[32] !== resolveText || $[33] !== translate) {
177
- t20 = (option) => resolveOptionLabel({
178
- value: option.value,
179
- label: option.label,
68
+ ], [
69
+ queryKey,
70
+ deferredSearch,
71
+ instanceId
72
+ ]),
73
+ queryFn: () => loadOptions?.(deferredSearch) ?? Promise.resolve([]),
74
+ enabled: !!loadOptions && (open || prefetchOnMount),
75
+ staleTime: 3e4,
76
+ gcTime: 5 * 6e4
77
+ });
78
+ const allOptions = useMemo(() => {
79
+ if (!loadOptions) return flatStaticOptions;
80
+ if (flatStaticOptions.length === 0) return dynamicOptions;
81
+ const mergedMap = [...flatStaticOptions, ...dynamicOptions].reduce((map, opt) => new Map(map).set(opt.value, opt), /* @__PURE__ */ new Map());
82
+ return Array.from(mergedMap.values());
83
+ }, [
84
+ loadOptions,
85
+ dynamicOptions,
86
+ flatStaticOptions
87
+ ]);
88
+ const getOptionLabel = useCallback((option) => resolveOptionLabel({
89
+ value: option.value,
90
+ label: option.label,
91
+ resolveText,
92
+ t: translate,
93
+ locale
94
+ }), [
95
+ locale,
96
+ resolveText,
97
+ translate
98
+ ]);
99
+ const filteredOptions = useMemo(() => {
100
+ if (loadOptions) return allOptions;
101
+ if (!search) return allOptions;
102
+ return allOptions.filter((opt) => getOptionLabel(opt).toLowerCase().includes(search.toLowerCase()));
103
+ }, [
104
+ allOptions,
105
+ search,
106
+ loadOptions,
107
+ getOptionLabel
108
+ ]);
109
+ const getLabel = useCallback((val) => {
110
+ return resolveOptionLabel({
111
+ value: val,
112
+ label: allOptions.find((opt) => opt.value === val)?.label,
180
113
  resolveText,
181
114
  t: translate,
182
115
  locale
183
116
  });
184
- $[31] = locale;
185
- $[32] = resolveText;
186
- $[33] = translate;
187
- $[34] = t20;
188
- } else t20 = $[34];
189
- const getOptionLabel = t20;
190
- let t21;
191
- bb1: {
192
- if (loadOptions) {
193
- t21 = allOptions;
194
- break bb1;
117
+ }, [
118
+ allOptions,
119
+ locale,
120
+ resolveText,
121
+ translate
122
+ ]);
123
+ const handleToggle = useCallback((selectedValue) => {
124
+ const typedValue = selectedValue;
125
+ if (resolvedValue.includes(typedValue)) onChange(resolvedValue.filter((v) => v !== typedValue));
126
+ else {
127
+ if (maxSelections && resolvedValue.length >= maxSelections) return;
128
+ onChange([...resolvedValue, typedValue]);
195
129
  }
196
- if (!search) {
197
- t21 = allOptions;
198
- break bb1;
199
- }
200
- let t22$1;
201
- if ($[35] !== allOptions || $[36] !== getOptionLabel || $[37] !== search) {
202
- let t23$1;
203
- if ($[39] !== getOptionLabel || $[40] !== search) {
204
- t23$1 = (opt_0) => getOptionLabel(opt_0).toLowerCase().includes(search.toLowerCase());
205
- $[39] = getOptionLabel;
206
- $[40] = search;
207
- $[41] = t23$1;
208
- } else t23$1 = $[41];
209
- t22$1 = allOptions.filter(t23$1);
210
- $[35] = allOptions;
211
- $[36] = getOptionLabel;
212
- $[37] = search;
213
- $[38] = t22$1;
214
- } else t22$1 = $[38];
215
- t21 = t22$1;
216
- }
217
- const filteredOptions = t21;
218
- let t22;
219
- if ($[42] !== allOptions || $[43] !== locale || $[44] !== resolveText || $[45] !== translate) {
220
- t22 = (val) => {
221
- return resolveOptionLabel({
222
- value: val,
223
- label: allOptions.find((opt_1) => opt_1.value === val)?.label,
224
- resolveText,
225
- t: translate,
226
- locale
227
- });
228
- };
229
- $[42] = allOptions;
230
- $[43] = locale;
231
- $[44] = resolveText;
232
- $[45] = translate;
233
- $[46] = t22;
234
- } else t22 = $[46];
235
- const getLabel = t22;
236
- let t23;
237
- if ($[47] !== maxSelections || $[48] !== onChange || $[49] !== resolvedValue) {
238
- t23 = (selectedValue) => {
239
- const typedValue = selectedValue;
240
- if (resolvedValue.includes(typedValue)) onChange(resolvedValue.filter((v) => v !== typedValue));
241
- else {
242
- if (maxSelections && resolvedValue.length >= maxSelections) return;
243
- onChange([...resolvedValue, typedValue]);
244
- }
245
- };
246
- $[47] = maxSelections;
247
- $[48] = onChange;
248
- $[49] = resolvedValue;
249
- $[50] = t23;
250
- } else t23 = $[50];
251
- const handleToggle = t23;
252
- let t24;
253
- if ($[51] !== onChange || $[52] !== resolvedValue) {
254
- t24 = (removedValue, e) => {
255
- e?.preventDefault();
256
- e?.stopPropagation();
257
- onChange(resolvedValue.filter((v_0) => v_0 !== removedValue));
258
- };
259
- $[51] = onChange;
260
- $[52] = resolvedValue;
261
- $[53] = t24;
262
- } else t24 = $[53];
263
- const handleRemove = t24;
264
- let t25;
265
- if ($[54] !== onChange) {
266
- t25 = (e_0) => {
267
- e_0.preventDefault();
268
- e_0.stopPropagation();
269
- onChange([]);
270
- };
271
- $[54] = onChange;
272
- $[55] = t25;
273
- } else t25 = $[55];
274
- const handleClearAll = t25;
275
- let t26;
276
- if ($[56] !== disabled || $[57] !== handleClearAll || $[58] !== resolvedValue.length) {
277
- t26 = (event) => {
278
- if (resolvedValue.length > 0 && !disabled && (event.key === "Backspace" || event.key === "Delete")) handleClearAll(event);
279
- };
280
- $[56] = disabled;
281
- $[57] = handleClearAll;
282
- $[58] = resolvedValue.length;
283
- $[59] = t26;
284
- } else t26 = $[59];
285
- const handleTriggerKeyDown = t26;
130
+ }, [
131
+ resolvedValue,
132
+ onChange,
133
+ maxSelections
134
+ ]);
135
+ const handleRemove = useCallback((removedValue, e) => {
136
+ e?.preventDefault();
137
+ e?.stopPropagation();
138
+ onChange(resolvedValue.filter((v) => v !== removedValue));
139
+ }, [resolvedValue, onChange]);
140
+ const handleClearAll = useCallback((e) => {
141
+ e.preventDefault();
142
+ e.stopPropagation();
143
+ onChange([]);
144
+ }, [onChange]);
145
+ const handleTriggerKeyDown = useCallback((event) => {
146
+ if (resolvedValue.length > 0 && !disabled && (event.key === "Backspace" || event.key === "Delete")) handleClearAll(event);
147
+ }, [
148
+ disabled,
149
+ handleClearAll,
150
+ resolvedValue.length
151
+ ]);
286
152
  const showLoading = isFetching || externalLoading;
287
153
  const canAddMore = !maxSelections || resolvedValue.length < maxSelections;
288
- let t27;
289
- let t28;
290
- let t29;
291
- let t30;
292
- let t31;
293
- let t32;
294
- let t33;
295
- let t34;
296
- if ($[60] !== ariaInvalid || $[61] !== className || $[62] !== disabled || $[63] !== getLabel || $[64] !== handleRemove || $[65] !== id || $[66] !== maxVisibleChips || $[67] !== open || $[68] !== resolvedPlaceholder || $[69] !== resolvedValue || $[70] !== t) {
297
- const visibleChips = resolvedValue.slice(0, maxVisibleChips);
298
- const hiddenCount = resolvedValue.length - maxVisibleChips;
299
- t27 = id;
300
- t28 = "combobox";
301
- t29 = "select-multi-list";
302
- t30 = open;
303
- t31 = ariaInvalid;
304
- t32 = 0;
305
- const t35$1 = disabled && "cursor-not-allowed opacity-50";
306
- const t36$1 = ariaInvalid && "border-destructive ring-destructive/20";
307
- if ($[79] !== className || $[80] !== t35$1 || $[81] !== t36$1) {
308
- t33 = cn("qa-select-multi control-surface font-chrome flex h-auto min-h-[var(--control-height)] w-full flex-wrap items-center gap-1 px-3 py-1.5 text-sm", "hover:bg-surface-low focus-within:border-border-strong focus-within:ring-ring/20 aria-expanded:border-border-strong aria-expanded:ring-ring/20 focus-within:ring-3 aria-expanded:ring-3", t35$1, t36$1, className);
309
- $[79] = className;
310
- $[80] = t35$1;
311
- $[81] = t36$1;
312
- $[82] = t33;
313
- } else t33 = $[82];
314
- t34 = resolvedValue.length === 0 ? /* @__PURE__ */ jsx("span", {
154
+ const visibleChips = resolvedValue.slice(0, maxVisibleChips);
155
+ const hiddenCount = resolvedValue.length - maxVisibleChips;
156
+ const TriggerContent = /* @__PURE__ */ jsxs("div", {
157
+ id,
158
+ role: "combobox",
159
+ "aria-controls": "select-multi-list",
160
+ "aria-expanded": open,
161
+ "aria-invalid": ariaInvalid,
162
+ tabIndex: 0,
163
+ className: cn("qa-select-multi control-surface font-chrome flex h-auto min-h-[var(--control-height)] w-full flex-wrap items-center gap-1 px-3 py-1.5 text-sm", "hover:bg-surface-low focus-within:border-border-strong focus-within:ring-ring/20 aria-expanded:border-border-strong aria-expanded:ring-ring/20 focus-within:ring-3 aria-expanded:ring-3", disabled && "cursor-not-allowed opacity-50", ariaInvalid && "border-destructive ring-destructive/20", className),
164
+ children: [resolvedValue.length === 0 ? /* @__PURE__ */ jsx("span", {
315
165
  className: "text-muted-foreground text-xs",
316
166
  children: resolvedPlaceholder
317
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [visibleChips.map((val_0) => /* @__PURE__ */ jsxs(Badge, {
167
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [visibleChips.map((val) => /* @__PURE__ */ jsxs(Badge, {
318
168
  variant: "secondary",
319
169
  className: "min-h-7 gap-1 pr-1",
320
170
  children: [/* @__PURE__ */ jsx("span", {
321
171
  className: "max-w-24 truncate",
322
- children: getLabel(val_0)
172
+ children: getLabel(val)
323
173
  }), !disabled && /* @__PURE__ */ jsx("span", {
324
174
  "aria-hidden": "true",
325
175
  title: t("field.removeItem", "Remove option"),
326
- onPointerDown: (e_1) => handleRemove(val_0, e_1),
327
- onClick: (e_2) => handleRemove(val_0, e_2),
176
+ onPointerDown: (e) => handleRemove(val, e),
177
+ onClick: (e) => handleRemove(val, e),
328
178
  className: "hover:bg-muted-foreground/20 inline-flex size-5 items-center justify-center rounded-full transition-colors",
329
179
  children: /* @__PURE__ */ jsx(Icon, {
330
180
  icon: "ph:x",
331
181
  className: "size-2.5"
332
182
  })
333
183
  })]
334
- }, String(val_0))), hiddenCount > 0 && /* @__PURE__ */ jsxs(Badge, {
184
+ }, String(val))), hiddenCount > 0 && /* @__PURE__ */ jsxs(Badge, {
335
185
  variant: "outline",
336
186
  className: "text-muted-foreground",
337
187
  children: [
@@ -339,317 +189,108 @@ function SelectMulti(t0) {
339
189
  hiddenCount,
340
190
  " more"
341
191
  ]
342
- })] });
343
- $[60] = ariaInvalid;
344
- $[61] = className;
345
- $[62] = disabled;
346
- $[63] = getLabel;
347
- $[64] = handleRemove;
348
- $[65] = id;
349
- $[66] = maxVisibleChips;
350
- $[67] = open;
351
- $[68] = resolvedPlaceholder;
352
- $[69] = resolvedValue;
353
- $[70] = t;
354
- $[71] = t27;
355
- $[72] = t28;
356
- $[73] = t29;
357
- $[74] = t30;
358
- $[75] = t31;
359
- $[76] = t32;
360
- $[77] = t33;
361
- $[78] = t34;
362
- } else {
363
- t27 = $[71];
364
- t28 = $[72];
365
- t29 = $[73];
366
- t30 = $[74];
367
- t31 = $[75];
368
- t32 = $[76];
369
- t33 = $[77];
370
- t34 = $[78];
371
- }
372
- let t35;
373
- if ($[83] !== disabled || $[84] !== handleClearAll || $[85] !== resolvedValue.length || $[86] !== t) {
374
- t35 = resolvedValue.length > 0 && !disabled && /* @__PURE__ */ jsx("span", {
375
- "aria-hidden": "true",
376
- title: t("common.clear", "Clear all"),
377
- onPointerDown: handleClearAll,
378
- onClick: handleClearAll,
379
- className: "hover:bg-muted inline-flex size-6 items-center justify-center rounded-md opacity-60 transition-[background-color,opacity] hover:opacity-100",
380
- children: /* @__PURE__ */ jsx(Icon, {
381
- icon: "ph:x",
382
- className: "size-3"
383
- })
384
- });
385
- $[83] = disabled;
386
- $[84] = handleClearAll;
387
- $[85] = resolvedValue.length;
388
- $[86] = t;
389
- $[87] = t35;
390
- } else t35 = $[87];
391
- let t36;
392
- if ($[88] === Symbol.for("react.memo_cache_sentinel")) {
393
- t36 = /* @__PURE__ */ jsx(Icon, {
394
- icon: "ph:plus",
395
- className: "size-3.5 opacity-50"
396
- });
397
- $[88] = t36;
398
- } else t36 = $[88];
399
- let t37;
400
- if ($[89] !== t35) {
401
- t37 = /* @__PURE__ */ jsxs("div", {
192
+ })] }), /* @__PURE__ */ jsxs("div", {
402
193
  className: "ml-auto flex shrink-0 items-center gap-1",
403
- children: [t35, t36]
404
- });
405
- $[89] = t35;
406
- $[90] = t37;
407
- } else t37 = $[90];
408
- let t38;
409
- if ($[91] !== t27 || $[92] !== t28 || $[93] !== t29 || $[94] !== t30 || $[95] !== t31 || $[96] !== t32 || $[97] !== t33 || $[98] !== t34 || $[99] !== t37) {
410
- t38 = /* @__PURE__ */ jsxs("div", {
411
- id: t27,
412
- role: t28,
413
- "aria-controls": t29,
414
- "aria-expanded": t30,
415
- "aria-invalid": t31,
416
- tabIndex: t32,
417
- className: t33,
418
- children: [t34, t37]
419
- });
420
- $[91] = t27;
421
- $[92] = t28;
422
- $[93] = t29;
423
- $[94] = t30;
424
- $[95] = t31;
425
- $[96] = t32;
426
- $[97] = t33;
427
- $[98] = t34;
428
- $[99] = t37;
429
- $[100] = t38;
430
- } else t38 = $[100];
431
- const TriggerContent = t38;
432
- const t39 = !loadOptions;
433
- let t40;
434
- if ($[101] !== t) {
435
- t40 = t("ui.searchPlaceholder", "Search...");
436
- $[101] = t;
437
- $[102] = t40;
438
- } else t40 = $[102];
439
- let t41;
440
- if ($[103] !== search || $[104] !== t40) {
441
- t41 = /* @__PURE__ */ jsx(CommandInput, {
442
- placeholder: t40,
443
- value: search,
444
- onValueChange: setSearch
445
- });
446
- $[103] = search;
447
- $[104] = t40;
448
- $[105] = t41;
449
- } else t41 = $[105];
450
- let t42;
451
- if ($[106] !== showLoading) {
452
- t42 = showLoading && /* @__PURE__ */ jsx("div", {
453
- className: "flex items-center justify-center py-6",
454
- children: /* @__PURE__ */ jsx(Icon, {
455
- icon: "ph:circle-notch",
456
- className: "text-muted-foreground size-4 animate-spin"
457
- })
458
- });
459
- $[106] = showLoading;
460
- $[107] = t42;
461
- } else t42 = $[107];
462
- let t43;
463
- if ($[108] !== resolvedEmptyMessage) {
464
- t43 = /* @__PURE__ */ jsx(CommandEmpty, { children: resolvedEmptyMessage });
465
- $[108] = resolvedEmptyMessage;
466
- $[109] = t43;
467
- } else t43 = $[109];
468
- let t44;
469
- if ($[110] !== canAddMore || $[111] !== filteredOptions || $[112] !== getOptionLabel || $[113] !== handleToggle || $[114] !== resolvedValue) {
470
- let t45$1;
471
- if ($[116] !== canAddMore || $[117] !== getOptionLabel || $[118] !== handleToggle || $[119] !== resolvedValue) {
472
- t45$1 = (option_1) => {
473
- const isSelected_0 = resolvedValue.includes(option_1.value);
474
- const isDisabled = option_1.disabled || !isSelected_0 && !canAddMore;
475
- return /* @__PURE__ */ jsxs(CommandItem, {
476
- value: String(option_1.value),
477
- onSelect: handleToggle,
478
- disabled: isDisabled,
479
- children: [
480
- /* @__PURE__ */ jsx("div", {
481
- className: cn("flex size-4 items-center justify-center border", isSelected_0 ? "border-foreground bg-foreground text-background" : "border-muted-foreground/30"),
482
- children: isSelected_0 && /* @__PURE__ */ jsx(Icon, {
483
- icon: "ph:check",
484
- className: "size-3"
485
- })
486
- }),
487
- option_1.icon,
488
- /* @__PURE__ */ jsx("span", {
489
- className: "truncate",
490
- children: getOptionLabel(option_1)
491
- })
492
- ]
493
- }, String(option_1.value));
494
- };
495
- $[116] = canAddMore;
496
- $[117] = getOptionLabel;
497
- $[118] = handleToggle;
498
- $[119] = resolvedValue;
499
- $[120] = t45$1;
500
- } else t45$1 = $[120];
501
- t44 = filteredOptions.map(t45$1);
502
- $[110] = canAddMore;
503
- $[111] = filteredOptions;
504
- $[112] = getOptionLabel;
505
- $[113] = handleToggle;
506
- $[114] = resolvedValue;
507
- $[115] = t44;
508
- } else t44 = $[115];
509
- let t45;
510
- if ($[121] !== t44) {
511
- t45 = /* @__PURE__ */ jsx(CommandGroup, { children: t44 });
512
- $[121] = t44;
513
- $[122] = t45;
514
- } else t45 = $[122];
515
- let t46;
516
- if ($[123] !== t42 || $[124] !== t43 || $[125] !== t45) {
517
- t46 = /* @__PURE__ */ jsxs(CommandList, { children: [
518
- t42,
519
- t43,
520
- t45
521
- ] });
522
- $[123] = t42;
523
- $[124] = t43;
524
- $[125] = t45;
525
- $[126] = t46;
526
- } else t46 = $[126];
527
- let t47;
528
- if ($[127] !== maxSelections || $[128] !== resolvedValue.length) {
529
- t47 = maxSelections && /* @__PURE__ */ jsxs("div", {
530
- className: "text-muted-foreground border-t p-2 text-center text-xs tabular-nums",
531
- children: [
532
- resolvedValue.length,
533
- " / ",
534
- maxSelections,
535
- " selected"
536
- ]
537
- });
538
- $[127] = maxSelections;
539
- $[128] = resolvedValue.length;
540
- $[129] = t47;
541
- } else t47 = $[129];
542
- let t48;
543
- if ($[130] !== t39 || $[131] !== t41 || $[132] !== t46 || $[133] !== t47) {
544
- t48 = /* @__PURE__ */ jsxs(Command, {
545
- shouldFilter: t39,
546
- children: [
547
- t41,
548
- t46,
549
- t47
550
- ]
551
- });
552
- $[130] = t39;
553
- $[131] = t41;
554
- $[132] = t46;
555
- $[133] = t47;
556
- $[134] = t48;
557
- } else t48 = $[134];
558
- const CommandContent = t48;
559
- if (isMobile) {
560
- let t49$1;
561
- if ($[135] !== TriggerContent || $[136] !== disabled || $[137] !== handleTriggerKeyDown) {
562
- t49$1 = /* @__PURE__ */ jsx(DrawerTrigger, {
563
- asChild: true,
564
- children: /* @__PURE__ */ jsx("button", {
565
- type: "button",
566
- disabled,
567
- onKeyDown: handleTriggerKeyDown,
568
- className: "w-full text-left",
569
- children: TriggerContent
194
+ children: [resolvedValue.length > 0 && !disabled && /* @__PURE__ */ jsx("span", {
195
+ "aria-hidden": "true",
196
+ title: t("common.clear", "Clear all"),
197
+ onPointerDown: handleClearAll,
198
+ onClick: handleClearAll,
199
+ className: "hover:bg-muted inline-flex size-6 items-center justify-center rounded-md opacity-60 transition-[background-color,opacity] hover:opacity-100",
200
+ children: /* @__PURE__ */ jsx(Icon, {
201
+ icon: "ph:x",
202
+ className: "size-3"
570
203
  })
571
- });
572
- $[135] = TriggerContent;
573
- $[136] = disabled;
574
- $[137] = handleTriggerKeyDown;
575
- $[138] = t49$1;
576
- } else t49$1 = $[138];
577
- let t50$1;
578
- if ($[139] !== resolvedDrawerTitle) {
579
- t50$1 = /* @__PURE__ */ jsx(DrawerHeader, { children: /* @__PURE__ */ jsx(DrawerTitle, { children: resolvedDrawerTitle }) });
580
- $[139] = resolvedDrawerTitle;
581
- $[140] = t50$1;
582
- } else t50$1 = $[140];
583
- let t51$1;
584
- if ($[141] !== CommandContent) {
585
- t51$1 = /* @__PURE__ */ jsx("div", {
586
- className: "px-4 pb-6",
587
- children: CommandContent
588
- });
589
- $[141] = CommandContent;
590
- $[142] = t51$1;
591
- } else t51$1 = $[142];
592
- let t52;
593
- if ($[143] !== t50$1 || $[144] !== t51$1) {
594
- t52 = /* @__PURE__ */ jsxs(DrawerContent, { children: [t50$1, t51$1] });
595
- $[143] = t50$1;
596
- $[144] = t51$1;
597
- $[145] = t52;
598
- } else t52 = $[145];
599
- let t53;
600
- if ($[146] !== open || $[147] !== t49$1 || $[148] !== t52) {
601
- t53 = /* @__PURE__ */ jsxs(Drawer, {
602
- open,
603
- onOpenChange: setOpen,
604
- children: [t49$1, t52]
605
- });
606
- $[146] = open;
607
- $[147] = t49$1;
608
- $[148] = t52;
609
- $[149] = t53;
610
- } else t53 = $[149];
611
- return t53;
612
- }
613
- let t49;
614
- if ($[150] !== TriggerContent || $[151] !== disabled || $[152] !== handleTriggerKeyDown) {
615
- t49 = /* @__PURE__ */ jsx(PopoverTrigger, { render: /* @__PURE__ */ jsx("button", {
204
+ }), /* @__PURE__ */ jsx(Icon, {
205
+ icon: "ph:plus",
206
+ className: "size-3.5 opacity-50"
207
+ })]
208
+ })]
209
+ });
210
+ const CommandContent = /* @__PURE__ */ jsxs(Command, {
211
+ shouldFilter: !loadOptions,
212
+ children: [
213
+ /* @__PURE__ */ jsx(CommandInput, {
214
+ placeholder: t("ui.searchPlaceholder", "Search..."),
215
+ value: search,
216
+ onValueChange: setSearch
217
+ }),
218
+ /* @__PURE__ */ jsxs(CommandList, { children: [
219
+ showLoading && /* @__PURE__ */ jsx("div", {
220
+ className: "flex items-center justify-center py-6",
221
+ children: /* @__PURE__ */ jsx(Icon, {
222
+ icon: "ph:circle-notch",
223
+ className: "text-muted-foreground size-4 animate-spin"
224
+ })
225
+ }),
226
+ /* @__PURE__ */ jsx(CommandEmpty, { children: resolvedEmptyMessage }),
227
+ /* @__PURE__ */ jsx(CommandGroup, { children: filteredOptions.map((option) => {
228
+ const isSelected = resolvedValue.includes(option.value);
229
+ const isDisabled = option.disabled || !isSelected && !canAddMore;
230
+ return /* @__PURE__ */ jsxs(CommandItem, {
231
+ value: String(option.value),
232
+ onSelect: handleToggle,
233
+ disabled: isDisabled,
234
+ children: [
235
+ /* @__PURE__ */ jsx("div", {
236
+ className: cn("flex size-4 items-center justify-center border", isSelected ? "border-foreground bg-foreground text-background" : "border-muted-foreground/30"),
237
+ children: isSelected && /* @__PURE__ */ jsx(Icon, {
238
+ icon: "ph:check",
239
+ className: "size-3"
240
+ })
241
+ }),
242
+ option.icon,
243
+ /* @__PURE__ */ jsx("span", {
244
+ className: "truncate",
245
+ children: getOptionLabel(option)
246
+ })
247
+ ]
248
+ }, String(option.value));
249
+ }) })
250
+ ] }),
251
+ maxSelections && /* @__PURE__ */ jsxs("div", {
252
+ className: "text-muted-foreground border-t p-2 text-center text-xs tabular-nums",
253
+ children: [
254
+ resolvedValue.length,
255
+ " / ",
256
+ maxSelections,
257
+ " selected"
258
+ ]
259
+ })
260
+ ]
261
+ });
262
+ if (isMobile) return /* @__PURE__ */ jsxs(Drawer, {
263
+ open,
264
+ onOpenChange: setOpen,
265
+ children: [/* @__PURE__ */ jsx(DrawerTrigger, {
266
+ asChild: true,
267
+ children: /* @__PURE__ */ jsx("button", {
268
+ type: "button",
269
+ disabled,
270
+ onKeyDown: handleTriggerKeyDown,
271
+ className: "w-full text-left",
272
+ children: TriggerContent
273
+ })
274
+ }), /* @__PURE__ */ jsxs(DrawerContent, { children: [/* @__PURE__ */ jsx(DrawerHeader, { children: /* @__PURE__ */ jsx(DrawerTitle, { children: resolvedDrawerTitle }) }), /* @__PURE__ */ jsx("div", {
275
+ className: "px-4 pb-6",
276
+ children: CommandContent
277
+ })] })]
278
+ });
279
+ return /* @__PURE__ */ jsxs(Popover, {
280
+ open,
281
+ onOpenChange: setOpen,
282
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, { render: /* @__PURE__ */ jsx("button", {
616
283
  type: "button",
617
284
  disabled,
618
285
  onKeyDown: handleTriggerKeyDown,
619
286
  className: "w-full text-left",
620
287
  children: TriggerContent
621
- }) });
622
- $[150] = TriggerContent;
623
- $[151] = disabled;
624
- $[152] = handleTriggerKeyDown;
625
- $[153] = t49;
626
- } else t49 = $[153];
627
- let t50;
628
- if ($[154] !== CommandContent) {
629
- t50 = /* @__PURE__ */ jsx(PopoverContent, {
288
+ }) }), /* @__PURE__ */ jsx(PopoverContent, {
630
289
  className: "w-(--anchor-width) p-0",
631
290
  align: "start",
632
291
  children: CommandContent
633
- });
634
- $[154] = CommandContent;
635
- $[155] = t50;
636
- } else t50 = $[155];
637
- let t51;
638
- if ($[156] !== open || $[157] !== t49 || $[158] !== t50) {
639
- t51 = /* @__PURE__ */ jsxs(Popover, {
640
- open,
641
- onOpenChange: setOpen,
642
- children: [t49, t50]
643
- });
644
- $[156] = open;
645
- $[157] = t49;
646
- $[158] = t50;
647
- $[159] = t51;
648
- } else t51 = $[159];
649
- return t51;
650
- }
651
- function _temp(map, opt) {
652
- return new Map(map).set(opt.value, opt);
292
+ })]
293
+ });
653
294
  }
654
295
 
655
296
  //#endregion