@mercurjs/admin 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 (338) hide show
  1. package/dist/[id]-BAPEFPAO.js +505 -0
  2. package/dist/{add-campaign-promotions-6Z2STQT4.js → add-campaign-promotions-KOGSYV2W.js} +14 -16
  3. package/dist/{adjust-inventory-NVBPZYOF.js → adjust-inventory-3IQ657W2.js} +15 -15
  4. package/dist/{api-key-management-create-THDCXGWK.js → api-key-management-create-UD5V7TOU.js} +3 -3
  5. package/dist/{api-key-management-detail-IRYR6J2I.js → api-key-management-detail-NBNHERF6.js} +27 -27
  6. package/dist/{api-key-management-edit-LTVNXP6T.js → api-key-management-edit-4TLKJSAE.js} +3 -3
  7. package/dist/{api-key-management-list-4WCDP4B3.js → api-key-management-list-SZUSD6UI.js} +11 -13
  8. package/dist/{api-key-management-sales-channels-NVFG2ESH.js → api-key-management-sales-channels-TK6XEGF3.js} +15 -15
  9. package/dist/attribute-create-IKTP5XRS.js +583 -0
  10. package/dist/attribute-create-possible-value-EXVHC272.js +476 -0
  11. package/dist/{attribute-detail-R26GDX7Q.js → attribute-detail-V4QI34FV.js} +78 -69
  12. package/dist/attribute-edit-LUY66TG3.js +183 -0
  13. package/dist/attribute-edit-possible-value-IOS3625C.js +164 -0
  14. package/dist/{attribute-edit-ranking-CEBR5LJ7.js → attribute-edit-ranking-7AAAYEC7.js} +66 -61
  15. package/dist/{attribute-list-XR7OSL2H.js → attribute-list-EMPHZ32M.js} +26 -29
  16. package/dist/{campaign-create-AZTR5UZP.js → campaign-create-VFFIIRE4.js} +5 -5
  17. package/dist/{campaign-detail-TCPO6DTI.js → campaign-detail-QY3AALUR.js} +29 -31
  18. package/dist/{campaign-list-DCLVAFEM.js → campaign-list-NQGNOFVZ.js} +10 -12
  19. package/dist/{categories-metadata-YVUNHMQT.js → categories-metadata-Z5JAWPAK.js} +19 -19
  20. package/dist/{category-create-DG3Z5RYE.js → category-create-GMCJABRW.js} +4 -4
  21. package/dist/{category-detail-K2UNFPRV.js → category-detail-IP5EPIUR.js} +32 -32
  22. package/dist/{category-edit-IXU6E3YT.js → category-edit-GLE4NTFG.js} +5 -5
  23. package/dist/{category-list-2MG37UXJ.js → category-list-SNVOQ64L.js} +11 -13
  24. package/dist/{category-organize-CCX2INRS.js → category-organize-UY4M4N7S.js} +2 -2
  25. package/dist/{category-products-LKT7564A.js → category-products-HWXJR7KR.js} +32 -32
  26. package/dist/{chunk-FSPZYOY6.js → chunk-2OF7GB7J.js} +4 -4
  27. package/dist/{chunk-W576GZBG.js → chunk-3AO6X4CE.js} +9 -9
  28. package/dist/{chunk-MANWKYT3.js → chunk-3HY4I76Q.js} +139 -204
  29. package/dist/{chunk-7YHAFHGI.js → chunk-3JSAS7QP.js} +92 -165
  30. package/dist/chunk-3VDLE5GA.js +87 -0
  31. package/dist/{chunk-GJPGL7RP.js → chunk-3VTAK3S6.js} +108 -28
  32. package/dist/{chunk-VIGX66F7.js → chunk-3XSC3NEG.js} +14 -1
  33. package/dist/{chunk-DBNPVU3L.js → chunk-453BC56K.js} +1 -1
  34. package/dist/{chunk-N23OD7WS.js → chunk-4GFS57XI.js} +7 -7
  35. package/dist/{chunk-EWMEXGFZ.js → chunk-4PU6GDCE.js} +19 -19
  36. package/dist/{chunk-C3WE6EFO.js → chunk-4YWKKCTT.js} +1 -2
  37. package/dist/chunk-533GMKEG.js +125 -0
  38. package/dist/{chunk-CEG375CR.js → chunk-5AZCIOS4.js} +4 -4
  39. package/dist/{chunk-X3YEY2PY.js → chunk-5FFZQPTT.js} +11 -11
  40. package/dist/{chunk-AEFDAU3Y.js → chunk-5KGMGL4N.js} +4 -24
  41. package/dist/chunk-5UPOHLBD.js +213 -0
  42. package/dist/{chunk-6676HWGI.js → chunk-623TMW36.js} +4 -4
  43. package/dist/{chunk-DL2ZIXBO.js → chunk-6FHQCLHQ.js} +1 -1
  44. package/dist/{chunk-WIQ2HBJG.js → chunk-72PLRAWM.js} +13 -13
  45. package/dist/{chunk-3IBSB2U6.js → chunk-7KZ5X5SU.js} +14 -14
  46. package/dist/chunk-7MMLCMV3.js +142 -0
  47. package/dist/{chunk-VGM5UQRA.js → chunk-A62MTLPR.js} +806 -327
  48. package/dist/{chunk-35Q6JF3S.js → chunk-A7JOHU6Q.js} +4 -4
  49. package/dist/{chunk-ARMGWHYU.js → chunk-ABWW3JHS.js} +19 -19
  50. package/dist/{chunk-UXD3VNBO.js → chunk-AJLGY3LQ.js} +1 -2
  51. package/dist/{chunk-HY3CV5V6.js → chunk-AKTAFKIU.js} +4 -4
  52. package/dist/{chunk-V7EPLR3E.js → chunk-BFT3CN5L.js} +10 -10
  53. package/dist/{chunk-HGULM6DF.js → chunk-BGQ7H2KL.js} +10 -10
  54. package/dist/{chunk-SOJ4TLWP.js → chunk-BPCU5QJE.js} +5 -5
  55. package/dist/{chunk-F67RRVMJ.js → chunk-BQ6ZDY6L.js} +13 -13
  56. package/dist/{chunk-GXRLLA5H.js → chunk-CKD5563X.js} +4 -4
  57. package/dist/{chunk-E3DLJSYD.js → chunk-COP7NFSJ.js} +1 -1
  58. package/dist/{chunk-ABUQBBEM.js → chunk-CVFVEDMV.js} +4 -4
  59. package/dist/{chunk-6A7MR5NS.js → chunk-CVZA23ES.js} +11 -11
  60. package/dist/{chunk-7MTFPHXR.js → chunk-CYGCCNIC.js} +8 -8
  61. package/dist/{chunk-6MJ5HPIP.js → chunk-D2VXOF46.js} +6 -6
  62. package/dist/{chunk-OQMBWJPH.js → chunk-DELK6EWH.js} +13 -187
  63. package/dist/{chunk-N57BOIPU.js → chunk-DJWOIRLV.js} +1 -1
  64. package/dist/{chunk-Z2QQZOG3.js → chunk-DN2K5EAH.js} +1 -1
  65. package/dist/{chunk-UEEYZGM3.js → chunk-DRJAKRTI.js} +46 -17
  66. package/dist/chunk-EBYWGIOR.js +334 -0
  67. package/dist/{chunk-MMEZWZXV.js → chunk-EGTH3PUK.js} +20 -20
  68. package/dist/{chunk-4LQX5FRH.js → chunk-EMQP2CNF.js} +5 -5
  69. package/dist/{chunk-WRRMBJBQ.js → chunk-ENFXIYIH.js} +1 -1
  70. package/dist/{chunk-KHHMQM2L.js → chunk-EYFWEKFJ.js} +5 -5
  71. package/dist/chunk-F52JLHE3.js +2051 -0
  72. package/dist/{chunk-MNYDJXTM.js → chunk-FB7DDNCA.js} +5 -5
  73. package/dist/{chunk-BEU674HI.js → chunk-FDD7TANX.js} +5 -5
  74. package/dist/{chunk-GZBVMHXS.js → chunk-FFNSWUDC.js} +10 -10
  75. package/dist/{chunk-Y3FXVIJO.js → chunk-FNKBJCNF.js} +6 -6
  76. package/dist/{chunk-GAD5DQOY.js → chunk-G5DQCCPL.js} +2 -2
  77. package/dist/{chunk-35NDMIYZ.js → chunk-GVEF6UDT.js} +1 -1
  78. package/dist/{chunk-5CK6XEFV.js → chunk-H3MAUKL7.js} +174 -118
  79. package/dist/{chunk-B6SYYKJI.js → chunk-HDOWEXDH.js} +13 -13
  80. package/dist/{chunk-Z4WRKGME.js → chunk-HEGPAGJT.js} +11 -11
  81. package/dist/{chunk-63OSYRLS.js → chunk-HR7TFO2X.js} +4 -4
  82. package/dist/{chunk-4Q7LZQVY.js → chunk-IAWZQKUH.js} +10 -10
  83. package/dist/chunk-IIFQ7KYL.js +171 -0
  84. package/dist/{chunk-DVKO4VRC.js → chunk-IQZ3T2Q4.js} +12 -12
  85. package/dist/{chunk-Y2M536WR.js → chunk-JHBNG7OD.js} +17 -0
  86. package/dist/{chunk-LNAXUDW2.js → chunk-JSH7JEKY.js} +60 -62
  87. package/dist/chunk-JSMUFZZN.js +101 -0
  88. package/dist/{chunk-X4DGVTMC.js → chunk-K4WU4PVL.js} +5 -5
  89. package/dist/{chunk-MWX5JCOM.js → chunk-KT7X72J4.js} +161 -172
  90. package/dist/{chunk-R46PKJUT.js → chunk-KXIA66EJ.js} +13 -13
  91. package/dist/{chunk-2OYCT5NO.js → chunk-LGL4QSGB.js} +6 -6
  92. package/dist/{chunk-PBQ5M44A.js → chunk-LJDGVBOQ.js} +11 -47
  93. package/dist/chunk-LO2ZWQGL.js +6 -0
  94. package/dist/{chunk-VVWB3GIK.js → chunk-LYZDVZWA.js} +3 -12
  95. package/dist/{chunk-SPIVEW2Y.js → chunk-M572YFDA.js} +8 -8
  96. package/dist/{chunk-4ZN3D4YS.js → chunk-MEXH366L.js} +9 -9
  97. package/dist/{chunk-MKA5JWE6.js → chunk-MR3MLNWV.js} +35 -35
  98. package/dist/{chunk-SJQG3RCN.js → chunk-MVDPDVMI.js} +19 -19
  99. package/dist/{chunk-J24X54DB.js → chunk-MVNO35S5.js} +7 -7
  100. package/dist/{chunk-XBHUWCBD.js → chunk-N4GJRJF5.js} +1 -1
  101. package/dist/{chunk-34I4QIBD.js → chunk-N6YOACEW.js} +1 -1
  102. package/dist/{chunk-NEN6KWAJ.js → chunk-N7OVIX55.js} +12 -12
  103. package/dist/{chunk-6YGOXPB5.js → chunk-NGDOLGBQ.js} +21 -9
  104. package/dist/{chunk-YKDEE7ZL.js → chunk-NJP3DEE5.js} +1 -1
  105. package/dist/{chunk-HKDFWQ6Q.js → chunk-NQEXDLYH.js} +460 -2
  106. package/dist/{chunk-AZAGUAN4.js → chunk-O2XHQTBX.js} +15 -15
  107. package/dist/{chunk-3IN6MMKV.js → chunk-OFOKVLV3.js} +2 -2
  108. package/dist/chunk-OMBP3YSV.js +165 -0
  109. package/dist/{chunk-B6FG7A6W.js → chunk-P5XVG4PY.js} +1 -1
  110. package/dist/{chunk-LFATSJPO.js → chunk-PASEZJC7.js} +9 -9
  111. package/dist/chunk-PT5PLV3N.js +78 -0
  112. package/dist/{chunk-4IZ2RD3L.js → chunk-PXKDYD3M.js} +8 -8
  113. package/dist/chunk-PYDRHQTY.js +24 -0
  114. package/dist/{chunk-XB3HXEZB.js → chunk-QLEGHL2Q.js} +78 -73
  115. package/dist/{chunk-3B6MTW5G.js → chunk-QUHSHIAC.js} +3 -0
  116. package/dist/{chunk-3DOCALSU.js → chunk-QUPUWR42.js} +395 -11
  117. package/dist/{chunk-NRJ7F7JW.js → chunk-R7ESTJHN.js} +14 -14
  118. package/dist/{chunk-7QWLLYOY.js → chunk-RQPDD3RI.js} +1 -1
  119. package/dist/{chunk-JCSPXBS3.js → chunk-SJGIQGEC.js} +1 -1
  120. package/dist/{chunk-3ZSYFPHB.js → chunk-SUVFPJ4J.js} +19 -19
  121. package/dist/{chunk-YEUUI6JF.js → chunk-TE4IF3MM.js} +1 -1
  122. package/dist/{chunk-OVEBN3NC.js → chunk-TZDRRTAX.js} +5 -5
  123. package/dist/{chunk-HNUA6XIW.js → chunk-UCX2T4BQ.js} +14 -14
  124. package/dist/{chunk-GZMXTNDN.js → chunk-UCYSCKZV.js} +1432 -1380
  125. package/dist/chunk-UIVWOKWT.js +63 -0
  126. package/dist/{chunk-3T5S5RDO.js → chunk-UXGLM3B4.js} +4 -4
  127. package/dist/{chunk-UYO5Y4JI.js → chunk-VT5E7OMM.js} +11 -11
  128. package/dist/{chunk-TAKEQAZZ.js → chunk-VT6QIVZW.js} +0 -93
  129. package/dist/{chunk-5ZBQICCP.js → chunk-VY7PT4SI.js} +15 -15
  130. package/dist/{chunk-O5YFLNSQ.js → chunk-W3FDZPPF.js} +101 -290
  131. package/dist/chunk-W6CW4WHC.js +1755 -0
  132. package/dist/{chunk-ORI7UXS6.js → chunk-W6V2L2FX.js} +6 -6
  133. package/dist/chunk-WPVDACTL.js +60 -0
  134. package/dist/{chunk-5OS2MBRB.js → chunk-WTK4MLMF.js} +8 -8
  135. package/dist/{chunk-GDHF6CT5.js → chunk-X45JKZYW.js} +11 -11
  136. package/dist/{chunk-PIZ7FN3L.js → chunk-X7H7TIOT.js} +16 -16
  137. package/dist/{chunk-GKJLFLGN.js → chunk-XJ3WC4G7.js} +4 -4
  138. package/dist/{chunk-SESTTUVM.js → chunk-YN3FGNJM.js} +53 -1
  139. package/dist/{chunk-S4SVK5DE.js → chunk-YVLANFBK.js} +29 -1
  140. package/dist/{chunk-U7WZYWGA.js → chunk-Z5T5EPLF.js} +1 -1
  141. package/dist/{chunk-M73MP4NC.js → chunk-ZO7A6VYP.js} +19 -19
  142. package/dist/{collection-add-products-IRYJ6U6P.js → collection-add-products-ABWXUOFD.js} +32 -32
  143. package/dist/{collection-create-3BTRORHU.js → collection-create-BRMP6SIZ.js} +2 -2
  144. package/dist/{collection-detail-263PM4DL.js → collection-detail-AMGR2B5N.js} +30 -30
  145. package/dist/{collection-edit-L5GPFBBX.js → collection-edit-YLWUEU4C.js} +2 -2
  146. package/dist/{collection-list-CEU2EZ6K.js → collection-list-6HZE43AC.js} +38 -40
  147. package/dist/{collection-metadata-KHGPTV5C.js → collection-metadata-JS5QP3GD.js} +19 -19
  148. package/dist/{commission-rate-create-U3XQ4S27.js → commission-rate-create-PSPSJZR5.js} +57 -58
  149. package/dist/{commission-rate-detail-MY3F2RHR.js → commission-rate-detail-U72E4ZIO.js} +20 -20
  150. package/dist/{commission-rate-edit-MPEWXGTE.js → commission-rate-edit-7NJPABVA.js} +57 -58
  151. package/dist/{commission-rate-list-JPBOTOTA.js → commission-rate-list-Y5XLEO67.js} +8 -10
  152. package/dist/{constants-CAwtRicB.d.ts → constants-Bahlh59D.d.ts} +8 -4
  153. package/dist/{customer-detail-2QBJPF7S.js → customer-detail-2RWBN6C4.js} +30 -32
  154. package/dist/{customer-group-add-customers-JCLAH45C.js → customer-group-add-customers-VJUBEN7M.js} +13 -15
  155. package/dist/{customer-group-detail-BDKFWKTI.js → customer-group-detail-ED66F7JM.js} +26 -28
  156. package/dist/{customer-group-list-3NEEJXQH.js → customer-group-list-6YUFKBHH.js} +26 -28
  157. package/dist/{customer-group-metadata-YJXZFSFG.js → customer-group-metadata-VQUOWR3P.js} +19 -19
  158. package/dist/{customer-list-ZIFNZXO4.js → customer-list-MB6WZFMA.js} +11 -13
  159. package/dist/{customer-metadata-SG6M7X3Q.js → customer-metadata-47AVJXRI.js} +19 -19
  160. package/dist/{customers-add-customer-group-OQIFQZBL.js → customers-add-customer-group-HI7J7YKN.js} +29 -31
  161. package/dist/{edit-inventory-item-TDG2ZTPM.js → edit-inventory-item-MBPSBJL4.js} +15 -15
  162. package/dist/{edit-inventory-item-attributes-T56PJTCT.js → edit-inventory-item-attributes-RVYWOFAC.js} +15 -15
  163. package/dist/{edit-reservation-T6SKOG2F.js → edit-reservation-7BLGYXCJ.js} +5 -5
  164. package/dist/{edit-rules-4AHZQGCX.js → edit-rules-ZWDKM5M3.js} +19 -18
  165. package/dist/index.d.ts +2 -2
  166. package/dist/index.js +792 -632
  167. package/dist/{inventory-create-P26OGAHD.js → inventory-create-Q4VBPXSG.js} +22 -22
  168. package/dist/{inventory-detail-7W7UUWNT.js → inventory-detail-6CKO3A3Y.js} +28 -30
  169. package/dist/{inventory-list-PA4B4RWY.js → inventory-list-2JGX6BRI.js} +10 -12
  170. package/dist/{inventory-metadata-LUGA3KNV.js → inventory-metadata-COGGE5ZR.js} +19 -19
  171. package/dist/{inventory-stock-UZSYXXPX.js → inventory-stock-2QIKS7LE.js} +204 -42
  172. package/dist/loader-OU7SKXOD.js +28 -0
  173. package/dist/{location-detail-RUC2ZP3K.js → location-detail-HOCNTQ7K.js} +24 -24
  174. package/dist/{location-fulfillment-providers-WDET6TJP.js → location-fulfillment-providers-YQ2XFPAJ.js} +38 -39
  175. package/dist/{location-list-R7EECG5Z.js → location-list-I2UMU25V.js} +21 -22
  176. package/dist/{location-sales-channels-IS6E3I4S.js → location-sales-channels-GKIWX6B2.js} +12 -12
  177. package/dist/{location-service-zone-create-HAQVVTKP.js → location-service-zone-create-ZS3UWJAA.js} +8 -11
  178. package/dist/{location-service-zone-manage-areas-5LCENMAM.js → location-service-zone-manage-areas-S7QZTIFT.js} +8 -11
  179. package/dist/{location-service-zone-shipping-option-create-FV5Y2PNB.js → location-service-zone-shipping-option-create-6GYLJHEC.js} +25 -24
  180. package/dist/{location-service-zone-shipping-option-edit-PLEDWIY3.js → location-service-zone-shipping-option-edit-3PGSNKYT.js} +8 -7
  181. package/dist/{location-service-zone-shipping-option-pricing-6QHLZ6IN.js → location-service-zone-shipping-option-pricing-POBJOF3Z.js} +13 -13
  182. package/dist/{login-EWHQY6G3.js → login-N7CVSQNG.js} +15 -15
  183. package/dist/{manage-locations-TU5HCIKG.js → manage-locations-TKLOHP3D.js} +1 -1
  184. package/dist/{marketplace-add-currencies-PB73MHM6.js → marketplace-add-currencies-6ANNBGZM.js} +8 -10
  185. package/dist/{marketplace-detail-3KFGJWQ7.js → marketplace-detail-K52ALYGT.js} +27 -29
  186. package/dist/{marketplace-edit-U5B6WA56.js → marketplace-edit-6Q3G2OY5.js} +5 -4
  187. package/dist/{marketplace-metadata-VYCPYFJD.js → marketplace-metadata-ZSX3IQF4.js} +22 -22
  188. package/dist/offers-UBD6NICA.js +442 -0
  189. package/dist/{order-create-claim-R2SX6YUS.js → order-create-claim-OVHMMR3J.js} +284 -293
  190. package/dist/{order-create-edit-AONQC3TO.js → order-create-edit-HEOYCYZO.js} +216 -155
  191. package/dist/{order-create-exchange-7KKMJHXE.js → order-create-exchange-L56VKQBL.js} +291 -271
  192. package/dist/{order-create-refund-KWYYLAED.js → order-create-refund-UTJKJ3AJ.js} +23 -23
  193. package/dist/{order-create-return-BQFRANNG.js → order-create-return-FLGYGUTQ.js} +66 -41
  194. package/dist/{order-detail-BITJD73H.js → order-detail-KAB4MV7X.js} +34 -37
  195. package/dist/{order-edit-billing-address-FLEI4VDB.js → order-edit-billing-address-RUURVISC.js} +18 -18
  196. package/dist/{order-edit-email-AZIA6X5Q.js → order-edit-email-OO7AMRHC.js} +17 -17
  197. package/dist/{order-edit-shipping-address-GJMUSOPK.js → order-edit-shipping-address-BRRXUE76.js} +17 -17
  198. package/dist/{order-list-O7C7ENXI.js → order-list-S3AJC6L5.js} +26 -28
  199. package/dist/{order-metadata-RXIJOP4V.js → order-metadata-OHK6TPAO.js} +20 -20
  200. package/dist/{order-request-transfer-6IZVCHGV.js → order-request-transfer-YLMXC7NL.js} +19 -18
  201. package/dist/pages/index.d.ts +562 -706
  202. package/dist/pages/index.js +202 -205
  203. package/dist/{payout-detail-JWS2Q4TY.js → payout-detail-TWO6HN4E.js} +3 -3
  204. package/dist/{payout-list-PW6BFT4O.js → payout-list-7WJZFNW5.js} +9 -11
  205. package/dist/{price-list-configuration-N5D5OFXX.js → price-list-configuration-Q5H22ZE2.js} +13 -15
  206. package/dist/{price-list-create-NQFC2JIJ.js → price-list-create-OYAVGRM5.js} +37 -37
  207. package/dist/{price-list-detail-HRVLVBPS.js → price-list-detail-Q4GFFUFG.js} +32 -32
  208. package/dist/{price-list-edit-BVVLQ5WV.js → price-list-edit-YY4SXEI3.js} +5 -5
  209. package/dist/{price-list-list-K4IJFZYH.js → price-list-list-OIOY43TF.js} +13 -15
  210. package/dist/{price-list-prices-add-WXEGEWRA.js → price-list-prices-add-KONZVSVQ.js} +33 -33
  211. package/dist/{price-list-prices-edit-KJEKS6TL.js → price-list-prices-edit-SMUKU7Q6.js} +24 -24
  212. package/dist/product-add-existing-attributes-GGRRNFDK.js +456 -0
  213. package/dist/{product-attributes-ASPKDH7H.js → product-attributes-C3KHQF2I.js} +4 -4
  214. package/dist/product-bulk-edit-J3CMBZN2.js +285 -0
  215. package/dist/{product-create-BDQ66ECX.js → product-create-UR5OFGUY.js} +38 -39
  216. package/dist/product-create-attribute-XARMC6FJ.js +224 -0
  217. package/dist/product-create-variant-6VUKYLWE.js +20 -0
  218. package/dist/{product-detail-DCHR4B4T.js → product-detail-OLFVJZ7T.js} +26 -30
  219. package/dist/{product-edit-IASCMBET.js → product-edit-F4CKOIUO.js} +13 -8
  220. package/dist/product-edit-attribute-LG2ZM6HQ.js +175 -0
  221. package/dist/{product-list-X72QPKOK.js → product-list-2BWYAATR.js} +33 -33
  222. package/dist/{product-media-VNSFLCSH.js → product-media-EUDMCJ75.js} +16 -9
  223. package/dist/{product-metadata-GJ7C2UJG.js → product-metadata-5WVNFCRL.js} +22 -22
  224. package/dist/{product-organization-PN22LYKQ.js → product-organization-BFWDCHP4.js} +18 -18
  225. package/dist/{product-sales-channels-J2ZNRKZT.js → product-sales-channels-WKQSYOEX.js} +15 -15
  226. package/dist/{product-shipping-profile-G7UPGWYK.js → product-shipping-profile-WDLKA2SN.js} +6 -5
  227. package/dist/{product-tag-create-PHJICTE4.js → product-tag-create-KQSVCWMC.js} +15 -15
  228. package/dist/{product-tag-detail-4CKJMGHR.js → product-tag-detail-CWDAY7F3.js} +54 -55
  229. package/dist/{product-tag-edit-G4UNGXPT.js → product-tag-edit-B4SIZCUK.js} +15 -15
  230. package/dist/{product-tag-list-WQLWIZZW.js → product-tag-list-2OK3OCMZ.js} +54 -55
  231. package/dist/{product-tag-metadata-I4V6CR6Z.js → product-tag-metadata-MASTMIKE.js} +19 -19
  232. package/dist/{product-type-detail-7GHH4ACU.js → product-type-detail-3X7ZTZJN.js} +30 -30
  233. package/dist/{product-type-list-LTYTTF4F.js → product-type-list-TM26QMHR.js} +12 -14
  234. package/dist/{product-type-metadata-KGVRMMTQ.js → product-type-metadata-6BKTQHQC.js} +19 -19
  235. package/dist/{product-variant-detail-PHGVJWUV.js → product-variant-detail-PQ4RKPZT.js} +23 -43
  236. package/dist/product-variant-edit-TLF475SH.js +776 -0
  237. package/dist/{product-variant-metadata-HV72UBCP.js → product-variant-metadata-3M72B3PM.js} +19 -19
  238. package/dist/{profile-detail-UQTGEFYF.js → profile-detail-ZRL5SERS.js} +4 -4
  239. package/dist/{promotion-add-campaign-M4OT6URB.js → promotion-add-campaign-S3JJSFHT.js} +8 -7
  240. package/dist/{promotion-create-GM37OXEW.js → promotion-create-OKZBUSJD.js} +25 -24
  241. package/dist/{promotion-detail-PDBRQII7.js → promotion-detail-MMNEDRXD.js} +23 -23
  242. package/dist/{promotion-list-XW4PNLJF.js → promotion-list-DHWW7FTI.js} +13 -15
  243. package/dist/{refund-reason-create-M2CYTCEM.js → refund-reason-create-N4DZ4UHS.js} +15 -15
  244. package/dist/{refund-reason-edit-M4XBV633.js → refund-reason-edit-OAHRDKXW.js} +15 -15
  245. package/dist/{refund-reason-list-OXBLAGYO.js → refund-reason-list-YLH4LD4S.js} +40 -39
  246. package/dist/{region-add-countries-T4XZ2CU3.js → region-add-countries-COXN4LP3.js} +7 -9
  247. package/dist/{region-create-MQXTWBKC.js → region-create-P66Q65XY.js} +14 -15
  248. package/dist/{region-detail-6OFP76OY.js → region-detail-P2HHBYFV.js} +11 -13
  249. package/dist/{region-edit-QNJ2HT76.js → region-edit-XFE54SAO.js} +8 -7
  250. package/dist/{region-list-EYTDREE2.js → region-list-2XXKCDDX.js} +11 -13
  251. package/dist/{region-metadata-4JWOEGTZ.js → region-metadata-BJSTTZFL.js} +22 -22
  252. package/dist/{reservation-create-26QAWABA.js → reservation-create-TXYAY3KF.js} +2 -2
  253. package/dist/{reservation-detail-G26K6HZV.js → reservation-detail-CEENG76D.js} +23 -23
  254. package/dist/{reservation-list-CHHR6CEV.js → reservation-list-SORWYHI4.js} +11 -13
  255. package/dist/{reservation-metadata-JFLJ27A3.js → reservation-metadata-G3QBZF4K.js} +22 -22
  256. package/dist/{reset-password-S6IBWG47.js → reset-password-QGQ4GAHK.js} +1 -1
  257. package/dist/{return-reason-list-65LQDOZB.js → return-reason-list-7HTIV7NK.js} +28 -29
  258. package/dist/{sales-channel-add-products-FH7B7UYR.js → sales-channel-add-products-3VZ5SLLP.js} +33 -33
  259. package/dist/{sales-channel-create-NSZEHGZE.js → sales-channel-create-XBR3QESI.js} +2 -2
  260. package/dist/{sales-channel-detail-KCS472HN.js → sales-channel-detail-PHRSKCNM.js} +30 -30
  261. package/dist/{sales-channel-edit-W6Z2ERBJ.js → sales-channel-edit-ILBZBQP4.js} +2 -2
  262. package/dist/{sales-channel-list-6HBRUZ2Z.js → sales-channel-list-3GCESYAM.js} +23 -23
  263. package/dist/{sales-channel-metadata-NDSKXOGH.js → sales-channel-metadata-HVPGS756.js} +19 -19
  264. package/dist/{shipping-option-type-create-MEL24PGH.js → shipping-option-type-create-3ZKT7WAC.js} +15 -15
  265. package/dist/{shipping-option-type-detail-IS7CNAYI.js → shipping-option-type-detail-IYXWAK7F.js} +21 -21
  266. package/dist/{shipping-option-type-edit-IVBHURXR.js → shipping-option-type-edit-QRXYNNRW.js} +15 -15
  267. package/dist/{shipping-option-type-list-BTPCLBSD.js → shipping-option-type-list-MLIDCA3L.js} +26 -28
  268. package/dist/{shipping-profile-detail-L3IHPGLL.js → shipping-profile-detail-YAKZHWZI.js} +5 -5
  269. package/dist/{shipping-profile-metadata-UZPX2PHJ.js → shipping-profile-metadata-T4HPNTLH.js} +21 -21
  270. package/dist/{shipping-profiles-list-2JKVMEZG.js → shipping-profiles-list-JF2SQIQ7.js} +9 -11
  271. package/dist/{store-bulk-edit-WBBPQAAC.js → store-bulk-edit-BNF3HH5K.js} +7 -7
  272. package/dist/{store-create-OQVFVIK4.js → store-create-KFLNOD73.js} +18 -18
  273. package/dist/{store-details-NRNZNKBY.js → store-details-E347PHAN.js} +47 -62
  274. package/dist/{store-edit-PZWUMDFA.js → store-edit-Y6NLBIOP.js} +14 -14
  275. package/dist/{store-list-GWOYTUBA.js → store-list-S2L44OLB.js} +39 -41
  276. package/dist/{store-member-invite-Z5S63WYE.js → store-member-invite-J5XSPWMW.js} +3 -3
  277. package/dist/{tax-region-create-5DDZ23QQ.js → tax-region-create-MIDQXQS4.js} +18 -17
  278. package/dist/{tax-region-detail-VNBNS7FS.js → tax-region-detail-AC7B3G57.js} +28 -29
  279. package/dist/{tax-region-edit-OARZRBVK.js → tax-region-edit-5CORTHTC.js} +17 -16
  280. package/dist/{tax-region-list-WCHVLVVC.js → tax-region-list-FIBHEFVD.js} +9 -9
  281. package/dist/{tax-region-metadata-XJRFOG7I.js → tax-region-metadata-QQZIQPAD.js} +19 -19
  282. package/dist/{tax-region-province-detail-MXYZMUX7.js → tax-region-province-detail-2MGX7LEO.js} +26 -27
  283. package/dist/{tax-region-tax-override-create-LGST6PD7.js → tax-region-tax-override-create-IONGD4TG.js} +57 -58
  284. package/dist/{tax-region-tax-override-edit-5XNWTGDS.js → tax-region-tax-override-edit-RIT6YRVK.js} +57 -58
  285. package/dist/{user-detail-LGIMHLY4.js → user-detail-MMVBN3AE.js} +6 -6
  286. package/dist/{user-invite-ZZSWFXFM.js → user-invite-HLZJ7FST.js} +14 -16
  287. package/dist/{user-list-5QJJS7EA.js → user-list-TR7RSGUO.js} +9 -11
  288. package/dist/{user-metadata-376YJMY3.js → user-metadata-OZLU3Y2X.js} +19 -19
  289. package/package.json +5 -5
  290. package/dist/attribute-create-EAOQ6KT6.js +0 -1010
  291. package/dist/attribute-create-possible-value-BIU2L7AN.js +0 -437
  292. package/dist/attribute-edit-DRHFOHMK.js +0 -282
  293. package/dist/attribute-edit-possible-value-G2ON2AE3.js +0 -264
  294. package/dist/chunk-2U5BRCQO.js +0 -170
  295. package/dist/chunk-33XUAKRP.js +0 -6
  296. package/dist/chunk-4GPAS5GW.js +0 -36
  297. package/dist/chunk-4ZTZTIIM.js +0 -69
  298. package/dist/chunk-7O5NDICV.js +0 -120
  299. package/dist/chunk-7XXM72CF.js +0 -679
  300. package/dist/chunk-IGTRIAUC.js +0 -84
  301. package/dist/chunk-KYPPQGGE.js +0 -467
  302. package/dist/chunk-LBXPX3XC.js +0 -1260
  303. package/dist/chunk-LO7XX5M7.js +0 -6
  304. package/dist/chunk-MXGDKEU5.js +0 -248
  305. package/dist/chunk-OG4WH7IW.js +0 -420
  306. package/dist/chunk-QOQSXNEF.js +0 -37
  307. package/dist/chunk-QSGR43JM.js +0 -30
  308. package/dist/chunk-RSBZREKG.js +0 -144
  309. package/dist/chunk-RXM4B6HR.js +0 -8
  310. package/dist/chunk-UM7ZR3VU.js +0 -14
  311. package/dist/chunk-WCEMRNW4.js +0 -6
  312. package/dist/chunk-Z5I2Z6L3.js +0 -160
  313. package/dist/chunk-ZMC7BKLT.js +0 -56
  314. package/dist/chunk-ZXYKF4A2.js +0 -2146
  315. package/dist/order-allocate-items-2B6T5JCK.js +0 -563
  316. package/dist/order-create-fulfillment-2FTTWTFE.js +0 -642
  317. package/dist/order-create-shipment-7XP6PDTD.js +0 -214
  318. package/dist/order-receive-return-JV3X7YHG.js +0 -562
  319. package/dist/product-create-option-B7SV42LO.js +0 -148
  320. package/dist/product-create-variant-7YAG2YRZ.js +0 -56
  321. package/dist/product-edit-option-KVTIY5NM.js +0 -156
  322. package/dist/product-export-YZ2XSXFN.js +0 -137
  323. package/dist/product-import-KOSPPCSW.js +0 -267
  324. package/dist/product-prices-HI4SOTMP.js +0 -267
  325. package/dist/product-stock-666D3AMJ.js +0 -544
  326. package/dist/product-variant-edit-L77HDGTA.js +0 -547
  327. package/dist/product-variant-manage-inventory-items-WENX2QCZ.js +0 -341
  328. package/dist/{chunk-XCANTVXS.js → chunk-CPXK5RSJ.js} +6 -6
  329. package/dist/{chunk-Y6NK6GBB.js → chunk-GP4J42UD.js} +5 -5
  330. package/dist/{chunk-L56WFGUN.js → chunk-IMR3MZDP.js} +3 -3
  331. package/dist/{chunk-OB4NOV4M.js → chunk-LYZT5REU.js} +3 -3
  332. package/dist/{chunk-ZBJ56XDB.js → chunk-Q2ULPJJ6.js} +3 -3
  333. package/dist/{chunk-KCYUY2AI.js → chunk-WQFFCK3R.js} +6 -6
  334. package/dist/{chunk-ZW34ZAIP.js → chunk-WYA62MUL.js} +8 -8
  335. package/dist/{chunk-56AUQBQX.js → chunk-YYMACYP6.js} +5 -5
  336. package/dist/{customer-edit-X4HQOUAE.js → customer-edit-JZ4PQTIN.js} +3 -3
  337. package/dist/{profile-edit-Y5UUUKVH.js → profile-edit-HQTWYWZ7.js} +6 -6
  338. package/dist/{promotion-edit-details-E2XKWY7L.js → promotion-edit-details-TKRC5HES.js} +6 -6
