Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edaa0a1

Browse files
committed
add theme hook & bugfixes
- fix async and runQueryLibrary in preview - fix: signature lazy - fix options context not exist in auto completion - fix(listView): fix listView's bug
1 parent 40a3a9c commit edaa0a1

Some content is hidden

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

60 files changed

+877
-299
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,8 +3209,8 @@ function updateNodesV2Action(value) {
32093209
value: value,
32103210
};
32113211
}
3212-
function wrapActionExtraInfo(action, extraCompInfos) {
3213-
return __assign(__assign({}, action), { extraInfo: { compInfos: extraCompInfos } });
3212+
function wrapActionExtraInfo(action, extraInfos) {
3213+
return __assign(__assign({}, action), { extraInfo: __assign(__assign({}, action.extraInfo), extraInfos) });
32143214
}
32153215
function deferAction(action) {
32163216
return __assign(__assign({}, action), { priority: "defer" });

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ declare type ExtraActionType =
504504
| "recover"
505505
| "upgrade";
506506
declare type ActionExtraInfo = {
507-
compInfos: {
507+
compInfos?: {
508508
compName: string;
509509
compType: string;
510510
type: ExtraActionType;
@@ -631,7 +631,7 @@ declare function changeChildAction(childName: string, value: JSONValue): CompAct
631631
declare function updateNodesV2Action(value: any): UpdateNodesV2Action;
632632
declare function wrapActionExtraInfo<T extends CompAction>(
633633
action: T,
634-
extraCompInfos: ActionExtraInfo["compInfos"]
634+
extraInfos: ActionExtraInfo
635635
): T;
636636
declare function deferAction<T extends CompAction>(action: T): T;
637637

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,8 +3201,8 @@ function updateNodesV2Action(value) {
32013201
value: value,
32023202
};
32033203
}
3204-
function wrapActionExtraInfo(action, extraCompInfos) {
3205-
return __assign(__assign({}, action), { extraInfo: { compInfos: extraCompInfos } });
3204+
function wrapActionExtraInfo(action, extraInfos) {
3205+
return __assign(__assign({}, action), { extraInfo: __assign(__assign({}, action.extraInfo), extraInfos) });
32063206
}
32073207
function deferAction(action) {
32083208
return __assign(__assign({}, action), { priority: "defer" });

client/packages/openblocks-core/src/actions/actionTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export type ExtraActionType =
5252
| "recover"
5353
| "upgrade";
5454
export type ActionExtraInfo = {
55-
compInfos: {
55+
compInfos?: {
5656
compName: string;
5757
compType: string;
5858
type: ExtraActionType;

client/packages/openblocks-core/src/actions/actions.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { JSONValue } from "util/jsonTypes";
1+
import { CompConstructor } from "baseComps/comp";
22
import _ from "lodash";
3+
import { JSONValue } from "util/jsonTypes";
34
import {
4-
CompAction,
55
ActionContextType,
66
ActionExtraInfo,
77
AddChildAction,
88
BroadcastAction,
99
ChangeValueAction,
10+
CompAction,
1011
CompActionTypes,
1112
CustomAction,
1213
ExecuteQueryAction,
1314
MultiChangeAction,
1415
RenameAction,
16+
ReplaceCompAction,
1517
RouteByNameAction,
1618
SimpleCompAction,
19+
TriggerModuleEventAction,
1720
UpdateActionContextAction,
1821
UpdateNodesV2Action,
19-
TriggerModuleEventAction,
20-
ReplaceCompAction,
2122
} from "./actionTypes";
22-
import { CompConstructor } from "baseComps/comp";
2323

2424
export function customAction<DataType>(value: DataType): CustomAction<DataType> {
2525
return {
@@ -189,9 +189,9 @@ export function updateNodesV2Action(value: any): UpdateNodesV2Action {
189189

190190
export function wrapActionExtraInfo<T extends CompAction>(
191191
action: T,
192-
extraCompInfos: ActionExtraInfo["compInfos"]
192+
extraInfos: ActionExtraInfo
193193
): T {
194-
return { ...action, extraInfo: { compInfos: extraCompInfos } };
194+
return { ...action, extraInfo: { ...action.extraInfo, ...extraInfos } };
195195
}
196196

197197
export function deferAction<T extends CompAction>(action: T): T {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const labelCss: any = css`
66
77
font-size: 13px;
88
color: #222222;
9+
line-height: 1;
910
1011
:hover {
1112
cursor: default;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const ChildrenWrapper = styled.div<{ layout: ControlLayout }>`
9898

9999
const LastNode = styled.div`
100100
margin-left: 8px;
101+
display: inline-flex;
102+
align-items: center;
101103
102104
.ant-select-selection-item {
103105
width: 40px;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ const AddBtn = styled(TacoButton)`
6565
&:hover ${AddIcon} g {
6666
stroke: #315efb;
6767
}
68+
69+
> svg {
70+
height: 8px;
71+
width: 8px;
72+
}
6873
`;
6974

7075
export const KeyValueList = (props: {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ const Label = styled.div<{ border?: boolean }>`
168168
}
169169
}};
170170
${labelCss};
171-
line-height: normal;
172171
margin: 0;
173172
width: fit-content;
174173
`;
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 14 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

client/packages/openblocks-design/src/icons/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,6 @@ export { ReactComponent as LeftOpen } from "./icon-left-comp-open.svg";
259259
export { ReactComponent as LeftClose } from "./icon-left-comp-close.svg";
260260
export { ReactComponent as ScannerIcon } from "./icon-scanner.svg";
261261
export { ReactComponent as MaterialUploadIcon } from "./icon-material-upload.svg";
262+
export { ReactComponent as LeftSignature } from "./icon-left-signature.svg";
263+
export { ReactComponent as UndoIcon } from "./icon-undo.svg";
264+
export { ReactComponent as SignatureIcon } from "./icon-signature.svg";

client/packages/openblocks/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@types/node": "^16.7.13",
3232
"@types/react": "^17.0.20",
3333
"@types/react-dom": "^17.0.9",
34+
"@types/react-signature-canvas": "^1.0.2",
3435
"@types/react-test-renderer": "^18.0.0",
3536
"@types/react-virtualized": "^9.21.21",
3637
"ali-oss": "^6.17.1",
@@ -75,6 +76,7 @@
7576
"react-resize-detector": "^7.0.0",
7677
"react-router": "^5.2.1",
7778
"react-router-dom": "^5.3.0",
79+
"react-signature-canvas": "^1.0.6",
7880
"react-test-renderer": "^18.1.0",
7981
"react-use": "^17.3.2",
8082
"really-relaxed-json": "^0.3.1",

client/packages/openblocks/src/base/codeEditor/codeEditorTypes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface CodeEditorProps extends CodeEditorControlParams {
3434

3535
// extension
3636
exposingData?: Record<string, unknown>;
37+
boostExposingData?: Record<string, unknown>;
3738
enableClickCompName?: boolean;
3839
onChange?: (state: EditorState) => void;
3940

client/packages/openblocks/src/base/codeEditor/completion/exposingCompletionSource.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const PRIORITY_FUNCTIONS = ["setValue", "setData"];
99

1010
export class ExposingCompletionSource extends CompletionSource {
1111
data?: Record<string, unknown>;
12+
boostExposingData?: Record<string, unknown>;
1213
completionSource(
1314
context: CompletionContext
1415
): CompletionResult | Promise<CompletionResult | null> | null {
@@ -34,11 +35,18 @@ export class ExposingCompletionSource extends CompletionSource {
3435
const keys = Object.keys(currentData).filter((key) => key.startsWith(prefix));
3536
const options = keys.map((key) => {
3637
const dataType = getDataType(currentData[key]);
38+
const isBoost = offset === 0 && this.boostExposingData?.hasOwnProperty(key);
3739
const result: Completion = {
3840
type: _.lowerCase(dataType),
3941
label: key,
4042
detail: _.capitalize(dataType),
41-
boost: PRIORITY_PROPS.includes(key) ? 3 : PRIORITY_FUNCTIONS.includes(key) ? 2 : 1,
43+
boost: isBoost
44+
? 20
45+
: PRIORITY_PROPS.includes(key)
46+
? 3
47+
: PRIORITY_FUNCTIONS.includes(key)
48+
? 2
49+
: 1,
4250
};
4351
return result;
4452
});

client/packages/openblocks/src/base/codeEditor/extensions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export function useChangeExtension(
318318
}
319319

320320
export function useCompletionSources(props: CodeEditorProps) {
321-
const { language, codeType, exposingData, enableMetaCompletion } = props;
321+
const { language, codeType, exposingData, boostExposingData, enableMetaCompletion } = props;
322322
const context = useContext(QueryContext); // FIXME: temporarily handle, expect to delete after the backend supports eval
323323
// auto-completion for comp exposing
324324
const exposingSource = useMemo(() => new ExposingCompletionSource(), []);
@@ -332,7 +332,8 @@ export function useCompletionSources(props: CodeEditorProps) {
332332

333333
useEffect(() => {
334334
exposingSource.data = exposingData;
335-
}, [exposingSource, exposingData]);
335+
exposingSource.boostExposingData = boostExposingData;
336+
}, [exposingSource, exposingData, boostExposingData]);
336337

337338
const sqlMetaData = useContext(MetaDataContext);
338339
useEffect(() => {

client/packages/openblocks/src/components/KeyValueItemList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const ListWrapper = styled.div`
2525
.list-header {
2626
display: flex;
2727
font-size: 13px;
28+
line-height: 1;
2829
margin-bottom: 8px;
2930
align-items: center;
3031
justify-content: space-between;

client/packages/openblocks/src/components/table/EditableCell.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export const SizeWrapper = styled.div<{ $size?: string }>`
4646
props.$size &&
4747
`padding: ${
4848
props.$size === "small" ? "8.5px 8px" : props.$size === "large" ? "16.5px 16px" : "12.5px 8px"
49-
}`}
49+
};
50+
line-height: 21px;
51+
`
52+
}
5053
`;
5154

5255
const BorderDiv = styled.div`

client/packages/openblocks/src/comps/comps/appSettingsComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import { GreyTextColor } from "constants/style";
1313
import { Divider } from "antd";
1414
import { THEME_SETTING } from "constants/routesURL";
1515
import { CustomShortcutsComp } from "./customShortcutsComp";
16+
import { DEFAULT_THEMEID } from "comps/utils/themeUtil";
1617

1718
const TITLE = trans("appSetting.title");
1819
const USER_DEFINE = "__USER_DEFINE";
19-
const DEFAULT_THEMEID = "default";
2020

2121
const ItemSpan = styled.span`
2222
display: inline-flex;

client/packages/openblocks/src/comps/comps/containerComp/containerView.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
import {
2-
CompAction,
3-
ActionExtraInfo,
4-
changeChildAction,
5-
changeValueAction,
6-
deferAction,
7-
deleteCompAction,
8-
multiChangeAction,
9-
wrapActionExtraInfo,
10-
wrapChildAction,
11-
} from "openblocks-core";
12-
import { Comp, DispatchType, RecordConstructorToView, wrapDispatch } from "openblocks-core";
131
import { EditorContext, EditorState } from "comps/editorState";
142
import { sameTypeMap, stateComp, valueComp } from "comps/generators";
153
import { addMapChildAction, addMapCompChildAction } from "comps/generators/sameTypeMap";
164
import { hookCompCategory, HookCompType } from "comps/hooks/hookCompTypes";
175
import { UICompLayoutInfo, uiCompRegistry, UICompType } from "comps/uiCompRegistry";
186
import { genRandomKey } from "comps/utils/idGenerator";
7+
import { parseCompType } from "comps/utils/remote";
198
import {
209
DEFAULT_POSITION_PARAMS,
2110
draggingUtils,
@@ -35,10 +24,26 @@ import {
3524
DEFAULT_ROW_HEIGHT,
3625
} from "layout/calculateUtils";
3726
import _ from "lodash";
27+
import {
28+
ActionExtraInfo,
29+
changeChildAction,
30+
changeValueAction,
31+
Comp,
32+
CompAction,
33+
deferAction,
34+
deleteCompAction,
35+
DispatchType,
36+
multiChangeAction,
37+
RecordConstructorToView,
38+
wrapActionExtraInfo,
39+
wrapChildAction,
40+
wrapDispatch,
41+
} from "openblocks-core";
3842
import React, {
3943
DragEvent,
4044
HTMLAttributes,
4145
MouseEvent,
46+
ReactElement,
4247
ReactNode,
4348
RefObject,
4449
useCallback,
@@ -48,14 +53,12 @@ import React, {
4853
useRef,
4954
useState,
5055
} from "react";
51-
import { ReactElement } from "react";
5256
import { useResizeDetector } from "react-resize-detector";
5357
import styled from "styled-components";
58+
import { checkIsMobile } from "util/commonUtils";
5459
import { ExternalEditorContext } from "util/context/ExternalEditorContext";
5560
import { selectCompModifierKeyPressed } from "util/keyUtils";
5661
import { defaultLayout, GridItemComp, GridItemDataType } from "../gridItemComp";
57-
import { checkIsMobile } from "util/commonUtils";
58-
import { parseCompType } from "comps/utils/remote";
5962

6063
const childrenMap = {
6164
layout: valueComp<Layout>({}),
@@ -161,7 +164,7 @@ const onLayoutChange = (
161164
onLayoutChange?.(newLayout);
162165
// Purely changing the layout does not need to eval
163166
// log.debug("layout: onLayoutChange. currentLayout: ", currentLayout, " newLayout: ", newLayout);
164-
dispatch(wrapActionExtraInfo(changeChildAction("layout", newLayout), compInfos));
167+
dispatch(wrapActionExtraInfo(changeChildAction("layout", newLayout), { compInfos }));
165168
};
166169

167170
const onFlyDrop = (layout: Layout, items: Layout, dispatch: DispatchType) => {
@@ -211,7 +214,7 @@ const onDrop = (
211214
editorState
212215
.getHooksComp()
213216
.pushAction({ name: compName, compType: compType as HookCompType }),
214-
[{ compName: compName, compType: compType, type: "add" }]
217+
{ compInfos: [{ compName: compName, compType: compType, type: "add" }] }
215218
)
216219
);
217220
editorState.setSelectedCompNames(new Set([compName]), "addComp");
@@ -239,7 +242,7 @@ const onDrop = (
239242
}),
240243
items: addMapChildAction(key, widgetValue),
241244
}),
242-
[{ compName: compName, compType: compType, type: "add" }]
245+
{ compInfos: [{ compName: compName, compType: compType, type: "add" }] }
243246
)
244247
);
245248
editorState.setSelectedCompNames(new Set([compName]), "addComp");

client/packages/openblocks/src/comps/comps/gridItemComp.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import _ from "lodash";
2020
import { Comp, CompAction, ConstructorToDataType } from "openblocks-core";
2121
import React, { Profiler, useContext, useMemo } from "react";
2222
import { profilerCallback } from "util/cacheUtils";
23-
import { setFieldsNoTypeCheck } from "util/objectUtils";
23+
import { setFieldsNoTypeCheck, shallowEqual } from "util/objectUtils";
2424
import { remoteComp } from "./remoteComp/remoteComp";
2525
import { SimpleNameComp } from "./simpleNameComp";
2626

@@ -134,8 +134,12 @@ export class GridItemComp extends TmpComp {
134134
override reduce(action: CompAction): this {
135135
let comp = super.reduce(action);
136136
const listViewContext = getReduceContext().listViewContext;
137-
if (listViewContext !== this.listViewContext)
137+
if (
138+
listViewContext.listViewDepth !== this.listViewContext.listViewDepth ||
139+
!shallowEqual(listViewContext.currentItem, this.listViewContext.currentItem)
140+
) {
138141
comp = setFieldsNoTypeCheck(comp, { listViewContext }, { keepCacheKeys: ["node"] });
142+
}
139143
return comp;
140144
}
141145
}

0 commit comments

Comments
 (0)