@mercurjs/admin 2.3.7-canary.0 → 2.3.7

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 (120) hide show
  1. package/dist/{add-campaign-promotions-HHMISUZB.js → add-campaign-promotions-6BYWL6AA.js} +1 -1
  2. package/dist/{api-key-management-list-D3W4HEBM.js → api-key-management-list-7L7OLDGO.js} +2 -2
  3. package/dist/{attribute-detail-4B2P7UFG.js → attribute-detail-5AB2NEZE.js} +1 -1
  4. package/dist/{attribute-list-TZH5MVDT.js → attribute-list-QPJM77HR.js} +2 -2
  5. package/dist/{campaign-detail-W57XZ472.js → campaign-detail-VT62HOSX.js} +2 -2
  6. package/dist/{campaign-list-QVXUWMO5.js → campaign-list-4UPMYKLS.js} +2 -2
  7. package/dist/{category-detail-T27AGZ6B.js → category-detail-WM5PKZHS.js} +2 -2
  8. package/dist/{category-list-F6ZFHTGZ.js → category-list-67JSNVXT.js} +2 -2
  9. package/dist/{category-products-UE5Y3VG3.js → category-products-RYOQ5TM5.js} +1 -1
  10. package/dist/{chunk-W76OQ4UW.js → chunk-2D5NZTA6.js} +1 -1
  11. package/dist/chunk-35TFC2OI.js +210 -0
  12. package/dist/{chunk-OIMNVZDF.js → chunk-37GE6N5V.js} +1 -1
  13. package/dist/{chunk-DL3P6W63.js → chunk-4NMCASJ4.js} +1 -1
  14. package/dist/{chunk-OIWWUZDL.js → chunk-64EWPXUL.js} +1 -1
  15. package/dist/{chunk-K6WZ5WW5.js → chunk-66YS5LUL.js} +1 -1
  16. package/dist/{chunk-46WZTQ36.js → chunk-6QXWDLBA.js} +1 -1
  17. package/dist/{chunk-FCV5FSUM.js → chunk-7CNMMPNC.js} +1 -1
  18. package/dist/{chunk-BIL56N3K.js → chunk-7WTDVMPJ.js} +1 -1
  19. package/dist/{chunk-F6OU2QCY.js → chunk-7ZFSINKL.js} +1 -1
  20. package/dist/{chunk-SU36MZXC.js → chunk-AJZPQDDW.js} +12 -4
  21. package/dist/{chunk-DM52HEOD.js → chunk-BJCD2G3U.js} +1 -1
  22. package/dist/{chunk-YIFUH266.js → chunk-BRC3VJXF.js} +1 -1
  23. package/dist/{chunk-EHNOBH5I.js → chunk-CDFZKJSC.js} +1 -1
  24. package/dist/{chunk-AXCRJBUY.js → chunk-D7PXCIZX.js} +1 -1
  25. package/dist/{chunk-EP5CUH4C.js → chunk-FVC2Z3LR.js} +1 -1
  26. package/dist/{chunk-ATZPWIEI.js → chunk-GF4BJFSQ.js} +1 -1
  27. package/dist/{chunk-6A4PFRRO.js → chunk-GIFVQPFT.js} +1 -1
  28. package/dist/{chunk-D2VI737U.js → chunk-IG6ODEES.js} +1 -1
  29. package/dist/{chunk-GMJLK3IK.js → chunk-JOIE6CIR.js} +20 -1
  30. package/dist/{chunk-X6NX7BIG.js → chunk-MXIRZGYW.js} +1 -1
  31. package/dist/{chunk-4CGY6T44.js → chunk-NGYIAHMG.js} +1 -1
  32. package/dist/{chunk-22WJ7M7K.js → chunk-O3JRFTHJ.js} +1 -1
  33. package/dist/{chunk-AR3A6ZV4.js → chunk-O4L5V6TE.js} +1 -1
  34. package/dist/{chunk-6BX43GXE.js → chunk-ODBRDDOZ.js} +1 -1
  35. package/dist/{chunk-YQUS4QOS.js → chunk-OHL76ICJ.js} +1 -1
  36. package/dist/{chunk-BB4C372O.js → chunk-OHTFAHSD.js} +1 -1
  37. package/dist/{chunk-PQJ2KGLD.js → chunk-PFP6ZXLY.js} +2 -2
  38. package/dist/{chunk-AAVL5MJC.js → chunk-PTE652T6.js} +1 -1
  39. package/dist/{chunk-HZ4ADOD4.js → chunk-PTEWKH52.js} +1 -1
  40. package/dist/{chunk-MXMLUPAQ.js → chunk-Q254WWFS.js} +1 -1
  41. package/dist/{chunk-FHZ6TGFK.js → chunk-Q2ZJOBFJ.js} +1 -1
  42. package/dist/{chunk-6HHWBWQS.js → chunk-QHWI5KGN.js} +1 -1
  43. package/dist/{chunk-XZ2I74IZ.js → chunk-QPMAY54N.js} +1 -1
  44. package/dist/{chunk-MBSBOJFI.js → chunk-T3IV6KW3.js} +1 -1
  45. package/dist/{chunk-NRR55ZC2.js → chunk-UUQEZYGA.js} +1 -1
  46. package/dist/{chunk-5R457J2W.js → chunk-V2N6JLWD.js} +1 -1
  47. package/dist/{chunk-WXZYC4LI.js → chunk-V6OUOIBQ.js} +1 -1
  48. package/dist/{chunk-TSYSLFEE.js → chunk-VHO5PEEO.js} +1 -1
  49. package/dist/{chunk-NJAKCRO2.js → chunk-WDTE56OU.js} +1 -1
  50. package/dist/{chunk-AMRK755L.js → chunk-WISQFAJG.js} +177 -176
  51. package/dist/{chunk-CGKIYXZ6.js → chunk-WUCZ7VH3.js} +1 -1
  52. package/dist/{chunk-GOHCQWAJ.js → chunk-Y3P5VQ64.js} +1 -1
  53. package/dist/{chunk-AHRICJVV.js → chunk-YRMMQMSK.js} +1 -1
  54. package/dist/{chunk-TVCHVG2A.js → chunk-YZ7TYYVL.js} +1 -1
  55. package/dist/{chunk-J7FYKWJU.js → chunk-ZCPG6OV7.js} +1 -1
  56. package/dist/{chunk-R7LXMTIT.js → chunk-ZPKQWWCF.js} +2 -2
  57. package/dist/{chunk-QE36PNTV.js → chunk-ZQMCTQ2T.js} +1 -1
  58. package/dist/{collection-add-products-VNSPLNGL.js → collection-add-products-YQP5YOZO.js} +1 -1
  59. package/dist/{collection-detail-2XGAQMMS.js → collection-detail-IQV54EVJ.js} +2 -2
  60. package/dist/{collection-list-D23O4C7N.js → collection-list-Z7IA57OF.js} +2 -2
  61. package/dist/{commissions-list-ENJJOKHU.js → commissions-list-4MRDFAN6.js} +2 -2
  62. package/dist/{customer-detail-DROF3TFM.js → customer-detail-KOWSLCSV.js} +4 -3
  63. package/dist/{customer-group-add-customers-BRAX5VEC.js → customer-group-add-customers-KF432FE3.js} +1 -1
  64. package/dist/{customer-group-detail-7SRN7XGR.js → customer-group-detail-KYEP2WK5.js} +2 -2
  65. package/dist/{customer-group-list-3UV4JFIC.js → customer-group-list-GOAFY7WR.js} +2 -2
  66. package/dist/{customer-list-IF5HB6CU.js → customer-list-NVJX3U6Z.js} +2 -2
  67. package/dist/{customers-add-customer-group-7XSK3ZI6.js → customers-add-customer-group-CAPDOFBQ.js} +1 -1
  68. package/dist/index.d.ts +7 -0
  69. package/dist/index.js +86 -86
  70. package/dist/{inventory-detail-YMY427YA.js → inventory-detail-5MBZ3WUH.js} +2 -2
  71. package/dist/{inventory-list-RNA7PFS5.js → inventory-list-PUHEUY6U.js} +2 -2
  72. package/dist/{location-fulfillment-providers-RI6OE65I.js → location-fulfillment-providers-RHFROGUA.js} +1 -1
  73. package/dist/{location-service-zone-create-Y3QEVCV2.js → location-service-zone-create-76EAFAJQ.js} +2 -2
  74. package/dist/{location-service-zone-manage-areas-7GT26QCN.js → location-service-zone-manage-areas-AU6O2R7D.js} +2 -2
  75. package/dist/{marketplace-add-currencies-2LCP4XJV.js → marketplace-add-currencies-LP54QP2F.js} +1 -1
  76. package/dist/{marketplace-detail-J7GVUZ7T.js → marketplace-detail-XIWEU2BP.js} +2 -2
  77. package/dist/{offer-detail-page-3H5APJUL.js → offer-detail-page-XNA63LSW.js} +2 -2
  78. package/dist/{offer-variant-detail-page-V6MP4SDN.js → offer-variant-detail-page-UATB4UIF.js} +2 -2
  79. package/dist/{offers-V4LY624Q.js → offers-3VVLBXXT.js} +1 -1
  80. package/dist/{order-create-claim-HRKNY4UI.js → order-create-claim-SA7G3BF7.js} +1 -1
  81. package/dist/{order-create-edit-LRHRGV4I.js → order-create-edit-MTLZ4MH6.js} +1 -1
  82. package/dist/{order-create-exchange-O23CVHIT.js → order-create-exchange-EY5GJP46.js} +1 -1
  83. package/dist/{order-create-return-R7YVDNVA.js → order-create-return-A7F4OQUD.js} +1 -1
  84. package/dist/{order-detail-56D3JKHO.js → order-detail-RJFKE5JR.js} +2 -2
  85. package/dist/{order-list-WJBA7YQN.js → order-list-V5SXVY4C.js} +4 -3
  86. package/dist/pages/index.js +45 -45
  87. package/dist/{payout-list-RYMCSVCT.js → payout-list-J5QBFBDQ.js} +2 -2
  88. package/dist/{price-list-create-UM63JWQQ.js → price-list-create-M7DT7DIB.js} +2 -2
  89. package/dist/{price-list-detail-G74QPX4O.js → price-list-detail-K5GT75MR.js} +2 -2
  90. package/dist/{price-list-list-IRVQYOHC.js → price-list-list-RVA2BXQB.js} +2 -2
  91. package/dist/{price-list-prices-add-H2MEQ2QR.js → price-list-prices-add-MNDRESKR.js} +2 -2
  92. package/dist/{product-create-WNSDDRLU.js → product-create-UZOSX5CO.js} +3 -3
  93. package/dist/{product-detail-3BCNKITT.js → product-detail-P5TG7T7B.js} +2 -2
  94. package/dist/{product-list-7CP6FHMX.js → product-list-YDYL765G.js} +2 -2
  95. package/dist/{product-media-SHV2VX7L.js → product-media-K2EC5Z2P.js} +1 -1
  96. package/dist/{product-tag-detail-LIAIYUDS.js → product-tag-detail-VJW4TMI6.js} +2 -2
  97. package/dist/{product-tag-list-BHRUK7QW.js → product-tag-list-ZF44FBU3.js} +2 -2
  98. package/dist/{product-type-detail-2K3HSKEC.js → product-type-detail-O5MQCKY2.js} +2 -2
  99. package/dist/{product-type-list-QA4OOOCL.js → product-type-list-B6RRMREU.js} +2 -2
  100. package/dist/{promotion-list-FXWF6U3M.js → promotion-list-AKK3OZJO.js} +2 -2
  101. package/dist/{region-add-countries-DV54R2PN.js → region-add-countries-IA2HWUQX.js} +1 -1
  102. package/dist/{region-create-CJM7NXOM.js → region-create-HRJDZSAK.js} +1 -1
  103. package/dist/{region-detail-3RF2GD3W.js → region-detail-UDNWHURY.js} +2 -2
  104. package/dist/{region-list-3QKAMIKS.js → region-list-QQ3XRZBU.js} +2 -2
  105. package/dist/{reservation-list-X4C45DYL.js → reservation-list-FJEIO3S2.js} +2 -2
  106. package/dist/{return-reason-list-OKMBV3IZ.js → return-reason-list-3PS25BKE.js} +2 -2
  107. package/dist/{review-list-M7LNFCKQ.js → review-list-TWXSIZOP.js} +2 -2
  108. package/dist/{sales-channel-add-products-Q6TSFJKU.js → sales-channel-add-products-KC4RYJT3.js} +1 -1
  109. package/dist/{sales-channel-detail-IISFMMEN.js → sales-channel-detail-2NIKTQNB.js} +2 -2
  110. package/dist/{shipping-option-type-list-TR3OGBEP.js → shipping-option-type-list-SC3AKZ3A.js} +2 -2
  111. package/dist/{shipping-profiles-list-WJI2DCLN.js → shipping-profiles-list-OC45TR2L.js} +2 -2
  112. package/dist/{store-details-GR4XNG6J.js → store-details-CGAKQDWN.js} +2 -2
  113. package/dist/{store-edit-JMRDCFIC.js → store-edit-XBWOY5CE.js} +1 -1
  114. package/dist/{store-list-6UMZQV5N.js → store-list-7FX5VPU2.js} +2 -2
  115. package/dist/{tax-region-tax-override-create-WPCZ47CE.js → tax-region-tax-override-create-5FUN3FYU.js} +2 -2
  116. package/dist/{tax-region-tax-override-edit-O5CTVPCG.js → tax-region-tax-override-edit-AGHJ76KK.js} +2 -2
  117. package/dist/{user-invite-S3SL2HJF.js → user-invite-DMUC4EQ4.js} +1 -1
  118. package/dist/{user-list-7P2ZSQGM.js → user-list-ZK63T6SJ.js} +2 -2
  119. package/package.json +6 -6
  120. package/dist/chunk-W7TEZYU7.js +0 -98
