vue-devui 1.0.0-rc.8 → 1.0.1

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 (228) hide show
  1. package/README.md +188 -149
  2. package/alert/index.es.js +14 -9
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +8392 -418
  6. package/auto-complete/index.umd.js +29 -5
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +59 -74
  9. package/avatar/index.umd.js +1 -1
  10. package/badge/index.es.js +10 -4
  11. package/badge/index.umd.js +1 -1
  12. package/badge/style.css +1 -1
  13. package/button/index.es.js +191 -53
  14. package/button/index.umd.js +17 -17
  15. package/button/style.css +1 -1
  16. package/card/index.es.js +7 -3
  17. package/card/index.umd.js +1 -1
  18. package/card/style.css +1 -1
  19. package/checkbox/index.es.js +8050 -241
  20. package/checkbox/index.umd.js +27 -1
  21. package/checkbox/style.css +1 -1
  22. package/{date-picker → collapse}/index.d.ts +0 -0
  23. package/collapse/index.es.js +213 -0
  24. package/collapse/index.umd.js +1 -0
  25. package/{date-picker → collapse}/package.json +1 -1
  26. package/collapse/style.css +1 -0
  27. package/countdown/index.es.js +56 -13
  28. package/countdown/index.umd.js +1 -1
  29. package/date-picker-pro/index.d.ts +7 -0
  30. package/date-picker-pro/index.es.js +12022 -0
  31. package/date-picker-pro/index.umd.js +27 -0
  32. package/date-picker-pro/package.json +7 -0
  33. package/date-picker-pro/style.css +1 -0
  34. package/drawer/index.es.js +24 -7
  35. package/drawer/index.umd.js +1 -1
  36. package/drawer/style.css +1 -1
  37. package/dropdown/index.es.js +190 -165
  38. package/dropdown/index.umd.js +1 -1
  39. package/dropdown/style.css +1 -1
  40. package/editable-select/index.es.js +785 -145
  41. package/editable-select/index.umd.js +1 -1
  42. package/editable-select/style.css +1 -1
  43. package/form/index.es.js +399 -300
  44. package/form/index.umd.js +16 -16
  45. package/form/style.css +1 -1
  46. package/fullscreen/index.es.js +2 -2
  47. package/fullscreen/index.umd.js +1 -1
  48. package/grid/index.es.js +8 -6
  49. package/grid/index.umd.js +1 -1
  50. package/icon/index.es.js +185 -23
  51. package/icon/index.umd.js +1 -1
  52. package/icon/style.css +1 -0
  53. package/image-preview/index.es.js +2 -2
  54. package/image-preview/index.umd.js +1 -1
  55. package/image-preview/style.css +1 -1
  56. package/input/index.es.js +8220 -45
  57. package/input/index.umd.js +27 -1
  58. package/input/style.css +1 -1
  59. package/input-number/index.es.js +279 -204
  60. package/input-number/index.umd.js +1 -1
  61. package/input-number/style.css +1 -1
  62. package/layout/index.es.js +3 -3
  63. package/layout/index.umd.js +1 -1
  64. package/loading/index.es.js +53 -53
  65. package/loading/index.umd.js +1 -1
  66. package/loading/style.css +1 -1
  67. package/mention/index.d.ts +7 -0
  68. package/mention/index.es.js +8319 -0
  69. package/mention/index.umd.js +36 -0
  70. package/mention/package.json +7 -0
  71. package/mention/style.css +1 -0
  72. package/menu/index.d.ts +7 -0
  73. package/menu/index.es.js +921 -0
  74. package/menu/index.umd.js +1 -0
  75. package/menu/package.json +7 -0
  76. package/menu/style.css +1 -0
  77. package/message/index.d.ts +7 -0
  78. package/message/index.es.js +539 -0
  79. package/message/index.umd.js +1 -0
  80. package/message/package.json +7 -0
  81. package/message/style.css +1 -0
  82. package/modal/index.es.js +451 -173
  83. package/modal/index.umd.js +1 -1
  84. package/modal/style.css +1 -1
  85. package/notification/index.es.js +212 -70
  86. package/notification/index.umd.js +1 -1
  87. package/notification/style.css +1 -1
  88. package/nuxt/components/CheckboxButton.js +3 -0
  89. package/nuxt/components/Collapse.js +3 -0
  90. package/nuxt/components/CollapseItem.js +3 -0
  91. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  92. package/nuxt/components/DatePickerPro.js +3 -0
  93. package/nuxt/components/Icon.js +1 -0
  94. package/nuxt/components/IconGroup.js +3 -0
  95. package/nuxt/components/LABEL_DATA.js +3 -0
  96. package/nuxt/components/Mention.js +3 -0
  97. package/nuxt/components/Menu.js +3 -0
  98. package/nuxt/components/MenuItem.js +3 -0
  99. package/nuxt/components/Message.js +3 -0
  100. package/nuxt/components/Option.js +3 -0
  101. package/nuxt/components/OptionGroup.js +3 -0
  102. package/nuxt/components/RadioButton.js +3 -0
  103. package/nuxt/components/Step.js +3 -0
  104. package/nuxt/components/Steps.js +3 -0
  105. package/nuxt/components/SubMenu.js +3 -0
  106. package/nuxt/components/TABLE_TOKEN.js +3 -0
  107. package/nuxt/components/TimePicker.js +3 -0
  108. package/nuxt/components/TimeSelect.js +3 -0
  109. package/nuxt/components/animationInjectionKey.js +3 -0
  110. package/nuxt/components/collapseItemProps.js +3 -0
  111. package/nuxt/components/collapseProps.js +3 -0
  112. package/nuxt/components/datePickerProCommonProps.js +3 -0
  113. package/nuxt/components/datePickerProPanelProps.js +3 -0
  114. package/nuxt/components/datePickerProProps.js +3 -0
  115. package/nuxt/components/iconProps.js +1 -0
  116. package/nuxt/components/mentionProps.js +3 -0
  117. package/nuxt/components/messageProps.js +3 -0
  118. package/nuxt/components/paginationInjectionKey.js +3 -0
  119. package/nuxt/components/roundInjectionKey.js +3 -0
  120. package/nuxt/components/skeletonItemProps.js +3 -0
  121. package/nuxt/components/stepProps.js +3 -0
  122. package/nuxt/components/stepsProps.js +3 -0
  123. package/nuxt/components/svgIconProps.js +3 -0
  124. package/nuxt/components/tableProps.js +3 -0
  125. package/nuxt/components/timerPickerPanelProps.js +3 -0
  126. package/nuxt/components/treeNodeProps.js +3 -0
  127. package/overlay/index.es.js +89 -142
  128. package/overlay/index.umd.js +1 -1
  129. package/overlay/style.css +1 -1
  130. package/package.json +8 -4
  131. package/pagination/index.es.js +10180 -129
  132. package/pagination/index.umd.js +27 -1
  133. package/pagination/style.css +1 -1
  134. package/panel/index.es.js +4 -0
  135. package/panel/index.umd.js +1 -1
  136. package/panel/style.css +1 -1
  137. package/popover/index.es.js +262 -229
  138. package/popover/index.umd.js +15 -15
  139. package/popover/style.css +1 -1
  140. package/progress/index.es.js +2 -2
  141. package/progress/index.umd.js +2 -2
  142. package/progress/style.css +1 -1
  143. package/radio/index.es.js +7954 -156
  144. package/radio/index.umd.js +27 -1
  145. package/radio/style.css +1 -1
  146. package/rate/index.es.js +16 -8
  147. package/rate/index.umd.js +1 -1
  148. package/rate/style.css +1 -1
  149. package/result/index.es.js +170 -22
  150. package/result/index.umd.js +1 -1
  151. package/result/style.css +1 -1
  152. package/search/index.es.js +3829 -1042
  153. package/search/index.umd.js +18 -18
  154. package/search/style.css +1 -1
  155. package/select/index.es.js +9202 -495
  156. package/select/index.umd.js +27 -1
  157. package/select/style.css +1 -1
  158. package/skeleton/index.es.js +89 -263
  159. package/skeleton/index.umd.js +1 -1
  160. package/skeleton/style.css +1 -1
  161. package/slider/index.es.js +118 -145
  162. package/slider/index.umd.js +1 -1
  163. package/slider/style.css +1 -1
  164. package/splitter/index.es.js +454 -233
  165. package/splitter/index.umd.js +13 -13
  166. package/splitter/style.css +1 -1
  167. package/statistic/index.es.js +34 -16
  168. package/statistic/index.umd.js +1 -1
  169. package/statistic/style.css +1 -1
  170. package/status/index.es.js +6 -2
  171. package/status/index.umd.js +1 -1
  172. package/status/style.css +1 -1
  173. package/steps/index.d.ts +7 -0
  174. package/steps/index.es.js +387 -0
  175. package/steps/index.umd.js +1 -0
  176. package/steps/package.json +7 -0
  177. package/steps/style.css +1 -0
  178. package/style.css +1 -1
  179. package/switch/index.es.js +7787 -62
  180. package/switch/index.umd.js +27 -1
  181. package/switch/style.css +1 -1
  182. package/table/index.es.js +5225 -1726
  183. package/table/index.umd.js +18 -18
  184. package/table/style.css +1 -1
  185. package/tabs/index.es.js +303 -102
  186. package/tabs/index.umd.js +1 -1
  187. package/tabs/style.css +1 -1
  188. package/tag/index.es.js +11 -8
  189. package/tag/index.umd.js +1 -1
  190. package/tag/style.css +1 -1
  191. package/textarea/index.es.js +7876 -41
  192. package/textarea/index.umd.js +35 -1
  193. package/textarea/style.css +1 -1
  194. package/time-picker/index.d.ts +7 -0
  195. package/time-picker/index.es.js +9549 -0
  196. package/time-picker/index.umd.js +27 -0
  197. package/time-picker/package.json +7 -0
  198. package/time-picker/style.css +1 -0
  199. package/time-select/index.d.ts +7 -0
  200. package/time-select/index.es.js +9607 -0
  201. package/time-select/index.umd.js +27 -0
  202. package/time-select/package.json +7 -0
  203. package/time-select/style.css +1 -0
  204. package/timeline/index.es.js +170 -22
  205. package/timeline/index.umd.js +1 -1
  206. package/timeline/style.css +1 -1
  207. package/tooltip/index.es.js +286 -238
  208. package/tooltip/index.umd.js +14 -14
  209. package/tooltip/style.css +1 -1
  210. package/tree/index.es.js +11342 -793
  211. package/tree/index.umd.js +27 -1
  212. package/tree/style.css +1 -1
  213. package/upload/index.es.js +458 -102
  214. package/upload/index.umd.js +1 -1
  215. package/upload/style.css +1 -1
  216. package/vue-devui.es.js +20475 -11072
  217. package/vue-devui.umd.js +31 -24
  218. package/date-picker/index.es.js +0 -1097
  219. package/date-picker/index.umd.js +0 -1
  220. package/date-picker/style.css +0 -1
  221. package/nuxt/components/DatePicker.js +0 -3
  222. package/nuxt/components/FormControl.js +0 -3
  223. package/nuxt/components/FormLabel.js +0 -3
  224. package/nuxt/components/Loading.js +0 -3
  225. package/nuxt/components/StickSlider.js +0 -3
  226. package/nuxt/components/formControlProps.js +0 -3
  227. package/nuxt/components/overlayEmits.js +0 -3
  228. package/nuxt/components/overlayProps.js +0 -3
@@ -1,1097 +0,0 @@
1
- import { inject, computed, ref, toRefs, defineComponent, watch, createVNode, mergeProps, createTextVNode, reactive, onMounted, onUnmounted } from "vue";
2
- const getDateTime = (d) => {
3
- const year = d.getFullYear();
4
- const month = d.getMonth() + 1;
5
- const date = d.getDate();
6
- const day = d.getDay();
7
- const hour = d.getHours();
8
- const minute = d.getMinutes();
9
- const second = d.getSeconds();
10
- const ms = d.getMilliseconds();
11
- return [year, month, date, day, hour, minute, second, ms];
12
- };
13
- const fixStart = (n, m, max = 2, ch = "0") => {
14
- return (n + "").padStart(Math.min(m.length, max), ch);
15
- };
16
- const formatDate = (fmt, d) => {
17
- const usage = getDateTime(d);
18
- let res = fmt;
19
- res = res.replace(/y+/g, (m) => {
20
- const year = usage[0] + "";
21
- if (m.length === 2) {
22
- return year.substring(2);
23
- }
24
- return year;
25
- });
26
- res = res.replace(/M+/g, (m) => fixStart(usage[1], m));
27
- res = res.replace(/d+/g, (m) => fixStart(usage[2], m));
28
- res = res.replace(/h+/g, (m) => fixStart(usage[4], m));
29
- res = res.replace(/m+/g, (m) => fixStart(usage[5], m));
30
- res = res.replace(/s+/g, (m) => fixStart(usage[6], m));
31
- return res;
32
- };
33
- const formatRange$1 = (fmt, a, b, conn = "-") => {
34
- const ab = [a, b];
35
- if (a.getTime() > b.getTime()) {
36
- ab.reverse();
37
- }
38
- return `${formatDate(fmt, ab[0])} ${conn} ${formatDate(fmt, ab[1])}`;
39
- };
40
- const isIn = (a, b) => {
41
- if (!b) {
42
- return false;
43
- }
44
- while (a) {
45
- if (a === b) {
46
- return true;
47
- }
48
- a = a.parentNode;
49
- }
50
- return false;
51
- };
52
- const invokeFunction = (fn, ...args) => {
53
- if (typeof fn === "function") {
54
- fn(...args);
55
- }
56
- };
57
- const getHumanDate = (d) => {
58
- const year = d.getFullYear();
59
- const month = d.getMonth() + 1;
60
- const date = d.getDate();
61
- const day = d.getDay();
62
- const hour = d.getHours();
63
- const minute = d.getMinutes();
64
- const second = d.getSeconds();
65
- const ms = d.getMilliseconds();
66
- return {
67
- year,
68
- y: year,
69
- month,
70
- M: month,
71
- date,
72
- d: date,
73
- day,
74
- hour,
75
- H: hour,
76
- h: hour,
77
- minute,
78
- m: minute,
79
- second,
80
- s: second,
81
- ms
82
- };
83
- };
84
- const getMonthDays = (year, month) => {
85
- const first = new Date(year, month - 1, 1);
86
- const last = new Date(year, month, 0);
87
- const dates = [];
88
- let day = first.getDay();
89
- while (day > 0) {
90
- day -= 1;
91
- dates.push({ date: new Date(year, month - 1, -day), current: -1 });
92
- }
93
- day = last.getDate() - first.getDate();
94
- for (let i = 0; i <= day; i++) {
95
- const date = new Date(first);
96
- date.setDate(i + 1);
97
- dates.push({ date, current: 0 });
98
- }
99
- day = last.getDay();
100
- let tail = last;
101
- for (let i = day; i < 6; i++) {
102
- tail = new Date(year, month, i - day + 1);
103
- dates.push({ date: tail, current: 1 });
104
- }
105
- if (dates.length < 42) {
106
- day = tail.getDate();
107
- for (let i = 1; i <= 7; i++) {
108
- tail = new Date(year, month, day + i);
109
- dates.push({ date: tail, current: 1 });
110
- }
111
- }
112
- return dates;
113
- };
114
- const getMonthWeeklyDays = (date = new Date()) => {
115
- if (!(date instanceof Date)) {
116
- date = new Date();
117
- }
118
- const { year, month } = getHumanDate(date);
119
- const days = getMonthDays(year, month);
120
- const dayRows = [];
121
- while (days.length > 0) {
122
- dayRows.push(days.splice(0, 7));
123
- }
124
- return dayRows;
125
- };
126
- const WEEK_DAYS = ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"];
127
- const invokeCallback = (cb, ...args) => {
128
- typeof cb === "function" && cb(...args);
129
- };
130
- const subDateMonth = (a, b) => {
131
- const am = a.getFullYear() * 12 + a.getMonth();
132
- const bm = b.getFullYear() * 12 + b.getMonth();
133
- return am - bm;
134
- };
135
- const ONE_DAY = 1e3 * 60 * 60 * 24;
136
- const subDateDay = (a, b) => {
137
- const ad = new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime();
138
- const bd = new Date(b.getFullYear(), b.getMonth(), b.getDate()).getTime();
139
- return (ad - bd) / ONE_DAY;
140
- };
141
- const compareDate = (small, big, mode, min) => {
142
- if (!small || !big) {
143
- return true;
144
- }
145
- if (mode === "year") {
146
- return big.getFullYear() - small.getFullYear() > min;
147
- } else {
148
- return subDateMonth(big, small) > min;
149
- }
150
- };
151
- const parseDate = (str) => {
152
- if (!str || typeof str !== "string") {
153
- return null;
154
- }
155
- const [dateStr = "", timeStr = ""] = str.split(/([ ]|T)+/);
156
- if (!dateStr) {
157
- return null;
158
- }
159
- const [y, m, d] = dateStr.split(/[^\d]+/);
160
- const year = _parseInt(y), month = _parseInt(m), date = _parseInt(d) || 1;
161
- if (!year || !month) {
162
- return null;
163
- }
164
- const time = parseTime(timeStr);
165
- return new Date(year, month - 1, date, ...time);
166
- };
167
- const _parseInt = (str, dftVal) => {
168
- if (!str || typeof str !== "string") {
169
- return dftVal;
170
- }
171
- const n = parseInt(str);
172
- if (isNaN(n)) {
173
- return dftVal;
174
- }
175
- return n;
176
- };
177
- const parseTime = (str) => {
178
- const [h, m, s, ms] = str.split(/[\:\.]+/);
179
- return [_parseInt(h, 0), _parseInt(m, 0), _parseInt(s, 0), _parseInt(ms, 0)];
180
- };
181
- const compareDateSort = (d1, d2, type = "d") => {
182
- const t1 = dateCounter(d1, type), t2 = dateCounter(d2, type);
183
- return t1 < t2 ? -1 : t1 > t2 ? 1 : 0;
184
- };
185
- const dateCounter = (date, type) => {
186
- switch (type) {
187
- case "y":
188
- return date.getFullYear();
189
- case "m":
190
- return date.getFullYear() * 12 + date.getMonth();
191
- }
192
- return date.getTime() / ONE_DAY >> 0;
193
- };
194
- const betweenDate = (date, left, right) => {
195
- if (left instanceof Date && compareDateSort(left, date, "d") > 0) {
196
- return false;
197
- }
198
- if (right instanceof Date && compareDateSort(date, right, "d") > 0) {
199
- return false;
200
- }
201
- return true;
202
- };
203
- const inputProps = {
204
- modelValue: {
205
- type: String,
206
- default: ""
207
- },
208
- disabled: {
209
- type: Boolean,
210
- default: false
211
- },
212
- error: {
213
- type: Boolean,
214
- default: false
215
- },
216
- size: {
217
- type: String,
218
- default: "md"
219
- }
220
- };
221
- const FORM_ITEM_TOKEN = Symbol("dFormItem");
222
- function createBem(namespace, element, modifier) {
223
- let cls = namespace;
224
- if (element) {
225
- cls += `__${element}`;
226
- }
227
- if (modifier) {
228
- cls += `--${modifier}`;
229
- }
230
- return cls;
231
- }
232
- function useNamespace(block) {
233
- const namespace = `devui-${block}`;
234
- const b = () => createBem(namespace);
235
- const e = (element) => element ? createBem(namespace, element) : "";
236
- const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
237
- const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
238
- return {
239
- b,
240
- e,
241
- m,
242
- em
243
- };
244
- }
245
- function useInputRender(props) {
246
- const formItemContext = inject(FORM_ITEM_TOKEN, void 0);
247
- const isValidateError = computed(() => (formItemContext == null ? void 0 : formItemContext.validateState) === "error");
248
- const ns = useNamespace("input");
249
- const isFocus = ref(false);
250
- const { error, size, disabled } = toRefs(props);
251
- const wrapClasses = computed(() => ({
252
- [ns.b()]: true,
253
- [ns.m("focus")]: isFocus.value,
254
- [ns.m("disabled")]: disabled.value,
255
- [ns.m("error")]: error.value || isValidateError.value,
256
- [ns.m("feedback")]: formItemContext == null ? void 0 : formItemContext.showFeedback,
257
- [ns.m(size.value)]: true
258
- }));
259
- return { isFocus, wrapClasses };
260
- }
261
- function useInputEvent(isFocus, ctx) {
262
- const formItemContext = inject(FORM_ITEM_TOKEN, void 0);
263
- const onFocus = (e) => {
264
- isFocus.value = true;
265
- ctx.emit("focus", e);
266
- };
267
- const onBlur = (e) => {
268
- isFocus.value = false;
269
- ctx.emit("blur", e);
270
- formItemContext == null ? void 0 : formItemContext.validate("blur").catch((err) => console.warn(err));
271
- };
272
- const onInput = (e) => {
273
- ctx.emit("update:modelValue", e.target.value);
274
- };
275
- const onChange = (e) => {
276
- ctx.emit("change", e.target.value);
277
- };
278
- const onKeydown = (e) => {
279
- ctx.emit("keydown", e);
280
- };
281
- return { onFocus, onBlur, onInput, onChange, onKeydown };
282
- }
283
- var input = "";
284
- var Input = defineComponent({
285
- name: "DInput",
286
- inheritAttrs: false,
287
- props: inputProps,
288
- emits: ["update:modelValue", "focus", "blur", "input", "change", "keydown"],
289
- setup(props, ctx) {
290
- const formItemContext = inject(FORM_ITEM_TOKEN, void 0);
291
- const {
292
- modelValue,
293
- disabled
294
- } = toRefs(props);
295
- const ns = useNamespace("input");
296
- const {
297
- isFocus,
298
- wrapClasses
299
- } = useInputRender(props);
300
- const {
301
- onFocus,
302
- onBlur,
303
- onInput,
304
- onChange,
305
- onKeydown
306
- } = useInputEvent(isFocus, ctx);
307
- watch(() => props.modelValue, () => {
308
- formItemContext == null ? void 0 : formItemContext.validate("change").catch((err) => console.warn(err));
309
- });
310
- return () => createVNode("div", {
311
- "class": wrapClasses.value
312
- }, [createVNode("input", mergeProps({
313
- "value": modelValue.value,
314
- "disabled": disabled.value,
315
- "class": ns.e("inner")
316
- }, ctx.attrs, {
317
- "onInput": onInput,
318
- "onFocus": onFocus,
319
- "onBlur": onBlur,
320
- "onChange": onChange,
321
- "onKeydown": onKeydown
322
- }), null)]);
323
- }
324
- });
325
- const iconProps = {
326
- name: {
327
- type: String,
328
- default: "",
329
- required: true
330
- },
331
- size: {
332
- type: String,
333
- default: "inherit"
334
- },
335
- color: {
336
- type: String,
337
- default: "inherit"
338
- },
339
- classPrefix: {
340
- type: String,
341
- default: "icon"
342
- }
343
- };
344
- var Icon = defineComponent({
345
- name: "DIcon",
346
- props: iconProps,
347
- setup(props) {
348
- const {
349
- name,
350
- size,
351
- color,
352
- classPrefix
353
- } = toRefs(props);
354
- return () => {
355
- return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
356
- "src": name.value,
357
- "alt": name.value.split("/")[name.value.split("/").length - 1],
358
- "style": {
359
- width: size.value,
360
- verticalAlign: "text-bottom"
361
- }
362
- }, null) : createVNode("i", {
363
- "class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
364
- "style": {
365
- fontSize: size.value,
366
- color: color.value
367
- }
368
- }, null);
369
- };
370
- }
371
- });
372
- const handleCalendarSwitchState = (state, index2, pos, date) => {
373
- switch (index2) {
374
- case 0:
375
- const preYear = new Date(date);
376
- preYear.setFullYear(preYear.getFullYear() - 1);
377
- pos === 0 ? state.current = preYear : state.next = preYear;
378
- break;
379
- case 1:
380
- const preMonth = new Date(date);
381
- preMonth.setMonth(preMonth.getMonth() - 1);
382
- pos === 0 ? state.current = preMonth : state.next = preMonth;
383
- break;
384
- case 2:
385
- const nextMonth = new Date(date);
386
- nextMonth.setMonth(nextMonth.getMonth() + 1);
387
- pos === 0 ? state.current = nextMonth : state.next = nextMonth;
388
- break;
389
- case 3:
390
- const nextYear = new Date(date);
391
- nextYear.setFullYear(nextYear.getFullYear() + 1);
392
- pos === 0 ? state.current = nextYear : state.next = nextYear;
393
- break;
394
- }
395
- };
396
- const formatValue = (state, props) => {
397
- const { format = "y/MM/dd", range, rangeSpliter = "-" } = props || {};
398
- if (range) {
399
- if (!state.start) {
400
- return "";
401
- } else if (!state.end) {
402
- return formatDate(format, state.start);
403
- }
404
- if (state.end < state.start) {
405
- const end = state.end;
406
- state.end = state.start;
407
- state.start = end;
408
- }
409
- return formatRange$1(format, state.start, state.end, rangeSpliter);
410
- } else {
411
- if (!state.start) {
412
- return "";
413
- }
414
- return formatDate(format, state.start);
415
- }
416
- };
417
- const formatPlaceholder = (props) => {
418
- if (!props) {
419
- return "";
420
- }
421
- const format = props.format || `y/MM/dd`;
422
- const sp = props.rangeSpliter || "-";
423
- return props.range ? `${format} ${sp} ${format}` : format;
424
- };
425
- const getDateKey = (date) => {
426
- return date.toDateString();
427
- };
428
- const cellClassName = (props, day, base = "cell") => {
429
- if (!betweenDate(day.date, props.dateMin, props.dateMax)) {
430
- return `${base} disabled`;
431
- } else if (day.current !== 0) {
432
- return `${base} not-current`;
433
- }
434
- const key = getDateKey(day.date);
435
- if (props.type === "range") {
436
- if (props.dateStart) {
437
- if (getDateKey(props.dateStart) === key) {
438
- return `${base} selected`;
439
- }
440
- if (props.dateEnd && getDateKey(props.dateEnd) === key) {
441
- return `${base} selected`;
442
- }
443
- const innerEnd = props.dateEnd || props.dateHover;
444
- if (innerEnd) {
445
- const range = innerEnd > props.dateStart ? [props.dateStart, innerEnd] : [innerEnd, props.dateStart];
446
- if (day.date > range[0] && day.date < range[1]) {
447
- return `${base} innerday`;
448
- }
449
- }
450
- }
451
- return base;
452
- } else {
453
- return props.dateStart && getDateKey(props.dateStart) === key ? `${base} selected` : base;
454
- }
455
- };
456
- const trigEvent = (props, day) => {
457
- if (!betweenDate(day.date, props.dateMin, props.dateMax)) {
458
- return;
459
- }
460
- if (props.type === "range") {
461
- if (!props.dateStart) {
462
- invokeCallback(props.onSelectStart, day.date);
463
- } else if (!props.dateEnd) {
464
- if (subDateDay(props.dateStart, day.date) !== 0) {
465
- invokeCallback(props.onSelectEnd, day.date);
466
- typeof props.onChange === "function" && props.onChange(props.type, props);
467
- }
468
- } else {
469
- invokeCallback(props.onReset, day.date);
470
- }
471
- } else {
472
- invokeCallback(props.onSelected, day.date);
473
- typeof props.onChange === "function" && props.onChange(props.type, props);
474
- }
475
- };
476
- const handleDateEnter = (props, day) => {
477
- if (day.current !== 0) {
478
- return;
479
- }
480
- const { dateMin, dateMax } = props;
481
- if (dateMin && subDateDay(day.date, dateMin) < 0) {
482
- return;
483
- }
484
- if (dateMax && subDateDay(dateMax, day.date) < 0) {
485
- return;
486
- }
487
- if (props.type === "range") {
488
- const key = getDateKey(day.date);
489
- if (!props.dateStart || getDateKey(props.dateStart) === key || props.dateEnd) {
490
- return;
491
- }
492
- invokeCallback(props.onSelecting, day.date);
493
- }
494
- };
495
- const Year = (props) => {
496
- const {
497
- color = "#585d6b",
498
- rotate = 0
499
- } = props;
500
- return createVNode("svg", {
501
- "style": {
502
- transform: `rotate(${rotate}deg)`
503
- },
504
- "width": "10px",
505
- "height": "10px",
506
- "viewBox": "0 0 10 10",
507
- "version": "1.1",
508
- "xmlns": "http://www.w3.org/2000/svg"
509
- }, [createVNode("g", {
510
- "fill": color,
511
- "transform": "translate(-1.000000, -1.000000)"
512
- }, [createVNode("path", {
513
- "d": "M11,1.83333333 L11,10.1666667 L7,7.38833333 L7,10.1666667 L1,6 L7,1.83333333 L7,4.61033333 L11,1.83333333 Z"
514
- }, null)])]);
515
- };
516
- const Month = (props) => {
517
- const {
518
- color = "#585d6b",
519
- rotate = 0
520
- } = props;
521
- return createVNode("svg", {
522
- "style": {
523
- transform: `rotate(${rotate}deg)`
524
- },
525
- "width": "6px",
526
- "height": "10px",
527
- "viewBox": "0 0 6 10",
528
- "version": "1.1",
529
- "xmlns": "http://www.w3.org/2000/svg"
530
- }, [createVNode("g", {
531
- "fill": color,
532
- "transform": "translate(-3.000000, -1.000000)"
533
- }, [createVNode("polygon", {
534
- "points": "6 3 10.1666667 9 1.83333333 9"
535
- }, null)])]);
536
- };
537
- var index$6 = "";
538
- const Item = (props) => {
539
- const {
540
- button: Btn,
541
- disabled = false,
542
- rotate = 0,
543
- date,
544
- pos
545
- } = props;
546
- const color = disabled ? "#cfd0d3" : "#585d6b";
547
- const className = `${disabled ? "disabled" : ""}`;
548
- const handleClick = disabled ? void 0 : () => invokeCallback(props.cb, date, pos);
549
- return createVNode("a", {
550
- "class": className,
551
- "onClick": handleClick
552
- }, [createVNode(Btn, {
553
- "color": color,
554
- "rotate": rotate
555
- }, null)]);
556
- };
557
- const Title = (props) => {
558
- const {
559
- date
560
- } = props;
561
- return createVNode("a", {
562
- "class": "title"
563
- }, [`${date.getFullYear()}\u5E74${(date.getMonth() + 1 + "").padStart(2, "0")}\u6708`]);
564
- };
565
- const CalendarToolbar = (props) => {
566
- const {
567
- type,
568
- current,
569
- compare,
570
- pos,
571
- dateMax,
572
- dateMin,
573
- onPreviousYear,
574
- onPreviousMonth,
575
- onNextMonth,
576
- onNextYear
577
- } = props;
578
- const dis = [false, false, false, false];
579
- if (type === "range") {
580
- if (pos === 1) {
581
- dis[0] = !compareDate(compare, current, "year", 1);
582
- dis[1] = !compareDate(compare, current, "month", 1);
583
- dis[2] = !compareDate(current, dateMax, "month", 0);
584
- dis[3] = !compareDate(current, dateMax, "year", 0);
585
- } else {
586
- dis[0] = !compareDate(dateMin, current, "year", 0);
587
- dis[1] = !compareDate(dateMin, current, "month", 0);
588
- dis[2] = !compareDate(current, compare, "month", 1);
589
- dis[3] = !compareDate(current, compare, "year", 1);
590
- }
591
- } else {
592
- dis[0] = !compareDate(dateMin, current, "year", 0);
593
- dis[1] = !compareDate(dateMin, current, "month", 0);
594
- dis[2] = !compareDate(current, dateMax, "month", 0);
595
- dis[3] = !compareDate(current, dateMax, "year", 0);
596
- }
597
- return createVNode("div", {
598
- "class": "devui-calendar-toolbar"
599
- }, [createVNode(Item, {
600
- "disabled": dis[0],
601
- "date": current,
602
- "pos": pos,
603
- "button": Year,
604
- "cb": onPreviousYear
605
- }, null), createVNode(Item, {
606
- "disabled": dis[1],
607
- "date": current,
608
- "pos": pos,
609
- "button": Month,
610
- "rotate": -90,
611
- "cb": onPreviousMonth
612
- }, null), createVNode(Title, {
613
- "date": current
614
- }, null), createVNode(Item, {
615
- "disabled": dis[2],
616
- "date": current,
617
- "pos": pos,
618
- "button": Month,
619
- "rotate": 90,
620
- "cb": onNextMonth
621
- }, null), createVNode(Item, {
622
- "disabled": dis[3],
623
- "date": current,
624
- "pos": pos,
625
- "button": Year,
626
- "rotate": 180,
627
- "cb": onNextYear
628
- }, null)]);
629
- };
630
- const TodayDefault = (props) => {
631
- const {
632
- onSelected = () => 0,
633
- disabled = false
634
- } = props;
635
- return createVNode("div", {
636
- "class": `today-container ${disabled ? "disabled" : ""}`
637
- }, [createVNode("button", {
638
- "class": "today-button",
639
- "disabled": disabled,
640
- "onClick": disabled ? void 0 : () => onSelected(new Date())
641
- }, [createTextVNode("\u4ECA\u5929")])]);
642
- };
643
- var index$5 = "";
644
- const CalendarDatePanel = (props) => {
645
- const today = new Date();
646
- return createVNode("div", {
647
- "class": "devui-calendar-panel"
648
- }, [createVNode(CalendarToolbar, {
649
- "current": props.current,
650
- "compare": props.compare,
651
- "pos": props.pos,
652
- "type": props.type,
653
- "showTime": props.showTime,
654
- "onPreviousYear": props.onPreviousYear,
655
- "onPreviousMonth": props.onPreviousMonth,
656
- "onNextMonth": props.onNextMonth,
657
- "onNextYear": props.onNextYear,
658
- "dateMax": props.dateMax,
659
- "dateMin": props.dateMin
660
- }, null), createVNode("ol", {
661
- "class": "head row"
662
- }, [WEEK_DAYS.map((day) => createVNode("li", {
663
- "class": "cell"
664
- }, [day]))]), createVNode("ul", {
665
- "class": "body"
666
- }, [getMonthWeeklyDays(props.current).map((row) => createVNode("li", {
667
- "class": "row"
668
- }, [row.map((day) => {
669
- return createVNode("span", {
670
- "class": cellClassName(props, day),
671
- "onClick": () => trigEvent(props, day),
672
- "onMouseenter": () => handleDateEnter(props, day)
673
- }, [day.date.getDate()]);
674
- })]))]), props.type !== "range" ? createVNode(TodayDefault, {
675
- "disabled": !betweenDate(today, props.dateMin, props.dateMax),
676
- "onSelected": (today2) => {
677
- typeof props.onToday === "function" && props.onToday(today2, 0);
678
- }
679
- }, null) : null]);
680
- };
681
- var index$4 = "";
682
- const VerticalSlider = defineComponent({
683
- props: {
684
- size: {
685
- type: Number,
686
- default: 26
687
- },
688
- items: {
689
- type: Array
690
- },
691
- selectedIndex: {
692
- type: Number
693
- },
694
- className: {
695
- type: String
696
- },
697
- itemClassNormal: {
698
- type: String
699
- },
700
- itemClassSelected: {
701
- type: String
702
- },
703
- onChange: {
704
- type: Function
705
- }
706
- },
707
- setup(props) {
708
- const {
709
- items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
710
- selectedIndex = 0,
711
- size = 26,
712
- className = "",
713
- itemClassNormal = "",
714
- itemClassSelected = "selected",
715
- onChange
716
- } = props || {};
717
- let max_y = 0, min_y = 0;
718
- const container = ref();
719
- const movbar = ref();
720
- let pos_start = null;
721
- let pos_cache = null;
722
- const state = reactive({
723
- selectedIndex,
724
- barOpacity: 0,
725
- x: 0,
726
- y: 0,
727
- transition: "none"
728
- });
729
- const handleMouseDown = (e) => {
730
- e.stopPropagation();
731
- e.preventDefault();
732
- pos_start = [e.clientX, e.clientY];
733
- state.transition = "none";
734
- };
735
- const handleMouseMove = (e) => {
736
- e.stopPropagation();
737
- e.preventDefault();
738
- if (!pos_start || !pos_cache) {
739
- return;
740
- }
741
- state.x = pos_cache[0] + e.clientX - pos_start[0];
742
- state.y = Math.min(max_y, Math.max(min_y, pos_cache[1] + e.clientY - pos_start[1]));
743
- state.selectedIndex = (max_y - state.y + size / 2) / size >> 0;
744
- };
745
- const handleMouseUp = (e) => {
746
- e.stopPropagation();
747
- e.preventDefault();
748
- pos_start = null;
749
- state.y = max_y - state.selectedIndex * size;
750
- state.transition = "transform 0.1s";
751
- pos_cache[0] = state.x;
752
- pos_cache[1] = state.y;
753
- if (typeof onChange === "function") {
754
- const idx = state.selectedIndex;
755
- const val = items[idx];
756
- onChange(val, idx);
757
- }
758
- };
759
- onMounted(() => {
760
- const {
761
- height: ch
762
- } = container.value.getBoundingClientRect();
763
- const {
764
- height: mh
765
- } = movbar.value.getBoundingClientRect();
766
- max_y = (ch - size) / 2;
767
- min_y = (ch + size) / 2 - mh;
768
- pos_cache = [0, max_y - state.selectedIndex * size];
769
- state.x = pos_cache[0];
770
- state.y = pos_cache[1];
771
- state.barOpacity = 1;
772
- state.transition = "transform 0.1s";
773
- });
774
- return () => {
775
- return createVNode("div", {
776
- "ref": container,
777
- "class": `devui-vertical-slider ${className}`
778
- }, [createVNode("div", {
779
- "ref": movbar,
780
- "class": "movable-bar",
781
- "style": {
782
- opacity: state.barOpacity,
783
- transform: `translateY(${state.y}px)`,
784
- transition: state.transition
785
- }
786
- }, [items.map((c, i) => {
787
- const className2 = i === state.selectedIndex ? itemClassSelected : itemClassNormal;
788
- return createVNode("span", {
789
- "class": `slider-item ${className2}`,
790
- "style": {
791
- height: `${size}px`,
792
- lineHeight: `${size}px`
793
- }
794
- }, [c]);
795
- })]), createVNode("div", {
796
- "class": "slider-mask",
797
- "onMousedown": handleMouseDown,
798
- "onMousemove": handleMouseMove,
799
- "onMouseup": handleMouseUp,
800
- "onMouseout": handleMouseUp
801
- }, null)]);
802
- };
803
- }
804
- });
805
- var index$3 = "";
806
- const TimePicker = defineComponent({
807
- props: {
808
- time: {
809
- type: Date
810
- }
811
- },
812
- setup(props) {
813
- const {
814
- time = new Date()
815
- } = props || {};
816
- const state = reactive({
817
- hour: time.getHours(),
818
- minute: time.getMinutes(),
819
- second: time.getSeconds()
820
- });
821
- const hours = Array(24).fill(0).map((_, i) => `${i}`.padStart(2, "0"));
822
- const minutes = Array(60).fill(0).map((_, i) => `${i}`.padStart(2, "0"));
823
- return () => {
824
- return createVNode("div", {
825
- "class": "devui-calendar-timepicker"
826
- }, [createVNode("div", {
827
- "class": "head"
828
- }, [createVNode("div", {
829
- "class": "chars"
830
- }, [createVNode("span", null, [state.hour.toString().padStart(2, "0"), createTextVNode(":"), state.minute.toString().padStart(2, "0"), createTextVNode(":"), state.second.toString().padStart(2, "0")])])]), createVNode("div", {
831
- "class": "select"
832
- }, [createVNode(VerticalSlider, {
833
- "items": hours,
834
- "selectedIndex": state.hour,
835
- "onChange": (_, idx) => state.hour = idx
836
- }, null), createVNode(VerticalSlider, {
837
- "items": minutes,
838
- "selectedIndex": state.minute,
839
- "onChange": (_, idx) => state.minute = idx
840
- }, null), createVNode(VerticalSlider, {
841
- "items": minutes,
842
- "selectedIndex": state.second,
843
- "onChange": (_, idx) => state.second = idx
844
- }, null)])]);
845
- };
846
- }
847
- });
848
- var index$2 = "";
849
- const Calendar = (props) => {
850
- const {
851
- showTime = false
852
- } = props;
853
- let {
854
- current
855
- } = props;
856
- if (!(current instanceof Date)) {
857
- current = new Date();
858
- }
859
- if (props.type === "range") {
860
- let {
861
- next
862
- } = props;
863
- if (!(next instanceof Date)) {
864
- next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
865
- }
866
- return createVNode("div", {
867
- "class": "devui-calendar-container"
868
- }, [createVNode(CalendarDatePanel, mergeProps(props, {
869
- "pos": 0,
870
- "current": current,
871
- "compare": next
872
- }), null), showTime ? createVNode(TimePicker, {
873
- "time": current
874
- }, null) : null, createVNode(CalendarDatePanel, mergeProps(props, {
875
- "pos": 1,
876
- "current": next,
877
- "compare": current
878
- }), null), showTime ? createVNode(TimePicker, {
879
- "time": next
880
- }, null) : null]);
881
- } else {
882
- return createVNode("div", {
883
- "class": "devui-calendar-container"
884
- }, [createVNode(CalendarDatePanel, mergeProps(props, {
885
- "pos": 0,
886
- "current": current
887
- }), null), showTime ? createVNode(TimePicker, {
888
- "time": current
889
- }, null) : null]);
890
- }
891
- };
892
- var datePicker = "";
893
- const formatRange = (state) => {
894
- const [start, end] = [state.start, state.end].sort((a, b) => a.getTime() - b.getTime());
895
- state.start = start;
896
- state.end = end;
897
- if (compareDateSort(start, end, "m") !== 0) {
898
- state.current = start;
899
- state.next = end;
900
- } else {
901
- if (compareDateSort(start, state.current) < 0) {
902
- state.current = start;
903
- }
904
- if (compareDateSort(state.next, end) < 0) {
905
- state.next = end;
906
- }
907
- }
908
- };
909
- var DatePicker = defineComponent({
910
- name: "DDatepicker",
911
- props: {
912
- selectedDateChange: {
913
- type: Function
914
- },
915
- autoClose: {
916
- type: Boolean,
917
- default: false
918
- },
919
- range: {
920
- type: Boolean,
921
- default: false
922
- },
923
- showTime: {
924
- type: Boolean,
925
- default: false
926
- },
927
- format: {
928
- type: String,
929
- default: "y/MM/dd"
930
- },
931
- rangeSpliter: {
932
- type: String,
933
- default: "-"
934
- },
935
- attachInputDom: {
936
- type: String
937
- },
938
- dateMin: {
939
- type: String
940
- },
941
- dateMax: {
942
- type: String
943
- }
944
- },
945
- setup(props) {
946
- const panel = ref(null);
947
- const input2 = ref(null);
948
- const current = parseDate(props.dateMin) || new Date();
949
- const next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
950
- const state = reactive({
951
- show: false,
952
- value: "",
953
- placeholder: formatPlaceholder(props),
954
- current,
955
- next
956
- });
957
- state.value = formatValue(state, props);
958
- state.placeholder = formatPlaceholder(props);
959
- const documentClick = (e) => {
960
- e.stopPropagation();
961
- if (isIn(e.target, panel.value) || isIn(e.target, input2.value)) {
962
- return;
963
- }
964
- state.show = false;
965
- };
966
- onMounted(() => {
967
- document.addEventListener("click", documentClick);
968
- });
969
- onUnmounted(() => {
970
- document.removeEventListener("click", documentClick);
971
- });
972
- return () => {
973
- return createVNode("div", {
974
- "class": "devui-datepicker-container"
975
- }, [createVNode("div", {
976
- "class": "input-container",
977
- "ref": input2
978
- }, [createVNode(Input, {
979
- "ref": input2,
980
- "class": "datepicker-input",
981
- "modelValue": state.value,
982
- "placeholder": state.placeholder,
983
- "onFocus": () => state.show = true
984
- }, null), createVNode(Icon, {
985
- "size": "small",
986
- "name": "calendar",
987
- "class": "datepicker-input-icon"
988
- }, null)]), createVNode("div", {
989
- "class": "devui-datepicker-panel",
990
- "ref": panel
991
- }, [state.show ? createVNode(Calendar, {
992
- "type": props.range ? "range" : "select",
993
- "showTime": props.showTime,
994
- "current": state.current,
995
- "next": state.next,
996
- "dateMin": parseDate(props.dateMin),
997
- "dateMax": parseDate(props.dateMax),
998
- "dateStart": state.start,
999
- "dateEnd": state.end,
1000
- "dateHover": state.hover,
1001
- "onReset": (date) => {
1002
- state.end = state.hover = void 0;
1003
- state.start = date;
1004
- },
1005
- "onChange": () => {
1006
- state.value = formatValue(state, props);
1007
- state.placeholder = formatPlaceholder(props);
1008
- invokeFunction(props.selectedDateChange, state.value);
1009
- if (props.autoClose) {
1010
- state.show = false;
1011
- }
1012
- },
1013
- "onToday": (date) => {
1014
- state.current = date;
1015
- state.start = date;
1016
- state.value = formatValue(state, props);
1017
- state.placeholder = formatPlaceholder(props);
1018
- invokeFunction(props.selectedDateChange, state.value);
1019
- if (props.autoClose) {
1020
- state.show = false;
1021
- }
1022
- },
1023
- "onSelected": (date) => {
1024
- state.start = date;
1025
- if (compareDateSort(state.current, date) !== 0) {
1026
- state.current = date;
1027
- }
1028
- },
1029
- "onSelectStart": (date) => state.start = date,
1030
- "onSelectEnd": (date) => {
1031
- state.end = date;
1032
- formatRange(state);
1033
- },
1034
- "onSelecting": (date) => state.hover = date,
1035
- "onPreviousYear": (date, pos) => handleCalendarSwitchState(state, 0, pos, date),
1036
- "onPreviousMonth": (date, pos) => handleCalendarSwitchState(state, 1, pos, date),
1037
- "onNextMonth": (date, pos) => handleCalendarSwitchState(state, 2, pos, date),
1038
- "onNextYear": (date, pos) => handleCalendarSwitchState(state, 3, pos, date)
1039
- }, null) : null])]);
1040
- };
1041
- }
1042
- });
1043
- var index$1 = "";
1044
- const StickSlider = defineComponent({
1045
- name: "DStickSlider",
1046
- props: {},
1047
- setup() {
1048
- const state = reactive({
1049
- showButtons: false,
1050
- selectedIndex: 0
1051
- });
1052
- const reset = () => {
1053
- state.showButtons = false;
1054
- };
1055
- const handleMainButtonMouseDown = (e) => {
1056
- e.stopPropagation();
1057
- state.showButtons = true;
1058
- };
1059
- const handleMainButtonMouseUp = (e) => {
1060
- e.stopPropagation();
1061
- reset();
1062
- };
1063
- return () => {
1064
- return createVNode("div", {
1065
- "class": "devui-stick-slider",
1066
- "onMousedown": handleMainButtonMouseDown,
1067
- "onMouseup": handleMainButtonMouseUp,
1068
- "onMouseleave": handleMainButtonMouseUp
1069
- }, [createVNode("div", {
1070
- "class": "sub-buttons",
1071
- "style": {
1072
- display: state.showButtons ? "" : "none"
1073
- }
1074
- }, [Array(16).fill(null).map((_, i) => {
1075
- return createVNode("div", {
1076
- "class": `button ${i === state.selectedIndex ? "selected" : ""}`,
1077
- "onMouseenter": () => state.selectedIndex = i
1078
- }, [i]);
1079
- })]), createVNode("div", {
1080
- "class": "main-button"
1081
- }, null)]);
1082
- };
1083
- }
1084
- });
1085
- DatePicker.install = function(app) {
1086
- app.component(DatePicker.name, DatePicker);
1087
- app.component(StickSlider.name, StickSlider);
1088
- };
1089
- var index = {
1090
- title: "DatePicker \u65E5\u671F\u9009\u62E9\u5668",
1091
- category: "\u6570\u636E\u5F55\u5165",
1092
- status: "50%",
1093
- install(app) {
1094
- app.use(DatePicker);
1095
- }
1096
- };
1097
- export { DatePicker, StickSlider, index as default };