@vue-start/pro 0.4.0 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -743,7 +743,6 @@ declare const proSearchFormProps: () => {
743
743
  */
744
744
  model: {
745
745
  type: PropType<Record<string, any>>;
746
- required: boolean;
747
746
  };
748
747
  /**
749
748
  * 初始化触发 onFinish
@@ -889,6 +888,7 @@ interface IProFormListProvide {
889
888
  pathList: (string | number)[];
890
889
  }
891
890
  declare const useProFormList: () => IProFormListProvide;
891
+ declare const provideProFormList: (ctx: IProFormListProvide) => void;
892
892
  declare const proFormListProps: () => {
893
893
  rowKey: {
894
894
  type: StringConstructor;
@@ -958,4 +958,4 @@ declare const generateId: () => string;
958
958
  */
959
959
  declare const createExpose: (methods: string[], targetRef: Ref$1) => {};
960
960
 
961
- export { BooleanObjType, BooleanRulesObjType, CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, FieldNames, FormItemProps, GridProps, ICurdAction, ICurdAddAction, ICurdCurrentMode, ICurdOperateOpts, ICurdState, ICurdSubAction, IElementConfig, IHighConfig, IListData, IOperateItem, IProCurdProvide, IProFormProvideExtra, IProModuleProvide, IProTableProvide, IProTableProvideExtra, IRequestOpts, ISearchMode, ITableOperate, InternalNamePath, NamePath, ProCurd, ProCurdAddOrEditProps, ProCurdListProps, ProCurdProps, ProFormItemProps, ProFormListProps, ProFormProps, ProModalCurd, ProModalCurdProps, ProModule, ProModuleProps, ProPageCurd, ProPageCurdProps, ProSearchFormProps, ProTableProps, RequestAction, SearchMode, TActionEvent, TActionState, TColumn, TColumns, TCurdActionEvent, TData, TDefaultValueType, TElementMap, TOption, TOptions, TPageState, TTableColumn, TTableColumns, TValueType, Wrapper, convertPathToList, createCurdDesc, createCurdForm, createCurdList, createExpose, createForm, createFormItemCompFn, createFormList, createGrid, createSearchForm, createTable, defaultPage, findTargetInTree, findTargetListInTree, generateId, getColumnFormItemName, getColumnValueType, getFirstPropName, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProModule, renderElement, renderElements, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
961
+ export { BooleanObjType, BooleanRulesObjType, CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, FieldNames, FormItemProps, GridProps, ICurdAction, ICurdAddAction, ICurdCurrentMode, ICurdOperateOpts, ICurdState, ICurdSubAction, IElementConfig, IHighConfig, IListData, IOperateItem, IProCurdProvide, IProFormProvideExtra, IProModuleProvide, IProTableProvide, IProTableProvideExtra, IRequestOpts, ISearchMode, ITableOperate, InternalNamePath, NamePath, ProCurd, ProCurdAddOrEditProps, ProCurdListProps, ProCurdProps, ProFormItemProps, ProFormListProps, ProFormProps, ProModalCurd, ProModalCurdProps, ProModule, ProModuleProps, ProPageCurd, ProPageCurdProps, ProSearchFormProps, ProTableProps, RequestAction, SearchMode, TActionEvent, TActionState, TColumn, TColumns, TCurdActionEvent, TData, TDefaultValueType, TElementMap, TOption, TOptions, TPageState, TTableColumn, TTableColumns, TValueType, Wrapper, convertPathToList, createCurdDesc, createCurdForm, createCurdList, createExpose, createForm, createFormItemCompFn, createFormList, createGrid, createSearchForm, createTable, defaultPage, findTargetInTree, findTargetListInTree, generateId, getColumnFormItemName, getColumnValueType, getFirstPropName, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProFormList, provideProModule, renderElement, renderElements, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
package/dist/index.es.js CHANGED
@@ -1943,6 +1943,114 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1943
1943
  });
1944
1944
  };
1945
1945
 
