@solar-taro/ui-vant 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/cascader/index.scss +0 -5
- package/date-range-picker/index.scss +0 -5
- package/index.d.ts +0 -1
- package/index.js +19 -21
- package/index.scss +2 -0
- package/index10.js +16 -61
- package/index11.js +3 -18
- package/index12.js +28 -3
- package/index13.js +4 -28
- package/index14.js +2 -5
- package/index15.js +1 -1
- package/index16.js +1 -1
- package/index17.js +1 -1
- package/index19.js +1 -1
- package/index2.js +1 -1
- package/index20.js +7 -2
- package/index21.js +40 -2
- package/index22.js +25 -7
- package/index3.js +122 -115
- package/index5.js +91 -84
- package/index6.js +278 -51
- package/index7.js +56 -280
- package/index8.js +370 -54
- package/index9.js +63 -382
- package/overlay/overlay.d.ts +2 -0
- package/package.json +1 -1
- package/selector/index.scss +0 -5
- package/selector/index.vue.d.ts +3 -6
- package/index23.js +0 -42
- package/index24.js +0 -27
- package/modal/index.d.ts +0 -1
- package/modal/index.scss +0 -14
- package/modal/index.vue.d.ts +0 -37
package/index8.js
CHANGED
|
@@ -1,64 +1,380 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { defineComponent as pe, inject as Q, useModel as X, ref as Y, computed as f, effect as Z, Fragment as ye, mergeModels as I, openBlock as ke, createElementBlock as he, renderSlot as me, createElementVNode as ge, normalizeClass as Se, createTextVNode as be, toDisplayString as xe, renderList as we, createBlock as Ve, unref as Te, withCtx as $e, withModifiers as Be, createCommentVNode as Le, createVNode as ze, createSlots as Me, normalizeStyle as Ne } from "vue";
|
|
2
|
+
import { SUN_ITEM as Ce, SUN_FIELD as Ee, SunTag as qe, SunIcon as M, SunLazyRender as We, SunModal as Re, SunSearchbar as De, SunVirtualList as Fe, SunListPlaceholder as Ue, SunItemDivider as _, SunItem as ee, SunList as Ge, SunButton as le } from "@solar-taro/ui-sun";
|
|
3
|
+
import { defaultRangeExtractor as je } from "./index20.js";
|
|
4
|
+
import { createReusableTemplate as Ae } from "./index21.js";
|
|
5
|
+
import { isNil as te } from "lodash-es";
|
|
6
|
+
const y = me, g = xe, b = be, S = ye, o = ke, p = he, k = Le, D = we, a = Te, u = $e, v = Ve, ne = Be, x = ze, F = Se, N = ge, C = Ne, Pe = Me, He = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "sun-selector-inner"
|
|
9
|
+
}, Je = {
|
|
10
|
+
key: 1,
|
|
11
|
+
class: "sun-selector-tags"
|
|
12
|
+
}, Ke = {
|
|
13
|
+
key: 1,
|
|
14
|
+
class: "sun-selector-placeholder"
|
|
15
|
+
}, Oe = { class: "sun-selector-option-label" }, Qe = { class: "sun-selector-option-label" }, el = /* @__PURE__ */ pe({
|
|
6
16
|
__name: "index",
|
|
7
|
-
props: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
valueKey: { default: "id" },
|
|
11
|
-
searchable: { type: Boolean, default: !0 },
|
|
12
|
-
title: {},
|
|
13
|
-
loading: { type: Boolean },
|
|
17
|
+
props: /* @__PURE__ */ I({
|
|
18
|
+
mode: { default: "single" },
|
|
19
|
+
placeholder: { default: "请选择" },
|
|
14
20
|
options: {},
|
|
21
|
+
loading: { type: Boolean },
|
|
22
|
+
height: { default: "65vh" },
|
|
23
|
+
required: { type: Boolean },
|
|
24
|
+
disabled: { type: Boolean },
|
|
25
|
+
delimiter: { default: ", " },
|
|
26
|
+
searchable: { type: Boolean, default: !0 },
|
|
27
|
+
clearable: { type: Boolean, default: !0 },
|
|
28
|
+
filter: {},
|
|
29
|
+
virtual: { type: Boolean },
|
|
30
|
+
optionSize: { type: [Number, Function], default: 44 },
|
|
31
|
+
refresher: { type: Boolean },
|
|
32
|
+
refreshing: { type: Boolean },
|
|
33
|
+
compareWith: { type: Function, default: (s, E) => s === E }
|
|
34
|
+
}, {
|
|
15
35
|
modelValue: {},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
() =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
modelModifiers: {},
|
|
37
|
+
keyword: { default: "" },
|
|
38
|
+
keywordModifiers: {}
|
|
39
|
+
}),
|
|
40
|
+
emits: /* @__PURE__ */ I(["select", "unselect", "clear", "close", "confirm", "refresh"], ["update:modelValue", "update:keyword"]),
|
|
41
|
+
setup(s, { expose: E, emit: oe }) {
|
|
42
|
+
const [ae, U] = Ae(), w = Q(Ce, void 0), q = Q(Ee, void 0), r = s, h = oe, d = X(s, "modelValue"), $ = Y(!1), se = f(() => {
|
|
43
|
+
const e = r.optionSize;
|
|
44
|
+
return typeof e == "function" ? e : () => e;
|
|
45
|
+
}), B = f(() => r.options.flatMap((e) => ve(e) ? e.options.map((t) => ({
|
|
46
|
+
...t,
|
|
47
|
+
parent: e
|
|
48
|
+
})) : e)), L = X(s, "keyword"), G = f(() => B.value.filter((e) => {
|
|
49
|
+
const t = L.value.toLowerCase();
|
|
50
|
+
return ue.value(e, t);
|
|
51
|
+
})), V = f(() => {
|
|
52
|
+
var e;
|
|
53
|
+
if (m.value) {
|
|
54
|
+
const t = B.value.find(
|
|
55
|
+
(l) => r.compareWith(l.value, d.value)
|
|
56
|
+
);
|
|
57
|
+
return t ? [t] : [];
|
|
58
|
+
}
|
|
59
|
+
return ((e = d.value) != null ? e : []).map(
|
|
60
|
+
(t) => B.value.find((l) => r.compareWith(l.value, t))
|
|
61
|
+
).filter(Boolean);
|
|
62
|
+
}), i = f(() => {
|
|
63
|
+
const e = G.value, t = /* @__PURE__ */ new Set();
|
|
64
|
+
return e.flatMap((l) => {
|
|
65
|
+
const n = [];
|
|
66
|
+
return l.parent && !t.has(l.parent) && (t.add(l.parent), n.push({ kind: "optionGroup", value: l.parent })), n.push({ kind: "option", value: l }), n;
|
|
67
|
+
});
|
|
68
|
+
}), j = f(
|
|
69
|
+
() => i.value.reduce((e, t, l) => (t.kind === "optionGroup" && e.push(l), e), [])
|
|
70
|
+
), re = f(() => [...j.value].reverse()), A = Y(0), ue = f(() => r.filter || ((e, t) => e.label.toLowerCase().includes(t))), P = f(() => V.value.map((e) => e.label).join(r.delimiter)), H = f(() => !ie(d.value) && r.clearable && !r.disabled), m = f(() => r.mode === "single");
|
|
71
|
+
function ie(e) {
|
|
72
|
+
return te(e) ? !0 : m.value ? !1 : e.length < 1;
|
|
73
|
+
}
|
|
74
|
+
function c(e) {
|
|
75
|
+
var l;
|
|
76
|
+
const t = e.value;
|
|
77
|
+
return m.value ? te(d.value) ? !1 : r.compareWith(d.value, t) : ((l = d.value) == null ? void 0 : l.some((n) => r.compareWith(n, t))) || !1;
|
|
78
|
+
}
|
|
79
|
+
function z() {
|
|
80
|
+
r.disabled || ($.value = !0);
|
|
81
|
+
}
|
|
82
|
+
function J() {
|
|
83
|
+
$.value = !1, h("close");
|
|
84
|
+
}
|
|
85
|
+
function K() {
|
|
86
|
+
var t;
|
|
87
|
+
const e = ((t = d.value) == null ? void 0 : t.map(
|
|
88
|
+
(l) => B.value.find(
|
|
89
|
+
(n) => r.compareWith(n.value, l)
|
|
90
|
+
)
|
|
91
|
+
)) || [];
|
|
92
|
+
h("confirm", e), J();
|
|
93
|
+
}
|
|
94
|
+
function O(e) {
|
|
95
|
+
const t = e.value;
|
|
96
|
+
m.value ? (c(e) ? r.required || (h("unselect", e), d.value = null) : (h("select", e), d.value = t), setTimeout(J, 100)) : c(e) ? (h("unselect", e), d.value = d.value.filter(
|
|
97
|
+
(l) => !r.compareWith(l, t)
|
|
98
|
+
)) : (h("select", e), d.value = (d.value || []).concat(
|
|
99
|
+
e.value
|
|
100
|
+
));
|
|
29
101
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
102
|
+
function W() {
|
|
103
|
+
h("clear", d.value), d.value = r.required && !m.value ? [] : null;
|
|
32
104
|
}
|
|
33
|
-
|
|
34
|
-
|
|
105
|
+
const de = (e) => A.value === e, ce = (e) => j.value.includes(e);
|
|
106
|
+
function ve(e) {
|
|
107
|
+
return "options" in e;
|
|
35
108
|
}
|
|
36
|
-
return (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
109
|
+
return E({
|
|
110
|
+
present: z,
|
|
111
|
+
clear: W,
|
|
112
|
+
keyword: L
|
|
113
|
+
}), Z(() => {
|
|
114
|
+
q && (q.required.value = r.required, q.disabled.value = r.disabled);
|
|
115
|
+
}), Z(() => {
|
|
116
|
+
w && (w.clickable.value = !r.disabled);
|
|
117
|
+
}), w == null || w.onTap(z), (e, t) => (o(), p(S, null, [
|
|
118
|
+
y(e.$slots, "default", {
|
|
119
|
+
present: z,
|
|
120
|
+
label: P.value,
|
|
121
|
+
selectedOptions: V.value
|
|
122
|
+
}, () => [
|
|
123
|
+
N("view", {
|
|
124
|
+
class: F(["sun-selector", {
|
|
125
|
+
"sun-selector-required": s.required,
|
|
126
|
+
"sun-selector-disabled": s.disabled
|
|
127
|
+
}]),
|
|
128
|
+
onTap: t[1] || (t[1] = (l) => z())
|
|
129
|
+
}, [
|
|
130
|
+
V.value.length ? (o(), p("view", He, [
|
|
131
|
+
m.value ? (o(), p(S, { key: 0 }, [
|
|
132
|
+
b(g(P.value), 1)
|
|
133
|
+
], 64)) : (o(), p("view", Je, [
|
|
134
|
+
(o(!0), p(S, null, D(V.value, (l) => (o(), v(a(qe), {
|
|
135
|
+
color: "medium",
|
|
136
|
+
type: "translucent"
|
|
137
|
+
}, {
|
|
138
|
+
default: u(() => [
|
|
139
|
+
b(g(l.label), 1)
|
|
140
|
+
]),
|
|
141
|
+
_: 2
|
|
142
|
+
}, 1024))), 256))
|
|
143
|
+
]))
|
|
144
|
+
])) : (o(), p("view", Ke, g(s.placeholder), 1)),
|
|
145
|
+
H.value ? (o(), v(a(M), {
|
|
146
|
+
key: 2,
|
|
147
|
+
class: "sun-selector-clear-icon",
|
|
148
|
+
name: "close-circle",
|
|
149
|
+
onTap: t[0] || (t[0] = ne((l) => W(), ["stop"]))
|
|
150
|
+
})) : k("", !0),
|
|
151
|
+
x(a(M), {
|
|
152
|
+
class: "sun-selector-icon",
|
|
153
|
+
name: "chevron-expand-outline"
|
|
154
|
+
})
|
|
155
|
+
], 34)
|
|
156
|
+
]),
|
|
157
|
+
x(a(We), { hook: "created" }, {
|
|
158
|
+
default: u(() => [
|
|
159
|
+
x(a(Re), {
|
|
160
|
+
show: $.value,
|
|
161
|
+
"onUpdate:show": t[7] || (t[7] = (l) => $.value = l),
|
|
162
|
+
title: s.placeholder,
|
|
163
|
+
"with-actions": !m.value,
|
|
164
|
+
onTap: t[8] || (t[8] = ne(() => {
|
|
165
|
+
}, ["stop"]))
|
|
166
|
+
}, Pe({
|
|
167
|
+
actions: u(() => [
|
|
168
|
+
y(e.$slots, "actions", { confirm: K }, () => [
|
|
169
|
+
m.value ? k("", !0) : (o(), v(a(le), {
|
|
170
|
+
key: 0,
|
|
171
|
+
expand: "block",
|
|
172
|
+
onTap: t[6] || (t[6] = (l) => K())
|
|
173
|
+
}, {
|
|
174
|
+
default: u(() => [...t[10] || (t[10] = [
|
|
175
|
+
b("确定", -1)
|
|
176
|
+
])]),
|
|
177
|
+
_: 1
|
|
178
|
+
}))
|
|
179
|
+
])
|
|
180
|
+
]),
|
|
181
|
+
default: u(() => [
|
|
182
|
+
y(e.$slots, "filter", {}, () => [
|
|
183
|
+
s.searchable ? (o(), v(a(De), {
|
|
184
|
+
key: 0,
|
|
185
|
+
modelValue: L.value,
|
|
186
|
+
"onUpdate:modelValue": t[3] || (t[3] = (l) => L.value = l),
|
|
187
|
+
placeholder: "输入关键字搜索"
|
|
188
|
+
}, null, 8, ["modelValue"])) : k("", !0)
|
|
189
|
+
]),
|
|
190
|
+
x(a(ae), null, {
|
|
191
|
+
default: u(() => [
|
|
192
|
+
s.virtual ? (o(), v(a(Fe), {
|
|
193
|
+
key: 0,
|
|
194
|
+
class: "sun-selector-options",
|
|
195
|
+
options: {
|
|
196
|
+
estimateSize: (l) => {
|
|
197
|
+
const n = i.value[l];
|
|
198
|
+
return n.kind === "optionGroup" ? 28 : se.value(n.value);
|
|
199
|
+
},
|
|
200
|
+
overscan: 3,
|
|
201
|
+
count: i.value.length,
|
|
202
|
+
rangeExtractor: (l) => {
|
|
203
|
+
const n = new Set(a(je)(l)), T = re.value.find((R) => l.startIndex >= R);
|
|
204
|
+
return T !== void 0 && (n.add(T), A.value = T), [...n].sort((R, fe) => R - fe);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
refresher: s.refresher,
|
|
208
|
+
refreshing: s.refreshing,
|
|
209
|
+
style: C({ height: s.height }),
|
|
210
|
+
onRefresh: t[4] || (t[4] = (l) => h("refresh"))
|
|
211
|
+
}, {
|
|
212
|
+
default: u(({ virtualItems: l }) => [
|
|
213
|
+
(o(!0), p(S, null, D(l, (n) => (o(), p(S, {
|
|
214
|
+
key: n.index
|
|
215
|
+
}, [
|
|
216
|
+
i.value[n.index].kind === "optionGroup" ? (o(), v(a(_), {
|
|
217
|
+
key: 0,
|
|
218
|
+
class: "sun-selector-option-divider",
|
|
219
|
+
style: C({
|
|
220
|
+
zIndex: ce(n.index) ? 1 : 0,
|
|
221
|
+
...n.style,
|
|
222
|
+
...de(n.index) ? {
|
|
223
|
+
position: "sticky",
|
|
224
|
+
transform: "unset"
|
|
225
|
+
} : {
|
|
226
|
+
position: "absolute"
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
}, {
|
|
230
|
+
default: u(() => [
|
|
231
|
+
b(g(i.value[n.index].value.label), 1)
|
|
232
|
+
]),
|
|
233
|
+
_: 2
|
|
234
|
+
}, 1032, ["style"])) : k("", !0),
|
|
235
|
+
i.value[n.index].kind === "option" ? (o(), v(a(ee), {
|
|
236
|
+
key: 1,
|
|
237
|
+
class: F(["sun-selector-option", { "sun-selector-option-active": c(i.value[n.index].value) }]),
|
|
238
|
+
clickable: !0,
|
|
239
|
+
style: C(n.style),
|
|
240
|
+
onTap: (T) => O(i.value[n.index].value)
|
|
241
|
+
}, {
|
|
242
|
+
start: u(() => [
|
|
243
|
+
y(e.$slots, "option-start", {
|
|
244
|
+
option: i.value[n.index].value,
|
|
245
|
+
index: n.index,
|
|
246
|
+
active: c(i.value[n.index].value)
|
|
247
|
+
})
|
|
248
|
+
]),
|
|
249
|
+
end: u(() => [
|
|
250
|
+
y(e.$slots, "option-end", {
|
|
251
|
+
option: i.value[n.index].value,
|
|
252
|
+
index: n.index,
|
|
253
|
+
active: c(i.value[n.index].value)
|
|
254
|
+
}),
|
|
255
|
+
c(i.value[n.index].value) ? (o(), v(a(M), {
|
|
256
|
+
key: 0,
|
|
257
|
+
class: "sun-selector-option-icon",
|
|
258
|
+
name: "checkmark"
|
|
259
|
+
})) : k("", !0)
|
|
260
|
+
]),
|
|
261
|
+
default: u(() => [
|
|
262
|
+
y(e.$slots, "option", {
|
|
263
|
+
option: i.value[n.index].value,
|
|
264
|
+
index: n.index,
|
|
265
|
+
active: c(i.value[n.index].value)
|
|
266
|
+
}, () => [
|
|
267
|
+
N("view", Oe, g(i.value[n.index].value.label), 1)
|
|
268
|
+
])
|
|
269
|
+
]),
|
|
270
|
+
_: 2
|
|
271
|
+
}, 1032, ["class", "style", "onTap"])) : k("", !0)
|
|
272
|
+
], 64))), 128))
|
|
273
|
+
]),
|
|
274
|
+
placeholder: u(() => [
|
|
275
|
+
x(a(Ue), { loading: s.loading }, null, 8, ["loading"])
|
|
276
|
+
]),
|
|
277
|
+
_: 3
|
|
278
|
+
}, 8, ["options", "refresher", "refreshing", "style"])) : (o(), v(a(Ge), {
|
|
279
|
+
key: 1,
|
|
280
|
+
class: "sun-selector-options",
|
|
281
|
+
refresher: s.refresher,
|
|
282
|
+
refreshing: s.refreshing,
|
|
283
|
+
data: G.value,
|
|
284
|
+
loading: s.loading,
|
|
285
|
+
style: C({ height: s.height }),
|
|
286
|
+
onRefresh: t[5] || (t[5] = (l) => h("refresh"))
|
|
287
|
+
}, {
|
|
288
|
+
default: u(() => [
|
|
289
|
+
N("view", null, [
|
|
290
|
+
(o(!0), p(S, null, D(i.value, (l, n) => (o(), p(S, { key: n }, [
|
|
291
|
+
l.kind === "optionGroup" ? (o(), v(a(_), {
|
|
292
|
+
key: 0,
|
|
293
|
+
class: "sun-selector-option-divider"
|
|
294
|
+
}, {
|
|
295
|
+
default: u(() => [
|
|
296
|
+
b(g(l.value.label), 1)
|
|
297
|
+
]),
|
|
298
|
+
_: 2
|
|
299
|
+
}, 1024)) : k("", !0),
|
|
300
|
+
l.kind === "option" ? (o(), v(a(ee), {
|
|
301
|
+
key: 1,
|
|
302
|
+
class: F(["sun-selector-option", { "sun-selector-option-active": c(l.value) }]),
|
|
303
|
+
clickable: !0,
|
|
304
|
+
onTap: (T) => O(l.value)
|
|
305
|
+
}, {
|
|
306
|
+
start: u(() => [
|
|
307
|
+
y(e.$slots, "option-start", {
|
|
308
|
+
option: l.value,
|
|
309
|
+
index: n,
|
|
310
|
+
active: c(l.value)
|
|
311
|
+
})
|
|
312
|
+
]),
|
|
313
|
+
end: u(() => [
|
|
314
|
+
y(e.$slots, "option-end", {
|
|
315
|
+
option: l.value,
|
|
316
|
+
index: n,
|
|
317
|
+
active: c(l.value)
|
|
318
|
+
}),
|
|
319
|
+
c(l.value) ? (o(), v(a(M), {
|
|
320
|
+
key: 0,
|
|
321
|
+
class: "sun-selector-option-icon",
|
|
322
|
+
name: "checkmark"
|
|
323
|
+
})) : k("", !0)
|
|
324
|
+
]),
|
|
325
|
+
default: u(() => [
|
|
326
|
+
y(e.$slots, "option", {
|
|
327
|
+
option: l.value,
|
|
328
|
+
index: n,
|
|
329
|
+
active: c(l.value)
|
|
330
|
+
}, () => [
|
|
331
|
+
N("view", Qe, g(l.value.label), 1)
|
|
332
|
+
])
|
|
333
|
+
]),
|
|
334
|
+
_: 2
|
|
335
|
+
}, 1032, ["class", "onTap"])) : k("", !0)
|
|
336
|
+
], 64))), 128))
|
|
337
|
+
])
|
|
338
|
+
]),
|
|
339
|
+
_: 3
|
|
340
|
+
}, 8, ["refresher", "refreshing", "data", "loading", "style"]))
|
|
341
|
+
]),
|
|
342
|
+
_: 3
|
|
343
|
+
}),
|
|
344
|
+
y(e.$slots, "list", { ListTemplate: a(U) }, () => [
|
|
345
|
+
x(a(U))
|
|
346
|
+
])
|
|
347
|
+
]),
|
|
348
|
+
_: 2
|
|
349
|
+
}, [
|
|
350
|
+
H.value ? {
|
|
351
|
+
name: "extra",
|
|
352
|
+
fn: u(() => [
|
|
353
|
+
x(a(le), {
|
|
354
|
+
size: "xsmall",
|
|
355
|
+
fill: "clear",
|
|
356
|
+
color: "medium",
|
|
357
|
+
shape: "round",
|
|
358
|
+
onTap: t[2] || (t[2] = (l) => W())
|
|
359
|
+
}, {
|
|
360
|
+
default: u(() => [
|
|
361
|
+
t[9] || (t[9] = b(" 清除 ", -1)),
|
|
362
|
+
m.value ? k("", !0) : (o(), p(S, { key: 0 }, [
|
|
363
|
+
b("(" + g(V.value.length) + ")", 1)
|
|
364
|
+
], 64))
|
|
365
|
+
]),
|
|
366
|
+
_: 1
|
|
367
|
+
})
|
|
368
|
+
]),
|
|
369
|
+
key: "0"
|
|
370
|
+
} : void 0
|
|
371
|
+
]), 1032, ["show", "title", "with-actions"])
|
|
372
|
+
]),
|
|
373
|
+
_: 3
|
|
374
|
+
})
|
|
375
|
+
], 64));
|
|
60
376
|
}
|
|
61
377
|
});
|
|
62
378
|
export {
|
|
63
|
-
|
|
379
|
+
el as default
|
|
64
380
|
};
|