mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
commit
16ac0fa5c9
@ -1,25 +1,22 @@
|
||||
import React = require('react');
|
||||
import NotFound from '../../src/components/404';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup} from '@testing-library/react';
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
test('Components:404 default View', () => {
|
||||
const component = renderer.create(
|
||||
<NotFound />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
const component = renderer.create(<NotFound />);
|
||||
let tree = component.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
test('Components:404 Custom code & messages', () => {
|
||||
const component = renderer.create(
|
||||
<NotFound code={500} description="Internal Error" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
const component = renderer.create(
|
||||
<NotFound code={500} description="Internal Error" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
import '../src/themes/default';
|
||||
import {render as amisRender} from '../src/index';
|
||||
import React = require('react');
|
||||
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup} from '@testing-library/react';
|
||||
import {wait, makeEnv} from './helper';
|
||||
|
||||
test('factory unregistered Renderer', async () => {
|
||||
|
@ -1,118 +1,128 @@
|
||||
import React = require('react');
|
||||
import Action from '../../src/renderers/Action';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
test('Renderers:Action MenuItem changes class when actived & disabled', () => {
|
||||
const component = renderer.create(
|
||||
<Action isMenuItem className="a" label="123" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
const component = renderer.create(
|
||||
<Action isMenuItem className="a" label="123" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
expect(tree).toMatchSnapshot();
|
||||
|
||||
component.update(
|
||||
<Action isMenuItem className="a" label="233" active />
|
||||
);
|
||||
component.update(<Action isMenuItem className="a" label="233" active />);
|
||||
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
|
||||
component.update(
|
||||
<Action isMenuItem className="a" label="233" active disabled />
|
||||
);
|
||||
component.update(
|
||||
<Action isMenuItem className="a" label="233" active disabled />
|
||||
);
|
||||
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Renderers:Action MenuItem display icon', () => {
|
||||
const component = renderer.create(
|
||||
<Action isMenuItem className="a" label="123" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
const component = renderer.create(
|
||||
<Action isMenuItem className="a" label="123" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
expect(tree).toMatchSnapshot();
|
||||
|
||||
component.update(
|
||||
<Action isMenuItem className="a" label="123" icon="fa fa-cloud" />
|
||||
);
|
||||
component.update(
|
||||
<Action isMenuItem className="a" label="123" icon="fa fa-cloud" />
|
||||
);
|
||||
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Renderers:Action [actionType = "link"] show active class', () => {
|
||||
const isCurrentUrl = (link:string) => link === "b";
|
||||
const component = renderer.create(
|
||||
<Action actionType="link" link="a" className="a" label="123" isCurrentUrl={isCurrentUrl} />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
const isCurrentUrl = (link: string) => link === 'b';
|
||||
const component = renderer.create(
|
||||
<Action
|
||||
actionType="link"
|
||||
link="a"
|
||||
className="a"
|
||||
label="123"
|
||||
isCurrentUrl={isCurrentUrl}
|
||||
/>
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
expect(tree).toMatchSnapshot();
|
||||
|
||||
component.update(
|
||||
<Action actionType="link" link="b" className="a" label="123" isCurrentUrl={isCurrentUrl} />
|
||||
);
|
||||
component.update(
|
||||
<Action
|
||||
actionType="link"
|
||||
link="b"
|
||||
className="a"
|
||||
label="123"
|
||||
isCurrentUrl={isCurrentUrl}
|
||||
/>
|
||||
);
|
||||
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Renderers:Action custom activeClass', () => {
|
||||
const component = renderer.create(
|
||||
<Action className="a" label="123" activeClassName="custom-active" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
const component = renderer.create(
|
||||
<Action className="a" label="123" activeClassName="custom-active" />
|
||||
);
|
||||
let tree = component.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
expect(tree).toMatchSnapshot();
|
||||
|
||||
component.update(
|
||||
<Action className="a" label="123" activeClassName="custom-active" active />
|
||||
);
|
||||
component.update(
|
||||
<Action className="a" label="123" activeClassName="custom-active" active />
|
||||
);
|
||||
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
tree = component.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Renderers:Action onAction called?', () => {
|
||||
const onAction = jest.fn();
|
||||
const {getByText} = render(
|
||||
<Action className="a" label="123" onAction={onAction}></Action>
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/123/));
|
||||
expect(onAction).toHaveBeenCalled();
|
||||
const onAction = jest.fn();
|
||||
const {getByText} = render(
|
||||
<Action className="a" label="123" onAction={onAction}></Action>
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/123/));
|
||||
expect(onAction).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('Renderers:Action disabled onAction called?', () => {
|
||||
const onAction = jest.fn();
|
||||
const {getByText} = render(
|
||||
<Action disabled className="a" label="123" onAction={onAction}></Action>
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/123/));
|
||||
expect(onAction).not.toHaveBeenCalled();
|
||||
const onAction = jest.fn();
|
||||
const {getByText} = render(
|
||||
<Action disabled className="a" label="123" onAction={onAction}></Action>
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/123/));
|
||||
expect(onAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('Renderers:Action onClick cancel onAction?', () => {
|
||||
const onAction = jest.fn();
|
||||
const onClick = jest.fn(e => e.preventDefault());
|
||||
const {getByText} = render(
|
||||
<Action
|
||||
isMenuItem
|
||||
className="a"
|
||||
label="123"
|
||||
onClick={onClick}
|
||||
onAction={onAction}>
|
||||
</Action>
|
||||
);
|
||||
const onAction = jest.fn();
|
||||
const onClick = jest.fn(e => e.preventDefault());
|
||||
const {getByText} = render(
|
||||
<Action
|
||||
isMenuItem
|
||||
className="a"
|
||||
label="123"
|
||||
onClick={onClick}
|
||||
onAction={onAction}
|
||||
></Action>
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/123/));
|
||||
fireEvent.click(getByText(/123/));
|
||||
|
||||
expect(onClick).toHaveBeenCalled();
|
||||
expect(onAction).not.toHaveBeenCalled();
|
||||
});
|
||||
expect(onClick).toHaveBeenCalled();
|
||||
expect(onAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -1,28 +1,29 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:alert', () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
body: {
|
||||
type: 'alert',
|
||||
level: 'success',
|
||||
body: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '提示内容'
|
||||
}
|
||||
]
|
||||
type: 'alert',
|
||||
level: 'success',
|
||||
body: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '提示内容'
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import {render as amisRender} from '../../src';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
@ -11,9 +11,9 @@ beforeAll(() => {
|
||||
get() {
|
||||
return () => {
|
||||
times++;
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@ -21,31 +21,35 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
test('Renderer:audio', () => {
|
||||
const {container} = render(amisRender(
|
||||
{
|
||||
type: 'audio',
|
||||
src: '${url}'
|
||||
},
|
||||
{
|
||||
data: {
|
||||
url: 'https://example.com/music.mp3'
|
||||
}
|
||||
},
|
||||
makeEnv({})
|
||||
));
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'audio',
|
||||
src: '${url}'
|
||||
},
|
||||
{
|
||||
data: {
|
||||
url: 'https://example.com/music.mp3'
|
||||
}
|
||||
},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should not call load method at first render phase', () => {
|
||||
render(amisRender(
|
||||
{
|
||||
type: 'audio',
|
||||
src: 'https://example.com/music.mp3'
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
));
|
||||
render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'audio',
|
||||
src: 'https://example.com/music.mp3'
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(times).toBe(0);
|
||||
});
|
||||
|
@ -1,31 +1,32 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:button-toolbar', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'button-toolbar',
|
||||
name: 'button-toolbar',
|
||||
label: 'button-toolbar',
|
||||
buttons: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮1',
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮2'
|
||||
}
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮2'
|
||||
}
|
||||
],
|
||||
className: 'show'
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,25 +1,25 @@
|
||||
import React = require("react");
|
||||
import { render, fireEvent } from "react-testing-library";
|
||||
import "../../src/themes/default";
|
||||
import { render as amisRender } from "../../src/index";
|
||||
import { makeEnv } from "../helper";
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test("Renderer:carousel", async () => {
|
||||
const { container } = render(
|
||||
test('Renderer:carousel', async () => {
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: "carousel",
|
||||
controlsTheme: "light",
|
||||
width: "500",
|
||||
height: "300",
|
||||
type: 'carousel',
|
||||
controlsTheme: 'light',
|
||||
width: '500',
|
||||
height: '300',
|
||||
options: [
|
||||
{
|
||||
image:
|
||||
"https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png",
|
||||
title: "标题",
|
||||
titleClassName: "block",
|
||||
description: "描述",
|
||||
descriptionClassName: "block"
|
||||
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png',
|
||||
title: '标题',
|
||||
titleClassName: 'block',
|
||||
description: '描述',
|
||||
descriptionClassName: 'block'
|
||||
},
|
||||
{
|
||||
html:
|
||||
@ -27,21 +27,21 @@ test("Renderer:carousel", async () => {
|
||||
},
|
||||
{
|
||||
image:
|
||||
"https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg"
|
||||
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
|
||||
}
|
||||
],
|
||||
className: "show"
|
||||
className: 'show'
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
const image = document.querySelector("div.a-Carousel-item");
|
||||
const image = document.querySelector('div.a-Carousel-item');
|
||||
fireEvent.mouseEnter(image as HTMLDivElement);
|
||||
const leftArrow = document.querySelector("div.a-Carousel-leftArrow");
|
||||
const leftArrow = document.querySelector('div.a-Carousel-leftArrow');
|
||||
fireEvent.click(leftArrow as HTMLDivElement);
|
||||
const rightArrow = document.querySelector("div.a-Carousel-rightArrow");
|
||||
const rightArrow = document.querySelector('div.a-Carousel-rightArrow');
|
||||
fireEvent.click(rightArrow as HTMLDivElement);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
@ -1,32 +1,33 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:container', () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
body: {
|
||||
type: 'container',
|
||||
className: 'bg-white',
|
||||
body: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '内容1'
|
||||
},
|
||||
{
|
||||
type: 'plain',
|
||||
tpl: '内容2'
|
||||
}
|
||||
]
|
||||
type: 'container',
|
||||
className: 'bg-white',
|
||||
body: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '内容1'
|
||||
},
|
||||
{
|
||||
type: 'plain',
|
||||
tpl: '内容2'
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
@ -1,49 +1,50 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:dropdown-button', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'dropdown-button',
|
||||
level: 'primary',
|
||||
buttons: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '系统提示',
|
||||
body: '对你点击了'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '系统提示',
|
||||
body: '对你点击了'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮',
|
||||
visible: false
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '系统提示',
|
||||
body: '对你点击了'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '系统提示',
|
||||
body: '对你点击了'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '按钮',
|
||||
visible: false
|
||||
}
|
||||
],
|
||||
className: 'show'
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
const dropdowmButton = document.querySelector('button.a-Button');
|
||||
fireEvent.click(dropdowmButton as HTMLDivElement);
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(dropdowmButton as HTMLDivElement);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
const dropdowmButton = document.querySelector('button.a-Button');
|
||||
fireEvent.click(dropdowmButton as HTMLDivElement);
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(dropdowmButton as HTMLDivElement);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,24 +1,25 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:each', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'each',
|
||||
items: {
|
||||
type: 'tpl',
|
||||
tpl: '<%= data.name %>'
|
||||
type: 'tpl',
|
||||
tpl: '<%= data.name %>'
|
||||
},
|
||||
value: [{name: 'jack'}, {name: 'martin'}],
|
||||
className: 'show'
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -0,0 +1,49 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Form:options:autoFill:data 1`] = `
|
||||
Object {
|
||||
"a": "a",
|
||||
"aId": 233,
|
||||
"aLabel": "OptionA",
|
||||
"aValue": "a",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Form:options:autoFill:data 2`] = `
|
||||
Object {
|
||||
"a": "b",
|
||||
"aId": "",
|
||||
"aLabel": "OptionB",
|
||||
"aValue": "b",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Form:options:autoFill:multiple:data 1`] = `
|
||||
Object {
|
||||
"a": "a",
|
||||
"aIds": Array [
|
||||
233,
|
||||
],
|
||||
"aLabels": Array [
|
||||
"OptionA",
|
||||
],
|
||||
"aValues": Array [
|
||||
"a",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Form:options:autoFill:multiple:data 2`] = `
|
||||
Object {
|
||||
"a": "b",
|
||||
"aIds": Array [
|
||||
undefined,
|
||||
],
|
||||
"aLabels": Array [
|
||||
"OptionB",
|
||||
],
|
||||
"aValues": Array [
|
||||
"b",
|
||||
],
|
||||
}
|
||||
`;
|
@ -33,7 +33,7 @@ exports[`Renderer:button 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default a-Form-control"
|
||||
class="a-Button a-Button--default"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
@ -49,7 +49,7 @@ exports[`Renderer:button 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default a-Form-control"
|
||||
class="a-Button a-Button--default"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
@ -62,7 +62,7 @@ exports[`Renderer:button 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--primary a-Form-control"
|
||||
class="a-Button a-Button--primary"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
@ -75,7 +75,7 @@ exports[`Renderer:button 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--danger a-Button--sm a-Form-control"
|
||||
class="a-Button a-Button--danger a-Button--sm"
|
||||
type="reset"
|
||||
>
|
||||
<span>
|
||||
@ -165,7 +165,7 @@ exports[`Renderer:button 2`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default a-Form-control"
|
||||
class="a-Button a-Button--default"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
@ -181,7 +181,7 @@ exports[`Renderer:button 2`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default a-Form-control"
|
||||
class="a-Button a-Button--default"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
@ -194,7 +194,7 @@ exports[`Renderer:button 2`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--primary a-Form-control"
|
||||
class="a-Button a-Button--primary"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
@ -207,7 +207,7 @@ exports[`Renderer:button 2`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--danger a-Button--sm a-Form-control"
|
||||
class="a-Button a-Button--danger a-Button--sm"
|
||||
type="reset"
|
||||
>
|
||||
<span>
|
||||
|
@ -33,7 +33,7 @@ exports[`Renderer:button-toolbar 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-ButtonToolbar a-Form-control"
|
||||
class="a-ButtonToolbar"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
@ -143,7 +143,7 @@ exports[`Renderer:button-toolbar 2`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-ButtonToolbar a-Form-control"
|
||||
class="a-ButtonToolbar"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
|
@ -46,53 +46,44 @@ exports[`Renderer:container 1`] = `
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-value a-Form-itemColumn--7"
|
||||
class="a-Form-value"
|
||||
>
|
||||
<div
|
||||
class="a-Container a-Form-control"
|
||||
class="a-Container"
|
||||
>
|
||||
<div
|
||||
class="a-Form--horizontal bg-white"
|
||||
class="a-Container-body bg-white"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--horizontal"
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label a-Form-itemColumn--normal"
|
||||
>
|
||||
<span />
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-value a-Form-itemColumn--7"
|
||||
class="a-Form-control a-TextControl a-TextControl--withAddOn"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl a-TextControl--withAddOn"
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="text"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="a-TextControl-button"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="text"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="a-TextControl-button"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
按钮
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<span>
|
||||
按钮
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -47,7 +47,7 @@ exports[`Renderer:fieldSet 1`] = `
|
||||
<span />
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-value a-Form-itemColumn--7"
|
||||
class="a-Form-value"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
|
@ -33,13 +33,13 @@ exports[`Renderer:hbox 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Grid a-Form-control"
|
||||
class="a-Grid"
|
||||
>
|
||||
<div
|
||||
class="a-Grid-col--md3 bg-white"
|
||||
>
|
||||
<div
|
||||
class="a-Grid-form a-Form--normal"
|
||||
class="a-Wrapper"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
|
@ -33,13 +33,13 @@ exports[`Renderer:hbox 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-FormHbox a-Form-control"
|
||||
class="a-Hbox"
|
||||
>
|
||||
<div
|
||||
class="a-Hbox"
|
||||
class="a-Hbox-col w-sm"
|
||||
>
|
||||
<div
|
||||
class="a-Hbox-col a-Form--normal w-sm"
|
||||
class="a-Wrapper"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
@ -63,17 +63,17 @@ exports[`Renderer:hbox 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Hbox-col a-Form--normal"
|
||||
</div>
|
||||
<div
|
||||
class="a-Hbox-col"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
其他类型的渲染器
|
||||
</span>
|
||||
<span>
|
||||
其他类型的渲染器
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
526
__tests__/renderers/Form/__snapshots__/initData.test.tsx.snap
Normal file
526
__tests__/renderers/Form/__snapshots__/initData.test.tsx.snap
Normal file
@ -0,0 +1,526 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Form:initData 1`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="b"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Form:initData 2`] = `
|
||||
Object {
|
||||
"a": "1",
|
||||
"b": "2",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Form:initData:remote 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="a-Panel a-Panel--default a-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="a-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="a-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
The form
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-body"
|
||||
>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Spinner-overlay in"
|
||||
/>
|
||||
<div
|
||||
class="a-Spinner in a-Spinner--overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
Label
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-control a-TextControl is-disabled"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
disabled=""
|
||||
name="a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="123"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-footerWrap"
|
||||
>
|
||||
<div
|
||||
class="a-Panel-btnToolbar a-Panel-footer"
|
||||
>
|
||||
<div
|
||||
class="a-Button a-Button--default is-disabled"
|
||||
disabled=""
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Form:initData:remote 2`] = `
|
||||
Object {
|
||||
"config": Object {
|
||||
"cancelExecutor": [Function],
|
||||
"errorMessage": "fetchFailed",
|
||||
"onSuccess": [Function],
|
||||
"successMessage": undefined,
|
||||
},
|
||||
"method": "get",
|
||||
"query": Object {
|
||||
"a": "123",
|
||||
},
|
||||
"url": "/api/xxx?a=123",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Form:initData:remote 3`] = `
|
||||
<div>
|
||||
<div
|
||||
class="a-Panel a-Panel--default a-Panel--form"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="a-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="a-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
The form
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-body"
|
||||
>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Spinner-overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Spinner a-Spinner--overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
Label
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-footerWrap"
|
||||
>
|
||||
<div
|
||||
class="a-Panel-btnToolbar a-Panel-footer"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Form:initData:remote 4`] = `
|
||||
Object {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Form:initData:super 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="a-Page"
|
||||
>
|
||||
<div
|
||||
class="a-Page-content"
|
||||
>
|
||||
<div
|
||||
class="a-Page-main"
|
||||
>
|
||||
<div
|
||||
class="a-Page-body"
|
||||
>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="b"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Form:initData:super 2`] = `Object {}`;
|
||||
|
||||
exports[`Form:initData:without-super 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="a-Page"
|
||||
>
|
||||
<div
|
||||
class="a-Page-content"
|
||||
>
|
||||
<div
|
||||
class="a-Page-main"
|
||||
>
|
||||
<div
|
||||
class="a-Page-body"
|
||||
>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="b"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Form:initData:without-super 2`] = `Object {}`;
|
@ -46,7 +46,7 @@ exports[`Renderer:fieldSet 1`] = `
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-value a-Form-itemColumn--7"
|
||||
class="a-Form-value"
|
||||
>
|
||||
<div
|
||||
class="a-InputGroup a-Form-control"
|
||||
|
462
__tests__/renderers/Form/__snapshots__/options.test.tsx.snap
Normal file
462
__tests__/renderers/Form/__snapshots__/options.test.tsx.snap
Normal file
@ -0,0 +1,462 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`options:linkage 1`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项x
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-ListControl a-Form-control is-inline"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-items"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项1
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项2
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项y
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-RadiosControl a-Form-control is-inline"
|
||||
>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项a
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项b
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`options:linkage 2`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项x
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-ListControl a-Form-control is-inline"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-items"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-item is-active"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项1
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项2
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项y
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-RadiosControl a-Form-control is-inline"
|
||||
>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
disabled=""
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项a
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项b
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`options:linkage 3`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项x
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-ListControl a-Form-control is-inline"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-items"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项1
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item is-active"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项2
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项y
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-RadiosControl a-Form-control is-inline"
|
||||
>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项a
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`options:linkage 4`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项x
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-ListControl a-Form-control is-inline"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-items"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项1
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项2
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-ListControl-item is-active"
|
||||
>
|
||||
<div
|
||||
class="a-ListControl-itemLabel"
|
||||
>
|
||||
选项3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label text-muted"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
选项y
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-RadiosControl a-Form-control is-inline"
|
||||
>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项a
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项b
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="a-Checkbox a-Checkbox--radio a-Checkbox--full"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
/>
|
||||
<i />
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
选项c
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
@ -33,131 +33,141 @@ exports[`Renderer:panel 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-FormHbox a-Form-control"
|
||||
class="a-Hbox"
|
||||
>
|
||||
<div
|
||||
class="a-Hbox"
|
||||
class="a-Hbox-col"
|
||||
>
|
||||
<div
|
||||
class="a-Hbox-col a-Form--normal"
|
||||
class="a-Wrapper"
|
||||
>
|
||||
<div
|
||||
class="a-Panel a-Panel--default"
|
||||
style="position: relative;"
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="a-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
bla bla
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="bg-white"
|
||||
>
|
||||
<span
|
||||
class="a-PlainField"
|
||||
>
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
Text
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-footerWrap"
|
||||
class="a-Panel a-Panel--default"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="bg-black"
|
||||
class="a-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="a-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
bla bla
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="bg-white"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
class="a-PlainField"
|
||||
>
|
||||
<span>
|
||||
<p>
|
||||
footer 内容
|
||||
</p>
|
||||
<span
|
||||
class="text-muted"
|
||||
>
|
||||
Text
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
class="a-Panel-footerWrap"
|
||||
>
|
||||
<div
|
||||
class="bg-black"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
<p>
|
||||
footer 内容
|
||||
</p>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Hbox-col"
|
||||
>
|
||||
<div
|
||||
class="a-Hbox-col a-Form--normal"
|
||||
class="a-Wrapper"
|
||||
>
|
||||
<div
|
||||
class="a-Panel a-Panel--default"
|
||||
style="position: relative;"
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="a-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
bla bla
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-body"
|
||||
class="a-Panel a-Panel--default"
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
class="a-Form--normal"
|
||||
class="a-Panel-heading"
|
||||
>
|
||||
<h3
|
||||
class="a-Panel-title"
|
||||
>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
bla bla
|
||||
</span>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="a-Panel-body"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
@ -171,7 +181,6 @@ exports[`Renderer:panel 1`] = `
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="text"
|
||||
placeholder="Text 1"
|
||||
size="10"
|
||||
type="text"
|
||||
@ -192,7 +201,6 @@ exports[`Renderer:panel 1`] = `
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="text2"
|
||||
placeholder="Text 2"
|
||||
size="10"
|
||||
type="text"
|
||||
@ -202,45 +210,45 @@ exports[`Renderer:panel 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
class="resize-sensor"
|
||||
style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
class="resize-sensor-expand"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
<div
|
||||
style="position: absolute; left: 0px; top: 0px; width: 10px; height: 10px;"
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="resize-sensor-shrink"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;"
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
style="position: absolute; left: 0; top: 0; width: 200%; height: 200%"
|
||||
/>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="resize-sensor-appear"
|
||||
style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;animation-name: apearSensor; animation-duration: 0.2s;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -256,6 +256,7 @@ exports[`Renderer:range:multiple 1`] = `
|
||||
>
|
||||
<span
|
||||
class="a-InputRange-label a-InputRange-label--value"
|
||||
style="left: calc(50% - 0px);"
|
||||
>
|
||||
<span
|
||||
class="a-InputRange-labelContainer"
|
||||
|
@ -85,78 +85,82 @@ exports[`Renderer:service 1`] = `
|
||||
class="a-Service m-t"
|
||||
>
|
||||
<div
|
||||
class="a-Form--normal"
|
||||
class="a-Service-body"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal is-required"
|
||||
data-role="form-item"
|
||||
class="a-Wrapper a-Wrapper--md"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal is-required"
|
||||
data-role="form-item"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
动态字段1
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
动态字段1
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="a-Form-star"
|
||||
>
|
||||
*
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="a-Form-star"
|
||||
>
|
||||
*
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
</label>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="dy_1"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="dy_1"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
动态字段2
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
动态字段2
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
</label>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="dy_2"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="dy_2"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -216,3 +220,214 @@ exports[`Renderer:service 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`form:service:remoteData 1`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Service"
|
||||
>
|
||||
<div
|
||||
class="a-Service-body"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="child-a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="123"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Spinner-overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Spinner a-Spinner--overlay a-Spinner--lg"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`form:service:remoteSchmea+data 1`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Service"
|
||||
>
|
||||
<div
|
||||
class="a-Service-body"
|
||||
>
|
||||
<div
|
||||
class="a-Wrapper a-Wrapper--md"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="child-a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="123"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="child-b"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="344"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Spinner-overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Spinner a-Spinner--overlay a-Spinner--lg"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`form:service:super-remoteData 1`] = `
|
||||
<div>
|
||||
<form
|
||||
class="a-Form a-Form--normal"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="a-Spinner-overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Spinner a-Spinner--overlay"
|
||||
/>
|
||||
<div
|
||||
class="a-Service"
|
||||
>
|
||||
<div
|
||||
class="a-Service-body"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="child-a"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value="123"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default"
|
||||
type="submit"
|
||||
>
|
||||
<span>
|
||||
Submit
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
style="display: none;"
|
||||
type="submit"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
@ -70,74 +70,70 @@ exports[`Renderer:tabs 1`] = `
|
||||
class="a-Tabs-pane"
|
||||
>
|
||||
<div
|
||||
class="a-Form--normal"
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
文本3
|
||||
</span>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
文本3
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="c"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="c"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
</div>
|
||||
<div
|
||||
class="a-Form-item a-Form-item--normal"
|
||||
data-role="form-item"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<label
|
||||
class="a-Form-label"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
文本4
|
||||
</span>
|
||||
<span>
|
||||
<span
|
||||
class="a-TplField"
|
||||
>
|
||||
<span>
|
||||
文本4
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
>
|
||||
<div
|
||||
class="a-Form-control a-TextControl"
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<div
|
||||
class="a-TextControl-input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="d"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
autocomplete="off"
|
||||
name="d"
|
||||
placeholder=""
|
||||
size="10"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
|
204
__tests__/renderers/Form/autoFill.test.tsx
Normal file
204
__tests__/renderers/Form/autoFill.test.tsx
Normal file
@ -0,0 +1,204 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Form:options:autoFill', async () => {
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'radios',
|
||||
name: 'a',
|
||||
autoFill: {
|
||||
aValue: '${value}',
|
||||
aLabel: '${label}',
|
||||
aId: '${id}'
|
||||
},
|
||||
options: [
|
||||
{
|
||||
label: 'OptionA',
|
||||
value: 'a',
|
||||
id: 233
|
||||
},
|
||||
{
|
||||
label: 'OptionB',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'a'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'aValue'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'aLabel'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'aId'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
// expect(container).toMatchSnapshot();
|
||||
fireEvent.click(getByText(/OptionA/));
|
||||
await wait(300);
|
||||
|
||||
expect(container.querySelector('input[name=a]')?.getAttribute('value')).toBe(
|
||||
'a'
|
||||
);
|
||||
expect(
|
||||
container.querySelector('input[name=aValue]')?.getAttribute('value')
|
||||
).toBe('a');
|
||||
expect(
|
||||
container.querySelector('input[name=aLabel]')?.getAttribute('value')
|
||||
).toBe('OptionA');
|
||||
expect(
|
||||
container.querySelector('input[name=aId]')?.getAttribute('value')
|
||||
).toBe('233');
|
||||
|
||||
fireEvent.click(getByText(/OptionB/));
|
||||
await wait(300);
|
||||
|
||||
expect(container.querySelector('input[name=a]')?.getAttribute('value')).toBe(
|
||||
'b'
|
||||
);
|
||||
expect(
|
||||
container.querySelector('input[name=aValue]')?.getAttribute('value')
|
||||
).toBe('b');
|
||||
expect(
|
||||
container.querySelector('input[name=aLabel]')?.getAttribute('value')
|
||||
).toBe('OptionB');
|
||||
expect(
|
||||
container.querySelector('input[name=aId]')?.getAttribute('value')
|
||||
).toBe('');
|
||||
});
|
||||
|
||||
test('Form:options:autoFill:data', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'radios',
|
||||
name: 'a',
|
||||
autoFill: {
|
||||
aValue: '${value}',
|
||||
aLabel: '${label}',
|
||||
aId: '${id}'
|
||||
},
|
||||
options: [
|
||||
{
|
||||
label: 'OptionA',
|
||||
value: 'a',
|
||||
id: 233
|
||||
},
|
||||
{
|
||||
label: 'OptionB',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: 'Submit'
|
||||
},
|
||||
{
|
||||
onSubmit: onSubmit
|
||||
},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/OptionA/));
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText(/OptionB/));
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalledTimes(2);
|
||||
expect(onSubmit.mock.calls[1][0]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Form:options:autoFill:multiple:data', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'radios',
|
||||
name: 'a',
|
||||
multiple: true,
|
||||
autoFill: {
|
||||
aValues: '${items|pick:value}',
|
||||
aLabels: '${items|pick:label}',
|
||||
aIds: '${items|pick:id}'
|
||||
},
|
||||
options: [
|
||||
{
|
||||
label: 'OptionA',
|
||||
value: 'a',
|
||||
id: 233
|
||||
},
|
||||
{
|
||||
label: 'OptionB',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: 'Submit'
|
||||
},
|
||||
{
|
||||
onSubmit: onSubmit
|
||||
},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
fireEvent.click(getByText(/OptionA/));
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText(/OptionB/));
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalledTimes(2);
|
||||
expect(onSubmit.mock.calls[1][0]).toMatchSnapshot();
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,35 +1,37 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:checkbox', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
name: 'checkbox',
|
||||
type: 'checkbox',
|
||||
label: 'Checkbox',
|
||||
option: '选项说明',
|
||||
trueValue: true,
|
||||
falseValue: false
|
||||
}
|
||||
{
|
||||
name: 'checkbox',
|
||||
type: 'checkbox',
|
||||
label: 'Checkbox',
|
||||
option: '选项说明',
|
||||
trueValue: true,
|
||||
falseValue: false
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,63 +1,64 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:checkboxes', async () => {
|
||||
const {
|
||||
getByText,
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {getByText, container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
name: 'checkboxes',
|
||||
type: 'checkboxes',
|
||||
label: 'Checkboxes',
|
||||
columnsCount: 1,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'Option C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
label: 'Option D',
|
||||
value: 'd'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'checkboxes',
|
||||
label: '当前值'
|
||||
}
|
||||
{
|
||||
name: 'checkboxes',
|
||||
type: 'checkboxes',
|
||||
label: 'Checkboxes',
|
||||
columnsCount: 1,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'Option C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
label: 'Option D',
|
||||
value: 'd'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'checkboxes',
|
||||
label: '当前值'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option A/));
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option B/));
|
||||
await wait(100);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option A/));
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option B/));
|
||||
await wait(100);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,52 +1,53 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import { makeEnv } from '../../helper';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
||||
test('Renderer:container', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/xxx',
|
||||
controls: [
|
||||
{
|
||||
type: 'container',
|
||||
name: 'a',
|
||||
label: 'container',
|
||||
mode: 'horizontal',
|
||||
className: 'no-border',
|
||||
bodyClassName: 'bg-white',
|
||||
horizontal: {
|
||||
leftFixed: 1,
|
||||
left: 4,
|
||||
right: 7
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
validation: 'isUrl',
|
||||
addOn: {
|
||||
label: '按钮',
|
||||
type: 'submit'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'text1',
|
||||
type: 'text',
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
type: 'container',
|
||||
name: 'a',
|
||||
label: 'container',
|
||||
mode: 'horizontal',
|
||||
className: 'no-border',
|
||||
bodyClassName: 'bg-white',
|
||||
horizontal: {
|
||||
leftFixed: 1,
|
||||
left: 4,
|
||||
right: 7
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
validation: 'isUrl',
|
||||
addOn: {
|
||||
label: '按钮',
|
||||
type: 'submit'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'text1',
|
||||
type: 'text',
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
actions: []
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
200
__tests__/renderers/Form/control.test.tsx
Normal file
200
__tests__/renderers/Form/control.test.tsx
Normal file
@ -0,0 +1,200 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Control:onChange', async () => {
|
||||
const onChange = jest
|
||||
.fn()
|
||||
.mockImplementation((value: any, oldValue: any, model: any, form: any) => {
|
||||
form.setValueByName('b', 2);
|
||||
});
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
wrapWithPanel: false,
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'a',
|
||||
onChange: onChange
|
||||
},
|
||||
|
||||
{
|
||||
type: 'text',
|
||||
name: 'b'
|
||||
},
|
||||
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
// expect(container).toMatchSnapshot();
|
||||
const input = container.querySelector('input[name=a]');
|
||||
expect(input).toBeTruthy();
|
||||
fireEvent.change(input!, {
|
||||
target: {
|
||||
value: '123'
|
||||
}
|
||||
});
|
||||
expect(onChange).toBeCalledTimes(1);
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
||||
a: '123',
|
||||
b: 2
|
||||
});
|
||||
});
|
||||
|
||||
test('Control:formItem:reload', async () => {
|
||||
const fetcher = jest.fn().mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
options: [
|
||||
{
|
||||
label: 'A',
|
||||
value: 'a'
|
||||
},
|
||||
|
||||
{
|
||||
label: 'B',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
body: [
|
||||
{
|
||||
type: 'form',
|
||||
name: 'xForm',
|
||||
wrapWithPanel: false,
|
||||
controls: [
|
||||
{
|
||||
type: 'select',
|
||||
name: 'a',
|
||||
source: '/api/source'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
},
|
||||
|
||||
{
|
||||
type: 'button',
|
||||
label: 'Reload',
|
||||
actionType: 'reload',
|
||||
target: 'xForm.a'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({
|
||||
fetcher
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
await wait(100);
|
||||
expect(fetcher).toHaveBeenCalled();
|
||||
|
||||
fireEvent.click(getByText('Reload'));
|
||||
await wait(300);
|
||||
|
||||
expect(fetcher).toBeCalledTimes(2);
|
||||
});
|
||||
|
||||
test('options:clearValueOnHidden ', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
wrapWithPanel: false,
|
||||
onSubmit,
|
||||
controls: [
|
||||
{
|
||||
label: '选项x',
|
||||
type: 'list',
|
||||
name: 'a',
|
||||
autoFill: {
|
||||
b: '${label}'
|
||||
},
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '选项2',
|
||||
value: 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'b',
|
||||
clearValueOnHidden: true,
|
||||
visibleOn: 'data.a !== 2'
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
fireEvent.click(getByText('选项1'));
|
||||
await wait(300);
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalledTimes(1);
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
||||
a: 1,
|
||||
b: '选项1'
|
||||
});
|
||||
|
||||
fireEvent.click(getByText('选项2'));
|
||||
await wait(300);
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalledTimes(2);
|
||||
expect(onSubmit.mock.calls[1][0]).toMatchObject({
|
||||
a: 2
|
||||
});
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
import React = require('react');
|
||||
import PageRenderer from '../../../src/renderers/Form';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup, getByText} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
@ -32,7 +32,9 @@ test('Renderer:date', async () => {
|
||||
);
|
||||
|
||||
const input = container.querySelector('.a-DatePicker-value');
|
||||
expect(input?.innerHTML).toEqual(moment(1559836800, 'X').format('YYYY-MM-DD'));
|
||||
expect(input?.innerHTML).toEqual(
|
||||
moment(1559836800, 'X').format('YYYY-MM-DD')
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React = require('react');
|
||||
import PageRenderer from '../../../src/renderers/Form';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup, getByText} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React = require('react');
|
||||
import PageRenderer from '../../../src/renderers/Form';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup, getByText} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,45 +1,46 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import { makeEnv } from '../../helper';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
||||
test('Renderer:fieldSet', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/xxx',
|
||||
controls: [
|
||||
{
|
||||
type: 'fieldSet',
|
||||
name: 'a',
|
||||
label: 'fieldSet',
|
||||
mode: 'horizontal',
|
||||
collapsable: true,
|
||||
collapsed: false,
|
||||
className: 'no-border',
|
||||
headingClassName: 'bg-dark',
|
||||
bodyClassName: 'bg-white',
|
||||
horizontal: {
|
||||
leftFixed: 1,
|
||||
left: 4,
|
||||
right: 7
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
type: 'fieldSet',
|
||||
name: 'a',
|
||||
label: 'fieldSet',
|
||||
mode: 'horizontal',
|
||||
collapsable: true,
|
||||
collapsed: false,
|
||||
className: 'no-border',
|
||||
headingClassName: 'bg-dark',
|
||||
bodyClassName: 'bg-white',
|
||||
horizontal: {
|
||||
leftFixed: 1,
|
||||
left: 4,
|
||||
right: 7
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
actions: []
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,83 +1,84 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import { makeEnv } from '../../helper';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
||||
test('Renderer:formula', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/xxx',
|
||||
controls: [
|
||||
{
|
||||
type: 'number',
|
||||
name: 'a',
|
||||
label: 'a'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'b',
|
||||
label: 'b'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'sum1',
|
||||
label: 'sum1'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'sum2',
|
||||
label: 'sum2'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'sum3',
|
||||
label: 'sum3'
|
||||
},
|
||||
{
|
||||
type: 'formula',
|
||||
name: 'sum1',
|
||||
value: 0,
|
||||
formula: "a + b"
|
||||
},
|
||||
{
|
||||
type: 'formula',
|
||||
name: 'sum2',
|
||||
condition: '${b}',
|
||||
value: 0,
|
||||
formula: "a + b + 1"
|
||||
},
|
||||
{
|
||||
type: 'formula',
|
||||
name: 'sum3',
|
||||
condition: 'data.b',
|
||||
value: 0,
|
||||
formula: "a + b + 2"
|
||||
}
|
||||
{
|
||||
type: 'number',
|
||||
name: 'a',
|
||||
label: 'a'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'b',
|
||||
label: 'b'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'sum1',
|
||||
label: 'sum1'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'sum2',
|
||||
label: 'sum2'
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'sum3',
|
||||
label: 'sum3'
|
||||
},
|
||||
{
|
||||
type: 'formula',
|
||||
name: 'sum1',
|
||||
value: 0,
|
||||
formula: 'a + b'
|
||||
},
|
||||
{
|
||||
type: 'formula',
|
||||
name: 'sum2',
|
||||
condition: '${b}',
|
||||
value: 0,
|
||||
formula: 'a + b + 1'
|
||||
},
|
||||
{
|
||||
type: 'formula',
|
||||
name: 'sum3',
|
||||
condition: 'data.b',
|
||||
value: 0,
|
||||
formula: 'a + b + 2'
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
actions: []
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
const inputs = document.querySelectorAll('input')
|
||||
fireEvent.change(inputs[0], {
|
||||
target: {
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
fireEvent.change(inputs[1], {
|
||||
target: {
|
||||
value: 2
|
||||
}
|
||||
});
|
||||
expect(inputs[2].value).toBe('3');
|
||||
expect(inputs[3].value).toBe('4');
|
||||
expect(inputs[4].value).toBe('5');
|
||||
const inputs = document.querySelectorAll('input');
|
||||
fireEvent.change(inputs[0], {
|
||||
target: {
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
fireEvent.change(inputs[1], {
|
||||
target: {
|
||||
value: 2
|
||||
}
|
||||
});
|
||||
expect(inputs[2].value).toBe('3');
|
||||
expect(inputs[3].value).toBe('4');
|
||||
expect(inputs[4].value).toBe('5');
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,50 +1,52 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:hbox', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: "grid",
|
||||
columns: [
|
||||
{
|
||||
md: 3,
|
||||
mdOffset: 1,
|
||||
columnClassName: 'bg-white',
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
md: 9,
|
||||
type: 'tpl',
|
||||
tpl: '其他渲染器类型'
|
||||
}
|
||||
{
|
||||
type: 'grid',
|
||||
columns: [
|
||||
{
|
||||
md: 3,
|
||||
mdOffset: 1,
|
||||
columnClassName: 'bg-white',
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
md: 9,
|
||||
type: 'tpl',
|
||||
tpl: '其他渲染器类型'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,88 +1,90 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:group', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'group',
|
||||
mode: 'horizontal',
|
||||
className: 'bg-white',
|
||||
horizontal: {
|
||||
label: 1,
|
||||
right: 10,
|
||||
offset: 1
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test1',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test2',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
}
|
||||
]
|
||||
{
|
||||
type: 'group',
|
||||
mode: 'horizontal',
|
||||
className: 'bg-white',
|
||||
horizontal: {
|
||||
label: 1,
|
||||
right: 10,
|
||||
offset: 1
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
mode: 'inline',
|
||||
className: 'bg-white',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test1',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test2',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
direction: 'vertical',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test1',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test2',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
}
|
||||
]
|
||||
}
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test1',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test2',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
mode: 'inline',
|
||||
className: 'bg-white',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test1',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test2',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
direction: 'vertical',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test1',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'test2',
|
||||
label: 'Label',
|
||||
placeholder: 'Placeholder'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,47 +1,49 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:hbox', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'hbox',
|
||||
columns: [
|
||||
{
|
||||
columnClassName: 'w-sm',
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '其他类型的渲染器'
|
||||
}
|
||||
{
|
||||
type: 'hbox',
|
||||
columns: [
|
||||
{
|
||||
columnClassName: 'w-sm',
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '其他类型的渲染器'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {fireEvent, render} from 'react-testing-library';
|
||||
import {fireEvent, render} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender, setIconVendor} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React = require('react');
|
||||
import PageRenderer from '../../../src/renderers/Form';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup, getByText} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {wait, makeEnv} from '../../helper';
|
||||
|
300
__tests__/renderers/Form/initData.test.tsx
Normal file
300
__tests__/renderers/Form/initData.test.tsx
Normal file
@ -0,0 +1,300 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Form:initData', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
wrapWithPanel: false,
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'a',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'b',
|
||||
value: '2'
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
onSubmit
|
||||
},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Form:initData:super', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
data: {
|
||||
a: 1,
|
||||
b: 2
|
||||
},
|
||||
body: {
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
wrapWithPanel: false,
|
||||
onSubmit,
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'a'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'b'
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Form:initData:without-super', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
data: {
|
||||
a: 1,
|
||||
b: 2
|
||||
},
|
||||
body: {
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
wrapWithPanel: false,
|
||||
onSubmit,
|
||||
canAccessSuperData: false,
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'a'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'b'
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
|
||||
// 这个应该是不能设置上初始值的
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText(/Submit/));
|
||||
await wait(300);
|
||||
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Form:initData:remote', async () => {
|
||||
const resultPromise = Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
a: 1,
|
||||
b: 2
|
||||
}
|
||||
}
|
||||
});
|
||||
const onSubmit = jest.fn();
|
||||
const fetcher = jest.fn().mockImplementation(() => resultPromise);
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
initApi: '/api/xxx?a=${a}',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'a',
|
||||
label: 'Label',
|
||||
value: '123'
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
actions: [
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({
|
||||
fetcher
|
||||
})
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
await wait(100);
|
||||
|
||||
await resultPromise;
|
||||
await wait(100);
|
||||
|
||||
expect(fetcher).toHaveBeenCalled();
|
||||
expect(fetcher.mock.calls[0][0]).toMatchSnapshot();
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// 主要用来测试 form 的 source 接口是否在 initApi 后调用
|
||||
// 并且发送的参数是否可以携带 initApi 返回的数据
|
||||
// 并且 source 接口如果返回了 value 是否可以应用上。
|
||||
test('Form:initData:remote:options:source', async () => {
|
||||
const initApiPromise = Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
id: 1
|
||||
}
|
||||
}
|
||||
});
|
||||
const fetcherinitApi = jest.fn().mockImplementation(() => initApiPromise);
|
||||
const sourceApiPromise = Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
value: 'b',
|
||||
options: [
|
||||
{
|
||||
label: 'OptionA',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'OptionB',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
const fetcherSourceApi = jest.fn().mockImplementation(() => sourceApiPromise);
|
||||
const onSubmit = jest.fn();
|
||||
const fetcher = (arg1: any, ...rest: Array<any>) => {
|
||||
const api = /\/api\/(\w+)/.test(arg1.url) ? RegExp.$1 : '';
|
||||
const map: any = {
|
||||
initApi: fetcherinitApi,
|
||||
source: fetcherSourceApi
|
||||
};
|
||||
|
||||
return map[api](arg1, ...rest);
|
||||
};
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
initApi: '/api/initApi?op=${op}',
|
||||
controls: [
|
||||
{
|
||||
type: 'hidden',
|
||||
name: 'op',
|
||||
value: 'init'
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
name: 'a',
|
||||
label: 'Select',
|
||||
source: '/api/source?id=${id}'
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
actions: [
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({
|
||||
fetcher
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
await initApiPromise;
|
||||
expect(fetcherinitApi).toHaveBeenCalled();
|
||||
expect(fetcherinitApi.mock.calls[0][0].url).toEqual('/api/initApi?op=init');
|
||||
|
||||
await wait(100);
|
||||
|
||||
await sourceApiPromise;
|
||||
expect(fetcherSourceApi).toHaveBeenCalled();
|
||||
expect(fetcherSourceApi.mock.calls[0][0].url).toEqual('/api/source?id=1');
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
||||
id: 1,
|
||||
op: 'init',
|
||||
a: 'b'
|
||||
});
|
||||
});
|
@ -1,51 +1,52 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import { makeEnv } from '../../helper';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
||||
test('Renderer:fieldSet', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/xxx',
|
||||
controls: [
|
||||
{
|
||||
type: 'input-group',
|
||||
name: 'a',
|
||||
label: 'input-group',
|
||||
mode: 'horizontal',
|
||||
className: 'no-border',
|
||||
horizontal: {
|
||||
leftFixed: 1,
|
||||
left: 4,
|
||||
right: 7
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
validation: 'isUrl',
|
||||
addOn: {
|
||||
label: '按钮',
|
||||
type: 'submit'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'text1',
|
||||
type: 'text',
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
type: 'input-group',
|
||||
name: 'a',
|
||||
label: 'input-group',
|
||||
mode: 'horizontal',
|
||||
className: 'no-border',
|
||||
horizontal: {
|
||||
leftFixed: 1,
|
||||
left: 4,
|
||||
right: 7
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
validation: 'isUrl',
|
||||
addOn: {
|
||||
label: '按钮',
|
||||
type: 'submit'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'text1',
|
||||
type: 'text',
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
actions: []
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,93 +1,99 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:list', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'list',
|
||||
name: 'select',
|
||||
label: '单选',
|
||||
clearable: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'OptionC',
|
||||
value: 'c',
|
||||
image: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
type: 'list',
|
||||
name: 'select',
|
||||
label: '单选',
|
||||
clearable: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'OptionC',
|
||||
value: 'c',
|
||||
image:
|
||||
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Renderer:list:multiple clearable', async () => {
|
||||
const {
|
||||
getByText,
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {getByText, container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'list',
|
||||
name: 'select',
|
||||
label: '多选',
|
||||
multiple: true,
|
||||
clearable: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'select',
|
||||
label: '当前值'
|
||||
}
|
||||
{
|
||||
type: 'list',
|
||||
name: 'select',
|
||||
label: '多选',
|
||||
multiple: true,
|
||||
clearable: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'select',
|
||||
label: '当前值'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option A/));
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option B/));
|
||||
expect(container).toMatchSnapshot();
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option B/));
|
||||
await wait(100);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option A/));
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option B/));
|
||||
expect(container).toMatchSnapshot();
|
||||
await wait(100);
|
||||
fireEvent.click(getByText(/Option B/));
|
||||
await wait(100);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
89
__tests__/renderers/Form/options.test.tsx
Normal file
89
__tests__/renderers/Form/options.test.tsx
Normal file
@ -0,0 +1,89 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('options:linkage', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
wrapWithPanel: false,
|
||||
controls: [
|
||||
{
|
||||
label: '选项x',
|
||||
type: 'list',
|
||||
multiple: false,
|
||||
labelClassName: 'text-muted',
|
||||
name: 'a',
|
||||
inline: true,
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '选项2',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
label: '选项3',
|
||||
value: 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '选项y',
|
||||
type: 'radios',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'b',
|
||||
inline: true,
|
||||
options: [
|
||||
{
|
||||
label: '选项a',
|
||||
value: 1,
|
||||
disabledOn: 'data.a == 1'
|
||||
},
|
||||
{
|
||||
label: '选项b',
|
||||
value: 2,
|
||||
hiddenOn: 'data.a == 2'
|
||||
},
|
||||
{
|
||||
label: '选项c',
|
||||
value: 3,
|
||||
visibleOn: 'data.a == 3'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(getByText('选项1'));
|
||||
await wait(300);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText('选项2'));
|
||||
await wait(300);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText('选项3'));
|
||||
await wait(300);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
@ -1,73 +1,75 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:panel', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'hbox',
|
||||
columns: [
|
||||
{
|
||||
controls: [
|
||||
{
|
||||
type: 'panel',
|
||||
title: 'bla bla',
|
||||
bodyClassName: 'bg-white',
|
||||
body: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text'
|
||||
}
|
||||
],
|
||||
footer: '<p>footer 内容</p>',
|
||||
footerClassName: 'bg-black'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
controls: [
|
||||
{
|
||||
type: 'panel',
|
||||
title: 'bla bla',
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text 1'
|
||||
},
|
||||
{
|
||||
name: 'text2',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text 2'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
type: 'hbox',
|
||||
columns: [
|
||||
{
|
||||
controls: [
|
||||
{
|
||||
type: 'panel',
|
||||
title: 'bla bla',
|
||||
bodyClassName: 'bg-white',
|
||||
body: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text'
|
||||
}
|
||||
],
|
||||
footer: '<p>footer 内容</p>',
|
||||
footerClassName: 'bg-black'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
controls: [
|
||||
{
|
||||
type: 'panel',
|
||||
title: 'bla bla',
|
||||
controls: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text 1'
|
||||
},
|
||||
{
|
||||
name: 'text2',
|
||||
type: 'text',
|
||||
label: false,
|
||||
placeholder: 'Text 2'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,59 +1,60 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup, fireEvent} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:radios', async () => {
|
||||
const {
|
||||
getByText,
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {getByText, container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
name: 'radios',
|
||||
type: 'radios',
|
||||
label: 'radios',
|
||||
columnsCount: 1,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'Option C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
label: 'Option D',
|
||||
value: 'd'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'radios',
|
||||
label: '当前值'
|
||||
}
|
||||
{
|
||||
name: 'radios',
|
||||
type: 'radios',
|
||||
label: 'radios',
|
||||
columnsCount: 1,
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'Option C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
label: 'Option D',
|
||||
value: 'd'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'radios',
|
||||
label: '当前值'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(getByText(/Option A/));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(getByText(/Option A/));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,32 +1,33 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import { makeEnv } from '../../helper';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
||||
test('Renderer:rating', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/xxx',
|
||||
controls: [
|
||||
{
|
||||
type: 'rating',
|
||||
name: 'a',
|
||||
label: 'rating',
|
||||
value: 3,
|
||||
count: 5,
|
||||
half: true,
|
||||
readOnly: false
|
||||
}
|
||||
{
|
||||
type: 'rating',
|
||||
name: 'a',
|
||||
label: 'rating',
|
||||
value: 3,
|
||||
count: 5,
|
||||
half: true,
|
||||
readOnly: false
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
actions: []
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,48 +1,49 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import { makeEnv } from '../../helper';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
||||
test('Renderer:repeat', async () => {
|
||||
const {
|
||||
container,
|
||||
getByText
|
||||
} = render(amisRender({
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/xxx',
|
||||
controls: [
|
||||
{
|
||||
type: 'repeat',
|
||||
name: 'a',
|
||||
label: 'repeat',
|
||||
options: 'secondly,minutely,hourly,daily,weekdays,weekly,monthly,yearly'
|
||||
}
|
||||
{
|
||||
type: 'repeat',
|
||||
name: 'a',
|
||||
label: 'repeat',
|
||||
options:
|
||||
'secondly,minutely,hourly,daily,weekdays,weekly,monthly,yearly'
|
||||
}
|
||||
],
|
||||
title: 'The form',
|
||||
actions: []
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
fireEvent.click(getByText('不重复'));
|
||||
fireEvent.click(getByText('秒'));
|
||||
fireEvent.click(getByText('秒'));
|
||||
fireEvent.click(getByText('时'));
|
||||
fireEvent.click(getByText('时'));
|
||||
fireEvent.click(getByText('分'));
|
||||
fireEvent.click(getByText('分'));
|
||||
fireEvent.click(getByText('天'));
|
||||
fireEvent.click(getByText('天'));
|
||||
fireEvent.click(getByText('周中'));
|
||||
fireEvent.click(getByText('周中'));
|
||||
fireEvent.click(getByText('周'));
|
||||
fireEvent.click(getByText('周'));
|
||||
fireEvent.click(getByText('月'));
|
||||
fireEvent.click(getByText('月'));
|
||||
fireEvent.click(getByText('年'));
|
||||
fireEvent.click(getByText('年'));
|
||||
fireEvent.click(getByText('不重复'));
|
||||
fireEvent.click(getByText('秒'));
|
||||
fireEvent.click(getByText('秒'));
|
||||
fireEvent.click(getByText('时'));
|
||||
fireEvent.click(getByText('时'));
|
||||
fireEvent.click(getByText('分'));
|
||||
fireEvent.click(getByText('分'));
|
||||
fireEvent.click(getByText('天'));
|
||||
fireEvent.click(getByText('天'));
|
||||
fireEvent.click(getByText('周中'));
|
||||
fireEvent.click(getByText('周中'));
|
||||
fireEvent.click(getByText('周'));
|
||||
fireEvent.click(getByText('周'));
|
||||
fireEvent.click(getByText('月'));
|
||||
fireEvent.click(getByText('月'));
|
||||
fireEvent.click(getByText('年'));
|
||||
fireEvent.click(getByText('年'));
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
@ -76,3 +76,220 @@ test('Renderer:service', async () => {
|
||||
expect(fetcher).toHaveBeenCalled();
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('form:service:remoteData', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const fetcher = jest.fn().mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
'child-a': '123'
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
wrapWithPanel: false,
|
||||
controls: [
|
||||
{
|
||||
type: 'service',
|
||||
api: '/api/initData',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'child-a'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({fetcher})
|
||||
)
|
||||
);
|
||||
|
||||
await wait(300);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
||||
'child-a': '123'
|
||||
});
|
||||
});
|
||||
|
||||
test('form:service:remoteSchmea+data', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const fetcher = jest.fn().mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
data: {
|
||||
'child-a': '123'
|
||||
},
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'child-a'
|
||||
},
|
||||
|
||||
{
|
||||
type: 'text',
|
||||
name: 'child-b',
|
||||
value: '344'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
wrapWithPanel: false,
|
||||
controls: [
|
||||
{
|
||||
type: 'service',
|
||||
schemaApi: '/api/schemaApi'
|
||||
},
|
||||
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({fetcher})
|
||||
)
|
||||
);
|
||||
|
||||
await wait(300);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
||||
'child-a': '123',
|
||||
'child-b': '344'
|
||||
});
|
||||
});
|
||||
|
||||
test('form:service:onChange', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
wrapWithPanel: false,
|
||||
controls: [
|
||||
{
|
||||
type: 'service',
|
||||
api: '/api/initData',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'child-a'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
const input = container.querySelector('input[name=child-a]');
|
||||
expect(input).toBeTruthy();
|
||||
fireEvent.change(input!, {
|
||||
target: {
|
||||
value: '123'
|
||||
}
|
||||
});
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(300);
|
||||
expect(onSubmit).toBeCalled();
|
||||
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
||||
'child-a': '123'
|
||||
});
|
||||
});
|
||||
|
||||
// Form => service, form 的 initApi 返回新数据,service 下面的 form 是否更新
|
||||
test('form:service:super-remoteData', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
const fetcher = jest.fn().mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
'child-a': '123'
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
onSubmit,
|
||||
wrapWithPanel: false,
|
||||
initApi: '/api/initData',
|
||||
controls: [
|
||||
{
|
||||
type: 'service',
|
||||
controls: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'child-a'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'submit',
|
||||
label: 'Submit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({fetcher})
|
||||
)
|
||||
);
|
||||
|
||||
await wait(300);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,65 +1,67 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:static', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static',
|
||||
label: 'label',
|
||||
value: 'static',
|
||||
description: 'static description',
|
||||
placeholder: '-',
|
||||
inline: true,
|
||||
className: 'bg-white'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 1',
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 2',
|
||||
visibleOn: 'this.static'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 3',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 4',
|
||||
hiddenOn: 'this.static'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 5',
|
||||
hiddenOn: 'this.static',
|
||||
inputClassName: 'padder-xs',
|
||||
labelClassName: 'font-bold',
|
||||
tpl: '<%= static tpl %>'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static',
|
||||
label: 'label',
|
||||
value: 'static',
|
||||
description: 'static description',
|
||||
placeholder: '-',
|
||||
inline: true,
|
||||
className: 'bg-white'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 1',
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 2',
|
||||
visibleOn: 'this.static'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 3',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 4',
|
||||
hiddenOn: 'this.static'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'static 5',
|
||||
hiddenOn: 'this.static',
|
||||
inputClassName: 'padder-xs',
|
||||
labelClassName: 'font-bold',
|
||||
tpl: '<%= static tpl %>'
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,46 +1,48 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:switch', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
name: 'switch',
|
||||
className: 'block',
|
||||
label: '开关',
|
||||
type: 'switch',
|
||||
addable: true,
|
||||
removeable: true,
|
||||
minLength: 1,
|
||||
maxLength: 4,
|
||||
addButtonText: '新增',
|
||||
draggable: true,
|
||||
draggableTip: '可通过拖动每行中的【交换】按钮进行顺序调整',
|
||||
value: true,
|
||||
trueValue: true,
|
||||
falseValue: false,
|
||||
disabled: false,
|
||||
option: 'switch',
|
||||
optionAtLeft: false
|
||||
}
|
||||
{
|
||||
name: 'switch',
|
||||
className: 'block',
|
||||
label: '开关',
|
||||
type: 'switch',
|
||||
addable: true,
|
||||
removeable: true,
|
||||
minLength: 1,
|
||||
maxLength: 4,
|
||||
addButtonText: '新增',
|
||||
draggable: true,
|
||||
draggableTip: '可通过拖动每行中的【交换】按钮进行顺序调整',
|
||||
value: true,
|
||||
trueValue: true,
|
||||
falseValue: false,
|
||||
disabled: false,
|
||||
option: 'switch',
|
||||
optionAtLeft: false
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,52 +1,54 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../../src/index';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
import { clearStoresCache } from '../../../src/factory';
|
||||
import {clearStoresCache} from '../../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:tabs', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'form',
|
||||
title: 'The form',
|
||||
controls: [
|
||||
{
|
||||
type: "tabs",
|
||||
tabClassName: 'bg-info',
|
||||
tabs: [
|
||||
{
|
||||
title: '基本配置',
|
||||
body: '<p>tab1 内容</p>',
|
||||
},
|
||||
{
|
||||
title: '其他配置',
|
||||
controls: [
|
||||
{
|
||||
name: 'c',
|
||||
type: 'text',
|
||||
label: '文本3'
|
||||
},
|
||||
{
|
||||
name: 'd',
|
||||
type: 'text',
|
||||
label: '文本4'
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
type: 'tabs',
|
||||
tabClassName: 'bg-info',
|
||||
tabs: [
|
||||
{
|
||||
title: '基本配置',
|
||||
body: '<p>tab1 内容</p>'
|
||||
},
|
||||
{
|
||||
title: '其他配置',
|
||||
controls: [
|
||||
{
|
||||
name: 'c',
|
||||
type: 'text',
|
||||
label: '文本3'
|
||||
},
|
||||
{
|
||||
name: 'd',
|
||||
type: 'text',
|
||||
label: '文本4'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
submitText: null,
|
||||
actions: []
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv} from '../../helper';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React = require('react');
|
||||
import PageRenderer from '../../../src/renderers/Form';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup, getByText} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
|
||||
import '../../../src/themes/default';
|
||||
import {render as amisRender} from '../../../src/index';
|
||||
import {makeEnv, wait} from '../../helper';
|
||||
|
@ -1,53 +1,54 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:hbox', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'hbox',
|
||||
columns: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: 'w-xs',
|
||||
className: 'bg-info',
|
||||
inline: false,
|
||||
columnClassName: 'w-xs'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: 'w-sm',
|
||||
className: 'bg-info lter',
|
||||
inline: false,
|
||||
columnClassName: 'w-sm'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: 'w',
|
||||
className: 'bg-info dk',
|
||||
inline: false,
|
||||
columnClassName: 'w'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '平均分配',
|
||||
className: 'bg-success',
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '平均分配',
|
||||
className: 'bg-primary',
|
||||
inline: false
|
||||
}
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: 'w-xs',
|
||||
className: 'bg-info',
|
||||
inline: false,
|
||||
columnClassName: 'w-xs'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: 'w-sm',
|
||||
className: 'bg-info lter',
|
||||
inline: false,
|
||||
columnClassName: 'w-sm'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: 'w',
|
||||
className: 'bg-info dk',
|
||||
inline: false,
|
||||
columnClassName: 'w'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '平均分配',
|
||||
className: 'bg-success',
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '平均分配',
|
||||
className: 'bg-primary',
|
||||
inline: false
|
||||
}
|
||||
]
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,22 +1,23 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:iframe', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'iframe',
|
||||
className: 'b-a',
|
||||
src: "https://www.baidu.com",
|
||||
src: 'https://www.baidu.com',
|
||||
height: 500,
|
||||
width: 500
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,23 +1,24 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:image', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'image',
|
||||
defaultImage: 'https://www.baidu.com/img/bd_logo1.png',
|
||||
title: '图片',
|
||||
description: '图片描述',
|
||||
imageClassName: 'b',
|
||||
className: 'show'
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,22 +1,23 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:link', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'link',
|
||||
href: 'https://www.baidu.com',
|
||||
placeholder: 'link address',
|
||||
className: 'show',
|
||||
blank: true
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,25 +1,26 @@
|
||||
import React = require('react');
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:mapping', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'mapping',
|
||||
mapping: {
|
||||
1: "<span class='label label-info'>漂亮</span>",
|
||||
2: "<span class='label label-success'>开心</span>",
|
||||
3: "<span class='label label-danger'>惊吓</span>",
|
||||
4: "<span class='label label-warning'>紧张</span>",
|
||||
"*": "其他:${type}"
|
||||
1: "<span class='label label-info'>漂亮</span>",
|
||||
2: "<span class='label label-success'>开心</span>",
|
||||
3: "<span class='label label-danger'>惊吓</span>",
|
||||
4: "<span class='label label-warning'>紧张</span>",
|
||||
'*': '其他:${type}'
|
||||
}
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React = require('react');
|
||||
import PageRenderer from '../../src/renderers/Page';
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {wait, makeEnv} from '../helper';
|
||||
|
@ -1,23 +1,24 @@
|
||||
import React = require('react');
|
||||
import {render, fireEvent} from 'react-testing-library';
|
||||
import {render, fireEvent} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import { makeEnv } from '../helper';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
import 'jest-canvas-mock';
|
||||
|
||||
test('Renderer:qr-code', () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
body: {
|
||||
type: 'qr-code',
|
||||
value: 'amis'
|
||||
type: 'qr-code',
|
||||
value: 'amis'
|
||||
}
|
||||
}, {}, makeEnv({
|
||||
})));
|
||||
},
|
||||
{},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,44 +1,46 @@
|
||||
import React = require('react');
|
||||
import {render, cleanup} from 'react-testing-library';
|
||||
import {render, cleanup} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {makeEnv} from '../helper';
|
||||
import { clearStoresCache } from '../../src/factory';
|
||||
import {clearStoresCache} from '../../src/factory';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
cleanup();
|
||||
clearStoresCache();
|
||||
});
|
||||
|
||||
test('Renderer:tabs', async () => {
|
||||
const {
|
||||
container
|
||||
} = render(amisRender({
|
||||
type: "tabs",
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'tabs',
|
||||
tabClassName: 'bg-info',
|
||||
tabs: [
|
||||
{
|
||||
title: '基本配置',
|
||||
body: '<p>tab1 内容</p>',
|
||||
},
|
||||
{
|
||||
title: '其他配置',
|
||||
controls: [
|
||||
{
|
||||
name: 'c',
|
||||
type: 'text',
|
||||
label: '文本3'
|
||||
},
|
||||
{
|
||||
name: 'd',
|
||||
type: 'text',
|
||||
label: '文本4'
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
title: '基本配置',
|
||||
body: '<p>tab1 内容</p>'
|
||||
},
|
||||
{
|
||||
title: '其他配置',
|
||||
controls: [
|
||||
{
|
||||
name: 'c',
|
||||
type: 'text',
|
||||
label: '文本3'
|
||||
},
|
||||
{
|
||||
name: 'd',
|
||||
type: 'text',
|
||||
label: '文本4'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {}, makeEnv()));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
},
|
||||
{},
|
||||
makeEnv()
|
||||
)
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,20 +1,22 @@
|
||||
import {render} from 'react-testing-library';
|
||||
import {render} from '@testing-library/react';
|
||||
import {render as amisRender} from '../../src';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('Renderer:alert', () => {
|
||||
const {container} = render(amisRender(
|
||||
{
|
||||
type: 'video',
|
||||
src: '${url}'
|
||||
},
|
||||
{
|
||||
data: {
|
||||
url: 'https://example.com/video.mp4'
|
||||
}
|
||||
},
|
||||
makeEnv({})
|
||||
));
|
||||
const {container} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'video',
|
||||
src: '${url}'
|
||||
},
|
||||
{
|
||||
data: {
|
||||
url: 'https://example.com/video.mp4'
|
||||
}
|
||||
},
|
||||
makeEnv({})
|
||||
)
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React = require('react');
|
||||
import * as renderer from 'react-test-renderer';
|
||||
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||||
import {render, fireEvent, cleanup} from '@testing-library/react';
|
||||
import '../../src/themes/default';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {wait, makeEnv} from '../helper';
|
||||
|
@ -611,7 +611,7 @@ exports[`Renderer:Wizard dialog 1`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default a-Form-control"
|
||||
class="a-Button a-Button--default"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
@ -925,7 +925,7 @@ exports[`Renderer:Wizard dialog 2`] = `
|
||||
data-role="form-item"
|
||||
>
|
||||
<button
|
||||
class="a-Button a-Button--default a-Form-control"
|
||||
class="a-Button a-Button--default"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
|
@ -1,194 +1,242 @@
|
||||
import {
|
||||
render as amisRender
|
||||
} from '../../src/index';
|
||||
import {render as amisRender} from '../../src/index';
|
||||
import {wait, makeEnv} from '../helper';
|
||||
import {render, fireEvent, cleanup} from 'react-testing-library';
|
||||
import {
|
||||
buildApi,
|
||||
isApiOutdated
|
||||
} from '../../src/utils/api';
|
||||
import {render, fireEvent, cleanup} from '@testing-library/react';
|
||||
import {buildApi, isApiOutdated} from '../../src/utils/api';
|
||||
|
||||
test('api:buildApi', () => {
|
||||
expect(buildApi('/api/xxx')).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx'
|
||||
});
|
||||
expect(buildApi('/api/xxx')).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx'
|
||||
});
|
||||
|
||||
expect(buildApi('get:/api/xxx')).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx'
|
||||
});
|
||||
expect(buildApi('get:/api/xxx')).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx'
|
||||
});
|
||||
|
||||
expect(buildApi('delete:/api/xxx')).toMatchObject({
|
||||
method: 'delete',
|
||||
url: '/api/xxx'
|
||||
});
|
||||
expect(buildApi('delete:/api/xxx')).toMatchObject({
|
||||
method: 'delete',
|
||||
url: '/api/xxx'
|
||||
});
|
||||
|
||||
|
||||
expect(buildApi('/api/xxx?a=${a}&b=${b}', {
|
||||
a: 1,
|
||||
b: 2
|
||||
})).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=1&b=2'
|
||||
});
|
||||
expect(
|
||||
buildApi('/api/xxx?a=${a}&b=${b}', {
|
||||
a: 1,
|
||||
b: 2
|
||||
})
|
||||
).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=1&b=2'
|
||||
});
|
||||
|
||||
expect(buildApi({
|
||||
expect(
|
||||
buildApi(
|
||||
{
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=${a}&b=${b}'
|
||||
}, {
|
||||
},
|
||||
{
|
||||
a: 1,
|
||||
b: 2
|
||||
})).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=1&b=2'
|
||||
});
|
||||
}
|
||||
)
|
||||
).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=1&b=2'
|
||||
});
|
||||
|
||||
expect(buildApi('/api/xxx?a=${a}', {
|
||||
a: '&'
|
||||
})).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=' + encodeURIComponent('&')
|
||||
});
|
||||
expect(
|
||||
buildApi('/api/xxx?a=${a}', {
|
||||
a: '&'
|
||||
})
|
||||
).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=' + encodeURIComponent('&')
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('api:buildApi:dataMapping', () => {
|
||||
expect(buildApi({
|
||||
expect(
|
||||
buildApi(
|
||||
{
|
||||
method: 'post',
|
||||
url: '/api/xxx',
|
||||
data: {
|
||||
a: 1,
|
||||
b: '${b}'
|
||||
a: 1,
|
||||
b: '${b}'
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
b: 2
|
||||
})).toMatchObject({
|
||||
method: 'post',
|
||||
url: '/api/xxx',
|
||||
data: {
|
||||
a: 1,
|
||||
b: 2
|
||||
}
|
||||
});
|
||||
}
|
||||
)
|
||||
).toMatchObject({
|
||||
method: 'post',
|
||||
url: '/api/xxx',
|
||||
data: {
|
||||
a: 1,
|
||||
b: 2
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
expect(buildApi({
|
||||
expect(
|
||||
buildApi(
|
||||
{
|
||||
method: 'post',
|
||||
url: '/api/xxx',
|
||||
headers: {
|
||||
a: 1,
|
||||
b: '${b}'
|
||||
a: 1,
|
||||
b: '${b}'
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
b: 2
|
||||
})).toMatchObject({
|
||||
method: 'post',
|
||||
url: '/api/xxx',
|
||||
headers: {
|
||||
a: 1,
|
||||
b: 2
|
||||
}
|
||||
});
|
||||
}
|
||||
)
|
||||
).toMatchObject({
|
||||
method: 'post',
|
||||
url: '/api/xxx',
|
||||
headers: {
|
||||
a: 1,
|
||||
b: 2
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('api:buildApi:autoAppend', () => {
|
||||
expect(buildApi({
|
||||
expect(
|
||||
buildApi(
|
||||
{
|
||||
method: 'get',
|
||||
url: '/api/xxx',
|
||||
}, {
|
||||
url: '/api/xxx'
|
||||
},
|
||||
{
|
||||
a: 1,
|
||||
b: 2
|
||||
}, {
|
||||
},
|
||||
{
|
||||
autoAppend: true
|
||||
})).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=1&b=2'
|
||||
});
|
||||
}
|
||||
)
|
||||
).toMatchObject({
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=1&b=2'
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('api:isApiOutdated', () => {
|
||||
expect(isApiOutdated('/api/xxx?a=${a}', '/api/xxx?a=${a}', {
|
||||
expect(
|
||||
isApiOutdated(
|
||||
'/api/xxx?a=${a}',
|
||||
'/api/xxx?a=${a}',
|
||||
{
|
||||
a: 1,
|
||||
b: 0
|
||||
}, {
|
||||
},
|
||||
{
|
||||
a: 1,
|
||||
b: 2,
|
||||
})).toBeFalsy();
|
||||
b: 2
|
||||
}
|
||||
)
|
||||
).toBeFalsy();
|
||||
|
||||
expect(isApiOutdated('/api/xxx?a=${a}', '/api/xxx?a=${a}', {
|
||||
expect(
|
||||
isApiOutdated(
|
||||
'/api/xxx?a=${a}',
|
||||
'/api/xxx?a=${a}',
|
||||
{
|
||||
a: 1,
|
||||
b: 0
|
||||
}, {
|
||||
},
|
||||
{
|
||||
a: 2,
|
||||
b: 2,
|
||||
})).toBeTruthy();
|
||||
b: 2
|
||||
}
|
||||
)
|
||||
).toBeTruthy();
|
||||
|
||||
|
||||
expect(isApiOutdated('/api/xxx', '/api/xxx', {
|
||||
expect(
|
||||
isApiOutdated(
|
||||
'/api/xxx',
|
||||
'/api/xxx',
|
||||
{
|
||||
a: 1,
|
||||
b: 0
|
||||
}, {
|
||||
},
|
||||
{
|
||||
a: 2,
|
||||
b: 2,
|
||||
})).toBeFalsy();
|
||||
b: 2
|
||||
}
|
||||
)
|
||||
).toBeFalsy();
|
||||
|
||||
expect(isApiOutdated({
|
||||
expect(
|
||||
isApiOutdated(
|
||||
{
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=${a}'
|
||||
}, {
|
||||
},
|
||||
{
|
||||
method: 'get',
|
||||
url: '/api/xxx?a=${a}',
|
||||
sendOn: 'this.b === 0'
|
||||
}, {
|
||||
},
|
||||
{
|
||||
a: 1,
|
||||
b: 0
|
||||
}, {
|
||||
},
|
||||
{
|
||||
a: 2,
|
||||
b: 2,
|
||||
})).toBeFalsy();
|
||||
b: 2
|
||||
}
|
||||
)
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
test('api:cache', async () => {
|
||||
let count = 1;
|
||||
const fetcher = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
let count = 1;
|
||||
const fetcher = jest.fn().mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
status: 0,
|
||||
msg: 'ok',
|
||||
data: {
|
||||
a: count++
|
||||
}
|
||||
a: count++
|
||||
}
|
||||
}));
|
||||
const {
|
||||
container,
|
||||
getByText
|
||||
} = render(amisRender({
|
||||
}
|
||||
})
|
||||
);
|
||||
const {container, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
name: 'thepage',
|
||||
initApi: {
|
||||
method: 'get',
|
||||
url: '/api/xxx?id=${id}',
|
||||
cache: 2000
|
||||
method: 'get',
|
||||
url: '/api/xxx?id=${id}',
|
||||
cache: 2000
|
||||
},
|
||||
toolbar: {
|
||||
type: 'button',
|
||||
label: 'Reload',
|
||||
actionType: 'reload',
|
||||
target: 'thepage'
|
||||
type: 'button',
|
||||
label: 'Reload',
|
||||
actionType: 'reload',
|
||||
target: 'thepage'
|
||||
},
|
||||
body: 'The variable value is ${a}'
|
||||
}, {}, makeEnv({
|
||||
},
|
||||
{},
|
||||
makeEnv({
|
||||
fetcher
|
||||
})));
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
await wait(100);
|
||||
expect(container).toMatchSnapshot();
|
||||
await wait(100);
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(getByText(/Reload/));
|
||||
fireEvent.click(getByText(/Reload/));
|
||||
|
||||
await wait(100);
|
||||
expect(fetcher).toHaveBeenCalledTimes(1); // 只请求一次,第二次请求从缓存中取
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
await wait(100);
|
||||
expect(fetcher).toHaveBeenCalledTimes(1); // 只请求一次,第二次请求从缓存中取
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1,67 +1,25 @@
|
||||
---
|
||||
title: Button-Group 按钮集合
|
||||
title: Button-Group-Select 按钮点选
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Button-Group
|
||||
menuName: Button-Group-Select
|
||||
icon:
|
||||
order: 6
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
用于将多个按钮在展现上合并到一起。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
{
|
||||
"type": "text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"type": "button-group",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "Button",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "对,你刚点击了!"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "提交"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "reset",
|
||||
"label": "重置"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 作为选择器表单项
|
||||
|
||||
当不配置 `buttons` 属性时,`button-group`还可以作为 [选择类表单项](./options) 使用。
|
||||
按钮集合当 select 点选用。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group",
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"options": [
|
||||
@ -79,8 +37,6 @@ order: 6
|
||||
}
|
||||
```
|
||||
|
||||
更多属性查看 [选择类表单项文档](./options) 。
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
@ -14,23 +14,23 @@ order: 12
|
||||
|
||||
## 基本使用
|
||||
|
||||
配置`controls`属性,组合多个表单项
|
||||
配置`items`属性,组合多个表单项
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "user",
|
||||
"label": "用户",
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "名字",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "gender",
|
||||
@ -53,16 +53,16 @@ order: 12
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo1",
|
||||
"label": "Combo 单行展示",
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -80,11 +80,11 @@ order: 12
|
||||
"name": "combo2",
|
||||
"label": "Combo 多行展示",
|
||||
"multiLine": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -110,16 +110,16 @@ order: 12
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo1",
|
||||
"label": "Combo 单选展示",
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -137,11 +137,11 @@ order: 12
|
||||
"name": "combo2",
|
||||
"label": "Combo 多选展示",
|
||||
"multiple": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -164,18 +164,18 @@ order: 12
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo1",
|
||||
"label": "最少添加1条",
|
||||
"multiple": true,
|
||||
"minLength": 1,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -191,11 +191,11 @@ order: 12
|
||||
"label": "最多添加3条",
|
||||
"multiple": true,
|
||||
"maxLength": 3,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -222,16 +222,16 @@ order: 12
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo1",
|
||||
"label": "Combo 单选展示",
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -249,11 +249,11 @@ order: 12
|
||||
"name": "combo2",
|
||||
"label": "Combo 多选展示",
|
||||
"multiple": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -277,16 +277,16 @@ order: 12
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo1",
|
||||
"label": "默认模式",
|
||||
"multiple": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -299,10 +299,10 @@ order: 12
|
||||
"label": "打平模式",
|
||||
"multiple": true,
|
||||
"flat": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -339,9 +339,9 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"label": "",
|
||||
"noBorder": true,
|
||||
"multiLine": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "b"
|
||||
}
|
||||
]
|
||||
@ -360,16 +360,16 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo666",
|
||||
"label": "唯一",
|
||||
"multiple": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"placeholder": "文本",
|
||||
"unique": true
|
||||
},
|
||||
@ -403,7 +403,7 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo",
|
||||
@ -420,10 +420,10 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
}
|
||||
],
|
||||
"draggable": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "select",
|
||||
@ -446,7 +446,7 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
|
||||
如下面的例子,定义了两种类型:文本和数字,用户新增的时候可以选择是新增文本还是数字。区分是文字和数字的方式是根据成员数据中的 type 字段来决定。
|
||||
|
||||
```schema: scope="form-item"
|
||||
```schema: scope="form-item2"
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo-conditions2",
|
||||
@ -468,16 +468,16 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"label": "文本",
|
||||
"name": ""
|
||||
},
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"label": "名称",
|
||||
"name": "label",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"label": "字段名",
|
||||
"name": "name",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -489,31 +489,31 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"label": "数字",
|
||||
"name": ""
|
||||
},
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"label": "名称",
|
||||
"name": "label",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"label": "字段名",
|
||||
"name": "name",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"label": "最小值",
|
||||
"name": "min",
|
||||
"type": "number"
|
||||
"type": "input-number"
|
||||
},
|
||||
{
|
||||
"label": "最大值",
|
||||
"name": "max",
|
||||
"type": "number"
|
||||
"type": "input-number"
|
||||
},
|
||||
{
|
||||
"label": "步长",
|
||||
"name": "step",
|
||||
"type": "number"
|
||||
"type": "input-number"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -525,14 +525,14 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
- `conditions[x].label` 类型名称
|
||||
- `conditions[x].test` 表达式,目标成员数据是否属于这个类型?
|
||||
- `conditions[x].scaffold` 初始数据,当新增的时候直接使用此数据。
|
||||
- `conditions[x].controls` 该类型的表单设置。
|
||||
- `conditions[x].items` 该类型的表单设置。
|
||||
- `typeSwitchable` 类型是否允许切换,如果设置成 true 会多一个类型切换的按钮。
|
||||
|
||||
## Tabs 模式
|
||||
|
||||
默认成员是一个一个排列的,如果数据比较多有点让人眼花缭乱。所以 Combo 支持了 tabs 的排列方式。
|
||||
|
||||
```schema: scope="form-item"
|
||||
```schema: scope="form-item2"
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo101",
|
||||
@ -545,11 +545,11 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"tabsMode": true,
|
||||
"tabsStyle": "card",
|
||||
"maxLength": 3,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "a",
|
||||
"label": "文本",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"placeholder": "文本",
|
||||
"value": "",
|
||||
"size": "full"
|
||||
@ -585,9 +585,9 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "父级文本框",
|
||||
"name": "super_text",
|
||||
"value": "123"
|
||||
@ -597,10 +597,10 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"name": "combo1",
|
||||
"label": "不可获取父级数据",
|
||||
"multiple": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "super_text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -616,9 +616,9 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "父级文本框",
|
||||
"name": "super_text",
|
||||
"value": "123"
|
||||
@ -629,10 +629,10 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"label": "可获取父级数据",
|
||||
"multiple": true,
|
||||
"canAccessSuperData": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "super_text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -652,9 +652,9 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "父级文本框",
|
||||
"name": "super_text",
|
||||
"value": "123"
|
||||
@ -665,10 +665,10 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"label": "可获取父级数据",
|
||||
"multiple": true,
|
||||
"canAccessSuperData": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "super_text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -689,9 +689,9 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "父级文本框",
|
||||
"name": "super_text",
|
||||
"value": "123"
|
||||
@ -704,10 +704,10 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"canAccessSuperData": true,
|
||||
"strictMode": false,
|
||||
"syncFields": ["super_text"],
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"name": "super_text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -725,13 +725,13 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "combo",
|
||||
"label": "显示序号",
|
||||
"multiple": true,
|
||||
"controls": [
|
||||
"items": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "<%= this.index + 1%>",
|
||||
@ -740,7 +740,7 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
},
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -20,15 +20,15 @@ order: 24
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"label": "邮箱:"
|
||||
}
|
||||
]
|
||||
@ -45,9 +45,9 @@ order: 24
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
@ -69,15 +69,15 @@ order: 24
|
||||
"type": "form",
|
||||
"title": "水平模式",
|
||||
"mode": "horizontal",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
},
|
||||
@ -110,15 +110,15 @@ order: 24
|
||||
"right": 10,
|
||||
"offset": 2
|
||||
},
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
},
|
||||
@ -149,15 +149,15 @@ order: 24
|
||||
"horizontal": {
|
||||
"leftFixed": "sm"
|
||||
},
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
},
|
||||
@ -179,14 +179,14 @@ order: 24
|
||||
"type": "form",
|
||||
"title": "内联模式",
|
||||
"mode": "inline",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password"
|
||||
},
|
||||
{
|
||||
@ -211,17 +211,17 @@ order: 24
|
||||
{
|
||||
"type": "form",
|
||||
"title": "常规模式",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
@ -233,17 +233,17 @@ order: 24
|
||||
"type": "form",
|
||||
"title": "水平模式",
|
||||
"mode": "horizontal",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email2",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password2",
|
||||
"label": "密码"
|
||||
}
|
||||
@ -255,17 +255,17 @@ order: 24
|
||||
"type": "form",
|
||||
"title": "内联模式",
|
||||
"mode": "inline",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
@ -291,9 +291,9 @@ Form 默认会在底部渲染一个提交按钮,用于执行表单的提交行
|
||||
"type": "form",
|
||||
"title": "通过 submitText 去掉提交按钮",
|
||||
"submitText": "",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -303,9 +303,9 @@ Form 默认会在底部渲染一个提交按钮,用于执行表单的提交行
|
||||
"type": "form",
|
||||
"title": "通过 actions 去掉提交按钮",
|
||||
"actions": [],
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -322,14 +322,14 @@ Form 默认会在底部渲染一个提交按钮,用于执行表单的提交行
|
||||
{
|
||||
"type": "form",
|
||||
"title": "表单",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
@ -367,14 +367,14 @@ Form 默认会在底部渲染一个提交按钮,用于执行表单的提交行
|
||||
{
|
||||
"type": "form",
|
||||
"wrapWithPanel": false,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
@ -397,14 +397,14 @@ Form 默认会在底部渲染一个提交按钮,用于执行表单的提交行
|
||||
"type": "form",
|
||||
"initApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/initData",
|
||||
"title": "编辑用户信息",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -444,9 +444,9 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"initApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/page/initData",
|
||||
"interval": 3000,
|
||||
"title": "表单",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "date",
|
||||
"label": "时间戳"
|
||||
}
|
||||
@ -463,9 +463,9 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"interval": 3000,
|
||||
"title": "表单",
|
||||
"stopAutoRefreshWhen": "this.date % 5",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "date",
|
||||
"label": "时间戳"
|
||||
}
|
||||
@ -485,14 +485,14 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"email": "rick@gmail.com"
|
||||
},
|
||||
"title": "用户信息",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
},
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -512,7 +512,7 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"data": {
|
||||
"select": ["a", "c"]
|
||||
},
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"label": "选项",
|
||||
"type": "select",
|
||||
@ -555,14 +555,14 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/saveForm",
|
||||
"title": "用户信息",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
},
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -617,14 +617,14 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
}
|
||||
},
|
||||
"title": "用户信息",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
},
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -648,14 +648,14 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"initApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/page/initData",
|
||||
"asyncApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/page/initData",
|
||||
"title": "用户信息",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
},
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
}
|
||||
@ -681,14 +681,14 @@ Form 支持轮询初始化接口,步骤如下:
|
||||
"message": "a 和 b 不能同时有值"
|
||||
}
|
||||
],
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "a",
|
||||
"label": "A"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"name": "b",
|
||||
"label": "B"
|
||||
}
|
||||
|
@ -1,27 +1,28 @@
|
||||
---
|
||||
title: Array 数组输入框
|
||||
title: InputArray 数组输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Array 数组输入框
|
||||
menuName: InputArray 数组输入框
|
||||
icon:
|
||||
order: 3
|
||||
---
|
||||
|
||||
Array 是一种简化的 [Combo](./combo),用于输入多个某种类型的[表单项](./formitem),提交的时将以数组的形式提交。
|
||||
InputArray 是一种简化的 [Combo](./combo),用于输入多个某种类型的[表单项](./formitem),提交的时将以数组的形式提交。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="form"
|
||||
```schema: scope="form2"
|
||||
[
|
||||
{
|
||||
"name": "array",
|
||||
"label": "颜色集合",
|
||||
"type": "array",
|
||||
"type": "input-array",
|
||||
"value": ["red"],
|
||||
"inline": true,
|
||||
"items": {
|
||||
"type": "color"
|
||||
"type": "input-color",
|
||||
"clearable": false
|
||||
}
|
||||
}
|
||||
]
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: City 城市选择器
|
||||
title: InputCity 城市选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: City
|
||||
menuName: InputCity
|
||||
icon:
|
||||
order: 10
|
||||
---
|
||||
@ -17,10 +17,10 @@ order: 10
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"searchable": true
|
||||
}
|
||||
@ -39,10 +39,10 @@ order: 10
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"allowDistrict": false,
|
||||
"allowCity": false
|
||||
@ -60,10 +60,10 @@ order: 10
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"extractValue": false
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Color 颜色选择器
|
||||
title: InputColor 颜色选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Color
|
||||
menuName: InputColor
|
||||
icon:
|
||||
order: 11
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 11
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "color",
|
||||
"type": "input-color",
|
||||
"name": "color",
|
||||
"label": "颜色"
|
||||
}
|
||||
@ -40,7 +40,7 @@ order: 11
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
{
|
||||
"type": "color",
|
||||
"type": "input-color",
|
||||
"name": "color",
|
||||
"label": "颜色",
|
||||
"format": "rgba"
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Date-Range 日期范围
|
||||
title: InputDateRange 日期范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Date-Range
|
||||
menuName: InputDateRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 15
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date-range",
|
||||
"type": "input-date-range",
|
||||
"name": "select",
|
||||
"label": "日期范围"
|
||||
}
|
||||
@ -31,9 +31,9 @@ order: 15
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date-range",
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期范围",
|
||||
"embed": true
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: Date 日期
|
||||
title: InputDate 日期
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
@ -14,9 +14,9 @@ order: 13
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期"
|
||||
}
|
||||
@ -34,9 +34,9 @@ order: 13
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"inputFormat": "YYYY年MM月DD日"
|
||||
@ -56,9 +56,9 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期"
|
||||
}
|
||||
@ -75,9 +75,9 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"format": "YYYY-MM-DD"
|
||||
@ -101,9 +101,9 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"value": "1591862818"
|
||||
@ -121,9 +121,9 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"value": "+1days"
|
||||
@ -153,16 +153,16 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "1591862818",
|
||||
"description": "限制可选最小日期是 <code>2020-06-11 16:06:58</code>"
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "end",
|
||||
"label": "结束时间",
|
||||
"maxDate": "1591862818",
|
||||
@ -181,9 +181,9 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "-1days",
|
||||
@ -204,15 +204,15 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始日期",
|
||||
"maxDate": "$end"
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "end",
|
||||
"label": "结束日期",
|
||||
"minDate": "$start"
|
||||
@ -230,9 +230,9 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"shortcuts": ["yesterday" ,"today", "tomorrow"]
|
||||
@ -272,15 +272,15 @@ order: 13
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "普通日期",
|
||||
"format": "YYYY-MM-DD"
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date-utc",
|
||||
"label": "UTC日期",
|
||||
"utc": true,
|
||||
@ -296,14 +296,14 @@ order: 13
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "static-date",
|
||||
"name": "date",
|
||||
"label": "当前值"
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"embed": true
|
||||
@ -320,7 +320,7 @@ order: 13
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "native-date",
|
||||
"name": "date",
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Datetime-Range 日期时间范围
|
||||
title: InputDatetimeRange 日期时间范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Datetime-Range
|
||||
menuName: InputDatetimeRange
|
||||
icon:
|
||||
order: 16
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 16
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime-range",
|
||||
"type": "input-datetime-range",
|
||||
"name": "select",
|
||||
"label": "日期时间范围"
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Datetime 日期时间
|
||||
title: InputDatetime 日期时间
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Datetime
|
||||
menuName: InputDatetime
|
||||
icon:
|
||||
order: 14
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 14
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间"
|
||||
}
|
||||
@ -34,9 +34,9 @@ order: 14
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"inputFormat": "YYYY年MM月DD日 HH时mm分ss秒"
|
||||
@ -56,9 +56,9 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间"
|
||||
}
|
||||
@ -75,9 +75,9 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
@ -101,9 +101,9 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"value": "1591862818"
|
||||
@ -121,9 +121,9 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期",
|
||||
"value": "+1hours"
|
||||
@ -151,16 +151,16 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "1591862818",
|
||||
"description": "限制可选最小日期是 <code>2020-06-11 16:06:58</code>"
|
||||
},
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "end",
|
||||
"label": "结束时间",
|
||||
"maxDate": "1591862818",
|
||||
@ -179,9 +179,9 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "-1days",
|
||||
@ -202,15 +202,15 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"maxDate": "$end"
|
||||
},
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "end",
|
||||
"label": "结束时间",
|
||||
"minDate": "$start"
|
||||
@ -228,9 +228,9 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期",
|
||||
"shortcuts": ["yesterday" ,"today", "tomorrow"]
|
||||
@ -256,15 +256,15 @@ order: 14
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "普通日期时间",
|
||||
"format": "YYYY-MM-DD"
|
||||
},
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "datetime-utc",
|
||||
"label": "UTC日期时间",
|
||||
"utc": true,
|
||||
@ -280,7 +280,7 @@ order: 14
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "static-date",
|
||||
"name": "date",
|
||||
@ -288,7 +288,7 @@ order: 14
|
||||
"label": "当前值"
|
||||
},
|
||||
{
|
||||
"type": "datetime",
|
||||
"type": "input-datetime",
|
||||
"name": "date",
|
||||
"label": "日期时间",
|
||||
"embed": true
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: File 文件上传
|
||||
title: InputFile 文件上传
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: File
|
||||
menuName: InputFile
|
||||
icon:
|
||||
order: 21
|
||||
---
|
||||
@ -16,9 +16,9 @@ order: 21
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "file",
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
@ -50,9 +50,9 @@ order: 21
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "file",
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "限制只能上传csv文件",
|
||||
"accept": ".csv",
|
||||
@ -73,9 +73,9 @@ order: 21
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "file",
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
@ -99,9 +99,9 @@ order: 21
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "file",
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
@ -152,9 +152,9 @@ order: 21
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "file",
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"multiple": true,
|
@ -1,14 +1,14 @@
|
||||
---
|
||||
title: Image 图片
|
||||
title: InputImage 图片
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Image
|
||||
menuName: InputImage
|
||||
icon:
|
||||
order: 27
|
||||
---
|
||||
|
||||
图片格式输入,需要实现接收器,提交时将以 url 的方式提交,如果需要以表单方式提交请使用 [File](file#手动上传)。
|
||||
图片格式输入,需要实现接收器,提交时将以 url 的方式提交,如果需要以表单方式提交请使用 [InputFile](input-file#手动上传)。
|
||||
|
||||
## 基本用法
|
||||
|
||||
@ -16,9 +16,9 @@ order: 27
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "image",
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"receiver": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/upload/file"
|
||||
@ -49,9 +49,9 @@ order: 27
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "image",
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "限制只能上传jpg图片",
|
||||
"accept": ".jpg",
|
||||
@ -71,9 +71,9 @@ order: 27
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "image",
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "限制只能上传宽度大于 1000 的图片",
|
||||
"accept": ".jpg",
|
||||
@ -92,9 +92,9 @@ order: 27
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "image",
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "限制只能上传jpg图片",
|
||||
"accept": ".jpg",
|
||||
@ -113,9 +113,9 @@ order: 27
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "image",
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"receiver": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/upload/file",
|
||||
@ -165,9 +165,9 @@ order: 27
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "image",
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"multiple": true,
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Month-Range 月份范围
|
||||
title: InputMonthRange 月份范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Month-Range
|
||||
menuName: InputMonthRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 15
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month-range",
|
||||
"type": "input-month-range",
|
||||
"name": "a",
|
||||
"label": "月份范围"
|
||||
}
|
||||
@ -31,9 +31,9 @@ order: 15
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month-range",
|
||||
"type": "input-month-range",
|
||||
"name": "a",
|
||||
"label": "月份范围",
|
||||
"embed": true
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Month 月份
|
||||
title: InputMonth 月份
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Month 月份
|
||||
menuName: InputMonth 月份
|
||||
icon:
|
||||
order: 81
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 81
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month",
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "时间"
|
||||
}
|
||||
@ -34,9 +34,9 @@ order: 81
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month",
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"inputFormat": "MM月"
|
||||
@ -56,9 +56,9 @@ order: 81
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month",
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份"
|
||||
}
|
||||
@ -75,9 +75,9 @@ order: 81
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month",
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"format": "MM"
|
||||
@ -101,9 +101,9 @@ order: 81
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month",
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"value": "1582992000"
|
||||
@ -121,9 +121,9 @@ order: 81
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "month",
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"value": "+1month"
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Number 数字输入框
|
||||
title: InputNumber 数字输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Number
|
||||
menuName: InputNumber
|
||||
icon:
|
||||
order: 32
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 32
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "number",
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字"
|
||||
}
|
||||
@ -32,7 +32,7 @@ order: 32
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "native-number",
|
||||
"name": "number",
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Quarter 季度
|
||||
title: InputQuarter 季度
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Quarter 季度
|
||||
menuName: InputQuarter 季度
|
||||
icon:
|
||||
order: 62
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 62
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "quarter",
|
||||
"type": "input-quarter",
|
||||
"name": "quarter",
|
||||
"label": "季度"
|
||||
}
|
||||
@ -24,4 +24,4 @@ order: 62
|
||||
}
|
||||
```
|
||||
|
||||
更多用法和配置可以参考 [Date 日期](date),quarter 就是 data 的特定配置,所以 data 的所有配置都能使用。
|
||||
更多用法和配置可以参考 [InputDate 日期](input-date),quarter 就是 data 的特定配置,所以 data 的所有配置都能使用。
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Range 滑块
|
||||
title: InputRange 滑块
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Range 范围
|
||||
menuName: InputRange 范围
|
||||
icon:
|
||||
order: 38
|
||||
---
|
||||
@ -18,9 +18,9 @@ order: 38
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "range",
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range"
|
||||
}
|
||||
@ -37,9 +37,9 @@ order: 38
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "range",
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"multiple": true
|
36
docs/zh-CN/components/form/input-rating.md
Executable file
36
docs/zh-CN/components/form/input-rating.md
Executable file
@ -0,0 +1,36 @@
|
||||
---
|
||||
title: InputRating 评分
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputRating 评分
|
||||
icon:
|
||||
order: 37
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | --------- | ------- | ---------------------- |
|
||||
| half | `boolean` | `false` | 是否使用半星选择 |
|
||||
| count | `number` | `5` | 共有多少星可供选择 |
|
||||
| readOnly | `boolean` | `false` | 只读 |
|
||||
| allowClear | `boolean` | `true` | 是否允许再次点击后清除 |
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Repeat 重复频率选择器
|
||||
title: InputRepeat 重复频率选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Repeat 重复频率
|
||||
menuName: InputRepeat 重复频率
|
||||
icon:
|
||||
order: 39
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 39
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "repeat",
|
||||
"type": "input-repeat",
|
||||
"name": "repeat",
|
||||
"label": "重复频率"
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Rich-Text 富文本编辑器
|
||||
title: InputRichText 富文本编辑器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Rich-Text
|
||||
menuName: InputRichText
|
||||
icon:
|
||||
order: 47
|
||||
---
|
||||
@ -16,9 +16,9 @@ order: 47
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "rich-text",
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"label": "Rich Text"
|
||||
}
|
||||
@ -36,9 +36,9 @@ order: 47
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "rich-text",
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"options": {
|
||||
"menubar": false,
|
||||
@ -63,9 +63,9 @@ order: 47
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "rich-text",
|
||||
"type": "input-rich-text",
|
||||
"vendor": "froala",
|
||||
"name": "rich",
|
||||
"label": "Rich Text"
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: SubForm 子表单
|
||||
title: InputSubForm 子表单
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: SubForm 子表单
|
||||
menuName: InputSubForm 子表单
|
||||
icon:
|
||||
order: 50
|
||||
---
|
||||
@ -14,25 +14,25 @@ order: 50
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"type": "input-sub-form",
|
||||
"name": "form",
|
||||
"label": "子Form",
|
||||
"btnLabel": "设置子表单",
|
||||
"form": {
|
||||
"title": "配置子表单",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "a",
|
||||
"label": "A",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "b",
|
||||
"label": "B",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -49,9 +49,9 @@ order: 50
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"type": "input-sub-form",
|
||||
"name": "form2",
|
||||
"label": "多选",
|
||||
"multiple": true,
|
||||
@ -59,16 +59,16 @@ order: 50
|
||||
"btnLabel": "设置子表单",
|
||||
"form": {
|
||||
"title": "配置子表单",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "a",
|
||||
"label": "A",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"label": "B",
|
||||
"type": "text"
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Table 表格
|
||||
title: InputTable 表格
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Table 表格
|
||||
menuName: InputTable 表格
|
||||
icon:
|
||||
order: 54
|
||||
---
|
||||
@ -33,9 +33,9 @@ order: 54
|
||||
]
|
||||
},
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type":"table",
|
||||
"type":"input-table",
|
||||
"name":"table",
|
||||
"columns":[
|
||||
{
|
||||
@ -62,9 +62,9 @@ order: 54
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type":"table",
|
||||
"type":"input-table",
|
||||
"name":"table",
|
||||
"addable": true,
|
||||
"editable": true,
|
||||
@ -107,9 +107,9 @@ order: 54
|
||||
]
|
||||
},
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "table",
|
||||
"type": "input-table",
|
||||
"name": "table",
|
||||
"label": "Table",
|
||||
"columns": [
|
||||
@ -159,9 +159,9 @@ order: 54
|
||||
]
|
||||
},
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "table",
|
||||
"type": "input-table",
|
||||
"name": "table",
|
||||
"label": "Table",
|
||||
"columns": [
|
||||
@ -205,9 +205,9 @@ order: 54
|
||||
]
|
||||
},
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "table",
|
||||
"type": "input-table",
|
||||
"name": "table",
|
||||
"label": "Table",
|
||||
"draggable": true,
|
||||
@ -250,9 +250,9 @@ order: 54
|
||||
]
|
||||
},
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "table",
|
||||
"type": "input-table",
|
||||
"name": "table",
|
||||
"label": "Table",
|
||||
"needConfirm": false,
|
||||
@ -284,15 +284,15 @@ order: 54
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "父级文本框",
|
||||
"name": "super_text",
|
||||
"value": "123"
|
||||
},
|
||||
{
|
||||
"type": "table",
|
||||
"type": "input-table",
|
||||
"name": "list",
|
||||
"label": "不可获取父级数据",
|
||||
"addable": true,
|
||||
@ -317,9 +317,9 @@ order: 54
|
||||
"debug": true,
|
||||
"mode": "horizontal",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "父级文本框",
|
||||
"name": "super_text",
|
||||
"value": "123"
|
||||
@ -331,7 +331,7 @@ order: 54
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"type": "table",
|
||||
"type": "input-table",
|
||||
"name": "list",
|
||||
"label": "可获取父级数据",
|
||||
"addable": true,
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Tag 标签选择器
|
||||
title: InputTag 标签选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Tag 标签选择器
|
||||
menuName: InputTag 标签选择器
|
||||
icon:
|
||||
order: 55
|
||||
---
|
||||
@ -13,9 +13,9 @@ order: 55
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tag",
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"options": [
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Text 输入框
|
||||
title: InputText 输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Text 输入框
|
||||
menuName: InputText 输入框
|
||||
icon:
|
||||
order: 56
|
||||
---
|
||||
@ -14,10 +14,10 @@ order: 56
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "text"
|
||||
}
|
||||
]
|
||||
@ -32,17 +32,17 @@ order: 56
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "text"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "url",
|
||||
"type": "input-url",
|
||||
"name": "url",
|
||||
"label": "链接"
|
||||
},
|
||||
@ -50,7 +50,7 @@ order: 56
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "email",
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
@ -58,7 +58,7 @@ order: 56
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
@ -74,10 +74,10 @@ order: 56
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"addOn": {
|
||||
"type": "button",
|
||||
@ -97,10 +97,10 @@ order: 56
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"clearable": true
|
||||
}
|
||||
@ -116,10 +116,10 @@ order: 56
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"options": [
|
||||
{
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Time 时间
|
||||
title: InputTime 时间
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Time 时间
|
||||
menuName: InputTime 时间
|
||||
icon:
|
||||
order: 58
|
||||
---
|
||||
@ -14,9 +14,9 @@ order: 58
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间"
|
||||
}
|
||||
@ -34,9 +34,9 @@ order: 58
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"inputFormat": "HH时mm分"
|
||||
@ -56,9 +56,9 @@ order: 58
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间"
|
||||
}
|
||||
@ -75,9 +75,9 @@ order: 58
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"format": "HH:mm"
|
||||
@ -97,9 +97,9 @@ order: 58
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"format": "HH:mm:ss",
|
||||
@ -123,9 +123,9 @@ order: 58
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"value": "1591862818"
|
||||
@ -143,9 +143,9 @@ order: 58
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "time",
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"value": "+1hours"
|
||||
@ -171,7 +171,7 @@ order: 58
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "native-time",
|
||||
"name": "time",
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Tree 树形选择框
|
||||
title: InputTree 树形选择框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Tree 树形选择框
|
||||
menuName: InpputTree 树形选择框
|
||||
icon:
|
||||
order: 59
|
||||
---
|
||||
@ -16,9 +16,9 @@ order: 59
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree",
|
||||
"label": "Tree",
|
||||
"options": [
|
||||
@ -68,7 +68,7 @@ order: 59
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree-select",
|
||||
"name": "tree",
|
||||
@ -112,9 +112,9 @@ order: 59
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree",
|
||||
"label": "Tree",
|
||||
"showOutline": true,
|
||||
@ -166,9 +166,9 @@ order: 59
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree1",
|
||||
"label": "默认自动选中子节点",
|
||||
"multiple": true,
|
||||
@ -205,7 +205,7 @@ order: 59
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree2",
|
||||
"label": "不自动选中子节点",
|
||||
"multiple": true,
|
||||
@ -252,9 +252,9 @@ order: 59
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree1",
|
||||
"label": "默认不自动带上子节点的值",
|
||||
"multiple": true,
|
||||
@ -291,7 +291,7 @@ order: 59
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree2",
|
||||
"label": "自动带上子节点的值",
|
||||
"multiple": true,
|
||||
@ -336,9 +336,9 @@ order: 59
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree1",
|
||||
"label": "默认不自动带上子节点的值",
|
||||
"multiple": true,
|
||||
@ -375,7 +375,7 @@ order: 59
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree2",
|
||||
"label": "只包含子节点的值",
|
||||
"multiple": true,
|
||||
@ -422,9 +422,9 @@ order: 59
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree1",
|
||||
"label": "默认不自动带上子节点的值",
|
||||
"initiallyOpen": false,
|
||||
@ -470,9 +470,9 @@ order: 59
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree1",
|
||||
"label": "默认不自动带上子节点的值",
|
||||
"initiallyOpen": false,
|
||||
@ -532,9 +532,9 @@ order: 59
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree",
|
||||
"label": "Tree",
|
||||
"creatable": true,
|
||||
@ -580,9 +580,9 @@ order: 59
|
||||
{
|
||||
"type": "form",
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"controls": [
|
||||
"body": [
|
||||
{
|
||||
"type": "tree",
|
||||
"type": "input-tree",
|
||||
"name": "tree",
|
||||
"label": "Tree",
|
||||
"deferApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/deferOptions?label=${label}&waitSeconds=2",
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user