zartui 3.1.84 → 3.1.86

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/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.84";
88
+ export const version: "3.1.86";
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.84";
187
+ const version = "3.1.86";
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, {