@mercurjs/vendor 2.1.6 → 2.2.0-canary.11

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 (259) hide show
  1. package/dist/[id]-A55T2ORL.js +3066 -0
  2. package/dist/[id]-B4YZTANM.js +1571 -0
  3. package/dist/{[id]-UTKO3VG4.js → [id]-EKLRGVBA.js} +10 -10
  4. package/dist/{[id]-TO6KT3ZE.js → [id]-FE5GYYVZ.js} +28 -25
  5. package/dist/{[id]-4VCL3MMM.js → [id]-GBT6VB4S.js} +29 -23
  6. package/dist/{[id]-3G5G7ZFV.js → [id]-GC3ZYPK4.js} +25 -22
  7. package/dist/{[id]-6PXEWRG7.js → [id]-J6BZG5PU.js} +14 -14
  8. package/dist/{[id]-B3LHVQM5.js → [id]-QOEO3JOV.js} +29 -23
  9. package/dist/{[id]-H3C3ZSC6.js → [id]-QQU5HVFU.js} +29 -23
  10. package/dist/{[id]-PDGHF5J2.js → [id]-SHAJTJNZ.js} +43 -36
  11. package/dist/{[id]-X4DDKOMQ.js → [id]-T5ECVBPF.js} +30 -24
  12. package/dist/{[id]-T2ROPEGY.js → [id]-U5KZEQDR.js} +7 -7
  13. package/dist/{[id]-7RUAH3TI.js → [id]-YPCO3DJV.js} +5 -5
  14. package/dist/{[id]-Y7GAMNC5.js → [id]-ZCMSBEVM.js} +4 -4
  15. package/dist/{[location_id]-D55RQOXT.js → [location_id]-NUBXDDJC.js} +9 -9
  16. package/dist/{[province_id]-OFH2ZOFQ.js → [province_id]-6GUA4PV5.js} +23 -20
  17. package/dist/{add-C6OX5C54.js → add-NTRYWOJF.js} +42 -35
  18. package/dist/add-RU3WL4YB.js +428 -0
  19. package/dist/{add-customer-groups-PJRJUWS2.js → add-customer-groups-U5RZWW4B.js} +19 -16
  20. package/dist/{add-products-INOLNPO6.js → add-products-Q4MMDQKT.js} +26 -20
  21. package/dist/{add-promotions-AHDOP52Q.js → add-promotions-3AYXQXTP.js} +8 -8
  22. package/dist/{add-to-campaign-HL6NGRR4.js → add-to-campaign-QKYQCSR2.js} +4 -4
  23. package/dist/{address-KRENKSLP.js → address-77Y3AOQ3.js} +19 -16
  24. package/dist/{adjust-inventory-H4EUP7J3.js → adjust-inventory-AFJLWF5R.js} +2 -2
  25. package/dist/{allocate-items-SUCUZU4D.js → allocate-items-TCM5A55Y.js} +141 -126
  26. package/dist/{areas-UUMZDXLX.js → areas-XUC5V5UO.js} +8 -8
  27. package/dist/{attributes-CALEHJJG.js → attributes-SZP2MM5L.js} +3 -3
  28. package/dist/{breadcrumb-KQSFIXQ4.js → breadcrumb-2XA2WOK7.js} +1 -1
  29. package/dist/{breadcrumb-IG7VZGW2.js → breadcrumb-5NP23D6X.js} +15 -12
  30. package/dist/{breadcrumb-TW5JEOYS.js → breadcrumb-EVZIOB2G.js} +14 -11
  31. package/dist/{breadcrumb-OIGGCB3L.js → breadcrumb-FPWBT76A.js} +8 -2
  32. package/dist/{breadcrumb-BS7Y5OKF.js → breadcrumb-IK6XCQOQ.js} +2 -2
  33. package/dist/{breadcrumb-M5Z5WA6I.js → breadcrumb-KTARIL65.js} +2 -2
  34. package/dist/{breadcrumb-VNNZ3TTW.js → breadcrumb-PBR27GGX.js} +3 -3
  35. package/dist/breadcrumb-THJ2HPRB.js +26 -0
  36. package/dist/{breadcrumb-6W2VP3OZ.js → breadcrumb-TNJSGX4T.js} +15 -12
  37. package/dist/{campaigns-HS6MIO7X.js → campaigns-JAQTSA4Z.js} +6 -6
  38. package/dist/{categories-PKWR3FM3.js → categories-T4QJYX4R.js} +8 -8
  39. package/dist/{chunk-4URLUCTD.js → chunk-25E4KME5.js} +3 -3
  40. package/dist/chunk-27KRIXMQ.js +71 -0
  41. package/dist/{chunk-SFQKKIHA.js → chunk-27WLUOI2.js} +1 -1
  42. package/dist/{chunk-ZYOXKUKZ.js → chunk-2QTNCGKX.js} +1 -1
  43. package/dist/{chunk-5UD4P6YL.js → chunk-2USXZSTK.js} +4 -4
  44. package/dist/{chunk-PXYDR7WQ.js → chunk-3BXCPHN6.js} +3 -2
  45. package/dist/{chunk-VQ5EKDA3.js → chunk-3PMM6AMP.js} +3 -3
  46. package/dist/{chunk-J6BRLL3F.js → chunk-463CNCJC.js} +3 -3
  47. package/dist/{chunk-Y2QI7KWS.js → chunk-4LVP635F.js} +408 -664
  48. package/dist/{chunk-UL4O5M4S.js → chunk-4S6XGIC6.js} +1 -18
  49. package/dist/{chunk-RUE5BPC2.js → chunk-5QI3NDJG.js} +1 -1
  50. package/dist/{chunk-PPLC4IKI.js → chunk-5T6UWTRU.js} +10 -5
  51. package/dist/{chunk-WITQNQXN.js → chunk-6FUIK3PX.js} +4 -4
  52. package/dist/{chunk-HGQTL7NX.js → chunk-6K6EQOJF.js} +3 -3
  53. package/dist/{chunk-KAZ5BYTQ.js → chunk-6OUPJNYO.js} +5 -3
  54. package/dist/{chunk-PEKANQ3T.js → chunk-6UZERVBI.js} +2 -2
  55. package/dist/{chunk-RTAWYMQP.js → chunk-7CMRFP5Q.js} +2 -2
  56. package/dist/{chunk-I2IKYOZX.js → chunk-7IPCLQ5V.js} +19 -19
  57. package/dist/chunk-ADGVQVHP.js +101 -0
  58. package/dist/{chunk-IZ5RG5XI.js → chunk-AJLGY3LQ.js} +1 -21
  59. package/dist/chunk-BER45EYD.js +82 -0
  60. package/dist/{chunk-PCMNEUMV.js → chunk-BXRNZS5K.js} +1 -1
  61. package/dist/chunk-CFRWIQIZ.js +43 -0
  62. package/dist/{chunk-RL7SFZOF.js → chunk-DDJQRV6E.js} +1 -1
  63. package/dist/{chunk-D2MA5TAP.js → chunk-DO4F5FIO.js} +2 -2
  64. package/dist/{chunk-X4FLOQ45.js → chunk-DQKK43PR.js} +3 -3
  65. package/dist/{chunk-6WY5X4PE.js → chunk-E6W57UP3.js} +35 -125
  66. package/dist/chunk-FP6U6BPH.js +61 -0
  67. package/dist/chunk-FWPGOIFA.js +22 -0
  68. package/dist/{chunk-BLVJAKBA.js → chunk-FWS4YJ4B.js} +1 -1
  69. package/dist/chunk-GAE6TKOR.js +811 -0
  70. package/dist/{chunk-3CK6OINO.js → chunk-GDWBOQI5.js} +3 -5
  71. package/dist/{chunk-PDQSPKG5.js → chunk-GN6KB75Z.js} +1 -1
  72. package/dist/chunk-HDEOZN2Q.js +60 -0
  73. package/dist/chunk-IBEUR3J7.js +173 -0
  74. package/dist/chunk-J6XCRFBW.js +30 -0
  75. package/dist/{chunk-ZEVYT6IX.js → chunk-JAUZ73XE.js} +151 -266
  76. package/dist/{chunk-CNLP35S7.js → chunk-K6LOZ4S3.js} +54 -18
  77. package/dist/{chunk-JQP7MOFH.js → chunk-KIFSQOM2.js} +2 -2
  78. package/dist/{chunk-DARJTN4I.js → chunk-L4KBTV57.js} +9 -2
  79. package/dist/chunk-L57USMYC.js +39 -0
  80. package/dist/chunk-LARLBYU6.js +127 -0
  81. package/dist/chunk-LDZCCWJB.js +518 -0
  82. package/dist/chunk-LEWA4BPH.js +18 -0
  83. package/dist/chunk-LFX6WU4A.js +36 -0
  84. package/dist/{chunk-ITI54CII.js → chunk-LKUW5SV4.js} +6 -6
  85. package/dist/{chunk-LPOAVK6Y.js → chunk-LQD232FW.js} +47 -12
  86. package/dist/{chunk-4MFMCZEJ.js → chunk-MJCL3WID.js} +2 -2
  87. package/dist/{chunk-32RYSB2V.js → chunk-NBKWY6XN.js} +2 -2
  88. package/dist/{chunk-GYV6SKY7.js → chunk-O7VOGTLX.js} +4 -6
  89. package/dist/{chunk-KQGVSLUI.js → chunk-OYKUQXJX.js} +1926 -957
  90. package/dist/{chunk-CYTNBXWF.js → chunk-OZ44ATGE.js} +8 -8
  91. package/dist/{chunk-7Q5SDEK7.js → chunk-PAVZ6FPK.js} +7 -7
  92. package/dist/{chunk-2RHAI7WK.js → chunk-QLBIBLOY.js} +2 -2
  93. package/dist/chunk-RXV7INUV.js +426 -0
  94. package/dist/chunk-S23FD6FA.js +210 -0
  95. package/dist/{chunk-NYDJTWRL.js → chunk-SGR4DMCW.js} +4 -4
  96. package/dist/{chunk-OXXL4WQU.js → chunk-SPOHNK4X.js} +6 -6
  97. package/dist/{chunk-AIF2KTEE.js → chunk-SSUUT5LK.js} +12 -2
  98. package/dist/{chunk-QX45GVAL.js → chunk-SZBERGA4.js} +8 -8
  99. package/dist/{chunk-6SBMVLJ2.js → chunk-T5MJWWDX.js} +2 -2
  100. package/dist/chunk-T6LHVNWO.js +27 -0
  101. package/dist/chunk-TBYCZRZ7.js +248 -0
  102. package/dist/chunk-TF6V3TFG.js +438 -0
  103. package/dist/chunk-TW324MAT.js +185 -0
  104. package/dist/{chunk-4ZGFODSC.js → chunk-TYESCFYW.js} +1 -1
  105. package/dist/chunk-U5G3AVED.js +64 -0
  106. package/dist/chunk-U6PBLMXD.js +14 -0
  107. package/dist/{chunk-GZMXTNDN.js → chunk-UCYSCKZV.js} +1432 -1380
  108. package/dist/{chunk-P3ZTO6T2.js → chunk-UFFVRF4V.js} +2 -2
  109. package/dist/chunk-UM7ZR3VU.js +14 -0
  110. package/dist/chunk-UORPTGV2.js +114 -0
  111. package/dist/{chunk-5M3SL4UZ.js → chunk-VCOQ7WQ2.js} +30 -106
  112. package/dist/chunk-VCUUITW6.js +35 -0
  113. package/dist/{chunk-PTW7JNAP.js → chunk-VDHW6H5F.js} +5 -5
  114. package/dist/chunk-VZUA5SRD.js +62 -0
  115. package/dist/{chunk-DKQ4XMSN.js → chunk-X4GWB6AT.js} +6 -6
  116. package/dist/{chunk-6YA3C4NB.js → chunk-XCIMOIX6.js} +3 -12
  117. package/dist/chunk-XP23ZVQT.js +2183 -0
  118. package/dist/{chunk-WBI7FEGI.js → chunk-Y2MQ5EMD.js} +29 -24
  119. package/dist/chunk-YBF45CX5.js +23 -0
  120. package/dist/{chunk-N7OVXN72.js → chunk-YGJCJBPM.js} +1 -1
  121. package/dist/{chunk-WNVEMFIK.js → chunk-YHIJCI4U.js} +3 -3
  122. package/dist/{chunk-WFE6CT6M.js → chunk-YQZBAP3S.js} +22 -76
  123. package/dist/chunk-ZHFFTT3I.js +17 -0
  124. package/dist/{collections-DJZI2RM2.js → collections-URH2TCWJ.js} +28 -24
  125. package/dist/{configuration-GN3TO77H.js → configuration-7IYZ6GNP.js} +3 -3
  126. package/dist/{configuration-RHPIO2QT.js → configuration-C4IGBNXH.js} +1 -1
  127. package/dist/{create-7S7CZWEN.js → create-5PSOIHIT.js} +4 -4
  128. package/dist/create-7R6CZU53.js +215 -0
  129. package/dist/{create-3EK5CNNX.js → create-A7B3MLJX.js} +41 -34
  130. package/dist/create-F5R76QML.js +1178 -0
  131. package/dist/create-FKRYB7ZS.js +1784 -0
  132. package/dist/create-GGACODDN.js +1914 -0
  133. package/dist/{create-YO55Z3YD.js → create-HVZYJ3YC.js} +35 -38
  134. package/dist/{create-IDVCZHIX.js → create-JF2OUZQA.js} +16 -13
  135. package/dist/{create-3ZVXEPX5.js → create-JGYG5SBM.js} +29 -23
  136. package/dist/{create-G4T2PAJH.js → create-MS6KKFSV.js} +21 -18
  137. package/dist/{create-OCFPLNNY.js → create-MZYXMGKP.js} +6 -6
  138. package/dist/{create-HKJVSFB7.js → create-O35JRZEF.js} +25 -22
  139. package/dist/{create-OGLPDVOI.js → create-ODOFJF5N.js} +40 -37
  140. package/dist/{create-GHM7OTCR.js → create-R7K3ECN6.js} +1 -1
  141. package/dist/{create-D6EW3EWC.js → create-SFU3W3ZH.js} +1 -1
  142. package/dist/create-TKXH5KQY.js +239 -0
  143. package/dist/{create-33TRLASX.js → create-UPYB65PD.js} +1 -1
  144. package/dist/{create-KGYL7FBM.js → create-XVHOCZHJ.js} +1 -1
  145. package/dist/{create-4AE3VTWN.js → create-YBF4YGWG.js} +2 -2
  146. package/dist/{customers-6ZLE65UX.js → customers-SOLJ2KQQ.js} +5 -5
  147. package/dist/{edit-QBISX7D3.js → edit-2R5QCPTB.js} +16 -13
  148. package/dist/{edit-IR6V2IDN.js → edit-3E4ZO7HT.js} +21 -18
  149. package/dist/{edit-ZSOI56BQ.js → edit-4G5D7TES.js} +52 -40
  150. package/dist/{edit-B5B3XKDM.js → edit-522DG3BY.js} +1 -1
  151. package/dist/{edit-B75KK5ZX.js → edit-5CROKEJE.js} +41 -34
  152. package/dist/{edit-ATXE6CM5.js → edit-C4OCKQVU.js} +1 -1
  153. package/dist/{edit-7HTH2UJF.js → edit-FXNXTVIW.js} +3 -3
  154. package/dist/{edit-RNT555GP.js → edit-G2E5SNGU.js} +15 -12
  155. package/dist/{edit-4HZHLYI3.js → edit-GQNIINRR.js} +1 -1
  156. package/dist/{edit-2KRJIPRK.js → edit-HTLLYECP.js} +21 -18
  157. package/dist/{edit-LRRJTHV2.js → edit-KAKVPHZZ.js} +1 -1
  158. package/dist/{edit-GIJXLMC3.js → edit-O4JLGKQR.js} +2 -2
  159. package/dist/{edit-FNDDSSMT.js → edit-OKU6FMHJ.js} +60 -9
  160. package/dist/{edit-5CJZRHAA.js → edit-ORXS3A2Y.js} +1 -1
  161. package/dist/{edit-FC64DWB2.js → edit-Q3UQIOLS.js} +1 -1
  162. package/dist/edit-VVLITC2E.js +910 -0
  163. package/dist/edit-XSICGAVO.js +176 -0
  164. package/dist/{edit-7GVP6SRA.js → edit-ZAHCMF5U.js} +1 -1
  165. package/dist/{edit-MYSWY6W4.js → edit-ZMERG3L7.js} +1 -1
  166. package/dist/{edit-budget-J27CSEZH.js → edit-budget-L3CCEWNF.js} +1 -1
  167. package/dist/{edit-inventory-item-US77M2FF.js → edit-inventory-item-ZKXXL3QK.js} +2 -2
  168. package/dist/{edit-inventory-item-attributes-UGAE2NAZ.js → edit-inventory-item-attributes-GSKUMORD.js} +3 -3
  169. package/dist/{fulfillment-DCS67LTK.js → fulfillment-76IVZ266.js} +32 -22
  170. package/dist/{fulfillment-providers-GM5PO6N3.js → fulfillment-providers-G2L6LEVO.js} +24 -20
  171. package/dist/index.css +104 -65
  172. package/dist/index.d.ts +3 -10
  173. package/dist/index.js +549 -456
  174. package/dist/{inventory-OPZ2FSEE.js → inventory-WSFLTA6Z.js} +7 -7
  175. package/dist/{invite-KEJLNXEZ.js → invite-2673PU4I.js} +17 -13
  176. package/dist/{invite-CQCKEQW2.js → invite-HRXZ5YBP.js} +28 -24
  177. package/dist/loader-VDYPD3RI.js +31 -0
  178. package/dist/{locations-ZVPTQCQY.js → locations-INS6FTMJ.js} +4 -4
  179. package/dist/{login-OUHRNNXA.js → login-TWUBU6I6.js} +14 -11
  180. package/dist/{manage-locations-YUKEFCBJ.js → manage-locations-XHH5DVIR.js} +2 -2
  181. package/dist/{media-4KYFHB5V.js → media-Z4N5MKFG.js} +42 -9
  182. package/dist/{metadata-AWUKZ25V.js → metadata-5BPOBBU2.js} +3 -3
  183. package/dist/{metadata-OCE6A3JE.js → metadata-D6M66NQK.js} +17 -14
  184. package/dist/{metadata-PYY4IB7K.js → metadata-NIDIBXJT.js} +17 -14
  185. package/dist/{metadata-XP3ZYW2M.js → metadata-Q74OJWUD.js} +18 -15
  186. package/dist/{metadata-NYYL26MQ.js → metadata-REQIFWWH.js} +18 -15
  187. package/dist/{metadata-G7KZXVNE.js → metadata-YVHJPDLD.js} +17 -14
  188. package/dist/offer-create-page-E4FLSDJQ.js +743 -0
  189. package/dist/offer-detail-page-6SIBQTLP.js +492 -0
  190. package/dist/offer-edit-page-3MO566RP.js +151 -0
  191. package/dist/offer-inventory-batch-page-BD6PMDLW.js +290 -0
  192. package/dist/offer-pricing-edit-page-4TINK42V.js +199 -0
  193. package/dist/offers-GVN5LCK6.js +32 -0
  194. package/dist/{onboarding-WXZHW62K.js → onboarding-MK2RIFD4.js} +24 -21
  195. package/dist/{orders-LWJ472VM.js → orders-TVQDR4OJ.js} +30 -26
  196. package/dist/organization-XO3T2K2X.js +340 -0
  197. package/dist/{organize-RFOMQCBG.js → organize-5XRZWD5C.js} +4 -4
  198. package/dist/{organize-OVKJ3HZO.js → organize-Z7JTTDH4.js} +4 -4
  199. package/dist/pages/index.d.ts +439 -758
  200. package/dist/pages/index.js +85 -78
  201. package/dist/{payment-details-UVXYCTUK.js → payment-details-CFTX3QDL.js} +19 -16
  202. package/dist/{payouts-TR7K5I37.js → payouts-7Q7D4FET.js} +8 -8
  203. package/dist/{price-lists-S2WNELFZ.js → price-lists-6TFLA53G.js} +9 -9
  204. package/dist/{pricing-UF27DAXA.js → pricing-ECXV6K7G.js} +41 -37
  205. package/dist/{product-tags-2CKH2M6D.js → product-tags-5O7ZG6SA.js} +40 -33
  206. package/dist/{product-types-FX43JEO2.js → product-types-PKUEL7X5.js} +6 -6
  207. package/dist/product-variant-detail-PUWOMVHQ.js +210 -0
  208. package/dist/{product-variant-edit-P3DSIFE3.js → product-variant-edit-WZNO4CQX.js} +134 -66
  209. package/dist/{products-H5EMRJYS.js → products-BM3IIH5P.js} +27 -21
  210. package/dist/{products-2LHGS7X3.js → products-CPTRYL2Z.js} +44 -45
  211. package/dist/{professional-details-HYKTH44B.js → professional-details-ED4HNYXY.js} +18 -15
  212. package/dist/{profile-PB27WIRW.js → profile-6TGCNNUU.js} +21 -18
  213. package/dist/{promotions-5EYPGHJP.js → promotions-4336KI7E.js} +9 -9
  214. package/dist/receive-224KLULH.js +578 -0
  215. package/dist/refund-IGMSXQNX.js +268 -0
  216. package/dist/{register-X45K325N.js → register-OZ5CRANZ.js} +18 -15
  217. package/dist/{reset-password-GTWLBOFK.js → reset-password-5UHZU4D3.js} +1 -1
  218. package/dist/{return-reasons-LOKYRGMI.js → return-reasons-QJRA2ZX6.js} +21 -17
  219. package/dist/{sales-channels-Y4LRP7JC.js → sales-channels-CZDU7VTE.js} +7 -6
  220. package/dist/{sales-channels-7R2IY3KG.js → sales-channels-U55MUDQP.js} +7 -6
  221. package/dist/{settings-2XDLFYMS.js → settings-2GCQQTO6.js} +47 -40
  222. package/dist/shipment-HWQHMX2L.js +242 -0
  223. package/dist/{shipping-profile-R3NABPQF.js → shipping-profile-ZP7M6VSS.js} +2 -2
  224. package/dist/{shipping-profiles-QVKNFLCW.js → shipping-profiles-C5WBXWZ2.js} +21 -18
  225. package/dist/{stock-5RXNUPUT.js → stock-MQA7PRO6.js} +21 -18
  226. package/dist/{store-MPYOWMZT.js → store-5ZHZR4JI.js} +84 -149
  227. package/dist/{store-closure-DNMCHUXD.js → store-closure-H5WHV3LA.js} +24 -16
  228. package/dist/{store-select-UTPJ7DM7.js → store-select-PZS556FB.js} +19 -16
  229. package/dist/{tax-regions-UD6P5FVC.js → tax-regions-HDLBFZVG.js} +6 -6
  230. package/dist/{team-IMS66MVP.js → team-CLKJCZNH.js} +29 -26
  231. package/dist/types-CtCEtTE6.d.ts +16 -0
  232. package/package.json +5 -5
  233. package/dist/[id]-BYP37PU4.js +0 -1314
  234. package/dist/[id]-INOFZHL7.js +0 -1219
  235. package/dist/add-KRAGFFBJ.js +0 -158
  236. package/dist/bulk-edit-3SMBLIOA.js +0 -244
  237. package/dist/chunk-47SXTGLN.js +0 -397
  238. package/dist/chunk-4KX6CBJ4.js +0 -178
  239. package/dist/chunk-DLNNTQRY.js +0 -217
  240. package/dist/chunk-FX4V5JCF.js +0 -37
  241. package/dist/chunk-GC33DBKG.js +0 -143
  242. package/dist/chunk-LQYMBSRQ.js +0 -66
  243. package/dist/chunk-NK4NR6MN.js +0 -173
  244. package/dist/chunk-PFU6FSXY.js +0 -430
  245. package/dist/chunk-QJEOPT2P.js +0 -330
  246. package/dist/chunk-QSGR43JM.js +0 -30
  247. package/dist/chunk-STR3NGWE.js +0 -3736
  248. package/dist/create-3DOO3RNH.js +0 -716
  249. package/dist/create-I7HV3RM6.js +0 -150
  250. package/dist/edit-K2AD335I.js +0 -237
  251. package/dist/edit-VO5XLIEL.js +0 -362
  252. package/dist/edit-stocks-and-prices-MHHQFWFA.js +0 -408
  253. package/dist/organization-LPYQRTQC.js +0 -303
  254. package/dist/prices-3OXV5RGY.js +0 -270
  255. package/dist/product-variant-detail-WV4KXVXR.js +0 -590
  256. package/dist/shipment-4GW2JFWB.js +0 -174
  257. package/dist/stock-GPC3BCL6.js +0 -500
  258. package/dist/{chunk-SDSEW72R.js → chunk-E2HQPY32.js} +3 -3
  259. /package/dist/{chunk-CAS74NLJ.js → chunk-YV6MK4PZ.js} +0 -0
@@ -0,0 +1,2183 @@
1
+ import {
2
+ DataGrid,
3
+ createDataGridHelper
4
+ } from "./chunk-4LVP635F.js";
5
+ import {
6
+ HandleInput
7
+ } from "./chunk-HJ56YXBU.js";
8
+ import {
9
+ defineTabMeta
10
+ } from "./chunk-LEWA4BPH.js";
11
+ import {
12
+ SwitchBox
13
+ } from "./chunk-YVCBMOJG.js";
14
+ import {
15
+ SingleCategoryCombobox
16
+ } from "./chunk-GAE6TKOR.js";
17
+ import {
18
+ useComboboxData
19
+ } from "./chunk-OVPAOBZB.js";
20
+ import {
21
+ UploadMediaFormItem
22
+ } from "./chunk-GN6KB75Z.js";
23
+ import {
24
+ PRODUCT_CREATE_FORM_DEFAULTS,
25
+ ProductCreateSchema,
26
+ decorateVariantsWithDefaultValues,
27
+ generateVariantsFromAttributes,
28
+ normalizeProductFormValues
29
+ } from "./chunk-LDZCCWJB.js";
30
+ import {
31
+ ChipInput
32
+ } from "./chunk-YGRTRAWX.js";
33
+ import {
34
+ useAttributeTableFilters,
35
+ useAttributeTableQuery
36
+ } from "./chunk-HDEOZN2Q.js";
37
+ import {
38
+ Combobox
39
+ } from "./chunk-VBRTC2VU.js";
40
+ import {
41
+ TabbedForm,
42
+ useTabbedForm
43
+ } from "./chunk-LQD232FW.js";
44
+ import {
45
+ RouteFocusModal,
46
+ StackedFocusModal,
47
+ useRouteModal,
48
+ useStackedModal
49
+ } from "./chunk-GDWBOQI5.js";
50
+ import {
51
+ Form
52
+ } from "./chunk-3QSRE5LS.js";
53
+ import {
54
+ DataTable
55
+ } from "./chunk-5T6UWTRU.js";
56
+ import {
57
+ require_dist
58
+ } from "./chunk-UCYSCKZV.js";
59
+ import {
60
+ useFeatureFlags
61
+ } from "./chunk-TBYCZRZ7.js";
62
+ import {
63
+ ActionMenu
64
+ } from "./chunk-BDGZ4EQO.js";
65
+ import {
66
+ useCreateProduct,
67
+ useProductAttributes
68
+ } from "./chunk-JAUZ73XE.js";
69
+ import {
70
+ sdk,
71
+ uploadFilesQuery
72
+ } from "./chunk-RIN4CBRB.js";
73
+ import {
74
+ __toESM
75
+ } from "./chunk-NBMM2TZK.js";
76
+
77
+ // src/pages/products/create/product-create.tsx
78
+ import { Children as Children2 } from "react";
79
+ import { useTranslation as useTranslation10 } from "react-i18next";
80
+
81
+ // src/pages/products/create/components/product-create-form/product-create-form.tsx
82
+ var import_types6 = __toESM(require_dist(), 1);
83
+ import { Button as Button3, toast } from "@medusajs/ui";
84
+ import { useEffect as useEffect3, useMemo as useMemo5, Children } from "react";
85
+ import { useForm, useWatch as useWatch3 } from "react-hook-form";
86
+ import { useTranslation as useTranslation9 } from "react-i18next";
87
+ import { zodResolver } from "@hookform/resolvers/zod";
88
+
89
+ // src/pages/products/create/components/product-create-attributes-form/product-create-attributes-form.tsx
90
+ var import_types = __toESM(require_dist(), 1);
91
+ import { CircleMiniFilledSolid, XMarkMini } from "@medusajs/icons";
92
+ import {
93
+ Button as Button2,
94
+ Heading,
95
+ Hint,
96
+ IconButton,
97
+ InlineTip,
98
+ Input,
99
+ Label,
100
+ Select,
101
+ Switch,
102
+ Text,
103
+ Textarea,
104
+ clx
105
+ } from "@medusajs/ui";
106
+ import { Select as RadixSelect } from "radix-ui";
107
+ import { forwardRef, useEffect as useEffect2 } from "react";
108
+ import {
109
+ Controller,
110
+ useFieldArray
111
+ } from "react-hook-form";
112
+ import { useTranslation as useTranslation2 } from "react-i18next";
113
+
114
+ // src/pages/products/create/components/product-create-attributes-form/product-create-add-attributes-modal.tsx
115
+ import {
116
+ Badge,
117
+ Button,
118
+ Checkbox,
119
+ createDataTableColumnHelper,
120
+ Tooltip
121
+ } from "@medusajs/ui";
122
+ import { useEffect, useMemo, useState } from "react";
123
+ import { useTranslation } from "react-i18next";
124
+ import { keepPreviousData } from "@tanstack/react-query";
125
+ import { jsx, jsxs } from "react/jsx-runtime";
126
+ var ADD_ATTRIBUTES_MODAL_ID = "add-attributes";
127
+ var PAGE_SIZE = 20;
128
+ var MAX_VISIBLE_VALUES = 2;
129
+ var ATTRIBUTE_TYPE_LABELS = {
130
+ single_select: "attributes.type.select",
131
+ multi_select: "attributes.type.multivalue",
132
+ unit: "attributes.type.unit",
133
+ toggle: "attributes.type.toggle",
134
+ text: "attributes.type.text_area"
135
+ };
136
+ var ROW_HIGHLIGHT_CLASSES = [
137
+ "[&_tr:has(button[role=checkbox][data-state=checked]:not([disabled]))>td]:!bg-ui-bg-highlight",
138
+ "[&_tr:has(button[role=checkbox][data-state=checked][disabled])>td]:!bg-ui-bg-subtle"
139
+ ].join(" ");
140
+ var ProductCreateAddAttributesModal = () => {
141
+ const form = useTabbedForm();
142
+ const { t } = useTranslation();
143
+ const { getValues, setValue } = form;
144
+ const { setIsOpen, getIsOpen } = useStackedModal();
145
+ const [rowSelection, setRowSelection] = useState(
146
+ {}
147
+ );
148
+ const [state, setState] = useState([]);
149
+ const { searchParams } = useAttributeTableQuery({
150
+ pageSize: PAGE_SIZE,
151
+ prefix: ADD_ATTRIBUTES_MODAL_ID
152
+ });
153
+ const { product_attributes, count, isLoading, isError, error } = useProductAttributes(searchParams, {
154
+ placeholderData: keepPreviousData
155
+ });
156
+ const open = getIsOpen(ADD_ATTRIBUTES_MODAL_ID);
157
+ useEffect(() => {
158
+ if (!open) {
159
+ return;
160
+ }
161
+ const attributes = getValues("attributes") ?? [];
162
+ const existing = attributes.filter((a) => a.attribute_id);
163
+ const selection = {};
164
+ const stateEntries = [];
165
+ for (const a of existing) {
166
+ if (a.attribute_id) {
167
+ selection[a.attribute_id] = true;
168
+ const apiAttr = product_attributes?.find(
169
+ (pa) => pa.id === a.attribute_id
170
+ );
171
+ stateEntries.push({
172
+ id: a.attribute_id,
173
+ name: a.title,
174
+ values: Array.isArray(a.values) ? a.values : a.values ? [a.values] : [],
175
+ is_variant_axis: a.use_for_variants,
176
+ type: a.type ?? apiAttr?.type ?? "",
177
+ available_values: a.available_values ?? apiAttr?.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
178
+ });
179
+ }
180
+ }
181
+ if (product_attributes) {
182
+ for (const attr of product_attributes) {
183
+ if (attr.is_required && !selection[attr.id]) {
184
+ selection[attr.id] = true;
185
+ stateEntries.push({
186
+ id: attr.id,
187
+ name: attr.name,
188
+ values: [],
189
+ is_variant_axis: attr.is_variant_axis,
190
+ type: attr.type,
191
+ available_values: attr.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
192
+ });
193
+ }
194
+ }
195
+ }
196
+ setRowSelection(selection);
197
+ setState(stateEntries);
198
+ }, [open, getValues, product_attributes]);
199
+ const onRowSelectionChange = (next) => {
200
+ if (product_attributes) {
201
+ for (const attr of product_attributes) {
202
+ if (attr.is_required) {
203
+ next[attr.id] = true;
204
+ }
205
+ }
206
+ }
207
+ const ids = Object.keys(next);
208
+ const addedIdsSet = new Set(
209
+ ids.filter((id) => next[id] && !rowSelection[id])
210
+ );
211
+ let addedAttributes = [];
212
+ if (addedIdsSet.size > 0) {
213
+ addedAttributes = product_attributes?.filter((attr) => addedIdsSet.has(attr.id)).map((attr) => ({
214
+ id: attr.id,
215
+ name: attr.name,
216
+ values: [],
217
+ is_variant_axis: attr.is_variant_axis,
218
+ type: attr.type,
219
+ available_values: attr.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
220
+ })) ?? [];
221
+ }
222
+ setState((prev) => {
223
+ const filteredPrev = prev.filter((a) => next[a.id]);
224
+ return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedAttributes]));
225
+ });
226
+ setRowSelection(next);
227
+ };
228
+ const handleAdd = () => {
229
+ const currentAttributes = getValues("attributes") ?? [];
230
+ const customAttributes = currentAttributes.filter((a) => a.is_custom);
231
+ const requiredIds = new Set(
232
+ product_attributes?.filter((a) => a.is_required).map((a) => a.id) ?? []
233
+ );
234
+ const selectedAttributes = state.map((a) => ({
235
+ attribute_id: a.id,
236
+ title: a.name,
237
+ values: a.values,
238
+ is_custom: false,
239
+ is_required: requiredIds.has(a.id),
240
+ use_for_variants: a.is_variant_axis,
241
+ type: a.type,
242
+ available_values: a.available_values
243
+ }));
244
+ setValue("attributes", [...selectedAttributes, ...customAttributes], {
245
+ shouldDirty: true,
246
+ shouldTouch: true
247
+ });
248
+ setIsOpen(ADD_ATTRIBUTES_MODAL_ID, false);
249
+ };
250
+ const filters = useAttributeTableFilters();
251
+ const columns = useColumns();
252
+ if (isError) {
253
+ throw error;
254
+ }
255
+ const emptyState = useMemo(
256
+ () => ({
257
+ empty: {
258
+ heading: t("products.create.attributes.noAttributesTitle"),
259
+ description: t("products.create.attributes.noAttributesDescription")
260
+ }
261
+ }),
262
+ [t]
263
+ );
264
+ return /* @__PURE__ */ jsxs(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
265
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
266
+ /* @__PURE__ */ jsx(
267
+ StackedFocusModal.Body,
268
+ {
269
+ className: `flex-1 overflow-hidden ${ROW_HIGHLIGHT_CLASSES}`,
270
+ "data-testid": "product-create-add-attributes-table",
271
+ children: /* @__PURE__ */ jsx(
272
+ DataTable,
273
+ {
274
+ data: product_attributes,
275
+ columns,
276
+ filters,
277
+ rowCount: count,
278
+ pageSize: PAGE_SIZE,
279
+ getRowId: (row) => row.id,
280
+ rowSelection: {
281
+ state: rowSelection,
282
+ onRowSelectionChange,
283
+ enableRowSelection: (row) => !row.original.is_required
284
+ },
285
+ isLoading,
286
+ layout: "fill",
287
+ prefix: ADD_ATTRIBUTES_MODAL_ID,
288
+ compact: true,
289
+ emptyState
290
+ }
291
+ )
292
+ }
293
+ ),
294
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
295
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: t("actions.cancel") }) }),
296
+ /* @__PURE__ */ jsx(Button, { size: "small", onClick: handleAdd, type: "button", children: t("actions.save") })
297
+ ] }) })
298
+ ] });
299
+ };
300
+ var columnHelper = createDataTableColumnHelper();
301
+ var useColumns = () => {
302
+ const { t } = useTranslation();
303
+ return useMemo(
304
+ () => [
305
+ columnHelper.select({
306
+ cell: (ctx) => {
307
+ const checked = ctx.row.getIsSelected();
308
+ const onChange = ctx.row.getToggleSelectedHandler();
309
+ const disabled = !ctx.row.getCanSelect();
310
+ const checkbox = /* @__PURE__ */ jsx(
311
+ Checkbox,
312
+ {
313
+ onClick: (e) => e.stopPropagation(),
314
+ checked,
315
+ onCheckedChange: onChange,
316
+ disabled
317
+ }
318
+ );
319
+ if (disabled) {
320
+ return /* @__PURE__ */ jsx(
321
+ Tooltip,
322
+ {
323
+ content: t("products.create.attributes.requiredTooltip"),
324
+ children: /* @__PURE__ */ jsx("span", { className: "inline-flex", children: checkbox })
325
+ }
326
+ );
327
+ }
328
+ return checkbox;
329
+ }
330
+ }),
331
+ columnHelper.accessor("name", {
332
+ header: t("attributes.fields.name"),
333
+ enableSorting: false
334
+ }),
335
+ columnHelper.accessor("handle", {
336
+ header: t("attributes.fields.handle"),
337
+ cell: (info) => {
338
+ const handle = info.getValue();
339
+ return handle ? `/${handle}` : "-";
340
+ },
341
+ enableSorting: false
342
+ }),
343
+ columnHelper.accessor("is_required", {
344
+ header: t("attributes.fields.required"),
345
+ cell: (info) => {
346
+ if (info.getValue()) {
347
+ return /* @__PURE__ */ jsx(
348
+ Tooltip,
349
+ {
350
+ content: t("products.create.attributes.requiredTooltip"),
351
+ children: /* @__PURE__ */ jsx("span", { className: "cursor-help underline decoration-dotted underline-offset-2", children: t("filters.radio.yes") })
352
+ }
353
+ );
354
+ }
355
+ return t("filters.radio.no");
356
+ },
357
+ enableSorting: false
358
+ }),
359
+ columnHelper.accessor("type", {
360
+ header: t("attributes.fields.type"),
361
+ cell: (info) => {
362
+ const type = info.getValue();
363
+ const labelKey = ATTRIBUTE_TYPE_LABELS[type];
364
+ return labelKey ? t(labelKey) : type;
365
+ },
366
+ enableSorting: false
367
+ }),
368
+ columnHelper.accessor("is_variant_axis", {
369
+ header: t("attributes.fields.variantAxis"),
370
+ cell: (info) => info.getValue() ? t("filters.radio.yes") : t("filters.radio.no"),
371
+ enableSorting: false
372
+ }),
373
+ columnHelper.display({
374
+ id: "values",
375
+ header: t("attributes.fields.values"),
376
+ cell: ({ row }) => {
377
+ const values = row.original.values ?? [];
378
+ if (!values.length) {
379
+ return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "-" });
380
+ }
381
+ const visible = values.slice(0, MAX_VISIBLE_VALUES);
382
+ const remaining = values.length - MAX_VISIBLE_VALUES;
383
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
384
+ visible.map((v) => /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "grey", children: v.name }, v.id)),
385
+ remaining > 0 && /* @__PURE__ */ jsxs(Badge, { size: "2xsmall", color: "grey", children: [
386
+ "+",
387
+ remaining
388
+ ] })
389
+ ] });
390
+ }
391
+ })
392
+ ],
393
+ [t]
394
+ );
395
+ };
396
+
397
+ // src/pages/products/create/components/product-create-attributes-form/product-create-attributes-form.tsx
398
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
399
+ var Root = () => {
400
+ const { t } = useTranslation2();
401
+ const form = useTabbedForm();
402
+ const { setIsOpen } = useStackedModal();
403
+ const { fields, append, remove } = useFieldArray({
404
+ control: form.control,
405
+ name: "attributes"
406
+ });
407
+ const handleCreateNew = () => {
408
+ append({
409
+ attribute_id: void 0,
410
+ title: "",
411
+ values: [],
412
+ is_custom: true,
413
+ use_for_variants: false
414
+ });
415
+ };
416
+ const handleAddExisting = () => {
417
+ setIsOpen(ADD_ATTRIBUTES_MODAL_ID, true);
418
+ };
419
+ return /* @__PURE__ */ jsxs2(
420
+ "div",
421
+ {
422
+ className: "flex flex-col items-center p-16",
423
+ "data-testid": "product-create-attributes-form",
424
+ children: [
425
+ /* @__PURE__ */ jsx2(StackedFocusModal, { id: ADD_ATTRIBUTES_MODAL_ID, children: /* @__PURE__ */ jsx2(ProductCreateAddAttributesModal, {}) }),
426
+ /* @__PURE__ */ jsxs2("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
427
+ /* @__PURE__ */ jsxs2("div", { children: [
428
+ /* @__PURE__ */ jsx2(Heading, { level: "h2", children: t("products.create.attributes.header") }),
429
+ /* @__PURE__ */ jsx2(
430
+ Text,
431
+ {
432
+ size: "small",
433
+ className: "text-ui-fg-subtle mt-1 whitespace-pre-line",
434
+ children: t("products.create.attributes.description")
435
+ }
436
+ )
437
+ ] }),
438
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
439
+ /* @__PURE__ */ jsx2(
440
+ Button2,
441
+ {
442
+ type: "button",
443
+ variant: "secondary",
444
+ size: "small",
445
+ onClick: handleAddExisting,
446
+ children: t("products.create.attributes.addExisting")
447
+ }
448
+ ),
449
+ /* @__PURE__ */ jsx2(
450
+ Button2,
451
+ {
452
+ type: "button",
453
+ variant: "secondary",
454
+ size: "small",
455
+ onClick: handleCreateNew,
456
+ children: t("products.create.attributes.createNew")
457
+ }
458
+ )
459
+ ] }),
460
+ fields.some((f) => !f.is_custom && !!f.attribute_id) && /* @__PURE__ */ jsx2(SelectedAttributes, { fields, remove }),
461
+ fields.some((f) => f.is_custom) && /* @__PURE__ */ jsx2("ul", { className: "flex flex-col gap-y-4", children: fields.map((field, index) => {
462
+ if (!field.is_custom) return null;
463
+ const useForVariants = form.watch(
464
+ `attributes.${index}.use_for_variants`
465
+ );
466
+ return /* @__PURE__ */ jsxs2(
467
+ "li",
468
+ {
469
+ className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
470
+ children: [
471
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
472
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
473
+ Label,
474
+ {
475
+ size: "xsmall",
476
+ weight: "plus",
477
+ className: "text-ui-fg-subtle",
478
+ htmlFor: `attributes.${index}.title`,
479
+ children: t("fields.title")
480
+ }
481
+ ) }),
482
+ /* @__PURE__ */ jsx2(
483
+ Input,
484
+ {
485
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
486
+ ...form.register(`attributes.${index}.title`),
487
+ placeholder: t(
488
+ "products.create.attributes.titlePlaceholder"
489
+ )
490
+ }
491
+ ),
492
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
493
+ Label,
494
+ {
495
+ size: "xsmall",
496
+ weight: "plus",
497
+ className: "text-ui-fg-subtle",
498
+ htmlFor: `attributes.${index}.values`,
499
+ children: t("fields.values")
500
+ }
501
+ ) }),
502
+ /* @__PURE__ */ jsx2(
503
+ Controller,
504
+ {
505
+ control: form.control,
506
+ name: `attributes.${index}.values`,
507
+ render: ({ field: { onChange, value, ...field2 } }) => useForVariants ? /* @__PURE__ */ jsx2(
508
+ ChipInput,
509
+ {
510
+ ...field2,
511
+ variant: "contrast",
512
+ value: Array.isArray(value) ? value : [],
513
+ onChange,
514
+ placeholder: t(
515
+ "products.create.attributes.valuePlaceholder"
516
+ )
517
+ }
518
+ ) : /* @__PURE__ */ jsx2(
519
+ Textarea,
520
+ {
521
+ ...field2,
522
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
523
+ value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
524
+ onChange: (e) => onChange(e.target.value),
525
+ placeholder: t(
526
+ "products.create.attributes.valuePlaceholder"
527
+ )
528
+ }
529
+ )
530
+ }
531
+ ),
532
+ /* @__PURE__ */ jsx2("div", {}),
533
+ /* @__PURE__ */ jsx2(
534
+ Form.Field,
535
+ {
536
+ control: form.control,
537
+ name: `attributes.${index}.use_for_variants`,
538
+ render: ({ field: { value, onChange, ref } }) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2("div", { className: "flex items-start gap-x-3 py-1.5", children: [
539
+ /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
540
+ Switch,
541
+ {
542
+ ref,
543
+ className: "shrink-0 rtl:rotate-180",
544
+ checked: value,
545
+ onCheckedChange: onChange
546
+ }
547
+ ) }),
548
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
549
+ /* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t("products.create.attributes.useForVariants") }),
550
+ /* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
551
+ "products.create.attributes.useForVariantsDescription"
552
+ ) })
553
+ ] })
554
+ ] }) })
555
+ }
556
+ )
557
+ ] }),
558
+ /* @__PURE__ */ jsx2(
559
+ IconButton,
560
+ {
561
+ type: "button",
562
+ size: "small",
563
+ variant: "transparent",
564
+ className: "text-ui-fg-muted",
565
+ onClick: () => remove(index),
566
+ children: /* @__PURE__ */ jsx2(XMarkMini, {})
567
+ }
568
+ )
569
+ ]
570
+ },
571
+ field.id
572
+ );
573
+ }) }),
574
+ /* @__PURE__ */ jsx2(RequiredAttributes, {})
575
+ ] })
576
+ ]
577
+ }
578
+ );
579
+ };
580
+ var SelectedAttributes = ({
581
+ fields,
582
+ remove
583
+ }) => {
584
+ const { t } = useTranslation2();
585
+ const form = useTabbedForm();
586
+ const entries = fields.map((field, index) => ({ field, index })).filter(
587
+ ({ field }) => !field.is_custom && !field.is_required && !!field.attribute_id
588
+ );
589
+ if (!entries.length) return null;
590
+ return /* @__PURE__ */ jsx2("ul", { className: "flex flex-col gap-y-4", children: entries.map(({ field, index }) => {
591
+ const attrType = field.type;
592
+ const availableValues = field.available_values ?? [];
593
+ return /* @__PURE__ */ jsxs2(
594
+ "li",
595
+ {
596
+ className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
597
+ children: [
598
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
599
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
600
+ Label,
601
+ {
602
+ size: "xsmall",
603
+ weight: "plus",
604
+ className: "text-ui-fg-subtle",
605
+ children: t("fields.title")
606
+ }
607
+ ) }),
608
+ /* @__PURE__ */ jsx2(
609
+ Input,
610
+ {
611
+ value: field.title,
612
+ disabled: true,
613
+ className: "bg-ui-bg-field-component"
614
+ }
615
+ ),
616
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
617
+ Label,
618
+ {
619
+ size: "xsmall",
620
+ weight: "plus",
621
+ className: "text-ui-fg-subtle",
622
+ children: t("fields.values")
623
+ }
624
+ ) }),
625
+ attrType === import_types.AttributeType.MULTI_SELECT ? /* @__PURE__ */ jsx2(
626
+ Controller,
627
+ {
628
+ control: form.control,
629
+ name: `attributes.${index}.values`,
630
+ render: ({ field: { onChange, value, ref, ...rest } }) => /* @__PURE__ */ jsx2(
631
+ Combobox,
632
+ {
633
+ ...rest,
634
+ ref,
635
+ value: Array.isArray(value) ? value : [],
636
+ onChange: (val) => onChange(val ?? []),
637
+ options: availableValues.map((v) => ({
638
+ value: v.name,
639
+ label: v.name
640
+ })),
641
+ placeholder: t("products.create.attributes.selectValues")
642
+ }
643
+ )
644
+ }
645
+ ) : attrType === import_types.AttributeType.SINGLE_SELECT ? /* @__PURE__ */ jsx2(
646
+ Controller,
647
+ {
648
+ control: form.control,
649
+ name: `attributes.${index}.values`,
650
+ render: ({ field: { onChange, value, ref, ...rest } }) => /* @__PURE__ */ jsxs2(
651
+ Select,
652
+ {
653
+ ...rest,
654
+ value: typeof value === "string" ? value : value?.[0] ?? "",
655
+ onValueChange: onChange,
656
+ children: [
657
+ /* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
658
+ Select.Value,
659
+ {
660
+ placeholder: t(
661
+ "products.create.attributes.selectValues"
662
+ )
663
+ }
664
+ ) }),
665
+ /* @__PURE__ */ jsx2(Select.Content, { children: availableValues.map((v) => /* @__PURE__ */ jsx2(Select.Item, { value: v.name, children: v.name }, v.id)) })
666
+ ]
667
+ }
668
+ )
669
+ }
670
+ ) : attrType === import_types.AttributeType.TEXT ? /* @__PURE__ */ jsx2(
671
+ Controller,
672
+ {
673
+ control: form.control,
674
+ name: `attributes.${index}.values`,
675
+ render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsx2(
676
+ Textarea,
677
+ {
678
+ ...rest,
679
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
680
+ value: typeof value === "string" ? value : value?.[0] ?? "",
681
+ onChange: (e) => onChange(e.target.value),
682
+ placeholder: t(
683
+ "products.create.attributes.valuePlaceholder"
684
+ )
685
+ }
686
+ )
687
+ }
688
+ ) : attrType === import_types.AttributeType.TOGGLE ? /* @__PURE__ */ jsx2(
689
+ Controller,
690
+ {
691
+ control: form.control,
692
+ name: `attributes.${index}.values`,
693
+ render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsxs2(
694
+ Select,
695
+ {
696
+ ...rest,
697
+ value: typeof value === "string" ? value : value?.[0] ?? "",
698
+ onValueChange: onChange,
699
+ children: [
700
+ /* @__PURE__ */ jsx2(Select.Trigger, { children: /* @__PURE__ */ jsx2(
701
+ Select.Value,
702
+ {
703
+ placeholder: t(
704
+ "products.create.attributes.selectValues"
705
+ )
706
+ }
707
+ ) }),
708
+ /* @__PURE__ */ jsxs2(Select.Content, { children: [
709
+ /* @__PURE__ */ jsx2(Select.Item, { value: "true", children: t("filters.radio.yes") }),
710
+ /* @__PURE__ */ jsx2(Select.Item, { value: "false", children: t("filters.radio.no") })
711
+ ] })
712
+ ]
713
+ }
714
+ )
715
+ }
716
+ ) : /* @__PURE__ */ jsx2(
717
+ Controller,
718
+ {
719
+ control: form.control,
720
+ name: `attributes.${index}.values`,
721
+ render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsx2(
722
+ Input,
723
+ {
724
+ ...rest,
725
+ value: typeof value === "string" ? value : value?.[0] ?? "",
726
+ onChange: (e) => onChange(e.target.value),
727
+ placeholder: t(
728
+ "products.create.attributes.valuePlaceholder"
729
+ )
730
+ }
731
+ )
732
+ }
733
+ ),
734
+ field.use_for_variants && /* @__PURE__ */ jsxs2(Fragment, { children: [
735
+ /* @__PURE__ */ jsx2("div", {}),
736
+ /* @__PURE__ */ jsx2(VariantAxisTip, { className: "border-none" })
737
+ ] })
738
+ ] }),
739
+ /* @__PURE__ */ jsx2(
740
+ IconButton,
741
+ {
742
+ type: "button",
743
+ size: "small",
744
+ variant: "transparent",
745
+ className: "text-ui-fg-muted",
746
+ onClick: () => remove(index),
747
+ children: /* @__PURE__ */ jsx2(XMarkMini, {})
748
+ }
749
+ )
750
+ ]
751
+ },
752
+ field.id
753
+ );
754
+ }) });
755
+ };
756
+ var RequiredAttributes = () => {
757
+ const { t } = useTranslation2();
758
+ const form = useTabbedForm();
759
+ const categoryId = form.watch("category_id");
760
+ const { product_attributes } = useProductAttributes(
761
+ {
762
+ category_id: categoryId,
763
+ is_required: true
764
+ },
765
+ { enabled: !!categoryId }
766
+ );
767
+ const attributes = form.watch("attributes") || [];
768
+ useEffect2(() => {
769
+ if (!product_attributes) return;
770
+ const currentAttributes = form.getValues("attributes") || [];
771
+ const requiredIds = new Set(product_attributes.map((a) => a.id));
772
+ const otherAttributes = currentAttributes.filter(
773
+ (a) => a.is_custom || !requiredIds.has(a.attribute_id ?? "")
774
+ );
775
+ const requiredAttributes = product_attributes.map((attr) => {
776
+ const existing = currentAttributes.find(
777
+ (a) => a.attribute_id === attr.id
778
+ );
779
+ if (existing) return existing;
780
+ return {
781
+ attribute_id: attr.id,
782
+ title: attr.name,
783
+ values: attr.type === import_types.AttributeType.MULTI_SELECT ? [] : "",
784
+ is_custom: false,
785
+ is_required: true,
786
+ use_for_variants: attr.is_variant_axis,
787
+ type: attr.type
788
+ };
789
+ });
790
+ form.setValue("attributes", [...otherAttributes, ...requiredAttributes]);
791
+ }, [product_attributes]);
792
+ if (!categoryId || !product_attributes?.length) return null;
793
+ const requiredEntries = attributes.map((attr, index) => ({ attr, index })).filter(({ attr }) => !attr.is_custom);
794
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
795
+ /* @__PURE__ */ jsx2("div", { className: "border-ui-border-base border-t border-dashed" }),
796
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-y-6", children: [
797
+ /* @__PURE__ */ jsxs2("div", { children: [
798
+ /* @__PURE__ */ jsx2(Text, { size: "small", weight: "plus", leading: "compact", children: t("products.create.attributes.requiredAttributes") }),
799
+ /* @__PURE__ */ jsx2(Text, { size: "small", className: "text-ui-fg-subtle", children: t("products.create.attributes.requiredAttributesHint") })
800
+ ] }),
801
+ requiredEntries.map(({ attr, index }) => {
802
+ const apiAttr = product_attributes.find(
803
+ (a) => a.id === attr.attribute_id
804
+ );
805
+ if (!apiAttr) return null;
806
+ return /* @__PURE__ */ jsx2(
807
+ RequiredAttributeField,
808
+ {
809
+ attribute: apiAttr,
810
+ index
811
+ },
812
+ apiAttr.id
813
+ );
814
+ })
815
+ ] })
816
+ ] });
817
+ };
818
+ var RadioSelectItem = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs2(
819
+ RadixSelect.Item,
820
+ {
821
+ ref,
822
+ className: clx(
823
+ "bg-ui-bg-component txt-compact-small grid cursor-pointer grid-cols-[15px_1fr] items-center gap-x-2 rounded-[4px] px-2 py-1.5 outline-none transition-colors",
824
+ "focus-visible:bg-ui-bg-component-hover",
825
+ "active:bg-ui-bg-component-pressed",
826
+ "data-[state=checked]:txt-compact-small-plus",
827
+ "disabled:text-ui-fg-disabled",
828
+ className
829
+ ),
830
+ ...props,
831
+ children: [
832
+ /* @__PURE__ */ jsx2("span", { className: "flex h-[15px] w-[15px] items-center justify-center", children: /* @__PURE__ */ jsx2(RadixSelect.ItemIndicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx2(CircleMiniFilledSolid, {}) }) }),
833
+ /* @__PURE__ */ jsx2(RadixSelect.ItemText, { className: "flex-1 truncate", children })
834
+ ]
835
+ }
836
+ ));
837
+ RadioSelectItem.displayName = "RadioSelectItem";
838
+ var RequiredAttributeField = ({
839
+ attribute,
840
+ index
841
+ }) => {
842
+ const { t } = useTranslation2();
843
+ const form = useTabbedForm();
844
+ return /* @__PURE__ */ jsx2(
845
+ Form.Field,
846
+ {
847
+ control: form.control,
848
+ name: `attributes.${index}.values`,
849
+ render: ({ field: { onChange, value, ref, ...field } }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
850
+ /* @__PURE__ */ jsx2(Form.Label, { children: attribute.name }),
851
+ /* @__PURE__ */ jsx2(Form.Control, { children: attribute.type === import_types.AttributeType.SINGLE_SELECT ? /* @__PURE__ */ jsxs2(
852
+ Select,
853
+ {
854
+ ...field,
855
+ value: typeof value === "string" ? value : value?.[0] ?? "",
856
+ onValueChange: onChange,
857
+ children: [
858
+ /* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
859
+ Select.Value,
860
+ {
861
+ placeholder: t(
862
+ "products.create.attributes.selectValuePlaceholder"
863
+ )
864
+ }
865
+ ) }),
866
+ /* @__PURE__ */ jsx2(Select.Content, { children: attribute.values?.map((v) => /* @__PURE__ */ jsx2(RadioSelectItem, { value: v.name, children: v.name }, v.id)) })
867
+ ]
868
+ }
869
+ ) : attribute.type === import_types.AttributeType.MULTI_SELECT ? /* @__PURE__ */ jsx2(
870
+ Combobox,
871
+ {
872
+ ...field,
873
+ ref,
874
+ value: Array.isArray(value) ? value : [],
875
+ onChange: (val) => onChange(val ?? []),
876
+ options: attribute.values?.map((v) => ({
877
+ value: v.name,
878
+ label: v.name
879
+ })) ?? [],
880
+ placeholder: t("products.create.attributes.selectValues")
881
+ }
882
+ ) : attribute.type === import_types.AttributeType.TEXT ? /* @__PURE__ */ jsx2(
883
+ Textarea,
884
+ {
885
+ ...field,
886
+ ref,
887
+ value: typeof value === "string" ? value : value?.[0] ?? "",
888
+ onChange: (e) => onChange(e.target.value),
889
+ placeholder: t(
890
+ "products.create.attributes.enterValuePlaceholder"
891
+ )
892
+ }
893
+ ) : attribute.type === import_types.AttributeType.TOGGLE ? /* @__PURE__ */ jsxs2(
894
+ Select,
895
+ {
896
+ ...field,
897
+ value: typeof value === "string" ? value : value?.[0] ?? "",
898
+ onValueChange: onChange,
899
+ children: [
900
+ /* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
901
+ Select.Value,
902
+ {
903
+ placeholder: t(
904
+ "products.create.attributes.selectValuePlaceholder"
905
+ )
906
+ }
907
+ ) }),
908
+ /* @__PURE__ */ jsxs2(Select.Content, { children: [
909
+ /* @__PURE__ */ jsx2(RadioSelectItem, { value: "true", children: t("filters.radio.yes") }),
910
+ /* @__PURE__ */ jsx2(RadioSelectItem, { value: "false", children: t("filters.radio.no") })
911
+ ] })
912
+ ]
913
+ }
914
+ ) : /* @__PURE__ */ jsx2(
915
+ Input,
916
+ {
917
+ ...field,
918
+ ref,
919
+ value: typeof value === "string" ? value : value?.[0] ?? "",
920
+ onChange: (e) => onChange(e.target.value),
921
+ placeholder: t(
922
+ "products.create.attributes.enterValuePlaceholder"
923
+ )
924
+ }
925
+ ) }),
926
+ /* @__PURE__ */ jsx2(Form.ErrorMessage, {}),
927
+ attribute.is_variant_axis && /* @__PURE__ */ jsx2(VariantAxisTip, {})
928
+ ] })
929
+ }
930
+ );
931
+ };
932
+ var VariantAxisTip = ({ className }) => {
933
+ const { t } = useTranslation2();
934
+ return /* @__PURE__ */ jsx2(
935
+ InlineTip,
936
+ {
937
+ label: t("products.create.attributes.tip"),
938
+ className,
939
+ children: t("products.create.attributes.variantAxisTip")
940
+ }
941
+ );
942
+ };
943
+ Root._tabMeta = defineTabMeta({
944
+ id: "attributes",
945
+ labelKey: "products.create.tabs.attributes",
946
+ validationFields: ["attributes"]
947
+ });
948
+ var ProductCreateAttributesForm = Root;
949
+
950
+ // src/pages/products/create/components/product-create-details-form/product-create-details-form.tsx
951
+ import { Heading as Heading3 } from "@medusajs/ui";
952
+ import { useTranslation as useTranslation6 } from "react-i18next";
953
+
954
+ // src/pages/products/create/components/product-create-details-form/components/product-create-details-general-section/product-create-general-section.tsx
955
+ import { Input as Input2, Textarea as Textarea2 } from "@medusajs/ui";
956
+ import { useTranslation as useTranslation3 } from "react-i18next";
957
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
958
+ var ProductCreateGeneralSection = () => {
959
+ const form = useTabbedForm();
960
+ const { t } = useTranslation3();
961
+ return /* @__PURE__ */ jsxs3("div", { id: "general", className: "flex flex-col gap-y-6", "data-testid": "product-create-general-section", children: [
962
+ /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-y-2", "data-testid": "product-create-general-section-fields", children: /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-3", "data-testid": "product-create-general-section-title-fields", children: [
963
+ /* @__PURE__ */ jsx3(
964
+ Form.Field,
965
+ {
966
+ control: form.control,
967
+ name: "title",
968
+ render: ({ field }) => {
969
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-title-item", children: [
970
+ /* @__PURE__ */ jsx3(Form.Label, { "data-testid": "product-create-general-section-title-label", children: t("products.fields.title.label") }),
971
+ /* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-title-control", children: /* @__PURE__ */ jsx3(Input2, { ...field, placeholder: t("products.fields.title.placeholder"), "data-testid": "product-create-general-section-title-input" }) }),
972
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
973
+ ] });
974
+ }
975
+ }
976
+ ),
977
+ /* @__PURE__ */ jsx3(
978
+ Form.Field,
979
+ {
980
+ control: form.control,
981
+ name: "subtitle",
982
+ render: ({ field }) => {
983
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-subtitle-item", children: [
984
+ /* @__PURE__ */ jsx3(Form.Label, { optional: true, "data-testid": "product-create-general-section-subtitle-label", children: t("products.fields.subtitle.label") }),
985
+ /* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-subtitle-control", children: /* @__PURE__ */ jsx3(Input2, { ...field, placeholder: t("products.fields.subtitle.placeholder"), "data-testid": "product-create-general-section-subtitle-input" }) })
986
+ ] });
987
+ }
988
+ }
989
+ ),
990
+ /* @__PURE__ */ jsx3(
991
+ Form.Field,
992
+ {
993
+ control: form.control,
994
+ name: "handle",
995
+ render: ({ field }) => {
996
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-handle-item", children: [
997
+ /* @__PURE__ */ jsx3(
998
+ Form.Label,
999
+ {
1000
+ tooltip: t("products.fields.handle.tooltip"),
1001
+ optional: true,
1002
+ "data-testid": "product-create-general-section-handle-label",
1003
+ children: t("fields.handle")
1004
+ }
1005
+ ),
1006
+ /* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-handle-control", children: /* @__PURE__ */ jsx3(HandleInput, { ...field, placeholder: t("products.fields.handle.placeholder"), "data-testid": "product-create-general-section-handle-input" }) })
1007
+ ] });
1008
+ }
1009
+ }
1010
+ )
1011
+ ] }) }),
1012
+ /* @__PURE__ */ jsx3(
1013
+ Form.Field,
1014
+ {
1015
+ control: form.control,
1016
+ name: "description",
1017
+ render: ({ field }) => {
1018
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-description-item", children: [
1019
+ /* @__PURE__ */ jsx3(Form.Label, { optional: true, "data-testid": "product-create-general-section-description-label", children: t("products.fields.description.label") }),
1020
+ /* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-description-control", children: /* @__PURE__ */ jsx3(Textarea2, { ...field, placeholder: t("products.fields.description.placeholder"), "data-testid": "product-create-general-section-description-input" }) })
1021
+ ] });
1022
+ }
1023
+ }
1024
+ )
1025
+ ] });
1026
+ };
1027
+
1028
+ // src/pages/products/create/components/product-create-details-form/components/product-create-details-media-section/product-create-details-media-section.tsx
1029
+ import {
1030
+ defaultDropAnimationSideEffects,
1031
+ DndContext,
1032
+ DragOverlay,
1033
+ KeyboardSensor,
1034
+ PointerSensor,
1035
+ useSensor,
1036
+ useSensors
1037
+ } from "@dnd-kit/core";
1038
+ import {
1039
+ arrayMove,
1040
+ SortableContext,
1041
+ sortableKeyboardCoordinates,
1042
+ useSortable
1043
+ } from "@dnd-kit/sortable";
1044
+ import { CSS } from "@dnd-kit/utilities";
1045
+ import {
1046
+ DotsSix,
1047
+ StackPerspective,
1048
+ ThumbnailBadge,
1049
+ Trash,
1050
+ XMark
1051
+ } from "@medusajs/icons";
1052
+ import { IconButton as IconButton2, Text as Text2 } from "@medusajs/ui";
1053
+ import { useState as useState2 } from "react";
1054
+ import { useFieldArray as useFieldArray2 } from "react-hook-form";
1055
+ import { useTranslation as useTranslation4 } from "react-i18next";
1056
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1057
+ var dropAnimationConfig = {
1058
+ sideEffects: defaultDropAnimationSideEffects({
1059
+ styles: {
1060
+ active: {
1061
+ opacity: "0.4"
1062
+ }
1063
+ }
1064
+ })
1065
+ };
1066
+ var ProductCreateMediaSection = () => {
1067
+ const form = useTabbedForm();
1068
+ const { fields, append, remove } = useFieldArray2({
1069
+ name: "media",
1070
+ control: form.control,
1071
+ keyName: "field_id"
1072
+ });
1073
+ const [activeId, setActiveId] = useState2(null);
1074
+ const sensors = useSensors(
1075
+ useSensor(PointerSensor),
1076
+ useSensor(KeyboardSensor, {
1077
+ coordinateGetter: sortableKeyboardCoordinates
1078
+ })
1079
+ );
1080
+ const handleDragStart = (event) => {
1081
+ setActiveId(event.active.id);
1082
+ };
1083
+ const handleDragEnd = (event) => {
1084
+ setActiveId(null);
1085
+ const { active, over } = event;
1086
+ if (active.id !== over?.id) {
1087
+ const oldIndex = fields.findIndex((item) => item.field_id === active.id);
1088
+ const newIndex = fields.findIndex((item) => item.field_id === over?.id);
1089
+ form.setValue("media", arrayMove(fields, oldIndex, newIndex), {
1090
+ shouldDirty: true,
1091
+ shouldTouch: true
1092
+ });
1093
+ }
1094
+ };
1095
+ const handleDragCancel = () => {
1096
+ setActiveId(null);
1097
+ };
1098
+ const getOnDelete = (index) => {
1099
+ return () => {
1100
+ remove(index);
1101
+ };
1102
+ };
1103
+ const getMakeThumbnail = (index) => {
1104
+ return () => {
1105
+ const newFields = fields.map((field, i) => {
1106
+ return {
1107
+ ...field,
1108
+ isThumbnail: i === index
1109
+ };
1110
+ });
1111
+ form.setValue("media", newFields, {
1112
+ shouldDirty: true,
1113
+ shouldTouch: true
1114
+ });
1115
+ };
1116
+ };
1117
+ const getItemHandlers = (index) => {
1118
+ return {
1119
+ onDelete: getOnDelete(index),
1120
+ onMakeThumbnail: getMakeThumbnail(index)
1121
+ };
1122
+ };
1123
+ return /* @__PURE__ */ jsxs4("div", { id: "media", className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section", children: [
1124
+ /* @__PURE__ */ jsx4(UploadMediaFormItem, { form, append, showHint: false }),
1125
+ /* @__PURE__ */ jsxs4(
1126
+ DndContext,
1127
+ {
1128
+ sensors,
1129
+ onDragEnd: handleDragEnd,
1130
+ onDragStart: handleDragStart,
1131
+ onDragCancel: handleDragCancel,
1132
+ children: [
1133
+ /* @__PURE__ */ jsx4(DragOverlay, { dropAnimation: dropAnimationConfig, children: activeId ? /* @__PURE__ */ jsx4(
1134
+ MediaGridItemOverlay,
1135
+ {
1136
+ field: fields.find((m) => m.field_id === activeId)
1137
+ }
1138
+ ) : null }),
1139
+ /* @__PURE__ */ jsx4("ul", { className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section-list", children: /* @__PURE__ */ jsx4(SortableContext, { items: fields.map((field) => field.field_id), children: fields.map((field, index) => {
1140
+ const { onDelete, onMakeThumbnail } = getItemHandlers(index);
1141
+ return /* @__PURE__ */ jsx4(
1142
+ MediaItem,
1143
+ {
1144
+ field,
1145
+ onDelete,
1146
+ onMakeThumbnail
1147
+ },
1148
+ field.field_id
1149
+ );
1150
+ }) }) })
1151
+ ]
1152
+ }
1153
+ )
1154
+ ] });
1155
+ };
1156
+ var MediaItem = ({ field, onDelete, onMakeThumbnail }) => {
1157
+ const { t } = useTranslation4();
1158
+ const {
1159
+ attributes,
1160
+ listeners,
1161
+ setNodeRef,
1162
+ setActivatorNodeRef,
1163
+ transform,
1164
+ transition,
1165
+ isDragging
1166
+ } = useSortable({ id: field.field_id });
1167
+ const style = {
1168
+ opacity: isDragging ? 0.4 : void 0,
1169
+ transform: CSS.Translate.toString(transform),
1170
+ transition
1171
+ };
1172
+ if (!field.file) {
1173
+ return null;
1174
+ }
1175
+ return /* @__PURE__ */ jsxs4(
1176
+ "li",
1177
+ {
1178
+ className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
1179
+ ref: setNodeRef,
1180
+ style,
1181
+ "data-testid": `product-create-media-section-item-${field.field_id}`,
1182
+ children: [
1183
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
1184
+ /* @__PURE__ */ jsx4(
1185
+ IconButton2,
1186
+ {
1187
+ variant: "transparent",
1188
+ type: "button",
1189
+ size: "small",
1190
+ ...attributes,
1191
+ ...listeners,
1192
+ ref: setActivatorNodeRef,
1193
+ className: "cursor-grab touch-none active:cursor-grabbing",
1194
+ children: /* @__PURE__ */ jsx4(DotsSix, { className: "text-ui-fg-muted" })
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-3", children: [
1198
+ /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx4(ThumbnailPreview, { url: field.url }) }),
1199
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
1200
+ /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: field.file.name }),
1201
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1202
+ field.isThumbnail && /* @__PURE__ */ jsx4(ThumbnailBadge, {}),
1203
+ /* @__PURE__ */ jsx4(
1204
+ Text2,
1205
+ {
1206
+ size: "xsmall",
1207
+ leading: "compact",
1208
+ className: "text-ui-fg-subtle",
1209
+ children: formatFileSize(field.file.size)
1210
+ }
1211
+ )
1212
+ ] })
1213
+ ] })
1214
+ ] })
1215
+ ] }),
1216
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1217
+ /* @__PURE__ */ jsx4(
1218
+ ActionMenu,
1219
+ {
1220
+ groups: [
1221
+ {
1222
+ actions: [
1223
+ {
1224
+ label: t("products.media.makeThumbnail"),
1225
+ icon: /* @__PURE__ */ jsx4(StackPerspective, {}),
1226
+ onClick: onMakeThumbnail
1227
+ }
1228
+ ]
1229
+ },
1230
+ {
1231
+ actions: [
1232
+ {
1233
+ icon: /* @__PURE__ */ jsx4(Trash, {}),
1234
+ label: t("actions.delete"),
1235
+ onClick: onDelete
1236
+ }
1237
+ ]
1238
+ }
1239
+ ]
1240
+ }
1241
+ ),
1242
+ /* @__PURE__ */ jsx4(
1243
+ IconButton2,
1244
+ {
1245
+ type: "button",
1246
+ size: "small",
1247
+ variant: "transparent",
1248
+ onClick: onDelete,
1249
+ children: /* @__PURE__ */ jsx4(XMark, {})
1250
+ }
1251
+ )
1252
+ ] })
1253
+ ]
1254
+ }
1255
+ );
1256
+ };
1257
+ var MediaGridItemOverlay = ({ field }) => {
1258
+ return /* @__PURE__ */ jsxs4("li", { className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2", children: [
1259
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
1260
+ /* @__PURE__ */ jsx4(
1261
+ IconButton2,
1262
+ {
1263
+ variant: "transparent",
1264
+ size: "small",
1265
+ className: "cursor-grab touch-none active:cursor-grabbing",
1266
+ children: /* @__PURE__ */ jsx4(DotsSix, { className: "text-ui-fg-muted" })
1267
+ }
1268
+ ),
1269
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-3", children: [
1270
+ /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx4(ThumbnailPreview, { url: field.url }) }),
1271
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
1272
+ /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: field.file?.name }),
1273
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1274
+ field.isThumbnail && /* @__PURE__ */ jsx4(ThumbnailBadge, {}),
1275
+ /* @__PURE__ */ jsx4(
1276
+ Text2,
1277
+ {
1278
+ size: "xsmall",
1279
+ leading: "compact",
1280
+ className: "text-ui-fg-subtle",
1281
+ children: formatFileSize(field.file?.size ?? 0)
1282
+ }
1283
+ )
1284
+ ] })
1285
+ ] })
1286
+ ] })
1287
+ ] }),
1288
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1289
+ /* @__PURE__ */ jsx4(ActionMenu, { groups: [] }),
1290
+ /* @__PURE__ */ jsx4(
1291
+ IconButton2,
1292
+ {
1293
+ type: "button",
1294
+ size: "small",
1295
+ variant: "transparent",
1296
+ onClick: () => {
1297
+ },
1298
+ children: /* @__PURE__ */ jsx4(XMark, {})
1299
+ }
1300
+ )
1301
+ ] })
1302
+ ] });
1303
+ };
1304
+ var ThumbnailPreview = ({ url }) => {
1305
+ if (!url) {
1306
+ return null;
1307
+ }
1308
+ return /* @__PURE__ */ jsx4("img", { src: url, alt: "", className: "size-full object-cover object-center" });
1309
+ };
1310
+ function formatFileSize(bytes, decimalPlaces = 2) {
1311
+ if (bytes === 0) {
1312
+ return "0 Bytes";
1313
+ }
1314
+ const k = 1024;
1315
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1316
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
1317
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPlaces)) + " " + sizes[i];
1318
+ }
1319
+
1320
+ // src/pages/products/create/components/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
1321
+ import {
1322
+ Alert,
1323
+ Checkbox as Checkbox2,
1324
+ clx as clx3,
1325
+ Heading as Heading2,
1326
+ Hint as Hint2,
1327
+ InlineTip as InlineTip2,
1328
+ Label as Label2,
1329
+ Text as Text3
1330
+ } from "@medusajs/ui";
1331
+ import { useFieldArray as useFieldArray3, useWatch } from "react-hook-form";
1332
+ import { useTranslation as useTranslation5 } from "react-i18next";
1333
+ import { useMemo as useMemo3 } from "react";
1334
+
1335
+ // src/components/common/sortable-list/sortable-list.tsx
1336
+ import {
1337
+ DndContext as DndContext2,
1338
+ DragOverlay as DragOverlay2,
1339
+ KeyboardSensor as KeyboardSensor2,
1340
+ PointerSensor as PointerSensor2,
1341
+ defaultDropAnimationSideEffects as defaultDropAnimationSideEffects2,
1342
+ useSensor as useSensor2,
1343
+ useSensors as useSensors2
1344
+ } from "@dnd-kit/core";
1345
+ import {
1346
+ SortableContext as SortableContext2,
1347
+ arrayMove as arrayMove2,
1348
+ sortableKeyboardCoordinates as sortableKeyboardCoordinates2,
1349
+ useSortable as useSortable2
1350
+ } from "@dnd-kit/sortable";
1351
+ import { CSS as CSS2 } from "@dnd-kit/utilities";
1352
+ import { DotsSix as DotsSix2 } from "@medusajs/icons";
1353
+ import { IconButton as IconButton3, clx as clx2 } from "@medusajs/ui";
1354
+ import {
1355
+ Fragment as Fragment2,
1356
+ createContext,
1357
+ useContext,
1358
+ useMemo as useMemo2,
1359
+ useState as useState3
1360
+ } from "react";
1361
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1362
+ var List = ({
1363
+ items,
1364
+ onChange,
1365
+ renderItem
1366
+ }) => {
1367
+ const [active, setActive] = useState3(null);
1368
+ const [activeItem, activeIndex] = useMemo2(() => {
1369
+ if (active === null) {
1370
+ return [null, null];
1371
+ }
1372
+ const index = items.findIndex(({ id }) => id === active.id);
1373
+ return [items[index], index];
1374
+ }, [active, items]);
1375
+ const sensors = useSensors2(
1376
+ useSensor2(PointerSensor2),
1377
+ useSensor2(KeyboardSensor2, {
1378
+ coordinateGetter: sortableKeyboardCoordinates2
1379
+ })
1380
+ );
1381
+ const handleDragStart = ({ active: active2 }) => {
1382
+ setActive(active2);
1383
+ };
1384
+ const handleDragEnd = ({ active: active2, over }) => {
1385
+ if (over && active2.id !== over.id) {
1386
+ const activeIndex2 = items.findIndex(({ id }) => id === active2.id);
1387
+ const overIndex = items.findIndex(({ id }) => id === over.id);
1388
+ onChange(arrayMove2(items, activeIndex2, overIndex));
1389
+ }
1390
+ setActive(null);
1391
+ };
1392
+ const handleDragCancel = () => {
1393
+ setActive(null);
1394
+ };
1395
+ return /* @__PURE__ */ jsxs5(
1396
+ DndContext2,
1397
+ {
1398
+ sensors,
1399
+ onDragStart: handleDragStart,
1400
+ onDragEnd: handleDragEnd,
1401
+ onDragCancel: handleDragCancel,
1402
+ children: [
1403
+ /* @__PURE__ */ jsx5(Overlay, { children: activeItem && activeIndex !== null ? renderItem(activeItem, activeIndex) : null }),
1404
+ /* @__PURE__ */ jsx5(SortableContext2, { items, children: /* @__PURE__ */ jsx5(
1405
+ "ul",
1406
+ {
1407
+ role: "application",
1408
+ className: "flex list-inside list-none list-image-none flex-col p-0",
1409
+ children: items.map((item, index) => /* @__PURE__ */ jsx5(Fragment2, { children: renderItem(item, index) }, item.id))
1410
+ }
1411
+ ) })
1412
+ ]
1413
+ }
1414
+ );
1415
+ };
1416
+ var dropAnimationConfig2 = {
1417
+ sideEffects: defaultDropAnimationSideEffects2({
1418
+ styles: {
1419
+ active: {
1420
+ opacity: "0.4"
1421
+ }
1422
+ }
1423
+ })
1424
+ };
1425
+ var Overlay = ({ children }) => {
1426
+ return /* @__PURE__ */ jsx5(
1427
+ DragOverlay2,
1428
+ {
1429
+ className: "shadow-elevation-card-hover overflow-hidden rounded-md [&>li]:border-b-0",
1430
+ dropAnimation: dropAnimationConfig2,
1431
+ children
1432
+ }
1433
+ );
1434
+ };
1435
+ var SortableItemContext = createContext(null);
1436
+ var useSortableItemContext = () => {
1437
+ const context = useContext(SortableItemContext);
1438
+ if (!context) {
1439
+ throw new Error(
1440
+ "useSortableItemContext must be used within a SortableItemContext"
1441
+ );
1442
+ }
1443
+ return context;
1444
+ };
1445
+ var Item = ({
1446
+ id,
1447
+ className,
1448
+ children
1449
+ }) => {
1450
+ const {
1451
+ attributes,
1452
+ isDragging,
1453
+ listeners,
1454
+ setNodeRef,
1455
+ setActivatorNodeRef,
1456
+ transform,
1457
+ transition
1458
+ } = useSortable2({ id });
1459
+ const context = useMemo2(
1460
+ () => ({
1461
+ attributes,
1462
+ listeners,
1463
+ ref: setActivatorNodeRef,
1464
+ isDragging
1465
+ }),
1466
+ [attributes, listeners, setActivatorNodeRef, isDragging]
1467
+ );
1468
+ const style = {
1469
+ opacity: isDragging ? 0.4 : void 0,
1470
+ transform: CSS2.Translate.toString(transform),
1471
+ transition
1472
+ };
1473
+ return /* @__PURE__ */ jsx5(SortableItemContext.Provider, { value: context, children: /* @__PURE__ */ jsx5(
1474
+ "li",
1475
+ {
1476
+ className: clx2("transition-fg flex flex-1 list-none", className),
1477
+ ref: setNodeRef,
1478
+ style,
1479
+ children
1480
+ }
1481
+ ) });
1482
+ };
1483
+ var DragHandle = () => {
1484
+ const { attributes, listeners, ref } = useSortableItemContext();
1485
+ return /* @__PURE__ */ jsx5(
1486
+ IconButton3,
1487
+ {
1488
+ variant: "transparent",
1489
+ size: "small",
1490
+ ...attributes,
1491
+ ...listeners,
1492
+ ref,
1493
+ className: "cursor-grab touch-none active:cursor-grabbing",
1494
+ children: /* @__PURE__ */ jsx5(DotsSix2, { className: "text-ui-fg-muted" })
1495
+ }
1496
+ );
1497
+ };
1498
+ var SortableList = Object.assign(List, {
1499
+ Item,
1500
+ DragHandle
1501
+ });
1502
+
1503
+ // src/pages/products/create/components/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
1504
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1505
+ var ProductCreateVariantsSection = () => {
1506
+ const form = useTabbedForm();
1507
+ const { t } = useTranslation5();
1508
+ const variants = useFieldArray3({
1509
+ control: form.control,
1510
+ name: "variants"
1511
+ });
1512
+ const watchedAttributes = useWatch({
1513
+ control: form.control,
1514
+ name: "attributes",
1515
+ defaultValue: []
1516
+ });
1517
+ const watchedVariants = useWatch({
1518
+ control: form.control,
1519
+ name: "variants",
1520
+ defaultValue: []
1521
+ });
1522
+ const variantAxes = useMemo3(() => {
1523
+ return (watchedAttributes ?? []).filter((attr) => attr.use_for_variants).map((attr) => ({
1524
+ title: attr.title,
1525
+ values: Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : []
1526
+ })).filter((axis) => axis.title && axis.values.length > 0);
1527
+ }, [watchedAttributes]);
1528
+ const hasVariantAxes = variantAxes.length > 0;
1529
+ const showInvalidVariantsMessage = form.formState.errors.variants?.root?.message === "invalid_length";
1530
+ const handleRankChange = (items) => {
1531
+ const update = items.map((item, index) => {
1532
+ const variant = watchedVariants.find((v) => v.title === item.title);
1533
+ return {
1534
+ id: item.id,
1535
+ ...variant || item,
1536
+ variant_rank: index
1537
+ };
1538
+ });
1539
+ variants.replace(update);
1540
+ };
1541
+ const getCheckboxState = (variants2) => {
1542
+ if (variants2.every((variant) => variant.should_create)) {
1543
+ return true;
1544
+ }
1545
+ if (variants2.some((variant) => variant.should_create)) {
1546
+ return "indeterminate";
1547
+ }
1548
+ return false;
1549
+ };
1550
+ const onCheckboxChange = (value) => {
1551
+ switch (value) {
1552
+ case true: {
1553
+ const update = watchedVariants.map((variant) => ({
1554
+ ...variant,
1555
+ should_create: true
1556
+ }));
1557
+ form.setValue("variants", update);
1558
+ break;
1559
+ }
1560
+ case false: {
1561
+ const update = watchedVariants.map((variant) => ({
1562
+ ...variant,
1563
+ should_create: false
1564
+ }));
1565
+ form.setValue("variants", decorateVariantsWithDefaultValues(update));
1566
+ break;
1567
+ }
1568
+ case "indeterminate":
1569
+ break;
1570
+ }
1571
+ };
1572
+ if (!hasVariantAxes) {
1573
+ return null;
1574
+ }
1575
+ return /* @__PURE__ */ jsxs6(
1576
+ "div",
1577
+ {
1578
+ id: "variants",
1579
+ className: "flex flex-col gap-y-8",
1580
+ "data-testid": "product-create-variants-section",
1581
+ children: [
1582
+ /* @__PURE__ */ jsx6("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx6(Heading2, { level: "h2", children: t("products.create.variants.header") }) }),
1583
+ /* @__PURE__ */ jsx6("div", { className: "grid grid-cols-1 gap-x-4 gap-y-8", children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-6", children: [
1584
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
1585
+ /* @__PURE__ */ jsx6(Label2, { weight: "plus", children: t("products.create.variants.productVariants.label") }),
1586
+ /* @__PURE__ */ jsx6(Hint2, { children: t("products.create.variants.productVariants.hint") })
1587
+ ] }),
1588
+ showInvalidVariantsMessage && /* @__PURE__ */ jsx6(Alert, { dismissible: true, variant: "error", children: t("products.create.errors.variants") }),
1589
+ variants.fields.length > 0 ? /* @__PURE__ */ jsxs6("div", { className: "overflow-hidden rounded-xl border", children: [
1590
+ /* @__PURE__ */ jsxs6(
1591
+ "div",
1592
+ {
1593
+ className: "bg-ui-bg-component text-ui-fg-subtle grid items-center gap-3 border-b px-6 py-2.5",
1594
+ style: {
1595
+ gridTemplateColumns: `20px 28px repeat(${variantAxes.length}, 1fr)`
1596
+ },
1597
+ children: [
1598
+ /* @__PURE__ */ jsx6("div", { children: /* @__PURE__ */ jsx6(
1599
+ Checkbox2,
1600
+ {
1601
+ className: "relative",
1602
+ checked: getCheckboxState(watchedVariants),
1603
+ onCheckedChange: onCheckboxChange
1604
+ }
1605
+ ) }),
1606
+ /* @__PURE__ */ jsx6("div", {}),
1607
+ variantAxes.map((axis, index) => /* @__PURE__ */ jsx6("div", { children: /* @__PURE__ */ jsx6(Text3, { size: "small", leading: "compact", weight: "plus", children: axis.title }) }, index))
1608
+ ]
1609
+ }
1610
+ ),
1611
+ /* @__PURE__ */ jsx6(
1612
+ SortableList,
1613
+ {
1614
+ items: variants.fields,
1615
+ onChange: handleRankChange,
1616
+ renderItem: (item, index) => {
1617
+ return /* @__PURE__ */ jsx6(
1618
+ SortableList.Item,
1619
+ {
1620
+ id: item.id,
1621
+ className: clx3("bg-ui-bg-base border-b", {
1622
+ "border-b-0": index === variants.fields.length - 1
1623
+ }),
1624
+ children: /* @__PURE__ */ jsxs6(
1625
+ "div",
1626
+ {
1627
+ className: "text-ui-fg-subtle grid w-full items-center gap-3 px-6 py-2.5",
1628
+ style: {
1629
+ gridTemplateColumns: `20px 28px repeat(${variantAxes.length}, 1fr)`
1630
+ },
1631
+ children: [
1632
+ /* @__PURE__ */ jsx6(
1633
+ Form.Field,
1634
+ {
1635
+ control: form.control,
1636
+ name: `variants.${index}.should_create`,
1637
+ render: ({
1638
+ field: { value, onChange, ...field }
1639
+ }) => /* @__PURE__ */ jsx6(Form.Item, { children: /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(
1640
+ Checkbox2,
1641
+ {
1642
+ className: "relative",
1643
+ ...field,
1644
+ checked: value,
1645
+ onCheckedChange: onChange
1646
+ }
1647
+ ) }) })
1648
+ }
1649
+ ),
1650
+ /* @__PURE__ */ jsx6(SortableList.DragHandle, {}),
1651
+ variantAxes.map((axis, i) => /* @__PURE__ */ jsx6(Text3, { size: "small", leading: "compact", children: item.options?.[axis.title] ?? "-" }, i))
1652
+ ]
1653
+ }
1654
+ )
1655
+ }
1656
+ );
1657
+ }
1658
+ }
1659
+ )
1660
+ ] }) : /* @__PURE__ */ jsx6(Alert, { children: t("products.create.variants.productVariants.alert") }),
1661
+ variants.fields.length > 0 && /* @__PURE__ */ jsx6(InlineTip2, { label: t("general.tip"), children: t("products.create.variants.productVariants.tip") })
1662
+ ] }) })
1663
+ ]
1664
+ }
1665
+ );
1666
+ };
1667
+
1668
+ // src/pages/products/create/components/product-create-details-form/product-create-details-form.tsx
1669
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1670
+ var Root2 = () => {
1671
+ return /* @__PURE__ */ jsx7(
1672
+ "div",
1673
+ {
1674
+ className: "flex flex-col items-center p-16",
1675
+ "data-testid": "product-create-details-form",
1676
+ children: /* @__PURE__ */ jsxs7(
1677
+ "div",
1678
+ {
1679
+ className: "flex w-full max-w-[720px] flex-col gap-y-8",
1680
+ "data-testid": "product-create-details-form-content",
1681
+ children: [
1682
+ /* @__PURE__ */ jsx7(Header, {}),
1683
+ /* @__PURE__ */ jsxs7(
1684
+ "div",
1685
+ {
1686
+ className: "flex flex-col gap-y-6",
1687
+ "data-testid": "product-create-details-form-sections",
1688
+ children: [
1689
+ /* @__PURE__ */ jsx7(ProductCreateGeneralSection, {}),
1690
+ /* @__PURE__ */ jsx7(ProductCreateMediaSection, {})
1691
+ ]
1692
+ }
1693
+ ),
1694
+ /* @__PURE__ */ jsx7(ProductCreateVariantsSection, {})
1695
+ ]
1696
+ }
1697
+ )
1698
+ }
1699
+ );
1700
+ };
1701
+ Root2._tabMeta = defineTabMeta({
1702
+ id: "details",
1703
+ labelKey: "products.create.tabs.details",
1704
+ validationFields: ["title", "handle", "description", "media"]
1705
+ });
1706
+ var ProductCreateDetailsForm = Root2;
1707
+ var Header = () => {
1708
+ const { t } = useTranslation6();
1709
+ return /* @__PURE__ */ jsx7(
1710
+ "div",
1711
+ {
1712
+ className: "flex flex-col",
1713
+ "data-testid": "product-create-details-form-header",
1714
+ children: /* @__PURE__ */ jsx7(Heading3, { "data-testid": "product-create-details-form-heading", children: t("products.create.header") })
1715
+ }
1716
+ );
1717
+ };
1718
+
1719
+ // src/pages/products/create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
1720
+ import { Heading as Heading4 } from "@medusajs/ui";
1721
+ import { useTranslation as useTranslation7 } from "react-i18next";
1722
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1723
+ var ProductCreateOrganizationSection = () => {
1724
+ const form = useTabbedForm();
1725
+ const { t } = useTranslation7();
1726
+ const collections = useComboboxData({
1727
+ queryKey: ["product_collections"],
1728
+ queryFn: (params) => sdk.vendor.collections.query(params),
1729
+ getOptions: (data) => data.collections.map((collection) => ({
1730
+ label: collection.title,
1731
+ value: collection.id
1732
+ }))
1733
+ });
1734
+ const types = useComboboxData({
1735
+ queryKey: ["product_types"],
1736
+ queryFn: (params) => sdk.vendor.productTypes.query(params),
1737
+ getOptions: (data) => data.product_types.map((type) => ({
1738
+ label: type.value,
1739
+ value: type.id
1740
+ }))
1741
+ });
1742
+ const tags = useComboboxData({
1743
+ queryKey: ["product_tags"],
1744
+ queryFn: (params) => sdk.vendor.productTags.query(params),
1745
+ getOptions: (data) => data.product_tags.map((tag) => ({
1746
+ label: tag.value,
1747
+ value: tag.id
1748
+ }))
1749
+ });
1750
+ return /* @__PURE__ */ jsxs8("div", { id: "organize", className: "flex flex-col gap-y-8", "data-testid": "product-create-organize-section", children: [
1751
+ /* @__PURE__ */ jsx8(Heading4, { "data-testid": "product-create-organize-section-heading", children: t("products.organization.header") }),
1752
+ /* @__PURE__ */ jsx8(
1753
+ SwitchBox,
1754
+ {
1755
+ control: form.control,
1756
+ name: "discountable",
1757
+ label: t("products.fields.discountable.label"),
1758
+ description: t("products.fields.discountable.hint"),
1759
+ optional: true
1760
+ }
1761
+ ),
1762
+ /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-category-collection", children: [
1763
+ /* @__PURE__ */ jsx8(
1764
+ Form.Field,
1765
+ {
1766
+ control: form.control,
1767
+ name: "category_id",
1768
+ render: ({ field }) => {
1769
+ return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-category-item", children: [
1770
+ /* @__PURE__ */ jsx8(
1771
+ Form.Label,
1772
+ {
1773
+ tooltip: t("products.fields.primaryCategory.tooltip"),
1774
+ "data-testid": "product-create-organize-section-category-label",
1775
+ children: t("fields.category")
1776
+ }
1777
+ ),
1778
+ /* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-category-control", children: /* @__PURE__ */ jsx8(SingleCategoryCombobox, { ...field }) }),
1779
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
1780
+ ] });
1781
+ }
1782
+ }
1783
+ ),
1784
+ /* @__PURE__ */ jsx8(
1785
+ Form.Field,
1786
+ {
1787
+ control: form.control,
1788
+ name: "collection_id",
1789
+ render: ({ field }) => {
1790
+ return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-collection-item", children: [
1791
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-collection-label", children: t("products.fields.collection.label") }),
1792
+ /* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-collection-control", children: /* @__PURE__ */ jsx8(
1793
+ Combobox,
1794
+ {
1795
+ ...field,
1796
+ options: collections.options,
1797
+ searchValue: collections.searchValue,
1798
+ onSearchValueChange: collections.onSearchValueChange,
1799
+ fetchNextPage: collections.fetchNextPage
1800
+ }
1801
+ ) }),
1802
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
1803
+ ] });
1804
+ }
1805
+ }
1806
+ )
1807
+ ] }),
1808
+ /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-type-tags", children: [
1809
+ /* @__PURE__ */ jsx8(
1810
+ Form.Field,
1811
+ {
1812
+ control: form.control,
1813
+ name: "type_id",
1814
+ render: ({ field }) => {
1815
+ return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-type-item", children: [
1816
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-type-label", children: t("products.fields.type.label") }),
1817
+ /* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-type-control", children: /* @__PURE__ */ jsx8(
1818
+ Combobox,
1819
+ {
1820
+ ...field,
1821
+ options: types.options,
1822
+ searchValue: types.searchValue,
1823
+ onSearchValueChange: types.onSearchValueChange,
1824
+ fetchNextPage: types.fetchNextPage
1825
+ }
1826
+ ) }),
1827
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
1828
+ ] });
1829
+ }
1830
+ }
1831
+ ),
1832
+ /* @__PURE__ */ jsx8(
1833
+ Form.Field,
1834
+ {
1835
+ control: form.control,
1836
+ name: "tags",
1837
+ render: ({ field }) => {
1838
+ return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-tags-item", children: [
1839
+ /* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-tags-label", children: t("products.fields.tags.label") }),
1840
+ /* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-tags-control", children: /* @__PURE__ */ jsx8(
1841
+ Combobox,
1842
+ {
1843
+ ...field,
1844
+ options: tags.options,
1845
+ searchValue: tags.searchValue,
1846
+ onSearchValueChange: tags.onSearchValueChange,
1847
+ fetchNextPage: tags.fetchNextPage
1848
+ }
1849
+ ) }),
1850
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
1851
+ ] });
1852
+ }
1853
+ }
1854
+ )
1855
+ ] })
1856
+ ] });
1857
+ };
1858
+
1859
+ // src/pages/products/create/components/product-create-organize-form/product-create-organize-form.tsx
1860
+ import { jsx as jsx9 } from "react/jsx-runtime";
1861
+ var Root3 = () => {
1862
+ return /* @__PURE__ */ jsx9(
1863
+ "div",
1864
+ {
1865
+ className: "flex flex-col items-center p-16",
1866
+ "data-testid": "product-create-organize-form",
1867
+ children: /* @__PURE__ */ jsx9(
1868
+ "div",
1869
+ {
1870
+ className: "flex w-full max-w-[720px] flex-col gap-y-8",
1871
+ "data-testid": "product-create-organize-form-content",
1872
+ children: /* @__PURE__ */ jsx9(ProductCreateOrganizationSection, {})
1873
+ }
1874
+ )
1875
+ }
1876
+ );
1877
+ };
1878
+ Root3._tabMeta = defineTabMeta({
1879
+ id: "organize",
1880
+ labelKey: "products.create.tabs.organize",
1881
+ validationFields: [
1882
+ "type_id",
1883
+ "collection_id",
1884
+ "category_id",
1885
+ "tags",
1886
+ "origin_country",
1887
+ "material",
1888
+ "width",
1889
+ "length",
1890
+ "height",
1891
+ "weight",
1892
+ "mid_code",
1893
+ "hs_code"
1894
+ ]
1895
+ });
1896
+ var ProductCreateOrganizeForm = Root3;
1897
+
1898
+ // src/pages/products/create/components/product-create-variants-form/product-create-variants-form.tsx
1899
+ import { useMemo as useMemo4 } from "react";
1900
+ import { useWatch as useWatch2 } from "react-hook-form";
1901
+ import { useTranslation as useTranslation8 } from "react-i18next";
1902
+ import { jsx as jsx10 } from "react/jsx-runtime";
1903
+ var Root4 = () => {
1904
+ const form = useTabbedForm();
1905
+ const { setCloseOnEscape } = useRouteModal();
1906
+ const variants = useWatch2({
1907
+ control: form.control,
1908
+ name: "variants",
1909
+ defaultValue: []
1910
+ });
1911
+ const watchedAttributes = useWatch2({
1912
+ control: form.control,
1913
+ name: "attributes",
1914
+ defaultValue: []
1915
+ });
1916
+ const variantAxes = useMemo4(() => {
1917
+ return (watchedAttributes ?? []).filter((attr) => attr.use_for_variants && attr.title).map((attr) => ({
1918
+ title: attr.title
1919
+ }));
1920
+ }, [watchedAttributes]);
1921
+ const columns = useColumns2({ variantAxes });
1922
+ const variantData = useMemo4(() => {
1923
+ const ret = [];
1924
+ variants.forEach((v, i) => {
1925
+ if (v.should_create) {
1926
+ ret.push({ ...v, originalIndex: i });
1927
+ }
1928
+ });
1929
+ return ret;
1930
+ }, [variants]);
1931
+ return /* @__PURE__ */ jsx10(
1932
+ "div",
1933
+ {
1934
+ className: "flex size-full flex-col divide-y overflow-hidden",
1935
+ "data-testid": "product-create-variants-form",
1936
+ children: /* @__PURE__ */ jsx10("div", { "data-testid": "product-create-variants-form-datagrid", children: /* @__PURE__ */ jsx10(
1937
+ DataGrid,
1938
+ {
1939
+ columns,
1940
+ data: variantData,
1941
+ state: form,
1942
+ onEditingChange: (editing) => setCloseOnEscape(!editing)
1943
+ }
1944
+ ) })
1945
+ }
1946
+ );
1947
+ };
1948
+ Root4._tabMeta = defineTabMeta({
1949
+ id: "variants",
1950
+ labelKey: "products.create.tabs.variants",
1951
+ validationFields: ["variants"]
1952
+ });
1953
+ var ProductCreateVariantsForm = Root4;
1954
+ var columnHelper2 = createDataGridHelper();
1955
+ var useColumns2 = ({
1956
+ variantAxes
1957
+ }) => {
1958
+ const { t } = useTranslation8();
1959
+ return useMemo4(
1960
+ () => [
1961
+ columnHelper2.column({
1962
+ id: "attributes",
1963
+ header: () => /* @__PURE__ */ jsx10("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx10("span", { className: "truncate", children: variantAxes.map((a) => a.title).join(" / ") }) }),
1964
+ cell: (context) => {
1965
+ return /* @__PURE__ */ jsx10(DataGrid.ReadonlyCell, { context, children: variantAxes.map((a) => context.row.original.options?.[a.title]).join(" / ") });
1966
+ },
1967
+ disableHiding: true
1968
+ }),
1969
+ columnHelper2.column({
1970
+ id: "title",
1971
+ name: t("fields.title"),
1972
+ header: t("fields.title"),
1973
+ field: (context) => `variants.${context.row.original.originalIndex}.title`,
1974
+ type: "text",
1975
+ cell: (context) => {
1976
+ return /* @__PURE__ */ jsx10(DataGrid.TextCell, { context });
1977
+ }
1978
+ }),
1979
+ columnHelper2.column({
1980
+ id: "sku",
1981
+ name: t("fields.sku"),
1982
+ header: t("fields.sku"),
1983
+ field: (context) => `variants.${context.row.original.originalIndex}.sku`,
1984
+ type: "text",
1985
+ cell: (context) => {
1986
+ return /* @__PURE__ */ jsx10(DataGrid.TextCell, { context });
1987
+ }
1988
+ })
1989
+ ],
1990
+ [variantAxes, t]
1991
+ );
1992
+ };
1993
+
1994
+ // src/pages/products/create/components/product-create-form/product-create-form.tsx
1995
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1996
+ var ProductCreateForm = ({
1997
+ children,
1998
+ schema,
1999
+ defaultValues: extraDefaults
2000
+ }) => {
2001
+ const { t } = useTranslation9();
2002
+ const { handleSuccess } = useRouteModal();
2003
+ const form = useForm({
2004
+ defaultValues: {
2005
+ ...PRODUCT_CREATE_FORM_DEFAULTS,
2006
+ ...extraDefaults
2007
+ },
2008
+ resolver: zodResolver(schema ?? ProductCreateSchema)
2009
+ });
2010
+ const { mutateAsync, isPending } = useCreateProduct();
2011
+ const { feature_flags } = useFeatureFlags();
2012
+ const productRequestEnabled = !!feature_flags?.[import_types6.MercurFeatureFlags.PRODUCT_REQUEST];
2013
+ const watchedAttributes = useWatch3({
2014
+ control: form.control,
2015
+ name: "attributes"
2016
+ });
2017
+ useEffect3(() => {
2018
+ const currentVariants = form.getValues("variants") ?? [];
2019
+ const newVariants = generateVariantsFromAttributes(
2020
+ watchedAttributes ?? [],
2021
+ currentVariants
2022
+ );
2023
+ if (JSON.stringify(newVariants.map((v) => v.options)) !== JSON.stringify(currentVariants.map((v) => v.options))) {
2024
+ form.setValue("variants", newVariants);
2025
+ }
2026
+ }, [watchedAttributes]);
2027
+ const submitProduct = async (values, isDraftSubmission) => {
2028
+ const media = values.media || [];
2029
+ const payload = { ...values, media: void 0 };
2030
+ let uploadedMedia = [];
2031
+ try {
2032
+ const filesToUpload = media.map((m, i) => ({ file: m.file, isThumbnail: m.isThumbnail, index: i })).filter((m) => !!m.file);
2033
+ if (filesToUpload.length) {
2034
+ const result = await uploadFilesQuery(
2035
+ filesToUpload.map(({ file }) => ({ file }))
2036
+ );
2037
+ const uploadedFiles = result?.files ?? [];
2038
+ uploadedMedia = uploadedFiles.map((file, i) => ({
2039
+ ...file,
2040
+ isThumbnail: filesToUpload[i].isThumbnail
2041
+ }));
2042
+ }
2043
+ } catch (error) {
2044
+ if (error instanceof Error) {
2045
+ toast.error(error.message);
2046
+ }
2047
+ }
2048
+ const submittedStatus = isDraftSubmission ? "draft" : productRequestEnabled ? "proposed" : "published";
2049
+ await mutateAsync(
2050
+ normalizeProductFormValues({
2051
+ ...payload,
2052
+ media: uploadedMedia,
2053
+ status: submittedStatus
2054
+ }),
2055
+ {
2056
+ onSuccess: (data) => {
2057
+ if (submittedStatus === "proposed") {
2058
+ toast.success(t("products.create.requestSuccessToast"));
2059
+ } else {
2060
+ toast.success(
2061
+ t("products.create.successToast", {
2062
+ title: data.product.title
2063
+ })
2064
+ );
2065
+ }
2066
+ handleSuccess(`../${data.product.id}`);
2067
+ },
2068
+ onError: (error) => {
2069
+ toast.error(error.message);
2070
+ }
2071
+ }
2072
+ );
2073
+ };
2074
+ const handleSubmit = form.handleSubmit(async (values) => {
2075
+ await submitProduct(values, false);
2076
+ });
2077
+ const handleSaveAsDraft = async () => {
2078
+ const titleValid = await form.trigger("title");
2079
+ if (!titleValid) {
2080
+ return;
2081
+ }
2082
+ await submitProduct(form.getValues(), true);
2083
+ };
2084
+ const defaultTabs = useMemo5(
2085
+ () => [
2086
+ /* @__PURE__ */ jsx11(ProductCreateDetailsForm, {}, "details"),
2087
+ /* @__PURE__ */ jsx11(ProductCreateOrganizeForm, {}, "organize"),
2088
+ /* @__PURE__ */ jsx11(ProductCreateAttributesForm, {}, "attributes"),
2089
+ /* @__PURE__ */ jsx11(ProductCreateVariantsForm, {}, "variants")
2090
+ ],
2091
+ []
2092
+ );
2093
+ const hasCustomChildren = Children.count(children) > 0;
2094
+ return /* @__PURE__ */ jsx11(
2095
+ TabbedForm,
2096
+ {
2097
+ form,
2098
+ onSubmit: handleSubmit,
2099
+ isLoading: isPending,
2100
+ footer: ({ isLastTab, onNext, isLoading }) => /* @__PURE__ */ jsxs9(
2101
+ "div",
2102
+ {
2103
+ className: "flex items-center justify-end gap-x-2",
2104
+ "data-testid": "product-create-form-footer-actions",
2105
+ children: [
2106
+ /* @__PURE__ */ jsx11(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx11(
2107
+ Button3,
2108
+ {
2109
+ variant: "secondary",
2110
+ size: "small",
2111
+ "data-testid": "product-create-form-cancel-button",
2112
+ children: t("actions.cancel")
2113
+ }
2114
+ ) }),
2115
+ /* @__PURE__ */ jsx11(
2116
+ Button3,
2117
+ {
2118
+ variant: "secondary",
2119
+ size: "small",
2120
+ type: "button",
2121
+ onClick: handleSaveAsDraft,
2122
+ isLoading,
2123
+ className: "whitespace-nowrap",
2124
+ "data-testid": "product-create-form-save-draft-button",
2125
+ children: t("actions.saveAsDraft")
2126
+ }
2127
+ ),
2128
+ isLastTab ? /* @__PURE__ */ jsx11(
2129
+ Button3,
2130
+ {
2131
+ "data-name": "publish-button",
2132
+ type: "submit",
2133
+ variant: "primary",
2134
+ size: "small",
2135
+ isLoading,
2136
+ "data-testid": "product-create-form-publish-button",
2137
+ children: t("actions.publish")
2138
+ },
2139
+ "submit-button"
2140
+ ) : /* @__PURE__ */ jsx11(
2141
+ Button3,
2142
+ {
2143
+ type: "button",
2144
+ variant: "primary",
2145
+ size: "small",
2146
+ onClick: () => onNext(),
2147
+ "data-testid": "product-create-form-continue-button",
2148
+ children: t("actions.continue")
2149
+ },
2150
+ "next-button"
2151
+ )
2152
+ ]
2153
+ }
2154
+ ),
2155
+ children: hasCustomChildren ? children : defaultTabs
2156
+ }
2157
+ );
2158
+ };
2159
+
2160
+ // src/pages/products/create/product-create.tsx
2161
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2162
+ var Root5 = ({ children }) => {
2163
+ const { t } = useTranslation10();
2164
+ return /* @__PURE__ */ jsxs10(RouteFocusModal, { children: [
2165
+ /* @__PURE__ */ jsx12(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx12("span", { className: "sr-only", children: t("products.create.title") }) }),
2166
+ /* @__PURE__ */ jsx12(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx12("span", { className: "sr-only", children: t("products.create.description") }) }),
2167
+ Children2.count(children) > 0 ? children : /* @__PURE__ */ jsx12(ProductCreateForm, {})
2168
+ ] });
2169
+ };
2170
+ var ProductCreate = Root5;
2171
+ var ProductCreatePage = Object.assign(Root5, {
2172
+ Form: ProductCreateForm,
2173
+ DetailsTab: ProductCreateDetailsForm,
2174
+ OrganizeTab: ProductCreateOrganizeForm,
2175
+ AttributesTab: ProductCreateAttributesForm,
2176
+ VariantsTab: ProductCreateVariantsForm,
2177
+ Tab: TabbedForm.Tab
2178
+ });
2179
+
2180
+ export {
2181
+ ProductCreate,
2182
+ ProductCreatePage
2183
+ };