@authing/vue-ui-components 3.1.1 → 3.1.6
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/components/AuthingGuard/index.js +8 -0
- package/{src/components/AuthingGuard.vue → components/AuthingGuard/src/index.vue} +23 -17
- package/components/Guard/index.js +8 -0
- package/components/Guard/src/index.vue +156 -0
- package/components/index.js +25 -0
- package/lib/index.min.css +1 -1
- package/lib/index.min.js +474 -1
- package/package.json +59 -43
- package/.eslintignore +0 -2
- package/LICENSE +0 -21
- package/configs/rollup.config.base.js +0 -78
- package/configs/rollup.config.browser.js +0 -15
- package/configs/rollup.config.es.js +0 -16
- package/configs/rollup.config.umd.js +0 -15
- package/src/components/index.d.ts +0 -0
- package/src/components/index.js +0 -21
- package/src/icons.js +0 -18
- package/src/index.js +0 -79
- package/src/mixins/CoupledChild.js +0 -49
- package/src/mixins/CoupledParent.js +0 -172
- package/src/mixins/DisableScroll.js +0 -25
- package/src/mixins/DisabledChild.js +0 -25
- package/src/mixins/DisabledParent.js +0 -35
- package/vue.config.js +0 -36
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authing/vue-ui-components",
|
|
3
3
|
"description": "Authing Vue UI components",
|
|
4
|
-
"
|
|
4
|
+
"files": [
|
|
5
|
+
"lib",
|
|
6
|
+
"components"
|
|
7
|
+
],
|
|
8
|
+
"version": "3.1.6",
|
|
5
9
|
"keywords": [
|
|
6
10
|
"vue",
|
|
7
11
|
"vuejs",
|
|
@@ -10,12 +14,13 @@
|
|
|
10
14
|
"license": "MIT",
|
|
11
15
|
"main": "src/components/index.js",
|
|
12
16
|
"scripts": {
|
|
17
|
+
"clean": "rimraf ./lib",
|
|
13
18
|
"demo:serve": "vue-cli-service serve",
|
|
14
19
|
"demo:build": "vue-cli-service build",
|
|
15
20
|
"demo:lint": "vue-cli-service lint",
|
|
16
21
|
"lint": "eslint --ext .js,.vue src/",
|
|
17
22
|
"dev": "nodemon --exec 'npm run build:es' --watch src -e js,vue,styl",
|
|
18
|
-
"build:lib": "
|
|
23
|
+
"build:lib": "npm run clean && rollup -c config/rollup.config.js --environment NODE_ENV:production",
|
|
19
24
|
"build:browser": "rollup --config configs/rollup.config.browser.js",
|
|
20
25
|
"build:es": "rollup --config configs/rollup.config.es.js",
|
|
21
26
|
"build:umd": "rollup --config configs/rollup.config.umd.js"
|
|
@@ -24,50 +29,62 @@
|
|
|
24
29
|
"type": "git",
|
|
25
30
|
"url": ""
|
|
26
31
|
},
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": ""
|
|
29
|
-
},
|
|
30
32
|
"homepage": "",
|
|
31
33
|
"publishConfig": {
|
|
32
34
|
"access": "public",
|
|
33
35
|
"registry": "https://registry.npmjs.org"
|
|
34
36
|
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@authing/native-js-ui-components": "^3.1.1"
|
|
37
|
-
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@babel/
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
38
|
+
"@authing/native-js-ui-components": "^3.1.6",
|
|
39
|
+
"@babel/core": "^7.0.0",
|
|
40
|
+
"@rollup/plugin-alias": "^3.1.8",
|
|
41
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
42
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
43
|
+
"@rollup/plugin-image": "^2.1.1",
|
|
44
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
46
|
+
"@types/html-minifier": "^4.0.1",
|
|
47
|
+
"@types/jest": "^26.0.23",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
49
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
50
|
+
"@vue/babel-preset-jsx": "^1.2.4",
|
|
51
|
+
"@vue/compiler-sfc": "^3.2.20",
|
|
52
|
+
"@vue/test-utils": "^2.0.0-rc.6",
|
|
53
|
+
"autoprefixer": "^9.8.8",
|
|
54
|
+
"babel-jest": "^26.x",
|
|
55
|
+
"clean-css": "^5.2.4",
|
|
56
|
+
"esbuild": "^0.12.5",
|
|
57
|
+
"eslint": "^7.32.0",
|
|
58
|
+
"eslint-plugin-vue": "^7.20.0",
|
|
59
|
+
"jest": "26.6.3",
|
|
60
|
+
"jest-serializer-vue": "^2.0.2",
|
|
61
|
+
"jest-transform-stub": "^2.0.0",
|
|
62
|
+
"node-sass": "^6.0.1",
|
|
63
|
+
"postcss": "^8.3.11",
|
|
64
|
+
"postcss-import": "^14.0.2",
|
|
65
|
+
"postcss-minify": "^1.1.0",
|
|
66
|
+
"postcss-preset-env": "^6.7.0",
|
|
67
|
+
"pre-commit": "^1.2.2",
|
|
68
|
+
"rimraf": "^3.0.2",
|
|
69
|
+
"rollup": "^2.59.0",
|
|
70
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
71
|
+
"rollup-plugin-browsersync": "^1.3.3",
|
|
72
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
73
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
74
|
+
"rollup-plugin-css-only": "^3.1.0",
|
|
75
|
+
"rollup-plugin-esbuild": "^4.6.0",
|
|
76
|
+
"rollup-plugin-filesize": "^9.1.1",
|
|
77
|
+
"rollup-plugin-html2": "^3.1.0",
|
|
78
|
+
"rollup-plugin-polyfill-node": "^0.7.0",
|
|
79
|
+
"rollup-plugin-postcss": "^4.0.1",
|
|
80
|
+
"rollup-plugin-progress": "^1.1.2",
|
|
81
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
82
|
+
"rollup-plugin-scss": "3",
|
|
83
|
+
"rollup-plugin-vue": "^6.0.0",
|
|
84
|
+
"ts-jest": "26.5.6",
|
|
85
|
+
"typescript": "^4.4.4",
|
|
86
|
+
"vue": "^3.2.20",
|
|
87
|
+
"vue-jest": "^5.0.0-alpha.10"
|
|
71
88
|
},
|
|
72
89
|
"peerDependencies": {
|
|
73
90
|
"vue": "^2.5.13"
|
|
@@ -78,6 +95,5 @@
|
|
|
78
95
|
"browserslist": [
|
|
79
96
|
"> 10%",
|
|
80
97
|
"last 2 versions"
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
}
|
|
98
|
+
]
|
|
99
|
+
}
|
package/.eslintignore
DELETED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Authing
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import babel from 'rollup-plugin-babel'
|
|
2
|
-
import resolve from 'rollup-plugin-node-resolve'
|
|
3
|
-
import vue from 'rollup-plugin-vue'
|
|
4
|
-
import cjs from 'rollup-plugin-commonjs'
|
|
5
|
-
import replace from 'rollup-plugin-replace'
|
|
6
|
-
import requireContext from 'rollup-plugin-require-context'
|
|
7
|
-
import { string } from 'rollup-plugin-string'
|
|
8
|
-
import fs from 'fs'
|
|
9
|
-
import CleanCSS from 'clean-css'
|
|
10
|
-
import autoprefixer from 'autoprefixer'
|
|
11
|
-
import css from 'rollup-plugin-css-only'
|
|
12
|
-
const postcss = require('rollup-plugin-postcss')
|
|
13
|
-
|
|
14
|
-
const config = require('../package.json')
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
input: 'src/components/index.js',
|
|
18
|
-
plugins: [
|
|
19
|
-
resolve({
|
|
20
|
-
jsnext: true,
|
|
21
|
-
main: true,
|
|
22
|
-
browser: true,
|
|
23
|
-
}),
|
|
24
|
-
string({
|
|
25
|
-
include: '**/*.svg',
|
|
26
|
-
}),
|
|
27
|
-
vue({
|
|
28
|
-
css: false,
|
|
29
|
-
style: {
|
|
30
|
-
postcssPlugins: [autoprefixer],
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
postcss({
|
|
34
|
-
extract: true,
|
|
35
|
-
}),
|
|
36
|
-
css({
|
|
37
|
-
output: (styles) => {
|
|
38
|
-
fs.writeFileSync(
|
|
39
|
-
'lib/index.min.css',
|
|
40
|
-
new CleanCSS().minify(styles).styles
|
|
41
|
-
)
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
babel({
|
|
45
|
-
exclude: 'node_modules/**',
|
|
46
|
-
runtimeHelpers: true,
|
|
47
|
-
}),
|
|
48
|
-
cjs({
|
|
49
|
-
namedExports: {
|
|
50
|
-
'@authing/native-js-ui-components': [
|
|
51
|
-
'AuthingGuard',
|
|
52
|
-
'GuardEventsCamelToKebabMap',
|
|
53
|
-
'GuardMode',
|
|
54
|
-
'GuardScenes',
|
|
55
|
-
'LoginMethods',
|
|
56
|
-
'RegisterMethods',
|
|
57
|
-
],
|
|
58
|
-
'../native-js/lib/index.min.js': [
|
|
59
|
-
'AuthingGuard',
|
|
60
|
-
'GuardEventsCamelToKebabMap',
|
|
61
|
-
'GuardMode',
|
|
62
|
-
'GuardScenes',
|
|
63
|
-
'LoginMethods',
|
|
64
|
-
'RegisterMethods',
|
|
65
|
-
'getAuthClient',
|
|
66
|
-
'initAuthClient',
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
}),
|
|
70
|
-
requireContext(),
|
|
71
|
-
// replace({
|
|
72
|
-
// VERSION: JSON.stringify(config.version),
|
|
73
|
-
// }),
|
|
74
|
-
],
|
|
75
|
-
watch: {
|
|
76
|
-
include: 'src/**',
|
|
77
|
-
},
|
|
78
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import base from './rollup.config.base'
|
|
2
|
-
import { terser } from 'rollup-plugin-terser'
|
|
3
|
-
|
|
4
|
-
const config = Object.assign({}, base, {
|
|
5
|
-
output: {
|
|
6
|
-
exports: 'named',
|
|
7
|
-
name: 'VueUi',
|
|
8
|
-
file: 'dist/vue-ui.min.js',
|
|
9
|
-
format: 'iife',
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
config.plugins.push(terser())
|
|
14
|
-
|
|
15
|
-
export default config
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import base from './rollup.config.base'
|
|
2
|
-
|
|
3
|
-
const config = Object.assign({}, base, {
|
|
4
|
-
output: {
|
|
5
|
-
name: 'vue-ui',
|
|
6
|
-
file: 'dist/vue-ui.esm.js',
|
|
7
|
-
format: 'es',
|
|
8
|
-
},
|
|
9
|
-
external: [
|
|
10
|
-
'focus-visible',
|
|
11
|
-
'v-tooltip',
|
|
12
|
-
'vue-resize',
|
|
13
|
-
],
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export default config
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import base from './rollup.config.base'
|
|
2
|
-
import { terser } from 'rollup-plugin-terser'
|
|
3
|
-
|
|
4
|
-
const config = Object.assign({}, base, {
|
|
5
|
-
output: {
|
|
6
|
-
exports: 'named',
|
|
7
|
-
name: 'AuthingVueUIComponents',
|
|
8
|
-
file: 'lib/index.min.js',
|
|
9
|
-
format: 'umd',
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
config.plugins.push(terser())
|
|
14
|
-
|
|
15
|
-
export default config
|
|
File without changes
|
package/src/components/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import AuthingGuard from './AuthingGuard.vue'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
getAuthClient,
|
|
5
|
-
initAuthClient,
|
|
6
|
-
GuardMode,
|
|
7
|
-
GuardScenes,
|
|
8
|
-
LoginMethods,
|
|
9
|
-
RegisterMethods,
|
|
10
|
-
} from "@authing/native-js-ui-components";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
AuthingGuard,
|
|
15
|
-
getAuthClient,
|
|
16
|
-
initAuthClient,
|
|
17
|
-
GuardMode,
|
|
18
|
-
GuardScenes,
|
|
19
|
-
LoginMethods,
|
|
20
|
-
RegisterMethods
|
|
21
|
-
}
|
package/src/icons.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const icons = require.context('../node_modules/material-design-icons/sprites/svg-sprite', true, /svg-sprite-(\w+)-symbol\.svg$/)
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
install (Vue) {
|
|
5
|
-
const iconsWrapper = document.createElement('div')
|
|
6
|
-
iconsWrapper.style.display = 'none'
|
|
7
|
-
// Load all the SVG symbols
|
|
8
|
-
icons.keys().forEach(key => {
|
|
9
|
-
const result = icons(key)
|
|
10
|
-
iconsWrapper.innerHTML += result
|
|
11
|
-
})
|
|
12
|
-
document.body.insertBefore(iconsWrapper, document.body.firstChild)
|
|
13
|
-
},
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function generateHtmlIcon (icon) {
|
|
17
|
-
return `<div class="vue-ui-icon"><svg><use xlink:href="#ic_${icon}_24px"></use></svg></div>`
|
|
18
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import VueIcons from './icons'
|
|
2
|
-
import VTooltip from 'v-tooltip'
|
|
3
|
-
import VueResize from 'vue-resize'
|
|
4
|
-
import 'focus-visible'
|
|
5
|
-
|
|
6
|
-
import 'vue-resize/dist/vue-resize.css'
|
|
7
|
-
import 'v-tooltip/dist/v-tooltip.css'
|
|
8
|
-
|
|
9
|
-
// Exported mixins
|
|
10
|
-
export { default as CoupledChild } from './mixins/CoupledChild'
|
|
11
|
-
export { default as CoupledParent } from './mixins/CoupledParent'
|
|
12
|
-
export { default as DisabledChild } from './mixins/DisabledChild'
|
|
13
|
-
export { default as DisableScroll } from './mixins/DisableScroll'
|
|
14
|
-
|
|
15
|
-
// Exported utils
|
|
16
|
-
export { generateHtmlIcon } from './icons'
|
|
17
|
-
|
|
18
|
-
// Require all the components that start with 'BaseXXX.vue'
|
|
19
|
-
const components = require.context('./components', true, /[a-z0-9]+\.vue$/)
|
|
20
|
-
|
|
21
|
-
export function install (Vue, options = {}) {
|
|
22
|
-
Vue.use(VueIcons)
|
|
23
|
-
|
|
24
|
-
Vue.use(VTooltip, mergeOptions({
|
|
25
|
-
boundariesElement: document.body,
|
|
26
|
-
themes: {
|
|
27
|
-
tooltip: {
|
|
28
|
-
delay: {
|
|
29
|
-
show: 1000,
|
|
30
|
-
hide: 800,
|
|
31
|
-
},
|
|
32
|
-
instantMove: true,
|
|
33
|
-
},
|
|
34
|
-
dropdown: {
|
|
35
|
-
handleResize: false,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}, options.vtooltip))
|
|
39
|
-
|
|
40
|
-
Vue.use(VueResize)
|
|
41
|
-
|
|
42
|
-
// To extract the component name
|
|
43
|
-
const nameReg = /([a-z0-9]+)\./i
|
|
44
|
-
// Registration
|
|
45
|
-
components.keys().forEach(key => {
|
|
46
|
-
const name = key.match(nameReg)[1]
|
|
47
|
-
Vue.component(name, components(key))
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const plugin = {
|
|
52
|
-
// eslint-disable-next-line no-undef
|
|
53
|
-
version: VERSION,
|
|
54
|
-
install,
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default plugin
|
|
58
|
-
|
|
59
|
-
function mergeOptions (to, from) {
|
|
60
|
-
for (const key in from) {
|
|
61
|
-
if (to[key] && from[key] && typeof to[key] === 'object' && typeof from[key] === 'object') {
|
|
62
|
-
mergeOptions(to[key], from[key])
|
|
63
|
-
} else {
|
|
64
|
-
to[key] = from[key]
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return to
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Auto-install
|
|
71
|
-
let GlobalVue = null
|
|
72
|
-
if (typeof window !== 'undefined') {
|
|
73
|
-
GlobalVue = window.Vue
|
|
74
|
-
} else if (typeof global !== 'undefined') {
|
|
75
|
-
GlobalVue = global.Vue
|
|
76
|
-
}
|
|
77
|
-
if (GlobalVue) {
|
|
78
|
-
GlobalVue.use(plugin)
|
|
79
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* (Use with the CoupleParent mixin)
|
|
3
|
-
* This mixin should be used on children components of a component implementing the CoupledParent mixin.
|
|
4
|
-
* @param {string} name Name of the injection
|
|
5
|
-
*/
|
|
6
|
-
export default function (name) {
|
|
7
|
-
// @vue/component
|
|
8
|
-
return {
|
|
9
|
-
inject: [
|
|
10
|
-
name,
|
|
11
|
-
],
|
|
12
|
-
|
|
13
|
-
computed: {
|
|
14
|
-
active () {
|
|
15
|
-
return this[name].activeChild === this.$_couplingProxy
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
created () {
|
|
20
|
-
const proxy = this.$_couplingProxy = {}
|
|
21
|
-
for (const key in this.$data) {
|
|
22
|
-
if (key.charAt(0) === '$' || key.charAt(0) === '_') continue
|
|
23
|
-
Object.defineProperty(proxy, key, {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: false,
|
|
26
|
-
get: () => this.$data[key],
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
for (const key in this.$props) {
|
|
30
|
-
if (key.charAt(0) === '$' || key.charAt(0) === '_') continue
|
|
31
|
-
Object.defineProperty(proxy, key, {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: false,
|
|
34
|
-
get: () => this.$props[key],
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
Object.defineProperty(proxy, '$slots', {
|
|
38
|
-
enumerable: false,
|
|
39
|
-
configurable: false,
|
|
40
|
-
get: () => this.$slots,
|
|
41
|
-
})
|
|
42
|
-
this[name].$_addCoupledChild(proxy)
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
beforeDestroy () {
|
|
46
|
-
this[name].$_removeCoupledChild(this.$_couplingProxy)
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* (Use with the CoupledChild mixin)
|
|
3
|
-
* Mixin allowing the automatic collection of children while preserving the virtual dom children order at all times.
|
|
4
|
-
* Useful for creating tabs-style component, when we need to replicate the order of the children to display
|
|
5
|
-
* a group of button (tab strip).
|
|
6
|
-
* @param {string} name Name of the injection
|
|
7
|
-
*/
|
|
8
|
-
export default function (name) {
|
|
9
|
-
// @vue/component
|
|
10
|
-
return {
|
|
11
|
-
provide () {
|
|
12
|
-
const proxy = {}
|
|
13
|
-
Object.defineProperty(proxy, 'activeChild', {
|
|
14
|
-
get: () => this.activeChild,
|
|
15
|
-
})
|
|
16
|
-
proxy.$_addCoupledChild = this.$_addCoupledChild.bind(this)
|
|
17
|
-
proxy.$_removeCoupledChild = this.$_removeCoupledChild.bind(this)
|
|
18
|
-
return {
|
|
19
|
-
[name]: proxy,
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
props: {
|
|
24
|
-
childIndex: {
|
|
25
|
-
default: 0,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
data () {
|
|
30
|
-
return {
|
|
31
|
-
children: [],
|
|
32
|
-
activeChildIndex: parseInt(this.childIndex) || 0,
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
computed: {
|
|
37
|
-
activeChild () {
|
|
38
|
-
if (this.activeChildIndex < this.children.length) {
|
|
39
|
-
return this.children[this.activeChildIndex]
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
watch: {
|
|
45
|
-
childIndex (val) {
|
|
46
|
-
this.activateChild(parseInt(val) || 0, true)
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
methods: {
|
|
51
|
-
/**
|
|
52
|
-
* Activates a child.
|
|
53
|
-
* @param {number} index Index of child to activate
|
|
54
|
-
* @param {boolean} external Indicates if the activation comes from an external source (like props)
|
|
55
|
-
*/
|
|
56
|
-
activateChild (index, external = false) {
|
|
57
|
-
const oldIndex = this.activeChildIndex
|
|
58
|
-
if (index < 0) {
|
|
59
|
-
index = 0
|
|
60
|
-
} else if (index >= this.children.length) {
|
|
61
|
-
index = this.children.length - 1
|
|
62
|
-
}
|
|
63
|
-
this.activeChildIndex = index
|
|
64
|
-
this.$emit('update:childIndex', index)
|
|
65
|
-
this.childActivated(index, oldIndex, external)
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Hook called when a child is activated.
|
|
70
|
-
* @param {number} index Index of the activated child
|
|
71
|
-
* @param {number} oldIndex Index of the previously activated child
|
|
72
|
-
* @param {boolean} external Indicates if the activation comes from an external source (like props)
|
|
73
|
-
*/
|
|
74
|
-
childActivated (index, oldIndex, external) {
|
|
75
|
-
// Override this in component
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Add a child component while preserving its order in the children list.
|
|
80
|
-
* @param {object} proxyVm Vue instance
|
|
81
|
-
*/
|
|
82
|
-
$_addCoupledChild (proxyVm) {
|
|
83
|
-
// Guard
|
|
84
|
-
if (this.$slots && this.$slots.default) {
|
|
85
|
-
// We need to wait for the instances creation
|
|
86
|
-
this.$nextTick(() => {
|
|
87
|
-
// We need to get the components in the slot
|
|
88
|
-
const childComponents = this.$slots.default.reduce((list, vnode) => {
|
|
89
|
-
const coupledChild = findCoupledChild(vnode)
|
|
90
|
-
if (coupledChild) {
|
|
91
|
-
list.push(coupledChild.$_couplingProxy)
|
|
92
|
-
}
|
|
93
|
-
return list
|
|
94
|
-
}, [])
|
|
95
|
-
// List has the child component in the right order
|
|
96
|
-
// We can now register the child component in the right place
|
|
97
|
-
const index = childComponents.indexOf(proxyVm)
|
|
98
|
-
// Add child
|
|
99
|
-
if (index !== -1) {
|
|
100
|
-
this.children.splice(index, 0, proxyVm)
|
|
101
|
-
// Hook
|
|
102
|
-
this.$_updateChildren('add', index, proxyVm)
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Removes a child component. Automatically activates the next remaining component.
|
|
110
|
-
* @param {object} proxyVm Vue instance
|
|
111
|
-
*/
|
|
112
|
-
$_removeCoupledChild (proxyVm) {
|
|
113
|
-
const index = this.children.indexOf(proxyVm)
|
|
114
|
-
// Remove child
|
|
115
|
-
if (index !== -1) {
|
|
116
|
-
this.children.splice(index, 1)
|
|
117
|
-
}
|
|
118
|
-
// Hook
|
|
119
|
-
this.$_updateChildren('remove', index, proxyVm)
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Hook called when an operation is processed. It will intelligently activate a child if needed.
|
|
124
|
-
* @param {string} operation Name of the operation. Can be 'add' or 'remove'
|
|
125
|
-
* @param {number} index Index of the related child.
|
|
126
|
-
* @param {object} proxyVm Related child Vue instance
|
|
127
|
-
*/
|
|
128
|
-
$_updateChildren (operation, index, proxyVm) {
|
|
129
|
-
if (operation === 'add') {
|
|
130
|
-
// If the child was added before the currently active one,
|
|
131
|
-
// we need to move the selection to the right
|
|
132
|
-
if (index <= this.activeChildIndex) {
|
|
133
|
-
this.activateChild(this.activeChildIndex + 1)
|
|
134
|
-
}
|
|
135
|
-
// Default when there is only one child
|
|
136
|
-
if (this.children.length === 1) {
|
|
137
|
-
this.activateChild(0)
|
|
138
|
-
}
|
|
139
|
-
} else if (operation === 'remove') {
|
|
140
|
-
// If we remove a child before the currently active one,
|
|
141
|
-
// we need to move the selection to the left
|
|
142
|
-
if (index <= this.activeChildIndex) {
|
|
143
|
-
this.activateChild(this.activeChildIndex - 1)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function findCoupledChild (vnode) {
|
|
152
|
-
const vm = vnode.child
|
|
153
|
-
if (vm) {
|
|
154
|
-
if (vm.$_couplingProxy) {
|
|
155
|
-
return vm
|
|
156
|
-
} else {
|
|
157
|
-
return findCoupledChildInChildren([...vm.$children])
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Breadth-first search
|
|
163
|
-
function findCoupledChildInChildren (queue) {
|
|
164
|
-
let child
|
|
165
|
-
while ((child = queue.shift())) {
|
|
166
|
-
if (child.$_couplingProxy) {
|
|
167
|
-
return child
|
|
168
|
-
} else {
|
|
169
|
-
queue.push(...child.$children)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
let count = 0
|
|
2
|
-
|
|
3
|
-
function getScrollingElements () {
|
|
4
|
-
return document.querySelectorAll('.vue-ui-disable-scroll, body')
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function updateScroll () {
|
|
8
|
-
if (count === 0) {
|
|
9
|
-
getScrollingElements().forEach(el => el.classList.remove('vue-ui-no-scroll'))
|
|
10
|
-
} else if (count === 1) {
|
|
11
|
-
getScrollingElements().forEach(el => el.classList.add('vue-ui-no-scroll'))
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
mounted () {
|
|
17
|
-
count++
|
|
18
|
-
updateScroll()
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
beforeDestroy () {
|
|
22
|
-
count--
|
|
23
|
-
updateScroll()
|
|
24
|
-
},
|
|
25
|
-
}
|