jky-component-lib 0.0.94 → 0.0.96

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.
@@ -28,6 +28,7 @@ declare const __VLS_component: import('vue').DefineComponent<AMapMarkerProps, {
28
28
  draggable: boolean;
29
29
  visible: boolean;
30
30
  updateMode: "incremental" | "full";
31
+ cluster: boolean;
31
32
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
32
33
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
33
34
  export default _default;
@@ -31,13 +31,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
31
31
  icon: {},
32
32
  offset: {},
33
33
  visible: { type: Boolean, default: true },
34
- updateMode: { default: "full" }
34
+ updateMode: { default: "full" },
35
+ cluster: { type: Boolean, default: false },
36
+ clusterOptions: {}
35
37
  },
36
38
  emits: ["click", "dragend", "mouseover", "mouseout"],
37
39
  setup(__props, { expose: __expose, emit: __emit }) {
38
40
  const props = __props;
39
41
  const emit = __emit;
40
42
  const markers = ref([]);
43
+ const clusterManager = ref(null);
41
44
  const amapContext = inject("amapContext", null);
42
45
  const mapInstance = (amapContext == null ? void 0 : amapContext.getMapInstance()) || null;
43
46
  const contentCleanupFns = /* @__PURE__ */ new WeakMap();
@@ -47,6 +50,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
47
50
  render(vnode, container);
48
51
  return container.firstElementChild || container;
49
52
  }
53
+ function createClusterManager() {
54
+ const AMap = window.AMap;
55
+ if (!AMap || !mapInstance)
56
+ return;
57
+ if (clusterManager.value) {
58
+ clusterManager.value.clearMarkers();
59
+ clusterManager.value = null;
60
+ }
61
+ const options = {
62
+ map: mapInstance
63
+ };
64
+ if (props.clusterOptions) {
65
+ Object.assign(options, props.clusterOptions);
66
+ }
67
+ clusterManager.value = new AMap.MarkerCluster(options);
68
+ }
50
69
  function createMarker(data) {
51
70
  const AMap = window.AMap;
52
71
  if (!AMap || !mapInstance) {
@@ -126,7 +145,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
126
145
  cleanupFn();
127
146
  contentCleanupFns.delete(marker);
128
147
  }
129
- mapInstance == null ? void 0 : mapInstance.remove(marker);
148
+ if (props.cluster && clusterManager.value) {
149
+ clusterManager.value.removeMarker(marker);
150
+ } else {
151
+ mapInstance == null ? void 0 : mapInstance.remove(marker);
152
+ }
130
153
  }
131
154
  });
132
155
  const markersToAdd = newMarkers.filter((data) => {
@@ -138,7 +161,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
138
161
  const marker = createMarker(data);
139
162
  if (marker) {
140
163
  newMarkersList.push(marker);
141
- mapInstance == null ? void 0 : mapInstance.add(marker);
164
+ if (props.cluster && clusterManager.value) {
165
+ clusterManager.value.addMarker(marker);
166
+ } else {
167
+ mapInstance == null ? void 0 : mapInstance.add(marker);
168
+ }
142
169
  }
143
170
  });
144
171
  markers.value.push(...newMarkersList);
@@ -148,12 +175,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
148
175
  if (!mapInstance)
149
176
  return;
150
177
  removeMarkers();
178
+ if (props.cluster && !clusterManager.value) {
179
+ createClusterManager();
180
+ }
151
181
  if (newMarkers && newMarkers.length > 0) {
152
182
  newMarkers.forEach((data) => {
153
183
  const marker = createMarker(data);
154
184
  if (marker) {
155
185
  markers.value.push(marker);
156
- mapInstance == null ? void 0 : mapInstance.add(marker);
186
+ if (props.cluster && clusterManager.value) {
187
+ clusterManager.value.addMarker(marker);
188
+ } else {
189
+ mapInstance == null ? void 0 : mapInstance.add(marker);
190
+ }
157
191
  }
158
192
  });
159
193
  }
