@medusajs/loyalty-plugin 0.0.1
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/.medusa/server/src/admin/components/action-menu.js +63 -0
- package/.medusa/server/src/admin/components/chip-group.js +82 -0
- package/.medusa/server/src/admin/components/chip-input.js +157 -0
- package/.medusa/server/src/admin/components/combobox.js +324 -0
- package/.medusa/server/src/admin/components/conditional-tooltip.js +15 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +66 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +77 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +110 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +16 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +214 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +77 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +32 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +743 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +37 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +54 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +66 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +166 -0
- package/.medusa/server/src/admin/components/data-grid/components/index.js +16 -0
- package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +7 -0
- package/.medusa/server/src/admin/components/data-grid/context/index.js +6 -0
- package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +14 -0
- package/.medusa/server/src/admin/components/data-grid/data-grid.js +31 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +28 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +85 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/index.js +6 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/index.js +31 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +50 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +123 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +52 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +43 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +191 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +70 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +51 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +15 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +86 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +149 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +482 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +64 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +81 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +14 -0
- package/.medusa/server/src/admin/components/data-grid/index.js +8 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +27 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +296 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +62 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +25 -0
- package/.medusa/server/src/admin/components/data-grid/models/index.js +10 -0
- package/.medusa/server/src/admin/components/data-grid/types.js +1 -0
- package/.medusa/server/src/admin/components/data-grid/utils.js +18 -0
- package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +36 -0
- package/.medusa/server/src/admin/components/data-table/data-table.js +271 -0
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +51 -0
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +90 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +10 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +48 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +19 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +30 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +23 -0
- package/.medusa/server/src/admin/components/data-table/index.js +4 -0
- package/.medusa/server/src/admin/components/data-table.js +249 -0
- package/.medusa/server/src/admin/components/display-id.js +18 -0
- package/.medusa/server/src/admin/components/file-upload.js +116 -0
- package/.medusa/server/src/admin/components/form.js +151 -0
- package/.medusa/server/src/admin/components/handle-input.js +22 -0
- package/.medusa/server/src/admin/components/header.js +41 -0
- package/.medusa/server/src/admin/components/icon-avatar.js +27 -0
- package/.medusa/server/src/admin/components/json-view-section.js +139 -0
- package/.medusa/server/src/admin/components/keybound-form.js +32 -0
- package/.medusa/server/src/admin/components/layouts/single-column.js +7 -0
- package/.medusa/server/src/admin/components/layouts/two-column.js +13 -0
- package/.medusa/server/src/admin/components/listicle.js +20 -0
- package/.medusa/server/src/admin/components/modals/index.js +19 -0
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +57 -0
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +71 -0
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +60 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +6 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +5 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +30 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +12 -0
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +55 -0
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +63 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +6 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +47 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +14 -0
- package/.medusa/server/src/admin/components/placeholder-cell.js +7 -0
- package/.medusa/server/src/admin/components/product/product-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +15 -0
- package/.medusa/server/src/admin/components/product/product-status-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +18 -0
- package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +31 -0
- package/.medusa/server/src/admin/components/product/variant-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +15 -0
- package/.medusa/server/src/admin/components/section-row.js +32 -0
- package/.medusa/server/src/admin/components/sidebar-link.js +31 -0
- package/.medusa/server/src/admin/components/sortable-list.js +152 -0
- package/.medusa/server/src/admin/components/switch-box.js +43 -0
- package/.medusa/server/src/admin/components/tax-badge.js +18 -0
- package/.medusa/server/src/admin/components/thumbnail.js +28 -0
- package/.medusa/server/src/admin/components/upload-media-form-item.js +83 -0
- package/.medusa/server/src/admin/hooks/api/customers.js +26 -0
- package/.medusa/server/src/admin/hooks/api/gift-cards.js +107 -0
- package/.medusa/server/src/admin/hooks/api/order.js +16 -0
- package/.medusa/server/src/admin/hooks/api/price-preferences.js +19 -0
- package/.medusa/server/src/admin/hooks/api/products.js +127 -0
- package/.medusa/server/src/admin/hooks/api/regions.js +17 -0
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +28 -0
- package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +41 -0
- package/.medusa/server/src/admin/hooks/api/store.js +31 -0
- package/.medusa/server/src/admin/hooks/api/transaction-groups.js +23 -0
- package/.medusa/server/src/admin/hooks/api/transactions.js +23 -0
- package/.medusa/server/src/admin/hooks/commands/use-command-history.js +45 -0
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +59 -0
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +89 -0
- package/.medusa/server/src/admin/hooks/common/use-date.js +32 -0
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +22 -0
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +14 -0
- package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/sales-channels/index.js +10 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +48 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +19 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +23 -0
- package/.medusa/server/src/admin/lib/currencies.js +729 -0
- package/.medusa/server/src/admin/lib/query-key.js +17 -0
- package/.medusa/server/src/admin/lib/sdk.js +10 -0
- package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +75 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +172 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +30 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +180 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +30 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +97 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +162 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +89 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +199 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +353 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +5 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +247 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +5 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +48 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +14 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +28 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +40 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +121 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +72 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +123 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +1 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +98 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +28 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +96 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +90 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +288 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +111 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +285 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +124 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +112 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +1 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +35 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +11 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +61 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/page.js +18 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +137 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +87 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +352 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +116 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +49 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +177 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +27 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +33 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +33 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +18 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +50 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +78 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +40 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +57 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +13 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +61 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-cards/page.js +27 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +126 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +31 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +43 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +44 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +18 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +37 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +58 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +39 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +58 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +13 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +31 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +56 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +19 -0
- package/.medusa/server/src/admin/utils/date-utils.js +27 -0
- package/.medusa/server/src/admin/utils/format-amount.js +9 -0
- package/.medusa/server/src/admin/utils/format-date.js +21 -0
- package/.medusa/server/src/admin/utils/refs.js +20 -0
- package/.medusa/server/src/admin/utils/statuses.js +23 -0
- package/.medusa/server/src/admin/utils/validations.js +71 -0
- package/.medusa/server/src/admin/utils/variants.js +92 -0
- package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +67 -0
- package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +42 -0
- package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +58 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/redeem/route.js +25 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.js +41 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/transfer/route.js +24 -0
- package/.medusa/server/src/api/admin/gift-cards/middlewares.js +55 -0
- package/.medusa/server/src/api/admin/gift-cards/query-config.js +29 -0
- package/.medusa/server/src/api/admin/gift-cards/route.js +42 -0
- package/.medusa/server/src/api/admin/gift-cards/validators.js +69 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.js +24 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.js +23 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.js +38 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.js +43 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/route.js +52 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.js +51 -0
- package/.medusa/server/src/api/admin/transaction-groups/middlewares.js +16 -0
- package/.medusa/server/src/api/admin/transaction-groups/query-config.js +13 -0
- package/.medusa/server/src/api/admin/transaction-groups/route.js +27 -0
- package/.medusa/server/src/api/admin/transaction-groups/validators.js +19 -0
- package/.medusa/server/src/api/middlewares.js +22 -0
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.js +43 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +26 -0
- package/.medusa/server/src/api/store/carts/query-config.js +9 -0
- package/.medusa/server/src/api/store/carts/validators.js +15 -0
- package/.medusa/server/src/api/store/gift-card-invitations/[code]/accept/route.js +24 -0
- package/.medusa/server/src/api/store/gift-card-invitations/[code]/reject/route.js +24 -0
- package/.medusa/server/src/api/store/gift-card-invitations/middlewares.js +30 -0
- package/.medusa/server/src/api/store/gift-card-invitations/query-config.js +17 -0
- package/.medusa/server/src/api/store/gift-card-invitations/validators.js +14 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/invitation/route.js +26 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/redeem/route.js +24 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/route.js +16 -0
- package/.medusa/server/src/api/store/gift-cards/middlewares.js +46 -0
- package/.medusa/server/src/api/store/gift-cards/query-config.js +26 -0
- package/.medusa/server/src/api/store/gift-cards/route.js +28 -0
- package/.medusa/server/src/api/store/gift-cards/validators.js +26 -0
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.js +31 -0
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.js +28 -0
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.js +24 -0
- package/.medusa/server/src/api/store/store-credit-accounts/route.js +40 -0
- package/.medusa/server/src/api/store/store-credit-accounts/validators.js +17 -0
- package/.medusa/server/src/links/cart-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/customer-gift-card-link.js +13 -0
- package/.medusa/server/src/links/customer-store-credit-account-link.js +13 -0
- package/.medusa/server/src/links/order-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +19 -0
- package/.medusa/server/src/modules/loyalty/index.js +12 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.js +17 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.js +14 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.js +14 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card-invitation.js +20 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card.js +28 -0
- package/.medusa/server/src/modules/loyalty/service.js +15 -0
- package/.medusa/server/src/modules/store-credit/index.js +12 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.js +16 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.js +18 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.js +19 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.js +14 -0
- package/.medusa/server/src/modules/store-credit/models/account-transaction.js +27 -0
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.js +29 -0
- package/.medusa/server/src/modules/store-credit/models/transaction-group.js +28 -0
- package/.medusa/server/src/modules/store-credit/service.js +412 -0
- package/.medusa/server/src/providers/index.js +12 -0
- package/.medusa/server/src/providers/store-credit-payment/index.js +12 -0
- package/.medusa/server/src/providers/store-credit-payment/service.js +181 -0
- package/.medusa/server/src/subscribers/create-gift-card.js +94 -0
- package/.medusa/server/src/types/cart/index.js +3 -0
- package/.medusa/server/src/types/http/gift-card.js +3 -0
- package/.medusa/server/src/types/http/index.js +21 -0
- package/.medusa/server/src/types/http/store-credit-account.js +3 -0
- package/.medusa/server/src/types/http/transaction-group.js +3 -0
- package/.medusa/server/src/types/http/transaction.js +3 -0
- package/.medusa/server/src/types/index.js +21 -0
- package/.medusa/server/src/types/loyalty/index.js +20 -0
- package/.medusa/server/src/types/loyalty/module.js +17 -0
- package/.medusa/server/src/types/loyalty/service.js +3 -0
- package/.medusa/server/src/types/loyalty/workflows.js +3 -0
- package/.medusa/server/src/types/modules.js +14 -0
- package/.medusa/server/src/types/store-credit/index.js +19 -0
- package/.medusa/server/src/types/store-credit/module.js +10 -0
- package/.medusa/server/src/types/store-credit/service.js +3 -0
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.js +167 -0
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.js +95 -0
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.js +136 -0
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.js +66 -0
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.js +11 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/create-gift-card-invitation.js +17 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/delete-gift-card-invitation.js +20 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/update-gift-card-invitation.js +31 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/accept-gift-card-invitation.js +79 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/create-gift-card-invitation.js +66 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/delete-gift-card-invitation.js +10 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/reject-gift-card-invitation.js +70 -0
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.js +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.js +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.js +20 -0
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.js +34 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.js +12 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.js +19 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.js +90 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/transfer-gift-card.js +48 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.js +12 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +26 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +27 -0
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.js +58 -0
- package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +96 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-transaction-groups.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.js +17 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.js +57 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-transaction-groups.js +12 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.js +12 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.js +12 -0
- package/.medusa/server/types/loyalty/module.js +8 -0
- package/README.md +62 -0
- package/package.json +94 -0
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AdjustmentsDone, Adjustments, ExclamationCircle } from "@medusajs/icons";
|
|
3
|
+
import { DropdownMenu, Button, clx } from "@medusajs/ui";
|
|
4
|
+
import { useReactTable, getCoreRowModel, flexRender } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@tanstack/react-table/build/lib/index.mjs";
|
|
5
|
+
import { useVirtualizer } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@tanstack/react-virtual/dist/esm/index.js";
|
|
6
|
+
import { useRef, useState, useMemo, useCallback, useEffect } from "react";
|
|
7
|
+
import { useCommandHistory } from "../../../hooks/commands/use-command-history.js";
|
|
8
|
+
import { ConditionalTooltip } from "../../conditional-tooltip.js";
|
|
9
|
+
import { DataGridContext } from "../context/data-grid-context.js";
|
|
10
|
+
import { isSpecialFocusKey, isCellMatch } from "../utils.js";
|
|
11
|
+
import { useDataGridCellHandlers } from "../hooks/use-data-grid-cell-handlers.js";
|
|
12
|
+
import { useDataGridCellMetadata } from "../hooks/use-data-grid-cell-metadata.js";
|
|
13
|
+
import { useDataGridCellSnapshot } from "../hooks/use-data-grid-cell-snapshot.js";
|
|
14
|
+
import { useDataGridClipboardEvents } from "../hooks/use-data-grid-clipboard-events.js";
|
|
15
|
+
import { useDataGridColumnVisibility } from "../hooks/use-data-grid-column-visibility.js";
|
|
16
|
+
import { useDataGridErrorHighlighting } from "../hooks/use-data-grid-error-highlighting.js";
|
|
17
|
+
import { useDataGridFormHandlers } from "../hooks/use-data-grid-form-handlers.js";
|
|
18
|
+
import { useDataGridKeydownEvent } from "../hooks/use-data-grid-keydown-event.js";
|
|
19
|
+
import { useDataGridMouseUpEvent } from "../hooks/use-data-grid-mouse-up-event.js";
|
|
20
|
+
import { useDataGridNavigation } from "../hooks/use-data-grid-navigation.js";
|
|
21
|
+
import { useDataGridQueryTool } from "../hooks/use-data-grid-query-tool.js";
|
|
22
|
+
import { DataGridMatrix } from "../models/data-grid-matrix.js";
|
|
23
|
+
const ROW_HEIGHT = 40;
|
|
24
|
+
const getCommonPinningStyles = (column) => {
|
|
25
|
+
const isPinned = column.getIsPinned();
|
|
26
|
+
const isDarkMode = document.documentElement.classList.contains("dark");
|
|
27
|
+
const BORDER_COLOR = isDarkMode ? "rgb(50,50,53)" : "rgb(228,228,231)";
|
|
28
|
+
return {
|
|
29
|
+
position: isPinned ? "sticky" : "relative",
|
|
30
|
+
width: column.getSize(),
|
|
31
|
+
zIndex: isPinned ? 1 : 0,
|
|
32
|
+
borderBottom: isPinned ? `1px solid ${BORDER_COLOR}` : void 0,
|
|
33
|
+
borderRight: isPinned ? `1px solid ${BORDER_COLOR}` : void 0,
|
|
34
|
+
left: isPinned === "left" ? `${column.getStart("left")}px` : void 0,
|
|
35
|
+
right: isPinned === "right" ? `${column.getAfter("right")}px` : void 0
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const DataGridRoot = ({
|
|
39
|
+
data = [],
|
|
40
|
+
columns,
|
|
41
|
+
state,
|
|
42
|
+
getSubRows,
|
|
43
|
+
onEditingChange,
|
|
44
|
+
disableInteractions,
|
|
45
|
+
multiColumnSelection = false
|
|
46
|
+
}) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const containerRef = useRef(null);
|
|
49
|
+
const { redo, undo, execute } = useCommandHistory();
|
|
50
|
+
const {
|
|
51
|
+
register,
|
|
52
|
+
control,
|
|
53
|
+
getValues,
|
|
54
|
+
setValue,
|
|
55
|
+
formState: { errors }
|
|
56
|
+
} = state;
|
|
57
|
+
const [internalTrapActive, setTrapActive] = useState(true);
|
|
58
|
+
const trapActive = !disableInteractions && internalTrapActive;
|
|
59
|
+
const [anchor, setAnchor] = useState(null);
|
|
60
|
+
const [rangeEnd, setRangeEnd] = useState(null);
|
|
61
|
+
const [dragEnd, setDragEnd] = useState(null);
|
|
62
|
+
const [isSelecting, setIsSelecting] = useState(false);
|
|
63
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
64
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
65
|
+
const [columnVisibility, setColumnVisibility] = useState({});
|
|
66
|
+
const [rowVisibility, setRowVisibility] = useState({});
|
|
67
|
+
const grid = useReactTable({
|
|
68
|
+
data,
|
|
69
|
+
columns,
|
|
70
|
+
initialState: {
|
|
71
|
+
columnPinning: {
|
|
72
|
+
left: [columns[0].id]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
state: {
|
|
76
|
+
columnVisibility
|
|
77
|
+
},
|
|
78
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
79
|
+
getSubRows,
|
|
80
|
+
getCoreRowModel: getCoreRowModel(),
|
|
81
|
+
defaultColumn: {
|
|
82
|
+
size: 200,
|
|
83
|
+
maxSize: 400
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const { flatRows } = grid.getRowModel();
|
|
87
|
+
const flatColumns = grid.getAllFlatColumns();
|
|
88
|
+
const visibleRows = useMemo(
|
|
89
|
+
() => flatRows.filter((_, index) => (rowVisibility == null ? void 0 : rowVisibility[index]) !== false),
|
|
90
|
+
[flatRows, rowVisibility]
|
|
91
|
+
);
|
|
92
|
+
const visibleColumns = grid.getVisibleLeafColumns();
|
|
93
|
+
const rowVirtualizer = useVirtualizer({
|
|
94
|
+
count: visibleRows.length,
|
|
95
|
+
estimateSize: () => ROW_HEIGHT,
|
|
96
|
+
getScrollElement: () => containerRef.current,
|
|
97
|
+
overscan: 5,
|
|
98
|
+
rangeExtractor: (range) => {
|
|
99
|
+
const toRender = new Set(
|
|
100
|
+
Array.from(
|
|
101
|
+
{ length: range.endIndex - range.startIndex + 1 },
|
|
102
|
+
(_, i) => range.startIndex + i
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
if (anchor && visibleRows[anchor.row]) {
|
|
106
|
+
toRender.add(anchor.row);
|
|
107
|
+
}
|
|
108
|
+
if (rangeEnd && visibleRows[rangeEnd.row]) {
|
|
109
|
+
toRender.add(rangeEnd.row);
|
|
110
|
+
}
|
|
111
|
+
return Array.from(toRender).sort((a, b) => a - b);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
115
|
+
const columnVirtualizer = useVirtualizer({
|
|
116
|
+
count: visibleColumns.length,
|
|
117
|
+
estimateSize: (index) => visibleColumns[index].getSize(),
|
|
118
|
+
getScrollElement: () => containerRef.current,
|
|
119
|
+
horizontal: true,
|
|
120
|
+
overscan: 3,
|
|
121
|
+
rangeExtractor: (range) => {
|
|
122
|
+
const startIndex = range.startIndex;
|
|
123
|
+
const endIndex = range.endIndex;
|
|
124
|
+
const toRender = new Set(
|
|
125
|
+
Array.from(
|
|
126
|
+
{ length: endIndex - startIndex + 1 },
|
|
127
|
+
(_, i) => startIndex + i
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
if (anchor && visibleColumns[anchor.col]) {
|
|
131
|
+
toRender.add(anchor.col);
|
|
132
|
+
}
|
|
133
|
+
if (rangeEnd && visibleColumns[rangeEnd.col]) {
|
|
134
|
+
toRender.add(rangeEnd.col);
|
|
135
|
+
}
|
|
136
|
+
toRender.add(0);
|
|
137
|
+
return Array.from(toRender).sort((a, b) => a - b);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
141
|
+
let virtualPaddingLeft;
|
|
142
|
+
let virtualPaddingRight;
|
|
143
|
+
if (columnVirtualizer && (virtualColumns == null ? void 0 : virtualColumns.length)) {
|
|
144
|
+
virtualPaddingLeft = ((_a = virtualColumns[0]) == null ? void 0 : _a.start) ?? 0;
|
|
145
|
+
virtualPaddingRight = columnVirtualizer.getTotalSize() - (((_b = virtualColumns[virtualColumns.length - 1]) == null ? void 0 : _b.end) ?? 0);
|
|
146
|
+
}
|
|
147
|
+
const matrix = useMemo(
|
|
148
|
+
() => new DataGridMatrix(
|
|
149
|
+
flatRows,
|
|
150
|
+
columns,
|
|
151
|
+
multiColumnSelection
|
|
152
|
+
),
|
|
153
|
+
[flatRows, columns, multiColumnSelection]
|
|
154
|
+
);
|
|
155
|
+
const queryTool = useDataGridQueryTool(containerRef);
|
|
156
|
+
const setSingleRange = useCallback(
|
|
157
|
+
(coordinates) => {
|
|
158
|
+
setAnchor(coordinates);
|
|
159
|
+
setRangeEnd(coordinates);
|
|
160
|
+
},
|
|
161
|
+
[]
|
|
162
|
+
);
|
|
163
|
+
const { errorCount, isHighlighted, toggleErrorHighlighting } = useDataGridErrorHighlighting(matrix, grid, errors);
|
|
164
|
+
const handleToggleErrorHighlighting = useCallback(() => {
|
|
165
|
+
toggleErrorHighlighting(
|
|
166
|
+
rowVisibility,
|
|
167
|
+
columnVisibility,
|
|
168
|
+
setRowVisibility,
|
|
169
|
+
setColumnVisibility
|
|
170
|
+
);
|
|
171
|
+
}, [toggleErrorHighlighting, rowVisibility, columnVisibility]);
|
|
172
|
+
const {
|
|
173
|
+
columnOptions,
|
|
174
|
+
handleToggleColumn,
|
|
175
|
+
handleResetColumns,
|
|
176
|
+
isDisabled: isColumsDisabled
|
|
177
|
+
} = useDataGridColumnVisibility(grid, matrix);
|
|
178
|
+
const handleToggleColumnVisibility = useCallback(
|
|
179
|
+
(index) => {
|
|
180
|
+
return handleToggleColumn(index);
|
|
181
|
+
},
|
|
182
|
+
[handleToggleColumn]
|
|
183
|
+
);
|
|
184
|
+
const { navigateToField, scrollToCoordinates } = useDataGridNavigation({
|
|
185
|
+
matrix,
|
|
186
|
+
queryTool,
|
|
187
|
+
anchor,
|
|
188
|
+
columnVirtualizer,
|
|
189
|
+
rowVirtualizer,
|
|
190
|
+
flatColumns,
|
|
191
|
+
setColumnVisibility,
|
|
192
|
+
setSingleRange,
|
|
193
|
+
visibleColumns,
|
|
194
|
+
visibleRows
|
|
195
|
+
});
|
|
196
|
+
const { createSnapshot, restoreSnapshot } = useDataGridCellSnapshot({
|
|
197
|
+
matrix,
|
|
198
|
+
form: state
|
|
199
|
+
});
|
|
200
|
+
const onEditingChangeHandler = useCallback(
|
|
201
|
+
(value) => {
|
|
202
|
+
if (onEditingChange) {
|
|
203
|
+
onEditingChange(value);
|
|
204
|
+
}
|
|
205
|
+
if (value) {
|
|
206
|
+
createSnapshot(anchor);
|
|
207
|
+
}
|
|
208
|
+
setIsEditing(value);
|
|
209
|
+
},
|
|
210
|
+
[anchor, createSnapshot, onEditingChange]
|
|
211
|
+
);
|
|
212
|
+
const { getSelectionValues, setSelectionValues } = useDataGridFormHandlers({
|
|
213
|
+
matrix,
|
|
214
|
+
form: state,
|
|
215
|
+
anchor
|
|
216
|
+
});
|
|
217
|
+
const { handleKeyDownEvent, handleSpecialFocusKeys } = useDataGridKeydownEvent({
|
|
218
|
+
containerRef,
|
|
219
|
+
matrix,
|
|
220
|
+
queryTool,
|
|
221
|
+
anchor,
|
|
222
|
+
rangeEnd,
|
|
223
|
+
isEditing,
|
|
224
|
+
setTrapActive,
|
|
225
|
+
setRangeEnd,
|
|
226
|
+
getSelectionValues,
|
|
227
|
+
getValues,
|
|
228
|
+
setSelectionValues,
|
|
229
|
+
onEditingChangeHandler,
|
|
230
|
+
restoreSnapshot,
|
|
231
|
+
createSnapshot,
|
|
232
|
+
setSingleRange,
|
|
233
|
+
scrollToCoordinates,
|
|
234
|
+
execute,
|
|
235
|
+
undo,
|
|
236
|
+
redo,
|
|
237
|
+
setValue
|
|
238
|
+
});
|
|
239
|
+
const { handleMouseUpEvent } = useDataGridMouseUpEvent({
|
|
240
|
+
matrix,
|
|
241
|
+
anchor,
|
|
242
|
+
dragEnd,
|
|
243
|
+
setDragEnd,
|
|
244
|
+
isDragging,
|
|
245
|
+
setIsDragging,
|
|
246
|
+
setRangeEnd,
|
|
247
|
+
setIsSelecting,
|
|
248
|
+
getSelectionValues,
|
|
249
|
+
setSelectionValues,
|
|
250
|
+
execute
|
|
251
|
+
});
|
|
252
|
+
const { handleCopyEvent, handlePasteEvent } = useDataGridClipboardEvents({
|
|
253
|
+
matrix,
|
|
254
|
+
isEditing,
|
|
255
|
+
anchor,
|
|
256
|
+
rangeEnd,
|
|
257
|
+
getSelectionValues,
|
|
258
|
+
setSelectionValues,
|
|
259
|
+
execute
|
|
260
|
+
});
|
|
261
|
+
const {
|
|
262
|
+
getWrapperFocusHandler,
|
|
263
|
+
getInputChangeHandler,
|
|
264
|
+
getOverlayMouseDownHandler,
|
|
265
|
+
getWrapperMouseOverHandler,
|
|
266
|
+
getIsCellDragSelected,
|
|
267
|
+
getIsCellSelected,
|
|
268
|
+
onDragToFillStart
|
|
269
|
+
} = useDataGridCellHandlers({
|
|
270
|
+
matrix,
|
|
271
|
+
anchor,
|
|
272
|
+
rangeEnd,
|
|
273
|
+
setRangeEnd,
|
|
274
|
+
isDragging,
|
|
275
|
+
setIsDragging,
|
|
276
|
+
isSelecting,
|
|
277
|
+
setIsSelecting,
|
|
278
|
+
setSingleRange,
|
|
279
|
+
dragEnd,
|
|
280
|
+
setDragEnd,
|
|
281
|
+
setValue,
|
|
282
|
+
execute,
|
|
283
|
+
multiColumnSelection
|
|
284
|
+
});
|
|
285
|
+
const { getCellErrorMetadata, getCellMetadata } = useDataGridCellMetadata({
|
|
286
|
+
matrix
|
|
287
|
+
});
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
if (!trapActive) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
window.addEventListener("keydown", handleKeyDownEvent);
|
|
293
|
+
window.addEventListener("mouseup", handleMouseUpEvent);
|
|
294
|
+
window.addEventListener("copy", handleCopyEvent);
|
|
295
|
+
window.addEventListener("paste", handlePasteEvent);
|
|
296
|
+
return () => {
|
|
297
|
+
window.removeEventListener("keydown", handleKeyDownEvent);
|
|
298
|
+
window.removeEventListener("mouseup", handleMouseUpEvent);
|
|
299
|
+
window.removeEventListener("copy", handleCopyEvent);
|
|
300
|
+
window.removeEventListener("paste", handlePasteEvent);
|
|
301
|
+
};
|
|
302
|
+
}, [
|
|
303
|
+
trapActive,
|
|
304
|
+
handleKeyDownEvent,
|
|
305
|
+
handleMouseUpEvent,
|
|
306
|
+
handleCopyEvent,
|
|
307
|
+
handlePasteEvent
|
|
308
|
+
]);
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
const specialFocusHandler = (e) => {
|
|
311
|
+
if (isSpecialFocusKey(e)) {
|
|
312
|
+
handleSpecialFocusKeys(e);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
window.addEventListener("keydown", specialFocusHandler);
|
|
317
|
+
return () => {
|
|
318
|
+
window.removeEventListener("keydown", specialFocusHandler);
|
|
319
|
+
};
|
|
320
|
+
}, [handleSpecialFocusKeys]);
|
|
321
|
+
const handleHeaderInteractionChange = useCallback((isActive) => {
|
|
322
|
+
if (isActive) {
|
|
323
|
+
setTrapActive(false);
|
|
324
|
+
}
|
|
325
|
+
}, []);
|
|
326
|
+
useEffect(() => {
|
|
327
|
+
if (!anchor) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (rangeEnd) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
setRangeEnd(anchor);
|
|
334
|
+
}, [anchor, rangeEnd]);
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
if (!anchor && matrix) {
|
|
337
|
+
const coords = matrix.getFirstNavigableCell();
|
|
338
|
+
if (coords) {
|
|
339
|
+
setSingleRange(coords);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}, [anchor, matrix, setSingleRange]);
|
|
343
|
+
const values = useMemo(
|
|
344
|
+
() => ({
|
|
345
|
+
anchor,
|
|
346
|
+
control,
|
|
347
|
+
trapActive,
|
|
348
|
+
errors,
|
|
349
|
+
setTrapActive,
|
|
350
|
+
setIsSelecting,
|
|
351
|
+
setIsEditing: onEditingChangeHandler,
|
|
352
|
+
setSingleRange,
|
|
353
|
+
setRangeEnd,
|
|
354
|
+
getWrapperFocusHandler,
|
|
355
|
+
getInputChangeHandler,
|
|
356
|
+
getOverlayMouseDownHandler,
|
|
357
|
+
getWrapperMouseOverHandler,
|
|
358
|
+
register,
|
|
359
|
+
getIsCellSelected,
|
|
360
|
+
getIsCellDragSelected,
|
|
361
|
+
getCellMetadata,
|
|
362
|
+
getCellErrorMetadata,
|
|
363
|
+
navigateToField
|
|
364
|
+
}),
|
|
365
|
+
[
|
|
366
|
+
anchor,
|
|
367
|
+
control,
|
|
368
|
+
trapActive,
|
|
369
|
+
errors,
|
|
370
|
+
setTrapActive,
|
|
371
|
+
setIsSelecting,
|
|
372
|
+
onEditingChangeHandler,
|
|
373
|
+
setSingleRange,
|
|
374
|
+
setRangeEnd,
|
|
375
|
+
getWrapperFocusHandler,
|
|
376
|
+
getInputChangeHandler,
|
|
377
|
+
getOverlayMouseDownHandler,
|
|
378
|
+
getWrapperMouseOverHandler,
|
|
379
|
+
register,
|
|
380
|
+
getIsCellSelected,
|
|
381
|
+
getIsCellDragSelected,
|
|
382
|
+
getCellMetadata,
|
|
383
|
+
getCellErrorMetadata,
|
|
384
|
+
navigateToField
|
|
385
|
+
]
|
|
386
|
+
);
|
|
387
|
+
const handleRestoreGridFocus = useCallback(() => {
|
|
388
|
+
if (anchor && !trapActive) {
|
|
389
|
+
setTrapActive(true);
|
|
390
|
+
setSingleRange(anchor);
|
|
391
|
+
scrollToCoordinates(anchor, "both");
|
|
392
|
+
requestAnimationFrame(() => {
|
|
393
|
+
var _a2;
|
|
394
|
+
(_a2 = queryTool == null ? void 0 : queryTool.getContainer(anchor)) == null ? void 0 : _a2.focus();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}, [anchor, trapActive, setSingleRange, scrollToCoordinates, queryTool]);
|
|
398
|
+
return /* @__PURE__ */ jsx(DataGridContext.Provider, { value: values, children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle flex size-full flex-col", children: [
|
|
399
|
+
/* @__PURE__ */ jsx(
|
|
400
|
+
DataGridHeader,
|
|
401
|
+
{
|
|
402
|
+
columnOptions,
|
|
403
|
+
isDisabled: isColumsDisabled,
|
|
404
|
+
onToggleColumn: handleToggleColumnVisibility,
|
|
405
|
+
errorCount,
|
|
406
|
+
onToggleErrorHighlighting: handleToggleErrorHighlighting,
|
|
407
|
+
onResetColumns: handleResetColumns,
|
|
408
|
+
isHighlighted,
|
|
409
|
+
onHeaderInteractionChange: handleHeaderInteractionChange
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
/* @__PURE__ */ jsx("div", { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
413
|
+
"div",
|
|
414
|
+
{
|
|
415
|
+
ref: containerRef,
|
|
416
|
+
autoFocus: true,
|
|
417
|
+
tabIndex: 0,
|
|
418
|
+
className: "relative h-full select-none overflow-auto outline-none",
|
|
419
|
+
onFocus: handleRestoreGridFocus,
|
|
420
|
+
onClick: handleRestoreGridFocus,
|
|
421
|
+
"data-container": true,
|
|
422
|
+
role: "application",
|
|
423
|
+
children: /* @__PURE__ */ jsxs("div", { role: "grid", className: "text-ui-fg-subtle grid", children: [
|
|
424
|
+
/* @__PURE__ */ jsx(
|
|
425
|
+
"div",
|
|
426
|
+
{
|
|
427
|
+
role: "rowgroup",
|
|
428
|
+
className: "txt-compact-small-plus bg-ui-bg-subtle sticky top-0 z-[1] grid",
|
|
429
|
+
children: grid.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs(
|
|
430
|
+
"div",
|
|
431
|
+
{
|
|
432
|
+
role: "row",
|
|
433
|
+
className: "flex h-10 w-full",
|
|
434
|
+
children: [
|
|
435
|
+
virtualPaddingLeft ? /* @__PURE__ */ jsx(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
role: "presentation",
|
|
439
|
+
style: { display: "flex", width: virtualPaddingLeft }
|
|
440
|
+
}
|
|
441
|
+
) : null,
|
|
442
|
+
virtualColumns.reduce((acc, vc, index, array) => {
|
|
443
|
+
const header = headerGroup.headers[vc.index];
|
|
444
|
+
const previousVC = array[index - 1];
|
|
445
|
+
if (previousVC && vc.index !== previousVC.index + 1) {
|
|
446
|
+
acc.push(
|
|
447
|
+
/* @__PURE__ */ jsx(
|
|
448
|
+
"div",
|
|
449
|
+
{
|
|
450
|
+
role: "presentation",
|
|
451
|
+
style: {
|
|
452
|
+
display: "flex",
|
|
453
|
+
width: `${vc.start - previousVC.end}px`
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
`padding-${previousVC.index}-${vc.index}`
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
acc.push(
|
|
461
|
+
/* @__PURE__ */ jsx(
|
|
462
|
+
"div",
|
|
463
|
+
{
|
|
464
|
+
role: "columnheader",
|
|
465
|
+
"data-column-index": vc.index,
|
|
466
|
+
style: {
|
|
467
|
+
width: header.getSize(),
|
|
468
|
+
...getCommonPinningStyles(header.column)
|
|
469
|
+
},
|
|
470
|
+
className: "bg-ui-bg-base txt-compact-small-plus flex items-center border-b border-r px-4 py-2.5",
|
|
471
|
+
children: header.isPlaceholder ? null : flexRender(
|
|
472
|
+
header.column.columnDef.header,
|
|
473
|
+
header.getContext()
|
|
474
|
+
)
|
|
475
|
+
},
|
|
476
|
+
header.id
|
|
477
|
+
)
|
|
478
|
+
);
|
|
479
|
+
return acc;
|
|
480
|
+
}, []),
|
|
481
|
+
virtualPaddingRight ? /* @__PURE__ */ jsx(
|
|
482
|
+
"div",
|
|
483
|
+
{
|
|
484
|
+
role: "presentation",
|
|
485
|
+
style: {
|
|
486
|
+
display: "flex",
|
|
487
|
+
width: virtualPaddingRight
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
) : null
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
headerGroup.id
|
|
494
|
+
))
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
/* @__PURE__ */ jsx(
|
|
498
|
+
"div",
|
|
499
|
+
{
|
|
500
|
+
role: "rowgroup",
|
|
501
|
+
className: "relative grid",
|
|
502
|
+
style: {
|
|
503
|
+
height: `${rowVirtualizer.getTotalSize()}px`
|
|
504
|
+
},
|
|
505
|
+
children: virtualRows.map((virtualRow) => {
|
|
506
|
+
const row = visibleRows[virtualRow.index];
|
|
507
|
+
const rowIndex = flatRows.findIndex((r) => r.id === row.id);
|
|
508
|
+
return /* @__PURE__ */ jsx(
|
|
509
|
+
DataGridRow,
|
|
510
|
+
{
|
|
511
|
+
row,
|
|
512
|
+
rowIndex,
|
|
513
|
+
virtualRow,
|
|
514
|
+
flatColumns,
|
|
515
|
+
virtualColumns,
|
|
516
|
+
anchor,
|
|
517
|
+
virtualPaddingLeft,
|
|
518
|
+
virtualPaddingRight,
|
|
519
|
+
onDragToFillStart,
|
|
520
|
+
multiColumnSelection
|
|
521
|
+
},
|
|
522
|
+
row.id
|
|
523
|
+
);
|
|
524
|
+
})
|
|
525
|
+
}
|
|
526
|
+
)
|
|
527
|
+
] })
|
|
528
|
+
}
|
|
529
|
+
) })
|
|
530
|
+
] }) });
|
|
531
|
+
};
|
|
532
|
+
const DataGridHeader = ({
|
|
533
|
+
columnOptions,
|
|
534
|
+
isDisabled,
|
|
535
|
+
onToggleColumn,
|
|
536
|
+
onResetColumns,
|
|
537
|
+
isHighlighted,
|
|
538
|
+
errorCount,
|
|
539
|
+
onToggleErrorHighlighting,
|
|
540
|
+
onHeaderInteractionChange
|
|
541
|
+
}) => {
|
|
542
|
+
const [columnsOpen, setColumnsOpen] = useState(false);
|
|
543
|
+
const hasChanged = columnOptions.some((column) => !column.checked);
|
|
544
|
+
const handleColumnsOpenChange = (value) => {
|
|
545
|
+
onHeaderInteractionChange(value);
|
|
546
|
+
setColumnsOpen(value);
|
|
547
|
+
};
|
|
548
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base flex items-center justify-between border-b p-4", children: [
|
|
549
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
550
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { open: columnsOpen, onOpenChange: handleColumnsOpenChange, children: [
|
|
551
|
+
/* @__PURE__ */ jsx(
|
|
552
|
+
ConditionalTooltip,
|
|
553
|
+
{
|
|
554
|
+
showTooltip: isDisabled,
|
|
555
|
+
content: "Changing which columns are visible is disabled.",
|
|
556
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, disabled: isDisabled, children: /* @__PURE__ */ jsxs(Button, { size: "small", variant: "secondary", children: [
|
|
557
|
+
hasChanged ? /* @__PURE__ */ jsx(AdjustmentsDone, {}) : /* @__PURE__ */ jsx(Adjustments, {}),
|
|
558
|
+
"View"
|
|
559
|
+
] }) })
|
|
560
|
+
}
|
|
561
|
+
),
|
|
562
|
+
/* @__PURE__ */ jsx(DropdownMenu.Content, { children: columnOptions.map((column, index) => {
|
|
563
|
+
const { checked, disabled, id, name } = column;
|
|
564
|
+
if (disabled) {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
return /* @__PURE__ */ jsx(
|
|
568
|
+
DropdownMenu.CheckboxItem,
|
|
569
|
+
{
|
|
570
|
+
checked,
|
|
571
|
+
onCheckedChange: onToggleColumn(index),
|
|
572
|
+
onSelect: (e) => e.preventDefault(),
|
|
573
|
+
children: name
|
|
574
|
+
},
|
|
575
|
+
id
|
|
576
|
+
);
|
|
577
|
+
}) })
|
|
578
|
+
] }),
|
|
579
|
+
hasChanged && /* @__PURE__ */ jsx(
|
|
580
|
+
Button,
|
|
581
|
+
{
|
|
582
|
+
size: "small",
|
|
583
|
+
variant: "transparent",
|
|
584
|
+
type: "button",
|
|
585
|
+
onClick: onResetColumns,
|
|
586
|
+
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
587
|
+
"data-id": "reset-columns",
|
|
588
|
+
children: "Reset to default"
|
|
589
|
+
}
|
|
590
|
+
)
|
|
591
|
+
] }),
|
|
592
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2", children: errorCount > 0 && /* @__PURE__ */ jsxs(
|
|
593
|
+
Button,
|
|
594
|
+
{
|
|
595
|
+
size: "small",
|
|
596
|
+
variant: "secondary",
|
|
597
|
+
type: "button",
|
|
598
|
+
onClick: onToggleErrorHighlighting,
|
|
599
|
+
className: clx({
|
|
600
|
+
"bg-ui-button-neutral-pressed": isHighlighted
|
|
601
|
+
}),
|
|
602
|
+
children: [
|
|
603
|
+
/* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-fg-subtle" }),
|
|
604
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
605
|
+
errorCount,
|
|
606
|
+
" errors"
|
|
607
|
+
] })
|
|
608
|
+
]
|
|
609
|
+
}
|
|
610
|
+
) })
|
|
611
|
+
] });
|
|
612
|
+
};
|
|
613
|
+
const DataGridCell = ({
|
|
614
|
+
cell,
|
|
615
|
+
columnIndex,
|
|
616
|
+
rowIndex,
|
|
617
|
+
anchor,
|
|
618
|
+
onDragToFillStart,
|
|
619
|
+
multiColumnSelection
|
|
620
|
+
}) => {
|
|
621
|
+
const coords = {
|
|
622
|
+
row: rowIndex,
|
|
623
|
+
col: columnIndex
|
|
624
|
+
};
|
|
625
|
+
const isAnchor = isCellMatch(coords, anchor);
|
|
626
|
+
return /* @__PURE__ */ jsx(
|
|
627
|
+
"div",
|
|
628
|
+
{
|
|
629
|
+
role: "gridcell",
|
|
630
|
+
"aria-rowindex": rowIndex,
|
|
631
|
+
"aria-colindex": columnIndex,
|
|
632
|
+
style: {
|
|
633
|
+
width: cell.column.getSize(),
|
|
634
|
+
...getCommonPinningStyles(cell.column)
|
|
635
|
+
},
|
|
636
|
+
"data-row-index": rowIndex,
|
|
637
|
+
"data-column-index": columnIndex,
|
|
638
|
+
className: clx(
|
|
639
|
+
"relative flex items-center border-b border-r p-0 outline-none"
|
|
640
|
+
),
|
|
641
|
+
tabIndex: -1,
|
|
642
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative h-full w-full", children: [
|
|
643
|
+
flexRender(cell.column.columnDef.cell, {
|
|
644
|
+
...cell.getContext(),
|
|
645
|
+
columnIndex,
|
|
646
|
+
rowIndex
|
|
647
|
+
}),
|
|
648
|
+
isAnchor && /* @__PURE__ */ jsx(
|
|
649
|
+
"div",
|
|
650
|
+
{
|
|
651
|
+
onMouseDown: onDragToFillStart,
|
|
652
|
+
className: clx(
|
|
653
|
+
"bg-ui-fg-interactive absolute bottom-0 right-0 z-[3] size-1.5 cursor-ns-resize",
|
|
654
|
+
{
|
|
655
|
+
"cursor-nwse-resize": multiColumnSelection
|
|
656
|
+
}
|
|
657
|
+
)
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
] })
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
};
|
|
664
|
+
const DataGridRow = ({
|
|
665
|
+
row,
|
|
666
|
+
rowIndex,
|
|
667
|
+
virtualRow,
|
|
668
|
+
virtualPaddingLeft,
|
|
669
|
+
virtualPaddingRight,
|
|
670
|
+
virtualColumns,
|
|
671
|
+
flatColumns,
|
|
672
|
+
anchor,
|
|
673
|
+
onDragToFillStart,
|
|
674
|
+
multiColumnSelection
|
|
675
|
+
}) => {
|
|
676
|
+
const visibleCells = row.getVisibleCells();
|
|
677
|
+
return /* @__PURE__ */ jsxs(
|
|
678
|
+
"div",
|
|
679
|
+
{
|
|
680
|
+
role: "row",
|
|
681
|
+
"aria-rowindex": virtualRow.index,
|
|
682
|
+
style: {
|
|
683
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
684
|
+
},
|
|
685
|
+
className: "bg-ui-bg-subtle txt-compact-small absolute flex h-10 w-full",
|
|
686
|
+
children: [
|
|
687
|
+
virtualPaddingLeft ? /* @__PURE__ */ jsx(
|
|
688
|
+
"div",
|
|
689
|
+
{
|
|
690
|
+
role: "presentation",
|
|
691
|
+
style: { display: "flex", width: virtualPaddingLeft }
|
|
692
|
+
}
|
|
693
|
+
) : null,
|
|
694
|
+
virtualColumns.reduce((acc, vc, index, array) => {
|
|
695
|
+
const cell = visibleCells[vc.index];
|
|
696
|
+
const column = cell.column;
|
|
697
|
+
const columnIndex = flatColumns.findIndex((c) => c.id === column.id);
|
|
698
|
+
const previousVC = array[index - 1];
|
|
699
|
+
if (previousVC && vc.index !== previousVC.index + 1) {
|
|
700
|
+
acc.push(
|
|
701
|
+
/* @__PURE__ */ jsx(
|
|
702
|
+
"div",
|
|
703
|
+
{
|
|
704
|
+
role: "presentation",
|
|
705
|
+
style: {
|
|
706
|
+
display: "flex",
|
|
707
|
+
width: `${vc.start - previousVC.end}px`
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
`padding-${previousVC.index}-${vc.index}`
|
|
711
|
+
)
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
acc.push(
|
|
715
|
+
/* @__PURE__ */ jsx(
|
|
716
|
+
DataGridCell,
|
|
717
|
+
{
|
|
718
|
+
cell,
|
|
719
|
+
columnIndex,
|
|
720
|
+
rowIndex,
|
|
721
|
+
anchor,
|
|
722
|
+
onDragToFillStart,
|
|
723
|
+
multiColumnSelection
|
|
724
|
+
},
|
|
725
|
+
cell.id
|
|
726
|
+
)
|
|
727
|
+
);
|
|
728
|
+
return acc;
|
|
729
|
+
}, []),
|
|
730
|
+
virtualPaddingRight ? /* @__PURE__ */ jsx(
|
|
731
|
+
"div",
|
|
732
|
+
{
|
|
733
|
+
role: "presentation",
|
|
734
|
+
style: { display: "flex", width: virtualPaddingRight }
|
|
735
|
+
}
|
|
736
|
+
) : null
|
|
737
|
+
]
|
|
738
|
+
}
|
|
739
|
+
);
|
|
740
|
+
};
|
|
741
|
+
export {
|
|
742
|
+
DataGridRoot
|
|
743
|
+
};
|