@bifrostui/react 2.0.0-beta.10 → 2.0.0-beta.12
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/Calendar/Calendar.js +5 -1
- package/dist/Calendar/Calendar.types.d.ts +5 -0
- package/dist/Collapse/Collapse.css +0 -1
- package/dist/Collapse/Collapse.d.ts +1 -1
- package/dist/Collapse/Collapse.js +11 -8
- package/dist/Collapse/Collapse.miniapp.d.ts +5 -0
- package/dist/Collapse/Collapse.miniapp.js +177 -0
- package/dist/CollapsePanel/CollapsePanel.css +4 -2
- package/dist/DatePicker/DatePicker.d.ts +4 -0
- package/dist/DatePicker/DatePicker.js +335 -0
- package/dist/DatePicker/DatePicker.types.d.ts +36 -0
- package/dist/DatePicker/DatePicker.types.js +15 -0
- package/dist/DatePicker/constants.d.ts +9 -0
- package/dist/DatePicker/constants.js +37 -0
- package/dist/DatePicker/index.d.ts +3 -0
- package/dist/DatePicker/index.js +44 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
- package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
- package/dist/DesktopDatePicker/index.css +61 -0
- package/dist/DesktopDatePicker/index.d.ts +2 -0
- package/dist/DesktopDatePicker/index.js +41 -0
- package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
- package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
- package/dist/DesktopDateTimePicker/index.css +66 -0
- package/dist/DesktopDateTimePicker/index.d.ts +2 -0
- package/dist/DesktopDateTimePicker/index.js +41 -0
- package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
- package/dist/DesktopPicker/DesktopPicker.js +243 -0
- package/dist/DesktopPicker/DesktopPicker.types.d.ts +61 -0
- package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
- package/dist/DesktopPicker/index.css +39 -0
- package/dist/DesktopPicker/index.d.ts +2 -0
- package/dist/DesktopPicker/index.js +41 -0
- package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
- package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
- package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
- package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
- package/dist/DesktopTimePicker/index.css +170 -0
- package/dist/DesktopTimePicker/index.d.ts +2 -0
- package/dist/DesktopTimePicker/index.js +41 -0
- package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
- package/dist/DesktopTimePicker/useGetTimePickerContent.js +249 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
- package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
- package/dist/DesktopTimePicker/utils/utils.js +408 -0
- package/dist/Dialog/Dialog.types.d.ts +5 -0
- package/dist/Dialog/FunctionalDialog.js +13 -2
- package/dist/Input/Input.css +0 -2
- package/dist/Modal/Modal.miniapp.d.ts +1 -1
- package/dist/Picker/Picker.css +5 -0
- package/dist/Picker/Picker.js +27 -5
- package/dist/Picker/Picker.types.d.ts +15 -2
- package/dist/Picker/PickerPanel.css +4 -0
- package/dist/Picker/PickerPanel.js +7 -6
- package/dist/Popover/Popover.js +70 -27
- package/dist/Portal/Portal.miniapp.js +7 -4
- package/dist/ScrollView/ScrollView.js +24 -11
- package/dist/ScrollView/ScrollView.types.d.ts +0 -1
- package/dist/Select/Select.css +1 -4
- package/dist/Select/Select.js +62 -37
- package/dist/Slider/Slider.js +13 -5
- package/dist/SwipeAction/SwipeAction.css +79 -0
- package/dist/SwipeAction/SwipeAction.d.ts +5 -0
- package/dist/SwipeAction/SwipeAction.js +349 -0
- package/dist/SwipeAction/SwipeAction.types.d.ts +75 -0
- package/dist/SwipeAction/SwipeAction.types.js +15 -0
- package/dist/SwipeAction/SwipeActionContext.d.ts +4 -0
- package/dist/SwipeAction/SwipeActionContext.js +30 -0
- package/dist/SwipeAction/SwipeActionItem.css +31 -0
- package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
- package/dist/SwipeAction/SwipeActionItem.js +105 -0
- package/dist/SwipeAction/constants.d.ts +9 -0
- package/dist/SwipeAction/constants.js +39 -0
- package/dist/SwipeAction/index.d.ts +5 -0
- package/dist/SwipeAction/index.js +50 -0
- package/dist/TabBar/TabBarItem.js +2 -2
- package/dist/Tabs/Tabs.js +29 -14
- package/dist/Tabs/utils/scroll.d.ts +2 -0
- package/dist/Tabs/utils/scroll.js +55 -0
- package/dist/Toast/FunctionalToast.js +13 -2
- package/dist/Toast/Toast.css +0 -1
- package/dist/Toast/Toast.types.d.ts +5 -0
- package/dist/Tooltip/Tooltip.js +70 -27
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -1
- package/dist/locales/base.d.ts +11 -0
- package/dist/locales/en-US.js +24 -0
- package/dist/locales/zh-CN.js +24 -0
- package/dist/locales/zh-TW.js +24 -0
- package/es/Calendar/Calendar.js +5 -1
- package/es/Calendar/Calendar.types.d.ts +5 -0
- package/es/Collapse/Collapse.css +0 -1
- package/es/Collapse/Collapse.d.ts +1 -1
- package/es/Collapse/Collapse.js +11 -8
- package/es/Collapse/Collapse.miniapp.d.ts +5 -0
- package/es/Collapse/Collapse.miniapp.js +157 -0
- package/es/CollapsePanel/CollapsePanel.css +4 -2
- package/es/DatePicker/DatePicker.d.ts +4 -0
- package/es/DatePicker/DatePicker.js +308 -0
- package/es/DatePicker/DatePicker.types.d.ts +36 -0
- package/es/DatePicker/DatePicker.types.js +1 -0
- package/es/DatePicker/constants.d.ts +9 -0
- package/es/DatePicker/constants.js +14 -0
- package/es/DatePicker/index.d.ts +3 -0
- package/es/DatePicker/index.js +8 -0
- package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
- package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
- package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
- package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
- package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
- package/es/DesktopDatePicker/index.css +61 -0
- package/es/DesktopDatePicker/index.d.ts +2 -0
- package/es/DesktopDatePicker/index.js +6 -0
- package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
- package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
- package/es/DesktopDateTimePicker/index.css +66 -0
- package/es/DesktopDateTimePicker/index.d.ts +2 -0
- package/es/DesktopDateTimePicker/index.js +9 -0
- package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
- package/es/DesktopPicker/DesktopPicker.js +226 -0
- package/es/DesktopPicker/DesktopPicker.types.d.ts +61 -0
- package/es/DesktopPicker/DesktopPicker.types.js +1 -0
- package/es/DesktopPicker/index.css +39 -0
- package/es/DesktopPicker/index.d.ts +2 -0
- package/es/DesktopPicker/index.js +6 -0
- package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
- package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
- package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
- package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
- package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
- package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
- package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
- package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
- package/es/DesktopTimePicker/index.css +170 -0
- package/es/DesktopTimePicker/index.d.ts +2 -0
- package/es/DesktopTimePicker/index.js +6 -0
- package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
- package/es/DesktopTimePicker/useGetTimePickerContent.js +226 -0
- package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
- package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
- package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
- package/es/DesktopTimePicker/utils/utils.js +365 -0
- package/es/Dialog/Dialog.types.d.ts +5 -0
- package/es/Dialog/FunctionalDialog.js +14 -3
- package/es/Input/Input.css +0 -2
- package/es/Picker/Picker.css +5 -0
- package/es/Picker/Picker.js +27 -5
- package/es/Picker/Picker.types.d.ts +15 -2
- package/es/Picker/PickerPanel.css +4 -0
- package/es/Picker/PickerPanel.js +7 -6
- package/es/Popover/Popover.js +73 -29
- package/es/Portal/Portal.miniapp.js +8 -5
- package/es/ScrollView/ScrollView.js +24 -11
- package/es/ScrollView/ScrollView.types.d.ts +0 -1
- package/es/Select/Select.css +1 -4
- package/es/Select/Select.js +62 -38
- package/es/Slider/Slider.js +16 -6
- package/es/SwipeAction/SwipeAction.css +79 -0
- package/es/SwipeAction/SwipeAction.d.ts +5 -0
- package/es/SwipeAction/SwipeAction.js +334 -0
- package/es/SwipeAction/SwipeAction.types.d.ts +75 -0
- package/es/SwipeAction/SwipeAction.types.js +1 -0
- package/es/SwipeAction/SwipeActionContext.d.ts +4 -0
- package/es/SwipeAction/SwipeActionContext.js +11 -0
- package/es/SwipeAction/SwipeActionItem.css +31 -0
- package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
- package/es/SwipeAction/SwipeActionItem.js +78 -0
- package/es/SwipeAction/constants.d.ts +9 -0
- package/es/SwipeAction/constants.js +15 -0
- package/es/SwipeAction/index.d.ts +5 -0
- package/es/SwipeAction/index.js +12 -0
- package/es/TabBar/TabBarItem.js +1 -1
- package/es/Tabs/Tabs.js +29 -14
- package/es/Tabs/utils/scroll.d.ts +2 -0
- package/es/Tabs/utils/scroll.js +36 -0
- package/es/Toast/FunctionalToast.js +14 -3
- package/es/Toast/Toast.css +0 -1
- package/es/Toast/Toast.types.d.ts +5 -0
- package/es/Tooltip/Tooltip.js +73 -29
- package/es/index.d.ts +6 -0
- package/es/index.js +6 -0
- package/es/locales/base.d.ts +11 -0
- package/es/locales/en-US.js +24 -0
- package/es/locales/zh-CN.js +24 -0
- package/es/locales/zh-TW.js +24 -0
- package/package.json +5 -5
- package/dist/Tabs/utils/bound.d.ts +0 -1
- package/es/Tabs/utils/bound.d.ts +0 -1
- package/es/Tabs/utils/bound.js +0 -13
|
@@ -64,11 +64,13 @@ var import_utils = require("@bifrostui/utils");
|
|
|
64
64
|
var import_clsx = __toESM(require("clsx"));
|
|
65
65
|
var import_dayjs = __toESM(require("dayjs"));
|
|
66
66
|
var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
|
|
67
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
67
68
|
var import_react = __toESM(require("react"));
|
|
68
69
|
var import_utils2 = require("./utils");
|
|
69
70
|
var import_locales = require("../locales");
|
|
70
71
|
var import_Calendar2 = require("./Calendar.css");
|
|
71
72
|
import_dayjs.default.extend(import_isoWeek.default);
|
|
73
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
72
74
|
const classes = {
|
|
73
75
|
root: "bui-calendar",
|
|
74
76
|
handler: "bui-calendar-handler",
|
|
@@ -91,6 +93,7 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
91
93
|
headerBarRightIcon,
|
|
92
94
|
disabledDate,
|
|
93
95
|
highlightDate = "today",
|
|
96
|
+
headerVisible = false,
|
|
94
97
|
dateRender,
|
|
95
98
|
weekRender,
|
|
96
99
|
onMonthChange,
|
|
@@ -108,6 +111,7 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
108
111
|
"headerBarRightIcon",
|
|
109
112
|
"disabledDate",
|
|
110
113
|
"highlightDate",
|
|
114
|
+
"headerVisible",
|
|
111
115
|
"dateRender",
|
|
112
116
|
"weekRender",
|
|
113
117
|
"onMonthChange",
|
|
@@ -322,7 +326,7 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
322
326
|
}, others), {
|
|
323
327
|
"data-mode": mode
|
|
324
328
|
}), data),
|
|
325
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: classes.handler }, /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickPrev, className: `${classes.handler}-btn` }, headerBarIcon.left), /* @__PURE__ */ import_react.default.createElement("div", { className: `${classes.handler}-text` }, (0, import_dayjs.default)(renderMonth).format(headerBarFormat)), /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickNext, className: `${classes.handler}-btn` }, headerBarIcon.right)),
|
|
329
|
+
!headerVisible && /* @__PURE__ */ import_react.default.createElement("div", { className: classes.handler }, /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickPrev, className: `${classes.handler}-btn` }, headerBarIcon.left), /* @__PURE__ */ import_react.default.createElement("div", { className: `${classes.handler}-text` }, (0, import_dayjs.default)(renderMonth).format(headerBarFormat)), /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickNext, className: `${classes.handler}-btn` }, headerBarIcon.right)),
|
|
326
330
|
/* @__PURE__ */ import_react.default.createElement("div", { className: classes.week }, SUNDAY_WEEK_DATA == null ? void 0 : SUNDAY_WEEK_DATA.map((w) => {
|
|
327
331
|
return weekRender ? weekRender(w) : /* @__PURE__ */ import_react.default.createElement("div", { key: w, className: `${classes.week}-item` }, w);
|
|
328
332
|
})),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CollapseProps } from './Collapse.types';
|
|
3
3
|
import './Collapse.less';
|
|
4
|
-
declare const Collapse: React.ForwardRefExoticComponent<CollapseProps & React.RefAttributes<
|
|
4
|
+
declare const Collapse: React.ForwardRefExoticComponent<CollapseProps & React.RefAttributes<HTMLElement>>;
|
|
5
5
|
export default Collapse;
|
|
@@ -61,12 +61,14 @@ __export(Collapse_exports, {
|
|
|
61
61
|
module.exports = __toCommonJS(Collapse_exports);
|
|
62
62
|
var import_react = __toESM(require("react"));
|
|
63
63
|
var import_utils = require("@bifrostui/utils");
|
|
64
|
+
var import_clsx = __toESM(require("clsx"));
|
|
64
65
|
var import_Transition = require("../Transition");
|
|
65
66
|
var import_Collapse2 = require("./Collapse.css");
|
|
66
67
|
const defaultEasing = {
|
|
67
68
|
enter: import_utils.easing.easeOut,
|
|
68
69
|
exit: import_utils.easing.sharp
|
|
69
70
|
};
|
|
71
|
+
const FIT_CONTENT = "fit-content";
|
|
70
72
|
const defaultTimeout = {
|
|
71
73
|
enter: import_utils.duration.enteringScreen,
|
|
72
74
|
exit: import_utils.duration.leavingScreen
|
|
@@ -95,7 +97,6 @@ const Collapse = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
95
97
|
"className",
|
|
96
98
|
"children"
|
|
97
99
|
]);
|
|
98
|
-
const nodeRef = (0, import_utils.useForkRef)(ref);
|
|
99
100
|
const wrapperRef = (0, import_react.useRef)(null);
|
|
100
101
|
const collapseRef = (0, import_utils.useForkRef)(wrapperRef, ref);
|
|
101
102
|
const transitions = (0, import_utils.createTransitions)();
|
|
@@ -103,11 +104,11 @@ const Collapse = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
103
104
|
const collapsedSize = typeof collapsedSizeProp === "number" ? `${collapsedSizeProp}px` : collapsedSizeProp;
|
|
104
105
|
const size = isHorizontal ? "width" : "height";
|
|
105
106
|
const getCollapseWrapperSize = (reactNode) => {
|
|
106
|
-
return reactNode ? `${reactNode[isHorizontal ? "clientWidth" : "clientHeight"]}px` :
|
|
107
|
+
return reactNode ? `${reactNode[isHorizontal ? "clientWidth" : "clientHeight"]}px` : FIT_CONTENT;
|
|
107
108
|
};
|
|
108
109
|
(0, import_react.useEffect)(() => {
|
|
109
110
|
var _a2, _b, _c, _d;
|
|
110
|
-
if (appear === false && inProp === true && ((_b = (_a2 = wrapperRef.current) == null ? void 0 : _a2.style) == null ? void 0 : _b[size]) ===
|
|
111
|
+
if (appear === false && inProp === true && ((_b = (_a2 = wrapperRef.current) == null ? void 0 : _a2.style) == null ? void 0 : _b[size]) === FIT_CONTENT) {
|
|
111
112
|
wrapperRef.current.style[size] = getCollapseWrapperSize(
|
|
112
113
|
(_d = (_c = wrapperRef.current) == null ? void 0 : _c.children) == null ? void 0 : _d[0]
|
|
113
114
|
);
|
|
@@ -118,7 +119,6 @@ const Collapse = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
118
119
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
119
120
|
import_Transition.Transition,
|
|
120
121
|
__spreadProps(__spreadValues({}, other), {
|
|
121
|
-
ref: nodeRef,
|
|
122
122
|
in: inProp,
|
|
123
123
|
timeout,
|
|
124
124
|
delay,
|
|
@@ -146,14 +146,17 @@ const Collapse = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
146
146
|
};
|
|
147
147
|
return import_react.default.createElement(
|
|
148
148
|
"div",
|
|
149
|
-
{
|
|
150
|
-
className:
|
|
149
|
+
__spreadProps(__spreadValues({
|
|
150
|
+
className: (0, import_clsx.default)("bui-collapse", {
|
|
151
|
+
className
|
|
152
|
+
}),
|
|
151
153
|
style: __spreadValues(__spreadProps(__spreadValues({}, style), {
|
|
152
154
|
transition,
|
|
153
155
|
WebkitTransition: transition
|
|
154
|
-
}), wrapperSize())
|
|
156
|
+
}), wrapperSize())
|
|
157
|
+
}, childProps), {
|
|
155
158
|
ref: collapseRef
|
|
156
|
-
},
|
|
159
|
+
}),
|
|
157
160
|
import_react.default.cloneElement(children, __spreadValues({
|
|
158
161
|
style: __spreadValues({}, (_a2 = children.props) == null ? void 0 : _a2.style)
|
|
159
162
|
}, childProps))
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
49
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
50
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
51
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
52
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
53
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
54
|
+
mod
|
|
55
|
+
));
|
|
56
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
57
|
+
var Collapse_miniapp_exports = {};
|
|
58
|
+
__export(Collapse_miniapp_exports, {
|
|
59
|
+
default: () => Collapse_miniapp_default
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(Collapse_miniapp_exports);
|
|
62
|
+
var import_react = __toESM(require("react"));
|
|
63
|
+
var import_utils = require("@bifrostui/utils");
|
|
64
|
+
var import_Transition = require("../Transition");
|
|
65
|
+
var import_Collapse2 = require("./Collapse.css");
|
|
66
|
+
const defaultEasing = {
|
|
67
|
+
enter: import_utils.easing.easeOut,
|
|
68
|
+
exit: import_utils.easing.sharp
|
|
69
|
+
};
|
|
70
|
+
const defaultTimeout = {
|
|
71
|
+
enter: import_utils.duration.enteringScreen,
|
|
72
|
+
exit: import_utils.duration.leavingScreen
|
|
73
|
+
};
|
|
74
|
+
const FIT_CONTENT = "fit-content";
|
|
75
|
+
const Collapse = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
76
|
+
const _a = props, {
|
|
77
|
+
appear = false,
|
|
78
|
+
in: inProp,
|
|
79
|
+
easing: easingProp = defaultEasing,
|
|
80
|
+
direction = "vertical",
|
|
81
|
+
timeout = defaultTimeout,
|
|
82
|
+
delay = 0,
|
|
83
|
+
collapsedSize: collapsedSizeProp = 0,
|
|
84
|
+
style,
|
|
85
|
+
className,
|
|
86
|
+
children
|
|
87
|
+
} = _a, other = __objRest(_a, [
|
|
88
|
+
"appear",
|
|
89
|
+
"in",
|
|
90
|
+
"easing",
|
|
91
|
+
"direction",
|
|
92
|
+
"timeout",
|
|
93
|
+
"delay",
|
|
94
|
+
"collapsedSize",
|
|
95
|
+
"style",
|
|
96
|
+
"className",
|
|
97
|
+
"children"
|
|
98
|
+
]);
|
|
99
|
+
const wrapperRef = (0, import_react.useRef)(null);
|
|
100
|
+
const collapseRef = (0, import_utils.useForkRef)(wrapperRef, ref);
|
|
101
|
+
const [wrapperSize, setWrapperSize] = (0, import_react.useState)("");
|
|
102
|
+
const transitions = (0, import_utils.createTransitions)();
|
|
103
|
+
const isHorizontal = direction === "horizontal";
|
|
104
|
+
const collapsedSize = typeof collapsedSizeProp === "number" ? `${collapsedSizeProp}px` : collapsedSizeProp;
|
|
105
|
+
const size = isHorizontal ? "width" : "height";
|
|
106
|
+
const getCollapseWrapperSize = (reactNode) => {
|
|
107
|
+
return new Promise((resolve) => {
|
|
108
|
+
var _a2;
|
|
109
|
+
const reactNodeChild = (_a2 = reactNode == null ? void 0 : reactNode.children) == null ? void 0 : _a2[0];
|
|
110
|
+
if (!reactNodeChild) {
|
|
111
|
+
resolve(FIT_CONTENT);
|
|
112
|
+
}
|
|
113
|
+
(0, import_utils.getBoundingClientRect)(reactNodeChild).then((res) => {
|
|
114
|
+
if (!res) {
|
|
115
|
+
resolve(FIT_CONTENT);
|
|
116
|
+
setWrapperSize(FIT_CONTENT);
|
|
117
|
+
} else {
|
|
118
|
+
setWrapperSize(isHorizontal ? `${res == null ? void 0 : res.width}px` : `${res == null ? void 0 : res.height}px`);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
(0, import_react.useEffect)(() => {
|
|
124
|
+
if (appear === false && inProp === true && wrapperSize === FIT_CONTENT) {
|
|
125
|
+
getCollapseWrapperSize(wrapperRef.current).then((res) => {
|
|
126
|
+
setWrapperSize(res);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}, [appear, inProp]);
|
|
130
|
+
if (!children)
|
|
131
|
+
return null;
|
|
132
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
133
|
+
import_Transition.Transition,
|
|
134
|
+
__spreadProps(__spreadValues({}, other), {
|
|
135
|
+
in: inProp,
|
|
136
|
+
timeout,
|
|
137
|
+
delay,
|
|
138
|
+
appear
|
|
139
|
+
}),
|
|
140
|
+
(state, childProps) => {
|
|
141
|
+
var _a2;
|
|
142
|
+
const transition = transitions.create(
|
|
143
|
+
size,
|
|
144
|
+
(0, import_utils.getTransitionProps)(
|
|
145
|
+
{ timeout, style, easing: easingProp, delay },
|
|
146
|
+
{ mode: state }
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
if (state === "entering" || state === "entered") {
|
|
150
|
+
getCollapseWrapperSize(wrapperRef.current).then(
|
|
151
|
+
(res = FIT_CONTENT) => {
|
|
152
|
+
setWrapperSize(res);
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
} else {
|
|
156
|
+
setWrapperSize(collapsedSize);
|
|
157
|
+
}
|
|
158
|
+
return import_react.default.createElement(
|
|
159
|
+
"div",
|
|
160
|
+
__spreadProps(__spreadValues({
|
|
161
|
+
className: `bui-collapse ${className || ""}`,
|
|
162
|
+
style: __spreadValues(__spreadProps(__spreadValues({}, style), {
|
|
163
|
+
transition,
|
|
164
|
+
WebkitTransition: transition
|
|
165
|
+
}), isHorizontal ? { width: wrapperSize, WebKitWidth: wrapperSize } : { height: wrapperSize, WebKitHeight: wrapperSize })
|
|
166
|
+
}, childProps), {
|
|
167
|
+
ref: collapseRef
|
|
168
|
+
}),
|
|
169
|
+
import_react.default.cloneElement(children, {
|
|
170
|
+
style: __spreadValues({}, (_a2 = children.props) == null ? void 0 : _a2.style)
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
Collapse.displayName = "BuiCollapse";
|
|
177
|
+
var Collapse_miniapp_default = Collapse;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
--width: var(--bui-collapse-panel-width, 100%);
|
|
3
3
|
--header-padding: var(--bui-collapse-panel-header-padding, var(--bui-spacing-lg) 0);
|
|
4
4
|
--content-padding: var(--bui-collapse-panel-content-padding, var(--bui-spacing-lg) 0);
|
|
5
|
+
--title-font-size: var(--bui-collapse-panel-title-font-size, var(--bui-title-size-3));
|
|
6
|
+
--content-font-size: var(--bui-collapse-panel-content-font-size, var(--bui-text-size-1));
|
|
5
7
|
width: var(--width);
|
|
6
8
|
background-color: var(--bui-color-bg-view);
|
|
7
9
|
color: var(--bui-color-fg-default);
|
|
@@ -15,7 +17,7 @@
|
|
|
15
17
|
}
|
|
16
18
|
.bui-collapse-panel-item-header-label {
|
|
17
19
|
padding: var(--header-padding);
|
|
18
|
-
font-size: var(--
|
|
20
|
+
font-size: var(--title-font-size);
|
|
19
21
|
}
|
|
20
22
|
.bui-collapse-panel-item-header-icon-arrow {
|
|
21
23
|
transform: rotate(0deg);
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
}
|
|
27
29
|
.bui-collapse-panel-item-content {
|
|
28
30
|
padding: var(--content-padding);
|
|
29
|
-
font-size: var(--
|
|
31
|
+
font-size: var(--content-font-size);
|
|
30
32
|
transition: height 0.5s ease;
|
|
31
33
|
overflow: hidden;
|
|
32
34
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePickerProps } from './DatePicker.types';
|
|
3
|
+
declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps<"div", Omit<import("../Picker").PickerProps<"div", import("..").DrawerProps>, "defaultValue" | "onChange" | "value" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export default DatePicker;
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
49
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
50
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
51
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
52
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
53
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
54
|
+
mod
|
|
55
|
+
));
|
|
56
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
57
|
+
var DatePicker_exports = {};
|
|
58
|
+
__export(DatePicker_exports, {
|
|
59
|
+
default: () => DatePicker_default
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(DatePicker_exports);
|
|
62
|
+
var import_react = __toESM(require("react"));
|
|
63
|
+
var import_clsx = __toESM(require("clsx"));
|
|
64
|
+
var import_utils = require("@bifrostui/utils");
|
|
65
|
+
var import_Picker = __toESM(require("../Picker"));
|
|
66
|
+
var import_locales = require("../locales");
|
|
67
|
+
var import_constants = require("./constants");
|
|
68
|
+
const MIN_DATE = new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1);
|
|
69
|
+
const MAX_DATE = new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11, 31);
|
|
70
|
+
const DEFAULT_PICKER = [
|
|
71
|
+
import_constants.DatePickerType.YEAR,
|
|
72
|
+
import_constants.DatePickerType.MONTH,
|
|
73
|
+
import_constants.DatePickerType.DAY
|
|
74
|
+
];
|
|
75
|
+
function isValidDate(value) {
|
|
76
|
+
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
77
|
+
}
|
|
78
|
+
const padZero = (num, targetLength = 2) => {
|
|
79
|
+
let str = `${num}`;
|
|
80
|
+
while (str.length < targetLength) {
|
|
81
|
+
str = `0${str}`;
|
|
82
|
+
}
|
|
83
|
+
return str;
|
|
84
|
+
};
|
|
85
|
+
const getMaxDay = (year, monthIndex) => {
|
|
86
|
+
return new Date(year, monthIndex + 1, 0).getDate();
|
|
87
|
+
};
|
|
88
|
+
const getDateTypeValue = (date, type) => {
|
|
89
|
+
switch (type) {
|
|
90
|
+
case import_constants.DatePickerType.YEAR:
|
|
91
|
+
return date.getFullYear();
|
|
92
|
+
case import_constants.DatePickerType.MONTH:
|
|
93
|
+
return date.getMonth() + 1;
|
|
94
|
+
case import_constants.DatePickerType.DAY:
|
|
95
|
+
return date.getDate();
|
|
96
|
+
case import_constants.DatePickerType.HOUR:
|
|
97
|
+
return date.getHours();
|
|
98
|
+
case import_constants.DatePickerType.MINUTE:
|
|
99
|
+
return date.getMinutes();
|
|
100
|
+
case import_constants.DatePickerType.SECOND:
|
|
101
|
+
return date.getSeconds();
|
|
102
|
+
default:
|
|
103
|
+
throw new Error(`\u9519\u8BEF\u7684picker\u7C7B\u578B\uFF1A${type}`);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const DatePicker = (0, import_react.forwardRef)((props, ref) => {
|
|
107
|
+
const _a = props, {
|
|
108
|
+
className,
|
|
109
|
+
value: propValue,
|
|
110
|
+
defaultValue,
|
|
111
|
+
views = DEFAULT_PICKER,
|
|
112
|
+
minDate: propMinDate = MIN_DATE,
|
|
113
|
+
maxDate: propMaxDate = MAX_DATE,
|
|
114
|
+
showUnit = false,
|
|
115
|
+
formatter,
|
|
116
|
+
filter,
|
|
117
|
+
disableDateTimeView,
|
|
118
|
+
dateTimeStep,
|
|
119
|
+
onConfirm,
|
|
120
|
+
onClose,
|
|
121
|
+
onChange
|
|
122
|
+
} = _a, others = __objRest(_a, [
|
|
123
|
+
"className",
|
|
124
|
+
"value",
|
|
125
|
+
"defaultValue",
|
|
126
|
+
"views",
|
|
127
|
+
"minDate",
|
|
128
|
+
"maxDate",
|
|
129
|
+
"showUnit",
|
|
130
|
+
"formatter",
|
|
131
|
+
"filter",
|
|
132
|
+
"disableDateTimeView",
|
|
133
|
+
"dateTimeStep",
|
|
134
|
+
"onConfirm",
|
|
135
|
+
"onClose",
|
|
136
|
+
"onChange"
|
|
137
|
+
]);
|
|
138
|
+
const [options, setOptions] = (0, import_react.useState)([]);
|
|
139
|
+
const [pickerValue, setPickerValue] = (0, import_react.useState)([]);
|
|
140
|
+
const datePickerText = (0, import_locales.useLocaleText)("datePicker");
|
|
141
|
+
const formatDate = (date) => {
|
|
142
|
+
let formattedDate = date;
|
|
143
|
+
if (!formattedDate || !isValidDate(date) || formattedDate.getTime() < propMinDate.getTime()) {
|
|
144
|
+
formattedDate = propMinDate;
|
|
145
|
+
}
|
|
146
|
+
if (formattedDate.getTime() > propMaxDate.getTime()) {
|
|
147
|
+
formattedDate = propMaxDate;
|
|
148
|
+
}
|
|
149
|
+
return formattedDate;
|
|
150
|
+
};
|
|
151
|
+
const [currentDate, triggerChange] = (0, import_utils.useValue)({
|
|
152
|
+
value: propValue && formatDate(propValue),
|
|
153
|
+
defaultValue: formatDate(defaultValue)
|
|
154
|
+
});
|
|
155
|
+
const handleConfirm = (e) => {
|
|
156
|
+
onConfirm == null ? void 0 : onConfirm(e, { value: currentDate });
|
|
157
|
+
};
|
|
158
|
+
const handleClose = (e) => {
|
|
159
|
+
onClose == null ? void 0 : onClose(e, { value: currentDate });
|
|
160
|
+
};
|
|
161
|
+
const handleChange = (e, { value, columnIndex }) => {
|
|
162
|
+
if (value[columnIndex] === null)
|
|
163
|
+
return;
|
|
164
|
+
const current = new Date(currentDate);
|
|
165
|
+
switch (views[columnIndex]) {
|
|
166
|
+
case import_constants.DatePickerType.YEAR:
|
|
167
|
+
current.setFullYear(value[columnIndex]);
|
|
168
|
+
break;
|
|
169
|
+
case import_constants.DatePickerType.MONTH: {
|
|
170
|
+
const selectedMaxDay = getMaxDay(
|
|
171
|
+
current.getFullYear(),
|
|
172
|
+
Number(value[columnIndex]) - 1
|
|
173
|
+
);
|
|
174
|
+
if (current.getDate() > selectedMaxDay) {
|
|
175
|
+
current.setDate(selectedMaxDay);
|
|
176
|
+
}
|
|
177
|
+
current.setMonth(value[columnIndex] - 1);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case import_constants.DatePickerType.DAY:
|
|
181
|
+
current.setDate(value[columnIndex]);
|
|
182
|
+
break;
|
|
183
|
+
case import_constants.DatePickerType.HOUR:
|
|
184
|
+
current.setHours(value[columnIndex]);
|
|
185
|
+
break;
|
|
186
|
+
case import_constants.DatePickerType.MINUTE:
|
|
187
|
+
current.setMinutes(value[columnIndex]);
|
|
188
|
+
break;
|
|
189
|
+
case import_constants.DatePickerType.SECOND:
|
|
190
|
+
current.setSeconds(value[columnIndex]);
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
throw new Error(`\u9519\u8BEF\u7684picker\u7C7B\u578B\uFF1A${views[columnIndex]}`);
|
|
194
|
+
}
|
|
195
|
+
triggerChange(e, formatDate(current));
|
|
196
|
+
onChange == null ? void 0 : onChange(e, { type: views[columnIndex], value: current });
|
|
197
|
+
};
|
|
198
|
+
const formatOption = (type, value) => {
|
|
199
|
+
let label = padZero(value);
|
|
200
|
+
if (formatter) {
|
|
201
|
+
return formatter(type, {
|
|
202
|
+
value,
|
|
203
|
+
label
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (showUnit) {
|
|
207
|
+
label += datePickerText[type];
|
|
208
|
+
}
|
|
209
|
+
return { value, label };
|
|
210
|
+
};
|
|
211
|
+
const generateOptions = (min, max, type, columnIndex) => {
|
|
212
|
+
const step = (dateTimeStep == null ? void 0 : dateTimeStep[type]) || 1;
|
|
213
|
+
let valueIndex = 0;
|
|
214
|
+
const optionsArray = Array.from(
|
|
215
|
+
{ length: (max - min + 1) / step || 1 },
|
|
216
|
+
(_, index) => {
|
|
217
|
+
const value = index * step + min;
|
|
218
|
+
if (value <= getDateTypeValue(currentDate, type)) {
|
|
219
|
+
valueIndex = index;
|
|
220
|
+
}
|
|
221
|
+
return formatOption(type, value);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
pickerValue[columnIndex] = optionsArray[valueIndex].value;
|
|
225
|
+
setPickerValue([...pickerValue]);
|
|
226
|
+
if ((disableDateTimeView == null ? void 0 : disableDateTimeView[type]) && typeof disableDateTimeView[type] === "function") {
|
|
227
|
+
const disabledOptionsValue = disableDateTimeView[type](
|
|
228
|
+
optionsArray.map((i) => i.value)
|
|
229
|
+
);
|
|
230
|
+
return optionsArray.map((option) => {
|
|
231
|
+
if (disabledOptionsValue.includes(option.value)) {
|
|
232
|
+
return __spreadProps(__spreadValues({}, option), {
|
|
233
|
+
disabled: true
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return option;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (filter) {
|
|
240
|
+
return filter(type, optionsArray);
|
|
241
|
+
}
|
|
242
|
+
return optionsArray;
|
|
243
|
+
};
|
|
244
|
+
const getBoundary = (type, value) => {
|
|
245
|
+
const boundary = type === "min" ? propMinDate : propMaxDate;
|
|
246
|
+
const year = boundary.getFullYear();
|
|
247
|
+
let month = 1;
|
|
248
|
+
let date = 1;
|
|
249
|
+
let hour = 0;
|
|
250
|
+
let minute = 0;
|
|
251
|
+
let seconds = 0;
|
|
252
|
+
if (type === "max") {
|
|
253
|
+
month = 12;
|
|
254
|
+
date = getMaxDay(value.getFullYear(), value.getMonth());
|
|
255
|
+
hour = 23;
|
|
256
|
+
minute = 59;
|
|
257
|
+
seconds = 59;
|
|
258
|
+
}
|
|
259
|
+
if (value.getFullYear() === year) {
|
|
260
|
+
month = boundary.getMonth() + 1;
|
|
261
|
+
if (value.getMonth() + 1 === month) {
|
|
262
|
+
date = boundary.getDate();
|
|
263
|
+
if (value.getDate() === date) {
|
|
264
|
+
hour = boundary.getHours();
|
|
265
|
+
if (value.getHours() === hour) {
|
|
266
|
+
minute = boundary.getMinutes();
|
|
267
|
+
if (value.getMinutes() === minute) {
|
|
268
|
+
seconds = boundary.getSeconds();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
[`${type}Year`]: year,
|
|
276
|
+
[`${type}Month`]: month,
|
|
277
|
+
[`${type}Date`]: date,
|
|
278
|
+
[`${type}Hour`]: hour,
|
|
279
|
+
[`${type}Minute`]: minute,
|
|
280
|
+
[`${type}Seconds`]: seconds
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const generateRanges = () => {
|
|
284
|
+
const ranges = [];
|
|
285
|
+
const { minYear, minMonth, minDate, minHour, minMinute, minSeconds } = getBoundary("min", currentDate);
|
|
286
|
+
const { maxYear, maxMonth, maxDate, maxHour, maxMinute, maxSeconds } = getBoundary("max", currentDate);
|
|
287
|
+
for (let i = 0; i < views.length; i += 1) {
|
|
288
|
+
const type = views[i];
|
|
289
|
+
switch (type) {
|
|
290
|
+
case import_constants.DatePickerType.YEAR:
|
|
291
|
+
ranges.push([minYear, maxYear]);
|
|
292
|
+
break;
|
|
293
|
+
case import_constants.DatePickerType.MONTH:
|
|
294
|
+
ranges.push([minMonth, maxMonth]);
|
|
295
|
+
break;
|
|
296
|
+
case import_constants.DatePickerType.DAY:
|
|
297
|
+
ranges.push([minDate, maxDate]);
|
|
298
|
+
break;
|
|
299
|
+
case import_constants.DatePickerType.HOUR:
|
|
300
|
+
ranges.push([minHour, maxHour]);
|
|
301
|
+
break;
|
|
302
|
+
case import_constants.DatePickerType.MINUTE:
|
|
303
|
+
ranges.push([minMinute, maxMinute]);
|
|
304
|
+
break;
|
|
305
|
+
case import_constants.DatePickerType.SECOND:
|
|
306
|
+
ranges.push([minSeconds, maxSeconds]);
|
|
307
|
+
break;
|
|
308
|
+
default:
|
|
309
|
+
throw new Error(`\u9519\u8BEF\u7684picker\u7C7B\u578B\uFF1A${type}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return ranges;
|
|
313
|
+
};
|
|
314
|
+
const generateRangeOptions = () => generateRanges().map(
|
|
315
|
+
(range, index) => generateOptions(range[0], range[1], views[index], index)
|
|
316
|
+
);
|
|
317
|
+
(0, import_react.useEffect)(() => {
|
|
318
|
+
setOptions(generateRangeOptions());
|
|
319
|
+
}, [currentDate, views, propMinDate, propMaxDate]);
|
|
320
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
321
|
+
import_Picker.default,
|
|
322
|
+
__spreadProps(__spreadValues({}, others), {
|
|
323
|
+
"data-selected": currentDate ? currentDate.getTime() : "",
|
|
324
|
+
className: (0, import_clsx.default)("bui-date-picker", className),
|
|
325
|
+
ref,
|
|
326
|
+
options,
|
|
327
|
+
value: pickerValue,
|
|
328
|
+
onConfirm: handleConfirm,
|
|
329
|
+
onClose: handleClose,
|
|
330
|
+
onOptionChange: handleChange
|
|
331
|
+
})
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
DatePicker.displayName = "BuiDatePicker";
|
|
335
|
+
var DatePicker_default = DatePicker;
|