Skip to content

Commit d9debc7

Browse files
authored
Merge pull request #333 from raheeliftikhar5/remove-moment
Remove momentJS
2 parents f24a7f7 + 92b5788 commit d9debc7

File tree

16 files changed

+24
-25
lines changed

16 files changed

+24
-25
lines changed

client/packages/lowcoder/src/comps/comps/autoCompleteComp/autoCompleteComp.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
booleanExposingStateControl,
4545
} from "comps/controls/codeStateControl";
4646

47-
import { getMomentLocale } from "i18n/momentLocale";
47+
import { getDayJSLocale } from "i18n/dayjsLocale";
4848
import {
4949
autoCompleteDate,
5050
itemsDataTooltip,
@@ -151,7 +151,7 @@ let AutoCompleteCompBase = (function () {
151151
const [validateState, setvalidateState] = useState({});
152152

153153
// 是否中文环境
154-
const [chineseEnv, setChineseEnv] = useState(getMomentLocale() === "zh-cn");
154+
const [chineseEnv, setChineseEnv] = useState(getDayJSLocale() === "zh-cn");
155155

156156
useEffect(() => {
157157
setsearchtext(props.value.value);
@@ -346,11 +346,11 @@ let AutoCompleteCompBase = (function () {
346346
tooltip: itemsDataTooltip,
347347
placeholder: "[]",
348348
})}
349-
{getMomentLocale() === "zh-cn" &&
349+
{getDayJSLocale() === "zh-cn" &&
350350
children.searchFirstPY.propertyView({
351351
label: trans("autoComplete.searchFirstPY"),
352352
})}
353-
{getMomentLocale() === "zh-cn" &&
353+
{getDayJSLocale() === "zh-cn" &&
354354
children.searchCompletePY.propertyView({
355355
label: trans("autoComplete.searchCompletePY"),
356356
})}

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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);
Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/hookComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const HookMap: HookCompMapRawType = {
8585
currentTime: CurrentTimeHookComp,
8686
lodashJsLib: LodashJsLib,
8787
dayJsLib: DayJsLib,
88-
momentJsLib: DayJsLib,
88+
momentJsLib: DayJsLib, // old components use this hook
8989
utils: UtilsComp,
9090
message: MessageComp,
9191
localStorage: LocalStorageComp,

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ export const en = {
17001700
preloadCSSApply: "Apply to the homepage of the workspace",
17011701
preloadLibsTitle: "JavaScript library",
17021702
preloadLibsHelp:
1703-
"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.",
1703+
"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.",
17041704
preloadLibsEmpty: "No JavaScript libraries were added",
17051705
preloadLibsAddBtn: "Add a library",
17061706
saveSuccess: "Saved successfully",
@@ -1962,7 +1962,7 @@ export const en = {
19621962
},
19631963
preLoad: {
19641964
jsLibraryHelpText:
1965-
"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.",
1965+
"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.",
19661966
exportedAs: "Exported as",
19671967
urlTooltip:
19681968
"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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ advanced: {
16771677
preloadCSSApply: "应用到工作空间的首页",
16781678
preloadLibsTitle: "JavaScript 库",
16791679
preloadLibsHelp:
1680-
"为当前工作空间中的所有应用程序设置预加载的 JavaScript 库,系统内置了 lodash、moment、uuid、numbro 可供直接使用.JavaScript 库在应用程序初始化之前加载,因此对应用程序性能有一定影响.",
1680+
"为当前工作空间中的所有应用程序设置预加载的 JavaScript 库,系统内置了 lodash、day.js、uuid、numbro 可供直接使用.JavaScript 库在应用程序初始化之前加载,因此对应用程序性能有一定影响.",
16811681
preloadLibsEmpty: "尚未添加 JavaScript 库",
16821682
preloadLibsAddBtn: "添加库",
16831683
saveSuccess: "保存成功",
@@ -1935,7 +1935,7 @@ userAuth: {
19351935
copyPassword: "复制密码",
19361936
},
19371937
preLoad: {
1938-
jsLibraryHelpText: "通过URL链接向当前应用程序添加JavaScript库.lodash、moment、uuid、numbro内置于系统中,可立即使用.JavaScript库在应用程序初始化之前加载,这可能会影响应用程序的性能.",
1938+
jsLibraryHelpText: "通过URL链接向当前应用程序添加JavaScript库.lodash、day.js、uuid、numbro内置于系统中,可立即使用.JavaScript库在应用程序初始化之前加载,这可能会影响应用程序的性能.",
19391939
exportedAs: "导出为",
19401940
urlTooltip: "JavaScript库的URL链接,建议使用[unpkg.com](https://unpkg.com/)或[jsdelivr.net](https://www.jsdelivr.com/).",
19411941
recommended: "推荐",

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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)