# zent-utils

> Zent工具库

Latest version **1.1.0** (published 2017-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install zent-utils
pnpm add zent-utils
yarn add zent-utils
bun add zent-utils
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-04-24 |
| First published | 2017-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2249 |
| Author | lichen |
| Maintainers | delai, youzan-lc |

## Links

- npm: https://www.npmjs.com/package/zent-utils
- Repository: https://github.com/youzan/zent
- Homepage: https://github.com/youzan/zent#readme
- Issues: https://github.com/youzan/zent/issues
- npm.io page: https://npm.io/package/zent-utils

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) 4.17.x
- [es6-error](https://npm.io/package/es6-error.md) 4.0.x
- [classnames](https://npm.io/package/classnames.md) 2.2.x
- [prop-types](https://npm.io/package/prop-types.md) 15.5.x

## Recent versions

- 1.1.0 (latest) — 2017-04-24
- 1.1.0-beta4 (beta) — 2017-04-19
- 1.1.0-beta1 — 2017-04-18
- 1.0.9 — 2017-04-13
- 1.0.8 — 2017-04-13
- 1.0.7 — 2017-03-08
- 1.0.7-beta2 — 2017-03-02
- 1.0.7-beta1 — 2017-02-27
- 1.0.6 — 2017-02-17
- 1.0.5 — 2017-02-15
- 1.0.3 — 2017-02-15
- 1.0.2 — 2017-02-13
- 1.0.1 — 2017-02-13
- 1.0.0 — 2017-02-10

## README

# zent-utils

[![npm version](https://img.shields.io/npm/v/zent-utils.svg?style=flat)](https://www.npmjs.com/package/zent-utils) [![downloads](https://img.shields.io/npm/dt/zent-utils.svg)](https://www.npmjs.com/package/zent-utils)

组件库的工具函数／工具组件

## 添加新组件／函数

为了方便引用, 所有打包之后生成的文件／目录应该处于根目录下. `package.json` 的 `files` 字段下需要加上新文件, 同时在 `.gitignore` 中忽略新文件.

## API

### classnames

导出了用来拼接React `className` 的 `classnames` 函数, 使用方法和 [classnames](https://github.com/JedWatson/classnames) 一致.

### lodash

导出了[lodash](<>)中的所有函数, 只支持按需 `import` 的方式引用.

`import isFunction from 'zent-utils/lodash/isFunction';`

### prop-types

导出了[prop-types](https://github.com/reactjs/prop-types).

### WindowEventHandler

在`window`上绑定全局事件.

| 参数         | 说明           | 类型     | 默认值     |
| ---------- | ------------ | ------ | ------- |
| eventName  | 事件名字         | string |         |
| callback   | 事件的回调函数      | func   | `noop`  |
| useCapture | 是否为capture事件 | bool   | `false` |

### WindowResizeHandler

监听全局的 `resize` 事件.

| 参数       | 说明            | 类型   |
| -------- | ------------- | ---- |
| onResize | resize事件的回调函数 | func |

### DOM 工具函数

#### findPositionedParent

`findPositionedParent(element: Node, inclusive: bool): Node`

搜索DOM树中最近的一个有指定 `position` 属性的节点, `inclusive` 为true时, `element` 也会加入搜索路径中.

#### getViewportSize

`getViewportSize(): { width: number, height: number }`

获取当前viewport的大小, viewport指浏览器的可视空间.

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