@solar-taro/ui-vant 3.5.3 → 4.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.
package/index22.js CHANGED
@@ -1,38 +1,9 @@
1
- import { makeDestructurable as d, camelize as f } from "./index23.js";
2
- import { shallowRef as p, defineComponent as i } from "vue";
3
- // @__NO_SIDE_EFFECTS__
4
- function h(r = {}) {
5
- const { inheritAttrs: t = !0 } = r, e = p(), u = i({ setup(a, { slots: o }) {
6
- return () => {
7
- e.value = o.default;
8
- };
9
- } }), s = i({
10
- inheritAttrs: t,
11
- props: r.props,
12
- setup(a, { attrs: o, slots: c }) {
13
- return () => {
14
- var l;
15
- if (!e.value) throw new Error("[VueUse] Failed to find the definition of reusable template");
16
- const n = (l = e.value) === null || l === void 0 ? void 0 : l.call(e, {
17
- ...r.props == null ? m(o) : a,
18
- $slots: c
19
- });
20
- return t && (n == null ? void 0 : n.length) === 1 ? n[0] : n;
21
- };
22
- }
23
- });
24
- return d({
25
- define: u,
26
- reuse: s
27
- }, [u, s]);
28
- }
29
- function m(r) {
30
- const t = {};
31
- for (const e in r) t[f(e)] = r[e];
32
- return t;
33
- }
1
+ const s = (t) => {
2
+ const o = Math.max(t.startIndex - t.overscan, 0), e = Math.min(t.endIndex + t.overscan, t.count - 1) - o + 1, r = new Array(e);
3
+ for (let n = 0; n < e; n++)
4
+ r[n] = o + n;
5
+ return r;
6
+ };
34
7
  export {
35
- f as camelize,
36
- h as createReusableTemplate,
37
- d as makeDestructurable
8
+ s as defaultRangeExtractor
38
9
  };
package/index23.js CHANGED
@@ -1,27 +1,42 @@
1
- import "vue";
2
- typeof WorkerGlobalScope != "undefined" && globalThis instanceof WorkerGlobalScope;
3
- function r(t) {
4
- const n = /* @__PURE__ */ Object.create(null);
5
- return (e) => n[e] || (n[e] = t(e));
6
- }
7
- const c = /-(\w)/g, a = r((t) => t.replace(c, (n, e) => e ? e.toUpperCase() : ""));
1
+ import { makeDestructurable as m, camelize as c } from "./index24.js";
2
+ import { shallowRef as p, defineComponent as d } from "vue";
8
3
  // @__NO_SIDE_EFFECTS__
9
- function u(t, n) {
10
- if (typeof Symbol != "undefined") {
11
- const e = { ...t };
12
- return Object.defineProperty(e, Symbol.iterator, {
13
- enumerable: !1,
14
- value() {
15
- let o = 0;
16
- return { next: () => ({
17
- value: n[o++],
18
- done: o > n.length
19
- }) };
20
- }
21
- }), e;
22
- } else return Object.assign([...n], t);
4
+ function w(e = {}) {
5
+ const { inheritAttrs: r = !0, name: t = "ReusableTemplate" } = e, o = p(), a = d({
6
+ name: `${t}.define`,
7
+ setup(i, { slots: l }) {
8
+ return () => {
9
+ o.value = l.default;
10
+ };
11
+ }
12
+ }), s = d({
13
+ inheritAttrs: r,
14
+ name: `${t}.reuse`,
15
+ props: e.props,
16
+ setup(i, { attrs: l, slots: f }) {
17
+ return () => {
18
+ var u;
19
+ if (!o.value) throw new Error("[VueUse] Failed to find the definition of reusable template");
20
+ const n = (u = o.value) === null || u === void 0 ? void 0 : u.call(o, {
21
+ ...e.props == null ? v(l) : i,
22
+ $slots: f
23
+ });
24
+ return r && (n == null ? void 0 : n.length) === 1 ? n[0] : n;
25
+ };
26
+ }
27
+ });
28
+ return m({
29
+ define: a,
30
+ reuse: s
31
+ }, [a, s]);
32
+ }
33
+ function v(e) {
34
+ const r = {};
35
+ for (const t in e) r[c(t)] = e[t];
36
+ return r;
23
37
  }
24
38
  export {
25
- a as camelize,
26
- u as makeDestructurable
39
+ c as camelize,
40
+ w as createReusableTemplate,
41
+ m as makeDestructurable
27
42
  };
package/index24.js ADDED
@@ -0,0 +1,27 @@
1
+ import "vue";
2
+ typeof WorkerGlobalScope != "undefined" && globalThis instanceof WorkerGlobalScope;
3
+ function r(t) {
4
+ const n = /* @__PURE__ */ Object.create(null);
5
+ return (e) => n[e] || (n[e] = t(e));
6
+ }
7
+ const c = /-(\w)/g, a = r((t) => t.replace(c, (n, e) => e ? e.toUpperCase() : ""));
8
+ // @__NO_SIDE_EFFECTS__
9
+ function u(t, n) {
10
+ if (typeof Symbol != "undefined") {
11
+ const e = { ...t };
12
+ return Object.defineProperty(e, Symbol.iterator, {
13
+ enumerable: !1,
14
+ value() {
15
+ let o = 0;
16
+ return { next: () => ({
17
+ value: n[o++],
18
+ done: o > n.length
19
+ }) };
20
+ }
21
+ }), e;
22
+ } else return Object.assign([...n], t);
23
+ }
24
+ export {
25
+ a as camelize,
26
+ u as makeDestructurable
27
+ };
package/index3.js CHANGED
@@ -1,139 +1,211 @@
1
- import { defineComponent as W, mergeModels as z, useModel as X, computed as n, ref as E, renderSlot as Y, unref as Z, openBlock as x, createBlock as ee, createCommentVNode as le, createElementVNode as ae, mergeProps as te, resolveDirective as ne, createElementBlock as oe, withDirectives as se, renderList as re, Fragment as ue, toDisplayString as ie, createVNode as de, createTextVNode as ce, normalizeClass as ve, withCtx as me, createSlots as pe, normalizeStyle as fe } from "vue";
2
- import { tree2list as he } from "@solar-kit/core";
3
- import { SunIcon as q, SunLazyRender as ye, SunItem as I } from "@solar-taro/ui-sun";
4
- import { SunModal as be } from "@solar-taro/ui-vant";
5
- import { linkedRef as M, untracked as ke } from "@solar-vue/core";
6
- const L = Y, r = Z, t = x, b = ee, k = le, g = ae, ge = te, we = ne, s = oe, Ke = se, w = re, m = ue, F = ie, K = de, P = ce, Ne = ve, c = me, Ve = pe, R = fe, Se = ["label", "value", "placeholder", "required", "disabled"], Ce = { name: "right-icon" }, Be = ["active"], _e = ["name", "title"], $e = ["name"], Me = /* @__PURE__ */ W({
1
+ import { defineComponent as ve, inject as Z, useModel as me, ref as U, useId as fe, computed as o, effect as ee, Fragment as pe, mergeModels as te, renderSlot as he, toDisplayString as be, openBlock as ke, createElementBlock as ye, createCommentVNode as we, unref as Te, withModifiers as xe, createBlock as Se, createVNode as Ve, normalizeClass as ge, createElementVNode as Ce, renderList as $e, createTextVNode as Ne, withCtx as Be, createSlots as Le, normalizeStyle as _e } from "vue";
2
+ import { tree2list as ze } from "@solar-kit/core";
3
+ import { SUN_ITEM as Ie, SUN_FIELD as Me, SunIcon as g, SunLazyRender as Ee, SunSearchbar as qe, SunItem as D, SunListPlaceholder as Ue } from "@solar-taro/ui-sun";
4
+ import { SunModal as De } from "@solar-taro/ui-vant";
5
+ import { linkedRef as le, untracked as Fe } from "@solar-vue/core";
6
+ import { nextTick as je, getCurrentInstance as Pe } from "@tarojs/taro";
7
+ const Re = he, k = be, a = ke, r = ye, y = we, n = Te, ae = xe, f = Se, w = Ve, F = ge, C = Ce, $ = $e, p = pe, j = Ne, d = Be, P = Le, R = _e, Ae = {
8
+ key: 0,
9
+ class: "sun-cascader-inner"
10
+ }, Ge = {
11
+ key: 1,
12
+ class: "sun-cascader-placeholder"
13
+ }, He = ["id", "active"], Je = ["name", "title"], Ke = ["name"], et = /* @__PURE__ */ ve({
7
14
  __name: "index",
8
- props: /* @__PURE__ */ z({
9
- label: {},
15
+ props: /* @__PURE__ */ te({
10
16
  placeholder: { default: "请选择" },
11
17
  options: {},
12
- labelKey: { default: "fullName" },
13
- valueKey: { default: "id" },
14
18
  required: { type: Boolean },
15
19
  disabled: { type: Boolean },
16
20
  clearable: { type: Boolean, default: !0 },
17
21
  delimiter: { default: "/" },
18
- height: { default: "50vh" }
22
+ height: { default: "50vh" },
23
+ searchable: { type: Boolean, default: !0 }
19
24
  }, {
20
25
  modelValue: {},
21
26
  modelModifiers: {}
22
27
  }),
23
- emits: /* @__PURE__ */ z(["select", "clear", "close"], ["update:modelValue"]),
24
- setup(N, { emit: j }) {
25
- const p = j, o = N, u = X(N, "modelValue"), U = n(() => u.value && o.clearable), i = E(!1), V = E(0), A = n(() => he(o.options)), f = n(() => A.value.find((e) => e.parent && !e.children && e[o.valueKey] === u.value)), G = n(() => {
28
+ emits: /* @__PURE__ */ te(["select", "clear", "close"], ["update:modelValue"]),
29
+ setup(i, { expose: ne, emit: se }) {
30
+ const h = Z(Ie, void 0), N = Z(Me, void 0), B = se, s = i, v = me(i, "modelValue"), b = U(""), A = fe(), G = o(() => v.value && s.clearable && !s.disabled), T = U(!1), H = U(0), oe = o(() => ze(s.options)), J = o(() => s.options.flatMap((e) => ie(e))), K = o(() => {
31
+ if (!b.value) return J.value;
32
+ const e = b.value.toLowerCase();
33
+ return J.value.filter((t) => t.label.toLowerCase().includes(e));
34
+ }), L = o(() => oe.value.find((e) => e.parent && !e.children && e.value === v.value)), re = o(() => {
26
35
  const e = [];
27
- let l = f.value;
28
- for (; l; )
29
- e.unshift(l), l = l.parent;
36
+ let t = L.value;
37
+ for (; t; )
38
+ e.unshift(t), t = t.parent;
30
39
  return e;
31
- }), v = M(() => f.value), h = n(() => {
40
+ }), x = le(() => L.value), _ = o(() => {
32
41
  const e = [];
33
- let l = v.value;
34
- for (; l; )
35
- e.unshift(l), l = l.parent;
42
+ let t = x.value;
43
+ for (; t; )
44
+ e.unshift(t), t = t.parent;
36
45
  return e;
37
- }), S = n(() => {
38
- const e = v.value;
46
+ }), O = o(() => {
47
+ const e = x.value;
39
48
  return e ? !e.children : !1;
40
- }), C = n(() => G.value.map((e) => e[o.labelKey]).join(` ${o.delimiter} `)), y = M(
49
+ }), z = o(() => re.value.map((e) => e.label).join(` ${s.delimiter} `)), I = le(
41
50
  () => (
42
51
  // 如果有值,则取 currentNodes 的最后索引,否则为 0
43
- f.value ? ke(() => h.value.length - 1) : 0
52
+ L.value ? Fe(() => _.value.length - 1) : 0
44
53
  )
45
- ), B = n(() => o.options.filter((e) => !e.parent)), H = n(() => {
46
- const e = v.value;
47
- return e ? e.children : B.value;
48
- });
49
- function _() {
50
- o.disabled || (i.value = !0, V.value++);
54
+ ), Q = o(() => s.options.filter((e) => !e.parent)), ue = o(() => {
55
+ const e = x.value;
56
+ return e ? e.children : Q.value;
57
+ }), W = o(() => ({ height: `calc(${s.height} - 44px)` }));
58
+ function S() {
59
+ s.disabled || (T.value = !0, H.value++, setTimeout(() => {
60
+ Y();
61
+ }, 300));
51
62
  }
52
- function J() {
53
- i.value = !1, p("close");
63
+ function X() {
64
+ T.value = !1, B("close");
54
65
  }
55
- function O() {
56
- p("clear", u.value), u.value = null;
66
+ function M() {
67
+ B("clear", v.value), v.value = null;
57
68
  }
58
- function $(e) {
59
- v.value = e, p("select", e), S.value ? (u.value = e[o.valueKey], i.value = !1) : y.value++;
69
+ function E(e) {
70
+ x.value = e, B("select", e), O.value ? (v.value = e.value, setTimeout(X, 100)) : I.value++, je(Y);
60
71
  }
61
- return (e, l) => {
62
- const Q = we("readonly");
63
- return t(), s(m, null, [
64
- L(e.$slots, "default", {
65
- present: _,
66
- label: C.value
67
- }, () => [
68
- Ke((t(), s("van-field", ge(e.$attrs, {
69
- class: "sun-cascader",
70
- label: e.label,
71
- value: C.value,
72
- placeholder: e.placeholder,
73
- required: e.required,
74
- disabled: e.disabled,
75
- onClickInput: l[1] || (l[1] = (a) => _())
76
- }), [
77
- g("slot-view", Ce, [
78
- U.value ? (t(), b(r(q), {
72
+ function ie(e, t = "") {
73
+ const l = [];
74
+ function u(c, m) {
75
+ var q;
76
+ const V = m + c.label;
77
+ if ((q = c.children) != null && q.length) {
78
+ const ce = `${V} ${s.delimiter} `;
79
+ for (const de of c.children)
80
+ u(de, ce);
81
+ return;
82
+ }
83
+ l.push({ ...c, label: V });
84
+ }
85
+ return u(e, t), l;
86
+ }
87
+ function Y() {
88
+ var t, l, u;
89
+ const { page: e } = Pe();
90
+ (u = (l = (t = e == null ? void 0 : e.selectComponent) == null ? void 0 : t.call(e, `#${A}`)) == null ? void 0 : l.resize) == null || u.call(l);
91
+ }
92
+ return ne({
93
+ present: S,
94
+ clear: M
95
+ }), ee(() => {
96
+ N && (N.required.value = s.required, N.disabled.value = s.disabled);
97
+ }), ee(() => {
98
+ h && (h.clickable.value = !s.disabled);
99
+ }), h == null || h.onTap(S), (e, t) => (a(), r(p, null, [
100
+ Re(e.$slots, "default", {
101
+ present: S,
102
+ label: z.value
103
+ }, () => [
104
+ C("view", {
105
+ class: F(["sun-cascader", {
106
+ "sun-cascader-required": i.required,
107
+ "sun-cascader-disabled": i.disabled
108
+ }]),
109
+ onTap: t[1] || (t[1] = (l) => S())
110
+ }, [
111
+ z.value ? (a(), r("view", Ae, k(z.value), 1)) : (a(), r("view", Ge, k(i.placeholder), 1)),
112
+ G.value ? (a(), f(n(g), {
113
+ key: 2,
114
+ class: "sun-cascader-clear-icon",
115
+ name: "close-circle",
116
+ onTap: t[0] || (t[0] = ae((l) => M(), ["stop"]))
117
+ })) : y("", !0),
118
+ w(n(g), {
119
+ class: "sun-cascader-icon",
120
+ name: "chevron-expand-outline"
121
+ })
122
+ ], 34)
123
+ ]),
124
+ w(n(Ee), { hook: "created" }, {
125
+ default: d(() => [
126
+ w(n(De), {
127
+ show: T.value,
128
+ "onUpdate:show": t[5] || (t[5] = (l) => T.value = l),
129
+ class: "sun-cascader-modal",
130
+ title: i.placeholder,
131
+ "show-buttons": !1,
132
+ onClose: t[6] || (t[6] = (l) => X()),
133
+ onTap: t[7] || (t[7] = ae(() => {
134
+ }, ["stop"]))
135
+ }, P({
136
+ default: d(() => [
137
+ i.searchable ? (a(), f(n(qe), {
79
138
  key: 0,
80
- class: "sun-cascader-clear-icon",
81
- name: "close-circle",
82
- onTap: l[0] || (l[0] = (a) => O())
83
- })) : k("", !0),
84
- L(e.$slots, "end")
85
- ])
86
- ], 16, Se)), [
87
- [Q]
88
- ])
89
- ]),
90
- K(r(ye), { hook: "created" }, {
91
- default: c(() => [
92
- K(r(be), {
93
- show: i.value,
94
- "onUpdate:show": l[3] || (l[3] = (a) => i.value = a),
95
- class: "sun-cascader-modal",
96
- title: e.placeholder,
97
- "show-buttons": !1,
98
- onClose: l[4] || (l[4] = (a) => J())
99
- }, {
100
- default: c(() => [
101
- V.value ? (t(), s("van-tabs", {
139
+ modelValue: b.value,
140
+ "onUpdate:modelValue": t[3] || (t[3] = (l) => b.value = l),
141
+ placeholder: "输入关键字搜索"
142
+ }, null, 8, ["modelValue"])) : y("", !0),
143
+ b.value ? (a(), r("view", {
144
+ key: 1,
145
+ class: "sun-cascader-options",
146
+ style: R({ height: i.height })
147
+ }, [
148
+ (a(!0), r(p, null, $(K.value, (l, u) => (a(), f(n(D), {
149
+ key: u,
150
+ class: F(["sun-cascader-option", { "sun-cascader-option-active": l.value === v.value }]),
151
+ clickable: !0,
152
+ onTap: (c) => E(l)
153
+ }, P({
154
+ default: d(() => [
155
+ j(k(l.label) + " ", 1)
156
+ ]),
157
+ _: 2
158
+ }, [
159
+ l.value === v.value ? {
160
+ name: "end",
161
+ fn: d(() => [
162
+ w(n(g), {
163
+ class: "sun-cascader-option-icon",
164
+ name: "checkmark"
165
+ })
166
+ ]),
167
+ key: "0"
168
+ } : void 0
169
+ ]), 1032, ["class", "onTap"]))), 128)),
170
+ K.value.length ? y("", !0) : (a(), f(n(Ue), { key: 0 }))
171
+ ], 4)) : (a(), r(p, { key: 2 }, [
172
+ H.value ? (a(), r("van-tabs", {
102
173
  key: 0,
174
+ id: n(A),
103
175
  class: "sun-cascader-tabs",
104
- active: r(y),
176
+ active: n(I),
105
177
  "line-width": "30px",
106
178
  "line-height": "4px",
107
179
  animated: "true",
108
- onChange: l[2] || (l[2] = (a) => y.value = a.detail.index)
180
+ onChange: t[4] || (t[4] = (l) => I.value = l.detail.index)
109
181
  }, [
110
- (t(!0), s(m, null, w(h.value, (a, T) => {
111
- var D;
112
- return t(), s("van-tab", {
113
- key: a[e.valueKey],
114
- name: T,
182
+ (a(!0), r(p, null, $(_.value, (l, u) => {
183
+ var c;
184
+ return a(), r("van-tab", {
185
+ key: l.value,
186
+ name: u,
115
187
  class: "sun-cascader-tab",
116
- title: a[e.labelKey]
188
+ title: l.label
117
189
  }, [
118
- g("view", {
119
- class: "sun-cascader-list",
120
- style: R({ height: e.height })
190
+ C("view", {
191
+ class: "sun-cascader-options",
192
+ style: R(W.value)
121
193
  }, [
122
- (t(!0), s(m, null, w(((D = a.parent) == null ? void 0 : D.children) || B.value, (d) => (t(), b(r(I), {
123
- key: d[e.valueKey],
124
- class: Ne(["sun-cascader-option", { "sun-cascader-option-active": a[e.valueKey] === d[e.valueKey] }]),
194
+ (a(!0), r(p, null, $(((c = l.parent) == null ? void 0 : c.children) || Q.value, (m, V) => (a(), f(n(D), {
195
+ key: V,
196
+ class: F(["sun-cascader-option", { "sun-cascader-option-active": l.value === m.value }]),
125
197
  clickable: !0,
126
- onTap: (Te) => $(d)
127
- }, Ve({
128
- default: c(() => [
129
- P(F(d[e.labelKey]) + " ", 1)
198
+ onTap: (q) => E(m)
199
+ }, P({
200
+ default: d(() => [
201
+ j(k(m.label) + " ", 1)
130
202
  ]),
131
203
  _: 2
132
204
  }, [
133
- a[e.valueKey] === d[e.valueKey] ? {
205
+ l.value === m.value ? {
134
206
  name: "end",
135
- fn: c(() => [
136
- K(r(q), {
207
+ fn: d(() => [
208
+ w(n(g), {
137
209
  class: "sun-cascader-option-icon",
138
210
  name: "checkmark"
139
211
  })
@@ -142,43 +214,54 @@ const L = Y, r = Z, t = x, b = ee, k = le, g = ae, ge = te, we = ne, s = oe, Ke
142
214
  } : void 0
143
215
  ]), 1032, ["class", "onTap"]))), 128))
144
216
  ], 4)
145
- ], 8, _e);
217
+ ], 8, Je);
146
218
  }), 128)),
147
- S.value ? k("", !0) : (t(), s("van-tab", {
219
+ O.value ? y("", !0) : (a(), r("van-tab", {
148
220
  key: 0,
149
- name: h.value.length,
221
+ name: _.value.length,
150
222
  class: "sun-cascader-tab",
151
223
  title: "请选择",
152
- "title-style": "color:#94a3b8"
224
+ "title-style": "color:var(--color-medium-tint);font-weight:normal;font-size:14px"
153
225
  }, [
154
- g("view", {
226
+ C("view", {
155
227
  class: "sun-cascader-list",
156
- style: R({ height: e.height })
228
+ style: R(W.value)
157
229
  }, [
158
- (t(!0), s(m, null, w(H.value, (a) => (t(), b(r(I), {
159
- key: a[e.valueKey],
230
+ (a(!0), r(p, null, $(ue.value, (l) => (a(), f(n(D), {
231
+ key: l.value,
160
232
  class: "sun-cascader-option",
161
233
  clickable: !0,
162
- onTap: (T) => $(a)
234
+ onTap: (u) => E(l)
163
235
  }, {
164
- default: c(() => [
165
- P(F(a[e.labelKey]), 1)
236
+ default: d(() => [
237
+ j(k(l.label), 1)
166
238
  ]),
167
239
  _: 2
168
240
  }, 1032, ["onTap"]))), 128))
169
241
  ], 4)
170
- ], 8, $e))
171
- ], 40, Be)) : k("", !0)
242
+ ], 8, Ke))
243
+ ], 40, He)) : y("", !0)
244
+ ], 64))
245
+ ]),
246
+ _: 2
247
+ }, [
248
+ G.value ? {
249
+ name: "extra",
250
+ fn: d(() => [
251
+ C("view", {
252
+ class: "sun-cascader-clear-btn",
253
+ onTap: t[2] || (t[2] = (l) => M())
254
+ }, "清除", 32)
172
255
  ]),
173
- _: 1
174
- }, 8, ["show", "title"])
175
- ]),
176
- _: 1
177
- })
178
- ], 64);
179
- };
256
+ key: "0"
257
+ } : void 0
258
+ ]), 1032, ["show", "title"])
259
+ ]),
260
+ _: 1
261
+ })
262
+ ], 64));
180
263
  }
181
264
  });
182
265
  export {
183
- Me as default
266
+ et as default
184
267
  };