@bifrostui/react 1.3.0 → 1.3.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionSheet/ActionSheet.css +6 -3
- package/dist/ActionSheet/ActionSheetItem.css +10 -6
- package/dist/Alert/index.css +14 -8
- package/dist/Avatar/Avatar.css +13 -9
- package/dist/Avatar/AvatarGroup.css +15 -8
- package/dist/Backdrop/Backdrop.css +2 -1
- package/dist/Badge/Badge.css +27 -17
- package/dist/Breadcrumb/Breadcrumb.css +34 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/dist/Breadcrumb/Breadcrumb.js +128 -0
- package/dist/Breadcrumb/Breadcrumb.types.d.ts +49 -0
- package/dist/Breadcrumb/Breadcrumb.types.js +15 -0
- package/dist/Breadcrumb/BreadcrumbItem.d.ts +4 -0
- package/dist/Breadcrumb/BreadcrumbItem.js +78 -0
- package/dist/Breadcrumb/index.d.ts +4 -0
- package/dist/Breadcrumb/index.js +45 -0
- package/dist/Button/Button.css +26 -17
- package/dist/Calendar/Calendar.css +33 -18
- package/dist/Calendar/Calendar.d.ts +1 -1
- package/dist/Calendar/Calendar.js +38 -17
- package/dist/Calendar/Calendar.types.d.ts +21 -0
- package/dist/Card/CardFooter.css +2 -1
- package/dist/Card/CardHeader.css +3 -1
- package/dist/Checkbox/Checkbox.css +7 -5
- package/dist/CitySelector/CitySelector.css +29 -15
- package/dist/CitySelector/CitySelectorCore.js +25 -16
- package/dist/CitySelector/Selector/index.css +4 -4
- package/dist/Collapse/Collapse.css +6 -0
- package/dist/Collapse/Collapse.d.ts +5 -0
- package/dist/Collapse/Collapse.js +165 -0
- package/dist/Collapse/Collapse.types.d.ts +16 -0
- package/dist/Collapse/Collapse.types.js +15 -0
- package/dist/Collapse/index.d.ts +2 -0
- package/dist/Collapse/index.js +41 -0
- package/dist/CollapsePanel/CollapsePanel.css +32 -0
- package/dist/CollapsePanel/CollapsePanel.d.ts +5 -0
- package/dist/CollapsePanel/CollapsePanel.js +159 -0
- package/dist/CollapsePanel/CollapsePanel.types.d.ts +64 -0
- package/dist/CollapsePanel/CollapsePanel.types.js +15 -0
- package/dist/CollapsePanel/CollapsePanelItem.d.ts +4 -0
- package/dist/CollapsePanel/CollapsePanelItem.js +112 -0
- package/dist/CollapsePanel/index.d.ts +4 -0
- package/dist/CollapsePanel/index.js +45 -0
- package/dist/Countdown/Countdown.css +2 -1
- package/dist/Dialog/Dialog.d.ts +2 -2
- package/dist/Dialog/Dialog.js +20 -8
- package/dist/Dialog/Dialog.types.d.ts +12 -1
- package/dist/Dialog/FunctionalDialog.js +38 -2
- package/dist/Dialog/index.css +27 -18
- package/dist/Divider/Divider.css +6 -4
- package/dist/IconButton/IconButton.css +9 -7
- package/dist/Image/index.css +2 -1
- package/dist/Input/Input.css +10 -5
- package/dist/List/List.css +3 -0
- package/dist/List/ListItem.css +3 -3
- package/dist/List/ListItemContent.css +1 -1
- package/dist/Loading/Loading.css +4 -2
- package/dist/Modal/Modal.miniapp.d.ts +1 -1
- package/dist/NavBar/NavBar.css +9 -5
- package/dist/Picker/Picker.css +25 -29
- package/dist/Picker/Picker.js +31 -11
- package/dist/Picker/Picker.types.d.ts +4 -0
- package/dist/Picker/PickerPanel.css +8 -8
- package/dist/Picker/PickerPanel.js +14 -8
- package/dist/Picker/utils.d.ts +16 -0
- package/dist/Picker/utils.js +32 -2
- package/dist/Popover/Popover.css +97 -0
- package/dist/Popover/Popover.d.ts +5 -0
- package/dist/Popover/Popover.js +186 -0
- package/dist/Popover/Popover.types.d.ts +59 -0
- package/dist/Popover/Popover.types.js +15 -0
- package/dist/Popover/index.d.ts +2 -0
- package/dist/Popover/index.js +41 -0
- package/dist/Portal/Portal.types.d.ts +4 -0
- package/dist/Portal/PortalCore.js +8 -1
- package/dist/Progress/Progress.css +8 -6
- package/dist/Radio/Radio.css +2 -1
- package/dist/Rating/Rating.css +8 -4
- package/dist/Select/Select.css +21 -10
- package/dist/Select/Select.js +1 -1
- package/dist/Select/SelectOption.js +3 -0
- package/dist/Skeleton/Skeleton.css +3 -2
- package/dist/Slider/Slider.css +24 -13
- package/dist/Steps/Step.css +11 -11
- package/dist/Steps/Steps.css +14 -5
- package/dist/Swiper/Swiper.css +2 -1
- package/dist/Switch/Switch.css +31 -16
- package/dist/TabBar/TabBar.css +7 -3
- package/dist/TabBar/TabBarItem.css +0 -1
- package/dist/Tabs/Tab.css +2 -6
- package/dist/Tabs/Tabs.css +7 -4
- package/dist/Tag/Tag.css +7 -10
- package/dist/Tag/TagGroup.css +9 -1
- package/dist/TextArea/TextArea.css +14 -8
- package/dist/ThemeProvider/ThemeProvider.d.ts +4 -0
- package/dist/ThemeProvider/ThemeProvider.js +91 -0
- package/dist/ThemeProvider/ThemeProvider.types.d.ts +127 -0
- package/dist/ThemeProvider/ThemeProvider.types.js +27 -0
- package/dist/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
- package/dist/ThemeProvider/hooks/ThemeContext.js +35 -0
- package/dist/ThemeProvider/hooks/createTheme.d.ts +2 -0
- package/dist/ThemeProvider/hooks/createTheme.js +55 -0
- package/dist/ThemeProvider/hooks/index.d.ts +4 -0
- package/dist/ThemeProvider/hooks/index.js +43 -0
- package/dist/ThemeProvider/hooks/useTheme.d.ts +1 -0
- package/dist/ThemeProvider/hooks/useTheme.js +39 -0
- package/dist/ThemeProvider/index.d.ts +4 -0
- package/dist/ThemeProvider/index.js +45 -0
- package/dist/ThemeProvider/utils/constants.d.ts +38 -0
- package/dist/ThemeProvider/utils/constants.js +65 -0
- package/dist/ThemeProvider/utils/index.d.ts +2 -0
- package/dist/ThemeProvider/utils/index.js +23 -0
- package/dist/ThemeProvider/utils/mountTokens.d.ts +26 -0
- package/dist/ThemeProvider/utils/mountTokens.js +123 -0
- package/dist/Toast/FunctionalToast.js +18 -0
- package/dist/Toast/Toast.css +15 -14
- package/dist/Toast/Toast.d.ts +2 -2
- package/dist/Toast/Toast.js +52 -48
- package/dist/Toast/Toast.types.d.ts +15 -1
- package/dist/Tooltip/Tooltip.css +91 -0
- package/dist/Tooltip/Tooltip.d.ts +5 -0
- package/dist/Tooltip/Tooltip.js +175 -0
- package/dist/Tooltip/Tooltip.types.d.ts +50 -0
- package/dist/Tooltip/Tooltip.types.js +15 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/Tooltip/index.js +41 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +15 -1
- package/dist/locales/base.d.ts +40 -0
- package/dist/locales/base.js +15 -0
- package/dist/locales/en-US.d.ts +3 -0
- package/dist/locales/en-US.js +69 -0
- package/dist/locales/hooks/useLocaleText.d.ts +3 -0
- package/dist/locales/hooks/useLocaleText.js +43 -0
- package/dist/locales/index.d.ts +5 -0
- package/dist/locales/index.js +49 -0
- package/dist/locales/zh-CN.d.ts +3 -0
- package/dist/locales/zh-CN.js +51 -0
- package/dist/locales/zh-TW.d.ts +3 -0
- package/dist/locales/zh-TW.js +51 -0
- package/es/ActionSheet/ActionSheet.css +6 -3
- package/es/ActionSheet/ActionSheetItem.css +10 -6
- package/es/Alert/index.css +14 -8
- package/es/Avatar/Avatar.css +13 -9
- package/es/Avatar/AvatarGroup.css +15 -8
- package/es/Backdrop/Backdrop.css +2 -1
- package/es/Badge/Badge.css +27 -17
- package/es/Breadcrumb/Breadcrumb.css +34 -0
- package/es/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/es/Breadcrumb/Breadcrumb.js +101 -0
- package/es/Breadcrumb/Breadcrumb.types.d.ts +49 -0
- package/es/Breadcrumb/Breadcrumb.types.js +1 -0
- package/es/Breadcrumb/BreadcrumbItem.d.ts +4 -0
- package/es/Breadcrumb/BreadcrumbItem.js +51 -0
- package/es/Breadcrumb/index.d.ts +4 -0
- package/es/Breadcrumb/index.js +9 -0
- package/es/Button/Button.css +26 -17
- package/es/Calendar/Calendar.css +33 -18
- package/es/Calendar/Calendar.d.ts +1 -1
- package/es/Calendar/Calendar.js +38 -17
- package/es/Calendar/Calendar.types.d.ts +21 -0
- package/es/Card/CardFooter.css +2 -1
- package/es/Card/CardHeader.css +3 -1
- package/es/Checkbox/Checkbox.css +7 -5
- package/es/CitySelector/CitySelector.css +29 -15
- package/es/CitySelector/CitySelectorCore.js +25 -16
- package/es/CitySelector/Selector/index.css +4 -4
- package/es/Collapse/Collapse.css +6 -0
- package/es/Collapse/Collapse.d.ts +5 -0
- package/es/Collapse/Collapse.js +144 -0
- package/es/Collapse/Collapse.types.d.ts +16 -0
- package/es/Collapse/Collapse.types.js +1 -0
- package/es/Collapse/index.d.ts +2 -0
- package/es/Collapse/index.js +6 -0
- package/es/CollapsePanel/CollapsePanel.css +32 -0
- package/es/CollapsePanel/CollapsePanel.d.ts +5 -0
- package/es/CollapsePanel/CollapsePanel.js +132 -0
- package/es/CollapsePanel/CollapsePanel.types.d.ts +64 -0
- package/es/CollapsePanel/CollapsePanel.types.js +1 -0
- package/es/CollapsePanel/CollapsePanelItem.d.ts +4 -0
- package/es/CollapsePanel/CollapsePanelItem.js +85 -0
- package/es/CollapsePanel/index.d.ts +4 -0
- package/es/CollapsePanel/index.js +9 -0
- package/es/Countdown/Countdown.css +2 -1
- package/es/Dialog/Dialog.d.ts +2 -2
- package/es/Dialog/Dialog.js +20 -8
- package/es/Dialog/Dialog.types.d.ts +12 -1
- package/es/Dialog/FunctionalDialog.js +38 -2
- package/es/Dialog/index.css +27 -18
- package/es/Divider/Divider.css +6 -4
- package/es/IconButton/IconButton.css +9 -7
- package/es/Image/index.css +2 -1
- package/es/Input/Input.css +10 -5
- package/es/List/List.css +3 -0
- package/es/List/ListItem.css +3 -3
- package/es/List/ListItemContent.css +1 -1
- package/es/Loading/Loading.css +4 -2
- package/es/Modal/Modal.miniapp.d.ts +1 -1
- package/es/NavBar/NavBar.css +9 -5
- package/es/Picker/Picker.css +25 -29
- package/es/Picker/Picker.js +32 -12
- package/es/Picker/Picker.types.d.ts +4 -0
- package/es/Picker/PickerPanel.css +8 -8
- package/es/Picker/PickerPanel.js +14 -8
- package/es/Picker/utils.d.ts +16 -0
- package/es/Picker/utils.js +29 -1
- package/es/Popover/Popover.css +97 -0
- package/es/Popover/Popover.d.ts +5 -0
- package/es/Popover/Popover.js +163 -0
- package/es/Popover/Popover.types.d.ts +59 -0
- package/es/Popover/Popover.types.js +1 -0
- package/es/Popover/index.d.ts +2 -0
- package/es/Popover/index.js +6 -0
- package/es/Portal/Portal.types.d.ts +4 -0
- package/es/Portal/PortalCore.js +8 -1
- package/es/Progress/Progress.css +8 -6
- package/es/Radio/Radio.css +2 -1
- package/es/Rating/Rating.css +8 -4
- package/es/Select/Select.css +21 -10
- package/es/Select/Select.js +1 -1
- package/es/Select/SelectOption.js +3 -0
- package/es/Skeleton/Skeleton.css +3 -2
- package/es/Slider/Slider.css +24 -13
- package/es/Steps/Step.css +11 -11
- package/es/Steps/Steps.css +14 -5
- package/es/Swiper/Swiper.css +2 -1
- package/es/Switch/Switch.css +31 -16
- package/es/TabBar/TabBar.css +7 -3
- package/es/TabBar/TabBarItem.css +0 -1
- package/es/Tabs/Tab.css +2 -6
- package/es/Tabs/Tabs.css +7 -4
- package/es/Tag/Tag.css +7 -10
- package/es/Tag/TagGroup.css +9 -1
- package/es/TextArea/TextArea.css +14 -8
- package/es/ThemeProvider/ThemeProvider.d.ts +4 -0
- package/es/ThemeProvider/ThemeProvider.js +62 -0
- package/es/ThemeProvider/ThemeProvider.types.d.ts +127 -0
- package/es/ThemeProvider/ThemeProvider.types.js +1 -0
- package/es/ThemeProvider/hooks/ThemeContext.d.ts +4 -0
- package/es/ThemeProvider/hooks/ThemeContext.js +6 -0
- package/es/ThemeProvider/hooks/createTheme.d.ts +2 -0
- package/es/ThemeProvider/hooks/createTheme.js +38 -0
- package/es/ThemeProvider/hooks/index.d.ts +4 -0
- package/es/ThemeProvider/hooks/index.js +8 -0
- package/es/ThemeProvider/hooks/useTheme.d.ts +1 -0
- package/es/ThemeProvider/hooks/useTheme.js +10 -0
- package/es/ThemeProvider/index.d.ts +4 -0
- package/es/ThemeProvider/index.js +8 -0
- package/es/ThemeProvider/utils/constants.d.ts +38 -0
- package/es/ThemeProvider/utils/constants.js +40 -0
- package/es/ThemeProvider/utils/index.d.ts +2 -0
- package/es/ThemeProvider/utils/index.js +2 -0
- package/es/ThemeProvider/utils/mountTokens.d.ts +26 -0
- package/es/ThemeProvider/utils/mountTokens.js +88 -0
- package/es/Toast/FunctionalToast.js +18 -0
- package/es/Toast/Toast.css +15 -14
- package/es/Toast/Toast.d.ts +2 -2
- package/es/Toast/Toast.js +53 -49
- package/es/Toast/Toast.types.d.ts +15 -1
- package/es/Tooltip/Tooltip.css +91 -0
- package/es/Tooltip/Tooltip.d.ts +5 -0
- package/es/Tooltip/Tooltip.js +152 -0
- package/es/Tooltip/Tooltip.types.d.ts +50 -0
- package/es/Tooltip/Tooltip.types.js +1 -0
- package/es/Tooltip/index.d.ts +2 -0
- package/es/Tooltip/index.js +6 -0
- package/es/index.d.ts +7 -0
- package/es/index.js +7 -0
- package/es/locales/base.d.ts +40 -0
- package/es/locales/base.js +0 -0
- package/es/locales/en-US.d.ts +3 -0
- package/es/locales/en-US.js +50 -0
- package/es/locales/hooks/useLocaleText.d.ts +3 -0
- package/es/locales/hooks/useLocaleText.js +26 -0
- package/es/locales/index.d.ts +5 -0
- package/es/locales/index.js +11 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +32 -0
- package/es/locales/zh-TW.d.ts +3 -0
- package/es/locales/zh-TW.js +32 -0
- package/package.json +5 -5
package/dist/Picker/Picker.js
CHANGED
|
@@ -63,6 +63,7 @@ var import_clsx = __toESM(require("clsx"));
|
|
|
63
63
|
var import_react = __toESM(require("react"));
|
|
64
64
|
var import_Drawer = __toESM(require("../Drawer"));
|
|
65
65
|
var import_PickerPanel = __toESM(require("./PickerPanel"));
|
|
66
|
+
var import_locales = require("../locales");
|
|
66
67
|
var import_utils = require("./utils");
|
|
67
68
|
var import_Picker2 = require("./Picker.css");
|
|
68
69
|
const prefixCls = "bui-picker";
|
|
@@ -94,6 +95,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
94
95
|
const rollerRefs = (0, import_react.useRef)([]);
|
|
95
96
|
const [columns, setColumns] = (0, import_react.useState)([]);
|
|
96
97
|
const [internalValue, setInternalValue] = (0, import_react.useState)([]);
|
|
98
|
+
const { cancel: cancelText, confirm: confirmText } = (0, import_locales.useLocaleText)("picker");
|
|
97
99
|
(0, import_react.useEffect)(() => {
|
|
98
100
|
if (!open)
|
|
99
101
|
return;
|
|
@@ -115,13 +117,18 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
115
117
|
}
|
|
116
118
|
}, [value, options]);
|
|
117
119
|
const confirm = (e) => {
|
|
118
|
-
const payload = {
|
|
119
|
-
value: internalValue,
|
|
120
|
-
options: columns
|
|
121
|
-
};
|
|
122
120
|
const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
|
|
123
121
|
if (isMoving)
|
|
124
122
|
return;
|
|
123
|
+
const { safeValue } = (0, import_utils.safeData)({
|
|
124
|
+
value: internalValue,
|
|
125
|
+
formatted: columns,
|
|
126
|
+
options
|
|
127
|
+
});
|
|
128
|
+
const payload = {
|
|
129
|
+
value: safeValue,
|
|
130
|
+
options: columns
|
|
131
|
+
};
|
|
125
132
|
onConfirm == null ? void 0 : onConfirm(e, payload);
|
|
126
133
|
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
127
134
|
from: "confirm"
|
|
@@ -129,11 +136,18 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
129
136
|
};
|
|
130
137
|
const cancel = (e) => {
|
|
131
138
|
onCancel == null ? void 0 : onCancel(e);
|
|
132
|
-
|
|
133
|
-
from: "cancel",
|
|
139
|
+
const { safeValue } = (0, import_utils.safeData)({
|
|
134
140
|
value: internalValue,
|
|
135
|
-
|
|
141
|
+
formatted: columns,
|
|
142
|
+
options
|
|
136
143
|
});
|
|
144
|
+
const payload = {
|
|
145
|
+
value: safeValue,
|
|
146
|
+
options: columns
|
|
147
|
+
};
|
|
148
|
+
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
149
|
+
from: "cancel"
|
|
150
|
+
}, payload));
|
|
137
151
|
};
|
|
138
152
|
const updateItem = (e, columnOption, columnIndex) => {
|
|
139
153
|
var _a2, _b, _c;
|
|
@@ -166,7 +180,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
166
180
|
currentOption: columnOption
|
|
167
181
|
});
|
|
168
182
|
} else {
|
|
169
|
-
const result = internalValue;
|
|
183
|
+
const result = [...internalValue];
|
|
170
184
|
result[columnIndex] = columnOption.value;
|
|
171
185
|
setInternalValue(result);
|
|
172
186
|
onOptionChange == null ? void 0 : onOptionChange(e, {
|
|
@@ -181,8 +195,13 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
181
195
|
updateItem(e, columnOption, columnIndex);
|
|
182
196
|
};
|
|
183
197
|
const handleClose = (e, data) => {
|
|
184
|
-
|
|
198
|
+
const { safeValue } = (0, import_utils.safeData)({
|
|
185
199
|
value: internalValue,
|
|
200
|
+
formatted: columns,
|
|
201
|
+
options
|
|
202
|
+
});
|
|
203
|
+
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
204
|
+
value: safeValue,
|
|
186
205
|
options: columns
|
|
187
206
|
}, data));
|
|
188
207
|
};
|
|
@@ -206,7 +225,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
206
225
|
__spreadProps(__spreadValues({}, contentProps), {
|
|
207
226
|
className: (0, import_clsx.default)(`${prefixCls}-content`, contentProps == null ? void 0 : contentProps.className)
|
|
208
227
|
}),
|
|
209
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel },
|
|
228
|
+
/* @__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("div", { className: `${prefixCls}-confirm`, onClick: confirm }, confirmText)),
|
|
210
229
|
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
211
230
|
import_PickerPanel.default,
|
|
212
231
|
{
|
|
@@ -215,7 +234,8 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
215
234
|
options: column,
|
|
216
235
|
columnIndex: index,
|
|
217
236
|
defaultValue: internalValue == null ? void 0 : internalValue[index],
|
|
218
|
-
onSelect: handleSelect
|
|
237
|
+
onSelect: handleSelect,
|
|
238
|
+
pickerStyle: others == null ? void 0 : others.style
|
|
219
239
|
}
|
|
220
240
|
)))
|
|
221
241
|
)
|
|
@@ -86,6 +86,10 @@ export type PickerPanelProps<D extends React.ElementType = 'div', P = {}> = Over
|
|
|
86
86
|
* 列索引
|
|
87
87
|
*/
|
|
88
88
|
columnIndex?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Piker组件的样式,PickerPanel的主题定制与css变量传入的Tokens有关,需要透传计算
|
|
91
|
+
*/
|
|
92
|
+
pickerStyle?: React.CSSProperties;
|
|
89
93
|
/**
|
|
90
94
|
* 选择选项时的回调
|
|
91
95
|
*/
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
background-image:
|
|
22
22
|
linear-gradient(
|
|
23
23
|
180deg,
|
|
24
|
-
var(--bui-color-bg-
|
|
25
|
-
var(--bui-color-bg-
|
|
24
|
+
var(--bui-color-bg-alpha-light-9),
|
|
25
|
+
var(--bui-color-bg-alpha-light-3)),
|
|
26
26
|
linear-gradient(
|
|
27
27
|
0deg,
|
|
28
|
-
var(--bui-color-bg-
|
|
29
|
-
var(--bui-color-bg-
|
|
28
|
+
var(--bui-color-bg-alpha-light-9),
|
|
29
|
+
var(--bui-color-bg-alpha-light-3));
|
|
30
30
|
background-position: top, bottom;
|
|
31
31
|
background-size: 100% var(--indicator-top);
|
|
32
32
|
background-repeat: no-repeat;
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
.bui-picker-panel-indicator {
|
|
36
36
|
position: absolute;
|
|
37
37
|
top: var(--indicator-top);
|
|
38
|
-
height: var(--
|
|
38
|
+
height: var(--option-height);
|
|
39
39
|
width: 100%;
|
|
40
|
-
border-top: 1px solid var(--
|
|
41
|
-
border-bottom: 1px solid var(--
|
|
40
|
+
border-top: 1px solid var(--bui-color-border-default);
|
|
41
|
+
border-bottom: 1px solid var(--bui-color-border-default);
|
|
42
42
|
}
|
|
43
43
|
.bui-picker-panel-option {
|
|
44
44
|
position: absolute;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
text-align: center;
|
|
48
48
|
height: var(--option-height);
|
|
49
49
|
line-height: var(--option-height);
|
|
50
|
-
color: var(--
|
|
50
|
+
color: var(--bui-color-fg-default);
|
|
51
51
|
font-size: var(--option-font-size);
|
|
52
52
|
backface-visibility: hidden;
|
|
53
53
|
width: auto;
|
|
@@ -63,25 +63,31 @@ var import_PickerPanel = require("./PickerPanel.css");
|
|
|
63
63
|
const prefixCls = "bui-picker-panel";
|
|
64
64
|
const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
65
65
|
(props, ref) => {
|
|
66
|
+
var _b;
|
|
66
67
|
const _a = props, {
|
|
67
68
|
options = [],
|
|
68
69
|
defaultValue,
|
|
69
70
|
onSelect,
|
|
70
|
-
columnIndex
|
|
71
|
+
columnIndex,
|
|
72
|
+
pickerStyle
|
|
71
73
|
} = _a, others = __objRest(_a, [
|
|
72
74
|
"options",
|
|
73
75
|
"defaultValue",
|
|
74
76
|
"onSelect",
|
|
75
|
-
"columnIndex"
|
|
77
|
+
"columnIndex",
|
|
78
|
+
"pickerStyle"
|
|
76
79
|
]);
|
|
77
80
|
const touch = (0, import_utils.useTouch)();
|
|
78
81
|
let timer;
|
|
79
82
|
const INERTIA_TIME = 200;
|
|
80
83
|
const INERTIA_DISTANCE = 15;
|
|
81
84
|
const DEFAULT_DURATION = 200;
|
|
82
|
-
const LINE_SPACING = 36;
|
|
83
85
|
const ROTATION = 20;
|
|
84
86
|
const TOUCH_END = "end";
|
|
87
|
+
const DEFAULT_LINE_SPACING = 36;
|
|
88
|
+
const LINE_SPACING_STR = (_b = ((pickerStyle == null ? void 0 : pickerStyle["--option-height"]) ? `${pickerStyle == null ? void 0 : pickerStyle["--option-height"]}` : `${DEFAULT_LINE_SPACING}`).match(/\d+/)) == null ? void 0 : _b[0];
|
|
89
|
+
const LINE_SPACING = parseInt(LINE_SPACING_STR, 10);
|
|
90
|
+
const INDICATOR_OFFSET = LINE_SPACING * 108 / DEFAULT_LINE_SPACING;
|
|
85
91
|
const [startY, setStartY] = (0, import_react.useState)(0);
|
|
86
92
|
const [currIndex, setCurrIndex] = (0, import_react.useState)(1);
|
|
87
93
|
const [startTime, setStartTime] = (0, import_react.useState)(0);
|
|
@@ -197,17 +203,17 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
197
203
|
}, 0);
|
|
198
204
|
};
|
|
199
205
|
(0, import_react.useEffect)(() => {
|
|
200
|
-
var _a2,
|
|
206
|
+
var _a2, _b2, _c;
|
|
201
207
|
(_a2 = PickerPanelRef.current) == null ? void 0 : _a2.addEventListener("touchstart", panelTouchStart);
|
|
202
|
-
(
|
|
208
|
+
(_b2 = PickerPanelRef.current) == null ? void 0 : _b2.addEventListener("touchmove", panelTouchMove);
|
|
203
209
|
(_c = PickerPanelRef.current) == null ? void 0 : _c.addEventListener("touchend", panelTouchEnd);
|
|
204
210
|
return () => {
|
|
205
|
-
var _a3,
|
|
211
|
+
var _a3, _b3, _c2;
|
|
206
212
|
(_a3 = PickerPanelRef.current) == null ? void 0 : _a3.removeEventListener(
|
|
207
213
|
"touchstart",
|
|
208
214
|
panelTouchStart
|
|
209
215
|
);
|
|
210
|
-
(
|
|
216
|
+
(_b3 = PickerPanelRef.current) == null ? void 0 : _b3.removeEventListener(
|
|
211
217
|
"touchmove",
|
|
212
218
|
panelTouchMove
|
|
213
219
|
);
|
|
@@ -253,7 +259,7 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
253
259
|
}),
|
|
254
260
|
key: `${item == null ? void 0 : item.value}-${i}`,
|
|
255
261
|
style: {
|
|
256
|
-
transform: `rotate3d(1, 0, 0, ${-ROTATION * (i + 1)}deg) translate3d(0px, 0px,
|
|
262
|
+
transform: `rotate3d(1, 0, 0, ${-ROTATION * (i + 1)}deg) translate3d(0px, 0px, ${INDICATOR_OFFSET}px)`
|
|
257
263
|
}
|
|
258
264
|
},
|
|
259
265
|
item == null ? void 0 : item.label
|
package/dist/Picker/utils.d.ts
CHANGED
|
@@ -11,3 +11,19 @@ export declare const formatCascade: (columns: ICascadePickerOptionItem[], values
|
|
|
11
11
|
* 统一options数据格式
|
|
12
12
|
*/
|
|
13
13
|
export declare const formatOptions: (internalValue: any, options?: any[]) => any[];
|
|
14
|
+
/**
|
|
15
|
+
* 在格式化后的数据源中是否存在等长子项的value
|
|
16
|
+
*/
|
|
17
|
+
export declare const existSameLengthValue: (value: any, formatted: any) => any;
|
|
18
|
+
/**
|
|
19
|
+
* 关闭选择器时,纠正value和格式化数据
|
|
20
|
+
* 取决于formatted后的options有几列,若value为格式化后数据源(formatted)的等长子集,则取value,否则执行纠正逻辑
|
|
21
|
+
*/
|
|
22
|
+
export declare const safeData: ({ value, formatted, options }: {
|
|
23
|
+
value: any;
|
|
24
|
+
formatted: any;
|
|
25
|
+
options: any;
|
|
26
|
+
}) => {
|
|
27
|
+
safeValue: any[];
|
|
28
|
+
safeFormatted: any[];
|
|
29
|
+
};
|
package/dist/Picker/utils.js
CHANGED
|
@@ -17,9 +17,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var utils_exports = {};
|
|
19
19
|
__export(utils_exports, {
|
|
20
|
+
existSameLengthValue: () => existSameLengthValue,
|
|
20
21
|
formatCascade: () => formatCascade,
|
|
21
22
|
formatOptions: () => formatOptions,
|
|
22
|
-
pickerPanelType: () => pickerPanelType
|
|
23
|
+
pickerPanelType: () => pickerPanelType,
|
|
24
|
+
safeData: () => safeData
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(utils_exports);
|
|
25
27
|
const pickerPanelType = (options = []) => {
|
|
@@ -63,9 +65,37 @@ const formatOptions = (internalValue, options = []) => {
|
|
|
63
65
|
return options;
|
|
64
66
|
}
|
|
65
67
|
};
|
|
68
|
+
const existSameLengthValue = (value, formatted) => {
|
|
69
|
+
const result = formatted.every(
|
|
70
|
+
(item, idx) => item.some((i) => (value == null ? void 0 : value[idx]) === (i == null ? void 0 : i.value))
|
|
71
|
+
);
|
|
72
|
+
return result;
|
|
73
|
+
};
|
|
74
|
+
const safeData = ({ value, formatted, options }) => {
|
|
75
|
+
let safeValue = [];
|
|
76
|
+
let safeFormatted = [];
|
|
77
|
+
const existValidChildren = existSameLengthValue(value, formatted);
|
|
78
|
+
if (existValidChildren) {
|
|
79
|
+
safeValue = value;
|
|
80
|
+
safeFormatted = formatted;
|
|
81
|
+
} else {
|
|
82
|
+
formatted.forEach((item, index) => {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
const childIndex = item.findIndex((i) => i.value === value[index]);
|
|
85
|
+
safeValue[index] = ((_a = item == null ? void 0 : item[childIndex]) == null ? void 0 : _a.value) || ((_b = item == null ? void 0 : item[0]) == null ? void 0 : _b.value);
|
|
86
|
+
});
|
|
87
|
+
safeFormatted = formatOptions(safeValue, options);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
safeValue,
|
|
91
|
+
safeFormatted
|
|
92
|
+
};
|
|
93
|
+
};
|
|
66
94
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
95
|
0 && (module.exports = {
|
|
96
|
+
existSameLengthValue,
|
|
68
97
|
formatCascade,
|
|
69
98
|
formatOptions,
|
|
70
|
-
pickerPanelType
|
|
99
|
+
pickerPanelType,
|
|
100
|
+
safeData
|
|
71
101
|
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
.bui-popover {
|
|
2
|
+
--arrow-size: var(--bui-popover-arrow-size, 8px);
|
|
3
|
+
--localtion-position: var(--bui-popover-localtion-position, 8px);
|
|
4
|
+
--max-width: var(--bui-popover-max-width, 350px);
|
|
5
|
+
--content-min-width: var(--bui-popover-content-min-width, 30px);
|
|
6
|
+
--content-min-height: var(--bui-popover-content-min-height, 32px);
|
|
7
|
+
--content-padding: var(--bui-popover-content-padding, 6px 8px);
|
|
8
|
+
max-width: var(--max-width);
|
|
9
|
+
font-size: var(--bui-text-size-1);
|
|
10
|
+
position: absolute;
|
|
11
|
+
visibility: hidden;
|
|
12
|
+
z-index: var(--bui-z-index-tooltip);
|
|
13
|
+
}
|
|
14
|
+
.bui-popover .bui-popover-arrow {
|
|
15
|
+
width: 0;
|
|
16
|
+
height: 0;
|
|
17
|
+
position: absolute;
|
|
18
|
+
}
|
|
19
|
+
.bui-popover .bui-popover-arrow.location-left {
|
|
20
|
+
left: var(--localtion-position);
|
|
21
|
+
}
|
|
22
|
+
.bui-popover .bui-popover-arrow.location-right {
|
|
23
|
+
right: var(--localtion-position);
|
|
24
|
+
}
|
|
25
|
+
.bui-popover .bui-popover-arrow.location-top {
|
|
26
|
+
top: var(--localtion-position);
|
|
27
|
+
}
|
|
28
|
+
.bui-popover .bui-popover-arrow.location-bottom {
|
|
29
|
+
bottom: var(--localtion-position);
|
|
30
|
+
}
|
|
31
|
+
.bui-popover.popover-top .location-center,
|
|
32
|
+
.bui-popover.popover-bottom .location-center {
|
|
33
|
+
left: 50%;
|
|
34
|
+
transform: translateX(-50%);
|
|
35
|
+
}
|
|
36
|
+
.bui-popover.popover-left .location-center,
|
|
37
|
+
.bui-popover.popover-right .location-center {
|
|
38
|
+
top: 50%;
|
|
39
|
+
transform: translateY(-50%);
|
|
40
|
+
}
|
|
41
|
+
.bui-popover.popover-top {
|
|
42
|
+
padding-bottom: var(--arrow-size);
|
|
43
|
+
}
|
|
44
|
+
.bui-popover.popover-top .bui-popover-arrow {
|
|
45
|
+
border-left: var(--arrow-size) solid transparent;
|
|
46
|
+
border-right: var(--arrow-size) solid transparent;
|
|
47
|
+
border-top: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
48
|
+
bottom: 0;
|
|
49
|
+
}
|
|
50
|
+
.bui-popover.popover-bottom {
|
|
51
|
+
padding-top: var(--arrow-size);
|
|
52
|
+
}
|
|
53
|
+
.bui-popover.popover-bottom .bui-popover-arrow {
|
|
54
|
+
border-left: var(--arrow-size) solid transparent;
|
|
55
|
+
border-right: var(--arrow-size) solid transparent;
|
|
56
|
+
border-bottom: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
57
|
+
top: 0;
|
|
58
|
+
}
|
|
59
|
+
.bui-popover.popover-left {
|
|
60
|
+
padding-right: var(--arrow-size);
|
|
61
|
+
}
|
|
62
|
+
.bui-popover.popover-left .bui-popover-arrow {
|
|
63
|
+
border-top: var(--arrow-size) solid transparent;
|
|
64
|
+
border-bottom: var(--arrow-size) solid transparent;
|
|
65
|
+
border-left: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
66
|
+
right: 0;
|
|
67
|
+
}
|
|
68
|
+
.bui-popover.popover-right {
|
|
69
|
+
padding-left: var(--arrow-size);
|
|
70
|
+
}
|
|
71
|
+
.bui-popover.popover-right .bui-popover-arrow {
|
|
72
|
+
border-top: var(--arrow-size) solid transparent;
|
|
73
|
+
border-bottom: var(--arrow-size) solid transparent;
|
|
74
|
+
border-right: var(--arrow-size) solid var(--bui-color-bg-view);
|
|
75
|
+
left: 0;
|
|
76
|
+
}
|
|
77
|
+
.bui-popover .bui-popover-title {
|
|
78
|
+
font-weight: var(--bui-font-weight-bold);
|
|
79
|
+
}
|
|
80
|
+
.bui-popover .bui-popover-content {
|
|
81
|
+
min-width: var(--content-min-width);
|
|
82
|
+
min-height: var(--content-min-height);
|
|
83
|
+
padding: var(--content-padding);
|
|
84
|
+
color: var(--bui-color-fg-muted);
|
|
85
|
+
text-align: left;
|
|
86
|
+
text-decoration: none;
|
|
87
|
+
word-wrap: break-word;
|
|
88
|
+
background-color: var(--bui-color-bg-popover);
|
|
89
|
+
border-radius: var(--bui-shape-radius-poster);
|
|
90
|
+
box-shadow:
|
|
91
|
+
0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
92
|
+
0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
93
|
+
0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
94
|
+
}
|
|
95
|
+
.bui-popover .bui-popover-content div:nth-child(2) {
|
|
96
|
+
margin-top: var(--bui-spacing-md);
|
|
97
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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 Popover_exports = {};
|
|
58
|
+
__export(Popover_exports, {
|
|
59
|
+
default: () => Popover_default
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(Popover_exports);
|
|
62
|
+
var import_clsx = __toESM(require("clsx"));
|
|
63
|
+
var import_react = __toESM(require("react"));
|
|
64
|
+
var import_utils = require("@bifrostui/utils");
|
|
65
|
+
var import_Portal = __toESM(require("../Portal"));
|
|
66
|
+
var import_Popover = require("./Popover.css");
|
|
67
|
+
const prefixCls = "bui-popover";
|
|
68
|
+
const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
69
|
+
const _a = props, {
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
children,
|
|
73
|
+
title,
|
|
74
|
+
content,
|
|
75
|
+
defaultOpen,
|
|
76
|
+
placement = "top",
|
|
77
|
+
trigger,
|
|
78
|
+
onOpenChange,
|
|
79
|
+
open,
|
|
80
|
+
hideArrow,
|
|
81
|
+
PortalProps
|
|
82
|
+
} = _a, others = __objRest(_a, [
|
|
83
|
+
"className",
|
|
84
|
+
"style",
|
|
85
|
+
"children",
|
|
86
|
+
"title",
|
|
87
|
+
"content",
|
|
88
|
+
"defaultOpen",
|
|
89
|
+
"placement",
|
|
90
|
+
"trigger",
|
|
91
|
+
"onOpenChange",
|
|
92
|
+
"open",
|
|
93
|
+
"hideArrow",
|
|
94
|
+
"PortalProps"
|
|
95
|
+
]);
|
|
96
|
+
const positionArr = placement.split(/([A-Z])/);
|
|
97
|
+
const direction = positionArr[0];
|
|
98
|
+
let location;
|
|
99
|
+
if (positionArr.length > 1) {
|
|
100
|
+
positionArr.splice(0, 1);
|
|
101
|
+
location = positionArr.join("").toLowerCase();
|
|
102
|
+
} else {
|
|
103
|
+
location = "center";
|
|
104
|
+
}
|
|
105
|
+
const childrenRef = (0, import_react.useRef)();
|
|
106
|
+
const [openStatus, setOpenStatus] = (0, import_react.useState)(defaultOpen);
|
|
107
|
+
const [arrowDirection, setArrowDirection] = (0, import_react.useState)(direction);
|
|
108
|
+
const [arrowLocation, setArrowLocation] = (0, import_react.useState)(location);
|
|
109
|
+
const [tooltyles, setTooltyles] = (0, import_react.useState)({});
|
|
110
|
+
const ttId = (0, import_utils.useUniqueId)();
|
|
111
|
+
const onRootElementMouted = () => {
|
|
112
|
+
const result = (0, import_utils.getStylesAndLocation)({
|
|
113
|
+
childrenRef,
|
|
114
|
+
arrowDirection,
|
|
115
|
+
arrowLocation,
|
|
116
|
+
selector: `[data-id="tt_${ttId}"]`
|
|
117
|
+
});
|
|
118
|
+
if (!result)
|
|
119
|
+
return;
|
|
120
|
+
const { styles, newArrowDirection, newArrowLocation } = result;
|
|
121
|
+
if (newArrowDirection !== arrowDirection) {
|
|
122
|
+
setArrowDirection(newArrowDirection);
|
|
123
|
+
}
|
|
124
|
+
if (newArrowLocation !== arrowLocation) {
|
|
125
|
+
setArrowLocation(newArrowLocation);
|
|
126
|
+
}
|
|
127
|
+
setTooltyles(styles);
|
|
128
|
+
};
|
|
129
|
+
const changeOpenStatus = (event, status) => {
|
|
130
|
+
if (open)
|
|
131
|
+
return;
|
|
132
|
+
setOpenStatus(status);
|
|
133
|
+
onOpenChange == null ? void 0 : onOpenChange(event, { open: status });
|
|
134
|
+
};
|
|
135
|
+
const triggerClick = (event) => {
|
|
136
|
+
const targetStatus = !openStatus;
|
|
137
|
+
changeOpenStatus(event, targetStatus);
|
|
138
|
+
};
|
|
139
|
+
const hidePopover = (event) => {
|
|
140
|
+
changeOpenStatus(event, false);
|
|
141
|
+
};
|
|
142
|
+
const showPopover = (event) => {
|
|
143
|
+
changeOpenStatus(event, true);
|
|
144
|
+
};
|
|
145
|
+
if (!title && !content)
|
|
146
|
+
return null;
|
|
147
|
+
const triggerEventOption = (0, import_utils.triggerEventTransform)({
|
|
148
|
+
trigger,
|
|
149
|
+
click: triggerClick,
|
|
150
|
+
show: showPopover,
|
|
151
|
+
hide: hidePopover
|
|
152
|
+
});
|
|
153
|
+
const childrenOptions = __spreadValues({
|
|
154
|
+
ref: childrenRef
|
|
155
|
+
}, triggerEventOption);
|
|
156
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, open || openStatus ? /* @__PURE__ */ import_react.default.createElement(
|
|
157
|
+
import_Portal.default,
|
|
158
|
+
__spreadProps(__spreadValues({
|
|
159
|
+
onRootElementMouted
|
|
160
|
+
}, PortalProps), {
|
|
161
|
+
ref
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
164
|
+
"div",
|
|
165
|
+
__spreadValues({
|
|
166
|
+
className: (0, import_clsx.default)(prefixCls, className, `popover-${arrowDirection}`, {
|
|
167
|
+
"bui-popover-arrow-hide": hideArrow
|
|
168
|
+
}),
|
|
169
|
+
"data-id": `tt_${ttId}`,
|
|
170
|
+
style: __spreadValues(__spreadValues({}, style), tooltyles)
|
|
171
|
+
}, others),
|
|
172
|
+
!hideArrow ? /* @__PURE__ */ import_react.default.createElement(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: (0, import_clsx.default)(
|
|
176
|
+
"bui-popover-arrow",
|
|
177
|
+
`location-${arrowLocation}`
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
) : null,
|
|
181
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "bui-popover-content" }, title ? /* @__PURE__ */ import_react.default.createElement("div", { className: "bui-popover-title" }, title) : null, content ? /* @__PURE__ */ import_react.default.createElement("div", { className: "bui-popover-inner-content" }, content) : null)
|
|
182
|
+
)
|
|
183
|
+
) : null, import_react.default.isValidElement(children) ? import_react.default.cloneElement(children, childrenOptions) : children);
|
|
184
|
+
});
|
|
185
|
+
Popover.displayName = "BuiPopover";
|
|
186
|
+
var Popover_default = Popover;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OverrideProps } from '@bifrostui/types';
|
|
3
|
+
import { PortalCoreProps } from '../Portal/Portal.types';
|
|
4
|
+
type triggerType = 'click' | 'hover';
|
|
5
|
+
export type PopoverProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
|
|
6
|
+
props: P & {
|
|
7
|
+
/**
|
|
8
|
+
* 默认是否显隐
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
defaultOpen?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 用于手动控制浮层显隐
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
open?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 浮层的标题
|
|
19
|
+
*/
|
|
20
|
+
title?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* 浮层的内容
|
|
23
|
+
*/
|
|
24
|
+
content?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* 是否展示箭头
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
hideArrow?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 气泡框位置
|
|
32
|
+
* @default 'top'
|
|
33
|
+
*/
|
|
34
|
+
placement?: 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
35
|
+
/**
|
|
36
|
+
* 触发行为
|
|
37
|
+
* - click: 点击触发
|
|
38
|
+
* - hover: hover触发
|
|
39
|
+
* - 或者是他们的数组
|
|
40
|
+
* @default 'click'
|
|
41
|
+
*/
|
|
42
|
+
trigger?: triggerType | triggerType[];
|
|
43
|
+
/**
|
|
44
|
+
* Portal组件的属性
|
|
45
|
+
*/
|
|
46
|
+
PortalProps?: PortalCoreProps;
|
|
47
|
+
/**
|
|
48
|
+
* 点击事件回调方法
|
|
49
|
+
* - event 触发事件
|
|
50
|
+
* - data.open 浮层显隐状态
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
onOpenChange?: (event: React.SyntheticEvent, data: {
|
|
54
|
+
open: boolean;
|
|
55
|
+
}) => void;
|
|
56
|
+
};
|
|
57
|
+
defaultComponent: D;
|
|
58
|
+
}, D>;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var Popover_types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(Popover_types_exports);
|