jky-component-lib 0.0.45 → 0.0.48

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.
@@ -110,8 +110,207 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
110
110
  resetFields: typeof resetFields;
111
111
  clearValidate: typeof clearValidate;
112
112
  getFormInstance: typeof getFormInstance;
113
+ formRef: globalThis.Ref<({
114
+ $: import('vue').ComponentInternalInstance;
115
+ $data: {};
116
+ $props: {
117
+ readonly model?: Record<string, any> | undefined;
118
+ readonly rules?: import('element-plus').FormRules | undefined;
119
+ readonly labelPosition?: "left" | "right" | "top" | undefined;
120
+ readonly requireAsteriskPosition?: "left" | "right" | undefined;
121
+ readonly labelWidth?: string | number | undefined;
122
+ readonly labelSuffix?: string | undefined;
123
+ readonly inline?: boolean | undefined;
124
+ readonly inlineMessage?: boolean | undefined;
125
+ readonly statusIcon?: boolean | undefined;
126
+ readonly showMessage?: boolean | undefined;
127
+ readonly validateOnRuleChange?: boolean | undefined;
128
+ readonly hideRequiredAsterisk?: boolean | undefined;
129
+ readonly scrollToError?: boolean | undefined;
130
+ readonly scrollIntoViewOptions?: (ScrollIntoViewOptions | boolean) | undefined;
131
+ readonly size?: import('element-plus').ComponentSize | undefined;
132
+ readonly disabled?: boolean | undefined;
133
+ readonly onValidate?: ((prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => any) | undefined | undefined;
134
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
135
+ $attrs: import('vue').Attrs;
136
+ $refs: {
137
+ [x: string]: unknown;
138
+ };
139
+ $slots: Readonly<{
140
+ [name: string]: globalThis.Slot | undefined;
141
+ }>;
142
+ $root: ComponentPublicInstance | null;
143
+ $parent: ComponentPublicInstance | null;
144
+ $host: Element | null;
145
+ $emit: (event: "validate", prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => void;
146
+ $el: any;
147
+ $options: import('vue').ComponentOptionsBase<Readonly<import('element-plus').FormProps> & Readonly<{
148
+ onValidate?: ((prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => any) | undefined;
149
+ }>, {
150
+ validate: (callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
151
+ validateField: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>, callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
152
+ resetFields: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
153
+ clearValidate: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
154
+ scrollToField: (prop: import('element-plus').FormItemProp) => void;
155
+ getField: (prop: import('element-plus').FormItemProp) => import('element-plus').FormItemContext | undefined;
156
+ fields: import('vue').Reactive<import('element-plus').FormItemContext[]>;
157
+ setInitialValues: (initModel: Record<string, any>) => void;
158
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
159
+ validate: (prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => void;
160
+ }, string, {
161
+ scrollIntoViewOptions: ScrollIntoViewOptions | boolean;
162
+ labelWidth: string | number;
163
+ labelPosition: "left" | "right" | "top";
164
+ requireAsteriskPosition: "left" | "right";
165
+ labelSuffix: string;
166
+ showMessage: boolean;
167
+ validateOnRuleChange: boolean;
168
+ }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & {
169
+ beforeCreate?: (() => void) | (() => void)[];
170
+ created?: (() => void) | (() => void)[];
171
+ beforeMount?: (() => void) | (() => void)[];
172
+ mounted?: (() => void) | (() => void)[];
173
+ beforeUpdate?: (() => void) | (() => void)[];
174
+ updated?: (() => void) | (() => void)[];
175
+ activated?: (() => void) | (() => void)[];
176
+ deactivated?: (() => void) | (() => void)[];
177
+ beforeDestroy?: (() => void) | (() => void)[];
178
+ beforeUnmount?: (() => void) | (() => void)[];
179
+ destroyed?: (() => void) | (() => void)[];
180
+ unmounted?: (() => void) | (() => void)[];
181
+ renderTracked?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
182
+ renderTriggered?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
183
+ errorCaptured?: ((err: unknown, instance: ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: ComponentPublicInstance | null, info: string) => boolean | void)[];
184
+ };
185
+ $forceUpdate: () => void;
186
+ $nextTick: typeof import('vue').nextTick;
187
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
188
+ } & Readonly<{
189
+ scrollIntoViewOptions: ScrollIntoViewOptions | boolean;
190
+ labelWidth: string | number;
191
+ labelPosition: "left" | "right" | "top";
192
+ requireAsteriskPosition: "left" | "right";
193
+ labelSuffix: string;
194
+ showMessage: boolean;
195
+ validateOnRuleChange: boolean;
196
+ }> & Omit<Readonly<import('element-plus').FormProps> & Readonly<{
197
+ onValidate?: ((prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => any) | undefined;
198
+ }>, "labelWidth" | "labelPosition" | "showMessage" | "validate" | "clearValidate" | "requireAsteriskPosition" | "labelSuffix" | "validateOnRuleChange" | "scrollIntoViewOptions" | "validateField" | "resetFields" | "scrollToField" | "getField" | "fields" | "setInitialValues"> & import('vue').ShallowUnwrapRef<{
199
+ validate: (callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
200
+ validateField: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>, callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
201
+ resetFields: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
202
+ clearValidate: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
203
+ scrollToField: (prop: import('element-plus').FormItemProp) => void;
204
+ getField: (prop: import('element-plus').FormItemProp) => import('element-plus').FormItemContext | undefined;
205
+ fields: import('vue').Reactive<import('element-plus').FormItemContext[]>;
206
+ setInitialValues: (initModel: Record<string, any>) => void;
207
+ }> & {} & import('vue').ComponentCustomProperties & {} & {
208
+ $slots: {
209
+ default?: (props: {}) => any;
210
+ };
211
+ }) | undefined, ({
212
+ $: import('vue').ComponentInternalInstance;
213
+ $data: {};
214
+ $props: {
215
+ readonly model?: Record<string, any> | undefined;
216
+ readonly rules?: import('element-plus').FormRules | undefined;
217
+ readonly labelPosition?: "left" | "right" | "top" | undefined;
218
+ readonly requireAsteriskPosition?: "left" | "right" | undefined;
219
+ readonly labelWidth?: string | number | undefined;
220
+ readonly labelSuffix?: string | undefined;
221
+ readonly inline?: boolean | undefined;
222
+ readonly inlineMessage?: boolean | undefined;
223
+ readonly statusIcon?: boolean | undefined;
224
+ readonly showMessage?: boolean | undefined;
225
+ readonly validateOnRuleChange?: boolean | undefined;
226
+ readonly hideRequiredAsterisk?: boolean | undefined;
227
+ readonly scrollToError?: boolean | undefined;
228
+ readonly scrollIntoViewOptions?: (ScrollIntoViewOptions | boolean) | undefined;
229
+ readonly size?: import('element-plus').ComponentSize | undefined;
230
+ readonly disabled?: boolean | undefined;
231
+ readonly onValidate?: ((prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => any) | undefined | undefined;
232
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
233
+ $attrs: import('vue').Attrs;
234
+ $refs: {
235
+ [x: string]: unknown;
236
+ };
237
+ $slots: Readonly<{
238
+ [name: string]: globalThis.Slot | undefined;
239
+ }>;
240
+ $root: ComponentPublicInstance | null;
241
+ $parent: ComponentPublicInstance | null;
242
+ $host: Element | null;
243
+ $emit: (event: "validate", prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => void;
244
+ $el: any;
245
+ $options: import('vue').ComponentOptionsBase<Readonly<import('element-plus').FormProps> & Readonly<{
246
+ onValidate?: ((prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => any) | undefined;
247
+ }>, {
248
+ validate: (callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
249
+ validateField: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>, callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
250
+ resetFields: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
251
+ clearValidate: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
252
+ scrollToField: (prop: import('element-plus').FormItemProp) => void;
253
+ getField: (prop: import('element-plus').FormItemProp) => import('element-plus').FormItemContext | undefined;
254
+ fields: import('vue').Reactive<import('element-plus').FormItemContext[]>;
255
+ setInitialValues: (initModel: Record<string, any>) => void;
256
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
257
+ validate: (prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => void;
258
+ }, string, {
259
+ scrollIntoViewOptions: ScrollIntoViewOptions | boolean;
260
+ labelWidth: string | number;
261
+ labelPosition: "left" | "right" | "top";
262
+ requireAsteriskPosition: "left" | "right";
263
+ labelSuffix: string;
264
+ showMessage: boolean;
265
+ validateOnRuleChange: boolean;
266
+ }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & {
267
+ beforeCreate?: (() => void) | (() => void)[];
268
+ created?: (() => void) | (() => void)[];
269
+ beforeMount?: (() => void) | (() => void)[];
270
+ mounted?: (() => void) | (() => void)[];
271
+ beforeUpdate?: (() => void) | (() => void)[];
272
+ updated?: (() => void) | (() => void)[];
273
+ activated?: (() => void) | (() => void)[];
274
+ deactivated?: (() => void) | (() => void)[];
275
+ beforeDestroy?: (() => void) | (() => void)[];
276
+ beforeUnmount?: (() => void) | (() => void)[];
277
+ destroyed?: (() => void) | (() => void)[];
278
+ unmounted?: (() => void) | (() => void)[];
279
+ renderTracked?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
280
+ renderTriggered?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
281
+ errorCaptured?: ((err: unknown, instance: ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: ComponentPublicInstance | null, info: string) => boolean | void)[];
282
+ };
283
+ $forceUpdate: () => void;
284
+ $nextTick: typeof import('vue').nextTick;
285
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
286
+ } & Readonly<{
287
+ scrollIntoViewOptions: ScrollIntoViewOptions | boolean;
288
+ labelWidth: string | number;
289
+ labelPosition: "left" | "right" | "top";
290
+ requireAsteriskPosition: "left" | "right";
291
+ labelSuffix: string;
292
+ showMessage: boolean;
293
+ validateOnRuleChange: boolean;
294
+ }> & Omit<Readonly<import('element-plus').FormProps> & Readonly<{
295
+ onValidate?: ((prop: import('element-plus').FormItemProp, isValid: boolean, message: string) => any) | undefined;
296
+ }>, "labelWidth" | "labelPosition" | "showMessage" | "validate" | "clearValidate" | "requireAsteriskPosition" | "labelSuffix" | "validateOnRuleChange" | "scrollIntoViewOptions" | "validateField" | "resetFields" | "scrollToField" | "getField" | "fields" | "setInitialValues"> & import('vue').ShallowUnwrapRef<{
297
+ validate: (callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
298
+ validateField: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>, callback?: import('element-plus').FormValidateCallback) => import('element-plus').FormValidationResult;
299
+ resetFields: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
300
+ clearValidate: (props?: import('element-plus/es/utils').Arrayable<import('element-plus').FormItemProp>) => void;
301
+ scrollToField: (prop: import('element-plus').FormItemProp) => void;
302
+ getField: (prop: import('element-plus').FormItemProp) => import('element-plus').FormItemContext | undefined;
303
+ fields: import('vue').Reactive<import('element-plus').FormItemContext[]>;
304
+ setInitialValues: (initModel: Record<string, any>) => void;
305
+ }> & {} & import('vue').ComponentCustomProperties & {} & {
306
+ $slots: {
307
+ default?: (props: {}) => any;
308
+ };
309
+ }) | undefined>;
113
310
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
114
311
  change: (value: Record<string, any>) => any;
312
+ reset: () => any;
313
+ submit: (data: Record<string, any>) => any;
115
314
  "update:modelValue": (value: Record<string, any>) => any;
116
315
  validate: (result: {
117
316
  valid: boolean;
@@ -119,6 +318,8 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
119
318
  }) => any;
120
319
  }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
121
320
  onChange?: ((value: Record<string, any>) => any) | undefined;
321
+ onReset?: (() => any) | undefined;
322
+ onSubmit?: ((data: Record<string, any>) => any) | undefined;
122
323
  "onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
123
324
  onValidate?: ((result: {
124
325
  valid: boolean;
@@ -128,11 +329,14 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
128
329
  size: import('element-plus').ComponentSize;
129
330
  labelWidth: string | number;
130
331
  labelPosition: "left" | "right" | "top";
332
+ showFooter: boolean;
131
333
  showTitle: boolean;
132
334
  gutter: number;
133
335
  defaultSpan: number;
134
336
  responsive: boolean;
135
337
  watchDeep: boolean;
338
+ submitText: string;
339
+ cancelText: string;
136
340
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
137
341
  formRef: ({
138
342
  $: import('vue').ComponentInternalInstance;
@@ -37,14 +37,18 @@ var __async = (__this, __arguments, generator) => {
37
37
  step((generator = generator.apply(__this, __arguments)).next());
38
38
  });
39
39
  };
40
- import { defineComponent, useModel, ref, computed, watch, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createVNode, unref, mergeProps, withCtx, createElementVNode, normalizeStyle, Fragment, renderList, createBlock, mergeModels } from "vue";
41
- import { ElForm } from "element-plus";
40
+ import { defineComponent, useModel, ref, computed, watch, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createVNode, unref, mergeProps, withCtx, Fragment, renderList, createBlock, createTextVNode, mergeModels } from "vue";
41
+ import { ElForm, ElButton } from "element-plus";
42
42
  import _sfc_main$1 from "./FormItem.vue.js";
43
43
  /* empty css */
44
44
  const _hoisted_1 = {
45
45
  key: 0,
46
46
  class: "jky-form__title mb-4 text-xl font-semibold"
47
47
  };
48
+ const _hoisted_2 = {
49
+ key: 1,
50
+ class: "jky-form__footer mt-6 flex justify-end gap-2"
51
+ };
48
52
  const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
49
53
  name: "JkyForm"
50
54
  }), {
@@ -61,7 +65,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
61
65
  readonly: { type: Boolean },
62
66
  disabled: { type: Boolean },
63
67
  watchDeep: { type: Boolean, default: true },
68
+ showFooter: { type: Boolean, default: false },
69
+ submitText: { default: "提交" },
70
+ cancelText: { default: "取消" },
71
+ submitDisabled: { type: Boolean },
72
+ cancelDisabled: { type: Boolean },
64
73
  onValidate: {},
74
+ onSubmit: {},
75
+ onReset: {},
65
76
  model: {},
66
77
  rules: {},
67
78
  labelPosition: { default: "right" },
@@ -81,7 +92,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
81
92
  "modelValue": { required: true, default: () => ({}) },
82
93
  "modelModifiers": {}
83
94
  }),
84
- emits: /* @__PURE__ */ mergeModels(["change", "validate"], ["update:modelValue"]),
95
+ emits: /* @__PURE__ */ mergeModels(["change", "validate", "submit", "reset"], ["update:modelValue"]),
85
96
  setup(__props, { expose: __expose, emit: __emit }) {
86
97
  const props = __props;
87
98
  const emit = __emit;
@@ -118,8 +129,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
118
129
  });
119
130
  }
120
131
  function resetFields() {
121
- var _a;
132
+ var _a, _b;
122
133
  (_a = formRef.value) == null ? void 0 : _a.resetFields();
134
+ emit("reset");
135
+ (_b = props.onReset) == null ? void 0 : _b.call(props);
123
136
  }
124
137
  function clearValidate(props2) {
125
138
  var _a;
@@ -128,11 +141,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
128
141
  function getFormInstance() {
129
142
  return formRef.value;
130
143
  }
144
+ function handleSubmit() {
145
+ return __async(this, null, function* () {
146
+ var _a, _b;
147
+ try {
148
+ yield (_a = formRef.value) == null ? void 0 : _a.validate();
149
+ emit("submit", __spreadValues({}, modelValue.value));
150
+ (_b = props.onSubmit) == null ? void 0 : _b.call(props, __spreadValues({}, modelValue.value));
151
+ } catch (error) {
152
+ emit("validate", { valid: false, fields: error.fields });
153
+ }
154
+ });
155
+ }
156
+ function handleCancel() {
157
+ resetFields();
158
+ }
131
159
  __expose({
132
160
  validate,
133
161
  resetFields,
134
162
  clearValidate,
135
- getFormInstance
163
+ getFormInstance,
164
+ formRef
136
165
  });
137
166
  return (_ctx, _cache) => {
138
167
  return openBlock(), createElementBlock("div", {
@@ -148,27 +177,41 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
148
177
  size: __props.size
149
178
  }, _ctx.$attrs), {
150
179
  default: withCtx(() => [
151
- createElementVNode("div", {
152
- class: "grid",
153
- style: normalizeStyle({
154
- gridTemplateColumns: "repeat(12, minmax(0, 1fr))",
155
- gap: `${__props.gutter}px`
156
- })
157
- }, [
158
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item) => {
159
- return openBlock(), createBlock(_sfc_main$1, {
160
- key: item.field,
161
- field: item.field,
162
- config: item,
163
- model: modelValue.value,
164
- readonly: __props.readonly,
165
- disabled: __props.disabled
166
- }, null, 8, ["field", "config", "model", "readonly", "disabled"]);
167
- }), 128))
168
- ], 4)
180
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item) => {
181
+ return openBlock(), createBlock(_sfc_main$1, {
182
+ key: item.field,
183
+ field: item.field,
184
+ config: item,
185
+ model: modelValue.value,
186
+ readonly: __props.readonly,
187
+ disabled: __props.disabled
188
+ }, null, 8, ["field", "config", "model", "readonly", "disabled"]);
189
+ }), 128))
169
190
  ]),
170
191
  _: 1
171
- }, 16, ["model", "label-width", "label-position", "size"])
192
+ }, 16, ["model", "label-width", "label-position", "size"]),
193
+ props.showFooter ? (openBlock(), createElementBlock("div", _hoisted_2, [
194
+ createVNode(unref(ElButton), {
195
+ disabled: __props.cancelDisabled || __props.disabled,
196
+ onClick: handleCancel
197
+ }, {
198
+ default: withCtx(() => [
199
+ createTextVNode(toDisplayString(__props.cancelText), 1)
200
+ ]),
201
+ _: 1
202
+ }, 8, ["disabled"]),
203
+ createVNode(unref(ElButton), {
204
+ type: "primary",
205
+ disabled: __props.submitDisabled || __props.disabled,
206
+ loading: false,
207
+ onClick: handleSubmit
208
+ }, {
209
+ default: withCtx(() => [
210
+ createTextVNode(toDisplayString(__props.submitText), 1)
211
+ ]),
212
+ _: 1
213
+ }, 8, ["disabled"])
214
+ ])) : createCommentVNode("", true)
172
215
  ], 2);
173
216
  };
174
217
  }
@@ -17,21 +17,34 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { defineComponent, computed, withDirectives, openBlock, createElementBlock, normalizeClass, toDisplayString, createBlock, unref, mergeProps, withCtx, createCommentVNode, resolveDynamicComponent, vShow, h } from "vue";
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { defineComponent, computed, openBlock, createElementBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, resolveDynamicComponent, Fragment, createTextVNode, toDisplayString, createCommentVNode, h } from "vue";
21
33
  import { ElFormItem, ElInput, ElInputNumber, ElRate, ElColorPicker, ElCascader, ElSlider, ElSwitch, ElCheckboxGroup, ElCheckbox, ElRadioGroup, ElRadio, ElTimeSelect, ElTimePicker, ElDatePicker, ElSelect, ElOption } from "element-plus";
22
34
  const _hoisted_1 = {
23
35
  key: 0,
24
- class: "jky-form-item__title mb-2 text-base font-medium"
36
+ style: { "display": "none" }
25
37
  };
26
- const _hoisted_2 = {
38
+ const _hoisted_2 = { class: "jky-form-item__title mb-2 text-base font-medium" };
39
+ const _hoisted_3 = {
27
40
  key: 0,
28
41
  class: "flex items-center"
29
42
  };
30
- const _hoisted_3 = {
43
+ const _hoisted_4 = {
31
44
  key: 0,
32
45
  class: "mr-2"
33
46
  };
34
- const _hoisted_4 = {
47
+ const _hoisted_5 = {
35
48
  key: 1,
36
49
  class: "ml-2"
37
50
  };
@@ -77,7 +90,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
77
90
  });
78
91
  const modelValue = computed({
79
92
  get: () => props.model[props.field],
80
- set: (_val) => {
93
+ set: (val) => {
94
+ props.model[props.field] = val;
81
95
  }
82
96
  });
83
97
  const isHidden = computed(() => {
@@ -90,20 +104,71 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
90
104
  }
91
105
  return props.config.hidden || false;
92
106
  });
93
- const spanClass = computed(() => {
94
- const span = props.config.span || 12;
95
- return `col-span-${span}`;
107
+ const formItemProps = computed(() => {
108
+ const config = props.config;
109
+ const _a = config, {
110
+ field,
111
+ type,
112
+ title,
113
+ placeholder,
114
+ componentProps: componentProps2,
115
+ hidden,
116
+ className,
117
+ customStyle,
118
+ children,
119
+ render,
120
+ prepend,
121
+ append,
122
+ prefixIcon,
123
+ suffixIcon,
124
+ clearable,
125
+ filterable,
126
+ multiple,
127
+ options,
128
+ formatValue,
129
+ formatModel,
130
+ noLabelMargin,
131
+ titleRender
132
+ } = _a, rest = __objRest(_a, [
133
+ "field",
134
+ "type",
135
+ "title",
136
+ "placeholder",
137
+ "componentProps",
138
+ "hidden",
139
+ "className",
140
+ "customStyle",
141
+ "children",
142
+ "render",
143
+ "prepend",
144
+ "append",
145
+ "prefixIcon",
146
+ "suffixIcon",
147
+ "clearable",
148
+ "filterable",
149
+ "multiple",
150
+ "options",
151
+ "formatValue",
152
+ "formatModel",
153
+ "noLabelMargin",
154
+ "titleRender"
155
+ ]);
156
+ return rest;
96
157
  });
97
158
  function renderComponent(type) {
98
159
  var _a, _b, _c;
99
160
  const commonProps = __spreadValues({
100
161
  "modelValue": modelValue.value,
101
- "onUpdate:modelValue": (_val) => {
162
+ "onUpdate:modelValue": (val) => {
163
+ props.model[props.field] = val;
102
164
  },
103
165
  "placeholder": props.config.placeholder,
104
- "disabled": props.disabled || props.config.disabled || props.readonly,
166
+ "disabled": props.disabled,
105
167
  "clearable": (_a = props.config.clearable) != null ? _a : true
106
168
  }, componentProps.value);
169
+ const inputNumberProps = type === "input-number" ? __spreadProps(__spreadValues({}, commonProps), {
170
+ modelValue: commonProps.modelValue === "" ? null : commonProps.modelValue
171
+ }) : commonProps;
107
172
  switch (type) {
108
173
  case "input":
109
174
  return h(ElInput, __spreadProps(__spreadValues({}, commonProps), {
@@ -156,7 +221,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
156
221
  default: () => options.map(
157
222
  (option) => h(ElRadio, {
158
223
  key: option.value,
159
- label: option.value,
224
+ value: option.value,
160
225
  disabled: option.disabled
161
226
  }, {
162
227
  default: () => option.label
@@ -167,14 +232,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
167
232
  }
168
233
  case "checkbox-group": {
169
234
  const options = props.config.options || [];
235
+ const arrayModelValue = Array.isArray(modelValue.value) ? modelValue.value : [];
170
236
  return h(
171
237
  ElCheckboxGroup,
172
- __spreadValues({}, commonProps),
238
+ __spreadProps(__spreadValues({}, commonProps), {
239
+ modelValue: arrayModelValue
240
+ }),
173
241
  {
174
242
  default: () => options.map(
175
243
  (option) => h(ElCheckbox, {
176
244
  key: option.value,
177
- label: option.value,
245
+ value: option.value,
178
246
  disabled: option.disabled
179
247
  }, {
180
248
  default: () => option.label
@@ -196,7 +264,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
196
264
  case "rate":
197
265
  return h(ElRate, __spreadValues({}, commonProps));
198
266
  case "input-number":
199
- return h(ElInputNumber, __spreadValues({}, commonProps));
267
+ return h(ElInputNumber, inputNumberProps);
200
268
  case "custom":
201
269
  return (_c = (_b = props.config).render) == null ? void 0 : _c.call(_b, commonProps);
202
270
  default:
@@ -204,37 +272,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
204
272
  }
205
273
  }
206
274
  return (_ctx, _cache) => {
207
- var _a, _b, _c, _d, _e;
208
- return withDirectives((openBlock(), createElementBlock("div", {
209
- class: normalizeClass([[
210
- __props.config.className,
211
- spanClass.value,
212
- ((_a = __props.config.responsiveSpan) == null ? void 0 : _a.xs) ? `xs:col-span-${__props.config.responsiveSpan.xs}` : "",
213
- ((_b = __props.config.responsiveSpan) == null ? void 0 : _b.sm) ? `sm:col-span-${__props.config.responsiveSpan.sm}` : "",
214
- ((_c = __props.config.responsiveSpan) == null ? void 0 : _c.md) ? `md:col-span-${__props.config.responsiveSpan.md}` : "",
215
- ((_d = __props.config.responsiveSpan) == null ? void 0 : _d.lg) ? `lg:col-span-${__props.config.responsiveSpan.lg}` : "",
216
- ((_e = __props.config.responsiveSpan) == null ? void 0 : _e.xl) ? `xl:col-span-${__props.config.responsiveSpan.xl}` : ""
217
- ], "jky-form-item"])
218
- }, [
219
- __props.config.title && !__props.config.label ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(__props.config.title), 1)) : (openBlock(), createBlock(unref(ElFormItem), mergeProps({
220
- key: 1,
221
- label: __props.config.label,
222
- prop: __props.field,
223
- rules: __props.config.rules,
224
- required: __props.config.required
225
- }, _ctx.$attrs), {
226
- default: withCtx(() => [
227
- __props.config.prepend || __props.config.append ? (openBlock(), createElementBlock("div", _hoisted_2, [
228
- __props.config.prepend ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.config.prepend), 1)) : createCommentVNode("", true),
229
- (openBlock(), createBlock(resolveDynamicComponent(renderComponent(__props.config.type || "input")))),
230
- __props.config.append ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.config.append), 1)) : createCommentVNode("", true)
231
- ])) : (openBlock(), createBlock(resolveDynamicComponent(renderComponent(__props.config.type || "input")), { key: 1 }))
275
+ return isHidden.value ? (openBlock(), createElementBlock("div", _hoisted_1)) : __props.config.title && !__props.config.label ? (openBlock(), createBlock(unref(ElFormItem), mergeProps({
276
+ key: 1,
277
+ prop: __props.field
278
+ }, __spreadValues(__spreadValues({}, formItemProps.value), _ctx.$attrs), {
279
+ class: ["jky-form-item", [__props.config.className]],
280
+ style: [__props.config.customStyle]
281
+ }), {
282
+ default: withCtx(() => [
283
+ createElementVNode("div", _hoisted_2, [
284
+ __props.config.titleRender ? (openBlock(), createBlock(resolveDynamicComponent(__props.config.titleRender({ model: modelValue.value, field: __props.field })), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
285
+ createTextVNode(toDisplayString(__props.config.title), 1)
286
+ ], 64))
232
287
  ]),
233
- _: 1
234
- }, 16, ["label", "prop", "rules", "required"]))
235
- ], 2)), [
236
- [vShow, !isHidden.value]
237
- ]);
288
+ (openBlock(), createBlock(resolveDynamicComponent(renderComponent(__props.config.type || "input"))))
289
+ ]),
290
+ _: 1
291
+ }, 16, ["prop", "class", "style"])) : (openBlock(), createBlock(unref(ElFormItem), mergeProps({
292
+ key: 2,
293
+ label: __props.config.label,
294
+ prop: __props.field
295
+ }, __spreadValues(__spreadValues({}, formItemProps.value), _ctx.$attrs), {
296
+ class: ["jky-form-item", [__props.config.className]]
297
+ }), {
298
+ default: withCtx(() => [
299
+ __props.config.prepend || __props.config.append ? (openBlock(), createElementBlock("div", _hoisted_3, [
300
+ __props.config.prepend ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.config.prepend), 1)) : createCommentVNode("", true),
301
+ (openBlock(), createBlock(resolveDynamicComponent(renderComponent(__props.config.type || "input")))),
302
+ __props.config.append ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(__props.config.append), 1)) : createCommentVNode("", true)
303
+ ])) : (openBlock(), createBlock(resolveDynamicComponent(renderComponent(__props.config.type || "input")), { key: 1 }))
304
+ ]),
305
+ _: 1
306
+ }, 16, ["label", "prop", "class"]));
238
307
  };
239
308
  }
240
309
  }));
@@ -1,3 +1,9 @@
1
+ :root {
2
+ /* 表单组件间距 */
3
+ /* --jky-form-item-gap: 12px; */
4
+ }
5
+
6
+
1
7
  /* Form 组件样式 */
2
8
  .jky-form {
3
9
  /* 表单容器样式 */
@@ -5,6 +11,8 @@
5
11
  .jky-form__title {
6
12
  /* 表单标题样式 */
7
13
  }
14
+
15
+
8
16
  /* FormItem 组件样式 */
9
17
  .jky-form-item {
10
18
  /* 表单项容器样式 */