Skip to content

Commit

Permalink
try: retranspile
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Apr 4, 2024
1 parent df81778 commit 8157a58
Show file tree
Hide file tree
Showing 26 changed files with 340 additions and 0 deletions.
1 change: 1 addition & 0 deletions dist/index.d.ts
@@ -0,0 +1 @@
export {};
2 changes: 2 additions & 0 deletions dist/index.js
@@ -0,0 +1,2 @@
import { hello_python } from "./other/fullscreen/test";
console.log(hello_python());
15 changes: 15 additions & 0 deletions dist/mui/components/custom/alert/AlertContextProvider.d.ts
@@ -0,0 +1,15 @@
import { AlertProps } from "@mui/material/Alert";
import { SnackbarProps } from "@mui/material/Snackbar";
import React from "react";
export type ExtendedAlertProps = AlertProps & {
content: string;
};
export declare const AlertContext: React.Context<{
show: (alertProps: ExtendedAlertProps, snackbarProps?: SnackbarProps) => void;
} | null>;
export interface AlertProvider {
children: React.ReactNode;
}
declare function AlertProvider({ children }: AlertProvider): React.JSX.Element;
export declare const AlertContextProvider: React.MemoExoticComponent<typeof AlertProvider>;
export {};
45 changes: 45 additions & 0 deletions dist/mui/components/custom/alert/AlertContextProvider.js
@@ -0,0 +1,45 @@
/* eslint-disable no-shadow */
/* eslint-disable react/jsx-props-no-spreading */
import Alert from "@mui/material/Alert";
import AlertTitle from "@mui/material/AlertTitle";
import Snackbar from "@mui/material/Snackbar";
import React, { createContext, memo, useCallback, useState } from "react";
export const AlertContext = createContext(null);
const defaultSnackbarProps = {
anchorOrigin: {
vertical: "bottom",
horizontal: "right",
},
autoHideDuration: 3000,
};
const defaultAlertProps = {
content: "Success Alert",
severity: "success",
variant: "filled",
};
// eslint-disable-next-line react/prop-types
function AlertProvider({ children }) {
const [isAlertShown, setShownAlert] = useState(false);
const [snackbarProps, setSnackbarProps] = useState(defaultSnackbarProps);
const [alertProps, setAlertProps] = useState(defaultAlertProps);
const showAlert = useCallback((alertProps, snackbarProps) => {
if (alertProps)
setAlertProps((prev) => ({ ...prev, ...alertProps }));
if (snackbarProps)
setSnackbarProps((prev) => ({ ...prev, ...snackbarProps }));
setShownAlert(true);
}, []);
const closeAlert = useCallback(() => {
setShownAlert(false);
}, []);
const { content, severity, variant, ...restAlertProps } = alertProps;
/* eslint-disable react/jsx-no-constructed-context-values */
return (React.createElement(AlertContext.Provider, { value: { show: showAlert } },
children,
React.createElement(Snackbar, { ...snackbarProps, open: isAlertShown, onClose: closeAlert },
React.createElement(Alert, { onClose: closeAlert, variant: variant, severity: severity, ...restAlertProps },
React.createElement(AlertTitle, null, severity),
content))));
/* eslint-enable react/jsx-no-constructed-context-values */
}
export const AlertContextProvider = memo(AlertProvider);
3 changes: 3 additions & 0 deletions dist/mui/components/custom/alert/hooks/useAlert.d.ts
@@ -0,0 +1,3 @@
export declare const useAlert: () => {
show: (alertProps: import("../AlertContextProvider").ExtendedAlertProps, snackbarProps?: import("@mui/material").SnackbarProps | undefined) => void;
} | null;
5 changes: 5 additions & 0 deletions dist/mui/components/custom/alert/hooks/useAlert.js
@@ -0,0 +1,5 @@
import { useContext } from "react";
import { AlertContext } from "../AlertContextProvider";
export const useAlert = () => {
return useContext(AlertContext);
};
1 change: 1 addition & 0 deletions dist/mui/components/custom/alert/index.d.ts
@@ -0,0 +1 @@
export * from "./hooks/useAlert";
1 change: 1 addition & 0 deletions dist/mui/components/custom/alert/index.js
@@ -0,0 +1 @@
export * from "./hooks/useAlert";
7 changes: 7 additions & 0 deletions dist/mui/components/stepper/StepIcon.d.ts
@@ -0,0 +1,7 @@
import React from "react";
export interface StepIconProps {
active: boolean;
icon: React.ReactNode;
}
declare function StepIcon(props: StepIconProps): React.JSX.Element;
export default StepIcon;
56 changes: 56 additions & 0 deletions dist/mui/components/stepper/StepIcon.js
@@ -0,0 +1,56 @@
import { styled } from "@mui/material/styles";
import classNames from "classnames";
import React from "react";
const StyledStepIcon = styled("div")(({ theme }) => ({
display: "flex",
justifyContent: "center",
alignItems: "center",
width: 50,
height: 50,
border: `1px solid ${theme.palette.primary.dark}`,
borderRadius: "50%",
color: theme.palette.common.white,
".internal-circle": {
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
width: 44,
height: 44,
background: "transparent",
borderRadius: "50%",
border: `1px solid ${theme.palette.primary.dark}`,
lineHeight: 1.2,
".step-number": {
fontSize: 13,
color: theme.palette.primary.dark,
},
".step-label": {
fontSize: 10,
color: theme.palette.primary.dark,
},
},
"&.active": {
border: `1px solid ${theme.palette.primary.dark}`,
color: theme.palette.common.white,
".internal-circle": {
background: theme.palette.primary.dark,
".step-number": {
fontSize: 13,
color: theme.palette.common.white,
},
".step-label": {
fontSize: 10,
color: theme.palette.common.white,
},
},
},
}));
function StepIcon(props) {
const { active, icon } = props;
return (React.createElement(StyledStepIcon, { className: classNames({ active }) },
React.createElement("div", { className: "internal-circle" },
React.createElement("span", { className: "step-number" }, icon),
React.createElement("span", { className: "step-label" }, "STEP"))));
}
export default StepIcon;
2 changes: 2 additions & 0 deletions dist/mui/components/stepper/Stepper.styled.d.ts
@@ -0,0 +1,2 @@
export declare const StyledConnector: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
export declare const StepMsg: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
45 changes: 45 additions & 0 deletions dist/mui/components/stepper/Stepper.styled.js
@@ -0,0 +1,45 @@
import StepConnector, { stepConnectorClasses } from "@mui/material/StepConnector";
import { styled } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
export const StyledConnector = styled(StepConnector)(({ theme }) => ({
[`&.${stepConnectorClasses.alternativeLabel}`]: {
top: 24,
left: "calc(-50% + 25px)",
right: "calc(50% + 25px)",
},
[`&.${stepConnectorClasses.active}`]: {
[`& .${stepConnectorClasses.line}`]: {
backgroundColor: theme.palette.primary.dark,
"&::after": {
backgroundColor: theme.palette.primary.dark,
},
},
},
[`&.${stepConnectorClasses.completed}`]: {
[`& .${stepConnectorClasses.line}`]: {
backgroundColor: theme.palette.primary.dark,
"&::after": {
backgroundColor: theme.palette.primary.dark,
},
},
},
[`& .${stepConnectorClasses.line}`]: {
height: 2,
border: 0,
backgroundColor: theme.palette.border.dark,
"&::after": {
position: "absolute",
right: "-3px",
top: "-2px",
display: "block",
content: '""',
width: "6px",
height: "6px",
backgroundColor: theme.palette.border.dark,
borderRadius: "50%",
},
},
}));
export const StepMsg = styled(Typography)(() => ({
marginTop: "15px",
}));
19 changes: 19 additions & 0 deletions dist/mui/components/textField/BasicTextField.d.ts
@@ -0,0 +1,19 @@
import { SxProps } from "@mui/material";
import React, { HTMLInputTypeAttribute } from "react";
type BasicTextFieldProps = {
label: string;
value?: string | number;
defaultValue?: string | number;
onChange?: (newValue: string | number) => void;
disabled?: boolean;
fullWidth?: boolean;
size?: "small" | "medium";
labelAsPlaceholder?: boolean;
sx?: SxProps;
type?: HTMLInputTypeAttribute;
variant?: "standard" | "filled" | "outlined";
required?: boolean;
};
declare function BasicTextField({ label, value, defaultValue, onChange, // eslint-disable-line @typescript-eslint/no-empty-function
disabled, fullWidth, size, labelAsPlaceholder, sx, type, variant, required, }: BasicTextFieldProps): React.JSX.Element;
export default BasicTextField;
8 changes: 8 additions & 0 deletions dist/mui/components/textField/BasicTextField.js
@@ -0,0 +1,8 @@
import TextField from "@mui/material/TextField";
import React from "react";
function BasicTextField({ label, value, defaultValue, onChange = () => { }, // eslint-disable-line @typescript-eslint/no-empty-function
disabled = false, fullWidth = true, size = "medium", labelAsPlaceholder = true, sx = {}, type = "text", variant = "outlined", required = false, }) {
const inputLabelProps = labelAsPlaceholder ? {} : { shrink: true };
return (React.createElement(TextField, { type: type, sx: sx, label: label, value: value, defaultValue: defaultValue, fullWidth: fullWidth, disabled: disabled, variant: variant, size: size, required: required, InputLabelProps: inputLabelProps, onChange: (e) => onChange(e.target.value) }));
}
export default BasicTextField;
2 changes: 2 additions & 0 deletions dist/mui/components/textField/index.d.ts
@@ -0,0 +1,2 @@
import BasicTextField from "./BasicTextField";
export { BasicTextField };
2 changes: 2 additions & 0 deletions dist/mui/components/textField/index.js
@@ -0,0 +1,2 @@
import BasicTextField from "./BasicTextField";
export { BasicTextField };
1 change: 1 addition & 0 deletions dist/other/fullscreen/test.d.ts
@@ -0,0 +1 @@
export declare function hello_python(): Promise<void>;
8 changes: 8 additions & 0 deletions dist/other/fullscreen/test.js
@@ -0,0 +1,8 @@
// import { loadPyodide } from "pyodide";
// const { loadPyodide } = require("pyodide");
export async function hello_python() {
// const pyodide = await loadPyodide({
// indexURL: "<pyodide artifacts folder>",
// });
// return pyodide.runPythonAsync("1+1");
}
1 change: 1 addition & 0 deletions dist/other/iframe-messaging/index.d.ts
@@ -0,0 +1 @@
export { default } from "./IframeToFromHostMessageHandler";
1 change: 1 addition & 0 deletions dist/other/iframe-messaging/index.js
@@ -0,0 +1 @@
export { default } from "./IframeToFromHostMessageHandler";
14 changes: 14 additions & 0 deletions dist/other/jupyterlite/MessageHandler.d.ts
@@ -0,0 +1,14 @@
import { IframeMessageSchema } from "@mat3ra/esse/lib/js/types";
type HandlerFunction = (...args: IframeMessageSchema["payload"][]) => void | any;
declare class MessageHandler {
private handlers;
private iframeOriginURL;
private hostOriginURL;
private iframeId;
init(iframeOriginURL: string, iframeId: string): void;
destroy(): void;
addHandlers(action: IframeMessageSchema["action"], handlers: HandlerFunction[]): void;
private receiveMessage;
sendData(data: object): void;
}
export default MessageHandler;
57 changes: 57 additions & 0 deletions dist/other/jupyterlite/MessageHandler.js
@@ -0,0 +1,57 @@
class MessageHandler {
constructor() {
this.handlers = { "get-data": [], "set-data": [], info: [] };
this.iframeOriginURL = "*";
this.hostOriginURL = "*";
this.iframeId = "";
this.receiveMessage = (event) => {
if (this.iframeOriginURL !== "*" &&
event.origin !== this.iframeOriginURL &&
event.origin !== this.hostOriginURL) {
return;
}
if (event.data.type === "from-iframe-to-host") {
const { action, payload } = event.data;
// @ts-ignore
if (this.handlers[action]) {
// @ts-ignore
this.handlers["set-data"].forEach((handler) => {
handler(payload);
});
this.handlers["get-data"].forEach((handler) => {
const data = handler();
this.sendData(data);
});
}
}
};
}
init(iframeOriginURL, iframeId) {
window.addEventListener("message", this.receiveMessage);
this.iframeOriginURL = iframeOriginURL;
this.hostOriginURL = window.location.origin;
this.iframeId = iframeId;
}
destroy() {
window.removeEventListener("message", this.receiveMessage);
}
addHandlers(action, handlers) {
if (!this.handlers[action]) {
this.handlers[action] = [];
}
this.handlers[action].push(...handlers);
}
sendData(data) {
const message = {
type: "from-host-to-iframe",
action: "set-data",
payload: data,
};
const iframe = document.getElementById(this.iframeId);
if (iframe) {
// @ts-ignore
iframe.contentWindow.postMessage(message, this.iframeOriginURL);
}
}
}
export default MessageHandler;
1 change: 1 addition & 0 deletions dist/other/jupyterlite/index.d.ts
@@ -0,0 +1 @@
export { default } from "./JupyterLiteSession";
1 change: 1 addition & 0 deletions dist/other/jupyterlite/index.js
@@ -0,0 +1 @@
export { default } from "./JupyterLiteSession";
10 changes: 10 additions & 0 deletions dist/other/rjsf/CustomObjectFieldTemplate.d.ts
@@ -0,0 +1,10 @@
import { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from "@rjsf/utils";
import React from "react";
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
* the properties.
*
* @param props - The `ObjectFieldTemplateProps` for this component
*/
declare function ObjectFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ description, title, properties, required, disabled, readonly, uiSchema, idSchema, schema, formData, onAddClick, registry, }: ObjectFieldTemplateProps<T, S, F>): React.JSX.Element;
export default ObjectFieldTemplate;
32 changes: 32 additions & 0 deletions dist/other/rjsf/CustomObjectFieldTemplate.js
@@ -0,0 +1,32 @@
/* eslint-disable react/no-array-index-key */
/* eslint-disable @typescript-eslint/no-explicit-any */
import Grid from "@mui/material/Grid";
import { useTheme } from "@mui/material/styles";
import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, } from "@rjsf/utils";
import React from "react";
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
* the properties.
*
* @param props - The `ObjectFieldTemplateProps` for this component
*/
function ObjectFieldTemplate({ description, title, properties, required, disabled, readonly, uiSchema, idSchema, schema, formData, onAddClick, registry, }) {
const theme = useTheme();
const uiOptions = getUiOptions(uiSchema);
const TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, uiOptions);
const DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions);
// Button templates are not overridden in the uiSchema
const { ButtonTemplates: { AddButton }, } = registry.templates;
return (React.createElement(React.Fragment, null,
title && (React.createElement(TitleFieldTemplate, { id: titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })),
description && (React.createElement(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry })),
React.createElement(Grid, { container: true, spacing: 2 },
properties.map((element, index) =>
// Remove the <Grid> if the inner element is hidden as the <Grid>
// itself would otherwise still take up space.
element.hidden ? (element.content) : (React.createElement(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, xl: 2, key: index, rowSpacing: theme.spacing(1.25) }, element.content))),
canExpand(schema, uiSchema, formData) && (React.createElement(Grid, { container: true, justifyContent: "flex-end" },
React.createElement(Grid, { item: true },
React.createElement(AddButton, { className: "object-property-expand", onClick: onAddClick(schema), disabled: disabled || readonly, uiSchema: uiSchema, registry: registry })))))));
}
export default ObjectFieldTemplate;

0 comments on commit 8157a58

Please sign in to comment.