uniapp-dyckui 4.1.2 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/assets/{style.BFlsbpSj.css → style.BEkFuBVh.css} +776 -774
  2. package/dist/{index.cjs.js → index.cjs} +841 -839
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/{index.es.js → index.mjs} +841 -839
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/src/components/MyComs/Button/index.vue.d.ts +6 -6
  7. package/dist/src/components/MyComs/Dialog/index.vue.d.ts +6 -6
  8. package/dist/src/components/MyComs/Divider/index.vue.d.ts +5 -5
  9. package/dist/src/components/MyComs/DropdownSelect/dropdownSelect.d.ts +2 -2
  10. package/dist/src/components/MyComs/DropdownSelect/index.vue.d.ts +3 -6
  11. package/dist/src/components/MyComs/DropdownWithBadge/index.vue.d.ts +3 -6
  12. package/dist/src/components/MyComs/FilterDrawer/index.vue.d.ts +3 -6
  13. package/dist/src/components/MyComs/FilterDrawer/useFilterDrawer.d.ts +1 -1
  14. package/dist/src/components/MyComs/InfiniteScroll/index.vue.d.ts +5 -5
  15. package/dist/src/components/MyComs/Popup/index.vue.d.ts +5 -5
  16. package/dist/src/components/MyComs/PullRefresh/index.vue.d.ts +5 -5
  17. package/dist/src/components/MyComs/Swiper/index.vue.d.ts +7 -7
  18. package/dist/src/components/MyComs/Toast/index.vue.d.ts +7 -7
  19. package/dist/src/components/MyComs/index.d.ts +1590 -17
  20. package/package.json +104 -97
  21. package/src/components/MyComs/Dialog/index.ts +3 -2
  22. package/src/components/MyComs/Divider/index.ts +3 -2
  23. package/src/components/MyComs/InfiniteScroll/index.ts +3 -2
  24. package/src/components/MyComs/Popup/index.ts +3 -2
  25. package/src/components/MyComs/Popup/index.vue +837 -835
  26. package/src/components/MyComs/PullRefresh/index.ts +3 -2
  27. package/src/components/MyComs/PullRefresh/index.vue +2 -1
  28. package/src/components/MyComs/Swiper/index.ts +3 -2
  29. package/src/components/MyComs/Swiper/index.vue +246 -245
  30. package/src/components/MyComs/Toast/index.ts +3 -2
  31. package/src/components/MyComs/Toast/index.vue +373 -372
  32. package/src/components/MyComs/index.ts +57 -20
  33. package/dist/index.cjs.js.map +0 -1
  34. package/dist/index.es.js.map +0 -1
@@ -1,19 +1,14 @@
1
- import { defineComponent, createElementBlock, openBlock, normalizeClass, createCommentVNode, Fragment, renderSlot, pushScopeId, popScopeId, createElementVNode, useCssVars, ref, watch, withModifiers, toDisplayString, onMounted, onUnmounted, withDirectives, normalizeStyle, vShow, computed, renderList, nextTick, unref, createTextVNode, resolveComponent, createBlock, normalizeProps, guardReactiveProps, mergeProps, toHandlers, withCtx, isRef } from "vue";
2
- const _withScopeId$4 = (n) => (pushScopeId("data-v-02c23a30"), n = n(), popScopeId(), n);
1
+ import { defineComponent, createElementBlock, openBlock, normalizeClass, createCommentVNode, createElementVNode, Fragment, renderSlot, useCssVars, ref, watch, withModifiers, toDisplayString, computed, resolveComponent, createBlock, normalizeProps, guardReactiveProps, unref, mergeProps, toHandlers, withCtx, withDirectives, vShow, isRef, onMounted, onUnmounted, normalizeStyle, nextTick, createTextVNode, renderList } from "vue";
3
2
  const _hoisted_1$a = ["disabled"];
4
3
  const _hoisted_2$9 = {
5
4
  key: 0,
6
5
  class: "sw-button__loading"
7
6
  };
8
- const _hoisted_3$9 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ createElementVNode("text", { class: "loading-spinner" }, null, -1));
9
- const _hoisted_4$7 = [
10
- _hoisted_3$9
11
- ];
12
- const _hoisted_5$5 = {
7
+ const _hoisted_3$9 = {
13
8
  key: 0,
14
9
  class: "sw-button__icon"
15
10
  };
16
- const _hoisted_6$5 = {
11
+ const _hoisted_4$6 = {
17
12
  key: 2,
18
13
  class: "sw-button__text"
19
14
  };
@@ -46,31 +41,33 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
46
41
  return (_ctx, _cache) => {
47
42
  return openBlock(), createElementBlock("view", {
48
43
  class: normalizeClass(["sw-button", [
49
- `sw-button--${_ctx.type}`,
50
- `sw-button--${_ctx.size}`,
51
- `sw-button--${_ctx.shape}`,
52
- { "is-disabled": _ctx.disabled },
53
- { "is-loading": _ctx.loading },
54
- { "is-block": _ctx.block },
55
- { "is-round": _ctx.round },
56
- { "is-plain": _ctx.plain },
57
- { "is-outline": _ctx.outline },
58
- { "is-link": _ctx.link }
44
+ `sw-button--${__props.type}`,
45
+ `sw-button--${__props.size}`,
46
+ `sw-button--${__props.shape}`,
47
+ { "is-disabled": __props.disabled },
48
+ { "is-loading": __props.loading },
49
+ { "is-block": __props.block },
50
+ { "is-round": __props.round },
51
+ { "is-plain": __props.plain },
52
+ { "is-outline": __props.outline },
53
+ { "is-link": __props.link }
59
54
  ]]),
60
- disabled: _ctx.disabled || _ctx.loading,
55
+ disabled: __props.disabled || __props.loading,
61
56
  onClick: handleClick
62
57
  }, [
63
- _ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_2$9, _hoisted_4$7)) : createCommentVNode("", true),
64
- !_ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
65
- _ctx.$slots.icon ? (openBlock(), createElementBlock("view", _hoisted_5$5, [
58
+ __props.loading ? (openBlock(), createElementBlock("view", _hoisted_2$9, [..._cache[0] || (_cache[0] = [
59
+ createElementVNode("text", { class: "loading-spinner" }, null, -1)
60
+ ])])) : createCommentVNode("", true),
61
+ !__props.loading ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
62
+ _ctx.$slots.icon ? (openBlock(), createElementBlock("view", _hoisted_3$9, [
66
63
  renderSlot(_ctx.$slots, "icon", {}, void 0, true)
67
64
  ])) : createCommentVNode("", true),
68
- _ctx.icon ? (openBlock(), createElementBlock("text", {
65
+ __props.icon ? (openBlock(), createElementBlock("text", {
69
66
  key: 1,
70
- class: normalizeClass(["sw-button__icon", [_ctx.icon]])
67
+ class: normalizeClass(["sw-button__icon", [__props.icon]])
71
68
  }, null, 2)) : createCommentVNode("", true)
72
69
  ], 64)) : createCommentVNode("", true),
73
- _ctx.$slots.default ? (openBlock(), createElementBlock("text", _hoisted_6$5, [
70
+ _ctx.$slots.default ? (openBlock(), createElementBlock("text", _hoisted_4$6, [
74
71
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
75
72
  ])) : createCommentVNode("", true)
76
73
  ], 10, _hoisted_1$a);
@@ -84,19 +81,17 @@ const _export_sfc = (sfc, props) => {
84
81
  }
85
82
  return target;
86
83
  };
87
- const index$7 = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-02c23a30"]]);
88
- const _withScopeId$3 = (n) => (pushScopeId("data-v-a2785685"), n = n(), popScopeId(), n);
84
+ const Button = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-02c23a30"]]);
89
85
  const _hoisted_1$9 = { class: "dialog-content" };
90
86
  const _hoisted_2$8 = { class: "dialog-icon" };
91
87
  const _hoisted_3$8 = ["src"];
92
- const _hoisted_4$6 = {
88
+ const _hoisted_4$5 = {
93
89
  key: 1,
94
90
  class: "default-icon"
95
91
  };
96
92
  const _hoisted_5$4 = { class: "dialog-title" };
97
93
  const _hoisted_6$4 = { class: "dialog-description" };
98
- const _hoisted_7$4 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createElementVNode("view", { class: "dialog-divider" }, null, -1));
99
- const _hoisted_8$4 = { class: "dialog-buttons" };
94
+ const _hoisted_7$2 = { class: "dialog-buttons" };
100
95
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
101
96
  __name: "index",
102
97
  props: {
@@ -112,7 +107,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
112
107
  emits: ["update:modelValue", "confirm", "cancel"],
113
108
  setup(__props, { emit: __emit }) {
114
109
  useCssVars((_ctx) => ({
115
- "1f434a4e": _ctx.maskOpacity
110
+ "v1f434a4e": _ctx.maskOpacity
116
111
  }));
117
112
  const props = __props;
118
113
  const emit = __emit;
@@ -149,18 +144,18 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
149
144
  }, [
150
145
  createElementVNode("view", _hoisted_1$9, [
151
146
  createElementVNode("view", _hoisted_2$8, [
152
- _ctx.icon ? (openBlock(), createElementBlock("image", {
147
+ __props.icon ? (openBlock(), createElementBlock("image", {
153
148
  key: 0,
154
- src: _ctx.icon,
149
+ src: __props.icon,
155
150
  alt: "dialog-icon"
156
- }, null, 8, _hoisted_3$8)) : (openBlock(), createElementBlock("view", _hoisted_4$6))
151
+ }, null, 8, _hoisted_3$8)) : (openBlock(), createElementBlock("view", _hoisted_4$5))
157
152
  ]),
158
- createElementVNode("text", _hoisted_5$4, toDisplayString(_ctx.title), 1),
159
- createElementVNode("text", _hoisted_6$4, toDisplayString(_ctx.description), 1)
153
+ createElementVNode("text", _hoisted_5$4, toDisplayString(__props.title), 1),
154
+ createElementVNode("text", _hoisted_6$4, toDisplayString(__props.description), 1)
160
155
  ]),
161
- _hoisted_7$4,
162
- createElementVNode("view", _hoisted_8$4, [
163
- _ctx.type === "open-app" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
156
+ _cache[1] || (_cache[1] = createElementVNode("view", { class: "dialog-divider" }, null, -1)),
157
+ createElementVNode("view", _hoisted_7$2, [
158
+ __props.type === "open-app" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
164
159
  createElementVNode("view", {
165
160
  class: "dialog-button dialog-button-cancel",
166
161
  onClick: handleCancel
@@ -169,11 +164,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
169
164
  class: "dialog-button dialog-button-primary",
170
165
  onClick: handleConfirm
171
166
  }, " 打开app ")
172
- ], 64)) : _ctx.type === "confirm" ? (openBlock(), createElementBlock("view", {
167
+ ], 64)) : __props.type === "confirm" ? (openBlock(), createElementBlock("view", {
173
168
  key: 1,
174
169
  class: "dialog-button dialog-button-full dialog-button-primary",
175
170
  onClick: handleConfirm
176
- }, " 知道了 ")) : _ctx.type === "continue" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
171
+ }, " 知道了 ")) : __props.type === "continue" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
177
172
  createElementVNode("view", {
178
173
  class: "dialog-button dialog-button-cancel",
179
174
  onClick: handleCancel
@@ -189,7 +184,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
189
184
  };
190
185
  }
191
186
  });
192
- const index$6 = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-a2785685"]]);
187
+ const Dialog = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-a2785685"]]);
193
188
  const _hoisted_1$8 = {
194
189
  key: 0,
195
190
  class: "sw-divider__text"
@@ -207,9 +202,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
207
202
  return (_ctx, _cache) => {
208
203
  return openBlock(), createElementBlock("view", {
209
204
  class: normalizeClass(["sw-divider", [
210
- { "is-vertical": _ctx.vertical },
211
- { "is-dashed": _ctx.dashed },
212
- { [`sw-divider--${_ctx.position}`]: _ctx.position !== "center" }
205
+ { "is-vertical": __props.vertical },
206
+ { "is-dashed": __props.dashed },
207
+ { [`sw-divider--${__props.position}`]: __props.position !== "center" }
213
208
  ]])
214
209
  }, [
215
210
  _ctx.$slots.default ? (openBlock(), createElementBlock("text", _hoisted_1$8, [
@@ -219,576 +214,596 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
219
214
  };
220
215
  }
221
216
  });
222
- const index$5 = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-b668cd0b"]]);
223
- const _withScopeId$2 = (n) => (pushScopeId("data-v-00bcefd1"), n = n(), popScopeId(), n);
224
- const _hoisted_1$7 = {
225
- key: 0,
226
- class: "popup-header"
227
- };
228
- const _hoisted_2$7 = {
229
- key: 1,
230
- class: "popup-header"
231
- };
232
- const _hoisted_3$7 = { class: "popup-title" };
233
- const _hoisted_4$5 = { class: "popup-content" };
234
- const _hoisted_5$3 = {
235
- key: 2,
236
- class: "popup-footer"
237
- };
238
- const _hoisted_6$3 = {
239
- key: 3,
240
- class: "popup-footer"
241
- };
242
- const _hoisted_7$3 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ createElementVNode("text", { class: "close-icon" }, "×", -1));
243
- const _hoisted_8$3 = [
244
- _hoisted_7$3
245
- ];
217
+ const Divider = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-b668cd0b"]]);
218
+ function useDropdownSelect(props, emit) {
219
+ const isOpen = ref(false);
220
+ const displayText = computed(() => {
221
+ var _a, _b;
222
+ if (!((_a = props.options) == null ? void 0 : _a.length)) {
223
+ return "请选择";
224
+ }
225
+ if (props.modelValue !== void 0 && props.modelValue !== null) {
226
+ const matched = props.options.find(
227
+ (opt) => opt.value === props.modelValue
228
+ );
229
+ if (matched)
230
+ return matched.text;
231
+ }
232
+ return ((_b = props.options[0]) == null ? void 0 : _b.text) || "请选择";
233
+ });
234
+ const internalValue = computed({
235
+ get() {
236
+ var _a, _b;
237
+ if (props.modelValue !== void 0 && props.modelValue !== null) {
238
+ return props.modelValue;
239
+ }
240
+ return ((_b = (_a = props.options) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) ?? "";
241
+ },
242
+ set(val) {
243
+ emit("update:modelValue", val);
244
+ }
245
+ });
246
+ const handleChange = (value) => {
247
+ emit("change", value);
248
+ };
249
+ const handleOpen = () => {
250
+ isOpen.value = true;
251
+ };
252
+ const handleClose = () => {
253
+ isOpen.value = false;
254
+ };
255
+ return {
256
+ displayText,
257
+ internalValue,
258
+ isOpen,
259
+ handleChange,
260
+ handleOpen,
261
+ handleClose
262
+ };
263
+ }
264
+ const _hoisted_1$7 = { class: "dropdown-select" };
265
+ const _hoisted_2$7 = { class: "dropdown-title" };
266
+ const _hoisted_3$7 = { class: "dropdown-text" };
246
267
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
247
268
  __name: "index",
248
269
  props: {
249
- modelValue: { type: Boolean, default: false },
250
- title: { default: "" },
251
- position: { default: "center" },
252
- animation: { default: "slide" },
253
- mask: { type: Boolean, default: true },
254
- maskOpacity: { default: 0.5 },
255
- closeOnMaskClick: { type: Boolean, default: true },
256
- showCloseButton: { type: Boolean, default: true },
257
- closeOnEsc: { type: Boolean, default: true },
258
- showConfirmButton: { type: Boolean, default: false },
259
- confirmText: { default: "确定" },
260
- showCancelButton: { type: Boolean, default: false },
261
- cancelText: { default: "取消" },
262
- width: { default: "50%" },
263
- height: { default: "100%" },
264
- maxWidth: { default: "500px" },
265
- lockScroll: { type: Boolean, default: true }
270
+ modelValue: {},
271
+ iconName: { default: "arrow-down" },
272
+ options: {}
266
273
  },
267
- emits: ["update:modelValue", "open", "close", "maskClick", "confirm", "cancel", "closeButtonClick"],
274
+ emits: ["update:modelValue", "change"],
268
275
  setup(__props, { emit: __emit }) {
269
276
  const props = __props;
270
277
  const emit = __emit;
271
- const popupRef = ref(null);
272
- const showPopup = ref(props.modelValue);
273
- const isClosing = ref(false);
274
- const lastScrollY = ref(0);
275
- watch(() => props.modelValue, (newVal) => {
276
- showPopup.value = newVal;
277
- if (newVal) {
278
- onOpen();
279
- } else {
280
- onClose();
281
- }
278
+ const { displayText, internalValue, handleChange, handleOpen, handleClose } = useDropdownSelect(props, emit);
279
+ const isOpen = ref(false);
280
+ const selectedIndex = computed(() => {
281
+ if (!props.options || !props.options.length)
282
+ return 0;
283
+ return props.options.findIndex((opt) => opt.value === internalValue.value);
282
284
  });
283
- watch(() => showPopup.value, (newVal) => {
284
- emit("update:modelValue", newVal);
285
- if (newVal) {
286
- onOpen();
285
+ function togglePicker() {
286
+ isOpen.value = !isOpen.value;
287
+ if (isOpen.value) {
288
+ handleOpen();
287
289
  } else {
288
- onClose();
289
- }
290
- });
291
- function onOpen() {
292
- if (props.lockScroll) {
293
- lockScroll();
294
- }
295
- if (props.closeOnEsc) {
296
- window.addEventListener("keydown", handleKeyDown);
297
- }
298
- emit("open");
299
- }
300
- function onClose() {
301
- if (props.lockScroll) {
302
- unlockScroll();
303
- }
304
- window.removeEventListener("keydown", handleKeyDown);
305
- emit("close");
306
- }
307
- function lockScroll() {
308
- lastScrollY.value = window.scrollY;
309
- document.body.style.position = "fixed";
310
- document.body.style.top = `-${lastScrollY.value}px`;
311
- document.body.style.left = "0";
312
- document.body.style.right = "0";
313
- document.body.style.overflow = "hidden";
314
- uni.hideTabBar();
315
- }
316
- function unlockScroll() {
317
- document.body.style.position = "";
318
- document.body.style.top = "";
319
- document.body.style.left = "";
320
- document.body.style.right = "";
321
- document.body.style.overflow = "";
322
- window.scrollTo(0, lastScrollY.value);
323
- uni.showTabBar();
324
- }
325
- function handleKeyDown(e) {
326
- if (e.key === "Escape" && props.closeOnEsc && showPopup.value) {
327
- handleClose();
328
- }
329
- }
330
- function handleMaskClick() {
331
- if (props.closeOnMaskClick) {
332
290
  handleClose();
333
291
  }
334
- emit("maskClick");
335
- }
336
- function handleClose() {
337
- isClosing.value = true;
338
- emit("closeButtonClick");
339
- }
340
- function handleAnimationEnd() {
341
- if (isClosing.value) {
342
- isClosing.value = false;
343
- showPopup.value = false;
344
- }
345
292
  }
346
- function handleConfirm() {
347
- emit("confirm");
293
+ function onPickerChange(e) {
294
+ const index2 = e.detail.value;
295
+ const selectedOption = props.options[index2];
296
+ handleChange(selectedOption.value);
297
+ isOpen.value = false;
298
+ handleClose();
348
299
  }
349
- function handleCancel() {
350
- emit("cancel");
300
+ function onPickerCancel() {
301
+ isOpen.value = false;
351
302
  handleClose();
352
303
  }
353
- onMounted(() => {
354
- if (showPopup.value) {
355
- onOpen();
356
- }
357
- });
358
- onUnmounted(() => {
359
- if (showPopup.value) {
360
- onClose();
361
- }
362
- });
363
304
  return (_ctx, _cache) => {
364
- return withDirectives((openBlock(), createElementBlock("view", {
365
- class: normalizeClass(["popup-wrapper", {
366
- "modal": _ctx.mask,
367
- "non-modal": !_ctx.mask,
368
- "closing": isClosing.value
369
- }]),
370
- onClick: withModifiers(handleMaskClick, ["self"])
371
- }, [
372
- _ctx.mask ? (openBlock(), createElementBlock("view", {
373
- key: 0,
374
- class: "popup-mask",
375
- style: normalizeStyle({ opacity: _ctx.maskOpacity }),
376
- onClick: handleMaskClick
377
- }, null, 4)) : createCommentVNode("", true),
305
+ const _component_picker = resolveComponent("picker");
306
+ return openBlock(), createElementBlock("view", _hoisted_1$7, [
378
307
  createElementVNode("view", {
379
- ref_key: "popupRef",
380
- ref: popupRef,
381
- class: normalizeClass(["popup-container", [
382
- `position-${_ctx.position}`,
383
- `animation-${_ctx.animation}`,
384
- { closing: isClosing.value }
385
- ]]),
386
- onClick: _cache[0] || (_cache[0] = withModifiers(() => {
387
- }, ["stop"])),
388
- onTouchmove: _cache[1] || (_cache[1] = withModifiers(() => {
389
- }, ["stop"])),
390
- onAnimationend: handleAnimationEnd
308
+ class: "dropdown-trigger",
309
+ onTap: togglePicker
391
310
  }, [
392
- _ctx.$slots.header ? (openBlock(), createElementBlock("view", _hoisted_1$7, [
393
- renderSlot(_ctx.$slots, "header", {}, void 0, true)
394
- ])) : _ctx.title ? (openBlock(), createElementBlock("view", _hoisted_2$7, [
395
- createElementVNode("text", _hoisted_3$7, toDisplayString(_ctx.title), 1)
396
- ])) : createCommentVNode("", true),
397
- createElementVNode("view", _hoisted_4$5, [
398
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
399
- ]),
400
- _ctx.$slots.footer ? (openBlock(), createElementBlock("view", _hoisted_5$3, [
401
- renderSlot(_ctx.$slots, "footer", {}, void 0, true)
402
- ])) : _ctx.showConfirmButton || _ctx.showCancelButton ? (openBlock(), createElementBlock("view", _hoisted_6$3, [
403
- _ctx.showCancelButton ? (openBlock(), createElementBlock("view", {
404
- key: 0,
405
- class: "popup-button popup-button-cancel",
406
- onClick: handleCancel
407
- }, toDisplayString(_ctx.cancelText), 1)) : createCommentVNode("", true),
408
- _ctx.showConfirmButton ? (openBlock(), createElementBlock("view", {
409
- key: 1,
410
- class: "popup-button popup-button-confirm",
411
- onClick: handleConfirm
412
- }, toDisplayString(_ctx.confirmText), 1)) : createCommentVNode("", true)
413
- ])) : createCommentVNode("", true),
414
- _ctx.showCloseButton ? (openBlock(), createElementBlock("view", {
415
- key: 4,
416
- class: "popup-close-button",
417
- onClick: handleClose
418
- }, _hoisted_8$3)) : createCommentVNode("", true)
419
- ], 34)
420
- ], 2)), [
421
- [vShow, showPopup.value]
311
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ text: unref(displayText) })), () => [
312
+ createElementVNode("view", _hoisted_2$7, [
313
+ createElementVNode("text", _hoisted_3$7, toDisplayString(unref(displayText)), 1),
314
+ createElementVNode("text", {
315
+ class: normalizeClass(["dropdown-icon", { "is-active": isOpen.value }])
316
+ }, [
317
+ renderSlot(_ctx.$slots, "icon", {}, () => [
318
+ createElementVNode("view", {
319
+ class: normalizeClass(["uni-icon", __props.iconName])
320
+ }, null, 2)
321
+ ])
322
+ ], 2)
323
+ ])
324
+ ])
325
+ ], 32),
326
+ isOpen.value ? (openBlock(), createBlock(_component_picker, {
327
+ key: 0,
328
+ mode: "selector",
329
+ range: __props.options,
330
+ "range-key": "text",
331
+ value: selectedIndex.value,
332
+ class: "dropdown-picker",
333
+ onChange: onPickerChange,
334
+ onCancel: onPickerCancel
335
+ }, null, 8, ["range", "value"])) : createCommentVNode("", true)
422
336
  ]);
423
337
  };
424
338
  }
425
339
  });
426
- const index$4 = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-00bcefd1"]]);
427
- const _hoisted_1$6 = {
428
- key: 0,
429
- class: "sw-toast__loading"
430
- };
431
- const _hoisted_2$6 = {
432
- key: 0,
433
- class: "sw-toast__spinner"
434
- };
435
- const _hoisted_3$6 = {
436
- key: 1,
437
- class: "sw-toast__custom-icon"
438
- };
439
- const _hoisted_4$4 = {
440
- key: 1,
441
- class: "sw-toast__icon"
442
- };
443
- const _hoisted_5$2 = {
340
+ function useDropdownWithBadge(props) {
341
+ const hasBadge = computed(() => {
342
+ return props.hideBadge(props.modelValue);
343
+ });
344
+ return { hasBadge };
345
+ }
346
+ const _hoisted_1$6 = { class: "dropdown-title" };
347
+ const _hoisted_2$6 = { class: "dropdown-text" };
348
+ const _hoisted_3$6 = { class: "dropdown-icon" };
349
+ const _hoisted_4$4 = { class: "dropdown-with-badge__dot" };
350
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
351
+ __name: "index",
352
+ props: {
353
+ hideBadge: { type: Function, default: (modelValue) => modelValue === "" || modelValue === null || modelValue === void 0 }
354
+ },
355
+ emits: ["update:modelValue", "change"],
356
+ setup(__props, { emit: __emit }) {
357
+ const props = __props;
358
+ const emit = __emit;
359
+ const { hasBadge } = useDropdownWithBadge(props);
360
+ return (_ctx, _cache) => {
361
+ return openBlock(), createBlock(unref(_sfc_main$7), mergeProps({ modelValue: _ctx.modelValue, options: _ctx.options }, { class: "dropdown-with-badge" }, toHandlers(emit)), {
362
+ default: withCtx(({ text }) => [
363
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ text })), () => [
364
+ createElementVNode("view", _hoisted_1$6, [
365
+ createElementVNode("text", _hoisted_2$6, toDisplayString(text), 1),
366
+ createElementVNode("text", _hoisted_3$6, [
367
+ renderSlot(_ctx.$slots, "icon", {}, () => [
368
+ createElementVNode("view", {
369
+ class: normalizeClass(["uni-icon", _ctx.iconName])
370
+ }, null, 2)
371
+ ])
372
+ ])
373
+ ]),
374
+ withDirectives(createElementVNode("text", _hoisted_4$4, null, 512), [
375
+ [vShow, !unref(hasBadge)]
376
+ ])
377
+ ])
378
+ ]),
379
+ _: 3
380
+ }, 16);
381
+ };
382
+ }
383
+ });
384
+ function useHasBadge(model) {
385
+ if (!model) {
386
+ return computed(() => false);
387
+ }
388
+ if (typeof model === "function") {
389
+ return computed(() => model());
390
+ }
391
+ if (isRef(model)) {
392
+ return computed(() => {
393
+ if (!model.value)
394
+ return false;
395
+ const obj = model.value;
396
+ for (const key in obj) {
397
+ if (obj[key]) {
398
+ return true;
399
+ }
400
+ }
401
+ return false;
402
+ });
403
+ }
404
+ return computed(() => {
405
+ for (const key in model) {
406
+ const val = model[key];
407
+ if (val) {
408
+ return true;
409
+ }
410
+ }
411
+ return false;
412
+ });
413
+ }
414
+ function useFilterDrawer(props, emit) {
415
+ const visible = ref(false);
416
+ const hasBadge = useHasBadge(props.modelValue);
417
+ const openDrawer = () => {
418
+ visible.value = true;
419
+ };
420
+ const closeDrawer = () => {
421
+ visible.value = false;
422
+ };
423
+ const resetDrawer = () => {
424
+ emit("reset");
425
+ closeDrawer();
426
+ };
427
+ const queryDrawer = () => {
428
+ emit("query");
429
+ closeDrawer();
430
+ };
431
+ return {
432
+ visible,
433
+ openDrawer,
434
+ closeDrawer,
435
+ resetDrawer,
436
+ queryDrawer,
437
+ hasBadge
438
+ };
439
+ }
440
+ const _hoisted_1$5 = {
444
441
  key: 0,
445
- class: "sw-toast__icon--success"
442
+ class: "filter-drawer__badge-dot"
446
443
  };
447
- const _hoisted_6$2 = {
444
+ const _hoisted_2$5 = {
448
445
  key: 1,
449
- class: "sw-toast__icon--fail"
446
+ class: "filter-drawer__popup",
447
+ style: { height: "100vh", width: "100vw" }
450
448
  };
451
- const _hoisted_7$2 = {
452
- key: 2,
453
- class: "sw-toast__custom-icon"
449
+ const _hoisted_3$5 = { class: "filter-drawer" };
450
+ const _hoisted_4$3 = { class: "filter-drawer__header" };
451
+ const _hoisted_5$3 = { class: "filter-drawer__body" };
452
+ const _hoisted_6$3 = { class: "filter-drawer__footer" };
453
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
454
+ __name: "index",
455
+ props: {
456
+ hasBadge: { type: Boolean, default: false },
457
+ modelValue: {}
458
+ },
459
+ emits: ["reset", "query"],
460
+ setup(__props, { emit: __emit }) {
461
+ const props = __props;
462
+ const emit = __emit;
463
+ const { visible, openDrawer, closeDrawer, resetDrawer, queryDrawer, hasBadge } = useFilterDrawer(props, emit);
464
+ return (_ctx, _cache) => {
465
+ return openBlock(), createElementBlock(Fragment, null, [
466
+ createElementVNode("view", {
467
+ class: "filter-drawer__trigger",
468
+ onClick: _cache[0] || (_cache[0] = //@ts-ignore
469
+ (...args) => unref(openDrawer) && unref(openDrawer)(...args))
470
+ }, [
471
+ renderSlot(_ctx.$slots, "trigger", {}, () => [
472
+ _cache[5] || (_cache[5] = createElementVNode("view", { class: "uni-icon icon-filter-o" }, null, -1))
473
+ ]),
474
+ unref(hasBadge) ? (openBlock(), createElementBlock("text", _hoisted_1$5)) : createCommentVNode("", true)
475
+ ]),
476
+ unref(visible) ? (openBlock(), createElementBlock("view", {
477
+ key: 0,
478
+ class: "filter-drawer__popup-mask",
479
+ onClick: _cache[1] || (_cache[1] = //@ts-ignore
480
+ (...args) => unref(closeDrawer) && unref(closeDrawer)(...args))
481
+ })) : createCommentVNode("", true),
482
+ unref(visible) ? (openBlock(), createElementBlock("view", _hoisted_2$5, [
483
+ createElementVNode("view", {
484
+ class: "filter-drawer__close",
485
+ onClick: _cache[2] || (_cache[2] = //@ts-ignore
486
+ (...args) => unref(closeDrawer) && unref(closeDrawer)(...args))
487
+ }, " × "),
488
+ createElementVNode("view", _hoisted_3$5, [
489
+ createElementVNode("view", _hoisted_4$3, [
490
+ renderSlot(_ctx.$slots, "header", {}, () => [
491
+ _cache[6] || (_cache[6] = createElementVNode("text", { class: "filter-drawer__title" }, "筛选", -1))
492
+ ])
493
+ ]),
494
+ createElementVNode("view", _hoisted_5$3, [
495
+ renderSlot(_ctx.$slots, "default")
496
+ ]),
497
+ createElementVNode("view", _hoisted_6$3, [
498
+ renderSlot(_ctx.$slots, "footer", {}, () => [
499
+ createElementVNode("view", {
500
+ class: "filter-drawer__button filter-drawer__button--plain",
501
+ onClick: _cache[3] || (_cache[3] = //@ts-ignore
502
+ (...args) => unref(resetDrawer) && unref(resetDrawer)(...args))
503
+ }, " 重置条件 "),
504
+ createElementVNode("view", {
505
+ class: "filter-drawer__button",
506
+ onClick: _cache[4] || (_cache[4] = //@ts-ignore
507
+ (...args) => unref(queryDrawer) && unref(queryDrawer)(...args))
508
+ }, " 查询 ")
509
+ ])
510
+ ])
511
+ ])
512
+ ])) : createCommentVNode("", true)
513
+ ], 64);
514
+ };
515
+ }
516
+ });
517
+ const _hoisted_1$4 = { class: "sw-infinite-scroll__content" };
518
+ const _hoisted_2$4 = {
519
+ key: 0,
520
+ class: "sw-infinite-scroll__loading"
454
521
  };
455
- const _hoisted_8$2 = {
456
- key: 2,
457
- class: "sw-toast__text"
522
+ const _hoisted_3$4 = {
523
+ key: 1,
524
+ class: "sw-infinite-scroll__finished"
458
525
  };
459
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
526
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
460
527
  __name: "index",
461
528
  props: {
462
- modelValue: { type: Boolean, default: false },
463
- type: { default: "text" },
464
- position: { default: "middle" },
465
- message: { default: "" },
466
- duration: { default: 3e3 },
467
529
  loading: { type: Boolean, default: false },
468
- icon: { type: Boolean, default: true },
469
- customIcon: { default: "" },
470
- large: { type: Boolean, default: false },
471
- customStyle: { default: () => ({}) }
530
+ finished: { type: Boolean, default: false },
531
+ offset: { default: 100 },
532
+ loadingText: { default: "加载中..." },
533
+ finishedText: { default: "没有更多了" },
534
+ disabled: { type: Boolean, default: false },
535
+ height: { default: "auto" }
472
536
  },
473
- emits: ["update:modelValue", "close", "click"],
474
- setup(__props, { expose: __expose, emit: __emit }) {
537
+ emits: ["load"],
538
+ setup(__props, { emit: __emit }) {
475
539
  const props = __props;
476
540
  const emit = __emit;
477
- const toastRef = ref(null);
478
- let timer = null;
479
- const showToast = ref(props.modelValue);
480
- const isClosing = ref(false);
481
- const showIcon = computed(() => {
482
- if (props.loading)
483
- return true;
484
- if (props.type === "text")
485
- return props.icon;
486
- return true;
541
+ const scrollContainer = ref(null);
542
+ const containerStyle = computed(() => {
543
+ return {
544
+ height: typeof props.height === "number" ? `${props.height}px` : props.height
545
+ };
487
546
  });
488
- function onClick() {
489
- emit("click");
490
- }
491
- function close() {
492
- if (!showToast.value)
547
+ function handleScroll() {
548
+ if (!scrollContainer.value || props.loading || props.finished || props.disabled) {
493
549
  return;
494
- isClosing.value = true;
495
- emit("close");
496
- }
497
- function startTimer() {
498
- clearTimer();
499
- if (props.duration > 0 && !props.loading) {
500
- timer = setTimeout(() => {
501
- close();
502
- }, props.duration);
503
550
  }
504
- }
505
- function clearTimer() {
506
- if (timer) {
507
- clearTimeout(timer);
508
- timer = null;
551
+ const { scrollTop, scrollHeight, clientHeight } = scrollContainer.value;
552
+ if (scrollHeight - scrollTop - clientHeight <= props.offset) {
553
+ emit("load");
509
554
  }
510
555
  }
511
- function handleTransitionEnd() {
512
- if (isClosing.value) {
513
- showToast.value = false;
514
- isClosing.value = false;
515
- emit("update:modelValue", false);
556
+ let resizeTimeout = null;
557
+ function handleResize() {
558
+ if (resizeTimeout) {
559
+ clearTimeout(resizeTimeout);
516
560
  }
561
+ resizeTimeout = setTimeout(() => {
562
+ handleScroll();
563
+ }, 100);
517
564
  }
518
- watch(() => props.modelValue, (newVal) => {
519
- if (newVal) {
520
- showToast.value = true;
521
- isClosing.value = false;
522
- startTimer();
523
- } else {
524
- close();
565
+ onMounted(() => {
566
+ handleScroll();
567
+ window.addEventListener("resize", handleResize);
568
+ });
569
+ onUnmounted(() => {
570
+ window.removeEventListener("resize", handleResize);
571
+ if (resizeTimeout) {
572
+ clearTimeout(resizeTimeout);
525
573
  }
526
574
  });
527
- watch(() => props.message, () => {
528
- if (showToast.value && !props.loading) {
529
- startTimer();
530
- }
531
- });
532
- onMounted(() => {
533
- if (props.modelValue) {
534
- startTimer();
535
- }
536
- });
537
- onUnmounted(() => {
538
- clearTimer();
539
- });
540
- __expose({
541
- /**
542
- * 手动关闭Toast
543
- */
544
- close
545
- });
546
575
  return (_ctx, _cache) => {
547
- return withDirectives((openBlock(), createElementBlock("view", {
548
- ref_key: "toastRef",
549
- ref: toastRef,
550
- class: normalizeClass(["sw-toast", [
551
- `sw-toast--${_ctx.type}`,
552
- `sw-toast--${_ctx.position}`,
553
- { "sw-toast--large": _ctx.large },
554
- { "sw-toast--text": !showIcon.value && _ctx.type === "text" },
555
- { "sw-toast--show": showToast.value && !isClosing.value },
556
- { "sw-toast--hide": showToast.value && isClosing.value }
557
- ]]),
558
- style: normalizeStyle(_ctx.customStyle),
559
- onClick,
560
- onTransitionend: handleTransitionEnd
576
+ return openBlock(), createElementBlock("view", {
577
+ ref_key: "scrollContainer",
578
+ ref: scrollContainer,
579
+ class: "sw-infinite-scroll",
580
+ style: normalizeStyle(containerStyle.value),
581
+ onScroll: handleScroll
561
582
  }, [
562
- _ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_1$6, [
563
- !_ctx.customIcon ? (openBlock(), createElementBlock("text", _hoisted_2$6)) : (openBlock(), createElementBlock("text", _hoisted_3$6, toDisplayString(_ctx.customIcon), 1))
564
- ])) : showIcon.value ? (openBlock(), createElementBlock("view", _hoisted_4$4, [
565
- _ctx.type === "success" ? (openBlock(), createElementBlock("text", _hoisted_5$2, "✓")) : _ctx.type === "fail" ? (openBlock(), createElementBlock("text", _hoisted_6$2, "✗")) : _ctx.customIcon ? (openBlock(), createElementBlock("text", _hoisted_7$2, toDisplayString(_ctx.customIcon), 1)) : createCommentVNode("", true)
583
+ createElementVNode("view", _hoisted_1$4, [
584
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
585
+ ]),
586
+ __props.loading ? (openBlock(), createElementBlock("view", _hoisted_2$4, [
587
+ _cache[0] || (_cache[0] = createElementVNode("view", { class: "loading-spinner" }, null, -1)),
588
+ createElementVNode("text", null, toDisplayString(__props.loadingText), 1)
566
589
  ])) : createCommentVNode("", true),
567
- _ctx.message ? (openBlock(), createElementBlock("text", _hoisted_8$2, toDisplayString(_ctx.message), 1)) : createCommentVNode("", true)
568
- ], 38)), [
569
- [vShow, showToast.value]
570
- ]);
590
+ __props.finished && !__props.loading ? (openBlock(), createElementBlock("view", _hoisted_3$4, toDisplayString(__props.finishedText), 1)) : createCommentVNode("", true)
591
+ ], 36);
571
592
  };
572
593
  }
573
594
  });
574
- const index$3 = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-2b648fd9"]]);
575
- const _hoisted_1$5 = { class: "sw-swiper" };
576
- const _hoisted_2$5 = {
595
+ const InfiniteScroll = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2e49050a"]]);
596
+ const _hoisted_1$3 = {
577
597
  key: 0,
578
- class: "swiper-indicators"
598
+ class: "popup-header"
579
599
  };
580
- const _hoisted_3$5 = ["onClick"];
581
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
600
+ const _hoisted_2$3 = {
601
+ key: 1,
602
+ class: "popup-header"
603
+ };
604
+ const _hoisted_3$3 = { class: "popup-title" };
605
+ const _hoisted_4$2 = { class: "popup-content" };
606
+ const _hoisted_5$2 = {
607
+ key: 2,
608
+ class: "popup-footer"
609
+ };
610
+ const _hoisted_6$2 = {
611
+ key: 3,
612
+ class: "popup-footer"
613
+ };
614
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
582
615
  __name: "index",
583
616
  props: {
584
- items: {},
585
- initialIndex: { default: 0 },
586
- autoPlay: { type: Boolean, default: true },
587
- interval: { default: 3e3 },
588
- duration: { default: 300 },
589
- showIndicators: { type: Boolean, default: true },
590
- showArrows: { type: Boolean, default: false },
591
- loop: { type: Boolean, default: true }
617
+ modelValue: { type: Boolean, default: false },
618
+ title: { default: "" },
619
+ position: { default: "center" },
620
+ animation: { default: "slide" },
621
+ mask: { type: Boolean, default: true },
622
+ maskOpacity: { default: 0.5 },
623
+ closeOnMaskClick: { type: Boolean, default: true },
624
+ showCloseButton: { type: Boolean, default: true },
625
+ closeOnEsc: { type: Boolean, default: true },
626
+ showConfirmButton: { type: Boolean, default: false },
627
+ confirmText: { default: "确定" },
628
+ showCancelButton: { type: Boolean, default: false },
629
+ cancelText: { default: "取消" },
630
+ width: { default: "50%" },
631
+ height: { default: "100%" },
632
+ maxWidth: { default: "500px" },
633
+ lockScroll: { type: Boolean, default: true }
592
634
  },
593
- emits: ["change", "prev", "next"],
594
- setup(__props, { expose: __expose, emit: __emit }) {
635
+ emits: ["update:modelValue", "open", "close", "maskClick", "confirm", "cancel", "closeButtonClick"],
636
+ setup(__props, { emit: __emit }) {
595
637
  const props = __props;
596
638
  const emit = __emit;
597
- const currentIndex = ref(props.initialIndex);
598
- let timer = null;
599
- function startAutoPlay() {
600
- if (props.autoPlay && props.items.length > 1) {
601
- timer = setInterval(() => {
602
- next();
603
- }, props.interval);
639
+ const popupRef = ref(null);
640
+ const showPopup = ref(props.modelValue);
641
+ const isClosing = ref(false);
642
+ const lastScrollY = ref(0);
643
+ watch(() => props.modelValue, (newVal) => {
644
+ showPopup.value = newVal;
645
+ if (newVal) {
646
+ onOpen();
647
+ } else {
648
+ onClose();
604
649
  }
605
- }
606
- function stopAutoPlay() {
607
- if (timer) {
608
- clearInterval(timer);
609
- timer = null;
650
+ });
651
+ watch(() => showPopup.value, (newVal) => {
652
+ emit("update:modelValue", newVal);
653
+ if (newVal) {
654
+ onOpen();
655
+ } else {
656
+ onClose();
657
+ }
658
+ });
659
+ function onOpen() {
660
+ if (props.lockScroll) {
661
+ lockScroll();
662
+ }
663
+ if (props.closeOnEsc) {
664
+ window.addEventListener("keydown", handleKeyDown);
610
665
  }
666
+ emit("open");
611
667
  }
612
- function prev() {
613
- if (props.loop) {
614
- currentIndex.value = currentIndex.value === 0 ? props.items.length - 1 : currentIndex.value - 1;
615
- } else if (currentIndex.value > 0) {
616
- currentIndex.value--;
668
+ function onClose() {
669
+ if (props.lockScroll) {
670
+ unlockScroll();
617
671
  }
618
- emit("prev", currentIndex.value);
619
- emit("change", currentIndex.value);
672
+ window.removeEventListener("keydown", handleKeyDown);
673
+ emit("close");
620
674
  }
621
- function next() {
622
- if (props.loop) {
623
- currentIndex.value = currentIndex.value === props.items.length - 1 ? 0 : currentIndex.value + 1;
624
- } else if (currentIndex.value < props.items.length - 1) {
625
- currentIndex.value++;
675
+ function lockScroll() {
676
+ lastScrollY.value = window.scrollY;
677
+ document.body.style.position = "fixed";
678
+ document.body.style.top = `-${lastScrollY.value}px`;
679
+ document.body.style.left = "0";
680
+ document.body.style.right = "0";
681
+ document.body.style.overflow = "hidden";
682
+ uni.hideTabBar();
683
+ }
684
+ function unlockScroll() {
685
+ document.body.style.position = "";
686
+ document.body.style.top = "";
687
+ document.body.style.left = "";
688
+ document.body.style.right = "";
689
+ document.body.style.overflow = "";
690
+ window.scrollTo(0, lastScrollY.value);
691
+ uni.showTabBar();
692
+ }
693
+ function handleKeyDown(e) {
694
+ if (e.key === "Escape" && props.closeOnEsc && showPopup.value) {
695
+ handleClose();
626
696
  }
627
- emit("next", currentIndex.value);
628
- emit("change", currentIndex.value);
629
697
  }
630
- watch(() => props.items, (newItems) => {
631
- if (newItems.length < currentIndex.value + 1) {
632
- currentIndex.value = Math.min(currentIndex.value, newItems.length - 1);
698
+ function handleMaskClick() {
699
+ if (props.closeOnMaskClick) {
700
+ handleClose();
633
701
  }
634
- stopAutoPlay();
635
- startAutoPlay();
636
- }, { deep: true });
637
- watch(() => props.autoPlay, (autoPlay) => {
638
- if (autoPlay) {
639
- startAutoPlay();
640
- } else {
641
- stopAutoPlay();
702
+ emit("maskClick");
703
+ }
704
+ function handleClose() {
705
+ isClosing.value = true;
706
+ emit("closeButtonClick");
707
+ }
708
+ function handleAnimationEnd() {
709
+ if (isClosing.value) {
710
+ isClosing.value = false;
711
+ showPopup.value = false;
642
712
  }
643
- });
713
+ }
714
+ function handleConfirm() {
715
+ emit("confirm");
716
+ }
717
+ function handleCancel() {
718
+ emit("cancel");
719
+ handleClose();
720
+ }
644
721
  onMounted(() => {
645
- startAutoPlay();
722
+ if (showPopup.value) {
723
+ onOpen();
724
+ }
646
725
  });
647
726
  onUnmounted(() => {
648
- stopAutoPlay();
649
- });
650
- __expose({
651
- prev,
652
- next,
653
- currentIndex
727
+ if (showPopup.value) {
728
+ onClose();
729
+ }
654
730
  });
655
731
  return (_ctx, _cache) => {
656
- return openBlock(), createElementBlock("view", _hoisted_1$5, [
732
+ return withDirectives((openBlock(), createElementBlock("view", {
733
+ class: normalizeClass(["popup-wrapper", {
734
+ "modal": __props.mask,
735
+ "non-modal": !__props.mask,
736
+ "closing": isClosing.value
737
+ }]),
738
+ onClick: withModifiers(handleMaskClick, ["self"])
739
+ }, [
740
+ __props.mask ? (openBlock(), createElementBlock("view", {
741
+ key: 0,
742
+ class: "popup-mask",
743
+ style: normalizeStyle({ opacity: __props.maskOpacity }),
744
+ onClick: handleMaskClick
745
+ }, null, 4)) : createCommentVNode("", true),
657
746
  createElementVNode("view", {
658
- class: "swiper-wrapper",
659
- style: normalizeStyle({
660
- transform: `translateX(-${currentIndex.value * 100}%)`,
661
- transition: `transform ${_ctx.duration}ms ease`
662
- })
747
+ ref_key: "popupRef",
748
+ ref: popupRef,
749
+ class: normalizeClass(["popup-container", [
750
+ `position-${__props.position}`,
751
+ `animation-${__props.animation}`,
752
+ { closing: isClosing.value }
753
+ ]]),
754
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
755
+ }, ["stop"])),
756
+ onTouchmove: _cache[1] || (_cache[1] = withModifiers(() => {
757
+ }, ["stop"])),
758
+ onAnimationend: handleAnimationEnd
663
759
  }, [
664
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.items, (item, index2) => {
665
- return openBlock(), createElementBlock("view", {
666
- key: index2,
667
- class: "swiper-item"
668
- }, [
669
- renderSlot(_ctx.$slots, "default", {
670
- item,
671
- index: index2
672
- }, void 0, true)
673
- ]);
674
- }), 128))
675
- ], 4),
676
- _ctx.showIndicators ? (openBlock(), createElementBlock("view", _hoisted_2$5, [
677
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.items, (item, index2) => {
678
- return openBlock(), createElementBlock("view", {
679
- key: index2,
680
- class: normalizeClass(["indicator-item", { active: index2 === currentIndex.value }]),
681
- onClick: ($event) => currentIndex.value = index2
682
- }, null, 10, _hoisted_3$5);
683
- }), 128))
684
- ])) : createCommentVNode("", true),
685
- _ctx.showArrows ? (openBlock(), createElementBlock("view", {
686
- key: 1,
687
- class: "swiper-arrow swiper-arrow-left",
688
- onClick: prev
689
- })) : createCommentVNode("", true),
690
- _ctx.showArrows ? (openBlock(), createElementBlock("view", {
691
- key: 2,
692
- class: "swiper-arrow swiper-arrow-right",
693
- onClick: next
694
- })) : createCommentVNode("", true)
760
+ _ctx.$slots.header ? (openBlock(), createElementBlock("view", _hoisted_1$3, [
761
+ renderSlot(_ctx.$slots, "header", {}, void 0, true)
762
+ ])) : __props.title ? (openBlock(), createElementBlock("view", _hoisted_2$3, [
763
+ createElementVNode("text", _hoisted_3$3, toDisplayString(__props.title), 1)
764
+ ])) : createCommentVNode("", true),
765
+ createElementVNode("view", _hoisted_4$2, [
766
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
767
+ ]),
768
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("view", _hoisted_5$2, [
769
+ renderSlot(_ctx.$slots, "footer", {}, void 0, true)
770
+ ])) : __props.showConfirmButton || __props.showCancelButton ? (openBlock(), createElementBlock("view", _hoisted_6$2, [
771
+ __props.showCancelButton ? (openBlock(), createElementBlock("view", {
772
+ key: 0,
773
+ class: "popup-button popup-button-cancel",
774
+ onClick: handleCancel
775
+ }, toDisplayString(__props.cancelText), 1)) : createCommentVNode("", true),
776
+ __props.showConfirmButton ? (openBlock(), createElementBlock("view", {
777
+ key: 1,
778
+ class: "popup-button popup-button-confirm",
779
+ onClick: handleConfirm
780
+ }, toDisplayString(__props.confirmText), 1)) : createCommentVNode("", true)
781
+ ])) : createCommentVNode("", true),
782
+ __props.showCloseButton ? (openBlock(), createElementBlock("view", {
783
+ key: 4,
784
+ class: "popup-close-button",
785
+ onClick: handleClose
786
+ }, [..._cache[2] || (_cache[2] = [
787
+ createElementVNode("text", { class: "close-icon" }, "×", -1)
788
+ ])])) : createCommentVNode("", true)
789
+ ], 34)
790
+ ], 2)), [
791
+ [vShow, showPopup.value]
695
792
  ]);
696
793
  };
697
794
  }
698
795
  });
699
- const index$2 = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-3735cbbd"]]);
700
- const _withScopeId$1 = (n) => (pushScopeId("data-v-2e49050a"), n = n(), popScopeId(), n);
701
- const _hoisted_1$4 = { class: "sw-infinite-scroll__content" };
702
- const _hoisted_2$4 = {
703
- key: 0,
704
- class: "sw-infinite-scroll__loading"
705
- };
706
- const _hoisted_3$4 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("view", { class: "loading-spinner" }, null, -1));
707
- const _hoisted_4$3 = {
708
- key: 1,
709
- class: "sw-infinite-scroll__finished"
710
- };
711
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
712
- __name: "index",
713
- props: {
714
- loading: { type: Boolean, default: false },
715
- finished: { type: Boolean, default: false },
716
- offset: { default: 100 },
717
- loadingText: { default: "加载中..." },
718
- finishedText: { default: "没有更多了" },
719
- disabled: { type: Boolean, default: false },
720
- height: { default: "auto" }
721
- },
722
- emits: ["load"],
723
- setup(__props, { emit: __emit }) {
724
- const props = __props;
725
- const emit = __emit;
726
- const scrollContainer = ref(null);
727
- const containerStyle = computed(() => {
728
- return {
729
- height: typeof props.height === "number" ? `${props.height}px` : props.height
730
- };
731
- });
732
- function handleScroll() {
733
- if (!scrollContainer.value || props.loading || props.finished || props.disabled) {
734
- return;
735
- }
736
- const { scrollTop, scrollHeight, clientHeight } = scrollContainer.value;
737
- if (scrollHeight - scrollTop - clientHeight <= props.offset) {
738
- emit("load");
739
- }
740
- }
741
- let resizeTimeout = null;
742
- function handleResize() {
743
- if (resizeTimeout) {
744
- clearTimeout(resizeTimeout);
745
- }
746
- resizeTimeout = setTimeout(() => {
747
- handleScroll();
748
- }, 100);
749
- }
750
- onMounted(() => {
751
- handleScroll();
752
- window.addEventListener("resize", handleResize);
753
- });
754
- onUnmounted(() => {
755
- window.removeEventListener("resize", handleResize);
756
- if (resizeTimeout) {
757
- clearTimeout(resizeTimeout);
758
- }
759
- });
760
- return (_ctx, _cache) => {
761
- return openBlock(), createElementBlock("view", {
762
- ref_key: "scrollContainer",
763
- ref: scrollContainer,
764
- class: "sw-infinite-scroll",
765
- style: normalizeStyle(containerStyle.value),
766
- onScroll: handleScroll
767
- }, [
768
- createElementVNode("view", _hoisted_1$4, [
769
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
770
- ]),
771
- _ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_2$4, [
772
- _hoisted_3$4,
773
- createElementVNode("text", null, toDisplayString(_ctx.loadingText), 1)
774
- ])) : createCommentVNode("", true),
775
- _ctx.finished && !_ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_4$3, toDisplayString(_ctx.finishedText), 1)) : createCommentVNode("", true)
776
- ], 36);
777
- };
778
- }
779
- });
780
- const index$1 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2e49050a"]]);
781
- const _withScopeId = (n) => (pushScopeId("data-v-d2876eca"), n = n(), popScopeId(), n);
782
- const _hoisted_1$3 = {
796
+ const Popup = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-a8084c82"]]);
797
+ const _hoisted_1$2 = {
783
798
  key: 0,
784
799
  class: "refresh-content"
785
800
  };
786
- const _hoisted_2$3 = { class: "refresh-icon" };
787
- const _hoisted_3$3 = {
801
+ const _hoisted_2$2 = { class: "refresh-icon" };
802
+ const _hoisted_3$2 = {
788
803
  key: 0,
789
804
  class: "refresh-loading"
790
805
  };
791
- const _hoisted_4$2 = {
806
+ const _hoisted_4$1 = {
792
807
  key: 1,
793
808
  class: "refresh-arrow"
794
809
  };
@@ -799,27 +814,23 @@ const _hoisted_8$1 = {
799
814
  key: 0,
800
815
  class: "infinite-scroll-loading"
801
816
  };
802
- const _hoisted_9 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("view", { class: "loading-spinner" }, [
803
- /* @__PURE__ */ createElementVNode("text", { class: "loading-icon" }, "●")
804
- ], -1));
805
- const _hoisted_10 = { class: "loading-text" };
806
- const _hoisted_11 = {
817
+ const _hoisted_9 = { class: "loading-text" };
818
+ const _hoisted_10 = {
807
819
  key: 1,
808
820
  class: "infinite-scroll-error"
809
821
  };
810
- const _hoisted_12 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("text", { class: "error-icon" }, "×", -1));
811
- const _hoisted_13 = { class: "error-text" };
812
- const _hoisted_14 = {
822
+ const _hoisted_11 = { class: "error-text" };
823
+ const _hoisted_12 = {
813
824
  key: 2,
814
825
  class: "infinite-scroll-no-more"
815
826
  };
816
- const _hoisted_15 = { class: "no-more-text" };
817
- const _hoisted_16 = {
827
+ const _hoisted_13 = { class: "no-more-text" };
828
+ const _hoisted_14 = {
818
829
  key: 3,
819
830
  class: "infinite-scroll-trigger",
820
831
  style: { height: `0px` }
821
832
  };
822
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
833
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
823
834
  __name: "index",
824
835
  props: {
825
836
  loading: { type: Boolean, default: false },
@@ -1022,9 +1033,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1022
1033
  class: "refresh-indicator",
1023
1034
  style: normalizeStyle({ height: `${pullDistance.value}px` })
1024
1035
  }, [
1025
- refreshStatus.value !== "normal" && (refreshStatus.value === "refreshing" || pullDistance.value > 0) ? (openBlock(), createElementBlock("view", _hoisted_1$3, [
1026
- createElementVNode("view", _hoisted_2$3, [
1027
- props.refreshLoading ? (openBlock(), createElementBlock("text", _hoisted_3$3, "●")) : (openBlock(), createElementBlock("text", _hoisted_4$2, "↓"))
1036
+ refreshStatus.value !== "normal" && (refreshStatus.value === "refreshing" || pullDistance.value > 0) ? (openBlock(), createElementBlock("view", _hoisted_1$2, [
1037
+ createElementVNode("view", _hoisted_2$2, [
1038
+ props.refreshLoading ? (openBlock(), createElementBlock("text", _hoisted_3$2, "●")) : (openBlock(), createElementBlock("text", _hoisted_4$1, "↓"))
1028
1039
  ]),
1029
1040
  createElementVNode("text", _hoisted_5$1, [
1030
1041
  props.refreshLoading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
@@ -1041,340 +1052,331 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1041
1052
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
1042
1053
  ]),
1043
1054
  createElementVNode("view", _hoisted_7$1, [
1044
- _ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_8$1, [
1045
- _hoisted_9,
1046
- createElementVNode("text", _hoisted_10, toDisplayString(_ctx.loadingText), 1)
1047
- ])) : _ctx.error ? (openBlock(), createElementBlock("view", _hoisted_11, [
1048
- _hoisted_12,
1049
- createElementVNode("text", _hoisted_13, toDisplayString(_ctx.errorText), 1),
1055
+ __props.loading ? (openBlock(), createElementBlock("view", _hoisted_8$1, [
1056
+ _cache[1] || (_cache[1] = createElementVNode("view", { class: "loading-spinner" }, [
1057
+ createElementVNode("text", { class: "loading-icon" }, "●")
1058
+ ], -1)),
1059
+ createElementVNode("text", _hoisted_9, toDisplayString(__props.loadingText), 1)
1060
+ ])) : __props.error ? (openBlock(), createElementBlock("view", _hoisted_10, [
1061
+ _cache[2] || (_cache[2] = createElementVNode("text", { class: "error-icon" }, "×", -1)),
1062
+ createElementVNode("text", _hoisted_11, toDisplayString(__props.errorText), 1),
1050
1063
  createElementVNode("view", {
1051
1064
  class: "retry-btn",
1052
1065
  onClick: onRetry
1053
- }, toDisplayString(_ctx.retryText), 1)
1054
- ])) : !_ctx.hasMore ? (openBlock(), createElementBlock("view", _hoisted_14, [
1055
- createElementVNode("text", _hoisted_15, toDisplayString(_ctx.noMoreText), 1)
1056
- ])) : (openBlock(), createElementBlock("view", _hoisted_16))
1066
+ }, toDisplayString(__props.retryText), 1)
1067
+ ])) : !__props.hasMore ? (openBlock(), createElementBlock("view", _hoisted_12, [
1068
+ createElementVNode("text", _hoisted_13, toDisplayString(__props.noMoreText), 1)
1069
+ ])) : (openBlock(), createElementBlock("view", _hoisted_14))
1057
1070
  ])
1058
1071
  ], 544);
1059
1072
  };
1060
1073
  }
1061
1074
  });
1062
- const index = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-d2876eca"]]);
1063
- function useDropdownSelect(props, emit) {
1064
- const isOpen = ref(false);
1065
- const displayText = computed(() => {
1066
- var _a, _b;
1067
- if (!((_a = props.options) == null ? void 0 : _a.length)) {
1068
- return "请选择";
1069
- }
1070
- if (props.modelValue !== void 0 && props.modelValue !== null) {
1071
- const matched = props.options.find(
1072
- (opt) => opt.value === props.modelValue
1073
- );
1074
- if (matched)
1075
- return matched.text;
1076
- }
1077
- return ((_b = props.options[0]) == null ? void 0 : _b.text) || "请选择";
1078
- });
1079
- const internalValue = computed({
1080
- get() {
1081
- var _a, _b;
1082
- if (props.modelValue !== void 0 && props.modelValue !== null) {
1083
- return props.modelValue;
1084
- }
1085
- return ((_b = (_a = props.options) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) ?? "";
1086
- },
1087
- set(val) {
1088
- emit("update:modelValue", val);
1089
- }
1090
- });
1091
- const handleChange = (value) => {
1092
- emit("change", value);
1093
- };
1094
- const handleOpen = () => {
1095
- isOpen.value = true;
1096
- };
1097
- const handleClose = () => {
1098
- isOpen.value = false;
1099
- };
1100
- return {
1101
- displayText,
1102
- internalValue,
1103
- isOpen,
1104
- handleChange,
1105
- handleOpen,
1106
- handleClose
1107
- };
1108
- }
1109
- const _hoisted_1$2 = { class: "dropdown-select" };
1110
- const _hoisted_2$2 = { class: "dropdown-title" };
1111
- const _hoisted_3$2 = { class: "dropdown-text" };
1112
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1075
+ const PullRefresh = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-b591b189"]]);
1076
+ const _hoisted_1$1 = { class: "sw-swiper" };
1077
+ const _hoisted_2$1 = {
1078
+ key: 0,
1079
+ class: "swiper-indicators"
1080
+ };
1081
+ const _hoisted_3$1 = ["onClick"];
1082
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1113
1083
  __name: "index",
1114
1084
  props: {
1115
- modelValue: {},
1116
- iconName: { default: "arrow-down" },
1117
- options: {}
1085
+ items: {},
1086
+ initialIndex: { default: 0 },
1087
+ autoPlay: { type: Boolean, default: true },
1088
+ interval: { default: 3e3 },
1089
+ duration: { default: 300 },
1090
+ showIndicators: { type: Boolean, default: true },
1091
+ showArrows: { type: Boolean, default: false },
1092
+ loop: { type: Boolean, default: true }
1118
1093
  },
1119
- emits: ["update:modelValue", "change"],
1120
- setup(__props, { emit: __emit }) {
1094
+ emits: ["change", "prev", "next"],
1095
+ setup(__props, { expose: __expose, emit: __emit }) {
1121
1096
  const props = __props;
1122
1097
  const emit = __emit;
1123
- const { displayText, internalValue, handleChange, handleOpen, handleClose } = useDropdownSelect(props, emit);
1124
- const isOpen = ref(false);
1125
- const selectedIndex = computed(() => {
1126
- if (!props.options || !props.options.length)
1127
- return 0;
1128
- return props.options.findIndex((opt) => opt.value === internalValue.value);
1129
- });
1130
- function togglePicker() {
1131
- isOpen.value = !isOpen.value;
1132
- if (isOpen.value) {
1133
- handleOpen();
1134
- } else {
1135
- handleClose();
1098
+ const currentIndex = ref(props.initialIndex);
1099
+ let timer = null;
1100
+ function startAutoPlay() {
1101
+ if (props.autoPlay && props.items.length > 1) {
1102
+ timer = setInterval(() => {
1103
+ next();
1104
+ }, props.interval);
1136
1105
  }
1137
1106
  }
1138
- function onPickerChange(e) {
1139
- const index2 = e.detail.value;
1140
- const selectedOption = props.options[index2];
1141
- handleChange(selectedOption.value);
1142
- isOpen.value = false;
1143
- handleClose();
1107
+ function stopAutoPlay() {
1108
+ if (timer) {
1109
+ clearInterval(timer);
1110
+ timer = null;
1111
+ }
1144
1112
  }
1145
- function onPickerCancel() {
1146
- isOpen.value = false;
1147
- handleClose();
1113
+ function prev() {
1114
+ if (props.loop) {
1115
+ currentIndex.value = currentIndex.value === 0 ? props.items.length - 1 : currentIndex.value - 1;
1116
+ } else if (currentIndex.value > 0) {
1117
+ currentIndex.value--;
1118
+ }
1119
+ emit("prev", currentIndex.value);
1120
+ emit("change", currentIndex.value);
1121
+ }
1122
+ function next() {
1123
+ if (props.loop) {
1124
+ currentIndex.value = currentIndex.value === props.items.length - 1 ? 0 : currentIndex.value + 1;
1125
+ } else if (currentIndex.value < props.items.length - 1) {
1126
+ currentIndex.value++;
1127
+ }
1128
+ emit("next", currentIndex.value);
1129
+ emit("change", currentIndex.value);
1148
1130
  }
1131
+ watch(() => props.items, (newItems) => {
1132
+ if (newItems.length < currentIndex.value + 1) {
1133
+ currentIndex.value = Math.min(currentIndex.value, newItems.length - 1);
1134
+ }
1135
+ stopAutoPlay();
1136
+ startAutoPlay();
1137
+ }, { deep: true });
1138
+ watch(() => props.autoPlay, (autoPlay) => {
1139
+ if (autoPlay) {
1140
+ startAutoPlay();
1141
+ } else {
1142
+ stopAutoPlay();
1143
+ }
1144
+ });
1145
+ onMounted(() => {
1146
+ startAutoPlay();
1147
+ });
1148
+ onUnmounted(() => {
1149
+ stopAutoPlay();
1150
+ });
1151
+ __expose({
1152
+ prev,
1153
+ next,
1154
+ currentIndex
1155
+ });
1149
1156
  return (_ctx, _cache) => {
1150
- const _component_picker = resolveComponent("picker");
1151
- return openBlock(), createElementBlock("view", _hoisted_1$2, [
1157
+ return openBlock(), createElementBlock("view", _hoisted_1$1, [
1152
1158
  createElementVNode("view", {
1153
- class: "dropdown-trigger",
1154
- onTap: togglePicker
1159
+ class: "swiper-wrapper",
1160
+ style: normalizeStyle({
1161
+ transform: `translateX(-${currentIndex.value * 100}%)`,
1162
+ transition: `transform ${__props.duration}ms ease`
1163
+ })
1155
1164
  }, [
1156
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ text: unref(displayText) })), () => [
1157
- createElementVNode("view", _hoisted_2$2, [
1158
- createElementVNode("text", _hoisted_3$2, toDisplayString(unref(displayText)), 1),
1159
- createElementVNode("text", {
1160
- class: normalizeClass(["dropdown-icon", { "is-active": isOpen.value }])
1161
- }, [
1162
- renderSlot(_ctx.$slots, "icon", {}, () => [
1163
- createElementVNode("view", {
1164
- class: normalizeClass(["uni-icon", _ctx.iconName])
1165
- }, null, 2)
1166
- ])
1167
- ], 2)
1168
- ])
1169
- ])
1170
- ], 32),
1171
- isOpen.value ? (openBlock(), createBlock(_component_picker, {
1172
- key: 0,
1173
- mode: "selector",
1174
- range: _ctx.options,
1175
- "range-key": "text",
1176
- value: selectedIndex.value,
1177
- class: "dropdown-picker",
1178
- onChange: onPickerChange,
1179
- onCancel: onPickerCancel
1180
- }, null, 8, ["range", "value"])) : createCommentVNode("", true)
1165
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index2) => {
1166
+ return openBlock(), createElementBlock("view", {
1167
+ key: index2,
1168
+ class: "swiper-item"
1169
+ }, [
1170
+ renderSlot(_ctx.$slots, "default", {
1171
+ item,
1172
+ index: index2
1173
+ }, void 0, true)
1174
+ ]);
1175
+ }), 128))
1176
+ ], 4),
1177
+ __props.showIndicators ? (openBlock(), createElementBlock("view", _hoisted_2$1, [
1178
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index2) => {
1179
+ return openBlock(), createElementBlock("view", {
1180
+ key: index2,
1181
+ class: normalizeClass(["indicator-item", { active: index2 === currentIndex.value }]),
1182
+ onClick: ($event) => currentIndex.value = index2
1183
+ }, null, 10, _hoisted_3$1);
1184
+ }), 128))
1185
+ ])) : createCommentVNode("", true),
1186
+ __props.showArrows ? (openBlock(), createElementBlock("view", {
1187
+ key: 1,
1188
+ class: "swiper-arrow swiper-arrow-left",
1189
+ onClick: prev
1190
+ })) : createCommentVNode("", true),
1191
+ __props.showArrows ? (openBlock(), createElementBlock("view", {
1192
+ key: 2,
1193
+ class: "swiper-arrow swiper-arrow-right",
1194
+ onClick: next
1195
+ })) : createCommentVNode("", true)
1181
1196
  ]);
1182
1197
  };
1183
1198
  }
1184
1199
  });
1185
- function useDropdownWithBadge(props) {
1186
- const hasBadge = computed(() => {
1187
- return props.hideBadge(props.modelValue);
1188
- });
1189
- return { hasBadge };
1190
- }
1191
- const _hoisted_1$1 = { class: "dropdown-title" };
1192
- const _hoisted_2$1 = { class: "dropdown-text" };
1193
- const _hoisted_3$1 = { class: "dropdown-icon" };
1194
- const _hoisted_4$1 = { class: "dropdown-with-badge__dot" };
1195
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1196
- __name: "index",
1197
- props: {
1198
- hideBadge: { type: Function, default: (modelValue) => modelValue === "" || modelValue === null || modelValue === void 0 }
1199
- },
1200
- emits: ["update:modelValue", "change"],
1201
- setup(__props, { emit: __emit }) {
1202
- const props = __props;
1203
- const emit = __emit;
1204
- const { hasBadge } = useDropdownWithBadge(props);
1205
- return (_ctx, _cache) => {
1206
- return openBlock(), createBlock(unref(_sfc_main$2), mergeProps({ modelValue: _ctx.modelValue, options: _ctx.options }, { class: "dropdown-with-badge" }, toHandlers(emit)), {
1207
- default: withCtx(({ text }) => [
1208
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ text })), () => [
1209
- createElementVNode("view", _hoisted_1$1, [
1210
- createElementVNode("text", _hoisted_2$1, toDisplayString(text), 1),
1211
- createElementVNode("text", _hoisted_3$1, [
1212
- renderSlot(_ctx.$slots, "icon", {}, () => [
1213
- createElementVNode("view", {
1214
- class: normalizeClass(["uni-icon", _ctx.iconName])
1215
- }, null, 2)
1216
- ])
1217
- ])
1218
- ]),
1219
- withDirectives(createElementVNode("text", _hoisted_4$1, null, 512), [
1220
- [vShow, !unref(hasBadge)]
1221
- ])
1222
- ])
1223
- ]),
1224
- _: 3
1225
- }, 16);
1226
- };
1227
- }
1228
- });
1229
- function useHasBadge(model) {
1230
- if (!model) {
1231
- return computed(() => false);
1232
- }
1233
- if (typeof model === "function") {
1234
- return computed(() => model());
1235
- }
1236
- if (isRef(model)) {
1237
- return computed(() => {
1238
- if (!model.value)
1239
- return false;
1240
- const obj = model.value;
1241
- for (const key in obj) {
1242
- if (obj[key]) {
1243
- return true;
1244
- }
1245
- }
1246
- return false;
1247
- });
1248
- }
1249
- return computed(() => {
1250
- for (const key in model) {
1251
- const val = model[key];
1252
- if (val) {
1253
- return true;
1254
- }
1255
- }
1256
- return false;
1257
- });
1258
- }
1259
- function useFilterDrawer(props, emit) {
1260
- const visible = ref(false);
1261
- const hasBadge = useHasBadge(props.modelValue);
1262
- const openDrawer = () => {
1263
- visible.value = true;
1264
- };
1265
- const closeDrawer = () => {
1266
- visible.value = false;
1267
- };
1268
- const resetDrawer = () => {
1269
- emit("reset");
1270
- closeDrawer();
1271
- };
1272
- const queryDrawer = () => {
1273
- emit("query");
1274
- closeDrawer();
1275
- };
1276
- return {
1277
- visible,
1278
- openDrawer,
1279
- closeDrawer,
1280
- resetDrawer,
1281
- queryDrawer,
1282
- hasBadge
1283
- };
1284
- }
1285
- const _hoisted_1 = /* @__PURE__ */ createElementVNode("view", { class: "uni-icon icon-filter-o" }, null, -1);
1200
+ const Swiper = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4f860ae8"]]);
1201
+ const _hoisted_1 = {
1202
+ key: 0,
1203
+ class: "sw-toast__loading"
1204
+ };
1286
1205
  const _hoisted_2 = {
1287
1206
  key: 0,
1288
- class: "filter-drawer__badge-dot"
1207
+ class: "sw-toast__spinner"
1289
1208
  };
1290
1209
  const _hoisted_3 = {
1291
1210
  key: 1,
1292
- class: "filter-drawer__popup",
1293
- style: { height: "100vh", width: "100vw" }
1211
+ class: "sw-toast__custom-icon"
1212
+ };
1213
+ const _hoisted_4 = {
1214
+ key: 1,
1215
+ class: "sw-toast__icon"
1216
+ };
1217
+ const _hoisted_5 = {
1218
+ key: 0,
1219
+ class: "sw-toast__icon--success"
1220
+ };
1221
+ const _hoisted_6 = {
1222
+ key: 1,
1223
+ class: "sw-toast__icon--fail"
1224
+ };
1225
+ const _hoisted_7 = {
1226
+ key: 2,
1227
+ class: "sw-toast__custom-icon"
1228
+ };
1229
+ const _hoisted_8 = {
1230
+ key: 2,
1231
+ class: "sw-toast__text"
1294
1232
  };
1295
- const _hoisted_4 = { class: "filter-drawer" };
1296
- const _hoisted_5 = { class: "filter-drawer__header" };
1297
- const _hoisted_6 = /* @__PURE__ */ createElementVNode("text", { class: "filter-drawer__title" }, "筛选", -1);
1298
- const _hoisted_7 = { class: "filter-drawer__body" };
1299
- const _hoisted_8 = { class: "filter-drawer__footer" };
1300
1233
  const _sfc_main = /* @__PURE__ */ defineComponent({
1301
1234
  __name: "index",
1302
1235
  props: {
1303
- hasBadge: { type: Boolean, default: false },
1304
- modelValue: {}
1236
+ modelValue: { type: Boolean, default: false },
1237
+ type: { default: "text" },
1238
+ position: { default: "middle" },
1239
+ message: { default: "" },
1240
+ duration: { default: 3e3 },
1241
+ loading: { type: Boolean, default: false },
1242
+ icon: { type: Boolean, default: true },
1243
+ customIcon: { default: "" },
1244
+ large: { type: Boolean, default: false },
1245
+ customStyle: { default: () => ({}) }
1305
1246
  },
1306
- emits: ["reset", "query"],
1307
- setup(__props, { emit: __emit }) {
1247
+ emits: ["update:modelValue", "close", "click"],
1248
+ setup(__props, { expose: __expose, emit: __emit }) {
1308
1249
  const props = __props;
1309
1250
  const emit = __emit;
1310
- const { visible, openDrawer, closeDrawer, resetDrawer, queryDrawer, hasBadge } = useFilterDrawer(props, emit);
1251
+ const toastRef = ref(null);
1252
+ let timer = null;
1253
+ const showToast = ref(props.modelValue);
1254
+ const isClosing = ref(false);
1255
+ const showIcon = computed(() => {
1256
+ if (props.loading)
1257
+ return true;
1258
+ if (props.type === "text")
1259
+ return props.icon;
1260
+ return true;
1261
+ });
1262
+ function onClick() {
1263
+ emit("click");
1264
+ }
1265
+ function close() {
1266
+ if (!showToast.value)
1267
+ return;
1268
+ isClosing.value = true;
1269
+ emit("close");
1270
+ }
1271
+ function startTimer() {
1272
+ clearTimer();
1273
+ if (props.duration > 0 && !props.loading) {
1274
+ timer = setTimeout(() => {
1275
+ close();
1276
+ }, props.duration);
1277
+ }
1278
+ }
1279
+ function clearTimer() {
1280
+ if (timer) {
1281
+ clearTimeout(timer);
1282
+ timer = null;
1283
+ }
1284
+ }
1285
+ function handleTransitionEnd() {
1286
+ if (isClosing.value) {
1287
+ showToast.value = false;
1288
+ isClosing.value = false;
1289
+ emit("update:modelValue", false);
1290
+ }
1291
+ }
1292
+ watch(() => props.modelValue, (newVal) => {
1293
+ if (newVal) {
1294
+ showToast.value = true;
1295
+ isClosing.value = false;
1296
+ startTimer();
1297
+ } else {
1298
+ close();
1299
+ }
1300
+ });
1301
+ watch(() => props.message, () => {
1302
+ if (showToast.value && !props.loading) {
1303
+ startTimer();
1304
+ }
1305
+ });
1306
+ onMounted(() => {
1307
+ if (props.modelValue) {
1308
+ startTimer();
1309
+ }
1310
+ });
1311
+ onUnmounted(() => {
1312
+ clearTimer();
1313
+ });
1314
+ __expose({
1315
+ /**
1316
+ * 手动关闭Toast
1317
+ */
1318
+ close
1319
+ });
1311
1320
  return (_ctx, _cache) => {
1312
- return openBlock(), createElementBlock(Fragment, null, [
1313
- createElementVNode("view", {
1314
- class: "filter-drawer__trigger",
1315
- onClick: _cache[0] || (_cache[0] = //@ts-ignore
1316
- (...args) => unref(openDrawer) && unref(openDrawer)(...args))
1317
- }, [
1318
- renderSlot(_ctx.$slots, "trigger", {}, () => [
1319
- _hoisted_1
1320
- ]),
1321
- unref(hasBadge) ? (openBlock(), createElementBlock("text", _hoisted_2)) : createCommentVNode("", true)
1322
- ]),
1323
- unref(visible) ? (openBlock(), createElementBlock("view", {
1324
- key: 0,
1325
- class: "filter-drawer__popup-mask",
1326
- onClick: _cache[1] || (_cache[1] = //@ts-ignore
1327
- (...args) => unref(closeDrawer) && unref(closeDrawer)(...args))
1328
- })) : createCommentVNode("", true),
1329
- unref(visible) ? (openBlock(), createElementBlock("view", _hoisted_3, [
1330
- createElementVNode("view", {
1331
- class: "filter-drawer__close",
1332
- onClick: _cache[2] || (_cache[2] = //@ts-ignore
1333
- (...args) => unref(closeDrawer) && unref(closeDrawer)(...args))
1334
- }, " × "),
1335
- createElementVNode("view", _hoisted_4, [
1336
- createElementVNode("view", _hoisted_5, [
1337
- renderSlot(_ctx.$slots, "header", {}, () => [
1338
- _hoisted_6
1339
- ])
1340
- ]),
1341
- createElementVNode("view", _hoisted_7, [
1342
- renderSlot(_ctx.$slots, "default")
1343
- ]),
1344
- createElementVNode("view", _hoisted_8, [
1345
- renderSlot(_ctx.$slots, "footer", {}, () => [
1346
- createElementVNode("view", {
1347
- class: "filter-drawer__button filter-drawer__button--plain",
1348
- onClick: _cache[3] || (_cache[3] = //@ts-ignore
1349
- (...args) => unref(resetDrawer) && unref(resetDrawer)(...args))
1350
- }, " 重置条件 "),
1351
- createElementVNode("view", {
1352
- class: "filter-drawer__button",
1353
- onClick: _cache[4] || (_cache[4] = //@ts-ignore
1354
- (...args) => unref(queryDrawer) && unref(queryDrawer)(...args))
1355
- }, " 查询 ")
1356
- ])
1357
- ])
1358
- ])
1359
- ])) : createCommentVNode("", true)
1360
- ], 64);
1321
+ return withDirectives((openBlock(), createElementBlock("view", {
1322
+ ref_key: "toastRef",
1323
+ ref: toastRef,
1324
+ class: normalizeClass(["sw-toast", [
1325
+ `sw-toast--${__props.type}`,
1326
+ `sw-toast--${__props.position}`,
1327
+ { "sw-toast--large": __props.large },
1328
+ { "sw-toast--text": !showIcon.value && __props.type === "text" },
1329
+ { "sw-toast--show": showToast.value && !isClosing.value },
1330
+ { "sw-toast--hide": showToast.value && isClosing.value }
1331
+ ]]),
1332
+ style: normalizeStyle(__props.customStyle),
1333
+ onClick,
1334
+ onTransitionend: handleTransitionEnd
1335
+ }, [
1336
+ __props.loading ? (openBlock(), createElementBlock("view", _hoisted_1, [
1337
+ !__props.customIcon ? (openBlock(), createElementBlock("text", _hoisted_2)) : (openBlock(), createElementBlock("text", _hoisted_3, toDisplayString(__props.customIcon), 1))
1338
+ ])) : showIcon.value ? (openBlock(), createElementBlock("view", _hoisted_4, [
1339
+ __props.type === "success" ? (openBlock(), createElementBlock("text", _hoisted_5, "✓")) : __props.type === "fail" ? (openBlock(), createElementBlock("text", _hoisted_6, "✗")) : __props.customIcon ? (openBlock(), createElementBlock("text", _hoisted_7, toDisplayString(__props.customIcon), 1)) : createCommentVNode("", true)
1340
+ ])) : createCommentVNode("", true),
1341
+ __props.message ? (openBlock(), createElementBlock("text", _hoisted_8, toDisplayString(__props.message), 1)) : createCommentVNode("", true)
1342
+ ], 38)), [
1343
+ [vShow, showToast.value]
1344
+ ]);
1361
1345
  };
1362
1346
  }
1363
1347
  });
1348
+ const Toast = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-482db7a0"]]);
1349
+ const index = {
1350
+ Button,
1351
+ Dialog,
1352
+ Divider,
1353
+ useDropdownSelect,
1354
+ DropdownSelect: _sfc_main$7,
1355
+ useDropdownWithBadge,
1356
+ DropdownWithBadge: _sfc_main$6,
1357
+ FilterDrawer: _sfc_main$5,
1358
+ useFilterDrawer,
1359
+ InfiniteScroll,
1360
+ Popup,
1361
+ PullRefresh,
1362
+ Swiper,
1363
+ Toast
1364
+ };
1364
1365
  export {
1365
- index$7 as Button,
1366
- index$6 as Dialog,
1367
- index$5 as Divider,
1368
- _sfc_main$2 as DropdownSelect,
1369
- _sfc_main$1 as DropdownWithBadge,
1370
- _sfc_main as FilterDrawer,
1371
- index$1 as InfiniteScroll,
1372
- index$4 as Popup,
1373
- index as PullRefresh,
1374
- index$2 as Swiper,
1375
- index$3 as Toast,
1366
+ Button,
1367
+ Dialog,
1368
+ Divider,
1369
+ _sfc_main$7 as DropdownSelect,
1370
+ _sfc_main$6 as DropdownWithBadge,
1371
+ _sfc_main$5 as FilterDrawer,
1372
+ InfiniteScroll,
1373
+ Popup,
1374
+ PullRefresh,
1375
+ Swiper,
1376
+ Toast,
1377
+ index as default,
1376
1378
  useDropdownSelect,
1377
1379
  useDropdownWithBadge,
1378
1380
  useFilterDrawer
1379
1381
  };
1380
- //# sourceMappingURL=index.es.js.map
1382
+ //# sourceMappingURL=index.mjs.map