Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remote components #852

Draft
wants to merge 88 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
54bb751
experiment: add remote components
mfal Oct 14, 2024
4b86592
Merge branch 'main' into flow-remote
mfal Nov 22, 2024
b3b865e
chore: update dependencies
mfal Nov 22, 2024
6c5cb4b
Merge remote-tracking branch 'origin/main' into flow-remote
ins0 Nov 26, 2024
44240e9
update yarn
ins0 Nov 26, 2024
133f939
update yarn
ins0 Nov 26, 2024
a0656e1
update master
ins0 Nov 26, 2024
0fb592a
Tweak demo app
mfal Nov 27, 2024
1158608
...
mfal Nov 27, 2024
b1247ff
...
mfal Nov 27, 2024
893786e
add simple Modal example
mfal Nov 28, 2024
39e76f2
Merge remote-tracking branch 'origin/main' into flow-remote
mfal Nov 28, 2024
2a82b80
fix compilation error
mfal Nov 28, 2024
62c6bcd
refactor: use Reg not LegacyRef
mfal Nov 28, 2024
69e5e96
rename stuff and add dispatchEvent
mfal Nov 28, 2024
11399b3
refactor basics
mfal Nov 29, 2024
7eb0bd9
refactor base class
mfal Nov 29, 2024
36f5818
refactor form
mfal Dec 2, 2024
e355f03
support simple form
mfal Dec 2, 2024
b3c94b5
fix ref usage
mfal Dec 2, 2024
9e7e3f2
...
mfal Dec 2, 2024
7ec1fe9
fix: avoid multiple connection
mfal Dec 3, 2024
8c1c6ff
add fragment renderer
ins0 Dec 3, 2024
8b101ac
cleanup
ins0 Dec 3, 2024
7126bb9
temp remove
ins0 Dec 3, 2024
a50a2a0
add suspense demo
ins0 Dec 4, 2024
e3e8f4d
support suspense
mfal Dec 4, 2024
e0b49b1
suspense tweaks
ins0 Dec 4, 2024
1986063
fix lint errors
mfal Dec 4, 2024
f3fc136
adjust suspense demo
mfal Dec 4, 2024
d325ec8
add select to demo
mfal Dec 4, 2024
0ceebe7
remove unused packages
mfal Dec 4, 2024
183518a
update packages
mfal Dec 4, 2024
6664b6d
update more packages
mfal Dec 4, 2024
658e7d1
update react 19 and add form server action example
mfal Dec 5, 2024
bf6022a
add icon support
ins0 Dec 5, 2024
0d58d42
use useFormStatus in demo
mfal Dec 6, 2024
1e3ab62
add removed components
mfal Dec 6, 2024
81f913e
refactor types
mfal Dec 6, 2024
c5eb1c8
use headings in demo
mfal Dec 6, 2024
edd2bb4
add svg element example
mfal Dec 6, 2024
2429a70
add type
ins0 Dec 6, 2024
27f882e
Merge branch 'main' into flow-remote
mfal Dec 9, 2024
f0ec2e8
support forward on modal
mfal Dec 9, 2024
111d9d0
Merge branch 'flow-remote' of github.com:mittwald/flow into flow-remote
mfal Dec 9, 2024
dd144d1
Merge remote-tracking branch 'origin/main' into flow-remote
mfal Dec 10, 2024
6b48b00
update dependencies
mfal Dec 10, 2024
dabfaa3
add list page
mfal Dec 10, 2024
db440c6
add deps
ins0 Dec 10, 2024
6ed7cac
implement svg rendering
ins0 Dec 10, 2024
3536752
Merge remote-tracking branch 'origin/flow-remote' into flow-remote
ins0 Dec 10, 2024
edbe3ac
update deps
ins0 Dec 10, 2024
53a91e1
add missing dependency
ins0 Dec 10, 2024
766a54c
remote console log
ins0 Dec 10, 2024
70727a0
fix clone element
ins0 Dec 11, 2024
576d58a
Merge branch 'main' into flow-remote
mfal Dec 18, 2024
567d9f6
merge master
mfal Dec 18, 2024
eeaaf89
basic remote list implementation
mfal Dec 20, 2024
e3d4307
implement basic react form hook support
ins0 Dec 27, 2024
13ff8a4
Merge remote-tracking branch 'origin/flow-remote' into flow-remote
ins0 Dec 27, 2024
cd7196b
update deps
ins0 Dec 27, 2024
0f48ee3
fix react 19 types
ins0 Dec 27, 2024
0823636
fix multiple react 19 type errors
ins0 Dec 27, 2024
4c661d1
configure icon context
ins0 Dec 30, 2024
2c3719e
cleanup
ins0 Dec 30, 2024
cfc14a3
clone fix
ins0 Dec 30, 2024
287ac85
fix ssr
ins0 Dec 30, 2024
dd6cb69
add react-hook-form remote element
ins0 Dec 30, 2024
f3ce11a
sync invalid status
ins0 Dec 31, 2024
0baa995
more remote list implementation
mfal Jan 6, 2025
6817748
Merge branch 'flow-remote' of github.com:mittwald/flow into flow-remote
mfal Jan 6, 2025
178ca3c
add script for code generation
mfal Jan 6, 2025
e8dbd2b
use auto-generated dir
mfal Jan 6, 2025
392a4fa
refactor remote component generator config
maaaathis Jan 6, 2025
fe253b3
re-add ActionStateContext to remote component generator config
maaaathis Jan 6, 2025
90d5105
Add auto-generated code
mfal Jan 6, 2025
173e67c
Merge branch 'flow-remote' of github.com:mittwald/flow into flow-remote
mfal Jan 6, 2025
5e2ee17
add auto-generated remote files
mfal Jan 6, 2025
69bbd82
use native ref
ins0 Jan 6, 2025
ba97edc
Merge remote-tracking branch 'origin/flow-remote' into flow-remote
ins0 Jan 6, 2025
790995e
configure CG via doc tags
mfal Jan 9, 2025
909092a
update deps
mfal Jan 9, 2025
aec73a1
ignore some props
mfal Jan 9, 2025
34c2239
Merge branch 'main' into flow-remote
mfal Jan 9, 2025
73aedff
fix dep errors
mfal Jan 9, 2025
64bd5bb
fix build
mfal Jan 9, 2025
fa7b9b3
add change
mfal Jan 9, 2025
dee2b23
fix generated files
mfal Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .idea/Flow - mittwald Design System.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .idea/compiler.xml

