@vendure/dashboard 3.2.0
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/README.md +13 -0
- package/dist/plugin/.vendure-dashboard-temp/dev-config.js +227 -0
- package/dist/plugin/.vendure-dashboard-temp/dev-config.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/api-extensions.js +33 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/api-extensions.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/mv.resolver.js +69 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/mv.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-process.js +110 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-process.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-seller-strategy.js +134 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-seller-strategy.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-payment-handler.js +86 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-payment-handler.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-eligibility-checker.js +49 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-eligibility-checker.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-line-assignment-strategy.js +57 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-line-assignment-strategy.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/constants.js +20 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/constants.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/multivendor.plugin.js +151 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/multivendor.plugin.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/payment/mv-connect-sdk.js +47 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/payment/mv-connect-sdk.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/service/mv.service.js +222 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/service/mv.service.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/types.js +4 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/package.json +3 -0
- package/dist/plugin/.vendure-dashboard-temp/schema.graphql +6378 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/api-extensions.js +103 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/api-extensions.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-entity.resolver.js +105 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-entity.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-admin.resolver.js +183 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-admin.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-entity.resolver.js +113 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-entity.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-shop.resolver.js +112 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-shop.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/entities/product-review.entity.js +111 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/entities/product-review.entity.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-admin-types.js +616 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-admin-types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-shop-types.js +563 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-shop-types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/reviews-plugin.js +135 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/reviews-plugin.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/types.js +4 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/tsconfig.json +10 -0
- package/dist/plugin/config-loader.d.ts +27 -0
- package/dist/plugin/config-loader.js +141 -0
- package/dist/plugin/constants.d.ts +5 -0
- package/dist/plugin/constants.js +277 -0
- package/dist/plugin/index.d.ts +1 -0
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/schema-generator.d.ts +5 -0
- package/dist/plugin/schema-generator.js +24 -0
- package/dist/plugin/ui-config.d.ts +3 -0
- package/dist/plugin/ui-config.js +35 -0
- package/dist/plugin/vite-plugin-admin-api-schema.d.ts +24 -0
- package/dist/plugin/vite-plugin-admin-api-schema.js +82 -0
- package/dist/plugin/vite-plugin-config-loader.d.ts +17 -0
- package/dist/plugin/vite-plugin-config-loader.js +56 -0
- package/dist/plugin/vite-plugin-config.d.ts +4 -0
- package/dist/plugin/vite-plugin-config.js +38 -0
- package/dist/plugin/vite-plugin-dashboard-metadata.d.ts +9 -0
- package/dist/plugin/vite-plugin-dashboard-metadata.js +52 -0
- package/dist/plugin/vite-plugin-gql-tada.d.ts +6 -0
- package/dist/plugin/vite-plugin-gql-tada.js +51 -0
- package/dist/plugin/vite-plugin-set-root.d.ts +4 -0
- package/dist/plugin/vite-plugin-set-root.js +15 -0
- package/dist/plugin/vite-plugin-ui-config.d.ts +15 -0
- package/dist/plugin/vite-plugin-ui-config.js +43 -0
- package/dist/plugin/vite-plugin-vendure-dashboard.d.ts +35 -0
- package/dist/plugin/vite-plugin-vendure-dashboard.js +81 -0
- package/index.html +15 -0
- package/lingui.config.js +12 -0
- package/package.json +118 -0
- package/src/app/app-providers.tsx +30 -0
- package/src/app/main.tsx +97 -0
- package/src/app/routeTree.gen.ts +1372 -0
- package/src/app/routes/__root.tsx +24 -0
- package/src/app/routes/_authenticated/_administrators/administrators.graphql.ts +79 -0
- package/src/app/routes/_authenticated/_administrators/administrators.tsx +86 -0
- package/src/app/routes/_authenticated/_administrators/administrators_.$id.tsx +155 -0
- package/src/app/routes/_authenticated/_administrators/components/role-permissions-display.tsx +133 -0
- package/src/app/routes/_authenticated/_assets/assets.tsx +19 -0
- package/src/app/routes/_authenticated/_channels/channels.graphql.ts +93 -0
- package/src/app/routes/_authenticated/_channels/channels.tsx +60 -0
- package/src/app/routes/_authenticated/_channels/channels_.$id.tsx +248 -0
- package/src/app/routes/_authenticated/_collections/collections.graphql.ts +133 -0
- package/src/app/routes/_authenticated/_collections/collections.tsx +195 -0
- package/src/app/routes/_authenticated/_collections/collections_.$id.tsx +224 -0
- package/src/app/routes/_authenticated/_collections/components/collection-contents-preview-table.tsx +127 -0
- package/src/app/routes/_authenticated/_collections/components/collection-contents-sheet.tsx +46 -0
- package/src/app/routes/_authenticated/_collections/components/collection-contents-table.tsx +82 -0
- package/src/app/routes/_authenticated/_collections/components/collection-filters-selector.tsx +91 -0
- package/src/app/routes/_authenticated/_countries/countries.graphql.ts +69 -0
- package/src/app/routes/_authenticated/_countries/countries.tsx +67 -0
- package/src/app/routes/_authenticated/_countries/countries_.$id.tsx +122 -0
- package/src/app/routes/_authenticated/_customer-groups/components/customer-group-members-sheet.tsx +44 -0
- package/src/app/routes/_authenticated/_customer-groups/components/customer-group-members-table.tsx +129 -0
- package/src/app/routes/_authenticated/_customer-groups/customer-groups.graphql.ts +71 -0
- package/src/app/routes/_authenticated/_customer-groups/customer-groups.tsx +68 -0
- package/src/app/routes/_authenticated/_customer-groups/customer-groups_.$id.tsx +111 -0
- package/src/app/routes/_authenticated/_customers/components/customer-address-card.tsx +155 -0
- package/src/app/routes/_authenticated/_customers/components/customer-address-form.tsx +344 -0
- package/src/app/routes/_authenticated/_customers/components/customer-group-controls.tsx +4 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history-container.tsx +78 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history.tsx +77 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/index.ts +3 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/use-customer-history.ts +169 -0
- package/src/app/routes/_authenticated/_customers/components/customer-order-table.tsx +88 -0
- package/src/app/routes/_authenticated/_customers/components/customer-status-badge.tsx +33 -0
- package/src/app/routes/_authenticated/_customers/customers.graphql.ts +204 -0
- package/src/app/routes/_authenticated/_customers/customers.tsx +82 -0
- package/src/app/routes/_authenticated/_customers/customers_.$id.tsx +274 -0
- package/src/app/routes/_authenticated/_facets/components/edit-facet-value.tsx +129 -0
- package/src/app/routes/_authenticated/_facets/components/facet-values-sheet.tsx +46 -0
- package/src/app/routes/_authenticated/_facets/components/facet-values-table.tsx +97 -0
- package/src/app/routes/_authenticated/_facets/facets.graphql.ts +104 -0
- package/src/app/routes/_authenticated/_facets/facets.tsx +97 -0
- package/src/app/routes/_authenticated/_facets/facets_.$id.tsx +139 -0
- package/src/app/routes/_authenticated/_global-settings/global-settings.graphql.ts +28 -0
- package/src/app/routes/_authenticated/_global-settings/global-settings.tsx +161 -0
- package/src/app/routes/_authenticated/_orders/components/order-address.tsx +58 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/index.ts +3 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/order-history-container.tsx +73 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/order-history.tsx +96 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/use-order-history.ts +171 -0
- package/src/app/routes/_authenticated/_orders/components/order-table.tsx +169 -0
- package/src/app/routes/_authenticated/_orders/components/order-tax-summary.tsx +39 -0
- package/src/app/routes/_authenticated/_orders/components/payment-details.tsx +61 -0
- package/src/app/routes/_authenticated/_orders/orders.graphql.ts +325 -0
- package/src/app/routes/_authenticated/_orders/orders.tsx +120 -0
- package/src/app/routes/_authenticated/_orders/orders_.$id.tsx +133 -0
- package/src/app/routes/_authenticated/_payment-methods/components/payment-eligibility-checker-selector.tsx +104 -0
- package/src/app/routes/_authenticated/_payment-methods/components/payment-handler-selector.tsx +100 -0
- package/src/app/routes/_authenticated/_payment-methods/payment-methods.graphql.ts +83 -0
- package/src/app/routes/_authenticated/_payment-methods/payment-methods.tsx +64 -0
- package/src/app/routes/_authenticated/_payment-methods/payment-methods_.$id.tsx +183 -0
- package/src/app/routes/_authenticated/_product-variants/components/variant-price-detail.tsx +87 -0
- package/src/app/routes/_authenticated/_product-variants/product-variants.graphql.ts +123 -0
- package/src/app/routes/_authenticated/_product-variants/product-variants.tsx +78 -0
- package/src/app/routes/_authenticated/_product-variants/product-variants_.$id.tsx +331 -0
- package/src/app/routes/_authenticated/_products/components/create-product-variants-dialog.tsx +228 -0
- package/src/app/routes/_authenticated/_products/components/create-product-variants.tsx +462 -0
- package/src/app/routes/_authenticated/_products/components/option-value-input.tsx +96 -0
- package/src/app/routes/_authenticated/_products/components/product-variants-table.tsx +87 -0
- package/src/app/routes/_authenticated/_products/products.graphql.ts +116 -0
- package/src/app/routes/_authenticated/_products/products.tsx +48 -0
- package/src/app/routes/_authenticated/_products/products_.$id.tsx +196 -0
- package/src/app/routes/_authenticated/_profile/profile.graphql.ts +23 -0
- package/src/app/routes/_authenticated/_profile/profile.tsx +122 -0
- package/src/app/routes/_authenticated/_promotions/components/promotion-actions-selector.tsx +107 -0
- package/src/app/routes/_authenticated/_promotions/components/promotion-conditions-selector.tsx +107 -0
- package/src/app/routes/_authenticated/_promotions/promotions.graphql.ts +96 -0
- package/src/app/routes/_authenticated/_promotions/promotions.tsx +61 -0
- package/src/app/routes/_authenticated/_promotions/promotions_.$id.tsx +235 -0
- package/src/app/routes/_authenticated/_roles/components/expandable-permissions.tsx +54 -0
- package/src/app/routes/_authenticated/_roles/components/permissions-grid.tsx +116 -0
- package/src/app/routes/_authenticated/_roles/roles.graphql.ts +67 -0
- package/src/app/routes/_authenticated/_roles/roles.tsx +96 -0
- package/src/app/routes/_authenticated/_roles/roles_.$id.tsx +142 -0
- package/src/app/routes/_authenticated/_sellers/sellers.graphql.ts +61 -0
- package/src/app/routes/_authenticated/_sellers/sellers.tsx +51 -0
- package/src/app/routes/_authenticated/_sellers/sellers_.$id.tsx +111 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/fulfillment-handler-selector.tsx +56 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/shipping-calculator-selector.tsx +101 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/shipping-eligibility-checker-selector.tsx +101 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/test-shipping-method-dialog.tsx +32 -0
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods.graphql.ts +83 -0
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods.tsx +55 -0
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods_.$id.tsx +171 -0
- package/src/app/routes/_authenticated/_stock-locations/stock-locations.graphql.ts +62 -0
- package/src/app/routes/_authenticated/_stock-locations/stock-locations.tsx +48 -0
- package/src/app/routes/_authenticated/_stock-locations/stock-locations_.$id.tsx +115 -0
- package/src/app/routes/_authenticated/_system/components/payload-dialog.tsx +34 -0
- package/src/app/routes/_authenticated/_system/healthchecks.tsx +93 -0
- package/src/app/routes/_authenticated/_system/job-queue.graphql.ts +43 -0
- package/src/app/routes/_authenticated/_system/job-queue.tsx +161 -0
- package/src/app/routes/_authenticated/_tax-categories/tax-categories.graphql.ts +63 -0
- package/src/app/routes/_authenticated/_tax-categories/tax-categories.tsx +65 -0
- package/src/app/routes/_authenticated/_tax-categories/tax-categories_.$id.tsx +115 -0
- package/src/app/routes/_authenticated/_tax-rates/tax-rates.graphql.ts +75 -0
- package/src/app/routes/_authenticated/_tax-rates/tax-rates.tsx +108 -0
- package/src/app/routes/_authenticated/_tax-rates/tax-rates_.$id.tsx +148 -0
- package/src/app/routes/_authenticated/_zones/components/zone-countries-add.tsx +0 -0
- package/src/app/routes/_authenticated/_zones/components/zone-countries-sheet.tsx +31 -0
- package/src/app/routes/_authenticated/_zones/components/zone-countries-table.tsx +79 -0
- package/src/app/routes/_authenticated/_zones/zones.graphql.ts +96 -0
- package/src/app/routes/_authenticated/_zones/zones.tsx +57 -0
- package/src/app/routes/_authenticated/_zones/zones_.$id.tsx +103 -0
- package/src/app/routes/_authenticated/index.tsx +194 -0
- package/src/app/routes/_authenticated.tsx +25 -0
- package/src/app/routes/login.tsx +48 -0
- package/src/app/styles.css +82 -0
- package/src/app/tailwindcss-animate.css +275 -0
- package/src/i18n/locales/de.po +1579 -0
- package/src/i18n/locales/en.po +1579 -0
- package/src/lib/components/data-display/boolean.tsx +23 -0
- package/src/lib/components/data-display/date-time.tsx +13 -0
- package/src/lib/components/data-display/json.tsx +5 -0
- package/src/lib/components/data-display/money.tsx +15 -0
- package/src/lib/components/data-input/affixed-input.tsx +49 -0
- package/src/lib/components/data-input/customer-group-input.tsx +72 -0
- package/src/lib/components/data-input/datetime-input.tsx +150 -0
- package/src/lib/components/data-input/facet-value-input.tsx +68 -0
- package/src/lib/components/data-input/money-input.tsx +112 -0
- package/src/lib/components/data-input/richt-text-input.tsx +99 -0
- package/src/lib/components/data-table/data-table-column-header.tsx +73 -0
- package/src/lib/components/data-table/data-table-faceted-filter.tsx +172 -0
- package/src/lib/components/data-table/data-table-filter-dialog.tsx +73 -0
- package/src/lib/components/data-table/data-table-pagination.tsx +87 -0
- package/src/lib/components/data-table/data-table-view-options.tsx +53 -0
- package/src/lib/components/data-table/data-table.tsx +218 -0
- package/src/lib/components/layout/app-layout.tsx +42 -0
- package/src/lib/components/layout/app-sidebar.tsx +34 -0
- package/src/lib/components/layout/channel-switcher.tsx +87 -0
- package/src/lib/components/layout/content-language-selector.tsx +41 -0
- package/src/lib/components/layout/generated-breadcrumbs.tsx +82 -0
- package/src/lib/components/layout/language-dialog.tsx +104 -0
- package/src/lib/components/layout/nav-main.tsx +178 -0
- package/src/lib/components/layout/nav-projects.tsx +81 -0
- package/src/lib/components/layout/nav-user.tsx +176 -0
- package/src/lib/components/layout/prerelease-popup.tsx +38 -0
- package/src/lib/components/login/login-form.tsx +173 -0
- package/src/lib/components/shared/alerts.tsx +20 -0
- package/src/lib/components/shared/animated-number.tsx +49 -0
- package/src/lib/components/shared/asset-gallery.tsx +433 -0
- package/src/lib/components/shared/asset-picker-dialog.tsx +72 -0
- package/src/lib/components/shared/asset-preview-dialog.tsx +48 -0
- package/src/lib/components/shared/asset-preview.tsx +345 -0
- package/src/lib/components/shared/assigned-facet-values.tsx +68 -0
- package/src/lib/components/shared/channel-code-label.tsx +7 -0
- package/src/lib/components/shared/channel-selector.tsx +51 -0
- package/src/lib/components/shared/configurable-operation-arg-input.tsx +51 -0
- package/src/lib/components/shared/configurable-operation-input.tsx +133 -0
- package/src/lib/components/shared/confirmation-dialog.tsx +58 -0
- package/src/lib/components/shared/copyable-text.tsx +31 -0
- package/src/lib/components/shared/country-selector.tsx +105 -0
- package/src/lib/components/shared/currency-selector.tsx +33 -0
- package/src/lib/components/shared/custom-fields-form.tsx +86 -0
- package/src/lib/components/shared/customer-address-form.tsx +330 -0
- package/src/lib/components/shared/customer-group-chip.tsx +30 -0
- package/src/lib/components/shared/customer-group-selector.tsx +62 -0
- package/src/lib/components/shared/customer-selector.tsx +107 -0
- package/src/lib/components/shared/detail-page-button.tsx +22 -0
- package/src/lib/components/shared/entity-assets.tsx +340 -0
- package/src/lib/components/shared/error-page.tsx +31 -0
- package/src/lib/components/shared/facet-value-chip.tsx +45 -0
- package/src/lib/components/shared/facet-value-selector.tsx +306 -0
- package/src/lib/components/shared/focal-point-control.tsx +65 -0
- package/src/lib/components/shared/form-field-wrapper.tsx +37 -0
- package/src/lib/components/shared/history-timeline/history-entry.tsx +112 -0
- package/src/lib/components/shared/history-timeline/history-note-checkbox.tsx +28 -0
- package/src/lib/components/shared/history-timeline/history-note-editor.tsx +60 -0
- package/src/lib/components/shared/history-timeline/history-note-input.tsx +39 -0
- package/src/lib/components/shared/history-timeline/history-timeline.tsx +56 -0
- package/src/lib/components/shared/icon-mark.tsx +18 -0
- package/src/lib/components/shared/language-selector.tsx +48 -0
- package/src/lib/components/shared/logo-mark.tsx +24 -0
- package/src/lib/components/shared/multi-select.tsx +159 -0
- package/src/lib/components/shared/option-value-input.tsx +95 -0
- package/src/lib/components/shared/paginated-list-data-table.tsx +520 -0
- package/src/lib/components/shared/permission-guard.tsx +21 -0
- package/src/lib/components/shared/rich-text-editor.tsx +0 -0
- package/src/lib/components/shared/role-code-label.tsx +8 -0
- package/src/lib/components/shared/role-selector.tsx +56 -0
- package/src/lib/components/shared/seller-selector.tsx +107 -0
- package/src/lib/components/shared/tax-category-selector.tsx +65 -0
- package/src/lib/components/shared/translatable-form-field.tsx +74 -0
- package/src/lib/components/shared/vendure-image.tsx +159 -0
- package/src/lib/components/shared/zone-selector.tsx +66 -0
- package/src/lib/components/ui/accordion.tsx +59 -0
- package/src/lib/components/ui/alert-dialog.tsx +128 -0
- package/src/lib/components/ui/alert.tsx +60 -0
- package/src/lib/components/ui/avatar.tsx +38 -0
- package/src/lib/components/ui/badge.tsx +38 -0
- package/src/lib/components/ui/breadcrumb.tsx +102 -0
- package/src/lib/components/ui/button.tsx +51 -0
- package/src/lib/components/ui/calendar.tsx +69 -0
- package/src/lib/components/ui/card.tsx +47 -0
- package/src/lib/components/ui/checkbox.tsx +27 -0
- package/src/lib/components/ui/collapsible.tsx +33 -0
- package/src/lib/components/ui/command.tsx +133 -0
- package/src/lib/components/ui/dialog.tsx +116 -0
- package/src/lib/components/ui/dropdown-menu.tsx +220 -0
- package/src/lib/components/ui/form.tsx +141 -0
- package/src/lib/components/ui/hover-card.tsx +36 -0
- package/src/lib/components/ui/input.tsx +19 -0
- package/src/lib/components/ui/label.tsx +21 -0
- package/src/lib/components/ui/pagination.tsx +127 -0
- package/src/lib/components/ui/popover.tsx +40 -0
- package/src/lib/components/ui/scroll-area.tsx +50 -0
- package/src/lib/components/ui/select.tsx +161 -0
- package/src/lib/components/ui/separator.tsx +26 -0
- package/src/lib/components/ui/sheet.tsx +118 -0
- package/src/lib/components/ui/sidebar.tsx +696 -0
- package/src/lib/components/ui/skeleton.tsx +13 -0
- package/src/lib/components/ui/sonner.tsx +27 -0
- package/src/lib/components/ui/switch.tsx +26 -0
- package/src/lib/components/ui/table.tsx +82 -0
- package/src/lib/components/ui/tabs.tsx +48 -0
- package/src/lib/components/ui/textarea.tsx +18 -0
- package/src/lib/components/ui/tooltip.tsx +51 -0
- package/src/lib/constants.ts +326 -0
- package/src/lib/framework/component-registry/component-registry.tsx +70 -0
- package/src/lib/framework/component-registry/dynamic-component.tsx +58 -0
- package/src/lib/framework/dashboard-widget/base-widget.tsx +97 -0
- package/src/lib/framework/dashboard-widget/latest-orders-widget/index.tsx +96 -0
- package/src/lib/framework/dashboard-widget/latest-orders-widget/latest-orders-widget.graphql.ts +35 -0
- package/src/lib/framework/dashboard-widget/metrics-widget/chart.tsx +24 -0
- package/src/lib/framework/dashboard-widget/metrics-widget/index.tsx +82 -0
- package/src/lib/framework/dashboard-widget/metrics-widget/metrics-widget.graphql.ts +14 -0
- package/src/lib/framework/dashboard-widget/orders-summary/index.tsx +167 -0
- package/src/lib/framework/dashboard-widget/orders-summary/order-summary-widget.graphql.ts +14 -0
- package/src/lib/framework/dashboard-widget/types.ts +22 -0
- package/src/lib/framework/dashboard-widget/widget-extensions.tsx +19 -0
- package/src/lib/framework/defaults.ts +219 -0
- package/src/lib/framework/document-introspection/add-custom-fields.spec.ts +242 -0
- package/src/lib/framework/document-introspection/add-custom-fields.ts +246 -0
- package/src/lib/framework/document-introspection/get-document-structure.spec.ts +310 -0
- package/src/lib/framework/document-introspection/get-document-structure.ts +460 -0
- package/src/lib/framework/document-introspection/hooks.ts +10 -0
- package/src/lib/framework/extension-api/define-dashboard-extension.ts +66 -0
- package/src/lib/framework/extension-api/extension-api-types.ts +58 -0
- package/src/lib/framework/extension-api/use-dashboard-extensions.ts +26 -0
- package/src/lib/framework/form-engine/form-schema-tools.ts +98 -0
- package/src/lib/framework/form-engine/use-generated-form.tsx +116 -0
- package/src/lib/framework/layout-engine/layout-extensions.ts +30 -0
- package/src/lib/framework/layout-engine/location-wrapper.tsx +96 -0
- package/src/lib/framework/layout-engine/page-layout.tsx +272 -0
- package/src/lib/framework/nav-menu/nav-menu-extensions.ts +66 -0
- package/src/lib/framework/page/detail-page-route-loader.tsx +48 -0
- package/src/lib/framework/page/detail-page.tsx +131 -0
- package/src/lib/framework/page/list-page.tsx +166 -0
- package/src/lib/framework/page/page-api.ts +9 -0
- package/src/lib/framework/page/page-types.ts +51 -0
- package/src/lib/framework/page/use-detail-page.ts +217 -0
- package/src/lib/framework/page/use-extended-router.tsx +69 -0
- package/src/lib/framework/registry/global-registry.ts +46 -0
- package/src/lib/framework/registry/registry-types.ts +15 -0
- package/src/lib/graphql/api.ts +61 -0
- package/src/lib/graphql/fragments.tsx +54 -0
- package/src/lib/graphql/graphql-env.d.ts +499 -0
- package/src/lib/graphql/graphql.ts +15 -0
- package/src/lib/hooks/use-auth.tsx +11 -0
- package/src/lib/hooks/use-channel.ts +12 -0
- package/src/lib/hooks/use-custom-field-config.ts +10 -0
- package/src/lib/hooks/use-grouped-permissions.ts +54 -0
- package/src/lib/hooks/use-local-format.ts +119 -0
- package/src/lib/hooks/use-mobile.ts +19 -0
- package/src/lib/hooks/use-page.tsx +11 -0
- package/src/lib/hooks/use-permissions.ts +22 -0
- package/src/lib/hooks/use-server-config.ts +4 -0
- package/src/lib/hooks/use-theme.ts +10 -0
- package/src/lib/hooks/use-user-settings.tsx +12 -0
- package/src/lib/index.ts +149 -0
- package/src/lib/lib/trans.tsx +16 -0
- package/src/lib/lib/utils.ts +60 -0
- package/src/lib/providers/auth.tsx +152 -0
- package/src/lib/providers/channel-provider.tsx +121 -0
- package/src/lib/providers/i18n-provider.tsx +28 -0
- package/src/lib/providers/server-config.tsx +279 -0
- package/src/lib/providers/theme-provider.tsx +54 -0
- package/src/lib/providers/user-settings.tsx +89 -0
- package/src/lib/virtual.d.ts +12 -0
- package/vite/config-loader.ts +181 -0
- package/vite/constants.ts +280 -0
- package/vite/index.ts +1 -0
- package/vite/schema-generator.ts +40 -0
- package/vite/ui-config.ts +60 -0
- package/vite/vite-plugin-admin-api-schema.ts +141 -0
- package/vite/vite-plugin-config-loader.ts +64 -0
- package/vite/vite-plugin-config.ts +42 -0
- package/vite/vite-plugin-dashboard-metadata.ts +58 -0
- package/vite/vite-plugin-gql-tada.ts +62 -0
- package/vite/vite-plugin-theme.ts +195 -0
- package/vite/vite-plugin-ui-config.ts +60 -0
- package/vite/vite-plugin-vendure-dashboard.ts +118 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ScrollArea } from '@/components/ui/scroll-area.js';
|
|
2
|
+
import { useState, createContext, useContext } from 'react';
|
|
3
|
+
import { HistoryNoteEditor } from './history-note-editor.js';
|
|
4
|
+
|
|
5
|
+
interface HistoryTimelineProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
onEditNote?: (entryId: string, note: string, isPublic: boolean) => void;
|
|
8
|
+
onDeleteNote?: (entryId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Use context to make the note editing functions available to the child
|
|
12
|
+
// HistoryEntry component
|
|
13
|
+
const HistoryTimelineContext = createContext<{
|
|
14
|
+
editNote: (noteId: string, note: string, isPrivate: boolean) => void;
|
|
15
|
+
deleteNote: (noteId: string) => void;
|
|
16
|
+
}>({ editNote: () => {}, deleteNote: () => {} });
|
|
17
|
+
|
|
18
|
+
type NoteEditorNote = { noteId: string; note: string; isPrivate: boolean };
|
|
19
|
+
|
|
20
|
+
export function useHistoryTimeline() {
|
|
21
|
+
return useContext(HistoryTimelineContext);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function HistoryTimeline({ children, onEditNote, onDeleteNote }: HistoryTimelineProps) {
|
|
25
|
+
const [noteEditorOpen, setNoteEditorOpen] = useState(false);
|
|
26
|
+
const [noteEditorNote, setNoteEditorNote] = useState<NoteEditorNote>({ noteId: '', note: '', isPrivate: true });
|
|
27
|
+
|
|
28
|
+
const editNote = (noteId: string, note: string, isPrivate: boolean) => {
|
|
29
|
+
setNoteEditorNote({ noteId, note, isPrivate });
|
|
30
|
+
setNoteEditorOpen(true);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const deleteNote = (noteId: string) => {
|
|
34
|
+
setNoteEditorNote({ noteId, note: '', isPrivate: true });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<HistoryTimelineContext.Provider value={{ editNote, deleteNote }}>
|
|
39
|
+
<ScrollArea className=" pr-4">
|
|
40
|
+
<div className="relative">
|
|
41
|
+
<div className="absolute left-5 top-0 bottom-[44px] w-0.5 bg-gray-200" />
|
|
42
|
+
{children}
|
|
43
|
+
</div>
|
|
44
|
+
</ScrollArea>
|
|
45
|
+
<HistoryNoteEditor
|
|
46
|
+
key={noteEditorNote.noteId}
|
|
47
|
+
note={noteEditorNote.note}
|
|
48
|
+
onNoteChange={(...args) => onEditNote?.(...args)}
|
|
49
|
+
open={noteEditorOpen}
|
|
50
|
+
onOpenChange={setNoteEditorOpen}
|
|
51
|
+
noteId={noteEditorNote.noteId}
|
|
52
|
+
isPrivate={noteEditorNote.isPrivate}
|
|
53
|
+
/>
|
|
54
|
+
</HistoryTimelineContext.Provider>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function IconMark(props: React.ComponentProps<'svg'>) {
|
|
2
|
+
return (
|
|
3
|
+
<svg viewBox="0 0 40 28" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
4
|
+
<path
|
|
5
|
+
d="M10.7466 12.6853V21.9481C10.7466 22.1142 10.8389 22.2712 10.9836 22.3527L19.3904 27.1155C19.6921 27.2846 20.0615 27.2846 20.3632 27.1155L28.77 22.3527C28.9178 22.2682 29.007 22.1142 29.007 21.9481V12.6853C29.007 12.3259 28.6099 12.0994 28.2929 12.2806L20.3632 16.7716C20.0615 16.9407 19.6921 16.9407 19.3904 16.7716L11.4607 12.2806C11.1437 12.0994 10.7466 12.3259 10.7466 12.6853Z"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
d="M8.8932 0.749702L0.486371 5.50943C0.184698 5.67856 0 5.99568 0 6.33393V15.8564C0 16.0225 0.0923489 16.1796 0.237029 16.2611L8.41299 20.894C8.73005 21.0752 9.12715 20.8487 9.12715 20.4893V11.5074C9.12715 11.1661 9.31185 10.852 9.61352 10.6829L17.5432 6.19199C17.8603 6.01078 17.8603 5.56077 17.5432 5.38258L9.36726 0.749702C9.2195 0.665138 9.03788 0.665138 8.89012 0.749702H8.8932Z"
|
|
10
|
+
fill="currentColor"
|
|
11
|
+
/>
|
|
12
|
+
<path
|
|
13
|
+
d="M30.86 0.740669L39.2668 5.5004C39.5685 5.66953 39.7532 5.98664 39.7532 6.3249V15.8474C39.7532 16.0135 39.6608 16.1705 39.5162 16.2521L31.3402 20.885C31.0231 21.0662 30.626 20.8397 30.626 20.4803V11.4984C30.626 11.1571 30.4413 10.843 30.1397 10.6739L22.21 6.18295C21.8929 6.00174 21.8929 5.55174 22.21 5.37355L30.3859 0.740669C30.5337 0.656105 30.7153 0.656105 30.8631 0.740669H30.86Z"
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { api } from '@/graphql/api.js';
|
|
2
|
+
import { graphql } from '@/graphql/graphql.js';
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { useLocalFormat } from '@/hooks/use-local-format.js';
|
|
5
|
+
import { MultiSelect } from './multi-select.js';
|
|
6
|
+
import { useLingui } from '@/lib/trans.js';
|
|
7
|
+
|
|
8
|
+
const availableGlobalLanguages = graphql(`
|
|
9
|
+
query AvailableGlobalLanguages {
|
|
10
|
+
globalSettings {
|
|
11
|
+
availableLanguages
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`);
|
|
15
|
+
|
|
16
|
+
export interface LanguageSelectorProps<T extends boolean> {
|
|
17
|
+
value: T extends true ? string[] : string;
|
|
18
|
+
onChange: (value: T extends true ? string[] : string) => void;
|
|
19
|
+
multiple?: T;
|
|
20
|
+
availableLanguageCodes?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function LanguageSelector<T extends boolean>(props: LanguageSelectorProps<T>) {
|
|
24
|
+
const { data } = useQuery({
|
|
25
|
+
queryKey: ['availableGlobalLanguages'],
|
|
26
|
+
queryFn: () => api.query(availableGlobalLanguages),
|
|
27
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
28
|
+
});
|
|
29
|
+
const { formatLanguageName } = useLocalFormat();
|
|
30
|
+
const { value, onChange, multiple, availableLanguageCodes } = props;
|
|
31
|
+
const { i18n } = useLingui();
|
|
32
|
+
|
|
33
|
+
const items = (availableLanguageCodes ?? data?.globalSettings.availableLanguages ?? []).map(language => ({
|
|
34
|
+
value: language,
|
|
35
|
+
label: formatLanguageName(language)
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<MultiSelect
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={onChange}
|
|
42
|
+
multiple={multiple}
|
|
43
|
+
items={items}
|
|
44
|
+
placeholder={i18n.t('Select a language')}
|
|
45
|
+
searchPlaceholder={i18n.t('Search languages...')}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function LogoMark(props: React.ComponentProps<'svg'>) {
|
|
2
|
+
return (
|
|
3
|
+
<svg viewBox="0 0 177 33" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
4
|
+
<path
|
|
5
|
+
d="M65.192 9.73a.729.729 0 0 0-.593-.307h-2.503a.733.733 0 0 0-.685.487l-4.263 12.438-4.33-12.445a.721.721 0 0 0-.684-.486h-2.577a.73.73 0 0 0-.592.307.753.753 0 0 0-.092.662l6.139 17.077c.098.288.37.48.675.48h2.726a.708.708 0 0 0 .675-.48l6.174-17.076a.699.699 0 0 0-.092-.663l.016.01.006-.004ZM83.004 19.262c.026-.272.041-.646.041-1.133 0-1.719-.386-3.3-1.144-4.705a8.804 8.804 0 0 0-3.16-3.357c-1.34-.82-2.865-1.242-4.51-1.242-1.746 0-3.334.428-4.716 1.274-1.382.845-2.469 2.035-3.242 3.53-.767 1.479-1.154 3.175-1.154 5.035 0 1.86.396 3.556 1.17 5.044.782 1.498 1.885 2.689 3.277 3.53 1.391.846 2.995 1.275 4.767 1.275 1.901 0 3.581-.388 4.995-1.166a9.396 9.396 0 0 0 3.423-3.216.739.739 0 0 0-.206-.992l-1.959-1.316c-.165-.109-.361-.15-.561-.109a.728.728 0 0 0-.46.33 5.63 5.63 0 0 1-2.04 2.026c-.84.48-1.934.726-3.259.726-1.581 0-2.789-.521-3.695-1.603a6.478 6.478 0 0 1-1.465-3.3h13.185c.37 0 .685-.282.716-.653v.016l-.003.006Zm-13.647-2.836a6.03 6.03 0 0 1 1.505-2.58c.872-.876 1.968-1.305 3.36-1.305 1.391 0 2.545.371 3.36 1.133.665.627 1.144 1.555 1.407 2.746H69.35l.01.01-.003-.004ZM100.347 12.054a6.516 6.516 0 0 0-2.69-2.423 8.235 8.235 0 0 0-3.598-.803c-1.391 0-2.633.339-3.705 1.002-.437.272-.84.595-1.201.96v-.653a.726.726 0 0 0-.726-.727h-2.469a.728.728 0 0 0-.726.727v17.076c0 .397.32.727.726.727h2.47a.728.728 0 0 0 .725-.727V18.67c0-1.927.396-3.473 1.176-4.58.732-1.044 1.829-1.556 3.334-1.556 2.586 0 3.788 1.38 3.788 4.35v10.329c0 .397.32.727.725.727h2.469a.728.728 0 0 0 .726-.727v-11.42c0-1.421-.336-2.68-.995-3.739h-.029ZM121.243.003h-2.459a.729.729 0 0 0-.726.73v10.082a7.873 7.873 0 0 0-1.54-1.069c-1.125-.601-2.387-.9-3.727-.9-1.744 0-3.331.43-4.717 1.272-1.381.845-2.469 2.026-3.239 3.514-.767 1.473-1.153 3.16-1.153 5.028 0 1.87.393 3.595 1.169 5.077.783 1.495 1.886 2.689 3.277 3.534 1.389.841 2.98 1.27 4.735 1.27 1.325 0 2.568-.304 3.68-.912a7.922 7.922 0 0 0 1.515-1.056v.653c0 .397.323.726.726.726h2.469a.728.728 0 0 0 .726-.726V.73c0-.397-.32-.73-.726-.73l-.01.003Zm-3.185 18.674c0 1.2-.231 2.285-.691 3.226-.453.934-1.062 1.639-1.87 2.15-.798.513-1.686.763-2.713.763-1.027 0-1.876-.247-2.659-.762-.792-.512-1.401-1.226-1.854-2.157-.463-.945-.691-2.036-.691-3.262s.231-2.273.691-3.198c.453-.925 1.062-1.622 1.854-2.141.78-.512 1.655-.762 2.659-.762 1.005 0 1.918.247 2.713.762.789.503 1.417 1.23 1.87 2.15.463.942.691 2.027.691 3.227v.007-.003ZM140.761 9.414h-2.469a.728.728 0 0 0-.726.726v8.533c0 1.927-.396 3.473-1.176 4.58-.732 1.044-1.829 1.556-3.334 1.556-2.583 0-3.788-1.38-3.788-4.35V10.13a.726.726 0 0 0-.726-.726h-2.469a.727.727 0 0 0-.725.726v11.42c0 1.422.336 2.68.995 3.74a6.494 6.494 0 0 0 2.691 2.422 8.263 8.263 0 0 0 3.597.804c1.391 0 2.634-.34 3.705-1.002.437-.272.84-.586 1.211-.96v.653c0 .396.32.726.726.726h2.469a.727.727 0 0 0 .725-.726V10.14a.726.726 0 0 0-.725-.726h.019ZM155.578 9.125a6.292 6.292 0 0 0-1.886-.288c-1.407 0-2.685.397-3.81 1.191-.485.34-.938.746-1.359 1.216v-1.091a.726.726 0 0 0-.726-.727h-2.469a.728.728 0 0 0-.726.727v17.076c0 .397.32.727.726.727h2.469a.728.728 0 0 0 .726-.727v-8.171c0-1.39.247-2.596.741-3.605.485-.982 1.129-1.738 1.911-2.25a4.46 4.46 0 0 1 2.511-.761c.5 0 .947.099 1.359.297.222.109.485.09.691-.042a.731.731 0 0 0 .336-.61V9.82a.718.718 0 0 0-.501-.685l.01-.01h-.003ZM173.399 19.262c.026-.272.042-.637.042-1.133 0-1.719-.387-3.306-1.135-4.705a8.802 8.802 0 0 0-3.16-3.358c-1.341-.819-2.865-1.232-4.51-1.232-1.746 0-3.334.429-4.716 1.274-1.382.845-2.469 2.036-3.242 3.53-.764 1.48-1.154 3.176-1.154 5.035 0 1.86.396 3.556 1.169 5.045.783 1.498 1.886 2.688 3.284 3.53 1.391.845 2.995 1.274 4.767 1.274 1.901 0 3.581-.387 4.995-1.165a9.396 9.396 0 0 0 3.423-3.217.739.739 0 0 0-.206-.992l-1.959-1.316c-.165-.108-.361-.15-.561-.108a.743.743 0 0 0-.459.33 5.592 5.592 0 0 1-2.051 2.025c-.84.48-1.933.727-3.258.727-1.582 0-2.789-.522-3.696-1.604a6.48 6.48 0 0 1-1.464-3.3h13.188a.717.717 0 0 0 .716-.653l-.009.01-.004.003Zm-13.647-2.836a6.039 6.039 0 0 1 1.505-2.58c.872-.877 1.969-1.305 3.36-1.305 1.391 0 2.542.37 3.36 1.133.665.627 1.144 1.555 1.407 2.746h-9.638l.009.01-.003-.004Z"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
fill-rule="evenodd"
|
|
10
|
+
clip-rule="evenodd"
|
|
11
|
+
d="M174.388 4.798a2.148 2.148 0 0 0-2.136 2.157c0 1.191.957 2.158 2.136 2.158a2.149 2.149 0 0 0 2.137-2.158c0-1.19-.958-2.157-2.137-2.157Zm-2.611 2.157c0-1.456 1.169-2.637 2.611-2.637 1.443 0 2.612 1.181 2.612 2.637 0 1.457-1.169 2.638-2.612 2.638-1.442 0-2.611-1.181-2.611-2.638Z"
|
|
12
|
+
fill="currentColor"
|
|
13
|
+
/>
|
|
14
|
+
<path
|
|
15
|
+
d="M174.242 6.738c.146 0 .254-.03.321-.087.063-.054.098-.147.098-.275 0-.128-.035-.218-.098-.272-.064-.055-.172-.08-.321-.08h-.301v.717h.301v-.003Zm-.297.496V8.29h-.714V5.499h1.088c.364 0 .63.06.798.186.171.121.254.316.254.585a.76.76 0 0 1-.13.455.766.766 0 0 1-.399.26.59.59 0 0 1 .263.153c.079.08.155.198.234.361l.39.791h-.758l-.339-.695c-.066-.137-.136-.236-.206-.284a.463.463 0 0 0-.279-.08h-.199l-.003.003ZM11.065 17.572v9.817a.5.5 0 0 0 .244.429l8.655 5.047a1 1 0 0 0 1.002 0l8.655-5.047a.497.497 0 0 0 .245-.429v-9.817a.49.49 0 0 0-.736-.429l-8.164 4.76a1 1 0 0 1-1.002 0l-8.164-4.76a.49.49 0 0 0-.736.43Z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
d="M9.156 4.923.501 9.967c-.31.18-.501.516-.501.874v10.092a.5.5 0 0 0 .244.429l8.418 4.91a.49.49 0 0 0 .735-.429v-9.519c0-.362.19-.695.501-.874l8.165-4.76a.498.498 0 0 0 0-.857l-8.418-4.91a.482.482 0 0 0-.492 0h.003ZM31.773 4.913l8.656 5.045c.31.179.501.515.501.873v10.092a.5.5 0 0 1-.244.43l-8.418 4.91a.49.49 0 0 1-.735-.43v-9.519c0-.361-.19-.694-.501-.873l-8.165-4.76a.498.498 0 0 1 0-.858l8.418-4.91c.152-.09.34-.09.492 0h-.004Z"
|
|
20
|
+
fill="currentColor"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover.js';
|
|
2
|
+
import { Badge } from '@/components/ui/badge.js';
|
|
3
|
+
import { X, ChevronDown } from 'lucide-react';
|
|
4
|
+
import { cn } from '@/lib/utils.js';
|
|
5
|
+
import { Button } from '@/components/ui/button.js';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { Input } from '../ui/input.js';
|
|
8
|
+
|
|
9
|
+
export interface MultiSelectProps<T extends boolean> {
|
|
10
|
+
value: T extends true ? string[] : string;
|
|
11
|
+
onChange: (value: T extends true ? string[] : string) => void;
|
|
12
|
+
multiple?: T;
|
|
13
|
+
items: Array<{
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* The display value to use for the item.
|
|
18
|
+
* If not provided, the label will be used.
|
|
19
|
+
* This is useful for displaying a more complex value in
|
|
20
|
+
* a React component.
|
|
21
|
+
*/
|
|
22
|
+
display?: string | React.ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
searchPlaceholder?: string;
|
|
26
|
+
showSearch?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function MultiSelect<T extends boolean>(props: MultiSelectProps<T>) {
|
|
31
|
+
const {
|
|
32
|
+
value,
|
|
33
|
+
onChange,
|
|
34
|
+
multiple,
|
|
35
|
+
items,
|
|
36
|
+
placeholder = 'Select items',
|
|
37
|
+
searchPlaceholder = 'Search...',
|
|
38
|
+
showSearch,
|
|
39
|
+
className,
|
|
40
|
+
} = props;
|
|
41
|
+
const [search, setSearch] = useState('');
|
|
42
|
+
|
|
43
|
+
const filteredItems = items.filter(item => item.label.toLowerCase().includes(search.toLowerCase()));
|
|
44
|
+
|
|
45
|
+
const handleSelect = (selectedValue: string) => {
|
|
46
|
+
if (multiple) {
|
|
47
|
+
const currentValue = value as string[];
|
|
48
|
+
const newValue = currentValue.includes(selectedValue)
|
|
49
|
+
? currentValue.filter(v => v !== selectedValue)
|
|
50
|
+
: [...currentValue, selectedValue];
|
|
51
|
+
onChange(newValue as T extends true ? string[] : string);
|
|
52
|
+
} else {
|
|
53
|
+
onChange(selectedValue as T extends true ? string[] : string);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleRemove = (valueToRemove: string) => {
|
|
58
|
+
if (multiple) {
|
|
59
|
+
const currentValue = value as string[];
|
|
60
|
+
onChange(currentValue.filter(v => v !== valueToRemove) as T extends true ? string[] : string);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const renderTrigger = () => {
|
|
65
|
+
if (multiple) {
|
|
66
|
+
const selectedValues = value as string[];
|
|
67
|
+
return (
|
|
68
|
+
<Button
|
|
69
|
+
variant="outline"
|
|
70
|
+
role="combobox"
|
|
71
|
+
className={cn(
|
|
72
|
+
'w-full justify-between',
|
|
73
|
+
'min-h-[2.5rem] h-auto',
|
|
74
|
+
'flex flex-wrap gap-1 p-1',
|
|
75
|
+
className,
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
<div className="flex flex-wrap gap-1">
|
|
79
|
+
{selectedValues.length > 0 ? (
|
|
80
|
+
selectedValues.map(selectedValue => {
|
|
81
|
+
const item = items.find(i => i.value === selectedValue);
|
|
82
|
+
return (
|
|
83
|
+
<Badge
|
|
84
|
+
key={selectedValue}
|
|
85
|
+
variant="secondary"
|
|
86
|
+
className="flex items-center gap-1"
|
|
87
|
+
>
|
|
88
|
+
{item?.display ?? item?.label ?? selectedValue}
|
|
89
|
+
<div
|
|
90
|
+
onClick={e => {
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
handleRemove(selectedValue);
|
|
93
|
+
}}
|
|
94
|
+
onKeyDown={e => {
|
|
95
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
handleRemove(selectedValue);
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
role="button"
|
|
101
|
+
tabIndex={0}
|
|
102
|
+
className="ml-1 hover:text-destructive cursor-pointer"
|
|
103
|
+
aria-label={`Remove ${item?.label ?? selectedValue}`}
|
|
104
|
+
>
|
|
105
|
+
<X className="h-3 w-3" />
|
|
106
|
+
</div>
|
|
107
|
+
</Badge>
|
|
108
|
+
);
|
|
109
|
+
})
|
|
110
|
+
) : (
|
|
111
|
+
<span className="text-muted-foreground">{placeholder}</span>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
<ChevronDown className="h-4 w-4 shrink-0 opacity-50" />
|
|
115
|
+
</Button>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
const selectedItem = items.find(i => i.value === value);
|
|
119
|
+
return (
|
|
120
|
+
<Button variant="outline" role="combobox" className={cn('w-full justify-between', className)}>
|
|
121
|
+
{selectedItem ? (selectedItem.display ?? selectedItem.label) : placeholder}
|
|
122
|
+
<ChevronDown className="h-4 w-4 shrink-0 opacity-50" />
|
|
123
|
+
</Button>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Popover>
|
|
129
|
+
<PopoverTrigger asChild>{renderTrigger()}</PopoverTrigger>
|
|
130
|
+
<PopoverContent className="w-[200px] p-0" side="bottom" align="start">
|
|
131
|
+
{(showSearch === true || items.length > 10) && (
|
|
132
|
+
<div className="p-2">
|
|
133
|
+
<Input
|
|
134
|
+
type="text"
|
|
135
|
+
placeholder={searchPlaceholder}
|
|
136
|
+
value={search}
|
|
137
|
+
onChange={e => setSearch(e.target.value)}
|
|
138
|
+
className="w-full px-2 py-1 text-sm border rounded"
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
<div className="max-h-[300px] overflow-auto">
|
|
143
|
+
{filteredItems.map(item => (
|
|
144
|
+
<button
|
|
145
|
+
key={item.value}
|
|
146
|
+
onClick={() => handleSelect(item.value)}
|
|
147
|
+
className={cn(
|
|
148
|
+
'w-full px-2 py-1.5 text-sm text-left hover:bg-accent',
|
|
149
|
+
multiple && (value as string[]).includes(item.value) && 'bg-accent',
|
|
150
|
+
)}
|
|
151
|
+
>
|
|
152
|
+
{item.display ?? item.label}
|
|
153
|
+
</button>
|
|
154
|
+
))}
|
|
155
|
+
</div>
|
|
156
|
+
</PopoverContent>
|
|
157
|
+
</Popover>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useFieldArray } from "react-hook-form";
|
|
2
|
+
import { useFormContext } from "react-hook-form";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Input } from "@/components/ui/input.js";
|
|
5
|
+
import { Button } from "@/components/ui/button.js";
|
|
6
|
+
import { Badge } from "@/components/ui/badge.js";
|
|
7
|
+
import { Plus, X } from "lucide-react";
|
|
8
|
+
|
|
9
|
+
interface OptionValue {
|
|
10
|
+
value: string;
|
|
11
|
+
id: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface FormValues {
|
|
15
|
+
optionGroups: {
|
|
16
|
+
name: string;
|
|
17
|
+
values: OptionValue[];
|
|
18
|
+
}[];
|
|
19
|
+
variants: Record<string, {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
sku: string;
|
|
22
|
+
price: string;
|
|
23
|
+
stock: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface OptionValueInputProps {
|
|
28
|
+
groupIndex: number;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function OptionValueInput({ groupIndex, disabled = false }: OptionValueInputProps) {
|
|
33
|
+
const { control, watch } = useFormContext<FormValues>();
|
|
34
|
+
const { fields, append, remove } = useFieldArray({
|
|
35
|
+
control,
|
|
36
|
+
name: `optionGroups.${groupIndex}.values`,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const [newValue, setNewValue] = useState('');
|
|
40
|
+
|
|
41
|
+
const handleAddValue = () => {
|
|
42
|
+
if (newValue.trim() && !fields.some(f => f.value === newValue.trim())) {
|
|
43
|
+
append({ value: newValue.trim(), id: crypto.randomUUID() });
|
|
44
|
+
setNewValue('');
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleKeyPress = (e: React.KeyboardEvent) => {
|
|
49
|
+
if (e.key === 'Enter') {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
handleAddValue();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="space-y-2">
|
|
57
|
+
<div className="flex items-center gap-2">
|
|
58
|
+
<Input
|
|
59
|
+
value={newValue}
|
|
60
|
+
onChange={e => setNewValue(e.target.value)}
|
|
61
|
+
onKeyDown={handleKeyPress}
|
|
62
|
+
placeholder="Enter value and press Enter"
|
|
63
|
+
disabled={disabled}
|
|
64
|
+
className="flex-1"
|
|
65
|
+
/>
|
|
66
|
+
<Button
|
|
67
|
+
type="button"
|
|
68
|
+
variant="outline"
|
|
69
|
+
size="sm"
|
|
70
|
+
onClick={handleAddValue}
|
|
71
|
+
disabled={disabled || !newValue.trim()}
|
|
72
|
+
>
|
|
73
|
+
<Plus className="h-4 w-4" />
|
|
74
|
+
</Button>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div className="flex flex-wrap gap-2">
|
|
78
|
+
{fields.map((field, index) => (
|
|
79
|
+
<Badge key={field.id} variant="secondary" className="flex items-center gap-1 py-1 px-2">
|
|
80
|
+
{field.value}
|
|
81
|
+
<Button
|
|
82
|
+
type="button"
|
|
83
|
+
variant="ghost"
|
|
84
|
+
size="sm"
|
|
85
|
+
className="h-4 w-4 p-0 ml-1"
|
|
86
|
+
onClick={() => remove(index)}
|
|
87
|
+
>
|
|
88
|
+
<X className="h-3 w-3" />
|
|
89
|
+
</Button>
|
|
90
|
+
</Badge>
|
|
91
|
+
))}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|