Skip to content

feat(): support editor for eo-date-picker #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bricks/form/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ import "./time-picker/index.js";
import "./date-picker/index.js";
import "./time-range-picker/index.js";
import "./color-picker/index.js";
import "./editors/index.js";
222 changes: 222 additions & 0 deletions bricks/form/src/editors/eo-date-picker/eoDatePicker.schema.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
export const eoDatePickerSchema = {

Check warning on line 1 in bricks/form/src/editors/eo-date-picker/eoDatePicker.schema.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-date-picker/eoDatePicker.schema.tsx#L1

Added line #L1 was not covered by tests
name: "layout",
type: "void",
component: {
name: "FormLayout",
props: {
layout: "vertical",
},
},
children: [
{
name: "categoryTitle_item",
type: "void",
decorator: {
name: "CategoryTitle",
props: {
text: "表单项",
},
},
},
{
name: "name",
title: "字段名",
type: "string",
},
{
name: "label",
title: "标签",
type: "string",
},
{
name: "value",
title: "值",
type: "string",
},
{
name: "disabled",
title: "禁用",
type: "boolean",
},
{
name: "notRender",
title: "隐藏表单项",
type: "boolean",
component: {
name: "Switch",
},
decorator: {
name: "FormItem",
props: {
layout: "horizontal",
tooltip:
"区别于通用的“隐藏”属性,隐藏表单项时,表单不仅不显示当前项,同时也不会校验当前项;通用隐藏仅仅是不显示,但仍会校验当前项。通常,您应选择此属性来隐藏表单项。",
},
},
},
{
name: "placeholder",
title: "占位文本",
type: "string",
},
{
name: "required",
title: "必填",
type: "boolean",
component: {
props: {
size: "small",
},
},
"x-reactions": [
{
target: "requiredValidatorText",
fulfill: {
state: {
visible: "{{$self.value}}",
},
},
},
],
},
{
name: "showTime",
title: "显示时间",
type: "boolean",
},
{
name: "format",
title: "显示预览格式",
type: "string",
},
{
name: "picker",
title: "选择器类型",
type: "string",
component: {
name: "Select",
props: {
options: ["date", "week", "month", "year", "quarter"].map((item) => ({

Check warning on line 99 in bricks/form/src/editors/eo-date-picker/eoDatePicker.schema.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-date-picker/eoDatePicker.schema.tsx#L99

Added line #L99 was not covered by tests
label: item,
value: item,
})),
},
},
},
{
name: "futureDateDisabled",
title: "不可选择未来的日期",
type: "boolean",
},
{
name: "disabledDate",
title: "禁用日期",
type: "string",
component: "CodeEditor",
decorator: "FormItemWithoutAdvanced",
},
{
name: "useFastSelectBtn",
title: "快速选项",
type: "boolean",
},
{
name: "categoryTitle_itemStyle",
type: "void",
decorator: {
name: "CategoryTitle",
props: {
text: "表单项样式",
},
},
},
{
name: "labelAlign",
title: "标签对齐方式",
type: "string",
decorator: {
name: "FormItem",
props: {
layout: "horizontal",
},
},
enum: [
{
label: "左对齐",
value: "left",
},
{
label: "右对齐",
value: "right",
},
],
component: {
name: "Radio.Group",
props: {
size: "small",
optionType: "button",
defaultValue: "left",
},
},
},
{
name: "labelColor",
title: "标签颜色",
type: "string",
component: "ColorPicker",
},
{
name: "labelBold",
title: "标签加粗",
type: "boolean",
},
{
name: "labelTooltip",
title: "标签提示",
type: "string",
},
{
name: "labelCol",
title: "标签布局",
component: {
name: "CodeEditor",
},
decorator: "FormItemWithoutAdvanced",
},
{
name: "labelBrick",
title: "标签构件",
component: {
name: "CodeEditor",
},
decorator: "FormItemWithoutAdvanced",
},
{
name: "inputBoxStyle",
title: "输入框样式",
type: "string",
component: {
name: "CodeEditor",
},
decorator: "FormItemWithoutAdvanced",
},
{
name: "wrapperCol",
title: "控件布局",
type: "string",
component: {
name: "CodeEditor",
},
decorator: "FormItemWithoutAdvanced",
},
{
name: "helpBrick",
title: "帮助构件",
type: "string",
component: {
name: "CodeEditor",
},
decorator: "FormItemWithoutAdvanced",
},
],
};
19 changes: 19 additions & 0 deletions bricks/form/src/editors/eo-date-picker/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type _React from "react";
import { customEditors } from "@next-core/runtime";
import type { EditorComponentProps } from "@next-shared/property-editor";
import { eoDatePickerSchema } from "./eoDatePicker.schema";

