@vunk/form 2.8.0 → 2.9.0

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.
@@ -14,6 +14,7 @@ var templatesLayout = require('@vunk/form/components/templates-layout');
14
14
  var utilsObject = require('@vunk/core/shared/utils-object');
15
15
  var form = require('@vunk/form/shared/form');
16
16
  var rendererData = require('@vunk/form/components/renderer-data');
17
+ var object = require('@vunk/shared/object');
17
18
  var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
18
19
 
19
20
  const props = {
@@ -141,14 +142,19 @@ var _sfc_main = vue.defineComponent({
141
142
  a.push(c);
142
143
  return a;
143
144
  }
144
- if (Reflect.has(c, "templateIf")) {
145
+ if (!c.templateLayout?.allowEmpty && Reflect.has(c, "templateIf")) {
145
146
  const templateIfFunc = form.genTemplateIfFunc(c.templateIf);
146
147
  const flag = templateIfFunc(props2.data);
147
148
  if (!flag) {
148
149
  return a;
149
150
  }
150
151
  }
151
- const colItem = genColItem(c, props2.colSource);
152
+ const colItem = genColItem(c, object.pickObject({
153
+ ...props2.colSource,
154
+ ...c.templateLayout
155
+ }, {
156
+ excludes: ["allowEmpty", "span"]
157
+ }));
152
158
  if (!lastRow || getRowEmptySpan(lastRow) < itemSpan) {
153
159
  a.push(genRowItem(colItem, props2.rowSource));
154
160
  } else {
@@ -10,6 +10,7 @@ import { VkfTemplatesLayout } from '@vunk/form/components/templates-layout';
10
10
  import { pickObject } from '@vunk/core/shared/utils-object';
11
11
  import { genTemplateIfFunc } from '@vunk/form/shared/form';
12
12
  import { VkfRendererData } from '@vunk/form/components/renderer-data';
13
+ import { pickObject as pickObject$1 } from '@vunk/shared/object';
13
14
  import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
14
15
 
15
16
  const props = {
@@ -137,14 +138,19 @@ var _sfc_main = defineComponent({
137
138
  a.push(c);
138
139
  return a;
139
140
  }
140
- if (Reflect.has(c, "templateIf")) {
141
+ if (!c.templateLayout?.allowEmpty && Reflect.has(c, "templateIf")) {
141
142
  const templateIfFunc = genTemplateIfFunc(c.templateIf);
142
143
  const flag = templateIfFunc(props2.data);
143
144
  if (!flag) {
144
145
  return a;
145
146
  }
146
147
  }
147
- const colItem = genColItem(c, props2.colSource);
148
+ const colItem = genColItem(c, pickObject$1({
149
+ ...props2.colSource,
150
+ ...c.templateLayout
151
+ }, {
152
+ excludes: ["allowEmpty", "span"]
153
+ }));
148
154
  if (!lastRow || getRowEmptySpan(lastRow) < itemSpan) {
149
155
  a.push(genRowItem(colItem, props2.rowSource));
150
156
  } else {
@@ -1,12 +1,25 @@
1
1
  import { __VkfTemplatesDefault } from '@vunk/form/components/templates-default';
2
2
  import { __VkfTemplatesLayout } from '@vunk/form/components/templates-layout';
3
- export type FormItem<P extends string = string> = (__VkfTemplatesDefault.Source<P> | __VkfTemplatesLayout.ElRowSource<FormItem<P>> | __VkfTemplatesLayout.ElColSource<FormItem<P>> | __VkfTemplatesLayout.VkfFlexSource<FormItem<P>>) & {
3
+ import { VueComponentPropsType } from '@vunk/shared';
4
+ import { ElCol } from 'element-plus';
5
+ export type LayoutProps = {
4
6
  /**
5
- * 如果开启 props.itemLayout,那么
7
+ * 如果开启 props.layout,那么
6
8
  * span 将生效
7
9
  * 1-24 之间的数字
8
10
  */
9
11
  span?: number;
12
+ /**
13
+ * layout 配置
14
+ */
15
+ templateLayout?: TemplateLayout;
10
16
  };
17
+ export type FormItem<P extends string = string> = (__VkfTemplatesDefault.Source<P> | __VkfTemplatesLayout.ElRowSource<FormItem<P>> | __VkfTemplatesLayout.ElColSource<FormItem<P>> | __VkfTemplatesLayout.VkfFlexSource<FormItem<P>>) & LayoutProps;
11
18
  export type ColItem = __VkfTemplatesLayout.ElColSource<FormItem>;
12
19
  export type RowItem = __VkfTemplatesLayout.ElRowSource<ColItem>;
20
+ export interface TemplateLayout extends VueComponentPropsType<typeof ElCol> {
21
+ /**
22
+ * 允许空渲染
23
+ */
24
+ allowEmpty?: boolean;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {