@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
|
@@ -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';
|
|
@@ -50,6 +50,7 @@ __export(components_exports, {
|
|
|
50
50
|
Money: () => import_money.default,
|
|
51
51
|
Page: () => import_page.default,
|
|
52
52
|
PopupPage: () => import_popup_page.default,
|
|
53
|
+
ProCalendar: () => import_pro_calendar.default,
|
|
53
54
|
ProCalendarPicker: () => import_pro_calendar_picker.default,
|
|
54
55
|
ProList: () => import_pro_list.default,
|
|
55
56
|
ProListPicker: () => import_pro_list_picker.default,
|
|
@@ -87,6 +88,7 @@ var import_money = __toESM(require("./money"));
|
|
|
87
88
|
var import_page = __toESM(require("./page"));
|
|
88
89
|
var import_popup_page = __toESM(require("./popup-page"));
|
|
89
90
|
var import_popup_picker_base = require("./popup-picker-base");
|
|
91
|
+
var import_pro_calendar = __toESM(require("./pro-calendar"));
|
|
90
92
|
var import_pro_calendar_picker = __toESM(require("./pro-calendar-picker"));
|
|
91
93
|
__reExport(components_exports, require("./pro-form"), module.exports);
|
|
92
94
|
var import_pro_list = __toESM(require("./pro-list"));
|
|
@@ -121,6 +123,7 @@ var import_tree_picker = __toESM(require("./tree-picker"));
|
|
|
121
123
|
Money,
|
|
122
124
|
Page,
|
|
123
125
|
PopupPage,
|
|
126
|
+
ProCalendar,
|
|
124
127
|
ProCalendarPicker,
|
|
125
128
|
ProList,
|
|
126
129
|
ProListPicker,
|
|
@@ -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,42 @@
|
|
|
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/index.tsx
|
|
30
|
+
var pro_calendar_exports = {};
|
|
31
|
+
__export(pro_calendar_exports, {
|
|
32
|
+
default: () => pro_calendar_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(pro_calendar_exports);
|
|
35
|
+
var import_pro_calendar = __toESM(require("./pro-calendar"));
|
|
36
|
+
var import_style = require("./style.less");
|
|
37
|
+
var import_utils = require("./utils");
|
|
38
|
+
var ProCalendar = Object.assign(import_pro_calendar.default, {
|
|
39
|
+
defaultFormat: import_utils.formatProCalendarDateValues,
|
|
40
|
+
computeDays: import_utils.computeDays
|
|
41
|
+
});
|
|
42
|
+
var pro_calendar_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,173 @@
|
|
|
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/pro-calendar.tsx
|
|
30
|
+
var pro_calendar_exports = {};
|
|
31
|
+
__export(pro_calendar_exports, {
|
|
32
|
+
convertValueToRange: () => convertValueToRange,
|
|
33
|
+
default: () => pro_calendar_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(pro_calendar_exports);
|
|
36
|
+
var import_ahooks = require("ahooks");
|
|
37
|
+
var import_antd_mobile = require("antd-mobile");
|
|
38
|
+
var import_classnames = __toESM(require("classnames"));
|
|
39
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
40
|
+
var import_lodash = require("lodash");
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
var import_bem = require("../../utils/bem");
|
|
43
|
+
var import_utils = require("./utils");
|
|
44
|
+
var bem = (0, import_bem.cn)("calendar");
|
|
45
|
+
function convertValueToRange(value) {
|
|
46
|
+
if (!value)
|
|
47
|
+
return null;
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
if (value.length <= 1)
|
|
50
|
+
return value;
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
return [value];
|
|
54
|
+
}
|
|
55
|
+
var ProCalendarRaw = ({
|
|
56
|
+
enableHalfDay = false,
|
|
57
|
+
enableHalfDayNight = false,
|
|
58
|
+
weekStartsOn = "Monday",
|
|
59
|
+
value: valueProp,
|
|
60
|
+
onChange: onChangeProp,
|
|
61
|
+
defaultValue: defaultValueProp,
|
|
62
|
+
selectionMode,
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}, ref) => {
|
|
66
|
+
const [value, setValue_] = (0, import_ahooks.useControllableValue)(
|
|
67
|
+
(0, import_lodash.pickBy)(
|
|
68
|
+
{
|
|
69
|
+
value: valueProp,
|
|
70
|
+
defaultValue: defaultValueProp,
|
|
71
|
+
onChange: onChangeProp
|
|
72
|
+
},
|
|
73
|
+
(v) => v !== void 0
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
const rangeValue = (0, import_react.useMemo)(() => convertValueToRange(value) ?? [], [value]);
|
|
77
|
+
const setValue = (0, import_react.useCallback)(
|
|
78
|
+
(v) => {
|
|
79
|
+
if (selectionMode === "range" && enableHalfDay) {
|
|
80
|
+
setValue_((prev) => {
|
|
81
|
+
if (!v)
|
|
82
|
+
return v;
|
|
83
|
+
if (!prev || !Array.isArray(prev) || !prev[0] || prev.length >= 2) {
|
|
84
|
+
return [v];
|
|
85
|
+
}
|
|
86
|
+
return (0, import_utils.mergeDates)([...prev, v]);
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setValue_(v);
|
|
91
|
+
},
|
|
92
|
+
[enableHalfDay, selectionMode, setValue_]
|
|
93
|
+
);
|
|
94
|
+
return /* @__PURE__ */ React.createElement(
|
|
95
|
+
import_antd_mobile.Calendar,
|
|
96
|
+
{
|
|
97
|
+
ref,
|
|
98
|
+
className: (0, import_classnames.default)(bem(), className),
|
|
99
|
+
weekStartsOn,
|
|
100
|
+
selectionMode: enableHalfDay ? void 0 : selectionMode,
|
|
101
|
+
value,
|
|
102
|
+
onChange: (v) => {
|
|
103
|
+
if (enableHalfDay)
|
|
104
|
+
return;
|
|
105
|
+
setValue(v);
|
|
106
|
+
},
|
|
107
|
+
cellRender: (oriNode, { date }) => {
|
|
108
|
+
const dd = (0, import_dayjs.default)(date);
|
|
109
|
+
const isWeekend = dd.day() === 0 || dd.day() === 6;
|
|
110
|
+
if (!enableHalfDay) {
|
|
111
|
+
const node2 = (0, import_react.cloneElement)(oriNode, {
|
|
112
|
+
className: (0, import_classnames.default)(
|
|
113
|
+
oriNode.props.className,
|
|
114
|
+
bem("cell", {
|
|
115
|
+
weekend: isWeekend
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
});
|
|
119
|
+
return node2;
|
|
120
|
+
}
|
|
121
|
+
const nextValue = new Date(date);
|
|
122
|
+
const classes = (0, import_utils.classesForDate)(date, rangeValue);
|
|
123
|
+
const node = (0, import_react.cloneElement)(oriNode, {
|
|
124
|
+
className: (0, import_classnames.default)(oriNode.props.className, bem("cell", classes)),
|
|
125
|
+
onClick: () => {
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const acts = [import_utils.HALF_DAY_PERIOD.AM, import_utils.HALF_DAY_PERIOD.PM];
|
|
129
|
+
if (enableHalfDayNight) {
|
|
130
|
+
acts.push(import_utils.HALF_DAY_PERIOD.NIGHT);
|
|
131
|
+
}
|
|
132
|
+
acts.unshift(import_utils.HALF_DAY_PERIOD.ALL);
|
|
133
|
+
const actions = acts.map((act) => ({
|
|
134
|
+
key: act,
|
|
135
|
+
text: import_utils.HALF_DAY_PERIOD_NAMES[act]
|
|
136
|
+
}));
|
|
137
|
+
return /* @__PURE__ */ React.createElement(
|
|
138
|
+
import_antd_mobile.Popover.Menu,
|
|
139
|
+
{
|
|
140
|
+
actions,
|
|
141
|
+
placement: "top",
|
|
142
|
+
className: bem("period-menu"),
|
|
143
|
+
onAction: (node2) => {
|
|
144
|
+
switch (node2.key) {
|
|
145
|
+
case import_utils.HALF_DAY_PERIOD.AM:
|
|
146
|
+
nextValue.period = import_utils.HALF_DAY_PERIOD.AM;
|
|
147
|
+
break;
|
|
148
|
+
case import_utils.HALF_DAY_PERIOD.PM:
|
|
149
|
+
nextValue.period = import_utils.HALF_DAY_PERIOD.PM;
|
|
150
|
+
break;
|
|
151
|
+
case import_utils.HALF_DAY_PERIOD.NIGHT:
|
|
152
|
+
nextValue.period = import_utils.HALF_DAY_PERIOD.NIGHT;
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
setValue(nextValue);
|
|
158
|
+
},
|
|
159
|
+
trigger: "click"
|
|
160
|
+
},
|
|
161
|
+
node
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
...props
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
var ProCalendar = (0, import_react.forwardRef)(ProCalendarRaw);
|
|
169
|
+
var pro_calendar_default = ProCalendar;
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
convertValueToRange
|
|
173
|
+
});
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare enum HALF_DAY_PERIOD {
|
|
2
|
+
ALL = 0,
|
|
3
|
+
AM = 1,
|
|
4
|
+
PM = 2,
|
|
5
|
+
NIGHT = 3
|
|
6
|
+
}
|
|
7
|
+
export declare const HALF_DAY_PERIOD_NAMES: {
|
|
8
|
+
readonly 0: "全天";
|
|
9
|
+
readonly 1: "上午";
|
|
10
|
+
readonly 2: "下午";
|
|
11
|
+
readonly 3: "晚上";
|
|
12
|
+
};
|
|
13
|
+
export type PickerDate = Date & {
|
|
14
|
+
period?: HALF_DAY_PERIOD;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 将选择的起止日期合并为有效的日期范围
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeDates(dates: PickerDate[]): PickerDate[];
|
|
20
|
+
export declare function classesForDate(date: Date, rangeValue: PickerDate[]): {
|
|
21
|
+
am: boolean;
|
|
22
|
+
pm: boolean;
|
|
23
|
+
night: boolean;
|
|
24
|
+
allday: boolean;
|
|
25
|
+
begin: boolean;
|
|
26
|
+
end: boolean;
|
|
27
|
+
cover: boolean;
|
|
28
|
+
weekend: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function formatProCalendarDate(date?: PickerDate): string;
|
|
31
|
+
export declare function formatProCalendarDateValues(dates?: PickerDate | PickerDate[] | null): string;
|
|
32
|
+
export declare function computeDays(value: PickerDate | PickerDate[] | null | undefined): number;
|
|
@@ -0,0 +1,175 @@
|
|
|
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/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
HALF_DAY_PERIOD: () => HALF_DAY_PERIOD,
|
|
33
|
+
HALF_DAY_PERIOD_NAMES: () => HALF_DAY_PERIOD_NAMES,
|
|
34
|
+
classesForDate: () => classesForDate,
|
|
35
|
+
computeDays: () => computeDays,
|
|
36
|
+
formatProCalendarDate: () => formatProCalendarDate,
|
|
37
|
+
formatProCalendarDateValues: () => formatProCalendarDateValues,
|
|
38
|
+
mergeDates: () => mergeDates
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(utils_exports);
|
|
41
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
42
|
+
var HALF_DAY_PERIOD = /* @__PURE__ */ ((HALF_DAY_PERIOD2) => {
|
|
43
|
+
HALF_DAY_PERIOD2[HALF_DAY_PERIOD2["ALL"] = 0] = "ALL";
|
|
44
|
+
HALF_DAY_PERIOD2[HALF_DAY_PERIOD2["AM"] = 1] = "AM";
|
|
45
|
+
HALF_DAY_PERIOD2[HALF_DAY_PERIOD2["PM"] = 2] = "PM";
|
|
46
|
+
HALF_DAY_PERIOD2[HALF_DAY_PERIOD2["NIGHT"] = 3] = "NIGHT";
|
|
47
|
+
return HALF_DAY_PERIOD2;
|
|
48
|
+
})(HALF_DAY_PERIOD || {});
|
|
49
|
+
var HALF_DAY_PERIOD_NAMES = {
|
|
50
|
+
[0 /* ALL */]: "全天",
|
|
51
|
+
[1 /* AM */]: "上午",
|
|
52
|
+
[2 /* PM */]: "下午",
|
|
53
|
+
[3 /* NIGHT */]: "晚上"
|
|
54
|
+
};
|
|
55
|
+
function mergeDates(dates) {
|
|
56
|
+
const sortedDates = dates.slice().sort((a, b) => {
|
|
57
|
+
return (0, import_dayjs.default)(a).diff(b, "day");
|
|
58
|
+
});
|
|
59
|
+
const [begin, end] = sortedDates;
|
|
60
|
+
const beginDay = (0, import_dayjs.default)(begin);
|
|
61
|
+
if (beginDay.isSame(end, "day")) {
|
|
62
|
+
if (!begin.period || !end.period) {
|
|
63
|
+
begin.period = void 0;
|
|
64
|
+
return [end];
|
|
65
|
+
}
|
|
66
|
+
if (begin.period === end.period) {
|
|
67
|
+
return [begin];
|
|
68
|
+
}
|
|
69
|
+
if ([begin.period, end.period].includes(1 /* AM */)) {
|
|
70
|
+
begin.period = void 0;
|
|
71
|
+
return [begin];
|
|
72
|
+
}
|
|
73
|
+
return sortedDates;
|
|
74
|
+
}
|
|
75
|
+
if (begin.period === 1 /* AM */) {
|
|
76
|
+
begin.period = void 0;
|
|
77
|
+
}
|
|
78
|
+
if (end.period && end.period >= 2 /* PM */) {
|
|
79
|
+
end.period = void 0;
|
|
80
|
+
}
|
|
81
|
+
return [begin, end];
|
|
82
|
+
}
|
|
83
|
+
function classesForDate(date, rangeValue) {
|
|
84
|
+
const dd = (0, import_dayjs.default)(date);
|
|
85
|
+
const [begin, end] = rangeValue;
|
|
86
|
+
let isAm = false;
|
|
87
|
+
let isPm = false;
|
|
88
|
+
let isNight = false;
|
|
89
|
+
let isAllDay = false;
|
|
90
|
+
let isCover = false;
|
|
91
|
+
let isBegin = false;
|
|
92
|
+
let isEnd = false;
|
|
93
|
+
if (begin) {
|
|
94
|
+
if (dd.isSame(begin, "day")) {
|
|
95
|
+
isAm = begin.period === 1 /* AM */;
|
|
96
|
+
isPm = begin.period === 2 /* PM */;
|
|
97
|
+
isNight = begin.period === 3 /* NIGHT */;
|
|
98
|
+
isAllDay = !begin.period;
|
|
99
|
+
isBegin = true;
|
|
100
|
+
if (!end) {
|
|
101
|
+
isEnd = true;
|
|
102
|
+
} else if (!begin.period || begin.period === 1 /* AM */) {
|
|
103
|
+
isCover = true;
|
|
104
|
+
}
|
|
105
|
+
} else if (end && dd.isSame(end, "day")) {
|
|
106
|
+
isAm = end.period === 1 /* AM */;
|
|
107
|
+
isPm = end.period === 2 /* PM */;
|
|
108
|
+
isNight = end.period === 3 /* NIGHT */;
|
|
109
|
+
isAllDay = !end.period;
|
|
110
|
+
isEnd = true;
|
|
111
|
+
isCover = !!end.period && end.period >= 2 /* PM */;
|
|
112
|
+
} else if (end) {
|
|
113
|
+
isCover = dd.isAfter(begin, "day") && dd.isBefore(end, "day");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
am: isAm,
|
|
118
|
+
pm: isPm,
|
|
119
|
+
night: isNight,
|
|
120
|
+
allday: isAllDay,
|
|
121
|
+
begin: isBegin,
|
|
122
|
+
end: isEnd,
|
|
123
|
+
cover: isCover,
|
|
124
|
+
weekend: dd.day() === 0 || dd.day() === 6
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function formatProCalendarDate(date) {
|
|
128
|
+
if (!date) {
|
|
129
|
+
return "";
|
|
130
|
+
}
|
|
131
|
+
const dateStr = (0, import_dayjs.default)(date).format("YYYY-MM-DD");
|
|
132
|
+
const periodStr = !date.period ? "" : HALF_DAY_PERIOD_NAMES[date.period];
|
|
133
|
+
return [dateStr, periodStr].filter((v) => !!v).join(" ");
|
|
134
|
+
}
|
|
135
|
+
function formatProCalendarDateValues(dates) {
|
|
136
|
+
if (!dates) {
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
const arr = Array.isArray(dates) ? dates : [dates];
|
|
140
|
+
return arr.map(formatProCalendarDate).join(" ~ ");
|
|
141
|
+
}
|
|
142
|
+
function computeDays(value) {
|
|
143
|
+
if (!value) {
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
const rangeValue = Array.isArray(value) ? value : [value];
|
|
147
|
+
const [begin, end] = rangeValue;
|
|
148
|
+
if (!end) {
|
|
149
|
+
if (!begin.period)
|
|
150
|
+
return 1;
|
|
151
|
+
if (begin.period === 3 /* NIGHT */)
|
|
152
|
+
return 0;
|
|
153
|
+
return 0.5;
|
|
154
|
+
}
|
|
155
|
+
let days = (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(begin), "day") + 1;
|
|
156
|
+
if (begin.period === 2 /* PM */) {
|
|
157
|
+
days -= 0.5;
|
|
158
|
+
} else if (begin.period === 3 /* NIGHT */) {
|
|
159
|
+
days -= 1;
|
|
160
|
+
}
|
|
161
|
+
if (end.period === 1 /* AM */) {
|
|
162
|
+
days -= 0.5;
|
|
163
|
+
}
|
|
164
|
+
return days;
|
|
165
|
+
}
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
HALF_DAY_PERIOD,
|
|
169
|
+
HALF_DAY_PERIOD_NAMES,
|
|
170
|
+
classesForDate,
|
|
171
|
+
computeDays,
|
|
172
|
+
formatProCalendarDate,
|
|
173
|
+
formatProCalendarDateValues,
|
|
174
|
+
mergeDates
|
|
175
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import ProCalendarPicker from './picker';
|
|
1
|
+
import ProCalendarPicker from './pro-calendar-picker';
|
|
2
|
+
import './style.less';
|
|
2
3
|
export default ProCalendarPicker;
|
|
3
|
-
export type { ProCalendarPickerActions, ProCalendarPickerProps, } from './picker';
|
|
4
|
+
export type { ProCalendarPickerActions, ProCalendarPickerProps, } from './pro-calendar-picker';
|
|
@@ -32,5 +32,6 @@ __export(pro_calendar_picker_exports, {
|
|
|
32
32
|
default: () => pro_calendar_picker_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(pro_calendar_picker_exports);
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var import_pro_calendar_picker = __toESM(require("./pro-calendar-picker"));
|
|
36
|
+
var import_style = require("./style.less");
|
|
37
|
+
var pro_calendar_picker_default = import_pro_calendar_picker.default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CalendarRef } from 'antd-mobile';
|
|
2
|
+
import { PickerActions } from 'antd-mobile/es/components/picker';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { ProCalendarDate, ProCalendarProps } from '../pro-calendar';
|
|
5
|
+
export interface ProCalendarPickerActions extends Partial<CalendarRef>, PickerActions {
|
|
6
|
+
}
|
|
7
|
+
export type ProCalendarPickerValue = ProCalendarDate | ProCalendarDate[] | null | undefined;
|
|
8
|
+
export type ProCalendarPickerProps = ProCalendarProps & {
|
|
9
|
+
allowClear?: boolean;
|
|
10
|
+
children?: (value: ProCalendarPickerValue, action: ProCalendarPickerActions) => ReactNode;
|
|
11
|
+
};
|
|
12
|
+
declare const ProCalendarPicker: import("react").ForwardRefExoticComponent<ProCalendarPickerProps & import("react").RefAttributes<ProCalendarPickerActions>>;
|
|
13
|
+
export default ProCalendarPicker;
|