@mdsfe/mds-ui 0.2.0

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 (153) hide show
  1. package/CHANGELOG.md +778 -0
  2. package/LICENSE +21 -0
  3. package/README.md +106 -0
  4. package/dist/_locale/index.js +18 -0
  5. package/dist/_locale/zh-CN.js +123 -0
  6. package/dist/_mixin/emitter.js +35 -0
  7. package/dist/_mixin/focus.js +13 -0
  8. package/dist/_mixin/locale.js +17 -0
  9. package/dist/_mixin/popper.js +192 -0
  10. package/dist/_mixin/tooltip.js +218 -0
  11. package/dist/_util/__test__/switchcase.test.js +43 -0
  12. package/dist/_util/autoprefixer.js +249 -0
  13. package/dist/_util/clickoutside.js +79 -0
  14. package/dist/_util/date.js +368 -0
  15. package/dist/_util/dateUtil.js +311 -0
  16. package/dist/_util/dom.js +240 -0
  17. package/dist/_util/getRequestAnimationFrame.js +50 -0
  18. package/dist/_util/getScroll.js +21 -0
  19. package/dist/_util/loaders/loaders.css.js +52 -0
  20. package/dist/_util/loaders/loading.js +53 -0
  21. package/dist/_util/merge.js +18 -0
  22. package/dist/_util/popper.js +1261 -0
  23. package/dist/_util/popup/index.js +232 -0
  24. package/dist/_util/popup/popup-manager.js +205 -0
  25. package/dist/_util/proptype.js +12 -0
  26. package/dist/_util/repeatClick.js +30 -0
  27. package/dist/_util/resize.js +61 -0
  28. package/dist/_util/resizeEvent.js +59 -0
  29. package/dist/_util/scrollIntoView.js +38 -0
  30. package/dist/_util/scrollbar-width.js +37 -0
  31. package/dist/_util/soda.js +54 -0
  32. package/dist/_util/switchcase.js +22 -0
  33. package/dist/_util/throttleByAnimationFrame.js +70 -0
  34. package/dist/_util/tree/node.js +412 -0
  35. package/dist/_util/tree/tree.js +410 -0
  36. package/dist/_util/util.js +166 -0
  37. package/dist/_util/vue-popper.js +213 -0
  38. package/dist/affix.js +509 -0
  39. package/dist/anchor.js +522 -0
  40. package/dist/avatar.js +437 -0
  41. package/dist/backtop.js +469 -0
  42. package/dist/badge.js +439 -0
  43. package/dist/bordershadow.js +310 -0
  44. package/dist/breadcrumb.js +434 -0
  45. package/dist/button.js +579 -0
  46. package/dist/card.js +514 -0
  47. package/dist/carousel.js +1326 -0
  48. package/dist/cascaderpanel.js +2320 -0
  49. package/dist/checkbox.js +681 -0
  50. package/dist/col.js +546 -0
  51. package/dist/collapse.js +671 -0
  52. package/dist/color.js +306 -0
  53. package/dist/datepicker.js +8089 -0
  54. package/dist/divider.js +346 -0
  55. package/dist/drawer.js +652 -0
  56. package/dist/dropdown.js +687 -0
  57. package/dist/empty.js +416 -0
  58. package/dist/font.js +306 -0
  59. package/dist/form.js +878 -0
  60. package/dist/icon.js +401 -0
  61. package/dist/index.js +1 -0
  62. package/dist/input.js +1251 -0
  63. package/dist/inputnumber.js +689 -0
  64. package/dist/layout.js +786 -0
  65. package/dist/list.js +789 -0
  66. package/dist/loading.js +430 -0
  67. package/dist/mds-ui.min.css +7 -0
  68. package/dist/mds-ui.min.js +64911 -0
  69. package/dist/menu.js +1131 -0
  70. package/dist/message.js +1016 -0
  71. package/dist/modal.js +895 -0
  72. package/dist/notification.js +818 -0
  73. package/dist/pagination.js +1213 -0
  74. package/dist/popconfirm.js +336 -0
  75. package/dist/popover.js +206 -0
  76. package/dist/progress.js +1023 -0
  77. package/dist/radio.js +760 -0
  78. package/dist/rate.js +765 -0
  79. package/dist/row.js +546 -0
  80. package/dist/select.js +4950 -0
  81. package/dist/slider.js +1411 -0
  82. package/dist/slottable.js +1414 -0
  83. package/dist/steps.js +546 -0
  84. package/dist/style/affix.css +5524 -0
  85. package/dist/style/anchor.css +5572 -0
  86. package/dist/style/avatar.css +5587 -0
  87. package/dist/style/backtop.css +34 -0
  88. package/dist/style/badge.css +5655 -0
  89. package/dist/style/bordershadow.css +5601 -0
  90. package/dist/style/breadcrumb.css +5551 -0
  91. package/dist/style/button.css +7679 -0
  92. package/dist/style/card.css +5670 -0
  93. package/dist/style/carousel.css +5731 -0
  94. package/dist/style/cascaderpanel.css +125 -0
  95. package/dist/style/checkbox.css +5700 -0
  96. package/dist/style/col.css +8121 -0
  97. package/dist/style/collapse.css +5593 -0
  98. package/dist/style/color.css +6136 -0
  99. package/dist/style/datepicker.css +5977 -0
  100. package/dist/style/divider.css +5558 -0
  101. package/dist/style/drawer.css +7979 -0
  102. package/dist/style/dropdown.css +7950 -0
  103. package/dist/style/empty.css +5563 -0
  104. package/dist/style/font.css +5559 -0
  105. package/dist/style/form.css +5662 -0
  106. package/dist/style/icon.css +5538 -0
  107. package/dist/style/input.css +6256 -0
  108. package/dist/style/inputnumber.css +5828 -0
  109. package/dist/style/layout.css +5572 -0
  110. package/dist/style/list.css +5655 -0
  111. package/dist/style/loading.css +5540 -0
  112. package/dist/style/menu.css +6183 -0
  113. package/dist/style/message.css +194 -0
  114. package/dist/style/modal.css +5637 -0
  115. package/dist/style/notification.css +5706 -0
  116. package/dist/style/pagination.css +6683 -0
  117. package/dist/style/popconfirm.css +7951 -0
  118. package/dist/style/popover.css +5727 -0
  119. package/dist/style/progress.css +5714 -0
  120. package/dist/style/radio.css +5769 -0
  121. package/dist/style/rate.css +5616 -0
  122. package/dist/style/row.css +8121 -0
  123. package/dist/style/select.css +5729 -0
  124. package/dist/style/slider.css +5594 -0
  125. package/dist/style/slottable.css +5831 -0
  126. package/dist/style/steps.css +6100 -0
  127. package/dist/style/switch.css +5624 -0
  128. package/dist/style/table.css +8392 -0
  129. package/dist/style/tabs.css +6047 -0
  130. package/dist/style/tag.css +5935 -0
  131. package/dist/style/text.css +5636 -0
  132. package/dist/style/timeline.css +5602 -0
  133. package/dist/style/timepicker.css +5904 -0
  134. package/dist/style/tooltip.css +5686 -0
  135. package/dist/style/transfer.css +101 -0
  136. package/dist/style/transition.css +1417 -0
  137. package/dist/style/tree.css +5598 -0
  138. package/dist/style/typography.css +5640 -0
  139. package/dist/style/upload.css +5834 -0
  140. package/dist/switch.js +448 -0
  141. package/dist/table.js +3809 -0
  142. package/dist/tabs.js +1273 -0
  143. package/dist/tag.js +478 -0
  144. package/dist/text.js +1100 -0
  145. package/dist/timeline.js +495 -0
  146. package/dist/timepicker.js +1567 -0
  147. package/dist/tooltip.js +179 -0
  148. package/dist/transfer.js +981 -0
  149. package/dist/transition.js +246 -0
  150. package/dist/tree.js +1866 -0
  151. package/dist/typography.js +469 -0
  152. package/dist/upload.js +1990 -0
  153. package/package.json +144 -0