@@ -161,6 +195,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
161
195
  function addMarkers() {
162
196
  if (!mapInstance)
163
197
  return;
198
+ if (props.cluster && !clusterManager.value) {
199
+ createClusterManager();
200
+ }
164
201
  if (props.markers && props.markers.length > 0) {
165
202
  if (props.updateMode === "full") {
166
203
  fullUpdate(props.markers);
@@ -178,12 +215,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
178
215
  const marker = createMarker(singleMarker);
179
216
  if (marker) {
180
217
  markers.value.push(marker);
181
- mapInstance == null ? void 0 : mapInstance.add(marker);
218
+ if (props.cluster && clusterManager.value) {
219
+ clusterManager.value.addMarker(marker);
220
+ } else {
221
+ mapInstance == null ? void 0 : mapInstance.add(marker);
222
+ }
182
223
  }
183
224
  }
184
225
  }
185
226
  function removeMarkers() {
186
- if (!mapInstance || markers.value.length === 0)
227
+ if (markers.value.length === 0)
187
228
  return;
188
229
  markers.value.forEach((marker) => {
189
230
  const cleanupFn = contentCleanupFns.get(marker);
@@ -191,9 +232,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
191
232
  cleanupFn();
192
233
  contentCleanupFns.delete(marker);
193
234
  }
194
- mapInstance == null ? void 0 : mapInstance.remove(marker);
235
+ if (props.cluster && clusterManager.value) {
236
+ clusterManager.value.removeMarker(marker);
237
+ } else if (mapInstance) {
238
+ mapInstance.remove(marker);
239
+ }
195
240
  });
196
241
  markers.value = [];
242
+ if (props.cluster && clusterManager.value) {
243
+ clusterManager.value.clearMarkers();
244
+ clusterManager.value = null;
245
+ }
197
246
  }
198
247
  __expose({
199
248
  getMarkers: () => markers.value,
@@ -228,20 +277,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
228
277
  });
229
278
  watch(
230
279
  () => props.markers,
231
- (newMarkers, _oldMarkers) => {
280
+ (newMarkers, oldMarkers) => {
232
281
  if (!mapInstance)
233
282
  return;
234
283
  if (!newMarkers) {
235
284
  removeMarkers();
236
285
  return;
237
286
  }
287
+ const isSameArray = newMarkers === oldMarkers;
288
+ const isLengthIncreased = oldMarkers && newMarkers.length > oldMarkers.length;
289
+ if (isSameArray && isLengthIncreased) {
290
+ incrementalUpdate(newMarkers);
291
+ return;
292
+ }
238
293
  if (props.updateMode === "full") {
239
294
  fullUpdate(newMarkers);
240
295
  } else {
241
296
  incrementalUpdate(newMarkers);
242
297
  }
243
298
  },
244
- { immediate: true }
299
+ { immediate: true, deep: true }
245
300
  );
246
301
  return (_ctx, _cache) => {
247
302
  return renderSlot(_ctx.$slots, "default");
@@ -72,6 +72,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
72
72
  responsive: { type: Boolean, default: true },
73
73
  grid: { type: [Boolean, Object], default: false },
74
74
  className: {},
75
+ formClass: {},
75
76
  readonly: { type: Boolean },
76
77
  disabled: { type: Boolean },
77
78
  watchDeep: { type: Boolean, default: true },
@@ -154,7 +155,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
154
155
  if (props.inline && props.grid) {
155
156
  classes.push("jky-form--grid");
156
157
  }
157
- return classes;
158
+ return [...classes, props.formClass || ""];
158
159
  });
159
160
  const _gridStyle = computed(() => {
160
161
  if (!props.inline || !props.grid || typeof props.grid === "boolean") {
@@ -1,4 +1,4 @@
1
- const version = "0.0.94";
1
+ const version = "0.0.96";
2
2
  export {
3
3
  version
4
4
  };
@@ -278,7 +278,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
278
278
  closable: true
279
279
  }, null, 8, ["store", "cachable", "round"])),
