vue-devui 1.0.0-rc.2 → 1.0.0-rc.5
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.
- package/README.md +9 -0
- package/auto-complete/index.es.js +132 -58
- package/auto-complete/index.umd.js +5 -3
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +77 -81
- package/avatar/index.umd.js +1 -1
- package/button/index.es.js +23 -15
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.es.js +3 -6
- package/card/index.umd.js +1 -1
- package/checkbox/index.es.js +5 -11
- package/checkbox/index.umd.js +1 -1
- package/comment/index.es.js +4 -6
- package/comment/index.umd.js +1 -1
- package/countdown/index.es.js +3 -6
- package/countdown/index.umd.js +1 -1
- package/{tag-input → date-picker}/index.d.ts +0 -0
- package/date-picker/index.es.js +1151 -0
- package/date-picker/index.umd.js +1 -0
- package/date-picker/package.json +7 -0
- package/date-picker/style.css +1 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +236 -0
- package/drawer/index.umd.js +1 -0
- package/{tag-input → drawer}/package.json +1 -1
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +716 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.es.js +2 -5
- package/editable-select/index.umd.js +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +7888 -0
- package/form/index.umd.js +27 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/grid/index.es.js +30 -36
- package/grid/index.umd.js +1 -1
- package/image-preview/index.es.js +19 -19
- package/image-preview/index.umd.js +1 -1
- package/input/index.es.js +2 -5
- package/input/index.umd.js +1 -1
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +229 -0
- package/input-number/index.umd.js +1 -0
- package/input-number/package.json +7 -0
- package/input-number/style.css +1 -0
- package/layout/index.es.js +9 -22
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +40 -25
- package/loading/index.umd.js +1 -1
- package/modal/index.es.js +70 -50
- package/modal/index.umd.js +1 -1
- package/notification/index.es.js +100 -10
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/DropdownPropsKey.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/LoadingOptions.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Tab.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/autoCompleteProps.js +3 -0
- package/nuxt/components/avatarProps.js +3 -0
- package/nuxt/components/cardProps.js +3 -0
- package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
- package/nuxt/components/checkboxGroupProps.js +3 -0
- package/nuxt/components/checkboxProps.js +3 -0
- package/nuxt/components/colProps.js +3 -0
- package/nuxt/components/colPropsBaseClass.js +3 -0
- package/nuxt/components/colPropsBaseStyle.js +3 -0
- package/nuxt/components/commentProps.js +3 -0
- package/nuxt/components/countdownProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/editableSelectProps.js +3 -0
- package/nuxt/components/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/loadingProps.js +3 -0
- package/nuxt/components/modalProps.js +3 -0
- package/nuxt/components/progressProps.js +3 -0
- package/nuxt/components/rateProps.js +3 -0
- package/nuxt/components/readTipProps.js +3 -0
- package/nuxt/components/resultProps.js +3 -0
- package/nuxt/components/rowProps.js +3 -0
- package/nuxt/components/screenSizes.js +3 -0
- package/nuxt/components/skeletonProps.js +3 -0
- package/nuxt/components/sliderProps.js +3 -0
- package/nuxt/components/splitterProps.js +3 -0
- package/nuxt/components/statisticProps.js +3 -0
- package/nuxt/components/switchProps.js +3 -0
- package/nuxt/components/tabsProps.js +3 -0
- package/nuxt/components/textareaProps.js +3 -0
- package/nuxt/components/timeAxisProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/overlay/index.es.js +20 -8
- package/overlay/index.umd.js +1 -1
- package/package.json +2 -2
- package/pagination/index.es.js +14 -13
- package/pagination/index.umd.js +1 -1
- package/popover/index.es.js +20 -8
- package/popover/index.umd.js +12 -12
- package/progress/index.es.js +33 -35
- package/progress/index.umd.js +3 -3
- package/rate/index.es.js +31 -41
- package/rate/index.umd.js +1 -1
- package/read-tip/index.es.js +34 -34
- package/read-tip/index.umd.js +1 -1
- package/read-tip/style.css +1 -1
- package/result/index.es.js +2 -5
- package/result/index.umd.js +1 -1
- package/search/index.es.js +11 -11
- package/search/index.umd.js +8 -8
- package/select/index.d.ts +7 -0
- package/select/index.es.js +696 -0
- package/select/index.umd.js +1 -0
- package/select/package.json +7 -0
- package/select/style.css +1 -0
- package/skeleton/index.es.js +9 -12
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +1 -4
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +23 -14
- package/splitter/index.umd.js +15 -15
- package/statistic/index.es.js +7 -18
- package/statistic/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +4 -7
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +2376 -0
- package/table/index.umd.js +1 -0
- package/table/package.json +7 -0
- package/table/style.css +1 -0
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +194 -0
- package/tabs/index.umd.js +1 -0
- package/tabs/package.json +7 -0
- package/tabs/style.css +1 -0
- package/textarea/index.es.js +2 -5
- package/textarea/index.umd.js +1 -1
- package/timeline/index.es.js +10 -16
- package/timeline/index.umd.js +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +5847 -0
- package/tooltip/index.umd.js +27 -0
- package/tooltip/package.json +7 -0
- package/tooltip/style.css +1 -0
- package/upload/index.es.js +160 -67
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +16936 -24821
- package/vue-devui.umd.js +24 -22
- package/nuxt/components/TagInput.js +0 -3
- package/tag-input/index.es.js +0 -331
- package/tag-input/index.umd.js +0 -1
- package/tag-input/style.css +0 -1
|
@@ -0,0 +1,1151 @@
|
|
|
1
|
+
import { defineComponent, inject, computed, ref, watch, createVNode, withDirectives, mergeProps, resolveDirective, resolveComponent, toRefs, 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
|
+
placeholder: {
|
|
205
|
+
type: String,
|
|
206
|
+
default: void 0
|
|
207
|
+
},
|
|
208
|
+
disabled: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
default: false
|
|
211
|
+
},
|
|
212
|
+
autoFocus: {
|
|
213
|
+
type: Boolean,
|
|
214
|
+
default: false
|
|
215
|
+
},
|
|
216
|
+
maxLength: {
|
|
217
|
+
type: Number,
|
|
218
|
+
default: Number.MAX_SAFE_INTEGER
|
|
219
|
+
},
|
|
220
|
+
cssClass: {
|
|
221
|
+
type: String,
|
|
222
|
+
default: ""
|
|
223
|
+
},
|
|
224
|
+
error: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
default: false
|
|
227
|
+
},
|
|
228
|
+
size: {
|
|
229
|
+
type: String,
|
|
230
|
+
default: ""
|
|
231
|
+
},
|
|
232
|
+
showPassword: {
|
|
233
|
+
type: Boolean,
|
|
234
|
+
default: false
|
|
235
|
+
},
|
|
236
|
+
modelValue: {
|
|
237
|
+
type: String,
|
|
238
|
+
default: ""
|
|
239
|
+
},
|
|
240
|
+
"update:modelValue": {
|
|
241
|
+
type: Function,
|
|
242
|
+
default: void 0
|
|
243
|
+
},
|
|
244
|
+
onChange: {
|
|
245
|
+
type: Function,
|
|
246
|
+
default: void 0
|
|
247
|
+
},
|
|
248
|
+
onKeydown: {
|
|
249
|
+
type: Function,
|
|
250
|
+
default: void 0
|
|
251
|
+
},
|
|
252
|
+
onFocus: {
|
|
253
|
+
type: Function,
|
|
254
|
+
default: void 0
|
|
255
|
+
},
|
|
256
|
+
onBlur: {
|
|
257
|
+
type: Function,
|
|
258
|
+
default: void 0
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var input = "";
|
|
262
|
+
const formItemInjectionKey = Symbol("dFormItem");
|
|
263
|
+
const dFormItemEvents = {
|
|
264
|
+
blur: "d.form.blur",
|
|
265
|
+
change: "d.form.change",
|
|
266
|
+
input: "d.form.input"
|
|
267
|
+
};
|
|
268
|
+
var Input = defineComponent({
|
|
269
|
+
name: "DInput",
|
|
270
|
+
directives: {
|
|
271
|
+
focus: {
|
|
272
|
+
mounted: function(el, binding) {
|
|
273
|
+
if (binding.value) {
|
|
274
|
+
el.focus();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
props: inputProps,
|
|
280
|
+
emits: ["update:modelValue", "focus", "blur", "change", "keydown"],
|
|
281
|
+
setup(props, ctx) {
|
|
282
|
+
const formItem = inject(formItemInjectionKey, {});
|
|
283
|
+
const hasFormItem = Object.keys(formItem).length > 0;
|
|
284
|
+
const sizeCls = computed(() => `devui-input-${props.size}`);
|
|
285
|
+
const showPwdIcon = ref(false);
|
|
286
|
+
const inputType = ref("text");
|
|
287
|
+
const inputCls = computed(() => {
|
|
288
|
+
return {
|
|
289
|
+
error: props.error,
|
|
290
|
+
[props.cssClass]: true,
|
|
291
|
+
"devui-input-restore": showPwdIcon.value,
|
|
292
|
+
[sizeCls.value]: props.size !== ""
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
const showPreviewIcon = computed(() => inputType.value === "password");
|
|
296
|
+
watch(() => props.showPassword, (flg) => {
|
|
297
|
+
inputType.value = flg ? "password" : "text";
|
|
298
|
+
showPwdIcon.value = props.showPassword;
|
|
299
|
+
}, {
|
|
300
|
+
immediate: true
|
|
301
|
+
});
|
|
302
|
+
const onInput = ($event) => {
|
|
303
|
+
ctx.emit("update:modelValue", $event.target.value);
|
|
304
|
+
hasFormItem && formItem.formItemMitt.emit(dFormItemEvents.input);
|
|
305
|
+
}, onFocus = () => {
|
|
306
|
+
ctx.emit("focus");
|
|
307
|
+
}, onBlur = () => {
|
|
308
|
+
ctx.emit("blur");
|
|
309
|
+
hasFormItem && formItem.formItemMitt.emit(dFormItemEvents.blur);
|
|
310
|
+
}, onChange = ($event) => {
|
|
311
|
+
ctx.emit("change", $event.target.value);
|
|
312
|
+
hasFormItem && formItem.formItemMitt.emit(dFormItemEvents.change);
|
|
313
|
+
}, onKeydown = ($event) => {
|
|
314
|
+
ctx.emit("keydown", $event);
|
|
315
|
+
}, onChangeInputType = () => {
|
|
316
|
+
inputType.value = inputType.value === "password" ? "text" : "password";
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
inputCls,
|
|
320
|
+
inputType,
|
|
321
|
+
showPreviewIcon,
|
|
322
|
+
showPwdIcon,
|
|
323
|
+
onInput,
|
|
324
|
+
onFocus,
|
|
325
|
+
onBlur,
|
|
326
|
+
onChange,
|
|
327
|
+
onKeydown,
|
|
328
|
+
onChangeInputType
|
|
329
|
+
};
|
|
330
|
+
},
|
|
331
|
+
render() {
|
|
332
|
+
const {
|
|
333
|
+
modelValue,
|
|
334
|
+
showPreviewIcon,
|
|
335
|
+
showPwdIcon,
|
|
336
|
+
inputCls,
|
|
337
|
+
inputType,
|
|
338
|
+
maxLength,
|
|
339
|
+
autoFocus,
|
|
340
|
+
placeholder,
|
|
341
|
+
disabled,
|
|
342
|
+
onInput,
|
|
343
|
+
onFocus,
|
|
344
|
+
onBlur,
|
|
345
|
+
onChange,
|
|
346
|
+
onKeydown,
|
|
347
|
+
onChangeInputType
|
|
348
|
+
} = this;
|
|
349
|
+
return createVNode("div", {
|
|
350
|
+
"class": "devui-input__wrap"
|
|
351
|
+
}, [withDirectives(createVNode("input", mergeProps({
|
|
352
|
+
dinput: true
|
|
353
|
+
}, {
|
|
354
|
+
"value": modelValue,
|
|
355
|
+
"disabled": disabled,
|
|
356
|
+
"type": inputType,
|
|
357
|
+
"maxlength": maxLength,
|
|
358
|
+
"placeholder": placeholder,
|
|
359
|
+
"class": inputCls,
|
|
360
|
+
"onInput": onInput,
|
|
361
|
+
"onFocus": onFocus,
|
|
362
|
+
"onBlur": onBlur,
|
|
363
|
+
"onChange": onChange,
|
|
364
|
+
"onKeydown": onKeydown
|
|
365
|
+
}), null), [[resolveDirective("focus"), autoFocus]]), showPwdIcon && createVNode("div", {
|
|
366
|
+
"class": "devui-input__preview",
|
|
367
|
+
"onClick": onChangeInputType
|
|
368
|
+
}, [showPreviewIcon ? createVNode(resolveComponent("d-icon"), {
|
|
369
|
+
"name": "preview-forbidden",
|
|
370
|
+
"size": "12px",
|
|
371
|
+
"key": 1
|
|
372
|
+
}, null) : createVNode(resolveComponent("d-icon"), {
|
|
373
|
+
"name": "preview",
|
|
374
|
+
"size": "12px",
|
|
375
|
+
"key": 2
|
|
376
|
+
}, null)])]);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
const iconProps = {
|
|
380
|
+
name: {
|
|
381
|
+
type: String,
|
|
382
|
+
default: "",
|
|
383
|
+
required: true
|
|
384
|
+
},
|
|
385
|
+
size: {
|
|
386
|
+
type: String,
|
|
387
|
+
default: "inherit"
|
|
388
|
+
},
|
|
389
|
+
color: {
|
|
390
|
+
type: String,
|
|
391
|
+
default: "inherit"
|
|
392
|
+
},
|
|
393
|
+
classPrefix: {
|
|
394
|
+
type: String,
|
|
395
|
+
default: "icon"
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
var Icon = defineComponent({
|
|
399
|
+
name: "DIcon",
|
|
400
|
+
props: iconProps,
|
|
401
|
+
setup(props) {
|
|
402
|
+
const {
|
|
403
|
+
name,
|
|
404
|
+
size,
|
|
405
|
+
color,
|
|
406
|
+
classPrefix
|
|
407
|
+
} = toRefs(props);
|
|
408
|
+
return () => {
|
|
409
|
+
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
410
|
+
"src": name.value,
|
|
411
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
412
|
+
"style": {
|
|
413
|
+
width: size.value,
|
|
414
|
+
verticalAlign: "text-bottom"
|
|
415
|
+
}
|
|
416
|
+
}, null) : createVNode("i", {
|
|
417
|
+
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
418
|
+
"style": {
|
|
419
|
+
fontSize: size.value,
|
|
420
|
+
color: color.value
|
|
421
|
+
}
|
|
422
|
+
}, null);
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
const handleCalendarSwitchState = (state, index2, pos, date) => {
|
|
427
|
+
switch (index2) {
|
|
428
|
+
case 0:
|
|
429
|
+
const preYear = new Date(date);
|
|
430
|
+
preYear.setFullYear(preYear.getFullYear() - 1);
|
|
431
|
+
pos === 0 ? state.current = preYear : state.next = preYear;
|
|
432
|
+
break;
|
|
433
|
+
case 1:
|
|
434
|
+
const preMonth = new Date(date);
|
|
435
|
+
preMonth.setMonth(preMonth.getMonth() - 1);
|
|
436
|
+
pos === 0 ? state.current = preMonth : state.next = preMonth;
|
|
437
|
+
break;
|
|
438
|
+
case 2:
|
|
439
|
+
const nextMonth = new Date(date);
|
|
440
|
+
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
|
441
|
+
pos === 0 ? state.current = nextMonth : state.next = nextMonth;
|
|
442
|
+
break;
|
|
443
|
+
case 3:
|
|
444
|
+
const nextYear = new Date(date);
|
|
445
|
+
nextYear.setFullYear(nextYear.getFullYear() + 1);
|
|
446
|
+
pos === 0 ? state.current = nextYear : state.next = nextYear;
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const formatValue = (state, props) => {
|
|
451
|
+
const { format = "y/MM/dd", range, rangeSpliter = "-" } = props || {};
|
|
452
|
+
if (range) {
|
|
453
|
+
if (!state.start) {
|
|
454
|
+
return "";
|
|
455
|
+
} else if (!state.end) {
|
|
456
|
+
return formatDate(format, state.start);
|
|
457
|
+
}
|
|
458
|
+
if (state.end < state.start) {
|
|
459
|
+
const end = state.end;
|
|
460
|
+
state.end = state.start;
|
|
461
|
+
state.start = end;
|
|
462
|
+
}
|
|
463
|
+
return formatRange$1(format, state.start, state.end, rangeSpliter);
|
|
464
|
+
} else {
|
|
465
|
+
if (!state.start) {
|
|
466
|
+
return "";
|
|
467
|
+
}
|
|
468
|
+
return formatDate(format, state.start);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
const formatPlaceholder = (props) => {
|
|
472
|
+
if (!props) {
|
|
473
|
+
return "";
|
|
474
|
+
}
|
|
475
|
+
const format = props.format || `y/MM/dd`;
|
|
476
|
+
const sp = props.rangeSpliter || "-";
|
|
477
|
+
return props.range ? `${format} ${sp} ${format}` : format;
|
|
478
|
+
};
|
|
479
|
+
const getDateKey = (date) => {
|
|
480
|
+
return date.toDateString();
|
|
481
|
+
};
|
|
482
|
+
const cellClassName = (props, day, base = "cell") => {
|
|
483
|
+
if (!betweenDate(day.date, props.dateMin, props.dateMax)) {
|
|
484
|
+
return `${base} disabled`;
|
|
485
|
+
} else if (day.current !== 0) {
|
|
486
|
+
return `${base} not-current`;
|
|
487
|
+
}
|
|
488
|
+
const key = getDateKey(day.date);
|
|
489
|
+
if (props.type === "range") {
|
|
490
|
+
if (props.dateStart) {
|
|
491
|
+
if (getDateKey(props.dateStart) === key) {
|
|
492
|
+
return `${base} selected`;
|
|
493
|
+
}
|
|
494
|
+
if (props.dateEnd && getDateKey(props.dateEnd) === key) {
|
|
495
|
+
return `${base} selected`;
|
|
496
|
+
}
|
|
497
|
+
const innerEnd = props.dateEnd || props.dateHover;
|
|
498
|
+
if (innerEnd) {
|
|
499
|
+
const range = innerEnd > props.dateStart ? [props.dateStart, innerEnd] : [innerEnd, props.dateStart];
|
|
500
|
+
if (day.date > range[0] && day.date < range[1]) {
|
|
501
|
+
return `${base} innerday`;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return base;
|
|
506
|
+
} else {
|
|
507
|
+
return props.dateStart && getDateKey(props.dateStart) === key ? `${base} selected` : base;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
const trigEvent = (props, day) => {
|
|
511
|
+
if (!betweenDate(day.date, props.dateMin, props.dateMax)) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (props.type === "range") {
|
|
515
|
+
if (!props.dateStart) {
|
|
516
|
+
invokeCallback(props.onSelectStart, day.date);
|
|
517
|
+
} else if (!props.dateEnd) {
|
|
518
|
+
if (subDateDay(props.dateStart, day.date) !== 0) {
|
|
519
|
+
invokeCallback(props.onSelectEnd, day.date);
|
|
520
|
+
typeof props.onChange === "function" && props.onChange(props.type, props);
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
invokeCallback(props.onReset, day.date);
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
invokeCallback(props.onSelected, day.date);
|
|
527
|
+
typeof props.onChange === "function" && props.onChange(props.type, props);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
const handleDateEnter = (props, day) => {
|
|
531
|
+
if (day.current !== 0) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const { dateMin, dateMax } = props;
|
|
535
|
+
if (dateMin && subDateDay(day.date, dateMin) < 0) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (dateMax && subDateDay(dateMax, day.date) < 0) {
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (props.type === "range") {
|
|
542
|
+
const key = getDateKey(day.date);
|
|
543
|
+
if (!props.dateStart || getDateKey(props.dateStart) === key || props.dateEnd) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
invokeCallback(props.onSelecting, day.date);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
const Year = (props) => {
|
|
550
|
+
const {
|
|
551
|
+
color = "#585d6b",
|
|
552
|
+
rotate = 0
|
|
553
|
+
} = props;
|
|
554
|
+
return createVNode("svg", {
|
|
555
|
+
"style": {
|
|
556
|
+
transform: `rotate(${rotate}deg)`
|
|
557
|
+
},
|
|
558
|
+
"width": "10px",
|
|
559
|
+
"height": "10px",
|
|
560
|
+
"viewBox": "0 0 10 10",
|
|
561
|
+
"version": "1.1",
|
|
562
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
563
|
+
}, [createVNode("g", {
|
|
564
|
+
"fill": color,
|
|
565
|
+
"transform": "translate(-1.000000, -1.000000)"
|
|
566
|
+
}, [createVNode("path", {
|
|
567
|
+
"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"
|
|
568
|
+
}, null)])]);
|
|
569
|
+
};
|
|
570
|
+
const Month = (props) => {
|
|
571
|
+
const {
|
|
572
|
+
color = "#585d6b",
|
|
573
|
+
rotate = 0
|
|
574
|
+
} = props;
|
|
575
|
+
return createVNode("svg", {
|
|
576
|
+
"style": {
|
|
577
|
+
transform: `rotate(${rotate}deg)`
|
|
578
|
+
},
|
|
579
|
+
"width": "6px",
|
|
580
|
+
"height": "10px",
|
|
581
|
+
"viewBox": "0 0 6 10",
|
|
582
|
+
"version": "1.1",
|
|
583
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
584
|
+
}, [createVNode("g", {
|
|
585
|
+
"fill": color,
|
|
586
|
+
"transform": "translate(-3.000000, -1.000000)"
|
|
587
|
+
}, [createVNode("polygon", {
|
|
588
|
+
"points": "6 3 10.1666667 9 1.83333333 9"
|
|
589
|
+
}, null)])]);
|
|
590
|
+
};
|
|
591
|
+
var index$6 = "";
|
|
592
|
+
const Item = (props) => {
|
|
593
|
+
const {
|
|
594
|
+
button: Btn,
|
|
595
|
+
disabled = false,
|
|
596
|
+
rotate = 0,
|
|
597
|
+
date,
|
|
598
|
+
pos
|
|
599
|
+
} = props;
|
|
600
|
+
const color = disabled ? "#cfd0d3" : "#585d6b";
|
|
601
|
+
const className = `${disabled ? "disabled" : ""}`;
|
|
602
|
+
const handleClick = disabled ? void 0 : () => invokeCallback(props.cb, date, pos);
|
|
603
|
+
return createVNode("a", {
|
|
604
|
+
"class": className,
|
|
605
|
+
"onClick": handleClick
|
|
606
|
+
}, [createVNode(Btn, {
|
|
607
|
+
"color": color,
|
|
608
|
+
"rotate": rotate
|
|
609
|
+
}, null)]);
|
|
610
|
+
};
|
|
611
|
+
const Title = (props) => {
|
|
612
|
+
const {
|
|
613
|
+
date
|
|
614
|
+
} = props;
|
|
615
|
+
return createVNode("a", {
|
|
616
|
+
"class": "title"
|
|
617
|
+
}, [`${date.getFullYear()}\u5E74${(date.getMonth() + 1 + "").padStart(2, "0")}\u6708`]);
|
|
618
|
+
};
|
|
619
|
+
const CalendarToolbar = (props) => {
|
|
620
|
+
const {
|
|
621
|
+
type,
|
|
622
|
+
current,
|
|
623
|
+
compare,
|
|
624
|
+
pos,
|
|
625
|
+
dateMax,
|
|
626
|
+
dateMin,
|
|
627
|
+
onPreviousYear,
|
|
628
|
+
onPreviousMonth,
|
|
629
|
+
onNextMonth,
|
|
630
|
+
onNextYear
|
|
631
|
+
} = props;
|
|
632
|
+
const dis = [false, false, false, false];
|
|
633
|
+
if (type === "range") {
|
|
634
|
+
if (pos === 1) {
|
|
635
|
+
dis[0] = !compareDate(compare, current, "year", 1);
|
|
636
|
+
dis[1] = !compareDate(compare, current, "month", 1);
|
|
637
|
+
dis[2] = !compareDate(current, dateMax, "month", 0);
|
|
638
|
+
dis[3] = !compareDate(current, dateMax, "year", 0);
|
|
639
|
+
} else {
|
|
640
|
+
dis[0] = !compareDate(dateMin, current, "year", 0);
|
|
641
|
+
dis[1] = !compareDate(dateMin, current, "month", 0);
|
|
642
|
+
dis[2] = !compareDate(current, compare, "month", 1);
|
|
643
|
+
dis[3] = !compareDate(current, compare, "year", 1);
|
|
644
|
+
}
|
|
645
|
+
} else {
|
|
646
|
+
dis[0] = !compareDate(dateMin, current, "year", 0);
|
|
647
|
+
dis[1] = !compareDate(dateMin, current, "month", 0);
|
|
648
|
+
dis[2] = !compareDate(current, dateMax, "month", 0);
|
|
649
|
+
dis[3] = !compareDate(current, dateMax, "year", 0);
|
|
650
|
+
}
|
|
651
|
+
return createVNode("div", {
|
|
652
|
+
"class": "devui-calendar-toolbar"
|
|
653
|
+
}, [createVNode(Item, {
|
|
654
|
+
"disabled": dis[0],
|
|
655
|
+
"date": current,
|
|
656
|
+
"pos": pos,
|
|
657
|
+
"button": Year,
|
|
658
|
+
"cb": onPreviousYear
|
|
659
|
+
}, null), createVNode(Item, {
|
|
660
|
+
"disabled": dis[1],
|
|
661
|
+
"date": current,
|
|
662
|
+
"pos": pos,
|
|
663
|
+
"button": Month,
|
|
664
|
+
"rotate": -90,
|
|
665
|
+
"cb": onPreviousMonth
|
|
666
|
+
}, null), createVNode(Title, {
|
|
667
|
+
"date": current
|
|
668
|
+
}, null), createVNode(Item, {
|
|
669
|
+
"disabled": dis[2],
|
|
670
|
+
"date": current,
|
|
671
|
+
"pos": pos,
|
|
672
|
+
"button": Month,
|
|
673
|
+
"rotate": 90,
|
|
674
|
+
"cb": onNextMonth
|
|
675
|
+
}, null), createVNode(Item, {
|
|
676
|
+
"disabled": dis[3],
|
|
677
|
+
"date": current,
|
|
678
|
+
"pos": pos,
|
|
679
|
+
"button": Year,
|
|
680
|
+
"rotate": 180,
|
|
681
|
+
"cb": onNextYear
|
|
682
|
+
}, null)]);
|
|
683
|
+
};
|
|
684
|
+
const TodayDefault = (props) => {
|
|
685
|
+
const {
|
|
686
|
+
onSelected = () => 0,
|
|
687
|
+
disabled = false
|
|
688
|
+
} = props;
|
|
689
|
+
return createVNode("div", {
|
|
690
|
+
"class": `today-container ${disabled ? "disabled" : ""}`
|
|
691
|
+
}, [createVNode("button", {
|
|
692
|
+
"class": "today-button",
|
|
693
|
+
"disabled": disabled,
|
|
694
|
+
"onClick": disabled ? void 0 : () => onSelected(new Date())
|
|
695
|
+
}, [createTextVNode("\u4ECA\u5929")])]);
|
|
696
|
+
};
|
|
697
|
+
var index$5 = "";
|
|
698
|
+
const CalendarDatePanel = (props) => {
|
|
699
|
+
const today = new Date();
|
|
700
|
+
return createVNode("div", {
|
|
701
|
+
"class": "devui-calendar-panel"
|
|
702
|
+
}, [createVNode(CalendarToolbar, {
|
|
703
|
+
"current": props.current,
|
|
704
|
+
"compare": props.compare,
|
|
705
|
+
"pos": props.pos,
|
|
706
|
+
"type": props.type,
|
|
707
|
+
"showTime": props.showTime,
|
|
708
|
+
"onPreviousYear": props.onPreviousYear,
|
|
709
|
+
"onPreviousMonth": props.onPreviousMonth,
|
|
710
|
+
"onNextMonth": props.onNextMonth,
|
|
711
|
+
"onNextYear": props.onNextYear,
|
|
712
|
+
"dateMax": props.dateMax,
|
|
713
|
+
"dateMin": props.dateMin
|
|
714
|
+
}, null), createVNode("ol", {
|
|
715
|
+
"class": "head row"
|
|
716
|
+
}, [WEEK_DAYS.map((day) => createVNode("li", {
|
|
717
|
+
"class": "cell"
|
|
718
|
+
}, [day]))]), createVNode("ul", {
|
|
719
|
+
"class": "body"
|
|
720
|
+
}, [getMonthWeeklyDays(props.current).map((row) => createVNode("li", {
|
|
721
|
+
"class": "row"
|
|
722
|
+
}, [row.map((day) => {
|
|
723
|
+
return createVNode("span", {
|
|
724
|
+
"class": cellClassName(props, day),
|
|
725
|
+
"onClick": () => trigEvent(props, day),
|
|
726
|
+
"onMouseenter": () => handleDateEnter(props, day)
|
|
727
|
+
}, [day.date.getDate()]);
|
|
728
|
+
})]))]), props.type !== "range" ? createVNode(TodayDefault, {
|
|
729
|
+
"disabled": !betweenDate(today, props.dateMin, props.dateMax),
|
|
730
|
+
"onSelected": (today2) => {
|
|
731
|
+
typeof props.onToday === "function" && props.onToday(today2, 0);
|
|
732
|
+
}
|
|
733
|
+
}, null) : null]);
|
|
734
|
+
};
|
|
735
|
+
var index$4 = "";
|
|
736
|
+
const VerticalSlider = defineComponent({
|
|
737
|
+
props: {
|
|
738
|
+
size: {
|
|
739
|
+
type: Number,
|
|
740
|
+
default: 26
|
|
741
|
+
},
|
|
742
|
+
items: {
|
|
743
|
+
type: Array
|
|
744
|
+
},
|
|
745
|
+
selectedIndex: {
|
|
746
|
+
type: Number
|
|
747
|
+
},
|
|
748
|
+
className: {
|
|
749
|
+
type: String
|
|
750
|
+
},
|
|
751
|
+
itemClassNormal: {
|
|
752
|
+
type: String
|
|
753
|
+
},
|
|
754
|
+
itemClassSelected: {
|
|
755
|
+
type: String
|
|
756
|
+
},
|
|
757
|
+
onChange: {
|
|
758
|
+
type: Function
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
setup(props) {
|
|
762
|
+
const {
|
|
763
|
+
items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
764
|
+
selectedIndex = 0,
|
|
765
|
+
size = 26,
|
|
766
|
+
className = "",
|
|
767
|
+
itemClassNormal = "",
|
|
768
|
+
itemClassSelected = "selected",
|
|
769
|
+
onChange
|
|
770
|
+
} = props || {};
|
|
771
|
+
let max_y = 0, min_y = 0;
|
|
772
|
+
const container = ref();
|
|
773
|
+
const movbar = ref();
|
|
774
|
+
let pos_start = null;
|
|
775
|
+
let pos_cache = null;
|
|
776
|
+
const state = reactive({
|
|
777
|
+
selectedIndex,
|
|
778
|
+
barOpacity: 0,
|
|
779
|
+
x: 0,
|
|
780
|
+
y: 0,
|
|
781
|
+
transition: "none"
|
|
782
|
+
});
|
|
783
|
+
const handleMouseDown = (e) => {
|
|
784
|
+
e.stopPropagation();
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
pos_start = [e.clientX, e.clientY];
|
|
787
|
+
state.transition = "none";
|
|
788
|
+
};
|
|
789
|
+
const handleMouseMove = (e) => {
|
|
790
|
+
e.stopPropagation();
|
|
791
|
+
e.preventDefault();
|
|
792
|
+
if (!pos_start || !pos_cache) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
state.x = pos_cache[0] + e.clientX - pos_start[0];
|
|
796
|
+
state.y = Math.min(max_y, Math.max(min_y, pos_cache[1] + e.clientY - pos_start[1]));
|
|
797
|
+
state.selectedIndex = (max_y - state.y + size / 2) / size >> 0;
|
|
798
|
+
};
|
|
799
|
+
const handleMouseUp = (e) => {
|
|
800
|
+
e.stopPropagation();
|
|
801
|
+
e.preventDefault();
|
|
802
|
+
pos_start = null;
|
|
803
|
+
state.y = max_y - state.selectedIndex * size;
|
|
804
|
+
state.transition = "transform 0.1s";
|
|
805
|
+
pos_cache[0] = state.x;
|
|
806
|
+
pos_cache[1] = state.y;
|
|
807
|
+
if (typeof onChange === "function") {
|
|
808
|
+
const idx = state.selectedIndex;
|
|
809
|
+
const val = items[idx];
|
|
810
|
+
onChange(val, idx);
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
onMounted(() => {
|
|
814
|
+
const {
|
|
815
|
+
height: ch
|
|
816
|
+
} = container.value.getBoundingClientRect();
|
|
817
|
+
const {
|
|
818
|
+
height: mh
|
|
819
|
+
} = movbar.value.getBoundingClientRect();
|
|
820
|
+
max_y = (ch - size) / 2;
|
|
821
|
+
min_y = (ch + size) / 2 - mh;
|
|
822
|
+
pos_cache = [0, max_y - state.selectedIndex * size];
|
|
823
|
+
state.x = pos_cache[0];
|
|
824
|
+
state.y = pos_cache[1];
|
|
825
|
+
state.barOpacity = 1;
|
|
826
|
+
state.transition = "transform 0.1s";
|
|
827
|
+
});
|
|
828
|
+
return () => {
|
|
829
|
+
return createVNode("div", {
|
|
830
|
+
"ref": container,
|
|
831
|
+
"class": `devui-vertical-slider ${className}`
|
|
832
|
+
}, [createVNode("div", {
|
|
833
|
+
"ref": movbar,
|
|
834
|
+
"class": "movable-bar",
|
|
835
|
+
"style": {
|
|
836
|
+
opacity: state.barOpacity,
|
|
837
|
+
transform: `translateY(${state.y}px)`,
|
|
838
|
+
transition: state.transition
|
|
839
|
+
}
|
|
840
|
+
}, [items.map((c, i) => {
|
|
841
|
+
const className2 = i === state.selectedIndex ? itemClassSelected : itemClassNormal;
|
|
842
|
+
return createVNode("span", {
|
|
843
|
+
"class": `slider-item ${className2}`,
|
|
844
|
+
"style": {
|
|
845
|
+
height: `${size}px`,
|
|
846
|
+
lineHeight: `${size}px`
|
|
847
|
+
}
|
|
848
|
+
}, [c]);
|
|
849
|
+
})]), createVNode("div", {
|
|
850
|
+
"class": "slider-mask",
|
|
851
|
+
"onMousedown": handleMouseDown,
|
|
852
|
+
"onMousemove": handleMouseMove,
|
|
853
|
+
"onMouseup": handleMouseUp,
|
|
854
|
+
"onMouseout": handleMouseUp
|
|
855
|
+
}, null)]);
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
var index$3 = "";
|
|
860
|
+
const TimePicker = defineComponent({
|
|
861
|
+
props: {
|
|
862
|
+
time: {
|
|
863
|
+
type: Date
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
setup(props) {
|
|
867
|
+
const {
|
|
868
|
+
time = new Date()
|
|
869
|
+
} = props || {};
|
|
870
|
+
const state = reactive({
|
|
871
|
+
hour: time.getHours(),
|
|
872
|
+
minute: time.getMinutes(),
|
|
873
|
+
second: time.getSeconds()
|
|
874
|
+
});
|
|
875
|
+
const hours = Array(24).fill(0).map((_, i) => `${i}`.padStart(2, "0"));
|
|
876
|
+
const minutes = Array(60).fill(0).map((_, i) => `${i}`.padStart(2, "0"));
|
|
877
|
+
return () => {
|
|
878
|
+
return createVNode("div", {
|
|
879
|
+
"class": "devui-calendar-timepicker"
|
|
880
|
+
}, [createVNode("div", {
|
|
881
|
+
"class": "head"
|
|
882
|
+
}, [createVNode("div", {
|
|
883
|
+
"class": "chars"
|
|
884
|
+
}, [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", {
|
|
885
|
+
"class": "select"
|
|
886
|
+
}, [createVNode(VerticalSlider, {
|
|
887
|
+
"items": hours,
|
|
888
|
+
"selectedIndex": state.hour,
|
|
889
|
+
"onChange": (_, idx) => state.hour = idx
|
|
890
|
+
}, null), createVNode(VerticalSlider, {
|
|
891
|
+
"items": minutes,
|
|
892
|
+
"selectedIndex": state.minute,
|
|
893
|
+
"onChange": (_, idx) => state.minute = idx
|
|
894
|
+
}, null), createVNode(VerticalSlider, {
|
|
895
|
+
"items": minutes,
|
|
896
|
+
"selectedIndex": state.second,
|
|
897
|
+
"onChange": (_, idx) => state.second = idx
|
|
898
|
+
}, null)])]);
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
var index$2 = "";
|
|
903
|
+
const Calendar = (props) => {
|
|
904
|
+
const {
|
|
905
|
+
showTime = false
|
|
906
|
+
} = props;
|
|
907
|
+
let {
|
|
908
|
+
current
|
|
909
|
+
} = props;
|
|
910
|
+
if (!(current instanceof Date)) {
|
|
911
|
+
current = new Date();
|
|
912
|
+
}
|
|
913
|
+
if (props.type === "range") {
|
|
914
|
+
let {
|
|
915
|
+
next
|
|
916
|
+
} = props;
|
|
917
|
+
if (!(next instanceof Date)) {
|
|
918
|
+
next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
|
|
919
|
+
}
|
|
920
|
+
return createVNode("div", {
|
|
921
|
+
"class": "devui-calendar-container"
|
|
922
|
+
}, [createVNode(CalendarDatePanel, mergeProps(props, {
|
|
923
|
+
"pos": 0,
|
|
924
|
+
"current": current,
|
|
925
|
+
"compare": next
|
|
926
|
+
}), null), showTime ? createVNode(TimePicker, {
|
|
927
|
+
"time": current
|
|
928
|
+
}, null) : null, createVNode(CalendarDatePanel, mergeProps(props, {
|
|
929
|
+
"pos": 1,
|
|
930
|
+
"current": next,
|
|
931
|
+
"compare": current
|
|
932
|
+
}), null), showTime ? createVNode(TimePicker, {
|
|
933
|
+
"time": next
|
|
934
|
+
}, null) : null]);
|
|
935
|
+
} else {
|
|
936
|
+
return createVNode("div", {
|
|
937
|
+
"class": "devui-calendar-container"
|
|
938
|
+
}, [createVNode(CalendarDatePanel, mergeProps(props, {
|
|
939
|
+
"pos": 0,
|
|
940
|
+
"current": current
|
|
941
|
+
}), null), showTime ? createVNode(TimePicker, {
|
|
942
|
+
"time": current
|
|
943
|
+
}, null) : null]);
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
var datePicker = "";
|
|
947
|
+
const formatRange = (state) => {
|
|
948
|
+
const [start, end] = [state.start, state.end].sort((a, b) => a.getTime() - b.getTime());
|
|
949
|
+
state.start = start;
|
|
950
|
+
state.end = end;
|
|
951
|
+
if (compareDateSort(start, end, "m") !== 0) {
|
|
952
|
+
state.current = start;
|
|
953
|
+
state.next = end;
|
|
954
|
+
} else {
|
|
955
|
+
if (compareDateSort(start, state.current) < 0) {
|
|
956
|
+
state.current = start;
|
|
957
|
+
}
|
|
958
|
+
if (compareDateSort(state.next, end) < 0) {
|
|
959
|
+
state.next = end;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
var DatePicker = defineComponent({
|
|
964
|
+
name: "DDatepicker",
|
|
965
|
+
props: {
|
|
966
|
+
selectedDateChange: {
|
|
967
|
+
type: Function
|
|
968
|
+
},
|
|
969
|
+
autoClose: {
|
|
970
|
+
type: Boolean,
|
|
971
|
+
default: false
|
|
972
|
+
},
|
|
973
|
+
range: {
|
|
974
|
+
type: Boolean,
|
|
975
|
+
default: false
|
|
976
|
+
},
|
|
977
|
+
showTime: {
|
|
978
|
+
type: Boolean,
|
|
979
|
+
default: false
|
|
980
|
+
},
|
|
981
|
+
format: {
|
|
982
|
+
type: String,
|
|
983
|
+
default: "y/MM/dd"
|
|
984
|
+
},
|
|
985
|
+
rangeSpliter: {
|
|
986
|
+
type: String,
|
|
987
|
+
default: "-"
|
|
988
|
+
},
|
|
989
|
+
attachInputDom: {
|
|
990
|
+
type: String
|
|
991
|
+
},
|
|
992
|
+
dateMin: {
|
|
993
|
+
type: String
|
|
994
|
+
},
|
|
995
|
+
dateMax: {
|
|
996
|
+
type: String
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
setup(props) {
|
|
1000
|
+
const panel = ref(null);
|
|
1001
|
+
const input2 = ref(null);
|
|
1002
|
+
const current = parseDate(props.dateMin) || new Date();
|
|
1003
|
+
const next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
|
|
1004
|
+
const state = reactive({
|
|
1005
|
+
show: false,
|
|
1006
|
+
value: "",
|
|
1007
|
+
placeholder: formatPlaceholder(props),
|
|
1008
|
+
current,
|
|
1009
|
+
next
|
|
1010
|
+
});
|
|
1011
|
+
state.value = formatValue(state, props);
|
|
1012
|
+
state.placeholder = formatPlaceholder(props);
|
|
1013
|
+
const documentClick = (e) => {
|
|
1014
|
+
e.stopPropagation();
|
|
1015
|
+
if (isIn(e.target, panel.value) || isIn(e.target, input2.value)) {
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
state.show = false;
|
|
1019
|
+
};
|
|
1020
|
+
onMounted(() => {
|
|
1021
|
+
document.addEventListener("click", documentClick);
|
|
1022
|
+
});
|
|
1023
|
+
onUnmounted(() => {
|
|
1024
|
+
document.removeEventListener("click", documentClick);
|
|
1025
|
+
});
|
|
1026
|
+
return () => {
|
|
1027
|
+
return createVNode("div", {
|
|
1028
|
+
"class": "devui-datepicker-container"
|
|
1029
|
+
}, [createVNode("div", {
|
|
1030
|
+
"class": "input-container",
|
|
1031
|
+
"ref": input2
|
|
1032
|
+
}, [createVNode(Input, {
|
|
1033
|
+
"ref": input2,
|
|
1034
|
+
"class": "datepicker-input",
|
|
1035
|
+
"modelValue": state.value,
|
|
1036
|
+
"placeholder": state.placeholder,
|
|
1037
|
+
"onFocus": () => state.show = true
|
|
1038
|
+
}, null), createVNode(Icon, {
|
|
1039
|
+
"size": "small",
|
|
1040
|
+
"name": "calendar",
|
|
1041
|
+
"class": "datepicker-input-icon"
|
|
1042
|
+
}, null)]), createVNode("div", {
|
|
1043
|
+
"class": "devui-datepicker-panel",
|
|
1044
|
+
"ref": panel
|
|
1045
|
+
}, [state.show ? createVNode(Calendar, {
|
|
1046
|
+
"type": props.range ? "range" : "select",
|
|
1047
|
+
"showTime": props.showTime,
|
|
1048
|
+
"current": state.current,
|
|
1049
|
+
"next": state.next,
|
|
1050
|
+
"dateMin": parseDate(props.dateMin),
|
|
1051
|
+
"dateMax": parseDate(props.dateMax),
|
|
1052
|
+
"dateStart": state.start,
|
|
1053
|
+
"dateEnd": state.end,
|
|
1054
|
+
"dateHover": state.hover,
|
|
1055
|
+
"onReset": (date) => {
|
|
1056
|
+
state.end = state.hover = void 0;
|
|
1057
|
+
state.start = date;
|
|
1058
|
+
},
|
|
1059
|
+
"onChange": () => {
|
|
1060
|
+
state.value = formatValue(state, props);
|
|
1061
|
+
state.placeholder = formatPlaceholder(props);
|
|
1062
|
+
invokeFunction(props.selectedDateChange, state.value);
|
|
1063
|
+
if (props.autoClose) {
|
|
1064
|
+
state.show = false;
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
"onToday": (date) => {
|
|
1068
|
+
state.current = date;
|
|
1069
|
+
state.start = date;
|
|
1070
|
+
state.value = formatValue(state, props);
|
|
1071
|
+
state.placeholder = formatPlaceholder(props);
|
|
1072
|
+
invokeFunction(props.selectedDateChange, state.value);
|
|
1073
|
+
if (props.autoClose) {
|
|
1074
|
+
state.show = false;
|
|
1075
|
+
}
|
|
1076
|
+
},
|
|
1077
|
+
"onSelected": (date) => {
|
|
1078
|
+
state.start = date;
|
|
1079
|
+
if (compareDateSort(state.current, date) !== 0) {
|
|
1080
|
+
state.current = date;
|
|
1081
|
+
}
|
|
1082
|
+
},
|
|
1083
|
+
"onSelectStart": (date) => state.start = date,
|
|
1084
|
+
"onSelectEnd": (date) => {
|
|
1085
|
+
state.end = date;
|
|
1086
|
+
formatRange(state);
|
|
1087
|
+
},
|
|
1088
|
+
"onSelecting": (date) => state.hover = date,
|
|
1089
|
+
"onPreviousYear": (date, pos) => handleCalendarSwitchState(state, 0, pos, date),
|
|
1090
|
+
"onPreviousMonth": (date, pos) => handleCalendarSwitchState(state, 1, pos, date),
|
|
1091
|
+
"onNextMonth": (date, pos) => handleCalendarSwitchState(state, 2, pos, date),
|
|
1092
|
+
"onNextYear": (date, pos) => handleCalendarSwitchState(state, 3, pos, date)
|
|
1093
|
+
}, null) : null])]);
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
var index$1 = "";
|
|
1098
|
+
const StickSlider = defineComponent({
|
|
1099
|
+
name: "DStickSlider",
|
|
1100
|
+
props: {},
|
|
1101
|
+
setup() {
|
|
1102
|
+
const state = reactive({
|
|
1103
|
+
showButtons: false,
|
|
1104
|
+
selectedIndex: 0
|
|
1105
|
+
});
|
|
1106
|
+
const reset = () => {
|
|
1107
|
+
state.showButtons = false;
|
|
1108
|
+
};
|
|
1109
|
+
const handleMainButtonMouseDown = (e) => {
|
|
1110
|
+
e.stopPropagation();
|
|
1111
|
+
state.showButtons = true;
|
|
1112
|
+
};
|
|
1113
|
+
const handleMainButtonMouseUp = (e) => {
|
|
1114
|
+
e.stopPropagation();
|
|
1115
|
+
reset();
|
|
1116
|
+
};
|
|
1117
|
+
return () => {
|
|
1118
|
+
return createVNode("div", {
|
|
1119
|
+
"class": "devui-stick-slider",
|
|
1120
|
+
"onMousedown": handleMainButtonMouseDown,
|
|
1121
|
+
"onMouseup": handleMainButtonMouseUp,
|
|
1122
|
+
"onMouseleave": handleMainButtonMouseUp
|
|
1123
|
+
}, [createVNode("div", {
|
|
1124
|
+
"class": "sub-buttons",
|
|
1125
|
+
"style": {
|
|
1126
|
+
display: state.showButtons ? "" : "none"
|
|
1127
|
+
}
|
|
1128
|
+
}, [Array(16).fill(null).map((_, i) => {
|
|
1129
|
+
return createVNode("div", {
|
|
1130
|
+
"class": `button ${i === state.selectedIndex ? "selected" : ""}`,
|
|
1131
|
+
"onMouseenter": () => state.selectedIndex = i
|
|
1132
|
+
}, [i]);
|
|
1133
|
+
})]), createVNode("div", {
|
|
1134
|
+
"class": "main-button"
|
|
1135
|
+
}, null)]);
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
DatePicker.install = function(app) {
|
|
1140
|
+
app.component(DatePicker.name, DatePicker);
|
|
1141
|
+
app.component(StickSlider.name, StickSlider);
|
|
1142
|
+
};
|
|
1143
|
+
var index = {
|
|
1144
|
+
title: "DatePicker \u65E5\u671F\u9009\u62E9\u5668",
|
|
1145
|
+
category: "\u6570\u636E\u5F55\u5165",
|
|
1146
|
+
status: "50%",
|
|
1147
|
+
install(app) {
|
|
1148
|
+
app.use(DatePicker);
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
export { DatePicker, StickSlider, index as default };
|