@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,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldInfo,
|
|
3
|
+
isEnumType,
|
|
4
|
+
isScalarType,
|
|
5
|
+
} from '@/framework/document-introspection/get-document-structure.js';
|
|
6
|
+
import { z, ZodRawShape, ZodType, ZodTypeAny } from 'zod';
|
|
7
|
+
|
|
8
|
+
export function createFormSchemaFromFields(fields: FieldInfo[]) {
|
|
9
|
+
const schemaConfig: ZodRawShape = {};
|
|
10
|
+
for (const field of fields) {
|
|
11
|
+
const isScalar = isScalarType(field.type);
|
|
12
|
+
const isEnum = isEnumType(field.type);
|
|
13
|
+
if (isScalar || isEnum) {
|
|
14
|
+
schemaConfig[field.name] = getZodTypeFromField(field);
|
|
15
|
+
} else if (field.typeInfo) {
|
|
16
|
+
let nestedType: ZodType = createFormSchemaFromFields(field.typeInfo);
|
|
17
|
+
if (field.nullable) {
|
|
18
|
+
nestedType = nestedType.optional().nullable();
|
|
19
|
+
}
|
|
20
|
+
if (field.list) {
|
|
21
|
+
nestedType = z.array(nestedType);
|
|
22
|
+
}
|
|
23
|
+
schemaConfig[field.name] = nestedType;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return z.object(schemaConfig);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getDefaultValuesFromFields(fields: FieldInfo[], defaultLanguageCode?: string) {
|
|
30
|
+
const defaultValues: Record<string, any> = {};
|
|
31
|
+
for (const field of fields) {
|
|
32
|
+
if (field.typeInfo) {
|
|
33
|
+
const nestedObjectDefaults = getDefaultValuesFromFields(field.typeInfo, defaultLanguageCode);
|
|
34
|
+
if (field.list) {
|
|
35
|
+
defaultValues[field.name] = [nestedObjectDefaults];
|
|
36
|
+
} else {
|
|
37
|
+
defaultValues[field.name] = nestedObjectDefaults;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
defaultValues[field.name] = getDefaultValueFromField(field, defaultLanguageCode);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return defaultValues;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getDefaultValueFromField(field: FieldInfo, defaultLanguageCode?: string) {
|
|
47
|
+
if (field.list) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
switch (field.type) {
|
|
51
|
+
case 'String':
|
|
52
|
+
case 'DateTime':
|
|
53
|
+
return '';
|
|
54
|
+
case 'Int':
|
|
55
|
+
case 'Float':
|
|
56
|
+
case 'Money':
|
|
57
|
+
return 0;
|
|
58
|
+
case 'Boolean':
|
|
59
|
+
return false;
|
|
60
|
+
case 'ID':
|
|
61
|
+
return '';
|
|
62
|
+
case 'LanguageCode':
|
|
63
|
+
return defaultLanguageCode || 'en';
|
|
64
|
+
case 'JSON':
|
|
65
|
+
return {};
|
|
66
|
+
default: {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function getZodTypeFromField(field: FieldInfo): ZodTypeAny {
|
|
73
|
+
let zodType: ZodType;
|
|
74
|
+
switch (field.type) {
|
|
75
|
+
case 'String':
|
|
76
|
+
case 'ID':
|
|
77
|
+
case 'DateTime':
|
|
78
|
+
zodType = z.string();
|
|
79
|
+
break;
|
|
80
|
+
case 'Int':
|
|
81
|
+
case 'Float':
|
|
82
|
+
case 'Money':
|
|
83
|
+
zodType = z.number();
|
|
84
|
+
break;
|
|
85
|
+
case 'Boolean':
|
|
86
|
+
zodType = z.boolean();
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
zodType = z.any();
|
|
90
|
+
}
|
|
91
|
+
if (field.list) {
|
|
92
|
+
zodType = z.array(zodType);
|
|
93
|
+
}
|
|
94
|
+
if (field.nullable) {
|
|
95
|
+
zodType = zodType.optional().nullable();
|
|
96
|
+
}
|
|
97
|
+
return zodType;
|
|
98
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getOperationVariablesFields } from '@/framework/document-introspection/get-document-structure.js';
|
|
2
|
+
import {
|
|
3
|
+
createFormSchemaFromFields,
|
|
4
|
+
getDefaultValuesFromFields,
|
|
5
|
+
} from '@/framework/form-engine/form-schema-tools.js';
|
|
6
|
+
import { useChannel } from '@/hooks/use-channel.js';
|
|
7
|
+
import { useServerConfig } from '@/hooks/use-server-config.js';
|
|
8
|
+
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
9
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
10
|
+
import { VariablesOf } from 'gql.tada';
|
|
11
|
+
import { FormEvent } from 'react';
|
|
12
|
+
import { useForm } from 'react-hook-form';
|
|
13
|
+
|
|
14
|
+
export interface GeneratedFormOptions<
|
|
15
|
+
T extends TypedDocumentNode<any, any>,
|
|
16
|
+
VarName extends keyof VariablesOf<T> = 'input',
|
|
17
|
+
E extends Record<string, any> = Record<string, any>,
|
|
18
|
+
> {
|
|
19
|
+
document?: T;
|
|
20
|
+
entity: E | null | undefined;
|
|
21
|
+
setValues: (entity: NonNullable<E>) => VariablesOf<T>[VarName];
|
|
22
|
+
onSubmit?: (values: VariablesOf<T>[VarName]) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @description
|
|
27
|
+
* This hook is used to create a form from a document and an entity.
|
|
28
|
+
* It will create a form with the fields defined in the document's input type.
|
|
29
|
+
* It will also create a submit handler that will submit the form to the server.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
export function useGeneratedForm<
|
|
33
|
+
T extends TypedDocumentNode<any, any>,
|
|
34
|
+
VarName extends keyof VariablesOf<T> = 'input',
|
|
35
|
+
E extends Record<string, any> = Record<string, any>,
|
|
36
|
+
>(options: GeneratedFormOptions<T, VarName, E>) {
|
|
37
|
+
const { document, entity, setValues, onSubmit } = options;
|
|
38
|
+
const { activeChannel } = useChannel();
|
|
39
|
+
const availableLanguages = useServerConfig()?.availableLanguages || [];
|
|
40
|
+
const updateFields = document ? getOperationVariablesFields(document) : [];
|
|
41
|
+
const schema = createFormSchemaFromFields(updateFields);
|
|
42
|
+
const defaultValues = getDefaultValuesFromFields(updateFields, activeChannel?.defaultLanguageCode);
|
|
43
|
+
const processedEntity = ensureTranslationsForAllLanguages(entity, availableLanguages);
|
|
44
|
+
|
|
45
|
+
const form = useForm({
|
|
46
|
+
resolver: async (values, context, options) => {
|
|
47
|
+
const result = await zodResolver(schema)(values, context, options);
|
|
48
|
+
if (Object.keys(result.errors).length > 0) {
|
|
49
|
+
console.log('Zod form validation errors:', result.errors);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
},
|
|
53
|
+
defaultValues,
|
|
54
|
+
values: processedEntity ? setValues(processedEntity) : defaultValues,
|
|
55
|
+
});
|
|
56
|
+
let submitHandler = (event: FormEvent) => {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
};
|
|
59
|
+
if (onSubmit) {
|
|
60
|
+
submitHandler = (event: FormEvent) => {
|
|
61
|
+
form.handleSubmit(onSubmit)(event);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return { form, submitHandler };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Ensures that an entity with translations has entries for all available languages.
|
|
70
|
+
* If a language is missing, it creates an empty translation based on the structure of existing translations.
|
|
71
|
+
*/
|
|
72
|
+
function ensureTranslationsForAllLanguages<E extends Record<string, any>>(
|
|
73
|
+
entity: E | null | undefined,
|
|
74
|
+
availableLanguages: string[] = [],
|
|
75
|
+
): E | null | undefined {
|
|
76
|
+
if (
|
|
77
|
+
!entity ||
|
|
78
|
+
!('translations' in entity) ||
|
|
79
|
+
!Array.isArray((entity as any).translations) ||
|
|
80
|
+
!availableLanguages.length
|
|
81
|
+
) {
|
|
82
|
+
return entity;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Create a deep copy of the entity to avoid mutation
|
|
86
|
+
const processedEntity = { ...entity } as any;
|
|
87
|
+
const translations = [...(processedEntity.translations || [])];
|
|
88
|
+
|
|
89
|
+
// Get existing language codes
|
|
90
|
+
const existingLanguageCodes = new Set(translations.map((t: any) => t.languageCode));
|
|
91
|
+
|
|
92
|
+
// Add missing language translations
|
|
93
|
+
for (const langCode of availableLanguages) {
|
|
94
|
+
if (!existingLanguageCodes.has(langCode)) {
|
|
95
|
+
// Find a translation to use as template for field structure
|
|
96
|
+
const template = translations[0] || {};
|
|
97
|
+
const emptyTranslation: Record<string, any> = {
|
|
98
|
+
languageCode: langCode,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Add empty fields based on template (excluding languageCode)
|
|
102
|
+
Object.keys(template).forEach(key => {
|
|
103
|
+
if (key !== 'languageCode') {
|
|
104
|
+
emptyTranslation[key] = '';
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
translations.push(emptyTranslation);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Update the processed entity with complete translations
|
|
113
|
+
processedEntity.translations = translations;
|
|
114
|
+
|
|
115
|
+
return processedEntity as E;
|
|
116
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DashboardActionBarItem,
|
|
3
|
+
DashboardPageBlockDefinition,
|
|
4
|
+
} from '../extension-api/extension-api-types.js';
|
|
5
|
+
import { globalRegistry } from '../registry/global-registry.js';
|
|
6
|
+
|
|
7
|
+
globalRegistry.register('dashboardActionBarItemRegistry', new Map<string, DashboardActionBarItem[]>());
|
|
8
|
+
globalRegistry.register('dashboardPageBlockRegistry', new Map<string, DashboardPageBlockDefinition[]>());
|
|
9
|
+
|
|
10
|
+
export function registerDashboardActionBarItem(item: DashboardActionBarItem) {
|
|
11
|
+
globalRegistry.set('dashboardActionBarItemRegistry', map => {
|
|
12
|
+
map.set(item.locationId, [...(map.get(item.locationId) ?? []), item]);
|
|
13
|
+
return map;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getDashboardActionBarItems(locationId: string) {
|
|
18
|
+
return globalRegistry.get('dashboardActionBarItemRegistry').get(locationId) ?? [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function registerDashboardPageBlock(block: DashboardPageBlockDefinition) {
|
|
22
|
+
globalRegistry.set('dashboardPageBlockRegistry', map => {
|
|
23
|
+
map.set(block.location.pageId, [...(map.get(block.location.pageId) ?? []), block]);
|
|
24
|
+
return map;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getDashboardPageBlocks(pageId: string) {
|
|
29
|
+
return globalRegistry.get('dashboardPageBlockRegistry').get(pageId) ?? [];
|
|
30
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { CopyableText } from '@/components/shared/copyable-text.js';
|
|
2
|
+
import { Button } from '@/components/ui/button.js';
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover.js';
|
|
4
|
+
import { usePage } from '@/hooks/use-page.js';
|
|
5
|
+
import { useUserSettings } from '@/hooks/use-user-settings.js';
|
|
6
|
+
import { cn } from '@/lib/utils.js';
|
|
7
|
+
import { Trans } from '@/lib/trans.js';
|
|
8
|
+
import { CodeXmlIcon, InfoIcon } from 'lucide-react';
|
|
9
|
+
import { createContext, useContext, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
const LocationWrapperContext = createContext<{
|
|
12
|
+
parentId: string | null;
|
|
13
|
+
hoveredId: string | null;
|
|
14
|
+
setHoveredId: ((id: string | null) => void) | null;
|
|
15
|
+
}>({
|
|
16
|
+
parentId: null,
|
|
17
|
+
hoveredId: null,
|
|
18
|
+
setHoveredId: null,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function LocationWrapper({ children, blockId }: { children: React.ReactNode; blockId?: string }) {
|
|
22
|
+
const page = usePage();
|
|
23
|
+
const { settings } = useUserSettings();
|
|
24
|
+
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
25
|
+
const isPageWrapper = !blockId;
|
|
26
|
+
|
|
27
|
+
const [hoveredIdTopLevel, setHoveredIdTopLevel] = useState<string | null>(null);
|
|
28
|
+
const { hoveredId, setHoveredId, parentId } = useContext(LocationWrapperContext);
|
|
29
|
+
const id = `${page.pageId}-${blockId ?? 'page'}`;
|
|
30
|
+
const isHovered = hoveredId === id || hoveredIdTopLevel === id;
|
|
31
|
+
|
|
32
|
+
const setHoverId = (id: string | null) => {
|
|
33
|
+
if (setHoveredId) {
|
|
34
|
+
setHoveredId(id);
|
|
35
|
+
} else {
|
|
36
|
+
setHoveredIdTopLevel(id);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (settings.devMode) {
|
|
41
|
+
const pageId = page.pageId;
|
|
42
|
+
return (
|
|
43
|
+
<LocationWrapperContext.Provider
|
|
44
|
+
value={{ hoveredId: hoveredIdTopLevel, setHoveredId: setHoveredIdTopLevel, parentId: id }}
|
|
45
|
+
>
|
|
46
|
+
<div
|
|
47
|
+
className={cn(
|
|
48
|
+
`ring-2 rounded-xl transition-all delay-50 relative`,
|
|
49
|
+
isHovered || isPopoverOpen ? 'ring-dev-mode' : 'ring-transparent',
|
|
50
|
+
isPageWrapper ? 'ring-inset' : '',
|
|
51
|
+
)}
|
|
52
|
+
onMouseEnter={() => setHoverId(id)}
|
|
53
|
+
onMouseLeave={() => setHoverId(parentId)}
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
className={`absolute top-0.5 right-0.5 transition-all delay-50 z-10 ${isHovered || isPopoverOpen ? 'visible' : 'invisible'}`}
|
|
57
|
+
>
|
|
58
|
+
<Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>
|
|
59
|
+
<PopoverTrigger asChild>
|
|
60
|
+
<Button variant="ghost" size="icon" className="rounded-lg">
|
|
61
|
+
<CodeXmlIcon className="text-dev-mode w-5 h-5" />
|
|
62
|
+
</Button>
|
|
63
|
+
</PopoverTrigger>
|
|
64
|
+
<PopoverContent className="w-60">
|
|
65
|
+
<div className="space-y-2">
|
|
66
|
+
<div className="flex items-center gap-2">
|
|
67
|
+
<InfoIcon className="h-4 w-4 text-dev-mode" />
|
|
68
|
+
<span className="font-medium">
|
|
69
|
+
<Trans>Location Details</Trans>
|
|
70
|
+
</span>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="space-y-1.5">
|
|
73
|
+
{pageId && (
|
|
74
|
+
<div>
|
|
75
|
+
<div className="text-xs text-muted-foreground">pageId</div>
|
|
76
|
+
<CopyableText text={pageId} />
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
{blockId && (
|
|
80
|
+
<div>
|
|
81
|
+
<div className="text-xs text-muted-foreground">blockId</div>
|
|
82
|
+
<CopyableText text={blockId} />
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</PopoverContent>
|
|
88
|
+
</Popover>
|
|
89
|
+
</div>
|
|
90
|
+
{children}
|
|
91
|
+
</div>
|
|
92
|
+
</LocationWrapperContext.Provider>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return children;
|
|
96
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { CustomFieldsForm } from '@/components/shared/custom-fields-form.js';
|
|
2
|
+
import { PermissionGuard } from '@/components/shared/permission-guard.js';
|
|
3
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card.js';
|
|
4
|
+
import { Form } from '@/components/ui/form.js';
|
|
5
|
+
import { useCustomFieldConfig } from '@/hooks/use-custom-field-config.js';
|
|
6
|
+
import { usePage } from '@/hooks/use-page.js';
|
|
7
|
+
import { cn } from '@/lib/utils.js';
|
|
8
|
+
import { useMediaQuery } from '@uidotdev/usehooks';
|
|
9
|
+
import React, { ComponentProps, createContext } from 'react';
|
|
10
|
+
import { Control, UseFormReturn } from 'react-hook-form';
|
|
11
|
+
import { DashboardActionBarItem } from '../extension-api/extension-api-types.js';
|
|
12
|
+
import { getDashboardActionBarItems, getDashboardPageBlocks } from './layout-extensions.js';
|
|
13
|
+
import { LocationWrapper } from './location-wrapper.js';
|
|
14
|
+
|
|
15
|
+
export interface PageProps extends ComponentProps<'div'> {
|
|
16
|
+
pageId?: string;
|
|
17
|
+
entity?: any;
|
|
18
|
+
form?: UseFormReturn<any>;
|
|
19
|
+
submitHandler?: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PageProvider = createContext<PageContext | undefined>(undefined);
|
|
23
|
+
|
|
24
|
+
export function Page({ children, pageId, entity, form, submitHandler, ...props }: PageProps) {
|
|
25
|
+
const childArray = React.Children.toArray(children);
|
|
26
|
+
|
|
27
|
+
const pageTitle = childArray.find(child => React.isValidElement(child) && child.type === PageTitle);
|
|
28
|
+
const pageActionBar = childArray.find(
|
|
29
|
+
child => React.isValidElement(child) && child.type === PageActionBar,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const pageContent = childArray.filter(
|
|
33
|
+
child => React.isValidElement(child) && child.type !== PageTitle && child.type !== PageActionBar,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const pageHeader = (
|
|
37
|
+
<div className="flex items-center justify-between">
|
|
38
|
+
{pageTitle}
|
|
39
|
+
{pageActionBar}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const pageContentWithOptionalForm = form ? (
|
|
44
|
+
<Form {...form}>
|
|
45
|
+
<form onSubmit={submitHandler} className="space-y-4">
|
|
46
|
+
{pageHeader}
|
|
47
|
+
{pageContent}
|
|
48
|
+
</form>
|
|
49
|
+
</Form>
|
|
50
|
+
) : (
|
|
51
|
+
<div className="space-y-4">
|
|
52
|
+
{pageHeader}
|
|
53
|
+
{pageContent}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<PageProvider value={{ pageId, form, entity }}>
|
|
59
|
+
<LocationWrapper>
|
|
60
|
+
<div className={cn('m-4', props.className)} {...props}>
|
|
61
|
+
{pageContentWithOptionalForm}
|
|
62
|
+
</div>
|
|
63
|
+
</LocationWrapper>
|
|
64
|
+
</PageProvider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type PageLayoutProps = {
|
|
69
|
+
children: React.ReactNode;
|
|
70
|
+
className?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function isPageBlock(child: unknown): child is React.ReactElement<PageBlockProps> {
|
|
74
|
+
if (!child) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!React.isValidElement(child)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const props = (child as React.ReactElement<PageBlockProps>).props;
|
|
81
|
+
const hasColumn = 'column' in props;
|
|
82
|
+
const hasBlockId = 'blockId' in props;
|
|
83
|
+
return hasColumn || hasBlockId;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function PageLayout({ children, className }: PageLayoutProps) {
|
|
87
|
+
const page = usePage();
|
|
88
|
+
const isDesktop = useMediaQuery('only screen and (min-width : 769px)');
|
|
89
|
+
// Separate blocks into categories
|
|
90
|
+
const childArray: React.ReactElement<PageBlockProps>[] = [];
|
|
91
|
+
const extensionBlocks = getDashboardPageBlocks(page.pageId ?? '');
|
|
92
|
+
React.Children.forEach(children, child => {
|
|
93
|
+
if (isPageBlock(child)) {
|
|
94
|
+
childArray.push(child);
|
|
95
|
+
}
|
|
96
|
+
// check for a React Fragment
|
|
97
|
+
if (React.isValidElement(child) && child.type === React.Fragment) {
|
|
98
|
+
React.Children.forEach((child as React.ReactElement<PageBlockProps>).props.children, child => {
|
|
99
|
+
if (isPageBlock(child)) {
|
|
100
|
+
childArray.push(child);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const finalChildArray: React.ReactElement<PageBlockProps>[] = [];
|
|
107
|
+
for (const childBlock of childArray) {
|
|
108
|
+
if (childBlock) {
|
|
109
|
+
const blockId =
|
|
110
|
+
childBlock.props.blockId ??
|
|
111
|
+
(childBlock.type === CustomFieldsPageBlock ? 'custom-fields' : undefined);
|
|
112
|
+
const extensionBlock = extensionBlocks.find(block => block.location.position.blockId === blockId);
|
|
113
|
+
if (extensionBlock) {
|
|
114
|
+
const ExtensionBlock = (
|
|
115
|
+
<PageBlock
|
|
116
|
+
column={extensionBlock.location.column}
|
|
117
|
+
blockId={extensionBlock.id}
|
|
118
|
+
title={extensionBlock.title}
|
|
119
|
+
>
|
|
120
|
+
{<extensionBlock.component context={page} />}
|
|
121
|
+
</PageBlock>
|
|
122
|
+
);
|
|
123
|
+
if (extensionBlock.location.position.order === 'before') {
|
|
124
|
+
finalChildArray.push(ExtensionBlock, childBlock);
|
|
125
|
+
} else if (extensionBlock.location.position.order === 'after') {
|
|
126
|
+
finalChildArray.push(childBlock, ExtensionBlock);
|
|
127
|
+
} else if (extensionBlock.location.position.order === 'replace') {
|
|
128
|
+
finalChildArray.push(ExtensionBlock);
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
finalChildArray.push(childBlock);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const fullWidthBlocks = finalChildArray.filter(
|
|
137
|
+
child => isPageBlock(child) && child.type === FullWidthPageBlock,
|
|
138
|
+
);
|
|
139
|
+
const mainBlocks = finalChildArray.filter(child => isPageBlock(child) && child.props.column === 'main');
|
|
140
|
+
const sideBlocks = finalChildArray.filter(child => isPageBlock(child) && child.props.column === 'side');
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div className={cn('w-full space-y-4', className)}>
|
|
144
|
+
{isDesktop ? (
|
|
145
|
+
<div className="hidden md:grid md:grid-cols-5 lg:grid-cols-4 md:gap-4">
|
|
146
|
+
{fullWidthBlocks.length > 0 && (
|
|
147
|
+
<div className="md:col-span-5 space-y-4">{fullWidthBlocks}</div>
|
|
148
|
+
)}
|
|
149
|
+
<div className="md:col-span-3 space-y-4">{mainBlocks}</div>
|
|
150
|
+
<div className="md:col-span-2 lg:col-span-1 space-y-4">{sideBlocks}</div>
|
|
151
|
+
</div>
|
|
152
|
+
) : (
|
|
153
|
+
<div className="md:hidden space-y-4">{children}</div>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function DetailFormGrid({ children }: { children: React.ReactNode }) {
|
|
160
|
+
return <div className="md:grid md:grid-cols-2 gap-4 items-start mb-4">{children}</div>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface PageContext {
|
|
164
|
+
pageId?: string;
|
|
165
|
+
entity?: any;
|
|
166
|
+
form?: UseFormReturn<any>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function PageTitle({ children }: { children: React.ReactNode }) {
|
|
170
|
+
return <h1 className="text-2xl font-semibold">{children}</h1>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function PageActionBar({ children }: { children: React.ReactNode }) {
|
|
174
|
+
let childArray = React.Children.toArray(children);
|
|
175
|
+
|
|
176
|
+
const leftContent = childArray.filter(
|
|
177
|
+
child => React.isValidElement(child) && child.type === PageActionBarLeft,
|
|
178
|
+
);
|
|
179
|
+
const rightContent = childArray.filter(
|
|
180
|
+
child => React.isValidElement(child) && child.type === PageActionBarRight,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<div className={cn('flex gap-2', leftContent.length > 0 ? 'justify-between' : 'justify-end')}>
|
|
185
|
+
{leftContent.length > 0 && <div className="flex justify-start gap-2">{leftContent}</div>}
|
|
186
|
+
{rightContent.length > 0 && <div className="flex justify-end gap-2">{rightContent}</div>}
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function PageActionBarLeft({ children }: { children: React.ReactNode }) {
|
|
192
|
+
return <div className="flex justify-start gap-2">{children}</div>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function PageActionBarRight({ children }: { children: React.ReactNode }) {
|
|
196
|
+
const page = usePage();
|
|
197
|
+
const actionBarItems = page.pageId ? getDashboardActionBarItems(page.pageId) : [];
|
|
198
|
+
return (
|
|
199
|
+
<div className="flex justify-end gap-2">
|
|
200
|
+
{actionBarItems.map((item, index) => (
|
|
201
|
+
<PageActionBarItem key={index} item={item} page={page} />
|
|
202
|
+
))}
|
|
203
|
+
{children}
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function PageActionBarItem({ item, page }: { item: DashboardActionBarItem; page: PageContext }) {
|
|
209
|
+
return (
|
|
210
|
+
<PermissionGuard requires={item.requiresPermission ?? []}>
|
|
211
|
+
<item.component context={page} />
|
|
212
|
+
</PermissionGuard>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type PageBlockProps = {
|
|
217
|
+
children?: React.ReactNode;
|
|
218
|
+
/** Which column this block should appear in */
|
|
219
|
+
column: 'main' | 'side';
|
|
220
|
+
blockId?: string;
|
|
221
|
+
title?: React.ReactNode | string;
|
|
222
|
+
description?: React.ReactNode | string;
|
|
223
|
+
className?: string;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export function PageBlock({ children, title, description, className, blockId }: PageBlockProps) {
|
|
227
|
+
return (
|
|
228
|
+
<LocationWrapper blockId={blockId}>
|
|
229
|
+
<Card className={cn('w-full', className)}>
|
|
230
|
+
{title || description ? (
|
|
231
|
+
<CardHeader>
|
|
232
|
+
{title && <CardTitle>{title}</CardTitle>}
|
|
233
|
+
{description && <CardDescription>{description}</CardDescription>}
|
|
234
|
+
</CardHeader>
|
|
235
|
+
) : null}
|
|
236
|
+
<CardContent className={cn(!title ? 'pt-6' : '')}>{children}</CardContent>
|
|
237
|
+
</Card>
|
|
238
|
+
</LocationWrapper>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function FullWidthPageBlock({
|
|
243
|
+
children,
|
|
244
|
+
className,
|
|
245
|
+
blockId,
|
|
246
|
+
}: Pick<PageBlockProps, 'children' | 'className' | 'blockId'>) {
|
|
247
|
+
return (
|
|
248
|
+
<LocationWrapper blockId={blockId}>
|
|
249
|
+
<div className={cn('w-full', className)}>{children}</div>
|
|
250
|
+
</LocationWrapper>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function CustomFieldsPageBlock({
|
|
255
|
+
column,
|
|
256
|
+
entityType,
|
|
257
|
+
control,
|
|
258
|
+
}: {
|
|
259
|
+
column: 'main' | 'side';
|
|
260
|
+
entityType: string;
|
|
261
|
+
control: Control<any, any>;
|
|
262
|
+
}) {
|
|
263
|
+
const customFieldConfig = useCustomFieldConfig(entityType);
|
|
264
|
+
if (!customFieldConfig || customFieldConfig.length === 0) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return (
|
|
268
|
+
<PageBlock column={column} blockId="custom-fields">
|
|
269
|
+
<CustomFieldsForm entityType={entityType} control={control} />
|
|
270
|
+
</PageBlock>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
|
|
3
|
+
import { globalRegistry } from '../registry/global-registry.js';
|
|
4
|
+
|
|
5
|
+
// Define the placement options for navigation sections
|
|
6
|
+
export type NavMenuSectionPlacement = 'top' | 'bottom';
|
|
7
|
+
|
|
8
|
+
interface NavMenuBaseItem {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
icon?: LucideIcon;
|
|
12
|
+
placement?: NavMenuSectionPlacement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface NavMenuItem extends NavMenuBaseItem {
|
|
16
|
+
url: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NavMenuSection extends NavMenuBaseItem {
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
items?: NavMenuItem[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NavMenuConfig {
|
|
25
|
+
sections: Array<NavMenuSection | NavMenuItem>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
globalRegistry.register('navMenuConfig', { sections: [] });
|
|
29
|
+
|
|
30
|
+
export function getNavMenuConfig() {
|
|
31
|
+
return globalRegistry.get('navMenuConfig');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function setNavMenuConfig(config: NavMenuConfig) {
|
|
35
|
+
globalRegistry.set('navMenuConfig', oldValue => {
|
|
36
|
+
return Object.assign({}, oldValue, config);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function addNavMenuItem(item: NavMenuItem, sectionId: string) {
|
|
41
|
+
const navMenuConfig = getNavMenuConfig();
|
|
42
|
+
navMenuConfig.sections = [...navMenuConfig.sections];
|
|
43
|
+
const sectionIndex = navMenuConfig.sections.findIndex(
|
|
44
|
+
(s: NavMenuSection | NavMenuItem) => s.id === sectionId,
|
|
45
|
+
);
|
|
46
|
+
if (sectionIndex !== -1) {
|
|
47
|
+
const sectionFromConfig = navMenuConfig.sections[sectionIndex];
|
|
48
|
+
|
|
49
|
+
if ('items' in sectionFromConfig) {
|
|
50
|
+
const section = {
|
|
51
|
+
...sectionFromConfig,
|
|
52
|
+
items: [...(sectionFromConfig.items ?? [])],
|
|
53
|
+
};
|
|
54
|
+
const itemIndex = section.items.findIndex((i: NavMenuItem) => i.id === item.id);
|
|
55
|
+
if (itemIndex === -1) {
|
|
56
|
+
section.items.push(item);
|
|
57
|
+
navMenuConfig.sections.splice(sectionIndex, 1, section);
|
|
58
|
+
} else {
|
|
59
|
+
section.items.splice(itemIndex, 1, item);
|
|
60
|
+
navMenuConfig.sections.splice(sectionIndex, 1, section);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
navMenuConfig.sections.splice(sectionIndex, 1, item);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|