@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,44 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { createSchemaFingerprint, stringifySchemaForExport } from "../shared/schema.js";
|
|
3
|
+
const getSchemaDraftSnapshot = (getSchema) => {
|
|
4
|
+
try {
|
|
5
|
+
return stringifySchemaForExport(getSchema());
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const useSchemaEditorDraft = (getSchema, isSchemaEditorActive, enabled = true) => {
|
|
12
|
+
const schemaDraftBaselineRef = useRef(undefined);
|
|
13
|
+
const wasSchemaEditorActiveRef = useRef(isSchemaEditorActive);
|
|
14
|
+
const [schemaDraftValue, setSchemaDraftValue] = useState();
|
|
15
|
+
const schemaFingerprint = enabled ? createSchemaFingerprint(getSchema) : undefined;
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const wasSchemaEditorActive = wasSchemaEditorActiveRef.current;
|
|
18
|
+
wasSchemaEditorActiveRef.current = isSchemaEditorActive;
|
|
19
|
+
if (!enabled) {
|
|
20
|
+
schemaDraftBaselineRef.current = undefined;
|
|
21
|
+
setSchemaDraftValue(undefined);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (schemaFingerprint === undefined)
|
|
25
|
+
return;
|
|
26
|
+
if (schemaDraftBaselineRef.current === undefined) {
|
|
27
|
+
schemaDraftBaselineRef.current = schemaFingerprint;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (schemaDraftBaselineRef.current === schemaFingerprint)
|
|
31
|
+
return;
|
|
32
|
+
if (isSchemaEditorActive && wasSchemaEditorActive)
|
|
33
|
+
return;
|
|
34
|
+
const nextSchemaDraftValue = getSchemaDraftSnapshot(getSchema);
|
|
35
|
+
if (nextSchemaDraftValue === undefined)
|
|
36
|
+
return;
|
|
37
|
+
schemaDraftBaselineRef.current = schemaFingerprint;
|
|
38
|
+
setSchemaDraftValue(nextSchemaDraftValue);
|
|
39
|
+
}, [enabled, getSchema, isSchemaEditorActive, schemaFingerprint]);
|
|
40
|
+
return {
|
|
41
|
+
schemaDraftValue,
|
|
42
|
+
setSchemaDraftValue,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./context.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export * from "./widgets/index.js";
|
|
5
|
+
export * from "./panels/index.js";
|
|
6
|
+
export * from "./layouts/index.js";
|
|
7
|
+
export * from "./antd/index.js";
|
|
8
|
+
export * from "./presets/index.js";
|
|
9
|
+
export * from "./runtime/index.js";
|
|
10
|
+
export { runtimeExamples } from "./examples/index.js";
|
|
11
|
+
export * from "./transformers/index.js";
|
|
12
|
+
export * from "./shared/index.js";
|
|
13
|
+
export { Playground } from "./Playground.js";
|
|
14
|
+
export { Workbench, Viewport, DesignerToolsWidget, DroppableWidget, ViewToolsWidget, HistoryWidget, } from '@yimoka/designable-react';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./context.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export * from "./widgets/index.js";
|
|
5
|
+
export * from "./panels/index.js";
|
|
6
|
+
export * from "./layouts/index.js";
|
|
7
|
+
export * from "./antd/index.js";
|
|
8
|
+
export * from "./presets/index.js";
|
|
9
|
+
export * from "./runtime/index.js";
|
|
10
|
+
export { runtimeExamples } from "./examples/index.js";
|
|
11
|
+
export * from "./transformers/index.js";
|
|
12
|
+
export * from "./shared/index.js";
|
|
13
|
+
export { Playground } from "./Playground.js";
|
|
14
|
+
export { Workbench, Viewport, DesignerToolsWidget, DroppableWidget, ViewToolsWidget, HistoryWidget, } from '@yimoka/designable-react';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare class WorkbenchViewErrorBoundary extends React.Component<React.PropsWithChildren<{
|
|
3
|
+
onError?: (error: unknown) => void;
|
|
4
|
+
resetKey: string;
|
|
5
|
+
}>, {
|
|
6
|
+
error: unknown | null;
|
|
7
|
+
}> {
|
|
8
|
+
static getDerivedStateFromError(error: unknown): {
|
|
9
|
+
error: unknown;
|
|
10
|
+
};
|
|
11
|
+
state: {
|
|
12
|
+
error: null;
|
|
13
|
+
};
|
|
14
|
+
componentDidCatch(error: unknown): void;
|
|
15
|
+
componentDidUpdate(prevProps: Readonly<React.PropsWithChildren<{
|
|
16
|
+
resetKey: string;
|
|
17
|
+
}>>): void;
|
|
18
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare class SidePanelErrorBoundary extends React.Component<React.PropsWithChildren<{
|
|
21
|
+
onError?: (error: unknown) => void;
|
|
22
|
+
panelTitle: string;
|
|
23
|
+
resetKey: string;
|
|
24
|
+
}>, {
|
|
25
|
+
error: unknown | null;
|
|
26
|
+
}> {
|
|
27
|
+
static getDerivedStateFromError(error: unknown): {
|
|
28
|
+
error: unknown;
|
|
29
|
+
};
|
|
30
|
+
state: {
|
|
31
|
+
error: null;
|
|
32
|
+
};
|
|
33
|
+
componentDidCatch(error: unknown): void;
|
|
34
|
+
componentDidUpdate(prevProps: Readonly<React.PropsWithChildren<{
|
|
35
|
+
panelTitle: string;
|
|
36
|
+
resetKey: string;
|
|
37
|
+
}>>): void;
|
|
38
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare class ToolbarItemErrorBoundary extends React.Component<React.PropsWithChildren<{
|
|
41
|
+
label: string;
|
|
42
|
+
onError?: (error: unknown) => void;
|
|
43
|
+
resetKey: string;
|
|
44
|
+
}>, {
|
|
45
|
+
error: unknown | null;
|
|
46
|
+
}> {
|
|
47
|
+
static getDerivedStateFromError(error: unknown): {
|
|
48
|
+
error: unknown;
|
|
49
|
+
};
|
|
50
|
+
state: {
|
|
51
|
+
error: null;
|
|
52
|
+
};
|
|
53
|
+
componentDidCatch(error: unknown): void;
|
|
54
|
+
componentDidUpdate(prevProps: Readonly<React.PropsWithChildren<{
|
|
55
|
+
label: string;
|
|
56
|
+
resetKey: string;
|
|
57
|
+
}>>): void;
|
|
58
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
59
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const getErrorMessage = (error) => {
|
|
4
|
+
if (error instanceof Error)
|
|
5
|
+
return error.message;
|
|
6
|
+
if (typeof error === 'string' && error.trim())
|
|
7
|
+
return error;
|
|
8
|
+
return '未知错误';
|
|
9
|
+
};
|
|
10
|
+
export class WorkbenchViewErrorBoundary extends React.Component {
|
|
11
|
+
static getDerivedStateFromError(error) {
|
|
12
|
+
return { error };
|
|
13
|
+
}
|
|
14
|
+
state = {
|
|
15
|
+
error: null,
|
|
16
|
+
};
|
|
17
|
+
componentDidCatch(error) {
|
|
18
|
+
this.props.onError?.(error);
|
|
19
|
+
}
|
|
20
|
+
componentDidUpdate(prevProps) {
|
|
21
|
+
if (!this.state.error)
|
|
22
|
+
return;
|
|
23
|
+
if (prevProps.resetKey === this.props.resetKey)
|
|
24
|
+
return;
|
|
25
|
+
this.setState({ error: null });
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
if (this.state.error) {
|
|
29
|
+
const message = getErrorMessage(this.state.error);
|
|
30
|
+
return (_jsxs("div", { role: "alert", style: {
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
background: '#fff1f0',
|
|
33
|
+
boxSizing: 'border-box',
|
|
34
|
+
color: '#a8071a',
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
gap: 8,
|
|
38
|
+
height: '100%',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
padding: 24,
|
|
41
|
+
textAlign: 'center',
|
|
42
|
+
}, children: [_jsx("div", { style: { fontSize: 14, fontWeight: 700 }, children: "\u5F53\u524D\u89C6\u56FE\u6E32\u67D3\u5931\u8D25" }), _jsx("div", { style: {
|
|
43
|
+
fontSize: 12,
|
|
44
|
+
lineHeight: '18px',
|
|
45
|
+
maxWidth: 560,
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
textOverflow: 'ellipsis',
|
|
48
|
+
whiteSpace: 'nowrap',
|
|
49
|
+
}, title: message, children: message })] }));
|
|
50
|
+
}
|
|
51
|
+
return this.props.children;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class SidePanelErrorBoundary extends React.Component {
|
|
55
|
+
static getDerivedStateFromError(error) {
|
|
56
|
+
return { error };
|
|
57
|
+
}
|
|
58
|
+
state = {
|
|
59
|
+
error: null,
|
|
60
|
+
};
|
|
61
|
+
componentDidCatch(error) {
|
|
62
|
+
this.props.onError?.(error);
|
|
63
|
+
}
|
|
64
|
+
componentDidUpdate(prevProps) {
|
|
65
|
+
if (!this.state.error)
|
|
66
|
+
return;
|
|
67
|
+
if (prevProps.resetKey === this.props.resetKey)
|
|
68
|
+
return;
|
|
69
|
+
this.setState({ error: null });
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
if (this.state.error) {
|
|
73
|
+
const message = getErrorMessage(this.state.error);
|
|
74
|
+
return (_jsxs("div", { role: "alert", style: {
|
|
75
|
+
background: '#fff1f0',
|
|
76
|
+
border: '1px solid #ffccc7',
|
|
77
|
+
borderRadius: 6,
|
|
78
|
+
color: '#a8071a',
|
|
79
|
+
fontSize: 12,
|
|
80
|
+
lineHeight: '18px',
|
|
81
|
+
margin: 6,
|
|
82
|
+
padding: 10,
|
|
83
|
+
}, children: [_jsxs("div", { style: { fontWeight: 700 }, children: [this.props.panelTitle, "\u6E32\u67D3\u5931\u8D25"] }), _jsx("div", { style: {
|
|
84
|
+
marginTop: 4,
|
|
85
|
+
overflow: 'hidden',
|
|
86
|
+
textOverflow: 'ellipsis',
|
|
87
|
+
whiteSpace: 'nowrap',
|
|
88
|
+
}, title: message, children: message }), _jsx("button", { style: {
|
|
89
|
+
background: '#fff',
|
|
90
|
+
border: '1px solid #ffccc7',
|
|
91
|
+
borderRadius: 4,
|
|
92
|
+
color: '#a8071a',
|
|
93
|
+
cursor: 'pointer',
|
|
94
|
+
fontSize: 12,
|
|
95
|
+
height: 24,
|
|
96
|
+
marginTop: 8,
|
|
97
|
+
padding: '0 8px',
|
|
98
|
+
}, type: "button", onClick: () => {
|
|
99
|
+
this.setState({ error: null });
|
|
100
|
+
}, children: "\u91CD\u8BD5" })] }));
|
|
101
|
+
}
|
|
102
|
+
return this.props.children;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export class ToolbarItemErrorBoundary extends React.Component {
|
|
106
|
+
static getDerivedStateFromError(error) {
|
|
107
|
+
return { error };
|
|
108
|
+
}
|
|
109
|
+
state = {
|
|
110
|
+
error: null,
|
|
111
|
+
};
|
|
112
|
+
componentDidCatch(error) {
|
|
113
|
+
this.props.onError?.(error);
|
|
114
|
+
}
|
|
115
|
+
componentDidUpdate(prevProps) {
|
|
116
|
+
if (!this.state.error)
|
|
117
|
+
return;
|
|
118
|
+
if (prevProps.resetKey === this.props.resetKey)
|
|
119
|
+
return;
|
|
120
|
+
this.setState({ error: null });
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
if (this.state.error) {
|
|
124
|
+
const message = getErrorMessage(this.state.error);
|
|
125
|
+
return (_jsxs("div", { role: "alert", style: {
|
|
126
|
+
alignItems: 'center',
|
|
127
|
+
background: '#fff7f6',
|
|
128
|
+
border: '1px solid #ffccc7',
|
|
129
|
+
borderRadius: 6,
|
|
130
|
+
color: '#a8071a',
|
|
131
|
+
display: 'flex',
|
|
132
|
+
fontSize: 12,
|
|
133
|
+
gap: 8,
|
|
134
|
+
height: 28,
|
|
135
|
+
lineHeight: '18px',
|
|
136
|
+
maxWidth: 220,
|
|
137
|
+
padding: '0 8px',
|
|
138
|
+
}, children: [_jsxs("span", { style: {
|
|
139
|
+
flex: 1,
|
|
140
|
+
minWidth: 0,
|
|
141
|
+
overflow: 'hidden',
|
|
142
|
+
textOverflow: 'ellipsis',
|
|
143
|
+
whiteSpace: 'nowrap',
|
|
144
|
+
}, title: message, children: [this.props.label, "\u52A0\u8F7D\u5931\u8D25\uFF1A", message] }), _jsx("button", { "aria-label": `重试${this.props.label}`, style: {
|
|
145
|
+
background: '#fff',
|
|
146
|
+
border: '1px solid #ffccc7',
|
|
147
|
+
borderRadius: 4,
|
|
148
|
+
color: '#a8071a',
|
|
149
|
+
cursor: 'pointer',
|
|
150
|
+
flex: 'none',
|
|
151
|
+
fontSize: 12,
|
|
152
|
+
height: 20,
|
|
153
|
+
lineHeight: '18px',
|
|
154
|
+
padding: '0 6px',
|
|
155
|
+
}, type: "button", onClick: () => {
|
|
156
|
+
this.setState({ error: null });
|
|
157
|
+
}, children: "\u91CD\u8BD5" })] }));
|
|
158
|
+
}
|
|
159
|
+
return this.props.children;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IPlaygroundLayoutProps } from "../../types.js";
|
|
3
|
+
declare function PlaygroundLayoutComponent<S = unknown>({ actions, availableViews, defaultView, leftPanelWidth, logo, onError, resourcePanelProps, rightPanelWidth, settingsPanel, showDesignerTools, showHistoryPanel, showNodeActions, showOutlinePanel, showResourcePanel, showSettingsPanel, showStorageActions, showViewTools, schemaEditorReadonly, ...props }: IPlaygroundLayoutProps<S>): React.JSX.Element;
|
|
4
|
+
export declare const PlaygroundLayout: typeof PlaygroundLayoutComponent & {
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
7
|
+
export {};
|