1946
+ /**
1947
+ * ProFormList ctx
1948
+ */
1949
+
1950
+ var ProFormListKey = Symbol("pro-form-list");
1951
+ var useProFormList = function useProFormList() {
1952
+ return inject(ProFormListKey);
1953
+ };
1954
+ var provideProFormList = function provideProFormList(ctx) {
1955
+ provide(ProFormListKey, ctx);
1956
+ };
1957
+ var FormListProvider = defineComponent({
1958
+ props: {
1959
+ pathList: {
1960
+ type: Array
1961
+ }
1962
+ },
1963
+ setup: function setup(props, _ref) {
1964
+ var slots = _ref.slots;
1965
+ provideProFormList({
1966
+ pathList: props.pathList
1967
+ });
1968
+ return function () {
1969
+ var _slots$default;
1970
+
1971
+ return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
1972
+ };
1973
+ }
1974
+ });
1975
+
1976
+ var createFormList = function createFormList(FormItem) {
1977
+ return defineComponent({
1978
+ props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
1979
+ //每行默认id
1980
+ rowKey: {
1981
+ type: String,
1982
+ "default": "id"
1983
+ }
1984
+ }),
1985
+ setup: function setup(props, _ref2) {
1986
+ var slots = _ref2.slots;
1987
+
1988
+ var _useProForm = useProForm(),
1989
+ formState = _useProForm.formState,
1990
+ readonly = _useProForm.readonly;
1991
+
1992
+ var formListCtx = useProFormList();
1993
+ var nameList = convertPathToList(props.name);
1994
+ var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
1995
+
1996
+ var handleAdd = function handleAdd() {
1997
+ var targetList = get(formState, path);
1998
+
1999
+ if (!isArray(targetList)) {
2000
+ targetList = [];
2001
+ }
2002
+
2003
+ targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
2004
+ set(formState, path, targetList);
2005
+ };
2006
+
2007
+ var handleRemove = function handleRemove(index) {
2008
+ var targetList = get(formState, path);
2009
+
2010
+ if (size(targetList) <= 0) {
2011
+ return;
2012
+ }
2013
+
2014
+ targetList.splice(index, 1);
2015
+ };
2016
+
2017
+ return function () {
2018
+ var _slots$add;
2019
+
2020
+ return createVNode(FormItem, omit(props, "rowKey"), {
2021
+ "default": function _default() {
2022
+ return [map(get(formState, path), function (item, index) {
2023
+ var _slots$default2, _slots$itemAdd, _slots$itemMinus;
2024
+
2025
+ return createVNode(FormListProvider, {
2026
+ "key": item[props.rowKey] || index,
2027
+ "pathList": [].concat(_toConsumableArray(path), [index])
2028
+ }, {
2029
+ "default": function _default() {
2030
+ return [createVNode("div", {
2031
+ "class": "pro-form-list-item"
2032
+ }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && createVNode(Fragment, null, [createVNode("div", {
2033
+ "class": "pro-form-list-item-add",
2034
+ "onClick": handleAdd
2035
+ }, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), createVNode("div", {
2036
+ "class": "pro-form-list-item-minus",
2037
+ "onClick": function onClick() {
2038
+ return handleRemove(index);
2039
+ }
2040
+ }, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
2041
+ }
2042
+ });
2043
+ }), !readonly.value && createVNode("div", {
2044
+ "class": "pro-form-list-add",
2045
+ "onClick": handleAdd
2046
+ }, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
2047
+ }
2048
+ });
2049
+ };
2050
+ }
2051
+ });
2052
+ };
2053
+
1946
2054
  var ProFormKey = Symbol("pro-form");
1947
2055
  var useProForm = function useProForm() {
1948
2056
  return inject(ProFormKey);
@@ -1954,24 +2062,24 @@ var provideProForm = function provideProForm(ctx) {
1954
2062
 
1955
2063
  var proFormProps = function proFormProps() {
1956
2064
  return {
1957
- /**
1958
- * 同 antd 或 element form中的model
2065
+ /**
2066
+ * 同 antd 或 element form中的model
1959
2067
  */
1960
2068
  model: {
1961
2069
  type: Object
1962
2070
  },
1963
2071
 
1964
- /**
1965
- * 子组件是否只读样式
2072
+ /**
2073
+ * 子组件是否只读样式
1966
2074
  */
1967
2075
  readonly: {
1968
2076
  type: Boolean,
1969
2077
  "default": undefined
1970
2078
  },
1971
2079
 
1972
- /**
1973
- * FormComponent 根据此项来确定组件是否显示
1974
- * rules 根据rules中方法生成showState对象
2080
+ /**
2081
+ * FormComponent 根据此项来确定组件是否显示
2082
+ * rules 根据rules中方法生成showState对象
1975
2083
  */
1976
2084
  showState: {
1977
2085
  type: Object
@@ -1980,8 +2088,8 @@ var proFormProps = function proFormProps() {
1980
2088
  type: Object
1981
2089
  },
1982
2090
 
1983
- /**
1984
- * 是否只读
2091
+ /**
2092
+ * 是否只读
1985
2093
  */
1986
2094
  readonlyState: {
1987
2095
  type: Object
@@ -1990,8 +2098,8 @@ var proFormProps = function proFormProps() {
1990
2098
  type: Object
1991
2099
  },
1992
2100
 
1993
- /**
1994
- * 是否disabled
2101
+ /**
2102
+ * 是否disabled
1995
2103
  */
1996
2104
  disableState: {
1997
2105
  type: Object
@@ -2000,8 +2108,8 @@ var proFormProps = function proFormProps() {
2000
2108
  type: Object
2001
2109
  },
2002
2110
 
2003
- /**
2004
- *
2111
+ /**
2112
+ *
2005
2113
  */
2006
2114
  columns: {
2007
2115
  type: Array
@@ -2010,30 +2118,30 @@ var proFormProps = function proFormProps() {
2010
2118
  type: Object
2011
2119
  },
2012
2120
 
2013
- /**
2014
- * 展示控件集合,readonly模式下使用这些组件渲染
2121
+ /**
2122
+ * 展示控件集合,readonly模式下使用这些组件渲染
2015
2123
  */
2016
2124
  elementMap: {
2017
2125
  type: Object
2018
2126
  },
2019
2127
 
2020
- /**
2021
- * 录入控件集合
2128
+ /**
2129
+ * 录入控件集合
2022
2130
  */
2023
2131
  formElementMap: {
2024
2132
  type: Object
2025
2133
  },
2026
2134
 
2027
- /**
2028
- * 是否启用rules验证
2135
+ /**
2136
+ * 是否启用rules验证
2029
2137
  */
2030
2138
  needRules: {
2031
2139
  type: Boolean,
2032
2140
  "default": true
2033
2141
  },
2034
2142
 
2035
- /**
2036
- * provide传递
2143
+ /**
2144
+ * provide传递
2037
2145
  */
2038
2146
  provideExtra: {
2039
2147
  type: Object
@@ -2123,7 +2231,9 @@ var createForm = function createForm(Form, Grid) {
2123
2231
  columns: columns,
2124
2232
  //
2125
2233
  formRef: formRef
2126
- }, props.provideExtra));
2234
+ }, props.provideExtra)); //为了不warning ...
2235
+
2236
+ provideProFormList({});
2127
2237
  var invalidKeys = keys(proFormProps());
2128
2238
  var gridKeys = keys(omit(Grid.props, "items"));
2129
2239
  return function () {
@@ -2165,40 +2275,39 @@ var SearchMode;
2165
2275
 
2166
2276
  var proSearchFormProps = function proSearchFormProps() {
2167
2277
  return {
2168
- /**
2169
- * 需要监听的对象
2278
+ /**
2279
+ * 需要监听的对象
2170
2280
  */
2171
2281
  model: {
2172
- type: Object,
2173
- required: true
2282
+ type: Object
2174
2283
  },
2175
2284
 
2176
- /**
2177
- * 初始化触发 onFinish
2285
+ /**
2286
+ * 初始化触发 onFinish
2178
2287
  */
2179
2288
  initEmit: {
2180
2289
  type: Boolean,
2181
2290
  "default": true
2182
2291
  },
2183
2292
 
2184
- /**
2185
- * 模式 自动触发或者手动触发 onFinish
2293
+ /**
2294
+ * 模式 自动触发或者手动触发 onFinish
2186
2295
  */
2187
2296
  searchMode: {
2188
2297
  type: String,
2189
2298
  "default": SearchMode.AUTO
2190
2299
  },
2191
2300
 
2192
- /**
2193
- * 配置 同ProForm中的columns
2194
- * 可以根据column中valueType计算出默认的debounceKeys
2301
+ /**
2302
+ * 配置 同ProForm中的columns
2303
+ * 可以根据column中valueType计算出默认的debounceKeys
2195
2304
  */
2196
2305
  columns: {
2197
2306
  type: Array
2198
2307
  },
2199
2308
 
2200
- /**
2201
- * 需要debounce处理的字段
2309
+ /**
2310
+ * 需要debounce处理的字段
2202
2311
  */
2203
2312
  debounceKeys: {
2204
2313
  type: Array
@@ -2215,9 +2324,9 @@ var proSearchFormProps = function proSearchFormProps() {
2215
2324
  };
2216
2325
  };
2217
2326
 
2218
- /**
2219
- * 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
2220
- * 针对传入的model(监听对象)做相应的finish(回调)处理
2327
+ /**
2328
+ * 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
2329
+ * 针对传入的model(监听对象)做相应的finish(回调)处理
2221
2330
  */
2222
2331
  var createSearchForm = function createSearchForm(Form, Props) {
2223
2332
  return defineComponent({
@@ -2288,116 +2397,6 @@ var createSearchForm = function createSearchForm(Form, Props) {
2288
2397
  });
2289
2398
  };
2290
2399
 
2291
- /**
2292
- * ProFormList ctx
2293
- */
2294
-
2295
- var ProFormListKey = Symbol("pro-form-list");
2296
- var useProFormList = function useProFormList() {
2297
- return inject(ProFormListKey);
2298
- };
2299
-
2300
- var provideProFormList = function provideProFormList(ctx) {
2301
- provide(ProFormListKey, ctx);
2302
- };
2303
-
2304
- var FormListProvider = defineComponent({
2305
- props: {
2306
- pathList: {
2307
- type: Array
2308
- }
2309
- },
2310
- setup: function setup(props, _ref) {
2311
- var slots = _ref.slots;
2312
- provideProFormList({
2313
- pathList: props.pathList
2314
- });
2315
- return function () {
2316
- var _slots$default;
2317
-
2318
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
2319
- };
2320
- }
2321
- });
2322
-
2323
- var createFormList = function createFormList(FormItem) {
2324
- return defineComponent({
2325
- props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
2326
- //每行默认id
2327
- rowKey: {
2328
- type: String,
2329
- "default": "id"
2330
- }
2331
- }),
2332
- setup: function setup(props, _ref2) {
2333
- var slots = _ref2.slots;
2334
-
2335
- var _useProForm = useProForm(),
2336
- formState = _useProForm.formState,
2337
- readonly = _useProForm.readonly;
2338
-
2339
- var formListCtx = useProFormList();
2340
- var nameList = convertPathToList(props.name);
2341
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
2342
-
2343
- var handleAdd = function handleAdd() {
2344
- var targetList = get(formState, path);
2345
-
2346
- if (!isArray(targetList)) {
2347
- targetList = [];
2348
- }
2349
-
2350
- targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
2351
- set(formState, path, targetList);
2352
- };
2353
-
2354
- var handleRemove = function handleRemove(index) {
2355
- var targetList = get(formState, path);
2356
-
2357
- if (size(targetList) <= 0) {
2358
- return;
2359
- }
2360
-
2361
- targetList.splice(index, 1);
2362
- };
2363
-
2364
- return function () {
2365
- var _slots$add;
2366
-
2367
- return createVNode(FormItem, omit(props, "rowKey"), {
2368
- "default": function _default() {
2369
- return [map(get(formState, path), function (item, index) {
2370
- var _slots$default2, _slots$itemAdd, _slots$itemMinus;
2371
-
2372
- return createVNode(FormListProvider, {
2373
- "key": item[props.rowKey] || index,
2374
- "pathList": [].concat(_toConsumableArray(path), [index])
2375
- }, {
2376
- "default": function _default() {
2377
- return [createVNode("div", {
2378
- "class": "pro-form-list-item"
2379
- }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && createVNode(Fragment, null, [createVNode("div", {
2380
- "class": "pro-form-list-item-add",
2381
- "onClick": handleAdd
2382
- }, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), createVNode("div", {
2383
- "class": "pro-form-list-item-minus",
2384
- "onClick": function onClick() {
2385
- return handleRemove(index);
2386
- }
2387
- }, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
2388
- }
2389
- });
2390
- }), !readonly.value && createVNode("div", {
2391
- "class": "pro-form-list-add",
2392
- "onClick": handleAdd
2393
- }, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
2394
- }
2395
- });
2396
- };
2397
- }
2398
- });
2399
- };
2400
-
2401
2400
  var proFormItemProps = function proFormItemProps() {
2402
2401
  return {
2403
2402
  readonly: {
@@ -2676,4 +2675,4 @@ var createTable = function createTable(Table, Props) {
2676
2675
  });
2677
2676
  };
2678
2677
 
2679
- export { CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, ProCurd, ProModalCurd, ProModule, ProPageCurd, RequestAction, SearchMode, Wrapper, convertPathToList, createCurdDesc, createCurdForm, createCurdList, createExpose, createForm, createFormItemCompFn, createFormList, createGrid, createSearchForm, createTable, defaultPage, findTargetInTree, findTargetListInTree, generateId, getColumnFormItemName, getColumnValueType, getFirstPropName, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProModule, renderElement, renderElements, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
2678
+ export { CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, ProCurd, ProModalCurd, ProModule, ProPageCurd, RequestAction, SearchMode, Wrapper, convertPathToList, createCurdDesc, createCurdForm, createCurdList, createExpose, createForm, createFormItemCompFn, createFormList, createGrid, createSearchForm, createTable, defaultPage, findTargetInTree, findTargetListInTree, generateId, getColumnFormItemName, getColumnValueType, getFirstPropName, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProFormList, provideProModule, renderElement, renderElements, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
package/dist/index.js CHANGED
@@ -1947,6 +1947,114 @@ var createCurdList = function createCurdList(SearchForm, Table) {
1947
1947
  });
1948
1948
  };
1949
1949
 
1950
+ /**
1951
+ * ProFormList ctx
1952
+ */
1953
+
1954
+ var ProFormListKey = Symbol("pro-form-list");
1955
+ var useProFormList = function useProFormList() {
1956
+ return vue.inject(ProFormListKey);
1957
+ };
1958
+ var provideProFormList = function provideProFormList(ctx) {
1959
+ vue.provide(ProFormListKey, ctx);
1960
+ };
1961
+ var FormListProvider = vue.defineComponent({
1962
+ props: {
1963
+ pathList: {
1964
+ type: Array
1965
+ }
1966
+ },
1967
+ setup: function setup(props, _ref) {
1968
+ var slots = _ref.slots;
1969
+ provideProFormList({
1970
+ pathList: props.pathList
1971
+ });
1972
+ return function () {
1973
+ var _slots$default;
1974
+
1975
+ return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
1976
+ };
1977
+ }
1978
+ });
1979
+
1980
+ var createFormList = function createFormList(FormItem) {
1981
+ return vue.defineComponent({
1982
+ props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
1983
+ //每行默认id
1984
+ rowKey: {
1985
+ type: String,
1986
+ "default": "id"
1987
+ }
1988
+ }),
1989
+ setup: function setup(props, _ref2) {
1990
+ var slots = _ref2.slots;
1991
+
1992
+ var _useProForm = useProForm(),
1993
+ formState = _useProForm.formState,
1994
+ readonly = _useProForm.readonly;
1995
+
1996
+ var formListCtx = useProFormList();
1997
+ var nameList = convertPathToList(props.name);
1998
+ var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
1999
+
2000
+ var handleAdd = function handleAdd() {
2001
+ var targetList = lodash.get(formState, path);
2002
+
2003
+ if (!lodash.isArray(targetList)) {
2004
+ targetList = [];
2005
+ }
2006
+
2007
+ targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
2008
+ lodash.set(formState, path, targetList);
2009
+ };
2010
+
2011
+ var handleRemove = function handleRemove(index) {
2012
+ var targetList = lodash.get(formState, path);
2013
+
2014
+ if (lodash.size(targetList) <= 0) {
2015
+ return;
2016
+ }
2017
+
2018
+ targetList.splice(index, 1);
2019
+ };
2020
+
2021
+ return function () {
2022
+ var _slots$add;
2023
+
2024
+ return vue.createVNode(FormItem, lodash.omit(props, "rowKey"), {
2025
+ "default": function _default() {
2026
+ return [lodash.map(lodash.get(formState, path), function (item, index) {
2027
+ var _slots$default2, _slots$itemAdd, _slots$itemMinus;
2028
+
2029
+ return vue.createVNode(FormListProvider, {
2030
+ "key": item[props.rowKey] || index,
2031
+ "pathList": [].concat(_toConsumableArray(path), [index])
2032
+ }, {
2033
+ "default": function _default() {
2034
+ return [vue.createVNode("div", {
2035
+ "class": "pro-form-list-item"
2036
+ }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
2037
+ "class": "pro-form-list-item-add",
2038
+ "onClick": handleAdd
2039
+ }, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), vue.createVNode("div", {
2040
+ "class": "pro-form-list-item-minus",
2041
+ "onClick": function onClick() {
2042
+ return handleRemove(index);
2043
+ }
2044
+ }, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
2045
+ }
2046
+ });
2047
+ }), !readonly.value && vue.createVNode("div", {
2048
+ "class": "pro-form-list-add",
2049
+ "onClick": handleAdd
2050
+ }, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
2051
+ }
2052
+ });
2053
+ };
2054
+ }
2055
+ });
2056
+ };
2057
+
1950
2058
  var ProFormKey = Symbol("pro-form");
1951
2059
  var useProForm = function useProForm() {
1952
2060
  return vue.inject(ProFormKey);
@@ -1958,24 +2066,24 @@ var provideProForm = function provideProForm(ctx) {
1958
2066
 
1959
2067
  var proFormProps = function proFormProps() {
1960
2068
  return {
1961
- /**
1962
- * 同 antd 或 element form中的model
2069
+ /**
2070
+ * 同 antd 或 element form中的model
1963
2071
  */
1964
2072
  model: {
1965
2073
  type: Object
1966
2074
  },
1967
2075
 
1968
- /**
1969
- * 子组件是否只读样式
2076
+ /**
2077
+ * 子组件是否只读样式
1970
2078
  */
1971
2079
  readonly: {
1972
2080
  type: Boolean,
1973
2081
  "default": undefined
1974
2082
  },
1975
2083
 
1976
- /**
1977
- * FormComponent 根据此项来确定组件是否显示
1978
- * rules 根据rules中方法生成showState对象
2084
+ /**
2085
+ * FormComponent 根据此项来确定组件是否显示
2086
+ * rules 根据rules中方法生成showState对象
1979
2087
  */
1980
2088
  showState: {
1981
2089
  type: Object
@@ -1984,8 +2092,8 @@ var proFormProps = function proFormProps() {
1984
2092
  type: Object
1985
2093
  },
1986
2094
 
1987
- /**
1988
- * 是否只读
2095
+ /**
2096
+ * 是否只读
1989
2097
  */
1990
2098
  readonlyState: {
1991
2099
  type: Object
@@ -1994,8 +2102,8 @@ var proFormProps = function proFormProps() {
1994
2102
  type: Object
1995
2103
  },
1996
2104
 
1997
- /**
1998
- * 是否disabled
2105
+ /**
2106
+ * 是否disabled
1999
2107
  */
2000
2108
  disableState: {
2001
2109
  type: Object
@@ -2004,8 +2112,8 @@ var proFormProps = function proFormProps() {
2004
2112
  type: Object
2005
2113
  },
2006
2114
 
2007
- /**
2008
- *
2115
+ /**
2116
+ *
2009
2117
  */
2010
2118
  columns: {
2011
2119
  type: Array
@@ -2014,30 +2122,30 @@ var proFormProps = function proFormProps() {
2014
2122
  type: Object
2015
2123
  },
2016
2124
 
2017
- /**
2018
- * 展示控件集合,readonly模式下使用这些组件渲染
2125
+ /**
2126
+ * 展示控件集合,readonly模式下使用这些组件渲染
2019
2127
  */
2020
2128
  elementMap: {
2021
2129
  type: Object
2022
2130
  },
2023
2131
 
2024
- /**
2025
- * 录入控件集合
2132
+ /**
2133
+ * 录入控件集合
2026
2134
  */
2027
2135
  formElementMap: {
2028
2136
  type: Object
2029
2137
  },
2030
2138
 
2031
- /**
2032
- * 是否启用rules验证
2139
+ /**
2140
+ * 是否启用rules验证
2033
2141
  */
2034
2142
  needRules: {
2035
2143
  type: Boolean,
2036
2144
  "default": true
2037
2145
  },
2038
2146
 
2039
- /**
2040
- * provide传递
2147
+ /**
2148
+ * provide传递
2041
2149
  */
2042
2150
  provideExtra: {
2043
2151
  type: Object
@@ -2127,7 +2235,9 @@ var createForm = function createForm(Form, Grid) {
2127
2235
  columns: columns,
2128
2236
  //
2129
2237
  formRef: formRef
2130
- }, props.provideExtra));
2238
+ }, props.provideExtra)); //为了不warning ...
2239
+
2240
+ provideProFormList({});
2131
2241
  var invalidKeys = lodash.keys(proFormProps());
2132
2242
  var gridKeys = lodash.keys(lodash.omit(Grid.props, "items"));
2133
2243
  return function () {
@@ -2169,40 +2279,39 @@ exports.SearchMode = void 0;
2169
2279
 
2170
2280
  var proSearchFormProps = function proSearchFormProps() {
2171
2281
  return {
2172
- /**
2173
- * 需要监听的对象
2282
+ /**
2283
+ * 需要监听的对象
2174
2284
  */
2175
2285
  model: {
2176
- type: Object,
2177
- required: true
2286
+ type: Object
2178
2287
  },
2179
2288
 
2180
- /**
2181
- * 初始化触发 onFinish
2289
+ /**
2290
+ * 初始化触发 onFinish
2182
2291
  */
2183
2292
  initEmit: {
2184
2293
  type: Boolean,
2185
2294
  "default": true
2186
2295
  },
2187
2296
 
2188
- /**
2189
- * 模式 自动触发或者手动触发 onFinish
2297
+ /**
2298
+ * 模式 自动触发或者手动触发 onFinish
2190
2299
  */
2191
2300
  searchMode: {
2192
2301
  type: String,
2193
2302
  "default": exports.SearchMode.AUTO
2194
2303
  },
2195
2304
 
2196
- /**
2197
- * 配置 同ProForm中的columns
2198
- * 可以根据column中valueType计算出默认的debounceKeys
2305
+ /**
2306
+ * 配置 同ProForm中的columns
2307
+ * 可以根据column中valueType计算出默认的debounceKeys
2199
2308
  */
2200
2309
  columns: {
2201
2310
  type: Array
2202
2311
  },
2203
2312
 
2204
- /**
2205
- * 需要debounce处理的字段
2313
+ /**
2314
+ * 需要debounce处理的字段
2206
2315
  */
2207
2316
  debounceKeys: {
2208
2317
  type: Array
@@ -2219,9 +2328,9 @@ var proSearchFormProps = function proSearchFormProps() {
2219
2328
  };
2220
2329
  };
2221
2330
 
2222
- /**
2223
- * 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
2224
- * 针对传入的model(监听对象)做相应的finish(回调)处理
2331
+ /**
2332
+ * 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
2333
+ * 针对传入的model(监听对象)做相应的finish(回调)处理
2225
2334
  */
2226
2335
  var createSearchForm = function createSearchForm(Form, Props) {
2227
2336
  return vue.defineComponent({
@@ -2292,116 +2401,6 @@ var createSearchForm = function createSearchForm(Form, Props) {
2292
2401
  });
2293
2402
  };
2294
2403
 
2295
- /**
2296
- * ProFormList ctx
2297
- */
2298
-
2299
- var ProFormListKey = Symbol("pro-form-list");
2300
- var useProFormList = function useProFormList() {
2301
- return vue.inject(ProFormListKey);
2302
- };
2303
-
2304
- var provideProFormList = function provideProFormList(ctx) {
2305
- vue.provide(ProFormListKey, ctx);
2306
- };
2307
-
2308
- var FormListProvider = vue.defineComponent({
2309
- props: {
2310
- pathList: {
2311
- type: Array
2312
- }
2313
- },
2314
- setup: function setup(props, _ref) {
2315
- var slots = _ref.slots;
2316
- provideProFormList({
2317
- pathList: props.pathList
2318
- });
2319
- return function () {
2320
- var _slots$default;
2321
-
2322
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
2323
- };
2324
- }
2325
- });
2326
-
2327
- var createFormList = function createFormList(FormItem) {
2328
- return vue.defineComponent({
2329
- props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
2330
- //每行默认id
2331
- rowKey: {
2332
- type: String,
2333
- "default": "id"
2334
- }
2335
- }),
2336
- setup: function setup(props, _ref2) {
2337
- var slots = _ref2.slots;
2338
-
2339
- var _useProForm = useProForm(),
2340
- formState = _useProForm.formState,
2341
- readonly = _useProForm.readonly;
2342
-
2343
- var formListCtx = useProFormList();
2344
- var nameList = convertPathToList(props.name);
2345
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
2346
-
2347
- var handleAdd = function handleAdd() {
2348
- var targetList = lodash.get(formState, path);
2349
-
2350
- if (!lodash.isArray(targetList)) {
2351
- targetList = [];
2352
- }
2353
-
2354
- targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
2355
- lodash.set(formState, path, targetList);
2356
- };
2357
-
2358
- var handleRemove = function handleRemove(index) {
2359
- var targetList = lodash.get(formState, path);
2360
-
2361
- if (lodash.size(targetList) <= 0) {
2362
- return;
2363
- }
2364
-
2365
- targetList.splice(index, 1);
2366
- };
2367
-
2368
- return function () {
2369
- var _slots$add;
2370
-
2371
- return vue.createVNode(FormItem, lodash.omit(props, "rowKey"), {
2372
- "default": function _default() {
2373
- return [lodash.map(lodash.get(formState, path), function (item, index) {
2374
- var _slots$default2, _slots$itemAdd, _slots$itemMinus;
2375
-
2376
- return vue.createVNode(FormListProvider, {
2377
- "key": item[props.rowKey] || index,
2378
- "pathList": [].concat(_toConsumableArray(path), [index])
2379
- }, {
2380
- "default": function _default() {
2381
- return [vue.createVNode("div", {
2382
- "class": "pro-form-list-item"
2383
- }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
2384
- "class": "pro-form-list-item-add",
2385
- "onClick": handleAdd
2386
- }, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), vue.createVNode("div", {
2387
- "class": "pro-form-list-item-minus",
2388
- "onClick": function onClick() {
2389
- return handleRemove(index);
2390
- }
2391
- }, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
2392
- }
2393
- });
2394
- }), !readonly.value && vue.createVNode("div", {
2395
- "class": "pro-form-list-add",
2396
- "onClick": handleAdd
2397
- }, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
2398
- }
2399
- });
2400
- };
2401
- }
2402
- });
2403
- };
2404
-
2405
2404
  var proFormItemProps = function proFormItemProps() {
2406
2405
  return {
2407
2406
  readonly: {
@@ -2709,6 +2708,7 @@ exports.getItemEl = getItemEl;
2709
2708
  exports.getValidValues = getValidValues;
2710
2709
  exports.mergeStateToList = mergeStateToList;
2711
2710
  exports.provideProCurd = provideProCurd;
2711
+ exports.provideProFormList = provideProFormList;
2712
2712
  exports.provideProModule = provideProModule;
2713
2713
  exports.renderElement = renderElement;
2714
2714
  exports.renderElements = renderElements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-start/pro",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "> TODO: description",
5
5
  "author": "zx <zxpstudy@163.com>",
6
6
  "homepage": "https://github.com/zxeryu/vue-start#readme",
@@ -32,5 +32,5 @@
32
32
  "vue": ">=3.x",
33
33
  "vue-router": ">=4.x"
34
34
  },
35
- "gitHead": "c2f7a6078abb1ff8477c93afa9ad75df4b5dbacc"
35
+ "gitHead": "adf3a978c60ccb84172c2287b67d2e5ead0d0dcf"
36
36
  }