@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,63 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { EllipsisHorizontal } from "@medusajs/icons";
|
|
3
|
+
import { DropdownMenu, IconButton, clx } from "@medusajs/ui";
|
|
4
|
+
import { Link } from "react-router-dom";
|
|
5
|
+
const ActionMenu = ({ groups }) => {
|
|
6
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
7
|
+
/* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { size: "small", variant: "transparent", children: /* @__PURE__ */ jsx(EllipsisHorizontal, {}) }) }),
|
|
8
|
+
/* @__PURE__ */ jsx(DropdownMenu.Content, { children: groups.map((group, index) => {
|
|
9
|
+
if (!group.actions.length) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const isLast = index === groups.length - 1;
|
|
13
|
+
return /* @__PURE__ */ jsxs(DropdownMenu.Group, { children: [
|
|
14
|
+
group.actions.map((action, index2) => {
|
|
15
|
+
if (action.onClick) {
|
|
16
|
+
return /* @__PURE__ */ jsxs(
|
|
17
|
+
DropdownMenu.Item,
|
|
18
|
+
{
|
|
19
|
+
disabled: action.disabled,
|
|
20
|
+
onClick: (e) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
action.onClick();
|
|
23
|
+
},
|
|
24
|
+
className: clx(
|
|
25
|
+
"[&_svg]:text-ui-fg-subtle flex items-center gap-x-2",
|
|
26
|
+
{
|
|
27
|
+
"[&_svg]:text-ui-fg-disabled": action.disabled
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
children: [
|
|
31
|
+
action.icon,
|
|
32
|
+
/* @__PURE__ */ jsx("span", { children: action.label })
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
index2
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
39
|
+
DropdownMenu.Item,
|
|
40
|
+
{
|
|
41
|
+
className: clx(
|
|
42
|
+
"[&_svg]:text-ui-fg-subtle flex items-center gap-x-2",
|
|
43
|
+
{
|
|
44
|
+
"[&_svg]:text-ui-fg-disabled": action.disabled
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
asChild: true,
|
|
48
|
+
disabled: action.disabled,
|
|
49
|
+
children: /* @__PURE__ */ jsxs(Link, { to: action.to, onClick: (e) => e.stopPropagation(), children: [
|
|
50
|
+
action.icon,
|
|
51
|
+
/* @__PURE__ */ jsx("span", { children: action.label })
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
) }, index2);
|
|
55
|
+
}),
|
|
56
|
+
!isLast && /* @__PURE__ */ jsx(DropdownMenu.Separator, {})
|
|
57
|
+
] }, index);
|
|
58
|
+
}) })
|
|
59
|
+
] });
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
ActionMenu
|
|
63
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { XMarkMini } from "@medusajs/icons";
|
|
3
|
+
import { clx, Button } from "@medusajs/ui";
|
|
4
|
+
import { createContext, Children, useContext } from "react";
|
|
5
|
+
const GroupContext = createContext(null);
|
|
6
|
+
const useGroupContext = () => {
|
|
7
|
+
const context = useContext(GroupContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"useGroupContext must be used within a ChipGroup component"
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
};
|
|
15
|
+
const Group = ({
|
|
16
|
+
onClearAll,
|
|
17
|
+
onRemove,
|
|
18
|
+
variant = "component",
|
|
19
|
+
className,
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
const showClearAll = !!onClearAll && Children.count(children) > 0;
|
|
23
|
+
return /* @__PURE__ */ jsx(GroupContext.Provider, { value: { onRemove, variant }, children: /* @__PURE__ */ jsxs(
|
|
24
|
+
"ul",
|
|
25
|
+
{
|
|
26
|
+
role: "application",
|
|
27
|
+
className: clx("flex flex-wrap items-center gap-2", className),
|
|
28
|
+
children: [
|
|
29
|
+
children,
|
|
30
|
+
showClearAll && /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
31
|
+
Button,
|
|
32
|
+
{
|
|
33
|
+
size: "small",
|
|
34
|
+
variant: "transparent",
|
|
35
|
+
type: "button",
|
|
36
|
+
onClick: onClearAll,
|
|
37
|
+
className: "text-ui-fg-muted active:text-ui-fg-subtle",
|
|
38
|
+
children: "Clear All"
|
|
39
|
+
}
|
|
40
|
+
) })
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
) });
|
|
44
|
+
};
|
|
45
|
+
const Chip = ({ index, className, children }) => {
|
|
46
|
+
const { onRemove, variant } = useGroupContext();
|
|
47
|
+
return /* @__PURE__ */ jsxs(
|
|
48
|
+
"li",
|
|
49
|
+
{
|
|
50
|
+
className: clx(
|
|
51
|
+
"bg-ui-bg-component shadow-borders-base flex items-stretch divide-x overflow-hidden rounded-md",
|
|
52
|
+
{
|
|
53
|
+
"bg-ui-bg-component": variant === "component",
|
|
54
|
+
"bg-ui-bg-base-": variant === "base"
|
|
55
|
+
},
|
|
56
|
+
className
|
|
57
|
+
),
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("span", { className: "txt-compact-small-plus text-ui-fg-subtle flex items-center justify-center px-2 py-1", children }),
|
|
60
|
+
!!onRemove && /* @__PURE__ */ jsx(
|
|
61
|
+
"button",
|
|
62
|
+
{
|
|
63
|
+
onClick: () => onRemove(index),
|
|
64
|
+
type: "button",
|
|
65
|
+
className: clx(
|
|
66
|
+
"text-ui-fg-muted active:text-ui-fg-subtle transition-fg flex items-center justify-center p-1",
|
|
67
|
+
{
|
|
68
|
+
"hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed": variant === "component",
|
|
69
|
+
"hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed": variant === "base"
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
children: /* @__PURE__ */ jsx(XMarkMini, {})
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
const ChipGroup = Object.assign(Group, { Chip });
|
|
80
|
+
export {
|
|
81
|
+
ChipGroup
|
|
82
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { XMarkMini } from "@medusajs/icons";
|
|
3
|
+
import { clx, Badge } from "@medusajs/ui";
|
|
4
|
+
import { AnimatePresence, motion } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/motion/dist/es/motion/lib/react.mjs";
|
|
5
|
+
import { forwardRef, useRef, useState, useImperativeHandle } from "react";
|
|
6
|
+
const ChipInput = forwardRef(
|
|
7
|
+
({
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
onBlur,
|
|
11
|
+
disabled,
|
|
12
|
+
name,
|
|
13
|
+
showRemove = true,
|
|
14
|
+
variant = "base",
|
|
15
|
+
allowDuplicates = false,
|
|
16
|
+
placeholder,
|
|
17
|
+
className
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const innerRef = useRef(null);
|
|
20
|
+
const isControlledRef = useRef(typeof value !== "undefined");
|
|
21
|
+
const isControlled = isControlledRef.current;
|
|
22
|
+
const [uncontrolledValue, setUncontrolledValue] = useState([]);
|
|
23
|
+
useImperativeHandle(
|
|
24
|
+
ref,
|
|
25
|
+
() => innerRef.current
|
|
26
|
+
);
|
|
27
|
+
const [duplicateIndex, setDuplicateIndex] = useState(null);
|
|
28
|
+
const chips = isControlled ? value : uncontrolledValue;
|
|
29
|
+
const handleAddChip = (chip) => {
|
|
30
|
+
const cleanValue = chip.trim();
|
|
31
|
+
if (!cleanValue) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!allowDuplicates && chips.includes(cleanValue)) {
|
|
35
|
+
setDuplicateIndex(chips.indexOf(cleanValue));
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
setDuplicateIndex(null);
|
|
38
|
+
}, 300);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
onChange == null ? void 0 : onChange([...chips, cleanValue]);
|
|
42
|
+
if (!isControlled) {
|
|
43
|
+
setUncontrolledValue([...chips, cleanValue]);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const handleRemoveChip = (chip) => {
|
|
47
|
+
onChange == null ? void 0 : onChange(chips.filter((v) => v !== chip));
|
|
48
|
+
if (!isControlled) {
|
|
49
|
+
setUncontrolledValue(chips.filter((v) => v !== chip));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleBlur = (e) => {
|
|
53
|
+
onBlur == null ? void 0 : onBlur();
|
|
54
|
+
if (e.target.value) {
|
|
55
|
+
handleAddChip(e.target.value);
|
|
56
|
+
e.target.value = "";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const handleKeyDown = (e) => {
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
|
+
if (e.key === "Enter" || e.key === ",") {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
if (!((_a = innerRef.current) == null ? void 0 : _a.value)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
handleAddChip(((_b = innerRef.current) == null ? void 0 : _b.value) ?? "");
|
|
67
|
+
innerRef.current.value = "";
|
|
68
|
+
(_c = innerRef.current) == null ? void 0 : _c.focus();
|
|
69
|
+
}
|
|
70
|
+
if (e.key === "Backspace" && ((_d = innerRef.current) == null ? void 0 : _d.value) === "") {
|
|
71
|
+
handleRemoveChip(chips[chips.length - 1]);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const shake = {
|
|
75
|
+
x: [0, -2, 2, -2, 2, 0],
|
|
76
|
+
transition: { duration: 0.3 }
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ jsxs(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: clx(
|
|
82
|
+
"shadow-borders-base flex min-h-8 flex-wrap items-center gap-1 rounded-md px-2 py-1.5",
|
|
83
|
+
"transition-fg focus-within:shadow-borders-interactive-with-active",
|
|
84
|
+
"has-[input:disabled]:bg-ui-bg-disabled has-[input:disabled]:text-ui-fg-disabled has-[input:disabled]:cursor-not-allowed",
|
|
85
|
+
{
|
|
86
|
+
"bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover": variant === "contrast",
|
|
87
|
+
"bg-ui-bg-field hover:bg-ui-bg-field-hover": variant === "base"
|
|
88
|
+
},
|
|
89
|
+
className
|
|
90
|
+
),
|
|
91
|
+
tabIndex: -1,
|
|
92
|
+
onClick: () => {
|
|
93
|
+
var _a;
|
|
94
|
+
return (_a = innerRef.current) == null ? void 0 : _a.focus();
|
|
95
|
+
},
|
|
96
|
+
children: [
|
|
97
|
+
chips.map((v, index) => {
|
|
98
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(
|
|
99
|
+
Badge,
|
|
100
|
+
{
|
|
101
|
+
size: "2xsmall",
|
|
102
|
+
className: clx("gap-x-0.5 pl-1.5 pr-1.5", {
|
|
103
|
+
"transition-fg pr-1": showRemove,
|
|
104
|
+
"shadow-borders-focus": index === duplicateIndex
|
|
105
|
+
}),
|
|
106
|
+
asChild: true,
|
|
107
|
+
children: /* @__PURE__ */ jsxs(
|
|
108
|
+
motion.div,
|
|
109
|
+
{
|
|
110
|
+
animate: index === duplicateIndex ? shake : void 0,
|
|
111
|
+
children: [
|
|
112
|
+
v,
|
|
113
|
+
showRemove && /* @__PURE__ */ jsx(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
tabIndex: -1,
|
|
117
|
+
type: "button",
|
|
118
|
+
onClick: () => handleRemoveChip(v),
|
|
119
|
+
className: clx(
|
|
120
|
+
"text-ui-fg-subtle transition-fg outline-none"
|
|
121
|
+
),
|
|
122
|
+
children: /* @__PURE__ */ jsx(XMarkMini, {})
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
) }, `${v}-${index}`);
|
|
130
|
+
}),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"input",
|
|
133
|
+
{
|
|
134
|
+
className: clx(
|
|
135
|
+
"caret-ui-fg-base text-ui-fg-base txt-compact-small flex-1 appearance-none bg-transparent",
|
|
136
|
+
"disabled:text-ui-fg-disabled disabled:cursor-not-allowed",
|
|
137
|
+
"focus:outline-none",
|
|
138
|
+
"placeholder:text-ui-fg-muted"
|
|
139
|
+
),
|
|
140
|
+
onKeyDown: handleKeyDown,
|
|
141
|
+
onBlur: handleBlur,
|
|
142
|
+
disabled,
|
|
143
|
+
name,
|
|
144
|
+
ref: innerRef,
|
|
145
|
+
placeholder: chips.length === 0 ? placeholder : void 0,
|
|
146
|
+
autoComplete: "off"
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
ChipInput.displayName = "ChipInput";
|
|
155
|
+
export {
|
|
156
|
+
ChipInput
|
|
157
|
+
};
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ComboboxProvider, Combobox as Combobox$1, ComboboxDisclosure, ComboboxPopover, ComboboxItem, ComboboxItemCheck, ComboboxItemValue, Separator } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@ariakit/react/esm/index.js";
|
|
3
|
+
import { XMarkMini, TrianglesMini, CheckMini, EllipseMiniSolid, PlusMini } from "@medusajs/icons";
|
|
4
|
+
import { clx, Text } from "@medusajs/ui";
|
|
5
|
+
import { matchSorter } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/match-sorter/dist/match-sorter.esm.js";
|
|
6
|
+
import { useState, useTransition, useRef, useImperativeHandle, useDeferredValue, useMemo, useCallback, Fragment } from "react";
|
|
7
|
+
import { genericForwardRef } from "../utils/refs.js";
|
|
8
|
+
const TABLUAR_NUM_WIDTH = 8;
|
|
9
|
+
const TAG_BASE_WIDTH = 28;
|
|
10
|
+
const ComboboxImpl = ({
|
|
11
|
+
value: controlledValue,
|
|
12
|
+
onChange,
|
|
13
|
+
searchValue: controlledSearchValue,
|
|
14
|
+
onSearchValueChange,
|
|
15
|
+
options,
|
|
16
|
+
className,
|
|
17
|
+
placeholder,
|
|
18
|
+
fetchNextPage,
|
|
19
|
+
isFetchingNextPage,
|
|
20
|
+
onCreateOption,
|
|
21
|
+
noResultsPlaceholder,
|
|
22
|
+
allowClear,
|
|
23
|
+
...inputProps
|
|
24
|
+
}, ref) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const [open, setOpen] = useState(false);
|
|
27
|
+
const [isPending, startTransition] = useTransition();
|
|
28
|
+
const comboboxRef = useRef(null);
|
|
29
|
+
const listboxRef = useRef(null);
|
|
30
|
+
useImperativeHandle(ref, () => comboboxRef.current);
|
|
31
|
+
const isValueControlled = controlledValue !== void 0;
|
|
32
|
+
const isSearchControlled = controlledSearchValue !== void 0;
|
|
33
|
+
const isArrayValue = Array.isArray(controlledValue);
|
|
34
|
+
const emptyState = isArrayValue ? [] : "";
|
|
35
|
+
const [uncontrolledSearchValue, setUncontrolledSearchValue] = useState(
|
|
36
|
+
controlledSearchValue || ""
|
|
37
|
+
);
|
|
38
|
+
const defferedSearchValue = useDeferredValue(uncontrolledSearchValue);
|
|
39
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(emptyState);
|
|
40
|
+
const searchValue = isSearchControlled ? controlledSearchValue : uncontrolledSearchValue;
|
|
41
|
+
const selectedValues = isValueControlled ? controlledValue : uncontrolledValue;
|
|
42
|
+
const handleValueChange = (newValues) => {
|
|
43
|
+
const exists = options.filter((o) => !o.disabled).find((o) => {
|
|
44
|
+
if (isArrayValue) {
|
|
45
|
+
return newValues == null ? void 0 : newValues.includes(o.value);
|
|
46
|
+
}
|
|
47
|
+
return o.value === newValues;
|
|
48
|
+
});
|
|
49
|
+
if (!exists && onCreateOption && newValues) {
|
|
50
|
+
onCreateOption(newValues);
|
|
51
|
+
}
|
|
52
|
+
if (!isValueControlled) {
|
|
53
|
+
setUncontrolledValue(newValues || emptyState);
|
|
54
|
+
}
|
|
55
|
+
if (onChange) {
|
|
56
|
+
onChange(newValues);
|
|
57
|
+
}
|
|
58
|
+
setUncontrolledSearchValue("");
|
|
59
|
+
};
|
|
60
|
+
const handleSearchChange = (query) => {
|
|
61
|
+
setUncontrolledSearchValue(query);
|
|
62
|
+
if (onSearchValueChange) {
|
|
63
|
+
onSearchValueChange(query);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const matches = useMemo(() => {
|
|
67
|
+
if (isSearchControlled) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return matchSorter(options, defferedSearchValue, {
|
|
71
|
+
keys: ["label"]
|
|
72
|
+
});
|
|
73
|
+
}, [options, defferedSearchValue, isSearchControlled]);
|
|
74
|
+
const observer = useRef(
|
|
75
|
+
new IntersectionObserver(
|
|
76
|
+
(entries) => {
|
|
77
|
+
const first = entries[0];
|
|
78
|
+
if (first.isIntersecting) {
|
|
79
|
+
fetchNextPage == null ? void 0 : fetchNextPage();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{ threshold: 1 }
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
const lastOptionRef = useCallback(
|
|
86
|
+
(node) => {
|
|
87
|
+
if (isFetchingNextPage) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (observer.current) {
|
|
91
|
+
observer.current.disconnect();
|
|
92
|
+
}
|
|
93
|
+
if (node) {
|
|
94
|
+
observer.current.observe(node);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
[isFetchingNextPage]
|
|
98
|
+
);
|
|
99
|
+
const handleOpenChange = (open2) => {
|
|
100
|
+
if (!open2) {
|
|
101
|
+
setUncontrolledSearchValue("");
|
|
102
|
+
}
|
|
103
|
+
setOpen(open2);
|
|
104
|
+
};
|
|
105
|
+
const hasValue = (selectedValues == null ? void 0 : selectedValues.length) > 0;
|
|
106
|
+
const showTag = hasValue && isArrayValue;
|
|
107
|
+
const showSelected = showTag && !searchValue && !open;
|
|
108
|
+
const hideInput = !isArrayValue && !open;
|
|
109
|
+
const selectedLabel = (_a = options.find((o) => o.value === selectedValues)) == null ? void 0 : _a.label;
|
|
110
|
+
const hidePlaceholder = showSelected || open;
|
|
111
|
+
const tagWidth = useMemo(() => {
|
|
112
|
+
if (!Array.isArray(selectedValues)) {
|
|
113
|
+
return TAG_BASE_WIDTH + TABLUAR_NUM_WIDTH;
|
|
114
|
+
}
|
|
115
|
+
const count = selectedValues.length;
|
|
116
|
+
const digits = count.toString().length;
|
|
117
|
+
return TAG_BASE_WIDTH + digits * TABLUAR_NUM_WIDTH;
|
|
118
|
+
}, [selectedValues]);
|
|
119
|
+
const results = useMemo(() => {
|
|
120
|
+
return isSearchControlled ? options : matches;
|
|
121
|
+
}, [matches, options, isSearchControlled]);
|
|
122
|
+
return /* @__PURE__ */ jsxs(
|
|
123
|
+
ComboboxProvider,
|
|
124
|
+
{
|
|
125
|
+
open,
|
|
126
|
+
setOpen: handleOpenChange,
|
|
127
|
+
selectedValue: selectedValues,
|
|
128
|
+
setSelectedValue: (value) => handleValueChange(value),
|
|
129
|
+
value: uncontrolledSearchValue,
|
|
130
|
+
setValue: (query) => {
|
|
131
|
+
startTransition(() => handleSearchChange(query));
|
|
132
|
+
},
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsxs(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: clx(
|
|
138
|
+
"relative flex cursor-pointer items-center gap-x-2 overflow-hidden",
|
|
139
|
+
"h-8 w-full rounded-md",
|
|
140
|
+
"bg-ui-bg-field transition-fg shadow-borders-base",
|
|
141
|
+
"has-[input:focus]:shadow-borders-interactive-with-active",
|
|
142
|
+
"has-[:invalid]:shadow-borders-error has-[[aria-invalid=true]]:shadow-borders-error",
|
|
143
|
+
"has-[:disabled]:bg-ui-bg-disabled has-[:disabled]:text-ui-fg-disabled has-[:disabled]:cursor-not-allowed",
|
|
144
|
+
className
|
|
145
|
+
),
|
|
146
|
+
style: {
|
|
147
|
+
"--tag-width": `${tagWidth}px`
|
|
148
|
+
},
|
|
149
|
+
children: [
|
|
150
|
+
showTag && /* @__PURE__ */ jsxs(
|
|
151
|
+
"button",
|
|
152
|
+
{
|
|
153
|
+
type: "button",
|
|
154
|
+
onClick: (e) => {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
handleValueChange(void 0);
|
|
157
|
+
},
|
|
158
|
+
className: "bg-ui-bg-base hover:bg-ui-bg-base-hover txt-compact-small-plus text-ui-fg-subtle focus-within:border-ui-fg-interactive transition-fg absolute left-0.5 top-0.5 z-[1] flex h-[28px] items-center rounded-[4px] border py-[3px] pl-1.5 pr-1 outline-none",
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ jsx("span", { className: "tabular-nums", children: selectedValues.length }),
|
|
161
|
+
/* @__PURE__ */ jsx(XMarkMini, { className: "text-ui-fg-muted" })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex size-full items-center", children: [
|
|
166
|
+
showSelected && /* @__PURE__ */ jsx(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
className: clx(
|
|
170
|
+
"pointer-events-none absolute inset-y-0 flex size-full items-center",
|
|
171
|
+
{
|
|
172
|
+
"left-[calc(var(--tag-width)+8px)]": showTag,
|
|
173
|
+
"left-2": !showTag
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "Selected" })
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
hideInput && /* @__PURE__ */ jsx(
|
|
180
|
+
"div",
|
|
181
|
+
{
|
|
182
|
+
className: clx(
|
|
183
|
+
"pointer-events-none absolute inset-y-0 flex size-full items-center overflow-hidden",
|
|
184
|
+
{
|
|
185
|
+
"left-[calc(var(--tag-width)+8px)]": showTag,
|
|
186
|
+
"left-2": !showTag
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
children: /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "truncate", children: selectedLabel })
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
Combobox$1,
|
|
194
|
+
{
|
|
195
|
+
autoSelect: true,
|
|
196
|
+
ref: comboboxRef,
|
|
197
|
+
onFocus: () => setOpen(true),
|
|
198
|
+
className: clx(
|
|
199
|
+
"txt-compact-small text-ui-fg-base !placeholder:text-ui-fg-muted transition-fg size-full cursor-pointer bg-transparent pl-2 pr-8 outline-none focus:cursor-text",
|
|
200
|
+
"hover:bg-ui-bg-field-hover",
|
|
201
|
+
{
|
|
202
|
+
"opacity-0": hideInput,
|
|
203
|
+
"pl-2": !showTag,
|
|
204
|
+
"pl-[calc(var(--tag-width)+8px)]": showTag
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
placeholder: hidePlaceholder ? void 0 : placeholder,
|
|
208
|
+
...inputProps
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
] }),
|
|
212
|
+
allowClear && controlledValue && /* @__PURE__ */ jsx(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
onClick: (e) => {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
handleValueChange(void 0);
|
|
219
|
+
},
|
|
220
|
+
className: "bg-ui-bg-base hover:bg-ui-bg-base-hover txt-compact-small-plus text-ui-fg-subtle focus-within:border-ui-fg-interactive transition-fg absolute right-[28px] top-0.5 z-[1] flex h-[28px] items-center rounded-[4px] border px-1.5 py-[2px] outline-none",
|
|
221
|
+
children: /* @__PURE__ */ jsx(XMarkMini, { className: "text-ui-fg-muted" })
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
/* @__PURE__ */ jsx(
|
|
225
|
+
ComboboxDisclosure,
|
|
226
|
+
{
|
|
227
|
+
render: (props) => {
|
|
228
|
+
return /* @__PURE__ */ jsx(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
...props,
|
|
232
|
+
type: "button",
|
|
233
|
+
className: "text-ui-fg-muted transition-fg hover:bg-ui-bg-field-hover absolute right-0 flex size-8 items-center justify-center rounded-r outline-none",
|
|
234
|
+
children: /* @__PURE__ */ jsx(TrianglesMini, {})
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
/* @__PURE__ */ jsxs(
|
|
244
|
+
ComboboxPopover,
|
|
245
|
+
{
|
|
246
|
+
gutter: 4,
|
|
247
|
+
sameWidth: true,
|
|
248
|
+
ref: listboxRef,
|
|
249
|
+
role: "listbox",
|
|
250
|
+
className: clx(
|
|
251
|
+
"shadow-elevation-flyout bg-ui-bg-base z-50 rounded-[8px] p-1",
|
|
252
|
+
"max-h-[200px] overflow-y-auto",
|
|
253
|
+
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
254
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
255
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
256
|
+
),
|
|
257
|
+
style: {
|
|
258
|
+
pointerEvents: open ? "auto" : "none"
|
|
259
|
+
},
|
|
260
|
+
"aria-busy": isPending,
|
|
261
|
+
children: [
|
|
262
|
+
results.map(({ value, label, disabled }) => /* @__PURE__ */ jsxs(
|
|
263
|
+
ComboboxItem,
|
|
264
|
+
{
|
|
265
|
+
value,
|
|
266
|
+
focusOnHover: true,
|
|
267
|
+
setValueOnClick: false,
|
|
268
|
+
disabled,
|
|
269
|
+
className: clx(
|
|
270
|
+
"transition-fg bg-ui-bg-base data-[active-item=true]:bg-ui-bg-base-hover group flex cursor-pointer items-center gap-x-2 rounded-[4px] px-2 py-1",
|
|
271
|
+
{
|
|
272
|
+
"text-ui-fg-disabled": disabled,
|
|
273
|
+
"bg-ui-bg-component": disabled
|
|
274
|
+
}
|
|
275
|
+
),
|
|
276
|
+
children: [
|
|
277
|
+
/* @__PURE__ */ jsx(ComboboxItemCheck, { className: "flex !size-5 items-center justify-center", children: isArrayValue ? /* @__PURE__ */ jsx(CheckMini, {}) : /* @__PURE__ */ jsx(EllipseMiniSolid, {}) }),
|
|
278
|
+
/* @__PURE__ */ jsx(ComboboxItemValue, { className: "txt-compact-small", children: label })
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
value
|
|
282
|
+
)),
|
|
283
|
+
!!fetchNextPage && /* @__PURE__ */ jsx("div", { ref: lastOptionRef, className: "w-px" }),
|
|
284
|
+
isFetchingNextPage && /* @__PURE__ */ jsx("div", { className: "transition-fg bg-ui-bg-base flex items-center rounded-[4px] px-2 py-1.5", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-component size-full h-5 w-full animate-pulse rounded-[4px]" }) }),
|
|
285
|
+
!results.length && (noResultsPlaceholder && !(searchValue == null ? void 0 : searchValue.length) ? noResultsPlaceholder : /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2 rounded-[4px] px-2 py-1.5", children: /* @__PURE__ */ jsx(
|
|
286
|
+
Text,
|
|
287
|
+
{
|
|
288
|
+
size: "small",
|
|
289
|
+
leading: "compact",
|
|
290
|
+
className: "text-ui-fg-subtle",
|
|
291
|
+
children: "No results found"
|
|
292
|
+
}
|
|
293
|
+
) })),
|
|
294
|
+
!results.length && onCreateOption && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
295
|
+
/* @__PURE__ */ jsx(Separator, { className: "bg-ui-border-base -mx-1" }),
|
|
296
|
+
/* @__PURE__ */ jsxs(
|
|
297
|
+
ComboboxItem,
|
|
298
|
+
{
|
|
299
|
+
value: uncontrolledSearchValue,
|
|
300
|
+
focusOnHover: true,
|
|
301
|
+
setValueOnClick: false,
|
|
302
|
+
className: "transition-fg bg-ui-bg-base data-[active-item=true]:bg-ui-bg-base-hover group mt-1 flex cursor-pointer items-center gap-x-2 rounded-[4px] px-2 py-1.5",
|
|
303
|
+
children: [
|
|
304
|
+
/* @__PURE__ */ jsx(PlusMini, { className: "text-ui-fg-subtle" }),
|
|
305
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", leading: "compact", children: [
|
|
306
|
+
'Create "',
|
|
307
|
+
searchValue,
|
|
308
|
+
'"'
|
|
309
|
+
] })
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
] })
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
const Combobox = genericForwardRef(ComboboxImpl);
|
|
322
|
+
export {
|
|
323
|
+
Combobox
|
|
324
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip } from "@medusajs/ui";
|
|
3
|
+
const ConditionalTooltip = ({
|
|
4
|
+
children,
|
|
5
|
+
showTooltip = false,
|
|
6
|
+
...props
|
|
7
|
+
}) => {
|
|
8
|
+
if (showTooltip) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Tooltip, { ...props, children });
|
|
10
|
+
}
|
|
11
|
+
return children;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
ConditionalTooltip
|
|
15
|
+
};
|