diff --git a/__tests__/renderers/Carousel.test.tsx b/__tests__/renderers/Carousel.test.tsx index 2d3c9e07..67d8bbc9 100644 --- a/__tests__/renderers/Carousel.test.tsx +++ b/__tests__/renderers/Carousel.test.tsx @@ -1,44 +1,48 @@ -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 "react-testing-library"; +import "../../src/themes/default"; +import { render as amisRender } from "../../src/index"; +import { makeEnv } from "../helper"; -test('Renderer:carousel', async () => { - const { - container - } = render(amisRender({ - type: 'carousel', - controlsTheme: 'light', - width: '500', - height: '300', +test("Renderer:carousel", async () => { + const { container } = render( + amisRender( + { + type: "carousel", + controlsTheme: "light", + width: "500", + height: "300", options: [ - { - image: 'https://video-react.js.org/assets/poster.png', - title: '标题', - titleClassName: 'block', - description: '描述', - descriptionClassName: 'block' - }, - { - html: '
添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - label: '编辑', - actionType: 'dialog', + type: "button", + label: "编辑", + actionType: "dialog", dialog: { - title: '编辑', + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'grade', - label: 'CSS grade' + type: "text", + name: "grade", + label: "CSS grade" } ] } } }, { - type: 'button', - label: '删除', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + label: "删除", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], body: [ { - name: 'engine', - label: 'engine', + name: "engine", + label: "engine", sortable: true, quickEdit: true }, { - name: 'browser', - label: 'Browser' + name: "browser", + label: "Browser" }, { - name: 'platform', - label: 'Platform' + name: "platform", + label: "Platform" }, { - name: 'version', - label: 'version' + name: "version", + label: "version" } ] } diff --git a/examples/components/Carousel.jsx b/examples/components/Carousel.jsx index 574ff075..b7122178 100644 --- a/examples/components/Carousel.jsx +++ b/examples/components/Carousel.jsx @@ -1,11 +1,11 @@ export default { - type: 'page', - title: '轮播图', + type: "page", + title: "轮播图", data: { carousel0: [ - 'https://hiphotos.baidu.com/fex/%70%69%63/item/bd3eb13533fa828b13b24500f31f4134960a5a44.jpg', - 'https://video-react.js.org/assets/poster.png', - 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg' + "https://hiphotos.baidu.com/fex/%70%69%63/item/bd3eb13533fa828b13b24500f31f4134960a5a44.jpg", + "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png", + "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg" ], carousel1: [ { @@ -14,28 +14,29 @@ export default { }, { image: - 'https://hiphotos.baidu.com/fex/%70%69%63/item/bd3eb13533fa828b13b24500f31f4134960a5a44.jpg' + "https://hiphotos.baidu.com/fex/%70%69%63/item/bd3eb13533fa828b13b24500f31f4134960a5a44.jpg" }, { 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" } ] }, body: [ { - type: 'grid', + type: "grid", columns: [ { - type: 'panel', - title: '直接页面配置', + type: "panel", + title: "直接页面配置", body: { - type: 'carousel', - controlsTheme: 'light', - height: '300', + type: "carousel", + controlsTheme: "light", + height: "300", options: [ { - image: 'https://video-react.js.org/assets/poster.png' + image: + "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png" }, { html: @@ -43,21 +44,21 @@ export default { }, { 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" } ] } }, { - type: 'panel', - title: '使用itemSchema配置', + type: "panel", + title: "使用itemSchema配置", body: { - type: 'carousel', - name: 'carousel0', - controlsTheme: 'dark', - height: '300', + type: "carousel", + name: "carousel0", + controlsTheme: "dark", + height: "300", itemSchema: { - type: 'tpl', + type: "tpl", tpl: '' } @@ -66,20 +67,20 @@ export default { ] }, { - type: 'grid', + type: "grid", columns: [ { - type: 'form', - title: '表单内展示', + type: "form", + title: "表单内展示", sm: 6, controls: [ { - type: 'carousel', - controlsTheme: 'dark', - name: 'carousel1', - label: 'carousel', - animation: 'slide', - height: '300' + type: "carousel", + controlsTheme: "dark", + name: "carousel1", + label: "carousel", + animation: "slide", + height: "300" } ] } diff --git a/examples/components/Form/Picker.jsx b/examples/components/Form/Picker.jsx index 38d03f93..e08aa1be 100644 --- a/examples/components/Form/Picker.jsx +++ b/examples/components/Form/Picker.jsx @@ -1,286 +1,286 @@ export default { - $schema: 'https://houtai.baidu.com/v2/schemas/page.json#', - title: '表格编辑', + $schema: "https://houtai.baidu.com/v2/schemas/page.json#", + title: "表格编辑", body: { - type: 'form', - mode: 'horizontal', - api: '/api/mock2/form/saveForm?waitSeconds=2', + type: "form", + mode: "horizontal", + api: "/api/mock2/form/saveForm?waitSeconds=2", actions: [ { - type: 'submit', - label: '提交', + type: "submit", + label: "提交", primary: true } ], controls: [ - '常规模式
', + "常规模式
", { - type: 'divider' + type: "divider" }, { - type: 'picker', - name: 'type', - label: '单选', + type: "picker", + name: "type", + label: "单选", value: 1, inline: true, options: [ { - label: '选项1', + label: "选项1", value: 1 }, { - label: '选项2', + label: "选项2", value: 2 }, { - label: '选项3', + label: "选项3", value: 3 }, { - label: '选项4', + label: "选项4", value: 4 } ] }, { - type: 'picker', - name: 'type2', - label: '多选', + type: "picker", + name: "type2", + label: "多选", multiple: true, options: [ { - label: '选项1', + label: "选项1", value: 1 }, { - label: '选项2', + label: "选项2", value: 2 }, { - label: '选项3', + label: "选项3", value: 3 }, { - label: '选项4', + label: "选项4", value: 4 } ] }, { - type: 'divider' + type: "divider" }, - 'Table 渲染类型
', + "Table 渲染类型
", { - type: 'divider' + type: "divider" }, { - type: 'picker', - name: 'type3', + type: "picker", + name: "type3", joinValues: true, - valueField: 'id', - labelField: 'engine', - label: '单选', - source: '/api/sample', - size: 'lg', - value: '4', + valueField: "id", + labelField: "engine", + label: "单选", + source: "/api/sample", + size: "lg", + value: "4", pickerSchema: { - mode: 'table', - name: 'thelist', - quickSaveApi: '/api/sample/bulkUpdate', - quickSaveItemApi: '/api/sample/$id', + mode: "table", + name: "thelist", + quickSaveApi: "/api/sample/bulkUpdate", + quickSaveItemApi: "/api/sample/$id", draggable: true, headerToolbar: { wrapWithPanel: false, - type: 'form', - className: 'text-right', - target: 'thelist', - mode: 'inline', + type: "form", + className: "text-right", + target: "thelist", + mode: "inline", controls: [ { - type: 'text', - name: 'keywords', + type: "text", + name: "keywords", addOn: { - type: 'submit', - label: '搜索', - level: 'primary', - icon: 'fa fa-search pull-left' + type: "submit", + label: "搜索", + level: "primary", + icon: "fa fa-search pull-left" } } ] }, columns: [ { - name: 'engine', - label: 'Rendering engine', + name: "engine", + label: "Rendering engine", sortable: true, searchable: true, - type: 'text', + type: "text", toggled: true }, { - name: 'browser', - label: 'Browser', + name: "browser", + label: "Browser", sortable: true, - type: 'text', + type: "text", toggled: true }, { - name: 'platform', - label: 'Platform(s)', + name: "platform", + label: "Platform(s)", sortable: true, - type: 'text', + type: "text", toggled: true }, { - name: 'version', - label: 'Engine version', + name: "version", + label: "Engine version", quickEdit: true, - type: 'text', + type: "text", toggled: true }, { - name: 'grade', - label: 'CSS grade', + name: "grade", + label: "CSS grade", quickEdit: { - mode: 'inline', - type: 'select', - options: ['A', 'B', 'C', 'D', 'X'], + mode: "inline", + type: "select", + options: ["A", "B", "C", "D", "X"], saveImmediately: true }, - type: 'text', + type: "text", toggled: true }, { - type: 'operation', - label: '操作', + type: "operation", + label: "操作", width: 100, buttons: [ { - type: 'button', - icon: 'fa fa-eye', - actionType: 'dialog', + type: "button", + icon: "fa fa-eye", + actionType: "dialog", dialog: { - title: '查看', + title: "查看", body: { - type: 'form', + type: "form", controls: [ { - type: 'static', - name: 'engine', - label: 'Engine' + type: "static", + name: "engine", + label: "Engine" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'browser', - label: 'Browser' + type: "static", + name: "browser", + label: "Browser" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'platform', - label: 'Platform(s)' + type: "static", + name: "platform", + label: "Platform(s)" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'version', - label: 'Engine version' + type: "static", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'grade', - label: 'CSS grade' + type: "static", + name: "grade", + label: "CSS grade" }, { - type: 'divider' + type: "divider" }, { - type: 'html', + type: "html", html: - '添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - icon: 'fa fa-pencil', - actionType: 'dialog', + type: "button", + icon: "fa fa-pencil", + actionType: "dialog", dialog: { - position: 'left', - size: 'lg', - title: '编辑', + position: "left", + size: "lg", + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'select', - name: 'grade', - label: 'CSS grade', - options: ['A', 'B', 'C', 'D', 'X'] + type: "select", + name: "grade", + label: "CSS grade", + options: ["A", "B", "C", "D", "X"] } ] } } }, { - type: 'button', - icon: 'fa fa-times text-danger', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + icon: "fa fa-times text-danger", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], toggled: true @@ -290,210 +290,210 @@ export default { }, { - type: 'picker', - name: 'type4', + type: "picker", + name: "type4", joinValues: true, - valueField: 'id', - labelField: 'engine', - label: '多选', - source: '/api/sample', - size: 'lg', - value: '4,5', + valueField: "id", + labelField: "engine", + label: "多选", + source: "/api/sample", + size: "lg", + value: "4,5", multiple: true, pickerSchema: { - mode: 'table', - name: 'thelist', - quickSaveApi: '/api/sample/bulkUpdate', - quickSaveItemApi: '/api/sample/$id', + mode: "table", + name: "thelist", + quickSaveApi: "/api/sample/bulkUpdate", + quickSaveItemApi: "/api/sample/$id", draggable: true, headerToolbar: { wrapWithPanel: false, - type: 'form', - className: 'text-right', - target: 'thelist', - mode: 'inline', + type: "form", + className: "text-right", + target: "thelist", + mode: "inline", controls: [ { - type: 'text', - name: 'keywords', + type: "text", + name: "keywords", addOn: { - type: 'submit', - label: '搜索', - level: 'primary', - icon: 'fa fa-search pull-left' + type: "submit", + label: "搜索", + level: "primary", + icon: "fa fa-search pull-left" } } ] }, columns: [ { - name: 'engine', - label: 'Rendering engine', + name: "engine", + label: "Rendering engine", sortable: true, searchable: true, - type: 'text', + type: "text", toggled: true }, { - name: 'browser', - label: 'Browser', + name: "browser", + label: "Browser", sortable: true, - type: 'text', + type: "text", toggled: true }, { - name: 'platform', - label: 'Platform(s)', + name: "platform", + label: "Platform(s)", sortable: true, - type: 'text', + type: "text", toggled: true }, { - name: 'version', - label: 'Engine version', + name: "version", + label: "Engine version", quickEdit: true, - type: 'text', + type: "text", toggled: true }, { - name: 'grade', - label: 'CSS grade', + name: "grade", + label: "CSS grade", quickEdit: { - mode: 'inline', - type: 'select', - options: ['A', 'B', 'C', 'D', 'X'], + mode: "inline", + type: "select", + options: ["A", "B", "C", "D", "X"], saveImmediately: true }, - type: 'text', + type: "text", toggled: true }, { - type: 'operation', - label: '操作', + type: "operation", + label: "操作", width: 100, buttons: [ { - type: 'button', - icon: 'fa fa-eye', - actionType: 'dialog', + type: "button", + icon: "fa fa-eye", + actionType: "dialog", dialog: { - title: '查看', + title: "查看", body: { - type: 'form', + type: "form", controls: [ { - type: 'static', - name: 'engine', - label: 'Engine' + type: "static", + name: "engine", + label: "Engine" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'browser', - label: 'Browser' + type: "static", + name: "browser", + label: "Browser" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'platform', - label: 'Platform(s)' + type: "static", + name: "platform", + label: "Platform(s)" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'version', - label: 'Engine version' + type: "static", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'grade', - label: 'CSS grade' + type: "static", + name: "grade", + label: "CSS grade" }, { - type: 'divider' + type: "divider" }, { - type: 'html', + type: "html", html: - '添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - icon: 'fa fa-pencil', - actionType: 'dialog', + type: "button", + icon: "fa fa-pencil", + actionType: "dialog", dialog: { - position: 'left', - size: 'lg', - title: '编辑', + position: "left", + size: "lg", + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'select', - name: 'grade', - label: 'CSS grade', - options: ['A', 'B', 'C', 'D', 'X'] + type: "select", + name: "grade", + label: "CSS grade", + options: ["A", "B", "C", "D", "X"] } ] } } }, { - type: 'button', - icon: 'fa fa-times text-danger', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + icon: "fa fa-times text-danger", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], toggled: true @@ -503,45 +503,45 @@ export default { }, { - type: 'divider' + type: "divider" }, - 'List 渲染类型
', + "List 渲染类型
", { - type: 'divider' + type: "divider" }, { - type: 'picker', - name: 'type5', + type: "picker", + name: "type5", joinValues: true, - valueField: 'id', - labelField: 'engine', - label: '单选', - source: '/api/sample', - size: 'lg', - value: '4', + valueField: "id", + labelField: "engine", + label: "单选", + source: "/api/sample", + size: "lg", + value: "4", pickerSchema: { - mode: 'list', - name: 'thelist', - quickSaveApi: '/api/sample/bulkUpdate', - quickSaveItemApi: '/api/sample/$id', + mode: "list", + name: "thelist", + quickSaveApi: "/api/sample/bulkUpdate", + quickSaveItemApi: "/api/sample/$id", draggable: true, headerToolbar: { wrapWithPanel: false, - type: 'form', - className: 'text-right', - target: 'thelist', - mode: 'inline', + type: "form", + className: "text-right", + target: "thelist", + mode: "inline", controls: [ { - type: 'text', - name: 'keywords', + type: "text", + name: "keywords", addOn: { - type: 'submit', - label: '搜索', - level: 'primary', - icon: 'fa fa-search pull-left' + type: "submit", + label: "搜索", + level: "primary", + icon: "fa fa-search pull-left" } } ] @@ -549,187 +549,187 @@ export default { listItem: { actions: [ { - type: 'button', - icon: 'fa fa-eye', - actionType: 'dialog', + type: "button", + icon: "fa fa-eye", + actionType: "dialog", dialog: { - title: '查看', + title: "查看", body: { - type: 'form', + type: "form", controls: [ { - type: 'static', - name: 'engine', - label: 'Engine' + type: "static", + name: "engine", + label: "Engine" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'browser', - label: 'Browser' + type: "static", + name: "browser", + label: "Browser" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'platform', - label: 'Platform(s)' + type: "static", + name: "platform", + label: "Platform(s)" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'version', - label: 'Engine version' + type: "static", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'grade', - label: 'CSS grade' + type: "static", + name: "grade", + label: "CSS grade" }, { - type: 'divider' + type: "divider" }, { - type: 'html', + type: "html", html: - '添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - icon: 'fa fa-pencil', - actionType: 'dialog', + type: "button", + icon: "fa fa-pencil", + actionType: "dialog", dialog: { - title: '编辑', + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'grade', - label: 'CSS grade' + type: "text", + name: "grade", + label: "CSS grade" } ] } } }, { - type: 'button', - icon: 'fa fa-times text-danger', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + icon: "fa fa-times text-danger", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], body: [ { - name: 'engine', - label: 'Rendering engine', + name: "engine", + label: "Rendering engine", sortable: true, quickEdit: true, - labelClassName: 'w-sm' + labelClassName: "w-sm" }, [ { - name: 'browser', - label: 'Browser', - labelClassName: 'w-sm' + name: "browser", + label: "Browser", + labelClassName: "w-sm" }, { - name: 'platform', - label: 'Platform(s)', - labelClassName: 'w-sm' + name: "platform", + label: "Platform(s)", + labelClassName: "w-sm" } ], { - name: 'version', - label: 'Engine version', - labelClassName: 'w-sm' + name: "version", + label: "Engine version", + labelClassName: "w-sm" } ] } } }, { - type: 'picker', - name: 'type6', + type: "picker", + name: "type6", joinValues: true, - valueField: 'id', - labelField: 'engine', - label: '多选', - source: '/api/sample', - size: 'lg', - value: '4,5', + valueField: "id", + labelField: "engine", + label: "多选", + source: "/api/sample", + size: "lg", + value: "4,5", multiple: true, pickerSchema: { - mode: 'list', - name: 'thelist', - quickSaveApi: '/api/sample/bulkUpdate', - quickSaveItemApi: '/api/sample/$id', + mode: "list", + name: "thelist", + quickSaveApi: "/api/sample/bulkUpdate", + quickSaveItemApi: "/api/sample/$id", draggable: true, headerToolbar: { wrapWithPanel: false, - type: 'form', - className: 'text-right', - target: 'thelist', - mode: 'inline', + type: "form", + className: "text-right", + target: "thelist", + mode: "inline", controls: [ { - type: 'text', - name: 'keywords', + type: "text", + name: "keywords", addOn: { - type: 'submit', - label: '搜索', - level: 'primary', - icon: 'fa fa-search pull-left' + type: "submit", + label: "搜索", + level: "primary", + icon: "fa fa-search pull-left" } } ] @@ -737,150 +737,150 @@ export default { listItem: { actions: [ { - type: 'button', - icon: 'fa fa-eye', - actionType: 'dialog', + type: "button", + icon: "fa fa-eye", + actionType: "dialog", dialog: { - title: '查看', + title: "查看", body: { - type: 'form', + type: "form", controls: [ { - type: 'static', - name: 'engine', - label: 'Engine' + type: "static", + name: "engine", + label: "Engine" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'browser', - label: 'Browser' + type: "static", + name: "browser", + label: "Browser" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'platform', - label: 'Platform(s)' + type: "static", + name: "platform", + label: "Platform(s)" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'version', - label: 'Engine version' + type: "static", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'grade', - label: 'CSS grade' + type: "static", + name: "grade", + label: "CSS grade" }, { - type: 'divider' + type: "divider" }, { - type: 'html', + type: "html", html: - '添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - icon: 'fa fa-pencil', - actionType: 'dialog', + type: "button", + icon: "fa fa-pencil", + actionType: "dialog", dialog: { - title: '编辑', + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'grade', - label: 'CSS grade' + type: "text", + name: "grade", + label: "CSS grade" } ] } } }, { - type: 'button', - icon: 'fa fa-times text-danger', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + icon: "fa fa-times text-danger", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], body: [ { - name: 'engine', - label: 'Rendering engine', + name: "engine", + label: "Rendering engine", sortable: true, quickEdit: true, - labelClassName: 'w-sm' + labelClassName: "w-sm" }, [ { - name: 'browser', - label: 'Browser', - labelClassName: 'w-sm' + name: "browser", + label: "Browser", + labelClassName: "w-sm" }, { - name: 'platform', - label: 'Platform(s)', - labelClassName: 'w-sm' + name: "platform", + label: "Platform(s)", + labelClassName: "w-sm" } ], { - name: 'version', - label: 'Engine version', - labelClassName: 'w-sm' + name: "version", + label: "Engine version", + labelClassName: "w-sm" } ] } @@ -888,198 +888,198 @@ export default { }, { - type: 'divider' + type: "divider" }, - 'Cards 渲染类型
', + "Cards 渲染类型
", { - type: 'divider' + type: "divider" }, { - type: 'picker', - name: 'type7', + type: "picker", + name: "type7", joinValues: true, - valueField: 'id', - labelField: 'engine', - label: '单选', - source: '/api/sample', - size: 'lg', - value: '4', + valueField: "id", + labelField: "engine", + label: "单选", + source: "/api/sample", + size: "lg", + value: "4", pickerSchema: { - mode: 'cards', - name: 'thelist', - quickSaveApi: '/api/sample/bulkUpdate', - quickSaveItemApi: '/api/sample/$id', + mode: "cards", + name: "thelist", + quickSaveApi: "/api/sample/bulkUpdate", + quickSaveItemApi: "/api/sample/$id", draggable: true, headerToolbar: { wrapWithPanel: false, - type: 'form', - className: 'text-right', - target: 'thelist', - mode: 'inline', + type: "form", + className: "text-right", + target: "thelist", + mode: "inline", controls: [ { - type: 'text', - name: 'keywords', + type: "text", + name: "keywords", addOn: { - type: 'submit', - label: '搜索', - level: 'primary', - icon: 'fa fa-search pull-left' + type: "submit", + label: "搜索", + level: "primary", + icon: "fa fa-search pull-left" } } ] }, card: { header: { - title: '$engine', - subTitle: '$platform', - subTitlePlaceholder: '暂无说明', + title: "$engine", + subTitle: "$platform", + subTitlePlaceholder: "暂无说明", avatar: - '<%= data.avatar || "http://bos.nj.bpc.baidu.com/showx/146bc2ce1b30f3824838f4208ad2663c" %>', - avatarClassName: 'pull-left thumb b-3x m-r' + '<%= data.avatar || "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1575350573496/4873dbfaf6a5.png" %>', + avatarClassName: "pull-left thumb b-3x m-r" }, actions: [ { - type: 'button', - label: '查看', - actionType: 'dialog', + type: "button", + label: "查看", + actionType: "dialog", dialog: { - title: '查看', + title: "查看", body: { - type: 'form', + type: "form", controls: [ { - type: 'static', - name: 'engine', - label: 'Engine' + type: "static", + name: "engine", + label: "Engine" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'browser', - label: 'Browser' + type: "static", + name: "browser", + label: "Browser" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'platform', - label: 'Platform(s)' + type: "static", + name: "platform", + label: "Platform(s)" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'version', - label: 'Engine version' + type: "static", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'grade', - label: 'CSS grade' + type: "static", + name: "grade", + label: "CSS grade" }, { - type: 'divider' + type: "divider" }, { - type: 'html', + type: "html", html: - '添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - label: '编辑', - actionType: 'dialog', + type: "button", + label: "编辑", + actionType: "dialog", dialog: { - title: '编辑', + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'grade', - label: 'CSS grade' + type: "text", + name: "grade", + label: "CSS grade" } ] } } }, { - type: 'button', - label: '删除', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + label: "删除", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], body: [ { - name: 'engine', - label: 'engine', + name: "engine", + label: "engine", sortable: true, quickEdit: true }, { - name: 'browser', - label: 'Browser' + name: "browser", + label: "Browser" }, { - name: 'platform', - label: 'Platform' + name: "platform", + label: "Platform" }, { - name: 'version', - label: 'version' + name: "version", + label: "version" } ] } @@ -1087,190 +1087,190 @@ export default { }, { - type: 'picker', - name: 'type8', + type: "picker", + name: "type8", joinValues: true, - valueField: 'id', - labelField: 'engine', - label: '多选', - source: '/api/sample', - size: 'lg', - value: '4,5', + valueField: "id", + labelField: "engine", + label: "多选", + source: "/api/sample", + size: "lg", + value: "4,5", multiple: true, pickerSchema: { - mode: 'cards', - name: 'thelist', - quickSaveApi: '/api/sample/bulkUpdate', - quickSaveItemApi: '/api/sample/$id', + mode: "cards", + name: "thelist", + quickSaveApi: "/api/sample/bulkUpdate", + quickSaveItemApi: "/api/sample/$id", draggable: true, headerToolbar: { wrapWithPanel: false, - type: 'form', - className: 'text-right', - target: 'thelist', - mode: 'inline', + type: "form", + className: "text-right", + target: "thelist", + mode: "inline", controls: [ { - type: 'text', - name: 'keywords', + type: "text", + name: "keywords", addOn: { - type: 'submit', - label: '搜索', - level: 'primary', - icon: 'fa fa-search pull-left' + type: "submit", + label: "搜索", + level: "primary", + icon: "fa fa-search pull-left" } } ] }, card: { header: { - title: '$engine', - subTitle: '$platform', - subTitlePlaceholder: '暂无说明', + title: "$engine", + subTitle: "$platform", + subTitlePlaceholder: "暂无说明", avatar: - '<%= data.avatar || "http://bos.nj.bpc.baidu.com/showx/146bc2ce1b30f3824838f4208ad2663c" %>', - avatarClassName: 'pull-left thumb b-3x m-r' + '<%= data.avatar || "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1575350573496/4873dbfaf6a5.png" %>', + avatarClassName: "pull-left thumb b-3x m-r" }, actions: [ { - type: 'button', - label: '查看', - actionType: 'dialog', + type: "button", + label: "查看", + actionType: "dialog", dialog: { - title: '查看', + title: "查看", body: { - type: 'form', + type: "form", controls: [ { - type: 'static', - name: 'engine', - label: 'Engine' + type: "static", + name: "engine", + label: "Engine" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'browser', - label: 'Browser' + type: "static", + name: "browser", + label: "Browser" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'platform', - label: 'Platform(s)' + type: "static", + name: "platform", + label: "Platform(s)" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'version', - label: 'Engine version' + type: "static", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'static', - name: 'grade', - label: 'CSS grade' + type: "static", + name: "grade", + label: "CSS grade" }, { - type: 'divider' + type: "divider" }, { - type: 'html', + type: "html", html: - '添加其他 Html 片段 需要支持变量替换(todo).
' + "添加其他 Html 片段 需要支持变量替换(todo).
" } ] } } }, { - type: 'button', - label: '编辑', - actionType: 'dialog', + type: "button", + label: "编辑", + actionType: "dialog", dialog: { - title: '编辑', + title: "编辑", body: { - type: 'form', - name: 'sample-edit-form', - api: '/api/sample/$id', + type: "form", + name: "sample-edit-form", + api: "/api/sample/$id", controls: [ { - type: 'text', - name: 'engine', - label: 'Engine', + type: "text", + name: "engine", + label: "Engine", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'browser', - label: 'Browser', + type: "text", + name: "browser", + label: "Browser", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'platform', - label: 'Platform(s)', + type: "text", + name: "platform", + label: "Platform(s)", required: true }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'version', - label: 'Engine version' + type: "text", + name: "version", + label: "Engine version" }, { - type: 'divider' + type: "divider" }, { - type: 'text', - name: 'grade', - label: 'CSS grade' + type: "text", + name: "grade", + label: "CSS grade" } ] } } }, { - type: 'button', - label: '删除', - actionType: 'ajax', - confirmText: '您确认要删除?', - api: 'delete:/api/sample/$id' + type: "button", + label: "删除", + actionType: "ajax", + confirmText: "您确认要删除?", + api: "delete:/api/sample/$id" } ], body: [ { - name: 'engine', - label: 'engine', + name: "engine", + label: "engine", sortable: true, quickEdit: true }, { - name: 'browser', - label: 'Browser' + name: "browser", + label: "Browser" }, { - name: 'platform', - label: 'Platform' + name: "platform", + label: "Platform" }, { - name: 'version', - label: 'version' + name: "version", + label: "version" } ] } diff --git a/examples/components/Video.jsx b/examples/components/Video.jsx index 0330d44a..123d1c2a 100644 --- a/examples/components/Video.jsx +++ b/examples/components/Video.jsx @@ -1,14 +1,16 @@ export default { - $schema: 'https://houtai.baidu.com/v2/schemas/page.json#', - title: '视频播放器', + $schema: "https://houtai.baidu.com/v2/schemas/page.json#", + title: "视频播放器", body: [ '另外还支持直播流, flv 和 hls 格式
', { - type: 'video', + type: "video", autoPlay: false, rates: [1.0, 1.5, 2.0], - src: 'https://media.w3.org/2010/05/sintel/trailer_hd.mp4', - poster: 'https://video-react.js.org/assets/poster.png' + src: + "https://amis.bj.bcebos.com/amis/2019-12/1577157317579/trailer_hd.mp4", + poster: + "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png" } ] }; diff --git a/mock/crud/list.js b/mock/crud/list.js index d6551266..43054176 100644 --- a/mock/crud/list.js +++ b/mock/crud/list.js @@ -1,58 +1,68 @@ -const faker = require('faker'); +const faker = require("faker"); function repeat(fn, times = 10) { - let arr = []; - while (times--) { - arr.push(fn()); - } + let arr = []; + while (times--) { + arr.push(fn()); + } - return arr; + return arr; } module.exports = function(req, res) { - res.json({ - status: 0, - msg: '', - data: repeat(() => ({ - id: '{{random.number}}', - text: '{{address.city}}', - progress: Math.round(Math.random() * 100), - type: Math.round(Math.random() * 5), - boolean: Math.random() > 0.5 ? true : false, - // boolean: ['pending', 'success', 'fail', 'queue', 'schedule'][Math.floor(Math.random()*5)], - list: repeat(() => ({ - title: '{{name.title}}', - description: '{{lorem.words}}' - }), Math.round(Math.random() * 10)), - audio: 'https://news-bos.cdn.bcebos.com/mvideo/%E7%9A%87%E5%90%8E%E5%A4%A7%E9%81%93%E4%B8%9C.aac', - carousel: [ - { - image: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg' - }, - { - html: '