@@ -0,0 +1,213 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _vue = require('vue');
6
+
7
+ var _vue2 = _interopRequireDefault(_vue);
8
+
9
+ var _popup = require('./popup');
10
+
11
+ var _popper = require('./popper.js');
12
+
13
+ var _popper2 = _interopRequireDefault(_popper);
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ // todo 可以替换但是 替换后功能有差异 待定
18
+ // import PopperJS2 from 'popper.js'
19
+ var PopperJS = _vue2.default.prototype.$isServer ? function () {} : _popper2.default;
20
+ var stop = function stop(e) {
21
+ return e.stopPropagation();
22
+ };
23
+
24
+ /**
25
+ * @param {HTMLElement} [reference=$refs.reference] - The reference element used to position the popper.
26
+ * @param {HTMLElement} [popper=$refs.popper] - The HTML element used as popper, or a configuration used to generate the popper.
27
+ * @param {String} [placement=button] - Placement of the popper accepted values: top(-start, -end), right(-start, -end), bottom(-start, -end), left(-start, -end)
28
+ * @param {Number} [offset=0] - Amount of pixels the popper will be shifted (can be negative).
29
+ * @param {Boolean} [visible=false] Visibility of the popup element.
30
+ * @param {Boolean} [visible-arrow=false] Visibility of the arrow, no style.
31
+ */
32
+ exports.default = {
33
+ props: {
34
+ transformOrigin: {
35
+ type: [Boolean, String],
36
+ default: true
37
+ },
38
+ placement: {
39
+ type: String,
40
+ default: 'bottom'
41
+ },
42
+ boundariesPadding: {
43
+ type: Number,
44
+ default: 5
45
+ },
46
+ reference: {},
47
+ popper: {},
48
+ offset: {
49
+ default: 0
50
+ },
51
+ value: Boolean,
52
+ visibleArrow: Boolean,
53
+ arrowOffset: {
54
+ type: Number,
55
+ default: 35
56
+ },
57
+ appendToBody: {
58
+ type: Boolean,
59
+ default: true
60
+ },
61
+ popperOptions: {
62
+ type: Object,
63
+ default: function _default() {
64
+ return {
65
+ gpuAcceleration: false
66
+ };
67
+ }
68
+ }
69
+ },
70
+
71
+ data: function data() {
72
+ return {
73
+ showPopper: false,
74
+ currentPlacement: ''
75
+ };
76
+ },
77
+
78
+
79
+ watch: {
80
+ value: {
81
+ immediate: true,
82
+ handler: function handler(val) {
83
+ this.showPopper = val;
84
+ this.$emit('input', val);
85
+ }
86
+ },
87
+
88
+ showPopper: function showPopper(val) {
89
+ if (this.disabled) return;
90
+ val ? this.updatePopper() : this.destroyPopper();
91
+ this.$emit('input', val);
92
+ }
93
+ },
94
+
95
+ methods: {
96
+ createPopper: function createPopper() {
97
+ var _this = this;
98
+
99
+ if (this.$isServer) return;
100
+ this.currentPlacement = this.currentPlacement || this.placement;
101
+ if (!/^(top|bottom|left|right)(-start|-end)?$/g.test(this.currentPlacement)) {
102
+ return;
103
+ }
104
+
105
+ var options = this.popperOptions;
106
+ var popper = this.popperElm = this.popperElm || this.popper || this.$refs.popper;
107
+ var reference = this.referenceElm = this.referenceElm || this.reference || this.$refs.reference;
108
+
109
+ if (!reference && this.$slots.reference && this.$slots.reference[0]) {
110
+ reference = this.referenceElm = this.$slots.reference[0].elm;
111
+ }
112
+
113
+ if (!popper || !reference) return;
114
+ if (this.visibleArrow) this.appendArrow(popper);
115
+ if (this.appendToBody) document.body.appendChild(this.popperElm);
116
+ if (this.popperJS && this.popperJS.destroy) {
117
+ this.popperJS.destroy();
118
+ }
119
+ options.placement = this.currentPlacement;
120
+ options.offset = this.offset;
121
+ options.arrowOffset = this.arrowOffset;
122
+ this.popperJS = new PopperJS(reference, popper, options);
123
+ this.popperJS.onCreate(function (_) {
124
+ _this.$emit('created', _this);
125
+ _this.resetTransformOrigin();
126
+ _this.$nextTick(_this.updatePopper);
127
+ });
128
+ if (typeof options.onUpdate === 'function') {
129
+ this.popperJS.onUpdate(options.onUpdate);
130
+ }
131
+ this.popperJS._popper.style.zIndex = _popup.PopupManager.nextZIndex();
132
+ this.popperElm.addEventListener('click', stop);
133
+ },
134
+ updatePopper: function updatePopper() {
135
+ var popperJS = this.popperJS;
136
+ if (popperJS) {
137
+ popperJS.update();
138
+ if (popperJS._popper) {
139
+ popperJS._popper.style.zIndex = _popup.PopupManager.nextZIndex();
140
+ }
141
+ } else {
142
+ this.createPopper();
143
+ }
144
+ },
145
+ doDestroy: function doDestroy(forceDestroy) {
146
+ /* istanbul ignore if */
147
+ if (!this.popperJS || this.showPopper && !forceDestroy) return;
148
+ if (!forceDestroy) {
149
+ if (this.popperElm && this.popperElm.parentNode === document.body) {
150
+ this.popperElm.removeEventListener('click', stop);
151
+ document.body.removeChild(this.popperElm);
152
+ }
153
+ }
154
+ this.popperJS.destroy();
155
+ this.popperJS = null;
156
+ },
157
+ destroyPopper: function destroyPopper() {
158
+ if (this.popperJS) {
159
+ this.resetTransformOrigin();
160
+ }
161
+ },
162
+ resetTransformOrigin: function resetTransformOrigin() {
163
+ if (!this.transformOrigin) return;
164
+ var placementMap = {
165
+ top: 'bottom',
166
+ bottom: 'top',
167
+ left: 'right',
168
+ right: 'left'
169
+ };
170
+ var placement = this.popperJS._popper.getAttribute('x-placement').split('-')[0];
171
+ var origin = placementMap[placement];
172
+ this.popperJS._popper.style.transformOrigin = typeof this.transformOrigin === 'string' ? this.transformOrigin : ['top', 'bottom'].indexOf(placement) > -1 ? 'center ' + origin : origin + ' center';
173
+ },
174
+ appendArrow: function appendArrow(element) {
175
+ var hash = void 0;
176
+ if (this.appended) {
177
+ return;
178
+ }
179
+
180
+ this.appended = true;
181
+
182
+ for (var item in element.attributes) {
183
+ if (/^_v-/.test(element.attributes[item].name)) {
184
+ hash = element.attributes[item].name;
185
+ break;
186
+ }
187
+ }
188
+
189
+ var arrow = document.createElement('div');
190
+
191
+ if (hash) {
192
+ arrow.setAttribute(hash, '');
193
+ }
194
+ arrow.setAttribute('x-arrow', '');
195
+ arrow.className = 'popper__arrow';
196
+ element.appendChild(arrow);
197
+ }
198
+ },
199
+
200
+ beforeDestroy: function beforeDestroy() {
201
+ this.doDestroy(true);
202
+ if (this.popperElm && this.popperElm.parentNode === document.body) {
203
+ this.popperElm.removeEventListener('click', stop);
204
+ document.body.removeChild(this.popperElm);
205
+ }
206
+ },
207
+
208
+
209
+ // call destroy in keep-alive mode
210
+ deactivated: function deactivated() {
211
+ this.$options.beforeDestroy[0].call(this);
212
+ }
213
+ };