Skip to content

Commit dce0e3a

Browse files
refactor: remove momentJS, use dayJS
1 parent 1c11818 commit dce0e3a

File tree

14 files changed

+19
-20
lines changed

14 files changed

+19
-20
lines changed

‎client/packages/lowcoder/src/comps/comps/formComp/generate/comp.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ const multiSelectComps: CompConfig[] = [
8888
const dateComp: CompConfig = {
8989
type: "date",
9090
};
91-
// TODO: RAHEEL
91+
9292
function dateTimeToTimestamp(compName: string) {
93-
return "moment(" + compName + ".value || 0).valueOf()";
93+
return "dayjs(" + compName + ".value || 0).valueOf()";
9494
}
9595
function dateTimeComp(toTimestamp?: boolean): CompConfig {
9696
return {

‎client/packages/lowcoder/src/comps/generators/hookToComp.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function hookToStateComp(useHookFn: () => JSONObject) {
4242
}
4343

4444
/**
45-
* Provide a comp of static data, such as exposure of lodash, moment library
45+
* Provide a comp of static data, such as exposure of lodash, day.js library
4646
*/
4747
export function simpleValueComp(value: any) {
4848
return simpleValueGetterComp(() => value);
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
22
* Hooks for managing dependencies
3-
* lodash and moment are supported by default
3+
* lodash and dayJS are supported by default
44
*/
55
export const DependecyHook = null;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let TmpDrawerComp = (function () {
125125
<Drawer
126126
resizable={resizable}
127127
onResizeStop={onResizeStop}
128-
style={props.visible.value ? { overflow: "auto", pointerEvents: "auto" } : {}}
128+
rootStyle={props.visible.value ? { overflow: "auto", pointerEvents: "auto" } : {}}
129129
contentWrapperStyle={{ maxHeight: "100%", maxWidth: "100%" }}
130130
bodyStyle={{ padding: 0, backgroundColor: props.style.background }}
131131
closable={false}

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

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const defaultHookListValue = [
1616
// { compType: "windowSize", name: "windowSize" },
1717
{ compType: "urlParams", name: "url" },
1818
{ compType: "dayJsLib", name: "dayjs" },
19-
// { compType: "momentJsLib", name: "dayjs" },
2019
{ compType: "lodashJsLib", name: "_" },
2120
{ compType: "utils", name: "utils" },
2221
{ compType: "message", name: "message" },

‎client/packages/lowcoder/src/i18n/momentLocale.ts renamed to ‎client/packages/lowcoder/src/i18n/dayjsLocale.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { language } from "i18n";
22

3-
export function getMomentLocale() {
3+
export function getDayJSLocale() {
44
switch (language) {
55
case "zh":
66
return "zh-cn";

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ export const en = {
16921692
preloadCSSApply: "Apply to the homepage of the workspace",
16931693
preloadLibsTitle: "JavaScript library",
16941694
preloadLibsHelp:
1695-
"Set up preloaded JavaScript libraries for all applications in the current workspace, and the system has built-in lodash, moment, uuid, numbro for direct use. JavaScript libraries are loaded before the app is initialized, so there is a certain impact on app performance.",
1695+
"Set up preloaded JavaScript libraries for all applications in the current workspace, and the system has built-in lodash, day.js, uuid, numbro for direct use. JavaScript libraries are loaded before the app is initialized, so there is a certain impact on app performance.",
16961696
preloadLibsEmpty: "No JavaScript libraries were added",
16971697
preloadLibsAddBtn: "Add a library",
16981698
saveSuccess: "Saved successfully",
@@ -1954,7 +1954,7 @@ export const en = {
19541954
},
19551955
preLoad: {
19561956
jsLibraryHelpText:
1957-
"Add JavaScript libraries to your current application via URL addresses. lodash, moment, uuid, numbro are built into the system for immediate use. JavaScript libraries are loaded before the application is initialized, which can have an impact on application performance.",
1957+
"Add JavaScript libraries to your current application via URL addresses. lodash, day.js, uuid, numbro are built into the system for immediate use. JavaScript libraries are loaded before the application is initialized, which can have an impact on application performance.",
19581958
exportedAs: "Exported as",
19591959
urlTooltip:
19601960
"URL address of the JavaScript library, [unpkg.com](https://unpkg.com/) or [jsdelivr.net](https://www.jsdelivr.com/) is recommended",

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ advanced: {
16691669
preloadCSSApply: "应用到工作空间的首页",
16701670
preloadLibsTitle: "JavaScript 库",
16711671
preloadLibsHelp:
1672-
"为当前工作空间中的所有应用程序设置预加载的 JavaScript 库,系统内置了 lodash、moment、uuid、numbro 可供直接使用.JavaScript 库在应用程序初始化之前加载,因此对应用程序性能有一定影响.",
1672+
"为当前工作空间中的所有应用程序设置预加载的 JavaScript 库,系统内置了 lodash、day.js、uuid、numbro 可供直接使用.JavaScript 库在应用程序初始化之前加载,因此对应用程序性能有一定影响.",
16731673
preloadLibsEmpty: "尚未添加 JavaScript 库",
16741674
preloadLibsAddBtn: "添加库",
16751675
saveSuccess: "保存成功",
@@ -1927,7 +1927,7 @@ userAuth: {
19271927
copyPassword: "复制密码",
19281928
},
19291929
preLoad: {
1930-
jsLibraryHelpText: "通过URL链接向当前应用程序添加JavaScript库.lodash、moment、uuid、numbro内置于系统中,可立即使用.JavaScript库在应用程序初始化之前加载,这可能会影响应用程序的性能.",
1930+
jsLibraryHelpText: "通过URL链接向当前应用程序添加JavaScript库.lodash、day.js、uuid、numbro内置于系统中,可立即使用.JavaScript库在应用程序初始化之前加载,这可能会影响应用程序的性能.",
19311931
exportedAs: "导出为",
19321932
urlTooltip: "JavaScript库的URL链接,建议使用[unpkg.com](https://unpkg.com/)或[jsdelivr.net](https://www.jsdelivr.com/).",
19331933
recommended: "推荐",

‎client/packages/lowcoder/src/pages/editor/bottom/BottomMetaDrawer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export default function BottomMetaDrawer(props: BottomMetaDrawerProps) {
285285
boxShadow: "none",
286286
borderRadius: "0",
287287
}}
288-
style={{
288+
rootStyle={{
289289
position: "absolute",
290290
height: "100%",
291291
bottom: 0,

‎client/packages/lowcoder/src/util/commonUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import log, { LogLevelDesc } from "loglevel";
22
import dayjs from "dayjs";
3-
import { getMomentLocale } from "i18n/momentLocale";
3+
import { getDayJSLocale } from "i18n/dayjsLocale";
44
import _ from "lodash";
55

66
// https://github.com/vitejs/vite/discussions/7492#discussioncomment-2449310
77
import "dayjs/locale/en-gb";
88
import "dayjs/locale/zh-cn";
99

1010
export function initApp() {
11-
dayjs.locale(getMomentLocale());
11+
dayjs.locale(getDayJSLocale());
1212
const logLevel = getEnvLogLevel();
1313
log.setLevel(logLevel);
1414
}

‎docs/build-apps/use-third-party-libraries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Lowcoder provides some JavaScript built-in libraries for use.
99
| Library | Docs | Version |
1010
| --------- | -------------------------------------------------------------------- | -------------------------- |
1111
| lodash | [https://lodash.com/docs/](https://lodash.com/docs/) | 4.17.21 |
12-
| moment | [https://momentjs.com/docs/](https://momentjs.com/docs/) | 2.29.3 |
12+
| day.js | [https://day.js.org/docs](https://day.js.org/docs/) | 2.29.3 |
1313
| uuid | [https://github.com/uuidjs/uuid](https://github.com/uuidjs/uuid) | 8.3.2(Support v1/v3/v4/v5) |
1414
| numbro | [https://numbrojs.com/format.html](https://numbrojs.com/format.html) | 2.3.6 |
1515
| papaparse | [https://www.papaparse.com/docs](https://www.papaparse.com/docs) | 5.3.2 |

‎docs/build-apps/write-javascript/javascript-query.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ function isMultiple(num1, num2) {
188188
return num1 % num2 === 0;
189189
}
190190
191-
// Call the moment library to return the current date
191+
// Call the day.js library to return the current date
192192
function getCurrentDate() {
193-
return moment().format("YYYY-MM-DD");
193+
return dayjs().format("YYYY-MM-DD");
194194
}
195195
```
196196

‎docs/build-apps/write-javascript/transformers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ In the following example, `transformer1` uses the data of star rating in `rating
2424

2525
### Transform timestamp
2626

27-
Use the `moment().format()` method to transform timestamp formats. The following example converts the timestamp value of `start_time` returned by `query1` to `YYYY-MM-DD` format.
27+
Use the `dayjs().format()` method to transform timestamp formats. The following example converts the timestamp value of `start_time` returned by `query1` to `YYYY-MM-DD` format.
2828

2929
```javascript
3030
return query1.data.map(it => {
3131
return {
3232
...it,
33-
start_time: moment(it.start_time).format('YYYY-MM-DD')
33+
start_time: dayjs(it.start_time).format('YYYY-MM-DD')
3434
};
3535
})
3636
```

‎docs/build-apps/write-javascript/write-javascript-in.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Lowercase a string.
4343
Change date format.
4444

4545
```javascript
46-
{{moment(table1.selectedRow.date_column).format('YYYY-MM-DD')}}
46+
{{dayjs(table1.selectedRow.date_column).format('YYYY-MM-DD')}}
4747
```
4848

4949
Return name from query results.

0 commit comments

Comments
 (0)