@mercurjs/vendor 2.0.0-canary.0

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 (290) hide show
  1. package/dist/[id]-23D3HY3G.js +444 -0
  2. package/dist/[id]-2VBOAZM4.js +1215 -0
  3. package/dist/[id]-A4FSDRER.js +325 -0
  4. package/dist/[id]-E45G2SDA.js +213 -0
  5. package/dist/[id]-FXKSI52D.js +477 -0
  6. package/dist/[id]-HHZ3BSXV.js +1166 -0
  7. package/dist/[id]-MIV4U5UW.js +137 -0
  8. package/dist/[id]-QSRIPPIP.js +612 -0
  9. package/dist/[id]-RGDXOC7T.js +499 -0
  10. package/dist/[id]-TI2MOR2C.js +377 -0
  11. package/dist/[id]-U5DT2ZLS.js +301 -0
  12. package/dist/[id]-UMFGLDM2.js +354 -0
  13. package/dist/[id]-VTFOP3BF.js +97 -0
  14. package/dist/[id]-ZYF75L6G.js +479 -0
  15. package/dist/[location_id]-4UIEW5KM.js +685 -0
  16. package/dist/[province_id]-ZCHPXXQN.js +205 -0
  17. package/dist/add-KNDQL6YN.js +660 -0
  18. package/dist/add-customer-groups-JA346MTF.js +275 -0
  19. package/dist/add-products-2VB57KXV.js +273 -0
  20. package/dist/add-promotions-KVKEP6EO.js +260 -0
  21. package/dist/add-to-campaign-V6D7JKRS.js +44 -0
  22. package/dist/additional-attributes-E36EZX4V.js +219 -0
  23. package/dist/adjust-inventory-P7AB7VIB.js +228 -0
  24. package/dist/allocate-items-QAS5PZLR.js +529 -0
  25. package/dist/areas-Y7VDWH7G.js +151 -0
  26. package/dist/attributes-UEM2VJKV.js +277 -0
  27. package/dist/breadcrumb-3QTVWXZB.js +27 -0
  28. package/dist/breadcrumb-5OTOCYNL.js +38 -0
  29. package/dist/breadcrumb-6NAAOPIY.js +11 -0
  30. package/dist/breadcrumb-ASB2YCNV.js +25 -0
  31. package/dist/breadcrumb-CIGKLKKS.js +28 -0
  32. package/dist/breadcrumb-EOYLR3IQ.js +22 -0
  33. package/dist/breadcrumb-LENACUAA.js +22 -0
  34. package/dist/breadcrumb-LIXGWUQF.js +44 -0
  35. package/dist/breadcrumb-MOQ7GI3Z.js +27 -0
  36. package/dist/breadcrumb-NCBGPQML.js +23 -0
  37. package/dist/breadcrumb-OVMEC5OZ.js +33 -0
  38. package/dist/breadcrumb-RIXJ5QSX.js +45 -0
  39. package/dist/breadcrumb-TZB6EWNC.js +31 -0
  40. package/dist/breadcrumb-WP34OXGQ.js +23 -0
  41. package/dist/campaigns-PMVKUFEA.js +28 -0
  42. package/dist/categories-CKKIUMYG.js +27 -0
  43. package/dist/chunk-26OOAKQ6.js +18 -0
  44. package/dist/chunk-2C3HUJ3Z.js +222 -0
  45. package/dist/chunk-2F3H6ORE.js +36 -0
  46. package/dist/chunk-2ZFELO2L.js +13 -0
  47. package/dist/chunk-3CK6OINO.js +448 -0
  48. package/dist/chunk-3EF54XFY.js +64 -0
  49. package/dist/chunk-3LPVUPZZ.js +74 -0
  50. package/dist/chunk-3QSRE5LS.js +161 -0
  51. package/dist/chunk-3SIDRPKT.js +185 -0
  52. package/dist/chunk-4F5GP7J7.js +45 -0
  53. package/dist/chunk-4GPAS5GW.js +36 -0
  54. package/dist/chunk-4MFMCZEJ.js +70 -0
  55. package/dist/chunk-4TBDDMFP.js +425 -0
  56. package/dist/chunk-4TLP3TAA.js +34 -0
  57. package/dist/chunk-54TMLQH3.js +9 -0
  58. package/dist/chunk-5NF4OTVV.js +169 -0
  59. package/dist/chunk-66V3GFSW.js +138 -0
  60. package/dist/chunk-6EYGH3TB.js +26 -0
  61. package/dist/chunk-6IJMSVC6.js +16 -0
  62. package/dist/chunk-6YA3C4NB.js +55 -0
  63. package/dist/chunk-7AV5EJJ5.js +29 -0
  64. package/dist/chunk-7RPRNVBS.js +45 -0
  65. package/dist/chunk-A2SY5L5G.js +183 -0
  66. package/dist/chunk-A5DJIOHN.js +4 -0
  67. package/dist/chunk-AIFLEWO2.js +56 -0
  68. package/dist/chunk-ASVMGV2B.js +80 -0
  69. package/dist/chunk-AW77UWCZ.js +363 -0
  70. package/dist/chunk-AYUG34XF.js +84 -0
  71. package/dist/chunk-AYVH6Q5O.js +31 -0
  72. package/dist/chunk-B2RVONU7.js +160 -0
  73. package/dist/chunk-BCU3FKP2.js +18 -0
  74. package/dist/chunk-BDGZ4EQO.js +86 -0
  75. package/dist/chunk-BDZOSMAX.js +23 -0
  76. package/dist/chunk-C6SUTRP2.js +13 -0
  77. package/dist/chunk-CDIZEXFJ.js +145 -0
  78. package/dist/chunk-CFETU5BI.js +261 -0
  79. package/dist/chunk-CMHI2RPL.js +20 -0
  80. package/dist/chunk-CP5IL4P6.js +98 -0
  81. package/dist/chunk-CUO22GTM.js +96 -0
  82. package/dist/chunk-CVVYQI5F.js +41 -0
  83. package/dist/chunk-DARJTN4I.js +60 -0
  84. package/dist/chunk-DB6ANJBO.js +35 -0
  85. package/dist/chunk-DC2K6CFQ.js +86 -0
  86. package/dist/chunk-DDEIH66R.js +123 -0
  87. package/dist/chunk-DY3XQPHC.js +31 -0
  88. package/dist/chunk-DYUTYBAQ.js +67 -0
  89. package/dist/chunk-E3MNEQID.js +24 -0
  90. package/dist/chunk-FBZHM2QZ.js +247 -0
  91. package/dist/chunk-FDZC3TFZ.js +717 -0
  92. package/dist/chunk-FGCKXH45.js +263 -0
  93. package/dist/chunk-FMFVTERD.js +0 -0
  94. package/dist/chunk-FOMEBUX6.js +89 -0
  95. package/dist/chunk-FQERBIVS.js +0 -0
  96. package/dist/chunk-GC33DBKG.js +143 -0
  97. package/dist/chunk-GDMNHL7E.js +144 -0
  98. package/dist/chunk-GTUR4HSV.js +53 -0
  99. package/dist/chunk-H35HHFTB.js +225 -0
  100. package/dist/chunk-HB3BP55W.js +25 -0
  101. package/dist/chunk-HHD2VUED.js +29 -0
  102. package/dist/chunk-HUNGNEPY.js +312 -0
  103. package/dist/chunk-HUZG6A3X.js +127 -0
  104. package/dist/chunk-INNFZYX2.js +183 -0
  105. package/dist/chunk-IQPN4PZJ.js +749 -0
  106. package/dist/chunk-IZ5RG5XI.js +72 -0
  107. package/dist/chunk-J2XP7VRG.js +1080 -0
  108. package/dist/chunk-JHIMVLB2.js +42 -0
  109. package/dist/chunk-JKXAL7WR.js +92 -0
  110. package/dist/chunk-JRTZWK77.js +1764 -0
  111. package/dist/chunk-JVBLYMY2.js +268 -0
  112. package/dist/chunk-JXP5YZ77.js +86 -0
  113. package/dist/chunk-KAZ5BYTQ.js +132 -0
  114. package/dist/chunk-KHHY7EEM.js +267 -0
  115. package/dist/chunk-LAVHRER2.js +17 -0
  116. package/dist/chunk-LQSLDDPT.js +67 -0
  117. package/dist/chunk-LWVBKUUL.js +77 -0
  118. package/dist/chunk-LYUCDASZ.js +115 -0
  119. package/dist/chunk-LZ7QV42C.js +37 -0
  120. package/dist/chunk-MAEP2UCK.js +110 -0
  121. package/dist/chunk-MG4GKUJW.js +31 -0
  122. package/dist/chunk-N2TQXB44.js +1280 -0
  123. package/dist/chunk-N3T24SEK.js +32 -0
  124. package/dist/chunk-NANYVBFI.js +106 -0
  125. package/dist/chunk-NCMUZ6BQ.js +0 -0
  126. package/dist/chunk-NCYTM57J.js +160 -0
  127. package/dist/chunk-NX26QE2O.js +47 -0
  128. package/dist/chunk-NYDJTWRL.js +389 -0
  129. package/dist/chunk-O5LRZEG6.js +253 -0
  130. package/dist/chunk-O6PRBSFL.js +115 -0
  131. package/dist/chunk-OJCDB3N5.js +539 -0
  132. package/dist/chunk-OSFOX7MG.js +176 -0
  133. package/dist/chunk-OVPAOBZB.js +110 -0
  134. package/dist/chunk-PADOWAXM.js +118 -0
  135. package/dist/chunk-PHOCVOZ5.js +9 -0
  136. package/dist/chunk-PKBMQBKP.js +7 -0
  137. package/dist/chunk-PLSJ74T2.js +298 -0
  138. package/dist/chunk-PVZBDWLK.js +41 -0
  139. package/dist/chunk-PWZKFTJS.js +247 -0
  140. package/dist/chunk-PXYDR7WQ.js +48 -0
  141. package/dist/chunk-PYQJ5N25.js +191 -0
  142. package/dist/chunk-Q4UVXS46.js +14 -0
  143. package/dist/chunk-QDPLZDMX.js +17 -0
  144. package/dist/chunk-QSGR43JM.js +30 -0
  145. package/dist/chunk-QUNDGPF7.js +92801 -0
  146. package/dist/chunk-R65A4P4H.js +136 -0
  147. package/dist/chunk-RE7YXVFG.js +128 -0
  148. package/dist/chunk-RETT6WME.js +37 -0
  149. package/dist/chunk-RHKRREUU.js +15 -0
  150. package/dist/chunk-RIILGKYR.js +32 -0
  151. package/dist/chunk-RM5RSDYP.js +353 -0
  152. package/dist/chunk-RNC4NFVK.js +170 -0
  153. package/dist/chunk-RSMZHZI2.js +2078 -0
  154. package/dist/chunk-RXM4B6HR.js +8 -0
  155. package/dist/chunk-S2WEYEQR.js +14 -0
  156. package/dist/chunk-S3PQKKNV.js +49 -0
  157. package/dist/chunk-S5GQ2SES.js +276 -0
  158. package/dist/chunk-SECZTXSU.js +31 -0
  159. package/dist/chunk-SI4ALL7W.js +180 -0
  160. package/dist/chunk-SID3COTK.js +21 -0
  161. package/dist/chunk-SMQT3ZNO.js +8 -0
  162. package/dist/chunk-SOZMJA7V.js +61 -0
  163. package/dist/chunk-TG3TCIL6.js +207 -0
  164. package/dist/chunk-THHRRYRS.js +16 -0
  165. package/dist/chunk-TKGWSUEI.js +0 -0
  166. package/dist/chunk-TTFCO5HU.js +173 -0
  167. package/dist/chunk-TXEPCJEQ.js +430 -0
  168. package/dist/chunk-U2EI2ZLM.js +32 -0
  169. package/dist/chunk-U2ZFCAPX.js +34 -0
  170. package/dist/chunk-U3X4DNV6.js +179 -0
  171. package/dist/chunk-UXKKD4AD.js +437 -0
  172. package/dist/chunk-UYJ65N46.js +261 -0
  173. package/dist/chunk-VDWGP2U6.js +71 -0
  174. package/dist/chunk-VGJTARSA.js +89 -0
  175. package/dist/chunk-VHMGJUYN.js +28 -0
  176. package/dist/chunk-VKC3XKFF.js +283 -0
  177. package/dist/chunk-VKOE5J66.js +31 -0
  178. package/dist/chunk-VOHEQ7B5.js +31 -0
  179. package/dist/chunk-VW56KWO2.js +9 -0
  180. package/dist/chunk-W4KHJ4D6.js +74 -0
  181. package/dist/chunk-W6Y3PPU5.js +73 -0
  182. package/dist/chunk-W6ZVQJYB.js +311 -0
  183. package/dist/chunk-WA3IVAUC.js +123 -0
  184. package/dist/chunk-WHTS4G5K.js +1551 -0
  185. package/dist/chunk-WIYFXWRI.js +30 -0
  186. package/dist/chunk-WPFTRRWV.js +455 -0
  187. package/dist/chunk-WQZ4ONQV.js +6 -0
  188. package/dist/chunk-WS652CCV.js +893 -0
  189. package/dist/chunk-XG4PTPRM.js +0 -0
  190. package/dist/chunk-XRNDVICA.js +85 -0
  191. package/dist/chunk-XXZJISPX.js +48 -0
  192. package/dist/chunk-Y224F4UU.js +81 -0
  193. package/dist/chunk-Y3FR5JC7.js +437 -0
  194. package/dist/chunk-Y4VBOHAP.js +111 -0
  195. package/dist/chunk-Y7QKP6QU.js +35 -0
  196. package/dist/chunk-YVCBMOJG.js +50 -0
  197. package/dist/chunk-Z2WPXJ6J.js +146 -0
  198. package/dist/chunk-ZA2KFUFR.js +19 -0
  199. package/dist/chunk-ZEKV7LGF.js +6 -0
  200. package/dist/chunk-ZFFA36DB.js +186 -0
  201. package/dist/chunk-ZPGWTLF2.js +499 -0
  202. package/dist/chunk-ZVT2QSWR.js +263 -0
  203. package/dist/chunk-ZZ7VKT2S.js +4113 -0
  204. package/dist/collections-TREF67TO.js +63 -0
  205. package/dist/configuration-KWAL2QZ5.js +152 -0
  206. package/dist/configuration-RNWBTRAH.js +205 -0
  207. package/dist/create-7UEEO5TM.js +125 -0
  208. package/dist/create-DTCDJMIT.js +634 -0
  209. package/dist/create-DYDRAY6V.js +622 -0
  210. package/dist/create-EJM5C2XP.js +27 -0
  211. package/dist/create-F7OMPGZV.js +853 -0
  212. package/dist/create-G4UJOJJ6.js +69 -0
  213. package/dist/create-IE6MYOIY.js +170 -0
  214. package/dist/create-L23TGTBH.js +225 -0
  215. package/dist/create-LOBCFTCT.js +583 -0
  216. package/dist/create-MKBBF2V3.js +150 -0
  217. package/dist/create-TFDUNJSI.js +163 -0
  218. package/dist/create-TMTZDKII.js +711 -0
  219. package/dist/create-XGF6DB5F.js +239 -0
  220. package/dist/create-YAAK7JQ3.js +1052 -0
  221. package/dist/create-YPCVTXAK.js +194 -0
  222. package/dist/create-ZU362U3B.js +310 -0
  223. package/dist/customers-4QWR5UOL.js +27 -0
  224. package/dist/edit-2QA5BVOY.js +735 -0
  225. package/dist/edit-47I7VVNB.js +167 -0
  226. package/dist/edit-5BUGSOTL.js +255 -0
  227. package/dist/edit-7LQATDUD.js +193 -0
  228. package/dist/edit-AQAPYMDY.js +260 -0
  229. package/dist/edit-BQLSTFTQ.js +138 -0
  230. package/dist/edit-BYXHU3IG.js +308 -0
  231. package/dist/edit-DG3MY3ZH.js +244 -0
  232. package/dist/edit-J3LD76JS.js +192 -0
  233. package/dist/edit-J6WCPHDS.js +205 -0
  234. package/dist/edit-KCZVZLSZ.js +131 -0
  235. package/dist/edit-LOKLQGM2.js +181 -0
  236. package/dist/edit-MDTTTB33.js +104 -0
  237. package/dist/edit-NFSU2K3O.js +413 -0
  238. package/dist/edit-RHNZWNXD.js +89 -0
  239. package/dist/edit-XU33IVZH.js +204 -0
  240. package/dist/edit-ZMINDMGM.js +116 -0
  241. package/dist/edit-budget-Z5USV462.js +145 -0
  242. package/dist/edit-inventory-item-YFW2AFRD.js +128 -0
  243. package/dist/edit-inventory-item-attributes-IYAMJDTB.js +278 -0
  244. package/dist/fulfillment-SKXAF3BZ.js +545 -0
  245. package/dist/fulfillment-providers-ACERVITQ.js +279 -0
  246. package/dist/home-PP7YYCSB.js +16 -0
  247. package/dist/index.css +6 -0
  248. package/dist/index.d.ts +39 -0
  249. package/dist/index.js +3656 -0
  250. package/dist/inventory-AIRQ2KNS.js +26 -0
  251. package/dist/locations-SQKM7JWN.js +23 -0
  252. package/dist/login-LKFCRHXN.js +35 -0
  253. package/dist/manage-locations-4PQS4QY7.js +195 -0
  254. package/dist/media-PL477QJO.js +703 -0
  255. package/dist/metadata-42MU3H7T.js +60 -0
  256. package/dist/metadata-DIJTVDF7.js +45 -0
  257. package/dist/metadata-NX3LEEB3.js +64 -0
  258. package/dist/metadata-RBDSM567.js +65 -0
  259. package/dist/metadata-VZTWNZPG.js +66 -0
  260. package/dist/metadata-X3XGQ563.js +67 -0
  261. package/dist/no-match-BO2NNLCM.js +33 -0
  262. package/dist/orders-2KHCHNO5.js +59 -0
  263. package/dist/organization-VQXCKHCN.js +233 -0
  264. package/dist/organize-3F5ZUIGB.js +23 -0
  265. package/dist/organize-WPWEPCF7.js +23 -0
  266. package/dist/pages/index.d.ts +1153 -0
  267. package/dist/pages/index.js +198 -0
  268. package/dist/payouts-3BY73LZ3.js +27 -0
  269. package/dist/price-lists-G256JJN7.js +34 -0
  270. package/dist/prices-EW7KBY6R.js +269 -0
  271. package/dist/pricing-3PUJDOZN.js +313 -0
  272. package/dist/product-tags-PI3RENEX.js +80 -0
  273. package/dist/product-types-WJPLJI7H.js +32 -0
  274. package/dist/product-variant-detail-EYTE7PHL.js +377 -0
  275. package/dist/product-variant-edit-PW7W5J5E.js +402 -0
  276. package/dist/products-GSN4I7BT.js +272 -0
  277. package/dist/products-RFYNEY57.js +85 -0
  278. package/dist/promotions-CIZIDQ64.js +31 -0
  279. package/dist/reset-password-OFUSH363.js +299 -0
  280. package/dist/return-reasons-4V2KVSRI.js +52 -0
  281. package/dist/sales-channels-MBWVM3X2.js +184 -0
  282. package/dist/sales-channels-ZKA62EAW.js +156 -0
  283. package/dist/seller-ZFDLKF5Y.js +36 -0
  284. package/dist/settings-NP2IAID5.js +111 -0
  285. package/dist/shipping-profile-7FTHSPY2.js +145 -0
  286. package/dist/shipping-profiles-7R6L65WG.js +43 -0
  287. package/dist/stock-ENMBCZRY.js +502 -0
  288. package/dist/stock-VYDJY46S.js +278 -0
  289. package/dist/tax-regions-V6G6244H.js +87 -0
  290. package/package.json +87 -0