This file was deleted.

9,300 changes: 5,464 additions & 3,836 deletions .pnp.cjs

Large diffs are not rendered by default.

574 changes: 287 additions & 287 deletions .yarn/releases/yarn-4.5.3.cjs → .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ enableScripts: false

logFilters:
- code: YN0086
level: error
level: warning
# @todo: reset to error when packages supporting React 19
# level: error
- code: YN0068
level: error
- code: YN0069
Expand Down Expand Up @@ -73,4 +75,4 @@ packageExtensions:
dependencies:
eslint: "*"

yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
14 changes: 14 additions & 0 deletions demos/remote-dom/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "next/core-web-vitals",
"overrides": [
{
"files": "src/content/**/examples/*.tsx",
"rules": {
"react/jsx-no-undef": ["off"]
}
}
],
"rules": {
"@next/next/no-html-link-for-pages": ["error", "packages/docs/src/app/"]
}
}
37 changes: 37 additions & 0 deletions demos/remote-dom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
/scripts/out/
7 changes: 7 additions & 0 deletions demos/remote-dom/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import("next").NextConfig} */
const nextConfig = {
basePath: process.env.NEXT_BASE_PATH ?? "",
pageExtensions: ["js", "jsx", "ts", "tsx"],
};

export default nextConfig;
50 changes: 50 additions & 0 deletions demos/remote-dom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@mittwald/flow-demo-remote-dom",
"private": true,
"type": "module",
"scripts": {
"dev": "run nx run-many --outputStyle=stream --projects=@mittwald/flow-demo-remote-dom --targets=start,build:deps:watch",
"start": "run next dev",
"test:compile": "run tsc --noEmit"
},
"dependencies": {
"@internationalized/date": "^3.6.0",
"@mittwald/flow-design-tokens": "workspace:^",
"@mittwald/flow-react-components": "workspace:^",
"@mittwald/flow-remote-elements": "workspace:^",
"@mittwald/flow-remote-react-components": "workspace:^",
"@mittwald/flow-remote-react-renderer": "workspace:^",
"@mittwald/react-use-promise": "^2.6.0",
"@tabler/icons-react": "^3.28.1",
"clsx": "^2.1.1",
"next": "~15.1.4",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-hook-form": "^7.54.2",
"remeda": "^2.19.0",
"sass": "^1.83.1",
"webpack": "^5.97.1"
},
"devDependencies": {
"@types/node": "^22.10.5",
"@types/react": "^19.0.4",
"@types/react-dom": "^19.0.2",
"@yarnpkg/pnpify": "^4.1.3",
"eslint": "^9.17.0",
"nx": "^20.3.1",
"typescript": "^5.7.3"
},
"overrides": {
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc"
},
"nx": {
"targets": {
"dev": {
"dependsOn": [
"^build"
]
}
}
}
}
3 changes: 3 additions & 0 deletions demos/remote-dom/src/app/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
padding: var(--size-px--l);
}
20 changes: 20 additions & 0 deletions demos/remote-dom/src/app/host/[demo]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";
import { RemoteRenderer } from "@mittwald/flow-remote-react-renderer";
import { useParams } from "next/navigation";

