diff --git a/packages/pluggable-widgets-tools/CHANGELOG.md b/packages/pluggable-widgets-tools/CHANGELOG.md index 367a3f47..7f9029eb 100644 --- a/packages/pluggable-widgets-tools/CHANGELOG.md +++ b/packages/pluggable-widgets-tools/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added + +- We added support for single object datasource properties, introduced in Mendix 11.11. + ### Changed - We changed the order of imports in generated widget prop types to match that of the eslint sort-imports rule. diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts index 50c894d8..0d6793a5 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts @@ -47,6 +47,8 @@ import {listActionWithVariablesInput, listActionWithVariablesInputNative} from " import {listActionWithVariablesOutput, listActionWithVariablesOutputNative} from "./outputs/list-action-with-variables"; import {imageWebInput, imageNativeInput} from "./inputs/image"; import {imageWebOutput, imageNativeOutput} from "./outputs/image"; +import { singleObjectDatasourceInput, singleObjectDatasourceInputNative } from "./inputs/single-object-datasource"; +import { singleObjectDatasourceNativeOutput, singleObjectDatasourceWebOutput } from "./outputs/single-object-datasource"; describe("Generating tests", () => { it("Generates a parsed typing from XML for native", () => { @@ -248,6 +250,16 @@ describe("Generating tests", () => { const newContent = generateNativeTypesFor(imageNativeInput); expect(newContent).toBe(imageNativeOutput); }); + + it("Generates a parsed typing from XML for web using single object datasource", () => { + const newContent = generateFullTypesFor(singleObjectDatasourceInput); + expect(newContent).toBe(singleObjectDatasourceWebOutput); + }); + + it("Generates a parsed typing from XML for native using single object datasource", () => { + const newContent = generateNativeTypesFor(singleObjectDatasourceInputNative); + expect(newContent).toBe(singleObjectDatasourceNativeOutput); + }); }); function generateFullTypesFor(xml: string) { diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/single-object-datasource.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/single-object-datasource.ts new file mode 100644 index 00000000..97850552 --- /dev/null +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/single-object-datasource.ts @@ -0,0 +1,136 @@ +export const singleObjectDatasourceInput = ` + + + + + Single object data source + + + + Optional single object data source + + + + List data source + + + + Single Content + + + + Single Attribute + + + + + + + + + Single Action + + + + Single Text Template + + + + Single Expression + + + + + Optional Single Attribute + + + + + + + Optional Single Action + + + + List Content + + + + List Attribute + + + + + + + List Action + + + + + + + + +`; + +export const singleObjectDatasourceInputNative = ` + + + + + Single object data source + + + + List data source + + + + Single Content + + + + Single Attribute + + + + + + + + + Single Action + + + + Single Text Template + + + + Single Expression + + + + + List Content + + + + List Attribute + + + + + + + List Action + + + + +`; diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/single-object-datasource.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/single-object-datasource.ts new file mode 100644 index 00000000..9aec6809 --- /dev/null +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/single-object-datasource.ts @@ -0,0 +1,62 @@ +export const singleObjectDatasourceWebOutput = `/** + * This file was generated from MyWidget.xml + * WARNING: All changes made to this file will be overwritten + * @author Mendix Widgets Framework Team + */ +import { ActionValue, DynamicValue, EditableValue, ListActionValue, ListAttributeValue, ListValue, ListWidgetValue, ObjectItem } from "mendix"; +import { ComponentType, ReactNode } from "react"; +import { Big } from "big.js"; + +export interface MyWidgetContainerProps { + name: string; + tabIndex?: number; + id: string; + singleSource: DynamicValue; + optionalSingleSource?: DynamicValue; + listSource: ListValue; + singleContent: ReactNode; + singleAttribute: EditableValue; + singleAction?: ActionValue; + singleTextTemplate: DynamicValue; + singleExpression: DynamicValue; + optionalSingleAttribute?: EditableValue; + optionalSingleAction?: ActionValue; + listContent: ListWidgetValue; + listAttribute: ListAttributeValue; + listAction?: ListActionValue; +} + +export interface MyWidgetPreviewProps { + readOnly: boolean; + renderMode: "design" | "xray" | "structure"; + translate: (text: string) => string; + singleSource: {} | { caption: string } | { type: string } | null; + optionalSingleSource: {} | { caption: string } | { type: string } | null; + listSource: {} | { caption: string } | { type: string } | null; + singleContent: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> }; + singleAttribute: string; + singleAction: {} | null; + singleTextTemplate: string; + singleExpression: string; + optionalSingleAttribute: string; + optionalSingleAction: {} | null; + listContent: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> }; + listAttribute: string; + listAction: {} | null; +} +`; + +export const singleObjectDatasourceNativeOutput = `export interface MyWidgetProps