goodteditor-ui 1.0.1 → 1.0.5
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/index.js +4 -0
- package/package.json +11 -6
- package/src/components/ui/Datalist.vue +1 -1
- package/src/components/ui/FileSelector.md +105 -0
- package/src/components/ui/FileSelector.vue +78 -0
- package/src/components/ui/Grid.md +130 -0
- package/src/components/ui/Grid.vue +92 -0
- package/src/components/ui/Image.md +59 -0
- package/src/components/ui/Image.vue +57 -0
- package/src/components/ui/InputTags.vue +9 -1
- package/src/components/ui/InputUnits.vue +5 -5
- package/src/components/ui/Popover.vue +17 -11
- package/src/components/ui/Select.md +53 -0
- package/src/components/ui/Select.vue +2 -14
- package/styleguide.config.js +7 -1
- package/public/index.html +0 -29
package/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import Collapse from './src/components/ui/Collapse.vue';
|
|
|
3
3
|
import ColorPicker from './src/components/ui/ColorPicker.vue';
|
|
4
4
|
import Datalist from './src/components/ui/Datalist.vue';
|
|
5
5
|
import DatePicker from './src/components/ui/DatePicker.vue';
|
|
6
|
+
import FileSelector from './src/components/ui/FileSelector.vue';
|
|
7
|
+
import Image from './src/components/ui/Image.vue';
|
|
6
8
|
import InputAutocomplete from './src/components/ui/InputAutocomplete.vue';
|
|
7
9
|
import InputColorPicker from './src/components/ui/InputColorPicker.vue';
|
|
8
10
|
import InputDatePicker from './src/components/ui/InputDatePicker.vue';
|
|
@@ -23,6 +25,8 @@ export {
|
|
|
23
25
|
ColorPicker,
|
|
24
26
|
Datalist,
|
|
25
27
|
DatePicker,
|
|
28
|
+
FileSelector,
|
|
29
|
+
Image,
|
|
26
30
|
InputAutocomplete,
|
|
27
31
|
InputColorPicker,
|
|
28
32
|
InputDatePicker,
|
package/package.json
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goodteditor-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "index.js",
|
|
5
|
+
"homepage": "https://goodt-ui.netlify.app/",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"serve": "vue-cli-service serve",
|
|
7
8
|
"build": "vue-cli-service build",
|
|
8
9
|
"lint": "vue-cli-service lint",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"deploy
|
|
10
|
+
"dev": "vue-styleguidist server",
|
|
11
|
+
"docs:build": "set NODE_ENV=development && vue-styleguidist build",
|
|
12
|
+
"docs:deploy": "npx netlify deploy --dir=docs --prod",
|
|
13
|
+
"notify": "node ./ci/teams-notify.js",
|
|
14
|
+
"publish": "npm publish && npm run docs:build && npm run docs:deploy && npm run notify"
|
|
12
15
|
},
|
|
13
16
|
"devDependencies": {
|
|
17
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
14
18
|
"@vue/cli-plugin-babel": "^4.5.11",
|
|
15
19
|
"@vue/cli-plugin-eslint": "^4.5.11",
|
|
16
20
|
"@vue/cli-service": "^4.5.11",
|
|
21
|
+
"axios": "^0.24.0",
|
|
17
22
|
"babel-eslint": "^10.1.0",
|
|
18
23
|
"eslint": "^6.7.2",
|
|
19
24
|
"eslint-plugin-vue": "^6.2.2",
|
|
20
25
|
"goodt-framework-css": "^1.1.1",
|
|
21
26
|
"less": "^3.13.1",
|
|
22
27
|
"less-loader": "^5.0.0",
|
|
28
|
+
"netlify-cli": "^5.0.1",
|
|
23
29
|
"vue-styleguidist": "4.35.0",
|
|
24
|
-
"vue-template-compiler": "^2.6.12"
|
|
25
|
-
"netlify-cli": "^5.0.1"
|
|
30
|
+
"vue-template-compiler": "^2.6.12"
|
|
26
31
|
},
|
|
27
32
|
"peerDependencies": {
|
|
28
33
|
"vue": "^2.6.12"
|
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
e.preventDefault();
|
|
140
140
|
this.setCursorIndex(this.cursorIndex + 1);
|
|
141
141
|
}
|
|
142
|
-
} else if (e.key === Key.ENTER) {
|
|
142
|
+
} else if (e.key === Key.ENTER && this.options.length) {
|
|
143
143
|
e.preventDefault();
|
|
144
144
|
let option = this.options[this.cursorIndex];
|
|
145
145
|
if (!option) {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
```vue
|
|
2
|
+
<template>
|
|
3
|
+
<div class="pad-l5">
|
|
4
|
+
<ui-file-selector v-bind="props" @change="onFileSelect">
|
|
5
|
+
<div class="btn btn-primary btn-small">select file</div>
|
|
6
|
+
</ui-file-selector>
|
|
7
|
+
<pre>{{ files }}</pre>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
<script>
|
|
11
|
+
import UiFileSelector from './FileSelector.vue';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
components: { UiFileSelector },
|
|
15
|
+
data() {
|
|
16
|
+
return {
|
|
17
|
+
files: [],
|
|
18
|
+
props: {
|
|
19
|
+
multiple: false,
|
|
20
|
+
accept: '',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
onFileSelect(files) {
|
|
26
|
+
this.files = files.map(({ name, type, size }) => ({ name, type, size }));
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Advanced demo: multiple image selection with preview
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<template>
|
|
37
|
+
<div class="pad-l5">
|
|
38
|
+
<div class="d-flex block">
|
|
39
|
+
<ui-file-selector ref="file-selector" v-bind="props" @change="onFileSelect">
|
|
40
|
+
<div class="btn btn-primary btn-small">
|
|
41
|
+
<template v-if="files.length">images selected: ({{ files.length }})</template>
|
|
42
|
+
<template v-else>select images</template>
|
|
43
|
+
</div>
|
|
44
|
+
</ui-file-selector>
|
|
45
|
+
<div class="btn btn-outline btn-small mar-h-3" v-if="files.length" @click="resetFiles">
|
|
46
|
+
reset
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<table class="table table-vmid w-6-12">
|
|
50
|
+
<tr v-for="meta in filesMeta" :key="meta.name">
|
|
51
|
+
<td class="table-w-auto">
|
|
52
|
+
<ui-image :src="meta.preview" style="display:block; width:2rem">
|
|
53
|
+
<div><i class="preloader"></i></div>
|
|
54
|
+
</ui-image>
|
|
55
|
+
</td>
|
|
56
|
+
<td>{{ meta.name }}</td>
|
|
57
|
+
<td>
|
|
58
|
+
<small>({{ meta.size }}kb)</small>
|
|
59
|
+
</td>
|
|
60
|
+
</tr>
|
|
61
|
+
</table>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
<script>
|
|
65
|
+
import UiFileSelector from './FileSelector.vue';
|
|
66
|
+
import UiImage from './Image.vue';
|
|
67
|
+
|
|
68
|
+
// b -> kb util
|
|
69
|
+
const toKb = n => Math.round((n / 1024) * 10) / 10;
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
components: { UiFileSelector, UiImage },
|
|
73
|
+
data() {
|
|
74
|
+
return {
|
|
75
|
+
files: [],
|
|
76
|
+
props: {
|
|
77
|
+
multiple: true,
|
|
78
|
+
accept: 'image/png,image/jpeg,image/gif',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
computed: {
|
|
83
|
+
filesMeta() {
|
|
84
|
+
return this.files.map(file => {
|
|
85
|
+
const { name, type, size } = file;
|
|
86
|
+
return {
|
|
87
|
+
name,
|
|
88
|
+
type,
|
|
89
|
+
size: toKb(size),
|
|
90
|
+
preview: file,
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
methods: {
|
|
96
|
+
resetFiles() {
|
|
97
|
+
this.files = [];
|
|
98
|
+
},
|
|
99
|
+
onFileSelect(files) {
|
|
100
|
+
this.files = files;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
</script>
|
|
105
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ui-file-selector">
|
|
3
|
+
<!--
|
|
4
|
+
@slot default slot
|
|
5
|
+
@binding {File[]} files selected files
|
|
6
|
+
-->
|
|
7
|
+
<slot v-bind="{ files }">select files</slot>
|
|
8
|
+
<input
|
|
9
|
+
class="ui-file-selector-input pos-abs pos-top-left w-100 h-100"
|
|
10
|
+
type="file"
|
|
11
|
+
v-bind="{ accept, multiple }"
|
|
12
|
+
@change="onFilesChanged"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
<style lang="less" scoped>
|
|
17
|
+
.ui-file-selector {
|
|
18
|
+
position: relative;
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
&-input {
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
&::file-selector-button {
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
visibility: hidden;
|
|
29
|
+
}
|
|
30
|
+
&::file-selector-label {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
<script>
|
|
37
|
+
export default {
|
|
38
|
+
props: {
|
|
39
|
+
/**
|
|
40
|
+
* html5 accept attr (a comma-separated list of one or more file types, or unique file type specifiers, describing which file types to allow.)
|
|
41
|
+
*/
|
|
42
|
+
accept: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: '',
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* html5 miltiple attr (single/multiple file selection)
|
|
48
|
+
*/
|
|
49
|
+
multiple: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
data() {
|
|
55
|
+
return {
|
|
56
|
+
files: [],
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
reset() {
|
|
61
|
+
this.files = [];
|
|
62
|
+
this.emitChange();
|
|
63
|
+
},
|
|
64
|
+
emitChange() {
|
|
65
|
+
/**
|
|
66
|
+
* Files change event (dispatched whenever files change)
|
|
67
|
+
* @property {File[]} files
|
|
68
|
+
*/
|
|
69
|
+
this.$emit('change', this.files);
|
|
70
|
+
},
|
|
71
|
+
onFilesChanged(e) {
|
|
72
|
+
const files = [...e.target.files];
|
|
73
|
+
this.files = files;
|
|
74
|
+
this.emitChange();
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
</script>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
```vue
|
|
2
|
+
<template>
|
|
3
|
+
<div class="pad-l5">
|
|
4
|
+
<div class="tile">
|
|
5
|
+
<ui-grid class="tile-body" v-bind="props">
|
|
6
|
+
<template #avatar="{ style }">
|
|
7
|
+
<img
|
|
8
|
+
class="avatar avatar-3 round"
|
|
9
|
+
src="https://picsum.photos/150/150"
|
|
10
|
+
:style="style"
|
|
11
|
+
/>
|
|
12
|
+
</template>
|
|
13
|
+
<template #info="{ style }">
|
|
14
|
+
<div :style="style">
|
|
15
|
+
<div class="text-bold">John Wick</div>
|
|
16
|
+
<div class="text-xsmall">john.wick@site.com</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<template #status="{ style }">
|
|
20
|
+
<div class="text-xsmall color-green" :style="style">online</div>
|
|
21
|
+
</template>
|
|
22
|
+
</ui-grid>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
<script>
|
|
27
|
+
import UiGrid from './Grid.vue';
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
components: { UiGrid },
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
props: {
|
|
34
|
+
areas: [['avatar', 'info', 'status']],
|
|
35
|
+
cols: ['auto', '1fr', 'auto'],
|
|
36
|
+
rows: ['1fr'],
|
|
37
|
+
gap: ['1rem'],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Using wrapper element
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<template>
|
|
49
|
+
<div class="pad-l5">
|
|
50
|
+
<div class="tile">
|
|
51
|
+
<ui-grid class="tile-body" v-bind="props">
|
|
52
|
+
<template #avatar>
|
|
53
|
+
<img class="avatar avatar-3 round" src="https://picsum.photos/150/150" />
|
|
54
|
+
</template>
|
|
55
|
+
<template #info>
|
|
56
|
+
<div class="text-bold">John Wick</div>
|
|
57
|
+
<div class="text-xsmall">john.wick@site.com</div>
|
|
58
|
+
</template>
|
|
59
|
+
<template #status>
|
|
60
|
+
<div class="text-xsmall color-green">online</div>
|
|
61
|
+
</template>
|
|
62
|
+
</ui-grid>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
66
|
+
<script>
|
|
67
|
+
import UiGrid from './Grid.vue';
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
components: { UiGrid },
|
|
71
|
+
data() {
|
|
72
|
+
return {
|
|
73
|
+
props: {
|
|
74
|
+
areas: [['avatar', 'info', 'status']],
|
|
75
|
+
cols: ['auto', '1fr', 'auto'],
|
|
76
|
+
rows: ['1fr'],
|
|
77
|
+
gap: ['1rem'],
|
|
78
|
+
wrapTag: 'div',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
</script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<template>
|
|
88
|
+
<div class="pad-l5">
|
|
89
|
+
<ui-grid v-bind="props">
|
|
90
|
+
<template v-for="name in areaNames" v-slot:[name]="{ style }">
|
|
91
|
+
<div class="box" :style="style">
|
|
92
|
+
<code>{{ name }}</code>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
</ui-grid>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
<script>
|
|
99
|
+
import UiGrid from './Grid.vue';
|
|
100
|
+
|
|
101
|
+
export default {
|
|
102
|
+
components: { UiGrid },
|
|
103
|
+
data() {
|
|
104
|
+
return {
|
|
105
|
+
props: {
|
|
106
|
+
areas: [
|
|
107
|
+
['area1', 'area3', 'area5'],
|
|
108
|
+
['area1', 'area4', 'area5'],
|
|
109
|
+
['area1', 'area2', 'area2'],
|
|
110
|
+
],
|
|
111
|
+
cols: ['auto', '1fr', 'auto'],
|
|
112
|
+
rows: ['1fr'],
|
|
113
|
+
gap: ['1rem'],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
computed: {
|
|
118
|
+
areaNames() {
|
|
119
|
+
return [...new Set(this.props.areas.flat())];
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
</script>
|
|
124
|
+
<style scopped>
|
|
125
|
+
.box {
|
|
126
|
+
padding: 1rem;
|
|
127
|
+
background: #eee;
|
|
128
|
+
}
|
|
129
|
+
</style>
|
|
130
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<style lang="less" scoped>
|
|
2
|
+
.ui-grid {
|
|
3
|
+
display: grid;
|
|
4
|
+
}
|
|
5
|
+
</style>
|
|
6
|
+
<script>
|
|
7
|
+
export default {
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Grid areas defined as a 2d array, which describe the layout (areas are mapped to slot names)
|
|
11
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas
|
|
12
|
+
*/
|
|
13
|
+
areas: {
|
|
14
|
+
type: Array,
|
|
15
|
+
default() {
|
|
16
|
+
return [['default']];
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Grid colum sizes array
|
|
21
|
+
* @see Possible values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns#values
|
|
22
|
+
*/
|
|
23
|
+
cols: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default() {
|
|
26
|
+
return ['1fr'];
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Grid row sizes array
|
|
31
|
+
* @see Possible values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows#values
|
|
32
|
+
*/
|
|
33
|
+
rows: {
|
|
34
|
+
type: Array,
|
|
35
|
+
default() {
|
|
36
|
+
return ['1fr'];
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Grid gaps array [<row-gap>, <column-gap>]
|
|
41
|
+
*/
|
|
42
|
+
gap: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default() {
|
|
45
|
+
return [0, 0];
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Wrapper element tag name @default null
|
|
50
|
+
*/
|
|
51
|
+
wrapTag: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: null,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
computed: {
|
|
57
|
+
gridStyle() {
|
|
58
|
+
const { areas, cols, rows, gap } = this;
|
|
59
|
+
const areasStr = areas.map(row => `"${row.join(' ')}"`).join(' ');
|
|
60
|
+
return {
|
|
61
|
+
'grid-template-areas': areasStr,
|
|
62
|
+
'grid-template-columns': cols.join(' '),
|
|
63
|
+
'grid-template-rows': rows.join(' '),
|
|
64
|
+
gap: gap.join(' '),
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
slotNames() {
|
|
68
|
+
const { areas } = this;
|
|
69
|
+
return [...new Set(areas.flat())].filter(val => val != '.');
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
methods: {
|
|
73
|
+
getSlotStyle(name) {
|
|
74
|
+
return { 'grid-area': name };
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
render(h) {
|
|
78
|
+
const { wrapTag, slotNames, gridStyle, getSlotStyle, $scopedSlots } = this;
|
|
79
|
+
const children = slotNames.map(name => {
|
|
80
|
+
const slot = $scopedSlots[name];
|
|
81
|
+
if (!slot) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const slotChild = slot({ style: getSlotStyle(name) });
|
|
85
|
+
return wrapTag
|
|
86
|
+
? h(wrapTag, { style: getSlotStyle(name), key: name }, [slotChild])
|
|
87
|
+
: slotChild;
|
|
88
|
+
});
|
|
89
|
+
return h('div', { class: 'ui-grid', style: gridStyle }, children);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
```vue
|
|
2
|
+
<template>
|
|
3
|
+
<div class="pad-l5">
|
|
4
|
+
<div class="p">
|
|
5
|
+
<div class="row">
|
|
6
|
+
<div class="col">
|
|
7
|
+
<div>String:</div>
|
|
8
|
+
<input
|
|
9
|
+
class="input input-small w-12-12 v-top"
|
|
10
|
+
type="text"
|
|
11
|
+
v-model="props.src"
|
|
12
|
+
/>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="col">
|
|
15
|
+
<div>File:</div>
|
|
16
|
+
<ui-file-selector accept="image/*" @change="onFilesChange">
|
|
17
|
+
<div class="btn btn-primary btn-small">select local image</div>
|
|
18
|
+
</ui-file-selector>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="col">
|
|
21
|
+
<div>Promise:</div>
|
|
22
|
+
<div class="btn btn-primary btn-small" @click="onImportImage">
|
|
23
|
+
import() image
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<ui-image v-bind="props" style="max-height:3rem">
|
|
29
|
+
<i class="preloader"></i>
|
|
30
|
+
</ui-image>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
<script>
|
|
34
|
+
import UiFileSelector from './FileSelector.vue';
|
|
35
|
+
import UiImage from './Image.vue';
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
components: { UiFileSelector, UiImage },
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
props: {
|
|
42
|
+
src: 'https://vuejs.org/images/logo.svg',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
onImportImage() {
|
|
48
|
+
// @NOTE async import() not working in demo previews
|
|
49
|
+
this.props.src = Promise.resolve(require('/public/js.png'));
|
|
50
|
+
},
|
|
51
|
+
onFilesChange(files) {
|
|
52
|
+
if (files.length) {
|
|
53
|
+
this.props.src = files[0];
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* @param {File} file
|
|
4
|
+
* @return {Promise<string>}
|
|
5
|
+
*/
|
|
6
|
+
const loadFile = file => {
|
|
7
|
+
return new Promise(resolve => {
|
|
8
|
+
const fr = new FileReader();
|
|
9
|
+
fr.addEventListener('load', ({ target }) => resolve(target.result));
|
|
10
|
+
fr.readAsDataURL(file);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* Image source (String, File, Promise<Module>, Promise<File>)
|
|
18
|
+
*/
|
|
19
|
+
src: {
|
|
20
|
+
type: [String, File, Promise],
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
source: null,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
watch: {
|
|
30
|
+
src: {
|
|
31
|
+
handler(val) {
|
|
32
|
+
if (typeof val === 'string') {
|
|
33
|
+
this.source = val;
|
|
34
|
+
} else if (val instanceof Promise) {
|
|
35
|
+
val.then(data => {
|
|
36
|
+
// async import()
|
|
37
|
+
if (typeof data === 'object' && data.default) {
|
|
38
|
+
this.source = data.default;
|
|
39
|
+
} else if (typeof data === 'string') {
|
|
40
|
+
this.source = data;
|
|
41
|
+
} else if (data instanceof File) {
|
|
42
|
+
loadFile(data).then(source => (this.source = source));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
} else if (val instanceof File) {
|
|
46
|
+
loadFile(val).then(source => (this.source = source));
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
immediate: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
render(h) {
|
|
53
|
+
const { source } = this;
|
|
54
|
+
return source ? h('img', { attrs: { src: source } }) : this.$slots.default;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
</script>
|
|
@@ -23,13 +23,21 @@
|
|
|
23
23
|
@slot Custom input slot
|
|
24
24
|
@binding {String} id input id attribute value
|
|
25
25
|
@binding {String} value input value
|
|
26
|
+
@binding {Function} addTag function to add tag
|
|
26
27
|
@binding {Function} setValue function to set the 'value' function(value)
|
|
27
28
|
@binding {Object} inputBinds input props (use v-bind)
|
|
28
29
|
@binding {Object} inputEvents input events (use v-on)
|
|
29
30
|
-->
|
|
30
31
|
<slot
|
|
31
32
|
name="input"
|
|
32
|
-
v-bind="{
|
|
33
|
+
v-bind="{
|
|
34
|
+
id: inputId,
|
|
35
|
+
value: newTag,
|
|
36
|
+
addTag,
|
|
37
|
+
setValue: setNewTag,
|
|
38
|
+
inputBinds,
|
|
39
|
+
inputEvents,
|
|
40
|
+
}"
|
|
33
41
|
>
|
|
34
42
|
<input
|
|
35
43
|
:id="inputId"
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
@focus="onRootFocus"
|
|
7
7
|
tabindex="0"
|
|
8
8
|
>
|
|
9
|
-
<!--
|
|
9
|
+
<!--
|
|
10
10
|
@slot Custom input slot
|
|
11
11
|
@binding {String} id input id attribute value
|
|
12
12
|
@binding {String} value input value
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
@select-option="onUnitChange"
|
|
37
37
|
>
|
|
38
38
|
<template #header>
|
|
39
|
-
<!--
|
|
39
|
+
<!--
|
|
40
40
|
@slot Dropdown header content
|
|
41
41
|
-->
|
|
42
42
|
<slot name="dropdown-header"></slot>
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
setCursorIndex,
|
|
50
50
|
}"
|
|
51
51
|
>
|
|
52
|
-
<!--
|
|
52
|
+
<!--
|
|
53
53
|
@slot Dropdown option
|
|
54
54
|
@binding {String} option option
|
|
55
55
|
@binding {Number} index option index
|
|
56
56
|
@binding {String} selectedOption current selected option
|
|
57
|
-
@binding {Number} cursorIndex current dropdown selection index
|
|
57
|
+
@binding {Number} cursorIndex current dropdown selection index
|
|
58
58
|
@binding {Function} selectOption function that select's the option
|
|
59
59
|
@binding {Function} setCursorIndex function that sets the cursor index
|
|
60
60
|
-->
|
|
@@ -121,7 +121,7 @@ import UiDatalist from './Datalist.vue';
|
|
|
121
121
|
import UiPopover from './Popover.vue';
|
|
122
122
|
import { Key, Position } from './utils/Helpers';
|
|
123
123
|
|
|
124
|
-
const withUnitRegExp = /^([\d.]*)(\D+)$/i;
|
|
124
|
+
const withUnitRegExp = /^(-?[\d.]*)(\D+)$/i;
|
|
125
125
|
|
|
126
126
|
export default {
|
|
127
127
|
mixins: [FormComponent, WithPopover],
|
|
@@ -97,17 +97,10 @@ export default {
|
|
|
97
97
|
default: false,
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
|
+
data() {
|
|
101
|
+
return { cssStyle: {} };
|
|
102
|
+
},
|
|
100
103
|
computed: {
|
|
101
|
-
cssStyle() {
|
|
102
|
-
const { zIndex, autoWidth } = this;
|
|
103
|
-
const obj = { zIndex };
|
|
104
|
-
const target = this.getTarget();
|
|
105
|
-
if (autoWidth && target) {
|
|
106
|
-
const b = target.getBoundingClientRect();
|
|
107
|
-
obj.width = `${b.width}px`;
|
|
108
|
-
}
|
|
109
|
-
return obj;
|
|
110
|
-
},
|
|
111
104
|
placement() {
|
|
112
105
|
const { position } = this;
|
|
113
106
|
const map = { t: Position.TOP, l: Position.START, r: Position.END, b: Position.BOTTOM };
|
|
@@ -146,7 +139,10 @@ export default {
|
|
|
146
139
|
},
|
|
147
140
|
],
|
|
148
141
|
});
|
|
149
|
-
this.$nextTick(() =>
|
|
142
|
+
this.$nextTick(() => {
|
|
143
|
+
this.calcStyle();
|
|
144
|
+
this.popper.update();
|
|
145
|
+
});
|
|
150
146
|
} else {
|
|
151
147
|
this.removeEventListeners();
|
|
152
148
|
this.destroyPopper();
|
|
@@ -172,6 +168,16 @@ export default {
|
|
|
172
168
|
window.removeEventListener('blur', this.onWinBlur);
|
|
173
169
|
document.removeEventListener('mousedown', this.onDocMouseDown);
|
|
174
170
|
},
|
|
171
|
+
calcStyle() {
|
|
172
|
+
const { zIndex, autoWidth } = this;
|
|
173
|
+
const target = this.getTarget();
|
|
174
|
+
const style = { zIndex };
|
|
175
|
+
if (autoWidth && target) {
|
|
176
|
+
const b = target.getBoundingClientRect();
|
|
177
|
+
style.width = `${b.width}px`;
|
|
178
|
+
}
|
|
179
|
+
this.cssStyle = style;
|
|
180
|
+
},
|
|
175
181
|
getTarget() {
|
|
176
182
|
let { target } = this;
|
|
177
183
|
return isElem(target) ? target : document.querySelector(target);
|
|
@@ -132,3 +132,56 @@ export default {
|
|
|
132
132
|
};
|
|
133
133
|
</script>
|
|
134
134
|
```
|
|
135
|
+
|
|
136
|
+
Runtime options
|
|
137
|
+
|
|
138
|
+
```vue
|
|
139
|
+
<template>
|
|
140
|
+
<div class="pad-l5">
|
|
141
|
+
<ui-select class="w-6-12 p" v-model="model" v-bind="props"></ui-select>
|
|
142
|
+
<p>
|
|
143
|
+
<label>
|
|
144
|
+
<input class="checkbox checkbox-small" type="checkbox" v-model="props.multiple" />
|
|
145
|
+
<span class="pad-left-2 v-mid">multiple</span>
|
|
146
|
+
</label>
|
|
147
|
+
</p>
|
|
148
|
+
<p><div class="btn btn-primary" @click="toggleOptions">toggle options</div></p>
|
|
149
|
+
<p>model: {{ model }}</p>
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|
|
152
|
+
<script>
|
|
153
|
+
import UiSelect from './Select.vue';
|
|
154
|
+
|
|
155
|
+
let options = [
|
|
156
|
+
'angular',
|
|
157
|
+
'aurelia',
|
|
158
|
+
'backbone',
|
|
159
|
+
'ember',
|
|
160
|
+
'meteor',
|
|
161
|
+
'react',
|
|
162
|
+
'riot',
|
|
163
|
+
'stencil',
|
|
164
|
+
'svelte',
|
|
165
|
+
'vue',
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
export default {
|
|
169
|
+
components: { UiSelect },
|
|
170
|
+
data() {
|
|
171
|
+
return {
|
|
172
|
+
model: 'vue',
|
|
173
|
+
props: {
|
|
174
|
+
options: [],
|
|
175
|
+
multiple: false,
|
|
176
|
+
},
|
|
177
|
+
overflow: false,
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
methods: {
|
|
181
|
+
toggleOptions() {
|
|
182
|
+
this.props.options = this.props.options.length ? [] : options;
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
</script>
|
|
187
|
+
```
|
|
@@ -292,27 +292,15 @@ export default {
|
|
|
292
292
|
},
|
|
293
293
|
immediate: true,
|
|
294
294
|
},
|
|
295
|
-
/*
|
|
296
|
-
@TODO refactor
|
|
297
295
|
options() {
|
|
298
|
-
|
|
299
|
-
if (n) {
|
|
300
|
-
this.optionsSelected = [];
|
|
301
|
-
this.dataListCursorIndex = -1;
|
|
302
|
-
this.triggerModelChange();
|
|
303
|
-
}
|
|
296
|
+
this.importModel(this.value);
|
|
304
297
|
},
|
|
305
|
-
*/
|
|
306
298
|
},
|
|
307
299
|
methods: {
|
|
308
300
|
importModel(model) {
|
|
309
|
-
// if (model == null) {
|
|
310
|
-
// this.optionsSelected = [];
|
|
311
|
-
// return;
|
|
312
|
-
// }
|
|
313
301
|
let ci = -1;
|
|
314
302
|
let tmp = [];
|
|
315
|
-
model = this.multiple ? model : [model];
|
|
303
|
+
model = this.multiple ? (Array.isArray(model) ? model : [model]) : [model];
|
|
316
304
|
model.forEach(modelItem => {
|
|
317
305
|
let modelItemValue = this.valueObjects ? this.getOptionValue(modelItem) : modelItem;
|
|
318
306
|
let optionIndex = this.options.findIndex(optionItem => {
|
package/styleguide.config.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { version } = require('./package.json');
|
|
1
3
|
|
|
2
4
|
module.exports = {
|
|
3
5
|
components: 'src/components/ui/[A-Z]*.vue',
|
|
4
6
|
require: ['goodt-framework-css'],
|
|
5
7
|
title: 'UI',
|
|
6
|
-
version
|
|
8
|
+
version,
|
|
7
9
|
styleguideDir: 'docs',
|
|
10
|
+
getComponentPathLine(componentPath) {
|
|
11
|
+
const name = path.basename(componentPath, '.vue');
|
|
12
|
+
return `import { ${name} } from 'goodteditor-ui';`;
|
|
13
|
+
},
|
|
8
14
|
template: {
|
|
9
15
|
head: {
|
|
10
16
|
links: [
|
package/public/index.html
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
7
|
-
<link rel="stylesheet" href="https://goodt-css.netlify.app/css/all.css" />
|
|
8
|
-
<link
|
|
9
|
-
rel="stylesheet"
|
|
10
|
-
href="https://cdn.materialdesignicons.com/5.4.55/css/materialdesignicons.min.css"
|
|
11
|
-
/>
|
|
12
|
-
<link
|
|
13
|
-
rel="stylesheet"
|
|
14
|
-
href="http://cdn.materialdesignicons.com/light/0.2.63/css/materialdesignicons-light.min.css"
|
|
15
|
-
/>
|
|
16
|
-
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<noscript>
|
|
21
|
-
<strong
|
|
22
|
-
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly
|
|
23
|
-
without JavaScript enabled. Please enable it to continue.</strong
|
|
24
|
-
>
|
|
25
|
-
</noscript>
|
|
26
|
-
<div id="app"></div>
|
|
27
|
-
<!-- built files will be auto injected -->
|
|
28
|
-
</body>
|
|
29
|
-
</html>
|