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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint:fix
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.biome": "always"
}
}
2 changes: 1 addition & 1 deletion benchmark/benchmarkWidget/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const base = require("@mendix/pluggable-widgets-tools/configs/eslint.ts.base.json");

module.exports = {
...base
...base,
};
8 changes: 6 additions & 2 deletions benchmark/benchmarkWidget/prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json");

module.exports = {
...base,
plugins: [require.resolve("@prettier/plugin-xml")],
...base,
plugins: [
require.resolve(
"@prettier/plugin-xml",
),
],
};
121 changes: 75 additions & 46 deletions benchmark/benchmarkWidget/src/BenchmarkWidget.editorConfig.ts
Original file line number Diff line number Diff line change
@@ -1,115 +1,144 @@
import { BenchmarkWidgetPreviewProps } from "../typings/BenchmarkWidgetProps";

export type Platform = "web" | "desktop";
export type Platform =
| "web"
| "desktop";

export type Properties = PropertyGroup[];
export type Properties =
PropertyGroup[];

type PropertyGroup = {
type PropertyGroup =
{
caption: string;
propertyGroups?: PropertyGroup[];
properties?: Property[];
};
};

type Property = {
key: string;
caption: string;
description?: string;
objectHeaders?: string[]; // used for customizing object grids
objects?: ObjectProperties[];
properties?: Properties[];
key: string;
caption: string;
description?: string;
objectHeaders?: string[]; // used for customizing object grids
objects?: ObjectProperties[];
properties?: Properties[];
};

type ObjectProperties = {
type ObjectProperties =
{
properties: PropertyGroup[];
captions?: string[]; // used for customizing object grids
};
};

export type Problem = {
export type Problem =
{
property?: string; // key of the property, at which the problem exists
severity?: "error" | "warning" | "deprecation"; // default = "error"
severity?:
| "error"
| "warning"
| "deprecation"; // default = "error"
message: string; // description of the problem
studioMessage?: string; // studio-specific message, defaults to message
url?: string; // link with more information about the problem
studioUrl?: string; // studio-specific link
};
};

type BaseProps = {
type: "Image" | "Container" | "RowLayout" | "Text" | "DropZone" | "Selectable" | "Datasource";
grow?: number; // optionally sets a growth factor if used in a layout (default = 1)
type:
| "Image"
| "Container"
| "RowLayout"
| "Text"
| "DropZone"
| "Selectable"
| "Datasource";
grow?: number; // optionally sets a growth factor if used in a layout (default = 1)
};

type ImageProps = BaseProps & {
type ImageProps =
BaseProps & {
type: "Image";
document?: string; // svg image
data?: string; // base64 image
property?: object; // widget image property object from Values API
width?: number; // sets a fixed maximum width
height?: number; // sets a fixed maximum height
};
};

type ContainerProps = BaseProps & {
type: "Container" | "RowLayout";
type ContainerProps =
BaseProps & {
type:
| "Container"
| "RowLayout";
children: PreviewProps[]; // any other preview element
borders?: boolean; // sets borders around the layout to visually group its children
borderRadius?: number; // integer. Can be used to create rounded borders
backgroundColor?: string; // HTML color, formatted #RRGGBB
borderWidth?: number; // sets the border width
padding?: number; // integer. adds padding around the container
};
};

type RowLayoutProps = ContainerProps & {
type RowLayoutProps =
ContainerProps & {
type: "RowLayout";
columnSize?: "fixed" | "grow"; // default is fixed
};
columnSize?:
| "fixed"
| "grow"; // default is fixed
};

type TextProps = BaseProps & {
type TextProps =
BaseProps & {
type: "Text";
content: string; // text that should be shown
fontSize?: number; // sets the font size
fontColor?: string; // HTML color, formatted #RRGGBB
bold?: boolean;
italic?: boolean;
};
};

type DropZoneProps = BaseProps & {
type DropZoneProps =
BaseProps & {
type: "DropZone";
property: object; // widgets property object from Values API
placeholder: string; // text to be shown inside the dropzone when empty
showDataSourceHeader?: boolean; // true by default. Toggles whether to show a header containing information about the datasource
};
};

type SelectableProps = BaseProps & {
type SelectableProps =
BaseProps & {
type: "Selectable";
object: object; // object property instance from the Value API
child: PreviewProps; // any type of preview property to visualize the object instance
};
};

type DatasourceProps = BaseProps & {
type DatasourceProps =
BaseProps & {
type: "Datasource";
property: object | null; // datasource property object from Values API
property:
| object
| null; // datasource property object from Values API
child?: PreviewProps; // any type of preview property component (optional)
};
};

