diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..7053c49
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,5 @@
+[*.{js,jsx,ts,tsx,vue}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2a00fa7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,26 @@
+.DS_Store
+.history
+node_modules
+/dist
+/es
+/lib
+package-lock.json
+yarn.lock
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..73ee303
--- /dev/null
+++ b/README.md
@@ -0,0 +1,39 @@
+# dom-zindex
+
+English | [简体中文](README.zh-CN.md)
+
+[](https://www.npmjs.com/package/dom-zindex)
+[](https://travis-ci.com/x-extends/dom-zindex)
+[](https://npm-stat.com/charts.html?package=dom-zindex)
+[](https://github.com/x-extends/dom-zindex/issues)
+[](https://github.com/x-extends/dom-zindex/issues?q=is%3Aissue+is%3Aclosed)
+[](https://github.com/x-extends/dom-zindex/pulls)
+[](https://github.com/x-extends/dom-zindex/pulls?q=is%3Apr+is%3Aclosed)
+[](LICENSE)
+
+Web common z-index style management.
+
+## Browser Support
+
+ |  |  |  | 
+--- | --- | --- | --- | --- |
+Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
+
+## Installing
+
+```shell
+npm install dom-zindex
+```
+
+### CDN
+
+It is not recommended to use the public CDN address for production, because the connection may fail at any time, causing the project to hang up;
+Remember to lock the version number by using CDN to avoid being affected by incompatible updates.
+
+```HTML
+
+```
+
+## License
+
+[MIT](LICENSE) © 2019-present, Xu Liangzhan
diff --git a/README.zh-CN.md b/README.zh-CN.md
new file mode 100644
index 0000000..b6b6232
--- /dev/null
+++ b/README.zh-CN.md
@@ -0,0 +1,39 @@
+# dom-zindex
+
+简体中文 | [繁體中文](README.zh-TW.md) | [English](README.en.md)
+
+[](https://www.npmjs.com/package/dom-zindex)
+[](https://travis-ci.com/x-extends/dom-zindex)
+[](https://npm-stat.com/charts.html?package=dom-zindex)
+[](https://github.com/x-extends/dom-zindex/issues)
+[](https://github.com/x-extends/dom-zindex/issues?q=is%3Aissue+is%3Aclosed)
+[](https://github.com/x-extends/dom-zindex/pulls)
+[](https://github.com/x-extends/dom-zindex/pulls?q=is%3Apr+is%3Aclosed)
+[](LICENSE)
+
+Web 通用的 z-index style 管理器
+
+## Browser Support
+
+ |  |  |  | 
+--- | --- | --- | --- | --- |
+Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
+
+## 安装
+
+```shell
+npm install dom-zindex
+```
+
+### CDN
+
+不建议将第三方的 CDN 地址用于生产,因为该连接随时都可能会失效,导致项目挂掉;
+使用 CDN 方式记得锁定版本号,避免受到非兼容性更新的影响
+
+```HTML
+
+```
+
+## License
+
+[MIT](LICENSE) © 2019-present, Xu Liangzhan
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..b39c2d2
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,62 @@
+const gulp = require('gulp')
+const uglify = require('gulp-uglify')
+const babel = require('gulp-babel')
+const rename = require('gulp-rename')
+const ts = require('gulp-typescript')
+const pack = require('./package.json')
+const tsconfig = require('./tsconfig.json')
+
+gulp.task('build_common', function () {
+ return gulp.src(['index.ts'])
+ .pipe(ts(tsconfig.compilerOptions))
+ .pipe(babel({
+ presets: ['@babel/env']
+ }))
+ .pipe(rename({
+ basename: 'index',
+ extname: '.common.js'
+ }))
+ .pipe(gulp.dest('dist'))
+})
+
+gulp.task('build_esm', function () {
+ return gulp.src(['index.ts'])
+ .pipe(ts({
+ strict: true,
+ moduleResolution: 'node',
+ noImplicitAny: true,
+ target: 'es5',
+ module: 'esnext',
+ lib: ['dom', 'esnext']
+ }))
+ .pipe(rename({
+ basename: 'index',
+ extname: '.esm.js'
+ }))
+ .pipe(gulp.dest('es'))
+})
+
+gulp.task('build_umd', function () {
+ return gulp.src(['index.ts'])
+ .pipe(ts(tsconfig.compilerOptions))
+ .pipe(babel({
+ moduleId: pack.name,
+ presets: ['@babel/env'],
+ plugins: ['@babel/transform-modules-umd']
+ }))
+ .pipe(rename({
+ basename: 'index',
+ suffix: '.umd',
+ extname: '.js'
+ }))
+ .pipe(gulp.dest('dist'))
+ .pipe(uglify())
+ .pipe(rename({
+ basename: 'index',
+ suffix: '.umd.min',
+ extname: '.js'
+ }))
+ .pipe(gulp.dest('dist'))
+})
+
+gulp.task('build', gulp.parallel('build_common','build_esm', 'build_umd'))
diff --git a/index.ts b/index.ts
new file mode 100644
index 0000000..10684d6
--- /dev/null
+++ b/index.ts
@@ -0,0 +1,92 @@
+let storeEl: HTMLElement | null = null
+let storeId = 'z-index-manage'
+let storeMainKey: 'm' = 'm'
+let storeSubKey: 's' = 's'
+
+const storeData = {
+ m: 1000,
+ s: 1000
+}
+
+function getDom () {
+ if (!storeEl) {
+ if (typeof document !== 'undefined') {
+ storeEl = document.getElementById(storeId)
+ if (!storeEl) {
+ storeEl = document.createElement('div')
+ storeEl.id = storeId
+ document.body.appendChild(storeEl)
+ setCurrent(storeData.m)
+ setSubCurrent(storeData.s)
+ }
+ }
+ }
+ return storeEl
+}
+
+function createSetHandle (key: keyof (typeof storeData)) {
+ return function (value: number) {
+ if (value) {
+ value = Number(value)
+ storeData[key] = value
+ let doc = getDom()
+ if (doc) {
+ if (doc.dataset) {
+ doc.dataset[key] = value + ''
+ } else {
+ doc.setAttribute('data-' + key, value + '')
+ }
+ }
+ }
+ return storeData[key]
+ }
+}
+
+export const setCurrent = createSetHandle(storeMainKey)
+
+function createGetHandle (key: keyof (typeof storeData)) {
+ return function getCurrent () {
+ let zIndex
+ let doc = getDom()
+ if (doc) {
+ zIndex = doc.dataset ? doc.dataset[key] : doc.getAttribute('data-' + key)
+ }
+ if (zIndex) {
+ return Number(zIndex)
+ }
+ return storeData[key]
+ }
+}
+
+export const getCurrent = createGetHandle(storeMainKey)
+
+export function getNext () {
+ return setCurrent(getCurrent() + 1)
+}
+
+export const setSubCurrent = createSetHandle(storeSubKey)
+
+const _getSubCurrent = createGetHandle(storeSubKey)
+
+export function getSubCurrent () {
+ return getCurrent() + _getSubCurrent()
+}
+
+export function getSubNext () {
+ setSubCurrent(_getSubCurrent() + 1)
+ return getSubCurrent()
+}
+
+/**
+ * Web common z-index style management
+ */
+const DomZIndex = {
+ setCurrent,
+ getCurrent,
+ getNext,
+ setSubCurrent,
+ getSubCurrent,
+ getSubNext
+}
+
+export default DomZIndex
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..35e0f60
--- /dev/null
+++ b/package.json
@@ -0,0 +1,57 @@
+{
+ "name": "dom-zindex",
+ "version": "0.1.0",
+ "description": "Web common z-index style management",
+ "files": [
+ "dist",
+ "es",
+ "types"
+ ],
+ "scripts": {
+ "lib": "gulp build"
+ },
+ "main": "dist/index.common.js",
+ "module": "es/index.esm.js",
+ "unpkg": "dist/index.umd.js",
+ "jsdelivr": "dist/index.umd.js",
+ "typings": "types/index.d.ts",
+ "devDependencies": {
+ "@babel/core": "^7.4.4",
+ "@babel/plugin-transform-runtime": "^7.4.4",
+ "@babel/preset-env": "^7.4.4",
+ "@babel/runtime": "^7.4.4",
+ "eslint": "^5.16.0",
+ "eslint-config-standard": "^12.0.0",
+ "eslint-friendly-formatter": "^4.0.1",
+ "eslint-plugin-import": "^2.16.0",
+ "eslint-plugin-node": "^8.0.1",
+ "eslint-plugin-promise": "^4.0.1",
+ "eslint-plugin-standard": "^4.0.0",
+ "gulp": "^4.0.2",
+ "gulp-babel": "^8.0.0",
+ "gulp-concat": "^2.6.1",
+ "gulp-rename": "^2.0.0",
+ "gulp-replace": "^1.1.3",
+ "gulp-typescript": "^5.0.1",
+ "gulp-uglify": "^3.0.2",
+ "typescript": "^4.6.4",
+ "markdown-doctest": "^1.0.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/x-extends/dom-zindex.git"
+ },
+ "keywords": [
+ "z-index",
+ "zindex"
+ ],
+ "author": {
+ "name": "Xu Liangzhan",
+ "email": "xu_liangzhan@163.com"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/x-extends/dom-zindex/issues"
+ },
+ "homepage": "https://github.com/x-extends/dom-zindex/"
+}
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..2b4f3f7
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,17 @@
+{
+ "files": [
+ "index.ts"
+ ],
+ "compilerOptions": {
+ "strict": true,
+ "moduleResolution": "node",
+ "noImplicitAny": true,
+ "allowSyntheticDefaultImports": true,
+ "target": "esnext",
+ "lib": [
+ "esnext",
+ "dom",
+ "dom.iterable"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..4d5e289
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,42 @@
+/**
+ * Set main z-index value
+ * @param value
+ */
+export function setCurrent(value: number): number
+
+/**
+ * Get main current z-index
+ */
+export function getCurrent(): number
+
+/**
+ * Get main next z-index
+ */
+export function getNext(): number
+
+/**
+ * Set subordinate z-index value
+ * @param value
+ */
+export function setSubCurrent(value: number): number
+
+/**
+ * Get subordinate current z-index
+ */
+export function getSubCurrent(): number
+
+/**
+ * Get subordinate next z-index
+ */
+export function getSubNext(): number
+
+const DomZIndex: {
+ setCurrent: typeof setCurrent
+ getCurrent: typeof getCurrent
+ getNext: typeof getNext
+ setSubCurrent: typeof setSubCurrent
+ getSubCurrent: typeof getSubCurrent
+ getSubNext: typeof getSubNext
+}
+
+export default DomZIndex
\ No newline at end of file