@zkwq/business 0.0.4 → 0.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.
Files changed (227) hide show
  1. package/package.json +2 -2
  2. package/src/components/base/ui/alert/Alert.vue +0 -94
  3. package/src/components/base/ui/autocomplete/autocomplete-suggestions.vue +0 -77
  4. package/src/components/base/ui/autocomplete/autocomplete.vue +0 -305
  5. package/src/components/base/ui/backtop/main.vue +0 -112
  6. package/src/components/base/ui/button/Button.vue +0 -84
  7. package/src/components/base/ui/button/ButtonGroup.vue +0 -10
  8. package/src/components/base/ui/carousel/Carousel.vue +0 -304
  9. package/src/components/base/ui/carousel/CarouselItem.vue +0 -137
  10. package/src/components/base/ui/cascader/cascader.vue +0 -650
  11. package/src/components/base/ui/cascader-panel/cascader-menu.vue +0 -138
  12. package/src/components/base/ui/cascader-panel/cascader-node.vue +0 -246
  13. package/src/components/base/ui/cascader-panel/cascader-panel.vue +0 -382
  14. package/src/components/base/ui/cascader-panel/node.js +0 -166
  15. package/src/components/base/ui/cascader-panel/store.js +0 -62
  16. package/src/components/base/ui/checkbox/checkbox-button.vue +0 -199
  17. package/src/components/base/ui/checkbox/checkbox-group.vue +0 -48
  18. package/src/components/base/ui/checkbox/checkbox.vue +0 -222
  19. package/src/components/base/ui/col/col.js +0 -71
  20. package/src/components/base/ui/collapse/collapse-item.vue +0 -180
  21. package/src/components/base/ui/collapse/collapse.vue +0 -73
  22. package/src/components/base/ui/color-picker/color.js +0 -317
  23. package/src/components/base/ui/color-picker/components/alpha-slider.vue +0 -132
  24. package/src/components/base/ui/color-picker/components/hue-slider.vue +0 -123
  25. package/src/components/base/ui/color-picker/components/picker-dropdown.vue +0 -119
  26. package/src/components/base/ui/color-picker/components/predefine.vue +0 -61
  27. package/src/components/base/ui/color-picker/components/sv-panel.vue +0 -100
  28. package/src/components/base/ui/color-picker/draggable.js +0 -36
  29. package/src/components/base/ui/color-picker/index.js +0 -2
  30. package/src/components/base/ui/color-picker/main.vue +0 -188
  31. package/src/components/base/ui/date-picker/basic/date-table.vue +0 -441
  32. package/src/components/base/ui/date-picker/basic/month-table.vue +0 -254
  33. package/src/components/base/ui/date-picker/basic/time-spinner.vue +0 -304
  34. package/src/components/base/ui/date-picker/basic/year-table.vue +0 -101
  35. package/src/components/base/ui/date-picker/panel/date-range.vue +0 -680
  36. package/src/components/base/ui/date-picker/panel/date.vue +0 -597
  37. package/src/components/base/ui/date-picker/panel/month-range.vue +0 -289
  38. package/src/components/base/ui/date-picker/panel/time-range.vue +0 -248
  39. package/src/components/base/ui/date-picker/panel/time-select.vue +0 -178
  40. package/src/components/base/ui/date-picker/panel/time.vue +0 -186
  41. package/src/components/base/ui/date-picker/picker/date-picker.js +0 -43
  42. package/src/components/base/ui/date-picker/picker/time-picker.js +0 -39
  43. package/src/components/base/ui/date-picker/picker/time-select.js +0 -21
  44. package/src/components/base/ui/date-picker/picker.vue +0 -942
  45. package/src/components/base/ui/dialog/Index.vue +0 -212
  46. package/src/components/base/ui/directive/repeat-click.js +0 -24
  47. package/src/components/base/ui/directive/ripple.js +0 -303
  48. package/src/components/base/ui/divider/Divider.vue +0 -37
  49. package/src/components/base/ui/drawer/Drawer.vue +0 -202
  50. package/src/components/base/ui/dropdown/dropdown-item.vue +0 -39
  51. package/src/components/base/ui/dropdown/dropdown-menu.vue +0 -63
  52. package/src/components/base/ui/dropdown/dropdown.vue +0 -308
  53. package/src/components/base/ui/form/Form.vue +0 -167
  54. package/src/components/base/ui/form/FormItem.vue +0 -334
  55. package/src/components/base/ui/form/LabelWrap.vue +0 -69
  56. package/src/components/base/ui/icon/icon.vue +0 -13
  57. package/src/components/base/ui/image/image-viewer.vue +0 -302
  58. package/src/components/base/ui/image/main.vue +0 -248
  59. package/src/components/base/ui/index.js +0 -189
  60. package/src/components/base/ui/input/Input.vue +0 -438
  61. package/src/components/base/ui/input/calcTextareaHeight.js +0 -104
  62. package/src/components/base/ui/input-number/input-number.vue +0 -285
  63. package/src/components/base/ui/locale/format.js +0 -32
  64. package/src/components/base/ui/locale/index.js +0 -48
  65. package/src/components/base/ui/locale/lang/zh-CN.js +0 -120
  66. package/src/components/base/ui/menu/menu-item-group.vue +0 -45
  67. package/src/components/base/ui/menu/menu-item.vue +0 -112
  68. package/src/components/base/ui/menu/menu-mixin.js +0 -44
  69. package/src/components/base/ui/menu/menu.vue +0 -312
  70. package/src/components/base/ui/menu/submenu.vue +0 -408
  71. package/src/components/base/ui/message/index.js +0 -2
  72. package/src/components/base/ui/message/main.js +0 -87
  73. package/src/components/base/ui/message/main.vue +0 -110
  74. package/src/components/base/ui/message-box/main.js +0 -216
  75. package/src/components/base/ui/message-box/main.vue +0 -323
  76. package/src/components/base/ui/mixin/emitter.js +0 -31
  77. package/src/components/base/ui/mixin/focus.js +0 -9
  78. package/src/components/base/ui/mixin/locale.js +0 -9
  79. package/src/components/base/ui/mixin/migrating.js +0 -33
  80. package/src/components/base/ui/pagination/pager.vue +0 -163
  81. package/src/components/base/ui/pagination/pagination.jsx +0 -391
  82. package/src/components/base/ui/popover/directive.js +0 -20
  83. package/src/components/base/ui/popover/index.js +0 -14
  84. package/src/components/base/ui/popover/main.vue +0 -236
  85. package/src/components/base/ui/progress/Progress.vue +0 -227
  86. package/src/components/base/ui/radio/radio-button.vue +0 -114
  87. package/src/components/base/ui/radio/radio-group.vue +0 -111
  88. package/src/components/base/ui/radio/radio.vue +0 -134
  89. package/src/components/base/ui/row/row.js +0 -47
  90. package/src/components/base/ui/scrollbar/bar.jsx +0 -91
  91. package/src/components/base/ui/scrollbar/index.jsx +0 -203
  92. package/src/components/base/ui/scrollbar/util.js +0 -32
  93. package/src/components/base/ui/select/Option.vue +0 -168
  94. package/src/components/base/ui/select/OptionGroup.vue +0 -60
  95. package/src/components/base/ui/select/Select.vue +0 -920
  96. package/src/components/base/ui/select/SelectDropdown.vue +0 -74
  97. package/src/components/base/ui/select/navigation-mixin.js +0 -54
  98. package/src/components/base/ui/skeleton/index.js +0 -8
  99. package/src/components/base/ui/skeleton/src/img-placeholder.vue +0 -16
  100. package/src/components/base/ui/skeleton/src/index.vue +0 -80
  101. package/src/components/base/ui/skeleton/src/item.vue +0 -22
  102. package/src/components/base/ui/skeleton-item/index.js +0 -8
  103. package/src/components/base/ui/slider/button.vue +0 -238
  104. package/src/components/base/ui/slider/main.vue +0 -427
  105. package/src/components/base/ui/slider/marker.js +0 -18
  106. package/src/components/base/ui/style/alert.scss +0 -147
  107. package/src/components/base/ui/style/animations.scss +0 -65
  108. package/src/components/base/ui/style/autocomplete.scss +0 -81
  109. package/src/components/base/ui/style/backtop.scss +0 -20
  110. package/src/components/base/ui/style/button-group.scss +0 -0
  111. package/src/components/base/ui/style/button.scss +0 -380
  112. package/src/components/base/ui/style/carousel-item.scss +0 -50
  113. package/src/components/base/ui/style/carousel.scss +0 -161
  114. package/src/components/base/ui/style/cascader-panel.scss +0 -120
  115. package/src/components/base/ui/style/cascader.scss +0 -185
  116. package/src/components/base/ui/style/checkbox-button.scss +0 -0
  117. package/src/components/base/ui/style/checkbox-group.scss +0 -0
  118. package/src/components/base/ui/style/checkbox.scss +0 -360
  119. package/src/components/base/ui/style/col.scss +0 -156
  120. package/src/components/base/ui/style/collapse-item.scss +0 -0
  121. package/src/components/base/ui/style/collapse.scss +0 -114
  122. package/src/components/base/ui/style/color-picker.scss +0 -387
  123. package/src/components/base/ui/style/config.scss +0 -4
  124. package/src/components/base/ui/style/date-picker/date-picker.scss +0 -97
  125. package/src/components/base/ui/style/date-picker/date-range-picker.scss +0 -101
  126. package/src/components/base/ui/style/date-picker/date-table.scss +0 -151
  127. package/src/components/base/ui/style/date-picker/month-table.scss +0 -82
  128. package/src/components/base/ui/style/date-picker/picker-panel.scss +0 -117
  129. package/src/components/base/ui/style/date-picker/picker.scss +0 -197
  130. package/src/components/base/ui/style/date-picker/time-picker.scss +0 -85
  131. package/src/components/base/ui/style/date-picker/time-range-picker.scss +0 -31
  132. package/src/components/base/ui/style/date-picker/time-spinner.scss +0 -110
  133. package/src/components/base/ui/style/date-picker/year-table.scss +0 -51
  134. package/src/components/base/ui/style/date-picker.scss +0 -12
  135. package/src/components/base/ui/style/dialog.scss +0 -123
  136. package/src/components/base/ui/style/divider.scss +0 -47
  137. package/src/components/base/ui/style/drawer.scss +0 -218
  138. package/src/components/base/ui/style/dropdown-item.scss +0 -0
  139. package/src/components/base/ui/style/dropdown-menu.scss +0 -0
  140. package/src/components/base/ui/style/dropdown.scss +0 -185
  141. package/src/components/base/ui/style/form-item.scss +0 -0
  142. package/src/components/base/ui/style/form.scss +0 -203
  143. package/src/components/base/ui/style/function.scss +0 -43
  144. package/src/components/base/ui/style/icon.scss +0 -1167
  145. package/src/components/base/ui/style/image.scss +0 -184
  146. package/src/components/base/ui/style/index.scss +0 -57
  147. package/src/components/base/ui/style/input-number.scss +0 -187
  148. package/src/components/base/ui/style/input.scss +0 -477
  149. package/src/components/base/ui/style/menu-item-group.scss +0 -0
  150. package/src/components/base/ui/style/menu-item.scss +0 -0
  151. package/src/components/base/ui/style/menu.scss +0 -294
  152. package/src/components/base/ui/style/message-box.scss +0 -231
  153. package/src/components/base/ui/style/message.scss +0 -120
  154. package/src/components/base/ui/style/mixins.scss +0 -196
  155. package/src/components/base/ui/style/option-group.scss +0 -42
  156. package/src/components/base/ui/style/option.scss +0 -36
  157. package/src/components/base/ui/style/pagination.scss +0 -295
  158. package/src/components/base/ui/style/popover.scss +0 -40
  159. package/src/components/base/ui/style/popper.scss +0 -102
  160. package/src/components/base/ui/style/popup.scss +0 -42
  161. package/src/components/base/ui/style/progress.scss +0 -141
  162. package/src/components/base/ui/style/radio-button.scss +0 -113
  163. package/src/components/base/ui/style/radio-group.scss +0 -9
  164. package/src/components/base/ui/style/radio.scss +0 -203
  165. package/src/components/base/ui/style/ripple.scss +0 -35
  166. package/src/components/base/ui/style/row.scss +0 -39
  167. package/src/components/base/ui/style/scrollbar.scss +0 -75
  168. package/src/components/base/ui/style/select-dropdown.scss +0 -59
  169. package/src/components/base/ui/style/select.scss +0 -154
  170. package/src/components/base/ui/style/skeleton-item.scss +0 -84
  171. package/src/components/base/ui/style/skeleton.scss +0 -40
  172. package/src/components/base/ui/style/slider.scss +0 -250
  173. package/src/components/base/ui/style/switch.scss +0 -116
  174. package/src/components/base/ui/style/tabs.scss +0 -602
  175. package/src/components/base/ui/style/tag.scss +0 -174
  176. package/src/components/base/ui/style/tooltip.scss +0 -146
  177. package/src/components/base/ui/style/transition.scss +0 -138
  178. package/src/components/base/ui/style/upload.scss +0 -603
  179. package/src/components/base/ui/style/utils.scss +0 -39
  180. package/src/components/base/ui/style/var.scss +0 -1011
  181. package/src/components/base/ui/switch/index.vue +0 -174
  182. package/src/components/base/ui/tabs/tab-bar.vue +0 -57
  183. package/src/components/base/ui/tabs/tab-nav.vue +0 -294
  184. package/src/components/base/ui/tabs/tab-pane.vue +0 -56
  185. package/src/components/base/ui/tabs/tabs.vue +0 -191
  186. package/src/components/base/ui/tag/Tag.vue +0 -60
  187. package/src/components/base/ui/tooltip/tooltip.jsx +0 -234
  188. package/src/components/base/ui/upload/Index.vue +0 -340
  189. package/src/components/base/ui/upload/Upload.vue +0 -216
  190. package/src/components/base/ui/upload/UploadDragger.vue +0 -70
  191. package/src/components/base/ui/upload/UploadList.vue +0 -100
  192. package/src/components/base/ui/upload/ajax.js +0 -85
  193. package/src/components/base/ui/util/aria-dialog.js +0 -90
  194. package/src/components/base/ui/util/aria-utils.js +0 -122
  195. package/src/components/base/ui/util/clickoutside.js +0 -76
  196. package/src/components/base/ui/util/date-util.js +0 -292
  197. package/src/components/base/ui/util/date.js +0 -355
  198. package/src/components/base/ui/util/debounce.js +0 -21
  199. package/src/components/base/ui/util/deepmerge.js +0 -100
  200. package/src/components/base/ui/util/dom.js +0 -215
  201. package/src/components/base/ui/util/index.js +0 -262
  202. package/src/components/base/ui/util/menu/aria-menubar.js +0 -14
  203. package/src/components/base/ui/util/menu/aria-menuitem.js +0 -49
  204. package/src/components/base/ui/util/menu/aria-submenu.js +0 -59
  205. package/src/components/base/ui/util/merge.js +0 -14
  206. package/src/components/base/ui/util/popper.js +0 -1235
  207. package/src/components/base/ui/util/popup/index.js +0 -218
  208. package/src/components/base/ui/util/popup/popup-manager.js +0 -194
  209. package/src/components/base/ui/util/resize-events.js +0 -32
  210. package/src/components/base/ui/util/scroll-into-view.js +0 -27
  211. package/src/components/base/ui/util/scrollbar-width.js +0 -29
  212. package/src/components/base/ui/util/shared.js +0 -7
  213. package/src/components/base/ui/util/throttle.js +0 -91
  214. package/src/components/base/ui/util/types.js +0 -24
  215. package/src/components/base/ui/util/vdom.js +0 -5
  216. package/src/components/base/ui/util/vue-popper.js +0 -188
  217. package/src/components/normal/AggsItemH.vue +0 -145
  218. package/src/index.js +0 -10
  219. package/src/static/base-icons.ttf +0 -0
  220. package/src/static/base-icons.woff +0 -0
  221. package/src/static/label_bg.png +0 -0
  222. package/src/static/term-label-bg.png +0 -0
  223. package/src/style/app-article.scss +0 -698
  224. package/src/style/app-comment.scss +0 -259
  225. package/src/style/app-recommend.scss +0 -48
  226. package/src/style/app-richtext.scss +0 -176
  227. package/src/style/index.scss +0 -523