@@ -0,0 +1,1551 @@
1
+ import {
2
+ DataTableSearch,
3
+ useSelectedParams
4
+ } from "./chunk-LYUCDASZ.js";
5
+ import {
6
+ DataTableOrderBy
7
+ } from "./chunk-KAZ5BYTQ.js";
8
+ import {
9
+ NoRecords,
10
+ NoResults
11
+ } from "./chunk-3EF54XFY.js";
12
+ import {
13
+ useDate
14
+ } from "./chunk-CFETU5BI.js";
15
+ import {
16
+ TableSkeleton
17
+ } from "./chunk-INNFZYX2.js";
18
+
19
+ // src/components/table/data-table/data-table.tsx
20
+ import { clx as clx8 } from "@medusajs/ui";
21
+ import { memo } from "react";
22
+
23
+ // src/components/table/data-table/data-table-filter/data-table-filter.tsx
24
+ import { Button, clx as clx6 } from "@medusajs/ui";
25
+ import { Popover as RadixPopover6 } from "radix-ui";
26
+ import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef, useState as useState5 } from "react";
27
+ import { useSearchParams } from "react-router-dom";
28
+ import { useTranslation as useTranslation5 } from "react-i18next";
29
+
30
+ // src/components/table/data-table/data-table-filter/context.tsx
31
+ import { createContext, useContext } from "react";
32
+ var DataTableFilterContext = createContext(null);
33
+ var useDataTableFilterContext = () => {
34
+ const ctx = useContext(DataTableFilterContext);
35
+ if (!ctx) {
36
+ throw new Error(
37
+ "useDataTableFacetedFilterContext must be used within a DataTableFacetedFilter"
38
+ );
39
+ }
40
+ return ctx;
41
+ };
42
+
43
+ // src/components/table/data-table/data-table-filter/date-filter.tsx
44
+ import { EllipseMiniSolid } from "@medusajs/icons";
45
+ import { DatePicker, Text as Text2, clx as clx2 } from "@medusajs/ui";
46
+ import isEqual from "lodash.isequal";
47
+ import { Popover as RadixPopover2 } from "radix-ui";
48
+ import { useMemo, useState } from "react";
49
+ import { t } from "i18next";
50
+ import { useTranslation as useTranslation2 } from "react-i18next";
51
+
52
+ // src/components/table/data-table/data-table-filter/filter-chip.tsx
53
+ import { XMarkMini } from "@medusajs/icons";
54
+ import { Text, clx } from "@medusajs/ui";
55
+ import { Popover as RadixPopover } from "radix-ui";
56
+ import { useTranslation } from "react-i18next";
57
+ import { jsx, jsxs } from "react/jsx-runtime";
58
+ var FilterChip = ({
59
+ hadPreviousValue,
60
+ label,
61
+ value,
62
+ readonly,
63
+ hasOperator,
64
+ onRemove
65
+ }) => {
66
+ const { t: t2 } = useTranslation();
67
+ const handleRemove = (e) => {
68
+ e.stopPropagation();
69
+ onRemove();
70
+ };
71
+ return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-field transition-fg shadow-borders-base text-ui-fg-subtle flex cursor-default select-none items-stretch overflow-hidden rounded-md", children: [
72
+ !hadPreviousValue && /* @__PURE__ */ jsx(RadixPopover.Anchor, {}),
73
+ /* @__PURE__ */ jsx(
74
+ "div",
75
+ {
76
+ className: clx(
77
+ "flex items-center justify-center whitespace-nowrap px-2 py-1",
78
+ {
79
+ "border-r": !!(value || hadPreviousValue)
80
+ }
81
+ ),
82
+ children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: label })
83
+ }
84
+ ),
85
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center overflow-hidden", children: [
86
+ hasOperator && !!(value || hadPreviousValue) && /* @__PURE__ */ jsx("div", { className: "border-r p-1 px-2", children: /* @__PURE__ */ jsx(
87
+ Text,
88
+ {
89
+ size: "small",
90
+ weight: "plus",
91
+ leading: "compact",
92
+ className: "text-ui-fg-muted",
93
+ children: t2("general.is")
94
+ }
95
+ ) }),
96
+ !!(value || hadPreviousValue) && /* @__PURE__ */ jsx(
97
+ RadixPopover.Trigger,
98
+ {
99
+ asChild: true,
100
+ className: clx(
101
+ "flex-1 cursor-pointer overflow-hidden border-r p-1 px-2",
102
+ {
103
+ "hover:bg-ui-bg-field-hover": !readonly,
104
+ "data-[state=open]:bg-ui-bg-field-hover": !readonly
105
+ }
106
+ ),
107
+ children: /* @__PURE__ */ jsx(
108
+ Text,
109
+ {
110
+ size: "small",
111
+ leading: "compact",
112
+ weight: "plus",
113
+ className: "truncate text-nowrap",
114
+ children: value || "\xA0"
115
+ }
116
+ )
117
+ }
118
+ )
119
+ ] }),
120
+ !readonly && !!(value || hadPreviousValue) && /* @__PURE__ */ jsx(
121
+ "button",
122
+ {
123
+ onClick: handleRemove,
124
+ className: clx(
125
+ "text-ui-fg-muted transition-fg flex items-center justify-center p-1",
126
+ "hover:bg-ui-bg-subtle-hover",
127
+ "active:bg-ui-bg-subtle-pressed active:text-ui-fg-base"
128
+ ),
129
+ children: /* @__PURE__ */ jsx(XMarkMini, {})
130
+ }
131
+ )
132
+ ] });
133
+ };
134
+ var filter_chip_default = FilterChip;
135
+
136
+ // src/components/table/data-table/data-table-filter/date-filter.tsx
137
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
138
+ var DateFilter = ({
139
+ filter,
140
+ prefix,
141
+ readonly,
142
+ openOnMount
143
+ }) => {
144
+ const [open, setOpen] = useState(openOnMount);
145
+ const [showCustom, setShowCustom] = useState(false);
146
+ const { getFullDate } = useDate();
147
+ const { key, label } = filter;
148
+ const { removeFilter } = useDataTableFilterContext();
149
+ const selectedParams = useSelectedParams({ param: key, prefix });
150
+ const presets = usePresets();
151
+ const handleSelectPreset = (value) => {
152
+ selectedParams.add(JSON.stringify(value));
153
+ setShowCustom(false);
154
+ };
155
+ const handleSelectCustom = () => {
156
+ selectedParams.delete();
157
+ setShowCustom((prev) => !prev);
158
+ };
159
+ const currentValue = selectedParams.get();
160
+ const currentDateComparison = parseDateComparison(currentValue);
161
+ const customStartValue = getDateFromComparison(currentDateComparison, "$gte");
162
+ const customEndValue = getDateFromComparison(currentDateComparison, "$lte");
163
+ const handleCustomDateChange = (value, pos) => {
164
+ const key2 = pos === "start" ? "$gte" : "$lte";
165
+ let dateValue = value;
166
+ if (key2 === "$lte" && value) {
167
+ dateValue = new Date(value.getTime());
168
+ dateValue.setHours(23, 59, 59, 999);
169
+ }
170
+ selectedParams.add(
171
+ JSON.stringify({
172
+ ...currentDateComparison || {},
173
+ [key2]: dateValue?.toISOString()
174
+ })
175
+ );
176
+ };
177
+ const getDisplayValueFromPresets = () => {
178
+ const preset = presets.find((p) => isEqual(p.value, currentDateComparison));
179
+ return preset?.label;
180
+ };
181
+ const formatCustomDate = (date) => {
182
+ return date ? getFullDate({ date }) : void 0;
183
+ };
184
+ const getCustomDisplayValue = () => {
185
+ const formattedDates = [customStartValue, customEndValue].map(
186
+ formatCustomDate
187
+ );
188
+ return formattedDates.filter(Boolean).join(" - ");
189
+ };
190
+ const displayValue = getDisplayValueFromPresets() || getCustomDisplayValue();
191
+ const [previousValue, setPreviousValue] = useState(
192
+ displayValue
193
+ );
194
+ const handleRemove = () => {
195
+ selectedParams.delete();
196
+ removeFilter(key);
197
+ };
198
+ let timeoutId = null;
199
+ const handleOpenChange = (open2) => {
200
+ setOpen(open2);
201
+ setPreviousValue(displayValue);
202
+ if (timeoutId) {
203
+ clearTimeout(timeoutId);
204
+ }
205
+ if (!open2 && !currentValue.length) {
206
+ timeoutId = setTimeout(() => {
207
+ removeFilter(key);
208
+ }, 200);
209
+ }
210
+ };
211
+ return /* @__PURE__ */ jsxs2(RadixPopover2.Root, { modal: true, open, onOpenChange: handleOpenChange, children: [
212
+ /* @__PURE__ */ jsx2(
213
+ filter_chip_default,
214
+ {
215
+ hadPreviousValue: !!previousValue,
216
+ label,
217
+ value: displayValue,
218
+ onRemove: handleRemove,
219
+ readonly
220
+ }
221
+ ),
222
+ !readonly && /* @__PURE__ */ jsx2(RadixPopover2.Portal, { children: /* @__PURE__ */ jsxs2(
223
+ RadixPopover2.Content,
224
+ {
225
+ "data-name": "date_filter_content",
226
+ align: "start",
227
+ sideOffset: 8,
228
+ collisionPadding: 24,
229
+ className: clx2(
230
+ "bg-ui-bg-base text-ui-fg-base shadow-elevation-flyout h-full max-h-[var(--radix-popper-available-height)] w-[300px] overflow-auto rounded-lg"
231
+ ),
232
+ onInteractOutside: (e) => {
233
+ if (e.target instanceof HTMLElement) {
234
+ if (e.target.attributes.getNamedItem("data-name")?.value === "filters_menu_content") {
235
+ e.preventDefault();
236
+ }
237
+ }
238
+ },
239
+ children: [
240
+ /* @__PURE__ */ jsxs2("ul", { className: "w-full p-1", children: [
241
+ presets.map((preset) => {
242
+ const isSelected = selectedParams.get().includes(JSON.stringify(preset.value));
243
+ return /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs2(
244
+ "button",
245
+ {
246
+ className: "bg-ui-bg-base hover:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-pressed text-ui-fg-base data-[disabled]:text-ui-fg-disabled txt-compact-small relative flex w-full cursor-pointer select-none items-center rounded-md px-2 py-1.5 outline-none transition-colors data-[disabled]:pointer-events-none",
247
+ type: "button",
248
+ onClick: () => {
249
+ handleSelectPreset(preset.value);
250
+ },
251
+ children: [
252
+ /* @__PURE__ */ jsx2(
253
+ "div",
254
+ {
255
+ className: clx2(
256
+ "transition-fg flex h-5 w-5 items-center justify-center",
257
+ {
258
+ "[&_svg]:invisible": !isSelected
259
+ }
260
+ ),
261
+ children: /* @__PURE__ */ jsx2(EllipseMiniSolid, {})
262
+ }
263
+ ),
264
+ preset.label
265
+ ]
266
+ }
267
+ ) }, preset.label);
268
+ }),
269
+ /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs2(
270
+ "button",
271
+ {
272
+ className: "bg-ui-bg-base hover:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-pressed text-ui-fg-base data-[disabled]:text-ui-fg-disabled txt-compact-small relative flex w-full cursor-pointer select-none items-center rounded-md px-2 py-1.5 outline-none transition-colors data-[disabled]:pointer-events-none",
273
+ type: "button",
274
+ onClick: handleSelectCustom,
275
+ children: [
276
+ /* @__PURE__ */ jsx2(
277
+ "div",
278
+ {
279
+ className: clx2(
280
+ "transition-fg flex h-5 w-5 items-center justify-center",
281
+ {
282
+ "[&_svg]:invisible": !showCustom
283
+ }
284
+ ),
285
+ children: /* @__PURE__ */ jsx2(EllipseMiniSolid, {})
286
+ }
287
+ ),
288
+ t("filters.date.custom")
289
+ ]
290
+ }
291
+ ) })
292
+ ] }),
293
+ showCustom && /* @__PURE__ */ jsxs2("div", { className: "border-t px-1 pb-3 pt-1", children: [
294
+ /* @__PURE__ */ jsxs2("div", { children: [
295
+ /* @__PURE__ */ jsx2("div", { className: "px-2 py-1", children: /* @__PURE__ */ jsx2(Text2, { size: "xsmall", leading: "compact", weight: "plus", children: t("filters.date.from") }) }),
296
+ /* @__PURE__ */ jsx2("div", { className: "px-2 py-1", children: /* @__PURE__ */ jsx2(
297
+ DatePicker,
298
+ {
299
+ modal: true,
300
+ maxValue: customEndValue,
301
+ value: customStartValue,
302
+ onChange: (d) => handleCustomDateChange(d, "start")
303
+ }
304
+ ) })
305
+ ] }),
306
+ /* @__PURE__ */ jsxs2("div", { children: [
307
+ /* @__PURE__ */ jsx2("div", { className: "px-2 py-1", children: /* @__PURE__ */ jsx2(Text2, { size: "xsmall", leading: "compact", weight: "plus", children: t("filters.date.to") }) }),
308
+ /* @__PURE__ */ jsx2("div", { className: "px-2 py-1", children: /* @__PURE__ */ jsx2(
309
+ DatePicker,
310
+ {
311
+ modal: true,
312
+ minValue: customStartValue,
313
+ value: customEndValue || void 0,
314
+ onChange: (d) => {
315
+ handleCustomDateChange(d, "end");
316
+ }
317
+ }
318
+ ) })
319
+ ] })
320
+ ] })
321
+ ]
322
+ }
323
+ ) })
324
+ ] });
325
+ };
326
+ var today = /* @__PURE__ */ new Date();
327
+ today.setHours(0, 0, 0, 0);
328
+ var usePresets = () => {
329
+ const { t: t2 } = useTranslation2();
330
+ return useMemo(
331
+ () => [
332
+ {
333
+ label: t2("filters.date.today"),
334
+ value: {
335
+ $gte: today.toISOString()
336
+ }
337
+ },
338
+ {
339
+ label: t2("filters.date.lastSevenDays"),
340
+ value: {
341
+ $gte: new Date(
342
+ today.getTime() - 7 * 24 * 60 * 60 * 1e3
343
+ ).toISOString()
344
+ // 7 days ago
345
+ }
346
+ },
347
+ {
348
+ label: t2("filters.date.lastThirtyDays"),
349
+ value: {
350
+ $gte: new Date(
351
+ today.getTime() - 30 * 24 * 60 * 60 * 1e3
352
+ ).toISOString()
353
+ // 30 days ago
354
+ }
355
+ },
356
+ {
357
+ label: t2("filters.date.lastNinetyDays"),
358
+ value: {
359
+ $gte: new Date(
360
+ today.getTime() - 90 * 24 * 60 * 60 * 1e3
361
+ ).toISOString()
362
+ // 90 days ago
363
+ }
364
+ },
365
+ {
366
+ label: t2("filters.date.lastTwelveMonths"),
367
+ value: {
368
+ $gte: new Date(
369
+ today.getTime() - 365 * 24 * 60 * 60 * 1e3
370
+ ).toISOString()
371
+ // 365 days ago
372
+ }
373
+ }
374
+ ],
375
+ [t2]
376
+ );
377
+ };
378
+ var parseDateComparison = (value) => {
379
+ return value?.length ? JSON.parse(value.join(",")) : null;
380
+ };
381
+ var getDateFromComparison = (comparison, key) => {
382
+ if (!comparison?.[key]) {
383
+ return void 0;
384
+ }
385
+ const compareDate = new Date(comparison[key]);
386
+ if (key === "$lte") {
387
+ compareDate.setHours(0, 0, 0, 0);
388
+ }
389
+ return compareDate;
390
+ };
391
+
392
+ // src/components/table/data-table/data-table-filter/number-filter.tsx
393
+ import { EllipseMiniSolid as EllipseMiniSolid2 } from "@medusajs/icons";
394
+ import { Input, Label, clx as clx3 } from "@medusajs/ui";
395
+ import debounce from "lodash.debounce";
396
+ import {
397
+ Popover as RadixPopover3,
398
+ RadioGroup as RadixRadioGroup
399
+ } from "radix-ui";
400
+ import { useCallback, useEffect, useState as useState2 } from "react";
401
+ import { useTranslation as useTranslation3 } from "react-i18next";
402
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
403
+ var NumberFilter = ({
404
+ filter,
405
+ prefix,
406
+ readonly,
407
+ openOnMount
408
+ }) => {
409
+ const { t: t2 } = useTranslation3();
410
+ const [open, setOpen] = useState2(openOnMount);
411
+ const { key, label } = filter;
412
+ const { removeFilter } = useDataTableFilterContext();
413
+ const selectedParams = useSelectedParams({
414
+ param: key,
415
+ prefix,
416
+ multiple: false
417
+ });
418
+ const currentValue = selectedParams.get();
419
+ const [previousValue, setPreviousValue] = useState2(
420
+ currentValue
421
+ );
422
+ const [operator, setOperator] = useState2(
423
+ getOperator(currentValue)
424
+ );
425
+ const debouncedOnChange = useCallback(
426
+ debounce((e, operator2) => {
427
+ const value = e.target.value;
428
+ const curr = JSON.parse(currentValue?.join(",") || "{}");
429
+ const isCurrentNumber = !isNaN(Number(curr));
430
+ const handleValue = (operator3) => {
431
+ if (!value && isCurrentNumber) {
432
+ selectedParams.delete();
433
+ return;
434
+ }
435
+ if (curr && !value) {
436
+ delete curr[operator3];
437
+ selectedParams.add(JSON.stringify(curr));
438
+ return;
439
+ }
440
+ if (!curr) {
441
+ selectedParams.add(JSON.stringify({ [operator3]: value }));
442
+ return;
443
+ }
444
+ selectedParams.add(JSON.stringify({ ...curr, [operator3]: value }));
445
+ };
446
+ switch (operator2) {
447
+ case "eq":
448
+ if (!value) {
449
+ selectedParams.delete();
450
+ } else {
451
+ selectedParams.add(value);
452
+ }
453
+ break;
454
+ case "lt":
455
+ case "gt":
456
+ handleValue(operator2);
457
+ break;
458
+ }
459
+ }, 500),
460
+ [selectedParams, currentValue]
461
+ );
462
+ useEffect(() => {
463
+ return () => {
464
+ debouncedOnChange.cancel();
465
+ };
466
+ }, [debouncedOnChange]);
467
+ let timeoutId = null;
468
+ const handleOpenChange = (open2) => {
469
+ setOpen(open2);
470
+ setPreviousValue(currentValue);
471
+ if (timeoutId) {
472
+ clearTimeout(timeoutId);
473
+ }
474
+ if (!open2 && !currentValue.length) {
475
+ timeoutId = setTimeout(() => {
476
+ removeFilter(key);
477
+ }, 200);
478
+ }
479
+ };
480
+ const handleRemove = () => {
481
+ selectedParams.delete();
482
+ removeFilter(key);
483
+ };
484
+ const operators = [
485
+ {
486
+ operator: "exact",
487
+ label: t2("filters.compare.exact")
488
+ },
489
+ {
490
+ operator: "range",
491
+ label: t2("filters.compare.range")
492
+ }
493
+ ];
494
+ const GT_KEY = `${key}-gt`;
495
+ const LT_KEY = `${key}-lt`;
496
+ const EQ_KEY = key;
497
+ const displayValue = parseDisplayValue(currentValue, t2);
498
+ const previousDisplayValue = parseDisplayValue(previousValue, t2);
499
+ return /* @__PURE__ */ jsxs3(RadixPopover3.Root, { modal: true, open, onOpenChange: handleOpenChange, children: [
500
+ /* @__PURE__ */ jsx3(
501
+ filter_chip_default,
502
+ {
503
+ hasOperator: true,
504
+ hadPreviousValue: !!previousDisplayValue,
505
+ label,
506
+ value: displayValue,
507
+ onRemove: handleRemove,
508
+ readonly
509
+ }
510
+ ),
511
+ !readonly && /* @__PURE__ */ jsx3(RadixPopover3.Portal, { children: /* @__PURE__ */ jsxs3(
512
+ RadixPopover3.Content,
513
+ {
514
+ "data-name": "number_filter_content",
515
+ align: "start",
516
+ sideOffset: 8,
517
+ collisionPadding: 24,
518
+ className: clx3(
519
+ "bg-ui-bg-base text-ui-fg-base shadow-elevation-flyout max-h-[var(--radix-popper-available-height)] w-[300px] divide-y overflow-y-auto rounded-lg outline-none"
520
+ ),
521
+ onInteractOutside: (e) => {
522
+ if (e.target instanceof HTMLElement) {
523
+ if (e.target.attributes.getNamedItem("data-name")?.value === "filters_menu_content") {
524
+ e.preventDefault();
525
+ }
526
+ }
527
+ },
528
+ children: [
529
+ /* @__PURE__ */ jsx3("div", { className: "p-1", children: /* @__PURE__ */ jsx3(
530
+ RadixRadioGroup.Root,
531
+ {
532
+ value: operator,
533
+ onValueChange: (val) => setOperator(val),
534
+ className: "flex flex-col items-start",
535
+ orientation: "vertical",
536
+ autoFocus: true,
537
+ children: operators.map((o) => /* @__PURE__ */ jsxs3(
538
+ RadixRadioGroup.Item,
539
+ {
540
+ value: o.operator,
541
+ className: "txt-compact-small hover:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed transition-fg grid w-full grid-cols-[20px_1fr] gap-2 rounded-[4px] px-2 py-1.5 text-left outline-none",
542
+ children: [
543
+ /* @__PURE__ */ jsx3("div", { className: "size-5", children: /* @__PURE__ */ jsx3(RadixRadioGroup.Indicator, { children: /* @__PURE__ */ jsx3(EllipseMiniSolid2, {}) }) }),
544
+ /* @__PURE__ */ jsx3("span", { className: "w-full", children: o.label })
545
+ ]
546
+ },
547
+ o.operator
548
+ ))
549
+ }
550
+ ) }),
551
+ /* @__PURE__ */ jsx3("div", { children: operator === "range" ? /* @__PURE__ */ jsxs3("div", { className: "px-1 pb-3 pt-1", children: [
552
+ /* @__PURE__ */ jsx3("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ jsx3(Label, { size: "xsmall", weight: "plus", htmlFor: GT_KEY, children: t2("filters.compare.greaterThan") }) }),
553
+ /* @__PURE__ */ jsx3("div", { className: "px-2 py-0.5", children: /* @__PURE__ */ jsx3(
554
+ Input,
555
+ {
556
+ name: GT_KEY,
557
+ size: "small",
558
+ type: "number",
559
+ defaultValue: getValue(currentValue, "gt"),
560
+ onChange: (e) => debouncedOnChange(e, "gt")
561
+ }
562
+ ) }),
563
+ /* @__PURE__ */ jsx3("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ jsx3(Label, { size: "xsmall", weight: "plus", htmlFor: LT_KEY, children: t2("filters.compare.lessThan") }) }),
564
+ /* @__PURE__ */ jsx3("div", { className: "px-2 py-0.5", children: /* @__PURE__ */ jsx3(
565
+ Input,
566
+ {
567
+ name: LT_KEY,
568
+ size: "small",
569
+ type: "number",
570
+ defaultValue: getValue(currentValue, "lt"),
571
+ onChange: (e) => debouncedOnChange(e, "lt")
572
+ }
573
+ ) })
574
+ ] }, "range") : /* @__PURE__ */ jsxs3("div", { className: "px-1 pb-3 pt-1", children: [
575
+ /* @__PURE__ */ jsx3("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ jsx3(Label, { size: "xsmall", weight: "plus", htmlFor: EQ_KEY, children: label }) }),
576
+ /* @__PURE__ */ jsx3("div", { className: "px-2 py-0.5", children: /* @__PURE__ */ jsx3(
577
+ Input,
578
+ {
579
+ name: EQ_KEY,
580
+ size: "small",
581
+ type: "number",
582
+ defaultValue: getValue(currentValue, "eq"),
583
+ onChange: (e) => debouncedOnChange(e, "eq")
584
+ }
585
+ ) })
586
+ ] }, "exact") })
587
+ ]
588
+ }
589
+ ) })
590
+ ] });
591
+ };
592
+ var parseDisplayValue = (value, t2) => {
593
+ const parsed = JSON.parse(value?.join(",") || "{}");
594
+ let displayValue = "";
595
+ if (typeof parsed === "object") {
596
+ const parts = [];
597
+ if (parsed.gt) {
598
+ parts.push(t2("filters.compare.greaterThanLabel", { value: parsed.gt }));
599
+ }
600
+ if (parsed.lt) {
601
+ parts.push(
602
+ t2("filters.compare.lessThanLabel", {
603
+ value: parsed.lt
604
+ })
605
+ );
606
+ }
607
+ displayValue = parts.join(` ${t2("filters.compare.andLabel")} `);
608
+ }
609
+ if (typeof parsed === "number") {
610
+ displayValue = parsed.toString();
611
+ }
612
+ return displayValue;
613
+ };
614
+ var parseValue = (value) => {
615
+ if (!value) {
616
+ return void 0;
617
+ }
618
+ const val = value.join(",");
619
+ if (!val) {
620
+ return void 0;
621
+ }
622
+ return JSON.parse(val);
623
+ };
624
+ var getValue = (value, key) => {
625
+ const parsed = parseValue(value);
626
+ if (typeof parsed === "object") {
627
+ return parsed[key];
628
+ }
629
+ if (typeof parsed === "number" && key === "eq") {
630
+ return parsed;
631
+ }
632
+ return void 0;
633
+ };
634
+ var getOperator = (value) => {
635
+ const parsed = parseValue(value);
636
+ return typeof parsed === "object" ? "range" : "exact";
637
+ };
638
+
639
+ // src/components/table/data-table/data-table-filter/select-filter.tsx
640
+ import { CheckMini, EllipseMiniSolid as EllipseMiniSolid3, XMarkMini as XMarkMini2 } from "@medusajs/icons";
641
+ import { clx as clx4 } from "@medusajs/ui";
642
+ import { Command } from "cmdk";
643
+ import { Popover as RadixPopover4 } from "radix-ui";
644
+ import { useState as useState3 } from "react";
645
+ import { useTranslation as useTranslation4 } from "react-i18next";
646
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
647
+ var SelectFilter = ({
648
+ filter,
649
+ prefix,
650
+ readonly,
651
+ multiple,
652
+ searchable,
653
+ options,
654
+ openOnMount
655
+ }) => {
656
+ const [open, setOpen] = useState3(openOnMount);
657
+ const [search, setSearch] = useState3("");
658
+ const [searchRef, setSearchRef] = useState3(null);
659
+ const { t: t2 } = useTranslation4();
660
+ const { removeFilter } = useDataTableFilterContext();
661
+ const { key, label } = filter;
662
+ const selectedParams = useSelectedParams({ param: key, prefix, multiple });
663
+ const currentValue = selectedParams.get();
664
+ const labelValues = currentValue.map((v) => options.find((o) => o.value === v)?.label).filter(Boolean);
665
+ const [previousValue, setPreviousValue] = useState3(labelValues);
666
+ const handleRemove = () => {
667
+ selectedParams.delete();
668
+ removeFilter(key);
669
+ };
670
+ let timeoutId = null;
671
+ const handleOpenChange = (open2) => {
672
+ setOpen(open2);
673
+ setPreviousValue(labelValues);
674
+ if (timeoutId) {
675
+ clearTimeout(timeoutId);
676
+ }
677
+ if (!open2 && !currentValue.length) {
678
+ timeoutId = setTimeout(() => {
679
+ removeFilter(key);
680
+ }, 200);
681
+ }
682
+ };
683
+ const handleClearSearch = () => {
684
+ setSearch("");
685
+ if (searchRef) {
686
+ searchRef.focus();
687
+ }
688
+ };
689
+ const handleSelect = (value) => {
690
+ const isSelected = selectedParams.get().includes(String(value));
691
+ if (isSelected) {
692
+ selectedParams.delete(String(value));
693
+ } else {
694
+ selectedParams.add(String(value));
695
+ }
696
+ };
697
+ const normalizedValues = labelValues ? Array.isArray(labelValues) ? labelValues : [labelValues] : null;
698
+ const normalizedPrev = previousValue ? Array.isArray(previousValue) ? previousValue : [previousValue] : null;
699
+ return /* @__PURE__ */ jsxs4(RadixPopover4.Root, { modal: true, open, onOpenChange: handleOpenChange, children: [
700
+ /* @__PURE__ */ jsx4(
701
+ filter_chip_default,
702
+ {
703
+ hasOperator: true,
704
+ hadPreviousValue: !!normalizedPrev?.length,
705
+ readonly,
706
+ label,
707
+ value: normalizedValues?.join(", "),
708
+ onRemove: handleRemove
709
+ }
710
+ ),
711
+ !readonly && /* @__PURE__ */ jsx4(RadixPopover4.Portal, { children: /* @__PURE__ */ jsx4(
712
+ RadixPopover4.Content,
713
+ {
714
+ hideWhenDetached: true,
715
+ align: "start",
716
+ sideOffset: 8,
717
+ collisionPadding: 8,
718
+ className: clx4(
719
+ "bg-ui-bg-base text-ui-fg-base shadow-elevation-flyout z-[1] h-full max-h-[200px] w-[300px] overflow-hidden rounded-lg outline-none"
720
+ ),
721
+ onInteractOutside: (e) => {
722
+ if (e.target instanceof HTMLElement) {
723
+ if (e.target.attributes.getNamedItem("data-name")?.value === "filters_menu_content") {
724
+ e.preventDefault();
725
+ e.stopPropagation();
726
+ }
727
+ }
728
+ },
729
+ children: /* @__PURE__ */ jsxs4(Command, { className: "h-full", children: [
730
+ searchable && /* @__PURE__ */ jsx4("div", { className: "border-b p-1", children: /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-[1fr_20px] gap-x-2 rounded-md px-2 py-1", children: [
731
+ /* @__PURE__ */ jsx4(
732
+ Command.Input,
733
+ {
734
+ ref: setSearchRef,
735
+ value: search,
736
+ onValueChange: setSearch,
737
+ className: "txt-compact-small placeholder:text-ui-fg-muted bg-transparent outline-none",
738
+ placeholder: "Search"
739
+ }
740
+ ),
741
+ /* @__PURE__ */ jsx4("div", { className: "flex h-5 w-5 items-center justify-center", children: /* @__PURE__ */ jsx4(
742
+ "button",
743
+ {
744
+ disabled: !search,
745
+ onClick: handleClearSearch,
746
+ className: clx4(
747
+ "transition-fg text-ui-fg-muted focus-visible:bg-ui-bg-base-pressed rounded-md outline-none",
748
+ {
749
+ invisible: !search
750
+ }
751
+ ),
752
+ children: /* @__PURE__ */ jsx4(XMarkMini2, {})
753
+ }
754
+ ) })
755
+ ] }) }),
756
+ /* @__PURE__ */ jsx4(Command.Empty, { className: "txt-compact-small flex items-center justify-center p-1", children: /* @__PURE__ */ jsx4("span", { className: "w-full px-2 py-1 text-center", children: t2("general.noResultsTitle") }) }),
757
+ /* @__PURE__ */ jsx4(Command.List, { className: "h-full max-h-[163px] min-h-[0] overflow-auto p-1 outline-none", children: options.map((option) => {
758
+ const isSelected = selectedParams.get().includes(String(option.value));
759
+ return /* @__PURE__ */ jsxs4(
760
+ Command.Item,
761
+ {
762
+ className: "bg-ui-bg-base hover:bg-ui-bg-base-hover aria-selected:bg-ui-bg-base-pressed focus-visible:bg-ui-bg-base-pressed text-ui-fg-base data-[disabled]:text-ui-fg-disabled txt-compact-small relative flex cursor-pointer select-none items-center gap-x-2 rounded-md px-2 py-1.5 outline-none transition-colors data-[disabled]:pointer-events-none",
763
+ value: option.label,
764
+ onSelect: () => {
765
+ handleSelect(option.value);
766
+ },
767
+ children: [
768
+ /* @__PURE__ */ jsx4(
769
+ "div",
770
+ {
771
+ className: clx4(
772
+ "transition-fg flex h-5 w-5 items-center justify-center",
773
+ {
774
+ "[&_svg]:invisible": !isSelected
775
+ }
776
+ ),
777
+ children: multiple ? /* @__PURE__ */ jsx4(CheckMini, {}) : /* @__PURE__ */ jsx4(EllipseMiniSolid3, {})
778
+ }
779
+ ),
780
+ option.label
781
+ ]
782
+ },
783
+ String(option.value)
784
+ );
785
+ }) })
786
+ ] })
787
+ }
788
+ ) })
789
+ ] });
790
+ };
791
+
792
+ // src/components/table/data-table/data-table-filter/string-filter.tsx
793
+ import { Input as Input2, Label as Label2, clx as clx5 } from "@medusajs/ui";
794
+ import debounce2 from "lodash.debounce";
795
+ import { Popover as RadixPopover5 } from "radix-ui";
796
+ import { useCallback as useCallback2, useEffect as useEffect2, useState as useState4 } from "react";
797
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
798
+ var StringFilter = ({
799
+ filter,
800
+ prefix,
801
+ readonly,
802
+ openOnMount
803
+ }) => {
804
+ const [open, setOpen] = useState4(openOnMount);
805
+ const { key, label } = filter;
806
+ const { removeFilter } = useDataTableFilterContext();
807
+ const selectedParams = useSelectedParams({ param: key, prefix });
808
+ const query = selectedParams.get();
809
+ const [previousValue, setPreviousValue] = useState4(
810
+ query?.[0]
811
+ );
812
+ const debouncedOnChange = useCallback2(
813
+ debounce2((e) => {
814
+ const value = e.target.value;
815
+ if (!value) {
816
+ selectedParams.delete();
817
+ } else {
818
+ selectedParams.add(value);
819
+ }
820
+ }, 500),
821
+ [selectedParams]
822
+ );
823
+ useEffect2(() => {
824
+ return () => {
825
+ debouncedOnChange.cancel();
826
+ };
827
+ }, [debouncedOnChange]);
828
+ let timeoutId = null;
829
+ const handleOpenChange = (open2) => {
830
+ setOpen(open2);
831
+ setPreviousValue(query?.[0]);
832
+ if (timeoutId) {
833
+ clearTimeout(timeoutId);
834
+ }
835
+ if (!open2 && !query.length) {
836
+ timeoutId = setTimeout(() => {
837
+ removeFilter(key);
838
+ }, 200);
839
+ }
840
+ };
841
+ const handleRemove = () => {
842
+ selectedParams.delete();
843
+ removeFilter(key);
844
+ };
845
+ return /* @__PURE__ */ jsxs5(RadixPopover5.Root, { modal: true, open, onOpenChange: handleOpenChange, children: [
846
+ /* @__PURE__ */ jsx5(
847
+ filter_chip_default,
848
+ {
849
+ hasOperator: true,
850
+ hadPreviousValue: !!previousValue,
851
+ label,
852
+ value: query?.[0],
853
+ onRemove: handleRemove,
854
+ readonly
855
+ }
856
+ ),
857
+ !readonly && /* @__PURE__ */ jsx5(RadixPopover5.Portal, { children: /* @__PURE__ */ jsx5(
858
+ RadixPopover5.Content,
859
+ {
860
+ hideWhenDetached: true,
861
+ align: "start",
862
+ sideOffset: 8,
863
+ collisionPadding: 8,
864
+ className: clx5(
865
+ "bg-ui-bg-base text-ui-fg-base shadow-elevation-flyout z-[1] h-full max-h-[200px] w-[300px] overflow-hidden rounded-lg outline-none"
866
+ ),
867
+ onInteractOutside: (e) => {
868
+ if (e.target instanceof HTMLElement) {
869
+ if (e.target.attributes.getNamedItem("data-name")?.value === "filters_menu_content") {
870
+ e.preventDefault();
871
+ e.stopPropagation();
872
+ }
873
+ }
874
+ },
875
+ children: /* @__PURE__ */ jsxs5("div", { className: "px-1 pb-3 pt-1", children: [
876
+ /* @__PURE__ */ jsx5("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ jsx5(Label2, { size: "xsmall", weight: "plus", htmlFor: key, children: label }) }),
877
+ /* @__PURE__ */ jsx5("div", { className: "px-2 py-0.5", children: /* @__PURE__ */ jsx5(
878
+ Input2,
879
+ {
880
+ name: key,
881
+ size: "small",
882
+ defaultValue: query?.[0] || void 0,
883
+ onChange: debouncedOnChange
884
+ }
885
+ ) })
886
+ ] })
887
+ }
888
+ ) })
889
+ ] });
890
+ };
891
+
892
+ // src/components/table/data-table/data-table-filter/data-table-filter.tsx
893
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
894
+ var DataTableFilter = ({
895
+ filters,
896
+ readonly,
897
+ prefix
898
+ }) => {
899
+ const { t: t2 } = useTranslation5();
900
+ const [searchParams] = useSearchParams();
901
+ const [open, setOpen] = useState5(false);
902
+ const [activeFilters, setActiveFilters] = useState5(
903
+ getInitialFilters({ searchParams, filters, prefix })
904
+ );
905
+ const availableFilters = filters.filter(
906
+ (f) => !activeFilters.find((af) => af.key === f.key)
907
+ );
908
+ const initialMount = useRef(true);
909
+ useEffect3(() => {
910
+ if (initialMount.current) {
911
+ const params = new URLSearchParams(searchParams);
912
+ filters.forEach((filter) => {
913
+ const key = prefix ? `${prefix}_${filter.key}` : filter.key;
914
+ const value = params.get(key);
915
+ if (value && !activeFilters.find((af) => af.key === filter.key)) {
916
+ if (filter.type === "select") {
917
+ setActiveFilters((prev) => [
918
+ ...prev,
919
+ {
920
+ ...filter,
921
+ multiple: filter.multiple,
922
+ options: filter.options,
923
+ openOnMount: false
924
+ }
925
+ ]);
926
+ } else {
927
+ setActiveFilters((prev) => [
928
+ ...prev,
929
+ { ...filter, openOnMount: false }
930
+ ]);
931
+ }
932
+ }
933
+ });
934
+ }
935
+ initialMount.current = false;
936
+ }, [activeFilters, filters, prefix, searchParams]);
937
+ const addFilter = (filter) => {
938
+ setOpen(false);
939
+ setActiveFilters((prev) => [...prev, { ...filter, openOnMount: true }]);
940
+ };
941
+ const removeFilter = useCallback3((key) => {
942
+ setActiveFilters((prev) => prev.filter((f) => f.key !== key));
943
+ }, []);
944
+ const removeAllFilters = useCallback3(() => {
945
+ setActiveFilters([]);
946
+ }, []);
947
+ return /* @__PURE__ */ jsx6(
948
+ DataTableFilterContext.Provider,
949
+ {
950
+ value: useMemo2(
951
+ () => ({
952
+ removeFilter,
953
+ removeAllFilters
954
+ }),
955
+ [removeAllFilters, removeFilter]
956
+ ),
957
+ children: /* @__PURE__ */ jsxs6("div", { className: "max-w-2/3 flex flex-wrap items-center gap-2", children: [
958
+ activeFilters.map((filter) => {
959
+ switch (filter.type) {
960
+ case "select":
961
+ return /* @__PURE__ */ jsx6(
962
+ SelectFilter,
963
+ {
964
+ filter,
965
+ prefix,
966
+ readonly,
967
+ options: filter.options,
968
+ multiple: filter.multiple,
969
+ searchable: filter.searchable,
970
+ openOnMount: filter.openOnMount
971
+ },
972
+ filter.key
973
+ );
974
+ case "date":
975
+ return /* @__PURE__ */ jsx6(
976
+ DateFilter,
977
+ {
978
+ filter,
979
+ prefix,
980
+ readonly,
981
+ openOnMount: filter.openOnMount
982
+ },
983
+ filter.key
984
+ );
985
+ case "string":
986
+ return /* @__PURE__ */ jsx6(
987
+ StringFilter,
988
+ {
989
+ filter,
990
+ prefix,
991
+ readonly,
992
+ openOnMount: filter.openOnMount
993
+ },
994
+ filter.key
995
+ );
996
+ case "number":
997
+ return /* @__PURE__ */ jsx6(
998
+ NumberFilter,
999
+ {
1000
+ filter,
1001
+ prefix,
1002
+ readonly,
1003
+ openOnMount: filter.openOnMount
1004
+ },
1005
+ filter.key
1006
+ );
1007
+ default:
1008
+ break;
1009
+ }
1010
+ }),
1011
+ !readonly && availableFilters.length > 0 && /* @__PURE__ */ jsxs6(RadixPopover6.Root, { modal: true, open, onOpenChange: setOpen, children: [
1012
+ /* @__PURE__ */ jsx6(RadixPopover6.Trigger, { asChild: true, id: "filters_menu_trigger", children: /* @__PURE__ */ jsx6(Button, { size: "small", variant: "secondary", children: t2("filters.addFilter") }) }),
1013
+ /* @__PURE__ */ jsx6(RadixPopover6.Portal, { children: /* @__PURE__ */ jsx6(
1014
+ RadixPopover6.Content,
1015
+ {
1016
+ className: clx6(
1017
+ "bg-ui-bg-base text-ui-fg-base shadow-elevation-flyout z-[1] h-full max-h-[200px] w-[300px] overflow-auto rounded-lg p-1 outline-none"
1018
+ ),
1019
+ "data-name": "filters_menu_content",
1020
+ align: "start",
1021
+ sideOffset: 8,
1022
+ collisionPadding: 8,
1023
+ onCloseAutoFocus: (e) => {
1024
+ const hasOpenFilter = activeFilters.find(
1025
+ (filter) => filter.openOnMount
1026
+ );
1027
+ if (hasOpenFilter) {
1028
+ e.preventDefault();
1029
+ }
1030
+ },
1031
+ children: availableFilters.map((filter) => {
1032
+ return /* @__PURE__ */ jsx6(
1033
+ "div",
1034
+ {
1035
+ className: "bg-ui-bg-base hover:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-pressed text-ui-fg-base data-[disabled]:text-ui-fg-disabled txt-compact-small relative flex cursor-pointer select-none items-center rounded-md px-2 py-1.5 outline-none transition-colors data-[disabled]:pointer-events-none",
1036
+ role: "menuitem",
1037
+ onClick: () => {
1038
+ addFilter(filter);
1039
+ },
1040
+ children: filter.label
1041
+ },
1042
+ filter.key
1043
+ );
1044
+ })
1045
+ }
1046
+ ) })
1047
+ ] }),
1048
+ !readonly && activeFilters.length > 0 && /* @__PURE__ */ jsx6(ClearAllFilters, { filters, prefix })
1049
+ ] })
1050
+ }
1051
+ );
1052
+ };
1053
+ var ClearAllFilters = ({ filters, prefix }) => {
1054
+ const { removeAllFilters } = useDataTableFilterContext();
1055
+ const [_, setSearchParams] = useSearchParams();
1056
+ const handleRemoveAll = () => {
1057
+ setSearchParams((prev) => {
1058
+ const newValues = new URLSearchParams(prev);
1059
+ filters.forEach((filter) => {
1060
+ newValues.delete(prefix ? `${prefix}_${filter.key}` : filter.key);
1061
+ });
1062
+ return newValues;
1063
+ });
1064
+ removeAllFilters();
1065
+ };
1066
+ return /* @__PURE__ */ jsx6(
1067
+ "button",
1068
+ {
1069
+ type: "button",
1070
+ onClick: handleRemoveAll,
1071
+ className: clx6(
1072
+ "text-ui-fg-muted transition-fg txt-compact-small-plus rounded-md px-2 py-1",
1073
+ "hover:text-ui-fg-subtle",
1074
+ "focus-visible:shadow-borders-focus"
1075
+ ),
1076
+ children: "Clear all"
1077
+ }
1078
+ );
1079
+ };
1080
+ var getInitialFilters = ({
1081
+ searchParams,
1082
+ filters,
1083
+ prefix
1084
+ }) => {
1085
+ const params = new URLSearchParams(searchParams);
1086
+ const activeFilters = [];
1087
+ filters.forEach((filter) => {
1088
+ const key = prefix ? `${prefix}_${filter.key}` : filter.key;
1089
+ const value = params.get(key);
1090
+ if (value) {
1091
+ if (filter.type === "select") {
1092
+ activeFilters.push({
1093
+ ...filter,
1094
+ multiple: filter.multiple,
1095
+ options: filter.options,
1096
+ openOnMount: false
1097
+ });
1098
+ } else {
1099
+ activeFilters.push({ ...filter, openOnMount: false });
1100
+ }
1101
+ }
1102
+ });
1103
+ return activeFilters;
1104
+ };
1105
+
1106
+ // src/components/table/data-table/data-table-query/data-table-query.tsx
1107
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1108
+ var DataTableQuery = ({
1109
+ search,
1110
+ orderBy,
1111
+ filters,
1112
+ prefix
1113
+ }) => {
1114
+ return (search || orderBy || filters || prefix) && /* @__PURE__ */ jsxs7("div", { className: "flex items-start justify-between gap-x-4 px-6 py-4", children: [
1115
+ /* @__PURE__ */ jsx7("div", { className: "w-full max-w-[60%]", children: filters && filters.length > 0 && /* @__PURE__ */ jsx7(DataTableFilter, { filters, prefix }) }),
1116
+ /* @__PURE__ */ jsxs7("div", { className: "flex shrink-0 items-center gap-x-2", children: [
1117
+ search && /* @__PURE__ */ jsx7(
1118
+ DataTableSearch,
1119
+ {
1120
+ prefix,
1121
+ autofocus: search === "autofocus"
1122
+ }
1123
+ ),
1124
+ orderBy && /* @__PURE__ */ jsx7(DataTableOrderBy, { keys: orderBy, prefix })
1125
+ ] })
1126
+ ] });
1127
+ };
1128
+
1129
+ // src/components/table/data-table/data-table-root/data-table-root.tsx
1130
+ import { CommandBar, Table, clx as clx7 } from "@medusajs/ui";
1131
+ import {
1132
+ flexRender
1133
+ } from "@tanstack/react-table";
1134
+ import {
1135
+ Fragment,
1136
+ useEffect as useEffect4,
1137
+ useRef as useRef2,
1138
+ useState as useState6
1139
+ } from "react";
1140
+ import { useTranslation as useTranslation6 } from "react-i18next";
1141
+ import { Link } from "react-router-dom";
1142
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1143
+ var DataTableRoot = ({
1144
+ table,
1145
+ columns,
1146
+ pagination,
1147
+ navigateTo,
1148
+ commands,
1149
+ count = 0,
1150
+ noResults = false,
1151
+ noHeader = false,
1152
+ layout = "fit"
1153
+ }) => {
1154
+ const { t: t2 } = useTranslation6();
1155
+ const [showStickyBorder, setShowStickyBorder] = useState6(false);
1156
+ const scrollableRef = useRef2(null);
1157
+ const hasSelect = columns.find((c) => c.id === "select");
1158
+ const hasActions = columns.find((c) => c.id === "actions");
1159
+ const hasCommandBar = commands && commands.length > 0;
1160
+ const rowSelection = table.getState().rowSelection;
1161
+ const { pageIndex, pageSize } = table.getState().pagination;
1162
+ const colCount = columns.length - (hasSelect ? 1 : 0) - (hasActions ? 1 : 0);
1163
+ const colWidth = 100 / colCount;
1164
+ const handleHorizontalScroll = (e) => {
1165
+ const scrollLeft = e.currentTarget.scrollLeft;
1166
+ if (scrollLeft > 0) {
1167
+ setShowStickyBorder(true);
1168
+ } else {
1169
+ setShowStickyBorder(false);
1170
+ }
1171
+ };
1172
+ const handleAction = async (action) => {
1173
+ await action(rowSelection).then(() => {
1174
+ table.resetRowSelection();
1175
+ });
1176
+ };
1177
+ useEffect4(() => {
1178
+ scrollableRef.current?.scroll({ top: 0, left: 0 });
1179
+ }, [pageIndex]);
1180
+ return /* @__PURE__ */ jsxs8(
1181
+ "div",
1182
+ {
1183
+ className: clx7("flex w-full flex-col overflow-hidden", {
1184
+ "flex flex-1 flex-col": layout === "fill"
1185
+ }),
1186
+ children: [
1187
+ /* @__PURE__ */ jsx8(
1188
+ "div",
1189
+ {
1190
+ ref: scrollableRef,
1191
+ onScroll: handleHorizontalScroll,
1192
+ className: clx7("w-full", {
1193
+ "min-h-0 flex-grow overflow-auto": layout === "fill",
1194
+ "overflow-x-auto": layout === "fit"
1195
+ }),
1196
+ children: !noResults ? /* @__PURE__ */ jsxs8(Table, { className: "relative w-full", children: [
1197
+ !noHeader && /* @__PURE__ */ jsx8(Table.Header, { className: "border-t-0", children: table.getHeaderGroups().map((headerGroup) => {
1198
+ return /* @__PURE__ */ jsx8(
1199
+ Table.Row,
1200
+ {
1201
+ className: clx7({
1202
+ "relative border-b-0 [&_th:last-of-type]:w-[1%] [&_th:last-of-type]:whitespace-nowrap": hasActions,
1203
+ "[&_th:first-of-type]:w-[1%] [&_th:first-of-type]:whitespace-nowrap": hasSelect
1204
+ }),
1205
+ children: headerGroup.headers.map((header, index) => {
1206
+ const isActionHeader = header.id === "actions";
1207
+ const isSelectHeader = header.id === "select";
1208
+ const isSpecialHeader = isActionHeader || isSelectHeader;
1209
+ const firstHeader = headerGroup.headers.findIndex(
1210
+ (h) => h.id !== "select"
1211
+ );
1212
+ const isFirstHeader = firstHeader !== -1 ? header.id === headerGroup.headers[firstHeader].id : index === 0;
1213
+ const isStickyHeader = isSelectHeader || isFirstHeader;
1214
+ return /* @__PURE__ */ jsx8(
1215
+ Table.HeaderCell,
1216
+ {
1217
+ "data-table-header-id": header.id,
1218
+ style: {
1219
+ width: !isSpecialHeader ? `${colWidth}%` : void 0
1220
+ },
1221
+ className: clx7({
1222
+ "bg-ui-bg-subtle sticky start-0 after:absolute after:inset-y-0 after:right-0 after:h-full after:w-px after:bg-transparent after:content-['']": isStickyHeader,
1223
+ "start-[68px]": isStickyHeader && hasSelect && !isSelectHeader,
1224
+ "after:bg-ui-border-base": showStickyBorder && isStickyHeader && !isSpecialHeader
1225
+ }),
1226
+ children: flexRender(
1227
+ header.column.columnDef.header,
1228
+ header.getContext()
1229
+ )
1230
+ },
1231
+ header.id
1232
+ );
1233
+ })
1234
+ },
1235
+ headerGroup.id
1236
+ );
1237
+ }) }),
1238
+ /* @__PURE__ */ jsx8(Table.Body, { className: "border-b-0", children: table.getRowModel().rows.map((row) => {
1239
+ const to = navigateTo ? navigateTo(row) : void 0;
1240
+ const isRowDisabled = hasSelect && !row.getCanSelect();
1241
+ const isOdd = row.depth % 2 !== 0;
1242
+ const cells = row.getVisibleCells();
1243
+ return /* @__PURE__ */ jsx8(
1244
+ Table.Row,
1245
+ {
1246
+ "data-selected": row.getIsSelected(),
1247
+ className: clx7(
1248
+ "transition-fg group/row group relative [&_td:last-of-type]:w-[1%] [&_td:last-of-type]:whitespace-nowrap",
1249
+ "has-[[data-row-link]:focus-visible]:bg-ui-bg-base-hover",
1250
+ {
1251
+ "bg-ui-bg-subtle hover:bg-ui-bg-subtle-hover": isOdd,
1252
+ "cursor-pointer": !!to,
1253
+ "bg-ui-bg-highlight hover:bg-ui-bg-highlight-hover": row.getIsSelected(),
1254
+ "!bg-ui-bg-disabled !hover:bg-ui-bg-disabled": isRowDisabled
1255
+ }
1256
+ ),
1257
+ children: cells.map((cell, index) => {
1258
+ const visibleCells = row.getVisibleCells();
1259
+ const isSelectCell = cell.column.id === "select";
1260
+ const firstCell = visibleCells.findIndex(
1261
+ (h) => h.column.id !== "select"
1262
+ );
1263
+ const isFirstCell = firstCell !== -1 ? cell.column.id === visibleCells[firstCell].column.id : index === 0;
1264
+ const isStickyCell = isSelectCell || isFirstCell;
1265
+ const depthOffset = row.depth > 0 && isFirstCell ? row.depth * 14 + 24 : void 0;
1266
+ const hasLeftOffset = isStickyCell && hasSelect && !isSelectCell;
1267
+ const Inner = flexRender(
1268
+ cell.column.columnDef.cell,
1269
+ cell.getContext()
1270
+ );
1271
+ const isTabableLink = isFirstCell && !!to;
1272
+ const shouldRenderAsLink = !!to && !isSelectCell;
1273
+ return /* @__PURE__ */ jsx8(
1274
+ Table.Cell,
1275
+ {
1276
+ className: clx7({
1277
+ "!ps-0 !pe-0": shouldRenderAsLink,
1278
+ "bg-ui-bg-base group-data-[selected=true]/row:bg-ui-bg-highlight group-data-[selected=true]/row:group-hover/row:bg-ui-bg-highlight-hover group-hover/row:bg-ui-bg-base-hover transition-fg group-has-[[data-row-link]:focus-visible]:bg-ui-bg-base-hover sticky start-0 after:absolute after:inset-y-0 after:right-0 after:h-full after:w-px after:bg-transparent after:content-['']": isStickyCell,
1279
+ "bg-ui-bg-subtle group-hover/row:bg-ui-bg-subtle-hover": isOdd && isStickyCell,
1280
+ "start-[68px]": hasLeftOffset,
1281
+ "after:bg-ui-border-base": showStickyBorder && isStickyCell && !isSelectCell,
1282
+ "!bg-ui-bg-disabled !hover:bg-ui-bg-disabled": isRowDisabled
1283
+ }),
1284
+ style: {
1285
+ paddingLeft: depthOffset ? `${depthOffset}px` : void 0
1286
+ },
1287
+ children: shouldRenderAsLink ? /* @__PURE__ */ jsx8(
1288
+ Link,
1289
+ {
1290
+ to,
1291
+ className: "size-full outline-none",
1292
+ "data-row-link": true,
1293
+ tabIndex: isTabableLink ? 0 : -1,
1294
+ children: /* @__PURE__ */ jsx8(
1295
+ "div",
1296
+ {
1297
+ className: clx7(
1298
+ "flex size-full items-center pe-6",
1299
+ {
1300
+ "ps-6": isTabableLink && !hasLeftOffset
1301
+ }
1302
+ ),
1303
+ children: Inner
1304
+ }
1305
+ )
1306
+ }
1307
+ ) : Inner
1308
+ },
1309
+ cell.id
1310
+ );
1311
+ })
1312
+ },
1313
+ row.id
1314
+ );
1315
+ }) })
1316
+ ] }) : /* @__PURE__ */ jsx8("div", { className: clx7({ "border-b": layout === "fit" }), children: /* @__PURE__ */ jsx8(NoResults, {}) })
1317
+ }
1318
+ ),
1319
+ pagination && /* @__PURE__ */ jsx8("div", { className: clx7({ "border-t": layout === "fill" }), children: /* @__PURE__ */ jsx8(
1320
+ Pagination,
1321
+ {
1322
+ canNextPage: table.getCanNextPage(),
1323
+ canPreviousPage: table.getCanPreviousPage(),
1324
+ nextPage: table.nextPage,
1325
+ previousPage: table.previousPage,
1326
+ count,
1327
+ pageIndex,
1328
+ pageCount: table.getPageCount(),
1329
+ pageSize
1330
+ }
1331
+ ) }),
1332
+ hasCommandBar && /* @__PURE__ */ jsx8(CommandBar, { open: !!Object.keys(rowSelection).length, children: /* @__PURE__ */ jsxs8(CommandBar.Bar, { children: [
1333
+ /* @__PURE__ */ jsx8(CommandBar.Value, { children: t2("general.countSelected", {
1334
+ count: Object.keys(rowSelection).length
1335
+ }) }),
1336
+ /* @__PURE__ */ jsx8(CommandBar.Seperator, {}),
1337
+ commands?.map((command, index) => {
1338
+ return /* @__PURE__ */ jsxs8(Fragment, { children: [
1339
+ /* @__PURE__ */ jsx8(
1340
+ CommandBar.Command,
1341
+ {
1342
+ label: command.label,
1343
+ shortcut: command.shortcut,
1344
+ action: () => handleAction(command.action)
1345
+ }
1346
+ ),
1347
+ index < commands.length - 1 && /* @__PURE__ */ jsx8(CommandBar.Seperator, {})
1348
+ ] }, index);
1349
+ })
1350
+ ] }) })
1351
+ ]
1352
+ }
1353
+ );
1354
+ };
1355
+ var Pagination = (props) => {
1356
+ const { t: t2 } = useTranslation6();
1357
+ const translations = {
1358
+ of: t2("general.of"),
1359
+ results: t2("general.results"),
1360
+ pages: t2("general.pages"),
1361
+ prev: t2("general.prev"),
1362
+ next: t2("general.next")
1363
+ };
1364
+ return /* @__PURE__ */ jsx8(
1365
+ Table.Pagination,
1366
+ {
1367
+ className: "flex-shrink-0",
1368
+ ...props,
1369
+ translations
1370
+ }
1371
+ );
1372
+ };
1373
+
1374
+ // src/components/table/data-table/data-table.tsx
1375
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
1376
+ var MemoizedDataTableQuery = memo(DataTableQuery);
1377
+ var _DataTable = ({
1378
+ table,
1379
+ columns,
1380
+ pagination,
1381
+ navigateTo,
1382
+ commands,
1383
+ count = 0,
1384
+ search = false,
1385
+ orderBy,
1386
+ filters,
1387
+ prefix,
1388
+ queryObject = {},
1389
+ pageSize,
1390
+ isLoading = false,
1391
+ noHeader = false,
1392
+ layout = "fit",
1393
+ noRecords: noRecordsProps = {}
1394
+ }) => {
1395
+ if (isLoading) {
1396
+ return /* @__PURE__ */ jsx9(
1397
+ TableSkeleton,
1398
+ {
1399
+ layout,
1400
+ rowCount: pageSize,
1401
+ search: !!search,
1402
+ filters: !!filters?.length,
1403
+ orderBy: !!orderBy?.length,
1404
+ pagination: !!pagination
1405
+ }
1406
+ );
1407
+ }
1408
+ const noQuery = Object.values(queryObject).filter((v) => Boolean(v)).length === 0;
1409
+ const noResults = !isLoading && count === 0 && !noQuery;
1410
+ const noRecords = !isLoading && count === 0 && noQuery;
1411
+ if (noRecords) {
1412
+ return /* @__PURE__ */ jsx9(
1413
+ NoRecords,
1414
+ {
1415
+ className: clx8({
1416
+ "flex h-full flex-col overflow-hidden": layout === "fill"
1417
+ }),
1418
+ ...noRecordsProps
1419
+ }
1420
+ );
1421
+ }
1422
+ return /* @__PURE__ */ jsxs9(
1423
+ "div",
1424
+ {
1425
+ className: clx8("divide-y", {
1426
+ "flex h-full flex-col overflow-hidden": layout === "fill"
1427
+ }),
1428
+ children: [
1429
+ /* @__PURE__ */ jsx9(
1430
+ MemoizedDataTableQuery,
1431
+ {
1432
+ search,
1433
+ orderBy,
1434
+ filters,
1435
+ prefix
1436
+ }
1437
+ ),
1438
+ /* @__PURE__ */ jsx9(
1439
+ DataTableRoot,
1440
+ {
1441
+ table,
1442
+ count,
1443
+ columns,
1444
+ pagination: true,
1445
+ navigateTo,
1446
+ commands,
1447
+ noResults,
1448
+ noHeader,
1449
+ layout
1450
+ }
1451
+ )
1452
+ ]
1453
+ }
1454
+ );
1455
+ };
1456
+
1457
+ // src/hooks/use-data-table.tsx
1458
+ import {
1459
+ getCoreRowModel,
1460
+ getExpandedRowModel,
1461
+ getPaginationRowModel,
1462
+ useReactTable
1463
+ } from "@tanstack/react-table";
1464
+ import { useEffect as useEffect5, useMemo as useMemo3, useState as useState7 } from "react";
1465
+ import { useSearchParams as useSearchParams2 } from "react-router-dom";
1466
+ var useDataTable = ({
1467
+ data = [],
1468
+ columns,
1469
+ count = 0,
1470
+ pageSize: _pageSize = 20,
1471
+ enablePagination = true,
1472
+ enableRowSelection = false,
1473
+ enableExpandableRows = false,
1474
+ rowSelection: _rowSelection,
1475
+ getSubRows,
1476
+ getRowId,
1477
+ meta,
1478
+ prefix
1479
+ }) => {
1480
+ const [searchParams, setSearchParams] = useSearchParams2();
1481
+ const offsetKey = `${prefix ? `${prefix}_` : ""}offset`;
1482
+ const offset = searchParams.get(offsetKey);
1483
+ const [{ pageIndex, pageSize }, setPagination] = useState7({
1484
+ pageIndex: offset ? Math.ceil(Number(offset) / _pageSize) : 0,
1485
+ pageSize: _pageSize
1486
+ });
1487
+ const pagination = useMemo3(
1488
+ () => ({
1489
+ pageIndex,
1490
+ pageSize
1491
+ }),
1492
+ [pageIndex, pageSize]
1493
+ );
1494
+ const [localRowSelection, setLocalRowSelection] = useState7({});
1495
+ const rowSelection = _rowSelection?.state ?? localRowSelection;
1496
+ const setRowSelection = _rowSelection?.updater ?? setLocalRowSelection;
1497
+ useEffect5(() => {
1498
+ if (!enablePagination) {
1499
+ return;
1500
+ }
1501
+ const index = offset ? Math.ceil(Number(offset) / _pageSize) : 0;
1502
+ if (index === pageIndex) {
1503
+ return;
1504
+ }
1505
+ setPagination((prev) => ({
1506
+ ...prev,
1507
+ pageIndex: index
1508
+ }));
1509
+ }, [offset, enablePagination, _pageSize, pageIndex]);
1510
+ const onPaginationChange = (updater) => {
1511
+ const state = updater(pagination);
1512
+ const { pageIndex: pageIndex2, pageSize: pageSize2 } = state;
1513
+ setSearchParams((prev) => {
1514
+ if (!pageIndex2) {
1515
+ prev.delete(offsetKey);
1516
+ return prev;
1517
+ }
1518
+ const newSearch = new URLSearchParams(prev);
1519
+ newSearch.set(offsetKey, String(pageIndex2 * pageSize2));
1520
+ return newSearch;
1521
+ });
1522
+ setPagination(state);
1523
+ return state;
1524
+ };
1525
+ const table = useReactTable({
1526
+ data,
1527
+ columns,
1528
+ state: {
1529
+ rowSelection,
1530
+ // We always pass a selection state to the table even if it's not enabled
1531
+ pagination: enablePagination ? pagination : void 0
1532
+ },
1533
+ pageCount: Math.ceil((count ?? 0) / pageSize),
1534
+ enableRowSelection,
1535
+ getRowId,
1536
+ getSubRows,
1537
+ onRowSelectionChange: enableRowSelection ? setRowSelection : void 0,
1538
+ onPaginationChange: enablePagination ? onPaginationChange : void 0,
1539
+ getCoreRowModel: getCoreRowModel(),
1540
+ getPaginationRowModel: enablePagination ? getPaginationRowModel() : void 0,
1541
+ getExpandedRowModel: enableExpandableRows ? getExpandedRowModel() : void 0,
1542
+ manualPagination: enablePagination ? true : void 0,
1543
+ meta
1544
+ });
1545
+ return { table };
1546
+ };
1547
+
1548
+ export {
1549
+ _DataTable,
1550
+ useDataTable
1551
+ };