@vunk/form 2.13.0 → 2.13.1

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,6 +1,6 @@
1
- import { formItemProps, ElFormItem, ElIcon, ElTooltip, ElButton, useGlobalConfig } from 'element-plus';
1
+ import { formItemProps, ElFormItem, ElTooltip, ElIcon, ElButton, useGlobalConfig } from 'element-plus';
2
2
  import { bindPropsFactory } from '@vunk/core/shared/utils-vue';
3
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, mergeProps, createSlots, withCtx, renderSlot, resolveDynamicComponent, createCommentVNode, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createVNode, renderList } from 'vue';
3
+ import { defineComponent, openBlock, createBlock, mergeProps, withCtx, renderSlot, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, normalizeProps, guardReactiveProps, createVNode, computed, h } from 'vue';
4
4
  import { createFormItemBindProps } from '@vunk/form/shared/element-plus';
5
5
  import { useComputedReadonly } from '@vunk/form/composables';
6
6
  import { isPlainObject } from '@vunk/core/shared/utils-object';
@@ -55,140 +55,65 @@ var ctx = /*#__PURE__*/Object.freeze({
55
55
  props: props
56
56
  });
57
57
 
58
- var _sfc_main = defineComponent({
59
- name: "VkfFormItem",
60
- components: {
61
- ElFormItem,
62
- ElIcon,
63
- ElTooltip,
64
- Warning: warning_default,
65
- ElButton
58
+ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
59
+ ...{
60
+ inheritAttrs: false
66
61
  },
67
- props,
68
- setup(props2, { slots }) {
69
- const formItemBindProps = createFormItemBindProps(props2, ["rules"]);
70
- const readonly = useComputedReadonly(props2);
71
- const globalConfig = useGlobalConfig();
72
- const localeName = computed(() => {
73
- return globalConfig.value?.locale?.name;
74
- });
75
- const requiredMessage = `${props2.label || "\u8BE5\u5B57\u6BB5"}\u4E0D\u80FD\u4E3A\u7A7A`;
76
- const setDefaultMessage = (rule) => {
77
- if (localeName.value === "zh-cn") {
78
- if (rule.message) return;
79
- if (rule.required) {
80
- rule.message = requiredMessage;
81
- }
82
- const ruleInfo = PATTERN_OPTIONS.find((i) => i.value === rule.pattern);
83
- if (ruleInfo) {
84
- rule.message = `\u8F93\u5165 ${props2.label || "\u8BE5\u5B57\u6BB5"} ${ruleInfo.title}`;
85
- }
86
- }
87
- };
88
- const rules = computed(() => {
89
- let data = [];
90
- if (!props2.rules && props2.required) {
91
- data.push({
92
- required: true
93
- });
94
- }
95
- if (isPlainObject(props2.rules)) {
96
- data = [props2.rules];
97
- }
98
- if (Array.isArray(props2.rules)) {
99
- data = props2.rules;
100
- if (props2.required && !props2.rules.find((item) => item.required)) {
101
- data.push({
102
- required: true
103
- });
104
- }
105
- }
106
- data = data.filter((rule) => {
107
- if (!rule) return;
108
- if (isPlainObject(rule)) {
109
- const enableKeys = Object.keys(rule).filter((key) => !key.startsWith("data-"));
110
- return enableKeys.length > 0;
111
- }
112
- });
113
- data.forEach((rule) => {
114
- setDefaultMessage(rule);
115
- });
116
- return data;
117
- });
118
- const elFormItemSlots = computed(() => {
119
- const slots2 = {};
120
- const keys = ["label", "default", "error"];
121
- const formItemSlots = props2.formItemSlots;
122
- if (formItemSlots) {
123
- Object.keys(formItemSlots).forEach((key) => {
124
- if (keys.includes(key)) {
125
- slots2[key] = formItemSlots?.[key];
126
- }
127
- });
128
- }
129
- return slots2;
130
- });
131
- const customSlots = computed(() => {
132
- const theSlots = {
133
- labelActions: slots?.labelActions ? () => slots.labelActions?.() : void 0
134
- };
135
- const keys = ["labelActions", "after"];
136
- const formItemSlots = props2.formItemSlots;
137
- formItemSlots && Object.keys(formItemSlots).filter((key) => keys.includes(key)).forEach((key) => {
138
- const slot = formItemSlots?.[key];
139
- if (slot) {
140
- theSlots[key] = slot;
141
- }
142
- });
143
- return theSlots;
144
- });
145
- return {
146
- formItemBindProps,
147
- readonly,
148
- rules,
149
- localeName,
150
- elFormItemSlots,
151
- customSlots
152
- };
62
+ __name: "core",
63
+ props: {
64
+ labelTip: {
65
+ type: String,
66
+ default: ""
67
+ },
68
+ formItemTip: {
69
+ type: String,
70
+ default: ""
71
+ },
72
+ formItemTipClass: null
73
+ },
74
+ setup(__props, { expose: __expose }) {
75
+ __expose();
76
+ const __returned__ = { get ElFormItem() {
77
+ return ElFormItem;
78
+ }, get ElTooltip() {
79
+ return ElTooltip;
80
+ }, get ElIcon() {
81
+ return ElIcon;
82
+ }, get ElButton() {
83
+ return ElButton;
84
+ }, get Warning() {
85
+ return warning_default;
86
+ } };
87
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
88
+ return __returned__;
153
89
  }
154
90
  });
155
91
 
156
92
  const _hoisted_1 = {
157
93
  key: 1,
158
- class: "vk-form-item-label__actions"
94
+ class: "vkf-form-item-label__actions"
159
95
  };
160
96
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
161
- const _component_Warning = resolveComponent("Warning");
162
- const _component_ElIcon = resolveComponent("ElIcon");
163
- const _component_ElButton = resolveComponent("ElButton");
164
- const _component_ElTooltip = resolveComponent("ElTooltip");
165
- const _component_ElFormItem = resolveComponent("ElFormItem");
166
- return openBlock(), createBlock(_component_ElFormItem, mergeProps(_ctx.formItemBindProps, {
167
- ref: _ctx.elRef,
97
+ return openBlock(), createBlock($setup["ElFormItem"], mergeProps(_ctx.$attrs, {
168
98
  class: ["vkf-form-item", {
169
- "is-readonly": _ctx.readonly,
170
- "vkf-form-item--inline": _ctx.inline,
171
- "is-empty-label": !_ctx.label,
172
- "is-information": _ctx.information,
173
- "has-label-actions": _ctx.customSlots.labelActions
174
- }],
175
- size: _ctx.formItemSize,
176
- rules: _ctx.rules
177
- }), createSlots({
99
+ "has-label-actions": _ctx.$slots.labelActions
100
+ }]
101
+ }), {
178
102
  default: withCtx(() => [
103
+ renderSlot(_ctx.$slots, "before"),
179
104
  renderSlot(_ctx.$slots, "default"),
180
- _ctx.customSlots.after ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.customSlots.after), { key: 0 })) : createCommentVNode("v-if", true),
181
- _ctx.formItemTip ? (openBlock(), createElementBlock(
105
+ renderSlot(_ctx.$slots, "after"),
106
+ $props.formItemTip ? (openBlock(), createElementBlock(
182
107
  "div",
183
108
  {
184
- key: 1,
185
- class: normalizeClass(["vkf-form-item__tip", _ctx.formItemTipClass])
109
+ key: 0,
110
+ class: normalizeClass(["vkf-form-item__tip", $props.formItemTipClass])
186
111
  },
187
112
  [
188
113
  createElementVNode(
189
114
  "span",
190
115
  null,
191
- toDisplayString(_ctx.formItemTip),
116
+ toDisplayString($props.formItemTip),
192
117
  1
193
118
  /* TEXT */
194
119
  )
@@ -197,32 +122,28 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
197
122
  /* CLASS */
198
123
  )) : createCommentVNode("v-if", true)
199
124
  ]),
200
- _: 2
201
- /* DYNAMIC */
202
- }, [
203
- !_ctx.formItemSlots?.label && (_ctx.label || _ctx.labelTip) ? {
204
- name: "label",
205
- fn: withCtx(() => [
125
+ label: withCtx((e) => [
126
+ renderSlot(_ctx.$slots, "label", normalizeProps(guardReactiveProps(e)), () => [
206
127
  createElementVNode(
207
128
  "span",
208
129
  null,
209
- toDisplayString(_ctx.label),
130
+ toDisplayString(e.label),
210
131
  1
211
132
  /* TEXT */
212
133
  ),
213
- _ctx.labelTip ? (openBlock(), createBlock(_component_ElTooltip, {
134
+ $props.labelTip ? (openBlock(), createBlock($setup["ElTooltip"], {
214
135
  key: 0,
215
- content: _ctx.labelTip
136
+ content: $props.labelTip
216
137
  }, {
217
138
  default: withCtx(() => [
218
- createVNode(_component_ElButton, {
139
+ createVNode($setup["ElButton"], {
219
140
  text: "",
220
141
  class: "vkf-form-item-label-tip-button"
221
142
  }, {
222
143
  default: withCtx(() => [
223
- createVNode(_component_ElIcon, null, {
144
+ createVNode($setup["ElIcon"], null, {
224
145
  default: withCtx(() => [
225
- createVNode(_component_Warning)
146
+ createVNode($setup["Warning"])
226
147
  ]),
227
148
  _: 1
228
149
  /* STABLE */
@@ -235,23 +156,97 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
235
156
  _: 1
236
157
  /* STABLE */
237
158
  }, 8, ["content"])) : createCommentVNode("v-if", true),
238
- _ctx.customSlots.labelActions ? (openBlock(), createElementBlock("div", _hoisted_1, [
239
- (openBlock(), createBlock(resolveDynamicComponent(_ctx.customSlots.labelActions)))
159
+ _ctx.$slots.labelActions ? (openBlock(), createElementBlock("div", _hoisted_1, [
160
+ renderSlot(_ctx.$slots, "labelActions")
240
161
  ])) : createCommentVNode("v-if", true)
241
- ]),
242
- key: "0"
243
- } : void 0,
244
- renderList(_ctx.elFormItemSlots, (item, key) => {
245
- return {
246
- name: key,
247
- fn: withCtx((e) => [
248
- (openBlock(), createBlock(resolveDynamicComponent(item?.(e))))
249
- ])
250
- };
251
- })
252
- ]), 1040, ["class", "size", "rules"]);
162
+ ])
163
+ ]),
164
+ error: withCtx((e) => [
165
+ renderSlot(_ctx.$slots, "error", normalizeProps(guardReactiveProps(e)))
166
+ ]),
167
+ _: 3
168
+ /* FORWARDED */
169
+ }, 16, ["class"]);
253
170
  }
254
- var VkfFormItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/form-item/src/index.vue"]]);
171
+ var FormItemCore = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/form-item/src/core.vue"]]);
172
+
173
+ var _sfc_main = /* @__PURE__ */ defineComponent({
174
+ name: "VkfFormItem",
175
+ props,
176
+ setup(props2, {
177
+ slots
178
+ }) {
179
+ const formItemBindProps = createFormItemBindProps(props2, ["rules"]);
180
+ const readonly = useComputedReadonly(props2);
181
+ const globalConfig = useGlobalConfig();
182
+ const localeName = computed(() => {
183
+ return globalConfig.value?.locale?.name;
184
+ });
185
+ const requiredMessage = `${props2.label || "\u8BE5\u5B57\u6BB5"}\u4E0D\u80FD\u4E3A\u7A7A`;
186
+ const setDefaultMessage = rule => {
187
+ if (localeName.value === "zh-cn") {
188
+ if (rule.message) return;
189
+ if (rule.required) {
190
+ rule.message = requiredMessage;
191
+ }
192
+ const ruleInfo = PATTERN_OPTIONS.find(i => i.value === rule.pattern);
193
+ if (ruleInfo) {
194
+ rule.message = `\u8F93\u5165 ${props2.label || "\u8BE5\u5B57\u6BB5"} ${ruleInfo.title}`;
195
+ }
196
+ }
197
+ };
198
+ const rules = computed(() => {
199
+ let data = [];
200
+ if (!props2.rules && props2.required) {
201
+ data.push({
202
+ required: true
203
+ });
204
+ }
205
+ if (isPlainObject(props2.rules)) {
206
+ data = [props2.rules];
207
+ }
208
+ if (Array.isArray(props2.rules)) {
209
+ data = props2.rules;
210
+ if (props2.required && !props2.rules.find(item => item.required)) {
211
+ data.push({
212
+ required: true
213
+ });
214
+ }
215
+ }
216
+ data = data.filter(rule => {
217
+ if (!rule) return;
218
+ if (isPlainObject(rule)) {
219
+ const enableKeys = Object.keys(rule).filter(key => !key.startsWith("data-"));
220
+ return enableKeys.length > 0;
221
+ }
222
+ });
223
+ data.forEach(rule => {
224
+ setDefaultMessage(rule);
225
+ });
226
+ return data;
227
+ });
228
+ return () => h(FormItemCore, {
229
+ ...formItemBindProps.value,
230
+ ref: props2.elRef,
231
+ class: {
232
+ "is-readonly": readonly.value,
233
+ "vkf-form-item--inline": props2.inline,
234
+ "is-empty-label": !props2.label,
235
+ "is-information": props2.information
236
+ },
237
+ size: props2.formItemSize,
238
+ rules: rules.value,
239
+ formItemTip: props2.formItemTip,
240
+ formItemTipClass: props2.formItemTipClass,
241
+ labelTip: props2.labelTip
242
+ }, {
243
+ ...slots,
244
+ ...props2.formItemSlots
245
+ });
246
+ }
247
+ });
248
+
249
+ var VkfFormItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/form-item/src/index.vue"]]);
255
250
 
256
251
  var types = /*#__PURE__*/Object.freeze({
257
252
  __proto__: null