@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,419 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFieldSchema } from '@formily/react';
|
|
3
|
+
import { Alert, ArrayItems, AutoComplete, Avatar, Badge, Button, Card, Carousel, Cascader, Checkbox, Collapse, Col, ColorPicker, DatePicker, DateRangePicker, Divider, Empty, Flex, FormItem, Image, Input, InputNumber, Mentions, Paragraph, QRCode, RadioGroup, Rate, Row, Search, SearchSelect, Select, Slider, Space, Statistic, Switch, Tabs, Tag, Text, Title, TimePicker, TimeRangePicker, Transfer, TreeSelect, Typography, Upload, } from '@yimoka/antd';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { RuntimeI18nEditor } from "../runtime/i18n.js";
|
|
6
|
+
import { sanitizeRuntimeNavigationHref, sanitizeRuntimeNavigationPing, } from "../runtime/navigation.js";
|
|
7
|
+
import { getOptionsFromSchema, withSchemaTransferDataSource, withSchemaTreeData, } from "../shared/schema-options.js";
|
|
8
|
+
import { canCopyRuntimeArrayItem, canMoveRuntimeArrayItem, canRemoveRuntimeArrayItem, canRenderRuntimeArrayTarget, createRuntimeArrayItemDefaultValue, isRuntimeArrayInsertionCompatible, isRuntimeArrayMoveCompatible, isRuntimeArrayRemovalCompatible, } from "./runtime-array-helpers.js";
|
|
9
|
+
import { omitRuntimeComponentProps } from "./runtime-component-props.js";
|
|
10
|
+
import { RuntimeForm, RuntimeFormGrid, RuntimeFormGridColumn, RuntimeFormLayout, } from "./runtime-form-components.js";
|
|
11
|
+
const RuntimeArrayActionContext = React.createContext({});
|
|
12
|
+
const sanitizeRuntimeNavigationRel = (rel, target) => {
|
|
13
|
+
if (typeof target !== 'string')
|
|
14
|
+
return typeof rel === 'string' ? rel : undefined;
|
|
15
|
+
const normalizedTarget = target.toLowerCase();
|
|
16
|
+
if (normalizedTarget === '' || ['_self', '_parent', '_top'].includes(normalizedTarget)) {
|
|
17
|
+
return typeof rel === 'string' ? rel : undefined;
|
|
18
|
+
}
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const tokens = (typeof rel === 'string' ? rel.split(/\s+/) : [])
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.filter(token => token.toLowerCase() !== 'opener')
|
|
23
|
+
.filter((token) => {
|
|
24
|
+
const normalized = token.toLowerCase();
|
|
25
|
+
if (seen.has(normalized))
|
|
26
|
+
return false;
|
|
27
|
+
seen.add(normalized);
|
|
28
|
+
return true;
|
|
29
|
+
});
|
|
30
|
+
['noopener', 'noreferrer'].forEach((token) => {
|
|
31
|
+
if (!seen.has(token))
|
|
32
|
+
tokens.push(token);
|
|
33
|
+
});
|
|
34
|
+
return tokens.join(' ');
|
|
35
|
+
};
|
|
36
|
+
const useRuntimeFieldSchemaProps = () => {
|
|
37
|
+
const fieldSchema = useFieldSchema();
|
|
38
|
+
const schemaProps = fieldSchema?.toJSON?.(false);
|
|
39
|
+
return schemaProps && typeof schemaProps === 'object' && !Array.isArray(schemaProps)
|
|
40
|
+
? schemaProps
|
|
41
|
+
: {};
|
|
42
|
+
};
|
|
43
|
+
const useRuntimeSchemaOptionProps = (props, fallbackOptions) => {
|
|
44
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
45
|
+
const mergedProps = {
|
|
46
|
+
...schemaProps,
|
|
47
|
+
...props,
|
|
48
|
+
};
|
|
49
|
+
if (typeof mergedProps.dataKey === 'string' && mergedProps.dataKey.trim())
|
|
50
|
+
return props;
|
|
51
|
+
if (mergedProps.data !== undefined)
|
|
52
|
+
return props;
|
|
53
|
+
const options = getOptionsFromSchema(mergedProps);
|
|
54
|
+
if (options)
|
|
55
|
+
return { ...props, options };
|
|
56
|
+
if (fallbackOptions
|
|
57
|
+
&& props.options === undefined
|
|
58
|
+
&& props.data === undefined) {
|
|
59
|
+
return { ...props, options: fallbackOptions };
|
|
60
|
+
}
|
|
61
|
+
return props;
|
|
62
|
+
};
|
|
63
|
+
const createRuntimeOptionsComponent = (Component, fallbackOptions) => ((props) => React.createElement(Component, useRuntimeSchemaOptionProps(props, fallbackOptions)));
|
|
64
|
+
const RuntimeAutoComplete = createRuntimeOptionsComponent(AutoComplete);
|
|
65
|
+
const RuntimeCascader = createRuntimeOptionsComponent(Cascader);
|
|
66
|
+
const RuntimeMentions = createRuntimeOptionsComponent(Mentions);
|
|
67
|
+
const RUNTIME_RADIO_DEFAULT_OPTIONS = [
|
|
68
|
+
{ label: '选项一', value: 'option1' },
|
|
69
|
+
{ label: '选项二', value: 'option2' },
|
|
70
|
+
];
|
|
71
|
+
const RuntimeRadio = createRuntimeOptionsComponent(RadioGroup, RUNTIME_RADIO_DEFAULT_OPTIONS);
|
|
72
|
+
const RuntimeSearch = createRuntimeOptionsComponent(Search);
|
|
73
|
+
const RuntimeSearchSelect = createRuntimeOptionsComponent(SearchSelect);
|
|
74
|
+
const RuntimeSelect = createRuntimeOptionsComponent(Select);
|
|
75
|
+
const RuntimeStatistic = (props) => {
|
|
76
|
+
const fieldSchema = useFieldSchema();
|
|
77
|
+
const schemaJson = fieldSchema?.toJSON?.(false);
|
|
78
|
+
const componentProps = schemaJson && typeof schemaJson === 'object'
|
|
79
|
+
? schemaJson['x-component-props']
|
|
80
|
+
: undefined;
|
|
81
|
+
const schemaValue = componentProps && typeof componentProps === 'object'
|
|
82
|
+
? componentProps.value
|
|
83
|
+
: undefined;
|
|
84
|
+
return (_jsx(Statistic, { ...props, value: (schemaValue ?? props.value) }));
|
|
85
|
+
};
|
|
86
|
+
const RuntimeLink = ({ children, href, ping, rel, target, to, ...props }) => {
|
|
87
|
+
const runtimeHref = sanitizeRuntimeNavigationHref(href ?? to);
|
|
88
|
+
const runtimeTarget = typeof target === 'string' ? target : undefined;
|
|
89
|
+
return (_jsx(Typography.Link, { ...props, href: runtimeHref || undefined, ping: sanitizeRuntimeNavigationPing(ping), rel: sanitizeRuntimeNavigationRel(rel, runtimeTarget), target: runtimeTarget, children: children }));
|
|
90
|
+
};
|
|
91
|
+
const RuntimeButton = ({ href, ping, rel, target, ...props }) => {
|
|
92
|
+
const runtimeHref = sanitizeRuntimeNavigationHref(href);
|
|
93
|
+
return (_jsx(Button, { ...props, href: runtimeHref || undefined, ping: sanitizeRuntimeNavigationPing(ping), rel: sanitizeRuntimeNavigationRel(rel, target), target: typeof target === 'string' ? target : undefined }));
|
|
94
|
+
};
|
|
95
|
+
const renderRuntimeTransferItem = (item) => {
|
|
96
|
+
if (React.isValidElement(item.title))
|
|
97
|
+
return item.title;
|
|
98
|
+
if (item.title !== undefined && item.title !== null)
|
|
99
|
+
return String(item.title);
|
|
100
|
+
return String(item.key ?? '');
|
|
101
|
+
};
|
|
102
|
+
const hasRuntimeExplicitData = (props, keys) => keys.some((key) => {
|
|
103
|
+
const value = props[key];
|
|
104
|
+
if (typeof value === 'string')
|
|
105
|
+
return Boolean(value.trim());
|
|
106
|
+
return value !== undefined;
|
|
107
|
+
});
|
|
108
|
+
const useRuntimeTransferProps = (props) => {
|
|
109
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
110
|
+
const mergedProps = { ...schemaProps, ...props };
|
|
111
|
+
if (hasRuntimeExplicitData(mergedProps, ['dataKey', 'dataSource', 'data']))
|
|
112
|
+
return props;
|
|
113
|
+
const mapped = withSchemaTransferDataSource(mergedProps);
|
|
114
|
+
return mapped.dataSource === undefined ? props : { ...props, dataSource: mapped.dataSource };
|
|
115
|
+
};
|
|
116
|
+
const useRuntimeTreeSelectProps = (props) => {
|
|
117
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
118
|
+
const mergedProps = { ...schemaProps, ...props };
|
|
119
|
+
if (hasRuntimeExplicitData(mergedProps, ['dataKey', 'treeData', 'data']))
|
|
120
|
+
return props;
|
|
121
|
+
const mapped = withSchemaTreeData(mergedProps);
|
|
122
|
+
return mapped.treeData === undefined ? props : { ...props, treeData: mapped.treeData };
|
|
123
|
+
};
|
|
124
|
+
const RuntimeTransfer = (inputProps) => {
|
|
125
|
+
const { render, ...props } = useRuntimeTransferProps(inputProps);
|
|
126
|
+
return _jsx(Transfer, { ...props, render: render ?? renderRuntimeTransferItem });
|
|
127
|
+
};
|
|
128
|
+
const RuntimeTreeSelect = (props) => (_jsx(TreeSelect, { ...useRuntimeTreeSelectProps(props) }));
|
|
129
|
+
const canMutateRuntimeArray = (array, disabled) => Boolean(array?.field?.pattern === 'editable'
|
|
130
|
+
&& !array.props?.disabled
|
|
131
|
+
&& !disabled);
|
|
132
|
+
const getPaneProps = (child) => (child.props && typeof child.props === 'object'
|
|
133
|
+
? child.props
|
|
134
|
+
: {});
|
|
135
|
+
const getPaneKey = (child, props, index) => String(props.name ?? props.tabKey ?? child.key ?? `pane_${index + 1}`);
|
|
136
|
+
const getRuntimePaneSchemaTitles = (schema) => {
|
|
137
|
+
if (!schema || typeof schema !== 'object' || Array.isArray(schema))
|
|
138
|
+
return [];
|
|
139
|
+
const { properties } = schema;
|
|
140
|
+
if (!properties || typeof properties !== 'object' || Array.isArray(properties))
|
|
141
|
+
return [];
|
|
142
|
+
return Object.values(properties).map((child) => {
|
|
143
|
+
if (!child || typeof child !== 'object' || Array.isArray(child))
|
|
144
|
+
return undefined;
|
|
145
|
+
const { title } = child;
|
|
146
|
+
return title;
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
const createTabItems = (children, schemaTitles = []) => (React.Children.toArray(children)
|
|
150
|
+
.filter((child) => React.isValidElement(child))
|
|
151
|
+
.map((child, index) => {
|
|
152
|
+
const props = getPaneProps(child);
|
|
153
|
+
return {
|
|
154
|
+
children: child,
|
|
155
|
+
disabled: props.disabled,
|
|
156
|
+
forceRender: props.forceRender,
|
|
157
|
+
key: getPaneKey(child, props, index),
|
|
158
|
+
label: props.tab ?? props.title ?? schemaTitles[index] ?? `标签 ${index + 1}`,
|
|
159
|
+
};
|
|
160
|
+
}));
|
|
161
|
+
const RuntimeTabs = ({ children, items, ...props }) => {
|
|
162
|
+
const fieldSchema = useFieldSchema();
|
|
163
|
+
const schemaTitles = getRuntimePaneSchemaTitles(fieldSchema?.toJSON?.(false));
|
|
164
|
+
const childItems = createTabItems(children, schemaTitles);
|
|
165
|
+
return (_jsx(Tabs, { ...props, items: childItems.length
|
|
166
|
+
? childItems
|
|
167
|
+
: items }));
|
|
168
|
+
};
|
|
169
|
+
const createCollapseItems = (children) => (React.Children.toArray(children)
|
|
170
|
+
.filter((child) => React.isValidElement(child))
|
|
171
|
+
.map((child, index) => {
|
|
172
|
+
const props = getPaneProps(child);
|
|
173
|
+
return {
|
|
174
|
+
children: child,
|
|
175
|
+
collapsible: props.disabled ? 'disabled' : props.collapsible,
|
|
176
|
+
extra: props.extra,
|
|
177
|
+
key: getPaneKey(child, props, index),
|
|
178
|
+
label: props.header ?? props.title ?? `分组 ${index + 1}`,
|
|
179
|
+
};
|
|
180
|
+
}));
|
|
181
|
+
const RuntimeFormCollapse = ({ children, items, ...props }) => {
|
|
182
|
+
const childItems = createCollapseItems(children);
|
|
183
|
+
return (_jsx(Collapse, { ...props, items: childItems.length
|
|
184
|
+
? childItems
|
|
185
|
+
: items }));
|
|
186
|
+
};
|
|
187
|
+
const RuntimePane = ({ children, ...props }) => {
|
|
188
|
+
const flexProps = omitRuntimeComponentProps(props, [
|
|
189
|
+
'collapsible',
|
|
190
|
+
'disabled',
|
|
191
|
+
'extra',
|
|
192
|
+
'forceRender',
|
|
193
|
+
'header',
|
|
194
|
+
'name',
|
|
195
|
+
'tab',
|
|
196
|
+
'tabKey',
|
|
197
|
+
'title',
|
|
198
|
+
]);
|
|
199
|
+
return (_jsx(Flex, { ...flexProps, vertical: true, children: children }));
|
|
200
|
+
};
|
|
201
|
+
const RuntimeObject = ({ bordered = true, children, layout, title, ...props }) => {
|
|
202
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
203
|
+
const runtimeTitle = title ?? schemaProps.title;
|
|
204
|
+
const cardProps = omitRuntimeComponentProps(props, [
|
|
205
|
+
'collapsible',
|
|
206
|
+
'defaultCollapsed',
|
|
207
|
+
'name',
|
|
208
|
+
]);
|
|
209
|
+
return (_jsx(Card, { ...cardProps, size: "small", title: runtimeTitle, variant: bordered ? 'outlined' : 'borderless', children: _jsx("div", { "data-runtime-object-content": "", style: {
|
|
210
|
+
display: layout === 'inline' ? 'flex' : 'block',
|
|
211
|
+
gap: layout === 'inline' ? 12 : undefined,
|
|
212
|
+
}, children: children }) }));
|
|
213
|
+
};
|
|
214
|
+
const RuntimeCheckbox = ({ ...inputProps }) => {
|
|
215
|
+
const { children, data, dataKey, options, ...props } = useRuntimeSchemaOptionProps(inputProps);
|
|
216
|
+
const hasOptions = Array.isArray(options);
|
|
217
|
+
const hasData = Array.isArray(data);
|
|
218
|
+
const hasDataKey = typeof dataKey === 'string' && Boolean(dataKey.trim());
|
|
219
|
+
if (hasOptions || hasData || hasDataKey) {
|
|
220
|
+
return (_jsx(Checkbox.Group, { ...props, data: hasData
|
|
221
|
+
? data
|
|
222
|
+
: undefined, dataKey: hasDataKey ? dataKey : undefined, options: hasOptions
|
|
223
|
+
? options
|
|
224
|
+
: undefined }));
|
|
225
|
+
}
|
|
226
|
+
return _jsx(Checkbox, { ...props, children: children });
|
|
227
|
+
};
|
|
228
|
+
const RuntimeCard = ({ bordered, children, ...props }) => (_jsx(Card, { ...props, ...(typeof bordered === 'boolean'
|
|
229
|
+
? { variant: bordered ? 'outlined' : 'borderless' }
|
|
230
|
+
: {}), children: children }));
|
|
231
|
+
const RuntimeText = ({ children, content, dangerouslySetInnerHTML: _dangerouslySetInnerHTML, mode = 'normal', strong = false, style, ...props }) => {
|
|
232
|
+
const textStyle = {
|
|
233
|
+
...style,
|
|
234
|
+
...(strong ? { fontWeight: 600 } : {}),
|
|
235
|
+
};
|
|
236
|
+
const textContent = children ?? content;
|
|
237
|
+
if (mode === 'p') {
|
|
238
|
+
return _jsx(Paragraph, { ...props, style: textStyle, children: textContent });
|
|
239
|
+
}
|
|
240
|
+
if (mode === 'h1' || mode === 'h2' || mode === 'h3') {
|
|
241
|
+
return (_jsx(Title, { ...props, level: Number(mode.slice(1)), style: textStyle, children: textContent }));
|
|
242
|
+
}
|
|
243
|
+
return _jsx(Text, { ...props, style: textStyle, children: textContent });
|
|
244
|
+
};
|
|
245
|
+
const RuntimeArrayAddition = () => {
|
|
246
|
+
const config = React.useContext(RuntimeArrayActionContext);
|
|
247
|
+
const array = ArrayItems.useArray();
|
|
248
|
+
const length = Array.isArray(array?.field.value) ? array.field.value.length : 0;
|
|
249
|
+
const canMutate = canMutateRuntimeArray(array, config.disabled);
|
|
250
|
+
const canAddItem = canRenderRuntimeArrayTarget(array?.schema, length, config.hasRenderableItem);
|
|
251
|
+
if (!array
|
|
252
|
+
|| !canMutate
|
|
253
|
+
|| !canAddItem
|
|
254
|
+
|| (config.maxItems !== undefined && length >= config.maxItems))
|
|
255
|
+
return null;
|
|
256
|
+
return (_jsx(Button, { block: true, type: "dashed", onClick: () => {
|
|
257
|
+
if (!canMutateRuntimeArray(array, config.disabled))
|
|
258
|
+
return;
|
|
259
|
+
const nextIndex = Array.isArray(array.field.value) ? array.field.value.length : 0;
|
|
260
|
+
if (config.maxItems !== undefined && nextIndex >= config.maxItems)
|
|
261
|
+
return;
|
|
262
|
+
if (!canRenderRuntimeArrayTarget(array.schema, nextIndex, config.hasRenderableItem))
|
|
263
|
+
return;
|
|
264
|
+
array.field.push(createRuntimeArrayItemDefaultValue(array.schema, nextIndex));
|
|
265
|
+
}, children: config.addButtonText ?? '新增' }));
|
|
266
|
+
};
|
|
267
|
+
const RuntimeArrayItem = ({ children, ...props }) => {
|
|
268
|
+
const config = React.useContext(RuntimeArrayActionContext);
|
|
269
|
+
const array = ArrayItems.useArray();
|
|
270
|
+
const index = ArrayItems.useIndex();
|
|
271
|
+
const length = Array.isArray(array?.field.value) ? array.field.value.length : 0;
|
|
272
|
+
const canMutate = canMutateRuntimeArray(array, config.disabled);
|
|
273
|
+
const canCopy = canCopyRuntimeArrayItem(array?.schema, index, length, config.maxItems, config.hasRenderableItem);
|
|
274
|
+
const canMoveUp = canMoveRuntimeArrayItem(array?.schema, index, index - 1, length);
|
|
275
|
+
const canMoveDown = canMoveRuntimeArrayItem(array?.schema, index, index + 1, length);
|
|
276
|
+
const canRemove = canRemoveRuntimeArrayItem(array?.schema, index, length, config.minItems);
|
|
277
|
+
const guardMove = (targetIndex, event) => {
|
|
278
|
+
if (!canMutateRuntimeArray(array, config.disabled)
|
|
279
|
+
|| !isRuntimeArrayMoveCompatible(array?.schema, index, targetIndex)) {
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const guardCopy = (event) => {
|
|
284
|
+
const currentLength = Array.isArray(array?.field.value)
|
|
285
|
+
? array.field.value.length
|
|
286
|
+
: 0;
|
|
287
|
+
if (!canMutateRuntimeArray(array, config.disabled)
|
|
288
|
+
|| (config.maxItems !== undefined && currentLength >= config.maxItems)
|
|
289
|
+
|| !canRenderRuntimeArrayTarget(array?.schema, index + 1, config.hasRenderableItem)
|
|
290
|
+
|| !isRuntimeArrayInsertionCompatible(array?.schema, index, currentLength)) {
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
const guardRemove = (event) => {
|
|
295
|
+
const currentLength = Array.isArray(array?.field.value)
|
|
296
|
+
? array.field.value.length
|
|
297
|
+
: 0;
|
|
298
|
+
if (!canMutateRuntimeArray(array, config.disabled)
|
|
299
|
+
|| (config.minItems !== undefined && currentLength <= config.minItems)
|
|
300
|
+
|| !isRuntimeArrayRemovalCompatible(array?.schema, index, currentLength)) {
|
|
301
|
+
event.preventDefault();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
return (_jsxs(ArrayItems.Item, { ...props, children: [children, _jsxs(Space, { size: "small", children: [canMutate && canCopy ? (_jsx(ArrayItems.Copy, { title: config.copyButtonText ?? '复制', onClick: guardCopy })) : null, canMutate && canMoveUp ? (_jsx(ArrayItems.MoveUp, { title: config.moveUpButtonText ?? '上移', onClick: event => guardMove(index - 1, event) })) : null, canMutate && canMoveDown ? (_jsx(ArrayItems.MoveDown, { title: config.moveDownButtonText ?? '下移', onClick: event => guardMove(index + 1, event) })) : null, canMutate && canRemove ? (_jsx(ArrayItems.Remove, { title: config.removeButtonText ?? '删除', onClick: guardRemove })) : null] })] }));
|
|
305
|
+
};
|
|
306
|
+
const getRuntimeArrayListPadding = (size) => {
|
|
307
|
+
if (size === 'small')
|
|
308
|
+
return 8;
|
|
309
|
+
if (size === 'large')
|
|
310
|
+
return 14;
|
|
311
|
+
return 11;
|
|
312
|
+
};
|
|
313
|
+
const normalizeRuntimeArrayLimit = (value) => (typeof value === 'number' && Number.isFinite(value) && value >= 0
|
|
314
|
+
? Math.floor(value)
|
|
315
|
+
: undefined);
|
|
316
|
+
const RuntimeArrayList = ({ addButtonText, bordered = true, children, className, copyButtonText, disabled, header, itemLayout = 'vertical', maxItems, minItems, moveDownButtonText, moveUpButtonText, removeButtonText, size, split = true, style, ...props }) => {
|
|
317
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
318
|
+
const runtimeMaxItems = normalizeRuntimeArrayLimit(maxItems)
|
|
319
|
+
?? normalizeRuntimeArrayLimit(schemaProps.maxItems);
|
|
320
|
+
const runtimeMinItems = normalizeRuntimeArrayLimit(minItems)
|
|
321
|
+
?? normalizeRuntimeArrayLimit(schemaProps.minItems);
|
|
322
|
+
const padding = getRuntimeArrayListPadding(size);
|
|
323
|
+
return (_jsx(RuntimeArrayActionContext.Provider, { value: {
|
|
324
|
+
addButtonText,
|
|
325
|
+
copyButtonText,
|
|
326
|
+
disabled: Boolean(disabled),
|
|
327
|
+
hasRenderableItem: React.Children.toArray(children).length > 0,
|
|
328
|
+
maxItems: runtimeMaxItems,
|
|
329
|
+
minItems: runtimeMinItems,
|
|
330
|
+
moveDownButtonText,
|
|
331
|
+
moveUpButtonText,
|
|
332
|
+
removeButtonText,
|
|
333
|
+
}, children: _jsxs("div", { ...props, className: typeof className === 'string' ? className : undefined, "data-runtime-array-list": "", role: "list", style: {
|
|
334
|
+
background: '#fff',
|
|
335
|
+
border: bordered ? '1px solid #d9e4f2' : 0,
|
|
336
|
+
borderRadius: 6,
|
|
337
|
+
minHeight: 64,
|
|
338
|
+
overflow: 'hidden',
|
|
339
|
+
width: '100%',
|
|
340
|
+
...(typeof style === 'object' && style !== null ? style : {}),
|
|
341
|
+
}, children: [header ? (_jsx("div", { "data-runtime-array-list-header": "", style: {
|
|
342
|
+
background: '#f8fbff',
|
|
343
|
+
borderBottom: split ? '1px solid #edf1f7' : 0,
|
|
344
|
+
color: '#253040',
|
|
345
|
+
fontSize: 13,
|
|
346
|
+
fontWeight: 600,
|
|
347
|
+
lineHeight: '18px',
|
|
348
|
+
padding: `${Math.max(8, padding - 1)}px ${padding + 1}px`,
|
|
349
|
+
}, children: header })) : null, _jsx("div", { "data-runtime-array-list-body": "", style: {
|
|
350
|
+
padding: split ? 0 : padding,
|
|
351
|
+
}, children: _jsxs(ArrayItems, { canMove: (oldIndex, newIndex) => (isRuntimeArrayMoveCompatible(schemaProps, oldIndex, newIndex)), direction: itemLayout === 'horizontal' ? 'horizontal' : 'vertical', listStyle: {
|
|
352
|
+
display: 'flex',
|
|
353
|
+
flexDirection: itemLayout === 'horizontal' ? 'row' : 'column',
|
|
354
|
+
gap: split ? 0 : 6,
|
|
355
|
+
}, sortable: !disabled, children: [children, _jsx(RuntimeArrayAddition, {})] }) })] }) }));
|
|
356
|
+
};
|
|
357
|
+
const RuntimeUpload = ({ action: _action, beforeUpload: _beforeUpload, children, customRequest: _customRequest, headers: _headers, method: _method, textContent, withCredentials: _withCredentials, ...props }) => (_jsx(Upload, { ...props, action: undefined, beforeUpload: () => false, customRequest: undefined, headers: undefined, method: undefined, withCredentials: false, children: children || (_jsx(Button, { icon: "UploadOutlined", children: textContent ?? '上传文件' })) }));
|
|
358
|
+
export const antdRuntimeComponents = {
|
|
359
|
+
Alert,
|
|
360
|
+
ArrayItem: RuntimeArrayItem,
|
|
361
|
+
ArrayList: RuntimeArrayList,
|
|
362
|
+
AutoComplete: RuntimeAutoComplete,
|
|
363
|
+
Avatar,
|
|
364
|
+
Badge,
|
|
365
|
+
Button: RuntimeButton,
|
|
366
|
+
Card: RuntimeCard,
|
|
367
|
+
Carousel,
|
|
368
|
+
Cascader: RuntimeCascader,
|
|
369
|
+
Checkbox: RuntimeCheckbox,
|
|
370
|
+
ColorPicker,
|
|
371
|
+
DatePicker,
|
|
372
|
+
DateRangePicker,
|
|
373
|
+
Divider,
|
|
374
|
+
Empty,
|
|
375
|
+
Flex,
|
|
376
|
+
Form: RuntimeForm,
|
|
377
|
+
FormCollapse: RuntimeFormCollapse,
|
|
378
|
+
FormCollapsePanel: RuntimePane,
|
|
379
|
+
FormGrid: RuntimeFormGrid,
|
|
380
|
+
FormGridColumn: RuntimeFormGridColumn,
|
|
381
|
+
FormItem,
|
|
382
|
+
FormLayout: RuntimeFormLayout,
|
|
383
|
+
FormTab: RuntimeTabs,
|
|
384
|
+
'FormTab.TabPane': RuntimePane,
|
|
385
|
+
GridCol: Col,
|
|
386
|
+
GridRow: Row,
|
|
387
|
+
I18nEditor: RuntimeI18nEditor,
|
|
388
|
+
Image,
|
|
389
|
+
Input,
|
|
390
|
+
InputSearch: Input.Search,
|
|
391
|
+
Link: RuntimeLink,
|
|
392
|
+
Mentions: RuntimeMentions,
|
|
393
|
+
NumberPicker: InputNumber,
|
|
394
|
+
Object: RuntimeObject,
|
|
395
|
+
Password: Input.Password,
|
|
396
|
+
QRCode,
|
|
397
|
+
Radio: RuntimeRadio,
|
|
398
|
+
Rate,
|
|
399
|
+
Search: RuntimeSearch,
|
|
400
|
+
SearchSelect: RuntimeSearchSelect,
|
|
401
|
+
Select: RuntimeSelect,
|
|
402
|
+
Slider,
|
|
403
|
+
Space,
|
|
404
|
+
Statistic: RuntimeStatistic,
|
|
405
|
+
Switch,
|
|
406
|
+
TabPane: RuntimePane,
|
|
407
|
+
Tabs: RuntimeTabs,
|
|
408
|
+
Tag,
|
|
409
|
+
Text: RuntimeText,
|
|
410
|
+
TextArea: Input.TextArea,
|
|
411
|
+
TimePicker,
|
|
412
|
+
TimeRangePicker,
|
|
413
|
+
Transfer: RuntimeTransfer,
|
|
414
|
+
TreeSelect: RuntimeTreeSelect,
|
|
415
|
+
Upload: RuntimeUpload,
|
|
416
|
+
};
|
|
417
|
+
export const createAntdRuntimeComponents = () => ({
|
|
418
|
+
...antdRuntimeComponents,
|
|
419
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface IRuntimeContainerProps extends Record<string, unknown> {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare const RuntimeForm: ({ children, labelCol, requiredMark, title, wrapperCol, ...props }: IRuntimeContainerProps) => React.JSX.Element;
|
|
6
|
+
export declare const RuntimeFormLayout: ({ bordered, children, className, labelCol, labelWidth, inset, requiredMark, style, title, wrapperAlign, wrapperCol, wrapperWidth, ...props }: IRuntimeContainerProps) => React.JSX.Element;
|
|
7
|
+
export declare const RuntimeFormGrid: ({ children, columnGap, colWrap, maxColumns, minColumns, minWidth, rowGap, style, ...props }: IRuntimeContainerProps) => React.JSX.Element;
|
|
8
|
+
export declare const RuntimeFormGridColumn: ({ children, gridSpan, style, ...props }: IRuntimeContainerProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFieldSchema } from '@formily/react';
|
|
3
|
+
import { Card, Form } from '@yimoka/antd';
|
|
4
|
+
import { omitRuntimeComponentProps } from "./runtime-component-props.js";
|
|
5
|
+
const useRuntimeFieldSchemaProps = () => {
|
|
6
|
+
const fieldSchema = useFieldSchema();
|
|
7
|
+
const schemaProps = fieldSchema?.toJSON?.(false);
|
|
8
|
+
return schemaProps && typeof schemaProps === 'object' && !Array.isArray(schemaProps)
|
|
9
|
+
? schemaProps
|
|
10
|
+
: {};
|
|
11
|
+
};
|
|
12
|
+
const normalizeFormCol = (value) => {
|
|
13
|
+
if (typeof value !== 'number')
|
|
14
|
+
return value;
|
|
15
|
+
return value > 0 ? { span: value } : undefined;
|
|
16
|
+
};
|
|
17
|
+
const normalizeRequiredMark = (value) => {
|
|
18
|
+
if (value === 'true')
|
|
19
|
+
return true;
|
|
20
|
+
if (value === 'false')
|
|
21
|
+
return false;
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
const normalizeRuntimeCssSize = (value) => {
|
|
25
|
+
if (typeof value === 'number')
|
|
26
|
+
return `${value}px`;
|
|
27
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
28
|
+
};
|
|
29
|
+
export const RuntimeForm = ({ children, labelCol, requiredMark, title, wrapperCol, ...props }) => {
|
|
30
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
31
|
+
const runtimeTitle = title ?? schemaProps.title;
|
|
32
|
+
return (_jsxs(Form, { ...props, labelCol: normalizeFormCol(labelCol), requiredMark: normalizeRequiredMark(requiredMark), wrapperCol: normalizeFormCol(wrapperCol), children: [runtimeTitle ? (_jsx("div", { "data-runtime-form-title": "", style: {
|
|
33
|
+
color: '#253040',
|
|
34
|
+
fontSize: 14,
|
|
35
|
+
fontWeight: 600,
|
|
36
|
+
marginBottom: 12,
|
|
37
|
+
}, children: runtimeTitle })) : null, children] }));
|
|
38
|
+
};
|
|
39
|
+
export const RuntimeFormLayout = ({ bordered = true, children, className, labelCol, labelWidth, inset, requiredMark, style, title, wrapperAlign, wrapperCol, wrapperWidth, ...props }) => {
|
|
40
|
+
const schemaProps = useRuntimeFieldSchemaProps();
|
|
41
|
+
const runtimeTitle = title ?? schemaProps.title;
|
|
42
|
+
const formProps = omitRuntimeComponentProps(props, [
|
|
43
|
+
'feedbackLayout',
|
|
44
|
+
'fullness',
|
|
45
|
+
'shallow',
|
|
46
|
+
'tooltipLayout',
|
|
47
|
+
'wrapperWrap',
|
|
48
|
+
]);
|
|
49
|
+
return (_jsx(Card, { className: typeof className === 'string' ? className : undefined, size: "small", style: style, title: runtimeTitle, variant: bordered ? 'outlined' : 'borderless', children: _jsx("div", { "data-runtime-form-layout-content": "", style: {
|
|
50
|
+
display: 'grid',
|
|
51
|
+
gridTemplateColumns: normalizeRuntimeCssSize(wrapperWidth)
|
|
52
|
+
? `minmax(0, ${normalizeRuntimeCssSize(wrapperWidth)})`
|
|
53
|
+
: undefined,
|
|
54
|
+
justifyContent: wrapperAlign === 'right' ? 'end' : 'stretch',
|
|
55
|
+
justifyItems: wrapperAlign === 'right' ? 'end' : 'stretch',
|
|
56
|
+
paddingInlineStart: inset ? 12 : undefined,
|
|
57
|
+
width: '100%',
|
|
58
|
+
}, children: _jsx(Form, { ...formProps, component: false, labelCol: normalizeFormCol(labelCol), labelWidth: typeof labelWidth === 'number'
|
|
59
|
+
? labelWidth
|
|
60
|
+
: normalizeRuntimeCssSize(labelWidth), requiredMark: normalizeRequiredMark(requiredMark), wrapperCol: normalizeFormCol(wrapperCol), children: children }) }) }));
|
|
61
|
+
};
|
|
62
|
+
const normalizeGridPositiveInteger = (value, fallback) => (typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
63
|
+
? Math.max(1, Math.round(value))
|
|
64
|
+
: fallback);
|
|
65
|
+
const normalizeGridNonNegativeNumber = (value, fallback) => (typeof value === 'number' && Number.isFinite(value) && value >= 0
|
|
66
|
+
? value
|
|
67
|
+
: fallback);
|
|
68
|
+
export const RuntimeFormGrid = ({ children, columnGap = 12, colWrap = true, maxColumns, minColumns = 2, minWidth = 220, rowGap = 12, style, ...props }) => {
|
|
69
|
+
const normalizedColumnGap = normalizeGridNonNegativeNumber(columnGap, 12);
|
|
70
|
+
const normalizedRowGap = normalizeGridNonNegativeNumber(rowGap, 12);
|
|
71
|
+
const normalizedMinColumns = normalizeGridPositiveInteger(minColumns, 2);
|
|
72
|
+
const normalizedMaxColumns = normalizeGridPositiveInteger(maxColumns, normalizedMinColumns);
|
|
73
|
+
const normalizedMinWidth = normalizeGridPositiveInteger(minWidth, 220);
|
|
74
|
+
const gridTemplateColumns = colWrap
|
|
75
|
+
? `repeat(auto-fit, minmax(${normalizedMinWidth}px, 1fr))`
|
|
76
|
+
: `repeat(${normalizedMaxColumns}, minmax(0, 1fr))`;
|
|
77
|
+
return (_jsx("div", { ...props, "data-runtime-form-grid": "", style: {
|
|
78
|
+
...style,
|
|
79
|
+
alignItems: 'stretch',
|
|
80
|
+
display: 'grid',
|
|
81
|
+
gap: `${normalizedRowGap}px ${normalizedColumnGap}px`,
|
|
82
|
+
gridTemplateColumns,
|
|
83
|
+
width: '100%',
|
|
84
|
+
}, children: children }));
|
|
85
|
+
};
|
|
86
|
+
export const RuntimeFormGridColumn = ({ children, gridSpan = 1, style, ...props }) => {
|
|
87
|
+
const normalizedSpan = typeof gridSpan === 'number' && Number.isFinite(gridSpan)
|
|
88
|
+
? Math.max(1, Math.min(12, Math.round(gridSpan)))
|
|
89
|
+
: 1;
|
|
90
|
+
return (_jsx("div", { ...props, "data-runtime-form-grid-column": "", style: {
|
|
91
|
+
...style,
|
|
92
|
+
gridColumn: `span ${normalizedSpan}`,
|
|
93
|
+
}, children: children }));
|
|
94
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IComponentCategory } from "../types.js";
|
|
2
|
+
export declare const FORM_EXAMPLE_IDS: readonly ["form-basic", "official-formily-antd", "runtime-store-injection", "i18n-store-config", "data-manual", "data-store-catalog", "ui-json-roundtrip"];
|
|
3
|
+
export declare const WEBSITE_EXAMPLE_IDS: readonly ["template-landing-home", "template-news-index", "template-news-detail", "template-about", "template-contact"];
|
|
4
|
+
export declare const WEBSITE_TEMPLATE_IDS: readonly ["landing-home", "news-index", "news-detail", "about", "contact"];
|
|
5
|
+
export declare const FORM_CATEGORIES: IComponentCategory[];
|
|
6
|
+
export declare const WEBSITE_CATEGORIES: IComponentCategory[];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const FORM_EXAMPLE_IDS = [
|
|
2
|
+
'form-basic',
|
|
3
|
+
'official-formily-antd',
|
|
4
|
+
'runtime-store-injection',
|
|
5
|
+
'i18n-store-config',
|
|
6
|
+
'data-manual',
|
|
7
|
+
'data-store-catalog',
|
|
8
|
+
'ui-json-roundtrip',
|
|
9
|
+
];
|
|
10
|
+
export const WEBSITE_EXAMPLE_IDS = [
|
|
11
|
+
'template-landing-home',
|
|
12
|
+
'template-news-index',
|
|
13
|
+
'template-news-detail',
|
|
14
|
+
'template-about',
|
|
15
|
+
'template-contact',
|
|
16
|
+
];
|
|
17
|
+
export const WEBSITE_TEMPLATE_IDS = [
|
|
18
|
+
'landing-home',
|
|
19
|
+
'news-index',
|
|
20
|
+
'news-detail',
|
|
21
|
+
'about',
|
|
22
|
+
'contact',
|
|
23
|
+
];
|
|
24
|
+
export const FORM_CATEGORIES = [
|
|
25
|
+
{
|
|
26
|
+
components: [
|
|
27
|
+
'Input',
|
|
28
|
+
'InputSearch',
|
|
29
|
+
'TextArea',
|
|
30
|
+
'Password',
|
|
31
|
+
'AutoComplete',
|
|
32
|
+
'Search',
|
|
33
|
+
'Mentions',
|
|
34
|
+
'NumberPicker',
|
|
35
|
+
'DatePicker',
|
|
36
|
+
'DateRangePicker',
|
|
37
|
+
'TimePicker',
|
|
38
|
+
'TimeRangePicker',
|
|
39
|
+
],
|
|
40
|
+
key: 'form-input',
|
|
41
|
+
title: '表单输入',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
components: [
|
|
45
|
+
'Select',
|
|
46
|
+
'SearchSelect',
|
|
47
|
+
'Cascader',
|
|
48
|
+
'TreeSelect',
|
|
49
|
+
'Transfer',
|
|
50
|
+
'Checkbox',
|
|
51
|
+
'Radio',
|
|
52
|
+
'Switch',
|
|
53
|
+
'Slider',
|
|
54
|
+
'Rate',
|
|
55
|
+
'ColorPicker',
|
|
56
|
+
],
|
|
57
|
+
key: 'form-choice',
|
|
58
|
+
title: '表单选择',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
components: ['Upload'],
|
|
62
|
+
key: 'form-upload',
|
|
63
|
+
title: '表单上传',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
components: ['Button'],
|
|
67
|
+
key: 'form-action',
|
|
68
|
+
title: '表单操作',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
components: ['Text', 'Alert', 'Divider', 'Tag'],
|
|
72
|
+
key: 'form-display',
|
|
73
|
+
title: '表单展示',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
components: [
|
|
77
|
+
'Form',
|
|
78
|
+
'FormCollapse',
|
|
79
|
+
'FormCollapsePanel',
|
|
80
|
+
'FormGrid',
|
|
81
|
+
'FormGridColumn',
|
|
82
|
+
'FormLayout',
|
|
83
|
+
'FormTab',
|
|
84
|
+
'FormTab.TabPane',
|
|
85
|
+
'Card',
|
|
86
|
+
'GridRow',
|
|
87
|
+
'GridCol',
|
|
88
|
+
'Flex',
|
|
89
|
+
'Space',
|
|
90
|
+
'Tabs',
|
|
91
|
+
'TabPane',
|
|
92
|
+
],
|
|
93
|
+
key: 'form-layout',
|
|
94
|
+
title: '表单布局',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
components: ['Object', 'ArrayList', 'ArrayItem'],
|
|
98
|
+
key: 'form-data',
|
|
99
|
+
title: '表单数据',
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
export const WEBSITE_CATEGORIES = [
|
|
103
|
+
{
|
|
104
|
+
components: ['Text', 'Image', 'Avatar', 'Badge', 'Tag', 'Statistic', 'QRCode'],
|
|
105
|
+
key: 'website-content',
|
|
106
|
+
title: '官网内容',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
components: ['Alert', 'Empty', 'Divider'],
|
|
110
|
+
key: 'website-feedback',
|
|
111
|
+
title: '官网反馈',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
components: ['Link', 'Button', 'Tabs', 'TabPane'],
|
|
115
|
+
key: 'website-navigation',
|
|
116
|
+
title: '官网导航',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
components: ['Card', 'Carousel', 'GridRow', 'GridCol', 'Flex', 'Space'],
|
|
120
|
+
key: 'website-layout',
|
|
121
|
+
title: '官网布局',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
components: ['Input', 'Select', 'SearchSelect'],
|
|
125
|
+
key: 'website-interaction',
|
|
126
|
+
title: '官网交互',
|
|
127
|
+
},
|
|
128
|
+
];
|