Skip to content

Commit b5ef764

Browse files
committed
refactor(ui): export default dayjs
1 parent 4fc1364 commit b5ef764

File tree

9 files changed

+15
-12
lines changed

9 files changed

+15
-12
lines changed

packages/platform/src/app/dayjs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import dayjs from '@react-devui/ui/dayjs';
2+
3+
export default dayjs;

packages/site/src/app/routes/docs/faq/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ The null value of the controlled component is generally defined as `null`, pleas
2626

2727
First of all, we should ensure that the project is the only `dayjs` globally, so the `dayjs` of the component library is placed in `peerDependencies`.
2828

29-
You only need to configure `dayjs` in your project, the best practice is to create a `startup` to ensure some configuration at the beginning, please refer to [startup](https://github.com/DevCloudFE/react-devui/tree/main/packages/platform/src/startup).
29+
You only need to configure `dayjs` in your project, the best practice is to create a `dayjs.ts` to share `dayjs` configuration, please refer to [dayjs.ts](https://github.com/DevCloudFE/react-devui/blob/main/packages/platform/src/app/dayjs.ts).

packages/site/src/app/routes/docs/faq/FAQ.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
首先我们应该确保项目是全局唯一的 `dayjs`,所以组件库的 `dayjs` 是放在 `peerDependencies` 中。
2828

29-
您只需要在您的项目中配置 `dayjs` 即可,最佳实践是创建一个 `startup` 确保最开始的时候进行一些配置,可参考 [startup](https://github.com/DevCloudFE/react-devui/tree/main/packages/platform/src/startup)
29+
您只需要在您的项目中配置 `dayjs` 即可,最佳实践是创建一个 `dayjs.ts` 来共享 `dayjs` 配置,可参考 [dayjs.ts](https://github.com/DevCloudFE/react-devui/blob/main/packages/platform/src/app/dayjs.ts)

packages/ui/src/components/_date-input/DateInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useAsync, useEvent, useEventCallback, useForceUpdate, useForkRef, useIm
99
import { CloseCircleFilled, SwapRightOutlined } from '@react-devui/icons';
1010
import { checkNodeExist, getClassName, getVerticalSidePosition } from '@react-devui/utils';
1111

12-
import { dayjs } from '../../dayjs';
12+
import dayjs from '../../dayjs';
1313
import { useDValue, useMaxIndex } from '../../hooks';
1414
import { cloneHTMLElement, TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../../utils';
1515
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';

packages/ui/src/components/_date-input/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { OpUnitType } from 'dayjs';
22

33
import { isArray, isDate, isNull } from 'lodash';
44

5-
import { dayjs } from '../../dayjs';
5+
import dayjs from '../../dayjs';
66

77
export function getCols(_format: string) {
88
const format = _format.replace(/\[[\s\S]*?\]/g, '');

packages/ui/src/components/date-picker/Panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useAsync, useUnmount } from '@react-devui/hooks';
77
import { DoubleLeftOutlined, DoubleRightOutlined, LeftOutlined, RightOutlined } from '@react-devui/icons';
88
import { getClassName } from '@react-devui/utils';
99

10-
import { dayjs } from '../../dayjs';
10+
import dayjs from '../../dayjs';
1111
import { usePrefixConfig, useTranslation } from '../root';
1212

1313
export interface DPanelProps {

packages/ui/src/components/root/Root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useRefExtra, useEvent } from '@react-devui/hooks';
77
import { DIconContext } from '@react-devui/icons/Icon';
88
import { getClassName } from '@react-devui/utils';
99

10-
import { dayjs } from '../../dayjs';
10+
import dayjs from '../../dayjs';
1111
import { DConfigContextManager } from './contex';
1212
import { DConfigContext } from './contex';
1313
import resources from './resources.json';

packages/ui/src/components/time-picker/Panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, { useImperativeHandle, useRef, useState } from 'react';
55
import { useEventCallback } from '@react-devui/hooks';
66
import { getClassName, scrollTo } from '@react-devui/utils';
77

8-
import { dayjs } from '../../dayjs';
8+
import dayjs from '../../dayjs';
99
import { usePrefixConfig } from '../root';
1010

1111
const H12 = freeze(['12', ...Array.from({ length: 11 }).map((_, i) => `${i + 1 < 10 ? '0' : ''}${i + 1}`)]);

packages/ui/src/dayjs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import d from 'dayjs';
1+
import dayjs from 'dayjs';
22
import 'dayjs/locale/zh-cn';
33
import customParseFormat from 'dayjs/plugin/customParseFormat';
44
import isBetween from 'dayjs/plugin/isBetween';
55
import localeData from 'dayjs/plugin/localeData';
66

7-
d.extend(customParseFormat);
8-
d.extend(isBetween);
9-
d.extend(localeData);
7+
dayjs.extend(customParseFormat);
8+
dayjs.extend(isBetween);
9+
dayjs.extend(localeData);
1010

11-
export const dayjs = d;
11+
export default dayjs;

0 commit comments

Comments
 (0)