@hb-ui/element-ui
Advanced tools
Comparing version 2.1.2 to 2.1.3
export interface OptionRecord<Raw = Record<string, any>> extends Record<string, any> { | ||
export interface OptionRecord<Raw = Record<PropertyKey, any>> extends Record<PropertyKey, any> { | ||
label: string | ||
@@ -4,0 +4,0 @@ value: string | number | boolean |
@@ -5,3 +5,3 @@ import type { ElCol } from 'element-ui/types/col'; | ||
import type { ElForm } from 'element-ui/types/form'; | ||
import type { ElFormItem } from 'element-ui/types/form-item'; | ||
import type { ElFormItem as ElFormItem2 } from 'element-ui/types/form-item'; | ||
import type { ElInput } from 'element-ui/types/input'; | ||
@@ -19,11 +19,14 @@ import type { ElSelect } from 'element-ui/types/select'; | ||
} | boolean; | ||
export interface FormElement extends Partial<ElFormItem> { | ||
render?: () => JSX_ELEMENT; | ||
export interface ElFormItem extends Partial<ElFormItem2> { | ||
input?: HBInput; | ||
select?: HBSelect; | ||
datePicker?: HBDatePicker; | ||
render?: () => JSX_ELEMENT; | ||
col?: ElCol; | ||
} | ||
export interface FormProps { | ||
elements: (FormElement | (() => JSX_ELEMENT))[]; | ||
props: Partial<ElForm>; | ||
items: (ElFormItem | (() => JSX_ELEMENT))[]; | ||
/** 预留给 [提交/重置] 的位置 */ | ||
lastItem?: false | ((nodes: import('vue').VNode[]) => JSX_ELEMENT); | ||
onSubmit?: () => Promise<void | boolean> | void | boolean; | ||
@@ -33,4 +36,2 @@ onReset?: () => void; | ||
cache?: CacheType; | ||
footer?: false | JSX_ELEMENT; | ||
props: Partial<ElForm>; | ||
row?: ElRow; | ||
@@ -37,0 +38,0 @@ col?: ElCol; |
@@ -61,3 +61,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
var FormElementUI = { | ||
var FormItemUI = { | ||
name: 'hb-ui-form', | ||
@@ -81,3 +81,3 @@ data: function data() { | ||
}, | ||
elements: { | ||
items: { | ||
// @ts-ignore | ||
@@ -89,2 +89,3 @@ type: Array, | ||
}, | ||
lastItem: undefined, | ||
// @ts-ignore | ||
@@ -105,3 +106,15 @@ onSubmit: Function, | ||
}, | ||
footer: false | ||
row: undefined, | ||
col: { | ||
// @ts-ignore | ||
"default": function _default() { | ||
return { | ||
xs: 12, | ||
sm: 12, | ||
md: 8, | ||
lg: 8, | ||
xl: 3 | ||
}; | ||
} | ||
} | ||
}, | ||
@@ -236,21 +249,14 @@ mounted: function mounted() { | ||
props = _ref6.props, | ||
elements = _ref6.elements, | ||
footer = _ref6.footer, | ||
items = _ref6.items, | ||
lastItem = _ref6.lastItem, | ||
row = _ref6.row, | ||
_ref6$col = _ref6.col, | ||
col = _ref6$col === void 0 ? { | ||
xs: 12, | ||
sm: 12, | ||
md: 8, | ||
lg: 8, | ||
xl: 3 | ||
} : _ref6$col; | ||
col = _ref6.col; | ||
var renderElement = function renderElement(element) { | ||
var prop = element.prop, | ||
render = element.render, | ||
_element$input = element.input, | ||
input = _element$input === void 0 ? {} : _element$input, | ||
select = element.select, | ||
datePicker = element.datePicker; | ||
var renderItem = function renderItem(item) { | ||
var prop = item.prop, | ||
render = item.render, | ||
_item$input = item.input, | ||
input = _item$input === void 0 ? {} : _item$input, | ||
select = item.select, | ||
datePicker = item.datePicker; | ||
var ComponentsMap = { | ||
@@ -343,2 +349,31 @@ input: function input(_ref7) { | ||
var renderLastItem = function renderLastItem(lastItem) { | ||
if (lastItem === false) { | ||
return null; | ||
} | ||
var nodes = [// @ts-ignore | ||
h(Button, { | ||
"key": "last-1", | ||
"attrs": { | ||
"type": 'primary' | ||
}, | ||
"on": { | ||
"click": _this2.onFormSubmit | ||
} | ||
}, ["\u67E5\u8BE2"]), // @ts-ignore | ||
h(Button, { | ||
"key": "last-2", | ||
"on": { | ||
"click": _this2.onFormReset | ||
} | ||
}, ["\u91CD\u7F6E"])]; | ||
if (typeof lastItem === 'function') { | ||
return lastItem(nodes); | ||
} | ||
return h("span", [nodes]); | ||
}; | ||
return (// @ts-ignore | ||
@@ -352,24 +387,13 @@ h(Form, { | ||
"props": _objectSpread({}, row) | ||
}, [elements.map(function (element) { | ||
return typeof element === 'function' ? element() : h(Col, { | ||
"props": _objectSpread({}, element.col || col) | ||
}, [items.map(function (item) { | ||
return typeof item === 'function' ? item() : h(Col, { | ||
"props": _objectSpread({}, item.col || col) | ||
}, [h(FormItem, { | ||
"props": _objectSpread({}, element) | ||
}, [renderElement(element)])]); | ||
})]), footer !== null && footer !== void 0 ? footer : h("span", [h(Button, { | ||
"attrs": { | ||
"type": 'primary' | ||
}, | ||
"on": { | ||
"click": this.onFormSubmit | ||
} | ||
}, ["\u67E5\u8BE2"]), h(Button, { | ||
"on": { | ||
"click": this.onFormReset | ||
} | ||
}, ["\u91CD\u7F6E"])])]) | ||
"props": _objectSpread({}, item) | ||
}, [renderItem(item)])]); | ||
})]), renderLastItem(lastItem)]) | ||
); | ||
} | ||
}; | ||
export default FormElementUI; | ||
export default FormItemUI; | ||
//# sourceMappingURL=index.js.map |
@@ -11,4 +11,4 @@ import type { ElForm } from 'element-ui/types/form'; | ||
import type { OptionRecord, JSX_ELEMENT } from '../types'; | ||
export interface TableProps<RowType = Record<string, any>> { | ||
columns: (Partial<ElTableColumn> & Record<string, any> & { | ||
export interface TableProps<RowType = Record<PropertyKey, any>> { | ||
columns: (Partial<ElTableColumn> & Record<PropertyKey, any> & { | ||
formItem?: Partial<ElFormItem> & { | ||
@@ -52,3 +52,3 @@ input?: Partial<ElInput>; | ||
/** 泛化 */ | ||
props?: Partial<ElPagination & Record<string, any>>; | ||
props?: Partial<ElPagination & Record<PropertyKey, any>>; | ||
}; | ||
@@ -60,10 +60,10 @@ handle?: { | ||
/** 泛化 */ | ||
props?: Partial<ElTable & Record<string, any>>; | ||
props?: Partial<ElTable & Record<PropertyKey, any>>; | ||
} | ||
export declare type TableColumn<RowType = Record<string, any>> = TableProps<RowType>['columns'][number]; | ||
export declare type tableData<RowType = Record<string, any>> = TableProps<RowType>['data'][number]; | ||
export declare type TableQuery<RowType = Record<string, any>> = TableProps<RowType>['query']; | ||
export declare type TableColumn<RowType = Record<PropertyKey, any>> = TableProps<RowType>['columns'][number]; | ||
export declare type tableData<RowType = Record<PropertyKey, any>> = TableProps<RowType>['data'][number]; | ||
export declare type TableQuery<RowType = Record<PropertyKey, any>> = TableProps<RowType>['query']; | ||
export declare type TablePagination = Pick<TableProps['pagination'], 'currentPage' | 'pageSize' | 'total'>; | ||
export declare type TableHandle<RowType = Record<string, any>> = TableProps<RowType>['handle']; | ||
export declare type TableHandle<RowType = Record<PropertyKey, any>> = TableProps<RowType>['handle']; | ||
declare const _default: any; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
export interface OptionRecord<Raw = Record<string, any>> extends Record<string, any> { | ||
export interface OptionRecord<Raw = Record<PropertyKey, any>> extends Record<PropertyKey, any> { | ||
label: string; | ||
@@ -3,0 +3,0 @@ value: string | number | boolean; |
{ | ||
"name": "@hb-ui/element-ui", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"packageManager": "pnpm@7.0.0", | ||
@@ -5,0 +5,0 @@ "description": "基于 Element UI 二次封装的一些常用组件", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
136530
1898