export type PreviewProps =
| ImageProps
| ContainerProps
| RowLayoutProps
| TextProps
| DropZoneProps
| SelectableProps
| DatasourceProps;
| ImageProps
| ContainerProps
| RowLayoutProps
| TextProps
| DropZoneProps
| SelectableProps
| DatasourceProps;

export function getProperties(
_values: BenchmarkWidgetPreviewProps,
defaultProperties: Properties /* , target: Platform*/
_values: BenchmarkWidgetPreviewProps,
defaultProperties: Properties /* , target: Platform*/,
): Properties {
// Do the values manipulation here to control the visibility of properties in Studio and Studio Pro conditionally.
/* Example
// Do the values manipulation here to control the visibility of properties in Studio and Studio Pro conditionally.
/* Example
if (values.myProperty === "custom") {
delete defaultProperties.properties.myOtherProperty;
}
*/
return defaultProperties;
return defaultProperties;
}

// export function check(_values: BenchmarkWidgetPreviewProps): Problem[] {
Expand Down
14 changes: 11 additions & 3 deletions benchmark/benchmarkWidget/src/BenchmarkWidget.editorPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { ReactElement, createElement } from "react";
import {
ReactElement,
createElement,
} from "react";

export function preview(): ReactElement {
return <div>Benchmark Widget</div>;
return (
<div>
Benchmark
Widget
</div>
);
}

export function getPreviewCss(): string {
return require("./ui/BenchmarkWidget.css");
return require("./ui/BenchmarkWidget.css");
}
9 changes: 7 additions & 2 deletions benchmark/benchmarkWidget/src/BenchmarkWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { ReactElement, createElement } from "react";
import {
ReactElement,
createElement,
} from "react";
import { CalendarWidget } from "./components/CalendarWidget";

import "./ui/BenchmarkWidget.css";

export function BenchmarkWidget(): ReactElement {
return <CalendarWidget />;
return (
<CalendarWidget />
);
}
38 changes: 27 additions & 11 deletions benchmark/benchmarkWidget/src/components/CalendarWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
import { ReactElement, createElement } from "react";
import { Calendar, dayjsLocalizer } from "react-big-calendar";
import {
ReactElement,
createElement,
} from "react";
import {
Calendar,
dayjsLocalizer,
} from "react-big-calendar";
import dayjs from "dayjs";

import "react-big-calendar/lib/css/react-big-calendar.css";

const localizer = dayjsLocalizer(dayjs);
const localizer =
dayjsLocalizer(
dayjs,
);

export function CalendarWidget(): ReactElement {
return (
<Calendar
localizer={localizer}
defaultDate={new Date()}
defaultView="month"
style={{ width: 600, height: 800 }}
/>
);
return (
<Calendar
localizer={
localizer
}
defaultDate={
new Date()
}
defaultView="month"
style={{
width: 600,
height: 800,
}}
/>
);
}
1 change: 0 additions & 1 deletion benchmark/benchmarkWidget/src/ui/BenchmarkWidget.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
Place your custom CSS here
*/
.widget-hello-world {

}
5 changes: 4 additions & 1 deletion benchmark/benchmarkWidget/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"compilerOptions": {
"baseUrl": "./"
},
"include": ["./src", "./typings"]
"include": [
"./src",
"./typings"
]
}
14 changes: 10 additions & 4 deletions benchmark/benchmarkWidget/typings/BenchmarkWidgetProps.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* This file was automatically generated by @repixelcorp/hyper-pwt v0.3.1
* DO NOT MODIFY THIS FILE DIRECTLY
*
*
* To regenerate this file, run the type generator with your widget XML file.
* Any manual changes to this file will be lost when the types are regenerated.
*/

import { CSSProperties } from 'mendix';
import { CSSProperties } from "mendix";

/**
* Props for Benchmark Widget
Expand All @@ -27,7 +27,10 @@ export interface BenchmarkWidgetContainerProps {
sampleText?: string;
}

import type { CSSProperties, PreviewValue } from 'react';
import type {
CSSProperties,
PreviewValue,
} from "react";

/**
* Preview props for Benchmark Widget
Expand All @@ -42,7 +45,10 @@ export interface BenchmarkWidgetPreviewProps {
/**
* The render mode of the widget preview
*/
renderMode?: "design" | "xray" | "structure";
renderMode?:
| "design"
| "xray"
| "structure";
/**
* @deprecated Use class property instead
*/
Expand Down
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"fs-extra": "^11.2.0"
},
"devDependencies": {}
}
}
Loading