zartui 3.1.85 → 3.1.87

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.
@@ -195,9 +195,13 @@ var stdin_default = defineComponent({
195
195
  const isStrValid = (text) => {
196
196
  return text !== null && text !== "" && Object.prototype.toString.call(text) === "[object String]";
197
197
  };
198
+ const showSearchPopup = () => {
199
+ updateOffset();
200
+ show.value = true;
201
+ };
198
202
  const onSearch = (value2) => {
199
203
  if (isStrValid(value2)) {
200
- show.value = true;
204
+ showSearchPopup();
201
205
  }
202
206
  };
203
207
  const onClickInput = (e) => {
@@ -445,7 +449,7 @@ var stdin_default = defineComponent({
445
449
  "onClickInput": onClickInput,
446
450
  "onSearch": onSearch,
447
451
  "onClear": clearSearch,
448
- "onFocus": () => show.value = true,
452
+ "onFocus": showSearchPopup,
449
453
  "autocomplete": "off"
450
454
  }, null), _withDirectives(_createVNode("div", {
451
455
  "class": [bem("wrap")],
package/es/index.d.ts CHANGED
@@ -85,4 +85,4 @@ declare namespace _default {
85
85
  }
86
86
  export default _default;
87
87
  export function install(app: any): void;
88
- export const version: "3.1.85";
88
+ export const version: "3.1.87";
package/es/index.mjs CHANGED
@@ -78,7 +78,7 @@ import { Timeline } from "./timeline/index.mjs";
78
78
  import { Toast } from "./toast/index.mjs";
79
79
  import { Uploader } from "./uploader/index.mjs";
80
80
  import { Video } from "./video/index.mjs";
81
- const version = "3.1.85";
81
+ const version = "3.1.87";
82
82
  function install(app) {
83
83
  const components = [
84
84
  ActionSheet,
@@ -20,7 +20,7 @@ var __async = (__this, __arguments, generator) => {
20
20
  };
21
21
  import { createVNode as _createVNode, mergeProps as _mergeProps, vShow as _vShow, withDirectives as _withDirectives } from "vue";
22
22
  import { createNamespace, isDef, isWeixin, makeArrayProp, makeNumberProp, makeStringProp, truthProp } from "../utils/index.mjs";
23
- import { computed, defineComponent, ref, watch } from "vue";
23
+ import { computed, defineComponent, nextTick, onBeforeUnmount, ref, watch } from "vue";
24
24
  import { showFailToast, showLoadingToast, closeToast } from "../toast/index.mjs";
25
25
  import DeleteIcon from "./image/DeleteIcon.mjs";
26
26
  import { fileTypeFromBuffer } from "file-type";
@@ -147,11 +147,29 @@ var stdin_default = defineComponent({
147
147
  const gridRef = ref();
148
148
  const mediaListPlaceholder = ref([]);
149
149
  const sort = ref();
150
- watch(() => props.mediaList.length, () => {
150
+ const shouldIsolateSortableTouch = () => props.sortable && props.mediaList.length > 0;
151
+ const stopSortableTouchStartPropagation = (event) => {
152
+ if (!shouldIsolateSortableTouch()) {
153
+ return;
154
+ }
155
+ event.stopPropagation();
156
+ };
157
+ const destroySortable = () => {
158
+ var _a;
159
+ if ((_a = sort.value) == null ? void 0 : _a.destroy) {
160
+ sort.value.destroy();
161
+ }
162
+ sort.value = void 0;
163
+ };
164
+ const initSortable = () => __async(this, null, function* () {
151
165
  var _a;
152
- if (sort.value || !props.sortable)
166
+ if (sort.value || !props.sortable || !props.mediaList.length)
153
167
  return;
154
- sort.value = Sortable.create((_a = gridRef.value) == null ? void 0 : _a.$el, {
168
+ yield nextTick();
169
+ const gridEl = (_a = gridRef.value) == null ? void 0 : _a.$el;
170
+ if (!gridEl)
171
+ return;
172
+ sort.value = Sortable.create(gridEl, {
155
173
  animation: 200,
156
174
  handle: ".zt-grid-item",
157
175
  onEnd: (evt) => {
@@ -882,6 +900,18 @@ var stdin_default = defineComponent({
882
900
  actionVisible.value = false;
883
901
  action.func && action.func();
884
902
  };
903
+ watch(() => [props.sortable, props.mediaList.length], (_0) => __async(this, [_0], function* ([sortable, mediaCount]) {
904
+ if (!sortable || !mediaCount) {
905
+ destroySortable();
906
+ return;
907
+ }
908
+ yield initSortable();
909
+ }), {
910
+ immediate: true
911
+ });
912
+ onBeforeUnmount(() => {
913
+ destroySortable();
914
+ });
885
915
  useExpose({
886
916
  mediaPickAction,
887
917
  handleInputFiles,
@@ -919,7 +949,8 @@ var stdin_default = defineComponent({
919
949
  "border": false,
920
950
  "square": true,
921
951
  "gutter": "4",
922
- "class": bem("grid")
952
+ "class": bem("grid"),
953
+ "onTouchstart": stopSortableTouchStartPropagation
923
954
  }, {
924
955
  default: () => [renderMediaList()]
925
956
  }), [[_vShow, props.mediaList.length]]), _withDirectives(_createVNode(ZtGrid, {
@@ -227,9 +227,13 @@ var stdin_default = (0, import_vue.defineComponent)({
227
227
  const isStrValid = (text) => {
228
228
  return text !== null && text !== "" && Object.prototype.toString.call(text) === "[object String]";
229
229
  };
230
+ const showSearchPopup = () => {
231
+ updateOffset();
232
+ show.value = true;
233
+ };
230
234
  const onSearch = (value2) => {
231
235
  if (isStrValid(value2)) {
232
- show.value = true;
236
+ showSearchPopup();
233
237
  }
234
238
  };
235
239
  const onClickInput = (e) => {
@@ -477,7 +481,7 @@ var stdin_default = (0, import_vue.defineComponent)({
477
481
  "onClickInput": onClickInput,
478
482
  "onSearch": onSearch,
479
483
  "onClear": clearSearch,
480
- "onFocus": () => show.value = true,
484
+ "onFocus": showSearchPopup,
481
485
  "autocomplete": "off"
482
486
  }, null), (0, import_vue.withDirectives)((0, import_vue.createVNode)("div", {
483
487
  "class": [bem("wrap")],
package/lib/index.d.ts CHANGED
@@ -85,4 +85,4 @@ declare namespace _default {
85
85
  }
86
86
  export default _default;
87
87
  export function install(app: any): void;
88
- export const version: "3.1.85";
88
+ export const version: "3.1.87";
package/lib/index.js CHANGED
@@ -184,7 +184,7 @@ __reExport(stdin_exports, require("./timeline"), module.exports);
184
184
  __reExport(stdin_exports, require("./toast"), module.exports);
185
185
  __reExport(stdin_exports, require("./uploader"), module.exports);
186
186
  __reExport(stdin_exports, require("./video"), module.exports);
187
- const version = "3.1.85";
187
+ const version = "3.1.87";
188
188
  function install(app) {
189
189
  const components = [
190
190
  import_action_sheet.ActionSheet,
@@ -179,11 +179,29 @@ var stdin_default = (0, import_vue2.defineComponent)({
179
179
  const gridRef = (0, import_vue2.ref)();
180
180
  const mediaListPlaceholder = (0, import_vue2.ref)([]);
181
181
  const sort = (0, import_vue2.ref)();
182
- (0, import_vue2.watch)(() => props.mediaList.length, () => {
182
+ const shouldIsolateSortableTouch = () => props.sortable && props.mediaList.length > 0;
183
+ const stopSortableTouchStartPropagation = (event) => {
184
+ if (!shouldIsolateSortableTouch()) {
185
+ return;
186
+ }
187
+ event.stopPropagation();
188
+ };
189
+ const destroySortable = () => {
190
+ var _a;
191
+ if ((_a = sort.value) == null ? void 0 : _a.destroy) {
192
+ sort.value.destroy();
193
+ }
194
+ sort.value = void 0;
195
+ };
196
+ const initSortable = () => __async(this, null, function* () {
183
197
  var _a;
184
- if (sort.value || !props.sortable)
198
+ if (sort.value || !props.sortable || !props.mediaList.length)
185
199
  return;
186
- sort.value = import_sortablejs.default.create((_a = gridRef.value) == null ? void 0 : _a.$el, {
200
+ yield (0, import_vue2.nextTick)();
201
+ const gridEl = (_a = gridRef.value) == null ? void 0 : _a.$el;
202
+ if (!gridEl)
203
+ return;
204
+ sort.value = import_sortablejs.default.create(gridEl, {
187
205
  animation: 200,
188
206
  handle: ".zt-grid-item",
189
207
  onEnd: (evt) => {
@@ -914,6 +932,18 @@ var stdin_default = (0, import_vue2.defineComponent)({
914
932
  actionVisible.value = false;
915
933
  action.func && action.func();
916
934
  };
935
+ (0, import_vue2.watch)(() => [props.sortable, props.mediaList.length], (_0) => __async(this, [_0], function* ([sortable, mediaCount]) {
936
+ if (!sortable || !mediaCount) {
937
+ destroySortable();
938
+ return;
939
+ }
940
+ yield initSortable();
941
+ }), {
942
+ immediate: true
943
+ });
944
+ (0, import_vue2.onBeforeUnmount)(() => {
945
+ destroySortable();
946
+ });
917
947
  (0, import_use_expose.useExpose)({
918
948
  mediaPickAction,
919
949
  handleInputFiles,
@@ -951,7 +981,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
951
981
  "border": false,
952
982
  "square": true,
953
983
  "gutter": "4",
954
- "class": bem("grid")
984
+ "class": bem("grid"),
985
+ "onTouchstart": stopSortableTouchStartPropagation
955
986
  }, {
956
987
  default: () => [renderMediaList()]
957
988
  }), [[import_vue.vShow, props.mediaList.length]]), (0, import_vue.withDirectives)((0, import_vue.createVNode)(import_grid.default, {