mirror of
https://github.com/NetEase/tango.git
synced 2026-08-31 09:30:28 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 897fe0a5a1 | |||
| b52bbad547 | |||
| f7c837a8a9 | |||
| f64d178ab8 | |||
| f2dcc942ed | |||
| ac48a8880e |
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"author": "Wells <ww.sun@outlook.com>",
|
||||
"scripts": {
|
||||
"dev": "HOST=local.netease.com PORT=8001 umi dev",
|
||||
"dev": "cross-env HOST=local.netease.com PORT=8001 umi dev",
|
||||
"build": "umi build",
|
||||
"postinstall": "umi setup",
|
||||
"setup": "umi setup",
|
||||
|
||||
@@ -174,6 +174,30 @@ const prototypes: Dict<IComponentPrototype> = {
|
||||
package: '@music163/antd',
|
||||
hasChildren: true,
|
||||
siblingNames: ['Box'],
|
||||
props: [
|
||||
{
|
||||
name: 'aaa',
|
||||
title: 'aaa',
|
||||
setter: 'textSetter',
|
||||
},
|
||||
{
|
||||
name: 'bbb',
|
||||
title: 'bbb',
|
||||
setter: 'textSetter',
|
||||
deprecated: true,
|
||||
},
|
||||
{
|
||||
name: 'ccc',
|
||||
title: 'ccc',
|
||||
setter: 'textSetter',
|
||||
deprecated: true,
|
||||
},
|
||||
{
|
||||
name: 'd',
|
||||
title: 'd',
|
||||
setter: 'textSetter',
|
||||
},
|
||||
],
|
||||
},
|
||||
Columns: {
|
||||
name: 'Columns',
|
||||
|
||||
@@ -63,6 +63,7 @@ const menuData = {
|
||||
'Columns',
|
||||
'Column',
|
||||
'Box',
|
||||
'Text',
|
||||
'Space',
|
||||
'Typography',
|
||||
'Title',
|
||||
|
||||
@@ -4,6 +4,7 @@ import { IComponentPrototype } from '@music163/tango-helpers';
|
||||
import { BorderSetter, DisplaySetter } from '@music163/tango-designer/src/setters/style-setter';
|
||||
import { JsxSetter } from '@music163/tango-designer/src/setters/jsx-setter';
|
||||
import { RenderSetter, TableCellSetter } from '@music163/tango-designer/src/setters/render-setter';
|
||||
import { NumberSetter } from '@music163/tango-designer/src/setters/number-setter';
|
||||
import { Box } from 'coral-system';
|
||||
import { JsonView } from '@music163/tango-ui';
|
||||
import { toJS } from 'mobx';
|
||||
@@ -37,6 +38,11 @@ register({
|
||||
component: TableCellSetter,
|
||||
});
|
||||
|
||||
register({
|
||||
name: 'numberSetter',
|
||||
component: NumberSetter,
|
||||
});
|
||||
|
||||
createFromIconfontCN({
|
||||
scriptUrl: '//at.alicdn.com/t/c/font_2891794_cou9i7556tl.js',
|
||||
});
|
||||
@@ -274,6 +280,22 @@ const prototype: IComponentPrototype = {
|
||||
title: 'invalidSetter',
|
||||
setter: 'invalidSetter',
|
||||
},
|
||||
{
|
||||
name: 'validate',
|
||||
title: 'validate',
|
||||
setter: 'numberSetter',
|
||||
validate: (value) => {
|
||||
if (!value && value !== 0) {
|
||||
return '必填';
|
||||
}
|
||||
if (value < 0) {
|
||||
return '必须大于 0';
|
||||
}
|
||||
if (value > 10) {
|
||||
return '必须小于等于 10';
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"@typescript-eslint/parser": "^6.13.2",
|
||||
"conventional-changelog-cli": "^4.1.0",
|
||||
"copyfiles": "^2.4.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.55.0",
|
||||
"eslint-config-ali": "^14.0.2",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-context",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "react context for tango-apps",
|
||||
"keywords": [
|
||||
"react",
|
||||
@@ -31,8 +31,8 @@
|
||||
"react": ">= 16.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"@music163/tango-core": "^1.0.1",
|
||||
"@music163/tango-helpers": "^1.0.0-alpha.7",
|
||||
"@music163/tango-core": "^1.0.2",
|
||||
"@music163/tango-helpers": "^1.0.0",
|
||||
"mobx-react-lite": "4.0.5"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-core",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "tango core",
|
||||
"author": "wwsun <ww.sun@outlook.com>",
|
||||
"homepage": "",
|
||||
@@ -28,7 +28,7 @@
|
||||
"@babel/parser": "^7.23.5",
|
||||
"@babel/traverse": "^7.23.5",
|
||||
"@babel/types": "^7.23.5",
|
||||
"@music163/tango-helpers": "^1.0.0-alpha.7",
|
||||
"@music163/tango-helpers": "^1.0.0",
|
||||
"@types/babel__generator": "^7.6.7",
|
||||
"@types/babel__traverse": "^7.20.4",
|
||||
"mobx": "6.12.0",
|
||||
|
||||
@@ -155,7 +155,7 @@ export function prototype2code(prototype: IComponentPrototype, extraProps?: Dict
|
||||
}))
|
||||
: [];
|
||||
// merge extraProps to props
|
||||
const props = [...prototype.props, ...propList];
|
||||
const props = [...(prototype.props || []), ...propList];
|
||||
|
||||
const keys =
|
||||
props.reduce((acc, item) => {
|
||||
|
||||
@@ -285,9 +285,16 @@ export interface IWorkspace {
|
||||
* 解析后的项目配置信息
|
||||
*/
|
||||
get projectConfig(): ITangoConfigJson;
|
||||
/**
|
||||
* 当前活动的视图文件
|
||||
*/
|
||||
get activeViewModule(): IViewFile;
|
||||
get pages(): any[];
|
||||
get bizComps(): string[];
|
||||
get baseComps(): string[];
|
||||
get localComps(): string[];
|
||||
/**
|
||||
* 是否是合法的项目
|
||||
*/
|
||||
get isValid(): boolean;
|
||||
}
|
||||
|
||||
@@ -144,6 +144,13 @@ export class Workspace extends EventTarget implements IWorkspace {
|
||||
*/
|
||||
private copyTempNodes: TangoNode[];
|
||||
|
||||
/**
|
||||
* 是否是合法的项目
|
||||
*/
|
||||
get isValid() {
|
||||
return !!this.tangoConfigJson && !!this.activeViewModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目配置,返回解析后的 tango.config.json 文件
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-designer",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "lowcode designer",
|
||||
"keywords": [
|
||||
"react"
|
||||
@@ -33,12 +33,12 @@
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^4.8.0",
|
||||
"@music163/request": "^0.1.2",
|
||||
"@music163/tango-context": "^1.0.1",
|
||||
"@music163/tango-core": "^1.0.1",
|
||||
"@music163/tango-helpers": "^1.0.0-alpha.7",
|
||||
"@music163/tango-sandbox": "^1.0.1",
|
||||
"@music163/tango-setting-form": "^1.0.2",
|
||||
"@music163/tango-ui": "^1.0.2",
|
||||
"@music163/tango-context": "^1.0.2",
|
||||
"@music163/tango-core": "^1.0.2",
|
||||
"@music163/tango-helpers": "^1.0.0",
|
||||
"@music163/tango-sandbox": "^1.0.2",
|
||||
"@music163/tango-setting-form": "^1.1.0",
|
||||
"@music163/tango-ui": "^1.0.3",
|
||||
"antd": "^4.24.2",
|
||||
"cash-dom": "^8.1.2",
|
||||
"classnames": "^2.3.2",
|
||||
|
||||
@@ -43,6 +43,7 @@ const setters: IFormItemCreateOptions[] = [
|
||||
name: 'expSetter',
|
||||
alias: ['expressionSetter'],
|
||||
component: ExpressionSetter,
|
||||
disableVariableSetter: true,
|
||||
},
|
||||
{
|
||||
name: 'numberSetter',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-helpers",
|
||||
"version": "1.0.0-alpha.7",
|
||||
"version": "1.0.0",
|
||||
"description": "Shared types, helpers, and hooks of tango-apps",
|
||||
"keywords": [
|
||||
"shared",
|
||||
|
||||
@@ -19,6 +19,15 @@ export type ComponentDndRulesType = IComponentDndRules;
|
||||
*/
|
||||
export type ComponentPrototypeType = IComponentPrototype;
|
||||
|
||||
/**
|
||||
* 组件校验规则
|
||||
*/
|
||||
export type ComponentPropValidate = (
|
||||
value: any,
|
||||
field: any,
|
||||
trigger: string,
|
||||
) => string | Promise<string>;
|
||||
|
||||
/**
|
||||
* 组件属性类型
|
||||
*/
|
||||
@@ -107,6 +116,10 @@ export interface IComponentProp<T = any> {
|
||||
* 动态设置表单项是否展示
|
||||
*/
|
||||
getVisible?: (form: any) => boolean;
|
||||
/**
|
||||
* 表单值校验逻辑
|
||||
*/
|
||||
validate?: ComponentPropValidate;
|
||||
/**
|
||||
* 标记属性是否已废弃
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-sandbox",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "sandbox of tango apps",
|
||||
"author": "wwsun <ww.sun@outlook.com>",
|
||||
"homepage": "",
|
||||
@@ -29,8 +29,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^4.8.0",
|
||||
"@music163/tango-core": "^1.0.1",
|
||||
"@music163/tango-helpers": "^1.0.0-alpha.7",
|
||||
"@music163/tango-core": "^1.0.2",
|
||||
"@music163/tango-helpers": "^1.0.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"lodash.isequal": "4.5.0",
|
||||
"react-frame-component": "^5.2.4"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-setting-form",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"description": "setting form of tango-apps",
|
||||
"author": "wwsun <ww.sun@outlook.com>",
|
||||
"homepage": "",
|
||||
@@ -28,9 +28,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^4.8.0",
|
||||
"@music163/tango-core": "^1.0.1",
|
||||
"@music163/tango-helpers": "^1.0.0-alpha.7",
|
||||
"@music163/tango-ui": "^1.0.2",
|
||||
"@music163/tango-core": "^1.0.2",
|
||||
"@music163/tango-helpers": "^1.0.0",
|
||||
"@music163/tango-ui": "^1.0.3",
|
||||
"antd": "^4.24.2",
|
||||
"coral-system": "^1.0.5",
|
||||
"mobx": "6.12.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { toJS } from 'mobx';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { clone, IComponentProp, useBoolean } from '@music163/tango-helpers';
|
||||
import { clone, ComponentPropValidate, IComponentProp, useBoolean } from '@music163/tango-helpers';
|
||||
import { isWrappedByExpressionContainer } from '@music163/tango-core';
|
||||
import { ToggleButton, CodeOutlined } from '@music163/tango-ui';
|
||||
import { InputProps } from 'antd';
|
||||
@@ -58,7 +58,7 @@ export interface IFormItemCreateOptions {
|
||||
/**
|
||||
* 默认的表单值校验逻辑
|
||||
*/
|
||||
validate?: (value: string) => string | Promise<any>;
|
||||
validate?: ComponentPropValidate;
|
||||
}
|
||||
|
||||
const defaultGetSetterProps = () => ({});
|
||||
@@ -86,6 +86,7 @@ export function createFormItem(options: IFormItemCreateOptions) {
|
||||
extra,
|
||||
footer,
|
||||
noStyle,
|
||||
validate,
|
||||
}: FormItemProps) {
|
||||
const { disableSwitchExpressionSetter, showItemSubtitle } = useFormVariable();
|
||||
const model = useFormModel();
|
||||
@@ -99,7 +100,7 @@ export function createFormItem(options: IFormItemCreateOptions) {
|
||||
const setterName = isVariable ? 'expressionSetter' : setter;
|
||||
|
||||
field.setConfig({
|
||||
validate: options.validate,
|
||||
validate: validate || options.validate,
|
||||
});
|
||||
|
||||
const baseComponentProps = clone(
|
||||
|
||||
@@ -234,11 +234,11 @@ export class Field {
|
||||
this.state.validating = false;
|
||||
this.state.error = error;
|
||||
|
||||
// 校验错误,不触发 onChange
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
// 校验错误,不触发 onChange
|
||||
this.parent?.onChange?.(this.name, this.value, this);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
||||
import { css, Box, HTMLCoralProps, Link } from 'coral-system';
|
||||
import { Checkbox, Tooltip } from 'antd';
|
||||
import { CollapsePanel } from '@music163/tango-ui';
|
||||
import { isNil, isString } from '@music163/tango-helpers';
|
||||
import { isString } from '@music163/tango-helpers';
|
||||
import { WarningOutlined } from '@ant-design/icons';
|
||||
|
||||
export interface FormControlProps extends Omit<FormLabelProps, 'type'> {
|
||||
@@ -94,7 +94,7 @@ export function FormControlGroup({
|
||||
onCheck?.(nextChecked);
|
||||
}}
|
||||
/>
|
||||
<FormLabel type="secondary" label={label} note={note} tip={tip} docs={docs} />
|
||||
<FormLabel label={label} note={note} tip={tip} docs={docs} />
|
||||
</Box>
|
||||
}
|
||||
extra={
|
||||
@@ -148,11 +148,6 @@ const tipStyle = css`
|
||||
`;
|
||||
|
||||
interface FormLabelProps extends HTMLCoralProps<'div'> {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
// eslint-disable-next-line react/no-unused-prop-types
|
||||
type?: 'normal' | 'secondary';
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@@ -176,15 +171,7 @@ interface FormLabelProps extends HTMLCoralProps<'div'> {
|
||||
deprecated?: boolean | string;
|
||||
}
|
||||
|
||||
function FormLabel({
|
||||
type = 'normal',
|
||||
label,
|
||||
note,
|
||||
tip,
|
||||
docs,
|
||||
deprecated,
|
||||
...rest
|
||||
}: FormLabelProps) {
|
||||
function FormLabel({ label, note, tip, docs, deprecated, ...rest }: FormLabelProps) {
|
||||
let help: React.ReactNode;
|
||||
if (deprecated || docs) {
|
||||
help = (
|
||||
@@ -209,16 +196,11 @@ function FormLabel({
|
||||
help = tip;
|
||||
}
|
||||
|
||||
const labelColor = {
|
||||
normal: 'text.body',
|
||||
secondary: 'text.note',
|
||||
}[type];
|
||||
|
||||
let labelNode = (
|
||||
<Box
|
||||
as="span"
|
||||
display="inline-block"
|
||||
color={labelColor}
|
||||
color="text2"
|
||||
className={help ? 'hasHelp' : ''}
|
||||
css={labelStyle}
|
||||
title={isString(label) ? label : undefined}
|
||||
@@ -236,7 +218,7 @@ function FormLabel({
|
||||
<Box fontSize="14px" {...rest}>
|
||||
{labelNode}
|
||||
{note && (
|
||||
<Box as="i" display="inline-block" fontSize="12px" color="text.note" ml="m">
|
||||
<Box as="i" display="inline-block" fontSize="12px" color="text3" ml="m">
|
||||
{note}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@@ -165,7 +165,15 @@ export function SettingForm({
|
||||
// 没有进行搜索的情况
|
||||
if (!keyword) {
|
||||
if (showGroups) {
|
||||
return componentPropGroups[tabKey] || [];
|
||||
return (
|
||||
componentPropGroups[tabKey].sort((a, b) => {
|
||||
// TIP: 将废弃属性往后移
|
||||
if (!a.deprecated && b.deprecated) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}) || []
|
||||
);
|
||||
} else {
|
||||
return computedProps;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ export function registerBuiltinSetters() {
|
||||
register({
|
||||
name: 'expressionSetter',
|
||||
component: ExpressionSetter,
|
||||
disableVariableSetter: true,
|
||||
});
|
||||
|
||||
register({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@music163/tango-ui",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "ui widgets of tango",
|
||||
"keywords": [
|
||||
"react",
|
||||
@@ -38,7 +38,7 @@
|
||||
"@codemirror/lang-javascript": "^6.2.1",
|
||||
"@codemirror/lint": "^6.4.2",
|
||||
"@codemirror/search": "^6.5.5",
|
||||
"@music163/tango-helpers": "^1.0.0-alpha.7",
|
||||
"@music163/tango-helpers": "^1.0.0",
|
||||
"@uiw/react-codemirror": "^4.21.21",
|
||||
"antd": "^4.24.2",
|
||||
"classnames": "^2.5.1",
|
||||
|
||||
Reference in New Issue
Block a user