Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"recommended": true,
"complexity": {
"noUselessFragments": "error"
},
"correctness": {
"noUnusedVariables": "error",
"noUnusedImports": "error",
"useExhaustiveDependencies": "warn"
"useExhaustiveDependencies": {
"fix": "none",
"level": "warn",
"options": {}
}
},
"style": {
"useConst": "error"
Expand Down
103 changes: 51 additions & 52 deletions libs/renderer/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,64 @@
import { defineConfig } from "rollup";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import image from "@rollup/plugin-image";
import json from "@rollup/plugin-json";

import resolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { defineConfig } from "rollup";
import del from "rollup-plugin-delete";

const isProduction = process.env.NODE_ENV === "production";

// Plugin to strip 'use client' directives
const stripUseClient = () => ({
name: 'strip-use-client',
transform(code, id) {
if (id.includes('node_modules') && code.includes("'use client'")) {
return {
code: code.replace(/'use client';\s*/g, ''),
map: null
};
}
return null;
}
name: "strip-use-client",
transform(code, id) {
if (id.includes("node_modules") && code.includes("'use client'")) {
return {
code: code.replace(/'use client';\s*/g, ""),
map: null,
};
}
return null;
},
});

export default defineConfig({
input: {
index: "src/index.ts",
},
output: {
dir: "dist",
format: "esm",
sourcemap: isProduction,
entryFileNames: "[name].mjs",
},
plugins: [
del({ targets: "dist" }),
stripUseClient(),
resolve(),
commonjs(),
image(),
json(),
typescript({
tsconfig: "./tsconfig.json",
}),
isProduction && terser(),
],
external: [
"@emotion/react",
"@emotion/styled",
"@mui/icons-material",
"@mui/material",
/@semoss\/sdk/,
"@semoss/ui",
"mobx",
"mobx-react-lite",
"react",
"react-dom",
"react-router-dom",
],
watch: {
clearScreen: false,
},
input: {
index: "src/index.ts",
},
output: {
dir: "dist",
format: "esm",
sourcemap: isProduction,
entryFileNames: "[name].mjs",
},
plugins: [
del({ targets: "dist" }),
stripUseClient(),
resolve(),
commonjs(),
image(),
json(),
typescript({
tsconfig: "./tsconfig.json",
}),
isProduction && terser(),
],
external: [
"@emotion/react",
"@emotion/styled",
"@mui/icons-material",
"@mui/material",
/@semoss\/sdk/,
"@semoss/ui",
"mobx",
"mobx-react-lite",
"react",
"react-dom",
"react-router-dom",
],
watch: {
clearScreen: false,
},
});
2 changes: 1 addition & 1 deletion libs/renderer/src/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Blocks, RendererEngine } from "./components/blocks";
import { DefaultCells } from "./components/cell-defaults";
import {
MigrationManager,
SerializedState,
type SerializedState,
STATE_VERSION,
StateStore,
} from "./store/state";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,95 +1,93 @@
import { CSSProperties, useEffect } from "react";
import { observer } from "mobx-react-lite";
import { ArrowDropDown } from "@mui/icons-material";

import { observer } from "mobx-react-lite";
import { type CSSProperties, useEffect } from "react";
import { Accordion, Stack, styled } from "@semoss/ui";

import { Slot } from "../../blocks";
import { useBlock } from "../../../hooks";
import { BlockDef, BlockComponent, ListenerActions } from "../../../store";
import type { BlockComponent, BlockDef, ListenerActions } from "../../../store";
import { Slot } from "../../blocks";

const StyledAccordion = styled(Accordion)(({ theme }) => ({
padding: 0,
margin: 0,
borderRadius: "12px",
"&.MuiAccordion-root:before": {
backgroundColor: "white",
},
padding: 0,
margin: 0,
borderRadius: "12px",
"&.MuiAccordion-root:before": {
backgroundColor: "white",
},
}));

