@avilang/practical-ui 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +2 -2
- package/button/button.vue +39 -0
- package/button/index.js +1 -0
- package/config-provider/config-provider.vue +34 -0
- package/config-provider/index.js +1 -0
- package/config-provider/reset.css +137 -0
- package/index.js +13 -0
- package/input/index.js +1 -0
- package/input/input.vue +58 -0
- package/package.json +28 -55
- package/utility/throttle-debounce.js +198 -0
- package/utility/util.js +7 -0
- package/vite.config.js +28 -0
- package/.browserslistrc +0 -6
- package/.editorconfig +0 -15
- package/.eslintrc +0 -25
- package/.gitattributes +0 -4
- package/.stylelintrc.json +0 -13
- package/LICENSE +0 -21
- package/README.md +0 -3
- package/dist/Icon-shared.js +0 -177
- package/dist/button/index.js +0 -151
- package/dist/button/style/index.css +0 -1
- package/dist/icon/index.js +0 -3
- package/dist/icon/style/index.css +0 -1
- package/dist/style/fonts/icomoon-practical.eot +0 -0
- package/dist/style/fonts/icomoon-practical.svg +0 -12
- package/dist/style/fonts/icomoon-practical.ttf +0 -0
- package/dist/style/fonts/icomoon-practical.woff +0 -0
- package/dist/style/index.css +0 -1
- package/docz.config.js +0 -3
- package/gatsby-config.js +0 -3
- package/gulpfile.js +0 -48
- package/lib/_fonts/icomoon-practical-v1.0/Read Me.txt +0 -7
- package/lib/_fonts/icomoon-practical-v1.0/demo-files/demo.css +0 -152
- package/lib/_fonts/icomoon-practical-v1.0/demo-files/demo.js +0 -30
- package/lib/_fonts/icomoon-practical-v1.0/demo.html +0 -66
- package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.eot +0 -0
- package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.svg +0 -12
- package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.ttf +0 -0
- package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.woff +0 -0
- package/lib/_fonts/icomoon-practical-v1.0/selection.json +0 -1
- package/lib/_fonts/icomoon-practical-v1.0/style.css +0 -33
- package/lib/_variables.scss +0 -17
- package/lib/button/Button.js +0 -110
- package/lib/button/doc/button.mdx +0 -99
- package/lib/button/index.js +0 -1
- package/lib/button/style/button.scss +0 -140
- package/lib/icon/Icon.js +0 -30
- package/lib/icon/doc/icon.mdx +0 -43
- package/lib/icon/index.js +0 -1
- package/lib/icon/style/icon.scss +0 -15
- package/lib/util/index.js +0 -1
- package/lib/util/useThrottleFn.js +0 -31
- package/prettier.config.js +0 -20
- package/rollup.config.js +0 -29
- package/src/gatsby-theme-docz/wrapper.js +0 -9
package/.husky/pre-commit
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<n-button
|
|
3
|
+
:class="`${attrs.class ? attrs.class : ''}`"
|
|
4
|
+
attr-type="button"
|
|
5
|
+
:focusable="false"
|
|
6
|
+
:bordered="true"
|
|
7
|
+
:keyboard="false"
|
|
8
|
+
:block="block"
|
|
9
|
+
:size="size"
|
|
10
|
+
:type="type"
|
|
11
|
+
@click="handleClick"
|
|
12
|
+
>
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</n-button>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { useAttrs } from 'vue'
|
|
19
|
+
import { NButton } from 'naive-ui'
|
|
20
|
+
import { debounce } from '../utility/throttle-debounce'
|
|
21
|
+
|
|
22
|
+
defineOptions({
|
|
23
|
+
name: 'PButton',
|
|
24
|
+
inheritAttrs: false
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
defineProps({
|
|
28
|
+
type: { type: String, default: 'primary' },
|
|
29
|
+
size: { type: String, default: 'medium' },
|
|
30
|
+
block: { type: Boolean, default: false }
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const attrs = useAttrs()
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits(['click'])
|
|
36
|
+
const handleClick = debounce(function () {
|
|
37
|
+
emit('click')
|
|
38
|
+
})
|
|
39
|
+
</script>
|
package/button/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PButton } from './button.vue'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<n-config-provider
|
|
3
|
+
preflight-style-disabled
|
|
4
|
+
abstract
|
|
5
|
+
inline-theme-disabled
|
|
6
|
+
:locale="zhCN"
|
|
7
|
+
:date-locale="dateZhCN"
|
|
8
|
+
:theme-overrides="themeOverrides"
|
|
9
|
+
>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</n-config-provider>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
import 'vfonts/Lato.css'
|
|
16
|
+
import { NConfigProvider, zhCN, dateZhCN } from 'naive-ui'
|
|
17
|
+
|
|
18
|
+
defineOptions({
|
|
19
|
+
name: 'PConfigProvider',
|
|
20
|
+
inheritAttrs: false
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const themeOverrides = {
|
|
24
|
+
common: {
|
|
25
|
+
fontWeightStrong: '600',
|
|
26
|
+
primaryColor: '#2080F0FF',
|
|
27
|
+
primaryColorHover: '#4098FCFF',
|
|
28
|
+
primaryColorPressed: '#1060C9FF',
|
|
29
|
+
primaryColorSuppl: '#4098FCFF'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<style src="./reset.css"></style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PConfigProvider } from './config-provider.vue'
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
html,
|
|
2
|
+
body,
|
|
3
|
+
div,
|
|
4
|
+
span,
|
|
5
|
+
applet,
|
|
6
|
+
object,
|
|
7
|
+
iframe,
|
|
8
|
+
h1,
|
|
9
|
+
h2,
|
|
10
|
+
h3,
|
|
11
|
+
h4,
|
|
12
|
+
h5,
|
|
13
|
+
h6,
|
|
14
|
+
p,
|
|
15
|
+
blockquote,
|
|
16
|
+
pre,
|
|
17
|
+
a,
|
|
18
|
+
abbr,
|
|
19
|
+
acronym,
|
|
20
|
+
address,
|
|
21
|
+
big,
|
|
22
|
+
cite,
|
|
23
|
+
code,
|
|
24
|
+
del,
|
|
25
|
+
dfn,
|
|
26
|
+
em,
|
|
27
|
+
img,
|
|
28
|
+
ins,
|
|
29
|
+
kbd,
|
|
30
|
+
q,
|
|
31
|
+
s,
|
|
32
|
+
samp,
|
|
33
|
+
small,
|
|
34
|
+
strike,
|
|
35
|
+
strong,
|
|
36
|
+
sub,
|
|
37
|
+
sup,
|
|
38
|
+
tt,
|
|
39
|
+
var,
|
|
40
|
+
b,
|
|
41
|
+
u,
|
|
42
|
+
i,
|
|
43
|
+
center,
|
|
44
|
+
dl,
|
|
45
|
+
dt,
|
|
46
|
+
dd,
|
|
47
|
+
ol,
|
|
48
|
+
ul,
|
|
49
|
+
li,
|
|
50
|
+
fieldset,
|
|
51
|
+
form,
|
|
52
|
+
label,
|
|
53
|
+
legend,
|
|
54
|
+
table,
|
|
55
|
+
caption,
|
|
56
|
+
tbody,
|
|
57
|
+
tfoot,
|
|
58
|
+
thead,
|
|
59
|
+
tr,
|
|
60
|
+
th,
|
|
61
|
+
td,
|
|
62
|
+
article,
|
|
63
|
+
aside,
|
|
64
|
+
canvas,
|
|
65
|
+
details,
|
|
66
|
+
embed,
|
|
67
|
+
figure,
|
|
68
|
+
figcaption,
|
|
69
|
+
footer,
|
|
70
|
+
header,
|
|
71
|
+
hgroup,
|
|
72
|
+
menu,
|
|
73
|
+
nav,
|
|
74
|
+
output,
|
|
75
|
+
ruby,
|
|
76
|
+
section,
|
|
77
|
+
summary,
|
|
78
|
+
time,
|
|
79
|
+
mark,
|
|
80
|
+
audio,
|
|
81
|
+
video {
|
|
82
|
+
margin: 0;
|
|
83
|
+
padding: 0;
|
|
84
|
+
border: 0;
|
|
85
|
+
font-size: 100%;
|
|
86
|
+
font: inherit;
|
|
87
|
+
vertical-align: baseline;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* HTML5 display-role reset for older browsers */
|
|
91
|
+
article,
|
|
92
|
+
aside,
|
|
93
|
+
details,
|
|
94
|
+
figcaption,
|
|
95
|
+
figure,
|
|
96
|
+
footer,
|
|
97
|
+
header,
|
|
98
|
+
hgroup,
|
|
99
|
+
menu,
|
|
100
|
+
nav,
|
|
101
|
+
section {
|
|
102
|
+
display: block;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
body {
|
|
106
|
+
text-size-adjust: 100%;
|
|
107
|
+
-webkit-tap-highlight-color: transparent;
|
|
108
|
+
background-color: rgb(255, 255, 255);
|
|
109
|
+
color: rgb(51, 54, 57);
|
|
110
|
+
font-size: 14px;
|
|
111
|
+
font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
|
112
|
+
line-height: 1.6;
|
|
113
|
+
transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
ol,
|
|
117
|
+
ul {
|
|
118
|
+
list-style: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
blockquote,
|
|
122
|
+
q {
|
|
123
|
+
quotes: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
blockquote:before,
|
|
127
|
+
blockquote:after,
|
|
128
|
+
q:before,
|
|
129
|
+
q:after {
|
|
130
|
+
content: '';
|
|
131
|
+
content: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
table {
|
|
135
|
+
border-collapse: collapse;
|
|
136
|
+
border-spacing: 0;
|
|
137
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PConfigProvider } from './config-provider/index.js'
|
|
2
|
+
import { PButton } from './button/index.js'
|
|
3
|
+
import { PInput } from './input/index.js'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
install: (app, options = {}) => {
|
|
7
|
+
const { prefix = 'p' } = options
|
|
8
|
+
|
|
9
|
+
app.component(`${prefix}-config-provider`, PConfigProvider)
|
|
10
|
+
app.component(`${prefix}-button`, PButton)
|
|
11
|
+
app.component(`${prefix}-input`, PInput)
|
|
12
|
+
}
|
|
13
|
+
}
|
package/input/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PInput } from './input.vue'
|
package/input/input.vue
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<n-input
|
|
3
|
+
:input-props="{ autocomplete: 'off' }"
|
|
4
|
+
:type="type"
|
|
5
|
+
:value="value"
|
|
6
|
+
:maxlength="maxlength"
|
|
7
|
+
:show-count="showCount"
|
|
8
|
+
:count-graphemes="(maxlength != null && maxlength > 0) || showCount ? countGraphemes : void 0"
|
|
9
|
+
:placeholder="placeholder"
|
|
10
|
+
@input="handleInput"
|
|
11
|
+
@blur="handleBlur"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
import { NInput } from 'naive-ui'
|
|
17
|
+
import { countGraphemes } from '../utility/util'
|
|
18
|
+
|
|
19
|
+
defineOptions({
|
|
20
|
+
name: 'PInput',
|
|
21
|
+
inheritAttrs: false
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const { trim } = defineProps({
|
|
25
|
+
type: { type: String, default: 'text' },
|
|
26
|
+
placeholder: { type: String, default: '' },
|
|
27
|
+
maxlength: { type: Number },
|
|
28
|
+
showCount: { type: Boolean, default: false },
|
|
29
|
+
trim: { type: Boolean, default: true }
|
|
30
|
+
})
|
|
31
|
+
const value = defineModel({ type: String, default: '' })
|
|
32
|
+
const emit = defineEmits(['blur', 'input'])
|
|
33
|
+
|
|
34
|
+
function handleValueWithTrim() {
|
|
35
|
+
let v = value.value
|
|
36
|
+
if (trim) {
|
|
37
|
+
const vWithTrim = v.trim()
|
|
38
|
+
value.value = vWithTrim
|
|
39
|
+
v = vWithTrim
|
|
40
|
+
}
|
|
41
|
+
return v
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function handleBlur() {
|
|
45
|
+
const val = handleValueWithTrim()
|
|
46
|
+
emit('blur', { value: val })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleInput(val) {
|
|
50
|
+
value.value = val
|
|
51
|
+
|
|
52
|
+
let v = val
|
|
53
|
+
if (trim) {
|
|
54
|
+
v = v.trim()
|
|
55
|
+
}
|
|
56
|
+
emit('input', { value: v })
|
|
57
|
+
}
|
|
58
|
+
</script>
|
package/package.json
CHANGED
|
@@ -1,67 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avilang/practical-ui",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "Practical UI components created based on vue3",
|
|
6
|
+
"main": "index.js",
|
|
5
7
|
"scripts": {
|
|
6
|
-
"build
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"docz:dev": "rimraf .docz && docz dev",
|
|
11
|
-
"docz:build": "docz build",
|
|
12
|
-
"docz:serve": "docz build && docz serve",
|
|
13
|
-
"prepare": "husky install"
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix",
|
|
10
|
+
"format": "prettier . --write",
|
|
11
|
+
"prepare": "cd ../.. && husky packages/components/.husky"
|
|
14
12
|
},
|
|
15
13
|
"lint-staged": {
|
|
16
|
-
"*.js":
|
|
17
|
-
|
|
14
|
+
"*.{js,jsx,vue}": [
|
|
15
|
+
"eslint",
|
|
16
|
+
"prettier --check"
|
|
17
|
+
],
|
|
18
|
+
"*.{css,less}": "prettier --check"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"naive-ui",
|
|
22
|
+
"vue3",
|
|
23
|
+
"practical ui"
|
|
24
|
+
],
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": "^3.5.10"
|
|
18
27
|
},
|
|
19
28
|
"dependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
29
|
+
"grapheme-splitter": "1.0.4",
|
|
30
|
+
"naive-ui": "2.40.1",
|
|
31
|
+
"vfonts": "0.0.3"
|
|
22
32
|
},
|
|
23
33
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
|
28
|
-
"@typescript-eslint/parser": "^4.0.0",
|
|
29
|
-
"babel-eslint": "^10.0.0",
|
|
30
|
-
"docz": "^2.3.1",
|
|
31
|
-
"eslint": "^7.25.0",
|
|
32
|
-
"eslint-config-airbnb": "^18.2.1",
|
|
33
|
-
"eslint-config-prettier": "^8.3.0",
|
|
34
|
-
"eslint-config-react-app": "^6.0.0",
|
|
35
|
-
"eslint-plugin-flowtype": "^5.2.0",
|
|
36
|
-
"eslint-plugin-import": "^2.22.0",
|
|
37
|
-
"eslint-plugin-jsx-a11y": "^6.3.1",
|
|
38
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
39
|
-
"eslint-plugin-react": "^7.20.3",
|
|
40
|
-
"eslint-plugin-react-hooks": "^4.0.8",
|
|
41
|
-
"gatsby-plugin-sass": "^4.4.0",
|
|
42
|
-
"gulp": "^4.0.2",
|
|
43
|
-
"gulp-autoprefixer": "^7.0.1",
|
|
44
|
-
"gulp-clean-css": "^4.3.0",
|
|
45
|
-
"gulp-cli": "^2.3.0",
|
|
46
|
-
"gulp-rename": "^2.0.0",
|
|
47
|
-
"gulp-sass": "^4.1.0",
|
|
48
|
-
"husky": "^6.0.0",
|
|
49
|
-
"lint-staged": "^10.5.4",
|
|
50
|
-
"node-sass": "^5.0.0",
|
|
51
|
-
"postcss": "^8.2.15",
|
|
52
|
-
"prettier": "^2.2.1",
|
|
53
|
-
"react": "^17.0.2",
|
|
54
|
-
"react-dom": "^17.0.2",
|
|
55
|
-
"rimraf": "^3.0.2",
|
|
56
|
-
"rollup": "^2.48.0",
|
|
57
|
-
"rollup-plugin-postcss": "^4.0.0",
|
|
58
|
-
"stylelint": "^13.13.1",
|
|
59
|
-
"stylelint-config-recess-order": "^2.4.0",
|
|
60
|
-
"stylelint-config-sass-guidelines": "^8.0.0",
|
|
61
|
-
"stylelint-config-standard": "^22.0.0"
|
|
62
|
-
},
|
|
63
|
-
"engines": {
|
|
64
|
-
"node": ">=14.16.1 <15"
|
|
34
|
+
"@laynezh/vite-plugin-lib-assets": "^0.5.24",
|
|
35
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
36
|
+
"vite": "^5.4.8"
|
|
65
37
|
},
|
|
38
|
+
"author": "avilang <1985945885@qq.com> (https://github.com/avilang)",
|
|
66
39
|
"license": "MIT"
|
|
67
40
|
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// 基于 https://github.com/cowboy/jquery-throttle-debounce/ 简单做了修改
|
|
3
|
+
// 接口文档和用法和原来库一致 连接 https://benalman.com/code/projects/jquery-throttle-debounce/docs/files/jquery-ba-throttle-debounce-js.html
|
|
4
|
+
|
|
5
|
+
// Since jQuery really isn't required for this plugin, use `jQuery` as the
|
|
6
|
+
// namespace only if it already exists, otherwise use the `Cowboy` namespace,
|
|
7
|
+
// creating it if necessary.
|
|
8
|
+
var _undefined = void(0);
|
|
9
|
+
var $ = {},
|
|
10
|
+
|
|
11
|
+
// Internal method reference.
|
|
12
|
+
jq_throttle;
|
|
13
|
+
|
|
14
|
+
// Method: jQuery.throttle
|
|
15
|
+
//
|
|
16
|
+
// Throttle execution of a function. Especially useful for rate limiting
|
|
17
|
+
// execution of handlers on events like resize and scroll. If you want to
|
|
18
|
+
// rate-limit execution of a function to a single time, see the
|
|
19
|
+
// <jQuery.debounce> method.
|
|
20
|
+
//
|
|
21
|
+
// In this visualization, | is a throttled-function call and X is the actual
|
|
22
|
+
// callback execution:
|
|
23
|
+
//
|
|
24
|
+
// > Throttled with `no_trailing` specified as false or unspecified:
|
|
25
|
+
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
|
|
26
|
+
// > X X X X X X X X X X X X
|
|
27
|
+
// >
|
|
28
|
+
// > Throttled with `no_trailing` specified as true:
|
|
29
|
+
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
|
|
30
|
+
// > X X X X X X X X X X
|
|
31
|
+
//
|
|
32
|
+
// Usage:
|
|
33
|
+
//
|
|
34
|
+
// > var throttled = jQuery.throttle( delay, [ no_trailing, ] callback );
|
|
35
|
+
// >
|
|
36
|
+
// > jQuery('selector').bind( 'someevent', throttled );
|
|
37
|
+
// > jQuery('selector').unbind( 'someevent', throttled );
|
|
38
|
+
//
|
|
39
|
+
// This also works in jQuery 1.4+:
|
|
40
|
+
//
|
|
41
|
+
// > jQuery('selector').bind( 'someevent', jQuery.throttle( delay, [ no_trailing, ] callback ) );
|
|
42
|
+
// > jQuery('selector').unbind( 'someevent', callback );
|
|
43
|
+
//
|
|
44
|
+
// Arguments:
|
|
45
|
+
//
|
|
46
|
+
// delay - (Number) A zero-or-greater delay in milliseconds. For event
|
|
47
|
+
// callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
48
|
+
// no_trailing - (Boolean) Optional, defaults to false. If no_trailing is
|
|
49
|
+
// true, callback will only execute every `delay` milliseconds while the
|
|
50
|
+
// throttled-function is being called. If no_trailing is false or
|
|
51
|
+
// unspecified, callback will be executed one final time after the last
|
|
52
|
+
// throttled-function call. (After the throttled-function has not been
|
|
53
|
+
// called for `delay` milliseconds, the internal counter is reset)
|
|
54
|
+
// callback - (Function) A function to be executed after delay milliseconds.
|
|
55
|
+
// The `this` context and all arguments are passed through, as-is, to
|
|
56
|
+
// `callback` when the throttled-function is executed.
|
|
57
|
+
//
|
|
58
|
+
// Returns:
|
|
59
|
+
//
|
|
60
|
+
// (Function) A new, throttled, function.
|
|
61
|
+
|
|
62
|
+
$.throttle = jq_throttle = function( delay, no_trailing, callback, debounce_mode ) {
|
|
63
|
+
// After wrapper has stopped being called, this timeout ensures that
|
|
64
|
+
// `callback` is executed at the proper times in `throttle` and `end`
|
|
65
|
+
// debounce modes.
|
|
66
|
+
var timeout_id,
|
|
67
|
+
|
|
68
|
+
// Keep track of the last time `callback` was executed.
|
|
69
|
+
last_exec = 0;
|
|
70
|
+
|
|
71
|
+
// `no_trailing` defaults to falsy.
|
|
72
|
+
if ( typeof no_trailing !== 'boolean' ) {
|
|
73
|
+
debounce_mode = callback;
|
|
74
|
+
callback = no_trailing;
|
|
75
|
+
no_trailing = _undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The `wrapper` function encapsulates all of the throttling / debouncing
|
|
79
|
+
// functionality and when executed will limit the rate at which `callback`
|
|
80
|
+
// is executed.
|
|
81
|
+
function wrapper() {
|
|
82
|
+
var that = this,
|
|
83
|
+
elapsed = +new Date() - last_exec,
|
|
84
|
+
args = arguments;
|
|
85
|
+
|
|
86
|
+
// Execute `callback` and update the `last_exec` timestamp.
|
|
87
|
+
function exec() {
|
|
88
|
+
last_exec = +new Date();
|
|
89
|
+
callback.apply( that, args );
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// If `debounce_mode` is true (at_begin) this is used to clear the flag
|
|
93
|
+
// to allow future `callback` executions.
|
|
94
|
+
function clear() {
|
|
95
|
+
timeout_id = _undefined;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if ( debounce_mode && !timeout_id ) {
|
|
99
|
+
// Since `wrapper` is being called for the first time and
|
|
100
|
+
// `debounce_mode` is true (at_begin), execute `callback`.
|
|
101
|
+
exec();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Clear any existing timeout.
|
|
105
|
+
timeout_id && clearTimeout( timeout_id );
|
|
106
|
+
|
|
107
|
+
if ( debounce_mode === _undefined && elapsed > delay ) {
|
|
108
|
+
// In throttle mode, if `delay` time has been exceeded, execute
|
|
109
|
+
// `callback`.
|
|
110
|
+
exec();
|
|
111
|
+
|
|
112
|
+
} else if ( no_trailing !== true ) {
|
|
113
|
+
// In trailing throttle mode, since `delay` time has not been
|
|
114
|
+
// exceeded, schedule `callback` to execute `delay` ms after most
|
|
115
|
+
// recent execution.
|
|
116
|
+
//
|
|
117
|
+
// If `debounce_mode` is true (at_begin), schedule `clear` to execute
|
|
118
|
+
// after `delay` ms.
|
|
119
|
+
//
|
|
120
|
+
// If `debounce_mode` is false (at end), schedule `callback` to
|
|
121
|
+
// execute after `delay` ms.
|
|
122
|
+
timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === _undefined ? delay - elapsed : delay );
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// Set the guid of `wrapper` function to the same of original callback, so
|
|
127
|
+
// it can be removed in jQuery 1.4+ .unbind or .die by using the original
|
|
128
|
+
// callback as a reference.
|
|
129
|
+
if ( $.guid ) {
|
|
130
|
+
wrapper.guid = callback.guid = callback.guid || $.guid++;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Return the wrapper function.
|
|
134
|
+
return wrapper;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Method: jQuery.debounce
|
|
138
|
+
//
|
|
139
|
+
// Debounce execution of a function. Debouncing, unlike throttling,
|
|
140
|
+
// guarantees that a function is only executed a single time, either at the
|
|
141
|
+
// very beginning of a series of calls, or at the very end. If you want to
|
|
142
|
+
// simply rate-limit execution of a function, see the <jQuery.throttle>
|
|
143
|
+
// method.
|
|
144
|
+
//
|
|
145
|
+
// In this visualization, | is a debounced-function call and X is the actual
|
|
146
|
+
// callback execution:
|
|
147
|
+
//
|
|
148
|
+
// > Debounced with `at_begin` specified as false or unspecified:
|
|
149
|
+
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
|
|
150
|
+
// > X X
|
|
151
|
+
// >
|
|
152
|
+
// > Debounced with `at_begin` specified as true:
|
|
153
|
+
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
|
|
154
|
+
// > X X
|
|
155
|
+
//
|
|
156
|
+
// Usage:
|
|
157
|
+
//
|
|
158
|
+
// > var debounced = jQuery.debounce( delay, [ at_begin, ] callback );
|
|
159
|
+
// >
|
|
160
|
+
// > jQuery('selector').bind( 'someevent', debounced );
|
|
161
|
+
// > jQuery('selector').unbind( 'someevent', debounced );
|
|
162
|
+
//
|
|
163
|
+
// This also works in jQuery 1.4+:
|
|
164
|
+
//
|
|
165
|
+
// > jQuery('selector').bind( 'someevent', jQuery.debounce( delay, [ at_begin, ] callback ) );
|
|
166
|
+
// > jQuery('selector').unbind( 'someevent', callback );
|
|
167
|
+
//
|
|
168
|
+
// Arguments:
|
|
169
|
+
//
|
|
170
|
+
// delay - (Number) A zero-or-greater delay in milliseconds. For event
|
|
171
|
+
// callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
172
|
+
// at_begin - (Boolean) Optional, defaults to false. If at_begin is false or
|
|
173
|
+
// unspecified, callback will only be executed `delay` milliseconds after
|
|
174
|
+
// the last debounced-function call. If at_begin is true, callback will be
|
|
175
|
+
// executed only at the first debounced-function call. (After the
|
|
176
|
+
// throttled-function has not been called for `delay` milliseconds, the
|
|
177
|
+
// internal counter is reset)
|
|
178
|
+
// callback - (Function) A function to be executed after delay milliseconds.
|
|
179
|
+
// The `this` context and all arguments are passed through, as-is, to
|
|
180
|
+
// `callback` when the debounced-function is executed.
|
|
181
|
+
//
|
|
182
|
+
// Returns:
|
|
183
|
+
//
|
|
184
|
+
// (Function) A new, debounced, function.
|
|
185
|
+
|
|
186
|
+
$.debounce = function( delay, at_begin, callback ) {
|
|
187
|
+
return callback === _undefined
|
|
188
|
+
? jq_throttle( delay, at_begin, false )
|
|
189
|
+
: jq_throttle( delay, callback, at_begin !== false );
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const debounce = function(callback, delay, at_begin) {
|
|
193
|
+
return $.debounce(delay || 300, at_begin == null ? true : at_begin, callback);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const throttle = function(callback, delay, no_trailing) {
|
|
197
|
+
return $.throttle(delay || 300, no_trailing == null ? false : no_trailing, callback);
|
|
198
|
+
}
|
package/utility/util.js
ADDED
package/vite.config.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
import vue from '@vitejs/plugin-vue'
|
|
5
|
+
import libAssets from '@laynezh/vite-plugin-lib-assets'
|
|
6
|
+
|
|
7
|
+
// READING https://github.com/vitejs/vite/issues/3295
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
vue(),
|
|
11
|
+
libAssets({
|
|
12
|
+
include: /\.woff2(\?.*)?$/,
|
|
13
|
+
name: '[name].[ext]'
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
build: {
|
|
17
|
+
assetsInlineLimit: 0,
|
|
18
|
+
cssCodeSplit: false,
|
|
19
|
+
lib: {
|
|
20
|
+
entry: resolve(__dirname, 'index.js'),
|
|
21
|
+
formats: ['es'],
|
|
22
|
+
fileName: 'index'
|
|
23
|
+
},
|
|
24
|
+
rollupOptions: {
|
|
25
|
+
external: ['vue']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
})
|
package/.browserslistrc
DELETED
package/.editorconfig
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
charset = utf-8
|
|
5
|
-
indent_style = space
|
|
6
|
-
indent_size = 2
|
|
7
|
-
end_of_line = lf
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
|
|
11
|
-
[*.md]
|
|
12
|
-
trim_trailing_whitespace = false
|
|
13
|
-
|
|
14
|
-
[*.html]
|
|
15
|
-
insert_final_newline = false
|
package/.eslintrc
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"react-app",
|
|
4
|
-
"airbnb",
|
|
5
|
-
"airbnb/hooks",
|
|
6
|
-
"plugin:jsx-a11y/recommended",
|
|
7
|
-
"plugin:prettier/recommended"
|
|
8
|
-
],
|
|
9
|
-
"plugins": ["jsx-a11y"],
|
|
10
|
-
"rules": {
|
|
11
|
-
"func-names": ["error", "never"],
|
|
12
|
-
"prefer-destructuring": "off",
|
|
13
|
-
"no-unused-expressions": "off",
|
|
14
|
-
"no-useless-return": "off",
|
|
15
|
-
"consistent-return": "off",
|
|
16
|
-
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
|
|
17
|
-
"import/prefer-default-export": "off",
|
|
18
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
19
|
-
"react/jsx-props-no-spreading": "off",
|
|
20
|
-
"react/forbid-prop-types": "off",
|
|
21
|
-
"react/prop-types": ["error", { "ignore": ["children"] }],
|
|
22
|
-
"react/require-default-props": "off",
|
|
23
|
-
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
|
|
24
|
-
}
|
|
25
|
-
}
|
package/.gitattributes
DELETED