@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,942 +0,0 @@
1
- <template>
2
- <base-input
3
- class="base-date-editor"
4
- :class="'base-date-editor--' + type"
5
- :readonly="!editable || readonly || type === 'dates' || type === 'week'"
6
- :disabled="pickerDisabled"
7
- :size="pickerSize"
8
- :ripple="ripple"
9
- :show-label="false"
10
- :name="name"
11
- v-bind="firstInputId"
12
- v-if="!ranged"
13
- v-clickoutside="handleClose"
14
- :placeholder="placeholder"
15
- @focus="handleFocus"
16
- @keydown.native="handleKeydown"
17
- :value="displayValue"
18
- @input="value => userInput = value"
19
- @change="handleChange"
20
- @mouseenter.native="handleMouseEnter"
21
- @mouseleave.native="showClose = false"
22
- :validateEvent="false"
23
- ref="reference">
24
- <i v-if="prefixIcon"
25
- slot="prefix"
26
- class="base-input__icon"
27
- :class="triggerClass"
28
- @click="handleFocus">
29
- </i>
30
- <i slot="suffix"
31
- class="base-input__icon"
32
- @click="handleClickIcon"
33
- :class="[showClose ? '' + clearIcon : '']"
34
- v-if="haveTrigger">
35
- </i>
36
- </base-input>
37
- <div
38
- class="base-date-editor base-range-editor base-input__inner"
39
- :class="[
40
- 'base-date-editor--' + type,
41
- pickerSize ? `base-range-editor--${ pickerSize }` : '',
42
- pickerDisabled ? 'is-disabled' : '',
43
- pickerVisible ? 'is-active' : ''
44
- ]"
45
- @click="handleRangeClick"
46
- @mouseenter="handleMouseEnter"
47
- @mouseleave="showClose = false"
48
- @keydown="handleKeydown"
49
- ref="reference"
50
- v-clickoutside="handleClose"
51
- v-else>
52
- <i :class="['base-input__icon', 'base-range__icon', triggerClass]"></i>
53
- <input
54
- autocomplete="off"
55
- :placeholder="startPlaceholder"
56
- :value="displayValue && displayValue[0]"
57
- :disabled="pickerDisabled"
58
- v-bind="firstInputId"
59
- :readonly="!editable || readonly"
60
- :name="name && name[0]"
61
- @input="handleStartInput"
62
- @change="handleStartChange"
63
- @focus="handleFocus"
64
- class="base-range-input">
65
- <slot name="range-separator">
66
- <span class="base-range-separator">{{ rangeSeparator }}</span>
67
- </slot>
68
- <input
69
- autocomplete="off"
70
- :placeholder="endPlaceholder"
71
- :value="displayValue && displayValue[1]"
72
- :disabled="pickerDisabled"
73
- v-bind="secondInputId"
74
- :readonly="!editable || readonly"
75
- :name="name && name[1]"
76
- @input="handleEndInput"
77
- @change="handleEndChange"
78
- @focus="handleFocus"
79
- class="base-range-input">
80
- <i
81
- @click="handleClickIcon"
82
- v-if="haveTrigger"
83
- :class="[showClose ? '' + clearIcon : '']"
84
- class="base-input__icon base-range__close-icon">
85
- </i>
86
- </div>
87
- </template>
88
-
89
- <script>
90
- import Vue from 'vue';
91
- import Clickoutside from '../util/clickoutside';
92
- import { formatDate, parseDate, isDateObject, getWeekNumber } from '../util/date-util';
93
- import Popper from '../util/vue-popper';
94
- import Emitter from '../mixin/emitter';
95
- import BaseInput from '../input/Input';
96
- import merge from '../util/merge';
97
-
98
- const NewPopper = {
99
- props: {
100
- appendToBody: Popper.props.appendToBody,
101
- offset: Popper.props.offset,
102
- boundariesPadding: Popper.props.boundariesPadding,
103
- arrowOffset: Popper.props.arrowOffset
104
- },
105
- methods: Popper.methods,
106
- data() {
107
- return merge({ visibleArrow: false }, Popper.data);
108
- },
109
- beforeDestroy: Popper.beforeDestroy
110
- };
111
-
112
- const DEFAULT_FORMATS = {
113
- date: 'yyyy-MM-dd',
114
- month: 'yyyy-MM',
115
- datetime: 'yyyy-MM-dd HH:mm:ss',
116
- time: 'HH:mm:ss',
117
- week: 'yyyywWW',
118
- timerange: 'HH:mm:ss',
119
- daterange: 'yyyy-MM-dd',
120
- monthrange: 'yyyy-MM',
121
- yearrange: 'yyyy',
122
- datetimerange: 'yyyy-MM-dd HH:mm:ss',
123
- year: 'yyyy'
124
- };
125
- const HAVE_TRIGGER_TYPES = [
126
- 'date',
127
- 'datetime',
128
- 'time',
129
- 'time-select',
130
- 'week',
131
- 'month',
132
- 'year',
133
- 'daterange',
134
- 'monthrange',
135
- 'yearrange',
136
- 'timerange',
137
- 'datetimerange',
138
- 'dates'
139
- ];
140
- const DATE_FORMATTER = function(value, format) {
141
- if (format === 'timestamp') return value.getTime();
142
- return formatDate(value, format);
143
- };
144
- const DATE_PARSER = function(text, format) {
145
- if (format === 'timestamp') return new Date(Number(text));
146
- return parseDate(text, format);
147
- };
148
- const RANGE_FORMATTER = function(value, format) {
149
- if (Array.isArray(value) && value.length === 2) {
150
- const start = value[0];
151
- const end = value[1];
152
-
153
- if (start && end) {
154
- return [DATE_FORMATTER(start, format), DATE_FORMATTER(end, format)];
155
- }
156
- }
157
- return '';
158
- };
159
- const RANGE_PARSER = function(array, format, separator) {
160
- if (!Array.isArray(array)) {
161
- array = array.split(separator);
162
- }
163
- if (array.length === 2) {
164
- const range1 = array[0];
165
- const range2 = array[1];
166
-
167
- return [DATE_PARSER(range1, format), DATE_PARSER(range2, format)];
168
- }
169
- return [];
170
- };
171
- const TYPE_VALUE_RESOLVER_MAP = {
172
- default: {
173
- formatter(value) {
174
- if (!value) return '';
175
- return '' + value;
176
- },
177
- parser(text) {
178
- if (text === undefined || text === '') return null;
179
- return text;
180
- }
181
- },
182
- week: {
183
- formatter(value, format) {
184
- let week = getWeekNumber(value);
185
- let month = value.getMonth();
186
- const trueDate = new Date(value);
187
- if (week === 1 && month === 11) {
188
- trueDate.setHours(0, 0, 0, 0);
189
- trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
190
- }
191
- let date = formatDate(trueDate, format);
192
-
193
- date = /WW/.test(date)
194
- ? date.replace(/WW/, week < 10 ? '0' + week : week)
195
- : date.replace(/W/, week);
196
- return date;
197
- },
198
- parser(text, format) {
199
- // parse as if a normal date
200
- return TYPE_VALUE_RESOLVER_MAP.date.parser(text, format);
201
- }
202
- },
203
- date: {
204
- formatter: DATE_FORMATTER,
205
- parser: DATE_PARSER
206
- },
207
- datetime: {
208
- formatter: DATE_FORMATTER,
209
- parser: DATE_PARSER
210
- },
211
- daterange: {
212
- formatter: RANGE_FORMATTER,
213
- parser: RANGE_PARSER
214
- },
215
- monthrange: {
216
- formatter: RANGE_FORMATTER,
217
- parser: RANGE_PARSER
218
- },
219
- yearrange: {
220
- formatter: RANGE_FORMATTER,
221
- parser: RANGE_PARSER
222
- },
223
- datetimerange: {
224
- formatter: RANGE_FORMATTER,
225
- parser: RANGE_PARSER
226
- },
227
- timerange: {
228
- formatter: RANGE_FORMATTER,
229
- parser: RANGE_PARSER
230
- },
231
- time: {
232
- formatter: DATE_FORMATTER,
233
- parser: DATE_PARSER
234
- },
235
- month: {
236
- formatter: DATE_FORMATTER,
237
- parser: DATE_PARSER
238
- },
239
- year: {
240
- formatter: DATE_FORMATTER,
241
- parser: DATE_PARSER
242
- },
243
- number: {
244
- formatter(value) {
245
- if (!value) return '';
246
- return '' + value;
247
- },
248
- parser(text) {
249
- let result = Number(text);
250
-
251
- if (!isNaN(text)) {
252
- return result;
253
- } else {
254
- return null;
255
- }
256
- }
257
- },
258
- dates: {
259
- formatter(value, format) {
260
- return value.map(date => DATE_FORMATTER(date, format));
261
- },
262
- parser(value, format) {
263
- return (typeof value === 'string' ? value.split(', ') : value)
264
- .map(date => date instanceof Date ? date : DATE_PARSER(date, format));
265
- }
266
- }
267
- };
268
- const PLACEMENT_MAP = {
269
- left: 'bottom-start',
270
- center: 'bottom',
271
- right: 'bottom-end'
272
- };
273
-
274
- const parseAsFormatAndType = (value, customFormat, type, rangeSeparator = '-') => {
275
- if (!value) return null;
276
- const parser = (
277
- TYPE_VALUE_RESOLVER_MAP[type] ||
278
- TYPE_VALUE_RESOLVER_MAP['default']
279
- ).parser;
280
- const format = customFormat || DEFAULT_FORMATS[type];
281
- return parser(value, format, rangeSeparator);
282
- };
283
-
284
- const formatAsFormatAndType = (value, customFormat, type) => {
285
- if (!value) return null;
286
- const formatter = (
287
- TYPE_VALUE_RESOLVER_MAP[type] ||
288
- TYPE_VALUE_RESOLVER_MAP['default']
289
- ).formatter;
290
- const format = customFormat || DEFAULT_FORMATS[type];
291
- return formatter(value, format);
292
- };
293
-
294
- /*
295
- * Considers:
296
- * 1. Date object
297
- * 2. date string
298
- * 3. array of 1 or 2
299
- */
300
- const valueEquals = function(a, b) {
301
- // considers Date object and string
302
- const dateEquals = function(a, b) {
303
- const aIsDate = a instanceof Date;
304
- const bIsDate = b instanceof Date;
305
- if (aIsDate && bIsDate) {
306
- return a.getTime() === b.getTime();
307
- }
308
- if (!aIsDate && !bIsDate) {
309
- return a === b;
310
- }
311
- return false;
312
- };
313
-
314
- const aIsArray = a instanceof Array;
315
- const bIsArray = b instanceof Array;
316
- if (aIsArray && bIsArray) {
317
- if (a.length !== b.length) {
318
- return false;
319
- }
320
- return a.every((item, index) => dateEquals(item, b[index]));
321
- }
322
- if (!aIsArray && !bIsArray) {
323
- return dateEquals(a, b);
324
- }
325
- return false;
326
- };
327
-
328
- const isString = function(val) {
329
- return typeof val === 'string' || val instanceof String;
330
- };
331
-
332
- const validator = function(val) {
333
- // either: String, Array of String, null / undefined
334
- return (
335
- val === null ||
336
- val === undefined ||
337
- isString(val) ||
338
- (Array.isArray(val) && val.length === 2 && val.every(isString))
339
- );
340
- };
341
-
342
- export default {
343
- mixins: [Emitter, NewPopper],
344
-
345
- inject: {
346
- baseForm: {
347
- default: ''
348
- },
349
- baseFormItem: {
350
- default: ''
351
- }
352
- },
353
-
354
- props: {
355
- size: String,
356
- format: String,
357
- valueFormat: String,
358
- readonly: Boolean,
359
- placeholder: String,
360
- startPlaceholder: String,
361
- endPlaceholder: String,
362
- prefixIcon: String,
363
- clearIcon: {
364
- type: String,
365
- default: 'base-icon-circle-close'
366
- },
367
- name: {
368
- default: '',
369
- validator
370
- },
371
- disabled: Boolean,
372
- clearable: {
373
- type: Boolean,
374
- default: true
375
- },
376
- id: {
377
- default: '',
378
- validator
379
- },
380
- popperClass: String,
381
- editable: {
382
- type: Boolean,
383
- default: true
384
- },
385
- ripple: {
386
- type: Boolean,
387
- default: true
388
- },
389
- align: {
390
- type: String,
391
- default: 'left'
392
- },
393
- value: {},
394
- defaultValue: {},
395
- defaultTime: {},
396
- rangeSeparator: {
397
- default: '-'
398
- },
399
- pickerOptions: {},
400
- unlinkPanels: Boolean,
401
- validateEvent: {
402
- type: Boolean,
403
- default: true
404
- }
405
- },
406
-
407
- components: { BaseInput },
408
-
409
- directives: { Clickoutside },
410
-
411
- data() {
412
- return {
413
- pickerVisible: false,
414
- showClose: false,
415
- userInput: null,
416
- valueOnOpen: null, // value when picker opens, used to determine whether to emit change
417
- unwatchPickerOptions: null
418
- };
419
- },
420
-
421
- watch: {
422
- pickerVisible(val) {
423
- if (this.readonly || this.pickerDisabled) return;
424
- if (val) {
425
- this.showPicker();
426
- this.valueOnOpen = Array.isArray(this.value) ? [...this.value] : this.value;
427
- } else {
428
- this.hidePicker();
429
- this.emitChange(this.value);
430
- this.userInput = null;
431
- if (this.validateEvent) {
432
- this.dispatch('BaseFormItem', 'base.form.blur');
433
- }
434
- this.$emit('blur', this);
435
- this.blur();
436
- }
437
- },
438
- parsedValue: {
439
- immediate: true,
440
- handler(val) {
441
- if (this.picker) {
442
- this.picker.value = val;
443
- }
444
- }
445
- },
446
- defaultValue(val) {
447
- // NOTE: should eventually move to jsx style picker + panel ?
448
- if (this.picker) {
449
- this.picker.defaultValue = val;
450
- }
451
- },
452
- value(val, oldVal) {
453
- if (!valueEquals(val, oldVal) && !this.pickerVisible && this.validateEvent) {
454
- this.dispatch('BaseFormItem', 'base.form.change', val);
455
- }
456
- }
457
- },
458
-
459
- computed: {
460
- ranged() {
461
- return this.type.indexOf('range') > -1;
462
- },
463
-
464
- reference() {
465
- const reference = this.$refs.reference;
466
- return reference.$el || reference;
467
- },
468
-
469
- refInput() {
470
- if (this.reference) {
471
- return [].slice.call(this.reference.querySelectorAll('input'));
472
- }
473
- return [];
474
- },
475
-
476
- valueIsEmpty() {
477
- const val = this.value;
478
- if (Array.isArray(val)) {
479
- for (let i = 0, len = val.length; i < len; i++) {
480
- if (val[i]) {
481
- return false;
482
- }
483
- }
484
- } else {
485
- if (val) {
486
- return false;
487
- }
488
- }
489
- return true;
490
- },
491
-
492
- triggerClass() {
493
- return this.prefixIcon || (this.type.indexOf('time') !== -1 ? 'base-icon-time' : 'base-icon-date');
494
- },
495
-
496
- selectionMode() {
497
- if (this.type === 'week') {
498
- return 'week';
499
- } else if (this.type === 'month') {
500
- return 'month';
501
- } else if (this.type === 'year') {
502
- return 'year';
503
- } else if (this.type === 'dates') {
504
- return 'dates';
505
- }
506
-
507
- return 'day';
508
- },
509
-
510
- haveTrigger() {
511
- if (typeof this.showTrigger !== 'undefined') {
512
- return this.showTrigger;
513
- }
514
- return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
515
- },
516
-
517
- displayValue() {
518
- const formattedValue = formatAsFormatAndType(this.parsedValue, this.format, this.type, this.rangeSeparator);
519
- if (Array.isArray(this.userInput)) {
520
- return [
521
- this.userInput[0] || (formattedValue && formattedValue[0]) || '',
522
- this.userInput[1] || (formattedValue && formattedValue[1]) || ''
523
- ];
524
- } else if (this.userInput !== null) {
525
- return this.userInput;
526
- } else if (formattedValue) {
527
- return this.type === 'dates'
528
- ? formattedValue.join(', ')
529
- : formattedValue;
530
- } else {
531
- return '';
532
- }
533
- },
534
-
535
- parsedValue() {
536
- if (!this.value) return this.value; // component value is not set
537
- if (this.type === 'time-select') return this.value; // time-select does not require parsing, this might change in next major version
538
-
539
- const valueIsDateObject = isDateObject(this.value) || (Array.isArray(this.value) && this.value.every(isDateObject));
540
- if (valueIsDateObject) {
541
- return this.value;
542
- }
543
-
544
- if (this.valueFormat) {
545
- return parseAsFormatAndType(this.value, this.valueFormat, this.type, this.rangeSeparator) || this.value;
546
- }
547
-
548
- // NOTE: deal with common but incorrect usage, should remove in next major version
549
- // user might provide string / timestamp without value-format, coerce them into date (or array of date)
550
- return Array.isArray(this.value) ? this.value.map(val => new Date(val)) : new Date(this.value);
551
- },
552
-
553
- _baseFormItemSize() {
554
- return (this.baseFormItem || {}).baseFormItemSize;
555
- },
556
-
557
- pickerSize() {
558
- return this.size || this._baseFormItemSize || (this.$ELEMENT || {}).size;
559
- },
560
-
561
- pickerDisabled() {
562
- return this.disabled || (this.baseForm || {}).disabled;
563
- },
564
-
565
- firstInputId() {
566
- const obj = {};
567
- let id;
568
- if (this.ranged) {
569
- id = this.id && this.id[0];
570
- } else {
571
- id = this.id;
572
- }
573
- if (id) obj.id = id;
574
- return obj;
575
- },
576
-
577
- secondInputId() {
578
- const obj = {};
579
- let id;
580
- if (this.ranged) {
581
- id = this.id && this.id[1];
582
- }
583
- if (id) obj.id = id;
584
- return obj;
585
- }
586
- },
587
-
588
- created() {
589
- // vue-popper
590
- this.popperOptions = {
591
- boundariesPadding: 0,
592
- gpuAcceleration: false
593
- };
594
- this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
595
-
596
- this.$on('fieldReset', this.handleFieldReset);
597
- },
598
-
599
- methods: {
600
- focus() {
601
- if (!this.ranged) {
602
- this.$refs.reference.focus();
603
- } else {
604
- this.handleFocus();
605
- }
606
- },
607
-
608
- blur() {
609
- this.refInput.forEach(input => input.blur());
610
- },
611
-
612
- // {parse, formatTo} Value deals maps component value with internal Date
613
- parseValue(value) {
614
- const isParsed = isDateObject(value) || (Array.isArray(value) && value.every(isDateObject));
615
- if (this.valueFormat && !isParsed) {
616
- return parseAsFormatAndType(value, this.valueFormat, this.type, this.rangeSeparator) || value;
617
- } else {
618
- return value;
619
- }
620
- },
621
-
622
- formatToValue(date) {
623
- const isFormattable = isDateObject(date) || (Array.isArray(date) && date.every(isDateObject));
624
- if (this.valueFormat && isFormattable) {
625
- return formatAsFormatAndType(date, this.valueFormat, this.type, this.rangeSeparator);
626
- } else {
627
- return formatAsFormatAndType(date, null, this.type, this.rangeSeparator);
628
- }
629
- },
630
-
631
- // {parse, formatTo} String deals with user input
632
- parseString(value) {
633
- const type = Array.isArray(value) ? this.type : this.type.replace('range', '');
634
- return parseAsFormatAndType(value, this.format, type);
635
- },
636
-
637
- formatToString(value) {
638
- const type = Array.isArray(value) ? this.type : this.type.replace('range', '');
639
- return formatAsFormatAndType(value, this.format, type);
640
- },
641
-
642
- handleMouseEnter() {
643
- if (this.readonly || this.pickerDisabled) return;
644
- if (!this.valueIsEmpty && this.clearable) {
645
- this.showClose = true;
646
- }
647
- },
648
-
649
- handleChange() {
650
- if (this.userInput) {
651
- const value = this.parseString(this.displayValue);
652
- if (value) {
653
- this.picker.value = value;
654
- if (this.isValidValue(value)) {
655
- this.emitInput(value);
656
- this.userInput = null;
657
- }
658
- }
659
- }
660
- if (this.userInput === '') {
661
- this.emitInput(null);
662
- this.emitChange(null);
663
- this.userInput = null;
664
- }
665
- },
666
-
667
- handleStartInput(event) {
668
- if (this.userInput) {
669
- this.userInput = [event.target.value, this.userInput[1]];
670
- } else {
671
- this.userInput = [event.target.value, null];
672
- }
673
- },
674
-
675
- handleEndInput(event) {
676
- if (this.userInput) {
677
- this.userInput = [this.userInput[0], event.target.value];
678
- } else {
679
- this.userInput = [null, event.target.value];
680
- }
681
- },
682
-
683
- handleStartChange(event) {
684
- const value = this.parseString(this.userInput && this.userInput[0]);
685
- if (value) {
686
- this.userInput = [this.formatToString(value), this.displayValue[1]];
687
- const newValue = [value, this.picker.value && this.picker.value[1]];
688
- this.picker.value = newValue;
689
- if (this.isValidValue(newValue)) {
690
- this.emitInput(newValue);
691
- this.userInput = null;
692
- }
693
- }
694
- },
695
-
696
- handleEndChange(event) {
697
- const value = this.parseString(this.userInput && this.userInput[1]);
698
- if (value) {
699
- this.userInput = [this.displayValue[0], this.formatToString(value)];
700
- const newValue = [this.picker.value && this.picker.value[0], value];
701
- this.picker.value = newValue;
702
- if (this.isValidValue(newValue)) {
703
- this.emitInput(newValue);
704
- this.userInput = null;
705
- }
706
- }
707
- },
708
-
709
- handleClickIcon(event) {
710
- if (this.readonly || this.pickerDisabled) return;
711
- if (this.showClose) {
712
- this.valueOnOpen = this.value;
713
- event.stopPropagation();
714
- this.emitInput(null);
715
- this.emitChange(null);
716
- this.showClose = false;
717
- if (this.picker && typeof this.picker.handleClear === 'function') {
718
- this.picker.handleClear();
719
- }
720
- } else {
721
- this.pickerVisible = !this.pickerVisible;
722
- }
723
- },
724
-
725
- handleClose() {
726
- if (!this.pickerVisible) return;
727
- this.pickerVisible = false;
728
-
729
- if (this.type === 'dates') {
730
- // restore to former value
731
- const oldValue = parseAsFormatAndType(this.valueOnOpen, this.valueFormat, this.type, this.rangeSeparator) || this.valueOnOpen;
732
- this.emitInput(oldValue);
733
- }
734
- },
735
-
736
- handleFieldReset(initialValue) {
737
- this.userInput = initialValue === '' ? null : initialValue;
738
- },
739
-
740
- handleFocus() {
741
- const type = this.type;
742
-
743
- if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
744
- this.pickerVisible = true;
745
- }
746
- this.$emit('focus', this);
747
- },
748
-
749
- handleKeydown(event) {
750
- const keyCode = event.keyCode;
751
-
752
- // ESC
753
- if (keyCode === 27) {
754
- this.pickerVisible = false;
755
- event.stopPropagation();
756
- return;
757
- }
758
-
759
- // Tab
760
- if (keyCode === 9) {
761
- if (!this.ranged) {
762
- this.handleChange();
763
- this.pickerVisible = this.picker.visible = false;
764
- this.blur();
765
- event.stopPropagation();
766
- } else {
767
- // user may change focus between two input
768
- setTimeout(() => {
769
- if (this.refInput.indexOf(document.activeElement) === -1) {
770
- this.pickerVisible = false;
771
- this.blur();
772
- event.stopPropagation();
773
- }
774
- }, 0);
775
- }
776
- return;
777
- }
778
-
779
- // Enter
780
- if (keyCode === 13) {
781
- if (this.userInput === '' || this.isValidValue(this.parseString(this.displayValue))) {
782
- this.handleChange();
783
- this.pickerVisible = this.picker.visible = false;
784
- this.blur();
785
- }
786
- event.stopPropagation();
787
- return;
788
- }
789
-
790
- // if user is typing, do not let picker handle key input
791
- if (this.userInput) {
792
- event.stopPropagation();
793
- return;
794
- }
795
-
796
- // delegate other keys to panel
797
- if (this.picker && this.picker.handleKeydown) {
798
- this.picker.handleKeydown(event);
799
- }
800
- },
801
-
802
- handleRangeClick() {
803
- const type = this.type;
804
-
805
- if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
806
- this.pickerVisible = true;
807
- }
808
- this.$emit('focus', this);
809
- },
810
-
811
- hidePicker() {
812
- if (this.picker) {
813
- this.picker.resetView && this.picker.resetView();
814
- this.pickerVisible = this.picker.visible = false;
815
- this.destroyPopper();
816
- }
817
- },
818
-
819
- showPicker() {
820
- if (this.$isServer) return;
821
- if (!this.picker) {
822
- this.mountPicker();
823
- }
824
- this.pickerVisible = this.picker.visible = true;
825
-
826
- this.updatePopper();
827
-
828
- this.picker.value = this.parsedValue;
829
- this.picker.resetView && this.picker.resetView();
830
-
831
- this.$nextTick(() => {
832
- this.picker.adjustSpinners && this.picker.adjustSpinners();
833
- });
834
- },
835
-
836
- mountPicker() {
837
- this.picker = new Vue(this.panel).$mount();
838
- this.picker.defaultValue = this.defaultValue;
839
- this.picker.defaultTime = this.defaultTime;
840
- this.picker.popperClass = this.popperClass;
841
- this.popperElm = this.picker.$el;
842
- this.picker.width = this.reference.getBoundingClientRect().width;
843
- this.picker.showTime = this.type === 'datetime' || this.type === 'datetimerange';
844
- this.picker.selectionMode = this.selectionMode;
845
- this.picker.unlinkPanels = this.unlinkPanels;
846
- this.picker.arrowControl = this.arrowControl || this.timeArrowControl || false;
847
- this.$watch('format', (format) => {
848
- this.picker.format = format;
849
- });
850
-
851
- const updateOptions = () => {
852
- const options = this.pickerOptions;
853
-
854
- if (options && options.selectableRange) {
855
- let ranges = options.selectableRange;
856
- const parser = TYPE_VALUE_RESOLVER_MAP.datetimerange.parser;
857
- const format = DEFAULT_FORMATS.timerange;
858
-
859
- ranges = Array.isArray(ranges) ? ranges : [ranges];
860
- this.picker.selectableRange = ranges.map(range => parser(range, format, this.rangeSeparator));
861
- }
862
-
863
- for (const option in options) {
864
- if (options.hasOwnProperty(option) &&
865
- // 忽略 time-picker 的该配置项
866
- option !== 'selectableRange') {
867
- this.picker[option] = options[option];
868
- }
869
- }
870
-
871
- // main format must prevail over undocumented pickerOptions.format
872
- if (this.format) {
873
- this.picker.format = this.format;
874
- }
875
- };
876
- updateOptions();
877
- this.unwatchPickerOptions = this.$watch('pickerOptions', () => updateOptions(), { deep: true });
878
- this.$el.appendChild(this.picker.$el);
879
- this.picker.resetView && this.picker.resetView();
880
-
881
- this.picker.$on('dodestroy', this.doDestroy);
882
- this.picker.$on('pick', (date = '', visible = false) => {
883
- this.userInput = null;
884
- this.pickerVisible = this.picker.visible = visible;
885
- this.emitInput(date);
886
- this.picker.resetView && this.picker.resetView();
887
- });
888
-
889
- this.picker.$on('select-range', (start, end, pos) => {
890
- if (this.refInput.length === 0) return;
891
- if (!pos || pos === 'min') {
892
- this.refInput[0].setSelectionRange(start, end);
893
- this.refInput[0].focus();
894
- } else if (pos === 'max') {
895
- this.refInput[1].setSelectionRange(start, end);
896
- this.refInput[1].focus();
897
- }
898
- });
899
- },
900
-
901
- unmountPicker() {
902
- if (this.picker) {
903
- this.picker.$destroy();
904
- this.picker.$off();
905
- if (typeof this.unwatchPickerOptions === 'function') {
906
- this.unwatchPickerOptions();
907
- }
908
- this.picker.$el.parentNode.removeChild(this.picker.$el);
909
- }
910
- },
911
-
912
- emitChange(val) {
913
- // determine user real change only
914
- if (!valueEquals(val, this.valueOnOpen)) {
915
- this.$emit('change', val);
916
- this.valueOnOpen = val;
917
- if (this.validateEvent) {
918
- this.dispatch('BaseFormItem', 'base.form.change', val);
919
- }
920
- }
921
- },
922
-
923
- emitInput(val) {
924
- const formatted = this.formatToValue(val);
925
- if (!valueEquals(this.value, formatted)) {
926
- this.$emit('input', formatted);
927
- }
928
- },
929
-
930
- isValidValue(value) {
931
- if (!this.picker) {
932
- this.mountPicker();
933
- }
934
- if (this.picker.isValidValue) {
935
- return value && this.picker.isValidValue(value);
936
- } else {
937
- return true;
938
- }
939
- }
940
- }
941
- };
942
- </script>