Skip to content

Commit 9f35296

Browse files
committed
fix: build issues
1 parent 2f18755 commit 9f35296

File tree

14 files changed

+70
-311
lines changed

14 files changed

+70
-311
lines changed

packages/components/src/components/button/showcase/button.showcase.lite.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { PatternhubProps } from '../../../shared/model';
12
import CardWrapperShowcase from '../../../shared/showcase/card-wrapper.showcase.lite';
2-
import ContainerWrapperShowcase, {
3-
PatternhubProps
4-
} from '../../../shared/showcase/container-wrapper.showcase.lite';
3+
import ContainerWrapperShowcase from '../../../shared/showcase/container-wrapper.showcase.lite';
54
import LinkWrapperShowcase from '../../../shared/showcase/link-wrapper.showcase.lite';
65
import ButtonDensity from '../examples/density.example.lite';
76
import ButtonDisabled from '../examples/disabled.example.lite';

packages/components/src/shared/model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,11 @@ export type PopoverState = {
718718
handleEnter: (parent?: HTMLElement) => void;
719719
handleLeave: (event?: any) => void;
720720
} & DocumentScrollState;
721+
722+
// TODO: Remove this after we migrate to one-platform
723+
export interface PatternhubProps {
724+
/**
725+
* Used for Patternhub
726+
*/
727+
isPatternhub?: boolean;
728+
}

packages/components/src/shared/showcase/card-wrapper.showcase.lite.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function CardWrapperShowcase(props: Props) {
2222
}
2323

2424
onMount(() => {
25-
if (window && localStorage) {
25+
if (typeof window !== 'undefined' && localStorage) {
2626
updateHref();
2727
}
2828
});

packages/components/src/shared/showcase/container-wrapper.showcase.lite.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { Fragment, onMount, Show, Slot, useState } from '@builder.io/mitosis';
22
import DBLink from '../../components/link/link.lite';
3-
4-
export interface PatternhubProps {
5-
/**
6-
* Used for Patternhub
7-
*/
8-
isPatternhub?: boolean;
9-
}
3+
import { PatternhubProps } from '../model';
104

115
type Props = {
126
title?: string;
@@ -26,35 +20,41 @@ export default function ContainerWrapperShowcase(props: Props) {
2620
const [hidden, setHidden] = useState<boolean>(false);
2721

2822
onMount(() => {
29-
const hash = window.location.hash;
30-
const queryString = hash.includes('?') ? hash.split('?')[1] : '';
31-
const params = new URLSearchParams(
32-
window.location.search || queryString
33-
);
23+
if (typeof window !== 'undefined') {
24+
const hash = window.location.hash;
25+
const queryString = hash.includes('?') ? hash.split('?')[1] : '';
26+
const params = new URLSearchParams(
27+
window.location.search || queryString
28+
);
3429

35-
setHidden(Boolean(params.get('page')));
30+
setHidden(Boolean(params.get('page')));
31+
}
3632
});
3733

3834
function getSourceFilePath(): string | undefined {
3935
if (!props.title) return;
4036

4137
const componentName = props.title
42-
.replace(/^DB/, '')
38+
?.replace(/^DB/, '')
4339
.replaceAll(/([A-Z])/g, (match, letter, index) =>
4440
index > 0 ? `-${letter.toLowerCase()}` : letter.toLowerCase()
4541
);
4642

4743
if (componentName && /^[a-z]+(-[a-z]+)*$/.test(componentName)) {
4844
return `packages/components/src/components/${componentName}/${componentName}.lite.tsx`;
4945
}
46+
47+
return;
5048
}
5149

5250
function getGitHubSourceUrl(): string | undefined {
5351
const filePath = getSourceFilePath();
5452
if (!filePath) return;
5553

5654
const targetBranch =
57-
process.env.GITHUB_BRANCH ?? process.env.BRANCH_NAME ?? 'main';
55+
process.env['GITHUB_BRANCH'] ??
56+
process.env['BRANCH_NAME'] ??
57+
'main';
5858

5959
return `https://github.com/db-ux-design-system/core-web/blob/${targetBranch}/${filePath}`;
6060
}

packages/components/src/shared/showcase/link-wrapper.showcase.lite.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,26 @@ export default function LinkWrapperShowcase(props: Props) {
1313
}
1414

1515
function getHref(): string {
16-
const hash = window.location.hash;
17-
const basePath = hash.includes('?') ? hash.split('?')[0] : hash;
18-
return `${basePath}?page=${getPage()}`;
16+
if (typeof window !== 'undefined') {
17+
const hash = window.location.hash;
18+
const basePath = hash.includes('?') ? hash.split('?')[0] : hash;
19+
return `${basePath}?page=${getPage()}`;
20+
}
21+
22+
return '';
1923
}
2024

2125
const [pageParam, setPageParam] = useState<string | null>(null);
2226

2327
onMount(() => {
24-
const hash = window.location.hash;
25-
const queryString = hash.includes('?') ? hash.split('?')[1] : '';
26-
const params = new URLSearchParams(
27-
window.location.search || queryString
28-
);
29-
setPageParam(params.get('page'));
28+
if (typeof window !== 'undefined') {
29+
const hash = window.location.hash;
30+
const queryString = hash.includes('?') ? hash.split('?')[1] : '';
31+
const params = new URLSearchParams(
32+
window.location.search || queryString
33+
);
34+
setPageParam(params.get('page'));
35+
}
3036
});
3137

3238
return (

showcases/angular-ssr-showcase/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
"module": "ES2022",
2121
"useDefineForClassFields": false,
2222
"resolveJsonModule": true,
23-
"lib": ["ES2022", "dom"]
23+
"lib": ["ES2022", "dom"],
24+
"paths": {
25+
"@components": ["../../output/angular/src"],
26+
"@components/src/*": ["../../output/angular/src/*"],
27+
"@components/components/*": ["../../output/angular/src/components/*"]
28+
}
2429
},
2530
"angularCompilerOptions": {
2631
"enableI18nLegacyMessageIdFormat": false,

showcases/next-showcase/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
"jsx": "preserve",
1515
"strictNullChecks": true,
1616
"downlevelIteration": true,
17-
"target": "ES2017"
17+
"target": "ES2017",
18+
"paths": {
19+
"@components": ["../../output/react/src"],
20+
"@components/src/*": ["../../output/react/src/*"],
21+
"@components/components/*": ["../../output/react/src/components/*"]
22+
}
1823
},
1924
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
2025
"exclude": ["node_modules"]

showcases/nuxt-showcase/nuxt.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
4+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
5+
16
export default defineNuxtConfig({
27
telemetry: false,
38
devtools: { enabled: true },
@@ -25,5 +30,8 @@ export default defineNuxtConfig({
2530
dir: '../../build-showcases/nuxt-showcase',
2631
publicDir: '../../build-showcases/nuxt-showcase'
2732
}
33+
},
34+
alias: {
35+
'@components': path.resolve(__dirname, '../../output/vue/src')
2836
}
2937
});
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
22
// https://nuxt.com/docs/guide/concepts/typescript
3-
"extends": "./.nuxt/tsconfig.json"
3+
"extends": "./.nuxt/tsconfig.json",
4+
"compilerOptions": {
5+
"paths": {
6+
"@components": ["../../output/vue/src"],
7+
"@components/src/*": ["../../output/vue/src/*"],
8+
"@components/components/*": ["../../output/vue/src/components/*"]
9+
}
10+
}
411
}

showcases/patternhub/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"build:app": "next build",
99
"build:copy": "cpr out ../../build-showcases/patternhub -o",
1010
"compile": "npm-run-all compile:*",
11-
"compile:01_jsx": "node scripts/generate-example-jsx.js",
1211
"compile:02_copy-docs": "cpr ../../docs ./public/docs -o",
13-
"compile:03_components": "node scripts/esbuild-generate.mjs",
1412
"compile:04_run": "node generated.js",
1513
"compile:05_test-table": "node scripts/generate-test-table.js",
1614
"dev": "cross-env NEXT_PUBLIC_BASE_PATH=/core-web/sub NODE_OPTIONS='--inspect' npm-run-all compile:* --parallel open next:dev",

0 commit comments

Comments
 (0)