280
280
  (openBlock(), createBlock(resolveDynamicComponent(props.mainWithCard ? unref(ElCard) : "div"), {
281
- class: normalizeClass(["jky-page-layout__content flex-1 min-h-0 overflow-hidden", props.contentClass]),
281
+ class: normalizeClass(["jky-page-layout__content flex-1 min-h-0 max-h-0 overflow-hidden", props.contentClass]),
282
282
  "body-class": props.mainWithScrollbar ? "" : "pb-0!"
283
283
  }, {
284
284
  default: withCtx(() => [
@@ -324,7 +324,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
324
324
  }, [
325
325
  __props.filterItems && __props.filterItems.length > 0 ? (openBlock(), createBlock(unref(ElCard), {
326
326
  key: 0,
327
- class: "mb-4 jky-page-table__filter-card"
327
+ class: "mb-3 jky-page-table__filter-card"
328
328
  }, {
329
329
  default: withCtx(() => [
330
330
  createVNode(unref(JkyForm), mergeProps({
package/dist/es/style.css CHANGED
@@ -1566,6 +1566,10 @@
1566
1566
  height: 100vh;
1567
1567
  }
1568
1568
 
1569
+ .max-h-0 {
1570
+ max-height: calc(var(--spacing) * 0);
1571
+ }
1572
+
1569
1573
  .min-h-0 {
1570
1574
  min-height: calc(var(--spacing) * 0);
1571
1575
  }
@@ -28,6 +28,7 @@ declare const __VLS_component: import('vue').DefineComponent<AMapMarkerProps, {
28
28
  draggable: boolean;
29
29
  visible: boolean;
30
30
  updateMode: "incremental" | "full";
31
+ cluster: boolean;
31
32
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
32
33
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
33
34
  export default _default;
@@ -33,13 +33,16 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
33
33
  icon: {},
34
34
  offset: {},
35
35
  visible: { type: Boolean, default: true },
36
- updateMode: { default: "full" }
36
+ updateMode: { default: "full" },
37
+ cluster: { type: Boolean, default: false },
38
+ clusterOptions: {}
37
39
  },
38
40
  emits: ["click", "dragend", "mouseover", "mouseout"],
39
41
  setup(__props, { expose: __expose, emit: __emit }) {
40
42
  const props = __props;
41
43
  const emit = __emit;
42
44
  const markers = vue.ref([]);
45
+ const clusterManager = vue.ref(null);
43
46
  const amapContext = vue.inject("amapContext", null);
44
47
  const mapInstance = (amapContext == null ? void 0 : amapContext.getMapInstance()) || null;
45
48
  const contentCleanupFns = /* @__PURE__ */ new WeakMap();
@@ -49,6 +52,22 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
49
52
  vue.render(vnode, container);
50
53
  return container.firstElementChild || container;
51
54
  }
55
+ function createClusterManager() {
56
+ const AMap = window.AMap;
57
+ if (!AMap || !mapInstance)
58
+ return;
59
+ if (clusterManager.value) {
60
+ clusterManager.value.clearMarkers();
61
+ clusterManager.value = null;
62
+ }
63
+ const options = {
64
+ map: mapInstance
65
+ };
66
+ if (props.clusterOptions) {
67
+ Object.assign(options, props.clusterOptions);
68
+ }
69
+ clusterManager.value = new AMap.MarkerCluster(options);
70
+ }
52
71
  function createMarker(data) {
53
72
  const AMap = window.AMap;
54
73
  if (!AMap || !mapInstance) {
@@ -128,7 +147,11 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
128
147
  cleanupFn();
129
148
  contentCleanupFns.delete(marker);
130
149
  }
131
- mapInstance == null ? void 0 : mapInstance.remove(marker);
150
+ if (props.cluster && clusterManager.value) {
151
+ clusterManager.value.removeMarker(marker);
152
+ } else {
153
+ mapInstance == null ? void 0 : mapInstance.remove(marker);
154
+ }
132
155
  }
133
156
  });
134
157
  const markersToAdd = newMarkers.filter((data) => {
@@ -140,7 +163,11 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
140
163
  const marker = createMarker(data);
141
164
  if (marker) {
142
165
  newMarkersList.push(marker);
143
- mapInstance == null ? void 0 : mapInstance.add(marker);
166
+ if (props.cluster && clusterManager.value) {
167
+ clusterManager.value.addMarker(marker);
168
+ } else {
169
+ mapInstance == null ? void 0 : mapInstance.add(marker);
170
+ }
144
171
  }
145
172
  });
146
173
  markers.value.push(...newMarkersList);
@@ -150,12 +177,19 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
150
177
  if (!mapInstance)
151
178
  return;
152
179
  removeMarkers();
180
+ if (props.cluster && !clusterManager.value) {
181
+ createClusterManager();
182
+ }
153
183
  if (newMarkers && newMarkers.length > 0) {
154
184
  newMarkers.forEach((data) => {
155
185
  const marker = createMarker(data);
156
186
  if (marker) {
157
187
  markers.value.push(marker);
158
- mapInstance == null ? void 0 : mapInstance.add(marker);
188
+ if (props.cluster && clusterManager.value) {
189
+ clusterManager.value.addMarker(marker);
190
+ } else {
191
+ mapInstance == null ? void 0 : mapInstance.add(marker);
192
+ }
159
193
  }
160
194
  });
161
195
  }
@@ -163,6 +197,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
163
197
  function addMarkers() {
164
198
  if (!mapInstance)
165
199
  return;
200
+ if (props.cluster && !clusterManager.value) {
201
+ createClusterManager();
202
+ }
166
203
  if (props.markers && props.markers.length > 0) {
167
204
  if (props.updateMode === "full") {
168
205
  fullUpdate(props.markers);
@@ -180,12 +217,16 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
180
217
  const marker = createMarker(singleMarker);
181
218
  if (marker) {
182
219
  markers.value.push(marker);
183
- mapInstance == null ? void 0 : mapInstance.add(marker);
220
+ if (props.cluster && clusterManager.value) {
221
+ clusterManager.value.addMarker(marker);
222
+ } else {
223
+ mapInstance == null ? void 0 : mapInstance.add(marker);
224
+ }
184
225
  }
185
226
  }
186
227
  }
187
228
  function removeMarkers() {
188
- if (!mapInstance || markers.value.length === 0)
229
+ if (markers.value.length === 0)
189
230
  return;
190
231
  markers.value.forEach((marker) => {
191
232
  const cleanupFn = contentCleanupFns.get(marker);
@@ -193,9 +234,17 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
193
234
  cleanupFn();
194
235
  contentCleanupFns.delete(marker);
195
236
  }
196
- mapInstance == null ? void 0 : mapInstance.remove(marker);
237
+ if (props.cluster && clusterManager.value) {
238
+ clusterManager.value.removeMarker(marker);
239
+ } else if (mapInstance) {
240
+ mapInstance.remove(marker);
241
+ }
197
242
  });
198
243
  markers.value = [];
244
+ if (props.cluster && clusterManager.value) {
245
+ clusterManager.value.clearMarkers();
246
+ clusterManager.value = null;
247
+ }
199
248
  }
200
249
  __expose({
201
250
  getMarkers: () => markers.value,
@@ -230,20 +279,26 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
230
279
  });
231
280
  vue.watch(
232
281
  () => props.markers,
233
- (newMarkers, _oldMarkers) => {
282
+ (newMarkers, oldMarkers) => {
234
283
  if (!mapInstance)
235
284
  return;
236
285
  if (!newMarkers) {
237
286
  removeMarkers();
238
287
  return;
239
288
  }
289
+ const isSameArray = newMarkers === oldMarkers;
290
+ const isLengthIncreased = oldMarkers && newMarkers.length > oldMarkers.length;
291
+ if (isSameArray && isLengthIncreased) {
292
+ incrementalUpdate(newMarkers);
293
+ return;
294
+ }
240
295
  if (props.updateMode === "full") {
241
296
  fullUpdate(newMarkers);
242
297
  } else {
243
298
  incrementalUpdate(newMarkers);
244
299
  }
245
300
  },
246
- { immediate: true }
301
+ { immediate: true, deep: true }
247
302
  );
248
303
  return (_ctx, _cache) => {
249
304
  return vue.renderSlot(_ctx.$slots, "default");
@@ -74,6 +74,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
74
74
  responsive: { type: Boolean, default: true },
75
75
  grid: { type: [Boolean, Object], default: false },
76
76
  className: {},
77
+ formClass: {},
77
78
  readonly: { type: Boolean },
78
79
  disabled: { type: Boolean },
79
80
  watchDeep: { type: Boolean, default: true },
@@ -156,7 +157,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
156
157
  if (props.inline && props.grid) {
157
158
  classes.push("jky-form--grid");
158
159
  }
159
- return classes;
160
+ return [...classes, props.formClass || ""];
160
161
  });
161
162
  const _gridStyle = vue.computed(() => {
162
163
  if (!props.inline || !props.grid || typeof props.grid === "boolean") {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "0.0.94";
3
+ const version = "0.0.96";
4
4
  exports.version = version;
@@ -280,7 +280,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
280
280
  closable: true
281
281
  }, null, 8, ["store", "cachable", "round"])),
282
282
  (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(props.mainWithCard ? vue.unref(ElementPlus.ElCard) : "div"), {
283
- class: vue.normalizeClass(["jky-page-layout__content flex-1 min-h-0 overflow-hidden", props.contentClass]),
283
+ class: vue.normalizeClass(["jky-page-layout__content flex-1 min-h-0 max-h-0 overflow-hidden", props.contentClass]),
284
284
  "body-class": props.mainWithScrollbar ? "" : "pb-0!"
285
285
  }, {
286
286
  default: vue.withCtx(() => [
@@ -326,7 +326,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
326
326
  }, [
327
327
  __props.filterItems && __props.filterItems.length > 0 ? (vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElCard), {
328
328
  key: 0,
329
- class: "mb-4 jky-page-table__filter-card"
329
+ class: "mb-3 jky-page-table__filter-card"
330
330
  }, {
331
331
  default: vue.withCtx(() => [
332
332
  vue.createVNode(vue.unref(index.JkyForm), vue.mergeProps({
@@ -1566,6 +1566,10 @@
1566
1566
  height: 100vh;
1567
1567
  }
1568
1568
 
1569
+ .max-h-0 {
1570
+ max-height: calc(var(--spacing) * 0);
1571
+ }
1572
+
1569
1573
  .min-h-0 {
1570
1574
  min-height: calc(var(--spacing) * 0);
1571
1575
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jky-component-lib",
3
3
  "type": "module",
4
- "version": "0.0.94",
4
+ "version": "0.0.96",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },