goodteditor-ui 1.0.12 → 1.0.13

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.
Files changed (75) hide show
  1. package/.eslintrc.js +7 -7
  2. package/.prettierrc +14 -14
  3. package/README.md +35 -35
  4. package/babel.config.js +5 -5
  5. package/dist/js.png +0 -0
  6. package/index.js +51 -51
  7. package/jsconfig.json +13 -13
  8. package/package.json +57 -57
  9. package/src/App.vue +36 -36
  10. package/src/components/ui/Avatar.md +68 -68
  11. package/src/components/ui/Avatar.vue +177 -177
  12. package/src/components/ui/Badge.md +20 -20
  13. package/src/components/ui/Badge.vue +75 -75
  14. package/src/components/ui/Collapse.md +90 -90
  15. package/src/components/ui/Collapse.vue +86 -86
  16. package/src/components/ui/ColorPicker/Alpha.vue +114 -114
  17. package/src/components/ui/ColorPicker/Colors.vue +117 -117
  18. package/src/components/ui/ColorPicker/Hue.vue +113 -113
  19. package/src/components/ui/ColorPicker/Preview.vue +55 -55
  20. package/src/components/ui/ColorPicker/Saturation.vue +123 -123
  21. package/src/components/ui/ColorPicker/mixin.js +105 -105
  22. package/src/components/ui/ColorPicker.md +17 -17
  23. package/src/components/ui/ColorPicker.vue +314 -314
  24. package/src/components/ui/Datalist.md +41 -41
  25. package/src/components/ui/Datalist.vue +157 -157
  26. package/src/components/ui/DatePicker.md +168 -168
  27. package/src/components/ui/DatePicker.vue +527 -527
  28. package/src/components/ui/FileSelector.md +105 -105
  29. package/src/components/ui/FileSelector.vue +82 -82
  30. package/src/components/ui/Grid.md +130 -130
  31. package/src/components/ui/Grid.vue +92 -92
  32. package/src/components/ui/Image.md +59 -59
  33. package/src/components/ui/Image.vue +57 -57
  34. package/src/components/ui/InputAutocomplete.md +115 -115
  35. package/src/components/ui/InputAutocomplete.vue +341 -341
  36. package/src/components/ui/InputColorPicker.md +51 -51
  37. package/src/components/ui/InputColorPicker.vue +151 -151
  38. package/src/components/ui/InputDatePicker.md +121 -121
  39. package/src/components/ui/InputDatePicker.vue +310 -310
  40. package/src/components/ui/InputTags.md +51 -51
  41. package/src/components/ui/InputTags.vue +184 -184
  42. package/src/components/ui/InputTimePicker.md +25 -25
  43. package/src/components/ui/InputTimePicker.vue +253 -253
  44. package/src/components/ui/InputUnits.md +20 -20
  45. package/src/components/ui/InputUnits.vue +257 -257
  46. package/src/components/ui/Lazy.md +37 -37
  47. package/src/components/ui/Lazy.vue +92 -92
  48. package/src/components/ui/Pagination.md +74 -74
  49. package/src/components/ui/Pagination.vue +138 -138
  50. package/src/components/ui/Paginator.md +34 -34
  51. package/src/components/ui/Paginator.vue +83 -83
  52. package/src/components/ui/Popover.md +34 -34
  53. package/src/components/ui/Popover.vue +258 -209
  54. package/src/components/ui/Popup.md +59 -59
  55. package/src/components/ui/Popup.vue +150 -150
  56. package/src/components/ui/ResponsiveContainer.md +58 -58
  57. package/src/components/ui/ResponsiveContainer.vue +99 -99
  58. package/src/components/ui/Select.md +187 -187
  59. package/src/components/ui/Select.vue +420 -420
  60. package/src/components/ui/TimePicker.md +50 -50
  61. package/src/components/ui/TimePicker.vue +252 -252
  62. package/src/components/ui/Tooltip.md +114 -52
  63. package/src/components/ui/Tooltip.vue +113 -113
  64. package/src/components/ui/utils/FormComponent.js +107 -107
  65. package/src/components/ui/utils/Helpers.js +84 -61
  66. package/src/components/ui/utils/WithPopover.js +99 -81
  67. package/src/main.js +8 -8
  68. package/styleguide.config.js +37 -37
  69. package/vue.config.js +8 -8
  70. package/.idea/codeStyles/Project.xml +0 -51
  71. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  72. package/.idea/goodt-ui.iml +0 -12
  73. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  74. package/.idea/modules.xml +0 -8
  75. package/.idea/vcs.xml +0 -6
@@ -1,209 +1,258 @@
1
- <template>
2
- <transition name="transition" appear>
3
- <div :style="cssStyle" v-if="show" v-append-body>
4
- <slot></slot>
5
- </div>
6
- </transition>
7
- </template>
8
- <style lang="less" scoped>
9
- .transition {
10
- &-enter,
11
- &-leave-to {
12
- opacity: 0;
13
- }
14
- &-enter-active,
15
- &-leave-active {
16
- transition: opacity 0.15s ease;
17
- }
18
- }
19
- </style>
20
- <script>
21
- import { createPopper } from '@popperjs/core';
22
- import { Position } from './utils/Helpers';
23
-
24
- const isElem = el => el instanceof HTMLElement;
25
-
26
- export default {
27
- directives: {
28
- 'append-body': {
29
- inserted(el, bindings, { context }) {
30
- let { appendToBody } = context;
31
- if (!appendToBody) {
32
- return;
33
- }
34
- const nt = context.$nextTick;
35
- nt(() => nt(() => document.body.appendChild(el)));
36
- },
37
- unbind(el, bindings, { context }) {
38
- el.parentNode && el.parentNode.removeChild(el);
39
- },
40
- },
41
- },
42
- props: {
43
- /**
44
- * Target HTMLElement or selector used for positioning
45
- */
46
- target: { default: null },
47
- /**
48
- * Whether to show popover
49
- */
50
- show: { type: Boolean, default: false },
51
- /**
52
- * z-index
53
- */
54
- zIndex: {
55
- type: Number,
56
- default: 1010,
57
- },
58
- /**
59
- * Whether to append popover to body
60
- */
61
- appendToBody: {
62
- type: Boolean,
63
- default: true,
64
- },
65
- /**
66
- * Position, values of the popover:
67
- * bl, br, tl, tr - bottom-left, bottom-right, top-left, top-right
68
- * @values bl, br, tl, tr, top, top-start, top-end, left, left-start, left-end, right, right-start, right-end, bottom, bottom-start, bottom-end
69
- */
70
- position: {
71
- type: String,
72
- default: `${Position.BOTTOM}-${Position.START}`,
73
- },
74
- /**
75
- * Position offset [ x, y ] where:
76
- * x - skidding (offset along target)
77
- * y - distance (offset away from target)
78
- */
79
- positionOffset: {
80
- type: Array,
81
- default() {
82
- return [1, 1];
83
- },
84
- },
85
- /**
86
- * Whether to flip position if out of viewport
87
- */
88
- positionFlip: {
89
- type: Boolean,
90
- default: true,
91
- },
92
- /**
93
- * Auto width
94
- */
95
- autoWidth: {
96
- type: Boolean,
97
- default: false,
98
- },
99
- },
100
- data() {
101
- return { cssStyle: {} };
102
- },
103
- computed: {
104
- placement() {
105
- const { position } = this;
106
- const map = { t: Position.TOP, l: Position.START, r: Position.END, b: Position.BOTTOM };
107
- // t-b-l-r mode
108
- if (position.length == 2) {
109
- return position
110
- .split('')
111
- .map(k => map[k])
112
- .filter(v => !!v)
113
- .join('-');
114
- }
115
- return position;
116
- },
117
- },
118
- watch: {
119
- show: {
120
- handler(val) {
121
- const { appendToBody, placement, positionFlip, positionOffset } = this;
122
- const strategy = appendToBody ? 'fixed' : 'absolute';
123
- this.$nextTick(() => {
124
- if (val) {
125
- this.addEventListeners();
126
- this.popper = createPopper(this.getTarget(), this.$el, {
127
- placement,
128
- strategy,
129
- modifiers: [
130
- {
131
- name: 'flip',
132
- enabled: positionFlip,
133
- },
134
- {
135
- name: 'offset',
136
- options: {
137
- offset: positionOffset,
138
- },
139
- },
140
- ],
141
- });
142
- this.$nextTick(() => {
143
- this.calcStyle();
144
- this.popper.update();
145
- });
146
- } else {
147
- this.removeEventListeners();
148
- this.destroyPopper();
149
- }
150
- });
151
- },
152
- immediate: true,
153
- },
154
- },
155
- created() {
156
- this.popper = null;
157
- },
158
- destroyed() {
159
- this.removeEventListeners();
160
- this.destroyPopper();
161
- },
162
- methods: {
163
- addEventListeners() {
164
- window.addEventListener('blur', this.onWinBlur);
165
- document.addEventListener('mousedown', this.onDocMouseDown);
166
- },
167
- removeEventListeners() {
168
- window.removeEventListener('blur', this.onWinBlur);
169
- document.removeEventListener('mousedown', this.onDocMouseDown);
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
- },
181
- getTarget() {
182
- let { target } = this;
183
- return isElem(target) ? target : document.querySelector(target);
184
- },
185
- setShow(val) {
186
- this.$nextTick(() => this.$emit('update:show', val));
187
- },
188
- destroyPopper() {
189
- this.popper && this.popper.destroy();
190
- this.popper = null;
191
- },
192
- onWinBlur(e) {
193
- if (this.show) {
194
- this.setShow(false);
195
- }
196
- },
197
- onDocMouseDown(e) {
198
- let target = this.getTarget();
199
- let root = this.$el && isElem(this.$el) ? this.$el : null;
200
- if ((root && root.contains(e.target)) || (target && target.contains(e.target))) {
201
- return;
202
- }
203
- if (this.show) {
204
- this.setShow(false);
205
- }
206
- },
207
- },
208
- };
209
- </script>
1
+ <template>
2
+ <transition name="transition" appear>
3
+ <div :style="cssStyle" v-if="show" v-append-body>
4
+ <slot></slot>
5
+ </div>
6
+ </transition>
7
+ </template>
8
+ <style lang="less" scoped>
9
+ .transition {
10
+ &-enter,
11
+ &-leave-to {
12
+ opacity: 0;
13
+ }
14
+ &-enter-active,
15
+ &-leave-active {
16
+ transition: opacity 0.15s ease;
17
+ }
18
+ }
19
+ </style>
20
+ <script>
21
+ import { createPopper } from '@popperjs/core';
22
+ import { Position, generateGetBoundingClientRect } from './utils/Helpers';
23
+
24
+ const isElem = el => el instanceof HTMLElement;
25
+
26
+ const Strategy = Object.freeze({
27
+ ABSOLUTE: 'absolute',
28
+ FIXED: 'fixed'
29
+ });
30
+
31
+ const Modifier = Object.freeze({
32
+ FLIP: 'flip',
33
+ OFFSET: 'offset'
34
+ });
35
+
36
+ export default {
37
+ directives: {
38
+ 'append-body': {
39
+ inserted(el, bindings, { context }) {
40
+ let { appendToBody } = context;
41
+ if (!appendToBody) {
42
+ return;
43
+ }
44
+ const nt = context.$nextTick;
45
+ nt(() => nt(() => document.body.appendChild(el)));
46
+ },
47
+ unbind(el, bindings, { context }) {
48
+ el.parentNode && el.parentNode.removeChild(el);
49
+ },
50
+ },
51
+ },
52
+ props: {
53
+ /**
54
+ * Target HTMLElement or selector used for positioning
55
+ */
56
+ target: { default: null },
57
+ /**
58
+ * Whether to show popover
59
+ */
60
+ show: { type: Boolean, default: false },
61
+ /**
62
+ * z-index
63
+ */
64
+ zIndex: {
65
+ type: Number,
66
+ default: 1010,
67
+ },
68
+ /**
69
+ * Whether to append popover to body
70
+ */
71
+ appendToBody: {
72
+ type: Boolean,
73
+ default: true,
74
+ },
75
+ /**
76
+ * Position, values of the popover:
77
+ * bl, br, tl, tr - bottom-left, bottom-right, top-left, top-right
78
+ * @values bl, br, tl, tr, top, top-start, top-end, left, left-start, left-end, right, right-start, right-end, bottom, bottom-start, bottom-end
79
+ */
80
+ position: {
81
+ type: String,
82
+ default: `${Position.BOTTOM}-${Position.START}`,
83
+ },
84
+ /**
85
+ * Position offset [ x, y ] where:
86
+ * x - skidding (offset along target)
87
+ * y - distance (offset away from target)
88
+ */
89
+ positionOffset: {
90
+ type: Array,
91
+ default() {
92
+ return [1, 1];
93
+ },
94
+ },
95
+ /**
96
+ * Whether to flip position if out of viewport
97
+ */
98
+ positionFlip: {
99
+ type: Boolean,
100
+ default: true,
101
+ },
102
+ /**
103
+ * Auto width
104
+ */
105
+ autoWidth: {
106
+ type: Boolean,
107
+ default: false,
108
+ },
109
+ /**
110
+ * Should follow the cursor
111
+ */
112
+ shouldFollowCursor: {
113
+ type: Boolean,
114
+ default: false
115
+ },
116
+ /**
117
+ * Cursor coordinates [ x, y ]
118
+ */
119
+ cursorCoordinates: {
120
+ type: Array,
121
+ default: () => [0, 0]
122
+ }
123
+ },
124
+ data() {
125
+ return { cssStyle: {} };
126
+ },
127
+ computed: {
128
+ placement() {
129
+ const { position } = this;
130
+ const map = { t: Position.TOP, l: Position.START, r: Position.END, b: Position.BOTTOM };
131
+ // t-b-l-r mode
132
+ if (position.length == 2) {
133
+ return position
134
+ .split('')
135
+ .map(k => map[k])
136
+ .filter(v => !!v)
137
+ .join('-');
138
+ }
139
+ return position;
140
+ },
141
+ options() {
142
+ const { appendToBody, placement, positionFlip, positionOffset } = this;
143
+ const strategy = appendToBody ? Strategy.FIXED : Strategy.ABSOLUTE;
144
+ const modifiers = [
145
+ {
146
+ name: Modifier.FLIP,
147
+ enabled: positionFlip,
148
+ },
149
+ {
150
+ name: Modifier.OFFSET,
151
+ options: {
152
+ offset: positionOffset,
153
+ },
154
+ },
155
+ ]
156
+ return { placement, strategy, modifiers };
157
+ }
158
+ },
159
+ watch: {
160
+ show: {
161
+ handler(val) {
162
+ this.$nextTick(() => {
163
+ if (val === true) {
164
+ this.addEventListeners();
165
+ this.createPopper();
166
+ return;
167
+ }
168
+
169
+ this.handleReset();
170
+ });
171
+ },
172
+ immediate: true,
173
+ },
174
+ },
175
+ created() {
176
+ this.popper = null;
177
+ },
178
+ destroyed() {
179
+ this.handleReset();
180
+ },
181
+ methods: {
182
+ addEventListeners() {
183
+ window.addEventListener('blur', this.onWinBlur);
184
+ document.addEventListener('mousedown', this.onDocMouseDown);
185
+ },
186
+ removeEventListeners() {
187
+ window.removeEventListener('blur', this.onWinBlur);
188
+ document.removeEventListener('mousedown', this.onDocMouseDown);
189
+ },
190
+ calcStyle() {
191
+ const { zIndex, autoWidth } = this;
192
+ const target = this.getTarget();
193
+ const style = { zIndex };
194
+ if (autoWidth && target) {
195
+ const b = target.getBoundingClientRect();
196
+ style.width = `${b.width}px`;
197
+ }
198
+ this.cssStyle = style;
199
+ },
200
+ getTarget() {
201
+ let { target } = this;
202
+ return isElem(target) ? target : document.querySelector(target);
203
+ },
204
+ setShow(val) {
205
+ this.$nextTick(() => this.$emit('update:show', val));
206
+ },
207
+ createPopper() {
208
+ const { shouldFollowCursor, options, $el: popper, cursorCoordinates } = this;
209
+ const target = this.getTarget();
210
+
211
+ if (shouldFollowCursor) {
212
+ const [x, y] = cursorCoordinates;
213
+ const virtualElem = {
214
+ getBoundingClientRect: generateGetBoundingClientRect(x, y),
215
+ contextElement: target
216
+ }
217
+
218
+ this.popper = createPopper(virtualElem, popper, options);
219
+ this.unwatchCursorCoordinates = this.$watch('cursorCoordinates', ([x, y]) => {
220
+ virtualElem.getBoundingClientRect = generateGetBoundingClientRect(x, y);
221
+ this.popper?.update();
222
+ })
223
+ } else {
224
+ this.popper = createPopper(target, popper, options);
225
+ }
226
+
227
+ this.$nextTick(() => {
228
+ this.calcStyle();
229
+ this.popper.update();
230
+ });
231
+ },
232
+ destroyPopper() {
233
+ this.popper?.destroy();
234
+ this.popper = null;
235
+ },
236
+ handleReset() {
237
+ this.unwatchCursorCoordinates?.();
238
+ this.removeEventListeners();
239
+ this.destroyPopper();
240
+ },
241
+ onWinBlur(e) {
242
+ if (this.show) {
243
+ this.setShow(false);
244
+ }
245
+ },
246
+ onDocMouseDown(e) {
247
+ let target = this.getTarget();
248
+ let root = this.$el && isElem(this.$el) ? this.$el : null;
249
+ if ((root && root.contains(e.target)) || (target && target.contains(e.target))) {
250
+ return;
251
+ }
252
+ if (this.show) {
253
+ this.setShow(false);
254
+ }
255
+ },
256
+ },
257
+ };
258
+ </script>
@@ -1,59 +1,59 @@
1
- Simple example
2
-
3
- ```vue
4
- <template>
5
- <div class="pad-l5">
6
- <ui-popup :visible.sync="visible" v-bind="props">
7
- <template #body>
8
- <div style="height:100%; max-width:30vw">
9
- <h3>Popup title</h3>
10
- <div>
11
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Totam nesciunt
12
- suscipit porro alias rem consequuntur veritatis iusto accusantium cumque
13
- assumenda.
14
- </div>
15
- </div>
16
- </template>
17
- <template #footer="{ close }">
18
- <div class="text-right">
19
- <div class="btn btn-primary" @click="close">close</div>
20
- </div>
21
- </template>
22
- </ui-popup>
23
- <div class="p" v-for="k in bools" :key="k">
24
- <label>
25
- <input class="checkbox checkbox-small" type="checkbox" v-model="props[k]" />
26
- <span class="pad-left-2 v-mid">{{ k }}</span>
27
- </label>
28
- </div>
29
- <div class="btn btn-primary" @click="visible = true">open popup</div>
30
- </div>
31
- </template>
32
- <script>
33
- import UiPopup from './Popup.vue';
34
-
35
- export default {
36
- components: { UiPopup },
37
- data() {
38
- return {
39
- visible: false,
40
- props: {
41
- modal: false,
42
- fullscreen: false,
43
- usePadding: true,
44
- showCloseButton: true,
45
- dialog: {
46
- class: {},
47
- style: {},
48
- },
49
- },
50
- };
51
- },
52
- computed: {
53
- bools() {
54
- return Object.keys(this.props).filter(p => typeof this.props[p] == 'boolean');
55
- },
56
- },
57
- };
58
- </script>
59
- ```
1
+ Simple example
2
+
3
+ ```vue
4
+ <template>
5
+ <div class="pad-l5">
6
+ <ui-popup :visible.sync="visible" v-bind="props">
7
+ <template #body>
8
+ <div style="height:100%; max-width:30vw">
9
+ <h3>Popup title</h3>
10
+ <div>
11
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Totam nesciunt
12
+ suscipit porro alias rem consequuntur veritatis iusto accusantium cumque
13
+ assumenda.
14
+ </div>
15
+ </div>
16
+ </template>
17
+ <template #footer="{ close }">
18
+ <div class="text-right">
19
+ <div class="btn btn-primary" @click="close">close</div>
20
+ </div>
21
+ </template>
22
+ </ui-popup>
23
+ <div class="p" v-for="k in bools" :key="k">
24
+ <label>
25
+ <input class="checkbox checkbox-small" type="checkbox" v-model="props[k]" />
26
+ <span class="pad-left-2 v-mid">{{ k }}</span>
27
+ </label>
28
+ </div>
29
+ <div class="btn btn-primary" @click="visible = true">open popup</div>
30
+ </div>
31
+ </template>
32
+ <script>
33
+ import UiPopup from './Popup.vue';
34
+
35
+ export default {
36
+ components: { UiPopup },
37
+ data() {
38
+ return {
39
+ visible: false,
40
+ props: {
41
+ modal: false,
42
+ fullscreen: false,
43
+ usePadding: true,
44
+ showCloseButton: true,
45
+ dialog: {
46
+ class: {},
47
+ style: {},
48
+ },
49
+ },
50
+ };
51
+ },
52
+ computed: {
53
+ bools() {
54
+ return Object.keys(this.props).filter(p => typeof this.props[p] == 'boolean');
55
+ },
56
+ },
57
+ };
58
+ </script>
59
+ ```