Skip to content

Commit

Permalink
lowcoder-comps backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
raheeliftikhar5 committed Jul 15, 2024
1 parent 6d59b28 commit 7919ba6
Show file tree
Hide file tree
Showing 27 changed files with 124 additions and 48 deletions.
2 changes: 1 addition & 1 deletion client/packages/lowcoder-comps/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lowcoder-comps",
"version": "2.4.8",
"version": "2.4.9",
"type": "module",
"license": "MIT",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ BasicChartTmpComp = withViewFn(BasicChartTmpComp, (comp) => {
log.error('theme chart error: ', error);
}

useMergeCompStyles(childrenToProps(comp.children), comp.dispatch);
useMergeCompStyles?.(childrenToProps(comp.children), comp.dispatch);

const triggerClickEvent = async (dispatch: any, action: CompAction<JSONValue>) => {
await getPromiseAfterDispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultEchartsJsonOption),
echartsTitle: withDefault(StringControl, trans("echarts.defaultTitle")),
echartsTitle: withDefault(StringControl, trans("echarts.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
ThemeContext,
CalendarStyle,
DateParser,
modalInstance,
CustomModal,
jsonValueExposingStateControl,
CalendarDeleteIcon,
Expand Down Expand Up @@ -70,16 +71,13 @@ import {
resourceTimeGridHeaderToolbar,
} from "./calendarConstants";

// this should ensure backwards compatibility with older versions of the SDK
const safeDragEventHandlerControl = typeof DragEventHandlerControl !== 'undefined' ? DragEventHandlerControl : () => {};

const childrenMap = {
let childrenMap: any = {
events: jsonValueExposingStateControl("events", defaultData),
resourcesEvents: jsonValueExposingStateControl("resourcesEvents", resourcesEventsDefaultData),
resources: jsonValueExposingStateControl("resources", resourcesDefaultData),
resourceName: withDefault(StringControl, trans("calendar.resourcesDefault")),
onEvent: ChangeEventHandlerControl,
onDropEvent: safeDragEventHandlerControl,
// onDropEvent: safeDragEventHandlerControl,
editable: withDefault(BoolControl, true),
showEventTime: withDefault(BoolControl, true),
showWeekends: withDefault(BoolControl, true),
Expand All @@ -93,7 +91,13 @@ const childrenMap = {
currentFreeView: dropdownControl(DefaultWithFreeViewOptions, "timeGridWeek"),
currentPremiumView: dropdownControl(DefaultWithPremiumViewOptions, "resourceTimelineDay"),
};

// this should ensure backwards compatibility with older versions of the SDK
if (DragEventHandlerControl) {
childrenMap = {
...childrenMap,
onDropEvent: DragEventHandlerControl,
}
}
let CalendarBasicComp = (function () {
return new UICompBuilder(childrenMap, (props: {
events: any;
Expand Down Expand Up @@ -124,7 +128,7 @@ let CalendarBasicComp = (function () {
const [left, setLeft] = useState<number | undefined>(undefined);
const [licensed, setLicensed] = useState<boolean>(props.licenseKey !== "");

useMergeCompStyles(props, dispatch);
useMergeCompStyles?.(props, dispatch);

useEffect(() => {
setLicensed(props.licenseKey !== "");
Expand Down Expand Up @@ -326,6 +330,8 @@ let CalendarBasicComp = (function () {
};

const showModal = (event: EventType, ifEdit: boolean) => {
if (!modalInstance) return;

const modalTitle = ifEdit
? trans("calendar.editEvent")
: trans("calendar.creatEvent");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultCandleStickChartOption),
echartsTitle: withDefault(StringControl, trans("candleStickChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function candleStickChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
}

const triggerClickEvent = async (dispatch: any, action: CompAction<JSONValue>) => {
await getPromiseAfterDispatch(
await getPromiseAfterDispatch?.(
dispatch,
action,
{ autoHandleAfterReduce: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultFunnelChartOption),
echartsTitle: withDefault(StringControl, trans("funnelChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
echartsTitleConfig:EchartsTitleConfig,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
label: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
Expand All @@ -267,6 +267,12 @@ const chartJsonModeChildren = {
max:withDefault(NumberControl,trans('funnelChart.defaultMax')),
gap:withDefault(NumberControl,trans('funnelChart.defaultGap'))
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function funnelChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultGaugeChartOption),
echartsTitle: withDefault(StringControl, trans("gaugeChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
echartsTitleConfig:EchartsTitleConfig,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
label: withDefault(BoolControl, true),
Expand All @@ -267,7 +267,12 @@ const chartJsonModeChildren = {
max:withDefault(NumberControl,trans('gaugeChart.defaultMax')),
gap:withDefault(NumberControl,trans('gaugeChart.defaultGap'))
}

if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}
const chartMapModeChildren = {
mapInstance: stateComp(),
getMapInstance: FunctionControl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function gaugeChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultGraphChartOption),
echartsTitle: withDefault(StringControl, trans("graphChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function graphChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultHeatmapChartOption),
echartsTitle: withDefault(StringControl, trans("heatmapChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function heatmapChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultRadarChartOption),
echartsTitle: withDefault(StringControl, trans("radarChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function radarChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultSankeyChartOption),
echartsTitle: withDefault(StringControl, trans("sankeyChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function sankeyChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,22 @@ export const chartUiModeChildren = {
onUIEvent: eventHandlerControl(UIEventOptions),
};

const chartJsonModeChildren = {
let chartJsonModeChildren: any = {
echartsOption: jsonControl(toObject, i18nObjs.defaultSunburstChartOption),
echartsTitle: withDefault(StringControl, trans("sunburstChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsConfig: EchartsOptionComp,
style: styleControl(EchartsStyle, 'style'),
// style: styleControl(EchartsStyle, 'style'),
tooltip: withDefault(BoolControl, true),
legendVisibility: withDefault(BoolControl, true),
}
if (EchartsStyle) {
chartJsonModeChildren = {
...chartJsonModeChildren,
style: styleControl(EchartsStyle, 'style'),
}
}

const chartMapModeChildren = {
mapInstance: stateComp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function sunburstChartPropertyView(
{children.onEvent.propertyView()}
</Section>
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
{children.style?.getPropertyView()}
</Section>
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
</>
Expand Down
Loading

0 comments on commit 7919ba6

Please sign in to comment.