@@ -0,0 +1,2051 @@
1
+ import {
2
+ SortableList
3
+ } from "./chunk-IIFQ7KYL.js";
4
+ import {
5
+ UploadMediaFormItem
6
+ } from "./chunk-26UTIAAZ.js";
7
+ import {
8
+ PRODUCT_CREATE_FORM_DEFAULTS,
9
+ ProductCreateSchema,
10
+ decorateVariantsWithDefaultValues,
11
+ generateVariantsFromAttributes,
12
+ normalizeProductFormValues
13
+ } from "./chunk-EBYWGIOR.js";
14
+ import {
15
+ HandleInput
16
+ } from "./chunk-HJ56YXBU.js";
17
+ import {
18
+ useAttributeTableFilters
19
+ } from "./chunk-RT6L7JXU.js";
20
+ import {
21
+ useAttributeTableQuery
22
+ } from "./chunk-4YWKKCTT.js";
23
+ import {
24
+ SingleCategoryCombobox
25
+ } from "./chunk-QUPUWR42.js";
26
+ import {
27
+ useComboboxData
28
+ } from "./chunk-5KGMGL4N.js";
29
+ import {
30
+ Combobox
31
+ } from "./chunk-AW77UWCZ.js";
32
+ import {
33
+ TabbedForm,
34
+ defineTabMeta,
35
+ useTabbedForm
36
+ } from "./chunk-4LXBQTFN.js";
37
+ import {
38
+ SwitchBox
39
+ } from "./chunk-2EME4AWX.js";
40
+ import {
41
+ ChipInput
42
+ } from "./chunk-YGRTRAWX.js";
43
+ import {
44
+ DataGrid,
45
+ createDataGridHelper
46
+ } from "./chunk-KT7X72J4.js";
47
+ import {
48
+ RouteFocusModal,
49
+ StackedFocusModal,
50
+ useRouteModal,
51
+ useStackedModal
52
+ } from "./chunk-FWJLS7XD.js";
53
+ import {
54
+ Form
55
+ } from "./chunk-3QSRE5LS.js";
56
+ import {
57
+ DataTable
58
+ } from "./chunk-LYZT5REU.js";
59
+ import {
60
+ require_dist
61
+ } from "./chunk-UCYSCKZV.js";
62
+ import {
63
+ useProductAttributes
64
+ } from "./chunk-533GMKEG.js";
65
+ import {
66
+ useRegions
67
+ } from "./chunk-ESPLVOFC.js";
68
+ import {
69
+ useStore
70
+ } from "./chunk-FXWKGNRV.js";
71
+ import {
72
+ ActionMenu
73
+ } from "./chunk-BDGZ4EQO.js";
74
+ import {
75
+ useSalesChannel
76
+ } from "./chunk-6FHQCLHQ.js";
77
+ import {
78
+ useCreateProduct
79
+ } from "./chunk-H3MAUKL7.js";
80
+ import {
81
+ sdk
82
+ } from "./chunk-ZBWL72TB.js";
83
+ import {
84
+ __toESM
85
+ } from "./chunk-NBMM2TZK.js";
86
+
87
+ // src/pages/products/product-create/product-create.tsx
88
+ import { Children as Children2 } from "react";
89
+ import { useTranslation as useTranslation10 } from "react-i18next";
90
+
91
+ // src/pages/products/product-create/components/product-create-form/product-create-form.tsx
92
+ import { Button as Button3, toast } from "@medusajs/ui";
93
+ import { useEffect as useEffect3, useMemo as useMemo4, Children } from "react";
94
+ import { useForm, useWatch as useWatch3 } from "react-hook-form";
95
+ import { useTranslation as useTranslation9 } from "react-i18next";
96
+
97
+ // src/pages/products/product-create/components/product-create-attributes-form/product-create-attributes-form.tsx
98
+ var import_types = __toESM(require_dist(), 1);
99
+ import { XMarkMini } from "@medusajs/icons";
100
+ import {
101
+ Button as Button2,
102
+ Heading,
103
+ Hint,
104
+ IconButton,
105
+ InlineTip,
106
+ Input,
107
+ Label,
108
+ Select,
109
+ Switch,
110
+ Text,
111
+ Textarea
112
+ } from "@medusajs/ui";
113
+ import { useEffect as useEffect2 } from "react";
114
+ import {
115
+ Controller,
116
+ useFieldArray
117
+ } from "react-hook-form";
118
+ import { useTranslation as useTranslation2 } from "react-i18next";
119
+
120
+ // src/pages/products/product-create/components/product-create-attributes-form/product-create-add-attributes-modal.tsx
121
+ import {
122
+ Badge,
123
+ Button,
124
+ createDataTableColumnHelper
125
+ } from "@medusajs/ui";
126
+ import { useEffect, useMemo, useState } from "react";
127
+ import { useTranslation } from "react-i18next";
128
+ import { keepPreviousData } from "@tanstack/react-query";
129
+ import { jsx, jsxs } from "react/jsx-runtime";
130
+ var ADD_ATTRIBUTES_MODAL_ID = "add-attributes";
131
+ var PAGE_SIZE = 20;
132
+ var MAX_VISIBLE_VALUES = 2;
133
+ var ATTRIBUTE_TYPE_LABELS = {
134
+ single_select: "attributes.type.select",
135
+ multi_select: "attributes.type.multivalue",
136
+ unit: "attributes.type.unit",
137
+ toggle: "attributes.type.toggle",
138
+ text: "attributes.type.text_area"
139
+ };
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 categoryId = form.watch("category_id");
150
+ const { searchParams } = useAttributeTableQuery({
151
+ pageSize: PAGE_SIZE,
152
+ prefix: ADD_ATTRIBUTES_MODAL_ID
153
+ });
154
+ const attributesQuery = useMemo(
155
+ () => ({ ...searchParams, category_id: categoryId || void 0 }),
156
+ [searchParams, categoryId]
157
+ );
158
+ const { product_attributes, count, isLoading, isError, error } = useProductAttributes(attributesQuery, {
159
+ placeholderData: keepPreviousData
160
+ });
161
+ const open = getIsOpen(ADD_ATTRIBUTES_MODAL_ID);
162
+ useEffect(() => {
163
+ if (!open) {
164
+ return;
165
+ }
166
+ const attributes = getValues("attributes") ?? [];
167
+ const existing = attributes.filter((a) => a.attribute_id);
168
+ const selection = {};
169
+ const stateEntries = [];
170
+ for (const a of existing) {
171
+ if (a.attribute_id) {
172
+ selection[a.attribute_id] = true;
173
+ const apiAttr = product_attributes?.find((pa) => pa.id === a.attribute_id);
174
+ stateEntries.push({
175
+ id: a.attribute_id,
176
+ name: a.title,
177
+ values: Array.isArray(a.values) ? a.values : a.values ? [a.values] : [],
178
+ is_variant_axis: a.use_for_variants,
179
+ type: a.type ?? apiAttr?.type ?? "",
180
+ available_values: a.available_values ?? apiAttr?.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
181
+ });
182
+ }
183
+ }
184
+ if (product_attributes) {
185
+ for (const attr of product_attributes) {
186
+ if (attr.is_required && !selection[attr.id]) {
187
+ selection[attr.id] = true;
188
+ stateEntries.push({
189
+ id: attr.id,
190
+ name: attr.name,
191
+ values: [],
192
+ is_variant_axis: attr.is_variant_axis,
193
+ type: attr.type,
194
+ available_values: attr.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
195
+ });
196
+ }
197
+ }
198
+ }
199
+ setRowSelection(selection);
200
+ setState(stateEntries);
201
+ }, [open, getValues, product_attributes]);
202
+ const onRowSelectionChange = (next) => {
203
+ if (product_attributes) {
204
+ for (const attr of product_attributes) {
205
+ if (attr.is_required) {
206
+ next[attr.id] = true;
207
+ }
208
+ }
209
+ }
210
+ const ids = Object.keys(next);
211
+ const addedIdsSet = new Set(
212
+ ids.filter((id) => next[id] && !rowSelection[id])
213
+ );
214
+ let addedAttributes = [];
215
+ if (addedIdsSet.size > 0) {
216
+ addedAttributes = product_attributes?.filter((attr) => addedIdsSet.has(attr.id)).map((attr) => ({
217
+ id: attr.id,
218
+ name: attr.name,
219
+ values: [],
220
+ is_variant_axis: attr.is_variant_axis,
221
+ type: attr.type,
222
+ available_values: attr.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
223
+ })) ?? [];
224
+ }
225
+ setState((prev) => {
226
+ const filteredPrev = prev.filter((a) => next[a.id]);
227
+ return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedAttributes]));
228
+ });
229
+ setRowSelection(next);
230
+ };
231
+ const handleAdd = () => {
232
+ const currentAttributes = getValues("attributes") ?? [];
233
+ const customAttributes = currentAttributes.filter((a) => a.is_custom);
234
+ const requiredIds = new Set(
235
+ product_attributes?.filter((a) => a.is_required).map((a) => a.id) ?? []
236
+ );
237
+ const selectedAttributes = state.map((a) => ({
238
+ attribute_id: a.id,
239
+ title: a.name,
240
+ values: a.values,
241
+ is_custom: false,
242
+ is_required: requiredIds.has(a.id),
243
+ use_for_variants: a.is_variant_axis,
244
+ type: a.type,
245
+ available_values: a.available_values
246
+ }));
247
+ setValue("attributes", [...selectedAttributes, ...customAttributes], {
248
+ shouldDirty: true,
249
+ shouldTouch: true
250
+ });
251
+ setIsOpen(ADD_ATTRIBUTES_MODAL_ID, false);
252
+ };
253
+ const filters = useAttributeTableFilters();
254
+ const columns = useColumns();
255
+ if (isError) {
256
+ throw error;
257
+ }
258
+ return /* @__PURE__ */ jsxs(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
259
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
260
+ /* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
261
+ DataTable,
262
+ {
263
+ data: product_attributes,
264
+ columns,
265
+ filters,
266
+ rowCount: count,
267
+ pageSize: PAGE_SIZE,
268
+ getRowId: (row) => row.id,
269
+ rowSelection: {
270
+ state: rowSelection,
271
+ onRowSelectionChange,
272
+ enableRowSelection: (row) => !row.original.is_required
273
+ },
274
+ isLoading,
275
+ layout: "fill",
276
+ prefix: ADD_ATTRIBUTES_MODAL_ID
277
+ }
278
+ ) }),
279
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
280
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: t("actions.cancel") }) }),
281
+ /* @__PURE__ */ jsx(Button, { size: "small", onClick: handleAdd, type: "button", children: t("actions.save") })
282
+ ] }) })
283
+ ] });
284
+ };
285
+ var columnHelper = createDataTableColumnHelper();
286
+ var useColumns = () => {
287
+ const { t } = useTranslation();
288
+ return useMemo(
289
+ () => [
290
+ columnHelper.select(),
291
+ columnHelper.accessor("name", {
292
+ header: t("attributes.fields.name"),
293
+ enableSorting: false
294
+ }),
295
+ columnHelper.accessor("handle", {
296
+ header: t("attributes.fields.handle"),
297
+ cell: (info) => {
298
+ const handle = info.getValue();
299
+ return handle ? `/${handle}` : "-";
300
+ },
301
+ enableSorting: false
302
+ }),
303
+ columnHelper.accessor("is_required", {
304
+ header: t("attributes.fields.required"),
305
+ cell: (info) => info.getValue() ? t("filters.radio.yes") : t("filters.radio.no"),
306
+ enableSorting: false
307
+ }),
308
+ columnHelper.accessor("type", {
309
+ header: t("attributes.fields.type"),
310
+ cell: (info) => {
311
+ const type = info.getValue();
312
+ const labelKey = ATTRIBUTE_TYPE_LABELS[type];
313
+ return labelKey ? t(labelKey) : type;
314
+ },
315
+ enableSorting: false
316
+ }),
317
+ columnHelper.accessor("is_variant_axis", {
318
+ header: t("attributes.fields.variantAxis"),
319
+ cell: (info) => info.getValue() ? t("filters.radio.yes") : t("filters.radio.no"),
320
+ enableSorting: false
321
+ }),
322
+ columnHelper.display({
323
+ id: "values",
324
+ header: t("attributes.fields.values"),
325
+ cell: ({ row }) => {
326
+ const values = row.original.values ?? [];
327
+ if (!values.length) {
328
+ return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "-" });
329
+ }
330
+ const visible = values.slice(0, MAX_VISIBLE_VALUES);
331
+ const remaining = values.length - MAX_VISIBLE_VALUES;
332
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
333
+ visible.map((v) => /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "grey", children: v.name }, v.id)),
334
+ remaining > 0 && /* @__PURE__ */ jsxs(Badge, { size: "2xsmall", color: "grey", children: [
335
+ "+",
336
+ remaining
337
+ ] })
338
+ ] });
339
+ }
340
+ })
341
+ ],
342
+ [t]
343
+ );
344
+ };
345
+
346
+ // src/pages/products/product-create/components/product-create-attributes-form/product-create-attributes-form.tsx
347
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
348
+ var Root = () => {
349
+ const { t } = useTranslation2();
350
+ const form = useTabbedForm();
351
+ const { setIsOpen } = useStackedModal();
352
+ const { fields, append, remove } = useFieldArray({
353
+ control: form.control,
354
+ name: "attributes"
355
+ });
356
+ const handleCreateNew = () => {
357
+ append({
358
+ attribute_id: void 0,
359
+ title: "",
360
+ values: [],
361
+ is_custom: true,
362
+ use_for_variants: false
363
+ });
364
+ };
365
+ const handleAddExisting = () => {
366
+ setIsOpen(ADD_ATTRIBUTES_MODAL_ID, true);
367
+ };
368
+ return /* @__PURE__ */ jsxs2(
369
+ "div",
370
+ {
371
+ className: "flex flex-col items-center p-16",
372
+ "data-testid": "product-create-attributes-form",
373
+ children: [
374
+ /* @__PURE__ */ jsx2(StackedFocusModal, { id: ADD_ATTRIBUTES_MODAL_ID, children: /* @__PURE__ */ jsx2(ProductCreateAddAttributesModal, {}) }),
375
+ /* @__PURE__ */ jsxs2("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
376
+ /* @__PURE__ */ jsxs2("div", { children: [
377
+ /* @__PURE__ */ jsx2(Heading, { level: "h2", children: t("products.create.attributes.header") }),
378
+ /* @__PURE__ */ jsx2(
379
+ Text,
380
+ {
381
+ size: "small",
382
+ className: "text-ui-fg-subtle mt-1 whitespace-pre-line",
383
+ children: t("products.create.attributes.description")
384
+ }
385
+ )
386
+ ] }),
387
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
388
+ /* @__PURE__ */ jsx2(
389
+ Button2,
390
+ {
391
+ type: "button",
392
+ variant: "secondary",
393
+ size: "small",
394
+ onClick: handleAddExisting,
395
+ "data-testid": "product-create-attributes-add-existing",
396
+ children: t("products.create.attributes.addExisting")
397
+ }
398
+ ),
399
+ /* @__PURE__ */ jsx2(
400
+ Button2,
401
+ {
402
+ type: "button",
403
+ variant: "secondary",
404
+ size: "small",
405
+ onClick: handleCreateNew,
406
+ "data-testid": "product-create-attributes-create-new",
407
+ children: t("products.create.attributes.createNew")
408
+ }
409
+ )
410
+ ] }),
411
+ fields.some((f) => !f.is_custom && !!f.attribute_id) && /* @__PURE__ */ jsx2(SelectedAttributes, { fields, remove }),
412
+ fields.some((f) => f.is_custom) && /* @__PURE__ */ jsx2(
413
+ "ul",
414
+ {
415
+ className: "flex flex-col gap-y-4",
416
+ "data-testid": "product-create-attributes-list",
417
+ children: fields.map((field, index) => {
418
+ if (!field.is_custom) return null;
419
+ const useForVariants = form.watch(
420
+ `attributes.${index}.use_for_variants`
421
+ );
422
+ return /* @__PURE__ */ jsxs2(
423
+ "li",
424
+ {
425
+ className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
426
+ "data-testid": `product-create-attribute-row-${index}`,
427
+ children: [
428
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
429
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
430
+ Label,
431
+ {
432
+ size: "xsmall",
433
+ weight: "plus",
434
+ className: "text-ui-fg-subtle",
435
+ htmlFor: `attributes.${index}.title`,
436
+ children: t("fields.title")
437
+ }
438
+ ) }),
439
+ /* @__PURE__ */ jsx2(
440
+ Input,
441
+ {
442
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
443
+ ...form.register(
444
+ `attributes.${index}.title`
445
+ ),
446
+ placeholder: t(
447
+ "products.create.attributes.titlePlaceholder"
448
+ ),
449
+ "data-testid": `product-create-attribute-title-${index}`
450
+ }
451
+ ),
452
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
453
+ Label,
454
+ {
455
+ size: "xsmall",
456
+ weight: "plus",
457
+ className: "text-ui-fg-subtle",
458
+ htmlFor: `attributes.${index}.values`,
459
+ children: t("fields.values")
460
+ }
461
+ ) }),
462
+ /* @__PURE__ */ jsx2(
463
+ Controller,
464
+ {
465
+ control: form.control,
466
+ name: `attributes.${index}.values`,
467
+ render: ({ field: { onChange, value, ...field2 } }) => useForVariants ? /* @__PURE__ */ jsx2(
468
+ ChipInput,
469
+ {
470
+ ...field2,
471
+ variant: "contrast",
472
+ value: Array.isArray(value) ? value : [],
473
+ onChange,
474
+ placeholder: t(
475
+ "products.create.attributes.valuePlaceholder"
476
+ ),
477
+ "data-testid": `product-create-attribute-values-${index}`
478
+ }
479
+ ) : /* @__PURE__ */ jsx2(
480
+ Textarea,
481
+ {
482
+ ...field2,
483
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
484
+ value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
485
+ onChange: (e) => onChange(e.target.value),
486
+ placeholder: t(
487
+ "products.create.attributes.valuePlaceholder"
488
+ ),
489
+ "data-testid": `product-create-attribute-values-${index}`
490
+ }
491
+ )
492
+ }
493
+ ),
494
+ /* @__PURE__ */ jsx2("div", {}),
495
+ /* @__PURE__ */ jsx2(
496
+ Form.Field,
497
+ {
498
+ control: form.control,
499
+ name: `attributes.${index}.use_for_variants`,
500
+ render: ({
501
+ field: { value, onChange, ref }
502
+ }) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2(
503
+ "div",
504
+ {
505
+ className: "flex items-start gap-x-3 py-1.5",
506
+ "data-testid": `product-create-attribute-use-for-variants-${index}`,
507
+ children: [
508
+ /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
509
+ Switch,
510
+ {
511
+ ref,
512
+ className: "shrink-0 rtl:rotate-180",
513
+ checked: value,
514
+ onCheckedChange: onChange
515
+ }
516
+ ) }),
517
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
518
+ /* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t(
519
+ "products.create.attributes.useForVariants"
520
+ ) }),
521
+ /* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
522
+ "products.create.attributes.useForVariantsDescription"
523
+ ) })
524
+ ] })
525
+ ]
526
+ }
527
+ ) })
528
+ }
529
+ )
530
+ ] }),
531
+ /* @__PURE__ */ jsx2(
532
+ IconButton,
533
+ {
534
+ type: "button",
535
+ size: "small",
536
+ variant: "transparent",
537
+ className: "text-ui-fg-muted",
538
+ onClick: () => remove(index),
539
+ "data-testid": `product-create-attribute-remove-${index}`,
540
+ children: /* @__PURE__ */ jsx2(XMarkMini, {})
541
+ }
542
+ )
543
+ ]
544
+ },
545
+ field.id
546
+ );
547
+ })
548
+ }
549
+ ),
550
+ /* @__PURE__ */ jsx2(RequiredAttributes, {})
551
+ ] })
552
+ ]
553
+ }
554
+ );
555
+ };
556
+ var SelectedAttributes = ({
557
+ fields,
558
+ remove
559
+ }) => {
560
+ const { t } = useTranslation2();
561
+ const form = useTabbedForm();
562
+ const entries = fields.map((field, index) => ({ field, index })).filter(({ field }) => !field.is_custom && !field.is_required && !!field.attribute_id);
563
+ if (!entries.length) return null;
564
+ return /* @__PURE__ */ jsx2(
565
+ "ul",
566
+ {
567
+ className: "flex flex-col gap-y-4",
568
+ "data-testid": "product-create-selected-attributes-list",
569
+ children: entries.map(({ field, index }) => {
570
+ const attrType = field.type;
571
+ const availableValues = field.available_values ?? [];
572
+ return /* @__PURE__ */ jsxs2(
573
+ "li",
574
+ {
575
+ className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
576
+ "data-testid": `product-create-selected-attribute-row-${index}`,
577
+ children: [
578
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
579
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
580
+ Label,
581
+ {
582
+ size: "xsmall",
583
+ weight: "plus",
584
+ className: "text-ui-fg-subtle",
585
+ children: t("fields.title")
586
+ }
587
+ ) }),
588
+ /* @__PURE__ */ jsx2(
589
+ Input,
590
+ {
591
+ value: field.title,
592
+ disabled: true,
593
+ className: "bg-ui-bg-field-component",
594
+ "data-testid": `product-create-selected-attribute-title-${index}`
595
+ }
596
+ ),
597
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
598
+ Label,
599
+ {
600
+ size: "xsmall",
601
+ weight: "plus",
602
+ className: "text-ui-fg-subtle",
603
+ children: t("fields.values")
604
+ }
605
+ ) }),
606
+ attrType === import_types.AttributeType.MULTI_SELECT ? /* @__PURE__ */ jsx2(
607
+ Controller,
608
+ {
609
+ control: form.control,
610
+ name: `attributes.${index}.values`,
611
+ render: ({ field: { onChange, value, ref, ...rest } }) => /* @__PURE__ */ jsx2(
612
+ Combobox,
613
+ {
614
+ ...rest,
615
+ ref,
616
+ value: Array.isArray(value) ? value : [],
617
+ onChange: (val) => onChange(val ?? []),
618
+ options: availableValues.map((v) => ({
619
+ value: v.name,
620
+ label: v.name
621
+ })),
622
+ placeholder: t(
623
+ "products.create.attributes.selectValues"
624
+ )
625
+ }
626
+ )
627
+ }
628
+ ) : attrType === import_types.AttributeType.SINGLE_SELECT ? /* @__PURE__ */ jsx2(
629
+ Controller,
630
+ {
631
+ control: form.control,
632
+ name: `attributes.${index}.values`,
633
+ render: ({ field: { onChange, value, ref, ...rest } }) => /* @__PURE__ */ jsxs2(
634
+ Select,
635
+ {
636
+ ...rest,
637
+ value: typeof value === "string" ? value : value?.[0] ?? "",
638
+ onValueChange: onChange,
639
+ children: [
640
+ /* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
641
+ Select.Value,
642
+ {
643
+ placeholder: t(
644
+ "products.create.attributes.selectValues"
645
+ )
646
+ }
647
+ ) }),
648
+ /* @__PURE__ */ jsx2(Select.Content, { children: availableValues.map((v) => /* @__PURE__ */ jsx2(Select.Item, { value: v.name, children: v.name }, v.id)) })
649
+ ]
650
+ }
651
+ )
652
+ }
653
+ ) : attrType === import_types.AttributeType.TEXT ? /* @__PURE__ */ jsx2(
654
+ Controller,
655
+ {
656
+ control: form.control,
657
+ name: `attributes.${index}.values`,
658
+ render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsx2(
659
+ Textarea,
660
+ {
661
+ ...rest,
662
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
663
+ value: typeof value === "string" ? value : value?.[0] ?? "",
664
+ onChange: (e) => onChange(e.target.value),
665
+ placeholder: t(
666
+ "products.create.attributes.valuePlaceholder"
667
+ )
668
+ }
669
+ )
670
+ }
671
+ ) : attrType === import_types.AttributeType.TOGGLE ? /* @__PURE__ */ jsx2(
672
+ Controller,
673
+ {
674
+ control: form.control,
675
+ name: `attributes.${index}.values`,
676
+ render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsxs2(
677
+ Select,
678
+ {
679
+ ...rest,
680
+ value: typeof value === "string" ? value : value?.[0] ?? "",
681
+ onValueChange: onChange,
682
+ children: [
683
+ /* @__PURE__ */ jsx2(Select.Trigger, { children: /* @__PURE__ */ jsx2(
684
+ Select.Value,
685
+ {
686
+ placeholder: t(
687
+ "products.create.attributes.selectValues"
688
+ )
689
+ }
690
+ ) }),
691
+ /* @__PURE__ */ jsxs2(Select.Content, { children: [
692
+ /* @__PURE__ */ jsx2(Select.Item, { value: "true", children: t("filters.radio.yes") }),
693
+ /* @__PURE__ */ jsx2(Select.Item, { value: "false", children: t("filters.radio.no") })
694
+ ] })
695
+ ]
696
+ }
697
+ )
698
+ }
699
+ ) : /* @__PURE__ */ jsx2(
700
+ Controller,
701
+ {
702
+ control: form.control,
703
+ name: `attributes.${index}.values`,
704
+ render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsx2(
705
+ Input,
706
+ {
707
+ ...rest,
708
+ value: typeof value === "string" ? value : value?.[0] ?? "",
709
+ onChange: (e) => onChange(e.target.value),
710
+ placeholder: t(
711
+ "products.create.attributes.valuePlaceholder"
712
+ )
713
+ }
714
+ )
715
+ }
716
+ ),
717
+ field.use_for_variants && /* @__PURE__ */ jsxs2(Fragment, { children: [
718
+ /* @__PURE__ */ jsx2("div", {}),
719
+ /* @__PURE__ */ jsx2(VariantAxisTip, {})
720
+ ] })
721
+ ] }),
722
+ /* @__PURE__ */ jsx2(
723
+ IconButton,
724
+ {
725
+ type: "button",
726
+ size: "small",
727
+ variant: "transparent",
728
+ className: "text-ui-fg-muted",
729
+ onClick: () => remove(index),
730
+ "data-testid": `product-create-selected-attribute-remove-${index}`,
731
+ children: /* @__PURE__ */ jsx2(XMarkMini, {})
732
+ }
733
+ )
734
+ ]
735
+ },
736
+ field.id
737
+ );
738
+ })
739
+ }
740
+ );
741
+ };
742
+ var RequiredAttributes = () => {
743
+ const { t } = useTranslation2();
744
+ const form = useTabbedForm();
745
+ const categoryId = form.watch("category_id");
746
+ const { product_attributes } = useProductAttributes(
747
+ {
748
+ category_id: categoryId,
749
+ is_required: true
750
+ },
751
+ { enabled: !!categoryId }
752
+ );
753
+ const attributes = form.watch("attributes") || [];
754
+ useEffect2(() => {
755
+ if (!product_attributes) return;
756
+ const currentAttributes = form.getValues("attributes") || [];
757
+ const requiredIds = new Set(product_attributes.map((a) => a.id));
758
+ const otherAttributes = currentAttributes.filter(
759
+ (a) => a.is_custom || !requiredIds.has(a.attribute_id ?? "")
760
+ );
761
+ const requiredAttributes = product_attributes.map((attr) => {
762
+ const existing = currentAttributes.find(
763
+ (a) => a.attribute_id === attr.id
764
+ );
765
+ if (existing) return existing;
766
+ return {
767
+ attribute_id: attr.id,
768
+ title: attr.name,
769
+ values: attr.type === import_types.AttributeType.MULTI_SELECT ? [] : "",
770
+ is_custom: false,
771
+ is_required: true,
772
+ use_for_variants: attr.is_variant_axis
773
+ };
774
+ });
775
+ form.setValue("attributes", [...otherAttributes, ...requiredAttributes]);
776
+ }, [product_attributes]);
777
+ if (!categoryId || !product_attributes?.length) return null;
778
+ const requiredEntries = attributes.map((attr, index) => ({ attr, index })).filter(({ attr }) => !attr.is_custom);
779
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
780
+ /* @__PURE__ */ jsx2("div", { className: "border-ui-border-base border-t border-dashed" }),
781
+ /* @__PURE__ */ jsxs2(
782
+ "div",
783
+ {
784
+ className: "flex flex-col gap-y-6",
785
+ "data-testid": "product-create-attributes-required",
786
+ children: [
787
+ /* @__PURE__ */ jsxs2("div", { children: [
788
+ /* @__PURE__ */ jsx2(Text, { size: "small", weight: "plus", leading: "compact", children: t("products.create.attributes.requiredAttributes") }),
789
+ /* @__PURE__ */ jsx2(Text, { size: "small", className: "text-ui-fg-subtle", children: t("products.create.attributes.requiredAttributesHint") })
790
+ ] }),
791
+ requiredEntries.map(({ attr, index }) => {
792
+ const apiAttr = product_attributes.find(
793
+ (a) => a.id === attr.attribute_id
794
+ );
795
+ if (!apiAttr) return null;
796
+ return /* @__PURE__ */ jsx2(
797
+ RequiredAttributeField,
798
+ {
799
+ attribute: apiAttr,
800
+ index
801
+ },
802
+ apiAttr.id
803
+ );
804
+ })
805
+ ]
806
+ }
807
+ )
808
+ ] });
809
+ };
810
+ var RequiredAttributeField = ({
811
+ attribute,
812
+ index
813
+ }) => {
814
+ const { t } = useTranslation2();
815
+ const form = useTabbedForm();
816
+ return /* @__PURE__ */ jsx2(
817
+ Form.Field,
818
+ {
819
+ control: form.control,
820
+ name: `attributes.${index}.values`,
821
+ render: ({ field: { onChange, value, ref, ...field } }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
822
+ /* @__PURE__ */ jsx2(Form.Label, { children: attribute.name }),
823
+ /* @__PURE__ */ jsx2(Form.Control, { children: attribute.type === import_types.AttributeType.SINGLE_SELECT ? /* @__PURE__ */ jsxs2(
824
+ Select,
825
+ {
826
+ ...field,
827
+ value: typeof value === "string" ? value : value?.[0] ?? "",
828
+ onValueChange: onChange,
829
+ children: [
830
+ /* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
831
+ Select.Value,
832
+ {
833
+ placeholder: t(
834
+ "products.create.attributes.valuePlaceholder"
835
+ )
836
+ }
837
+ ) }),
838
+ /* @__PURE__ */ jsx2(Select.Content, { children: attribute.values?.map((v) => /* @__PURE__ */ jsx2(Select.Item, { value: v.name, children: v.name }, v.id)) })
839
+ ]
840
+ }
841
+ ) : attribute.type === import_types.AttributeType.MULTI_SELECT ? /* @__PURE__ */ jsx2(
842
+ Combobox,
843
+ {
844
+ ...field,
845
+ ref,
846
+ value: Array.isArray(value) ? value : [],
847
+ onChange: (val) => onChange(val ?? []),
848
+ options: attribute.values?.map((v) => ({
849
+ value: v.name,
850
+ label: v.name
851
+ })) ?? [],
852
+ placeholder: t(
853
+ "products.create.attributes.selectValues"
854
+ )
855
+ }
856
+ ) : attribute.type === import_types.AttributeType.TEXT ? /* @__PURE__ */ jsx2(
857
+ Input,
858
+ {
859
+ ...field,
860
+ ref,
861
+ value: typeof value === "string" ? value : value?.[0] ?? "",
862
+ onChange: (e) => onChange(e.target.value),
863
+ placeholder: t(
864
+ "products.create.attributes.valuePlaceholder"
865
+ )
866
+ }
867
+ ) : attribute.type === import_types.AttributeType.TOGGLE ? /* @__PURE__ */ jsx2(
868
+ Switch,
869
+ {
870
+ ...field,
871
+ className: "rtl:rotate-180",
872
+ checked: value === "true" || value === true,
873
+ onCheckedChange: (checked) => onChange(String(checked))
874
+ }
875
+ ) : /* @__PURE__ */ jsx2(
876
+ Input,
877
+ {
878
+ ...field,
879
+ ref,
880
+ value: typeof value === "string" ? value : value?.[0] ?? "",
881
+ onChange: (e) => onChange(e.target.value),
882
+ placeholder: t(
883
+ "products.create.attributes.valuePlaceholder"
884
+ )
885
+ }
886
+ ) }),
887
+ /* @__PURE__ */ jsx2(Form.ErrorMessage, {}),
888
+ attribute.is_variant_axis && /* @__PURE__ */ jsx2(VariantAxisTip, {})
889
+ ] })
890
+ }
891
+ );
892
+ };
893
+ var VariantAxisTip = () => {
894
+ const { t } = useTranslation2();
895
+ return /* @__PURE__ */ jsx2(InlineTip, { label: t("products.create.attributes.tip"), children: t("products.create.attributes.variantAxisTip") });
896
+ };
897
+ Root._tabMeta = defineTabMeta({
898
+ id: "attributes",
899
+ labelKey: "products.create.tabs.attributes",
900
+ validationFields: ["attributes"]
901
+ });
902
+ var ProductCreateAttributesForm = Root;
903
+
904
+ // src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
905
+ import { Heading as Heading3 } from "@medusajs/ui";
906
+ import { useTranslation as useTranslation6 } from "react-i18next";
907
+
908
+ // src/pages/products/product-create/components/product-create-details-form/components/product-create-details-general-section/product-create-general-section.tsx
909
+ import { Input as Input2, Textarea as Textarea2 } from "@medusajs/ui";
910
+ import { useTranslation as useTranslation3 } from "react-i18next";
911
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
912
+ var ProductCreateGeneralSection = () => {
913
+ const form = useTabbedForm();
914
+ const { t } = useTranslation3();
915
+ return /* @__PURE__ */ jsxs3("div", { id: "general", className: "flex flex-col gap-y-6", "data-testid": "product-create-general-section", children: [
916
+ /* @__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: [
917
+ /* @__PURE__ */ jsx3(
918
+ Form.Field,
919
+ {
920
+ control: form.control,
921
+ name: "title",
922
+ render: ({ field }) => {
923
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-title-item", children: [
924
+ /* @__PURE__ */ jsx3(Form.Label, { "data-testid": "product-create-general-section-title-label", children: t("products.fields.title.label") }),
925
+ /* @__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" }) })
926
+ ] });
927
+ }
928
+ }
929
+ ),
930
+ /* @__PURE__ */ jsx3(
931
+ Form.Field,
932
+ {
933
+ control: form.control,
934
+ name: "subtitle",
935
+ render: ({ field }) => {
936
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-subtitle-item", children: [
937
+ /* @__PURE__ */ jsx3(Form.Label, { optional: true, "data-testid": "product-create-general-section-subtitle-label", children: t("products.fields.subtitle.label") }),
938
+ /* @__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" }) })
939
+ ] });
940
+ }
941
+ }
942
+ ),
943
+ /* @__PURE__ */ jsx3(
944
+ Form.Field,
945
+ {
946
+ control: form.control,
947
+ name: "handle",
948
+ render: ({ field }) => {
949
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-handle-item", children: [
950
+ /* @__PURE__ */ jsx3(
951
+ Form.Label,
952
+ {
953
+ tooltip: t("products.fields.handle.tooltip"),
954
+ optional: true,
955
+ "data-testid": "product-create-general-section-handle-label",
956
+ children: t("fields.handle")
957
+ }
958
+ ),
959
+ /* @__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" }) })
960
+ ] });
961
+ }
962
+ }
963
+ )
964
+ ] }) }),
965
+ /* @__PURE__ */ jsx3(
966
+ Form.Field,
967
+ {
968
+ control: form.control,
969
+ name: "description",
970
+ render: ({ field }) => {
971
+ return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-description-item", children: [
972
+ /* @__PURE__ */ jsx3(Form.Label, { optional: true, "data-testid": "product-create-general-section-description-label", children: t("products.fields.description.label") }),
973
+ /* @__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" }) })
974
+ ] });
975
+ }
976
+ }
977
+ )
978
+ ] });
979
+ };
980
+
981
+ // src/pages/products/product-create/components/product-create-details-form/components/product-create-details-media-section/product-create-details-media-section.tsx
982
+ import {
983
+ defaultDropAnimationSideEffects,
984
+ DndContext,
985
+ DragOverlay,
986
+ KeyboardSensor,
987
+ PointerSensor,
988
+ useSensor,
989
+ useSensors
990
+ } from "@dnd-kit/core";
991
+ import {
992
+ arrayMove,
993
+ SortableContext,
994
+ sortableKeyboardCoordinates,
995
+ useSortable
996
+ } from "@dnd-kit/sortable";
997
+ import { CSS } from "@dnd-kit/utilities";
998
+ import {
999
+ DotsSix,
1000
+ StackPerspective,
1001
+ ThumbnailBadge,
1002
+ Trash,
1003
+ XMark
1004
+ } from "@medusajs/icons";
1005
+ import { IconButton as IconButton2, Text as Text2 } from "@medusajs/ui";
1006
+ import { useState as useState2 } from "react";
1007
+ import { useFieldArray as useFieldArray2 } from "react-hook-form";
1008
+ import { useTranslation as useTranslation4 } from "react-i18next";
1009
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1010
+ var dropAnimationConfig = {
1011
+ sideEffects: defaultDropAnimationSideEffects({
1012
+ styles: {
1013
+ active: {
1014
+ opacity: "0.4"
1015
+ }
1016
+ }
1017
+ })
1018
+ };
1019
+ var ProductCreateMediaSection = () => {
1020
+ const form = useTabbedForm();
1021
+ const { fields, append, remove } = useFieldArray2({
1022
+ name: "media",
1023
+ control: form.control,
1024
+ keyName: "field_id"
1025
+ });
1026
+ const [activeId, setActiveId] = useState2(null);
1027
+ const sensors = useSensors(
1028
+ useSensor(PointerSensor),
1029
+ useSensor(KeyboardSensor, {
1030
+ coordinateGetter: sortableKeyboardCoordinates
1031
+ })
1032
+ );
1033
+ const handleDragStart = (event) => {
1034
+ setActiveId(event.active.id);
1035
+ };
1036
+ const handleDragEnd = (event) => {
1037
+ setActiveId(null);
1038
+ const { active, over } = event;
1039
+ if (active.id !== over?.id) {
1040
+ const oldIndex = fields.findIndex((item) => item.field_id === active.id);
1041
+ const newIndex = fields.findIndex((item) => item.field_id === over?.id);
1042
+ form.setValue("media", arrayMove(fields, oldIndex, newIndex), {
1043
+ shouldDirty: true,
1044
+ shouldTouch: true
1045
+ });
1046
+ }
1047
+ };
1048
+ const handleDragCancel = () => {
1049
+ setActiveId(null);
1050
+ };
1051
+ const getOnDelete = (index) => {
1052
+ return () => {
1053
+ remove(index);
1054
+ };
1055
+ };
1056
+ const getMakeThumbnail = (index) => {
1057
+ return () => {
1058
+ const newFields = fields.map((field, i) => {
1059
+ return {
1060
+ ...field,
1061
+ isThumbnail: i === index
1062
+ };
1063
+ });
1064
+ form.setValue("media", newFields, {
1065
+ shouldDirty: true,
1066
+ shouldTouch: true
1067
+ });
1068
+ };
1069
+ };
1070
+ const getItemHandlers = (index) => {
1071
+ return {
1072
+ onDelete: getOnDelete(index),
1073
+ onMakeThumbnail: getMakeThumbnail(index)
1074
+ };
1075
+ };
1076
+ return /* @__PURE__ */ jsxs4("div", { id: "media", className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section", children: [
1077
+ /* @__PURE__ */ jsx4(UploadMediaFormItem, { form, append, showHint: false, "data-testid": "product-create-media-section-upload" }),
1078
+ /* @__PURE__ */ jsxs4(
1079
+ DndContext,
1080
+ {
1081
+ sensors,
1082
+ onDragEnd: handleDragEnd,
1083
+ onDragStart: handleDragStart,
1084
+ onDragCancel: handleDragCancel,
1085
+ children: [
1086
+ /* @__PURE__ */ jsx4(DragOverlay, { dropAnimation: dropAnimationConfig, children: activeId ? /* @__PURE__ */ jsx4(
1087
+ MediaGridItemOverlay,
1088
+ {
1089
+ field: fields.find((m) => m.field_id === activeId)
1090
+ }
1091
+ ) : null }),
1092
+ /* @__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) => {
1093
+ const { onDelete, onMakeThumbnail } = getItemHandlers(index);
1094
+ return /* @__PURE__ */ jsx4(
1095
+ MediaItem,
1096
+ {
1097
+ field,
1098
+ onDelete,
1099
+ onMakeThumbnail
1100
+ },
1101
+ field.field_id
1102
+ );
1103
+ }) }) })
1104
+ ]
1105
+ }
1106
+ )
1107
+ ] });
1108
+ };
1109
+ var MediaItem = ({ field, onDelete, onMakeThumbnail }) => {
1110
+ const { t } = useTranslation4();
1111
+ const {
1112
+ attributes,
1113
+ listeners,
1114
+ setNodeRef,
1115
+ setActivatorNodeRef,
1116
+ transform,
1117
+ transition,
1118
+ isDragging
1119
+ } = useSortable({ id: field.field_id });
1120
+ const style = {
1121
+ opacity: isDragging ? 0.4 : void 0,
1122
+ transform: CSS.Translate.toString(transform),
1123
+ transition
1124
+ };
1125
+ if (!field.file) {
1126
+ return null;
1127
+ }
1128
+ return /* @__PURE__ */ jsxs4(
1129
+ "li",
1130
+ {
1131
+ className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
1132
+ ref: setNodeRef,
1133
+ style,
1134
+ "data-testid": `product-create-media-section-item-${field.field_id}`,
1135
+ children: [
1136
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
1137
+ /* @__PURE__ */ jsx4(
1138
+ IconButton2,
1139
+ {
1140
+ variant: "transparent",
1141
+ type: "button",
1142
+ size: "small",
1143
+ ...attributes,
1144
+ ...listeners,
1145
+ ref: setActivatorNodeRef,
1146
+ className: "cursor-grab touch-none active:cursor-grabbing",
1147
+ children: /* @__PURE__ */ jsx4(DotsSix, { className: "text-ui-fg-muted" })
1148
+ }
1149
+ ),
1150
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-3", children: [
1151
+ /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx4(ThumbnailPreview, { url: field.url }) }),
1152
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
1153
+ /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: field.file.name }),
1154
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1155
+ field.isThumbnail && /* @__PURE__ */ jsx4(ThumbnailBadge, {}),
1156
+ /* @__PURE__ */ jsx4(
1157
+ Text2,
1158
+ {
1159
+ size: "xsmall",
1160
+ leading: "compact",
1161
+ className: "text-ui-fg-subtle",
1162
+ children: formatFileSize(field.file.size)
1163
+ }
1164
+ )
1165
+ ] })
1166
+ ] })
1167
+ ] })
1168
+ ] }),
1169
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1170
+ /* @__PURE__ */ jsx4(
1171
+ ActionMenu,
1172
+ {
1173
+ groups: [
1174
+ {
1175
+ actions: [
1176
+ {
1177
+ label: t("products.media.makeThumbnail"),
1178
+ icon: /* @__PURE__ */ jsx4(StackPerspective, {}),
1179
+ onClick: onMakeThumbnail
1180
+ }
1181
+ ]
1182
+ },
1183
+ {
1184
+ actions: [
1185
+ {
1186
+ icon: /* @__PURE__ */ jsx4(Trash, {}),
1187
+ label: t("actions.delete"),
1188
+ onClick: onDelete
1189
+ }
1190
+ ]
1191
+ }
1192
+ ],
1193
+ "data-testid": `product-create-media-section-item-menu-${field.field_id}`
1194
+ }
1195
+ ),
1196
+ /* @__PURE__ */ jsx4(
1197
+ IconButton2,
1198
+ {
1199
+ type: "button",
1200
+ size: "small",
1201
+ variant: "transparent",
1202
+ onClick: onDelete,
1203
+ "data-testid": `product-create-media-section-item-delete-${field.field_id}`,
1204
+ children: /* @__PURE__ */ jsx4(XMark, {})
1205
+ }
1206
+ )
1207
+ ] })
1208
+ ]
1209
+ }
1210
+ );
1211
+ };
1212
+ var MediaGridItemOverlay = ({ field }) => {
1213
+ 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: [
1214
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
1215
+ /* @__PURE__ */ jsx4(
1216
+ IconButton2,
1217
+ {
1218
+ variant: "transparent",
1219
+ size: "small",
1220
+ className: "cursor-grab touch-none active:cursor-grabbing",
1221
+ children: /* @__PURE__ */ jsx4(DotsSix, { className: "text-ui-fg-muted" })
1222
+ }
1223
+ ),
1224
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-3", children: [
1225
+ /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx4(ThumbnailPreview, { url: field.url }) }),
1226
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
1227
+ /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: field.file?.name }),
1228
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1229
+ field.isThumbnail && /* @__PURE__ */ jsx4(ThumbnailBadge, {}),
1230
+ /* @__PURE__ */ jsx4(
1231
+ Text2,
1232
+ {
1233
+ size: "xsmall",
1234
+ leading: "compact",
1235
+ className: "text-ui-fg-subtle",
1236
+ children: formatFileSize(field.file?.size ?? 0)
1237
+ }
1238
+ )
1239
+ ] })
1240
+ ] })
1241
+ ] })
1242
+ ] }),
1243
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1244
+ /* @__PURE__ */ jsx4(ActionMenu, { groups: [] }),
1245
+ /* @__PURE__ */ jsx4(
1246
+ IconButton2,
1247
+ {
1248
+ type: "button",
1249
+ size: "small",
1250
+ variant: "transparent",
1251
+ onClick: () => {
1252
+ },
1253
+ children: /* @__PURE__ */ jsx4(XMark, {})
1254
+ }
1255
+ )
1256
+ ] })
1257
+ ] });
1258
+ };
1259
+ var ThumbnailPreview = ({ url }) => {
1260
+ if (!url) {
1261
+ return null;
1262
+ }
1263
+ return /* @__PURE__ */ jsx4("img", { src: url, alt: "", className: "size-full object-cover object-center" });
1264
+ };
1265
+ function formatFileSize(bytes, decimalPlaces = 2) {
1266
+ if (bytes === 0) {
1267
+ return "0 Bytes";
1268
+ }
1269
+ const k = 1024;
1270
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1271
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
1272
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPlaces)) + " " + sizes[i];
1273
+ }
1274
+
1275
+ // src/pages/products/product-create/components/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
1276
+ import {
1277
+ Alert,
1278
+ Checkbox,
1279
+ clx,
1280
+ Heading as Heading2,
1281
+ Hint as Hint2,
1282
+ InlineTip as InlineTip2,
1283
+ Label as Label2,
1284
+ Text as Text3
1285
+ } from "@medusajs/ui";
1286
+ import { useFieldArray as useFieldArray3, useWatch } from "react-hook-form";
1287
+ import { useTranslation as useTranslation5 } from "react-i18next";
1288
+ import { useMemo as useMemo2 } from "react";
1289
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1290
+ var ProductCreateVariantsSection = () => {
1291
+ const form = useTabbedForm();
1292
+ const { t } = useTranslation5();
1293
+ const variants = useFieldArray3({
1294
+ control: form.control,
1295
+ name: "variants"
1296
+ });
1297
+ const watchedAttributes = useWatch({
1298
+ control: form.control,
1299
+ name: "attributes",
1300
+ defaultValue: []
1301
+ });
1302
+ const watchedVariants = useWatch({
1303
+ control: form.control,
1304
+ name: "variants",
1305
+ defaultValue: []
1306
+ });
1307
+ const variantAxes = useMemo2(() => {
1308
+ return (watchedAttributes ?? []).filter((attr) => attr.use_for_variants).map((attr) => ({
1309
+ title: attr.title,
1310
+ values: Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : []
1311
+ })).filter((axis) => axis.title && axis.values.length > 0);
1312
+ }, [watchedAttributes]);
1313
+ const hasVariantAxes = variantAxes.length > 0;
1314
+ const showInvalidVariantsMessage = form.formState.errors.variants?.root?.message === "invalid_length";
1315
+ const handleRankChange = (items) => {
1316
+ const update = items.map((item, index) => {
1317
+ const variant = watchedVariants.find((v) => v.title === item.title);
1318
+ return {
1319
+ id: item.id,
1320
+ ...variant || item,
1321
+ variant_rank: index
1322
+ };
1323
+ });
1324
+ variants.replace(update);
1325
+ };
1326
+ const getCheckboxState = (variants2) => {
1327
+ if (variants2.every((variant) => variant.should_create)) {
1328
+ return true;
1329
+ }
1330
+ if (variants2.some((variant) => variant.should_create)) {
1331
+ return "indeterminate";
1332
+ }
1333
+ return false;
1334
+ };
1335
+ const onCheckboxChange = (value) => {
1336
+ switch (value) {
1337
+ case true: {
1338
+ const update = watchedVariants.map((variant) => ({
1339
+ ...variant,
1340
+ should_create: true
1341
+ }));
1342
+ form.setValue("variants", update);
1343
+ break;
1344
+ }
1345
+ case false: {
1346
+ const update = watchedVariants.map((variant) => ({
1347
+ ...variant,
1348
+ should_create: false
1349
+ }));
1350
+ form.setValue("variants", decorateVariantsWithDefaultValues(update));
1351
+ break;
1352
+ }
1353
+ case "indeterminate":
1354
+ break;
1355
+ }
1356
+ };
1357
+ if (!hasVariantAxes) {
1358
+ return null;
1359
+ }
1360
+ return /* @__PURE__ */ jsxs5(
1361
+ "div",
1362
+ {
1363
+ id: "variants",
1364
+ className: "flex flex-col gap-y-8",
1365
+ "data-testid": "product-create-variants-section",
1366
+ children: [
1367
+ /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx5(Heading2, { level: "h2", children: t("products.create.variants.header") }) }),
1368
+ /* @__PURE__ */ jsx5("div", { className: "grid grid-cols-1 gap-x-4 gap-y-8", children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-6", children: [
1369
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
1370
+ /* @__PURE__ */ jsx5(Label2, { weight: "plus", children: t("products.create.variants.productVariants.label") }),
1371
+ /* @__PURE__ */ jsx5(Hint2, { children: t("products.create.variants.productVariants.hint") })
1372
+ ] }),
1373
+ showInvalidVariantsMessage && /* @__PURE__ */ jsx5(Alert, { dismissible: true, variant: "error", children: t("products.create.errors.variants") }),
1374
+ variants.fields.length > 0 ? /* @__PURE__ */ jsxs5("div", { className: "overflow-hidden rounded-xl border", children: [
1375
+ /* @__PURE__ */ jsxs5(
1376
+ "div",
1377
+ {
1378
+ className: "bg-ui-bg-component text-ui-fg-subtle grid items-center gap-3 border-b px-6 py-2.5",
1379
+ style: {
1380
+ gridTemplateColumns: `20px 28px repeat(${variantAxes.length}, 1fr)`
1381
+ },
1382
+ children: [
1383
+ /* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(
1384
+ Checkbox,
1385
+ {
1386
+ className: "relative",
1387
+ checked: getCheckboxState(watchedVariants),
1388
+ onCheckedChange: onCheckboxChange
1389
+ }
1390
+ ) }),
1391
+ /* @__PURE__ */ jsx5("div", {}),
1392
+ variantAxes.map((axis, index) => /* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", weight: "plus", children: axis.title }) }, index))
1393
+ ]
1394
+ }
1395
+ ),
1396
+ /* @__PURE__ */ jsx5(
1397
+ SortableList,
1398
+ {
1399
+ items: variants.fields,
1400
+ onChange: handleRankChange,
1401
+ renderItem: (item, index) => {
1402
+ return /* @__PURE__ */ jsx5(
1403
+ SortableList.Item,
1404
+ {
1405
+ id: item.id,
1406
+ className: clx("bg-ui-bg-base border-b", {
1407
+ "border-b-0": index === variants.fields.length - 1
1408
+ }),
1409
+ children: /* @__PURE__ */ jsxs5(
1410
+ "div",
1411
+ {
1412
+ className: "text-ui-fg-subtle grid w-full items-center gap-3 px-6 py-2.5",
1413
+ style: {
1414
+ gridTemplateColumns: `20px 28px repeat(${variantAxes.length}, 1fr)`
1415
+ },
1416
+ children: [
1417
+ /* @__PURE__ */ jsx5(
1418
+ Form.Field,
1419
+ {
1420
+ control: form.control,
1421
+ name: `variants.${index}.should_create`,
1422
+ render: ({
1423
+ field: { value, onChange, ...field }
1424
+ }) => /* @__PURE__ */ jsx5(Form.Item, { children: /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(
1425
+ Checkbox,
1426
+ {
1427
+ className: "relative",
1428
+ ...field,
1429
+ checked: value,
1430
+ onCheckedChange: onChange
1431
+ }
1432
+ ) }) })
1433
+ }
1434
+ ),
1435
+ /* @__PURE__ */ jsx5(SortableList.DragHandle, {}),
1436
+ variantAxes.map((axis, i) => /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", children: item.options?.[axis.title] ?? "-" }, i))
1437
+ ]
1438
+ }
1439
+ )
1440
+ }
1441
+ );
1442
+ }
1443
+ }
1444
+ )
1445
+ ] }) : /* @__PURE__ */ jsx5(Alert, { children: t("products.create.variants.productVariants.alert") }),
1446
+ variants.fields.length > 0 && /* @__PURE__ */ jsx5(InlineTip2, { label: t("general.tip"), children: t("products.create.variants.productVariants.tip") })
1447
+ ] }) })
1448
+ ]
1449
+ }
1450
+ );
1451
+ };
1452
+
1453
+ // src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
1454
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1455
+ var Root2 = () => {
1456
+ return /* @__PURE__ */ jsx6(
1457
+ "div",
1458
+ {
1459
+ className: "flex flex-col items-center p-16",
1460
+ "data-testid": "product-create-details-form",
1461
+ children: /* @__PURE__ */ jsxs6(
1462
+ "div",
1463
+ {
1464
+ className: "flex w-full max-w-[720px] flex-col gap-y-8",
1465
+ "data-testid": "product-create-details-form-content",
1466
+ children: [
1467
+ /* @__PURE__ */ jsx6(Header, {}),
1468
+ /* @__PURE__ */ jsxs6(
1469
+ "div",
1470
+ {
1471
+ className: "flex flex-col gap-y-6",
1472
+ "data-testid": "product-create-details-form-sections",
1473
+ children: [
1474
+ /* @__PURE__ */ jsx6(ProductCreateGeneralSection, {}),
1475
+ /* @__PURE__ */ jsx6(ProductCreateMediaSection, {})
1476
+ ]
1477
+ }
1478
+ ),
1479
+ /* @__PURE__ */ jsx6(ProductCreateVariantsSection, {})
1480
+ ]
1481
+ }
1482
+ )
1483
+ }
1484
+ );
1485
+ };
1486
+ Root2._tabMeta = defineTabMeta({
1487
+ id: "details",
1488
+ labelKey: "products.create.tabs.details",
1489
+ validationFields: ["title", "handle", "description", "media"]
1490
+ });
1491
+ var ProductCreateDetailsForm = Root2;
1492
+ var Header = () => {
1493
+ const { t } = useTranslation6();
1494
+ return /* @__PURE__ */ jsx6(
1495
+ "div",
1496
+ {
1497
+ className: "flex flex-col",
1498
+ "data-testid": "product-create-details-form-header",
1499
+ children: /* @__PURE__ */ jsx6(Heading3, { "data-testid": "product-create-details-form-heading", children: t("products.create.header") })
1500
+ }
1501
+ );
1502
+ };
1503
+
1504
+ // src/pages/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
1505
+ import { Heading as Heading4 } from "@medusajs/ui";
1506
+ import { useTranslation as useTranslation7 } from "react-i18next";
1507
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1508
+ var ProductCreateOrganizationSection = () => {
1509
+ const form = useTabbedForm();
1510
+ const { t } = useTranslation7();
1511
+ const collections = useComboboxData({
1512
+ queryKey: ["product_collections"],
1513
+ queryFn: (params) => sdk.admin.collections.query(params),
1514
+ getOptions: (data) => data.collections.map((collection) => ({
1515
+ label: collection.title,
1516
+ value: collection.id
1517
+ }))
1518
+ });
1519
+ const types = useComboboxData({
1520
+ queryKey: ["product_types"],
1521
+ queryFn: (params) => sdk.admin.productTypes.query(params),
1522
+ getOptions: (data) => data.product_types.map((type) => ({
1523
+ label: type.value,
1524
+ value: type.id
1525
+ }))
1526
+ });
1527
+ const tags = useComboboxData({
1528
+ queryKey: ["product_tags"],
1529
+ queryFn: (params) => sdk.admin.productTags.query(params),
1530
+ getOptions: (data) => data.product_tags.map((tag) => ({
1531
+ label: tag.value,
1532
+ value: tag.id
1533
+ }))
1534
+ });
1535
+ const sellers = useComboboxData({
1536
+ queryKey: ["sellers"],
1537
+ queryFn: (params) => sdk.admin.sellers.query(params),
1538
+ getOptions: (data) => data.sellers.map((seller) => ({
1539
+ label: seller.name,
1540
+ value: seller.id
1541
+ }))
1542
+ });
1543
+ return /* @__PURE__ */ jsxs7("div", { id: "organize", className: "flex flex-col gap-y-8", "data-testid": "product-create-organize-section", children: [
1544
+ /* @__PURE__ */ jsx7(Heading4, { "data-testid": "product-create-organize-section-heading", children: t("products.organization.header") }),
1545
+ /* @__PURE__ */ jsx7(
1546
+ SwitchBox,
1547
+ {
1548
+ control: form.control,
1549
+ name: "discountable",
1550
+ label: t("products.fields.discountable.label"),
1551
+ description: t("products.fields.discountable.hint"),
1552
+ optional: true,
1553
+ "data-testid": "product-create-organize-section-discountable-switch"
1554
+ }
1555
+ ),
1556
+ /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-category-collection", children: [
1557
+ /* @__PURE__ */ jsx7(
1558
+ Form.Field,
1559
+ {
1560
+ control: form.control,
1561
+ name: "category_id",
1562
+ render: ({ field }) => {
1563
+ return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-category-item", children: [
1564
+ /* @__PURE__ */ jsx7(Form.Label, { "data-testid": "product-create-organize-section-category-label", children: t("fields.category") }),
1565
+ /* @__PURE__ */ jsx7(Form.Control, { "data-testid": "product-create-organize-section-category-control", children: /* @__PURE__ */ jsx7(
1566
+ SingleCategoryCombobox,
1567
+ {
1568
+ ...field,
1569
+ "data-testid": "product-create-organize-section-category-input"
1570
+ }
1571
+ ) }),
1572
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1573
+ ] });
1574
+ }
1575
+ }
1576
+ ),
1577
+ /* @__PURE__ */ jsx7(
1578
+ Form.Field,
1579
+ {
1580
+ control: form.control,
1581
+ name: "collection_id",
1582
+ render: ({ field }) => {
1583
+ return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-collection-item", children: [
1584
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, "data-testid": "product-create-organize-section-collection-label", children: t("products.fields.collection.label") }),
1585
+ /* @__PURE__ */ jsx7(Form.Control, { "data-testid": "product-create-organize-section-collection-control", children: /* @__PURE__ */ jsx7(
1586
+ Combobox,
1587
+ {
1588
+ ...field,
1589
+ options: collections.options,
1590
+ searchValue: collections.searchValue,
1591
+ onSearchValueChange: collections.onSearchValueChange,
1592
+ fetchNextPage: collections.fetchNextPage,
1593
+ "data-testid": "product-create-organize-section-collection-input"
1594
+ }
1595
+ ) }),
1596
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1597
+ ] });
1598
+ }
1599
+ }
1600
+ )
1601
+ ] }),
1602
+ /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-type-tags", children: [
1603
+ /* @__PURE__ */ jsx7(
1604
+ Form.Field,
1605
+ {
1606
+ control: form.control,
1607
+ name: "type_id",
1608
+ render: ({ field }) => {
1609
+ return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-type-item", children: [
1610
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, "data-testid": "product-create-organize-section-type-label", children: t("products.fields.type.label") }),
1611
+ /* @__PURE__ */ jsx7(Form.Control, { "data-testid": "product-create-organize-section-type-control", children: /* @__PURE__ */ jsx7(
1612
+ Combobox,
1613
+ {
1614
+ ...field,
1615
+ options: types.options,
1616
+ searchValue: types.searchValue,
1617
+ onSearchValueChange: types.onSearchValueChange,
1618
+ fetchNextPage: types.fetchNextPage,
1619
+ "data-testid": "product-create-organize-section-type-input"
1620
+ }
1621
+ ) }),
1622
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1623
+ ] });
1624
+ }
1625
+ }
1626
+ ),
1627
+ /* @__PURE__ */ jsx7(
1628
+ Form.Field,
1629
+ {
1630
+ control: form.control,
1631
+ name: "tags",
1632
+ render: ({ field }) => {
1633
+ return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-tags-item", children: [
1634
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, "data-testid": "product-create-organize-section-tags-label", children: t("products.fields.tags.label") }),
1635
+ /* @__PURE__ */ jsx7(Form.Control, { "data-testid": "product-create-organize-section-tags-control", children: /* @__PURE__ */ jsx7(
1636
+ Combobox,
1637
+ {
1638
+ ...field,
1639
+ options: tags.options,
1640
+ searchValue: tags.searchValue,
1641
+ onSearchValueChange: tags.onSearchValueChange,
1642
+ fetchNextPage: tags.fetchNextPage,
1643
+ "data-testid": "product-create-organize-section-tags-input"
1644
+ }
1645
+ ) }),
1646
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1647
+ ] });
1648
+ }
1649
+ }
1650
+ )
1651
+ ] }),
1652
+ /* @__PURE__ */ jsx7("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-stores", children: /* @__PURE__ */ jsx7(
1653
+ Form.Field,
1654
+ {
1655
+ control: form.control,
1656
+ name: "seller_ids",
1657
+ render: ({ field }) => {
1658
+ return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-stores-item", children: [
1659
+ /* @__PURE__ */ jsx7(Form.Label, { optional: true, "data-testid": "product-create-organize-section-stores-label", children: t("products.fields.stores.label") }),
1660
+ /* @__PURE__ */ jsx7(Form.Control, { "data-testid": "product-create-organize-section-stores-control", children: /* @__PURE__ */ jsx7(
1661
+ Combobox,
1662
+ {
1663
+ ...field,
1664
+ value: field.value ?? [],
1665
+ options: sellers.options,
1666
+ searchValue: sellers.searchValue,
1667
+ onSearchValueChange: sellers.onSearchValueChange,
1668
+ fetchNextPage: sellers.fetchNextPage,
1669
+ "data-testid": "product-create-organize-section-stores-input"
1670
+ }
1671
+ ) }),
1672
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1673
+ ] });
1674
+ }
1675
+ }
1676
+ ) })
1677
+ ] });
1678
+ };
1679
+
1680
+ // src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx
1681
+ import { jsx as jsx8 } from "react/jsx-runtime";
1682
+ var Root3 = () => {
1683
+ return /* @__PURE__ */ jsx8(
1684
+ "div",
1685
+ {
1686
+ className: "flex flex-col items-center p-16",
1687
+ "data-testid": "product-create-organize-form",
1688
+ children: /* @__PURE__ */ jsx8(
1689
+ "div",
1690
+ {
1691
+ className: "flex w-full max-w-[720px] flex-col gap-y-8",
1692
+ "data-testid": "product-create-organize-form-content",
1693
+ children: /* @__PURE__ */ jsx8(ProductCreateOrganizationSection, {})
1694
+ }
1695
+ )
1696
+ }
1697
+ );
1698
+ };
1699
+ Root3._tabMeta = defineTabMeta({
1700
+ id: "organize",
1701
+ labelKey: "products.create.tabs.organize",
1702
+ validationFields: [
1703
+ "type_id",
1704
+ "collection_id",
1705
+ "category_id",
1706
+ "seller_ids",
1707
+ "tags",
1708
+ "origin_country",
1709
+ "material",
1710
+ "width",
1711
+ "length",
1712
+ "height",
1713
+ "weight",
1714
+ "mid_code",
1715
+ "hs_code"
1716
+ ]
1717
+ });
1718
+ var ProductCreateOrganizeForm = Root3;
1719
+
1720
+ // src/pages/products/product-create/components/product-create-variants-form/product-create-variants-form.tsx
1721
+ import { useMemo as useMemo3 } from "react";
1722
+ import { useWatch as useWatch2 } from "react-hook-form";
1723
+ import { useTranslation as useTranslation8 } from "react-i18next";
1724
+ import { jsx as jsx9 } from "react/jsx-runtime";
1725
+ var Root4 = () => {
1726
+ const form = useTabbedForm();
1727
+ const { setCloseOnEscape } = useRouteModal();
1728
+ const variants = useWatch2({
1729
+ control: form.control,
1730
+ name: "variants",
1731
+ defaultValue: []
1732
+ });
1733
+ const watchedAttributes = useWatch2({
1734
+ control: form.control,
1735
+ name: "attributes",
1736
+ defaultValue: []
1737
+ });
1738
+ const variantAxes = useMemo3(() => {
1739
+ return (watchedAttributes ?? []).filter((attr) => attr.use_for_variants && attr.title).map((attr) => ({
1740
+ title: attr.title
1741
+ }));
1742
+ }, [watchedAttributes]);
1743
+ const columns = useColumns2({
1744
+ variantAxes
1745
+ });
1746
+ const variantData = useMemo3(() => {
1747
+ const ret = [];
1748
+ variants.forEach((v, i) => {
1749
+ if (v.should_create) {
1750
+ ret.push({ ...v, originalIndex: i });
1751
+ }
1752
+ });
1753
+ return ret;
1754
+ }, [variants]);
1755
+ return /* @__PURE__ */ jsx9(
1756
+ "div",
1757
+ {
1758
+ className: "flex size-full flex-col divide-y overflow-hidden",
1759
+ "data-testid": "product-create-variants-form",
1760
+ children: /* @__PURE__ */ jsx9("div", { "data-testid": "product-create-variants-form-datagrid", children: /* @__PURE__ */ jsx9(
1761
+ DataGrid,
1762
+ {
1763
+ columns,
1764
+ data: variantData,
1765
+ state: form,
1766
+ onEditingChange: (editing) => setCloseOnEscape(!editing)
1767
+ }
1768
+ ) })
1769
+ }
1770
+ );
1771
+ };
1772
+ Root4._tabMeta = defineTabMeta({
1773
+ id: "variants",
1774
+ labelKey: "products.create.tabs.variants",
1775
+ validationFields: ["variants"]
1776
+ });
1777
+ var ProductCreateVariantsForm = Root4;
1778
+ var columnHelper2 = createDataGridHelper();
1779
+ var useColumns2 = ({
1780
+ variantAxes
1781
+ }) => {
1782
+ const { t } = useTranslation8();
1783
+ return useMemo3(
1784
+ () => [
1785
+ columnHelper2.column({
1786
+ id: "attributes",
1787
+ header: () => /* @__PURE__ */ jsx9("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx9("span", { className: "truncate", children: variantAxes.map((a) => a.title).join(" / ") }) }),
1788
+ cell: (context) => {
1789
+ return /* @__PURE__ */ jsx9(DataGrid.ReadonlyCell, { context, children: variantAxes.map((a) => context.row.original.options?.[a.title]).join(" / ") });
1790
+ },
1791
+ disableHiding: true
1792
+ }),
1793
+ columnHelper2.column({
1794
+ id: "title",
1795
+ name: t("fields.title"),
1796
+ header: t("fields.title"),
1797
+ field: (context) => `variants.${context.row.original.originalIndex}.title`,
1798
+ type: "text",
1799
+ cell: (context) => {
1800
+ return /* @__PURE__ */ jsx9(DataGrid.TextCell, { context });
1801
+ }
1802
+ }),
1803
+ columnHelper2.column({
1804
+ id: "sku",
1805
+ name: t("fields.sku"),
1806
+ header: t("fields.sku"),
1807
+ field: (context) => `variants.${context.row.original.originalIndex}.sku`,
1808
+ type: "text",
1809
+ cell: (context) => {
1810
+ return /* @__PURE__ */ jsx9(DataGrid.TextCell, { context });
1811
+ }
1812
+ })
1813
+ ],
1814
+ [variantAxes, t]
1815
+ );
1816
+ };
1817
+
1818
+ // src/pages/products/product-create/components/product-create-form/product-create-form.tsx
1819
+ import { zodResolver } from "@hookform/resolvers/zod";
1820
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1821
+ var SAVE_DRAFT_BUTTON = "save-draft-button";
1822
+ var ProductCreateForm = ({
1823
+ children,
1824
+ schema,
1825
+ defaultValues: extraDefaults
1826
+ }) => {
1827
+ const { t } = useTranslation9();
1828
+ const { handleSuccess } = useRouteModal();
1829
+ const form = useForm({
1830
+ defaultValues: {
1831
+ ...PRODUCT_CREATE_FORM_DEFAULTS,
1832
+ ...extraDefaults
1833
+ },
1834
+ resolver: zodResolver(schema ?? ProductCreateSchema)
1835
+ });
1836
+ const { mutateAsync, isPending } = useCreateProduct();
1837
+ const {
1838
+ regions,
1839
+ isPending: isRegionsPending,
1840
+ isError: isRegionsError,
1841
+ error: regionsError
1842
+ } = useRegions({ limit: 9999 });
1843
+ if (isRegionsError) {
1844
+ throw regionsError;
1845
+ }
1846
+ const regionsCurrencyMap = useMemo4(() => {
1847
+ if (!regions?.length) {
1848
+ return {};
1849
+ }
1850
+ return regions.reduce(
1851
+ (acc, reg) => {
1852
+ acc[reg.id] = reg.currency_code;
1853
+ return acc;
1854
+ },
1855
+ {}
1856
+ );
1857
+ }, [regions]);
1858
+ const watchedAttributes = useWatch3({
1859
+ control: form.control,
1860
+ name: "attributes"
1861
+ });
1862
+ useEffect3(() => {
1863
+ const currentVariants = form.getValues("variants") ?? [];
1864
+ const newVariants = generateVariantsFromAttributes(
1865
+ watchedAttributes ?? [],
1866
+ currentVariants
1867
+ );
1868
+ if (JSON.stringify(newVariants.map((v) => v.options)) !== JSON.stringify(currentVariants.map((v) => v.options))) {
1869
+ form.setValue("variants", newVariants);
1870
+ }
1871
+ }, [watchedAttributes]);
1872
+ const handleSubmit = form.handleSubmit(async (values, e) => {
1873
+ if (isRegionsPending) {
1874
+ return;
1875
+ }
1876
+ let isDraftSubmission = false;
1877
+ if (e?.nativeEvent instanceof SubmitEvent) {
1878
+ const submitter = e?.nativeEvent?.submitter;
1879
+ isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
1880
+ }
1881
+ const media = values.media || [];
1882
+ const payload = { ...values, media: void 0 };
1883
+ let uploadedMedia = [];
1884
+ try {
1885
+ if (media.length) {
1886
+ const thumbnailReq = media.find((m) => m.isThumbnail);
1887
+ const otherMediaReq = media.filter((m) => !m.isThumbnail);
1888
+ const fileReqs = [];
1889
+ if (thumbnailReq) {
1890
+ fileReqs.push(
1891
+ sdk.admin.uploads.mutate({ files: [thumbnailReq.file] }).then((r) => r.files.map((f) => ({ ...f, isThumbnail: true })))
1892
+ );
1893
+ }
1894
+ if (otherMediaReq?.length) {
1895
+ fileReqs.push(
1896
+ sdk.admin.uploads.mutate({
1897
+ files: otherMediaReq.map((m) => m.file)
1898
+ }).then((r) => r.files.map((f) => ({ ...f, isThumbnail: false })))
1899
+ );
1900
+ }
1901
+ uploadedMedia = (await Promise.all(fileReqs)).flat();
1902
+ }
1903
+ } catch (error) {
1904
+ if (error instanceof Error) {
1905
+ toast.error(error.message);
1906
+ }
1907
+ }
1908
+ await mutateAsync(
1909
+ normalizeProductFormValues({
1910
+ ...payload,
1911
+ media: uploadedMedia,
1912
+ status: isDraftSubmission ? "draft" : "published",
1913
+ regionsCurrencyMap
1914
+ }),
1915
+ {
1916
+ onSuccess: (data) => {
1917
+ toast.success(
1918
+ t("products.create.successToast", {
1919
+ title: data.product.title
1920
+ })
1921
+ );
1922
+ handleSuccess(`../${data.product.id}`);
1923
+ },
1924
+ onError: (error) => {
1925
+ toast.error(error.message);
1926
+ }
1927
+ }
1928
+ );
1929
+ });
1930
+ const defaultTabs = useMemo4(
1931
+ () => [
1932
+ /* @__PURE__ */ jsx10(ProductCreateDetailsForm, {}, "details"),
1933
+ /* @__PURE__ */ jsx10(ProductCreateOrganizeForm, {}, "organize"),
1934
+ /* @__PURE__ */ jsx10(ProductCreateAttributesForm, {}, "attributes"),
1935
+ /* @__PURE__ */ jsx10(ProductCreateVariantsForm, {}, "variants")
1936
+ ],
1937
+ []
1938
+ );
1939
+ const hasCustomChildren = Children.count(children) > 0;
1940
+ return /* @__PURE__ */ jsx10(
1941
+ TabbedForm,
1942
+ {
1943
+ form,
1944
+ onSubmit: handleSubmit,
1945
+ isLoading: isPending || isRegionsPending,
1946
+ footer: ({ isLastTab, onNext, isLoading }) => /* @__PURE__ */ jsxs8(
1947
+ "div",
1948
+ {
1949
+ className: "flex items-center justify-end gap-x-2",
1950
+ "data-testid": "product-create-form-footer-actions",
1951
+ children: [
1952
+ /* @__PURE__ */ jsx10(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx10(
1953
+ Button3,
1954
+ {
1955
+ variant: "secondary",
1956
+ size: "small",
1957
+ "data-testid": "product-create-form-cancel-button",
1958
+ children: t("actions.cancel")
1959
+ }
1960
+ ) }),
1961
+ /* @__PURE__ */ jsx10(
1962
+ Button3,
1963
+ {
1964
+ "data-name": SAVE_DRAFT_BUTTON,
1965
+ size: "small",
1966
+ type: "submit",
1967
+ isLoading,
1968
+ className: "whitespace-nowrap",
1969
+ "data-testid": "product-create-form-save-draft-button",
1970
+ children: t("actions.saveAsDraft")
1971
+ }
1972
+ ),
1973
+ isLastTab ? /* @__PURE__ */ jsx10(
1974
+ Button3,
1975
+ {
1976
+ "data-name": "publish-button",
1977
+ type: "submit",
1978
+ variant: "primary",
1979
+ size: "small",
1980
+ isLoading,
1981
+ "data-testid": "product-create-form-publish-button",
1982
+ children: t("actions.publish")
1983
+ },
1984
+ "submit-button"
1985
+ ) : /* @__PURE__ */ jsx10(
1986
+ Button3,
1987
+ {
1988
+ type: "button",
1989
+ variant: "primary",
1990
+ size: "small",
1991
+ onClick: () => onNext(),
1992
+ "data-testid": "product-create-form-continue-button",
1993
+ children: t("actions.continue")
1994
+ },
1995
+ "next-button"
1996
+ )
1997
+ ]
1998
+ }
1999
+ ),
2000
+ children: hasCustomChildren ? children : defaultTabs
2001
+ }
2002
+ );
2003
+ };
2004
+
2005
+ // src/pages/products/product-create/product-create.tsx
2006
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2007
+ var Root5 = ({ children }) => {
2008
+ const { t } = useTranslation10();
2009
+ const {
2010
+ store,
2011
+ isPending: isStorePending,
2012
+ isError: isStoreError,
2013
+ error: storeError
2014
+ } = useStore({
2015
+ fields: "+default_sales_channel"
2016
+ });
2017
+ const {
2018
+ sales_channel,
2019
+ isPending: isSalesChannelPending,
2020
+ isError: isSalesChannelError,
2021
+ error: salesChannelError
2022
+ } = useSalesChannel(store?.default_sales_channel_id, {
2023
+ enabled: !!store?.default_sales_channel_id
2024
+ });
2025
+ const ready = !!store && !isStorePending && !!sales_channel && !isSalesChannelPending;
2026
+ if (isStoreError) {
2027
+ throw storeError;
2028
+ }
2029
+ if (isSalesChannelError) {
2030
+ throw salesChannelError;
2031
+ }
2032
+ return /* @__PURE__ */ jsxs9(RouteFocusModal, { children: [
2033
+ /* @__PURE__ */ jsx11(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx11("span", { className: "sr-only", children: t("products.create.title") }) }),
2034
+ /* @__PURE__ */ jsx11(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx11("span", { className: "sr-only", children: t("products.create.description") }) }),
2035
+ ready && (Children2.count(children) > 0 ? children : /* @__PURE__ */ jsx11(ProductCreateForm, {}))
2036
+ ] });
2037
+ };
2038
+ var ProductCreate = Root5;
2039
+ var ProductCreatePage = Object.assign(Root5, {
2040
+ Form: ProductCreateForm,
2041
+ DetailsTab: ProductCreateDetailsForm,
2042
+ OrganizeTab: ProductCreateOrganizeForm,
2043
+ AttributesTab: ProductCreateAttributesForm,
2044
+ VariantsTab: ProductCreateVariantsForm,
2045
+ Tab: TabbedForm.Tab
2046
+ });
2047
+
2048
+ export {
2049
+ ProductCreate,
2050
+ ProductCreatePage
2051
+ };