@chiselandco/nexus 2.2.6
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 +676 -0
- package/dist/GalleryCarousel.d.ts +7 -0
- package/dist/GalleryCarousel.d.ts.map +1 -0
- package/dist/GalleryCarousel.js +84 -0
- package/dist/ProjectCard.d.ts +15 -0
- package/dist/ProjectCard.d.ts.map +1 -0
- package/dist/ProjectCard.js +159 -0
- package/dist/ProjectDetail.d.ts +25 -0
- package/dist/ProjectDetail.d.ts.map +1 -0
- package/dist/ProjectDetail.js +179 -0
- package/dist/ProjectFilters.d.ts +11 -0
- package/dist/ProjectFilters.d.ts.map +1 -0
- package/dist/ProjectFilters.js +49 -0
- package/dist/ProjectGrid.d.ts +10 -0
- package/dist/ProjectGrid.d.ts.map +1 -0
- package/dist/ProjectGrid.js +8 -0
- package/dist/ProjectMenu.d.ts +79 -0
- package/dist/ProjectMenu.d.ts.map +1 -0
- package/dist/ProjectMenu.js +170 -0
- package/dist/ProjectMenuClient.d.ts +44 -0
- package/dist/ProjectMenuClient.d.ts.map +1 -0
- package/dist/ProjectMenuClient.js +386 -0
- package/dist/ProjectPortfolio.d.ts +42 -0
- package/dist/ProjectPortfolio.d.ts.map +1 -0
- package/dist/ProjectPortfolio.js +153 -0
- package/dist/ProjectPortfolioClient.d.ts +21 -0
- package/dist/ProjectPortfolioClient.d.ts.map +1 -0
- package/dist/ProjectPortfolioClient.js +141 -0
- package/dist/SimilarProjects.d.ts +46 -0
- package/dist/SimilarProjects.d.ts.map +1 -0
- package/dist/SimilarProjects.js +125 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/types.d.ts +45 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Project, CustomFieldSchema } from "./types";
|
|
2
|
+
export interface ProjectMenuProps {
|
|
3
|
+
/** Client slug used to fetch projects */
|
|
4
|
+
clientSlug: string;
|
|
5
|
+
/** API base URL e.g. "https://nexus.chiselandco.com" */
|
|
6
|
+
apiBase: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional menu ID to fetch a specific curated menu instead of all projects.
|
|
9
|
+
* When provided, fetches from /api/v1/clients/{clientSlug}/menus/{menuId}
|
|
10
|
+
*/
|
|
11
|
+
menuId?: string;
|
|
12
|
+
/** Base path for project detail links. Defaults to "/projects" */
|
|
13
|
+
basePath?: string;
|
|
14
|
+
/** Path for the "View All" link. Defaults to basePath */
|
|
15
|
+
viewAllPath?: string;
|
|
16
|
+
/** Optional subtitle paragraph shown above the project cards */
|
|
17
|
+
subtitle?: string;
|
|
18
|
+
/** Font family string passed to all inline styles */
|
|
19
|
+
font?: string;
|
|
20
|
+
/** Max number of projects to show at once. Defaults to 6 */
|
|
21
|
+
maxProjects?: number;
|
|
22
|
+
/** Revalidation period in seconds. Defaults to 86400 (24 hours) */
|
|
23
|
+
revalidate?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Disable all caching. Every request hits the API fresh.
|
|
26
|
+
* Useful for debugging — do not use in production.
|
|
27
|
+
*/
|
|
28
|
+
noCache?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* createMenuHandler
|
|
32
|
+
*
|
|
33
|
+
* Creates a Next.js route handler that fetches and server-caches the menu data.
|
|
34
|
+
* Drop it into app/api/chisel-menu/route.ts — one line of setup.
|
|
35
|
+
*
|
|
36
|
+
* Features:
|
|
37
|
+
* - Cached for 24 hours by default (override with revalidate option)
|
|
38
|
+
* - Add ?bust=1 to bypass the cache for a single request (dev/testing)
|
|
39
|
+
* - Set CHISEL_CACHE_BYPASS=true in env to disable caching for the whole deployment (staging)
|
|
40
|
+
* - Fetch is tagged with "chisel-menu-{clientSlug}" for revalidateTag() support
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // app/api/chisel-menu/route.ts
|
|
44
|
+
* import { createMenuHandler } from "project-portfolio"
|
|
45
|
+
* export const GET = createMenuHandler({ clientSlug: "my-client", apiBase: "https://nexus.chiselandco.com" })
|
|
46
|
+
*
|
|
47
|
+
* // Bust the cache manually (one request):
|
|
48
|
+
* fetch("/api/chisel-menu?bust=1")
|
|
49
|
+
*
|
|
50
|
+
* // Invalidate from a CMS webhook:
|
|
51
|
+
* import { revalidateTag } from "next/cache"
|
|
52
|
+
* revalidateTag("chisel-menu-my-client")
|
|
53
|
+
*/
|
|
54
|
+
export declare function createMenuHandler({ clientSlug, apiBase, menuId, revalidate, }: {
|
|
55
|
+
clientSlug: string;
|
|
56
|
+
apiBase: string;
|
|
57
|
+
/** Optional menu ID to fetch a specific curated menu instead of all projects */
|
|
58
|
+
menuId?: string;
|
|
59
|
+
revalidate?: number;
|
|
60
|
+
}): (request: Request) => Promise<Response>;
|
|
61
|
+
export declare function fetchProjectMenuData({ apiBase, clientSlug, menuId, revalidate, noCache, }: {
|
|
62
|
+
apiBase: string;
|
|
63
|
+
clientSlug: string;
|
|
64
|
+
menuId?: string;
|
|
65
|
+
revalidate?: number;
|
|
66
|
+
noCache?: boolean;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
projects: Project[];
|
|
69
|
+
schema: CustomFieldSchema[];
|
|
70
|
+
filterOptions: {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
}[];
|
|
74
|
+
filterFieldKey: string | null;
|
|
75
|
+
filterFieldName: string;
|
|
76
|
+
fieldOptionsMap: Record<string, Record<string, string>>;
|
|
77
|
+
}>;
|
|
78
|
+
export declare function ProjectMenu({ clientSlug, apiBase, menuId, basePath, viewAllPath, subtitle, font, maxProjects, revalidate, noCache, }: ProjectMenuProps): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
79
|
+
//# sourceMappingURL=ProjectMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectMenu.d.ts","sourceRoot":"","sources":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EAAE,CAAA;IACnB,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,aAAa,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC9C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACxD,CAAC,CAqBD;AA0DD,wBAAsB,WAAW,CAAC,EAChC,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAsB,EACtB,WAAW,EACX,QAAQ,EACR,IAA0E,EAC1E,WAAe,EACf,UAAkB,EAClB,OAAe,GAChB,EAAE,gBAAgB,oDAiClB"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cache } from "react";
|
|
3
|
+
import { ProjectMenuClient } from "./ProjectMenuClient";
|
|
4
|
+
const API_KEY = "pk_live_crmsuTIm7NNfb9uEWBCyv88F6kj2YQUR";
|
|
5
|
+
/**
|
|
6
|
+
* createMenuHandler
|
|
7
|
+
*
|
|
8
|
+
* Creates a Next.js route handler that fetches and server-caches the menu data.
|
|
9
|
+
* Drop it into app/api/chisel-menu/route.ts — one line of setup.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Cached for 24 hours by default (override with revalidate option)
|
|
13
|
+
* - Add ?bust=1 to bypass the cache for a single request (dev/testing)
|
|
14
|
+
* - Set CHISEL_CACHE_BYPASS=true in env to disable caching for the whole deployment (staging)
|
|
15
|
+
* - Fetch is tagged with "chisel-menu-{clientSlug}" for revalidateTag() support
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // app/api/chisel-menu/route.ts
|
|
19
|
+
* import { createMenuHandler } from "project-portfolio"
|
|
20
|
+
* export const GET = createMenuHandler({ clientSlug: "my-client", apiBase: "https://nexus.chiselandco.com" })
|
|
21
|
+
*
|
|
22
|
+
* // Bust the cache manually (one request):
|
|
23
|
+
* fetch("/api/chisel-menu?bust=1")
|
|
24
|
+
*
|
|
25
|
+
* // Invalidate from a CMS webhook:
|
|
26
|
+
* import { revalidateTag } from "next/cache"
|
|
27
|
+
* revalidateTag("chisel-menu-my-client")
|
|
28
|
+
*/
|
|
29
|
+
export function createMenuHandler({ clientSlug, apiBase, menuId, revalidate = 86400, }) {
|
|
30
|
+
return async function GET(request) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
32
|
+
const bypass = process.env.CHISEL_CACHE_BYPASS === "true" ||
|
|
33
|
+
new URL(request.url).searchParams.has("bust");
|
|
34
|
+
const cacheTag = menuId ? `chisel-menu-${clientSlug}-${menuId}` : `chisel-menu-${clientSlug}`;
|
|
35
|
+
const fetchOpts = bypass
|
|
36
|
+
? { cache: "no-store" }
|
|
37
|
+
: { next: { revalidate, tags: [cacheTag] } };
|
|
38
|
+
try {
|
|
39
|
+
// /projects always returns schema + options. Use it in both cases.
|
|
40
|
+
// When menuId provided: 2 calls — /menus/{slug} for projects, /projects for schema.
|
|
41
|
+
// Without menuId: 1 call — /projects for everything.
|
|
42
|
+
const fetches = menuId
|
|
43
|
+
? [
|
|
44
|
+
fetch(`${apiBase}/api/v1/clients/${clientSlug}/menus/${menuId}?api_key=${API_KEY}`, fetchOpts),
|
|
45
|
+
fetch(`${apiBase}/api/v1/clients/${clientSlug}/projects?api_key=${API_KEY}`, fetchOpts),
|
|
46
|
+
]
|
|
47
|
+
: [fetch(`${apiBase}/api/v1/clients/${clientSlug}/projects?api_key=${API_KEY}`, fetchOpts)];
|
|
48
|
+
const [primaryRes, schemaRes] = await Promise.all(fetches);
|
|
49
|
+
const primaryJson = primaryRes.ok ? await primaryRes.json() : {};
|
|
50
|
+
const schemaJson = schemaRes ? (schemaRes.ok ? await schemaRes.json() : {}) : primaryJson;
|
|
51
|
+
const rawProjects = menuId
|
|
52
|
+
? ((_a = primaryJson.projects) !== null && _a !== void 0 ? _a : [])
|
|
53
|
+
: ((_b = primaryJson.data) !== null && _b !== void 0 ? _b : []);
|
|
54
|
+
const projects = rawProjects.filter((p) => p.is_published !== false);
|
|
55
|
+
const schema = (_d = (_c = schemaJson === null || schemaJson === void 0 ? void 0 : schemaJson.client) === null || _c === void 0 ? void 0 : _c.custom_fields_schema) !== null && _d !== void 0 ? _d : [];
|
|
56
|
+
const fieldOptionsMap = {};
|
|
57
|
+
for (const field of schema) {
|
|
58
|
+
const map = {};
|
|
59
|
+
for (const opt of ((_e = field.options) !== null && _e !== void 0 ? _e : [])) {
|
|
60
|
+
if (typeof opt === "object" && opt.id && opt.label) {
|
|
61
|
+
map[opt.id] = opt.label;
|
|
62
|
+
map[opt.label] = opt.label;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
fieldOptionsMap[field.key] = map;
|
|
66
|
+
}
|
|
67
|
+
const filterField = (_f = schema.find((f) => f.is_filterable && (f.type === "select" || f.type === "multi-select"))) !== null && _f !== void 0 ? _f : null;
|
|
68
|
+
const filterOptions = filterField
|
|
69
|
+
? ((_g = filterField.options) !== null && _g !== void 0 ? _g : []).map((opt) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
if (typeof opt === "string")
|
|
72
|
+
return { id: opt.toLowerCase().replace(/\s+/g, "-"), label: opt };
|
|
73
|
+
return { id: (_a = opt.id) !== null && _a !== void 0 ? _a : "", label: (_b = opt.label) !== null && _b !== void 0 ? _b : "" };
|
|
74
|
+
})
|
|
75
|
+
: [];
|
|
76
|
+
return Response.json({
|
|
77
|
+
projects,
|
|
78
|
+
schema,
|
|
79
|
+
filterOptions,
|
|
80
|
+
filterFieldKey: (_h = filterField === null || filterField === void 0 ? void 0 : filterField.key) !== null && _h !== void 0 ? _h : null,
|
|
81
|
+
filterFieldName: (_j = filterField === null || filterField === void 0 ? void 0 : filterField.name) !== null && _j !== void 0 ? _j : "Project Type",
|
|
82
|
+
fieldOptionsMap,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (_k) {
|
|
86
|
+
return Response.json({ projects: [], schema: [], filterOptions: [], filterFieldKey: null, filterFieldName: "Project Type", fieldOptionsMap: {} }, { status: 500 });
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export async function fetchProjectMenuData({ apiBase, clientSlug, menuId, revalidate = 86400, noCache = false, }) {
|
|
91
|
+
var _a, _b, _c, _d;
|
|
92
|
+
const raw = await _fetchMenuData(apiBase, clientSlug, menuId, revalidate, noCache);
|
|
93
|
+
const filterField = (_a = raw.schema.find((f) => f.is_filterable && (f.type === "select" || f.type === "multi-select"))) !== null && _a !== void 0 ? _a : null;
|
|
94
|
+
const filterOptions = filterField
|
|
95
|
+
? ((_b = filterField.options) !== null && _b !== void 0 ? _b : []).map((opt) => {
|
|
96
|
+
var _a, _b, _c;
|
|
97
|
+
if (typeof opt === "string") {
|
|
98
|
+
return { id: opt.toLowerCase().replace(/\s+/g, "-"), label: opt };
|
|
99
|
+
}
|
|
100
|
+
return { id: (_a = opt.id) !== null && _a !== void 0 ? _a : String((_b = opt.label) !== null && _b !== void 0 ? _b : "").toLowerCase().replace(/\s+/g, "-"), label: (_c = opt.label) !== null && _c !== void 0 ? _c : "" };
|
|
101
|
+
})
|
|
102
|
+
: [];
|
|
103
|
+
return {
|
|
104
|
+
projects: raw.projects,
|
|
105
|
+
schema: raw.schema,
|
|
106
|
+
filterOptions,
|
|
107
|
+
filterFieldKey: (_c = filterField === null || filterField === void 0 ? void 0 : filterField.key) !== null && _c !== void 0 ? _c : null,
|
|
108
|
+
filterFieldName: (_d = filterField === null || filterField === void 0 ? void 0 : filterField.name) !== null && _d !== void 0 ? _d : "Project Type",
|
|
109
|
+
fieldOptionsMap: raw.fieldOptionsMap,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const _fetchMenuData = cache(async (apiBase, clientSlug, menuId, revalidate, noCache = false) => {
|
|
113
|
+
var _a, _b, _c, _d, _e;
|
|
114
|
+
const fetchOpts = noCache
|
|
115
|
+
? { cache: "no-store" }
|
|
116
|
+
: { next: { revalidate } };
|
|
117
|
+
try {
|
|
118
|
+
// /projects always returns schema + options. Use it in both cases.
|
|
119
|
+
// When menuId provided: 2 calls — /menus/{slug} for projects, /projects for schema.
|
|
120
|
+
// Without menuId: 1 call — /projects for everything.
|
|
121
|
+
const fetches = menuId
|
|
122
|
+
? [
|
|
123
|
+
fetch(`${apiBase}/api/v1/clients/${clientSlug}/menus/${menuId}?api_key=${API_KEY}`, fetchOpts),
|
|
124
|
+
fetch(`${apiBase}/api/v1/clients/${clientSlug}/projects?api_key=${API_KEY}`, fetchOpts),
|
|
125
|
+
]
|
|
126
|
+
: [fetch(`${apiBase}/api/v1/clients/${clientSlug}/projects?api_key=${API_KEY}`, fetchOpts)];
|
|
127
|
+
const [primaryRes, schemaRes] = await Promise.all(fetches);
|
|
128
|
+
if (!primaryRes.ok)
|
|
129
|
+
return { projects: [], schema: [], fieldOptionsMap: {} };
|
|
130
|
+
const primaryJson = await primaryRes.json();
|
|
131
|
+
const schemaJson = schemaRes ? (schemaRes.ok ? await schemaRes.json() : {}) : primaryJson;
|
|
132
|
+
const rawProjects = menuId
|
|
133
|
+
? ((_a = primaryJson.projects) !== null && _a !== void 0 ? _a : [])
|
|
134
|
+
: ((_b = primaryJson.data) !== null && _b !== void 0 ? _b : []);
|
|
135
|
+
const projects = rawProjects.filter((p) => p.is_published !== false);
|
|
136
|
+
const schema = (_d = (_c = schemaJson === null || schemaJson === void 0 ? void 0 : schemaJson.client) === null || _c === void 0 ? void 0 : _c.custom_fields_schema) !== null && _d !== void 0 ? _d : [];
|
|
137
|
+
const fieldOptionsMap = {};
|
|
138
|
+
for (const field of schema) {
|
|
139
|
+
const map = {};
|
|
140
|
+
for (const opt of ((_e = field.options) !== null && _e !== void 0 ? _e : [])) {
|
|
141
|
+
if (typeof opt === "object" && opt.id && opt.label) {
|
|
142
|
+
map[opt.id] = opt.label;
|
|
143
|
+
map[opt.label] = opt.label;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
fieldOptionsMap[field.key] = map;
|
|
147
|
+
}
|
|
148
|
+
return { projects, schema, fieldOptionsMap };
|
|
149
|
+
}
|
|
150
|
+
catch (_f) {
|
|
151
|
+
return { projects: [], schema: [], fieldOptionsMap: {} };
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
export async function ProjectMenu({ clientSlug, apiBase, menuId, basePath = "/projects", viewAllPath, subtitle, font = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", maxProjects = 6, revalidate = 86400, noCache = false, }) {
|
|
155
|
+
var _a, _b, _c, _d;
|
|
156
|
+
const { projects, schema, fieldOptionsMap } = await _fetchMenuData(apiBase, clientSlug, menuId, revalidate, noCache);
|
|
157
|
+
// Find the filterable select field (badge_overlay is our category field)
|
|
158
|
+
const filterField = (_a = schema.find((f) => f.is_filterable && (f.type === "select" || f.type === "multi-select"))) !== null && _a !== void 0 ? _a : null;
|
|
159
|
+
// Build filter option list from schema
|
|
160
|
+
const filterOptions = filterField
|
|
161
|
+
? ((_b = filterField.options) !== null && _b !== void 0 ? _b : []).map((opt) => {
|
|
162
|
+
var _a, _b, _c;
|
|
163
|
+
if (typeof opt === "string") {
|
|
164
|
+
return { id: opt.toLowerCase().replace(/\s+/g, "-"), label: opt };
|
|
165
|
+
}
|
|
166
|
+
return { id: (_a = opt.id) !== null && _a !== void 0 ? _a : String((_b = opt.label) !== null && _b !== void 0 ? _b : "").toLowerCase().replace(/\s+/g, "-"), label: (_c = opt.label) !== null && _c !== void 0 ? _c : "" };
|
|
167
|
+
})
|
|
168
|
+
: [];
|
|
169
|
+
return (_jsx(ProjectMenuClient, { projects: projects, schema: schema, filterOptions: filterOptions, filterFieldKey: (_c = filterField === null || filterField === void 0 ? void 0 : filterField.key) !== null && _c !== void 0 ? _c : null, filterFieldName: (_d = filterField === null || filterField === void 0 ? void 0 : filterField.name) !== null && _d !== void 0 ? _d : "Project Type", fieldOptionsMap: fieldOptionsMap, subtitle: subtitle, basePath: basePath, viewAllPath: viewAllPath !== null && viewAllPath !== void 0 ? viewAllPath : basePath, font: font, maxProjects: maxProjects }));
|
|
170
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Project, CustomFieldSchema } from "./types";
|
|
2
|
+
export interface ProjectMenuClientProps {
|
|
3
|
+
/**
|
|
4
|
+
* URL of a local API route created with createMenuHandler().
|
|
5
|
+
* Recommended for production — data is server-cached for 24h and never
|
|
6
|
+
* exposes the upstream API key to the browser.
|
|
7
|
+
* e.g. dataUrl="/api/chisel-menu"
|
|
8
|
+
*/
|
|
9
|
+
dataUrl?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Pass clientSlug + apiBase to have the component fetch its own data directly.
|
|
12
|
+
* Use this for quick setup or non-Next.js environments.
|
|
13
|
+
* For production Next.js apps, prefer dataUrl + createMenuHandler instead.
|
|
14
|
+
*/
|
|
15
|
+
clientSlug?: string;
|
|
16
|
+
apiBase?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional menu slug to fetch a specific curated menu instead of all projects.
|
|
19
|
+
* When provided, fetches from /api/v1/clients/{clientSlug}/menus/{slug}
|
|
20
|
+
*/
|
|
21
|
+
menuId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* When true, bypasses the module-level data cache and always fetches fresh data.
|
|
24
|
+
* Also sets fetch cache to "no-store" on all underlying requests.
|
|
25
|
+
* Useful during development or when projects update frequently.
|
|
26
|
+
*/
|
|
27
|
+
noCache?: boolean;
|
|
28
|
+
projects?: Project[];
|
|
29
|
+
schema?: CustomFieldSchema[];
|
|
30
|
+
filterOptions?: {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
}[];
|
|
34
|
+
filterFieldKey?: string | null;
|
|
35
|
+
filterFieldName?: string;
|
|
36
|
+
fieldOptionsMap?: Record<string, Record<string, string>>;
|
|
37
|
+
subtitle?: string;
|
|
38
|
+
basePath: string;
|
|
39
|
+
viewAllPath: string;
|
|
40
|
+
font?: string;
|
|
41
|
+
maxProjects?: number;
|
|
42
|
+
}
|
|
43
|
+
export declare function ProjectMenuClient({ dataUrl, clientSlug, apiBase, menuId, noCache, projects: projectsProp, schema: schemaProp, filterOptions: filterOptionsProp, filterFieldKey: filterFieldKeyProp, filterFieldName: filterFieldNameProp, fieldOptionsMap: fieldOptionsMapProp, subtitle, basePath, viewAllPath, font, maxProjects, }: ProjectMenuClientProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
//# sourceMappingURL=ProjectMenuClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectMenuClient.d.ts","sourceRoot":"","sources":["../src/ProjectMenuClient.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAA;AAa3E,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC5B,aAAa,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC/C,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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