# @tp-ui/tp-window

> # Features

Latest version **0.2.0** (published 2018-12-06) · 0 weekly downloads

## Install

```sh
npm install @tp-ui/tp-window
pnpm add @tp-ui/tp-window
yarn add @tp-ui/tp-window
bun add @tp-ui/tp-window
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-12-06 |
| First published | 2018-08-09 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 277.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | cjamhe01385, zack9433 |

## Links

- npm: https://www.npmjs.com/package/@tp-ui/tp-window
- npm.io page: https://npm.io/package/@tp-ui/tp-window

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Recent versions

- 0.2.0 (latest) — 2018-12-06
- 0.0.11 — 2018-08-27
- 0.0.10 — 2018-08-27
- 0.0.9 — 2018-08-27
- 0.0.8 — 2018-08-14
- 0.0.7 — 2018-08-14
- 0.0.6 — 2018-08-14
- 0.0.5 — 2018-08-13
- 0.0.4 — 2018-08-13
- 0.0.3 — 2018-08-13
- 0.0.2 — 2018-08-12
- 0.0.1 — 2018-08-09

## README

# ThingsPro Window

# Features

## Usages

### 1. Create a tp-window state config or write a config in template directly.

Example: create a config
```javascript
const tpStateConfig: TpWindowStateConfig = new TpWindowStateConfig('stateId', 'stateName', 'STATE', 'settings');
```

Example: write config in template files.
```html
<tp-window-state stateId="demoState" name="{{Demo State}}" type="CONTENT" icon="settings">  
</tp-window-state>
```

### 2. Setup tp-window 

Notice: tp-window `id` and tp-window-state `config` is required.

```html
<tp-window [name]="name" maxStateNumber="3" id="tpDemoId" [optionPortal]="portal" (stateChange)="onStateChange($event)">
  <tp-window-state [config]="tpStateConfig">
    <!-- Your DOM template -->
  <tp-window-state>
</tp-window>
```

### 3. Inject `TpWindowService` to manipulate your states.

```javascript
constructor(public tpWindow: TpWindowService) {}
// Navigate a window to a state
this.tpWindow.navigateTo('windowId.stateId'); // windowId + '.' + stateId

// Show or hide progress bar
this.tpWindow.progressStart('tpDemoId');
this.tpWindow.progressComplete('tpDemoId');

// Show or hide state icon
this.tpWindow.setIcons([{stateUrl: 'tpDemoId.stateId',isShow: false}, {stateUrl: 'tpDemoId.stateId',isShow: false}]);
```

## API Document

### tp-window (TpWindowComponent)

| Property       | Type                                         | Description                                                                                                                                                          |
| -------------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \*windowId     | @Input `string`                              | The identification for window                                                                                                                                        |
| name           | @Input `string`                              | The name will be showed on the title of component.                                                                                                                   |
| maxStateNumber | @Input `number`                              | Limit the total number of icons on the tool bar. The rest of icons will be sorted to menu list as the number of icons exceeds it. This setting could be used to RWD. |
| loading        | @Input `Observable<any>`                     | It Will show a loading bar before observable completed.                                                                                                              |
| optionPortal   | @Input `Portal<any>`                         | Add customized actions or information by using `CdkPortal`                                                                                                           |
| stateChange    | @Output `EventEmitter<WindowStateComponent>` | emit clicked state component.                                                                                                                                        |

### tp-window-state (TpWindowStateComponent)

| Property | Type                         | Description   |
| -------- | ---------------------------- | ------------- |
| \*config | @input `TpWindowStateConfig` | State config. |

### TpWindowStateConfig

| Property | Type                | Description                                                                              |
| -------- | ------------------- | ---------------------------------------------------------------------------------------- |
| stateId  | `string`            | The identification for state.                                                            |
| name     | `string`            | The name will be showed on the menu item or tooltip.                                     |
| type     | `TpWindowStateType` | `'ACTION'` `'STATE'` `'CONTENT'`                                                         |
| icon     | `string`            | The name of Angular Material Icon ，please see [Icons](https://material.io/tools/icons/) |

### TpWindowService

| Methods                                                         | Description                  |
| --------------------------------------------------------------- | ---------------------------- |
| navigateTo(stateUrl: `string`)                                  | Navigate a state of a window |
| progress(windowId: `string`, progress: `Observable<any>`)       | Show progress bar            |
| progressStart(windowId: `string`)                               | Show progress bar            |
| progressComplete(windowId: `string`)                            | Hide progress bar            |
| setIcons(options: `Array<{stateUrl: string, isShow: boolean}>`) | Hide a icon of a state       |

---
_Source: https://npm.io/package/@tp-ui/tp-window · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
