@yimoka/designable-playground 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/demo/components/Alert/index.d.ts +4 -0
- package/dist/demo/components/Alert/index.js +41 -0
- package/dist/demo/components/ArrayCards/index.d.ts +17 -0
- package/dist/demo/components/ArrayCards/index.js +62 -0
- package/dist/demo/components/ArrayList/index.d.ts +25 -0
- package/dist/demo/components/ArrayList/index.js +143 -0
- package/dist/demo/components/ArrayTable/index.d.ts +39 -0
- package/dist/demo/components/ArrayTable/index.js +247 -0
- package/dist/demo/components/AutoComplete/index.d.ts +4 -0
- package/dist/demo/components/AutoComplete/index.js +52 -0
- package/dist/demo/components/Avatar/index.d.ts +4 -0
- package/dist/demo/components/Avatar/index.js +34 -0
- package/dist/demo/components/Badge/index.d.ts +4 -0
- package/dist/demo/components/Badge/index.js +35 -0
- package/dist/demo/components/Button/index.d.ts +4 -0
- package/dist/demo/components/Button/index.js +86 -0
- package/dist/demo/components/Card/index.d.ts +4 -0
- package/dist/demo/components/Card/index.js +72 -0
- package/dist/demo/components/Carousel/index.d.ts +4 -0
- package/dist/demo/components/Carousel/index.js +33 -0
- package/dist/demo/components/Cascader/index.d.ts +4 -0
- package/dist/demo/components/Cascader/index.js +60 -0
- package/dist/demo/components/Checkbox/index.d.ts +8 -0
- package/dist/demo/components/Checkbox/index.js +55 -0
- package/dist/demo/components/ColorPicker/index.d.ts +4 -0
- package/dist/demo/components/ColorPicker/index.js +38 -0
- package/dist/demo/components/DatePicker/index.d.ts +4 -0
- package/dist/demo/components/DatePicker/index.js +61 -0
- package/dist/demo/components/DateRangePicker/index.d.ts +4 -0
- package/dist/demo/components/DateRangePicker/index.js +58 -0
- package/dist/demo/components/Divider/index.d.ts +4 -0
- package/dist/demo/components/Divider/index.js +39 -0
- package/dist/demo/components/Empty/index.d.ts +4 -0
- package/dist/demo/components/Empty/index.js +29 -0
- package/dist/demo/components/Flex/index.d.ts +4 -0
- package/dist/demo/components/Flex/index.js +51 -0
- package/dist/demo/components/Form/index.d.ts +21 -0
- package/dist/demo/components/Form/index.js +116 -0
- package/dist/demo/components/FormCollapse/index.d.ts +28 -0
- package/dist/demo/components/FormCollapse/index.js +164 -0
- package/dist/demo/components/FormGrid/index.d.ts +22 -0
- package/dist/demo/components/FormGrid/index.js +134 -0
- package/dist/demo/components/FormItem/index.d.ts +14 -0
- package/dist/demo/components/FormItem/index.js +33 -0
- package/dist/demo/components/FormLayout/index.d.ts +26 -0
- package/dist/demo/components/FormLayout/index.js +260 -0
- package/dist/demo/components/FormTab/index.d.ts +15 -0
- package/dist/demo/components/FormTab/index.js +186 -0
- package/dist/demo/components/GridCol/index.d.ts +4 -0
- package/dist/demo/components/GridCol/index.js +53 -0
- package/dist/demo/components/GridRow/index.d.ts +4 -0
- package/dist/demo/components/GridRow/index.js +70 -0
- package/dist/demo/components/HTMLContent/index.d.ts +4 -0
- package/dist/demo/components/HTMLContent/index.js +34 -0
- package/dist/demo/components/I18nEditor/index.d.ts +8 -0
- package/dist/demo/components/I18nEditor/index.js +64 -0
- package/dist/demo/components/Image/index.d.ts +4 -0
- package/dist/demo/components/Image/index.js +36 -0
- package/dist/demo/components/Input/index.d.ts +4 -0
- package/dist/demo/components/Input/index.js +36 -0
- package/dist/demo/components/InputSearch/index.d.ts +4 -0
- package/dist/demo/components/InputSearch/index.js +40 -0
- package/dist/demo/components/Link/index.d.ts +4 -0
- package/dist/demo/components/Link/index.js +37 -0
- package/dist/demo/components/Mentions/index.d.ts +4 -0
- package/dist/demo/components/Mentions/index.js +41 -0
- package/dist/demo/components/NumberPicker/index.d.ts +6 -0
- package/dist/demo/components/NumberPicker/index.js +63 -0
- package/dist/demo/components/ObjectContainer/index.d.ts +14 -0
- package/dist/demo/components/ObjectContainer/index.js +46 -0
- package/dist/demo/components/Password/index.d.ts +6 -0
- package/dist/demo/components/Password/index.js +44 -0
- package/dist/demo/components/QRCode/index.d.ts +4 -0
- package/dist/demo/components/QRCode/index.js +34 -0
- package/dist/demo/components/Radio/index.d.ts +6 -0
- package/dist/demo/components/Radio/index.js +49 -0
- package/dist/demo/components/Rate/index.d.ts +6 -0
- package/dist/demo/components/Rate/index.js +43 -0
- package/dist/demo/components/Search/index.d.ts +4 -0
- package/dist/demo/components/Search/index.js +42 -0
- package/dist/demo/components/SearchSelect/index.d.ts +4 -0
- package/dist/demo/components/SearchSelect/index.js +53 -0
- package/dist/demo/components/Select/index.d.ts +4 -0
- package/dist/demo/components/Select/index.js +59 -0
- package/dist/demo/components/Slider/index.d.ts +6 -0
- package/dist/demo/components/Slider/index.js +61 -0
- package/dist/demo/components/Space/index.d.ts +9 -0
- package/dist/demo/components/Space/index.js +61 -0
- package/dist/demo/components/Statistic/index.d.ts +4 -0
- package/dist/demo/components/Statistic/index.js +33 -0
- package/dist/demo/components/Switch/index.d.ts +4 -0
- package/dist/demo/components/Switch/index.js +49 -0
- package/dist/demo/components/Tabs/index.d.ts +10 -0
- package/dist/demo/components/Tabs/index.js +181 -0
- package/dist/demo/components/Tag/index.d.ts +4 -0
- package/dist/demo/components/Tag/index.js +33 -0
- package/dist/demo/components/Text/index.d.ts +11 -0
- package/dist/demo/components/Text/index.js +64 -0
- package/dist/demo/components/TextArea/index.d.ts +6 -0
- package/dist/demo/components/TextArea/index.js +43 -0
- package/dist/demo/components/TimePicker/index.d.ts +4 -0
- package/dist/demo/components/TimePicker/index.js +69 -0
- package/dist/demo/components/TimeRangePicker/index.d.ts +4 -0
- package/dist/demo/components/TimeRangePicker/index.js +68 -0
- package/dist/demo/components/Transfer/index.d.ts +6 -0
- package/dist/demo/components/Transfer/index.js +59 -0
- package/dist/demo/components/TreeSelect/index.d.ts +4 -0
- package/dist/demo/components/TreeSelect/index.js +63 -0
- package/dist/demo/components/Upload/index.d.ts +8 -0
- package/dist/demo/components/Upload/index.js +64 -0
- package/dist/demo/components/index.d.ts +55 -0
- package/dist/demo/components/index.js +55 -0
- package/dist/demo/components/shared.d.ts +143 -0
- package/dist/demo/components/shared.js +315 -0
- package/dist/src/Playground.d.ts +3 -0
- package/dist/src/Playground.js +304 -0
- package/dist/src/antd/AntdPlayground.d.ts +16 -0
- package/dist/src/antd/AntdPlayground.js +136 -0
- package/dist/src/antd/index.d.ts +1 -0
- package/dist/src/antd/index.js +1 -0
- package/dist/src/context.d.ts +4 -0
- package/dist/src/context.js +13 -0
- package/dist/src/examples/index.d.ts +267 -0
- package/dist/src/examples/index.js +824 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/remoteSchemaAdapter.d.ts +53 -0
- package/dist/src/hooks/remoteSchemaAdapter.js +262 -0
- package/dist/src/hooks/usePlayground.d.ts +38 -0
- package/dist/src/hooks/usePlayground.js +642 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.d.ts +135 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.js +736 -0
- package/dist/src/hooks/useSchemaEditorDraft.d.ts +4 -0
- package/dist/src/hooks/useSchemaEditorDraft.js +44 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.d.ts +59 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.js +161 -0
- package/dist/src/layouts/PlaygroundLayout/index.d.ts +7 -0
- package/dist/src/layouts/PlaygroundLayout/index.js +443 -0
- package/dist/src/layouts/index.d.ts +1 -0
- package/dist/src/layouts/index.js +1 -0
- package/dist/src/panels/CompositePanel/index.d.ts +6 -0
- package/dist/src/panels/CompositePanel/index.js +139 -0
- package/dist/src/panels/ToolbarPanel/index.d.ts +3 -0
- package/dist/src/panels/ToolbarPanel/index.js +24 -0
- package/dist/src/panels/index.d.ts +2 -0
- package/dist/src/panels/index.js +2 -0
- package/dist/src/presets/antd.d.ts +19 -0
- package/dist/src/presets/antd.js +112 -0
- package/dist/src/presets/index.d.ts +4 -0
- package/dist/src/presets/index.js +3 -0
- package/dist/src/presets/runtime-array-helpers.d.ts +8 -0
- package/dist/src/presets/runtime-array-helpers.js +147 -0
- package/dist/src/presets/runtime-component-props.d.ts +3 -0
- package/dist/src/presets/runtime-component-props.js +5 -0
- package/dist/src/presets/runtime-components.d.ts +5 -0
- package/dist/src/presets/runtime-components.js +419 -0
- package/dist/src/presets/runtime-form-components.d.ts +9 -0
- package/dist/src/presets/runtime-form-components.js +94 -0
- package/dist/src/presets/scenario-catalog.d.ts +6 -0
- package/dist/src/presets/scenario-catalog.js +128 -0
- package/dist/src/presets/scenarios.d.ts +52 -0
- package/dist/src/presets/scenarios.js +603 -0
- package/dist/src/runtime/actions.d.ts +19 -0
- package/dist/src/runtime/actions.js +307 -0
- package/dist/src/runtime/contracts.d.ts +149 -0
- package/dist/src/runtime/contracts.js +1 -0
- package/dist/src/runtime/document-bindings.d.ts +3 -0
- package/dist/src/runtime/document-bindings.js +101 -0
- package/dist/src/runtime/document-core.d.ts +57 -0
- package/dist/src/runtime/document-core.js +379 -0
- package/dist/src/runtime/document-entity.d.ts +12 -0
- package/dist/src/runtime/document-entity.js +351 -0
- package/dist/src/runtime/document-expressions.d.ts +35 -0
- package/dist/src/runtime/document-expressions.js +346 -0
- package/dist/src/runtime/document-security.d.ts +34 -0
- package/dist/src/runtime/document-security.js +538 -0
- package/dist/src/runtime/document.d.ts +16 -0
- package/dist/src/runtime/document.js +212 -0
- package/dist/src/runtime/environment.d.ts +16 -0
- package/dist/src/runtime/environment.js +76 -0
- package/dist/src/runtime/i18n-schema.d.ts +36 -0
- package/dist/src/runtime/i18n-schema.js +338 -0
- package/dist/src/runtime/i18n.d.ts +25 -0
- package/dist/src/runtime/i18n.js +447 -0
- package/dist/src/runtime/index.d.ts +8 -0
- package/dist/src/runtime/index.js +8 -0
- package/dist/src/runtime/navigation.d.ts +5 -0
- package/dist/src/runtime/navigation.js +43 -0
- package/dist/src/runtime/playground.d.ts +30 -0
- package/dist/src/runtime/playground.js +243 -0
- package/dist/src/runtime/preview-boundaries.d.ts +13 -0
- package/dist/src/runtime/preview-boundaries.js +43 -0
- package/dist/src/runtime/preview.d.ts +44 -0
- package/dist/src/runtime/preview.js +574 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.d.ts +10 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.js +21 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.d.ts +15 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.js +65 -0
- package/dist/src/runtime/templates.d.ts +1560 -0
- package/dist/src/runtime/templates.js +508 -0
- package/dist/src/runtime/website-contact-template.d.ts +1 -0
- package/dist/src/runtime/website-contact-template.js +66 -0
- package/dist/src/runtime/website-template-shared.d.ts +14 -0
- package/dist/src/runtime/website-template-shared.js +210 -0
- package/dist/src/runtime/website-templates.d.ts +5 -0
- package/dist/src/runtime/website-templates.js +976 -0
- package/dist/src/shared/clipboard.d.ts +4 -0
- package/dist/src/shared/clipboard.js +56 -0
- package/dist/src/shared/componentRegistry.d.ts +133 -0
- package/dist/src/shared/componentRegistry.js +381 -0
- package/dist/src/shared/formilyCompatibility.d.ts +8 -0
- package/dist/src/shared/formilyCompatibility.js +40 -0
- package/dist/src/shared/index.d.ts +6 -0
- package/dist/src/shared/index.js +6 -0
- package/dist/src/shared/productionAcceptance.d.ts +63 -0
- package/dist/src/shared/productionAcceptance.js +201 -0
- package/dist/src/shared/schema-options.d.ts +16 -0
- package/dist/src/shared/schema-options.js +138 -0
- package/dist/src/shared/schema.d.ts +63 -0
- package/dist/src/shared/schema.js +627 -0
- package/dist/src/shared/styleSecurity.d.ts +2 -0
- package/dist/src/shared/styleSecurity.js +35 -0
- package/dist/src/transformers/formily.d.ts +34 -0
- package/dist/src/transformers/formily.js +943 -0
- package/dist/src/transformers/index.d.ts +1 -0
- package/dist/src/transformers/index.js +1 -0
- package/dist/src/types.d.ts +186 -0
- package/dist/src/types.js +1 -0
- package/dist/src/widgets/ActionsWidget/index.d.ts +3 -0
- package/dist/src/widgets/ActionsWidget/index.js +10 -0
- package/dist/src/widgets/ComponentTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/ComponentTreeWidget/index.js +333 -0
- package/dist/src/widgets/NodeActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/NodeActionsWidget/index.js +125 -0
- package/dist/src/widgets/OutlineTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/OutlineTreeWidget/index.js +432 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.d.ts +32 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.js +79 -0
- package/dist/src/widgets/PreviewWidget/index.d.ts +2 -0
- package/dist/src/widgets/PreviewWidget/index.js +1566 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.d.ts +18 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.js +356 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.d.ts +18 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.js +438 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.d.ts +39 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.js +475 -0
- package/dist/src/widgets/ResourceWidget/index.d.ts +3 -0
- package/dist/src/widgets/ResourceWidget/index.js +491 -0
- package/dist/src/widgets/SchemaCodeView/index.d.ts +7 -0
- package/dist/src/widgets/SchemaCodeView/index.js +225 -0
- package/dist/src/widgets/SchemaEditorWidget/index.d.ts +10 -0
- package/dist/src/widgets/SchemaEditorWidget/index.js +484 -0
- package/dist/src/widgets/SettingsPanelWidget/index.d.ts +3 -0
- package/dist/src/widgets/SettingsPanelWidget/index.js +190 -0
- package/dist/src/widgets/StorageActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/StorageActionsWidget/index.js +284 -0
- package/dist/src/widgets/index.d.ts +13 -0
- package/dist/src/widgets/index.js +13 -0
- package/package.json +100 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Empty as AntdEmpty } from '@yimoka/antd';
|
|
3
|
+
import { createBehavior, createResource } from '@yimoka/designable-core';
|
|
4
|
+
import { createContainerPropsSchema, createInputProperty, createSelectProperty, splitDesignableStyleProps, } from "../shared.js";
|
|
5
|
+
export const Empty = (props) => {
|
|
6
|
+
const { componentProps: emptyProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
7
|
+
return (_jsx("div", { ...designerProps, style: { width: '100%', ...wrapperStyle }, children: _jsx(AntdEmpty, { ...emptyProps }) }));
|
|
8
|
+
};
|
|
9
|
+
Empty.Behavior = createBehavior({
|
|
10
|
+
name: 'Empty',
|
|
11
|
+
selector: node => node.componentName === 'Empty',
|
|
12
|
+
designerProps: {
|
|
13
|
+
propsSchema: createContainerPropsSchema({
|
|
14
|
+
description: createInputProperty('描述'),
|
|
15
|
+
image: createSelectProperty('图片样式', ['default', 'simple', null]),
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
Empty.Resource = createResource({
|
|
20
|
+
icon: '',
|
|
21
|
+
elements: [
|
|
22
|
+
{
|
|
23
|
+
componentName: 'Empty',
|
|
24
|
+
props: {
|
|
25
|
+
description: '暂无数据',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Flex as AntdFlex } from '@yimoka/antd';
|
|
3
|
+
import { createBehavior, createResource } from '@yimoka/designable-core';
|
|
4
|
+
import { DroppableWidget } from '@yimoka/designable-react';
|
|
5
|
+
import { createContainerPropsSchema, createInputProperty, createNumberProperty, createSelectProperty, createSwitchProperty, splitDesignableStyleProps, } from "../shared.js";
|
|
6
|
+
export const Flex = (props) => {
|
|
7
|
+
const { componentProps: flexProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
8
|
+
const { children, ...restFlexProps } = flexProps;
|
|
9
|
+
return (_jsx(DroppableWidget, { ...designerProps, placeholder: false, style: wrapperStyle, children: _jsx(AntdFlex, { ...restFlexProps, style: { minHeight: 40 }, children: children }) }));
|
|
10
|
+
};
|
|
11
|
+
Flex.Behavior = createBehavior({
|
|
12
|
+
name: 'Flex',
|
|
13
|
+
selector: node => node.componentName === 'Flex',
|
|
14
|
+
designerProps: {
|
|
15
|
+
droppable: true,
|
|
16
|
+
propsSchema: createContainerPropsSchema({
|
|
17
|
+
vertical: createSwitchProperty('垂直方向'),
|
|
18
|
+
wrap: createSwitchProperty('自动换行'),
|
|
19
|
+
gap: createNumberProperty('间距'),
|
|
20
|
+
flex: createInputProperty('弹性值'),
|
|
21
|
+
justify: createSelectProperty('主轴对齐', ['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly', null]),
|
|
22
|
+
align: createSelectProperty('交叉轴对齐', ['flex-start', 'center', 'flex-end', 'stretch', 'baseline', null]),
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
Flex.Resource = createResource({
|
|
27
|
+
icon: '',
|
|
28
|
+
elements: [
|
|
29
|
+
{
|
|
30
|
+
componentName: 'Flex',
|
|
31
|
+
props: {
|
|
32
|
+
gap: 12,
|
|
33
|
+
wrap: true,
|
|
34
|
+
},
|
|
35
|
+
children: [
|
|
36
|
+
{
|
|
37
|
+
componentName: 'Text',
|
|
38
|
+
props: {
|
|
39
|
+
content: '内容一',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
componentName: 'Text',
|
|
44
|
+
props: {
|
|
45
|
+
content: '内容二',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Form as AntdForm } from '@yimoka/antd';
|
|
2
|
+
import { DnFC } from '@yimoka/designable-react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
type FormCol = React.ComponentProps<typeof AntdForm>['labelCol'];
|
|
5
|
+
export interface IFormProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
colon?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
labelAlign?: 'left' | 'right';
|
|
10
|
+
labelCol?: number | FormCol;
|
|
11
|
+
labelWrap?: boolean;
|
|
12
|
+
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
13
|
+
name?: string;
|
|
14
|
+
requiredMark?: boolean | 'optional' | 'true' | 'false';
|
|
15
|
+
size?: 'large' | 'middle' | 'small';
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
title?: React.ReactNode;
|
|
18
|
+
wrapperCol?: number | FormCol;
|
|
19
|
+
}
|
|
20
|
+
export declare const Form: DnFC<IFormProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Form as AntdForm } from '@yimoka/antd';
|
|
3
|
+
import { createBehavior, createResource } from '@yimoka/designable-core';
|
|
4
|
+
import { DroppableWidget } from '@yimoka/designable-react';
|
|
5
|
+
import { createFieldPropsSchema, designPlaceholderStyle, hasDesignerProps, sizeProperty, splitDesignableStyleProps, } from "../shared.js";
|
|
6
|
+
const getCol = (col) => {
|
|
7
|
+
if (typeof col === 'number') {
|
|
8
|
+
return col > 0 ? { span: col } : undefined;
|
|
9
|
+
}
|
|
10
|
+
return col;
|
|
11
|
+
};
|
|
12
|
+
const getRequiredMark = (value) => {
|
|
13
|
+
if (value === 'true')
|
|
14
|
+
return true;
|
|
15
|
+
if (value === 'false')
|
|
16
|
+
return false;
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
export const Form = (props) => {
|
|
20
|
+
const { componentProps: formProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
21
|
+
const { children, labelCol = 6, layout = 'horizontal', requiredMark, title, wrapperCol = 16, ...restFormProps } = formProps;
|
|
22
|
+
const isDesignMode = hasDesignerProps(designerProps);
|
|
23
|
+
return (_jsx(DroppableWidget, { ...designerProps, placeholder: false, style: wrapperStyle, children: _jsxs(AntdForm, { ...restFormProps, labelCol: getCol(labelCol), layout: layout, requiredMark: getRequiredMark(requiredMark), style: {
|
|
24
|
+
background: '#fff',
|
|
25
|
+
border: '1px solid #d9e4f2',
|
|
26
|
+
borderRadius: 6,
|
|
27
|
+
minHeight: 96,
|
|
28
|
+
padding: 16,
|
|
29
|
+
width: '100%',
|
|
30
|
+
}, wrapperCol: getCol(wrapperCol), children: [title ? (_jsx("div", { style: {
|
|
31
|
+
color: '#253040',
|
|
32
|
+
fontSize: 14,
|
|
33
|
+
fontWeight: 600,
|
|
34
|
+
marginBottom: 12,
|
|
35
|
+
}, children: title })) : null, children || (isDesignMode ? (_jsx("div", { style: designPlaceholderStyle, children: "\u62D6\u5165\u5B57\u6BB5\u5F00\u59CB\u8BBE\u8BA1\u8868\u5355" })) : null)] }) }));
|
|
36
|
+
};
|
|
37
|
+
Form.Behavior = createBehavior({
|
|
38
|
+
name: 'Form',
|
|
39
|
+
selector: node => node.componentName === 'Form',
|
|
40
|
+
designerProps: {
|
|
41
|
+
droppable: true,
|
|
42
|
+
propsSchema: createFieldPropsSchema({
|
|
43
|
+
layout: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
enum: ['horizontal', 'vertical', 'inline'],
|
|
46
|
+
'x-decorator': 'FormItem',
|
|
47
|
+
'x-component': 'Select',
|
|
48
|
+
title: '布局',
|
|
49
|
+
},
|
|
50
|
+
labelCol: {
|
|
51
|
+
type: 'number',
|
|
52
|
+
'x-decorator': 'FormItem',
|
|
53
|
+
'x-component': 'NumberPicker',
|
|
54
|
+
title: '标签栅格',
|
|
55
|
+
},
|
|
56
|
+
wrapperCol: {
|
|
57
|
+
type: 'number',
|
|
58
|
+
'x-decorator': 'FormItem',
|
|
59
|
+
'x-component': 'NumberPicker',
|
|
60
|
+
title: '控件栅格',
|
|
61
|
+
},
|
|
62
|
+
labelAlign: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
enum: ['left', 'right'],
|
|
65
|
+
'x-decorator': 'FormItem',
|
|
66
|
+
'x-component': 'Select',
|
|
67
|
+
title: '标签对齐',
|
|
68
|
+
},
|
|
69
|
+
colon: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
'x-decorator': 'FormItem',
|
|
72
|
+
'x-component': 'Switch',
|
|
73
|
+
title: '显示冒号',
|
|
74
|
+
},
|
|
75
|
+
labelWrap: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
'x-decorator': 'FormItem',
|
|
78
|
+
'x-component': 'Switch',
|
|
79
|
+
title: '标签换行',
|
|
80
|
+
},
|
|
81
|
+
requiredMark: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: [true, false, 'optional'],
|
|
84
|
+
'x-decorator': 'FormItem',
|
|
85
|
+
'x-component': 'Select',
|
|
86
|
+
title: '必填标记',
|
|
87
|
+
},
|
|
88
|
+
disabled: {
|
|
89
|
+
type: 'boolean',
|
|
90
|
+
'x-decorator': 'FormItem',
|
|
91
|
+
'x-component': 'Switch',
|
|
92
|
+
title: '禁用',
|
|
93
|
+
},
|
|
94
|
+
size: sizeProperty,
|
|
95
|
+
}),
|
|
96
|
+
defaultProps: {
|
|
97
|
+
labelCol: 6,
|
|
98
|
+
layout: 'horizontal',
|
|
99
|
+
wrapperCol: 16,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
Form.Resource = createResource({
|
|
104
|
+
icon: 'FormOutlined',
|
|
105
|
+
elements: [
|
|
106
|
+
{
|
|
107
|
+
componentName: 'Form',
|
|
108
|
+
props: {
|
|
109
|
+
name: 'form',
|
|
110
|
+
title: '表单',
|
|
111
|
+
labelCol: 6,
|
|
112
|
+
wrapperCol: 16,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DnFC } from '@yimoka/designable-react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface IFormCollapseProps {
|
|
4
|
+
accordion?: boolean;
|
|
5
|
+
bordered?: boolean;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
collapsible?: 'header' | 'disabled';
|
|
8
|
+
ghost?: boolean;
|
|
9
|
+
items?: Array<{
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
collapsible?: IFormCollapsePanelProps['collapsible'];
|
|
12
|
+
extra?: React.ReactNode;
|
|
13
|
+
key: React.Key;
|
|
14
|
+
label?: React.ReactNode;
|
|
15
|
+
}>;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
export interface IFormCollapsePanelProps {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
collapsible?: 'header' | 'disabled';
|
|
21
|
+
extra?: React.ReactNode;
|
|
22
|
+
header?: React.ReactNode;
|
|
23
|
+
name?: string;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
title?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
export declare const FormCollapse: DnFC<IFormCollapseProps>;
|
|
28
|
+
export declare const FormCollapsePanel: DnFC<IFormCollapsePanelProps>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Collapse as AntdCollapse } from '@yimoka/antd';
|
|
3
|
+
import { createBehavior, createResource } from '@yimoka/designable-core';
|
|
4
|
+
import { DroppableWidget, useTreeNode } from '@yimoka/designable-react';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { createContainerPropsSchema, createValueProperty, designPlaceholderStyle, hasDesignerProps, splitDesignableStyleProps, } from "../shared.js";
|
|
7
|
+
const getPanelProps = (child) => (child.props && typeof child.props === 'object'
|
|
8
|
+
? child.props
|
|
9
|
+
: {});
|
|
10
|
+
const toReactNode = (value) => (React.isValidElement(value)
|
|
11
|
+
|| typeof value === 'string'
|
|
12
|
+
|| typeof value === 'number'
|
|
13
|
+
? value
|
|
14
|
+
: undefined);
|
|
15
|
+
const renderEditableHeader = (header, panelId) => {
|
|
16
|
+
if (header === undefined || header === null)
|
|
17
|
+
return undefined;
|
|
18
|
+
return (_jsx("span", { "data-content-editable": "header", "data-content-editable-node-id": panelId, children: header }));
|
|
19
|
+
};
|
|
20
|
+
const getPanelHeader = (nodeProps, panelProps) => (toReactNode(nodeProps.header)
|
|
21
|
+
?? toReactNode(nodeProps.title)
|
|
22
|
+
?? panelProps.header
|
|
23
|
+
?? panelProps.title);
|
|
24
|
+
const getPanelExtra = (nodeProps, panelProps) => (toReactNode(nodeProps.extra) ?? panelProps.extra);
|
|
25
|
+
const getPanelKey = (nodeProps, panelProps, childKey, index) => String(nodeProps.name ?? panelProps.name ?? childKey ?? `panel_${index + 1}`);
|
|
26
|
+
const getPanelCollapsible = (nodeProps, panelProps) => (nodeProps.collapsible ?? panelProps.collapsible);
|
|
27
|
+
const createCollapseItem = (child, panelNode, index) => {
|
|
28
|
+
const nodeProps = panelNode?.props ?? {};
|
|
29
|
+
const panelProps = getPanelProps(child);
|
|
30
|
+
const header = getPanelHeader(nodeProps, panelProps);
|
|
31
|
+
return {
|
|
32
|
+
key: getPanelKey(nodeProps, panelProps, child.key, index),
|
|
33
|
+
label: renderEditableHeader(header ?? `分组 ${index + 1}`, panelNode?.id),
|
|
34
|
+
extra: getPanelExtra(nodeProps, panelProps),
|
|
35
|
+
collapsible: getPanelCollapsible(nodeProps, panelProps),
|
|
36
|
+
children: child,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const createCollapseItems = (children, panelNodes) => (React.Children
|
|
40
|
+
.toArray(children)
|
|
41
|
+
.filter(React.isValidElement)
|
|
42
|
+
.map((child, index) => createCollapseItem(child, panelNodes?.[index], index)));
|
|
43
|
+
export const FormCollapse = (props) => {
|
|
44
|
+
const { componentProps: collapseProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
45
|
+
const { children, items: explicitItems, ...restCollapseProps } = collapseProps;
|
|
46
|
+
const node = useTreeNode();
|
|
47
|
+
const items = explicitItems ?? createCollapseItems(children, node?.children);
|
|
48
|
+
return (_jsx("div", { ...designerProps, style: wrapperStyle, children: _jsx(AntdCollapse, { ...restCollapseProps, items: items }) }));
|
|
49
|
+
};
|
|
50
|
+
export const FormCollapsePanel = (props) => {
|
|
51
|
+
const { componentProps: panelProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
52
|
+
const { children, header, title, } = panelProps;
|
|
53
|
+
const isDesignMode = hasDesignerProps(designerProps);
|
|
54
|
+
return (_jsx(DroppableWidget, { ...designerProps, placeholder: false, style: wrapperStyle, children: _jsx("div", { style: { minHeight: 56 }, children: children || (isDesignMode ? (_jsx("div", { style: designPlaceholderStyle, children: header ?? title ?? '分组内容' })) : null) }) }));
|
|
55
|
+
};
|
|
56
|
+
FormCollapse.Behavior = createBehavior({
|
|
57
|
+
name: 'FormCollapse',
|
|
58
|
+
selector: node => node.componentName === 'FormCollapse',
|
|
59
|
+
designerProps: {
|
|
60
|
+
droppable: true,
|
|
61
|
+
propsSchema: createContainerPropsSchema({
|
|
62
|
+
activeKey: createValueProperty('当前展开项', 'panel_1 或 ["panel_1"]'),
|
|
63
|
+
defaultActiveKey: createValueProperty('默认展开项', 'panel_1 或 ["panel_1"]'),
|
|
64
|
+
accordion: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
'x-decorator': 'FormItem',
|
|
67
|
+
'x-component': 'Switch',
|
|
68
|
+
title: '手风琴',
|
|
69
|
+
},
|
|
70
|
+
bordered: {
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
'x-decorator': 'FormItem',
|
|
73
|
+
'x-component': 'Switch',
|
|
74
|
+
title: '显示边框',
|
|
75
|
+
},
|
|
76
|
+
ghost: {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
'x-decorator': 'FormItem',
|
|
79
|
+
'x-component': 'Switch',
|
|
80
|
+
title: '透明背景',
|
|
81
|
+
},
|
|
82
|
+
collapsible: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
enum: ['header', 'disabled'],
|
|
85
|
+
'x-decorator': 'FormItem',
|
|
86
|
+
'x-component': 'Select',
|
|
87
|
+
title: '折叠触发',
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
FormCollapsePanel.Behavior = createBehavior({
|
|
93
|
+
name: 'FormCollapsePanel',
|
|
94
|
+
selector: node => node.componentName === 'FormCollapsePanel',
|
|
95
|
+
designerProps: {
|
|
96
|
+
droppable: true,
|
|
97
|
+
propsSchema: createContainerPropsSchema({
|
|
98
|
+
name: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
'x-decorator': 'FormItem',
|
|
101
|
+
'x-component': 'Input',
|
|
102
|
+
title: '标识',
|
|
103
|
+
},
|
|
104
|
+
header: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
'x-decorator': 'FormItem',
|
|
107
|
+
'x-component': 'Input',
|
|
108
|
+
title: '标题',
|
|
109
|
+
},
|
|
110
|
+
extra: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
'x-decorator': 'FormItem',
|
|
113
|
+
'x-component': 'Input',
|
|
114
|
+
title: '右侧内容',
|
|
115
|
+
},
|
|
116
|
+
collapsible: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
enum: ['header', 'disabled'],
|
|
119
|
+
'x-decorator': 'FormItem',
|
|
120
|
+
'x-component': 'Select',
|
|
121
|
+
title: '折叠触发',
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
FormCollapse.Resource = createResource({
|
|
127
|
+
icon: 'CaretRightOutlined',
|
|
128
|
+
elements: [
|
|
129
|
+
{
|
|
130
|
+
componentName: 'FormCollapse',
|
|
131
|
+
props: {
|
|
132
|
+
bordered: true,
|
|
133
|
+
},
|
|
134
|
+
children: [
|
|
135
|
+
{
|
|
136
|
+
componentName: 'FormCollapsePanel',
|
|
137
|
+
props: {
|
|
138
|
+
name: 'panel_1',
|
|
139
|
+
header: '分组一',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
componentName: 'FormCollapsePanel',
|
|
144
|
+
props: {
|
|
145
|
+
name: 'panel_2',
|
|
146
|
+
header: '分组二',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
FormCollapsePanel.Resource = createResource({
|
|
154
|
+
icon: 'CaretRightOutlined',
|
|
155
|
+
elements: [
|
|
156
|
+
{
|
|
157
|
+
componentName: 'FormCollapsePanel',
|
|
158
|
+
props: {
|
|
159
|
+
name: 'panel',
|
|
160
|
+
header: '分组',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DnFC } from '@yimoka/designable-react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface IFormGridProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
columnGap?: number;
|
|
7
|
+
colWrap?: boolean;
|
|
8
|
+
maxColumns?: number;
|
|
9
|
+
minColumns?: number;
|
|
10
|
+
minWidth?: number;
|
|
11
|
+
rowGap?: number;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export interface IFormGridColumnProps {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
gridSpan?: number;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
}
|
|
19
|
+
export declare const FormGrid: DnFC<IFormGridProps> & {
|
|
20
|
+
GridColumn?: DnFC<IFormGridColumnProps>;
|
|
21
|
+
};
|
|
22
|
+
export declare const FormGridColumn: DnFC<IFormGridColumnProps>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createBehavior, createResource } from '@yimoka/designable-core';
|
|
3
|
+
import { DroppableWidget } from '@yimoka/designable-react';
|
|
4
|
+
import { createContainerPropsSchema, designPlaceholderStyle, hasDesignerProps, splitDesignableStyleProps, } from "../shared.js";
|
|
5
|
+
const clampGridSpan = (span) => {
|
|
6
|
+
if (typeof span !== 'number' || Number.isNaN(span))
|
|
7
|
+
return 1;
|
|
8
|
+
return Math.max(1, Math.min(12, Math.round(span)));
|
|
9
|
+
};
|
|
10
|
+
export const FormGrid = (props) => {
|
|
11
|
+
const { componentProps: gridProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
12
|
+
const { children, className, columnGap = 12, colWrap = true, maxColumns, minColumns = 2, minWidth = 220, rowGap = 12, } = gridProps;
|
|
13
|
+
const minmax = colWrap
|
|
14
|
+
? `repeat(auto-fit, minmax(${minWidth}px, 1fr))`
|
|
15
|
+
: `repeat(${Math.max(1, maxColumns ?? minColumns)}, minmax(0, 1fr))`;
|
|
16
|
+
const isDesignMode = hasDesignerProps(designerProps);
|
|
17
|
+
return (_jsx(DroppableWidget, { ...designerProps, placeholder: false, style: wrapperStyle, children: _jsx("div", { className: className, "data-designable-form-grid": "", style: {
|
|
18
|
+
alignItems: 'stretch',
|
|
19
|
+
display: 'grid',
|
|
20
|
+
gap: `${rowGap}px ${columnGap}px`,
|
|
21
|
+
gridTemplateColumns: minmax,
|
|
22
|
+
minHeight: 56,
|
|
23
|
+
width: '100%',
|
|
24
|
+
}, children: children || (isDesignMode ? (_jsx("div", { style: designPlaceholderStyle, children: "\u62D6\u5165\u5B57\u6BB5\u7EC4\u6210\u6805\u683C" })) : null) }) }));
|
|
25
|
+
};
|
|
26
|
+
export const FormGridColumn = (props) => {
|
|
27
|
+
const { componentProps: columnProps, designerProps, wrapperStyle, } = splitDesignableStyleProps(props);
|
|
28
|
+
const { children, gridSpan, } = columnProps;
|
|
29
|
+
const isDesignMode = hasDesignerProps(designerProps);
|
|
30
|
+
return (_jsx(DroppableWidget, { ...designerProps, placeholder: false, style: wrapperStyle, children: _jsx("div", { "data-designable-form-grid-column": "", style: {
|
|
31
|
+
gridColumn: `span ${clampGridSpan(gridSpan)}`,
|
|
32
|
+
minHeight: 40,
|
|
33
|
+
}, children: children || (isDesignMode ? (_jsx("div", { style: designPlaceholderStyle, children: "\u62D6\u5165\u5B57\u6BB5" })) : null) }) }));
|
|
34
|
+
};
|
|
35
|
+
FormGrid.GridColumn = FormGridColumn;
|
|
36
|
+
FormGrid.Behavior = createBehavior({
|
|
37
|
+
name: 'FormGrid',
|
|
38
|
+
selector: node => node.componentName === 'FormGrid',
|
|
39
|
+
designerProps: {
|
|
40
|
+
droppable: true,
|
|
41
|
+
propsSchema: createContainerPropsSchema({
|
|
42
|
+
minWidth: {
|
|
43
|
+
type: 'number',
|
|
44
|
+
'x-decorator': 'FormItem',
|
|
45
|
+
'x-component': 'NumberPicker',
|
|
46
|
+
title: '最小列宽',
|
|
47
|
+
},
|
|
48
|
+
minColumns: {
|
|
49
|
+
type: 'number',
|
|
50
|
+
'x-decorator': 'FormItem',
|
|
51
|
+
'x-component': 'NumberPicker',
|
|
52
|
+
title: '最小列数',
|
|
53
|
+
},
|
|
54
|
+
maxColumns: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
'x-decorator': 'FormItem',
|
|
57
|
+
'x-component': 'NumberPicker',
|
|
58
|
+
title: '最大列数',
|
|
59
|
+
},
|
|
60
|
+
columnGap: {
|
|
61
|
+
type: 'number',
|
|
62
|
+
'x-decorator': 'FormItem',
|
|
63
|
+
'x-component': 'NumberPicker',
|
|
64
|
+
title: '列间距',
|
|
65
|
+
},
|
|
66
|
+
rowGap: {
|
|
67
|
+
type: 'number',
|
|
68
|
+
'x-decorator': 'FormItem',
|
|
69
|
+
'x-component': 'NumberPicker',
|
|
70
|
+
title: '行间距',
|
|
71
|
+
},
|
|
72
|
+
colWrap: {
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
'x-decorator': 'FormItem',
|
|
75
|
+
'x-component': 'Switch',
|
|
76
|
+
title: '自动换行',
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
FormGridColumn.Behavior = createBehavior({
|
|
82
|
+
name: 'FormGridColumn',
|
|
83
|
+
selector: node => node.componentName === 'FormGridColumn',
|
|
84
|
+
designerProps: {
|
|
85
|
+
droppable: true,
|
|
86
|
+
propsSchema: createContainerPropsSchema({
|
|
87
|
+
gridSpan: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
'x-decorator': 'FormItem',
|
|
90
|
+
'x-component': 'NumberPicker',
|
|
91
|
+
title: '占位列数',
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
FormGrid.Resource = createResource({
|
|
97
|
+
icon: 'TableOutlined',
|
|
98
|
+
elements: [
|
|
99
|
+
{
|
|
100
|
+
componentName: 'FormGrid',
|
|
101
|
+
props: {
|
|
102
|
+
columnGap: 12,
|
|
103
|
+
minColumns: 2,
|
|
104
|
+
minWidth: 220,
|
|
105
|
+
rowGap: 12,
|
|
106
|
+
},
|
|
107
|
+
children: [
|
|
108
|
+
{
|
|
109
|
+
componentName: 'FormGridColumn',
|
|
110
|
+
props: {
|
|
111
|
+
gridSpan: 1,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
componentName: 'FormGridColumn',
|
|
116
|
+
props: {
|
|
117
|
+
gridSpan: 1,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
FormGridColumn.Resource = createResource({
|
|
125
|
+
icon: 'InsertRowRightOutlined',
|
|
126
|
+
elements: [
|
|
127
|
+
{
|
|
128
|
+
componentName: 'FormGridColumn',
|
|
129
|
+
props: {
|
|
130
|
+
gridSpan: 1,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AntForm } from '@yimoka/antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type FormItemCol = React.ComponentProps<typeof AntForm.Item>['labelCol'];
|
|
4
|
+
export interface IFormItemProps extends Omit<React.ComponentProps<typeof AntForm.Item>, 'label' | 'labelCol' | 'wrapperCol'> {
|
|
5
|
+
[key: `data-${string}`]: unknown;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
labelCol?: number | FormItemCol;
|
|
10
|
+
title?: React.ReactNode;
|
|
11
|
+
wrapperCol?: number | FormItemCol;
|
|
12
|
+
}
|
|
13
|
+
export declare const FormItem: React.FC<IFormItemProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AntForm } from '@yimoka/antd';
|
|
3
|
+
const getCol = (col) => {
|
|
4
|
+
if (typeof col === 'number') {
|
|
5
|
+
return col > 0 ? { span: col } : undefined;
|
|
6
|
+
}
|
|
7
|
+
return col;
|
|
8
|
+
};
|
|
9
|
+
export const FormItem = ({ children, description, extra, help, label, labelCol, title, wrapperCol, ...props }) => {
|
|
10
|
+
const designerProps = {};
|
|
11
|
+
const formItemProps = {};
|
|
12
|
+
const wrapperStyle = props.style;
|
|
13
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
14
|
+
if (key.startsWith('data-designer')) {
|
|
15
|
+
designerProps[key] = value;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (key === 'style')
|
|
19
|
+
return;
|
|
20
|
+
formItemProps[key] = value;
|
|
21
|
+
});
|
|
22
|
+
const isDesignNode = typeof designerProps['data-designer-node-id'] === 'string';
|
|
23
|
+
const renderEditable = (value, propName) => {
|
|
24
|
+
if (!isDesignNode || value === undefined || value === null)
|
|
25
|
+
return value;
|
|
26
|
+
return (_jsx("span", { "data-content-editable": propName, children: value }));
|
|
27
|
+
};
|
|
28
|
+
const item = (_jsx(AntForm.Item, { ...formItemProps, ...(!isDesignNode && wrapperStyle ? { style: wrapperStyle } : {}), extra: renderEditable(extra ?? description, extra === undefined || extra === null ? 'description' : 'extra'), help: renderEditable(help, 'help'), label: renderEditable(label ?? title, label === undefined || label === null ? 'title' : 'label'), labelCol: getCol(labelCol), wrapperCol: getCol(wrapperCol), children: children }));
|
|
29
|
+
if (!isDesignNode)
|
|
30
|
+
return item;
|
|
31
|
+
return (_jsx("div", { ...designerProps, style: wrapperStyle, children: item }));
|
|
32
|
+
};
|
|
33
|
+
FormItem.displayName = 'FormItem';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DnFC } from '@yimoka/designable-react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface IFormLayoutProps {
|
|
4
|
+
bordered?: boolean;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
colon?: boolean;
|
|
8
|
+
feedbackLayout?: 'loose' | 'terse' | 'popover' | 'none';
|
|
9
|
+
fullness?: boolean;
|
|
10
|
+
inset?: boolean;
|
|
11
|
+
labelAlign?: 'left' | 'right';
|
|
12
|
+
labelCol?: number;
|
|
13
|
+
labelWidth?: number | string;
|
|
14
|
+
labelWrap?: boolean;
|
|
15
|
+
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
16
|
+
shallow?: boolean;
|
|
17
|
+
size?: 'large' | 'small' | 'default';
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
title?: React.ReactNode;
|
|
20
|
+
tooltipLayout?: 'icon' | 'text';
|
|
21
|
+
wrapperAlign?: 'left' | 'right';
|
|
22
|
+
wrapperCol?: number;
|
|
23
|
+
wrapperWidth?: number | string;
|
|
24
|
+
wrapperWrap?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const FormLayout: DnFC<IFormLayoutProps>;
|