Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb3854b

Browse files
authored
Merge pull requestlowcoder-org#721 from sudoischenny/main
Add toast notifications & loading message type.
2 parentsb395356 +56d2086 commiteb3854b

File tree

11 files changed

+174
-9
lines changed

11 files changed

+174
-9
lines changed

‎.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.background":"#2A3012",
4+
"titleBar.activeBackground":"#3B431A",
5+
"titleBar.activeForeground":"#F9FAF2"
6+
}
7+
}

‎client/packages/lowcoder/src/comps/hooks/hookComp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { useInterval, useTitle, useWindowSize } from "react-use";
2929
import{useCurrentUser}from"util/currentUser";
3030
import{LocalStorageComp}from"./localStorageComp";
3131
import{MessageComp}from"./messageComp";
32+
import{ToastComp}from"./toastComp";
3233
import{ThemeComp}from"./themeComp";
3334
importUrlParamsHookCompfrom"./UrlParamsHookComp";
3435
import{UtilsComp}from"./utilsComp";
@@ -94,6 +95,7 @@ const HookMap: HookCompMapRawType = {
9495
momentJsLib:DayJsLib,// old components use this hook
9596
utils:UtilsComp,
9697
message:MessageComp,
98+
toast:ToastComp,
9799
localStorage:LocalStorageComp,
98100
modal:ModalComp,
99101
meeting:VideoMeetingControllerComp,

‎client/packages/lowcoder/src/comps/hooks/hookCompTypes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const AllHookComp = [
1212
"momentJsLib",
1313
"utils",
1414
"message",
15+
"toast",
1516
"localStorage",
1617
"currentUser",
1718
"screenInfo",
@@ -58,6 +59,7 @@ const HookCompConfig: Record<
5859
},
5960
utils:{category:"hide"},
6061
message:{category:"hide"},
62+
toast:{category:"hide"},
6163
};
6264

6365
// Get hook component category

