Skip to content

Commit 4f4885f

Browse files
committed
multiChanges: feat: mssql support gui mode
- feat: download action support base64 - feat: dynamic query config - feat: dynamic datasource extra params - feat: download action support base64 - feat: refactor withType - feat: restApi add icon - feat(table) support edit column width - feat(grid): develop Grid Comp based on ListView - bug fixes
1 parent 3bffd39 commit 4f4885f

File tree

116 files changed

+2305
-484
lines changed

Some content is hidden

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

116 files changed

+2305
-484
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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ var CodeNode = /** @class */ (function (_super) {
16911691
});
16921692
var dependingNodeMap = this.filterNodes(exposingNodes);
16931693
dependingNodeMap.forEach(function (paths, depend) {
1694-
var fi = depend.fetchInfo(exposingNodes);
1694+
var fi = depend.fetchInfo(exposingNodes, options);
16951695
isFetching_1 = isFetching_1 || fi.isFetching;
16961696
ready_1 = ready_1 && fi.ready;
16971697
});
@@ -3329,6 +3329,7 @@ var MultiBaseComp = /** @class */ (function (_super) {
33293329
__extends(MultiBaseComp, _super);
33303330
function MultiBaseComp(params) {
33313331
var _this = _super.call(this, params) || this;
3332+
_this.IGNORABLE_DEFAULT_VALUE = {};
33323333
_this.children = _this.parseChildrenFromValue(params);
33333334
return _this;
33343335
}
@@ -3472,16 +3473,24 @@ var MultiBaseComp = /** @class */ (function (_super) {
34723473
});
34733474
return _super.prototype.changeDispatch.call(this, dispatch).setChildren(newChildren, { keepCacheKeys: ["node"] });
34743475
};
3476+
MultiBaseComp.prototype.ignoreChildDefaultValue = function () {
3477+
return false;
3478+
};
34753479
MultiBaseComp.prototype.toJsonValue = function () {
34763480
var _this = this;
34773481
var result = {};
3482+
var ignore = this.ignoreChildDefaultValue();
34783483
Object.keys(this.children).forEach(function (key) {
34793484
var comp = _this.children[key];
34803485
// FIXME: this implementation is a little tricky, better choose a encapsulated implementation
34813486
if (comp.hasOwnProperty("NO_PERSISTENCE")) {
34823487
return;
34833488
}
3484-
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;
34853494
});
34863495
return result;
34873496
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ declare abstract class MultiBaseComp<
687687
};
688688
nodeWithoutCache(): NodeType;
689689
changeDispatch(dispatch: DispatchType): this;
690+
protected ignoreChildDefaultValue(): boolean;
691+
readonly IGNORABLE_DEFAULT_VALUE: {};
690692
toJsonValue(): DataType;
691693
autoHeight(): boolean;
692694
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ var CodeNode = /** @class */ (function (_super) {
16831683
});
16841684
var dependingNodeMap = this.filterNodes(exposingNodes);
16851685
dependingNodeMap.forEach(function (paths, depend) {
1686-
var fi = depend.fetchInfo(exposingNodes);
1686+
var fi = depend.fetchInfo(exposingNodes, options);
16871687
isFetching_1 = isFetching_1 || fi.isFetching;
16881688
ready_1 = ready_1 && fi.ready;
16891689
});
@@ -3321,6 +3321,7 @@ var MultiBaseComp = /** @class */ (function (_super) {
33213321
__extends(MultiBaseComp, _super);
33223322
function MultiBaseComp(params) {
33233323
var _this = _super.call(this, params) || this;
3324+
_this.IGNORABLE_DEFAULT_VALUE = {};
33243325
_this.children = _this.parseChildrenFromValue(params);
33253326
return _this;
33263327
}
@@ -3464,16 +3465,24 @@ var MultiBaseComp = /** @class */ (function (_super) {
34643465
});
34653466
return _super.prototype.changeDispatch.call(this, dispatch).setChildren(newChildren, { keepCacheKeys: ["node"] });
34663467
};
3468+
MultiBaseComp.prototype.ignoreChildDefaultValue = function () {
3469+
return false;
3470+
};
34673471
MultiBaseComp.prototype.toJsonValue = function () {
34683472
var _this = this;
34693473
var result = {};
3474+
var ignore = this.ignoreChildDefaultValue();
34703475
Object.keys(this.children).forEach(function (key) {
34713476
var comp = _this.children[key];
34723477
// FIXME: this implementation is a little tricky, better choose a encapsulated implementation
34733478
if (comp.hasOwnProperty("NO_PERSISTENCE")) {
34743479
return;
34753480
}
3476-
result[key] = comp.toJsonValue();
3481+
var value = comp.toJsonValue();
3482+
if (ignore && _.isEqual(value, comp["IGNORABLE_DEFAULT_VALUE"])) {
3483+
return;
3484+
}
3485+
result[key] = value;
34773486
});
34783487
return result;
34793488
};

client/packages/openblocks-core/src/baseComps/multiBaseComp.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,25 @@ export abstract class MultiBaseComp<
230230
return super.changeDispatch(dispatch).setChildren(newChildren, { keepCacheKeys: ["node"] });
231231
}
232232

233+
protected ignoreChildDefaultValue() {
234+
return false;
235+
}
236+
237+
readonly IGNORABLE_DEFAULT_VALUE = {};
233238
override toJsonValue(): DataType {
234239
const result: Record<string, any> = {};
240+
const ignore = this.ignoreChildDefaultValue();
235241
Object.keys(this.children).forEach((key) => {
236242
const comp = this.children[key];
237243
// FIXME: this implementation is a little tricky, better choose a encapsulated implementation
238244
if (comp.hasOwnProperty("NO_PERSISTENCE")) {
239245
return;
240246
}
241-
result[key] = comp.toJsonValue();
247+
const value = comp.toJsonValue();
248+
if (ignore && _.isEqual(value, (comp as any)["IGNORABLE_DEFAULT_VALUE"])) {
249+
return;
250+
}
251+
result[key] = value;
242252
});
243253
return result as DataType;
244254
}

client/packages/openblocks-core/src/eval/codeNode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class CodeNode extends AbstractNode<ValueAndMsg<unknown>> {
182182

183183
const dependingNodeMap = this.filterNodes(exposingNodes);
184184
dependingNodeMap.forEach((paths, depend) => {
185-
const fi = depend.fetchInfo(exposingNodes);
185+
const fi = depend.fetchInfo(exposingNodes, options);
186186
isFetching = isFetching || fi.isFetching;
187187
ready = ready && fi.ready;
188188
});

client/packages/openblocks-design/src/components/CustomModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ function ModalFooter(props: {
177177
if (result && !!result.then) {
178178
return result.then(model && model.destroy).finally(() => setConfirmLoading(false));
179179
}
180+
setConfirmLoading(false)
180181
model && model.destroy();
181182
}}
182183
autoFocus={autoFocusButton === "ok"}

client/packages/openblocks-design/src/components/Dropdown.tsx

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Segmented as AntdSegmented } from "antd";
1+
import { Segmented as AntdSegmented, SelectProps } from "antd";
2+
import { GreyTextColor } from "constants/style";
23
import { ReactComponent as Packup } from "icons/icon-Pack-up.svg";
34
import _ from "lodash";
45
import { ReactNode } from "react";
@@ -132,13 +133,13 @@ const LabelWrapper = styled.div<{ placement: ControlPlacement }>`
132133
export type OptionType = {
133134
readonly label: ReactNode;
134135
readonly value: string;
136+
[key: string]: any;
135137
};
136138
export type OptionsType = readonly OptionType[];
137139
export type ValueFromOption<Options extends OptionsType> = Options[number]["value"];
138140

139-
export function Dropdown<T extends OptionsType>(props: {
141+
interface DropdownProps<T extends OptionsType> extends Omit<SelectProps, "placement" | "options"> {
140142
label?: ReactNode;
141-
placeholder?: string;
142143
options: T;
143144
defaultValue?: ValueFromOption<T>;
144145
value?: ValueFromOption<T>;
@@ -148,13 +149,12 @@ export function Dropdown<T extends OptionsType>(props: {
148149
type?: "oneline";
149150
toolTip?: string | React.ReactNode;
150151
placement?: ControlPlacement;
151-
disabled?: boolean;
152-
allowClear?: boolean;
153152
itemNode?: (value: string) => JSX.Element;
154153
preNode?: () => JSX.Element;
155-
showSearch?: boolean;
156154
lineHeight?: number;
157-
}) {
155+
}
156+
157+
export function Dropdown<T extends OptionsType>(props: DropdownProps<T>) {
158158
const { placement = "right" } = props;
159159
const valueInfoMap = _.fromPairs(props.options.map((option) => [option.value, option]));
160160
return (
@@ -169,10 +169,18 @@ export function Dropdown<T extends OptionsType>(props: {
169169
<Tooltip title={!props.label ? props.toolTip : undefined}>
170170
<DropdownContainer placement={placement}>
171171
<CustomSelect
172+
open={props.open}
172173
listHeight={props.lineHeight}
173174
dropdownClassName="ob-dropdown-control-select"
174175
showSearch={props.showSearch}
175176
filterOption={(input, option) => {
177+
if (props.optionFilterProp) {
178+
const value = (option as any)[props.optionFilterProp];
179+
if (value && typeof value === "string") {
180+
return value.toLowerCase().includes(input.toLowerCase());
181+
}
182+
}
183+
176184
if (!option?.value) {
177185
return false;
178186
}
@@ -182,7 +190,7 @@ export function Dropdown<T extends OptionsType>(props: {
182190
typeof label === "string" ||
183191
typeof label === "boolean"
184192
) {
185-
return label.toString().toLowerCase().includes(input);
193+
return label.toString().toLowerCase().includes(input.toLowerCase());
186194
}
187195
return false;
188196
}}
@@ -195,7 +203,7 @@ export function Dropdown<T extends OptionsType>(props: {
195203
disabled={props.disabled}
196204
allowClear={props.allowClear}
197205
placeholder={props.placeholder}
198-
optionLabelProp="children"
206+
optionLabelProp={props.optionLabelProp}
199207
dropdownRender={(menu) =>
200208
props.preNode ? (
201209
<>
@@ -207,13 +215,14 @@ export function Dropdown<T extends OptionsType>(props: {
207215
)
208216
}
209217
>
210-
{props.options.map((item, index) => {
218+
{props.options.map((item) => {
219+
const { value, label, ...others } = item;
211220
return (
212-
<CustomSelect.Option key={item.value} value={item.value}>
221+
<CustomSelect.Option key={value} value={value} {...others}>
213222
{props.itemNode ? (
214-
props.itemNode(item.value)
223+
props.itemNode(value)
215224
) : (
216-
<DropDownItemLabel>{item.label}</DropDownItemLabel>
225+
<DropDownItemLabel>{label}</DropDownItemLabel>
217226
)}
218227
</CustomSelect.Option>
219228
);
@@ -237,3 +246,18 @@ export function Dropdown<T extends OptionsType>(props: {
237246
</FlexDiv>
238247
);
239248
}
249+
250+
interface DropdownOptionLabelWithDescProps {
251+
label: string;
252+
description: string;
253+
}
254+
255+
export function DropdownOptionLabelWithDesc(props: DropdownOptionLabelWithDescProps) {
256+
const { label, description } = props;
257+
return (
258+
<div style={{ padding: 0 }}>
259+
<div style={{ fontWeight: 700, marginBottom: 4 }}>{label}</div>
260+
{description && <div style={{ fontSize: 12, color: GreyTextColor }}>{description}</div>}
261+
</div>
262+
);
263+
}

client/packages/openblocks-design/src/components/edit.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const EditTextWrapper = styled.div<{ disabled?: boolean; hasPrefix?: bool
1919
display: flex;
2020
justify-content: space-between;
2121
align-items: center;
22-
padding: 0 8px;
23-
padding-left: ${(props) => (props.hasPrefix ? "28px" : "8px")};
22+
padding: 0 8px 0 4px;
23+
padding-left: ${(props) => (props.hasPrefix ? "28px" : "4px")};
2424
border-radius: 4px;
2525
width: 220px;
2626
height: 28px;
@@ -35,6 +35,9 @@ export const EditTextWrapper = styled.div<{ disabled?: boolean; hasPrefix?: bool
3535
3636
:hover svg {
3737
visibility: ${(props) => (props.disabled ? "hidden" : "visible")};
38+
&:hover g {
39+
fill: #315efb;
40+
}
3841
}
3942
`;
4043
export const TextWrapper = styled.div`
@@ -63,8 +66,8 @@ const TextInput = styled(Input)<InputProps & { $hasPrefix?: boolean }>`
6366
min-height: 0;
6467
background-color: #8b8fa34c;
6568
border: none;
66-
padding: 0 8px;
67-
padding-left: ${(props) => (props.$hasPrefix ? "28px" : "8px")};
69+
padding: 0 8px 0 4px;
70+
padding-left: ${(props) => (props.$hasPrefix ? "28px" : "4px")};
6871
color: #ffffff;
6972
line-height: 28px;
7073
font-size: 14px;

client/packages/openblocks-design/src/components/form.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,25 @@ const FormItem = styled(Form.Item)`
3434
}
3535
`;
3636
const FormInput = styled(Input)`
37-
background: #ffffff;
37+
&:not(.ant-input-affix-wrapper-disabled) {
38+
background: #ffffff;
39+
}
3840
border: 1px solid #d7d9e0;
3941
border-radius: 4px;
4042
`;
4143

4244
const FormNumberInput = styled(InputNumber)`
43-
background: #ffffff;
45+
&:not(.ant-input-number-affix-wrapper-disabled)&:not(.ant-input-number-disabled) {
46+
background: #ffffff;
47+
}
4448
border: 1px solid #d7d9e0;
4549
border-radius: 4px;
4650
`;
4751

4852
const FormInputPassword = styled(Input)`
49-
background: #ffffff;
53+
&:not(.ant-input-affix-wrapper-disabled) {
54+
background: #ffffff;
55+
}
5056
border: 1px solid #d7d9e0;
5157
border-radius: 4px;
5258
`;

0 commit comments

Comments
 (0)