@@ -21,7 +21,7 @@ import {
21
21
  import {
22
22
  _DataTable,
23
23
  useDataTable
24
- } from "./chunk-SU36MZXC.js";
24
+ } from "./chunk-AJZPQDDW.js";
25
25
  import {
26
26
  ActionMenu
27
27
  } from "./chunk-3UOYBH5O.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  _DataTable,
15
15
  useDataTable
16
- } from "./chunk-SU36MZXC.js";
16
+ } from "./chunk-AJZPQDDW.js";
17
17
  import {
18
18
  ActionMenu
19
19
  } from "./chunk-3UOYBH5O.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useOrderGroupTableFilters
3
- } from "./chunk-W7TEZYU7.js";
3
+ } from "./chunk-35TFC2OI.js";
4
4
  import {
5
5
  useOrderTableQuery
6
6
  } from "./chunk-QUHSHIAC.js";
@@ -27,7 +27,7 @@ import {
27
27
  import {
28
28
  _DataTable,
29
29
  useDataTable
30
- } from "./chunk-SU36MZXC.js";
30
+ } from "./chunk-AJZPQDDW.js";
31
31
  import {
32
32
  useOrderGroups
33
33
  } from "./chunk-37XW63IZ.js";
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  _DataTable,
13
13
  useDataTable