export default function Page() {
const { demo } = useParams<{ demo: string }>();
return (
<RemoteRenderer
src={`http://localhost:3000/remote/${demo}`}
iframeStyle={{
border: 0,
bottom: 0,
left: 0,
right: 0,
height: "600px",
width: "100%",
}}
/>
);
}
10 changes: 10 additions & 0 deletions demos/remote-dom/src/app/host/layout.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.rootContainer {
max-width: 1000px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: var(--size-px--l);
}

.mainContainer {
}
31 changes: 31 additions & 0 deletions demos/remote-dom/src/app/host/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import "@mittwald/flow-react-components/all.css";
import "@mittwald/flow-remote-react-renderer/polyfill";
import type { PropsWithChildren } from "react";
import HeaderNavigation from "@mittwald/flow-react-components/HeaderNavigation";
import { Link } from "@mittwald/flow-react-components/Link";
import styles from "./layout.module.css";
import { Separator } from "@mittwald/flow-react-components/Separator";

export default function Layout(props: PropsWithChildren) {
return (
<div className={styles.rootContainer}>
<HeaderNavigation>
<Link href="/host/non-interactive">Non-interactive</Link>
<Link href="/host/event-handler">Event handler</Link>
<Link href="/host/modal">Modal</Link>
<Link href="/host/simple-form">Simple Form</Link>
<Link href="/host/action-form">Action Form</Link>
<Link href="/host/react-hook-form">React Hook Form</Link>
<Link href="/host/rhf-form">RHF Form</Link>
<Link href="/host/suspense">Suspense</Link>
<Link href="/host/svg">Icon/SVG</Link>
<Link href="/host/list">List</Link>
<Link href="/host/performance">Performance</Link>
</HeaderNavigation>
<Separator />
<main className={styles.mainContainer}>
<div>{props.children}</div>
</main>
</div>
);
}
5 changes: 5 additions & 0 deletions demos/remote-dom/src/app/host/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Text } from "@mittwald/flow-react-components/Text";