function EoDatePickerComponentFactory(React: typeof _React) {
return function EoDatePickerComponent(

Check warning on line 7 in bricks/form/src/editors/eo-date-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-date-picker/index.tsx#L6-L7

Added lines #L6 - L7 were not covered by tests
props: EditorComponentProps
): React.ReactElement {
const { SchemaFieldComponent, formilySchemaFormatter, scope } = props;

Check warning on line 10 in bricks/form/src/editors/eo-date-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-date-picker/index.tsx#L10

Added line #L10 was not covered by tests

return React.createElement(SchemaFieldComponent, {

Check warning on line 12 in bricks/form/src/editors/eo-date-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-date-picker/index.tsx#L12

Added line #L12 was not covered by tests
schema: formilySchemaFormatter(eoDatePickerSchema as any),
scope,
});
};
}

customEditors.define("eo-date-picker", EoDatePickerComponentFactory);

Check warning on line 19 in bricks/form/src/editors/eo-date-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-date-picker/index.tsx#L19

Added line #L19 was not covered by tests
82 changes: 82 additions & 0 deletions bricks/form/src/editors/eo-time-picker/eoTimePicker.schema.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export const EoTimePickerSchema = {

Check warning on line 1 in bricks/form/src/editors/eo-time-picker/eoTimePicker.schema.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-time-picker/eoTimePicker.schema.tsx#L1

Added line #L1 was not covered by tests
name: "layout",
type: "void",
component: {
name: "FormLayout",
props: {
layout: "vertical",
},
},
children: [
{
name: "categoryTitle_item",
type: "void",
decorator: {
name: "CategoryTitle",
props: {
text: "表单项",
},
},
},
{
name: "name",
title: "字段名",
type: "string",
},
{
name: "label",
title: "标签",
type: "string",
},
{
name: "value",
title: "值",
type: "string",
},
{
name: "disabled",
title: "禁用",
type: "boolean",
},
{
name: "notRender",
title: "隐藏表单项",
type: "boolean",
component: {
name: "Switch",
},
decorator: {
name: "FormItem",
props: {
layout: "horizontal",
tooltip:
"区别于通用的“隐藏”属性,隐藏表单项时,表单不仅不显示当前项,同时也不会校验当前项;通用隐藏仅仅是不显示,但仍会校验当前项。通常,您应选择此属性来隐藏表单项。",
},
},
},
{
name: "required",
title: "必填",
type: "boolean",
component: {
props: {
size: "small",
},
},
},
{
name: "placeholder",
title: "占位说明",
type: "string",
},
{
name: "configProps",
title: "Antd timePicker 属性",
type: "string",
component: {
name: "CodeEditor",
},
decorator: "FormItemWithoutAdvanced",
},
],
};
19 changes: 19 additions & 0 deletions bricks/form/src/editors/eo-time-picker/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type _React from "react";
import { customEditors } from "@next-core/runtime";
import type { EditorComponentProps } from "@next-shared/property-editor";
import { EoTimePickerSchema } from "./eoTimePicker.schema";

function EoTimePickerComponentFactory(React: typeof _React) {
return function EoTimePickerComponent(

Check warning on line 7 in bricks/form/src/editors/eo-time-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-time-picker/index.tsx#L6-L7

Added lines #L6 - L7 were not covered by tests
props: EditorComponentProps
): React.ReactElement {
const { SchemaFieldComponent, formilySchemaFormatter, scope } = props;

Check warning on line 10 in bricks/form/src/editors/eo-time-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-time-picker/index.tsx#L10

Added line #L10 was not covered by tests

return React.createElement(SchemaFieldComponent, {

Check warning on line 12 in bricks/form/src/editors/eo-time-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-time-picker/index.tsx#L12

Added line #L12 was not covered by tests
schema: formilySchemaFormatter(EoTimePickerSchema as any),
scope,
});
};
}

customEditors.define("eo-time-picker", EoTimePickerComponentFactory);

Check warning on line 19 in bricks/form/src/editors/eo-time-picker/index.tsx

View check run for this annotation

Codecov / codecov/patch

bricks/form/src/editors/eo-time-picker/index.tsx#L19

Added line #L19 was not covered by tests
2 changes: 2 additions & 0 deletions bricks/form/src/editors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./eo-date-picker/index.js";
import "./eo-time-picker/index.js";
Loading