14
- } from "./chunk-SU36MZXC.js";
14
+ } from "./chunk-AJZPQDDW.js";
15
15
  import {
16
16
  ActionMenu
17
17
  } from "./chunk-3UOYBH5O.js";
@@ -16,7 +16,7 @@ import {
16
16
  import {
17
17
  _DataTable,
18
18
  useDataTable
19
- } from "./chunk-SU36MZXC.js";
19
+ } from "./chunk-AJZPQDDW.js";
20
20
  import {
21
21
  ActionMenu
22
22
  } from "./chunk-3UOYBH5O.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  _DataTable,
15
15
  useDataTable
16
- } from "./chunk-SU36MZXC.js";
16
+ } from "./chunk-AJZPQDDW.js";
17
17
  import {
18
18
  ActionMenu
19
19
  } from "./chunk-3UOYBH5O.js";
@@ -17,7 +17,7 @@ import {
17
17
  import {
18
18
  _DataTable,
19
19
  useDataTable
20
- } from "./chunk-SU36MZXC.js";
20
+ } from "./chunk-AJZPQDDW.js";
21
21
  import {
22
22
  ActionMenu
23
23
  } from "./chunk-3UOYBH5O.js";
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  _DataTable,
20
20
  useDataTable
21
- } from "./chunk-SU36MZXC.js";
21
+ } from "./chunk-AJZPQDDW.js";
22
22
  import {
23
23
  ActionMenu
24
24
  } from "./chunk-3UOYBH5O.js";
@@ -41,7 +41,7 @@ import {
41
41
  import {
42
42
  _DataTable,
43
43
  useDataTable
44
- } from "./chunk-SU36MZXC.js";
44
+ } from "./chunk-AJZPQDDW.js";
45
45
  import {
46
46
  useProductTypes
47
47
  } from "./chunk-MD27DYVZ.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  _DataTable,
15
15
  useDataTable
16
- } from "./chunk-SU36MZXC.js";
16
+ } from "./chunk-AJZPQDDW.js";
17
17
  import {
18
18
  ActionMenu
19
19
  } from "./chunk-3UOYBH5O.js";
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  _DataTable,
13
13
  useDataTable
14
- } from "./chunk-SU36MZXC.js";
14
+ } from "./chunk-AJZPQDDW.js";
15
15
  import {
16
16
  ActionMenu
17
17
  } from "./chunk-3UOYBH5O.js";
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  _DataTable,
22
22
  useDataTable
23
- } from "./chunk-SU36MZXC.js";
23
+ } from "./chunk-AJZPQDDW.js";
24
24
  import {
25
25
  ActionMenu
26
26
  } from "./chunk-3UOYBH5O.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  _DataTable,
15
15
  useDataTable
16
- } from "./chunk-SU36MZXC.js";
16
+ } from "./chunk-AJZPQDDW.js";
17
17
  import {
18
18
  ActionMenu
19
19
  } from "./chunk-3UOYBH5O.js";
@@ -30,7 +30,7 @@ import {
30
30
  import {
31
31
  _DataTable,
32
32
  useDataTable
33
- } from "./chunk-SU36MZXC.js";
33
+ } from "./chunk-AJZPQDDW.js";
34
34
  import {
35
35
  useBatchPriceListPrices,
36
36
  usePriceList
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  _DataTable,
9
9
  useDataTable
10
- } from "./chunk-SU36MZXC.js";
10
+ } from "./chunk-AJZPQDDW.js";
11
11
  import {
12
12
  ActionMenu
13
13
  } from "./chunk-3UOYBH5O.js";
@@ -8,9 +8,9 @@ import {
8
8
  PRODUCT_CREATE_FORM_DEFAULTS,
9
9
  ProductCreateSchema,
10
10
  decorateVariantsWithDefaultValues,
11
- generateVariantsFromAttributes,
12
- normalizeProductFormValues
13
- } from "./chunk-GMJLK3IK.js";
11
+ normalizeProductFormValues,
12
+ subscribeVariantsToAttributes
13
+ } from "./chunk-JOIE6CIR.js";
14
14
  import {
15
15
  HandleInput
16
16
  } from "./chunk-HJ56YXBU.js";
@@ -65,7 +65,7 @@ import {
65
65
  import {
66
66
  _DataTable,
67
67
  useDataTable
68
- } from "./chunk-SU36MZXC.js";
68
+ } from "./chunk-AJZPQDDW.js";
69
69
  import {
70
70
  ActionMenu
71
71
  } from "./chunk-3UOYBH5O.js";
@@ -99,7 +99,7 @@ import { useCan as useCan4 } from "@mercurjs/dashboard-shared";
99
99
  // src/pages/products/product-create/components/product-create-form/product-create-form.tsx
100
100
  import { Button as Button3, toast } from "@medusajs/ui";
101
101
  import { useEffect as useEffect3, useMemo as useMemo4, Children } from "react";
102
- import { useForm, useWatch as useWatch4 } from "react-hook-form";
102
+ import { useForm } from "react-hook-form";
103
103
  import { useTranslation as useTranslation9 } from "react-i18next";
104
104
  import { isForbidden as isForbidden2, useCan as useCan3 } from "@mercurjs/dashboard-shared";
105
105
 
@@ -123,7 +123,8 @@ import {
123
123
  import { useEffect as useEffect2 } from "react";
124
124
  import {
125
125
  Controller,
126
- useFieldArray
126
+ useFieldArray,
127
+ useWatch
127
128
  } from "react-hook-form";
128
129
  import { useTranslation as useTranslation2 } from "react-i18next";
129
130
 
@@ -461,137 +462,16 @@ var Root = () => {
461
462
  {
462
463
  className: "flex flex-col gap-y-4",
463
464
  "data-testid": "product-create-attributes-list",
464
- children: fields.map((field, index) => {
465
- if (!field.is_custom) return null;
466
- const useForVariants = form.watch(
467
- `attributes.${index}.use_for_variants`
468
- );
469
- return /* @__PURE__ */ jsxs2(
470
- "li",
465
+ children: fields.map(
466
+ (field, index) => field.is_custom ? /* @__PURE__ */ jsx2(
467
+ CustomAttributeRow,
471
468
  {
472
- className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
473
- "data-testid": `product-create-attribute-row-${index}`,
474
- children: [
475
- /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
476
- /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
477
- Label,
478
- {
479
- size: "xsmall",
480
- weight: "plus",
481
- className: "text-ui-fg-subtle",
482
- htmlFor: `attributes.${index}.title`,
483
- children: t("fields.title")
484
- }
485
- ) }),
486
- /* @__PURE__ */ jsx2(
487
- Input,
488
- {
489
- className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
490
- ...form.register(
491
- `attributes.${index}.title`
492
- ),
493
- placeholder: t(
494
- "products.create.attributes.titlePlaceholder"
495
- ),
496
- "data-testid": `product-create-attribute-title-${index}`
497
- }
498
- ),
499
- /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
500
- Label,
501
- {
502
- size: "xsmall",
503
- weight: "plus",
504
- className: "text-ui-fg-subtle",
505
- htmlFor: `attributes.${index}.values`,
506
- children: t("fields.values")
507
- }
508
- ) }),
509
- /* @__PURE__ */ jsx2(
510
- Controller,
511
- {
512
- control: form.control,
513
- name: `attributes.${index}.values`,
514
- render: ({ field: { onChange, value, ...field2 } }) => useForVariants ? /* @__PURE__ */ jsx2(
515
- ChipInput,
516
- {
517
- ...field2,
518
- variant: "contrast",
519
- value: Array.isArray(value) ? value : [],
520
- onChange,
521
- placeholder: t(
522
- "products.create.attributes.valuePlaceholder"
523
- ),
524
- "data-testid": `product-create-attribute-values-${index}`
525
- }
526
- ) : /* @__PURE__ */ jsx2(
527
- Textarea,
528
- {
529
- ...field2,
530
- className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
531
- value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
532
- onChange: (e) => onChange(e.target.value),
533
- placeholder: t(
534
- "products.create.attributes.valuePlaceholder"
535
- ),
536
- "data-testid": `product-create-attribute-values-${index}`
537
- }
538
- )
539
- }
540
- ),
541
- /* @__PURE__ */ jsx2("div", {}),
542
- /* @__PURE__ */ jsx2(
543
- Form.Field,
544
- {
545
- control: form.control,
546
- name: `attributes.${index}.use_for_variants`,
547
- render: ({
548
- field: { value, onChange, ref }
549
- }) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2(
550
- "div",
551
- {
552
- className: "flex items-start gap-x-3 py-1.5",
553
- "data-testid": `product-create-attribute-use-for-variants-${index}`,
554
- children: [
555
- /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
556
- Switch,
557
- {
558
- ref,
559
- className: "shrink-0 rtl:rotate-180",
560
- checked: value,
561
- onCheckedChange: onChange
562
- }
563
- ) }),
564
- /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
565
- /* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t(
566
- "products.create.attributes.useForVariants"
567
- ) }),
568
- /* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
569
- "products.create.attributes.useForVariantsDescription"
570
- ) })
571
- ] })
572
- ]
573
- }
574
- ) })
575
- }
576
- )
577
- ] }),
578
- /* @__PURE__ */ jsx2(
579
- IconButton,
580
- {
581
- type: "button",
582
- size: "small",
583
- variant: "transparent",
584
- className: "text-ui-fg-muted",
585
- onClick: () => remove(index),
586
- "data-testid": `product-create-attribute-remove-${index}`,
587
- children: /* @__PURE__ */ jsx2(XMarkMini, {})
588
- }
589
- )
590
- ]
469
+ index,
470
+ remove
591
471
  },
592
472
  field.id
593
- );
594
- })
473
+ ) : null
474
+ )
595
475
  }
