@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,18 @@
|
|
|
1
|
+
import type { DnComponentRegistryItem } from '@yimoka/designable-react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type IPlaygroundProductionReadinessDecision, type IPlaygroundProductionReadinessReport } from "../../shared/index.js";
|
|
4
|
+
import type { IComponentCategory } from "../../types.js";
|
|
5
|
+
export interface IProductionReadinessWidgetProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'title'> {
|
|
6
|
+
components: Record<string, DnComponentRegistryItem>;
|
|
7
|
+
categories?: IComponentCategory[];
|
|
8
|
+
report?: IPlaygroundProductionReadinessReport;
|
|
9
|
+
onReportChange?: (report: IPlaygroundProductionReadinessReport) => void;
|
|
10
|
+
onDecisionChange?: (decision: IPlaygroundProductionReadinessDecision) => void;
|
|
11
|
+
schema?: unknown;
|
|
12
|
+
requiredSettingsPropPaths?: Record<string, string[]>;
|
|
13
|
+
blockWarnings?: boolean;
|
|
14
|
+
showComponentDetails?: boolean;
|
|
15
|
+
maxComponents?: number;
|
|
16
|
+
title?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const ProductionReadinessWidget: React.FC<IProductionReadinessWidgetProps>;
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { usePrefix } from '@yimoka/designable-react';
|
|
3
|
+
import cls from 'classnames';
|
|
4
|
+
import { useEffect, useMemo } from 'react';
|
|
5
|
+
import { analyzePlaygroundProductionReadiness, getPlaygroundProductionReadinessDecision, getPlaygroundProductionReadinessPhaseSummary, getPlaygroundProductionReadinessStatus, } from "../../shared/index.js";
|
|
6
|
+
const toneStyles = {
|
|
7
|
+
danger: {
|
|
8
|
+
background: '#fff2f0',
|
|
9
|
+
borderColor: '#ffccc7',
|
|
10
|
+
color: '#a8071a',
|
|
11
|
+
},
|
|
12
|
+
muted: {
|
|
13
|
+
background: '#f7f9fc',
|
|
14
|
+
borderColor: '#dfe7f1',
|
|
15
|
+
color: '#4c5a6a',
|
|
16
|
+
},
|
|
17
|
+
success: {
|
|
18
|
+
background: '#f6ffed',
|
|
19
|
+
borderColor: '#b7eb8f',
|
|
20
|
+
color: '#237804',
|
|
21
|
+
},
|
|
22
|
+
warning: {
|
|
23
|
+
background: '#fffbe6',
|
|
24
|
+
borderColor: '#ffe58f',
|
|
25
|
+
color: '#874d00',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const getPercentText = (value, total) => {
|
|
29
|
+
if (total <= 0)
|
|
30
|
+
return '0%';
|
|
31
|
+
return `${Math.round((value / total) * 100)}%`;
|
|
32
|
+
};
|
|
33
|
+
const getIssueCounts = (report) => {
|
|
34
|
+
const errors = report.validation.issues.filter(issue => issue.severity === 'error').length;
|
|
35
|
+
const warnings = report.validation.issues.filter(issue => issue.severity === 'warning').length;
|
|
36
|
+
return { errors, warnings };
|
|
37
|
+
};
|
|
38
|
+
const getIssueMetricTone = (errors, warnings) => {
|
|
39
|
+
if (errors > 0)
|
|
40
|
+
return 'danger';
|
|
41
|
+
if (warnings > 0)
|
|
42
|
+
return 'warning';
|
|
43
|
+
return 'success';
|
|
44
|
+
};
|
|
45
|
+
const createSummaryMetrics = (report) => {
|
|
46
|
+
const { errors, warnings } = getIssueCounts(report);
|
|
47
|
+
const total = report.registry.totalComponentCount;
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
label: '组件',
|
|
51
|
+
tone: 'muted',
|
|
52
|
+
value: total,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: '可编辑',
|
|
56
|
+
tone: report.registry.editableComponentCount === total ? 'success' : 'warning',
|
|
57
|
+
value: getPercentText(report.registry.editableComponentCount, total),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: '可拖拽',
|
|
61
|
+
tone: report.registry.resourceComponentCount === total ? 'success' : 'warning',
|
|
62
|
+
value: getPercentText(report.registry.resourceComponentCount, total),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: '样式',
|
|
66
|
+
tone: report.settings.styleCapableComponentCount === total ? 'success' : 'warning',
|
|
67
|
+
value: getPercentText(report.settings.styleCapableComponentCount, total),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: '问题',
|
|
71
|
+
tone: getIssueMetricTone(errors, warnings),
|
|
72
|
+
value: `${errors}/${warnings}`,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: '通过',
|
|
76
|
+
tone: report.componentMatrix.blockedComponentCount > 0 || report.componentMatrix.warningComponentCount > 0
|
|
77
|
+
? 'warning'
|
|
78
|
+
: 'success',
|
|
79
|
+
value: getPercentText(report.componentMatrix.readyComponentCount, report.componentMatrix.totalComponentCount),
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
};
|
|
83
|
+
const SummaryCard = ({ metric }) => {
|
|
84
|
+
const toneStyle = toneStyles[metric.tone];
|
|
85
|
+
return (_jsxs("div", { style: {
|
|
86
|
+
background: toneStyle.background,
|
|
87
|
+
border: `1px solid ${toneStyle.borderColor}`,
|
|
88
|
+
borderRadius: 6,
|
|
89
|
+
boxSizing: 'border-box',
|
|
90
|
+
minWidth: 0,
|
|
91
|
+
padding: '8px 10px',
|
|
92
|
+
}, children: [_jsx("div", { style: {
|
|
93
|
+
color: '#6b7788',
|
|
94
|
+
fontSize: 11,
|
|
95
|
+
lineHeight: '16px',
|
|
96
|
+
}, children: metric.label }), _jsx("div", { style: {
|
|
97
|
+
color: toneStyle.color,
|
|
98
|
+
fontSize: 16,
|
|
99
|
+
fontWeight: 700,
|
|
100
|
+
lineHeight: '22px',
|
|
101
|
+
marginTop: 2,
|
|
102
|
+
}, children: metric.value })] }));
|
|
103
|
+
};
|
|
104
|
+
const statusBadgeMeta = {
|
|
105
|
+
blocked: {
|
|
106
|
+
label: '存在阻断',
|
|
107
|
+
tone: 'danger',
|
|
108
|
+
},
|
|
109
|
+
ready: {
|
|
110
|
+
label: '可生产接入',
|
|
111
|
+
tone: 'success',
|
|
112
|
+
},
|
|
113
|
+
warning: {
|
|
114
|
+
label: '存在待补',
|
|
115
|
+
tone: 'warning',
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
const StatusBadge = ({ status }) => {
|
|
119
|
+
const meta = statusBadgeMeta[status];
|
|
120
|
+
const toneStyle = toneStyles[meta.tone];
|
|
121
|
+
return (_jsx("span", { role: "status", style: {
|
|
122
|
+
background: toneStyle.background,
|
|
123
|
+
border: `1px solid ${toneStyle.borderColor}`,
|
|
124
|
+
borderRadius: 999,
|
|
125
|
+
color: toneStyle.color,
|
|
126
|
+
display: 'inline-block',
|
|
127
|
+
fontSize: 12,
|
|
128
|
+
fontWeight: 700,
|
|
129
|
+
lineHeight: '22px',
|
|
130
|
+
padding: '0 10px',
|
|
131
|
+
whiteSpace: 'nowrap',
|
|
132
|
+
}, children: meta.label }));
|
|
133
|
+
};
|
|
134
|
+
const getPhaseTone = (summary) => {
|
|
135
|
+
if (summary.phase === 'blocked')
|
|
136
|
+
return 'danger';
|
|
137
|
+
if (summary.phase === 'gray')
|
|
138
|
+
return 'warning';
|
|
139
|
+
return 'success';
|
|
140
|
+
};
|
|
141
|
+
const DecisionSummary = ({ phaseSummary }) => {
|
|
142
|
+
const { decision } = phaseSummary;
|
|
143
|
+
const tone = getPhaseTone(phaseSummary);
|
|
144
|
+
const toneStyle = toneStyles[tone];
|
|
145
|
+
const firstAction = phaseSummary.requiredActions[0] ?? phaseSummary.description;
|
|
146
|
+
return (_jsxs("div", { style: {
|
|
147
|
+
background: toneStyle.background,
|
|
148
|
+
border: `1px solid ${toneStyle.borderColor}`,
|
|
149
|
+
borderRadius: 6,
|
|
150
|
+
color: toneStyle.color,
|
|
151
|
+
display: 'grid',
|
|
152
|
+
gap: 6,
|
|
153
|
+
lineHeight: '18px',
|
|
154
|
+
padding: '8px 10px',
|
|
155
|
+
}, children: [_jsxs("div", { style: {
|
|
156
|
+
alignItems: 'center',
|
|
157
|
+
display: 'flex',
|
|
158
|
+
fontSize: 12,
|
|
159
|
+
fontWeight: 700,
|
|
160
|
+
gap: 8,
|
|
161
|
+
justifyContent: 'space-between',
|
|
162
|
+
minWidth: 0,
|
|
163
|
+
}, children: [_jsx("span", { style: {
|
|
164
|
+
overflow: 'hidden',
|
|
165
|
+
textOverflow: 'ellipsis',
|
|
166
|
+
whiteSpace: 'nowrap',
|
|
167
|
+
}, title: decision.summary, children: decision.summary }), _jsxs("span", { "aria-label": "\u53D1\u5E03\u51B3\u7B56", style: {
|
|
168
|
+
color: '#4c5a6a',
|
|
169
|
+
flex: '0 0 auto',
|
|
170
|
+
fontSize: 11,
|
|
171
|
+
fontWeight: 600,
|
|
172
|
+
}, children: ["\u9636\u6BB5\uFF1A", phaseSummary.title] })] }), _jsxs("div", { style: {
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
color: toneStyle.color,
|
|
175
|
+
display: 'grid',
|
|
176
|
+
fontSize: 11,
|
|
177
|
+
gap: 8,
|
|
178
|
+
gridTemplateColumns: 'minmax(0, 1fr) auto',
|
|
179
|
+
minWidth: 0,
|
|
180
|
+
}, children: [_jsx("span", { style: {
|
|
181
|
+
overflow: 'hidden',
|
|
182
|
+
textOverflow: 'ellipsis',
|
|
183
|
+
whiteSpace: 'nowrap',
|
|
184
|
+
}, title: phaseSummary.requiredActions.length ? phaseSummary.requiredActions.join(';') : phaseSummary.description, children: firstAction }), _jsxs("span", { "aria-label": "\u53D1\u5E03\u5F00\u5173", style: {
|
|
185
|
+
color: '#4c5a6a',
|
|
186
|
+
fontWeight: 600,
|
|
187
|
+
}, children: ["\u6B63\u5F0F ", decision.canPublish ? '允许' : '阻断', " / \u7070\u5EA6 ", decision.canGrayRelease ? '允许' : '阻断'] })] })] }));
|
|
188
|
+
};
|
|
189
|
+
const IssueList = ({ report }) => {
|
|
190
|
+
if (report.validation.issues.length === 0) {
|
|
191
|
+
return (_jsx("div", { style: {
|
|
192
|
+
background: '#f7fbff',
|
|
193
|
+
border: '1px solid #d8e8ff',
|
|
194
|
+
borderRadius: 6,
|
|
195
|
+
color: '#4e647d',
|
|
196
|
+
fontSize: 12,
|
|
197
|
+
lineHeight: '18px',
|
|
198
|
+
padding: '8px 10px',
|
|
199
|
+
}, children: "\u672A\u53D1\u73B0\u751F\u4EA7\u51C6\u5165\u963B\u65AD\u95EE\u9898" }));
|
|
200
|
+
}
|
|
201
|
+
return (_jsx("div", { style: {
|
|
202
|
+
display: 'grid',
|
|
203
|
+
gap: 6,
|
|
204
|
+
}, children: report.validation.issues.slice(0, 5).map(issue => (_jsxs("div", { style: {
|
|
205
|
+
alignItems: 'center',
|
|
206
|
+
background: issue.severity === 'error' ? '#fff7f6' : '#fffdf2',
|
|
207
|
+
border: `1px solid ${issue.severity === 'error' ? '#ffd4cf' : '#ffec99'}`,
|
|
208
|
+
borderRadius: 6,
|
|
209
|
+
color: issue.severity === 'error' ? '#a8071a' : '#7a4b00',
|
|
210
|
+
display: 'grid',
|
|
211
|
+
fontSize: 12,
|
|
212
|
+
gap: 8,
|
|
213
|
+
gridTemplateColumns: '54px minmax(0, 1fr)',
|
|
214
|
+
lineHeight: '18px',
|
|
215
|
+
minWidth: 0,
|
|
216
|
+
padding: '7px 9px',
|
|
217
|
+
}, title: issue.message, children: [_jsx("span", { style: { fontWeight: 700 }, children: issue.severity === 'error' ? '错误' : '警告' }), _jsx("span", { style: {
|
|
218
|
+
overflow: 'hidden',
|
|
219
|
+
textOverflow: 'ellipsis',
|
|
220
|
+
whiteSpace: 'nowrap',
|
|
221
|
+
}, children: issue.message })] }, `${issue.code}:${issue.path}`))) }));
|
|
222
|
+
};
|
|
223
|
+
const ComponentDetails = ({ maxComponents, report }) => {
|
|
224
|
+
const components = report.componentMatrix.components.slice(0, maxComponents);
|
|
225
|
+
const displayedCount = components.length;
|
|
226
|
+
const totalCount = report.componentMatrix.components.length;
|
|
227
|
+
const remainingCount = Math.max(totalCount - displayedCount, 0);
|
|
228
|
+
return (_jsxs("div", { style: {
|
|
229
|
+
border: '1px solid #e4ebf5',
|
|
230
|
+
borderRadius: 6,
|
|
231
|
+
overflow: 'hidden',
|
|
232
|
+
}, children: [_jsxs("div", { style: {
|
|
233
|
+
background: '#f8fafc',
|
|
234
|
+
borderBottom: '1px solid #e4ebf5',
|
|
235
|
+
color: '#6b7788',
|
|
236
|
+
display: 'grid',
|
|
237
|
+
fontSize: 11,
|
|
238
|
+
fontWeight: 700,
|
|
239
|
+
gridTemplateColumns: 'minmax(0, 1.3fr) 56px 44px 44px 44px minmax(0, 1.1fr)',
|
|
240
|
+
lineHeight: '28px',
|
|
241
|
+
padding: '0 10px',
|
|
242
|
+
}, children: [_jsx("span", { children: "\u7EC4\u4EF6" }), _jsx("span", { children: "\u72B6\u6001" }), _jsx("span", { children: "\u8D44\u6E90" }), _jsx("span", { children: "\u5C5E\u6027" }), _jsx("span", { children: "\u6837\u5F0F" }), _jsx("span", { children: "\u7F3A\u53E3" })] }), components.map(component => (_jsx(ComponentMatrixRow, { component: component }, component.componentName))), _jsxs("div", { style: {
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
background: '#fbfdff',
|
|
245
|
+
borderTop: '1px solid #edf2f7',
|
|
246
|
+
color: '#6b7788',
|
|
247
|
+
display: 'flex',
|
|
248
|
+
fontSize: 11,
|
|
249
|
+
justifyContent: 'space-between',
|
|
250
|
+
lineHeight: '26px',
|
|
251
|
+
padding: '0 10px',
|
|
252
|
+
}, children: [_jsxs("span", { children: ["\u5DF2\u663E\u793A ", displayedCount, " / ", totalCount] }), remainingCount > 0 && (_jsxs("span", { children: ["\u8FD8\u6709 ", remainingCount, " \u4E2A\u7EC4\u4EF6\u672A\u5C55\u793A"] }))] })] }));
|
|
253
|
+
};
|
|
254
|
+
const statusLabels = {
|
|
255
|
+
blocked: '阻断',
|
|
256
|
+
ready: '通过',
|
|
257
|
+
warning: '待补',
|
|
258
|
+
};
|
|
259
|
+
const getStatusTone = (status) => {
|
|
260
|
+
if (status === 'blocked')
|
|
261
|
+
return 'danger';
|
|
262
|
+
if (status === 'warning')
|
|
263
|
+
return 'warning';
|
|
264
|
+
return 'success';
|
|
265
|
+
};
|
|
266
|
+
const ComponentMatrixRow = ({ component }) => {
|
|
267
|
+
const toneStyle = toneStyles[getStatusTone(component.status)];
|
|
268
|
+
const missingPropsText = component.missingRequiredSettingsPropPaths.length
|
|
269
|
+
? `缺属性 ${component.missingRequiredSettingsPropPaths.length}: ${component.missingRequiredSettingsPropPaths.slice(0, 3).join('、')}`
|
|
270
|
+
: '';
|
|
271
|
+
const reasonText = missingPropsText || component.reasons.join(';');
|
|
272
|
+
const reasonTitle = component.missingRequiredSettingsPropPaths.length
|
|
273
|
+
? `缺少生产关键属性:${component.missingRequiredSettingsPropPaths.join('、')}`
|
|
274
|
+
: reasonText;
|
|
275
|
+
return (_jsxs("div", { style: {
|
|
276
|
+
alignItems: 'center',
|
|
277
|
+
borderTop: '1px solid #edf2f7',
|
|
278
|
+
color: '#243247',
|
|
279
|
+
display: 'grid',
|
|
280
|
+
fontSize: 12,
|
|
281
|
+
gridTemplateColumns: 'minmax(0, 1.3fr) 56px 44px 44px 44px minmax(0, 1.1fr)',
|
|
282
|
+
lineHeight: '32px',
|
|
283
|
+
minWidth: 0,
|
|
284
|
+
padding: '0 10px',
|
|
285
|
+
}, children: [_jsx("span", { style: {
|
|
286
|
+
fontWeight: 700,
|
|
287
|
+
overflow: 'hidden',
|
|
288
|
+
textOverflow: 'ellipsis',
|
|
289
|
+
whiteSpace: 'nowrap',
|
|
290
|
+
}, title: component.componentName, children: component.componentName }), _jsx("span", { style: {
|
|
291
|
+
background: toneStyle.background,
|
|
292
|
+
border: `1px solid ${toneStyle.borderColor}`,
|
|
293
|
+
borderRadius: 999,
|
|
294
|
+
color: toneStyle.color,
|
|
295
|
+
fontSize: 11,
|
|
296
|
+
fontWeight: 700,
|
|
297
|
+
lineHeight: '20px',
|
|
298
|
+
textAlign: 'center',
|
|
299
|
+
}, children: statusLabels[component.status] }), _jsx("span", { children: component.hasResource ? '有' : '缺' }), _jsx("span", { children: component.settingsEditablePropCount }), _jsx("span", { children: component.settingsStylePropertyCount }), _jsx("span", { style: {
|
|
300
|
+
color: reasonText ? '#6b7788' : '#98a2b3',
|
|
301
|
+
overflow: 'hidden',
|
|
302
|
+
textOverflow: 'ellipsis',
|
|
303
|
+
whiteSpace: 'nowrap',
|
|
304
|
+
}, title: reasonTitle, children: reasonText || '无' })] }));
|
|
305
|
+
};
|
|
306
|
+
export const ProductionReadinessWidget = ({ blockWarnings = true, categories, className, components, maxComponents = 10, onDecisionChange, onReportChange, report: reportProp, requiredSettingsPropPaths, schema, showComponentDetails = true, style, title = '生产准入', ...restProps }) => {
|
|
307
|
+
const prefix = usePrefix('production-readiness');
|
|
308
|
+
const report = useMemo(() => reportProp ?? analyzePlaygroundProductionReadiness(components, {
|
|
309
|
+
categories,
|
|
310
|
+
requiredSettingsPropPaths,
|
|
311
|
+
schema,
|
|
312
|
+
}), [categories, components, reportProp, requiredSettingsPropPaths, schema]);
|
|
313
|
+
const metrics = useMemo(() => createSummaryMetrics(report), [report]);
|
|
314
|
+
const readinessStatus = useMemo(() => getPlaygroundProductionReadinessStatus(report), [report]);
|
|
315
|
+
const readinessDecision = useMemo(() => getPlaygroundProductionReadinessDecision(report, { blockWarnings }), [blockWarnings, report]);
|
|
316
|
+
const readinessPhaseSummary = useMemo(() => getPlaygroundProductionReadinessPhaseSummary(report, { blockWarnings }), [blockWarnings, report]);
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
onReportChange?.(report);
|
|
319
|
+
}, [onReportChange, report]);
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
onDecisionChange?.(readinessDecision);
|
|
322
|
+
}, [onDecisionChange, readinessDecision]);
|
|
323
|
+
return (_jsxs("div", { ...restProps, "aria-label": "\u751F\u4EA7\u51C6\u5165\u8BCA\u65AD", className: cls(prefix, className), role: "region", style: {
|
|
324
|
+
background: '#ffffff',
|
|
325
|
+
border: '1px solid #dfe7f1',
|
|
326
|
+
borderRadius: 8,
|
|
327
|
+
boxShadow: '0 8px 24px rgba(18, 38, 63, 0.08)',
|
|
328
|
+
boxSizing: 'border-box',
|
|
329
|
+
color: '#1f2d3d',
|
|
330
|
+
display: 'grid',
|
|
331
|
+
gap: 10,
|
|
332
|
+
maxWidth: 620,
|
|
333
|
+
minWidth: 320,
|
|
334
|
+
padding: 12,
|
|
335
|
+
...style,
|
|
336
|
+
}, children: [_jsxs("div", { style: {
|
|
337
|
+
alignItems: 'center',
|
|
338
|
+
display: 'flex',
|
|
339
|
+
gap: 12,
|
|
340
|
+
justifyContent: 'space-between',
|
|
341
|
+
minWidth: 0,
|
|
342
|
+
}, children: [_jsx("div", { style: {
|
|
343
|
+
fontSize: 14,
|
|
344
|
+
fontWeight: 700,
|
|
345
|
+
lineHeight: '22px',
|
|
346
|
+
minWidth: 0,
|
|
347
|
+
overflow: 'hidden',
|
|
348
|
+
textOverflow: 'ellipsis',
|
|
349
|
+
whiteSpace: 'nowrap',
|
|
350
|
+
}, children: title }), _jsx(StatusBadge, { status: readinessStatus })] }), _jsx("div", { style: {
|
|
351
|
+
display: 'grid',
|
|
352
|
+
gap: 8,
|
|
353
|
+
gridTemplateColumns: 'repeat(6, minmax(0, 1fr))',
|
|
354
|
+
}, children: metrics.map(metric => (_jsx(SummaryCard, { metric: metric }, metric.label))) }), _jsx(DecisionSummary, { phaseSummary: readinessPhaseSummary }), _jsx(IssueList, { report: report }), showComponentDetails && (_jsx(ComponentDetails, { maxComponents: maxComponents, report: report }))] }));
|
|
355
|
+
};
|
|
356
|
+
ProductionReadinessWidget.displayName = 'ProductionReadinessWidget';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IUsePlaygroundRemotePersistenceResult } from "../../hooks/usePlaygroundRemotePersistence.js";
|
|
3
|
+
export interface IRemotePersistenceActionPermissions {
|
|
4
|
+
canLoad?: boolean;
|
|
5
|
+
canSave?: boolean;
|
|
6
|
+
canPublish?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface IRemotePersistenceStatusWidgetProps<S = unknown> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
9
|
+
persistence: Pick<IUsePlaygroundRemotePersistenceResult<S>, 'canSave' | 'conflicted' | 'dirty' | 'error' | 'lastErrorAction' | 'lastErrorReason' | 'lastLoadedAt' | 'lastSaveAttemptMode' | 'lastSaveMetadata' | 'lastSaveValidation' | 'lastSavedAt' | 'loadRemoteSchema' | 'loading' | 'saveRemoteSchema' | 'saving' | 'status'>;
|
|
10
|
+
showLoadAction?: boolean;
|
|
11
|
+
showPublishAction?: boolean;
|
|
12
|
+
showDiagnostics?: boolean;
|
|
13
|
+
showTimestamp?: boolean;
|
|
14
|
+
actionPermissions?: IRemotePersistenceActionPermissions;
|
|
15
|
+
remoteMetadata?: Record<string, unknown>;
|
|
16
|
+
revision?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const RemotePersistenceStatusWidget: React.MemoExoticComponent<import("@formily/reactive-react").ReactFC<IRemotePersistenceStatusWidgetProps<unknown>>>;
|