zhihao-ui 1.3.57 → 1.3.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zhihao-ui",
3
- "version": "1.3.57",
3
+ "version": "1.3.58",
4
4
  "description": "components",
5
5
  "type": "module",
6
6
  "main": "./dist/umd/index.umd.cjs",
@@ -1,287 +0,0 @@
1
- import { defineComponent as ae, useModel as oe, ref as s, watch as R, nextTick as g, withDirectives as se, openBlock as h, createElementBlock as k, createVNode as A, unref as S, withCtx as B, createBlock as W, toDisplayString as ne, createCommentVNode as re, mergeProps as ce, Fragment as ie, renderList as ue, mergeModels as $ } from "vue";
2
- import { e as H, f as pe, g as de, h as ve, i as fe, C as me } from "./vendor-DkGhDRdQ.js";
3
- import { w as ge } from "./utils-B-n1yx0L.js";
4
- const he = { class: "w-100" }, ye = {
5
- key: 1,
6
- class: "cascader-select-empty"
7
- }, Ce = {
8
- key: 2,
9
- class: "loading"
10
- }, Se = /* @__PURE__ */ ae({
11
- name: "CascaderLoadMore",
12
- __name: "CascaderLoadMore",
13
- props: /* @__PURE__ */ $({
14
- onChange: {
15
- type: Function,
16
- required: !1
17
- },
18
- // 默认选中项
19
- initialValue: {
20
- type: [String, Number, Array],
21
- required: !1
22
- },
23
- pageSize: {
24
- type: Number,
25
- default: 10
26
- },
27
- // 数据请求函数
28
- requestFunction: {
29
- type: Function,
30
- required: !0
31
- },
32
- // 选项处理函数
33
- handleOptionsFunction: {
34
- type: Function,
35
- required: !0
36
- },
37
- placeholder: {
38
- type: String,
39
- default: "输入关键字搜索名称"
40
- },
41
- // 强制搜索:不输入内容也进行搜索,即点击下拉默认展示数据
42
- forceSearch: {
43
- type: Boolean,
44
- default: !0
45
- },
46
- // 初始下拉项用于回显数据
47
- initialOptions: {
48
- type: Array,
49
- required: !1,
50
- default: () => []
51
- },
52
- // 多选,默认false
53
- multiple: {
54
- type: Boolean,
55
- default: !1
56
- },
57
- collapseTags: {
58
- type: Boolean,
59
- default: !1
60
- },
61
- collapseTagsTooltip: {
62
- type: Boolean,
63
- default: !1
64
- },
65
- clearable: {
66
- type: Boolean,
67
- default: !0
68
- },
69
- cascaderProps: {
70
- type: Object,
71
- default: () => ({})
72
- },
73
- placement: {
74
- type: String,
75
- default: "bottom-start"
76
- },
77
- trigger: {
78
- type: String,
79
- default: "click"
80
- },
81
- popperClass: {
82
- type: String
83
- },
84
- teleported: {
85
- type: Boolean,
86
- default: !1
87
- },
88
- noDataText: {
89
- type: String,
90
- default: "暂无数据"
91
- }
92
- }, {
93
- modelValue: {},
94
- modelModifiers: {}
95
- }),
96
- emits: /* @__PURE__ */ $(["change", "removeTag"], ["update:modelValue"]),
97
- setup(p, { expose: I, emit: N }) {
98
- const o = p, c = oe(p, "modelValue"), f = s(c.value || []), m = s(!1), d = s({
99
- page: 1,
100
- size: o.pageSize
101
- }), b = s(void 0), T = s(!1), E = s(!0), v = s(o.initialOptions || []), n = s(o.initialOptions || []), y = s(void 0), O = s(!1), U = {
102
- expandTrigger: "hover",
103
- checkStrictly: !1,
104
- multiple: o.multiple,
105
- emitPath: !0,
106
- ...o.cascaderProps
107
- }, D = s(), q = s(), j = () => {
108
- m.value = !0;
109
- }, Z = () => {
110
- m.value = !1;
111
- }, Q = (e) => {
112
- const l = /* @__PURE__ */ new Map();
113
- return (e || []).forEach((t) => {
114
- const a = `${t.value}`;
115
- l.has(a) || l.set(a, t);
116
- }), Array.from(l.values());
117
- };
118
- function V(e) {
119
- const l = [];
120
- function t(a, i = "") {
121
- const r = i && (o.cascaderProps.emitPath ?? !0) ? `${i}/${a.label}` : a.label;
122
- l.push({
123
- ...a,
124
- value: a.value,
125
- label: r
126
- // 如果需要保留原始路径结构,可加上 fullPath 字段
127
- // fullPath: currentPath
128
- }), a.children && a.children.length > 0 && a.children.forEach((u) => t(u, r));
129
- }
130
- return e.forEach((a) => t(a)), l;
131
- }
132
- const x = async (e) => {
133
- var i;
134
- if (!o.forceSearch && !e) return;
135
- const l = y.value === e || !y.value && !e;
136
- if (l || (d.value.page = 1), l && b.value !== void 0 && d.value.page > b.value && !O.value) return;
137
- O.value = !1, T.value = !0, n.value.length === 0 && (E.value = !0);
138
- const a = await o.requestFunction(d.value.page, d.value.size, e);
139
- if (a && Object.keys(a).length) {
140
- b.value = a.totalPage;
141
- const r = (i = a == null ? void 0 : a.list) == null ? void 0 : i.map(o.handleOptionsFunction);
142
- l && d.value.page !== 1 ? n.value = Q([...n.value, ...r]) : n.value = r || [], f.value = H(c.value), v.value = V(n.value);
143
- }
144
- g(() => {
145
- z();
146
- }), y.value = e, T.value = !1, n.value.length !== 0 && (E.value = !1);
147
- }, G = () => {
148
- d.value.page = d.value.page + 1, x(y.value);
149
- }, J = (e) => {
150
- c.value = e, f.value = e;
151
- const l = M(e), t = o.onChange;
152
- t && t(e, l);
153
- }, M = (e) => {
154
- const l = e || c.value;
155
- return o.multiple ? v.value.filter(
156
- (t) => (l || []).includes(t.value)
157
- ) : v.value.find((t) => t.value === l);
158
- }, K = () => {
159
- c.value = o.initialValue, f.value = o.initialValue, d.value.page = 1, d.value.size = o.pageSize, v.value = o.initialOptions || [], n.value = o.initialOptions || [], b.value = void 0, y.value = void 0;
160
- }, w = N;
161
- R(
162
- () => o.initialOptions,
163
- () => {
164
- v.value = V(o.initialOptions), console.log("options.value", v.value), n.value = o.initialOptions;
165
- },
166
- { immediate: !0 }
167
- );
168
- const X = (e) => {
169
- w("removeTag", e);
170
- }, Y = (e) => {
171
- O.value = e;
172
- }, P = s(null), C = s(null), L = () => {
173
- if (!m.value) return;
174
- const e = q.value.popperRef.contentRef, l = e == null ? void 0 : e.querySelector(".el-cascader-panel .el-scrollbar__wrap");
175
- l && (P.value = l, C.value = () => _(l), l.addEventListener("scroll", C.value));
176
- }, F = () => {
177
- P.value && C.value && (P.value.removeEventListener("scroll", C.value), P.value = null, C.value = null);
178
- }, _ = (e) => {
179
- const { scrollTop: l, scrollHeight: t, clientHeight: a } = e;
180
- let i = t - l;
181
- a + 10 > i && G();
182
- };
183
- g(() => L()), R(m, (e) => {
184
- e ? (console.log("visible", e), g(() => L())) : F();
185
- }), R(n, (e) => {
186
- e != null && e.length && m.value ? g(() => L()) : F();
187
- });
188
- const ee = async (e) => {
189
- (o.cascaderProps.emitPath ?? !0) && Array.isArray(e) ? o.multiple ? c.value = e.map((a) => a.at(-1)) : c.value = e.at(-1) : c.value = H(f.value), await g();
190
- const l = M(c.value);
191
- w("change", e, l);
192
- const t = o.onChange;
193
- t && t(e, l);
194
- }, z = () => {
195
- var i;
196
- const e = q.value.popperRef.contentRef, l = e.querySelectorAll(".el-cascader-node__label"), t = (i = D.value) == null ? void 0 : i.$el, a = e == null ? void 0 : e.querySelector(".cascader-select-empty");
197
- if (t && a) {
198
- const r = t.offsetWidth;
199
- a.style.width = `${r}px`;
200
- }
201
- l.forEach((r) => {
202
- const u = document.createElement("span");
203
- u.style.visibility = "hidden", u.style.position = "absolute", u.style.whiteSpace = "nowrap", u.style.font = window.getComputedStyle(r).font, u.textContent = r.textContent || "", document.body.appendChild(u);
204
- const te = u.offsetWidth;
205
- document.body.removeChild(u), r instanceof HTMLElement && (r.style.whiteSpace = te > 240 ? "break-spaces" : "nowrap");
206
- });
207
- }, le = () => {
208
- g(() => {
209
- z();
210
- });
211
- };
212
- return I({
213
- reset: K,
214
- getSelectedOption: M,
215
- remoteMethod: x,
216
- handleRequestParamsChanged: Y,
217
- options: v,
218
- cascderOptions: n
219
- }), (e, l) => se((h(), k("div", he, [
220
- A(S(pe), {
221
- ref_key: "popoverRef",
222
- ref: q,
223
- teleported: p.teleported,
224
- placement: o.placement,
225
- trigger: o.trigger,
226
- "popper-class": "warp-cascade-panel " + o.popperClass,
227
- visible: m.value
228
- }, {
229
- reference: B(() => [
230
- A(S(ve), ce({
231
- ref_key: "remoteSelectRef",
232
- ref: D,
233
- modelValue: c.value,
234
- "onUpdate:modelValue": l[0] || (l[0] = (t) => c.value = t),
235
- multiple: p.multiple,
236
- placeholder: p.placeholder,
237
- "remote-method": x,
238
- teleported: !0,
239
- clearable: p.clearable,
240
- "collapse-tags": p.collapseTags,
241
- "collapse-tags-tooltip": p.collapseTagsTooltip,
242
- filterable: "",
243
- height: "300",
244
- remote: "",
245
- "remote-show-suffix": "",
246
- "reserve-keyword": "",
247
- "popper-class": "hidden-dropdown",
248
- class: "cascader-select"
249
- }, e.$attrs, {
250
- onClick: j,
251
- onChange: J,
252
- onRemoveTag: X
253
- }), {
254
- default: B(() => [
255
- (h(!0), k(ie, null, ue(v.value, (t) => (h(), W(S(fe), {
256
- key: t.value,
257
- label: t.label,
258
- value: t.value
259
- }, null, 8, ["label", "value"]))), 128))
260
- ]),
261
- _: 1
262
- }, 16, ["modelValue", "multiple", "placeholder", "clearable", "collapse-tags", "collapse-tags-tooltip"])
263
- ]),
264
- default: B(() => [
265
- !E.value && n.value.length > 0 ? (h(), W(S(de), {
266
- key: 0,
267
- modelValue: f.value,
268
- "onUpdate:modelValue": l[1] || (l[1] = (t) => f.value = t),
269
- border: !1,
270
- props: U,
271
- options: n.value,
272
- class: "select-cascader-panel",
273
- onChange: ee,
274
- onExpandChange: le
275
- }, null, 8, ["modelValue", "options"])) : (h(), k("div", ye, ne(p.noDataText), 1)),
276
- T.value ? (h(), k("div", Ce, "加载中...")) : re("", !0)
277
- ]),
278
- _: 1
279
- }, 8, ["teleported", "placement", "trigger", "popper-class", "visible"])
280
- ])), [
281
- [S(me), Z]
282
- ]);
283
- }
284
- }), Te = ge(Se);
285
- export {
286
- Te as Z
287
- };