goodteditor-ui 1.0.2 → 1.0.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/package.json +8 -4
- package/src/components/ui/Datalist.vue +1 -1
- package/src/components/ui/FileSelector.vue +1 -0
- package/src/components/ui/Grid.md +130 -0
- package/src/components/ui/Grid.vue +92 -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/public/index.html +0 -29
- package/public/js.png +0 -0
package/package.json
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goodteditor-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
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": {
|
|
14
17
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
15
18
|
"@vue/cli-plugin-babel": "^4.5.11",
|
|
16
19
|
"@vue/cli-plugin-eslint": "^4.5.11",
|
|
17
20
|
"@vue/cli-service": "^4.5.11",
|
|
21
|
+
"axios": "^0.24.0",
|
|
18
22
|
"babel-eslint": "^10.1.0",
|
|
19
23
|
"eslint": "^6.7.2",
|
|
20
24
|
"eslint-plugin-vue": "^6.2.2",
|
|
@@ -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,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>
|
|
@@ -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/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>
|
package/public/js.png
DELETED
|
Binary file
|