Skip to content

Commit

Permalink
Merge pull request #4 from ikepu-tp/feature-addView
Browse files Browse the repository at this point in the history
Feature-addView
  • Loading branch information
ikepu-tp committed Oct 2, 2023
2 parents b798422 + f7f3a33 commit 831c992
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
7 changes: 7 additions & 0 deletions View/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@ikepu-tp/react-mvc/View",
"private":true,
"main": "./../dist/cjs/View.js",
"module": "./../dist/esm/View.js",
"types": "./../dist/esm/View.d.ts"
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ikepu-tp/react-mvc",
"type": "module",
"version": "0.8.2",
"version": "0.9.0",
"description": "React MVC is a library for supporting MVC-like implementations in JavaScript projects.",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down Expand Up @@ -53,6 +53,11 @@
"import": "./dist/esm/Controller.js",
"types": "./dist/esm/Controller.d.ts"
},
"./View": {
"require": "./dist/cjs/View.js",
"import": "./dist/esm/View.js",
"types": "./dist/esm/View.d.ts"
},
"./Function": {
"require": "./dist/cjs/Function.js",
"import": "./dist/esm/Function.js",
Expand Down
21 changes: 18 additions & 3 deletions src/Controller.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
import { PropsWithChildren } from 'react';
import View from './View';

export type ControllerWrapperProps = PropsWithChildren & {};
export type ControllerIndexProps = PropsWithChildren & {};
export type ControllerShowProps = PropsWithChildren & {};
export type ControllerEditProps = PropsWithChildren & {};
export class Controller {
public view = View;

public wrapper(props: ControllerWrapperProps): JSX.Element {
return <>{props.children}</>;
}

public index(props: ControllerIndexProps): JSX.Element {
return <this.wrapper {...props}></this.wrapper>;
return (
<this.wrapper {...props}>
<this.view.Index></this.view.Index>
</this.wrapper>
);
}

public show(props: ControllerShowProps): JSX.Element {
return <this.wrapper {...props}></this.wrapper>;
return (
<this.wrapper {...props}>
<this.view.Show></this.view.Show>
</this.wrapper>
);
}

public edit(props: ControllerEditProps): JSX.Element {
return <this.wrapper {...props}></this.wrapper>;
return (
<this.wrapper {...props}>
<this.view.Edit></this.view.Edit>
</this.wrapper>
);
}
}
const controller = new Controller();
Expand Down
25 changes: 25 additions & 0 deletions src/View.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PropsWithChildren } from 'react';

export type ViewIndexProps = PropsWithChildren & {};
export type ViewShowProps = PropsWithChildren & {};
export type ViewEditProps = PropsWithChildren & {};
export class View<I = ViewIndexProps, S = ViewShowProps, E = ViewEditProps> {
public index(props: I): JSX.Element {
return <div {...(props as ViewIndexProps)} />;
}

public show(props: S): JSX.Element {
return <div {...(props as ViewShowProps)} />;
}

public edit(props: E): JSX.Element {
return <div {...(props as ViewEditProps)} />;
}
}

const view = new View();
export default {
Index: view.index,
Show: view.show,
Edit: view.edit,
};
3 changes: 2 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export default defineConfig({
Url: resolve(__dirname, "src/Url.ts"),
Send: resolve(__dirname, "src/Send.ts"),
Model: resolve(__dirname, "src/Model.ts"),
Controller: resolve(__dirname, "src/Controller.ts"),
Controller: resolve(__dirname, "src/Controller.tsx"),
View: resolve(__dirname, "src/View.tsx"),
index: resolve(__dirname, "src/index.ts"),
},
name: '@ikepu-tp/react-mvc',
Expand Down

0 comments on commit 831c992

Please sign in to comment.