@medusajs/admin-shared
Advanced tools
Comparing version 0.0.2-snapshot-20230525210913 to 0.0.2-snapshot-20230529102512
import { ComponentType } from 'react'; | ||
import { NavigateFunction } from 'react-router-dom'; | ||
declare const extensionTypes: readonly ["widget", "page"]; | ||
declare const injectionZones: readonly ["order.details", "order.list", "draft_order.list", "draft_order.details", "customer.details", "customer.list", "customer_group.details", "customer_group.list", "product.details", "product.list", "product_collection.details", "product_collection.list", "price_list.details", "price_list.list", "discount.details", "discount.list", "gift_card.details", "gift_card.list", "custom_gift_card"]; | ||
declare const extensionTypes: readonly ["widget", "route", "nested-route"]; | ||
declare const injectionZones: readonly ["order.details", "order.list", "draft_order.list", "draft_order.details", "customer.details", "customer.list", "customer_group.details", "customer_group.list", "product.details", "product.list", "product_collection.details", "product_collection.list", "price_list.details", "price_list.list", "discount.details", "discount.list", "gift_card.details", "gift_card.list", "custom_gift_card", "login.before", "login.after"]; | ||
@@ -13,8 +13,14 @@ type InjectionZone = typeof injectionZones[number]; | ||
}; | ||
type PageConfig = { | ||
type: "page"; | ||
type RouteConfig = { | ||
type: "route"; | ||
path: string; | ||
title: string; | ||
icon?: ComponentType; | ||
}; | ||
type ExtensionConfig = WidgetConfig | PageConfig; | ||
type NestedRouteConfig = { | ||
type: "nested-route"; | ||
path: string; | ||
parent: string; | ||
}; | ||
type ExtensionConfig = WidgetConfig | RouteConfig | NestedRouteConfig; | ||
type WidgetExtension = { | ||
@@ -24,7 +30,11 @@ Component: React.ComponentType<any>; | ||
}; | ||
type PageExtension = { | ||
type RouteExtension = { | ||
Component: React.ComponentType<any>; | ||
config: PageConfig; | ||
config: RouteConfig; | ||
}; | ||
type Extension = WidgetExtension | PageExtension; | ||
type NestedRouteExtension = { | ||
Component: React.ComponentType<any>; | ||
config: NestedRouteConfig; | ||
}; | ||
type Extension = WidgetExtension | RouteExtension | NestedRouteExtension; | ||
type ExtensionsEntry = { | ||
@@ -43,3 +53,9 @@ identifier: string; | ||
}; | ||
type Link = Pick<PageConfig, "path" | "title">; | ||
type NestedRoute = { | ||
origin: string; | ||
parent: string; | ||
path: string; | ||
Page: ComponentType<any>; | ||
}; | ||
type Link = Pick<RouteConfig, "path" | "title" | "icon">; | ||
type Notify = { | ||
@@ -56,8 +72,12 @@ success: (title: string, message: string) => void; | ||
declare class PageRegistry { | ||
declare class RouteRegistry { | ||
links: Link[]; | ||
routes: Route[]; | ||
registerPage(origin: string, page: PageExtension): void; | ||
nestedRoutes: Map<string, Route[]>; | ||
private formatPath_; | ||
registerRoute(origin: string, route: RouteExtension): void; | ||
registerNestedRoute(origin: string, route: NestedRouteExtension): void; | ||
getLinks(): Link[]; | ||
getRoutes(): Route[]; | ||
getNestedRoutes(parent: string): Route[]; | ||
} | ||
@@ -74,4 +94,5 @@ | ||
declare function isWidgetExtension(extension: Extension): extension is WidgetExtension; | ||
declare function isPageExtension(extension: Extension): extension is PageExtension; | ||
declare function isRouteExtension(extension: Extension): extension is RouteExtension; | ||
declare function isNestedRouteExtension(extension: Extension): extension is NestedRouteExtension; | ||
export { Extension, ExtensionConfig, ExtensionProps, ExtensionType, ExtensionsEntry, InjectionZone, Link, PageConfig, PageExtension, PageRegistry, Route, Widget, WidgetConfig, WidgetExtension, WidgetRegistry, extensionTypes, injectionZones, isPageExtension, isValidExtensionType, isValidInjectionZone, isWidgetExtension }; | ||
export { Extension, ExtensionConfig, ExtensionProps, ExtensionType, ExtensionsEntry, InjectionZone, Link, NestedRoute, NestedRouteConfig, NestedRouteExtension, Route, RouteConfig, RouteExtension, RouteRegistry, Widget, WidgetConfig, WidgetExtension, WidgetRegistry, extensionTypes, injectionZones, isNestedRouteExtension, isRouteExtension, isValidExtensionType, isValidInjectionZone, isWidgetExtension }; |
@@ -23,7 +23,8 @@ var __defProp = Object.defineProperty; | ||
__export(src_exports, { | ||
PageRegistry: () => page_registry_default, | ||
RouteRegistry: () => route_registry_default, | ||
WidgetRegistry: () => widget_registry_default, | ||
extensionTypes: () => extensionTypes, | ||
injectionZones: () => injectionZones, | ||
isPageExtension: () => isPageExtension, | ||
isNestedRouteExtension: () => isNestedRouteExtension, | ||
isRouteExtension: () => isRouteExtension, | ||
isValidExtensionType: () => isValidExtensionType, | ||
@@ -35,17 +36,47 @@ isValidInjectionZone: () => isValidInjectionZone, | ||
// src/page-registry.tsx | ||
var PageRegistry = /* @__PURE__ */ __name(class PageRegistry2 { | ||
// src/route-registry.tsx | ||
var RouteRegistry = /* @__PURE__ */ __name(class RouteRegistry2 { | ||
links = []; | ||
routes = []; | ||
registerPage(origin, page) { | ||
const { path, title } = page.config; | ||
nestedRoutes = /* @__PURE__ */ new Map(); | ||
formatPath_(path) { | ||
if (path.startsWith("a/")) { | ||
path = path.substring(2); | ||
} | ||
if (path.startsWith("/a/")) { | ||
path = path.substring(3); | ||
} | ||
if (path.startsWith("/")) { | ||
path = path.substring(1); | ||
} | ||
if (path.endsWith("/")) { | ||
path = path.substring(0, path.length - 1); | ||
} | ||
return path; | ||
} | ||
registerRoute(origin, route) { | ||
const { path, title, icon } = route.config; | ||
const formattedPath = this.formatPath_(path); | ||
this.routes.push({ | ||
origin, | ||
path: formattedPath, | ||
Page: route.Component | ||
}); | ||
this.links.push({ | ||
path, | ||
title | ||
path: formattedPath, | ||
title, | ||
icon | ||
}); | ||
this.routes.push({ | ||
} | ||
registerNestedRoute(origin, route) { | ||
const { path, parent } = route.config; | ||
const formattedPath = this.formatPath_(path); | ||
const formattedParent = this.formatPath_(parent); | ||
const routes = this.nestedRoutes.get(formattedParent) || []; | ||
routes.push({ | ||
origin, | ||
path, | ||
Page: page.Component | ||
path: formattedPath, | ||
Page: route.Component | ||
}); | ||
this.nestedRoutes.set(formattedParent, routes); | ||
} | ||
@@ -58,4 +89,7 @@ getLinks() { | ||
} | ||
}, "PageRegistry"); | ||
var page_registry_default = PageRegistry; | ||
getNestedRoutes(parent) { | ||
return this.nestedRoutes.get(parent) || []; | ||
} | ||
}, "RouteRegistry"); | ||
var route_registry_default = RouteRegistry; | ||
@@ -83,3 +117,4 @@ // src/widget-registry.tsx | ||
"widget", | ||
"page" | ||
"route", | ||
"nested-route" | ||
]; | ||
@@ -114,3 +149,6 @@ var injectionZones = [ | ||
"gift_card.list", | ||
"custom_gift_card" | ||
"custom_gift_card", | ||
// Login | ||
"login.before", | ||
"login.after" | ||
]; | ||
@@ -131,13 +169,18 @@ | ||
__name(isWidgetExtension, "isWidgetExtension"); | ||
function isPageExtension(extension) { | ||
return extension.config.type === "page"; | ||
function isRouteExtension(extension) { | ||
return extension.config.type === "route"; | ||
} | ||
__name(isPageExtension, "isPageExtension"); | ||
__name(isRouteExtension, "isRouteExtension"); | ||
function isNestedRouteExtension(extension) { | ||
return extension.config.type === "nested-route"; | ||
} | ||
__name(isNestedRouteExtension, "isNestedRouteExtension"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
PageRegistry, | ||
RouteRegistry, | ||
WidgetRegistry, | ||
extensionTypes, | ||
injectionZones, | ||
isPageExtension, | ||
isNestedRouteExtension, | ||
isRouteExtension, | ||
isValidExtensionType, | ||
@@ -144,0 +187,0 @@ isValidInjectionZone, |
{ | ||
"name": "@medusajs/admin-shared", | ||
"version": "0.0.2-snapshot-20230525210913", | ||
"version": "0.0.2-snapshot-20230529102512", | ||
"author": "Kasper Kristensen <kasper@medusajs.com>", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29606
414