Skip to content

Commit b66cfe7

Browse files
committed
Merge branch 'sync_v1.1.5' into 'develop'
multiChanges: feat: query event handler add default See merge request taco/openblocks-oss!11
2 parents 01e0fbf + 4f4885f commit b66cfe7

File tree

184 files changed

+4333
-1494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+4333
-1494
lines changed

client/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.4
1+
1.1.5

client/packages/openblocks-cli/client.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ declare var REACT_APP_LOG_LEVEL: string;
3636
declare var REACT_APP_IMPORT_MAP: string;
3737
declare var REACT_APP_SERVER_IPS: string;
3838
declare var REACT_APP_BUNDLE_TYPE: "sdk" | "app";
39+
declare var REACT_APP_DISABLE_JS_SANDBOX: string;
40+
declare var REACT_APP_BUNDLE_BUILTIN_PLUGIN: string;

client/packages/openblocks-comps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openblocks-comps",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {

client/packages/openblocks-comps/src/comps/chartComp/chartComp.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AxisFormatterComp, EchartsAxisType } from "./chartConfigs/cartesianAxis
99
import { chartChildrenMap, ChartSize, getDataKeys } from "./chartConstants";
1010
import { chartPropertyView } from "./chartPropertyView";
1111
import _ from "lodash";
12-
import { useEffect, useMemo, useRef, useState } from "react";
12+
import { useContext, useEffect, useMemo, useRef, useState } from "react";
1313
import ReactResizeDetector from "react-resize-detector";
1414
import ReactECharts from "./reactEcharts";
1515
import {
@@ -24,6 +24,8 @@ import {
2424
withDefault,
2525
withExposingConfigs,
2626
withViewFn,
27+
ThemeContext,
28+
chartColorPalette,
2729
} from "openblocks-sdk";
2830
import { getEchartsLocale, trans } from "i18n/comps";
2931
import { ItemColorComp } from "comps/chartComp/chartConfigs/lineChartConfig";
@@ -32,6 +34,7 @@ import {
3234
getEchartsConfig,
3335
getSelectedPoints,
3436
} from "comps/chartComp/chartUtils";
37+
import log from "loglevel";
3538

3639
let ChartTmpComp = (function () {
3740
return new UICompBuilder(chartChildrenMap, () => null)
@@ -43,6 +46,17 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
4346
const echartsCompRef = useRef<ReactECharts | null>();
4447
const [chartSize, setChartSize] = useState<ChartSize>();
4548
const firstResize = useRef(true);
49+
const theme = useContext(ThemeContext);
50+
const defaultChartTheme = {
51+
color: chartColorPalette,
52+
backgroundColor: "#fff",
53+
};
54+
let themeConfig = defaultChartTheme;
55+
try {
56+
themeConfig = theme?.theme.chart ? JSON.parse(theme?.theme.chart) : defaultChartTheme;
57+
} catch (error) {
58+
log.error('theme chart error: ', error);
59+
}
4660
const onEvent = comp.children.onEvent.getView();
4761
useEffect(() => {
4862
// bind events
@@ -94,6 +108,7 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
94108
lazyUpdate
95109
opts={{ locale: getEchartsLocale() }}
96110
option={option}
111+
theme={themeConfig}
97112
/>
98113
</ReactResizeDetector>
99114
);

client/packages/openblocks-comps/src/comps/chartComp/chartUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ export function getEchartsConfig(props: EchartsConfigProps, chartSize?: ChartSiz
135135
bottom: 35,
136136
};
137137
let config: EChartsOption = {
138-
color: chartColorPalette,
139138
title: { text: props.title, left: "center" },
140-
backgroundColor: "#fff",
141139
tooltip: {
142140
confine: true,
143141
trigger: axisChart ? "axis" : "item",

client/packages/openblocks-core/lib/index.cjs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ var FunctionNode = /** @class */ (function (_super) {
318318
FunctionNode.prototype.dependValues = function () {
319319
return this.child.dependValues();
320320
};
321-
FunctionNode.prototype.fetchInfo = function (exposingNodes) {
322-
return this.child.fetchInfo(exposingNodes);
321+
FunctionNode.prototype.fetchInfo = function (exposingNodes, options) {
322+
return this.child.fetchInfo(exposingNodes, options);
323323
};
324324
__decorate([
325325
memoized()
@@ -390,12 +390,12 @@ var RecordNode = /** @class */ (function (_super) {
390390
});
391391
return ret;
392392
};
393-
RecordNode.prototype.fetchInfo = function (exposingNodes) {
393+
RecordNode.prototype.fetchInfo = function (exposingNodes, options) {
394394
var isFetching = false;
395395
var ready = true;
396396
Object.entries(this.children).forEach(function (_a) {
397397
_a[0]; var child = _a[1];
398-
var fi = child.fetchInfo(exposingNodes);
398+
var fi = child.fetchInfo(exposingNodes, options);
399399
isFetching = fi.isFetching || isFetching;
400400
ready = fi.ready && ready;
401401
});
@@ -1552,6 +1552,7 @@ function string2Fn(unevaledValue, type, methods) {
15521552

15531553
var IS_FETCHING_FIELD = "isFetching";
15541554
var LATEST_END_TIME_FIELD = "latestEndTime";
1555+
var TRIGGER_TYPE_FIELD = "triggerType";
15551556
/**
15561557
* user input node
15571558
*
@@ -1662,7 +1663,7 @@ var CodeNode = /** @class */ (function (_super) {
16621663
});
16631664
return ret;
16641665
};
1665-
CodeNode.prototype.fetchInfo = function (exposingNodes) {
1666+
CodeNode.prototype.fetchInfo = function (exposingNodes, options) {
16661667
if (!!this.evalCache.inIsFetching) {
16671668
return {
16681669
isFetching: false,
@@ -1676,6 +1677,11 @@ var CodeNode = /** @class */ (function (_super) {
16761677
var ready_1 = true;
16771678
topDepends.forEach(function (paths, depend) {
16781679
var value = depend.evaluate(exposingNodes);
1680+
if ((options === null || options === void 0 ? void 0 : options.ignoreManualDepReadyStatus) &&
1681+
___default["default"].has(value, TRIGGER_TYPE_FIELD) &&
1682+
value.triggerType === "manual") {
1683+
return;
1684+
}
16791685
if (___default["default"].has(value, IS_FETCHING_FIELD)) {
16801686
isFetching_1 = isFetching_1 || value.isFetching === true;
16811687
}
@@ -1685,7 +1691,7 @@ var CodeNode = /** @class */ (function (_super) {
16851691
});
16861692
var dependingNodeMap = this.filterNodes(exposingNodes);
16871693
dependingNodeMap.forEach(function (paths, depend) {
1688-
var fi = depend.fetchInfo(exposingNodes);
1694+
var fi = depend.fetchInfo(exposingNodes, options);
16891695
isFetching_1 = isFetching_1 || fi.isFetching;
16901696
ready_1 = ready_1 && fi.ready;
16911697
});
@@ -1727,9 +1733,10 @@ function fixCyclic(extra, exposingNodes) {
17271733
*/
17281734
var FetchCheckNode = /** @class */ (function (_super) {
17291735
__extends(FetchCheckNode, _super);
1730-
function FetchCheckNode(child) {
1736+
function FetchCheckNode(child, options) {
17311737
var _this = _super.call(this) || this;
17321738
_this.child = child;
1739+
_this.options = options;
17331740
_this.type = "fetchCheck";
17341741
return _this;
17351742
}
@@ -1746,7 +1753,7 @@ var FetchCheckNode = /** @class */ (function (_super) {
17461753
return this.child.dependValues();
17471754
};
17481755
FetchCheckNode.prototype.fetchInfo = function (exposingNodes) {
1749-
return this.child.fetchInfo(exposingNodes);
1756+
return this.child.fetchInfo(exposingNodes, this.options);
17501757
};
17511758
__decorate([
17521759
memoized()
@@ -3322,6 +3329,7 @@ var MultiBaseComp = /** @class */ (function (_super) {
33223329
__extends(MultiBaseComp, _super);
33233330
function MultiBaseComp(params) {
33243331
var _this = _super.call(this, params) || this;
3332+
_this.IGNORABLE_DEFAULT_VALUE = {};
33253333
_this.children = _this.parseChildrenFromValue(params);
33263334
return _this;
33273335
}
@@ -3465,16 +3473,24 @@ var MultiBaseComp = /** @class */ (function (_super) {
34653473
});
34663474
return _super.prototype.changeDispatch.call(this, dispatch).setChildren(newChildren, { keepCacheKeys: ["node"] });
34673475
};
3476+
MultiBaseComp.prototype.ignoreChildDefaultValue = function () {
3477+
return false;
3478+
};
34683479
MultiBaseComp.prototype.toJsonValue = function () {
34693480
var _this = this;
34703481
var result = {};
3482+
var ignore = this.ignoreChildDefaultValue();
34713483
Object.keys(this.children).forEach(function (key) {
34723484
var comp = _this.children[key];
34733485
// FIXME: this implementation is a little tricky, better choose a encapsulated implementation
34743486
if (comp.hasOwnProperty("NO_PERSISTENCE")) {
34753487
return;
34763488
}
3477-
result[key] = comp.toJsonValue();
3489+
var value = comp.toJsonValue();
3490+
if (ignore && ___default["default"].isEqual(value, comp["IGNORABLE_DEFAULT_VALUE"])) {
3491+
return;
3492+
}
3493+
result[key] = value;
34783494
});
34793495
return result;
34803496
};
@@ -7484,10 +7500,14 @@ var Translator = /** @class */ (function () {
74847500
this.messages = Object.assign({}, data, globalMessages);
74857501
this.language = language;
74867502
this.trans = this.trans.bind(this);
7503+
this.transToNode = this.transToNode.bind(this);
74877504
}
74887505
Translator.prototype.trans = function (key, variables) {
7506+
return this.transToNode(key, variables).toString();
7507+
};
7508+
Translator.prototype.transToNode = function (key, variables) {
74897509
var message = this.getMessage(key);
7490-
return new IntlMessageFormat(message, i18n.locale).format(variables).toString();
7510+
return new IntlMessageFormat(message, i18n.locale).format(variables);
74917511
};
74927512
Translator.prototype.getMessage = function (key) {
74937513
var value = this.messages[key];

client/packages/openblocks-core/lib/index.d.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference types="react" />
2+
import * as react from "react";
13
import { ReactNode } from "react";
24

35
declare type EvalMethods = Record<string, Record<string, Function>>;
@@ -27,6 +29,9 @@ declare type NonOptionalKeys<T> = {
2729
declare type RecordOptionalNodeToValue<T> = {
2830
[K in NonOptionalKeys<T>]: NodeToValue<T[K]>;
2931
};
32+
interface FetchInfoOptions {
33+
ignoreManualDepReadyStatus?: boolean;
34+
}
3035
/**
3136
* the base structure for evaluate
3237
*/
@@ -56,7 +61,7 @@ interface Node<T> {
5661
* FIXME: this should be a protected function.
5762
*/
5863
filterNodes(exposingNodes: Record<string, Node<unknown>>): Map<Node<unknown>, Set<string>>;
59-
fetchInfo(exposingNodes: Record<string, Node<unknown>>): FetchInfo;
64+
fetchInfo(exposingNodes: Record<string, Node<unknown>>, options?: FetchInfoOptions): FetchInfo;
6065
}
6166
declare abstract class AbstractNode<T> implements Node<T> {
6267
readonly type: string;
@@ -140,7 +145,7 @@ declare class FunctionNode<T, OutputType> extends AbstractNode<OutputType> {
140145
justEval(exposingNodes: Record<string, Node<unknown>>, methods?: EvalMethods): OutputType;
141146
getChildren(): Node<unknown>[];
142147
dependValues(): Record<string, unknown>;
143-
fetchInfo(exposingNodes: Record<string, Node<unknown>>): FetchInfo;
148+
fetchInfo(exposingNodes: Record<string, Node<unknown>>, options?: FetchInfoOptions): FetchInfo;
144149
}
145150
declare function withFunction<T, OutputType>(
146151
child: Node<T>,
@@ -193,7 +198,7 @@ declare class CodeNode extends AbstractNode<ValueAndMsg<unknown>> {
193198
): ValueAndMsg<unknown>;
194199
getChildren(): Node<unknown>[];
195200
dependValues(): Record<string, unknown>;
196-
fetchInfo(exposingNodes: Record<string, Node<unknown>>): FetchInfo;
201+
fetchInfo(exposingNodes: Record<string, Node<unknown>>, options?: FetchInfoOptions): FetchInfo;
197202
}
198203
/**
199204
* generate node for unevaledValue
@@ -207,8 +212,9 @@ declare function fromUnevaledValue(
207212
*/
208213
declare class FetchCheckNode extends AbstractNode<FetchInfo> {
209214
readonly child: Node<unknown>;
215+
readonly options?: FetchInfoOptions | undefined;
210216
readonly type = "fetchCheck";
211-
constructor(child: Node<unknown>);
217+
constructor(child: Node<unknown>, options?: FetchInfoOptions | undefined);
212218
filterNodes(exposingNodes: Record<string, Node<unknown>>): Map<Node<unknown>, Set<string>>;
213219
justEval(exposingNodes: Record<string, Node<unknown>>): FetchInfo;
214220
getChildren(): Node<unknown>[];
@@ -236,7 +242,10 @@ declare class RecordNode<T extends Record<string, Node<unknown>>> extends Abstra
236242
): RecordNodeToValue<T>;
237243
getChildren(): Node<unknown>[];
238244
dependValues(): Record<string, unknown>;
239-
fetchInfo(exposingNodes: Record<string, Node<unknown>>): {
245+
fetchInfo(
246+
exposingNodes: Record<string, Node<unknown>>,
247+
options?: FetchInfoOptions
248+
): {
240249
isFetching: boolean;
241250
ready: boolean;
242251
};
@@ -678,6 +687,8 @@ declare abstract class MultiBaseComp<
678687
};
679688
nodeWithoutCache(): NodeType;
680689
changeDispatch(dispatch: DispatchType): this;
690+
protected ignoreChildDefaultValue(): boolean;
691+
readonly IGNORABLE_DEFAULT_VALUE: {};
681692
toJsonValue(): DataType;
682693
autoHeight(): boolean;
683694
}
@@ -737,7 +748,7 @@ declare type AddPrefix<T, P extends string> = {
737748
};
738749
declare const globalMessages: AddPrefix<{}, "@">;
739750
declare type GlobalMessageKey = NestedKey<typeof globalMessages>;
740-
declare type VariableValue = string | number | boolean | Date;
751+
declare type VariableValue = string | number | boolean | Date | React.ReactNode;
741752
declare class Translator<Messages extends object> {
742753
private readonly messages;
743754
readonly language: string;
@@ -746,6 +757,22 @@ declare class Translator<Messages extends object> {
746757
key: NestedKey<Messages> | GlobalMessageKey,
747758
variables?: Record<string, VariableValue>
748759
): string;
760+
transToNode(
761+
key: NestedKey<Messages> | GlobalMessageKey,
762+
variables?: Record<string, VariableValue>
763+
):
764+
| string
765+
| {}
766+
| react.ReactElement<any, string | react.JSXElementConstructor<any>>
767+
| Iterable<react.ReactNode>
768+
| react.ReactPortal
769+
| (
770+
| string
771+
| {}
772+
| react.ReactElement<any, string | react.JSXElementConstructor<any>>
773+
| Iterable<react.ReactNode>
774+
| react.ReactPortal
775+
)[];
749776
private getMessage;
750777
}
751778
declare function getI18nObjects<I18nObjects>(fileData: object, filterLocales?: string): I18nObjects;
@@ -781,6 +808,7 @@ export {
781808
ExtraNodeType,
782809
FetchCheckNode,
783810
FetchInfo,
811+
FetchInfoOptions,
784812
FunctionNode,
785813
MultiBaseComp,
786814
MultiChangeAction,

0 commit comments

Comments
 (0)