jky-component-lib 0.0.126 → 0.0.127

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.
@@ -1,7 +1,3 @@
1
1
 
2
- /* JkyAMarker 组件样式 - 参考高德官方示例 */
3
- .amap-icon img,
4
- .amap-marker-content img {
5
- width: 25px;
6
- height: 34px;
7
- }
2
+ /* 轨迹回放组件不需要额外样式 */
3
+ /* 所有样式通过 TailwindCSS 工具类或外部组件控制 */
@@ -1,3 +1,7 @@
1
1
 
2
- /* 轨迹回放组件不需要额外样式 */
3
- /* 所有样式通过 TailwindCSS 工具类或外部组件控制 */
2
+ /* JkyAMarker 组件样式 - 参考高德官方示例 */
3
+ .amap-icon img,
4
+ .amap-marker-content img {
5
+ width: 25px;
6
+ height: 34px;
7
+ }
@@ -56,7 +56,6 @@ import { JkyAddInput } from "../add-input/index.js";
56
56
  import { JkyCodeMirrorEditor } from "../code-mirror-editor/index.js";
57
57
  import { JkyRichEditor } from "../rich-editor/index.js";
58
58
  import _sfc_main$1 from "./LinkedSelect.vue.js";
59
- /* empty css */
60
59
  import _sfc_main$2 from "./SelectTable.vue.js";
61
60
  /* empty css */
62
61
  const _hoisted_1 = {
@@ -17,8 +17,10 @@ declare function __VLS_template(): {
17
17
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
18
18
  declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
19
19
  "update:modelValue": (value: any[]) => any;
20
+ change: (value: any[]) => any;
20
21
  }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
21
22
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
23
+ onChange?: ((value: any[]) => any) | undefined;
22
24
  }>, {
23
25
  modelValue: any[];
24
26
  disabled: boolean;
@@ -37,8 +37,8 @@ var __async = (__this, __arguments, generator) => {
37
37
  step((generator = generator.apply(__this, __arguments)).next());
38
38
  });
39
39
  };
40
- import { defineComponent, ref, onMounted, watch, openBlock, createElementBlock, renderSlot, Fragment, renderList, createBlock, unref, mergeProps, withCtx } from "vue";
41
- import { ElSelect } from "element-plus";
40
+ import { defineComponent, ref, onMounted, openBlock, createElementBlock, renderSlot, Fragment, renderList, unref, createBlock, mergeProps, withCtx, watch } from "vue";
41
+ import { ElSelect, ElOption } from "element-plus";
42
42
  const _hoisted_1 = { class: "flex gap-2" };
43
43
  const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
44
44
  name: "JkyLinkedSelect"
@@ -50,82 +50,97 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
50
50
  disabled: { type: Boolean, default: false },
51
51
  componentProps: { default: void 0 }
52
52
  },
53
- emits: ["update:modelValue"],
53
+ emits: ["update:modelValue", "change"],
54
54
  setup(__props, { emit: __emit }) {
55
+ var _a;
55
56
  const props = __props;
56
57
  const emit = __emit;
57
- const linkedSelectOptions = ref([]);
58
- const linkedSelectLoading = ref([]);
59
- function loadLinkedSelectOptions() {
58
+ const level = ((_a = props.config) == null ? void 0 : _a.level) || 1;
59
+ const optionsList = ref(Array.from({ length: level }, () => []));
60
+ const loadingList = ref(Array.from({ length: level }, () => false));
61
+ const values = ref(
62
+ props.modelValue && props.modelValue.length > 0 ? props.modelValue.slice(0, level) : Array.from({ length: level }, () => void 0)
63
+ );
64
+ function loadOptions(levelIndex, value) {
60
65
  return __async(this, null, function* () {
61
- if (!props.config) {
66
+ var _a2;
67
+ if (!((_a2 = props.config) == null ? void 0 : _a2.getOptions) || levelIndex >= level) {
62
68
  return;
63
69
  }
64
- const level = props.config.level || 1;
65
- linkedSelectLoading.value = Array.from({ length: level }, () => false);
66
- if (props.config.getAllOptions) {
67
- try {
68
- const allOptions = yield props.config.getAllOptions(props.modelValue);
69
- linkedSelectOptions.value = allOptions;
70
- } catch (error) {
71
- console.error("Failed to load linked select options:", error);
72
- linkedSelectOptions.value = Array.from({ length: level }, () => []);
73
- }
74
- return;
70
+ loadingList.value[levelIndex] = true;
71
+ try {
72
+ const levelOptions = yield props.config.getOptions(levelIndex + 1, value);
73
+ optionsList.value[levelIndex] = levelOptions || [];
74
+ } catch (error) {
75
+ console.error("Failed to load linked select options:", error);
76
+ optionsList.value[levelIndex] = [];
77
+ } finally {
78
+ loadingList.value[levelIndex] = false;
75
79
  }
76
- if (props.config.getOptions) {
77
- try {
78
- const options = [];
79
- for (let i = 0; i < level; i++) {
80
- linkedSelectLoading.value[i] = true;
81
- const levelOptions = yield props.config.getOptions(i + 1, props.modelValue || []);
82
- options.push(levelOptions);
83
- linkedSelectLoading.value[i] = false;
84
- }
85
- linkedSelectOptions.value = options;
86
- } catch (error) {
87
- console.error("Failed to load linked select options:", error);
88
- linkedSelectOptions.value = Array.from({ length: level }, () => []);
80
+ });
81
+ }
82
+ function loadDisplayData() {
83
+ return __async(this, null, function* () {
84
+ for (let i = 0; i < level - 1; i++) {
85
+ if (values.value[i] !== void 0 && values.value[i] !== null) {
86
+ yield loadOptions(i + 1, values.value[i]);
89
87
  }
90
88
  }
91
89
  });
92
90
  }
93
- onMounted(() => {
94
- loadLinkedSelectOptions();
95
- });
96
- watch(
97
- () => props.modelValue,
98
- () => {
99
- loadLinkedSelectOptions();
100
- },
101
- { deep: true }
102
- );
103
- function handleValueChange(index, val) {
104
- const newValue = Array.isArray(props.modelValue) ? [...props.modelValue] : [];
105
- newValue[index] = val;
91
+ function watchModelValue() {
92
+ watch(
93
+ () => props.modelValue,
94
+ (newVal) => __async(null, null, function* () {
95
+ if (newVal && newVal.length > 0) {
96
+ values.value = [...newVal];
97
+ yield loadDisplayData();
98
+ }
99
+ }),
100
+ { deep: true }
101
+ );
102
+ }
103
+ function handleSelectChange(index, value) {
104
+ for (let i = index + 1; i < level; i++) {
105
+ values.value[i] = void 0;
106
+ optionsList.value[i] = [];
107
+ }
108
+ const newValue = [...values.value];
106
109
  emit("update:modelValue", newValue);
110
+ emit("change", newValue);
111
+ if (value !== void 0 && value !== null && index + 1 < level) {
112
+ loadOptions(index + 1, value);
113
+ }
107
114
  }
115
+ onMounted(() => {
116
+ var _a2;
117
+ watchModelValue();
118
+ loadDisplayData();
119
+ if ((_a2 = props.config) == null ? void 0 : _a2.getOptions) {
120
+ loadOptions(0, void 0);
121
+ }
122
+ });
108
123
  return (_ctx, _cache) => {
109
- var _a;
110
124
  return openBlock(), createElementBlock("div", _hoisted_1, [
111
125
  renderSlot(_ctx.$slots, "prefix"),
112
- (openBlock(true), createElementBlock(Fragment, null, renderList(Array.from({ length: ((_a = __props.config) == null ? void 0 : _a.level) || 1 }), (_, index) => {
126
+ (openBlock(true), createElementBlock(Fragment, null, renderList(Array.from({ length: unref(level) }), (_, index) => {
113
127
  var _a2, _b, _c, _d, _e, _f;
114
128
  return openBlock(), createBlock(unref(ElSelect), mergeProps({
115
129
  key: index,
116
- "model-value": Array.isArray(__props.modelValue) ? __props.modelValue[index] : void 0,
130
+ modelValue: values.value[index],
131
+ "onUpdate:modelValue": ($event) => values.value[index] = $event,
117
132
  placeholder: ((_b = (_a2 = __props.config) == null ? void 0 : _a2.placeholders) == null ? void 0 : _b[index]) || "请选择",
118
- disabled: __props.disabled,
133
+ disabled: __props.disabled || index > 0 && values.value[index - 1] === void 0 && values.value[index - 1] !== null,
119
134
  filterable: (_d = (_c = __props.config) == null ? void 0 : _c.filterable) != null ? _d : false,
120
135
  clearable: (_f = (_e = __props.config) == null ? void 0 : _e.clearable) != null ? _f : true,
121
- loading: linkedSelectLoading.value[index],
136
+ loading: loadingList.value[index],
122
137
  class: "flex-1 min-w-30"
123
138
  }, { ref_for: true }, __props.componentProps, {
124
- "onUpdate:modelValue": ($event) => handleValueChange(index, $event)
139
+ onChange: ($event) => handleSelectChange(index, $event)
125
140
  }), {
126
141
  default: withCtx(() => [
127
- (openBlock(true), createElementBlock(Fragment, null, renderList(linkedSelectOptions.value[index] || [], (option) => {
128
- return openBlock(), createBlock(unref(ElSelect).Option, {
142
+ (openBlock(true), createElementBlock(Fragment, null, renderList(optionsList.value[index] || [], (option) => {
143
+ return openBlock(), createBlock(unref(ElOption), {
129
144
  key: option.value,
130
145
  value: option.value,
131
146
  label: option.label,
@@ -134,7 +149,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
134
149
  }), 128))
135
150
  ]),
136
151
  _: 2
137
- }, 1040, ["model-value", "placeholder", "disabled", "filterable", "clearable", "loading", "onUpdate:modelValue"]);
152
+ }, 1040, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled", "filterable", "clearable", "loading", "onChange"]);
138
153
  }), 128)),
139
154
  renderSlot(_ctx.$slots, "suffix")
140
155
  ]);
@@ -1,5 +1,4 @@
1
1
  import _sfc_main from "./LinkedSelect.vue.js";
2
- /* empty css */
3
2
  export {
4
3
  _sfc_main as default
5
4
  };
@@ -1,7 +1,6 @@
1
1
  import _sfc_main from "./Form.vue.js";
2
2
  /* empty css */
3
3
  import _sfc_main$1 from "./LinkedSelect.vue.js";
4
- /* empty css */
5
4
  import { installWithSFC } from "../utils/with-install.js";
6
5
  const JkyForm = installWithSFC(_sfc_main);
7
6
  const JkyLinkedSelect = installWithSFC(_sfc_main$1);
@@ -1,4 +1,4 @@
1
- const version = "0.0.126";
1
+ const version = "0.0.127";
2
2
  export {
3
3
  version
4
4
  };
@@ -1,7 +1,3 @@
1
1
 
2
- /* JkyAMarker 组件样式 - 参考高德官方示例 */
3
- .amap-icon img,
4
- .amap-marker-content img {
5
- width: 25px;
6
- height: 34px;
7
- }
2
+ /* 轨迹回放组件不需要额外样式 */
3
+ /* 所有样式通过 TailwindCSS 工具类或外部组件控制 */
@@ -1,3 +1,7 @@
1
1
 
2
- /* 轨迹回放组件不需要额外样式 */
3
- /* 所有样式通过 TailwindCSS 工具类或外部组件控制 */
2
+ /* JkyAMarker 组件样式 - 参考高德官方示例 */
3
+ .amap-icon img,
4
+ .amap-marker-content img {
5
+ width: 25px;
6
+ height: 34px;
7
+ }
@@ -58,7 +58,6 @@ const index = require("../add-input/index.js");
58
58
  const index$2 = require("../code-mirror-editor/index.js");
59
59
  const index$1 = require("../rich-editor/index.js");
60
60
  const LinkedSelect_vue_vue_type_script_setup_true_lang = require("./LinkedSelect.vue.js");
61
- ;/* empty css */
62
61
  const SelectTable_vue_vue_type_script_setup_true_lang = require("./SelectTable.vue.js");
63
62
  ;/* empty css */
64
63
  const _hoisted_1 = {
@@ -17,8 +17,10 @@ declare function __VLS_template(): {
17
17
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
18
18
  declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
19
19
  "update:modelValue": (value: any[]) => any;
20
+ change: (value: any[]) => any;
20
21
  }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
21
22
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
23
+ onChange?: ((value: any[]) => any) | undefined;
22
24
  }>, {
23
25
  modelValue: any[];
24
26
  disabled: boolean;
@@ -52,82 +52,97 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
52
52
  disabled: { type: Boolean, default: false },
53
53
  componentProps: { default: void 0 }
54
54
  },
55
- emits: ["update:modelValue"],
55
+ emits: ["update:modelValue", "change"],
56
56
  setup(__props, { emit: __emit }) {
57
+ var _a;
57
58
  const props = __props;
58
59
  const emit = __emit;
59
- const linkedSelectOptions = vue.ref([]);
60
- const linkedSelectLoading = vue.ref([]);
61
- function loadLinkedSelectOptions() {
60
+ const level = ((_a = props.config) == null ? void 0 : _a.level) || 1;
61
+ const optionsList = vue.ref(Array.from({ length: level }, () => []));
62
+ const loadingList = vue.ref(Array.from({ length: level }, () => false));
63
+ const values = vue.ref(
64
+ props.modelValue && props.modelValue.length > 0 ? props.modelValue.slice(0, level) : Array.from({ length: level }, () => void 0)
65
+ );
66
+ function loadOptions(levelIndex, value) {
62
67
  return __async(this, null, function* () {
63
- if (!props.config) {
68
+ var _a2;
69
+ if (!((_a2 = props.config) == null ? void 0 : _a2.getOptions) || levelIndex >= level) {
64
70
  return;
65
71
  }
66
- const level = props.config.level || 1;
67
- linkedSelectLoading.value = Array.from({ length: level }, () => false);
68
- if (props.config.getAllOptions) {
69
- try {
70
- const allOptions = yield props.config.getAllOptions(props.modelValue);
71
- linkedSelectOptions.value = allOptions;
72
- } catch (error) {
73
- console.error("Failed to load linked select options:", error);
74
- linkedSelectOptions.value = Array.from({ length: level }, () => []);
75
- }
76
- return;
72
+ loadingList.value[levelIndex] = true;
73
+ try {
74
+ const levelOptions = yield props.config.getOptions(levelIndex + 1, value);
75
+ optionsList.value[levelIndex] = levelOptions || [];
76
+ } catch (error) {
77
+ console.error("Failed to load linked select options:", error);
78
+ optionsList.value[levelIndex] = [];
79
+ } finally {
80
+ loadingList.value[levelIndex] = false;
77
81
  }
78
- if (props.config.getOptions) {
79
- try {
80
- const options = [];
81
- for (let i = 0; i < level; i++) {
82
- linkedSelectLoading.value[i] = true;
83
- const levelOptions = yield props.config.getOptions(i + 1, props.modelValue || []);
84
- options.push(levelOptions);
85
- linkedSelectLoading.value[i] = false;
86
- }
87
- linkedSelectOptions.value = options;
88
- } catch (error) {
89
- console.error("Failed to load linked select options:", error);
90
- linkedSelectOptions.value = Array.from({ length: level }, () => []);
82
+ });
83
+ }
84
+ function loadDisplayData() {
85
+ return __async(this, null, function* () {
86
+ for (let i = 0; i < level - 1; i++) {
87
+ if (values.value[i] !== void 0 && values.value[i] !== null) {
88
+ yield loadOptions(i + 1, values.value[i]);
91
89
  }
92
90
  }
93
91
  });
94
92
  }
95
- vue.onMounted(() => {
96
- loadLinkedSelectOptions();
97
- });
98
- vue.watch(
99
- () => props.modelValue,
100
- () => {
101
- loadLinkedSelectOptions();
102
- },
103
- { deep: true }
104
- );
105
- function handleValueChange(index, val) {
106
- const newValue = Array.isArray(props.modelValue) ? [...props.modelValue] : [];
107
- newValue[index] = val;
93
+ function watchModelValue() {
94
+ vue.watch(
95
+ () => props.modelValue,
96
+ (newVal) => __async(null, null, function* () {
97
+ if (newVal && newVal.length > 0) {
98
+ values.value = [...newVal];
99
+ yield loadDisplayData();
100
+ }
101
+ }),
102
+ { deep: true }
103
+ );
104
+ }
105
+ function handleSelectChange(index, value) {
106
+ for (let i = index + 1; i < level; i++) {
107
+ values.value[i] = void 0;
108
+ optionsList.value[i] = [];
109
+ }
110
+ const newValue = [...values.value];
108
111
  emit("update:modelValue", newValue);
112
+ emit("change", newValue);
113
+ if (value !== void 0 && value !== null && index + 1 < level) {
114
+ loadOptions(index + 1, value);
115
+ }
109
116
  }
117
+ vue.onMounted(() => {
118
+ var _a2;
119
+ watchModelValue();
120
+ loadDisplayData();
121
+ if ((_a2 = props.config) == null ? void 0 : _a2.getOptions) {
122
+ loadOptions(0, void 0);
123
+ }
124
+ });
110
125
  return (_ctx, _cache) => {
111
- var _a;
112
126
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
113
127
  vue.renderSlot(_ctx.$slots, "prefix"),
114
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(Array.from({ length: ((_a = __props.config) == null ? void 0 : _a.level) || 1 }), (_, index) => {
128
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(Array.from({ length: vue.unref(level) }), (_, index) => {
115
129
  var _a2, _b, _c, _d, _e, _f;
116
130
  return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElSelect), vue.mergeProps({
117
131
  key: index,
118
- "model-value": Array.isArray(__props.modelValue) ? __props.modelValue[index] : void 0,
132
+ modelValue: values.value[index],
133
+ "onUpdate:modelValue": ($event) => values.value[index] = $event,
119
134
  placeholder: ((_b = (_a2 = __props.config) == null ? void 0 : _a2.placeholders) == null ? void 0 : _b[index]) || "请选择",
120
- disabled: __props.disabled,
135
+ disabled: __props.disabled || index > 0 && values.value[index - 1] === void 0 && values.value[index - 1] !== null,
121
136
  filterable: (_d = (_c = __props.config) == null ? void 0 : _c.filterable) != null ? _d : false,
122
137
  clearable: (_f = (_e = __props.config) == null ? void 0 : _e.clearable) != null ? _f : true,
123
- loading: linkedSelectLoading.value[index],
138
+ loading: loadingList.value[index],
124
139
  class: "flex-1 min-w-30"
125
140
  }, { ref_for: true }, __props.componentProps, {
126
- "onUpdate:modelValue": ($event) => handleValueChange(index, $event)
141
+ onChange: ($event) => handleSelectChange(index, $event)
127
142
  }), {
128
143
  default: vue.withCtx(() => [
129
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(linkedSelectOptions.value[index] || [], (option) => {
130
- return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElSelect).Option, {
144
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(optionsList.value[index] || [], (option) => {
145
+ return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElOption), {
131
146
  key: option.value,
132
147
  value: option.value,
133
148
  label: option.label,
@@ -136,7 +151,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
136
151
  }), 128))
137
152
  ]),
138
153
  _: 2
139
- }, 1040, ["model-value", "placeholder", "disabled", "filterable", "clearable", "loading", "onUpdate:modelValue"]);
154
+ }, 1040, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled", "filterable", "clearable", "loading", "onChange"]);
140
155
  }), 128)),
141
156
  vue.renderSlot(_ctx.$slots, "suffix")
142
157
  ]);
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const LinkedSelect_vue_vue_type_script_setup_true_lang = require("./LinkedSelect.vue.js");
4
- ;/* empty css */
5
4
  exports.default = LinkedSelect_vue_vue_type_script_setup_true_lang.default;
@@ -3,7 +3,6 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const Form_vue_vue_type_script_setup_true_lang = require("./Form.vue.js");
4
4
  ;/* empty css */
5
5
  const LinkedSelect_vue_vue_type_script_setup_true_lang = require("./LinkedSelect.vue.js");
6
- ;/* empty css */
7
6
  const withInstall = require("../utils/with-install.js");
8
7
  const JkyForm = withInstall.installWithSFC(Form_vue_vue_type_script_setup_true_lang.default);
9
8
  const JkyLinkedSelect = withInstall.installWithSFC(LinkedSelect_vue_vue_type_script_setup_true_lang.default);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "0.0.126";
3
+ const version = "0.0.127";
4
4
  exports.version = version;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jky-component-lib",
3
3
  "type": "module",
4
- "version": "0.0.126",
4
+ "version": "0.0.127",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },