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