@bifrostui/react 1.4.1 → 1.4.2-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.
@@ -68,7 +68,6 @@ var import_react = __toESM(require("react"));
68
68
  var import_utils2 = require("./utils");
69
69
  var import_locales = require("../locales");
70
70
  var import_Calendar2 = require("./Calendar.css");
71
- const Picker = (0, import_react.lazy)(() => import("../Picker"));
72
71
  import_dayjs.default.extend(import_isoWeek.default);
73
72
  const classes = {
74
73
  root: "bui-calendar",
@@ -91,12 +90,10 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
91
90
  headerBarLeftIcon,
92
91
  headerBarRightIcon,
93
92
  disabledDate,
94
- enableSelectYear,
95
93
  highlightDate,
96
94
  dateRender,
97
95
  weekRender,
98
96
  onMonthChange,
99
- onYearChange,
100
97
  onChange
101
98
  } = _a, others = __objRest(_a, [
102
99
  "className",
@@ -110,12 +107,10 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
110
107
  "headerBarLeftIcon",
111
108
  "headerBarRightIcon",
112
109
  "disabledDate",
113
- "enableSelectYear",
114
110
  "highlightDate",
115
111
  "dateRender",
116
112
  "weekRender",
117
113
  "onMonthChange",
118
- "onYearChange",
119
114
  "onChange"
120
115
  ]);
121
116
  const { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } = (0, import_locales.useLocaleText)("calendar");
@@ -136,7 +131,6 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
136
131
  minDate,
137
132
  maxDate
138
133
  );
139
- const [openPicker, setOpenPicker] = (0, import_react.useState)(false);
140
134
  const [renderMonth, setRenderMonth] = (0, import_react.useState)(() => {
141
135
  const initMonth = formattedValue === void 0 ? formattedDefaultValue == null ? void 0 : formattedDefaultValue[0] : formattedValue == null ? void 0 : formattedValue[0];
142
136
  return (0, import_dayjs.default)(initMonth || minDate).toDate();
@@ -215,19 +209,6 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
215
209
  });
216
210
  return list;
217
211
  };
218
- const getYearsList = () => {
219
- const result = [];
220
- let startTime = new Date(minDate).getFullYear();
221
- const endTime = new Date(maxDate).getFullYear();
222
- while (endTime - startTime >= 0) {
223
- result.push({
224
- label: startTime,
225
- value: startTime
226
- });
227
- startTime += 1;
228
- }
229
- return result;
230
- };
231
212
  const getDayClassName = ({ day: itemDate, disabled }) => {
232
213
  let result = "";
233
214
  if (disabled)
@@ -320,23 +301,6 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
320
301
  });
321
302
  }
322
303
  };
323
- const onClickDate = (e) => {
324
- if (!enableSelectYear) {
325
- return;
326
- }
327
- e.stopPropagation();
328
- setOpenPicker(true);
329
- getYearsList();
330
- };
331
- const onClosePicker = (e, data2) => {
332
- const selectYear = data2.value[0];
333
- e.stopPropagation();
334
- setRenderMonth((0, import_dayjs.default)(renderMonth).set("year", selectYear).toDate());
335
- onYearChange == null ? void 0 : onYearChange(e, {
336
- year: selectYear
337
- });
338
- setOpenPicker(false);
339
- };
340
304
  let data = {};
341
305
  if (isRangeMode) {
342
306
  data = {
@@ -358,20 +322,11 @@ const Calendar = /* @__PURE__ */ import_react.default.forwardRef(
358
322
  }, others), {
359
323
  "data-mode": mode
360
324
  }), data),
361
- /* @__PURE__ */ import_react.default.createElement("div", { className: classes.handler }, /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickPrev, className: `${classes.handler}-btn` }, headerBarIcon.left), /* @__PURE__ */ import_react.default.createElement("div", { className: `${classes.handler}-text`, onClick: onClickDate }, (0, import_dayjs.default)(renderMonth).format(headerBarFormat)), /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickNext, className: `${classes.handler}-btn` }, headerBarIcon.right)),
325
+ /* @__PURE__ */ import_react.default.createElement("div", { className: classes.handler }, /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickPrev, className: `${classes.handler}-btn` }, headerBarIcon.left), /* @__PURE__ */ import_react.default.createElement("div", { className: `${classes.handler}-text` }, (0, import_dayjs.default)(renderMonth).format(headerBarFormat)), /* @__PURE__ */ import_react.default.createElement("div", { onClick: onClickNext, className: `${classes.handler}-btn` }, headerBarIcon.right)),
362
326
  /* @__PURE__ */ import_react.default.createElement("div", { className: classes.week }, SUNDAY_WEEK_DATA == null ? void 0 : SUNDAY_WEEK_DATA.map((w) => {
363
327
  return weekRender ? weekRender(w) : /* @__PURE__ */ import_react.default.createElement("div", { key: w, className: `${classes.week}-item` }, w);
364
328
  })),
365
- /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_clsx.default)(`${classes.root}-month`) }, renderDayList()),
366
- enableSelectYear && /* @__PURE__ */ import_react.default.createElement(import_react.Suspense, { fallback: null }, /* @__PURE__ */ import_react.default.createElement(
367
- Picker,
368
- {
369
- options: [getYearsList()],
370
- open: openPicker,
371
- value: [(0, import_dayjs.default)(renderMonth).year()],
372
- onClose: onClosePicker
373
- }
374
- ))
329
+ /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_clsx.default)(`${classes.root}-month`) }, renderDayList())
375
330
  );
376
331
  }
377
332
  );
@@ -379,7 +334,6 @@ Calendar.displayName = "BuiCalendar";
379
334
  Calendar.defaultProps = {
380
335
  hideDaysOutsideCurrentMonth: false,
381
336
  headerBarFormat: "YYYY/MM",
382
- enableSelectYear: false,
383
337
  mode: "single",
384
338
  minDate: (0, import_dayjs.default)((0, import_dayjs.default)().format("YYYYMMDD")).add(0, "month").toDate(),
385
339
  maxDate: (0, import_dayjs.default)((0, import_dayjs.default)().format("YYYYMMDD")).add(11, "month").toDate(),
@@ -12,10 +12,6 @@ export interface ICalendarMonthChangeData {
12
12
  /** 操作类型,prev: 点击上个月 next: 点击下个月 */
13
13
  type: 'prev' | 'next';
14
14
  }
15
- export interface ICalendarYearChangeData {
16
- /** 切换后的年份 */
17
- year: number;
18
- }
19
15
  export interface ICustomIconProps {
20
16
  /** 是否为可选范围内的最小月份 */
21
17
  isMinMonth?: boolean;
@@ -86,14 +82,6 @@ export type CalendarProps<D extends React.ElementType = 'div', P = {}> = Overrid
86
82
  * 自定义周单元格的内容
87
83
  */
88
84
  weekRender?: (week: string) => React.ReactNode;
89
- /**
90
- * 是否开启选择年
91
- */
92
- enableSelectYear?: boolean;
93
- /**
94
- * 年份发生变化的回调
95
- */
96
- onYearChange?: (e: React.SyntheticEvent, data: ICalendarYearChangeData) => void;
97
85
  /**
98
86
  * 月份发生变化的回调
99
87
  */
@@ -39,10 +39,6 @@
39
39
  outline: none;
40
40
  background-color: var(--background-color);
41
41
  font-size: var(--bui-text-size-2);
42
- width: auto;
43
- overflow: hidden;
44
- text-overflow: ellipsis;
45
- white-space: nowrap;
46
42
  }
47
43
  .bui-input-input::placeholder {
48
44
  color: var(--bui-color-fg-subtle);
@@ -3,7 +3,7 @@
3
3
  --localtion-position: var(--bui-popover-localtion-position, 8PX);
4
4
  --max-width: var(--bui-popover-max-width, 350px);
5
5
  --content-min-width: var(--bui-popover-content-min-width, 30px);
6
- --content-padding: var(--bui-popover-content-padding, 0);
6
+ --content-padding: var(--bui-popover-content-padding, 6px 8px);
7
7
  max-width: var(--max-width);
8
8
  font-size: var(--bui-text-size-1);
9
9
  position: absolute;
@@ -70,6 +70,7 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
70
70
  title,
71
71
  content,
72
72
  defaultOpen,
73
+ offsetSpacing = 0,
73
74
  placement = "top",
74
75
  trigger = "click",
75
76
  onOpenChange,
@@ -82,6 +83,7 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
82
83
  "title",
83
84
  "content",
84
85
  "defaultOpen",
86
+ "offsetSpacing",
85
87
  "placement",
86
88
  "trigger",
87
89
  "onOpenChange",
@@ -136,6 +138,7 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
136
138
  childrenRef,
137
139
  arrowDirection,
138
140
  arrowLocation,
141
+ offsetSpacing,
139
142
  selector: `[data-id="tt_${ttId}"]`
140
143
  });
141
144
  if (!result)
@@ -25,6 +25,10 @@ export type PopoverProps<D extends React.ElementType = 'div', P = {}> = Override
25
25
  * @default false
26
26
  */
27
27
  hideArrow?: boolean;
28
+ /**
29
+ * 用于控制浮层和目标元素偏移量
30
+ */
31
+ offsetSpacing?: number;
28
32
  /**
29
33
  * 气泡框位置
30
34
  * @default 'top'
@@ -61,7 +61,19 @@ var import_react = __toESM(require("react"));
61
61
  var import_TabPanel = require("./TabPanel.css");
62
62
  const prefixCls = "bui-tabpanel";
63
63
  const TabPanel = (0, import_react.forwardRef)((props, ref) => {
64
- const _a = props, { className, children, value, index, keepMounted } = _a, others = __objRest(_a, ["className", "children", "value", "index", "keepMounted"]);
64
+ const _a = props, {
65
+ className,
66
+ children,
67
+ value,
68
+ index,
69
+ keepMounted = false
70
+ } = _a, others = __objRest(_a, [
71
+ "className",
72
+ "children",
73
+ "value",
74
+ "index",
75
+ "keepMounted"
76
+ ]);
65
77
  const keepActiveDom = keepMounted ? children : null;
66
78
  return /* @__PURE__ */ import_react.default.createElement(
67
79
  "div",
@@ -76,7 +88,4 @@ const TabPanel = (0, import_react.forwardRef)((props, ref) => {
76
88
  );
77
89
  });
78
90
  TabPanel.displayName = "BuiTabPanel";
79
- TabPanel.defaultProps = {
80
- keepMounted: false
81
- };
82
91
  var TabPanel_default = TabPanel;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import './Tabs.less';
3
2
  import { TabsProps } from './Tabs.types';
3
+ import './Tabs.less';
4
4
  declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
5
  export default Tabs;
package/dist/Tabs/Tabs.js CHANGED
@@ -60,9 +60,9 @@ var import_utils = require("@bifrostui/utils");
60
60
  var import_clsx = __toESM(require("clsx"));
61
61
  var import_react = __toESM(require("react"));
62
62
  var import_Tab = __toESM(require("./Tab"));
63
- var import_Tabs = require("./Tabs.css");
64
63
  var import_TabsContext = require("./TabsContext");
65
64
  var import_bound = __toESM(require("./utils/bound"));
65
+ var import_Tabs2 = require("./Tabs.css");
66
66
  const prefixCls = "bui-tabs";
67
67
  const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
68
68
  const _a = props, { children, className, value, tabs, align, onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "align", "onChange"]);
@@ -81,16 +81,13 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
81
81
  const container = tabsRef.current;
82
82
  if (!container)
83
83
  return;
84
- const activeIndex = !!tabs.length && tabs.findIndex((item) => {
85
- var _a2;
86
- return item.index === (active || ((_a2 = tabs[0]) == null ? void 0 : _a2.index));
87
- });
84
+ const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === active);
88
85
  const activeLine = activeLineRef.current;
89
86
  if (!activeLine)
90
87
  return;
91
88
  let activeTab;
92
89
  if (tabs.length) {
93
- activeTab = container.childNodes[activeIndex + 1];
90
+ activeTab = activeIndex > -1 ? container.childNodes[activeIndex + 1] : void 0;
94
91
  } else {
95
92
  activeTab = [...container.childNodes].find((child) => {
96
93
  if (import_utils.isMini) {
@@ -101,20 +98,26 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
101
98
  return [...child.classList].includes("bui-tab-active");
102
99
  });
103
100
  }
104
- if (!activeTab)
105
- return;
106
- const activeTabLeft = activeTab.offsetLeft;
107
- const activeTabWidth = activeTab.offsetWidth;
108
- const containerWidth = container.offsetWidth;
109
- const containerScrollWidth = container.scrollWidth;
110
- const activeLineWidth = activeLine.offsetWidth;
111
- const x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
101
+ let activeTabLeft = 0;
102
+ let activeTabWidth = 0;
103
+ let containerWidth = 0;
104
+ let containerScrollWidth = 0;
105
+ let activeLineWidth = 0;
106
+ let x = 0;
107
+ if (activeTab) {
108
+ activeTabLeft = activeTab.offsetLeft;
109
+ activeTabWidth = activeTab.offsetWidth;
110
+ containerWidth = container.offsetWidth;
111
+ containerScrollWidth = container.scrollWidth;
112
+ activeLineWidth = activeLine.offsetWidth;
113
+ x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
114
+ }
112
115
  setLineData({
113
116
  x,
114
117
  transitionInUse
115
118
  });
116
119
  const maxScrollDistance = containerScrollWidth - containerWidth;
117
- if (maxScrollDistance <= 0)
120
+ if (maxScrollDistance <= 0 || !activeTab)
118
121
  return;
119
122
  const nextScrollLeft = (0, import_bound.default)(
120
123
  activeTabLeft - (containerWidth - activeTabWidth) / 2,
@@ -126,8 +129,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
126
129
  }
127
130
  };
128
131
  (0, import_react.useEffect)(() => {
129
- const defaultIndex = safeValue();
130
- setActive(defaultIndex);
132
+ setActive(value);
131
133
  }, [value]);
132
134
  (0, import_react.useLayoutEffect)(() => {
133
135
  animate({ transitionInUse: false });
@@ -145,26 +147,6 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
145
147
  (0, import_utils.useDidMountEffect)(() => {
146
148
  animate({ transitionInUse: true });
147
149
  }, [active, tabs, children]);
148
- const safeValue = () => {
149
- var _a2;
150
- let defaultIndex = value;
151
- const childs = import_react.default.Children.toArray(children);
152
- const hasSameChild = !!childs.length && childs.some(
153
- (child) => {
154
- var _a3;
155
- return import_react.default.isValidElement(child) && ((_a3 = child == null ? void 0 : child.props) == null ? void 0 : _a3.index) === value;
156
- }
157
- );
158
- if (!!tabs.length && !tabs.some((item) => item.index === value)) {
159
- defaultIndex = (_a2 = tabs[0]) == null ? void 0 : _a2.index;
160
- } else if (children && !hasSameChild) {
161
- const childNode = childs[0];
162
- if (import_react.default.isValidElement(childNode)) {
163
- defaultIndex = childNode.props.index;
164
- }
165
- }
166
- return defaultIndex;
167
- };
168
150
  const updateMask = (0, import_react.useMemo)(
169
151
  () => (0, import_utils.throttle)(
170
152
  () => {
@@ -205,8 +187,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
205
187
  }
206
188
  };
207
189
  const providerValue = (0, import_react.useMemo)(() => {
208
- const v = safeValue();
209
- return { value: v, align, triggerChange: handleClick };
190
+ return { value, align, triggerChange: handleClick };
210
191
  }, [value, align, children, handleClick]);
211
192
  return /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(prefixCls, className) }, others), /* @__PURE__ */ import_react.default.createElement(
212
193
  "div",
@@ -229,7 +210,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
229
210
  {
230
211
  ref: activeLineRef,
231
212
  className: (0, import_clsx.default)(`${prefixCls}-tabline`, {
232
- "bui-tabline-invisible": import_utils.isMini
213
+ "bui-tabline-invisible": import_utils.isMini || !lineData.x
233
214
  }),
234
215
  style: {
235
216
  transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
@@ -69,6 +69,7 @@ const Tooltip = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
69
69
  children,
70
70
  title,
71
71
  defaultOpen,
72
+ offsetSpacing = 0,
72
73
  placement = "top",
73
74
  trigger = "click",
74
75
  onOpenChange,
@@ -79,6 +80,7 @@ const Tooltip = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
79
80
  "children",
80
81
  "title",
81
82
  "defaultOpen",
83
+ "offsetSpacing",
82
84
  "placement",
83
85
  "trigger",
84
86
  "onOpenChange",
@@ -132,6 +134,7 @@ const Tooltip = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
132
134
  childrenRef,
133
135
  arrowDirection,
134
136
  arrowLocation,
137
+ offsetSpacing,
135
138
  selector: `[data-id="tt_${ttId}"]`
136
139
  });
137
140
  if (!result)
@@ -16,6 +16,10 @@ export type TooltipProps<D extends React.ElementType = 'div', P = {}> = Override
16
16
  * 用于手动控制气泡浮层显隐
17
17
  */
18
18
  open?: boolean;
19
+ /**
20
+ * 用于控制气泡浮层和目标元素偏移量
21
+ */
22
+ offsetSpacing?: number;
19
23
  /**
20
24
  * 气泡框位置
21
25
  * @default 'top'
@@ -34,16 +34,10 @@ import { useDidMountEffect, useValue } from "@bifrostui/utils";
34
34
  import clsx from "clsx";
35
35
  import dayjs from "dayjs";
36
36
  import isoWeek from "dayjs/plugin/isoWeek";
37
- import React, {
38
- Suspense,
39
- lazy,
40
- useMemo,
41
- useState
42
- } from "react";
37
+ import React, { useMemo, useState } from "react";
43
38
  import { formatDate, isRange, isSame } from "./utils";
44
39
  import { useLocaleText } from "../locales";
45
40
  import "./Calendar.css";
46
- const Picker = lazy(() => import("../Picker"));
47
41
  dayjs.extend(isoWeek);
48
42
  const classes = {
49
43
  root: "bui-calendar",
@@ -66,12 +60,10 @@ const Calendar = /* @__PURE__ */ React.forwardRef(
66
60
  headerBarLeftIcon,
67
61
  headerBarRightIcon,
68
62
  disabledDate,
69
- enableSelectYear,
70
63
  highlightDate,
71
64
  dateRender,
72
65
  weekRender,
73
66
  onMonthChange,
74
- onYearChange,
75
67
  onChange
76
68
  } = _a, others = __objRest(_a, [
77
69
  "className",
@@ -85,12 +77,10 @@ const Calendar = /* @__PURE__ */ React.forwardRef(
85
77
  "headerBarLeftIcon",
86
78
  "headerBarRightIcon",
87
79
  "disabledDate",
88
- "enableSelectYear",
89
80
  "highlightDate",
90
81
  "dateRender",
91
82
  "weekRender",
92
83
  "onMonthChange",
93
- "onYearChange",
94
84
  "onChange"
95
85
  ]);
96
86
  const { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } = useLocaleText("calendar");
@@ -111,7 +101,6 @@ const Calendar = /* @__PURE__ */ React.forwardRef(
111
101
  minDate,
112
102
  maxDate
113
103
  );
114
- const [openPicker, setOpenPicker] = useState(false);
115
104
  const [renderMonth, setRenderMonth] = useState(() => {
116
105
  const initMonth = formattedValue === void 0 ? formattedDefaultValue == null ? void 0 : formattedDefaultValue[0] : formattedValue == null ? void 0 : formattedValue[0];
117
106
  return dayjs(initMonth || minDate).toDate();
@@ -190,19 +179,6 @@ const Calendar = /* @__PURE__ */ React.forwardRef(
190
179
  });
191
180
  return list;
192
181
  };
193
- const getYearsList = () => {
194
- const result = [];
195
- let startTime = new Date(minDate).getFullYear();
196
- const endTime = new Date(maxDate).getFullYear();
197
- while (endTime - startTime >= 0) {
198
- result.push({
199
- label: startTime,
200
- value: startTime
201
- });
202
- startTime += 1;
203
- }
204
- return result;
205
- };
206
182
  const getDayClassName = ({ day: itemDate, disabled }) => {
207
183
  let result = "";
208
184
  if (disabled)
@@ -295,23 +271,6 @@ const Calendar = /* @__PURE__ */ React.forwardRef(
295
271
  });
296
272
  }
297
273
  };
298
- const onClickDate = (e) => {
299
- if (!enableSelectYear) {
300
- return;
301
- }
302
- e.stopPropagation();
303
- setOpenPicker(true);
304
- getYearsList();
305
- };
306
- const onClosePicker = (e, data2) => {
307
- const selectYear = data2.value[0];
308
- e.stopPropagation();
309
- setRenderMonth(dayjs(renderMonth).set("year", selectYear).toDate());
310
- onYearChange == null ? void 0 : onYearChange(e, {
311
- year: selectYear
312
- });
313
- setOpenPicker(false);
314
- };
315
274
  let data = {};
316
275
  if (isRangeMode) {
317
276
  data = {
@@ -333,20 +292,11 @@ const Calendar = /* @__PURE__ */ React.forwardRef(
333
292
  }, others), {
334
293
  "data-mode": mode
335
294
  }), data),
336
- /* @__PURE__ */ React.createElement("div", { className: classes.handler }, /* @__PURE__ */ React.createElement("div", { onClick: onClickPrev, className: `${classes.handler}-btn` }, headerBarIcon.left), /* @__PURE__ */ React.createElement("div", { className: `${classes.handler}-text`, onClick: onClickDate }, dayjs(renderMonth).format(headerBarFormat)), /* @__PURE__ */ React.createElement("div", { onClick: onClickNext, className: `${classes.handler}-btn` }, headerBarIcon.right)),
295
+ /* @__PURE__ */ React.createElement("div", { className: classes.handler }, /* @__PURE__ */ React.createElement("div", { onClick: onClickPrev, className: `${classes.handler}-btn` }, headerBarIcon.left), /* @__PURE__ */ React.createElement("div", { className: `${classes.handler}-text` }, dayjs(renderMonth).format(headerBarFormat)), /* @__PURE__ */ React.createElement("div", { onClick: onClickNext, className: `${classes.handler}-btn` }, headerBarIcon.right)),
337
296
  /* @__PURE__ */ React.createElement("div", { className: classes.week }, SUNDAY_WEEK_DATA == null ? void 0 : SUNDAY_WEEK_DATA.map((w) => {
338
297
  return weekRender ? weekRender(w) : /* @__PURE__ */ React.createElement("div", { key: w, className: `${classes.week}-item` }, w);
339
298
  })),
340
- /* @__PURE__ */ React.createElement("div", { className: clsx(`${classes.root}-month`) }, renderDayList()),
341
- enableSelectYear && /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(
342
- Picker,
343
- {
344
- options: [getYearsList()],
345
- open: openPicker,
346
- value: [dayjs(renderMonth).year()],
347
- onClose: onClosePicker
348
- }
349
- ))
299
+ /* @__PURE__ */ React.createElement("div", { className: clsx(`${classes.root}-month`) }, renderDayList())
350
300
  );
351
301
  }
352
302
  );
@@ -354,7 +304,6 @@ Calendar.displayName = "BuiCalendar";
354
304
  Calendar.defaultProps = {
355
305
  hideDaysOutsideCurrentMonth: false,
356
306
  headerBarFormat: "YYYY/MM",
357
- enableSelectYear: false,
358
307
  mode: "single",
359
308
  minDate: dayjs(dayjs().format("YYYYMMDD")).add(0, "month").toDate(),
360
309
  maxDate: dayjs(dayjs().format("YYYYMMDD")).add(11, "month").toDate(),
@@ -12,10 +12,6 @@ export interface ICalendarMonthChangeData {
12
12
  /** 操作类型,prev: 点击上个月 next: 点击下个月 */
13
13
  type: 'prev' | 'next';
14
14
  }
15
- export interface ICalendarYearChangeData {
16
- /** 切换后的年份 */
17
- year: number;
18
- }
19
15
  export interface ICustomIconProps {
20
16
  /** 是否为可选范围内的最小月份 */
21
17
  isMinMonth?: boolean;
@@ -86,14 +82,6 @@ export type CalendarProps<D extends React.ElementType = 'div', P = {}> = Overrid
86
82
  * 自定义周单元格的内容
87
83
  */
88
84
  weekRender?: (week: string) => React.ReactNode;
89
- /**
90
- * 是否开启选择年
91
- */
92
- enableSelectYear?: boolean;
93
- /**
94
- * 年份发生变化的回调
95
- */
96
- onYearChange?: (e: React.SyntheticEvent, data: ICalendarYearChangeData) => void;
97
85
  /**
98
86
  * 月份发生变化的回调
99
87
  */
@@ -39,10 +39,6 @@
39
39
  outline: none;
40
40
  background-color: var(--background-color);
41
41
  font-size: var(--bui-text-size-2);
42
- width: auto;
43
- overflow: hidden;
44
- text-overflow: ellipsis;
45
- white-space: nowrap;
46
42
  }
47
43
  .bui-input-input::placeholder {
48
44
  color: var(--bui-color-fg-subtle);
@@ -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
- }, "open" | keyof import("@bifrostui/types").ICommonProps | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, keyof import("@bifrostui/types").ICommonProps | "open" | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Modal;
@@ -3,7 +3,7 @@
3
3
  --localtion-position: var(--bui-popover-localtion-position, 8PX);
4
4
  --max-width: var(--bui-popover-max-width, 350px);
5
5
  --content-min-width: var(--bui-popover-content-min-width, 30px);
6
- --content-padding: var(--bui-popover-content-padding, 0);
6
+ --content-padding: var(--bui-popover-content-padding, 6px 8px);
7
7
  max-width: var(--max-width);
8
8
  font-size: var(--bui-text-size-1);
9
9
  position: absolute;
@@ -45,6 +45,7 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
45
45
  title,
46
46
  content,
47
47
  defaultOpen,
48
+ offsetSpacing = 0,
48
49
  placement = "top",
49
50
  trigger = "click",
50
51
  onOpenChange,
@@ -57,6 +58,7 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
57
58
  "title",
58
59
  "content",
59
60
  "defaultOpen",
61
+ "offsetSpacing",
60
62
  "placement",
61
63
  "trigger",
62
64
  "onOpenChange",
@@ -111,6 +113,7 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
111
113
  childrenRef,
112
114
  arrowDirection,
113
115
  arrowLocation,
116
+ offsetSpacing,
114
117
  selector: `[data-id="tt_${ttId}"]`
115
118
  });
116
119
  if (!result)
@@ -25,6 +25,10 @@ export type PopoverProps<D extends React.ElementType = 'div', P = {}> = Override
25
25
  * @default false
26
26
  */
27
27
  hideArrow?: boolean;
28
+ /**
29
+ * 用于控制浮层和目标元素偏移量
30
+ */
31
+ offsetSpacing?: number;
28
32
  /**
29
33
  * 气泡框位置
30
34
  * @default 'top'
@@ -31,7 +31,19 @@ import React, { forwardRef } from "react";
31
31
  import "./TabPanel.css";
32
32
  const prefixCls = "bui-tabpanel";
33
33
  const TabPanel = forwardRef((props, ref) => {
34
- const _a = props, { className, children, value, index, keepMounted } = _a, others = __objRest(_a, ["className", "children", "value", "index", "keepMounted"]);
34
+ const _a = props, {
35
+ className,
36
+ children,
37
+ value,
38
+ index,
39
+ keepMounted = false
40
+ } = _a, others = __objRest(_a, [
41
+ "className",
42
+ "children",
43
+ "value",
44
+ "index",
45
+ "keepMounted"
46
+ ]);
35
47
  const keepActiveDom = keepMounted ? children : null;
36
48
  return /* @__PURE__ */ React.createElement(
37
49
  "div",
@@ -46,9 +58,6 @@ const TabPanel = forwardRef((props, ref) => {
46
58
  );
47
59
  });
48
60
  TabPanel.displayName = "BuiTabPanel";
49
- TabPanel.defaultProps = {
50
- keepMounted: false
51
- };
52
61
  var TabPanel_default = TabPanel;
53
62
  export {
54
63
  TabPanel_default as default
package/es/Tabs/Tabs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import './Tabs.less';
3
2
  import { TabsProps } from './Tabs.types';
3
+ import './Tabs.less';
4
4
  declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
5
  export default Tabs;
package/es/Tabs/Tabs.js CHANGED
@@ -41,9 +41,9 @@ import React, {
41
41
  useState
42
42
  } from "react";
43
43
  import Tab from "./Tab";
44
- import "./Tabs.css";
45
44
  import { TabsContextProvider } from "./TabsContext";
46
45
  import bound from "./utils/bound";
46
+ import "./Tabs.css";
47
47
  const prefixCls = "bui-tabs";
48
48
  const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
49
49
  const _a = props, { children, className, value, tabs, align, onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "align", "onChange"]);
@@ -62,16 +62,13 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
62
62
  const container = tabsRef.current;
63
63
  if (!container)
64
64
  return;
65
- const activeIndex = !!tabs.length && tabs.findIndex((item) => {
66
- var _a2;
67
- return item.index === (active || ((_a2 = tabs[0]) == null ? void 0 : _a2.index));
68
- });
65
+ const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === active);
69
66
  const activeLine = activeLineRef.current;
70
67
  if (!activeLine)
71
68
  return;
72
69
  let activeTab;
73
70
  if (tabs.length) {
74
- activeTab = container.childNodes[activeIndex + 1];
71
+ activeTab = activeIndex > -1 ? container.childNodes[activeIndex + 1] : void 0;
75
72
  } else {
76
73
  activeTab = [...container.childNodes].find((child) => {
77
74
  if (isMini) {
@@ -82,20 +79,26 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
82
79
  return [...child.classList].includes("bui-tab-active");
83
80
  });
84
81
  }
85
- if (!activeTab)
86
- return;
87
- const activeTabLeft = activeTab.offsetLeft;
88
- const activeTabWidth = activeTab.offsetWidth;
89
- const containerWidth = container.offsetWidth;
90
- const containerScrollWidth = container.scrollWidth;
91
- const activeLineWidth = activeLine.offsetWidth;
92
- const x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
82
+ let activeTabLeft = 0;
83
+ let activeTabWidth = 0;
84
+ let containerWidth = 0;
85
+ let containerScrollWidth = 0;
86
+ let activeLineWidth = 0;
87
+ let x = 0;
88
+ if (activeTab) {
89
+ activeTabLeft = activeTab.offsetLeft;
90
+ activeTabWidth = activeTab.offsetWidth;
91
+ containerWidth = container.offsetWidth;
92
+ containerScrollWidth = container.scrollWidth;
93
+ activeLineWidth = activeLine.offsetWidth;
94
+ x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
95
+ }
93
96
  setLineData({
94
97
  x,
95
98
  transitionInUse
96
99
  });
97
100
  const maxScrollDistance = containerScrollWidth - containerWidth;
98
- if (maxScrollDistance <= 0)
101
+ if (maxScrollDistance <= 0 || !activeTab)
99
102
  return;
100
103
  const nextScrollLeft = bound(
101
104
  activeTabLeft - (containerWidth - activeTabWidth) / 2,
@@ -107,8 +110,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
107
110
  }
108
111
  };
109
112
  useEffect(() => {
110
- const defaultIndex = safeValue();
111
- setActive(defaultIndex);
113
+ setActive(value);
112
114
  }, [value]);
113
115
  useLayoutEffect(() => {
114
116
  animate({ transitionInUse: false });
@@ -126,26 +128,6 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
126
128
  useDidMountEffect(() => {
127
129
  animate({ transitionInUse: true });
128
130
  }, [active, tabs, children]);
129
- const safeValue = () => {
130
- var _a2;
131
- let defaultIndex = value;
132
- const childs = React.Children.toArray(children);
133
- const hasSameChild = !!childs.length && childs.some(
134
- (child) => {
135
- var _a3;
136
- return React.isValidElement(child) && ((_a3 = child == null ? void 0 : child.props) == null ? void 0 : _a3.index) === value;
137
- }
138
- );
139
- if (!!tabs.length && !tabs.some((item) => item.index === value)) {
140
- defaultIndex = (_a2 = tabs[0]) == null ? void 0 : _a2.index;
141
- } else if (children && !hasSameChild) {
142
- const childNode = childs[0];
143
- if (React.isValidElement(childNode)) {
144
- defaultIndex = childNode.props.index;
145
- }
146
- }
147
- return defaultIndex;
148
- };
149
131
  const updateMask = useMemo(
150
132
  () => throttle(
151
133
  () => {
@@ -186,8 +168,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
186
168
  }
187
169
  };
188
170
  const providerValue = useMemo(() => {
189
- const v = safeValue();
190
- return { value: v, align, triggerChange: handleClick };
171
+ return { value, align, triggerChange: handleClick };
191
172
  }, [value, align, children, handleClick]);
192
173
  return /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), /* @__PURE__ */ React.createElement(
193
174
  "div",
@@ -210,7 +191,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
210
191
  {
211
192
  ref: activeLineRef,
212
193
  className: clsx(`${prefixCls}-tabline`, {
213
- "bui-tabline-invisible": isMini
194
+ "bui-tabline-invisible": isMini || !lineData.x
214
195
  }),
215
196
  style: {
216
197
  transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
@@ -44,6 +44,7 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
44
44
  children,
45
45
  title,
46
46
  defaultOpen,
47
+ offsetSpacing = 0,
47
48
  placement = "top",
48
49
  trigger = "click",
49
50
  onOpenChange,
@@ -54,6 +55,7 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
54
55
  "children",
55
56
  "title",
56
57
  "defaultOpen",
58
+ "offsetSpacing",
57
59
  "placement",
58
60
  "trigger",
59
61
  "onOpenChange",
@@ -107,6 +109,7 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
107
109
  childrenRef,
108
110
  arrowDirection,
109
111
  arrowLocation,
112
+ offsetSpacing,
110
113
  selector: `[data-id="tt_${ttId}"]`
111
114
  });
112
115
  if (!result)
@@ -16,6 +16,10 @@ export type TooltipProps<D extends React.ElementType = 'div', P = {}> = Override
16
16
  * 用于手动控制气泡浮层显隐
17
17
  */
18
18
  open?: boolean;
19
+ /**
20
+ * 用于控制气泡浮层和目标元素偏移量
21
+ */
22
+ offsetSpacing?: number;
19
23
  /**
20
24
  * 气泡框位置
21
25
  * @default 'top'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/react",
3
- "version": "1.4.1",
3
+ "version": "1.4.2-beta.1",
4
4
  "description": "React components for building mobile application",
5
5
  "homepage": "http://bui.taopiaopiao.com",
6
6
  "license": "MIT",
@@ -33,10 +33,10 @@
33
33
  "clsx": "^1.2.1",
34
34
  "dayjs": "^1.11.7",
35
35
  "swiper": "^8.1.5",
36
- "@bifrostui/icons": "1.4.1",
37
- "@bifrostui/styles": "1.4.1",
38
- "@bifrostui/types": "1.4.1",
39
- "@bifrostui/utils": "1.4.1"
36
+ "@bifrostui/icons": "1.4.2-beta.1",
37
+ "@bifrostui/styles": "1.4.2-beta.1",
38
+ "@bifrostui/types": "1.4.2-beta.1",
39
+ "@bifrostui/utils": "1.4.2-beta.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@tarojs/components": "^3.0.0",