@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,438 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { observer } from '@formily/reactive-react';
|
|
3
|
+
import { usePrefix, useUIAdapter } from '@yimoka/designable-react';
|
|
4
|
+
import cls from 'classnames';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
const getErrorMessage = (error) => {
|
|
7
|
+
if (error instanceof Error)
|
|
8
|
+
return error.message;
|
|
9
|
+
if (typeof error === 'string' && error.trim())
|
|
10
|
+
return error;
|
|
11
|
+
return '未知错误';
|
|
12
|
+
};
|
|
13
|
+
const formatTime = (date) => {
|
|
14
|
+
if (!date)
|
|
15
|
+
return '';
|
|
16
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
17
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
18
|
+
};
|
|
19
|
+
const isPublishSaveAttempt = (persistence) => persistence.lastSaveAttemptMode === 'publish' || persistence.lastSaveMetadata?.mode === 'publish';
|
|
20
|
+
const getErrorLabel = (persistence) => {
|
|
21
|
+
const action = persistence.lastErrorAction;
|
|
22
|
+
if (action === 'load')
|
|
23
|
+
return '加载失败';
|
|
24
|
+
if (action === 'save')
|
|
25
|
+
return isPublishSaveAttempt(persistence) ? '发布失败' : '保存失败';
|
|
26
|
+
return '同步失败';
|
|
27
|
+
};
|
|
28
|
+
const toneStyles = {
|
|
29
|
+
danger: {
|
|
30
|
+
background: '#fff2f0',
|
|
31
|
+
borderColor: '#ffccc7',
|
|
32
|
+
color: '#a8071a',
|
|
33
|
+
},
|
|
34
|
+
info: {
|
|
35
|
+
background: '#e6f4ff',
|
|
36
|
+
borderColor: '#91caff',
|
|
37
|
+
color: '#0958d9',
|
|
38
|
+
},
|
|
39
|
+
muted: {
|
|
40
|
+
background: '#f6f8fb',
|
|
41
|
+
borderColor: '#dfe7f1',
|
|
42
|
+
color: '#5f6b7a',
|
|
43
|
+
},
|
|
44
|
+
success: {
|
|
45
|
+
background: '#f6ffed',
|
|
46
|
+
borderColor: '#b7eb8f',
|
|
47
|
+
color: '#237804',
|
|
48
|
+
},
|
|
49
|
+
warning: {
|
|
50
|
+
background: '#fffbe6',
|
|
51
|
+
borderColor: '#ffe58f',
|
|
52
|
+
color: '#874d00',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const getPersistenceStatus = (persistence, timestamp) => {
|
|
56
|
+
if (persistence.loading)
|
|
57
|
+
return { tone: 'info', text: '远程加载中' };
|
|
58
|
+
if (persistence.saving) {
|
|
59
|
+
return { tone: 'info', text: isPublishSaveAttempt(persistence) ? '远程发布中' : '远程保存中' };
|
|
60
|
+
}
|
|
61
|
+
if (isConflictStatus(persistence))
|
|
62
|
+
return getConflictStatus(persistence.error);
|
|
63
|
+
if (persistence.status === 'error')
|
|
64
|
+
return getErrorStatus(persistence);
|
|
65
|
+
if (persistence.dirty)
|
|
66
|
+
return { tone: 'warning', text: '存在未保存变更' };
|
|
67
|
+
if (persistence.status === 'saved')
|
|
68
|
+
return getSavedStatus(persistence, timestamp);
|
|
69
|
+
if (persistence.status === 'loaded')
|
|
70
|
+
return getSuccessStatus('已加载', timestamp);
|
|
71
|
+
return { tone: 'muted', text: '等待同步' };
|
|
72
|
+
};
|
|
73
|
+
const isConflictStatus = (persistence) => persistence.status === 'conflict' || persistence.conflicted;
|
|
74
|
+
const getConflictStatus = (error) => ({
|
|
75
|
+
tone: 'warning',
|
|
76
|
+
text: `远程版本冲突:${getErrorMessage(error)}`,
|
|
77
|
+
});
|
|
78
|
+
const getErrorStatus = (persistence) => ({
|
|
79
|
+
tone: 'danger',
|
|
80
|
+
text: `${getErrorLabel(persistence)}:${getErrorMessage(persistence.error)}`,
|
|
81
|
+
});
|
|
82
|
+
const getSuccessStatus = (label, timestamp) => ({
|
|
83
|
+
tone: 'success',
|
|
84
|
+
text: timestamp ? `${label} ${timestamp}` : label,
|
|
85
|
+
});
|
|
86
|
+
const getSavedWarningCount = (persistence) => {
|
|
87
|
+
const issues = persistence.lastSaveValidation?.issues ?? [];
|
|
88
|
+
return issues.filter(issue => issue.severity === 'warning').length;
|
|
89
|
+
};
|
|
90
|
+
const getSavedStatus = (persistence, timestamp) => {
|
|
91
|
+
const warningCount = getSavedWarningCount(persistence);
|
|
92
|
+
if (warningCount <= 0)
|
|
93
|
+
return getSuccessStatus('已保存', timestamp);
|
|
94
|
+
return {
|
|
95
|
+
tone: 'warning',
|
|
96
|
+
text: timestamp
|
|
97
|
+
? `已保存,存在 ${warningCount} 个提示 ${timestamp}`
|
|
98
|
+
: `已保存,存在 ${warningCount} 个提示`,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const countValidationIssues = (persistence, severity) => (persistence.lastSaveValidation?.issues.filter(issue => issue.severity === severity).length ?? 0);
|
|
102
|
+
const getMetadataCount = (metadata) => (metadata ? Object.keys(metadata).length : 0);
|
|
103
|
+
const getMetadataTitle = (metadata) => {
|
|
104
|
+
if (!metadata)
|
|
105
|
+
return undefined;
|
|
106
|
+
try {
|
|
107
|
+
return JSON.stringify(metadata);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return '远程元数据';
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const getValidationDiagnosticColor = (errorCount, warningCount) => {
|
|
114
|
+
if (errorCount > 0)
|
|
115
|
+
return '#a8071a';
|
|
116
|
+
if (warningCount > 0)
|
|
117
|
+
return '#874d00';
|
|
118
|
+
return '#237804';
|
|
119
|
+
};
|
|
120
|
+
const errorReasonLabels = {
|
|
121
|
+
'baseline-sync': '基线同步失败',
|
|
122
|
+
conflict: '版本冲突',
|
|
123
|
+
export: '导出失败',
|
|
124
|
+
'load-protected-dirty': 'dirty 加载保护',
|
|
125
|
+
'permission-denied': '权限不足',
|
|
126
|
+
'production-acceptance': '生产验收阻断',
|
|
127
|
+
'production-readiness': '生产准入阻断',
|
|
128
|
+
remote: '远程失败',
|
|
129
|
+
'save-stale': '保存期间变更',
|
|
130
|
+
unknown: '未知失败',
|
|
131
|
+
validation: '校验失败',
|
|
132
|
+
};
|
|
133
|
+
const getErrorReasonText = (reason) => (reason ? errorReasonLabels[reason] : undefined);
|
|
134
|
+
const getErrorReasonColor = (reason) => {
|
|
135
|
+
if (reason === 'conflict' || reason === 'save-stale' || reason === 'load-protected-dirty')
|
|
136
|
+
return '#874d00';
|
|
137
|
+
if (reason)
|
|
138
|
+
return '#a8071a';
|
|
139
|
+
return '#46566f';
|
|
140
|
+
};
|
|
141
|
+
const isRecord = (value) => (typeof value === 'object' && value !== null);
|
|
142
|
+
const getErrorAcceptanceSnapshot = (error) => {
|
|
143
|
+
if (!isRecord(error) || !isRecord(error.acceptanceSnapshot))
|
|
144
|
+
return undefined;
|
|
145
|
+
return error.acceptanceSnapshot;
|
|
146
|
+
};
|
|
147
|
+
const getErrorAcceptancePhaseSummary = (error) => {
|
|
148
|
+
if (!isRecord(error) || !isRecord(error.acceptancePhaseSummary))
|
|
149
|
+
return undefined;
|
|
150
|
+
return error.acceptancePhaseSummary;
|
|
151
|
+
};
|
|
152
|
+
const getStringValue = (value) => (typeof value === 'string' ? value : undefined);
|
|
153
|
+
const getNumberValue = (value) => (typeof value === 'number' ? value : undefined);
|
|
154
|
+
const getAcceptanceCaseDetails = (errorSnapshot) => {
|
|
155
|
+
const cases = Array.isArray(errorSnapshot?.cases) ? errorSnapshot.cases : [];
|
|
156
|
+
return cases
|
|
157
|
+
.filter((item) => isRecord(item) && item.status !== 'ready')
|
|
158
|
+
.map(item => ({
|
|
159
|
+
name: getStringValue(item.name) ?? '未命名样本',
|
|
160
|
+
reasons: Array.isArray(item.reasons) ? item.reasons.filter(reason => typeof reason === 'string') : [],
|
|
161
|
+
status: getStringValue(item.status) ?? 'blocked',
|
|
162
|
+
}));
|
|
163
|
+
};
|
|
164
|
+
const formatAcceptanceCaseDetail = (item) => (`${item.name}:${item.reasons.join(';') || '未通过生产试点验收'}`);
|
|
165
|
+
const getAcceptanceStatus = (persistence, errorSnapshot) => persistence.lastSaveMetadata?.productionAcceptanceStatus ?? getStringValue(errorSnapshot?.status);
|
|
166
|
+
const getAcceptanceTotalCaseCount = (persistence, errorSnapshot) => persistence.lastSaveMetadata?.productionAcceptanceCaseCount ?? getNumberValue(errorSnapshot?.totalCaseCount);
|
|
167
|
+
const getAcceptanceBlockedCaseCount = (persistence, errorSnapshot) => (persistence.lastSaveMetadata?.productionAcceptanceBlockedCaseCount ?? getNumberValue(errorSnapshot?.blockedCaseCount));
|
|
168
|
+
const getAcceptanceSummary = (persistence, errorSnapshot) => persistence.lastSaveMetadata?.productionAcceptanceSummary ?? getStringValue(errorSnapshot?.summary);
|
|
169
|
+
const getAcceptancePhaseTitle = (persistence, errorPhaseSummary) => (persistence.lastSaveMetadata?.productionAcceptancePhaseTitle
|
|
170
|
+
?? getStringValue(errorPhaseSummary?.title));
|
|
171
|
+
const getAcceptanceTitleParts = (phaseTitle, summary) => [
|
|
172
|
+
phaseTitle && !summary?.startsWith(phaseTitle) ? phaseTitle : undefined,
|
|
173
|
+
summary,
|
|
174
|
+
].filter(Boolean);
|
|
175
|
+
const getAcceptanceDiagnostic = (persistence) => {
|
|
176
|
+
const errorSnapshot = getErrorAcceptanceSnapshot(persistence.error);
|
|
177
|
+
const errorPhaseSummary = getErrorAcceptancePhaseSummary(persistence.error);
|
|
178
|
+
const status = getAcceptanceStatus(persistence, errorSnapshot);
|
|
179
|
+
if (!status)
|
|
180
|
+
return undefined;
|
|
181
|
+
const totalCaseCount = getAcceptanceTotalCaseCount(persistence, errorSnapshot);
|
|
182
|
+
const blockedCaseCount = getAcceptanceBlockedCaseCount(persistence, errorSnapshot);
|
|
183
|
+
const summary = getAcceptanceSummary(persistence, errorSnapshot);
|
|
184
|
+
const phaseTitle = getAcceptancePhaseTitle(persistence, errorPhaseSummary);
|
|
185
|
+
const cases = getAcceptanceCaseDetails(errorSnapshot);
|
|
186
|
+
const caseReasons = cases.map(formatAcceptanceCaseDetail);
|
|
187
|
+
return {
|
|
188
|
+
blockedCaseCount,
|
|
189
|
+
cases,
|
|
190
|
+
phaseTitle,
|
|
191
|
+
status,
|
|
192
|
+
summary,
|
|
193
|
+
title: [...getAcceptanceTitleParts(phaseTitle, summary), ...caseReasons].join(';') || '生产试点验收',
|
|
194
|
+
totalCaseCount,
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
const getAcceptanceDiagnosticColor = (status) => {
|
|
198
|
+
if (status === 'blocked')
|
|
199
|
+
return '#a8071a';
|
|
200
|
+
if (status === 'warning')
|
|
201
|
+
return '#874d00';
|
|
202
|
+
return '#237804';
|
|
203
|
+
};
|
|
204
|
+
const getAcceptanceDiagnosticText = ({ blockedCaseCount, phaseTitle, status, totalCaseCount, }) => {
|
|
205
|
+
const countText = typeof blockedCaseCount === 'number' && typeof totalCaseCount === 'number'
|
|
206
|
+
? ` ${blockedCaseCount}/${totalCaseCount}`
|
|
207
|
+
: '';
|
|
208
|
+
if (phaseTitle) {
|
|
209
|
+
if (status === 'ready' && typeof totalCaseCount === 'number')
|
|
210
|
+
return `${phaseTitle} ${totalCaseCount}`;
|
|
211
|
+
return `${phaseTitle}${countText}`;
|
|
212
|
+
}
|
|
213
|
+
if (status === 'blocked')
|
|
214
|
+
return `试点阻断${countText}`;
|
|
215
|
+
if (status === 'warning')
|
|
216
|
+
return `试点关注${countText}`;
|
|
217
|
+
if (typeof totalCaseCount === 'number')
|
|
218
|
+
return `试点通过 ${totalCaseCount}`;
|
|
219
|
+
return '试点通过';
|
|
220
|
+
};
|
|
221
|
+
const getSaveModeText = (persistence) => {
|
|
222
|
+
if (persistence.lastSaveMetadata?.mode === 'publish')
|
|
223
|
+
return '已发布';
|
|
224
|
+
if (persistence.lastSaveMetadata?.mode === 'draft')
|
|
225
|
+
return '草稿';
|
|
226
|
+
return undefined;
|
|
227
|
+
};
|
|
228
|
+
const SaveModeBadge = ({ text }) => (text ? (_jsx("span", { "aria-label": "\u4FDD\u5B58\u6A21\u5F0F", style: diagnosticBadgeStyle, children: text })) : null);
|
|
229
|
+
const RevisionBadge = ({ revision }) => (revision ? (_jsxs("span", { "aria-label": "\u8FDC\u7A0B\u7248\u672C", style: diagnosticBadgeStyle, title: revision, children: ["\u7248\u672C ", revision] })) : null);
|
|
230
|
+
const MetadataBadge = ({ count, title }) => (count > 0 ? (_jsxs("span", { "aria-label": "\u8FDC\u7A0B\u5143\u6570\u636E", style: diagnosticBadgeStyle, title: title, children: ["\u5143\u6570\u636E ", count, " \u9879"] })) : null);
|
|
231
|
+
const ValidationBadge = ({ errorCount, title, warningCount }) => (_jsxs("span", { "aria-label": "\u4FDD\u5B58\u6821\u9A8C\u6458\u8981", style: {
|
|
232
|
+
...diagnosticBadgeStyle,
|
|
233
|
+
color: getValidationDiagnosticColor(errorCount, warningCount),
|
|
234
|
+
}, title: title, children: ["\u6821\u9A8C ", errorCount, " \u9519 / ", warningCount, " \u8B66"] }));
|
|
235
|
+
const ErrorReasonBadge = ({ reason }) => {
|
|
236
|
+
const text = getErrorReasonText(reason);
|
|
237
|
+
if (!text)
|
|
238
|
+
return null;
|
|
239
|
+
return (_jsxs("span", { "aria-label": "\u5931\u8D25\u539F\u56E0", style: {
|
|
240
|
+
...diagnosticBadgeStyle,
|
|
241
|
+
color: getErrorReasonColor(reason),
|
|
242
|
+
}, title: `失败原因:${reason}`, children: ["\u539F\u56E0 ", text] }));
|
|
243
|
+
};
|
|
244
|
+
const AcceptanceBadge = ({ blockedCaseCount, phaseTitle, status, title, totalCaseCount, }) => (_jsx("span", { "aria-label": "\u751F\u4EA7\u8BD5\u70B9\u9A8C\u6536", style: {
|
|
245
|
+
...diagnosticBadgeStyle,
|
|
246
|
+
color: getAcceptanceDiagnosticColor(status),
|
|
247
|
+
}, title: title, children: getAcceptanceDiagnosticText({
|
|
248
|
+
blockedCaseCount,
|
|
249
|
+
phaseTitle,
|
|
250
|
+
status,
|
|
251
|
+
totalCaseCount,
|
|
252
|
+
}) }));
|
|
253
|
+
const AcceptanceDetailButton = ({ diagnostic }) => {
|
|
254
|
+
const { Button } = useUIAdapter();
|
|
255
|
+
const [open, setOpen] = React.useState(false);
|
|
256
|
+
if (diagnostic.cases.length <= 0)
|
|
257
|
+
return null;
|
|
258
|
+
return (_jsxs("span", { style: { position: 'relative' }, children: [_jsx(Button, { ariaLabel: "\u67E5\u770B\u751F\u4EA7\u8BD5\u70B9\u9A8C\u6536\u8BE6\u60C5", size: "small", onClick: () => setOpen(value => !value), children: "\u8BE6\u60C5" }), open ? (_jsxs("div", { "aria-label": "\u751F\u4EA7\u8BD5\u70B9\u9A8C\u6536\u8BE6\u60C5", role: "region", style: acceptanceDetailPanelStyle, children: [_jsx("div", { style: acceptanceDetailTitleStyle, children: getAcceptanceTitleParts(diagnostic.phaseTitle, diagnostic.summary).join(':') || '生产试点验收详情' }), diagnostic.cases.map((item, index) => (_jsxs("div", { style: acceptanceDetailItemStyle, children: [_jsx("strong", { children: item.name }), _jsx("span", { children: item.reasons.join(';') || '未通过生产试点验收' })] }, `${item.name}-${index}`)))] })) : null] }));
|
|
259
|
+
};
|
|
260
|
+
const shouldShowDiagnostics = ({ acceptanceDiagnostic, hasErrorReason, hasValidation, metadataCount, revision, saveModeText, }) => Boolean(revision
|
|
261
|
+
|| metadataCount > 0
|
|
262
|
+
|| hasValidation
|
|
263
|
+
|| hasErrorReason
|
|
264
|
+
|| saveModeText
|
|
265
|
+
|| acceptanceDiagnostic);
|
|
266
|
+
const RemotePersistenceDiagnostics = ({ persistence, remoteMetadata, revision, }) => {
|
|
267
|
+
const metadataCount = getMetadataCount(remoteMetadata);
|
|
268
|
+
const errorCount = countValidationIssues(persistence, 'error');
|
|
269
|
+
const warningCount = countValidationIssues(persistence, 'warning');
|
|
270
|
+
const hasValidation = Boolean(persistence.lastSaveValidation);
|
|
271
|
+
const hasErrorReason = Boolean(persistence.lastErrorReason);
|
|
272
|
+
const metadataTitle = getMetadataTitle(remoteMetadata);
|
|
273
|
+
const saveModeText = getSaveModeText(persistence);
|
|
274
|
+
const acceptanceDiagnostic = getAcceptanceDiagnostic(persistence);
|
|
275
|
+
if (!shouldShowDiagnostics({
|
|
276
|
+
acceptanceDiagnostic,
|
|
277
|
+
hasErrorReason,
|
|
278
|
+
hasValidation,
|
|
279
|
+
metadataCount,
|
|
280
|
+
revision,
|
|
281
|
+
saveModeText,
|
|
282
|
+
}))
|
|
283
|
+
return null;
|
|
284
|
+
return (_jsxs(_Fragment, { children: [_jsx(SaveModeBadge, { text: saveModeText }), _jsx(ErrorReasonBadge, { reason: persistence.lastErrorReason }), _jsx(RevisionBadge, { revision: revision }), _jsx(MetadataBadge, { count: metadataCount, title: metadataTitle }), hasValidation ? (_jsx(ValidationBadge, { errorCount: errorCount, title: persistence.lastSaveValidation?.issues.map(issue => issue.message).join(';') || '校验通过', warningCount: warningCount })) : null, acceptanceDiagnostic ? (_jsxs(_Fragment, { children: [_jsx(AcceptanceBadge, { blockedCaseCount: acceptanceDiagnostic.blockedCaseCount, phaseTitle: acceptanceDiagnostic.phaseTitle, status: acceptanceDiagnostic.status, title: acceptanceDiagnostic.title, totalCaseCount: acceptanceDiagnostic.totalCaseCount }), _jsx(AcceptanceDetailButton, { diagnostic: acceptanceDiagnostic })] })) : null] }));
|
|
285
|
+
};
|
|
286
|
+
const acceptanceDetailPanelStyle = {
|
|
287
|
+
background: '#fff',
|
|
288
|
+
border: '1px solid #dfe7f1',
|
|
289
|
+
borderRadius: 8,
|
|
290
|
+
boxShadow: '0 8px 24px rgba(15, 23, 42, 0.14)',
|
|
291
|
+
boxSizing: 'border-box',
|
|
292
|
+
color: '#253041',
|
|
293
|
+
display: 'grid',
|
|
294
|
+
gap: 8,
|
|
295
|
+
maxHeight: 260,
|
|
296
|
+
overflow: 'auto',
|
|
297
|
+
padding: 10,
|
|
298
|
+
position: 'absolute',
|
|
299
|
+
right: 0,
|
|
300
|
+
top: 30,
|
|
301
|
+
width: 320,
|
|
302
|
+
zIndex: 20,
|
|
303
|
+
};
|
|
304
|
+
const acceptanceDetailTitleStyle = {
|
|
305
|
+
color: '#46566f',
|
|
306
|
+
fontSize: 12,
|
|
307
|
+
fontWeight: 600,
|
|
308
|
+
lineHeight: '18px',
|
|
309
|
+
};
|
|
310
|
+
const acceptanceDetailItemStyle = {
|
|
311
|
+
display: 'grid',
|
|
312
|
+
fontSize: 12,
|
|
313
|
+
gap: 4,
|
|
314
|
+
lineHeight: '18px',
|
|
315
|
+
};
|
|
316
|
+
const diagnosticBadgeStyle = {
|
|
317
|
+
background: '#f8fafc',
|
|
318
|
+
border: '1px solid #dfe7f1',
|
|
319
|
+
borderRadius: 999,
|
|
320
|
+
boxSizing: 'border-box',
|
|
321
|
+
color: '#46566f',
|
|
322
|
+
display: 'inline-block',
|
|
323
|
+
flex: '0 1 auto',
|
|
324
|
+
fontSize: 12,
|
|
325
|
+
lineHeight: '22px',
|
|
326
|
+
maxWidth: 128,
|
|
327
|
+
minHeight: 24,
|
|
328
|
+
overflow: 'hidden',
|
|
329
|
+
padding: '0 8px',
|
|
330
|
+
textOverflow: 'ellipsis',
|
|
331
|
+
whiteSpace: 'nowrap',
|
|
332
|
+
};
|
|
333
|
+
const getTimestamp = (persistence, showTimestamp) => {
|
|
334
|
+
if (!showTimestamp)
|
|
335
|
+
return '';
|
|
336
|
+
return formatTime(persistence.lastSavedAt ?? persistence.lastLoadedAt);
|
|
337
|
+
};
|
|
338
|
+
const getActionState = (actionPermissions, persistence, showLoadAction, showPublishAction) => {
|
|
339
|
+
const busy = persistence.loading || persistence.saving;
|
|
340
|
+
const permissions = normalizeActionPermissions(actionPermissions);
|
|
341
|
+
return {
|
|
342
|
+
showPublishAction: canShowPublishAction(persistence, showPublishAction, busy, permissions),
|
|
343
|
+
showReloadAction: canShowReloadAction(persistence, showLoadAction, busy, permissions),
|
|
344
|
+
showSaveAction: canShowSaveAction(persistence, busy, permissions),
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
const normalizeActionPermissions = (actionPermissions) => ({
|
|
348
|
+
canLoad: actionPermissions?.canLoad ?? true,
|
|
349
|
+
canPublish: actionPermissions?.canPublish ?? true,
|
|
350
|
+
canSave: actionPermissions?.canSave ?? true,
|
|
351
|
+
});
|
|
352
|
+
const canShowReloadAction = (persistence, showLoadAction, busy, permissions) => (showLoadAction
|
|
353
|
+
&& permissions.canLoad
|
|
354
|
+
&& !busy
|
|
355
|
+
&& (isConflictStatus(persistence)
|
|
356
|
+
|| (persistence.status === 'error' && persistence.lastErrorAction === 'load')));
|
|
357
|
+
const canShowSaveAction = (persistence, busy, permissions) => (persistence.canSave
|
|
358
|
+
&& !busy
|
|
359
|
+
&& !isConflictStatus(persistence)
|
|
360
|
+
&& (persistence.status === 'error' && isPublishSaveAttempt(persistence)
|
|
361
|
+
? permissions.canPublish
|
|
362
|
+
: permissions.canSave)
|
|
363
|
+
&& (persistence.dirty || (persistence.status === 'error' && persistence.lastErrorAction !== 'load')));
|
|
364
|
+
const canShowPublishAction = (persistence, showPublishAction, busy, permissions) => (showPublishAction
|
|
365
|
+
&& permissions.canPublish
|
|
366
|
+
&& persistence.canSave
|
|
367
|
+
&& !busy
|
|
368
|
+
&& !isConflictStatus(persistence)
|
|
369
|
+
&& (persistence.dirty
|
|
370
|
+
|| persistence.status === 'loaded'
|
|
371
|
+
|| persistence.status === 'saved'));
|
|
372
|
+
const getSaveAction = (persistence) => {
|
|
373
|
+
const isRetry = persistence.status === 'error';
|
|
374
|
+
const isPublishRetry = isRetry && isPublishSaveAttempt(persistence);
|
|
375
|
+
if (isPublishRetry) {
|
|
376
|
+
return {
|
|
377
|
+
ariaLabel: '重试远程发布',
|
|
378
|
+
label: '重试发布',
|
|
379
|
+
options: { mode: 'publish' },
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
if (isRetry) {
|
|
383
|
+
return {
|
|
384
|
+
ariaLabel: '重试远程保存',
|
|
385
|
+
label: '重试',
|
|
386
|
+
options: undefined,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
ariaLabel: '远程保存',
|
|
391
|
+
label: '保存',
|
|
392
|
+
options: undefined,
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
const RemotePersistenceActions = ({ persistence, showPublishAction, showReloadAction, showSaveAction, }) => {
|
|
396
|
+
const { Button } = useUIAdapter();
|
|
397
|
+
const forceReload = isConflictStatus(persistence);
|
|
398
|
+
const saveAction = getSaveAction(persistence);
|
|
399
|
+
return (_jsxs(_Fragment, { children: [showSaveAction && (_jsx(Button, { ariaLabel: saveAction.ariaLabel, size: "small", onClick: () => {
|
|
400
|
+
void persistence.saveRemoteSchema(saveAction.options);
|
|
401
|
+
}, children: saveAction.label })), showReloadAction && (_jsx(Button, { ariaLabel: "\u91CD\u65B0\u52A0\u8F7D\u8FDC\u7A0B Schema", size: "small", onClick: () => {
|
|
402
|
+
void persistence.loadRemoteSchema(forceReload ? { force: true } : undefined);
|
|
403
|
+
}, children: "\u91CD\u8F7D" })), showPublishAction && (_jsx(Button, { ariaLabel: "\u53D1\u5E03\u8FDC\u7A0B\u914D\u7F6E", size: "small", onClick: () => {
|
|
404
|
+
void persistence.saveRemoteSchema({ mode: 'publish' });
|
|
405
|
+
}, children: "\u53D1\u5E03" }))] }));
|
|
406
|
+
};
|
|
407
|
+
export const RemotePersistenceStatusWidget = observer(({ actionPermissions, className, persistence, remoteMetadata, revision, showDiagnostics = true, showLoadAction = false, showPublishAction = false, showTimestamp = true, style, ...restProps }) => {
|
|
408
|
+
const prefix = usePrefix('remote-persistence-status');
|
|
409
|
+
const timestamp = getTimestamp(persistence, showTimestamp);
|
|
410
|
+
const status = useMemo(() => getPersistenceStatus(persistence, timestamp), [persistence, timestamp]);
|
|
411
|
+
const statusStyle = toneStyles[status.tone];
|
|
412
|
+
const { showPublishAction: shouldShowPublishAction, showReloadAction, showSaveAction, } = getActionState(actionPermissions, persistence, showLoadAction, showPublishAction);
|
|
413
|
+
return (_jsxs("div", { ...restProps, className: cls(prefix, className), style: {
|
|
414
|
+
alignItems: 'center',
|
|
415
|
+
display: 'inline-flex',
|
|
416
|
+
gap: 8,
|
|
417
|
+
minWidth: 0,
|
|
418
|
+
...style,
|
|
419
|
+
}, children: [_jsx("span", { "aria-live": "polite", role: "status", style: {
|
|
420
|
+
background: statusStyle.background,
|
|
421
|
+
border: `1px solid ${statusStyle.borderColor}`,
|
|
422
|
+
borderRadius: 999,
|
|
423
|
+
boxSizing: 'border-box',
|
|
424
|
+
color: statusStyle.color,
|
|
425
|
+
display: 'inline-block',
|
|
426
|
+
flex: '0 1 220px',
|
|
427
|
+
fontSize: 12,
|
|
428
|
+
lineHeight: '24px',
|
|
429
|
+
maxWidth: 220,
|
|
430
|
+
minHeight: 26,
|
|
431
|
+
minWidth: 96,
|
|
432
|
+
overflow: 'hidden',
|
|
433
|
+
padding: '0 10px',
|
|
434
|
+
textOverflow: 'ellipsis',
|
|
435
|
+
whiteSpace: 'nowrap',
|
|
436
|
+
}, title: status.text, children: status.text }), showDiagnostics ? (_jsx(RemotePersistenceDiagnostics, { persistence: persistence, remoteMetadata: remoteMetadata, revision: revision })) : null, _jsx(RemotePersistenceActions, { persistence: persistence, showPublishAction: shouldShowPublishAction, showReloadAction: showReloadAction, showSaveAction: showSaveAction })] }));
|
|
437
|
+
});
|
|
438
|
+
RemotePersistenceStatusWidget.displayName = 'RemotePersistenceStatusWidget';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ITreeNode } from '@yimoka/designable-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { IPlaygroundRemoteSchemaVersion } from "../../hooks/remoteSchemaAdapter.js";
|
|
4
|
+
import { type IPlaygroundRemotePersistenceLoadResult } from "../../hooks/usePlaygroundRemotePersistence.js";
|
|
5
|
+
import type { IPlaygroundApi } from "../../types.js";
|
|
6
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
export interface IRemoteVersionHistoryActionPermissions {
|
|
8
|
+
canLoadVersion?: boolean;
|
|
9
|
+
canRestoreVersion?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface IRemoteVersionLoadHandlingResult {
|
|
12
|
+
applied: true;
|
|
13
|
+
}
|
|
14
|
+
export interface IRemoteVersionHistoryWidgetProps<S = unknown> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onError'> {
|
|
15
|
+
api?: Pick<IPlaygroundApi<S>, 'importDesign' | 'isDirty' | 'markSaved'>;
|
|
16
|
+
contextKey?: string | number;
|
|
17
|
+
versions?: IPlaygroundRemoteSchemaVersion[];
|
|
18
|
+
listRemoteVersions?: () => MaybePromise<IPlaygroundRemoteSchemaVersion[]>;
|
|
19
|
+
loadRemoteVersion?: (version: IPlaygroundRemoteSchemaVersion) => MaybePromise<IPlaygroundRemotePersistenceLoadResult<S> | S | ITreeNode | null | undefined>;
|
|
20
|
+
commitLoadedRemoteSnapshot?: (schema: S | ITreeNode | null | undefined) => MaybePromise<void>;
|
|
21
|
+
restoreRemoteVersion?: (version: IPlaygroundRemoteSchemaVersion) => MaybePromise<IPlaygroundRemotePersistenceLoadResult<S> | S | ITreeNode | null | undefined>;
|
|
22
|
+
onLoadVersion?: (version: IPlaygroundRemoteSchemaVersion, schema: S | ITreeNode | null | undefined) => MaybePromise<boolean | IRemoteVersionLoadHandlingResult | void>;
|
|
23
|
+
onRestoreVersion?: (version: IPlaygroundRemoteSchemaVersion) => MaybePromise<void>;
|
|
24
|
+
onError?: (error: unknown, context: {
|
|
25
|
+
action: 'list' | 'load' | 'restore';
|
|
26
|
+
version?: IPlaygroundRemoteSchemaVersion;
|
|
27
|
+
}) => void;
|
|
28
|
+
actionPermissions?: IRemoteVersionHistoryActionPermissions;
|
|
29
|
+
confirmBeforeDirtyLoad?: boolean;
|
|
30
|
+
dirtyLoadConfirmMessage?: string;
|
|
31
|
+
maxVersions?: number;
|
|
32
|
+
emptyText?: React.ReactNode;
|
|
33
|
+
autoLoad?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const RemoteVersionHistoryWidget: {
|
|
36
|
+
<S = unknown>({ actionPermissions, api, autoLoad, className, commitLoadedRemoteSnapshot, confirmBeforeDirtyLoad, contextKey, dirtyLoadConfirmMessage, emptyText, listRemoteVersions, loadRemoteVersion, maxVersions, onError, onLoadVersion, onRestoreVersion, restoreRemoteVersion, style, versions, ...props }: IRemoteVersionHistoryWidgetProps<S>): React.JSX.Element;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
export {};
|