@@ -1,216 +0,0 @@
1
- const defaults = {
2
- title: null,
3
- message: '',
4
- type: '',
5
- iconClass: '',
6
- showInput: false,
7
- showClose: false,
8
- modalFade: true,
9
- lockScroll: true,
10
- closeOnClickModal: true,
11
- closeOnPressEscape: true,
12
- closeOnHashChange: true,
13
- inputValue: null,
14
- inputPlaceholder: '',
15
- inputType: 'text',
16
- inputPattern: null,
17
- inputValidator: null,
18
- inputErrorMessage: '',
19
- showConfirmButton: true,
20
- showCancelButton: false,
21
- confirmButtonPosition: 'right',
22
- confirmButtonHighlight: false,
23
- cancelButtonHighlight: false,
24
- confirmButtonText: '',
25
- cancelButtonText: '',
26
- confirmButtonClass: '',
27
- cancelButtonClass: '',
28
- customClass: '',
29
- beforeClose: null,
30
- dangerouslyUseHTMLString: false,
31
- center: true,
32
- roundButton: false,
33
- distinguishCancelAndClose: false
34
- };
35
-
36
- import Vue from 'vue';
37
- import msgboxVue from './main.vue';
38
- import merge from '../util/merge';
39
- import { isVNode } from '../util/vdom';
40
-
41
- const MessageBoxConstructor = Vue.extend(msgboxVue);
42
-
43
- let currentMsg, instance;
44
- let msgQueue = [];
45
-
46
- const defaultCallback = action => {
47
- if (currentMsg) {
48
- let callback = currentMsg.callback;
49
- if (typeof callback === 'function') {
50
- if (instance.showInput) {
51
- callback(instance.inputValue, action);
52
- } else {
53
- callback(action);
54
- }
55
- }
56
- if (currentMsg.resolve) {
57
- if (action === 'confirm') {
58
- if (instance.showInput) {
59
- currentMsg.resolve({ value: instance.inputValue, action });
60
- } else {
61
- currentMsg.resolve(action);
62
- }
63
- } else if (currentMsg.reject && (action === 'cancel' || action === 'close')) {
64
- currentMsg.reject(action);
65
- }
66
- }
67
- }
68
- };
69
-
70
- const initInstance = () => {
71
- instance = new MessageBoxConstructor({
72
- el: document.createElement('div')
73
- });
74
-
75
- instance.callback = defaultCallback;
76
- };
77
-
78
- const showNextMsg = () => {
79
- if (!instance) {
80
- initInstance();
81
- }
82
- instance.action = '';
83
-
84
- if (!instance.visible || instance.closeTimer) {
85
- if (msgQueue.length > 0) {
86
- currentMsg = msgQueue.shift();
87
-
88
- let options = currentMsg.options;
89
- for (let prop in options) {
90
- if (options.hasOwnProperty(prop)) {
91
- instance[prop] = options[prop];
92
- }
93
- }
94
- if (options.callback === undefined) {
95
- instance.callback = defaultCallback;
96
- }
97
-
98
- let oldCb = instance.callback;
99
- instance.callback = (action, instance) => {
100
- oldCb(action, instance);
101
- showNextMsg();
102
- };
103
- if (isVNode(instance.message)) {
104
- instance.$slots.default = [instance.message];
105
- instance.message = null;
106
- } else {
107
- delete instance.$slots.default;
108
- }
109
- ['modal', 'showClose', 'closeOnClickModal', 'closeOnPressEscape', 'closeOnHashChange'].forEach(prop => {
110
- if (instance[prop] === undefined) {
111
- instance[prop] = true;
112
- }
113
- });
114
- document.body.appendChild(instance.$el);
115
-
116
- Vue.nextTick(() => {
117
- instance.visible = true;
118
- });
119
- }
120
- }
121
- };
122
-
123
- const MessageBox = function(options, callback) {
124
- if (Vue.prototype.$isServer) return;
125
- if (typeof options === 'string' || isVNode(options)) {
126
- options = {
127
- message: options
128
- };
129
- if (typeof arguments[1] === 'string') {
130
- options.title = arguments[1];
131
- }
132
- } else if (options.callback && !callback) {
133
- callback = options.callback;
134
- }
135
-
136
- if (typeof Promise !== 'undefined') {
137
- return new Promise((resolve, reject) => { // eslint-disable-line
138
- msgQueue.push({
139
- options: merge({}, defaults, MessageBox.defaults, options),
140
- callback: callback,
141
- resolve: resolve,
142
- reject: reject
143
- });
144
-
145
- showNextMsg();
146
- });
147
- } else {
148
- msgQueue.push({
149
- options: merge({}, defaults, MessageBox.defaults, options),
150
- callback: callback
151
- });
152
-
153
- showNextMsg();
154
- }
155
- };
156
-
157
- MessageBox.setDefaults = defaults => {
158
- MessageBox.defaults = defaults;
159
- };
160
-
161
- MessageBox.alert = (message, title, options) => {
162
- if (typeof title === 'object') {
163
- options = title;
164
- title = '';
165
- } else if (title === undefined) {
166
- title = '';
167
- }
168
- return MessageBox(merge({
169
- title: title,
170
- message: message,
171
- $type: 'alert',
172
- closeOnPressEscape: false,
173
- closeOnClickModal: false
174
- }, options));
175
- };
176
-
177
- MessageBox.confirm = (message, title, options) => {
178
- if (typeof title === 'object') {
179
- options = title;
180
- title = '';
181
- } else if (title === undefined) {
182
- title = '';
183
- }
184
- return MessageBox(merge({
185
- title: title,
186
- message: message,
187
- $type: 'confirm',
188
- showCancelButton: true
189
- }, options));
190
- };
191
-
192
- MessageBox.prompt = (message, title, options) => {
193
- if (typeof title === 'object') {
194
- options = title;
195
- title = '';
196
- } else if (title === undefined) {
197
- title = '';
198
- }
199
- return MessageBox(merge({
200
- title: title,
201
- message: message,
202
- showCancelButton: true,
203
- showInput: true,
204
- $type: 'prompt'
205
- }, options));
206
- };
207
-
208
- MessageBox.close = () => {
209
- instance.doClose();
210
- instance.visible = false;
211
- msgQueue = [];
212
- currentMsg = null;
213
- };
214
-
215
- export default MessageBox;
216
- export { MessageBox };
@@ -1,323 +0,0 @@
1
- <template>
2
- <transition name="msgbox-fade">
3
- <div
4
- class="base-message-box__wrapper"
5
- tabindex="-1"
6
- v-show="visible"
7
- @click.self="handleWrapperClick"
8
- role="dialog"
9
- aria-modal="true"
10
- :aria-label="title || 'dialog'">
11
- <div class="base-message-box" :class="[customClass, center && 'base-message-box--center']">
12
- <div class="base-message-box__header" v-if="title !== null">
13
- <div class="base-message-box__title">{{ title }}</div>
14
- <button
15
- type="button"
16
- class="base-message-box__headerbtn"
17
- aria-label="Close"
18
- v-if="showClose"
19
- @click="handleAction(distinguishCancelAndClose ? 'close' : 'cancel')"
20
- @keydown.enter="handleAction(distinguishCancelAndClose ? 'close' : 'cancel')">
21
- <i class="base-message-box__close base-icon-close"></i>
22
- </button>
23
- </div>
24
- <div class="base-message-box__content">
25
- <div class="base-message-box__container">
26
- <div class="base-message-box__message" v-if="message !== ''">
27
- <slot>
28
- <p v-if="!dangerouslyUseHTMLString">{{ message }}</p>
29
- <p v-else v-html="message"></p>
30
- </slot>
31
- </div>
32
- </div>
33
- <div class="base-message-box__input" v-if="showInput">
34
- <base-input
35
- v-model="inputValue"
36
- :type="inputType"
37
- @keydown.enter.native="handleInputEnter"
38
- :placeholder="inputPlaceholder"
39
- ref="input"></base-input>
40
- <div class="base-message-box__errormsg" :style="{ visibility: !!editorErrorMessage ? 'visible' : 'hidden' }">{{ editorErrorMessage }}</div>
41
- </div>
42
- </div>
43
- <div class="base-message-box__btns">
44
- <base-button
45
- :loading="cancelButtonLoading"
46
- :class="[ cancelButtonClasses ]"
47
- v-if="showCancelButton"
48
- :round="roundButton"
49
- size="medium"
50
- light
51
- @click.native="handleAction('cancel')"
52
- @keydown.enter="handleAction('cancel')">
53
- {{ cancelButtonText || t('base.messagebox.cancel') }}
54
- </base-button>
55
- <base-button
56
- :loading="confirmButtonLoading"
57
- ref="confirm"
58
- :class="[ confirmButtonClasses ]"
59
- v-show="showConfirmButton"
60
- :round="roundButton"
61
- size="medium"
62
- @click.native="handleAction('confirm')"
63
- @keydown.enter="handleAction('confirm')">
64
- {{ confirmButtonText || t('base.messagebox.confirm') }}
65
- </base-button>
66
- </div>
67
- </div>
68
- </div>
69
- </transition>
70
- </template>
71
-
72
- <script type="text/babel">
73
- import Popup from '../util/popup';
74
- import Locale from '../mixin/locale';
75
- import BaseInput from '../input/Input';
76
- import BaseButton from '../button/Button';
77
- import { addClass, removeClass } from '../util/dom';
78
- import { t } from '../locale';
79
- import Dialog from '../util/aria-dialog';
80
-
81
- let messageBox;
82
- let typeMap = {
83
- success: 'success',
84
- info: 'info',
85
- warning: 'warning',
86
- error: 'error'
87
- };
88
-
89
- export default {
90
- mixins: [Popup, Locale],
91
-
92
- props: {
93
- modal: {
94
- default: true
95
- },
96
- lockScroll: {
97
- default: true
98
- },
99
- showClose: {
100
- type: Boolean,
101
- default: true
102
- },
103
- closeOnClickModal: {
104
- default: true
105
- },
106
- closeOnPressEscape: {
107
- default: true
108
- },
109
- closeOnHashChange: {
110
- default: true
111
- },
112
- center: {
113
- default: false,
114
- type: Boolean
115
- },
116
- roundButton: {
117
- default: false,
118
- type: Boolean
119
- }
120
- },
121
-
122
- components: {
123
- BaseInput,
124
- BaseButton
125
- },
126
-
127
- computed: {
128
- icon() {
129
- const { type, iconClass } = this;
130
- return iconClass || (type && typeMap[type] ? `base-icon-${ typeMap[type] }` : '');
131
- },
132
-
133
- confirmButtonClasses() {
134
- return `base-button--primary ${ this.confirmButtonClass }`;
135
- },
136
- cancelButtonClasses() {
137
- return `${ this.cancelButtonClass }`;
138
- }
139
- },
140
-
141
- methods: {
142
- getSafeClose() {
143
- const currentId = this.uid;
144
- return () => {
145
- this.$nextTick(() => {
146
- if (currentId === this.uid) this.doClose();
147
- });
148
- };
149
- },
150
- doClose() {
151
- if (!this.visible) return;
152
- this.visible = false;
153
- this._closing = true;
154
-
155
- this.onClose && this.onClose();
156
- messageBox.closeDialog(); // 解绑
157
- if (this.lockScroll) {
158
- setTimeout(this.restoreBodyStyle, 200);
159
- }
160
- this.opened = false;
161
- this.doAfterClose();
162
- setTimeout(() => {
163
- if (this.action) this.callback(this.action, this);
164
- });
165
- },
166
-
167
- handleWrapperClick() {
168
- if (this.closeOnClickModal) {
169
- this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel');
170
- }
171
- },
172
-
173
- handleInputEnter() {
174
- if (this.inputType !== 'textarea') {
175
- return this.handleAction('confirm');
176
- }
177
- },
178
-
179
- handleAction(action) {
180
- if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
181
- return;
182
- }
183
- this.action = action;
184
- if (typeof this.beforeClose === 'function') {
185
- this.close = this.getSafeClose();
186
- this.beforeClose(action, this, this.close);
187
- } else {
188
- this.doClose();
189
- }
190
- },
191
-
192
- validate() {
193
- if (this.$type === 'prompt') {
194
- const inputPattern = this.inputPattern;
195
- if (inputPattern && !inputPattern.test(this.inputValue || '')) {
196
- this.editorErrorMessage = this.inputErrorMessage || t('base.messagebox.error');
197
- addClass(this.getInputElement(), 'invalid');
198
- return false;
199
- }
200
- const inputValidator = this.inputValidator;
201
- if (typeof inputValidator === 'function') {
202
- const validateResult = inputValidator(this.inputValue);
203
- if (validateResult === false) {
204
- this.editorErrorMessage = this.inputErrorMessage || t('base.messagebox.error');
205
- addClass(this.getInputElement(), 'invalid');
206
- return false;
207
- }
208
- if (typeof validateResult === 'string') {
209
- this.editorErrorMessage = validateResult;
210
- addClass(this.getInputElement(), 'invalid');
211
- return false;
212
- }
213
- }
214
- }
215
- this.editorErrorMessage = '';
216
- removeClass(this.getInputElement(), 'invalid');
217
- return true;
218
- },
219
- getFirstFocus() {
220
- const btn = this.$el.querySelector('.base-message-box__btns .base-button');
221
- const title = this.$el.querySelector('.base-message-box__btns .base-message-box__title');
222
- return btn || title;
223
- },
224
- getInputElement() {
225
- const inputRefs = this.$refs.input.$refs;
226
- return inputRefs.input || inputRefs.textarea;
227
- },
228
- handleClose() {
229
- this.handleAction('close');
230
- }
231
- },
232
-
233
- watch: {
234
- inputValue: {
235
- immediate: true,
236
- handler(val) {
237
- this.$nextTick(_ => {
238
- if (this.$type === 'prompt' && val !== null) {
239
- this.validate();
240
- }
241
- });
242
- }
243
- },
244
-
245
- visible(val) {
246
- if (val) {
247
- this.uid++;
248
- if (this.$type === 'alert' || this.$type === 'confirm') {
249
- this.$nextTick(() => {
250
- this.$refs.confirm.$el.focus();
251
- });
252
- }
253
- this.focusAfterClosed = document.activeElement;
254
- messageBox = new Dialog(this.$el, this.focusAfterClosed, this.getFirstFocus());
255
- }
256
-
257
- // prompt
258
- if (this.$type !== 'prompt') return;
259
- if (val) {
260
- setTimeout(() => {
261
- if (this.$refs.input && this.$refs.input.$el) {
262
- this.getInputElement().focus();
263
- }
264
- }, 500);
265
- } else {
266
- this.editorErrorMessage = '';
267
- removeClass(this.getInputElement(), 'invalid');
268
- }
269
- }
270
- },
271
-
272
- mounted() {
273
- this.$nextTick(() => {
274
- if (this.closeOnHashChange) {
275
- window.addEventListener('hashchange', this.close);
276
- }
277
- });
278
- },
279
-
280
- beforeDestroy() {
281
- if (this.closeOnHashChange) {
282
- window.removeEventListener('hashchange', this.close);
283
- }
284
- setTimeout(() => {
285
- messageBox.closeDialog();
286
- });
287
- },
288
-
289
- data() {
290
- return {
291
- uid: 1,
292
- title: undefined,
293
- message: '',
294
- type: '',
295
- iconClass: '',
296
- customClass: '',
297
- showInput: false,
298
- inputValue: null,
299
- inputPlaceholder: '',
300
- inputType: 'text',
301
- inputPattern: null,
302
- inputValidator: null,
303
- inputErrorMessage: '',
304
- showConfirmButton: true,
305
- showCancelButton: false,
306
- action: '',
307
- confirmButtonText: '',
308
- cancelButtonText: '',
309
- confirmButtonLoading: false,
310
- cancelButtonLoading: false,
311
- confirmButtonClass: '',
312
- confirmButtonDisabled: false,
313
- cancelButtonClass: '',
314
- editorErrorMessage: null,
315
- callback: null,
316
- dangerouslyUseHTMLString: false,
317
- focusAfterClosed: null,
318
- isOnComposition: false,
319
- distinguishCancelAndClose: false
320
- };
321
- }
322
- };
323
- </script>
@@ -1,31 +0,0 @@
1
- function broadcast (componentName, eventName, params) {
2
- this.$children.forEach(child => {
3
- let name = child.$options.componentName
4
- if (name === componentName) {
5
- child.$emit.apply(child, [eventName].concat(params))
6
- } else {
7
- broadcast.apply(child, [componentName, eventName].concat([params]))
8
- }
9
- })
10
- }
11
- export default {
12
- methods: {
13
- dispatch (componentName, eventName, params) {
14
- let parent = this.$parent || this.$root
15
- let name = parent.$options.componentName
16
-
17
- while (parent && (!name || name !== componentName)) {
18
- parent = parent.$parent
19
- if (parent) {
20
- name = parent.$options.componentName
21
- }
22
- }
23
- if (parent) {
24
- parent.$emit.apply(parent, [eventName].concat(params))
25
- }
26
- },
27
- broadcast (componentName, eventName, params) {
28
- broadcast.call(this, componentName, eventName, params)
29
- }
30
- }
31
- }
@@ -1,9 +0,0 @@
1
- export default function(ref) {
2
- return {
3
- methods: {
4
- focus() {
5
- this.$refs[ref].focus()
6
- }
7
- }
8
- }
9
- }
@@ -1,9 +0,0 @@
1
- import { t } from '../locale/index'
2
-
3
- export default {
4
- methods: {
5
- t(...args) {
6
- return t.apply(this, args)
7
- }
8
- }
9
- }
@@ -1,33 +0,0 @@
1
- import { kebabCase } from '../util/index'
2
- export default {
3
- mounted() {
4
- if (process.env.NODE_ENV === 'production') return
5
- if (!this.$vnode) return
6
- const { props = {}, events = {} } = this.getMigratingConfig()
7
- const { data, componentOptions } = this.$vnode
8
- const definedProps = data.attrs || {}
9
- const definedEvents = componentOptions.listeners || {}
10
-
11
- for (let propName in definedProps) {
12
- propName = kebabCase(propName)
13
- if (props[propName]) {
14
- console.warn(`[Element Migrating][${this.$options.name}][Attribute]: ${props[propName]}`)
15
- }
16
- }
17
-
18
- for (let eventName in definedEvents) {
19
- eventName = kebabCase(eventName)
20
- if (events[eventName]) {
21
- console.warn(`[Element Migrating][${this.$options.name}][Event]: ${events[eventName]}`)
22
- }
23
- }
24
- },
25
- methods: {
26
- getMigratingConfig() {
27
- return {
28
- props: {},
29
- events: {}
30
- }
31
- }
32
- }
33
- }