build的一些小问题
This commit is contained in:
parent
fde3fe5ef6
commit
9fc852541c
|
|
@ -0,0 +1,11 @@
|
|||
/// <reference types="react" />
|
||||
declare type Props = {
|
||||
src: string;
|
||||
alt?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
bordered?: boolean;
|
||||
type?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down' | 'initial' | 'inherit';
|
||||
};
|
||||
declare function ImgBox(props: Props): JSX.Element;
|
||||
export default ImgBox;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||
var index_module_less_1 = tslib_1.__importDefault(require("./index.module.less"));
|
||||
function ImgBox(props) {
|
||||
var width = props.width, height = props.height, _a = props.bordered, bordered = _a === void 0 ? false : _a, _b = props.type, type = _b === void 0 ? 'contain' : _b, src = props.src, alt = props.alt;
|
||||
if (bordered) {
|
||||
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: index_module_less_1.default.imgBox }, { children: (0, jsx_runtime_1.jsx)("img", { width: 72 || width, height: 72 || height, src: src, style: {
|
||||
objectFit: type,
|
||||
borderRadius: 8,
|
||||
}, alt: 'img' || alt }) })));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)("img", { width: 72 || width, height: 72 || height, src: src, style: {
|
||||
objectFit: type,
|
||||
}, alt: 'img' || alt }));
|
||||
}
|
||||
exports.default = ImgBox;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
.imgBox {
|
||||
padding: 4px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e0e0e0;
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ exports.default = OakComponent({
|
|||
lifetimes: {
|
||||
ready: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, attributes, entity, data, attributesMb, schema, colorDict, columnDef, converter;
|
||||
var _a, attributes, entity, data, attributesMb, schema, colorDict, converter;
|
||||
var _this = this;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
_a = this.props, attributes = _a.attributes, entity = _a.entity, data = _a.data, attributesMb = _a.attributesMb;
|
||||
|
|
@ -49,13 +49,6 @@ exports.default = OakComponent({
|
|||
colorDict = this.features.style.getColorDict();
|
||||
(0, assert_1.default)(!!data, 'data不能为空');
|
||||
(0, assert_1.default)(!!entity, 'list属性entity不能为空');
|
||||
if (attributes && attributes.length) {
|
||||
columnDef = (0, usefulFn_1.analyzeAttrDefForTable)(schema, entity, attributes, function (k, params) { return _this.t(k, params); }, attributesMb).columnDef;
|
||||
this.setState({
|
||||
columns: columnDef,
|
||||
colorDict: colorDict,
|
||||
});
|
||||
}
|
||||
if (attributesMb) {
|
||||
converter = (0, usefulFn_1.analyzeAttrMobileForCard)(schema, entity, function (k, params) { return _this.t(k, params); }, attributesMb, colorDict);
|
||||
this.setState({
|
||||
|
|
@ -77,6 +70,6 @@ exports.default = OakComponent({
|
|||
action: action,
|
||||
cascadeAction: cascadeAction,
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ import { WebComponentProps } from '../../types/Page';
|
|||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { ColorDict } from 'oak-domain/lib/types/Style';
|
||||
import { StorageSchema } from 'oak-domain/lib/types/Storage';
|
||||
import { ColumnDefProps, AttrRender, onActionFnDef } from '../../types/AbstractComponent';
|
||||
import { OakAbsAttrDef, ColumnDefProps, AttrRender, onActionFnDef } from '../../types/AbstractComponent';
|
||||
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
|
||||
width: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
||||
loading: boolean;
|
||||
extraActions: string[];
|
||||
entity: string;
|
||||
schema: StorageSchema<EntityDict & BaseEntityDict>;
|
||||
attributes: OakAbsAttrDef[];
|
||||
columns: ColumnDefProps[];
|
||||
mobileData: AttrRender[];
|
||||
data: any[];
|
||||
|
|
|
|||
|
|
@ -5,9 +5,22 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|||
var react_1 = require("react");
|
||||
var antd_1 = require("antd");
|
||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
var lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
||||
var actionBtn_1 = tslib_1.__importDefault(require("../actionBtn"));
|
||||
var usefulFn_1 = require("../../utils/usefulFn");
|
||||
var imgBox_1 = tslib_1.__importDefault(require("../imgBox"));
|
||||
function getDownload(file) {
|
||||
var aLink = document.createElement('a');
|
||||
fetch(file === null || file === void 0 ? void 0 : file.url)
|
||||
.then(function (res) { return res.blob(); })
|
||||
.then(function (blob) {
|
||||
// 将链接地址字符内容转变成blob地址
|
||||
aLink.href = URL.createObjectURL(blob);
|
||||
aLink.download = file === null || file === void 0 ? void 0 : file.filename;
|
||||
aLink.style.display = 'none';
|
||||
document.body.appendChild(aLink);
|
||||
aLink.click();
|
||||
});
|
||||
}
|
||||
function RenderCell(props) {
|
||||
var value = props.value, type = props.type, color = props.color;
|
||||
if (!value) {
|
||||
|
|
@ -17,6 +30,21 @@ function RenderCell(props) {
|
|||
else if (type === 'tag') {
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: color }, { children: value })));
|
||||
}
|
||||
else if (type === 'img') {
|
||||
if (value instanceof Array) {
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Space, { children: value.map(function (ele) { return ((0, jsx_runtime_1.jsx)(imgBox_1.default, { src: ele.url, width: 120, height: 70 })); }) }));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(imgBox_1.default, { src: value.url, width: 120, height: 70 }));
|
||||
}
|
||||
else if (type === 'avatar') {
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Avatar, { src: value }));
|
||||
}
|
||||
else if (type === 'file') {
|
||||
if (value instanceof Array) {
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: value.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed" /* icon={} */, onClick: function () { return getDownload(ele); } }, { children: ele.filename }))); }) })));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed" /* icon={} */, onClick: function () { return getDownload(value); } }, { children: value.filename })));
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: value }));
|
||||
}
|
||||
var sizeForWidth = {
|
||||
|
|
@ -38,33 +66,31 @@ function Render(props) {
|
|||
var t = methods.t;
|
||||
var _a = tslib_1.__read((0, react_1.useState)([]), 2), selectedRowKeys = _a[0], setSelectedRowKeys = _a[1];
|
||||
var _b = tslib_1.__read((0, react_1.useState)([]), 2), tableColumns = _b[0], setTabelColumns = _b[1];
|
||||
var loading = oakData.loading, entity = oakData.entity, schema = oakData.schema, extraActions = oakData.extraActions, oakEntity = oakData.oakEntity, data = oakData.data, columns = oakData.columns, colorDict = oakData.colorDict, _c = oakData.disabledOp, disabledOp = _c === void 0 ? false : _c, handleClick = oakData.handleClick, tablePagination = oakData.tablePagination, onAction = oakData.onAction, rowSelection = oakData.rowSelection, width = oakData.width, scroll = oakData.scroll;
|
||||
var loading = oakData.loading, entity = oakData.entity, schema = oakData.schema, extraActions = oakData.extraActions, oakEntity = oakData.oakEntity, data = oakData.data, columns = oakData.columns, colorDict = oakData.colorDict, _c = oakData.disabledOp, disabledOp = _c === void 0 ? false : _c, handleClick = oakData.handleClick, tablePagination = oakData.tablePagination, onAction = oakData.onAction, rowSelection = oakData.rowSelection, width = oakData.width, scroll = oakData.scroll, attributes = oakData.attributes;
|
||||
(0, react_1.useEffect)(function () {
|
||||
var tableColumns = columns && columns.map(function (ele) {
|
||||
var tableColumns = attributes && attributes.map(function (ele) {
|
||||
var path = (0, usefulFn_1.getPath)(ele);
|
||||
var _a = (0, usefulFn_1.resolvePath)(schema, entity, path), attrType = _a.attrType, attr = _a.attr, attribute = _a.attribute, entityI8n = _a.entity;
|
||||
var title = (0, usefulFn_1.getLabel)(ele, entityI8n, attr, t);
|
||||
var width = (0, usefulFn_1.getWidth)(ele, attrType, 'table');
|
||||
var type = (0, usefulFn_1.getType)(ele, attrType);
|
||||
var column = {
|
||||
dataIndex: ele.path,
|
||||
title: ele.title,
|
||||
key: path,
|
||||
title: title,
|
||||
align: 'center',
|
||||
render: function (v, row) {
|
||||
var _a, _b;
|
||||
if (v && ele.type === 'text') {
|
||||
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: v });
|
||||
}
|
||||
var value = (0, lodash_1.get)(row, ele.path);
|
||||
var value = (0, usefulFn_1.getValue)(ele, row, path, entityI8n, attr, attrType, t);
|
||||
var color = 'black';
|
||||
if (ele.type === 'tag' && !!value) {
|
||||
(0, assert_1.default)(!!((_b = (_a = colorDict === null || colorDict === void 0 ? void 0 : colorDict[ele.entity]) === null || _a === void 0 ? void 0 : _a[ele.attr]) === null || _b === void 0 ? void 0 : _b[value]), "".concat(entity, "\u5B9E\u4F53iState\u989C\u8272\u5B9A\u4E49\u7F3A\u5931"));
|
||||
color = colorDict[ele.entity][ele.attr][value];
|
||||
value = t("".concat(ele.entity, ":v.").concat(ele.attr, ".").concat(value));
|
||||
if (type === 'tag' && !!value) {
|
||||
(0, assert_1.default)(!!((_b = (_a = colorDict === null || colorDict === void 0 ? void 0 : colorDict[entityI8n]) === null || _a === void 0 ? void 0 : _a[attr]) === null || _b === void 0 ? void 0 : _b[value]), "".concat(entity, "\u5B9E\u4F53iState\u989C\u8272\u5B9A\u4E49\u7F3A\u5931"));
|
||||
color = colorDict[entityI8n][attr][value];
|
||||
}
|
||||
if (ele.type === 'datetime' && !!value) {
|
||||
value = (0, dayjs_1.default)(value).format('YYYY-MM-DD HH:mm');
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(RenderCell, { color: color, value: value, type: ele.type }));
|
||||
return ((0, jsx_runtime_1.jsx)(RenderCell, { color: color, value: value, type: type }));
|
||||
}
|
||||
};
|
||||
if (ele.width) {
|
||||
Object.assign(column, { width: ele.width });
|
||||
if (width) {
|
||||
Object.assign(column, { width: width });
|
||||
}
|
||||
return column;
|
||||
});
|
||||
|
|
@ -96,20 +122,22 @@ function Render(props) {
|
|||
return {
|
||||
onClick: function () {
|
||||
var index = selectedRowKeys.findIndex(function (ele) { return ele === record.id; });
|
||||
var keys = selectedRowKeys;
|
||||
if ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox') {
|
||||
if (index !== -1) {
|
||||
selectedRowKeys.splice(index, 1);
|
||||
keys.splice(index, 1);
|
||||
}
|
||||
else {
|
||||
selectedRowKeys.push(record.id);
|
||||
keys.push(record.id);
|
||||
}
|
||||
setSelectedRowKeys(tslib_1.__spreadArray([], tslib_1.__read(selectedRowKeys), false));
|
||||
}
|
||||
else {
|
||||
keys = [record.id];
|
||||
setSelectedRowKeys([record.id]);
|
||||
}
|
||||
var row = data.filter(function (ele) { return selectedRowKeys.includes(ele.id); });
|
||||
(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) && (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange(selectedRowKeys, row, { type: 'all' }));
|
||||
var row = data.filter(function (ele) { return keys.includes(ele.id); });
|
||||
(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) && (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange(keys, row, { type: 'all' }));
|
||||
}
|
||||
};
|
||||
} }));
|
||||
|
|
|
|||
|
|
@ -17,11 +17,34 @@ exports.default = OakComponent({
|
|||
mode: String, // 'default' | 'card'
|
||||
},
|
||||
formData: function () {
|
||||
var data = this.props.data;
|
||||
var _this = this;
|
||||
var _a = this.props, data = _a.data, entity = _a.entity;
|
||||
var transformer = this.state.transformer;
|
||||
var renderData = transformer(data);
|
||||
var renderData1 = renderData === null || renderData === void 0 ? void 0 : renderData.map(function (ele) {
|
||||
var label = ele.label, attr = ele.attr, type = ele.type, required = ele.required;
|
||||
var label2 = label;
|
||||
if (!label2) {
|
||||
if (type === 'ref') {
|
||||
var refEntity = ele.entity;
|
||||
if (attr === 'entityId') {
|
||||
// 反指
|
||||
label2 = _this.t("".concat(refEntity, ":name"));
|
||||
}
|
||||
else {
|
||||
label2 = _this.t("".concat(entity, ":attr.").concat(attr));
|
||||
}
|
||||
}
|
||||
else {
|
||||
label2 = _this.t("".concat(entity, ":attr.").concat(attr));
|
||||
}
|
||||
}
|
||||
Object.assign(ele, { label: label2 });
|
||||
return ele;
|
||||
});
|
||||
return {
|
||||
renderData: renderData,
|
||||
name: 'ddd',
|
||||
renderData: renderData1,
|
||||
};
|
||||
},
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -97,14 +97,16 @@ function makeAttrInput(attrRender, onValueChange, t, label) {
|
|||
}) })));
|
||||
}
|
||||
case 'ref': {
|
||||
return ((0, jsx_runtime_1.jsx)(refAttr_1.default, { multiple: false, entityId: value, pickerRender: attrRender, onChange: function (value) { onValueChange(value); } }));
|
||||
return ((0, jsx_runtime_1.jsx)(refAttr_1.default, { multiple: false, entityId: value, pickerRender: attrRender, onChange: function (value) {
|
||||
onValueChange(value);
|
||||
} }));
|
||||
}
|
||||
case 'coordinate': {
|
||||
var coordinate = (value || {}).coordinate;
|
||||
var extra = attrRender.extra;
|
||||
var poiNameAttr_1 = (extra === null || extra === void 0 ? void 0 : extra.poiName) || 'poiName';
|
||||
var areaIdAttr_1 = (extra === null || extra === void 0 ? void 0 : extra.areaId) || 'areaId';
|
||||
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ width: '80vw', open: sl, closable: false, onCancel: function () { return setSl(false); }, okText: "\u786E\u8BA4", cancelText: "\u53D6\u6D88", okButtonProps: {
|
||||
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ width: "80vw", open: sl, closable: false, onCancel: function () { return setSl(false); }, okText: "\u786E\u8BA4", cancelText: "\u53D6\u6D88", okButtonProps: {
|
||||
disabled: !poi,
|
||||
}, onOk: function () {
|
||||
var _a;
|
||||
|
|
@ -125,9 +127,7 @@ function makeAttrInput(attrRender, onValueChange, t, label) {
|
|||
width: '100%',
|
||||
} }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", size: 8 }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ align: "center" }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed", onClick: function () {
|
||||
setSl(true);
|
||||
} }, { children: value
|
||||
? '重选位置'
|
||||
: '选择位置' })) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: {
|
||||
} }, { children: value ? '重选位置' : '选择位置' })) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
width: '100%',
|
||||
|
|
@ -141,6 +141,7 @@ function makeAttrInput(attrRender, onValueChange, t, label) {
|
|||
function render(props) {
|
||||
var _a = props.data, _b = _a.renderData, renderData = _b === void 0 ? [] : _b, helps = _a.helps, entity = _a.entity;
|
||||
var _c = props.methods, update = _c.update, t = _c.t;
|
||||
console.log(renderData);
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ labelCol: { span: 4 }, layout: "horizontal", style: {
|
||||
margin: '0px auto',
|
||||
maxWidth: '100%',
|
||||
|
|
@ -148,26 +149,25 @@ function render(props) {
|
|||
// 因为i18n渲染机制的缘故,t必须放到这里来计算
|
||||
var label = ele.label, attr = ele.attr, type = ele.type, required = ele.required;
|
||||
var label2 = label;
|
||||
if (!label2) {
|
||||
if (type === 'ref') {
|
||||
var refEntity = ele.entity;
|
||||
if (attr === 'entityId') {
|
||||
// 反指
|
||||
label2 = t("".concat(refEntity, ":name"));
|
||||
}
|
||||
else {
|
||||
label2 = t("".concat(entity, ":attr.").concat(attr));
|
||||
}
|
||||
}
|
||||
else {
|
||||
label2 = t("".concat(entity, ":attr.").concat(attr));
|
||||
}
|
||||
}
|
||||
// if (!label2) {
|
||||
// if (type === 'ref') {
|
||||
// const { entity: refEntity } =
|
||||
// ele as OakAbsRefAttrPickerRender<ED, keyof ED>;
|
||||
// if (attr === 'entityId') {
|
||||
// // 反指
|
||||
// label2 = t(`${refEntity}:name`);
|
||||
// } else {
|
||||
// label2 = t(`${entity}:attr.${attr}`);
|
||||
// }
|
||||
// } else {
|
||||
// label2 = t(`${entity}:attr.${attr}`);
|
||||
// }
|
||||
// }
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: label2, rules: [
|
||||
{
|
||||
required: !!required,
|
||||
},
|
||||
], help: helps && helps[attr] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: makeAttrInput(ele, function (value, extra) {
|
||||
], help: helps && helps[attr], name: required ? attr : '' }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: makeAttrInput(ele, function (value, extra) {
|
||||
var _a;
|
||||
var attr = ele.attr;
|
||||
update(tslib_1.__assign((_a = {}, _a[attr] = value, _a), extra));
|
||||
|
|
|
|||
|
|
@ -504,9 +504,6 @@ function translateListeners(listeners) {
|
|||
}
|
||||
}
|
||||
function createComponent(option, features) {
|
||||
if (option.observers) {
|
||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
||||
}
|
||||
var entity = option.entity, data = option.data, properties = option.properties, methods = option.methods, wechatMp = option.wechatMp, lifetimes = option.lifetimes, listeners = option.listeners;
|
||||
var _a = lifetimes || {}, attached = _a.attached, show = _a.show, hide = _a.hide, created = _a.created, detached = _a.detached, ready = _a.ready, moved = _a.moved, error = _a.error;
|
||||
var _b = wechatMp || {}, options = _b.options, externalClasses = _b.externalClasses;
|
||||
|
|
|
|||
|
|
@ -428,9 +428,6 @@ function translateListeners(listeners) {
|
|||
var DEFAULT_REACH_BOTTOM_DISTANCE = 50;
|
||||
function createComponent(option, features) {
|
||||
var _a = option, data = _a.data, methods = _a.methods, lifetimes = _a.lifetimes, getRender = _a.getRender, path = _a.path, listeners = _a.listeners;
|
||||
if (option.observers) {
|
||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
||||
}
|
||||
var fn = translateListeners(listeners).fn;
|
||||
var OakComponentWrapper = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(OakComponentWrapper, _super);
|
||||
|
|
|
|||
|
|
@ -52,24 +52,24 @@ export declare type RowWithActions<ED extends EntityDict & BaseEntityDict, T ext
|
|||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||
};
|
||||
};
|
||||
interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption> {
|
||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
||||
interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> {
|
||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||
path?: string;
|
||||
isList: IsList;
|
||||
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => {
|
||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||
};
|
||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ActionDef<ED, T>[]);
|
||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data'] | undefined);
|
||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||
append?: boolean;
|
||||
pagination?: Pagination;
|
||||
filters?: Array<{
|
||||
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['filter'] | undefined);
|
||||
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||
'#name'?: string;
|
||||
}>;
|
||||
sorters?: Array<{
|
||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||
'#name'?: string;
|
||||
}>;
|
||||
formData?: (options: {
|
||||
|
|
@ -77,10 +77,11 @@ interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyo
|
|||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
||||
props: Partial<PropertyOptionToData<TProperty>>;
|
||||
legalActions: ActionDef<ED, T>[];
|
||||
}) => FormedData & ThisType<ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList>>;
|
||||
}) => FormedData;
|
||||
ns?: T | T[];
|
||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => TData) | TData;
|
||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||
properties?: TProperty;
|
||||
methods?: TMethod;
|
||||
}
|
||||
export declare type MiniprogramStyleMethods = {
|
||||
animate(selector: string, keyFrames: WechatMiniprogram.Component.KeyFrame[], duration: number, callback?: () => void): void;
|
||||
|
|
@ -109,8 +110,7 @@ export declare type ComponentFullThisType<ED extends EntityDict & BaseEntityDict
|
|||
setState: (data: Partial<OakComponentData<ED, T>>, callback?: () => void) => void;
|
||||
triggerEvent: <DetailType = any>(name: string, detail?: DetailType, options?: WechatMiniprogram.Component.TriggerEventOption) => void;
|
||||
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
||||
export declare type OakComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any>, TProperty extends PropertyOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty> & Partial<{
|
||||
methods: TMethod;
|
||||
export declare type OakComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any>, TProperty extends PropertyOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod> & Partial<{
|
||||
lifetimes: {
|
||||
created?(): void;
|
||||
attached?(): void;
|
||||
|
|
@ -121,8 +121,7 @@ export declare type OakComponentOption<ED extends EntityDict & BaseEntityDict, T
|
|||
show?(): void;
|
||||
hide?(): void;
|
||||
};
|
||||
observers: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>, ...args: any[]) => any>;
|
||||
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||
}> & Partial<{
|
||||
wechatMp: {
|
||||
externalClasses?: string[];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { EntityDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { StorageSchema, Attribute } from 'oak-domain/lib/types';
|
||||
import { OakAbsAttrDef, CardDef, DataTransformer, ColumnDefProps, OakAbsAttrUpsertDef, AttrUpsertRender } from '../types/AbstractComponent';
|
||||
import { OakAbsAttrDef, CardDef, DataTransformer, OakAbsAttrUpsertDef, AttrUpsertRender } from '../types/AbstractComponent';
|
||||
import { DataType } from 'oak-domain/lib/types/schema/DataTypes';
|
||||
import { ColorDict } from 'oak-domain/lib/types/Style';
|
||||
export declare function getAttributes(attributes: Record<string, Attribute>): Record<string, Attribute>;
|
||||
|
|
@ -12,11 +12,13 @@ export declare function resolvePath<ED extends EntityDict & BaseEntityDict>(data
|
|||
attrType: DataType | "ref";
|
||||
attribute: Attribute;
|
||||
};
|
||||
export declare function getPath(attribute: OakAbsAttrDef): string;
|
||||
export declare function getLabel<ED extends EntityDict & BaseEntityDict>(attribute: OakAbsAttrDef, entity: keyof ED, attr: string, t: (k: string, params?: object) => string): string;
|
||||
export declare function getWidth(attribute: OakAbsAttrDef, attrType: string, useFor: 'table' | 'other'): number | undefined;
|
||||
export declare function getValue<ED extends EntityDict & BaseEntityDict>(attribute: OakAbsAttrDef, data: any, path: string, entity: keyof ED, attr: string, attrType: string, t: (k: string, params?: object) => string): any;
|
||||
export declare function getType(attribute: OakAbsAttrDef, attrType: string): string | undefined;
|
||||
export declare function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrDefs: OakAbsAttrDef[], colorDict?: ColorDict<ED>): DataTransformer;
|
||||
export declare function analyzeDataUpsertTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrUpsertDefs: OakAbsAttrUpsertDef<ED>[]): (data: any) => AttrUpsertRender<ED>[];
|
||||
export declare function analyzeAttrDefForTable<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrDefs: OakAbsAttrDef[], t: (k: string, params?: object) => string, mobileAttrDef?: CardDef, colorDict?: ColorDict<ED>): {
|
||||
columnDef: ColumnDefProps[];
|
||||
};
|
||||
export declare function analyzeAttrMobileForCard<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, t: (k: string, params?: object) => string, mobileAttrDef: CardDef, colorDict: ColorDict<ED>): (data: any[]) => {
|
||||
title: string;
|
||||
rows: {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.analyzeAttrMobileForCard = exports.analyzeAttrDefForTable = exports.analyzeDataUpsertTransformer = exports.makeDataTransformer = exports.resolvePath = exports.getAttributes = void 0;
|
||||
exports.analyzeAttrMobileForCard = exports.analyzeDataUpsertTransformer = exports.makeDataTransformer = exports.getType = exports.getValue = exports.getWidth = exports.getLabel = exports.getPath = exports.resolvePath = exports.getAttributes = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
var relation_1 = require("oak-domain/lib/store/relation");
|
||||
|
|
@ -86,6 +86,7 @@ function getPath(attribute) {
|
|||
}
|
||||
return attribute.path;
|
||||
}
|
||||
exports.getPath = getPath;
|
||||
function getLabel(attribute, entity, attr, t) {
|
||||
var label = t("".concat(entity, ":attr.").concat(attr));
|
||||
if (attr === '$$createAt$$' ||
|
||||
|
|
@ -98,6 +99,7 @@ function getLabel(attribute, entity, attr, t) {
|
|||
}
|
||||
return label;
|
||||
}
|
||||
exports.getLabel = getLabel;
|
||||
// 目前width属性可以是undefined,只有特殊type或用户自定义才有值,这样其余attr属性可以自适应
|
||||
function getWidth(attribute, attrType, useFor) {
|
||||
var width;
|
||||
|
|
@ -112,6 +114,7 @@ function getWidth(attribute, attrType, useFor) {
|
|||
}
|
||||
return width;
|
||||
}
|
||||
exports.getWidth = getWidth;
|
||||
function getValue(attribute, data, path, entity, attr, attrType, t) {
|
||||
var value = (0, lodash_1.get)(data, path);
|
||||
// 枚举类型还要通过i18转一下中文
|
||||
|
|
@ -127,19 +130,20 @@ function getValue(attribute, data, path, entity, attr, attrType, t) {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
exports.getValue = getValue;
|
||||
function getType(attribute, attrType) {
|
||||
var type = 'text';
|
||||
if (attrType === 'enum') {
|
||||
type = 'tag';
|
||||
return 'tag';
|
||||
}
|
||||
if (attrType === 'datetime') {
|
||||
type = 'datetime';
|
||||
return 'datetime';
|
||||
}
|
||||
if (isAttrbuteType(attribute).type) {
|
||||
type = isAttrbuteType(attrType).type;
|
||||
return isAttrbuteType(attrType).type;
|
||||
}
|
||||
return type;
|
||||
return attrType;
|
||||
}
|
||||
exports.getType = getType;
|
||||
function getLabelI18(dataSchema, entity, path, t) {
|
||||
var _a = resolvePath(dataSchema, entity, path), attr = _a.attr, entityI8n = _a.entity;
|
||||
return t("".concat(entityI8n, ":attr.").concat(attr));
|
||||
|
|
@ -247,28 +251,6 @@ function analyzeDataUpsertTransformer(dataSchema, entity, attrUpsertDefs) {
|
|||
};
|
||||
}
|
||||
exports.analyzeDataUpsertTransformer = analyzeDataUpsertTransformer;
|
||||
function analyzeAttrDefForTable(dataSchema, entity, attrDefs, t, mobileAttrDef, colorDict) {
|
||||
// web使用
|
||||
var columnDef = attrDefs.map(function (ele) {
|
||||
var path = getPath(ele);
|
||||
var _a = resolvePath(dataSchema, entity, path), attrType = _a.attrType, attr = _a.attr, attribute = _a.attribute, entityI8n = _a.entity;
|
||||
var title = getLabel(ele, entity, attr, t);
|
||||
var width = getWidth(ele, attrType, 'table');
|
||||
var type = getType(ele, attrType);
|
||||
return {
|
||||
title: title,
|
||||
width: width,
|
||||
type: type,
|
||||
path: path,
|
||||
entity: entityI8n,
|
||||
attr: attr,
|
||||
};
|
||||
});
|
||||
return {
|
||||
columnDef: columnDef,
|
||||
};
|
||||
}
|
||||
exports.analyzeAttrDefForTable = analyzeAttrDefForTable;
|
||||
function analyzeAttrMobileForCard(dataSchema, entity, t, mobileAttrDef, colorDict) {
|
||||
return function (data) {
|
||||
// 遍历用户传入的数据源
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ function getDownload(file: { filename: string; url: string }) {
|
|||
document.body.appendChild(aLink);
|
||||
aLink.click();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
type RenderCellProps = {
|
||||
value: any;
|
||||
|
|
@ -76,7 +76,7 @@ function RenderCell(props: RenderCellProps) {
|
|||
return (
|
||||
<Space direction="vertical">
|
||||
{value.map((ele) => (
|
||||
<Button type="dashed" icon={} onClick={() => getDownload(ele)}>
|
||||
<Button type="dashed" /* icon={} */ onClick={() => getDownload(ele)}>
|
||||
{ele.filename}
|
||||
</Button>
|
||||
))}
|
||||
|
|
@ -84,7 +84,7 @@ function RenderCell(props: RenderCellProps) {
|
|||
)
|
||||
}
|
||||
return (
|
||||
<Button type="dashed" icon={} onClick={() => getDownload(value)}>
|
||||
<Button type="dashed" /* icon={} */onClick={() => getDownload(value)}>
|
||||
{value.filename}
|
||||
</Button>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export default OakComponent({
|
|||
return ele;
|
||||
});
|
||||
return {
|
||||
name: 'ddd',
|
||||
renderData: renderData1,
|
||||
};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -731,10 +731,6 @@ export function createComponent<
|
|||
>,
|
||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
||||
) {
|
||||
if (option.observers) {
|
||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
||||
}
|
||||
|
||||
const {
|
||||
entity,
|
||||
data,
|
||||
|
|
|
|||
|
|
@ -693,10 +693,6 @@ export function createComponent<
|
|||
getRender: () => React.ComponentType<any>;
|
||||
};
|
||||
|
||||
if (option.observers) {
|
||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
||||
}
|
||||
|
||||
const { fn } = translateListeners(listeners);
|
||||
class OakComponentWrapper extends OakComponentBase<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod> {
|
||||
features = features;
|
||||
|
|
|
|||
|
|
@ -114,24 +114,26 @@ interface ComponentOption<
|
|||
IsList extends boolean,
|
||||
TData extends DataOption,
|
||||
TProperty extends PropertyOption,
|
||||
TMethod extends Record<string, Function>,
|
||||
EMethod extends Record<string, Function> = {},
|
||||
> {
|
||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||
path?: string;
|
||||
isList: IsList;
|
||||
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => {
|
||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||
},
|
||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ActionDef<ED, T>[]);
|
||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data'] | undefined);
|
||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||
append?: boolean;
|
||||
pagination?: Pagination;
|
||||
filters?: Array<{
|
||||
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['filter'] | undefined);
|
||||
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||
'#name'?: string;
|
||||
}>;
|
||||
sorters?: Array<{
|
||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||
'#name'?: string;
|
||||
}>;
|
||||
formData?: (options: {
|
||||
|
|
@ -139,10 +141,11 @@ interface ComponentOption<
|
|||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
||||
props: Partial<PropertyOptionToData<TProperty>>;
|
||||
legalActions: ActionDef<ED, T>[];
|
||||
}) => FormedData & ThisType<ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList>>;
|
||||
}) => FormedData;
|
||||
ns?: T | T[];
|
||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => TData) | TData;
|
||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||
properties?: TProperty;
|
||||
methods?: TMethod;
|
||||
};
|
||||
|
||||
export type MiniprogramStyleMethods = {
|
||||
|
|
@ -193,7 +196,7 @@ export type ComponentPublicThisType<
|
|||
TData extends Record<string, any> = {},
|
||||
TProperty extends PropertyOption = {},
|
||||
TMethod extends MethodOption = {},
|
||||
EMethod extends Record<string, Function> = {}
|
||||
EMethod extends Record<string, Function> = {},
|
||||
> = {
|
||||
subscribed: Array<() => void>;
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
|
|
@ -244,10 +247,9 @@ export type OakComponentOption<
|
|||
TData extends Record<string, any>,
|
||||
TProperty extends PropertyOption,
|
||||
TMethod extends Record<string, Function>,
|
||||
EMethod extends Record<string, Function> = {}
|
||||
> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty> &
|
||||
EMethod extends Record<string, Function> = {},
|
||||
> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod> &
|
||||
Partial<{
|
||||
methods: TMethod;
|
||||
lifetimes: {
|
||||
created?(): void;
|
||||
attached?(): void;
|
||||
|
|
@ -258,11 +260,8 @@ export type OakComponentOption<
|
|||
show?(): void;
|
||||
hide?(): void;
|
||||
};
|
||||
observers: Record<string, (this: ComponentPublicThisType<
|
||||
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod
|
||||
>, ...args: any[]) => any>; // 待废弃
|
||||
listeners: Record<string, (this: ComponentPublicThisType<
|
||||
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod
|
||||
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod
|
||||
>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||
}> &
|
||||
Partial<{
|
||||
|
|
@ -308,74 +307,74 @@ export type OakNavigateToParameters<ED extends EntityDict & BaseEntityDict, T ex
|
|||
export type OakCommonComponentMethods<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
T extends keyof ED
|
||||
> = {
|
||||
setDisablePulldownRefresh: (able: boolean) => void;
|
||||
sub: (type: string, callback: Function) => void;
|
||||
unsub: (type: string, callback: Function) => void;
|
||||
pub: (type: string, options?: any) => void;
|
||||
unsubAll: (type: string) => void;
|
||||
save: (key: string, item: any) => void;
|
||||
load: (key: string) => any;
|
||||
clear: () => void;
|
||||
resolveInput: <K extends string>(
|
||||
input: any,
|
||||
keys?: K[]
|
||||
) => { dataset?: Record<string, any>; value?: string } & {
|
||||
[k in K]?: any;
|
||||
};
|
||||
setNotification: (data: NotificationProps) => void;
|
||||
consumeNotification: () => NotificationProps | undefined;
|
||||
setMessage: (data: MessageProps) => void;
|
||||
consumeMessage: () => MessageProps | undefined;
|
||||
reRender: (extra?: Record<string, any>) => void;
|
||||
getFreshValue: (
|
||||
path?: string
|
||||
) =>
|
||||
| Partial<ED[keyof ED]['Schema']>[]
|
||||
| Partial<ED[keyof ED]['Schema']>
|
||||
| undefined;
|
||||
navigateTo: <T2 extends keyof ED>(
|
||||
options: { url: string } & OakNavigateToParameters<ED, T2>,
|
||||
state?: Record<string, any>,
|
||||
disableNamespace?: boolean
|
||||
) => Promise<void>;
|
||||
navigateBack: (delta?: number) => Promise<void>;
|
||||
redirectTo: <T2 extends keyof ED>(
|
||||
options: Parameters<typeof wx.redirectTo>[0] &
|
||||
OakNavigateToParameters<ED, T2>,
|
||||
state?: Record<string, any>,
|
||||
disableNamespace?: boolean
|
||||
) => Promise<void>;
|
||||
switchTab: <T2 extends keyof ED>(
|
||||
options: Parameters<typeof wx.switchTab>[0] &
|
||||
OakNavigateToParameters<ED, T2>,
|
||||
state?: Record<string, any>,
|
||||
disableNamespace?: boolean
|
||||
) => Promise<void>;
|
||||
// setProps: (props: Record<string, any>, usingState?: true) => void;
|
||||
clean: (path?: string) => void;
|
||||
> = {
|
||||
setDisablePulldownRefresh: (able: boolean) => void;
|
||||
sub: (type: string, callback: Function) => void;
|
||||
unsub: (type: string, callback: Function) => void;
|
||||
pub: (type: string, options?: any) => void;
|
||||
unsubAll: (type: string) => void;
|
||||
save: (key: string, item: any) => void;
|
||||
load: (key: string) => any;
|
||||
clear: () => void;
|
||||
resolveInput: <K extends string>(
|
||||
input: any,
|
||||
keys?: K[]
|
||||
) => { dataset?: Record<string, any>; value?: string } & {
|
||||
[k in K]?: any;
|
||||
};
|
||||
setNotification: (data: NotificationProps) => void;
|
||||
consumeNotification: () => NotificationProps | undefined;
|
||||
setMessage: (data: MessageProps) => void;
|
||||
consumeMessage: () => MessageProps | undefined;
|
||||
reRender: (extra?: Record<string, any>) => void;
|
||||
getFreshValue: (
|
||||
path?: string
|
||||
) =>
|
||||
| Partial<ED[keyof ED]['Schema']>[]
|
||||
| Partial<ED[keyof ED]['Schema']>
|
||||
| undefined;
|
||||
navigateTo: <T2 extends keyof ED>(
|
||||
options: { url: string } & OakNavigateToParameters<ED, T2>,
|
||||
state?: Record<string, any>,
|
||||
disableNamespace?: boolean
|
||||
) => Promise<void>;
|
||||
navigateBack: (delta?: number) => Promise<void>;
|
||||
redirectTo: <T2 extends keyof ED>(
|
||||
options: Parameters<typeof wx.redirectTo>[0] &
|
||||
OakNavigateToParameters<ED, T2>,
|
||||
state?: Record<string, any>,
|
||||
disableNamespace?: boolean
|
||||
) => Promise<void>;
|
||||
switchTab: <T2 extends keyof ED>(
|
||||
options: Parameters<typeof wx.switchTab>[0] &
|
||||
OakNavigateToParameters<ED, T2>,
|
||||
state?: Record<string, any>,
|
||||
disableNamespace?: boolean
|
||||
) => Promise<void>;
|
||||
// setProps: (props: Record<string, any>, usingState?: true) => void;
|
||||
clean: (path?: string) => void;
|
||||
|
||||
t(key: string, params?: object): string;
|
||||
execute: (
|
||||
action?: ED[T]['Action'],
|
||||
messageProps?: boolean | MessageProps
|
||||
) => Promise<void>;
|
||||
checkOperation: (
|
||||
entity: T,
|
||||
action: ED[T]['Action'],
|
||||
data?: ED[T]['Update']['data'],
|
||||
filter?: ED[T]['Update']['filter'],
|
||||
checkerTypes?: CheckerType[]
|
||||
) => boolean;
|
||||
tryExecute: (path?: string) => boolean | Error;
|
||||
getOperations: (
|
||||
path?: string
|
||||
) => { operation: ED[T]['Operation']; entity: T }[] | undefined;
|
||||
refresh: () => Promise<void>;
|
||||
aggregate: (
|
||||
aggregation: ED[T]['Aggregation']
|
||||
) => Promise<AggregationResult<ED[T]['Schema']>>;
|
||||
};
|
||||
t(key: string, params?: object): string;
|
||||
execute: (
|
||||
action?: ED[T]['Action'],
|
||||
messageProps?: boolean | MessageProps
|
||||
) => Promise<void>;
|
||||
checkOperation: (
|
||||
entity: T,
|
||||
action: ED[T]['Action'],
|
||||
data?: ED[T]['Update']['data'],
|
||||
filter?: ED[T]['Update']['filter'],
|
||||
checkerTypes?: CheckerType[]
|
||||
) => boolean;
|
||||
tryExecute: (path?: string) => boolean | Error;
|
||||
getOperations: (
|
||||
path?: string
|
||||
) => { operation: ED[T]['Operation']; entity: T }[] | undefined;
|
||||
refresh: () => Promise<void>;
|
||||
aggregate: (
|
||||
aggregation: ED[T]['Aggregation']
|
||||
) => Promise<AggregationResult<ED[T]['Schema']>>;
|
||||
};
|
||||
|
||||
export type OakSingleComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||
setId: (id: string) => void;
|
||||
|
|
|
|||
Loading…
Reference in New Issue