@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
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { Ref } from 'react';
|
|
2
|
+
import { OverrideProps } from '@bifrostui/types';
|
|
3
|
+
import { DesktopPickerProps } from '../DesktopPicker';
|
|
4
|
+
import { CalendarProps } from '../Calendar';
|
|
5
|
+
export type IDateTimePickerValue = Date | null;
|
|
6
|
+
export interface IDateTimePickerInstance {
|
|
7
|
+
/** 日期对象 */
|
|
8
|
+
day: Date;
|
|
9
|
+
/** 是否禁用 */
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface IDateTimePickerCustomIconProps {
|
|
13
|
+
/**
|
|
14
|
+
* 是否是最小时间
|
|
15
|
+
*/
|
|
16
|
+
isMinMonth?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 是否是最大时间
|
|
19
|
+
*/
|
|
20
|
+
isMaxMonth?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface IDateTimePickerCalendarProps {
|
|
23
|
+
/**
|
|
24
|
+
* 是否隐藏当前月之外的日期,默认为false
|
|
25
|
+
*/
|
|
26
|
+
hideDaysOutsideCurrentMonth?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 高亮的日期,默认为today
|
|
29
|
+
* today 若选中的非当天,则当天高亮显示,若选中的是当天,则当天展示选中态
|
|
30
|
+
* weekend 可选的周末高亮显示
|
|
31
|
+
*/
|
|
32
|
+
highlightDate?: 'today' | 'weekend';
|
|
33
|
+
/**
|
|
34
|
+
* 自定义日期单元格的内容
|
|
35
|
+
*/
|
|
36
|
+
dateRender?: (currentDate: IDateTimePickerInstance) => React.ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* 自定义周单元格的内容
|
|
39
|
+
*/
|
|
40
|
+
weekRender?: (week: string) => React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
export type DateTimePickerProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
|
|
43
|
+
props: P & {
|
|
44
|
+
/**
|
|
45
|
+
* 默认选中的值,当组件非受控时使用
|
|
46
|
+
*/
|
|
47
|
+
defaultValue?: IDateTimePickerValue;
|
|
48
|
+
/**
|
|
49
|
+
* 选中的值,当组件受控时使用
|
|
50
|
+
*/
|
|
51
|
+
value?: IDateTimePickerValue;
|
|
52
|
+
/**
|
|
53
|
+
* 输入框占位内容
|
|
54
|
+
*/
|
|
55
|
+
placeholder?: string;
|
|
56
|
+
/**
|
|
57
|
+
* 可选择的最小日期,默认为当前日期
|
|
58
|
+
* 渲染指定月时:value=null并指定minDate
|
|
59
|
+
*/
|
|
60
|
+
minDate?: Date;
|
|
61
|
+
/**
|
|
62
|
+
* 可选择的最大日期,默认为当前日期的一年后
|
|
63
|
+
*/
|
|
64
|
+
maxDate?: Date;
|
|
65
|
+
/**
|
|
66
|
+
* 弹层是否打开
|
|
67
|
+
*/
|
|
68
|
+
open?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* 输入框icon
|
|
71
|
+
*/
|
|
72
|
+
icon?: React.ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* inputRef
|
|
75
|
+
*/
|
|
76
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
77
|
+
/**
|
|
78
|
+
* inputProp
|
|
79
|
+
*/
|
|
80
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
81
|
+
/**
|
|
82
|
+
* 选择器类型
|
|
83
|
+
*/
|
|
84
|
+
views?: Array<'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'>;
|
|
85
|
+
/**
|
|
86
|
+
* 头部操作栏左边图标
|
|
87
|
+
*/
|
|
88
|
+
headerBarLeftIcon?: (options: IDateTimePickerCustomIconProps) => React.ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* 头部操作栏右边图标
|
|
91
|
+
*/
|
|
92
|
+
headerBarRightIcon?: (options: IDateTimePickerCustomIconProps) => React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* 是否禁用日期选择器
|
|
95
|
+
*/
|
|
96
|
+
disabled?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 不可选择的日期
|
|
99
|
+
*/
|
|
100
|
+
disabledDate?: (currentDate: Date) => boolean;
|
|
101
|
+
/**
|
|
102
|
+
* 自定义月份单元格的内容
|
|
103
|
+
*/
|
|
104
|
+
monthRender?: ({ month, currentDate, }: {
|
|
105
|
+
month: string | number;
|
|
106
|
+
currentDate: IDateTimePickerInstance;
|
|
107
|
+
}) => React.ReactNode;
|
|
108
|
+
/**
|
|
109
|
+
* 自定义年份单元格的内容
|
|
110
|
+
*/
|
|
111
|
+
yearRender?: ({ year, currentDate, }: {
|
|
112
|
+
year: string | number;
|
|
113
|
+
currentDate: IDateTimePickerInstance;
|
|
114
|
+
}) => React.ReactNode;
|
|
115
|
+
/**
|
|
116
|
+
* 日期发生变化的回调
|
|
117
|
+
*/
|
|
118
|
+
onChange?: (e: React.SyntheticEvent, data: {
|
|
119
|
+
value: IDateTimePickerValue;
|
|
120
|
+
}) => void;
|
|
121
|
+
/**
|
|
122
|
+
* 选择日期后是否立刻关闭
|
|
123
|
+
*/
|
|
124
|
+
closeOnSelect?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* 禁用弹层选择功能
|
|
127
|
+
*/
|
|
128
|
+
disableOpenPicker?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* 日期格式化
|
|
131
|
+
*/
|
|
132
|
+
format?: string;
|
|
133
|
+
/**
|
|
134
|
+
* 弹层关闭的回调
|
|
135
|
+
*/
|
|
136
|
+
onClose?: () => void;
|
|
137
|
+
/**
|
|
138
|
+
* 弹层打开的回调
|
|
139
|
+
*/
|
|
140
|
+
onOpen?: () => void;
|
|
141
|
+
/**
|
|
142
|
+
* 月份切换的回调
|
|
143
|
+
*/
|
|
144
|
+
onMonthChange?: (e: React.SyntheticEvent, data: {
|
|
145
|
+
value: Date;
|
|
146
|
+
}) => void;
|
|
147
|
+
/**
|
|
148
|
+
* 年份切换的回调
|
|
149
|
+
*/
|
|
150
|
+
onYearChange?: (e: React.SyntheticEvent, data: {
|
|
151
|
+
value: Date;
|
|
152
|
+
}) => void;
|
|
153
|
+
/**
|
|
154
|
+
* DesktopPickerProps
|
|
155
|
+
*/
|
|
156
|
+
DesktopPickerProps?: Omit<DesktopPickerProps, 'open'>;
|
|
157
|
+
/**
|
|
158
|
+
* CalendarProps
|
|
159
|
+
*/
|
|
160
|
+
CalendarProps?: CalendarProps;
|
|
161
|
+
};
|
|
162
|
+
defaultComponent: D;
|
|
163
|
+
}, D>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
:root,
|
|
2
|
+
page,
|
|
3
|
+
xhs-page {
|
|
4
|
+
--bui-datetime-picker-height: var(--bui-input-height, 32px);
|
|
5
|
+
--bui-datetime-picker-min-width: var(--bui-input-min-width, 100px);
|
|
6
|
+
--bui-datetime-picker-icon-size: var(--bui-title-size-3, 16px);
|
|
7
|
+
--bui-datetime-picker-font-size: var(--bui-title-size-3, 16px);
|
|
8
|
+
--bui-datetime-picker-container-padding: var(--bui-spacing-md, 9px);
|
|
9
|
+
--bui-datetime-picker-bg: var(--bui-color-bg-view);
|
|
10
|
+
--bui-datetime-picker-font-family: var(--bui-font-family);
|
|
11
|
+
--bui-datetime-picker-border: 1px solid var(--bui-color-border-default);
|
|
12
|
+
--bui-datetime-picker-shadow: 0 0 0 2px var(--bui-color-bg-default);
|
|
13
|
+
--bui-datetime-picker-disabled-color: var(--bui-color-fg-subtle);
|
|
14
|
+
}
|
|
15
|
+
.bui-datetime-picker {
|
|
16
|
+
position: relative;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
height: var(--bui-datetime-picker-height);
|
|
19
|
+
min-width: 100px;
|
|
20
|
+
font-size: var(--bui-datetime-picker-font-size);
|
|
21
|
+
border-radius: 5px;
|
|
22
|
+
background-color: var(--bui-datetime-picker-bg);
|
|
23
|
+
font-family: var(--bui-datetime-picker-font-family);
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
border: var(--bui-datetime-picker-border);
|
|
26
|
+
}
|
|
27
|
+
.bui-datetime-picker:active,
|
|
28
|
+
.bui-datetime-picker-active {
|
|
29
|
+
box-shadow: var(--bui-datetime-picker-shadow);
|
|
30
|
+
}
|
|
31
|
+
.bui-datetime-picker-invalid {
|
|
32
|
+
border: 1px solid var(--bui-color-danger);
|
|
33
|
+
}
|
|
34
|
+
.bui-datetime-picker-icon {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
font-size: var(--bui-datetime-picker-icon-size);
|
|
38
|
+
}
|
|
39
|
+
.bui-datetime-picker-container {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
padding: 0 10px;
|
|
43
|
+
height: 100%;
|
|
44
|
+
}
|
|
45
|
+
.bui-datetime-picker-input {
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: space-between;
|
|
48
|
+
align-items: center;
|
|
49
|
+
flex: 1;
|
|
50
|
+
height: 100%;
|
|
51
|
+
background-color: transparent;
|
|
52
|
+
outline: none;
|
|
53
|
+
border: 0;
|
|
54
|
+
}
|
|
55
|
+
.bui-datetime-picker-box {
|
|
56
|
+
display: flex;
|
|
57
|
+
width: 420px;
|
|
58
|
+
}
|
|
59
|
+
.bui-datetime-picker.bui-datetime-picker-disabled {
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
box-shadow: none;
|
|
62
|
+
background-color: rgba(188, 188, 188, 0.2);
|
|
63
|
+
}
|
|
64
|
+
.bui-datetime-picker.bui-datetime-picker-disabled input {
|
|
65
|
+
color: var(--bui-datetime-picker-disabled-color);
|
|
66
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DesktopPickerProps } from './DesktopPicker.types';
|
|
3
|
+
import './index.less';
|
|
4
|
+
declare const DesktopPicker: React.ForwardRefExoticComponent<Omit<DesktopPickerProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default DesktopPicker;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
import clsx from "clsx";
|
|
53
|
+
import React, {
|
|
54
|
+
useEffect,
|
|
55
|
+
useMemo,
|
|
56
|
+
useRef,
|
|
57
|
+
useState
|
|
58
|
+
} from "react";
|
|
59
|
+
import {
|
|
60
|
+
getStylesAndLocation,
|
|
61
|
+
isMini,
|
|
62
|
+
getRootContainer,
|
|
63
|
+
useDidMountEffect
|
|
64
|
+
} from "@bifrostui/utils";
|
|
65
|
+
import Backdrop from "../Backdrop";
|
|
66
|
+
import Portal from "../Portal";
|
|
67
|
+
import calcAfterMounted from "./utils/calcAfterMounted";
|
|
68
|
+
import "./index.css";
|
|
69
|
+
const prefixCls = "bui-desktop-picker";
|
|
70
|
+
const directionMap = {
|
|
71
|
+
bottom: "top",
|
|
72
|
+
top: "bottom"
|
|
73
|
+
};
|
|
74
|
+
const DesktopPicker = /* @__PURE__ */ React.forwardRef(
|
|
75
|
+
(props, ref) => {
|
|
76
|
+
const _a = props, {
|
|
77
|
+
className,
|
|
78
|
+
open,
|
|
79
|
+
container,
|
|
80
|
+
children,
|
|
81
|
+
defaultDirection = "bottom",
|
|
82
|
+
inheritWidth = true,
|
|
83
|
+
content,
|
|
84
|
+
miniBackdropInvisible = false,
|
|
85
|
+
onClose,
|
|
86
|
+
onMount,
|
|
87
|
+
onUnmounted,
|
|
88
|
+
containerWidth = "auto",
|
|
89
|
+
BackdropProps,
|
|
90
|
+
prefix = ""
|
|
91
|
+
} = _a, others = __objRest(_a, [
|
|
92
|
+
"className",
|
|
93
|
+
"open",
|
|
94
|
+
"container",
|
|
95
|
+
"children",
|
|
96
|
+
"defaultDirection",
|
|
97
|
+
"inheritWidth",
|
|
98
|
+
"content",
|
|
99
|
+
"miniBackdropInvisible",
|
|
100
|
+
"onClose",
|
|
101
|
+
"onMount",
|
|
102
|
+
"onUnmounted",
|
|
103
|
+
"containerWidth",
|
|
104
|
+
"BackdropProps",
|
|
105
|
+
"prefix"
|
|
106
|
+
]);
|
|
107
|
+
const contentRef = useRef(null);
|
|
108
|
+
const nodeRef = useRef(null);
|
|
109
|
+
const renderChildren = React.cloneElement(children, {
|
|
110
|
+
ref: nodeRef,
|
|
111
|
+
style: {
|
|
112
|
+
flex: 1
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const [contentPosition, setContentPosition] = useState(
|
|
116
|
+
"bottom"
|
|
117
|
+
);
|
|
118
|
+
const [transform, setTransform] = useState(false);
|
|
119
|
+
const getContentDirection = () => __async(void 0, null, function* () {
|
|
120
|
+
const curScrollRoot = getRootContainer(container);
|
|
121
|
+
const result = yield getStylesAndLocation({
|
|
122
|
+
scrollRoot: container && curScrollRoot,
|
|
123
|
+
childrenRef: nodeRef,
|
|
124
|
+
arrowDirection: defaultDirection,
|
|
125
|
+
arrowLocation: "none",
|
|
126
|
+
offsetSpacing: 0,
|
|
127
|
+
tipRef: contentRef
|
|
128
|
+
});
|
|
129
|
+
if (!result)
|
|
130
|
+
return;
|
|
131
|
+
const { newArrowDirection, styles, childrenStyle } = result;
|
|
132
|
+
const element = contentRef.current;
|
|
133
|
+
element.style.transform = styles == null ? void 0 : styles.transform;
|
|
134
|
+
element.style.visibility = styles == null ? void 0 : styles.visibility;
|
|
135
|
+
element.style.top = styles == null ? void 0 : styles.top;
|
|
136
|
+
element.style.left = styles == null ? void 0 : styles.left;
|
|
137
|
+
if (inheritWidth) {
|
|
138
|
+
element.style.width = childrenStyle == null ? void 0 : childrenStyle.width;
|
|
139
|
+
}
|
|
140
|
+
setContentPosition(newArrowDirection);
|
|
141
|
+
});
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!isMini && open) {
|
|
144
|
+
const addEventListenerClick = (e) => {
|
|
145
|
+
var _a2;
|
|
146
|
+
if (!((_a2 = nodeRef.current) == null ? void 0 : _a2.contains(e.target))) {
|
|
147
|
+
onClose(null, { value: !open });
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
getContentDirection();
|
|
151
|
+
const containerDom = getRootContainer(container, window);
|
|
152
|
+
containerDom.addEventListener("scroll", getContentDirection);
|
|
153
|
+
window.addEventListener("resize", getContentDirection);
|
|
154
|
+
window.addEventListener("click", addEventListenerClick);
|
|
155
|
+
return () => {
|
|
156
|
+
containerDom.removeEventListener("scroll", getContentDirection);
|
|
157
|
+
window.removeEventListener("resize", getContentDirection);
|
|
158
|
+
window.removeEventListener("click", addEventListenerClick);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (isMini && open) {
|
|
162
|
+
calcAfterMounted(getContentDirection);
|
|
163
|
+
}
|
|
164
|
+
}, [container, open]);
|
|
165
|
+
const renderContent = () => {
|
|
166
|
+
return /* @__PURE__ */ React.createElement(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
className: clsx(
|
|
170
|
+
`${prefixCls}-container`,
|
|
171
|
+
`${prefixCls}-${contentPosition}`
|
|
172
|
+
),
|
|
173
|
+
style: {
|
|
174
|
+
width: containerWidth
|
|
175
|
+
},
|
|
176
|
+
ref: contentRef
|
|
177
|
+
},
|
|
178
|
+
/* @__PURE__ */ React.createElement(
|
|
179
|
+
"div",
|
|
180
|
+
{
|
|
181
|
+
className: `${prefixCls}-container-${transform && open ? "open" : "close"} ${prefixCls}-container-content`,
|
|
182
|
+
style: {
|
|
183
|
+
transformOrigin: `${directionMap[contentPosition]} center`
|
|
184
|
+
},
|
|
185
|
+
onTransitionEnd: () => {
|
|
186
|
+
if (!open) {
|
|
187
|
+
setTransform(false);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
content
|
|
192
|
+
)
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
if (open) {
|
|
197
|
+
calcAfterMounted(() => {
|
|
198
|
+
setTransform(true);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, [open]);
|
|
202
|
+
const renderContainer = useMemo(() => {
|
|
203
|
+
return open || transform;
|
|
204
|
+
}, [open, transform]);
|
|
205
|
+
useDidMountEffect(() => {
|
|
206
|
+
if (!renderContainer) {
|
|
207
|
+
onUnmounted == null ? void 0 : onUnmounted();
|
|
208
|
+
} else {
|
|
209
|
+
onMount == null ? void 0 : onMount();
|
|
210
|
+
}
|
|
211
|
+
}, [renderContainer]);
|
|
212
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), prefix, renderChildren), !isMini && renderContainer && /* @__PURE__ */ React.createElement(Portal, null, renderContent()), isMini && renderContainer && /* @__PURE__ */ React.createElement(Portal, null, renderContent(), !miniBackdropInvisible && /* @__PURE__ */ React.createElement(
|
|
213
|
+
Backdrop,
|
|
214
|
+
__spreadProps(__spreadValues({}, BackdropProps), {
|
|
215
|
+
invisible: true,
|
|
216
|
+
open,
|
|
217
|
+
onClick: (e) => onClose(e, { value: !open })
|
|
218
|
+
})
|
|
219
|
+
)));
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
DesktopPicker.displayName = "BUIDesktopPicker";
|
|
223
|
+
var DesktopPicker_default = DesktopPicker;
|
|
224
|
+
export {
|
|
225
|
+
DesktopPicker_default as default
|
|
226
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OverrideProps } from '@bifrostui/types';
|
|
3
|
+
import { BackdropProps } from '../Backdrop/Backdrop.types';
|
|
4
|
+
export type DesktopPickerProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
|
|
5
|
+
props: P & {
|
|
6
|
+
/**
|
|
7
|
+
* 前缀
|
|
8
|
+
*/
|
|
9
|
+
prefix?: React.ReactNode | string;
|
|
10
|
+
/**
|
|
11
|
+
* 是否继承宽度
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
inheritWidth?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 是否打开
|
|
17
|
+
*/
|
|
18
|
+
open: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 浮层的内容
|
|
21
|
+
*/
|
|
22
|
+
content?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* 浮层宽度
|
|
25
|
+
*/
|
|
26
|
+
containerWidth?: number;
|
|
27
|
+
/**
|
|
28
|
+
* 是否指定滚动容器
|
|
29
|
+
*/
|
|
30
|
+
container?: HTMLElement | (() => HTMLElement);
|
|
31
|
+
/**
|
|
32
|
+
* 小程序是否使用backdrop
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
miniBackdropInvisible?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 关闭浮层
|
|
38
|
+
*/
|
|
39
|
+
onClose?: (e: React.MouseEvent<any>, data: {
|
|
40
|
+
value: boolean;
|
|
41
|
+
}) => void;
|
|
42
|
+
/**
|
|
43
|
+
* 打开后动画开始的回调
|
|
44
|
+
*/
|
|
45
|
+
onMount?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* 卸载后动画结束的回调
|
|
48
|
+
*/
|
|
49
|
+
onUnmounted?: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* 默认的浮层位置
|
|
52
|
+
* @default bottom
|
|
53
|
+
*/
|
|
54
|
+
defaultDirection?: 'top' | 'bottom';
|
|
55
|
+
/**
|
|
56
|
+
* 透传浮层的Props
|
|
57
|
+
*/
|
|
58
|
+
BackdropProps?: BackdropProps;
|
|
59
|
+
};
|
|
60
|
+
defaultComponent: D;
|
|
61
|
+
}, D>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
:root,
|
|
2
|
+
page,
|
|
3
|
+
xhs-page {
|
|
4
|
+
--bui-desktop-picker-zindex: var(--bui-z-index-tooltip);
|
|
5
|
+
--bui-desktop-picker-bg: var(--bui-color-bg-view);
|
|
6
|
+
--bui-desktop-picker-shadow: 0 0 0 2px var(--bui-color-bg-default);
|
|
7
|
+
}
|
|
8
|
+
.bui-desktop-picker {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
position: relative;
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
.bui-desktop-picker-container {
|
|
15
|
+
position: absolute;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
visibility: hidden;
|
|
18
|
+
z-index: var(--bui-desktop-picker-zindex);
|
|
19
|
+
}
|
|
20
|
+
.bui-desktop-picker-container-content {
|
|
21
|
+
border-radius: 3px;
|
|
22
|
+
background-color: var(--bui-desktop-picker-bg);
|
|
23
|
+
box-shadow: var(--bui-desktop-picker-shadow);
|
|
24
|
+
}
|
|
25
|
+
.bui-desktop-picker-container-open {
|
|
26
|
+
transform: none;
|
|
27
|
+
transition: opacity 321ms cubic-bezier(0.4, 0, 0.2, 1), transform 214ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
28
|
+
}
|
|
29
|
+
.bui-desktop-picker-container-close {
|
|
30
|
+
opacity: 0;
|
|
31
|
+
transform: scale(0.75, 0.5625);
|
|
32
|
+
transition: opacity 321ms cubic-bezier(0.4, 0, 0.2, 1), transform 214ms cubic-bezier(0.4, 0, 0.2, 1) 107ms;
|
|
33
|
+
}
|
|
34
|
+
.bui-desktop-picker-top {
|
|
35
|
+
margin-top: -6px;
|
|
36
|
+
}
|
|
37
|
+
.bui-desktop-picker-bottom {
|
|
38
|
+
margin-top: 6px;
|
|
39
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TimePickerProps } from './DesktopTimePicker.types';
|
|
3
|
+
import './index.less';
|
|
4
|
+
declare const DesktopTimePicker: React.ForwardRefExoticComponent<Omit<TimePickerProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default DesktopTimePicker;
|