# prospective-web-canvas

> prospective-web-canvas

Latest version **1.0.2** (published 2023-12-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install prospective-web-canvas
pnpm add prospective-web-canvas
yarn add prospective-web-canvas
bun add prospective-web-canvas
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-12-10 |
| First published | 2023-12-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 70.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jongoshmoe |

## Links

- npm: https://www.npmjs.com/package/prospective-web-canvas
- npm.io page: https://npm.io/package/prospective-web-canvas

## Dependencies (1)

- [declaration-bundler-webpack-plugin](https://npm.io/package/declaration-bundler-webpack-plugin.md) ^1.0.3

## Recent versions

- 1.0.2 (latest) — 2023-12-10
- 1.0.1 — 2023-12-10

## README

## Simple Prespective Canvas Package

This package contains some simple classes to draw svg component on prespective designer.

# Requirements:
- map your props into the following interface:
```typescript
	export interface ComponentState {
	    name: string;
	    variant: string;
	    setup: any;                 // setup props
	    status: any;                // status props
	    clickEvent: any;            // component deselect props
	    deselectedEvent: any;       // component deselect props
	    information: any;           // information props to include in event
	}

  folow provided schemas for the above, except for information which is up to you to define
```
- Implement props write like below and add to the props.json of your object
```typescript
	// this must be implemented to provide access to props write
    writeStatus(isSelected: boolean, clickCounter: number): void {
        this.props.props.writeStatus(isSelected,clickCounter); 
    }
```
- create an abstract class like below
```typescript
	
	// this is the base component where all common functions and properties will be defined
	export abstract class BaseComponent<T extends object, U> extends Component<ComponentProps<T>, U> {
	    perspectiveComponent = new PrespectiveComponent(this.refreshFigure.bind(this),this.writeStatus.bind(this));
	    canvasRef: React.RefObject<SVGSVGElement> = React.createRef();

	    componentDidMount() { 
	        // pass canvas reference for drawing
	        this.mapProps();
	        this.perspectiveComponent.className = "your-component";
	        this.perspectiveComponent.canvasRef = this.canvasRef;        
	        this.perspectiveComponent.componentDidMount();        
	    }

	    componentWillUnmount() {
	        this.perspectiveComponent.componentWillUnmount();        
	    }

	    componentDidUpdate() {  
	        this.mapProps(); 
	        const refreshRequired = this.componentDidUpdateTasks();      
	        this.perspectiveComponent.componentDidUpdate(refreshRequired);
	    }

	    // refreshFigure to be implemented in actual class
	    abstract refreshFigure(): void;
	    abstract writeStatus(isSelected: boolean, clickCounter: number): void;
	    protected abstract mapProps(): void;
	    abstract componentDidUpdateTasks(): boolean;      // any thing to be dome before componentDidUpdate
	} 
```
- your component will extend BaseComponent:
```typescript
	class YourComponent extends BaseComponent<ConveyorProps, ComponentState>
```

---
_Source: https://npm.io/package/prospective-web-canvas · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
