@medusajs/loyalty-plugin 0.0.1 → 0.0.3
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/index.js +30277 -0
- package/.medusa/server/src/admin/index.mjs +30256 -0
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +24 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +9 -1
- package/.medusa/server/src/api/store/carts/validators.js +5 -2
- package/.medusa/server/src/links/customer-gift-card-link.js +2 -2
- package/.medusa/server/src/links/customer-store-credit-account-link.js +2 -2
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +2 -2
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +104 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +2 -2
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +3 -3
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +1 -1
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +1 -1
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +115 -0
- package/package.json +14 -9
- package/.medusa/server/src/admin/components/action-menu.js +0 -63
- package/.medusa/server/src/admin/components/chip-group.js +0 -82
- package/.medusa/server/src/admin/components/chip-input.js +0 -157
- package/.medusa/server/src/admin/components/combobox.js +0 -324
- package/.medusa/server/src/admin/components/conditional-tooltip.js +0 -15
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +0 -66
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +0 -77
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +0 -110
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +0 -16
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +0 -214
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +0 -77
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +0 -32
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +0 -743
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +0 -37
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +0 -54
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +0 -66
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +0 -166
- package/.medusa/server/src/admin/components/data-grid/components/index.js +0 -16
- package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +0 -7
- package/.medusa/server/src/admin/components/data-grid/context/index.js +0 -6
- package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +0 -14
- package/.medusa/server/src/admin/components/data-grid/data-grid.js +0 -31
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +0 -28
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +0 -85
- package/.medusa/server/src/admin/components/data-grid/helpers/index.js +0 -6
- package/.medusa/server/src/admin/components/data-grid/hooks/index.js +0 -31
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +0 -50
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +0 -123
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +0 -52
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +0 -43
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +0 -191
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +0 -70
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +0 -51
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +0 -15
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +0 -86
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +0 -149
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +0 -482
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +0 -64
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +0 -81
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +0 -14
- package/.medusa/server/src/admin/components/data-grid/index.js +0 -8
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +0 -27
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +0 -296
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +0 -62
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +0 -25
- package/.medusa/server/src/admin/components/data-grid/models/index.js +0 -10
- package/.medusa/server/src/admin/components/data-grid/types.js +0 -1
- package/.medusa/server/src/admin/components/data-grid/utils.js +0 -18
- package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +0 -36
- package/.medusa/server/src/admin/components/data-table/data-table.js +0 -271
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +0 -51
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +0 -90
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +0 -10
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +0 -48
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +0 -19
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +0 -30
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +0 -23
- package/.medusa/server/src/admin/components/data-table/index.js +0 -4
- package/.medusa/server/src/admin/components/data-table.js +0 -249
- package/.medusa/server/src/admin/components/display-id.js +0 -18
- package/.medusa/server/src/admin/components/file-upload.js +0 -116
- package/.medusa/server/src/admin/components/form.js +0 -151
- package/.medusa/server/src/admin/components/handle-input.js +0 -22
- package/.medusa/server/src/admin/components/header.js +0 -41
- package/.medusa/server/src/admin/components/icon-avatar.js +0 -27
- package/.medusa/server/src/admin/components/json-view-section.js +0 -139
- package/.medusa/server/src/admin/components/keybound-form.js +0 -32
- package/.medusa/server/src/admin/components/layouts/single-column.js +0 -7
- package/.medusa/server/src/admin/components/layouts/two-column.js +0 -13
- package/.medusa/server/src/admin/components/listicle.js +0 -20
- package/.medusa/server/src/admin/components/modals/index.js +0 -19
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +0 -57
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +0 -71
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +0 -60
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +0 -30
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +0 -12
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +0 -55
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +0 -63
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +0 -47
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +0 -14
- package/.medusa/server/src/admin/components/placeholder-cell.js +0 -7
- package/.medusa/server/src/admin/components/product/product-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +0 -15
- package/.medusa/server/src/admin/components/product/product-status-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +0 -18
- package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +0 -31
- package/.medusa/server/src/admin/components/product/variant-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +0 -15
- package/.medusa/server/src/admin/components/section-row.js +0 -32
- package/.medusa/server/src/admin/components/sidebar-link.js +0 -31
- package/.medusa/server/src/admin/components/sortable-list.js +0 -152
- package/.medusa/server/src/admin/components/switch-box.js +0 -43
- package/.medusa/server/src/admin/components/tax-badge.js +0 -18
- package/.medusa/server/src/admin/components/thumbnail.js +0 -28
- package/.medusa/server/src/admin/components/upload-media-form-item.js +0 -83
- package/.medusa/server/src/admin/hooks/api/customers.js +0 -26
- package/.medusa/server/src/admin/hooks/api/gift-cards.js +0 -107
- package/.medusa/server/src/admin/hooks/api/order.js +0 -16
- package/.medusa/server/src/admin/hooks/api/price-preferences.js +0 -19
- package/.medusa/server/src/admin/hooks/api/products.js +0 -127
- package/.medusa/server/src/admin/hooks/api/regions.js +0 -17
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +0 -28
- package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +0 -41
- package/.medusa/server/src/admin/hooks/api/store.js +0 -31
- package/.medusa/server/src/admin/hooks/api/transaction-groups.js +0 -23
- package/.medusa/server/src/admin/hooks/api/transactions.js +0 -23
- package/.medusa/server/src/admin/hooks/commands/use-command-history.js +0 -45
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +0 -59
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +0 -89
- package/.medusa/server/src/admin/hooks/common/use-date.js +0 -32
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +0 -22
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +0 -14
- package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/sales-channels/index.js +0 -10
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +0 -48
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +0 -19
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +0 -23
- package/.medusa/server/src/admin/lib/currencies.js +0 -729
- package/.medusa/server/src/admin/lib/query-key.js +0 -17
- package/.medusa/server/src/admin/lib/sdk.js +0 -10
- package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +0 -75
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +0 -172
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +0 -30
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +0 -180
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +0 -30
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +0 -97
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +0 -162
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +0 -89
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +0 -199
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +0 -353
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +0 -5
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +0 -247
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +0 -5
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +0 -48
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +0 -14
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +0 -28
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +0 -40
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +0 -121
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +0 -72
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +0 -123
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +0 -1
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +0 -98
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +0 -28
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +0 -96
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +0 -90
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +0 -288
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +0 -111
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +0 -285
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +0 -124
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +0 -112
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +0 -1
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +0 -35
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +0 -11
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +0 -61
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/page.js +0 -18
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +0 -137
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +0 -87
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +0 -352
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +0 -116
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +0 -49
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +0 -177
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +0 -27
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +0 -33
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +0 -33
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +0 -18
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +0 -50
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +0 -78
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +0 -40
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +0 -57
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +0 -13
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +0 -61
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-cards/page.js +0 -27
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +0 -126
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +0 -31
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +0 -43
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +0 -44
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +0 -18
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +0 -37
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +0 -58
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +0 -39
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +0 -58
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +0 -13
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +0 -31
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +0 -56
- package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +0 -19
- package/.medusa/server/src/admin/utils/date-utils.js +0 -27
- package/.medusa/server/src/admin/utils/format-amount.js +0 -9
- package/.medusa/server/src/admin/utils/format-date.js +0 -21
- package/.medusa/server/src/admin/utils/refs.js +0 -20
- package/.medusa/server/src/admin/utils/statuses.js +0 -23
- package/.medusa/server/src/admin/utils/validations.js +0 -71
- package/.medusa/server/src/admin/utils/variants.js +0 -92
- package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +0 -67
- package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +0 -42
- package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +0 -58
- package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +0 -96
- package/.medusa/server/types/loyalty/module.js +0 -8
|
@@ -1,157 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,324 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox } from "@medusajs/ui";
|
|
3
|
-
import { Controller } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
4
|
-
import { useCombinedRefs } from "../../../utils/refs.js";
|
|
5
|
-
import { useDataGridCell } from "../hooks/use-data-grid-cell.js";
|
|
6
|
-
import { useDataGridCellError } from "../hooks/use-data-grid-cell-error.js";
|
|
7
|
-
import "react";
|
|
8
|
-
import "../context/data-grid-context.js";
|
|
9
|
-
import "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/get.js";
|
|
10
|
-
import "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/set.js";
|
|
11
|
-
import { DataGridCellContainer } from "./data-grid-cell-container.js";
|
|
12
|
-
const DataGridBooleanCell = ({
|
|
13
|
-
context,
|
|
14
|
-
disabled
|
|
15
|
-
}) => {
|
|
16
|
-
const { field, control, renderProps } = useDataGridCell({
|
|
17
|
-
context
|
|
18
|
-
});
|
|
19
|
-
const errorProps = useDataGridCellError({ context });
|
|
20
|
-
const { container, input } = renderProps;
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
Controller,
|
|
23
|
-
{
|
|
24
|
-
control,
|
|
25
|
-
name: field,
|
|
26
|
-
render: ({ field: field2 }) => {
|
|
27
|
-
return /* @__PURE__ */ jsx(DataGridCellContainer, { ...container, ...errorProps, children: /* @__PURE__ */ jsx(Inner, { field: field2, inputProps: input, disabled }) });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
const Inner = ({
|
|
33
|
-
field,
|
|
34
|
-
inputProps,
|
|
35
|
-
disabled
|
|
36
|
-
}) => {
|
|
37
|
-
const { ref, value, onBlur, name, disabled: fieldDisabled } = field;
|
|
38
|
-
const {
|
|
39
|
-
ref: inputRef,
|
|
40
|
-
onBlur: onInputBlur,
|
|
41
|
-
onChange,
|
|
42
|
-
onFocus,
|
|
43
|
-
...attributes
|
|
44
|
-
} = inputProps;
|
|
45
|
-
const combinedRefs = useCombinedRefs(ref, inputRef);
|
|
46
|
-
return /* @__PURE__ */ jsx(
|
|
47
|
-
Checkbox,
|
|
48
|
-
{
|
|
49
|
-
disabled: disabled || fieldDisabled,
|
|
50
|
-
name,
|
|
51
|
-
checked: value,
|
|
52
|
-
onCheckedChange: (newValue) => onChange(newValue === true, value),
|
|
53
|
-
onFocus,
|
|
54
|
-
onBlur: () => {
|
|
55
|
-
onBlur();
|
|
56
|
-
onInputBlur();
|
|
57
|
-
},
|
|
58
|
-
ref: combinedRefs,
|
|
59
|
-
tabIndex: -1,
|
|
60
|
-
...attributes
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
DataGridBooleanCell
|
|
66
|
-
};
|
package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ErrorMessage } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@hookform/error-message/dist/index.esm.js";
|
|
3
|
-
import { ExclamationCircle } from "@medusajs/icons";
|
|
4
|
-
import { clx, Tooltip } from "@medusajs/ui";
|
|
5
|
-
import { get } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
6
|
-
import { DataGridRowErrorIndicator } from "./data-grid-row-error-indicator.js";
|
|
7
|
-
const DataGridCellContainer = ({
|
|
8
|
-
isAnchor,
|
|
9
|
-
isSelected,
|
|
10
|
-
isDragSelected,
|
|
11
|
-
field,
|
|
12
|
-
showOverlay,
|
|
13
|
-
placeholder,
|
|
14
|
-
innerProps,
|
|
15
|
-
overlayProps,
|
|
16
|
-
children,
|
|
17
|
-
errors,
|
|
18
|
-
rowErrors,
|
|
19
|
-
outerComponent
|
|
20
|
-
}) => {
|
|
21
|
-
const error = get(errors, field);
|
|
22
|
-
const hasError = !!error;
|
|
23
|
-
return /* @__PURE__ */ jsxs("div", { className: "group/container relative size-full", children: [
|
|
24
|
-
/* @__PURE__ */ jsxs(
|
|
25
|
-
"div",
|
|
26
|
-
{
|
|
27
|
-
className: clx(
|
|
28
|
-
"bg-ui-bg-base group/cell relative flex size-full items-center gap-x-2 px-4 py-2.5 outline-none",
|
|
29
|
-
{
|
|
30
|
-
"bg-ui-tag-red-bg text-ui-tag-red-text": hasError && !isAnchor && !isSelected && !isDragSelected,
|
|
31
|
-
"ring-ui-bg-interactive ring-2 ring-inset": isAnchor,
|
|
32
|
-
"bg-ui-bg-highlight [&:has([data-field]:focus)]:bg-ui-bg-base": isSelected || isAnchor,
|
|
33
|
-
"bg-ui-bg-subtle": isDragSelected && !isAnchor
|
|
34
|
-
}
|
|
35
|
-
),
|
|
36
|
-
tabIndex: -1,
|
|
37
|
-
...innerProps,
|
|
38
|
-
children: [
|
|
39
|
-
/* @__PURE__ */ jsx(
|
|
40
|
-
ErrorMessage,
|
|
41
|
-
{
|
|
42
|
-
name: field,
|
|
43
|
-
errors,
|
|
44
|
-
render: ({ message }) => {
|
|
45
|
-
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(Tooltip, { content: message, delayDuration: 0, children: /* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-tag-red-icon z-[3]" }) }) });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
),
|
|
49
|
-
/* @__PURE__ */ jsx("div", { className: "relative z-[1] flex size-full items-center justify-center", children: /* @__PURE__ */ jsx(RenderChildren, { isAnchor, placeholder, children }) }),
|
|
50
|
-
/* @__PURE__ */ jsx(DataGridRowErrorIndicator, { rowErrors }),
|
|
51
|
-
showOverlay && /* @__PURE__ */ jsx(
|
|
52
|
-
"div",
|
|
53
|
-
{
|
|
54
|
-
...overlayProps,
|
|
55
|
-
"data-cell-overlay": "true",
|
|
56
|
-
className: "absolute inset-0 z-[2]"
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
),
|
|
62
|
-
outerComponent
|
|
63
|
-
] });
|
|
64
|
-
};
|
|
65
|
-
const RenderChildren = ({
|
|
66
|
-
isAnchor,
|
|
67
|
-
placeholder,
|
|
68
|
-
children
|
|
69
|
-
}) => {
|
|
70
|
-
if (!isAnchor && placeholder) {
|
|
71
|
-
return placeholder;
|
|
72
|
-
}
|
|
73
|
-
return children;
|
|
74
|
-
};
|
|
75
|
-
export {
|
|
76
|
-
DataGridCellContainer
|
|
77
|
-
};
|