‎client/packages/lowcoder/src/comps/hooks/hookListComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const defaultHookListValue = [
1919
{compType:"lodashJsLib",name:"_"},
2020
{compType:"utils",name:"utils"},
2121
{compType:"message",name:"message"},
22+
{compType:"toast",name:"toast"},
2223
{compType:"localStorage",name:"localStorage"},
2324
{compType:"currentUser",name:"currentUser"},
2425
{compType:"screenInfo",name:"screenInfo"},

‎client/packages/lowcoder/src/comps/hooks/messageComp.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const params: ParamsConfig = [
1111
{name:"options",type:"JSON"},
1212
];
1313

14-
constshowMessage=(params:EvalParamType[],level:"info"|"success"|"warning"|"error")=>{
14+
constshowMessage=(params:EvalParamType[],level:"info"|"success"|"loading"|"warning"|"error")=>{
1515
consttext=params?.[0];
1616
constoptions=params?.[1]asJSONObject;
1717
constduration=options?.["duration"]??3;
@@ -35,6 +35,12 @@ MessageComp = withMethodExposing(MessageComp, [
3535
showMessage(params,"success");
3636
},
3737
},
38+
{
39+
method:{name:"loading",description:trans("messageComp.loading"),params:params},
40+
execute:(comp,params)=>{
41+
showMessage(params,"loading");
42+
},
43+
},
3844
{
3945
method:{name:"warn",description:trans("messageComp.warn"),params:params},
4046
execute:(comp,params)=>{
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import{withMethodExposing}from"../generators/withMethodExposing";
2+
import{simpleMultiComp}from"../generators";
3+
import{withExposingConfigs}from"../generators/withExposing";
4+
import{EvalParamType,ParamsConfig}from"../controls/actionSelector/executeCompTypes";
5+
import{JSONObject}from"../../util/jsonTypes";
6+
import{trans}from"i18n";
7+
import{notificationInstance}from"lowcoder-design";
8+
importtype{ArgsProps,NotificationPlacement}from'antd/es/notification/interface';
9+
10+
constparams:ParamsConfig=[
11+
{name:"text",type:"string"},
12+
{name:"options",type:"JSON"},
13+
];
14+
15+
constshowNotification=(
16+
params:EvalParamType[],
17+
level:"open"|"info"|"success"|"warning"|"error"
18+
)=>{
19+
consttext=params?.[0]asstring;
20+
constoptions=params?.[1]asJSONObject;
21+
22+
const{ message, duration, id, placement, dismissible}=options;
23+
24+
constcloseIcon:boolean|undefined=dismissible===true ?undefined :(dismissible===false ?false :undefined);
25+
26+
constdurationNumberOrNull:number|null=typeofduration==='number' ?duration :null;
27+
28+
constnotificationArgs:ArgsProps={
29+
message:text,
30+
description:messageasReact.ReactNode,
31+
duration:durationNumberOrNull??3,
32+
key:idasReact.Key,
33+
placement:placementasNotificationPlacement??"bottomRight",
34+
closeIcon:closeIconasboolean,
35+
};
36+
37+
// Use notificationArgs to trigger the notification
38+
39+
text&&notificationInstance[level](notificationArgs);
40+
};
41+
42+
constdestroy=(
43+
params:EvalParamType[]
44+
)=>{
45+
// Extract the id from the params
46+
constid=params[0]asReact.Key;
47+
48+
// Call notificationInstance.destroy with the provided id
49+
notificationInstance.destroy(id);
50+
};
51+
52+
//what we would like to expose: title, text, duration, id, btn-obj, onClose, placement
53+
54+
constToastCompBase=simpleMultiComp({});
55+
56+
exportletToastComp=withExposingConfigs(ToastCompBase,[]);
57+
58+
ToastComp=withMethodExposing(ToastComp,[
59+
{
60+
method:{name:"destroy",description:trans("toastComp.destroy"),params:params},
61+
execute:(comp,params)=>destroy(params),
62+
},
63+
{
64+
method:{name:"open",description:trans("toastComp.info"),params:params},
65+
execute:(comp,params)=>{
66+
showNotification(params,"open");
67+
},
68+
},
69+
{
70+
method:{name:"info",description:trans("toastComp.info"),params:params},
71+
execute:(comp,params)=>{
72+
showNotification(params,"info");
73+
},
74+
},
75+
{
76+
method:{name:"success",description:trans("toastComp.success"),params:params},
77+
execute:(comp,params)=>{
78+
showNotification(params,"success");
79+
},
80+
},
81+
{
82+
method:{name:"warn",description:trans("toastComp.warn"),params:params},
83+
execute:(comp,params)=>{
84+
showNotification(params,"warning");
85+
},
86+
},
87+
{
88+
method:{name:"error",description:trans("toastComp.error"),params:params},
89+
execute:(comp,params)=>{
90+
showNotification(params,"error");
91+
},
92+
},
93+
]);
94+
95+

‎client/packages/lowcoder/src/i18n/locales/de.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,10 +1615,18 @@ export const de = {
16151615
},
16161616
"messageComp":{
16171617
"info":"Eine Benachrichtigung senden",
1618+
"loading":"Ladebestätigung senden",
16181619
"success":"Erfolgsbenachrichtigung senden",
16191620
"warn":"Eine Warnmeldung senden",
16201621
"error":"Eine Fehlerbenachrichtigung senden"
16211622
},
1623+
"tostComp":{
1624+
"info":"Eine Benachrichtigung senden",
1625+
"loading":"Ladebestätigung senden",
1626+
"success":"Erfolgsbenachrichtigung senden",
1627+
"warn":"Eine Warnmeldung senden",
1628+
"error":"Eine Fehlerbenachrichtigung senden"
1629+
},
16221630
"themeComp":{
16231631
"switchTo":"Thema wechseln"
16241632
},

‎client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,15 @@ export const en = {
17781778
},
17791779
"messageComp":{
17801780
"info":"Send a Notification",
1781+
"loading":"Send a Loading Notification",
1782+
"success":"Send a Success Notification",
1783+
"warn":"Send a Warning Notification",
1784+
"error":"Send an Error Notification"
1785+
},
1786+
"toastComp":{
1787+
"destroy":"close a Notification",
1788+
"info":"Send a Notification",
1789+
"loading":"Send a Loading Notification",
17811790
"success":"Send a Success Notification",
17821791
"warn":"Send a Warning Notification",
17831792
"error":"Send an Error Notification"

‎client/packages/lowcoder/src/i18n/locales/zh.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,14 @@ utilsComp: {
16861686
},
16871687
messageComp:{
16881688
info:"发送通知",
1689+
loading:"发送加载通知",
1690+
success:"发送成功通知",
1691+
warn:"发送警告通知",
1692+
error:"发送错误通知",
1693+
},
1694+
toastComp:{
1695+
info:"发送通知",
1696+
loading:"发送加载通知",
16891697
success:"发送成功通知",
16901698
warn:"发送警告通知",
16911699
error:"发送错误通知",
33.6 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp