@medusajs/dashboard 3.0.0-snapshot-20251214110905 → 3.0.0-snapshot-20251215162333
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.
- package/dist/{adjust-inventory-I5VYMAI4.mjs → adjust-inventory-26YXAXQL.mjs} +2 -1
- package/dist/{api-key-management-create-CVRFY4PL.mjs → api-key-management-create-EMP32G2D.mjs} +4 -3
- package/dist/{api-key-management-detail-HRVP6HRC.mjs → api-key-management-detail-NRGL7HHX.mjs} +11 -10
- package/dist/{api-key-management-edit-JMU3WEPX.mjs → api-key-management-edit-IBM3ZXHK.mjs} +4 -3
- package/dist/{api-key-management-list-RGLZMUCB.mjs → api-key-management-list-LJSWRAGE.mjs} +4 -3
- package/dist/{api-key-management-sales-channels-4OU5VGIG.mjs → api-key-management-sales-channels-3GRNDBZ4.mjs} +4 -3
- package/dist/app.css +3 -0
- package/dist/app.js +1085 -835
- package/dist/app.mjs +12 -11
- package/dist/{campaign-detail-BDI3P2SF.mjs → campaign-detail-22Q6XWGL.mjs} +11 -10
- package/dist/{categories-metadata-BARTITD5.mjs → categories-metadata-J7M3XWI7.mjs} +11 -10
- package/dist/{category-create-L2KJCHPO.mjs → category-create-KHJZSC7G.mjs} +3 -2
- package/dist/{category-detail-CUMEBNXU.mjs → category-detail-RRKJPMEG.mjs} +13 -12
- package/dist/{category-edit-U6SLZSAX.mjs → category-edit-CTA2EPDG.mjs} +3 -2
- package/dist/{category-list-W7JW4PWA.mjs → category-list-4HZP4FRE.mjs} +4 -3
- package/dist/{category-organize-LLSVAO3U.mjs → category-organize-SXP33XET.mjs} +3 -2
- package/dist/{category-products-GYXTDDBQ.mjs → category-products-EFZRTCSF.mjs} +12 -11
- package/dist/{chunk-XIVBRONM.mjs → chunk-23GTCEOV.mjs} +1 -1
- package/dist/{chunk-N3FCYZV6.mjs → chunk-2XTBDCGE.mjs} +1 -1
- package/dist/{chunk-DS5IRNJY.mjs → chunk-32FPYJ3S.mjs} +1 -1
- package/dist/{chunk-FPBKWWSI.mjs → chunk-43X7ZR3P.mjs} +1 -1
- package/dist/{chunk-RU4ZS47V.mjs → chunk-4JQR6QNW.mjs} +2 -2
- package/dist/{chunk-Z6NHG5LQ.mjs → chunk-6P4Q4AAP.mjs} +3 -3
- package/dist/{chunk-F5NZDW7L.mjs → chunk-A2WBKOXJ.mjs} +2 -2
- package/dist/{chunk-F63F3FIT.mjs → chunk-A4XYK3MY.mjs} +2 -2
- package/dist/{chunk-NT6C7CHT.mjs → chunk-AWRCV3ME.mjs} +1 -1
- package/dist/{chunk-5X6SKB2P.mjs → chunk-BMS2QLJY.mjs} +1 -1
- package/dist/{chunk-67KHYLIQ.mjs → chunk-DK7IWUMK.mjs} +3 -3
- package/dist/{chunk-FEB3ZGTL.mjs → chunk-DNUVCBN7.mjs} +159 -5
- package/dist/{chunk-N4O5FAUC.mjs → chunk-FYWHE3W5.mjs} +1 -1
- package/dist/{chunk-HKKZJTRO.mjs → chunk-GRZSG4EP.mjs} +89 -34
- package/dist/chunk-HGRIOEAR.mjs +32 -0
- package/dist/{chunk-Y5UO73CH.mjs → chunk-HTCYX4VD.mjs} +1 -1
- package/dist/{chunk-34KFHPN6.mjs → chunk-IAV7IKJ6.mjs} +1 -1
- package/dist/{chunk-3BJLNORD.mjs → chunk-KQ4LC2YV.mjs} +1 -1
- package/dist/{chunk-GC3QXC6D.mjs → chunk-OHY2N2Q4.mjs} +4 -4
- package/dist/{chunk-7AX6R6G6.mjs → chunk-OSHH5GAS.mjs} +13 -1
- package/dist/{chunk-PXZEQZ6Q.mjs → chunk-PHLCT2HA.mjs} +1 -1
- package/dist/{chunk-35LSPN2U.mjs → chunk-QKALAT7P.mjs} +1 -1
- package/dist/{chunk-BBTE6VKD.mjs → chunk-RL5EYTP6.mjs} +1 -1
- package/dist/{chunk-B3AOQW2B.mjs → chunk-U6G4M5LP.mjs} +1 -1
- package/dist/{chunk-HKIF5HVL.mjs → chunk-UJ2TMPV4.mjs} +12 -0
- package/dist/{chunk-NHDFPGQ3.mjs → chunk-UWY5ZV66.mjs} +13 -1
- package/dist/{chunk-AH4DORIW.mjs → chunk-XY7A7GZJ.mjs} +1 -1
- package/dist/{chunk-FQDPOKEK.mjs → chunk-Y2YVTIJI.mjs} +1 -1
- package/dist/{chunk-Q4AXBDFH.mjs → chunk-YTYDWNYA.mjs} +155 -153
- package/dist/{chunk-2HDKZN4Q.mjs → chunk-YYOPBKME.mjs} +3 -3
- package/dist/{chunk-LEJUZW3P.mjs → chunk-Z6BFNHEO.mjs} +12 -0
- package/dist/{chunk-AIZ6W4QI.mjs → chunk-ZMG5B4FG.mjs} +1 -1
- package/dist/{collection-add-products-4WBPS6PY.mjs → collection-add-products-XUMV6XR7.mjs} +12 -11
- package/dist/{collection-create-4JX4YE47.mjs → collection-create-GWKWVT7B.mjs} +3 -2
- package/dist/{collection-detail-HT4SSV32.mjs → collection-detail-ONRBKJLN.mjs} +12 -11
- package/dist/{collection-edit-MXL35GQQ.mjs → collection-edit-EZIO2BR5.mjs} +3 -2
- package/dist/{collection-list-FYONEBDN.mjs → collection-list-XCC4SIPJ.mjs} +13 -12
- package/dist/{collection-metadata-YEZ2TBRX.mjs → collection-metadata-QK7MI3D2.mjs} +11 -10
- package/dist/{customer-detail-MB7CS7OG.mjs → customer-detail-FR6J37ZC.mjs} +12 -11
- package/dist/{customer-group-detail-U5UAP7QS.mjs → customer-group-detail-YSKSNETG.mjs} +11 -10
- package/dist/{customer-group-list-KAS6JSCQ.mjs → customer-group-list-XBCD4FZH.mjs} +11 -10
- package/dist/{customers-add-customer-group-UKLSPYEU.mjs → customers-add-customer-group-Q7FMR2Y5.mjs} +11 -10
- package/dist/{edit-inventory-item-RATTNP2Y.mjs → edit-inventory-item-H7DAZWIT.mjs} +2 -1
- package/dist/{edit-inventory-item-attributes-JHH5GSNL.mjs → edit-inventory-item-attributes-7HTXXPGZ.mjs} +2 -1
- package/dist/{edit-reservation-UZCSNLHY.mjs → edit-reservation-OVTRZHJR.mjs} +3 -2
- package/dist/{edit-rules-VMEHCXYQ.mjs → edit-rules-SMVRTCUP.mjs} +11 -10
- package/dist/en.json +1 -0
- package/dist/{inventory-create-KN72V2KK.mjs → inventory-create-3XONKYMZ.mjs} +12 -11
- package/dist/{inventory-detail-7OHCFAJO.mjs → inventory-detail-6A6GOLB6.mjs} +11 -10
- package/dist/{inventory-list-BQPHK3FV.mjs → inventory-list-2CJLAK3X.mjs} +2 -1
- package/dist/{inventory-metadata-I3IRRMLH.mjs → inventory-metadata-FNEJ3RAT.mjs} +11 -10
- package/dist/{inventory-stock-5IUICNEH.mjs → inventory-stock-S3ZYYCMZ.mjs} +13 -12
- package/dist/{location-detail-3MSUGB4W.mjs → location-detail-N3GUZSY7.mjs} +11 -10
- package/dist/{location-fulfillment-providers-ZVZMLCIC.mjs → location-fulfillment-providers-WM6DT252.mjs} +13 -12
- package/dist/{location-sales-channels-NKNM5TQK.mjs → location-sales-channels-WLVTMU4Z.mjs} +3 -2
- package/dist/{location-service-zone-shipping-option-create-CZWEHKVJ.mjs → location-service-zone-shipping-option-create-MJPH3WKX.mjs} +13 -12
- package/dist/{location-service-zone-shipping-option-pricing-Z5IFOLFJ.mjs → location-service-zone-shipping-option-pricing-6IRNPWJY.mjs} +2 -2
- package/dist/{login-OCYZM7SI.mjs → login-VNOLI5YG.mjs} +11 -10
- package/dist/{manage-locations-MLNMPQ5I.mjs → manage-locations-7HH6R4UP.mjs} +2 -1
- package/dist/{order-allocate-items-VRPPVPP3.mjs → order-allocate-items-HZGGYJ42.mjs} +4 -3
- package/dist/{order-create-claim-O3ZYTAIC.mjs → order-create-claim-GUYTLVPB.mjs} +13 -12
- package/dist/{order-create-edit-HUS7IRS3.mjs → order-create-edit-ODIN6GRW.mjs} +12 -11
- package/dist/{order-create-exchange-TUP4NHHX.mjs → order-create-exchange-ZT5RBRKL.mjs} +13 -12
- package/dist/{order-create-fulfillment-4BGDYHBB.mjs → order-create-fulfillment-OWUVTZXW.mjs} +11 -10
- package/dist/{order-create-refund-FA5ERI7M.mjs → order-create-refund-Q6HQY42R.mjs} +11 -10
- package/dist/{order-create-return-7GPHJ2WU.mjs → order-create-return-E2KILJX2.mjs} +5 -4
- package/dist/{order-create-shipment-27UBYPKT.mjs → order-create-shipment-WAGGEPRW.mjs} +11 -10
- package/dist/{order-detail-2J7KDTKG.mjs → order-detail-HFJONELJ.mjs} +15 -14
- package/dist/{order-edit-billing-address-E7CD5FBQ.mjs → order-edit-billing-address-UM76J4KX.mjs} +11 -10
- package/dist/{order-edit-email-ELRIQYVN.mjs → order-edit-email-CL3KNOCM.mjs} +11 -10
- package/dist/{order-edit-shipping-address-HVNAJUZI.mjs → order-edit-shipping-address-PIESTGVL.mjs} +11 -10
- package/dist/{order-export-TRMFVBFO.mjs → order-export-4MZUPMGD.mjs} +12 -11
- package/dist/{order-list-Y4FET3XV.mjs → order-list-ACSFGIPD.mjs} +6 -5
- package/dist/{order-metadata-THARHEJC.mjs → order-metadata-FHBB7MTG.mjs} +11 -10
- package/dist/{order-receive-return-X5ASB7DL.mjs → order-receive-return-PRVKP6J2.mjs} +12 -11
- package/dist/{order-request-transfer-PKF4ULJY.mjs → order-request-transfer-XSAGRUMT.mjs} +11 -10
- package/dist/{price-list-configuration-SZRY7CXO.mjs → price-list-configuration-IHPSUNZJ.mjs} +3 -2
- package/dist/{price-list-create-TYNSJDDM.mjs → price-list-create-YHXRQSC3.mjs} +14 -13
- package/dist/{price-list-detail-ORYFRNB6.mjs → price-list-detail-FR3FQR3H.mjs} +13 -12
- package/dist/{price-list-edit-I5QNCWJP.mjs → price-list-edit-53UW35L3.mjs} +3 -2
- package/dist/{price-list-list-AZOGEZAS.mjs → price-list-list-YSEM6IAI.mjs} +4 -3
- package/dist/{price-list-prices-add-MWAUNUBF.mjs → price-list-prices-add-GJVI47OY.mjs} +14 -13
- package/dist/{price-list-prices-edit-Z4YJ4YBY.mjs → price-list-prices-edit-E4Q5TQPM.mjs} +5 -4
- package/dist/{product-attributes-5QW6ZEYB.mjs → product-attributes-TKCE2M63.mjs} +12 -11
- package/dist/{product-create-YQ76CEF3.mjs → product-create-OLDZPMLW.mjs} +14 -13
- package/dist/{product-create-option-UMZKRNTC.mjs → product-create-option-7AOXAA4S.mjs} +2 -1
- package/dist/{product-create-variant-IASRY2JX.mjs → product-create-variant-KEBN5OR7.mjs} +12 -11
- package/dist/{product-detail-NVLJQGGK.mjs → product-detail-O6QWJIKR.mjs} +12 -11
- package/dist/{product-edit-DP42G3EU.mjs → product-edit-56XDGDUN.mjs} +12 -11
- package/dist/{product-edit-option-ZMTSLRG5.mjs → product-edit-option-LWJT3CYJ.mjs} +2 -1
- package/dist/{product-export-OK5FCD42.mjs → product-export-WUZYHPS5.mjs} +13 -12
- package/dist/{product-image-variants-edit-VEWNL52X.mjs → product-image-variants-edit-Y363J5NG.mjs} +11 -10
- package/dist/{product-import-LX625CIX.mjs → product-import-V3KQN4TV.mjs} +11 -10
- package/dist/{product-list-TXEPE6NL.mjs → product-list-DNTS7WUN.mjs} +12 -11
- package/dist/{product-media-ULNJ7JJY.mjs → product-media-3VJ7KENL.mjs} +2 -1
- package/dist/{product-metadata-ZKKBE6GG.mjs → product-metadata-GL2MVPDI.mjs} +11 -10
- package/dist/{product-organization-NMA2WJNT.mjs → product-organization-PNKWRNHC.mjs} +13 -12
- package/dist/{product-prices-5WCCQDS6.mjs → product-prices-JOG6IIQ7.mjs} +3 -2
- package/dist/{product-sales-channels-2PN4L7II.mjs → product-sales-channels-ANCFZZ5S.mjs} +3 -2
- package/dist/{product-shipping-profile-45XXB7FM.mjs → product-shipping-profile-ETQFZ7DC.mjs} +2 -1
- package/dist/{product-stock-KUHH6MFA.mjs → product-stock-NYUFMEVG.mjs} +13 -12
- package/dist/{product-tag-create-7EVRE5BL.mjs → product-tag-create-PQMDDKWH.mjs} +11 -10
- package/dist/{product-tag-detail-WULO55NT.mjs → product-tag-detail-EHBB3WUB.mjs} +14 -13
- package/dist/{product-tag-edit-J4ODRLXN.mjs → product-tag-edit-K3BBQLJR.mjs} +11 -10
- package/dist/{product-tag-list-V4CCQTL6.mjs → product-tag-list-LSW5FFVN.mjs} +14 -13
- package/dist/{product-tag-metadata-KHDYQMSG.mjs → product-tag-metadata-MJH5LH7E.mjs} +11 -10
- package/dist/{product-type-create-KHSNCQCV.mjs → product-type-create-DRFXTL5O.mjs} +2 -1
- package/dist/{product-type-detail-F35MUSLD.mjs → product-type-detail-3VB6AWUW.mjs} +13 -12
- package/dist/{product-type-edit-3LRBWZ3S.mjs → product-type-edit-SRHCZDK7.mjs} +2 -1
- package/dist/{product-type-list-K2GULUPF.mjs → product-type-list-FD3TGPNP.mjs} +3 -2
- package/dist/{product-type-metadata-CGXFFEJO.mjs → product-type-metadata-CDJDFFGQ.mjs} +11 -10
- package/dist/{product-variant-detail-NT2MB3Z4.mjs → product-variant-detail-43T33AQP.mjs} +11 -10
- package/dist/{product-variant-edit-KZ6D5CSA.mjs → product-variant-edit-DEZEY2H2.mjs} +11 -10
- package/dist/{product-variant-manage-inventory-items-OGM64KYP.mjs → product-variant-manage-inventory-items-Y2VEOHP7.mjs} +2 -1
- package/dist/{product-variant-media-C3KCFODU.mjs → product-variant-media-2WLVNGI4.mjs} +2 -1
- package/dist/{product-variant-metadata-I2PN64TH.mjs → product-variant-metadata-VTZDNWUT.mjs} +11 -10
- package/dist/{promotion-create-4KVSXYAI.mjs → promotion-create-HWFNUQXG.mjs} +11 -10
- package/dist/{promotion-detail-NGNVELME.mjs → promotion-detail-VJB55PJK.mjs} +11 -10
- package/dist/{refund-reason-create-CTAPBK3X.mjs → refund-reason-create-YHCDEHGQ.mjs} +11 -10
- package/dist/{refund-reason-edit-B6HRNXGE.mjs → refund-reason-edit-CZ5QZ2SZ.mjs} +11 -10
- package/dist/{refund-reason-list-7OUHUORB.mjs → refund-reason-list-URYYYEK6.mjs} +11 -10
- package/dist/{region-metadata-GRG3QSJY.mjs → region-metadata-H6XXUQ4S.mjs} +11 -10
- package/dist/{reservation-create-C6HTEF3R.mjs → reservation-create-ZCIYM6JI.mjs} +3 -2
- package/dist/{reservation-detail-KAI7N5UP.mjs → reservation-detail-LZAQL4XA.mjs} +11 -10
- package/dist/{reservation-list-SOJRN5RI.mjs → reservation-list-2DN3YHIJ.mjs} +3 -2
- package/dist/{reservation-metadata-TWV7KLOB.mjs → reservation-metadata-5HZSDDOK.mjs} +11 -10
- package/dist/{sales-channel-add-products-CBECZU46.mjs → sales-channel-add-products-VH5T3GDA.mjs} +12 -11
- package/dist/{sales-channel-create-4XLJDVJO.mjs → sales-channel-create-MI7HHZYE.mjs} +3 -2
- package/dist/{sales-channel-detail-NQSBPPIE.mjs → sales-channel-detail-I2ZHVXMG.mjs} +12 -11
- package/dist/{sales-channel-edit-UZGSXD5X.mjs → sales-channel-edit-VSHOIR37.mjs} +3 -2
- package/dist/{sales-channel-list-UYN2OCBR.mjs → sales-channel-list-3FV4S2NN.mjs} +11 -10
- package/dist/{sales-channel-metadata-4XWXYN2E.mjs → sales-channel-metadata-M364R4RJ.mjs} +11 -10
- package/dist/{shipping-option-type-create-U7PIKVMV.mjs → shipping-option-type-create-C5WUWON7.mjs} +11 -10
- package/dist/{shipping-option-type-detail-QNZLQGI6.mjs → shipping-option-type-detail-PENS2K73.mjs} +12 -11
- package/dist/{shipping-option-type-edit-BP6HLZ7B.mjs → shipping-option-type-edit-CIU5EHRP.mjs} +11 -10
- package/dist/{shipping-option-type-list-L274RM6A.mjs → shipping-option-type-list-ZMZMXFME.mjs} +12 -11
- package/dist/{shipping-profile-metadata-BZKPLXHO.mjs → shipping-profile-metadata-75G2NNMA.mjs} +11 -10
- package/dist/{store-add-locales-EXR3NLOM.mjs → store-add-locales-IZOZP5C6.mjs} +12 -18
- package/dist/{store-detail-T4YY5NHG.mjs → store-detail-4IBAEVSD.mjs} +16 -28
- package/dist/{store-edit-AB5CDUTK.mjs → store-edit-5ZS562ZO.mjs} +1 -42
- package/dist/{store-metadata-FN3WZLXA.mjs → store-metadata-CYXTVJUE.mjs} +11 -10
- package/dist/{tax-region-create-PWXTFE3Q.mjs → tax-region-create-DWGL4EUT.mjs} +11 -10
- package/dist/{tax-region-detail-GJW63AMV.mjs → tax-region-detail-O2T7BI3V.mjs} +16 -15
- package/dist/{tax-region-edit-WOUO7TPQ.mjs → tax-region-edit-EEVEEU2Q.mjs} +11 -10
- package/dist/{tax-region-province-detail-FCHPIRXW.mjs → tax-region-province-detail-2W7RXAM5.mjs} +16 -15
- package/dist/{tax-region-tax-override-create-ZLWXRNLN.mjs → tax-region-tax-override-create-7IM4ZVPH.mjs} +14 -13
- package/dist/{tax-region-tax-override-edit-ZM2JUFNJ.mjs → tax-region-tax-override-edit-3ZT5IZYR.mjs} +15 -14
- package/dist/{translation-list-Y2GWTRGW.mjs → translation-list-AFK5MGSH.mjs} +68 -79
- package/dist/{translations-edit-PM4PSMRF.mjs → translations-edit-EN47PWTO.mjs} +146 -81
- package/dist/{user-detail-KEDJ7N3Q.mjs → user-detail-BJUXLZZQ.mjs} +2 -1
- package/dist/{user-metadata-LNADHFTW.mjs → user-metadata-2WPJOEJA.mjs} +11 -10
- package/dist/{workflow-execution-detail-POTSURJX.mjs → workflow-execution-detail-H2AKEZJX.mjs} +11 -10
- package/package.json +9 -9
- package/src/components/data-grid/components/data-grid-root.tsx +184 -5
- package/src/components/data-grid/data-grid.tsx +12 -1
- package/src/components/data-grid/helpers/create-data-grid-column-helper.ts +18 -0
- package/src/components/data-grid/hooks/use-data-grid-cell.tsx +1 -1
- package/src/hooks/api/categories.tsx +32 -0
- package/src/hooks/api/collections.tsx +31 -0
- package/src/hooks/api/product-types.tsx +32 -0
- package/src/hooks/api/product-variants.tsx +40 -2
- package/src/hooks/api/products.tsx +29 -0
- package/src/hooks/api/tags.tsx +32 -0
- package/src/hooks/api/translations.tsx +114 -62
- package/src/hooks/use-infinite-list.tsx +92 -0
- package/src/i18n/translations/$schema.json +4 -0
- package/src/i18n/translations/en.json +1 -0
- package/src/i18n/translations/es.json +1 -0
- package/src/routes/store/store-add-locales/components/add-locales-form/add-locales-form.tsx +0 -9
- package/src/routes/store/store-detail/components/store-general-section/store-general-section.tsx +0 -24
- package/src/routes/store/store-detail/components/store-locale-section/store-locale-section.tsx +1 -9
- package/src/routes/store/store-edit/components/edit-store-form/edit-store-form.tsx +1 -45
- package/src/routes/translations/translation-list/components/active-locales-section/active-locales-section.tsx +2 -2
- package/src/routes/translations/translation-list/components/translation-list-section/translation-list-section.tsx +1 -8
- package/src/routes/translations/translation-list/components/translations-completion-section/translations-completion-section.tsx +10 -4
- package/src/routes/translations/translation-list/translation-list.tsx +66 -68
- package/src/routes/translations/translations-edit/components/translations-edit-form/translations-edit-form.tsx +131 -65
- package/src/routes/translations/translations-edit/translations-edit.tsx +36 -12
- package/src/routes/translations/translations-edit/utils/index.ts +0 -1
- package/src/routes/translations/translations-edit/utils/reference-label-map.ts +0 -10
|
@@ -51,7 +51,7 @@ import { isCellMatch, isSpecialFocusKey } from "../utils"
|
|
|
51
51
|
import { DataGridKeyboardShortcutModal } from "./data-grid-keyboard-shortcut-modal"
|
|
52
52
|
export interface DataGridRootProps<
|
|
53
53
|
TData,
|
|
54
|
-
TFieldValues extends FieldValues = FieldValues
|
|
54
|
+
TFieldValues extends FieldValues = FieldValues
|
|
55
55
|
> {
|
|
56
56
|
data?: TData[]
|
|
57
57
|
columns: ColumnDef<TData>[]
|
|
@@ -60,6 +60,19 @@ export interface DataGridRootProps<
|
|
|
60
60
|
onEditingChange?: (isEditing: boolean) => void
|
|
61
61
|
disableInteractions?: boolean
|
|
62
62
|
multiColumnSelection?: boolean
|
|
63
|
+
/**
|
|
64
|
+
* Lazy loading props - when totalRowCount is provided, the grid enters lazy loading mode.
|
|
65
|
+
* In this mode, the virtualizer will size based on totalRowCount and trigger onFetchMore
|
|
66
|
+
* when the user scrolls near the end of loaded data.
|
|
67
|
+
*/
|
|
68
|
+
/** Total count of rows for scroll sizing (enables lazy loading mode when provided) */
|
|
69
|
+
totalRowCount?: number
|
|
70
|
+
/** Called when more data should be fetched */
|
|
71
|
+
onFetchMore?: () => void
|
|
72
|
+
/** Whether more data is currently being fetched */
|
|
73
|
+
isFetchingMore?: boolean
|
|
74
|
+
/** Whether there is more data to fetch */
|
|
75
|
+
hasNextPage?: boolean
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
const ROW_HEIGHT = 40
|
|
@@ -97,7 +110,7 @@ const getCommonPinningStyles = <TData,>(
|
|
|
97
110
|
|
|
98
111
|
export const DataGridRoot = <
|
|
99
112
|
TData,
|
|
100
|
-
TFieldValues extends FieldValues = FieldValues
|
|
113
|
+
TFieldValues extends FieldValues = FieldValues
|
|
101
114
|
>({
|
|
102
115
|
data = [],
|
|
103
116
|
columns,
|
|
@@ -106,7 +119,13 @@ export const DataGridRoot = <
|
|
|
106
119
|
onEditingChange,
|
|
107
120
|
disableInteractions,
|
|
108
121
|
multiColumnSelection = false,
|
|
122
|
+
totalRowCount,
|
|
123
|
+
onFetchMore,
|
|
124
|
+
isFetchingMore,
|
|
125
|
+
hasNextPage,
|
|
109
126
|
}: DataGridRootProps<TData, TFieldValues>) => {
|
|
127
|
+
// TODO: remove once everything is lazy loaded
|
|
128
|
+
const isLazyMode = totalRowCount !== undefined
|
|
110
129
|
const containerRef = useRef<HTMLDivElement>(null)
|
|
111
130
|
|
|
112
131
|
const { redo, undo, execute } = useCommandHistory()
|
|
@@ -163,8 +182,10 @@ export const DataGridRoot = <
|
|
|
163
182
|
)
|
|
164
183
|
const visibleColumns = grid.getVisibleLeafColumns()
|
|
165
184
|
|
|
185
|
+
const effectiveRowCount = isLazyMode ? totalRowCount! : visibleRows.length
|
|
186
|
+
|
|
166
187
|
const rowVirtualizer = useVirtualizer({
|
|
167
|
-
count:
|
|
188
|
+
count: effectiveRowCount,
|
|
168
189
|
estimateSize: () => ROW_HEIGHT,
|
|
169
190
|
getScrollElement: () => containerRef.current,
|
|
170
191
|
overscan: 5,
|
|
@@ -189,6 +210,76 @@ export const DataGridRoot = <
|
|
|
189
210
|
})
|
|
190
211
|
const virtualRows = rowVirtualizer.getVirtualItems()
|
|
191
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Lazy loading scroll detection.
|
|
215
|
+
* When the user scrolls near the end of loaded data, trigger onFetchMore.
|
|
216
|
+
* We use refs to get latest values in the scroll handler without re-attaching.
|
|
217
|
+
*/
|
|
218
|
+
const lazyLoadingRefs = useRef({
|
|
219
|
+
onFetchMore,
|
|
220
|
+
hasNextPage,
|
|
221
|
+
isFetchingMore,
|
|
222
|
+
loadedRowCount: visibleRows.length,
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
// Keep refs updated
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
lazyLoadingRefs.current = {
|
|
228
|
+
onFetchMore,
|
|
229
|
+
hasNextPage,
|
|
230
|
+
isFetchingMore,
|
|
231
|
+
loadedRowCount: visibleRows.length,
|
|
232
|
+
}
|
|
233
|
+
}, [onFetchMore, hasNextPage, isFetchingMore, visibleRows.length])
|
|
234
|
+
|
|
235
|
+
const hasData = visibleRows.length > 0
|
|
236
|
+
|
|
237
|
+
const handleScroll = useCallback(() => {
|
|
238
|
+
const { onFetchMore, hasNextPage, isFetchingMore, loadedRowCount } =
|
|
239
|
+
lazyLoadingRefs.current
|
|
240
|
+
|
|
241
|
+
if (!onFetchMore || !hasNextPage || isFetchingMore) {
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const scrollElement = containerRef.current
|
|
246
|
+
|
|
247
|
+
const { scrollTop, clientHeight } = scrollElement!
|
|
248
|
+
const loadedHeight = loadedRowCount * ROW_HEIGHT
|
|
249
|
+
const viewportBottom = scrollTop + clientHeight
|
|
250
|
+
const fetchThreshold = loadedHeight - ROW_HEIGHT * 10
|
|
251
|
+
|
|
252
|
+
if (viewportBottom >= fetchThreshold) {
|
|
253
|
+
onFetchMore()
|
|
254
|
+
}
|
|
255
|
+
}, [lazyLoadingRefs, containerRef])
|
|
256
|
+
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
if (!isLazyMode || !hasData) {
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const container = containerRef.current
|
|
263
|
+
if (!container) {
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const timeoutId = setTimeout(() => {
|
|
268
|
+
const scrollElement: HTMLElement | null = containerRef.current
|
|
269
|
+
if (!scrollElement) {
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
scrollElement.addEventListener("scroll", handleScroll)
|
|
274
|
+
}, 100)
|
|
275
|
+
|
|
276
|
+
return () => {
|
|
277
|
+
clearTimeout(timeoutId)
|
|
278
|
+
const scrollElement = containerRef.current
|
|
279
|
+
scrollElement?.removeEventListener("scroll", handleScroll)
|
|
280
|
+
}
|
|
281
|
+
}, [isLazyMode, hasData])
|
|
282
|
+
|
|
192
283
|
const columnVirtualizer = useVirtualizer({
|
|
193
284
|
count: visibleColumns.length,
|
|
194
285
|
estimateSize: (index) => visibleColumns[index].getSize(),
|
|
@@ -650,6 +741,20 @@ export const DataGridRoot = <
|
|
|
650
741
|
>
|
|
651
742
|
{virtualRows.map((virtualRow) => {
|
|
652
743
|
const row = visibleRows[virtualRow.index] as Row<TData>
|
|
744
|
+
|
|
745
|
+
// In lazy mode, rows beyond loaded data show as skeleton
|
|
746
|
+
if (!row) {
|
|
747
|
+
return (
|
|
748
|
+
<DataGridRowSkeleton
|
|
749
|
+
key={`skeleton-${virtualRow.index}`}
|
|
750
|
+
virtualRow={virtualRow}
|
|
751
|
+
virtualColumns={virtualColumns}
|
|
752
|
+
virtualPaddingLeft={virtualPaddingLeft}
|
|
753
|
+
virtualPaddingRight={virtualPaddingRight}
|
|
754
|
+
/>
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
|
|
653
758
|
const rowIndex = flatRows.findIndex((r) => r.id === row.id)
|
|
654
759
|
|
|
655
760
|
return (
|
|
@@ -861,10 +966,10 @@ const DataGridCell = <TData,>({
|
|
|
861
966
|
type DataGridRowProps<TData> = {
|
|
862
967
|
row: Row<TData>
|
|
863
968
|
rowIndex: number
|
|
864
|
-
virtualRow: VirtualItem
|
|
969
|
+
virtualRow: VirtualItem
|
|
865
970
|
virtualPaddingLeft?: number
|
|
866
971
|
virtualPaddingRight?: number
|
|
867
|
-
virtualColumns: VirtualItem
|
|
972
|
+
virtualColumns: VirtualItem[]
|
|
868
973
|
flatColumns: Column<TData, unknown>[]
|
|
869
974
|
anchor: DataGridCoordinates | null
|
|
870
975
|
onDragToFillStart: (e: React.MouseEvent<HTMLElement>) => void
|
|
@@ -943,3 +1048,77 @@ const DataGridRow = <TData,>({
|
|
|
943
1048
|
</div>
|
|
944
1049
|
)
|
|
945
1050
|
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Skeleton row component for lazy loading.
|
|
1054
|
+
* Displays placeholder cells while data is being fetched.
|
|
1055
|
+
*/
|
|
1056
|
+
type DataGridRowSkeletonProps = {
|
|
1057
|
+
virtualRow: VirtualItem
|
|
1058
|
+
virtualPaddingLeft?: number
|
|
1059
|
+
virtualPaddingRight?: number
|
|
1060
|
+
virtualColumns: VirtualItem[]
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
const DataGridRowSkeleton = ({
|
|
1064
|
+
virtualRow,
|
|
1065
|
+
virtualPaddingLeft,
|
|
1066
|
+
virtualPaddingRight,
|
|
1067
|
+
virtualColumns,
|
|
1068
|
+
}: DataGridRowSkeletonProps) => {
|
|
1069
|
+
return (
|
|
1070
|
+
<div
|
|
1071
|
+
role="row"
|
|
1072
|
+
aria-rowindex={virtualRow.index}
|
|
1073
|
+
style={{
|
|
1074
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
1075
|
+
}}
|
|
1076
|
+
className="bg-ui-bg-subtle txt-compact-small absolute flex h-10 w-full"
|
|
1077
|
+
>
|
|
1078
|
+
{virtualPaddingLeft ? (
|
|
1079
|
+
<div
|
|
1080
|
+
role="presentation"
|
|
1081
|
+
style={{ display: "flex", width: virtualPaddingLeft }}
|
|
1082
|
+
/>
|
|
1083
|
+
) : null}
|
|
1084
|
+
{virtualColumns.map((vc, index, array) => {
|
|
1085
|
+
const previousVC = array[index - 1]
|
|
1086
|
+
const elements: ReactNode[] = []
|
|
1087
|
+
|
|
1088
|
+
if (previousVC && vc.index !== previousVC.index + 1) {
|
|
1089
|
+
elements.push(
|
|
1090
|
+
<div
|
|
1091
|
+
key={`padding-${previousVC.index}-${vc.index}`}
|
|
1092
|
+
role="presentation"
|
|
1093
|
+
style={{
|
|
1094
|
+
display: "flex",
|
|
1095
|
+
width: `${vc.start - previousVC.end}px`,
|
|
1096
|
+
}}
|
|
1097
|
+
/>
|
|
1098
|
+
)
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
elements.push(
|
|
1102
|
+
<div
|
|
1103
|
+
key={`skeleton-cell-${vc.index}`}
|
|
1104
|
+
role="gridcell"
|
|
1105
|
+
style={{ width: vc.size }}
|
|
1106
|
+
className="relative flex items-center border-b border-r p-0 outline-none"
|
|
1107
|
+
>
|
|
1108
|
+
<div className="flex h-full w-full items-center px-4">
|
|
1109
|
+
<div className="bg-ui-bg-component h-4 w-3/4 animate-pulse rounded" />
|
|
1110
|
+
</div>
|
|
1111
|
+
</div>
|
|
1112
|
+
)
|
|
1113
|
+
|
|
1114
|
+
return elements
|
|
1115
|
+
})}
|
|
1116
|
+
{virtualPaddingRight ? (
|
|
1117
|
+
<div
|
|
1118
|
+
role="presentation"
|
|
1119
|
+
style={{ display: "flex", width: virtualPaddingRight }}
|
|
1120
|
+
/>
|
|
1121
|
+
) : null}
|
|
1122
|
+
</div>
|
|
1123
|
+
)
|
|
1124
|
+
}
|
|
@@ -19,6 +19,11 @@ interface DataGridProps<TData, TFieldValues extends FieldValues = FieldValues>
|
|
|
19
19
|
|
|
20
20
|
const _DataGrid = <TData, TFieldValues extends FieldValues = FieldValues>({
|
|
21
21
|
isLoading,
|
|
22
|
+
// Lazy loading props - passed through to DataGridRoot
|
|
23
|
+
totalRowCount,
|
|
24
|
+
onFetchMore,
|
|
25
|
+
isFetchingMore,
|
|
26
|
+
hasNextPage,
|
|
22
27
|
...props
|
|
23
28
|
}: DataGridProps<TData, TFieldValues>) => {
|
|
24
29
|
return isLoading ? (
|
|
@@ -29,7 +34,13 @@ const _DataGrid = <TData, TFieldValues extends FieldValues = FieldValues>({
|
|
|
29
34
|
}
|
|
30
35
|
/>
|
|
31
36
|
) : (
|
|
32
|
-
<DataGridRoot
|
|
37
|
+
<DataGridRoot
|
|
38
|
+
{...props}
|
|
39
|
+
totalRowCount={totalRowCount}
|
|
40
|
+
onFetchMore={onFetchMore}
|
|
41
|
+
isFetchingMore={isFetchingMore}
|
|
42
|
+
hasNextPage={hasNextPage}
|
|
43
|
+
/>
|
|
33
44
|
)
|
|
34
45
|
}
|
|
35
46
|
|
|
@@ -36,6 +36,18 @@ type DataGridHelperColumnsProps<TData, TFieldValues extends FieldValues> = {
|
|
|
36
36
|
* @default false
|
|
37
37
|
*/
|
|
38
38
|
disableHiding?: boolean
|
|
39
|
+
/**
|
|
40
|
+
* The size of the column in pixels.
|
|
41
|
+
*/
|
|
42
|
+
size?: number
|
|
43
|
+
/**
|
|
44
|
+
* The minimum size of the column in pixels.
|
|
45
|
+
*/
|
|
46
|
+
minSize?: number
|
|
47
|
+
/**
|
|
48
|
+
* The maximum size of the column in pixels.
|
|
49
|
+
*/
|
|
50
|
+
maxSize?: number
|
|
39
51
|
} & (
|
|
40
52
|
| {
|
|
41
53
|
field: FieldFunction<TData, TFieldValues>
|
|
@@ -59,12 +71,18 @@ export function createDataGridHelper<
|
|
|
59
71
|
disableHiding = false,
|
|
60
72
|
field,
|
|
61
73
|
type,
|
|
74
|
+
size,
|
|
75
|
+
minSize,
|
|
76
|
+
maxSize,
|
|
62
77
|
}: DataGridHelperColumnsProps<TData, TFieldValues>) =>
|
|
63
78
|
columnHelper.display({
|
|
64
79
|
id,
|
|
65
80
|
header,
|
|
66
81
|
cell,
|
|
67
82
|
enableHiding: !disableHiding,
|
|
83
|
+
size,
|
|
84
|
+
minSize,
|
|
85
|
+
maxSize,
|
|
68
86
|
meta: {
|
|
69
87
|
name,
|
|
70
88
|
field,
|
|
@@ -202,7 +202,7 @@ export const useDataGridCell = <TData, TValue>({
|
|
|
202
202
|
|
|
203
203
|
useEffect(() => {
|
|
204
204
|
if (isAnchor && !containerRef.current?.contains(document.activeElement)) {
|
|
205
|
-
containerRef.current?.focus()
|
|
205
|
+
containerRef.current?.focus({ preventScroll: true })
|
|
206
206
|
}
|
|
207
207
|
}, [isAnchor])
|
|
208
208
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FetchError } from "@medusajs/js-sdk"
|
|
2
2
|
import { HttpTypes } from "@medusajs/types"
|
|
3
3
|
import {
|
|
4
|
+
InfiniteData,
|
|
4
5
|
QueryKey,
|
|
6
|
+
UseInfiniteQueryOptions,
|
|
5
7
|
UseMutationOptions,
|
|
6
8
|
UseQueryOptions,
|
|
7
9
|
useMutation,
|
|
@@ -11,6 +13,7 @@ import { sdk } from "../../lib/client"
|
|
|
11
13
|
import { queryClient } from "../../lib/query-client"
|
|
12
14
|
import { queryKeysFactory } from "../../lib/query-key-factory"
|
|
13
15
|
import { productsQueryKeys } from "./products"
|
|
16
|
+
import { useInfiniteList } from "../use-infinite-list"
|
|
14
17
|
|
|
15
18
|
const CATEGORIES_QUERY_KEY = "categories" as const
|
|
16
19
|
export const categoriesQueryKeys = queryKeysFactory(CATEGORIES_QUERY_KEY)
|
|
@@ -58,6 +61,35 @@ export const useProductCategories = (
|
|
|
58
61
|
return { ...data, ...rest }
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
export const useInfiniteCategories = (
|
|
65
|
+
query?: Omit<HttpTypes.AdminProductCategoryListParams, "offset" | "limit"> & {
|
|
66
|
+
limit?: number
|
|
67
|
+
},
|
|
68
|
+
options?: Omit<
|
|
69
|
+
UseInfiniteQueryOptions<
|
|
70
|
+
HttpTypes.AdminProductCategoryListResponse,
|
|
71
|
+
FetchError,
|
|
72
|
+
InfiniteData<HttpTypes.AdminProductCategoryListResponse, number>,
|
|
73
|
+
HttpTypes.AdminProductCategoryListResponse,
|
|
74
|
+
QueryKey,
|
|
75
|
+
number
|
|
76
|
+
>,
|
|
77
|
+
"queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
|
|
78
|
+
>
|
|
79
|
+
) => {
|
|
80
|
+
return useInfiniteList<
|
|
81
|
+
HttpTypes.AdminProductCategoryListResponse,
|
|
82
|
+
HttpTypes.AdminProductCategoryListParams,
|
|
83
|
+
FetchError,
|
|
84
|
+
QueryKey
|
|
85
|
+
>({
|
|
86
|
+
queryKey: (params) => categoriesQueryKeys.list(params),
|
|
87
|
+
queryFn: (params) => sdk.admin.productCategory.list(params),
|
|
88
|
+
query,
|
|
89
|
+
options,
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
61
93
|
export const useCreateProductCategory = (
|
|
62
94
|
options?: UseMutationOptions<
|
|
63
95
|
HttpTypes.AdminProductCategoryResponse,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FetchError } from "@medusajs/js-sdk"
|
|
2
2
|
import { FindParams, HttpTypes, PaginatedResponse } from "@medusajs/types"
|
|
3
3
|
import {
|
|
4
|
+
InfiniteData,
|
|
4
5
|
QueryKey,
|
|
6
|
+
UseInfiniteQueryOptions,
|
|
5
7
|
UseMutationOptions,
|
|
6
8
|
UseQueryOptions,
|
|
7
9
|
useMutation,
|
|
@@ -11,6 +13,7 @@ import { sdk } from "../../lib/client"
|
|
|
11
13
|
import { queryClient } from "../../lib/query-client"
|
|
12
14
|
import { queryKeysFactory } from "../../lib/query-key-factory"
|
|
13
15
|
import { productsQueryKeys } from "./products"
|
|
16
|
+
import { useInfiniteList } from "../use-infinite-list"
|
|
14
17
|
|
|
15
18
|
const COLLECTION_QUERY_KEY = "collections" as const
|
|
16
19
|
export const collectionsQueryKeys = queryKeysFactory(COLLECTION_QUERY_KEY)
|
|
@@ -57,6 +60,34 @@ export const useCollections = (
|
|
|
57
60
|
return { ...data, ...rest }
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
export const useInfiniteCollections = (
|
|
64
|
+
query?: Omit<HttpTypes.AdminCollectionListParams, "offset" | "limit"> & {
|
|
65
|
+
limit?: number
|
|
66
|
+
},
|
|
67
|
+
options?: Omit<
|
|
68
|
+
UseInfiniteQueryOptions<
|
|
69
|
+
HttpTypes.AdminCollectionListResponse,
|
|
70
|
+
FetchError,
|
|
71
|
+
InfiniteData<HttpTypes.AdminCollectionListResponse, number>,
|
|
72
|
+
HttpTypes.AdminCollectionListResponse,
|
|
73
|
+
QueryKey,
|
|
74
|
+
number
|
|
75
|
+
>,
|
|
76
|
+
"queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
|
|
77
|
+
>
|
|
78
|
+
) => {
|
|
79
|
+
return useInfiniteList<
|
|
80
|
+
HttpTypes.AdminCollectionListResponse,
|
|
81
|
+
HttpTypes.AdminCollectionListParams,
|
|
82
|
+
FetchError,
|
|
83
|
+
QueryKey
|
|
84
|
+
>({
|
|
85
|
+
queryKey: (params) => collectionsQueryKeys.list(params),
|
|
86
|
+
queryFn: (params) => sdk.admin.productCollection.list(params),
|
|
87
|
+
query,
|
|
88
|
+
options,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
60
91
|
export const useUpdateCollection = (
|
|
61
92
|
id: string,
|
|
62
93
|
options?: UseMutationOptions<
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FetchError } from "@medusajs/js-sdk"
|
|
2
2
|
import { HttpTypes } from "@medusajs/types"
|
|
3
3
|
import {
|
|
4
|
+
InfiniteData,
|
|
4
5
|
QueryKey,
|
|
6
|
+
UseInfiniteQueryOptions,
|
|
5
7
|
UseMutationOptions,
|
|
6
8
|
UseQueryOptions,
|
|
7
9
|
useMutation,
|
|
@@ -10,6 +12,7 @@ import {
|
|
|
10
12
|
import { sdk } from "../../lib/client"
|
|
11
13
|
import { queryClient } from "../../lib/query-client"
|
|
12
14
|
import { queryKeysFactory } from "../../lib/query-key-factory"
|
|
15
|
+
import { useInfiniteList } from "../use-infinite-list"
|
|
13
16
|
|
|
14
17
|
const PRODUCT_TYPES_QUERY_KEY = "product_types" as const
|
|
15
18
|
export const productTypesQueryKeys = queryKeysFactory(PRODUCT_TYPES_QUERY_KEY)
|
|
@@ -57,6 +60,35 @@ export const useProductTypes = (
|
|
|
57
60
|
return { ...data, ...rest }
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
export const useInfiniteProductTypes = (
|
|
64
|
+
query?: Omit<HttpTypes.AdminProductTypeListParams, "offset" | "limit"> & {
|
|
65
|
+
limit?: number
|
|
66
|
+
},
|
|
67
|
+
options?: Omit<
|
|
68
|
+
UseInfiniteQueryOptions<
|
|
69
|
+
HttpTypes.AdminProductTypeListResponse,
|
|
70
|
+
FetchError,
|
|
71
|
+
InfiniteData<HttpTypes.AdminProductTypeListResponse, number>,
|
|
72
|
+
HttpTypes.AdminProductTypeListResponse,
|
|
73
|
+
QueryKey,
|
|
74
|
+
number
|
|
75
|
+
>,
|
|
76
|
+
"queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
|
|
77
|
+
>
|
|
78
|
+
) => {
|
|
79
|
+
return useInfiniteList<
|
|
80
|
+
HttpTypes.AdminProductTypeListResponse,
|
|
81
|
+
HttpTypes.AdminProductTypeListParams,
|
|
82
|
+
FetchError,
|
|
83
|
+
QueryKey
|
|
84
|
+
>({
|
|
85
|
+
queryKey: (params) => productTypesQueryKeys.list(params),
|
|
86
|
+
queryFn: (params) => sdk.admin.productType.list(params),
|
|
87
|
+
query,
|
|
88
|
+
options,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
60
92
|
export const useCreateProductType = (
|
|
61
93
|
options?: UseMutationOptions<
|
|
62
94
|
HttpTypes.AdminProductTypeResponse,
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
QueryKey,
|
|
3
|
+
UseInfiniteQueryOptions,
|
|
4
|
+
useQuery,
|
|
5
|
+
UseQueryOptions,
|
|
6
|
+
} from "@tanstack/react-query"
|
|
7
|
+
import { InfiniteData } from "@tanstack/query-core"
|
|
2
8
|
import { sdk } from "../../lib/client"
|
|
3
9
|
import { queryKeysFactory } from "../../lib/query-key-factory"
|
|
4
10
|
import { FetchError } from "@medusajs/js-sdk"
|
|
5
11
|
import { HttpTypes } from "@medusajs/types"
|
|
12
|
+
import { useInfiniteList } from "../use-infinite-list"
|
|
6
13
|
|
|
7
14
|
const PRODUCT_VARIANT_QUERY_KEY = "product_variant" as const
|
|
8
15
|
export const productVariantQueryKeys = queryKeysFactory(
|
|
@@ -10,7 +17,7 @@ export const productVariantQueryKeys = queryKeysFactory(
|
|
|
10
17
|
)
|
|
11
18
|
|
|
12
19
|
export const useVariants = (
|
|
13
|
-
query?:
|
|
20
|
+
query?: HttpTypes.AdminProductVariantParams,
|
|
14
21
|
options?: Omit<
|
|
15
22
|
UseQueryOptions<
|
|
16
23
|
HttpTypes.AdminProductVariantListResponse,
|
|
@@ -29,3 +36,34 @@ export const useVariants = (
|
|
|
29
36
|
|
|
30
37
|
return { ...data, ...rest }
|
|
31
38
|
}
|
|
39
|
+
|
|
40
|
+
export const useInfiniteVariants = (
|
|
41
|
+
query?: Omit<HttpTypes.AdminProductVariantParams, "offset" | "limit"> & {
|
|
42
|
+
limit?: number
|
|
43
|
+
},
|
|
44
|
+
options?: Omit<
|
|
45
|
+
UseInfiniteQueryOptions<
|
|
46
|
+
HttpTypes.AdminProductVariantListResponse,
|
|
47
|
+
FetchError,
|
|
48
|
+
InfiniteData<HttpTypes.AdminProductVariantListResponse, number>,
|
|
49
|
+
HttpTypes.AdminProductVariantListResponse,
|
|
50
|
+
QueryKey,
|
|
51
|
+
number
|
|
52
|
+
>,
|
|
53
|
+
"queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
|
|
54
|
+
>
|
|
55
|
+
) => {
|
|
56
|
+
return useInfiniteList<
|
|
57
|
+
HttpTypes.AdminProductVariantListResponse,
|
|
58
|
+
HttpTypes.AdminProductVariantParams,
|
|
59
|
+
FetchError,
|
|
60
|
+
QueryKey
|
|
61
|
+
>({
|
|
62
|
+
queryKey: (params) => productVariantQueryKeys.list(params),
|
|
63
|
+
queryFn: async (params) => {
|
|
64
|
+
return await sdk.admin.productVariant.list(params)
|
|
65
|
+
},
|
|
66
|
+
query,
|
|
67
|
+
options,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
@@ -2,15 +2,18 @@ import { FetchError } from "@medusajs/js-sdk"
|
|
|
2
2
|
import { HttpTypes } from "@medusajs/types"
|
|
3
3
|
import {
|
|
4
4
|
QueryKey,
|
|
5
|
+
UseInfiniteQueryOptions,
|
|
5
6
|
useMutation,
|
|
6
7
|
UseMutationOptions,
|
|
7
8
|
useQuery,
|
|
8
9
|
UseQueryOptions,
|
|
9
10
|
} from "@tanstack/react-query"
|
|
11
|
+
import { InfiniteData } from "@tanstack/query-core"
|
|
10
12
|
import { sdk } from "../../lib/client"
|
|
11
13
|
import { queryClient } from "../../lib/query-client"
|
|
12
14
|
import { queryKeysFactory } from "../../lib/query-key-factory"
|
|
13
15
|
import { inventoryItemsQueryKeys } from "./inventory.tsx"
|
|
16
|
+
import { useInfiniteList } from "../use-infinite-list.tsx"
|
|
14
17
|
|
|
15
18
|
const PRODUCTS_QUERY_KEY = "products" as const
|
|
16
19
|
export const productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY)
|
|
@@ -310,6 +313,32 @@ export const useProducts = (
|
|
|
310
313
|
return { ...data, ...rest }
|
|
311
314
|
}
|
|
312
315
|
|
|
316
|
+
export const useInfiniteProducts = (
|
|
317
|
+
query?: HttpTypes.AdminProductListParams,
|
|
318
|
+
options?: Omit<
|
|
319
|
+
UseInfiniteQueryOptions<
|
|
320
|
+
HttpTypes.AdminProductListResponse,
|
|
321
|
+
FetchError,
|
|
322
|
+
InfiniteData<HttpTypes.AdminProductListResponse, number>,
|
|
323
|
+
HttpTypes.AdminProductListResponse,
|
|
324
|
+
QueryKey,
|
|
325
|
+
number
|
|
326
|
+
>,
|
|
327
|
+
"queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
|
|
328
|
+
>
|
|
329
|
+
) => {
|
|
330
|
+
return useInfiniteList<
|
|
331
|
+
HttpTypes.AdminProductListResponse,
|
|
332
|
+
HttpTypes.AdminProductListParams,
|
|
333
|
+
FetchError,
|
|
334
|
+
QueryKey
|
|
335
|
+
>({
|
|
336
|
+
queryKey: (params) => productsQueryKeys.list(params),
|
|
337
|
+
queryFn: (params) => sdk.admin.product.list(params),
|
|
338
|
+
query,
|
|
339
|
+
options,
|
|
340
|
+
})
|
|
341
|
+
}
|
|
313
342
|
export const useCreateProduct = (
|
|
314
343
|
options?: UseMutationOptions<
|
|
315
344
|
HttpTypes.AdminProductResponse,
|
package/src/hooks/api/tags.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FetchError } from "@medusajs/js-sdk"
|
|
2
2
|
import { HttpTypes } from "@medusajs/types"
|
|
3
3
|
import {
|
|
4
|
+
InfiniteData,
|
|
4
5
|
QueryKey,
|
|
6
|
+
UseInfiniteQueryOptions,
|
|
5
7
|
UseMutationOptions,
|
|
6
8
|
UseQueryOptions,
|
|
7
9
|
useMutation,
|
|
@@ -10,6 +12,7 @@ import {
|
|
|
10
12
|
import { sdk } from "../../lib/client"
|
|
11
13
|
import { queryClient } from "../../lib/query-client"
|
|
12
14
|
import { queryKeysFactory } from "../../lib/query-key-factory"
|
|
15
|
+
import { useInfiniteList } from "../use-infinite-list"
|
|
13
16
|
|
|
14
17
|
const TAGS_QUERY_KEY = "tags" as const
|
|
15
18
|
export const productTagsQueryKeys = queryKeysFactory(TAGS_QUERY_KEY)
|
|
@@ -57,6 +60,35 @@ export const useProductTags = (
|
|
|
57
60
|
return { ...data, ...rest }
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
export const useInfiniteProductTags = (
|
|
64
|
+
query?: Omit<HttpTypes.AdminProductTagListParams, "offset" | "limit"> & {
|
|
65
|
+
limit?: number
|
|
66
|
+
},
|
|
67
|
+
options?: Omit<
|
|
68
|
+
UseInfiniteQueryOptions<
|
|
69
|
+
HttpTypes.AdminProductTagListResponse,
|
|
70
|
+
FetchError,
|
|
71
|
+
InfiniteData<HttpTypes.AdminProductTagListResponse, number>,
|
|
72
|
+
HttpTypes.AdminProductTagListResponse,
|
|
73
|
+
QueryKey,
|
|
74
|
+
number
|
|
75
|
+
>,
|
|
76
|
+
"queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
|
|
77
|
+
>
|
|
78
|
+
) => {
|
|
79
|
+
return useInfiniteList<
|
|
80
|
+
HttpTypes.AdminProductTagListResponse,
|
|
81
|
+
HttpTypes.AdminProductTagListParams,
|
|
82
|
+
FetchError,
|
|
83
|
+
QueryKey
|
|
84
|
+
>({
|
|
85
|
+
queryKey: (params) => productTagsQueryKeys.list(params),
|
|
86
|
+
queryFn: (params) => sdk.admin.productTag.list(params),
|
|
87
|
+
query,
|
|
88
|
+
options,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
60
92
|
export const useCreateProductTag = (
|
|
61
93
|
query?: HttpTypes.AdminProductTagParams,
|
|
62
94
|
options?: UseMutationOptions<
|