596
476
  ),
597
477
  /* @__PURE__ */ jsx2(RequiredAttributes, {})
@@ -600,6 +480,141 @@ var Root = () => {
600
480
  }
601
481
  );
602
482
  };
483
+ var CustomAttributeRow = ({
484
+ index,
485
+ remove
486
+ }) => {
487
+ const { t } = useTranslation2();
488
+ const form = useTabbedForm();
489
+ const useForVariants = useWatch({
490
+ control: form.control,
491
+ name: `attributes.${index}.use_for_variants`
492
+ });
493
+ return /* @__PURE__ */ jsxs2(
494
+ "li",
495
+ {
496
+ className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
497
+ "data-testid": `product-create-attribute-row-${index}`,
498
+ children: [
499
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
500
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
501
+ Label,
502
+ {
503
+ size: "xsmall",
504
+ weight: "plus",
505
+ className: "text-ui-fg-subtle",
506
+ htmlFor: `attributes.${index}.title`,
507
+ children: t("fields.title")
508
+ }
509
+ ) }),
510
+ /* @__PURE__ */ jsx2(
511
+ Input,
512
+ {
513
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
514
+ ...form.register(
515
+ `attributes.${index}.title`
516
+ ),
517
+ placeholder: t(
518
+ "products.create.attributes.titlePlaceholder"
519
+ ),
520
+ "data-testid": `product-create-attribute-title-${index}`
521
+ }
522
+ ),
523
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
524
+ Label,
525
+ {
526
+ size: "xsmall",
527
+ weight: "plus",
528
+ className: "text-ui-fg-subtle",
529
+ htmlFor: `attributes.${index}.values`,
530
+ children: t("fields.values")
531
+ }
532
+ ) }),
533
+ /* @__PURE__ */ jsx2(
534
+ Controller,
535
+ {
536
+ control: form.control,
537
+ name: `attributes.${index}.values`,
538
+ render: ({ field: { onChange, value, ...field } }) => useForVariants ? /* @__PURE__ */ jsx2(
539
+ ChipInput,
540
+ {
541
+ ...field,
542
+ variant: "contrast",
543
+ value: Array.isArray(value) ? value : [],
544
+ onChange,
545
+ placeholder: t(
546
+ "products.create.attributes.valuePlaceholder"
547
+ ),
548
+ "data-testid": `product-create-attribute-values-${index}`
549
+ }
550
+ ) : /* @__PURE__ */ jsx2(
551
+ Textarea,
552
+ {
553
+ ...field,
554
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
555
+ value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
556
+ onChange: (e) => onChange(e.target.value),
557
+ placeholder: t(
558
+ "products.create.attributes.valuePlaceholder"
559
+ ),
560
+ "data-testid": `product-create-attribute-values-${index}`
561
+ }
562
+ )
563
+ }
564
+ ),
565
+ /* @__PURE__ */ jsx2("div", {}),
566
+ /* @__PURE__ */ jsx2(
567
+ Form.Field,
568
+ {
569
+ control: form.control,
570
+ name: `attributes.${index}.use_for_variants`,
571
+ render: ({
572
+ field: { value, onChange, ref }
573
+ }) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2(
574
+ "div",
575
+ {
576
+ className: "flex items-start gap-x-3 py-1.5",
577
+ "data-testid": `product-create-attribute-use-for-variants-${index}`,
578
+ children: [
579
+ /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
580
+ Switch,
581
+ {
582
+ ref,
583
+ className: "shrink-0 rtl:rotate-180",
584
+ checked: value,
585
+ onCheckedChange: onChange
586
+ }
587
+ ) }),
588
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
589
+ /* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t(
590
+ "products.create.attributes.useForVariants"
591
+ ) }),
592
+ /* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
593
+ "products.create.attributes.useForVariantsDescription"
594
+ ) })
595
+ ] })
596
+ ]
597
+ }
598
+ ) })
599
+ }
600
+ )
601
+ ] }),
602
+ /* @__PURE__ */ jsx2(
603
+ IconButton,
604
+ {
605
+ type: "button",
606
+ size: "small",
607
+ variant: "transparent",
608
+ className: "text-ui-fg-muted",
609
+ onClick: () => remove(index),
610
+ "data-testid": `product-create-attribute-remove-${index}`,
611
+ children: /* @__PURE__ */ jsx2(XMarkMini, {})
612
+ }
613
+ )
614
+ ]
615
+ }
616
+ );
617
+ };
603
618
  var SelectedAttributes = ({
604
619
  fields,
605
620
  remove
@@ -1350,7 +1365,7 @@ import {
1350
1365
  Label as Label2,
1351
1366
  Text as Text3
1352
1367
  } from "@medusajs/ui";
1353
- import { useFieldArray as useFieldArray3, useWatch } from "react-hook-form";
1368
+ import { useFieldArray as useFieldArray3, useWatch as useWatch2 } from "react-hook-form";
1354
1369
  import { useTranslation as useTranslation5 } from "react-i18next";
1355
1370
  import { useMemo as useMemo2 } from "react";
1356
1371
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
@@ -1361,12 +1376,12 @@ var ProductCreateVariantsSection = () => {
1361
1376
  control: form.control,
1362
1377
  name: "variants"
1363
1378
  });
1364
- const watchedAttributes = useWatch({
1379
+ const watchedAttributes = useWatch2({
1365
1380
  control: form.control,
1366
1381
  name: "attributes",
1367
1382
  defaultValue: []
1368
1383
  });
1369
- const watchedVariants = useWatch({
1384
+ const watchedVariants = useWatch2({
1370
1385
  control: form.control,
1371
1386
  name: "variants",
1372
1387
  defaultValue: []
@@ -1571,7 +1586,7 @@ var Header = () => {
1571
1586
  // src/pages/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
1572
1587
  import { usePermissionGate } from "@mercurjs/dashboard-shared";
1573
1588
  import { Heading as Heading4 } from "@medusajs/ui";
1574
- import { useWatch as useWatch2 } from "react-hook-form";
1589
+ import { useWatch as useWatch3 } from "react-hook-form";
1575
1590
  import { useTranslation as useTranslation7 } from "react-i18next";
1576
1591
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1577
1592
  var ProductCreateOrganizationSection = () => {
@@ -1617,7 +1632,7 @@ var ProductCreateOrganizationSection = () => {
1617
1632
  })),
1618
1633
  enabled: sellersGate.allowed
1619
1634
  });
1620
- const isGloballyAvailable = useWatch2({
1635
+ const isGloballyAvailable = useWatch3({
1621
1636
  control: form.control,
1622
1637
  name: "globally_available"
1623
1638
  });
@@ -1847,7 +1862,7 @@ var ProductCreateOrganizeForm = Root3;
1847
1862
  // src/pages/products/product-create/components/product-create-variants-form/product-create-variants-form.tsx
1848
1863
  import { Input as Input3 } from "@medusajs/ui";
1849
1864
  import { useMemo as useMemo3, useState as useState3 } from "react";
1850
- import { useWatch as useWatch3 } from "react-hook-form";
1865
+ import { useWatch as useWatch4 } from "react-hook-form";
1851
1866
  import { useTranslation as useTranslation8 } from "react-i18next";
1852
1867
  import { jsx as jsx9 } from "react/jsx-runtime";
1853
1868
  var Root4 = () => {
@@ -1855,12 +1870,12 @@ var Root4 = () => {
1855
1870
  const form = useTabbedForm();
1856
1871
  const { setCloseOnEscape } = useRouteModal();
1857
1872
  const [search, setSearch] = useState3("");
1858
- const variants = useWatch3({
1873
+ const variants = useWatch4({
1859
1874
  control: form.control,
1860
1875
  name: "variants",
1861
1876
  defaultValue: []
1862
1877
  });
1863
- const watchedAttributes = useWatch3({
1878
+ const watchedAttributes = useWatch4({
1864
1879
  control: form.control,
1865
1880
  name: "attributes",
1866
1881
  defaultValue: []
@@ -2021,20 +2036,7 @@ var ProductCreateForm = ({
2021
2036
  {}
2022
2037
  );
2023
2038
  }, [regions]);
2024
- const watchedAttributes = useWatch4({
2025
- control: form.control,
2026
- name: "attributes"
2027
- });
2028
- useEffect3(() => {
2029
- const currentVariants = form.getValues("variants") ?? [];
2030
- const newVariants = generateVariantsFromAttributes(
2031
- watchedAttributes ?? [],
2032
- currentVariants
2033
- );
2034
- if (JSON.stringify(newVariants.map((v) => v.options)) !== JSON.stringify(currentVariants.map((v) => v.options))) {
2035
- form.setValue("variants", newVariants);
2036
- }
2037
- }, [watchedAttributes, form]);
2039
+ useEffect3(() => subscribeVariantsToAttributes(form), [form]);
2038
2040
  const handleSubmit = form.handleSubmit(async (values, e) => {
2039
2041
  if (isRegionsPending) {
2040
2042
  return;
@@ -2071,27 +2073,26 @@ var ProductCreateForm = ({
2071
2073
  toast.error(error.message);
2072
2074
  }
2073
2075
  }
2074
- await mutateAsync(
2075
- normalizeProductFormValues({
2076
- ...payload,
2077
- media: uploadedMedia,
2078
- status: isDraftSubmission ? "draft" : "published",
2079
- regionsCurrencyMap
2080
- }),
2081
- {
2082
- onSuccess: (data) => {
2083
- toast.success(
2084
- t("products.create.successToast", {
2085
- title: data.product.title
2086
- })
2087
- );
2088
- handleSuccess(`../${data.product.id}`);
2089
- },
2090
- onError: (error) => {
2091
- toast.error(error.message);
2092
- }
2076
+ try {
2077
+ const data = await mutateAsync(
2078
+ normalizeProductFormValues({
2079
+ ...payload,
2080
+ media: uploadedMedia,
2081
+ status: isDraftSubmission ? "draft" : "published",
2082
+ regionsCurrencyMap
2083
+ })
2084
+ );
2085
+ toast.success(
2086
+ t("products.create.successToast", {
2087
+ title: data.product.title
2088
+ })
2089
+ );
2090
+ handleSuccess(`../${data.product.id}`);
2091
+ } catch (error) {
2092
+ if (error instanceof Error) {
2093
+ toast.error(error.message);
2093
2094
  }
2094
- );
2095
+ }
2095
2096
  });
2096
2097
  const defaultTabs = useMemo4(
2097
2098
  () => [
@@ -29,7 +29,7 @@ import {
29
29
  import {
30
30
  _DataTable,
31
31
  useDataTable
32
- } from "./chunk-SU36MZXC.js";
32
+ } from "./chunk-AJZPQDDW.js";
33
33
  import {
34
34
  ActionMenu
35
35
  } from "./chunk-3UOYBH5O.js";
@@ -78,7 +78,7 @@ import {
78
78
  import {
79
79
  _DataTable,
80
80
  useDataTable
81
- } from "./chunk-SU36MZXC.js";
81
+ } from "./chunk-AJZPQDDW.js";
82
82
  import {
83
83
  useDate
84
84
  } from "./chunk-EIWPJWKF.js";
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  _DataTable,
12
12
  useDataTable
13
- } from "./chunk-SU36MZXC.js";
13
+ } from "./chunk-AJZPQDDW.js";
14
14
  import {
15
15
  ActionMenu
16
16
  } from "./chunk-3UOYBH5O.js";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  _DataTable,
9
9
  useDataTable
10
- } from "./chunk-SU36MZXC.js";
10
+ } from "./chunk-AJZPQDDW.js";
11
11
  import {
12
12
  NoRecords
13
13
  } from "./chunk-4J74G7N2.js";
@@ -22,7 +22,7 @@ import {
22
22
  import {
23
23
  _DataTable,
24
24
  useDataTable
25
- } from "./chunk-SU36MZXC.js";
25
+ } from "./chunk-AJZPQDDW.js";
26
26
  import {
27
27
  ActionMenu
28
28
  } from "./chunk-3UOYBH5O.js";