@nickeylin/antd-mobile-pro 2.0.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +3 -0
- package/dist/cjs/components/input-captcha/input-captcha.d.ts +1 -1
- package/dist/cjs/components/pro-calendar/index.d.ts +10 -0
- package/dist/cjs/components/pro-calendar/index.js +42 -0
- package/dist/cjs/components/pro-calendar/pro-calendar.d.ts +37 -0
- package/dist/cjs/components/pro-calendar/pro-calendar.js +173 -0
- package/dist/cjs/components/pro-calendar/style.less +105 -0
- package/dist/cjs/components/pro-calendar/utils.d.ts +32 -0
- package/dist/cjs/components/pro-calendar/utils.js +175 -0
- package/dist/cjs/components/pro-calendar-picker/index.d.ts +3 -2
- package/dist/cjs/components/pro-calendar-picker/index.js +3 -2
- package/dist/cjs/components/pro-calendar-picker/pro-calendar-picker.d.ts +13 -0
- package/dist/cjs/components/pro-calendar-picker/pro-calendar-picker.js +141 -0
- package/dist/cjs/components/pro-calendar-picker/style.less +38 -0
- package/dist/cjs/components/pro-form/pro-form-item-calendar-picker.d.ts +1 -1
- package/dist/cjs/components/pro-form/pro-form-item-calendar-picker.js +12 -6
- package/dist/cjs/components/pro-list/pro-list.d.ts +2 -1
- package/dist/cjs/components/styles/global.less +6 -0
- package/dist/cjs/components/tree-picker/index.d.ts +1 -1
- package/dist/cjs/components/tree-picker/tree-picker.d.ts +1 -1
- package/dist/cjs/locales/base.d.ts +4 -0
- package/dist/cjs/locales/en-US.d.ts +4 -0
- package/dist/es/components/index.d.ts +1 -0
- package/dist/es/components/index.js +1 -0
- package/dist/es/components/input-captcha/input-captcha.d.ts +1 -1
- package/dist/es/components/pro-calendar/index.d.ts +10 -0
- package/dist/es/components/pro-calendar/index.js +8 -0
- package/dist/es/components/pro-calendar/pro-calendar.d.ts +37 -0
- package/dist/es/components/pro-calendar/pro-calendar.js +138 -0
- package/dist/es/components/pro-calendar/style.less +105 -0
- package/dist/es/components/pro-calendar/utils.d.ts +32 -0
- package/dist/es/components/pro-calendar/utils.js +138 -0
- package/dist/es/components/pro-calendar-picker/index.d.ts +3 -2
- package/dist/es/components/pro-calendar-picker/index.js +2 -1
- package/dist/es/components/pro-calendar-picker/pro-calendar-picker.d.ts +13 -0
- package/dist/es/components/pro-calendar-picker/pro-calendar-picker.js +124 -0
- package/dist/es/components/pro-calendar-picker/style.less +38 -0
- package/dist/es/components/pro-form/pro-form-item-calendar-picker.d.ts +1 -1
- package/dist/es/components/pro-form/pro-form-item-calendar-picker.js +8 -8
- package/dist/es/components/pro-list/pro-list.d.ts +2 -1
- package/dist/es/components/styles/global.less +6 -0
- package/dist/es/components/tree-picker/index.d.ts +1 -1
- package/dist/es/components/tree-picker/tree-picker.d.ts +1 -1
- package/dist/es/locales/base.d.ts +4 -0
- package/dist/es/locales/en-US.d.ts +4 -0
- package/dist/umd/antd-mobile-pro.min.css +1 -1
- package/dist/umd/antd-mobile-pro.min.js +1 -1
- package/package.json +5 -3
- package/dist/cjs/types/index.d.ts +0 -2
- package/dist/cjs/types/service/approve-outline.d.ts +0 -89
- package/dist/cjs/types/service/bpm.d.ts +0 -241
- package/dist/cjs/types/service/common.d.ts +0 -90
- package/dist/es/types/index.d.ts +0 -2
- package/dist/es/types/service/approve-outline.d.ts +0 -89
- package/dist/es/types/service/bpm.d.ts +0 -241
- package/dist/es/types/service/common.d.ts +0 -90
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pro-calendar-picker/pro-calendar-picker.tsx
|
|
30
|
+
var pro_calendar_picker_exports = {};
|
|
31
|
+
__export(pro_calendar_picker_exports, {
|
|
32
|
+
default: () => pro_calendar_picker_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(pro_calendar_picker_exports);
|
|
35
|
+
var import_ahooks = require("ahooks");
|
|
36
|
+
var import_antd_mobile = require("antd-mobile");
|
|
37
|
+
var import_antd_mobile_icons = require("antd-mobile-icons");
|
|
38
|
+
var import_lodash = require("lodash");
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_bem = require("../../utils/bem");
|
|
41
|
+
var import_pro_calendar = __toESM(require("../pro-calendar"));
|
|
42
|
+
var bem = (0, import_bem.cn)("calendar-picker");
|
|
43
|
+
var ProCalendarPickerRaw = ({
|
|
44
|
+
children,
|
|
45
|
+
allowClear = false,
|
|
46
|
+
selectionMode = "single",
|
|
47
|
+
value: valueProp,
|
|
48
|
+
onChange,
|
|
49
|
+
...props
|
|
50
|
+
}, ref) => {
|
|
51
|
+
const [value, setValue] = (0, import_ahooks.useControllableValue)(
|
|
52
|
+
(0, import_lodash.pickBy)({
|
|
53
|
+
value: valueProp,
|
|
54
|
+
onChange
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
const [visible, setVisible] = (0, import_react.useState)(false);
|
|
58
|
+
const [tempValue, setTempValue] = (0, import_react.useState)(valueProp);
|
|
59
|
+
(0, import_react.useEffect)(() => {
|
|
60
|
+
if (visible)
|
|
61
|
+
setTempValue(value ?? null);
|
|
62
|
+
}, [value, visible]);
|
|
63
|
+
const calendarRef = (0, import_react.useRef)(null);
|
|
64
|
+
const action = (0, import_react.useMemo)(() => {
|
|
65
|
+
return {
|
|
66
|
+
...calendarRef.current,
|
|
67
|
+
open() {
|
|
68
|
+
setVisible(true);
|
|
69
|
+
},
|
|
70
|
+
close() {
|
|
71
|
+
setVisible(false);
|
|
72
|
+
},
|
|
73
|
+
toggle() {
|
|
74
|
+
setVisible((v) => !v);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
(0, import_react.useImperativeHandle)(ref, () => action);
|
|
79
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children == null ? void 0 : children(value, action), /* @__PURE__ */ React.createElement(
|
|
80
|
+
import_antd_mobile.Popup,
|
|
81
|
+
{
|
|
82
|
+
visible,
|
|
83
|
+
onClose: () => setVisible(false),
|
|
84
|
+
className: bem("popup"),
|
|
85
|
+
destroyOnClose: true
|
|
86
|
+
},
|
|
87
|
+
/* @__PURE__ */ React.createElement("div", { className: bem("popup-head") }, allowClear && /* @__PURE__ */ React.createElement(
|
|
88
|
+
import_antd_mobile.Button,
|
|
89
|
+
{
|
|
90
|
+
color: "default",
|
|
91
|
+
fill: "none",
|
|
92
|
+
size: "small",
|
|
93
|
+
className: bem("popup-head__clear"),
|
|
94
|
+
onClick: () => {
|
|
95
|
+
setValue(void 0);
|
|
96
|
+
setVisible(false);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"清除"
|
|
100
|
+
), /* @__PURE__ */ React.createElement("div", { className: bem("popup-head__title") }, "日期选择"), /* @__PURE__ */ React.createElement(
|
|
101
|
+
import_antd_mobile.Button,
|
|
102
|
+
{
|
|
103
|
+
color: "default",
|
|
104
|
+
fill: "none",
|
|
105
|
+
size: "small",
|
|
106
|
+
className: bem("popup-head__close"),
|
|
107
|
+
onClick: () => {
|
|
108
|
+
setVisible(false);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
/* @__PURE__ */ React.createElement(import_antd_mobile_icons.CloseOutline, null)
|
|
112
|
+
)),
|
|
113
|
+
/* @__PURE__ */ React.createElement(
|
|
114
|
+
import_pro_calendar.default,
|
|
115
|
+
{
|
|
116
|
+
selectionMode,
|
|
117
|
+
value: tempValue ?? null,
|
|
118
|
+
onChange: (v) => {
|
|
119
|
+
setTempValue(v);
|
|
120
|
+
},
|
|
121
|
+
...props,
|
|
122
|
+
ref: calendarRef
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ React.createElement("div", { className: bem("popup-footer") }, /* @__PURE__ */ React.createElement(
|
|
126
|
+
import_antd_mobile.Button,
|
|
127
|
+
{
|
|
128
|
+
block: true,
|
|
129
|
+
color: "primary",
|
|
130
|
+
onClick: () => {
|
|
131
|
+
console.log("setValue", tempValue);
|
|
132
|
+
setValue(tempValue);
|
|
133
|
+
setVisible(false);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"确定"
|
|
137
|
+
), /* @__PURE__ */ React.createElement(import_antd_mobile.SafeArea, { position: "bottom" }))
|
|
138
|
+
));
|
|
139
|
+
};
|
|
140
|
+
var ProCalendarPicker = (0, import_react.forwardRef)(ProCalendarPickerRaw);
|
|
141
|
+
var pro_calendar_picker_default = ProCalendarPicker;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import '../styles/variable.less';
|
|
2
|
+
|
|
3
|
+
@class-prefix-pro-calendar-picker:~ '@{adm-pro-prefix}-calendar-picker';
|
|
4
|
+
.@{class-prefix-pro-calendar-picker} {
|
|
5
|
+
&__popup-head {
|
|
6
|
+
font-size: var(--adm-font-size-9);
|
|
7
|
+
color: var(--adm-color-text);
|
|
8
|
+
position: relative;
|
|
9
|
+
border-bottom: 1px solid var(--adm-color-border);
|
|
10
|
+
margin-bottom: 10px;
|
|
11
|
+
& &__clear {
|
|
12
|
+
position: absolute;
|
|
13
|
+
left: 6px;
|
|
14
|
+
top: 0;
|
|
15
|
+
bottom: 0;
|
|
16
|
+
margin: auto;
|
|
17
|
+
padding: 6px 12px;
|
|
18
|
+
height: 30px;
|
|
19
|
+
}
|
|
20
|
+
&__title {
|
|
21
|
+
text-align: center;
|
|
22
|
+
line-height: 45px;
|
|
23
|
+
}
|
|
24
|
+
& &__close {
|
|
25
|
+
position: absolute;
|
|
26
|
+
right: 6px;
|
|
27
|
+
top: 0;
|
|
28
|
+
bottom: 0;
|
|
29
|
+
margin: auto;
|
|
30
|
+
padding: 6px 12px;
|
|
31
|
+
height: 30px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
&__popup-footer {
|
|
35
|
+
padding: var(--adm-padding-m) var(--adm-padding-l);
|
|
36
|
+
border-top: 1px solid var(--adm-color-border);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { ProCalendarPickerProps } from '../pro-calendar-picker';
|
|
3
3
|
import { ProFormItemFieldProps } from './pro-form-item';
|
|
4
|
-
export type ProFormCalendarPickerProps = ProFormItemFieldProps<ProCalendarPickerProps> & Pick<ProCalendarPickerProps, '
|
|
4
|
+
export type ProFormCalendarPickerProps = ProFormItemFieldProps<ProCalendarPickerProps> & Pick<ProCalendarPickerProps, 'selectionMode' | 'min' | 'max' | 'enableHalfDay'>;
|
|
5
5
|
declare const ProFormCalendarPicker: FC<ProFormCalendarPickerProps>;
|
|
6
6
|
export default ProFormCalendarPicker;
|
|
@@ -33,6 +33,7 @@ __export(pro_form_item_calendar_picker_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(pro_form_item_calendar_picker_exports);
|
|
35
35
|
var import_config_provider = require("../config-provider");
|
|
36
|
+
var import_pro_calendar = __toESM(require("../pro-calendar"));
|
|
36
37
|
var import_pro_calendar_picker = __toESM(require("../pro-calendar-picker"));
|
|
37
38
|
var import_pro_form_item = __toESM(require("./pro-form-item"));
|
|
38
39
|
var import_utils = require("./utils");
|
|
@@ -41,20 +42,25 @@ var ProFormCalendarPicker = (p) => {
|
|
|
41
42
|
const {
|
|
42
43
|
fieldProps,
|
|
43
44
|
placeholder = locale.common.selectPlaceholder,
|
|
44
|
-
|
|
45
|
+
selectionMode,
|
|
45
46
|
min,
|
|
46
47
|
max,
|
|
47
|
-
|
|
48
|
+
enableHalfDay,
|
|
48
49
|
onClick,
|
|
49
50
|
...props
|
|
50
51
|
} = p;
|
|
51
|
-
const calendarProps = {
|
|
52
|
+
const calendarProps = {
|
|
53
|
+
selectionMode,
|
|
54
|
+
min,
|
|
55
|
+
max,
|
|
56
|
+
enableHalfDay,
|
|
57
|
+
...fieldProps
|
|
58
|
+
};
|
|
52
59
|
const readonly = (0, import_utils.useReadonly)(props);
|
|
53
60
|
return /* @__PURE__ */ React.createElement(
|
|
54
61
|
import_pro_form_item.default,
|
|
55
62
|
{
|
|
56
63
|
...props,
|
|
57
|
-
trigger: "onConfirm",
|
|
58
64
|
onClick: (e, pickerRef) => {
|
|
59
65
|
var _a;
|
|
60
66
|
(_a = pickerRef.current) == null ? void 0 : _a.open();
|
|
@@ -62,12 +68,12 @@ var ProFormCalendarPicker = (p) => {
|
|
|
62
68
|
}
|
|
63
69
|
},
|
|
64
70
|
/* @__PURE__ */ React.createElement(import_pro_calendar_picker.default, { ...calendarProps }, (val) => {
|
|
65
|
-
const value =
|
|
71
|
+
const value = import_pro_calendar.default.defaultFormat(val);
|
|
66
72
|
return /* @__PURE__ */ React.createElement(
|
|
67
73
|
import_pro_form_item.ProFormItemValue,
|
|
68
74
|
{
|
|
69
75
|
placeholder,
|
|
70
|
-
value: value
|
|
76
|
+
value: value || void 0,
|
|
71
77
|
readonly
|
|
72
78
|
}
|
|
73
79
|
);
|
|
@@ -10,7 +10,8 @@ export interface ProListPaginationProps {
|
|
|
10
10
|
/** 页码,从1开始 */
|
|
11
11
|
pageIndex?: number;
|
|
12
12
|
}
|
|
13
|
-
type ProListCustomRequestParams<U> =
|
|
13
|
+
type ProListCustomRequestParams<U> = {
|
|
14
|
+
keyword?: string;
|
|
14
15
|
pageInfo?: {
|
|
15
16
|
page: number;
|
|
16
17
|
rows: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import prompt from './prompt';
|
|
3
3
|
import './tree-picker.less';
|
|
4
|
-
declare const TreePicker: (<T extends import("..").TreeDataNode<object> = import("..").TreeDataNode<object>>(props: Omit<import("..").PopupPickerMixinProps<T | T[]>, "fieldNames"> & Pick<import("..").TreeProps<T>, "search" | "
|
|
4
|
+
declare const TreePicker: (<T extends import("..").TreeDataNode<object> = import("..").TreeDataNode<object>>(props: Omit<import("..").PopupPickerMixinProps<T | T[]>, "fieldNames"> & Pick<import("..").TreeProps<T>, "search" | "params" | "request" | "rowKey" | "fieldNames" | "dataSource"> & {
|
|
5
5
|
treeProps?: Omit<import("..").TreeProps<T>, "rowKey"> | undefined;
|
|
6
6
|
multiple?: boolean | undefined;
|
|
7
7
|
} & {
|
|
@@ -9,7 +9,7 @@ export type TreePickerProps<T extends TreeDataNode<object> = TreeDataNode<object
|
|
|
9
9
|
*/
|
|
10
10
|
multiple?: boolean;
|
|
11
11
|
} & NativeProps;
|
|
12
|
-
declare const TreePicker: <T extends TreeDataNode<object> = TreeDataNode<object>>(props: Omit<PopupPickerMixinProps<T | T[]>, "fieldNames"> & Pick<TreeProps<T>, "search" | "
|
|
12
|
+
declare const TreePicker: <T extends TreeDataNode<object> = TreeDataNode<object>>(props: Omit<PopupPickerMixinProps<T | T[]>, "fieldNames"> & Pick<TreeProps<T>, "search" | "params" | "request" | "rowKey" | "fieldNames" | "dataSource"> & {
|
|
13
13
|
treeProps?: Omit<TreeProps<T>, "rowKey"> | undefined;
|
|
14
14
|
/**
|
|
15
15
|
* 启用多选时,将启用复选框禁用选择,即点击整行会选中复选框
|
|
@@ -12,6 +12,7 @@ declare const base: {
|
|
|
12
12
|
confirm: string;
|
|
13
13
|
start: string;
|
|
14
14
|
end: string;
|
|
15
|
+
startAndEnd: string;
|
|
15
16
|
today: string;
|
|
16
17
|
markItems: string[];
|
|
17
18
|
yearAndMonth: string;
|
|
@@ -112,6 +113,9 @@ declare const base: {
|
|
|
112
113
|
Modal: {
|
|
113
114
|
ok: string;
|
|
114
115
|
};
|
|
116
|
+
NumberKeyboard: {
|
|
117
|
+
backspace: string;
|
|
118
|
+
};
|
|
115
119
|
PasscodeInput: {
|
|
116
120
|
name: string;
|
|
117
121
|
};
|
|
@@ -11,6 +11,7 @@ declare const enUS: {
|
|
|
11
11
|
confirm: string;
|
|
12
12
|
start: string;
|
|
13
13
|
end: string;
|
|
14
|
+
startAndEnd: string;
|
|
14
15
|
today: string;
|
|
15
16
|
markItems: string[];
|
|
16
17
|
yearAndMonth: string;
|
|
@@ -111,6 +112,9 @@ declare const enUS: {
|
|
|
111
112
|
Modal: {
|
|
112
113
|
ok: string;
|
|
113
114
|
};
|
|
115
|
+
NumberKeyboard: {
|
|
116
|
+
backspace: string;
|
|
117
|
+
};
|
|
114
118
|
PasscodeInput: {
|
|
115
119
|
name: string;
|
|
116
120
|
};
|
|
@@ -19,6 +19,7 @@ export { default as Money, type MoneyProps } from './money';
|
|
|
19
19
|
export { default as Page, type PageBodyProps, type PageFooterProps, type PageProps, type PageToolbarProps, } from './page';
|
|
20
20
|
export { default as PopupPage, type PopupPageProps } from './popup-page';
|
|
21
21
|
export { createPopupPickerPrompt, usePopupPickerMixin, type PopupPickerActions, type PopupPickerMixinProps, } from './popup-picker-base';
|
|
22
|
+
export { default as ProCalendar, type ProCalendarDate, type ProCalendarProps, } from './pro-calendar';
|
|
22
23
|
export { default as ProCalendarPicker, type ProCalendarPickerActions, type ProCalendarPickerProps, } from './pro-calendar-picker';
|
|
23
24
|
export * from './pro-form';
|
|
24
25
|
export { default as ProList, type ProListAction, type ProListPaginationProps, type ProListProps, } from './pro-list';
|
|
@@ -19,6 +19,7 @@ export { default as Money } from "./money";
|
|
|
19
19
|
export { default as Page } from "./page";
|
|
20
20
|
export { default as PopupPage } from "./popup-page";
|
|
21
21
|
export { createPopupPickerPrompt, usePopupPickerMixin } from "./popup-picker-base";
|
|
22
|
+
export { default as ProCalendar } from "./pro-calendar";
|
|
22
23
|
export { default as ProCalendarPicker } from "./pro-calendar-picker";
|
|
23
24
|
export * from "./pro-form";
|
|
24
25
|
export { default as ProList } from "./pro-list";
|
|
@@ -23,7 +23,7 @@ declare const InputCaptcha: import("react").ForwardRefExoticComponent<{
|
|
|
23
23
|
className?: string | undefined;
|
|
24
24
|
style?: (import("react").CSSProperties & Partial<Record<never, string>>) | undefined;
|
|
25
25
|
tabIndex?: number | undefined;
|
|
26
|
-
} & import("react").AriaAttributes & Omit<InputProps, "
|
|
26
|
+
} & import("react").AriaAttributes & Omit<InputProps, "className" | "style"> & {
|
|
27
27
|
inputClassName?: string | undefined;
|
|
28
28
|
inputStyle?: InputProps['style'];
|
|
29
29
|
/** 获取验证码按钮的 props */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './style.less';
|
|
3
|
+
import { computeDays, formatProCalendarDateValues } from './utils';
|
|
4
|
+
declare const ProCalendar: import("react").ForwardRefExoticComponent<import("./pro-calendar").ProCalendarProps & import("react").RefAttributes<import("antd-mobile").CalendarRef>> & {
|
|
5
|
+
defaultFormat: typeof formatProCalendarDateValues;
|
|
6
|
+
computeDays: typeof computeDays;
|
|
7
|
+
};
|
|
8
|
+
export default ProCalendar;
|
|
9
|
+
export type { ProCalendarProps } from './pro-calendar';
|
|
10
|
+
export type { PickerDate as ProCalendarDate } from './utils';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _ProCalendar from "./pro-calendar";
|
|
2
|
+
import "./style.less";
|
|
3
|
+
import { computeDays, formatProCalendarDateValues } from "./utils";
|
|
4
|
+
var ProCalendar = Object.assign(_ProCalendar, {
|
|
5
|
+
defaultFormat: formatProCalendarDateValues,
|
|
6
|
+
computeDays: computeDays
|
|
7
|
+
});
|
|
8
|
+
export default ProCalendar;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CalendarProps, CalendarRef } from 'antd-mobile';
|
|
3
|
+
import { PickerDate } from './utils';
|
|
4
|
+
interface ProCalendarPropsInner {
|
|
5
|
+
/**
|
|
6
|
+
* 是否开启半日选择
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
enableHalfDay?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 是否开启晚上选择
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
enableHalfDayNight?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ProCalendarNormalProps {
|
|
17
|
+
selectionMode?: undefined;
|
|
18
|
+
value?: undefined;
|
|
19
|
+
defaultValue?: undefined;
|
|
20
|
+
onChange?: undefined;
|
|
21
|
+
}
|
|
22
|
+
interface ProCalendarSingleProps {
|
|
23
|
+
selectionMode: 'single';
|
|
24
|
+
value?: PickerDate | null;
|
|
25
|
+
defaultValue?: PickerDate | null;
|
|
26
|
+
onChange?: (value: PickerDate | null) => void;
|
|
27
|
+
}
|
|
28
|
+
interface ProCalendarRangeProps {
|
|
29
|
+
selectionMode?: 'range';
|
|
30
|
+
value?: PickerDate[] | null;
|
|
31
|
+
defaultValue?: PickerDate[] | null;
|
|
32
|
+
onChange?: (value: PickerDate[] | null) => void;
|
|
33
|
+
}
|
|
34
|
+
export type ProCalendarProps = ProCalendarPropsInner & (ProCalendarNormalProps | ProCalendarSingleProps | ProCalendarRangeProps) & Omit<CalendarProps, 'value' | 'onChange' | 'defaultValue' | 'selectionMode'>;
|
|
35
|
+
export declare function convertValueToRange(value: PickerDate | PickerDate[] | null): PickerDate[] | null;
|
|
36
|
+
declare const ProCalendar: import("react").ForwardRefExoticComponent<ProCalendarProps & import("react").RefAttributes<CalendarRef>>;
|
|
37
|
+
export default ProCalendar;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["enableHalfDay", "enableHalfDayNight", "weekStartsOn", "value", "onChange", "defaultValue", "selectionMode", "className"];
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import { useControllableValue } from 'ahooks';
|
|
9
|
+
import { Calendar, Popover } from 'antd-mobile';
|
|
10
|
+
import classNames from 'classnames';
|
|
11
|
+
import dayjs from 'dayjs';
|
|
12
|
+
import { pickBy } from 'lodash';
|
|
13
|
+
import { cloneElement, forwardRef, useCallback, useMemo } from 'react';
|
|
14
|
+
import { cn } from "../../utils/bem";
|
|
15
|
+
import { HALF_DAY_PERIOD, HALF_DAY_PERIOD_NAMES, classesForDate, mergeDates } from "./utils";
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
var bem = cn('calendar');
|
|
20
|
+
export function convertValueToRange(value) {
|
|
21
|
+
if (!value) return null;
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
if (value.length <= 1) return value;
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
return [value];
|
|
27
|
+
}
|
|
28
|
+
var ProCalendarRaw = function ProCalendarRaw(_ref, ref) {
|
|
29
|
+
var _ref$enableHalfDay = _ref.enableHalfDay,
|
|
30
|
+
enableHalfDay = _ref$enableHalfDay === void 0 ? false : _ref$enableHalfDay,
|
|
31
|
+
_ref$enableHalfDayNig = _ref.enableHalfDayNight,
|
|
32
|
+
enableHalfDayNight = _ref$enableHalfDayNig === void 0 ? false : _ref$enableHalfDayNig,
|
|
33
|
+
_ref$weekStartsOn = _ref.weekStartsOn,
|
|
34
|
+
weekStartsOn = _ref$weekStartsOn === void 0 ? 'Monday' : _ref$weekStartsOn,
|
|
35
|
+
valueProp = _ref.value,
|
|
36
|
+
onChangeProp = _ref.onChange,
|
|
37
|
+
defaultValueProp = _ref.defaultValue,
|
|
38
|
+
selectionMode = _ref.selectionMode,
|
|
39
|
+
className = _ref.className,
|
|
40
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
+
var _useControllableValue = useControllableValue(pickBy({
|
|
42
|
+
value: valueProp,
|
|
43
|
+
defaultValue: defaultValueProp,
|
|
44
|
+
onChange: onChangeProp
|
|
45
|
+
}, function (v) {
|
|
46
|
+
return v !== undefined;
|
|
47
|
+
})),
|
|
48
|
+
_useControllableValue2 = _slicedToArray(_useControllableValue, 2),
|
|
49
|
+
value = _useControllableValue2[0],
|
|
50
|
+
setValue_ = _useControllableValue2[1];
|
|
51
|
+
var rangeValue = useMemo(function () {
|
|
52
|
+
var _convertValueToRange;
|
|
53
|
+
return (_convertValueToRange = convertValueToRange(value)) !== null && _convertValueToRange !== void 0 ? _convertValueToRange : [];
|
|
54
|
+
}, [value]);
|
|
55
|
+
var setValue = useCallback(function (v) {
|
|
56
|
+
if (selectionMode === 'range' && enableHalfDay) {
|
|
57
|
+
setValue_(function (prev) {
|
|
58
|
+
if (!v) return v;
|
|
59
|
+
if (!prev || !Array.isArray(prev) || !prev[0] || prev.length >= 2) {
|
|
60
|
+
return [v];
|
|
61
|
+
}
|
|
62
|
+
return mergeDates([].concat(_toConsumableArray(prev), [v]));
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
setValue_(v);
|
|
67
|
+
}, [enableHalfDay, selectionMode, setValue_]);
|
|
68
|
+
return /*#__PURE__*/_jsx(Calendar, _objectSpread({
|
|
69
|
+
ref: ref,
|
|
70
|
+
className: classNames(bem(), className),
|
|
71
|
+
weekStartsOn: weekStartsOn,
|
|
72
|
+
selectionMode: enableHalfDay ? undefined : selectionMode,
|
|
73
|
+
value: value,
|
|
74
|
+
onChange: function onChange(v) {
|
|
75
|
+
if (enableHalfDay) return;
|
|
76
|
+
setValue(v);
|
|
77
|
+
},
|
|
78
|
+
cellRender: function cellRender(oriNode, _ref2) {
|
|
79
|
+
var date = _ref2.date;
|
|
80
|
+
var dd = dayjs(date);
|
|
81
|
+
var isWeekend = dd.day() === 0 || dd.day() === 6;
|
|
82
|
+
if (!enableHalfDay) {
|
|
83
|
+
var _node = /*#__PURE__*/cloneElement(oriNode, {
|
|
84
|
+
className: classNames(oriNode.props.className, bem('cell', {
|
|
85
|
+
weekend: isWeekend
|
|
86
|
+
}))
|
|
87
|
+
});
|
|
88
|
+
return _node;
|
|
89
|
+
}
|
|
90
|
+
var nextValue = new Date(date);
|
|
91
|
+
var classes = classesForDate(date, rangeValue);
|
|
92
|
+
var node = /*#__PURE__*/cloneElement(oriNode, {
|
|
93
|
+
className: classNames(oriNode.props.className, bem('cell', classes)),
|
|
94
|
+
onClick: function onClick() {}
|
|
95
|
+
});
|
|
96
|
+
var acts = [HALF_DAY_PERIOD.AM, HALF_DAY_PERIOD.PM];
|
|
97
|
+
if (enableHalfDayNight) {
|
|
98
|
+
acts.push(HALF_DAY_PERIOD.NIGHT);
|
|
99
|
+
}
|
|
100
|
+
acts.unshift(HALF_DAY_PERIOD.ALL);
|
|
101
|
+
var actions = acts.map(function (act) {
|
|
102
|
+
return {
|
|
103
|
+
key: act,
|
|
104
|
+
text: HALF_DAY_PERIOD_NAMES[act]
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
return /*#__PURE__*/_jsx(Popover.Menu, {
|
|
108
|
+
actions: actions,
|
|
109
|
+
placement: "top",
|
|
110
|
+
className: bem('period-menu'),
|
|
111
|
+
onAction: function onAction(node) {
|
|
112
|
+
switch (node.key) {
|
|
113
|
+
case HALF_DAY_PERIOD.AM:
|
|
114
|
+
// 上午
|
|
115
|
+
nextValue.period = HALF_DAY_PERIOD.AM;
|
|
116
|
+
break;
|
|
117
|
+
case HALF_DAY_PERIOD.PM:
|
|
118
|
+
// 下午
|
|
119
|
+
nextValue.period = HALF_DAY_PERIOD.PM;
|
|
120
|
+
break;
|
|
121
|
+
case HALF_DAY_PERIOD.NIGHT:
|
|
122
|
+
// 晚上
|
|
123
|
+
nextValue.period = HALF_DAY_PERIOD.NIGHT;
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
// 全天
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
setValue(nextValue);
|
|
130
|
+
},
|
|
131
|
+
trigger: "click",
|
|
132
|
+
children: node
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, props));
|
|
136
|
+
};
|
|
137
|
+
var ProCalendar = /*#__PURE__*/forwardRef(ProCalendarRaw);
|
|
138
|
+
export default ProCalendar;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@import '../styles/variable.less';
|
|
2
|
+
|
|
3
|
+
@class-prefix-pro-calendar:~ '@{adm-pro-prefix}-calendar';
|
|
4
|
+
|
|
5
|
+
.@{class-prefix-pro-calendar} {
|
|
6
|
+
.adm-calendar-cell {
|
|
7
|
+
&-selected:not(&-selected-begin):not(&-selected-end) {
|
|
8
|
+
background-color: rgba(22, 119, 255, 0.1);
|
|
9
|
+
color: var(--adm-color-text);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
.adm-calendar-cell.adm-calendar-cell-disabled {
|
|
13
|
+
color: var(--adm-color-border);
|
|
14
|
+
}
|
|
15
|
+
.adm-calendar-cell.adm-calendar-cell-today {
|
|
16
|
+
color: var(--adm-color-text);
|
|
17
|
+
border: 1px solid var(--adm-color-primary);
|
|
18
|
+
border-radius: 4px;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__cell {
|
|
23
|
+
position: relative;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
& > div {
|
|
26
|
+
position: relative;
|
|
27
|
+
}
|
|
28
|
+
// &&--weekend {
|
|
29
|
+
// color: var(--adm-color-weak);
|
|
30
|
+
// }
|
|
31
|
+
&&--allday,
|
|
32
|
+
&&--allday.adm-calendar-cell-today {
|
|
33
|
+
background-color: var(--adm-color-primary);
|
|
34
|
+
color: var(--adm-color-white);
|
|
35
|
+
}
|
|
36
|
+
&--begin {
|
|
37
|
+
border-top-left-radius: 4px;
|
|
38
|
+
border-bottom-left-radius: 4px;
|
|
39
|
+
}
|
|
40
|
+
&--end {
|
|
41
|
+
border-top-right-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
}
|
|
44
|
+
&--am::before,
|
|
45
|
+
&--pm::before,
|
|
46
|
+
&--night::before {
|
|
47
|
+
content: '';
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 0;
|
|
50
|
+
right: 0;
|
|
51
|
+
background-color: var(--adm-color-primary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&--am {
|
|
55
|
+
&::before {
|
|
56
|
+
top: 0;
|
|
57
|
+
height: 50%;
|
|
58
|
+
// border-top-left-radius: 4px;
|
|
59
|
+
// border-top-right-radius: 4px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
&--pm {
|
|
63
|
+
&::before {
|
|
64
|
+
bottom: 0;
|
|
65
|
+
height: 50%;
|
|
66
|
+
// border-bottom-left-radius: 4px;
|
|
67
|
+
// border-bottom-right-radius: 4px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
&--night {
|
|
71
|
+
&::before {
|
|
72
|
+
bottom: 0;
|
|
73
|
+
height: 6px;
|
|
74
|
+
// border-bottom-left-radius: 4px;
|
|
75
|
+
// border-bottom-right-radius: 4px;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
&--cover {
|
|
79
|
+
background-color: rgba(22, 119, 255, 0.1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&__period-menu {
|
|
84
|
+
.adm-popover-menu-list {
|
|
85
|
+
min-width: 80px;
|
|
86
|
+
}
|
|
87
|
+
.adm-popover-menu-item {
|
|
88
|
+
padding: 0;
|
|
89
|
+
}
|
|
90
|
+
.adm-popover-menu-item-text {
|
|
91
|
+
padding: 10px 20px 10px 20px;
|
|
92
|
+
text-align: center;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
html[data-prefers-color-scheme='dark'] {
|
|
98
|
+
.@{class-prefix-pro-calendar} {
|
|
99
|
+
&__period-menu {
|
|
100
|
+
--background: rgba(0, 0, 0, 0.75);
|
|
101
|
+
--adm-color-text: #ffffff;
|
|
102
|
+
backdrop-filter: blur(10px);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|