export default function Page() {
return <Text>Please select a demo</Text>;
}
13 changes: 13 additions & 0 deletions demos/remote-dom/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { PropsWithChildren } from "react";
import { LinkProvider } from "@mittwald/flow-react-components/nextjs";
import "./global.css";

export default function Layout(props: PropsWithChildren) {
return (
<html lang="en">
<body>
<LinkProvider>{props.children}</LinkProvider>
</body>
</html>
);
}
19 changes: 19 additions & 0 deletions demos/remote-dom/src/app/local/action-form/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";
import Button from "@mittwald/flow-react-components/Button";
import Section from "@mittwald/flow-react-components/Section";
import TextField from "@mittwald/flow-react-components/TextField";
import { useActionState } from "react";
import { formServerAction } from "@/app/remote/actions";

export default function Page() {
const [, formAction] = useActionState(formServerAction, null);

return (
<form action={formAction}>
<Section>
<TextField name="test" aria-label="Test" />
<Button type="submit">Submit</Button>
</Section>
</form>
);
}
7 changes: 7 additions & 0 deletions demos/remote-dom/src/app/local/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use client";
import "@mittwald/flow-react-components/all.css";
import { type PropsWithChildren } from "react";

export default function Page(props: PropsWithChildren) {
return <>{props.children}</>;
}
5 changes: 5 additions & 0 deletions demos/remote-dom/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";

export default function Page() {
redirect("/host");
}
38 changes: 38 additions & 0 deletions demos/remote-dom/src/app/remote/action-form/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";
import {
Button,
Text,
Form,
Section,
TextField,
CodeBlock,
} from "@mittwald/flow-remote-react-components";
import { formServerAction } from "@/app/remote/actions";
import type { FC } from "react";
import { useFormStatus } from "react-dom";
import { useActionState } from "react";

const FormStatus: FC = () => {
const status = useFormStatus();
return <CodeBlock code={JSON.stringify(status, undefined, 2)} />;
};

export default function Page() {
const [callCount, dispatchFormServerAction, isPending] = useActionState(
formServerAction,
0,
);

return (
<Form action={dispatchFormServerAction}>
<Section>
<TextField name="test" aria-label="Test" />
<Button type="submit" isPending={isPending}>
Submit
</Button>
<Text>Called {callCount} times</Text>
<FormStatus />
</Section>
</Form>
);
}
32 changes: 32 additions & 0 deletions demos/remote-dom/src/app/remote/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use server";

const sleep = () => new Promise((res) => setTimeout(res, 2000));

export async function getServerData() {
await sleep();
return "Data from server action";
}

export async function login(formState: unknown | null, formData: FormData) {
await sleep();
console.log(formData, "Server");

return {
success: true,
};
}

export async function formServerAction(prevState: number, formData: FormData) {
console.log("Calling form server action with data: ", formData);
await sleep();
console.log("Done");
return prevState + 1;
}

export async function formReactHookServerAction(
prevState: unknown,
formData: FormData,
) {
await sleep();
console.log("action form", formData);
}
22 changes: 22 additions & 0 deletions demos/remote-dom/src/app/remote/event-handler/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";
import {
Button,
CodeBlock,
Section,
TextField,
} from "@mittwald/flow-remote-react-components";
import { useState } from "react";

export default function Page() {
const [event, setEvent] = useState<unknown>();

return (
<Section>
<Button onPress={setEvent} color="danger" variant="outline">
Press me
</Button>
<TextField onChange={setEvent} aria-label="Test" />
<CodeBlock code={JSON.stringify(event, undefined, 2)} />
</Section>
);
}
21 changes: 21 additions & 0 deletions demos/remote-dom/src/app/remote/layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
body {
background-color: bisque;
}

script {
display: none;
}

* {
background-color: rgba(0, 0, 0, 0.1);
display: block;
font-family: sans-serif;
}

[flr-*] {
display: none;
}

* * {
padding-left: 20px;
}
Loading
Loading