@bifrostui/react 2.0.0-beta.10 → 2.0.0-beta.11
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/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/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,408 @@
|
|
|
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
|
+
var utils_exports = {};
|
|
29
|
+
__export(utils_exports, {
|
|
30
|
+
calculateValidMinTime: () => calculateValidMinTime,
|
|
31
|
+
dateToDayjs: () => dateToDayjs,
|
|
32
|
+
getIsRangeDate: () => getIsRangeDate,
|
|
33
|
+
getIsRangeTime: () => getIsRangeTime,
|
|
34
|
+
getOutOfMaxRangeMinutes: () => getOutOfMaxRangeMinutes,
|
|
35
|
+
getOutOfMaxRangeSeconds: () => getOutOfMaxRangeSeconds,
|
|
36
|
+
getOutOfMinRangeMinutes: () => getOutOfMinRangeMinutes,
|
|
37
|
+
getOutOfMinRangeSeconds: () => getOutOfMinRangeSeconds,
|
|
38
|
+
getdisabledTime: () => getdisabledTime,
|
|
39
|
+
isDisabledTime: () => isDisabledTime,
|
|
40
|
+
isDisabledViewTime: () => isDisabledViewTime
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(utils_exports);
|
|
43
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
44
|
+
const getIsRangeDate = (time, start, end) => {
|
|
45
|
+
if (!time)
|
|
46
|
+
return true;
|
|
47
|
+
if (!start && !end) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (start && end) {
|
|
51
|
+
return !time.isBefore(start, "day") && !time.isAfter(end, "day");
|
|
52
|
+
}
|
|
53
|
+
if (start) {
|
|
54
|
+
return !time.isBefore(start, "day") && (end ? !time.isAfter(end, "day") : true);
|
|
55
|
+
}
|
|
56
|
+
if (end) {
|
|
57
|
+
return !time.isAfter(end, "day") && (start ? !time.isBefore(start, "day") : true);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
};
|
|
61
|
+
const isDisabledViewTime = (time, disabledTimeView) => {
|
|
62
|
+
const isDisabledViewTimeItem = (type) => {
|
|
63
|
+
const disabledArr = disabledTimeView == null ? void 0 : disabledTimeView()[type](time.hour(), time.minute());
|
|
64
|
+
const value = time[type]();
|
|
65
|
+
return (disabledArr == null ? void 0 : disabledArr.indexOf(value)) !== -1;
|
|
66
|
+
};
|
|
67
|
+
return isDisabledViewTimeItem("hour") || isDisabledViewTimeItem("minute") || isDisabledViewTimeItem("second");
|
|
68
|
+
};
|
|
69
|
+
const getIsRangeTime = (time, start, end) => {
|
|
70
|
+
if (start && end) {
|
|
71
|
+
return !time.isBefore(start, "second") && !time.isAfter(end, "second");
|
|
72
|
+
}
|
|
73
|
+
if (start) {
|
|
74
|
+
return !time.isBefore(start, "second");
|
|
75
|
+
}
|
|
76
|
+
if (end) {
|
|
77
|
+
return !time.isAfter(end, "second");
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
81
|
+
const isDisabledTime = (time, start, end, disabledTimeView) => {
|
|
82
|
+
if (!time)
|
|
83
|
+
return false;
|
|
84
|
+
return isDisabledViewTime(time, disabledTimeView) || !getIsRangeTime(time, start, end);
|
|
85
|
+
};
|
|
86
|
+
const getOutOfMinRangeMinutes = (hourValue, minTime, dataList) => {
|
|
87
|
+
if (!minTime) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
const outOfMinRangeMinutes = [];
|
|
91
|
+
if (hourValue === minTime.hour()) {
|
|
92
|
+
outOfMinRangeMinutes.push(
|
|
93
|
+
...dataList.map((item) => item.value).filter((minute) => minute < minTime.minute())
|
|
94
|
+
);
|
|
95
|
+
} else if (hourValue < minTime.hour()) {
|
|
96
|
+
outOfMinRangeMinutes.push(...dataList.map((item) => item.value));
|
|
97
|
+
}
|
|
98
|
+
return outOfMinRangeMinutes;
|
|
99
|
+
};
|
|
100
|
+
const getOutOfMaxRangeMinutes = (hourValue, maxTime, dataList) => {
|
|
101
|
+
if (!maxTime) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const outOfMaxRangeMinutes = [];
|
|
105
|
+
if (hourValue === maxTime.hour()) {
|
|
106
|
+
outOfMaxRangeMinutes.push(
|
|
107
|
+
...dataList.map((item) => item.value).filter((minute) => minute > maxTime.minute())
|
|
108
|
+
);
|
|
109
|
+
} else if (hourValue > maxTime.hour()) {
|
|
110
|
+
outOfMaxRangeMinutes.push(...dataList.map((item) => item.value));
|
|
111
|
+
}
|
|
112
|
+
return outOfMaxRangeMinutes;
|
|
113
|
+
};
|
|
114
|
+
const getOutOfMinRangeSeconds = (hourValue, minuteValue, minTime, dataList) => {
|
|
115
|
+
if (!minTime) {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
const outOfMinRangeMinutes = [];
|
|
119
|
+
if (hourValue === minTime.hour() && minuteValue === minTime.minute()) {
|
|
120
|
+
outOfMinRangeMinutes.push(
|
|
121
|
+
...dataList.map((item) => item.value).filter((second) => second < minTime.second())
|
|
122
|
+
);
|
|
123
|
+
} else if (hourValue === minTime.hour() && minuteValue < minTime.minute()) {
|
|
124
|
+
outOfMinRangeMinutes.push(...dataList.map((item) => item.value));
|
|
125
|
+
} else if (hourValue < minTime.hour()) {
|
|
126
|
+
outOfMinRangeMinutes.push(...dataList.map((item) => item.value));
|
|
127
|
+
}
|
|
128
|
+
return outOfMinRangeMinutes;
|
|
129
|
+
};
|
|
130
|
+
const getOutOfMaxRangeSeconds = (hourValue, minuteValue, maxTime, dataList) => {
|
|
131
|
+
if (!maxTime) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
const outOfMaxRangeMinutes = [];
|
|
135
|
+
if (hourValue === maxTime.hour() && minuteValue === maxTime.minute()) {
|
|
136
|
+
outOfMaxRangeMinutes.push(
|
|
137
|
+
...dataList.map((item) => item.value).filter((second) => second > maxTime.second())
|
|
138
|
+
);
|
|
139
|
+
} else if (hourValue === maxTime.hour() && minuteValue > maxTime.minute()) {
|
|
140
|
+
outOfMaxRangeMinutes.push(...dataList.map((item) => item.value));
|
|
141
|
+
} else if (hourValue > maxTime.hour()) {
|
|
142
|
+
outOfMaxRangeMinutes.push(...dataList.map((item) => item.value));
|
|
143
|
+
}
|
|
144
|
+
return outOfMaxRangeMinutes;
|
|
145
|
+
};
|
|
146
|
+
const getdisabledTime = (type, timeValue, minTime, maxTime, dataList, disabledTimeView, timeSteps, ampm) => {
|
|
147
|
+
var _a, _b, _c, _d, _e;
|
|
148
|
+
const isRangeDate = getIsRangeDate(timeValue, minTime, maxTime);
|
|
149
|
+
if (!isRangeDate) {
|
|
150
|
+
return dataList.map((item) => item.value);
|
|
151
|
+
}
|
|
152
|
+
const hourValue = timeValue == null ? void 0 : timeValue.hour();
|
|
153
|
+
const minuteValue = timeValue == null ? void 0 : timeValue.minute();
|
|
154
|
+
const getDisabledViewTime = () => {
|
|
155
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
156
|
+
switch (type) {
|
|
157
|
+
case "hour": {
|
|
158
|
+
const disabledHours = ((_b2 = disabledTimeView == null ? void 0 : (_a2 = disabledTimeView()).hour) == null ? void 0 : _b2.call(_a2)) || [];
|
|
159
|
+
if (ampm && (timeValue == null ? void 0 : timeValue.format("A")) === "PM") {
|
|
160
|
+
return disabledHours.map((hour) => hour - 12);
|
|
161
|
+
}
|
|
162
|
+
return disabledHours;
|
|
163
|
+
}
|
|
164
|
+
case "minute": {
|
|
165
|
+
const disabledMinutes = ((_d2 = disabledTimeView == null ? void 0 : (_c2 = disabledTimeView()).minute) == null ? void 0 : _d2.call(_c2, hourValue)) || [];
|
|
166
|
+
return disabledMinutes;
|
|
167
|
+
}
|
|
168
|
+
case "second": {
|
|
169
|
+
const disabledSeconds = ((_f = disabledTimeView == null ? void 0 : (_e2 = disabledTimeView()).second) == null ? void 0 : _f.call(_e2, hourValue, minuteValue)) || [];
|
|
170
|
+
return disabledSeconds;
|
|
171
|
+
}
|
|
172
|
+
default:
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const disabledViewTime = getDisabledViewTime();
|
|
177
|
+
const getOutOfMinRangeTime = () => {
|
|
178
|
+
if (!minTime) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
switch (type) {
|
|
182
|
+
case "hour": {
|
|
183
|
+
const outOfRangeHours = dataList.map((item) => item.value).filter((hour) => {
|
|
184
|
+
const minHour2 = minTime == null ? void 0 : minTime.hour();
|
|
185
|
+
const meridiemValue = timeValue == null ? void 0 : timeValue.format("A");
|
|
186
|
+
if (ampm) {
|
|
187
|
+
if (meridiemValue === "AM") {
|
|
188
|
+
return minHour2 >= 12 || hour < minHour2;
|
|
189
|
+
}
|
|
190
|
+
if (minHour2 < 12) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return hour < minHour2 - 12;
|
|
194
|
+
}
|
|
195
|
+
return hour < minHour2;
|
|
196
|
+
});
|
|
197
|
+
return outOfRangeHours;
|
|
198
|
+
}
|
|
199
|
+
case "minute": {
|
|
200
|
+
const outOfRangeMinutes = getOutOfMinRangeMinutes(
|
|
201
|
+
hourValue,
|
|
202
|
+
minTime,
|
|
203
|
+
dataList
|
|
204
|
+
);
|
|
205
|
+
return outOfRangeMinutes;
|
|
206
|
+
}
|
|
207
|
+
case "second": {
|
|
208
|
+
const outOfRangeSeconds = getOutOfMinRangeSeconds(
|
|
209
|
+
hourValue,
|
|
210
|
+
minuteValue,
|
|
211
|
+
minTime,
|
|
212
|
+
dataList
|
|
213
|
+
);
|
|
214
|
+
return outOfRangeSeconds;
|
|
215
|
+
}
|
|
216
|
+
default:
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const getOutOfMaxRangeTime = () => {
|
|
221
|
+
if (!maxTime) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
switch (type) {
|
|
225
|
+
case "hour": {
|
|
226
|
+
const outOfRangeHours = dataList.map((item) => item.value).filter((hour) => {
|
|
227
|
+
if (ampm) {
|
|
228
|
+
const maxHour2 = maxTime == null ? void 0 : maxTime.hour();
|
|
229
|
+
const meridiemValue = timeValue == null ? void 0 : timeValue.format("A");
|
|
230
|
+
if (maxHour2 >= 12) {
|
|
231
|
+
if (meridiemValue === "AM") {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return hour > maxHour2 - 12;
|
|
235
|
+
}
|
|
236
|
+
if (meridiemValue === "AM") {
|
|
237
|
+
return hour > maxHour2;
|
|
238
|
+
}
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
return hour > (maxTime == null ? void 0 : maxTime.hour());
|
|
242
|
+
});
|
|
243
|
+
return outOfRangeHours;
|
|
244
|
+
}
|
|
245
|
+
case "minute": {
|
|
246
|
+
const outOfRangeMinutes = getOutOfMaxRangeMinutes(
|
|
247
|
+
hourValue,
|
|
248
|
+
maxTime,
|
|
249
|
+
dataList
|
|
250
|
+
);
|
|
251
|
+
return outOfRangeMinutes;
|
|
252
|
+
}
|
|
253
|
+
case "second": {
|
|
254
|
+
const outOfRangeSeconds = getOutOfMaxRangeSeconds(
|
|
255
|
+
hourValue,
|
|
256
|
+
minuteValue,
|
|
257
|
+
maxTime,
|
|
258
|
+
dataList
|
|
259
|
+
);
|
|
260
|
+
return outOfRangeSeconds;
|
|
261
|
+
}
|
|
262
|
+
default:
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
const outOfMinRangeTime = getOutOfMinRangeTime();
|
|
267
|
+
const outOfMaxRangeTime = getOutOfMaxRangeTime();
|
|
268
|
+
const isEqualMinDate = timeValue == null ? void 0 : timeValue.isSame(minTime, "day");
|
|
269
|
+
const isEqualMaxDate = timeValue == null ? void 0 : timeValue.isSame(maxTime, "day");
|
|
270
|
+
const allHours = Array.from({ length: 24 }, (_, i) => i);
|
|
271
|
+
const disabledViewHours = ((_b = disabledTimeView == null ? void 0 : (_a = disabledTimeView()).hour) == null ? void 0 : _b.call(_a)) || [];
|
|
272
|
+
const minHour = (_c = minTime == null ? void 0 : minTime.hour()) != null ? _c : 0;
|
|
273
|
+
const maxHour = (_d = maxTime == null ? void 0 : maxTime.hour()) != null ? _d : 23;
|
|
274
|
+
const outOfMinHours = allHours.filter((hour) => hour < minHour);
|
|
275
|
+
const outOfMaxHours = allHours.filter((hour) => hour > maxHour);
|
|
276
|
+
const generateHourArray = (start, end, step) => {
|
|
277
|
+
if (!step) {
|
|
278
|
+
step = 1;
|
|
279
|
+
}
|
|
280
|
+
return Array.from(
|
|
281
|
+
{ length: Math.ceil((end - start) / step) },
|
|
282
|
+
(_, i) => start + i * step
|
|
283
|
+
);
|
|
284
|
+
};
|
|
285
|
+
const hourStep = (_e = timeSteps.hour) != null ? _e : 1;
|
|
286
|
+
const amArr = generateHourArray(0, 12, hourStep);
|
|
287
|
+
const pmArr = generateHourArray(12, 24, hourStep);
|
|
288
|
+
const disabledAmPm = (disabledHours) => {
|
|
289
|
+
const containsAll = (arr) => arr.every((item) => disabledHours.includes(item));
|
|
290
|
+
const containsAllAmArr = containsAll(amArr);
|
|
291
|
+
const containsAllPmArr = containsAll(pmArr);
|
|
292
|
+
if (containsAllAmArr && containsAllPmArr)
|
|
293
|
+
return ["AM", "PM"];
|
|
294
|
+
if (containsAllAmArr)
|
|
295
|
+
return ["AM"];
|
|
296
|
+
if (containsAllPmArr)
|
|
297
|
+
return ["PM"];
|
|
298
|
+
return [];
|
|
299
|
+
};
|
|
300
|
+
if (!timeValue || isEqualMinDate && isEqualMaxDate) {
|
|
301
|
+
if (type === "meridiem") {
|
|
302
|
+
const disabledHours = [
|
|
303
|
+
.../* @__PURE__ */ new Set([...outOfMinHours, ...outOfMaxHours, ...disabledViewHours])
|
|
304
|
+
];
|
|
305
|
+
return disabledAmPm(disabledHours);
|
|
306
|
+
}
|
|
307
|
+
return [
|
|
308
|
+
.../* @__PURE__ */ new Set([
|
|
309
|
+
...disabledViewTime,
|
|
310
|
+
...outOfMinRangeTime,
|
|
311
|
+
...outOfMaxRangeTime
|
|
312
|
+
])
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
if (!isEqualMinDate && !isEqualMaxDate) {
|
|
316
|
+
if (type === "meridiem") {
|
|
317
|
+
const disabledHours = disabledViewHours;
|
|
318
|
+
return disabledAmPm(disabledHours);
|
|
319
|
+
}
|
|
320
|
+
return disabledViewTime;
|
|
321
|
+
}
|
|
322
|
+
if (isEqualMinDate) {
|
|
323
|
+
if (type === "meridiem") {
|
|
324
|
+
const disabledHours = [
|
|
325
|
+
.../* @__PURE__ */ new Set([...outOfMinHours, ...disabledViewHours])
|
|
326
|
+
];
|
|
327
|
+
return disabledAmPm(disabledHours);
|
|
328
|
+
}
|
|
329
|
+
return [.../* @__PURE__ */ new Set([...disabledViewTime, ...outOfMinRangeTime])];
|
|
330
|
+
}
|
|
331
|
+
if (type === "meridiem") {
|
|
332
|
+
const disabledHours = [
|
|
333
|
+
.../* @__PURE__ */ new Set([...outOfMaxHours, ...disabledViewHours])
|
|
334
|
+
];
|
|
335
|
+
return disabledAmPm(disabledHours);
|
|
336
|
+
}
|
|
337
|
+
return [.../* @__PURE__ */ new Set([...disabledViewTime, ...outOfMaxRangeTime])];
|
|
338
|
+
};
|
|
339
|
+
const calculateValidMinTime = (disabledTimeView, minTime) => {
|
|
340
|
+
var _a, _b, _c, _d, _e, _f;
|
|
341
|
+
const defaultTime = (0, import_dayjs.default)().set("hour", 0).set("minute", 0).set("second", 0);
|
|
342
|
+
let validTime = minTime || defaultTime;
|
|
343
|
+
const disabledHours = (_b = disabledTimeView == null ? void 0 : (_a = disabledTimeView()).hour) == null ? void 0 : _b.call(_a);
|
|
344
|
+
if (disabledHours.includes(validTime.hour())) {
|
|
345
|
+
const validHours = Array.from({ length: 24 }, (_, i) => i).filter(
|
|
346
|
+
(value) => !disabledHours.includes(value) && value > validTime.hour()
|
|
347
|
+
);
|
|
348
|
+
const minValue = Math.min(...validHours);
|
|
349
|
+
validTime = validTime.set("hour", minValue);
|
|
350
|
+
}
|
|
351
|
+
if (validTime.hour() > (minTime == null ? void 0 : minTime.hour())) {
|
|
352
|
+
validTime = validTime.set("minute", 0);
|
|
353
|
+
validTime = validTime.set("second", 0);
|
|
354
|
+
}
|
|
355
|
+
const disabledMinutes = (_d = disabledTimeView == null ? void 0 : (_c = disabledTimeView()).minute) == null ? void 0 : _d.call(_c, validTime.hour());
|
|
356
|
+
if (disabledMinutes.includes(validTime.minute())) {
|
|
357
|
+
const validMinutes = Array.from({ length: 60 }, (_, i) => i).filter(
|
|
358
|
+
(value) => {
|
|
359
|
+
if (validTime.hour() > (minTime == null ? void 0 : minTime.hour())) {
|
|
360
|
+
return !disabledMinutes.includes(value);
|
|
361
|
+
}
|
|
362
|
+
return !disabledMinutes.includes(value) && value > validTime.minute();
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
const minValue = Math.min(...validMinutes);
|
|
366
|
+
validTime = validTime.set("minute", minValue);
|
|
367
|
+
}
|
|
368
|
+
if (validTime.minute() > (minTime == null ? void 0 : minTime.minute())) {
|
|
369
|
+
validTime = validTime.set("second", 0);
|
|
370
|
+
}
|
|
371
|
+
const disabledSeconds = (_f = disabledTimeView == null ? void 0 : (_e = disabledTimeView()).second) == null ? void 0 : _f.call(
|
|
372
|
+
_e,
|
|
373
|
+
validTime.hour(),
|
|
374
|
+
validTime.minute()
|
|
375
|
+
);
|
|
376
|
+
if (disabledSeconds.includes(validTime.second())) {
|
|
377
|
+
const validSeconds = Array.from({ length: 60 }, (_, i) => i).filter(
|
|
378
|
+
(value) => {
|
|
379
|
+
if (validTime.hour() > (minTime == null ? void 0 : minTime.hour()) || validTime.minute() > (minTime == null ? void 0 : minTime.minute())) {
|
|
380
|
+
return !disabledSeconds.includes(value);
|
|
381
|
+
}
|
|
382
|
+
return !disabledMinutes.includes(value) && value > validTime.second();
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
const minValue = Math.min(...validSeconds);
|
|
386
|
+
validTime = validTime.set("second", minValue);
|
|
387
|
+
}
|
|
388
|
+
return validTime;
|
|
389
|
+
};
|
|
390
|
+
const dateToDayjs = (date) => {
|
|
391
|
+
if (!date)
|
|
392
|
+
return void 0;
|
|
393
|
+
return (0, import_dayjs.default)(date);
|
|
394
|
+
};
|
|
395
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
396
|
+
0 && (module.exports = {
|
|
397
|
+
calculateValidMinTime,
|
|
398
|
+
dateToDayjs,
|
|
399
|
+
getIsRangeDate,
|
|
400
|
+
getIsRangeTime,
|
|
401
|
+
getOutOfMaxRangeMinutes,
|
|
402
|
+
getOutOfMaxRangeSeconds,
|
|
403
|
+
getOutOfMinRangeMinutes,
|
|
404
|
+
getOutOfMinRangeSeconds,
|
|
405
|
+
getdisabledTime,
|
|
406
|
+
isDisabledTime,
|
|
407
|
+
isDisabledViewTime
|
|
408
|
+
});
|
|
@@ -91,10 +91,21 @@ const formatProps = (props) => {
|
|
|
91
91
|
};
|
|
92
92
|
const DialogGenerator = (options) => {
|
|
93
93
|
const rootWrapper = document.createElement("div");
|
|
94
|
-
const rootElement = (0, import_utils.
|
|
94
|
+
const rootElement = (0, import_utils.getRootContainer)(options == null ? void 0 : options.container);
|
|
95
95
|
rootElement.appendChild(rootWrapper);
|
|
96
96
|
const DialogComponent = () => {
|
|
97
|
-
const _a = options, {
|
|
97
|
+
const _a = options, {
|
|
98
|
+
onConfirm,
|
|
99
|
+
onCancel,
|
|
100
|
+
ref,
|
|
101
|
+
container: container
|
|
102
|
+
} = _a, others = __objRest(_a, [
|
|
103
|
+
"onConfirm",
|
|
104
|
+
"onCancel",
|
|
105
|
+
"ref",
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
+
"container"
|
|
108
|
+
]);
|
|
98
109
|
const [visible, setVisible] = (0, import_react.useState)(false);
|
|
99
110
|
const close = (0, import_react.useCallback)(() => {
|
|
100
111
|
setVisible(false);
|
package/dist/Input/Input.css
CHANGED
|
@@ -12,5 +12,5 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
|
|
|
12
12
|
keepMounted?: boolean;
|
|
13
13
|
} & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
14
|
ref?: React.Ref<HTMLDivElement>;
|
|
15
|
-
}, keyof import("@bifrostui/types").ICommonProps | "
|
|
15
|
+
}, "open" | keyof import("@bifrostui/types").ICommonProps | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
16
16
|
export default Modal;
|
package/dist/Picker/Picker.css
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
--panel-container-height: var(--bui-picker-panel-height, 260px);
|
|
9
9
|
--indicator-top: var(--bui-picker-indicator-top, 108px);
|
|
10
10
|
--option-height: var(--bui-picker-option-height, 36px);
|
|
11
|
+
--bui-picker-confirm-disabled-opacity: 0.38;
|
|
11
12
|
font-family: var(--bui-font-family);
|
|
12
13
|
}
|
|
13
14
|
.bui-picker .bui-drawer-content {
|
|
@@ -41,6 +42,10 @@
|
|
|
41
42
|
line-height: var(--confirm-line-height);
|
|
42
43
|
color: var(--bui-color-primary);
|
|
43
44
|
}
|
|
45
|
+
.bui-picker-confirm-disabled {
|
|
46
|
+
color: var(--bui-color-fg-default);
|
|
47
|
+
opacity: var(--bui-picker-confirm-disabled-opacity);
|
|
48
|
+
}
|
|
44
49
|
.bui-picker-container {
|
|
45
50
|
width: 100%;
|
|
46
51
|
height: var(--panel-container-height);
|
package/dist/Picker/Picker.js
CHANGED
|
@@ -67,6 +67,12 @@ var import_locales = require("../locales");
|
|
|
67
67
|
var import_utils = require("./utils");
|
|
68
68
|
var import_Picker2 = require("./Picker.css");
|
|
69
69
|
const prefixCls = "bui-picker";
|
|
70
|
+
const checkDisabled = (values, columns) => values.find(
|
|
71
|
+
(value, index) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return (_b = (_a = columns == null ? void 0 : columns[index]) == null ? void 0 : _a.find((column) => (column == null ? void 0 : column.value) === value)) == null ? void 0 : _b.disabled;
|
|
74
|
+
}
|
|
75
|
+
);
|
|
70
76
|
const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
71
77
|
const _a = props, {
|
|
72
78
|
className,
|
|
@@ -74,6 +80,8 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
74
80
|
title,
|
|
75
81
|
options = [],
|
|
76
82
|
value,
|
|
83
|
+
confirmText: propConfirmText,
|
|
84
|
+
cancelText: propCancelText,
|
|
77
85
|
contentProps,
|
|
78
86
|
onConfirm,
|
|
79
87
|
onOptionChange,
|
|
@@ -85,6 +93,8 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
85
93
|
"title",
|
|
86
94
|
"options",
|
|
87
95
|
"value",
|
|
96
|
+
"confirmText",
|
|
97
|
+
"cancelText",
|
|
88
98
|
"contentProps",
|
|
89
99
|
"onConfirm",
|
|
90
100
|
"onOptionChange",
|
|
@@ -96,6 +106,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
96
106
|
const [columns, setColumns] = (0, import_react.useState)([]);
|
|
97
107
|
const [internalValue, setInternalValue] = (0, import_react.useState)([]);
|
|
98
108
|
const { cancel: cancelText, confirm: confirmText } = (0, import_locales.useLocaleText)("picker");
|
|
109
|
+
const disabled = checkDisabled(internalValue, columns);
|
|
99
110
|
(0, import_react.useEffect)(() => {
|
|
100
111
|
if (!open)
|
|
101
112
|
return;
|
|
@@ -118,7 +129,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
118
129
|
}, [value, options]);
|
|
119
130
|
const confirm = (e) => {
|
|
120
131
|
const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
|
|
121
|
-
if (isMoving)
|
|
132
|
+
if (isMoving || disabled)
|
|
122
133
|
return;
|
|
123
134
|
const { safeValue } = (0, import_utils.safeData)({
|
|
124
135
|
value: internalValue,
|
|
@@ -177,7 +188,8 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
177
188
|
onOptionChange == null ? void 0 : onOptionChange(e, {
|
|
178
189
|
value: conbineValues,
|
|
179
190
|
options: formatted,
|
|
180
|
-
currentOption: columnOption
|
|
191
|
+
currentOption: columnOption,
|
|
192
|
+
columnIndex
|
|
181
193
|
});
|
|
182
194
|
} else {
|
|
183
195
|
const result = [...internalValue];
|
|
@@ -186,7 +198,8 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
186
198
|
onOptionChange == null ? void 0 : onOptionChange(e, {
|
|
187
199
|
value: result,
|
|
188
200
|
options,
|
|
189
|
-
currentOption: columnOption
|
|
201
|
+
currentOption: columnOption,
|
|
202
|
+
columnIndex
|
|
190
203
|
});
|
|
191
204
|
}
|
|
192
205
|
}
|
|
@@ -228,7 +241,16 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
228
241
|
__spreadProps(__spreadValues({}, contentProps), {
|
|
229
242
|
className: (0, import_clsx.default)(`${prefixCls}-content`, contentProps == null ? void 0 : contentProps.className)
|
|
230
243
|
}),
|
|
231
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel }, cancelText), title && /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-title` }, title), /* @__PURE__ */ import_react.default.createElement(
|
|
244
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel }, propCancelText || cancelText), title && /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-title` }, title), /* @__PURE__ */ import_react.default.createElement(
|
|
245
|
+
"div",
|
|
246
|
+
{
|
|
247
|
+
className: (0, import_clsx.default)(`${prefixCls}-confirm`, {
|
|
248
|
+
[`${prefixCls}-confirm-disabled`]: disabled
|
|
249
|
+
}),
|
|
250
|
+
onClick: confirm
|
|
251
|
+
},
|
|
252
|
+
propConfirmText || confirmText
|
|
253
|
+
)),
|
|
232
254
|
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
233
255
|
import_PickerPanel.default,
|
|
234
256
|
{
|
|
@@ -236,7 +258,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
236
258
|
key: index,
|
|
237
259
|
options: column,
|
|
238
260
|
columnIndex: index,
|
|
239
|
-
|
|
261
|
+
value: internalValue == null ? void 0 : internalValue[index],
|
|
240
262
|
onSelect: handleSelect,
|
|
241
263
|
pickerStyle: others == null ? void 0 : others.style
|
|
242
264
|
}
|
|
@@ -10,6 +10,10 @@ export interface IPickerOptionItem {
|
|
|
10
10
|
* 选项对应唯一的值
|
|
11
11
|
*/
|
|
12
12
|
value: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* 是否禁用
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
13
17
|
}
|
|
14
18
|
export type ICascadePickerChildOptionItem = IPickerOptionItem & {
|
|
15
19
|
/**
|
|
@@ -34,6 +38,14 @@ export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> =
|
|
|
34
38
|
* 标题
|
|
35
39
|
*/
|
|
36
40
|
title?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 确认文本内容
|
|
43
|
+
*/
|
|
44
|
+
confirmText?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 取消文本内容
|
|
47
|
+
*/
|
|
48
|
+
cancelText?: string;
|
|
37
49
|
/**
|
|
38
50
|
* 列表数据
|
|
39
51
|
* @default []
|
|
@@ -61,6 +73,7 @@ export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> =
|
|
|
61
73
|
value: (string | number)[];
|
|
62
74
|
options: ICascadePickerChildOptionItem[][];
|
|
63
75
|
currentOption: ICascadePickerChildOptionItem;
|
|
76
|
+
columnIndex: number;
|
|
64
77
|
}) => void;
|
|
65
78
|
/**
|
|
66
79
|
* 点击取消按钮时候回调
|
|
@@ -85,9 +98,9 @@ export type PickerPanelProps<D extends React.ElementType = 'div', P = {}> = Over
|
|
|
85
98
|
*/
|
|
86
99
|
options?: ICascadePickerChildOptionItem[];
|
|
87
100
|
/**
|
|
88
|
-
*
|
|
101
|
+
* 选中值
|
|
89
102
|
*/
|
|
90
|
-
|
|
103
|
+
value?: string | number;
|
|
91
104
|
/**
|
|
92
105
|
* 列索引
|
|
93
106
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.bui-picker-panel {
|
|
2
|
+
--bui-picker-option-disabled-opacity: 0.38;
|
|
2
3
|
flex: 1;
|
|
3
4
|
flex-shrink: 0;
|
|
4
5
|
position: relative;
|
|
@@ -56,6 +57,9 @@
|
|
|
56
57
|
white-space: nowrap;
|
|
57
58
|
width: 100%;
|
|
58
59
|
}
|
|
60
|
+
.bui-picker-panel-option-disabled {
|
|
61
|
+
opacity: var(--bui-picker-option-disabled-opacity);
|
|
62
|
+
}
|
|
59
63
|
.bui-picker-panel-option-hidden {
|
|
60
64
|
visibility: hidden;
|
|
61
65
|
opacity: 0;
|
|
@@ -66,13 +66,13 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
66
66
|
var _b;
|
|
67
67
|
const _a = props, {
|
|
68
68
|
options = [],
|
|
69
|
-
|
|
69
|
+
value,
|
|
70
70
|
onSelect,
|
|
71
71
|
columnIndex,
|
|
72
72
|
pickerStyle
|
|
73
73
|
} = _a, others = __objRest(_a, [
|
|
74
74
|
"options",
|
|
75
|
-
"
|
|
75
|
+
"value",
|
|
76
76
|
"onSelect",
|
|
77
77
|
"columnIndex",
|
|
78
78
|
"pickerStyle"
|
|
@@ -102,9 +102,9 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
102
102
|
(0, import_utils.useTouchEmulator)(PickerPanelRef.current);
|
|
103
103
|
const updateSelect = () => {
|
|
104
104
|
let index = -1;
|
|
105
|
-
if (
|
|
105
|
+
if (value) {
|
|
106
106
|
options.some((item, idx) => {
|
|
107
|
-
if (item.value ===
|
|
107
|
+
if (item.value === value) {
|
|
108
108
|
index = idx;
|
|
109
109
|
return true;
|
|
110
110
|
}
|
|
@@ -122,7 +122,7 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
122
122
|
return () => {
|
|
123
123
|
clearTimeout(timer);
|
|
124
124
|
};
|
|
125
|
-
}, [options]);
|
|
125
|
+
}, [options, value]);
|
|
126
126
|
const setTransform = (type, deg, time = DEFAULT_DURATION, translateY = 0) => {
|
|
127
127
|
let nTime = time;
|
|
128
128
|
if (type !== TOUCH_END) {
|
|
@@ -255,7 +255,8 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
255
255
|
"div",
|
|
256
256
|
{
|
|
257
257
|
className: (0, import_clsx.default)(`${prefixCls}-option`, {
|
|
258
|
-
[`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8
|
|
258
|
+
[`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8,
|
|
259
|
+
[`${prefixCls}-option-disabled`]: item == null ? void 0 : item.disabled
|
|
259
260
|
}),
|
|
260
261
|
key: `${item == null ? void 0 : item.value}-${i}`,
|
|
261
262
|
style: {
|