const AccordionTrigger = styled(Accordion.Trigger)(({ theme }) => ({
"& .MuiAccordionSummary-content": {
margin: 0,
},
minHeight: "fit-content",
margin: 0,
padding: 0,
borderRadius: "inherit",
//if accordion is expanded, then remove the border radius from bottom left and right side of the trigger element
"&.MuiButtonBase-root.Mui-expanded": {
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
},
"& .MuiAccordionSummary-content": {
margin: 0,
},
minHeight: "fit-content",
margin: 0,
padding: 0,
borderRadius: "inherit",
//if accordion is expanded, then remove the border radius from bottom left and right side of the trigger element
"&.MuiButtonBase-root.Mui-expanded": {
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
},
}));

const AccordionContent = styled(Accordion.Content)(({ theme }) => ({
margin: 0,
padding: 0,
borderRadius: "inherit",
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
margin: 0,
padding: 0,
borderRadius: "inherit",
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
}));

export interface AccordionBlockDef extends BlockDef<"accordion"> {
widget: "accordion";
data: {
style: CSSProperties;
triggerBgColor: string;
contentBgColor: string;
showExpandIcon: boolean;
show: string;
};
slots: {
header: true;
content: true;
};
listeners: {
preProcess: {
type: "sync" | "async";
order: ListenerActions[];
};
};
widget: "accordion";
data: {
style: CSSProperties;
triggerBgColor: string;
contentBgColor: string;
showExpandIcon: boolean;
show: string;
};
slots: {
header: true;
content: true;
};
listeners: {
preProcess: {
type: "sync" | "async";
order: ListenerActions[];
};
};
}

export const AccordionBlock: BlockComponent = observer(({ id }) => {
const { attrs, data, slots, listeners } = useBlock<AccordionBlockDef>(id);
const { attrs, data, slots, listeners } = useBlock<AccordionBlockDef>(id);

useEffect(() => {
if (listeners.preProcess) {
listeners.preProcess();
}
}, []);
useEffect(() => {
if (listeners.preProcess) {
listeners.preProcess();
}
}, []);

return (
<StyledAccordion
{...attrs}
sx={{ ...data.style, overflow: "hidden" }}
square={true}
disableGutters={true}
>
<AccordionTrigger
sx={{
backgroundColor: data.triggerBgColor,
}}
expandIcon={data.showExpandIcon ? <ArrowDropDown /> : null}
>
<Stack sx={{ width: "100%" }}>
<Slot slot={slots.header} />
</Stack>
</AccordionTrigger>
<AccordionContent sx={{ backgroundColor: data.contentBgColor }}>
<Slot slot={slots.content} />
</AccordionContent>
</StyledAccordion>
);
return (
<StyledAccordion
{...attrs}
sx={{ ...data.style, overflow: "hidden" }}
square={true}
disableGutters={true}
>
<AccordionTrigger
sx={{
backgroundColor: data.triggerBgColor,
}}
expandIcon={data.showExpandIcon ? <ArrowDropDown /> : null}
>
<Stack sx={{ width: "100%" }}>
<Slot slot={slots.header} />
</Stack>
</AccordionTrigger>
<AccordionContent sx={{ backgroundColor: data.contentBgColor }}>
<Slot slot={slots.content} />
</AccordionContent>
</StyledAccordion>
);
});
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { BlockConfig } from "../../../store";
import type { BlockConfig } from "../../../store";
import { BLOCK_TYPE_LAYOUT } from "../block-defaults.constants";
import { AccordionBlock, AccordionBlockDef } from "./AccordionBlock";
import { AccordionBlock, type AccordionBlockDef } from "./AccordionBlock";

export const config: BlockConfig<AccordionBlockDef> = {
widget: "accordion",
type: BLOCK_TYPE_LAYOUT,
data: {
style: {},
triggerBgColor: "",
contentBgColor: "",
showExpandIcon: true,
show: "true",
},
listeners: {
preProcess: {
type: "sync",
order: [],
},
},
slots: {
header: [],
content: [],
},
render: AccordionBlock,
widget: "accordion",
type: BLOCK_TYPE_LAYOUT,
data: {
style: {},
triggerBgColor: "",
contentBgColor: "",
showExpandIcon: true,
show: "true",
},
listeners: {
preProcess: {
type: "sync",
order: [],
},
},
slots: {
header: [],
content: [],
},
render: AccordionBlock,
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./config";
export * from "./AccordionBlock";
export * from "./config";
Loading