-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathindex.tsx
131 lines (116 loc) · 2.92 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import {
UICompBuilder,
Section,
withExposingConfigs,
stringExposingStateControl,
NameConfig,
eventHandlerControl,
withMethodExposing,
} from "lowcoder-sdk";
import Mermaid from "./mermaid";
// Collection of example mermaid diagrams that showcase different diagram types
const mermaidExamples = {
flowchart:
`flowchart TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]
B -->|No| D[Debug]
D --> E[Check Documentation]
E --> B
C --> F[Deploy]`,
sequence:
`sequenceDiagram
participant User
participant App
participant API
participant DB
User->>App: Submit Form
App->>API: Send Request
API->>DB: Query Data
DB->>API: Return Result
API->>App: Send Response
App->>User: Show Result`,
classDiagram:
`classDiagram
class User {
+String name
+String email
+authenticate()
+updateProfile()
}
class Product {
+String name
+Number price
+getDetails()
}
class Order {
+Date date
+Number total
+process()
}
User "1" --> "*" Order
Order "*" --> "*" Product`,
gantt:
`gantt
title Project Timeline
dateFormat YYYY-MM-DD
section Planning
Research :done, a1, 2023-01-01, 10d
Requirements :active, a2, after a1, 7d
section Development
Design :a3, after a2, 8d
Implementation :a4, after a3, 14d
Testing :a5, after a4, 7d
section Deployment
Release :milestone, after a5, 0d`,
entityRelationship:
`erDiagram
CUSTOMER }|--o{ ORDER : places
ORDER ||--|{ ORDER_ITEM : contains
CUSTOMER ||--o{ PAYMENT : makes
PRODUCT ||--|{ ORDER_ITEM : "ordered in"`,
journey:
`journey
title User Purchase Journey
section Visit Website
Homepage: 5: User
Product listing: 4: User
Product detail: 3: User
section Purchase
Add to cart: 4: User
Checkout: 3: User, Admin
Payment: 3: User, Admin
section Post-Purchase
Order confirmation: 5: User, Admin
Shipping: 4: Admin
Delivery: 5: User, Admin`
};
// Using the flowchart example as default
const childrenMap = {
code: stringExposingStateControl(
"code",
mermaidExamples.flowchart
),
onEvent: eventHandlerControl([
{
label: "onChange",
value: "change",
description: "",
},
]),
};
const CompBase = new UICompBuilder(childrenMap, (props: any) => {
const code = props.code.value;
return <Mermaid code={code} />;
})
.setPropertyViewFn((children: any) => {
return (
<>
<Section name="Basic">{children.code.propertyView({ label: "code" })}</Section>
<Section name="Interaction">{children.onEvent.propertyView()}</Section>
</>
);
})
.build();
const AppViewCompTemp = withMethodExposing(CompBase, []);
export const MermaidComp = withExposingConfigs(AppViewCompTemp, [new NameConfig("code", "")]);