Skip to content
9 changes: 8 additions & 1 deletion packages/app-design-forest/src/customPropsTree.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Joi from "joi";
export type SimpleCustomProp = {
type:
| "text"
Expand Down Expand Up @@ -38,6 +39,11 @@ export type ArrayMapCustomProp = {
attributes: MapCustomProp["attributes"];
};

export type JSONCustomProp = {
type: "json";
schema: Joi.ArraySchema; // tried AnySchema, ObjectSchema, ArraySchema from Joi
};

/**
* This type represents a custom field that takes an object as a value.
* This object does not have fixed keys unlike MapCustomProp.
Expand Down Expand Up @@ -77,7 +83,8 @@ export type CustomPropsTreeOptions = {
| ArrayMapCustomProp
| VariableKeyMapCustomProp
| TypedMapCustomProp
| ArrayTypedMapCustomProp;
| ArrayTypedMapCustomProp
| JSONCustomProp;
};
};

Expand Down
10 changes: 9 additions & 1 deletion packages/custom-props-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@
"@atrilabs/layer-types": "^1.0.0-alpha.8",
"@atrilabs/react-component-manifest-schema": "^1.0.0-alpha.8",
"@atrilabs/shared-layer-lib": "^1.0.0-alpha.8",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/language": "^6.6.0",
"@codemirror/legacy-modes": "^6.3.1",
"@codemirror/lint": "^6.0.0",
"@uiw/react-codemirror": "^4.19.9",
"eslint-plugin-atrilabs": "^1.0.0-alpha.8",
"typescript": "4.6.3"
"joi": "^17.8.4",
"typescript": "4.6.3",
"url": "^0.11.0"
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/plugin-syntax-flow": "^7.16.7",
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@types/joi": "^17.2.3",
"@types/react": "18.0.5",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ExternalLink } from "../external-link/ExternalLink";
import { EnumCustomProp } from "@atrilabs/app-design-forest";
import { Enum } from "../enum/Enum";
import { EnumList } from "../enum-list/EnumList";
import { TypedJson } from "../typed-json/TypedJson";

export const CommonPropTypeContainer: React.FC<CommonPropTypeContainerTypes> = (
props
Expand Down Expand Up @@ -168,5 +169,14 @@ export const CommonPropTypeContainer: React.FC<CommonPropTypeContainerTypes> = (
/>
);
}
if (propType === "json")
return (
<TypedJson
{...props}
propName={propName}
key={propName}
routes={routes}
/>
);
return <React.Fragment key={propName}></React.Fragment>;
};
158 changes: 158 additions & 0 deletions packages/custom-props-layer/src/components/commons/Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
function Modal(props: any) {
return (
<>
<style>
{` .modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
animation-name: animatetop;
animation-duration: 0.4s;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.modal-footer {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.modal-body {padding: 2px 16px;}
.modal-header {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
body:after {
position: absolute;
content: '';
left: 0;
top: 0;
height: 100vh;
width: 100vw;
background: rgba(0,0,0,0.5);
/* visibility: hidden; */
z-index: 0;
}
body:after {
position: absolute;
content: '';
left: 0;
top: 0;
height: 100vh;
width: 100vw;
background: rgba(0,0,0,0.5);
z-index: 0;
}

.modal-content{
position:fixed !important;
top:50%;
left:50%;
transform: translate(-50%, -50%);
z-index: 1;
width:800px;
height:800px;
border-radius: 5px;
box-sizing: border-box;

}
.modal-header{
background-color: transparent;
padding: 16px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom:1px solid #dee2e6;
}
.modal-footer{
background-color: transparent;
padding-top: 16px;
border-top: 1px solid #dee2e6 ;
padding:16px;
display:flex;
gap:10px;
justify-content:end;
}
.modal-header h2{
color: black;
margin: 0;
font-size:20px;
font-weight:500;
}
.modal-body{
padding: 0px;
}
.modal-content .modal-body .cm-theme-light{
height: 660px;
overflow-y: scroll;
}
.modal-content .error .cm-theme-light {
height: 620px ! important;
overflow-y: scroll;
}
.modal-footer .disabled{
background-color:#efefef !important;
cursor: not-allowed;
color: gray !important;
border: none;
height: 38px;
border-radius: 5px;
font-size: 16px;
}
.modal-footer button:first-child{
background: #007bff;
color: #ffffff;
border: none;
height: 38px;
border-radius: 5px;
font-size: 16px;
}
.modal-footer button:last-child{
background: #6c757d;
color: #ffffff;
border: none;
width: 75px;
height: 38px;
border-radius: 5px;
font-size: 16px;
}
`}
</style>

{props.showModal && (
<div className="modal-content">
<div className="modal-header">
<h2>{props.title}</h2>
<span className="close" onClick={() => props.setShowModal(false)}>
&times;
</span>
</div>
<div className="modal-body" >{props.children}</div>
<div className="modal-footer">
{props.footer}
</div>
</div>
)}
</>
);
}

export default Modal;
Loading