@bifrostui/react 1.4.2-beta.1 → 1.4.2
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/Input/Input.css +4 -0
- package/dist/Popover/Popover.css +1 -1
- package/dist/Popover/Popover.js +0 -3
- package/dist/Popover/Popover.types.d.ts +0 -4
- package/dist/Tabs/TabPanel.js +4 -13
- package/dist/Tabs/Tabs.d.ts +1 -1
- package/dist/Tabs/Tabs.js +40 -21
- package/dist/Tooltip/Tooltip.js +0 -3
- package/dist/Tooltip/Tooltip.types.d.ts +0 -4
- package/es/Input/Input.css +4 -0
- package/es/Modal/Modal.miniapp.d.ts +1 -1
- package/es/Popover/Popover.css +1 -1
- package/es/Popover/Popover.js +0 -3
- package/es/Popover/Popover.types.d.ts +0 -4
- package/es/Tabs/TabPanel.js +4 -13
- package/es/Tabs/Tabs.d.ts +1 -1
- package/es/Tabs/Tabs.js +40 -21
- package/es/Tooltip/Tooltip.js +0 -3
- package/es/Tooltip/Tooltip.types.d.ts +0 -4
- package/package.json +5 -5
package/dist/Input/Input.css
CHANGED
|
@@ -39,6 +39,10 @@
|
|
|
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;
|
|
42
46
|
}
|
|
43
47
|
.bui-input-input::placeholder {
|
|
44
48
|
color: var(--bui-color-fg-subtle);
|
package/dist/Popover/Popover.css
CHANGED
|
@@ -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,
|
|
6
|
+
--content-padding: var(--bui-popover-content-padding, 0);
|
|
7
7
|
max-width: var(--max-width);
|
|
8
8
|
font-size: var(--bui-text-size-1);
|
|
9
9
|
position: absolute;
|
package/dist/Popover/Popover.js
CHANGED
|
@@ -70,7 +70,6 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
70
70
|
title,
|
|
71
71
|
content,
|
|
72
72
|
defaultOpen,
|
|
73
|
-
offsetSpacing = 0,
|
|
74
73
|
placement = "top",
|
|
75
74
|
trigger = "click",
|
|
76
75
|
onOpenChange,
|
|
@@ -83,7 +82,6 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
83
82
|
"title",
|
|
84
83
|
"content",
|
|
85
84
|
"defaultOpen",
|
|
86
|
-
"offsetSpacing",
|
|
87
85
|
"placement",
|
|
88
86
|
"trigger",
|
|
89
87
|
"onOpenChange",
|
|
@@ -138,7 +136,6 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
138
136
|
childrenRef,
|
|
139
137
|
arrowDirection,
|
|
140
138
|
arrowLocation,
|
|
141
|
-
offsetSpacing,
|
|
142
139
|
selector: `[data-id="tt_${ttId}"]`
|
|
143
140
|
});
|
|
144
141
|
if (!result)
|
package/dist/Tabs/TabPanel.js
CHANGED
|
@@ -61,19 +61,7 @@ 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, {
|
|
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
|
-
]);
|
|
64
|
+
const _a = props, { className, children, value, index, keepMounted } = _a, others = __objRest(_a, ["className", "children", "value", "index", "keepMounted"]);
|
|
77
65
|
const keepActiveDom = keepMounted ? children : null;
|
|
78
66
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
79
67
|
"div",
|
|
@@ -88,4 +76,7 @@ const TabPanel = (0, import_react.forwardRef)((props, ref) => {
|
|
|
88
76
|
);
|
|
89
77
|
});
|
|
90
78
|
TabPanel.displayName = "BuiTabPanel";
|
|
79
|
+
TabPanel.defaultProps = {
|
|
80
|
+
keepMounted: false
|
|
81
|
+
};
|
|
91
82
|
var TabPanel_default = TabPanel;
|
package/dist/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TabsProps } from './Tabs.types';
|
|
3
2
|
import './Tabs.less';
|
|
3
|
+
import { TabsProps } from './Tabs.types';
|
|
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");
|
|
63
64
|
var import_TabsContext = require("./TabsContext");
|
|
64
65
|
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,13 +81,16 @@ 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) =>
|
|
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
|
+
});
|
|
85
88
|
const activeLine = activeLineRef.current;
|
|
86
89
|
if (!activeLine)
|
|
87
90
|
return;
|
|
88
91
|
let activeTab;
|
|
89
92
|
if (tabs.length) {
|
|
90
|
-
activeTab =
|
|
93
|
+
activeTab = container.childNodes[activeIndex + 1];
|
|
91
94
|
} else {
|
|
92
95
|
activeTab = [...container.childNodes].find((child) => {
|
|
93
96
|
if (import_utils.isMini) {
|
|
@@ -98,26 +101,20 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
98
101
|
return [...child.classList].includes("bui-tab-active");
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
activeTabWidth = activeTab.offsetWidth;
|
|
110
|
-
containerWidth = container.offsetWidth;
|
|
111
|
-
containerScrollWidth = container.scrollWidth;
|
|
112
|
-
activeLineWidth = activeLine.offsetWidth;
|
|
113
|
-
x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
|
|
114
|
-
}
|
|
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;
|
|
115
112
|
setLineData({
|
|
116
113
|
x,
|
|
117
114
|
transitionInUse
|
|
118
115
|
});
|
|
119
116
|
const maxScrollDistance = containerScrollWidth - containerWidth;
|
|
120
|
-
if (maxScrollDistance <= 0
|
|
117
|
+
if (maxScrollDistance <= 0)
|
|
121
118
|
return;
|
|
122
119
|
const nextScrollLeft = (0, import_bound.default)(
|
|
123
120
|
activeTabLeft - (containerWidth - activeTabWidth) / 2,
|
|
@@ -129,7 +126,8 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
129
126
|
}
|
|
130
127
|
};
|
|
131
128
|
(0, import_react.useEffect)(() => {
|
|
132
|
-
|
|
129
|
+
const defaultIndex = safeValue();
|
|
130
|
+
setActive(defaultIndex);
|
|
133
131
|
}, [value]);
|
|
134
132
|
(0, import_react.useLayoutEffect)(() => {
|
|
135
133
|
animate({ transitionInUse: false });
|
|
@@ -147,6 +145,26 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
147
145
|
(0, import_utils.useDidMountEffect)(() => {
|
|
148
146
|
animate({ transitionInUse: true });
|
|
149
147
|
}, [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
|
+
};
|
|
150
168
|
const updateMask = (0, import_react.useMemo)(
|
|
151
169
|
() => (0, import_utils.throttle)(
|
|
152
170
|
() => {
|
|
@@ -187,7 +205,8 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
187
205
|
}
|
|
188
206
|
};
|
|
189
207
|
const providerValue = (0, import_react.useMemo)(() => {
|
|
190
|
-
|
|
208
|
+
const v = safeValue();
|
|
209
|
+
return { value: v, align, triggerChange: handleClick };
|
|
191
210
|
}, [value, align, children, handleClick]);
|
|
192
211
|
return /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(prefixCls, className) }, others), /* @__PURE__ */ import_react.default.createElement(
|
|
193
212
|
"div",
|
|
@@ -210,7 +229,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
210
229
|
{
|
|
211
230
|
ref: activeLineRef,
|
|
212
231
|
className: (0, import_clsx.default)(`${prefixCls}-tabline`, {
|
|
213
|
-
"bui-tabline-invisible": import_utils.isMini
|
|
232
|
+
"bui-tabline-invisible": import_utils.isMini
|
|
214
233
|
}),
|
|
215
234
|
style: {
|
|
216
235
|
transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
|
package/dist/Tooltip/Tooltip.js
CHANGED
|
@@ -69,7 +69,6 @@ const Tooltip = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
69
69
|
children,
|
|
70
70
|
title,
|
|
71
71
|
defaultOpen,
|
|
72
|
-
offsetSpacing = 0,
|
|
73
72
|
placement = "top",
|
|
74
73
|
trigger = "click",
|
|
75
74
|
onOpenChange,
|
|
@@ -80,7 +79,6 @@ const Tooltip = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
80
79
|
"children",
|
|
81
80
|
"title",
|
|
82
81
|
"defaultOpen",
|
|
83
|
-
"offsetSpacing",
|
|
84
82
|
"placement",
|
|
85
83
|
"trigger",
|
|
86
84
|
"onOpenChange",
|
|
@@ -134,7 +132,6 @@ const Tooltip = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
|
|
|
134
132
|
childrenRef,
|
|
135
133
|
arrowDirection,
|
|
136
134
|
arrowLocation,
|
|
137
|
-
offsetSpacing,
|
|
138
135
|
selector: `[data-id="tt_${ttId}"]`
|
|
139
136
|
});
|
|
140
137
|
if (!result)
|
package/es/Input/Input.css
CHANGED
|
@@ -39,6 +39,10 @@
|
|
|
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;
|
|
42
46
|
}
|
|
43
47
|
.bui-input-input::placeholder {
|
|
44
48
|
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
|
-
}, 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/es/Popover/Popover.css
CHANGED
|
@@ -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,
|
|
6
|
+
--content-padding: var(--bui-popover-content-padding, 0);
|
|
7
7
|
max-width: var(--max-width);
|
|
8
8
|
font-size: var(--bui-text-size-1);
|
|
9
9
|
position: absolute;
|
package/es/Popover/Popover.js
CHANGED
|
@@ -45,7 +45,6 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
45
45
|
title,
|
|
46
46
|
content,
|
|
47
47
|
defaultOpen,
|
|
48
|
-
offsetSpacing = 0,
|
|
49
48
|
placement = "top",
|
|
50
49
|
trigger = "click",
|
|
51
50
|
onOpenChange,
|
|
@@ -58,7 +57,6 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
58
57
|
"title",
|
|
59
58
|
"content",
|
|
60
59
|
"defaultOpen",
|
|
61
|
-
"offsetSpacing",
|
|
62
60
|
"placement",
|
|
63
61
|
"trigger",
|
|
64
62
|
"onOpenChange",
|
|
@@ -113,7 +111,6 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
113
111
|
childrenRef,
|
|
114
112
|
arrowDirection,
|
|
115
113
|
arrowLocation,
|
|
116
|
-
offsetSpacing,
|
|
117
114
|
selector: `[data-id="tt_${ttId}"]`
|
|
118
115
|
});
|
|
119
116
|
if (!result)
|
package/es/Tabs/TabPanel.js
CHANGED
|
@@ -31,19 +31,7 @@ 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, {
|
|
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
|
-
]);
|
|
34
|
+
const _a = props, { className, children, value, index, keepMounted } = _a, others = __objRest(_a, ["className", "children", "value", "index", "keepMounted"]);
|
|
47
35
|
const keepActiveDom = keepMounted ? children : null;
|
|
48
36
|
return /* @__PURE__ */ React.createElement(
|
|
49
37
|
"div",
|
|
@@ -58,6 +46,9 @@ const TabPanel = forwardRef((props, ref) => {
|
|
|
58
46
|
);
|
|
59
47
|
});
|
|
60
48
|
TabPanel.displayName = "BuiTabPanel";
|
|
49
|
+
TabPanel.defaultProps = {
|
|
50
|
+
keepMounted: false
|
|
51
|
+
};
|
|
61
52
|
var TabPanel_default = TabPanel;
|
|
62
53
|
export {
|
|
63
54
|
TabPanel_default as default
|
package/es/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TabsProps } from './Tabs.types';
|
|
3
2
|
import './Tabs.less';
|
|
3
|
+
import { TabsProps } from './Tabs.types';
|
|
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";
|
|
44
45
|
import { TabsContextProvider } from "./TabsContext";
|
|
45
46
|
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,13 +62,16 @@ 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) =>
|
|
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
|
+
});
|
|
66
69
|
const activeLine = activeLineRef.current;
|
|
67
70
|
if (!activeLine)
|
|
68
71
|
return;
|
|
69
72
|
let activeTab;
|
|
70
73
|
if (tabs.length) {
|
|
71
|
-
activeTab =
|
|
74
|
+
activeTab = container.childNodes[activeIndex + 1];
|
|
72
75
|
} else {
|
|
73
76
|
activeTab = [...container.childNodes].find((child) => {
|
|
74
77
|
if (isMini) {
|
|
@@ -79,26 +82,20 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
79
82
|
return [...child.classList].includes("bui-tab-active");
|
|
80
83
|
});
|
|
81
84
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
activeTabWidth = activeTab.offsetWidth;
|
|
91
|
-
containerWidth = container.offsetWidth;
|
|
92
|
-
containerScrollWidth = container.scrollWidth;
|
|
93
|
-
activeLineWidth = activeLine.offsetWidth;
|
|
94
|
-
x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
|
|
95
|
-
}
|
|
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;
|
|
96
93
|
setLineData({
|
|
97
94
|
x,
|
|
98
95
|
transitionInUse
|
|
99
96
|
});
|
|
100
97
|
const maxScrollDistance = containerScrollWidth - containerWidth;
|
|
101
|
-
if (maxScrollDistance <= 0
|
|
98
|
+
if (maxScrollDistance <= 0)
|
|
102
99
|
return;
|
|
103
100
|
const nextScrollLeft = bound(
|
|
104
101
|
activeTabLeft - (containerWidth - activeTabWidth) / 2,
|
|
@@ -110,7 +107,8 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
110
107
|
}
|
|
111
108
|
};
|
|
112
109
|
useEffect(() => {
|
|
113
|
-
|
|
110
|
+
const defaultIndex = safeValue();
|
|
111
|
+
setActive(defaultIndex);
|
|
114
112
|
}, [value]);
|
|
115
113
|
useLayoutEffect(() => {
|
|
116
114
|
animate({ transitionInUse: false });
|
|
@@ -128,6 +126,26 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
128
126
|
useDidMountEffect(() => {
|
|
129
127
|
animate({ transitionInUse: true });
|
|
130
128
|
}, [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
|
+
};
|
|
131
149
|
const updateMask = useMemo(
|
|
132
150
|
() => throttle(
|
|
133
151
|
() => {
|
|
@@ -168,7 +186,8 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
168
186
|
}
|
|
169
187
|
};
|
|
170
188
|
const providerValue = useMemo(() => {
|
|
171
|
-
|
|
189
|
+
const v = safeValue();
|
|
190
|
+
return { value: v, align, triggerChange: handleClick };
|
|
172
191
|
}, [value, align, children, handleClick]);
|
|
173
192
|
return /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), /* @__PURE__ */ React.createElement(
|
|
174
193
|
"div",
|
|
@@ -191,7 +210,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
191
210
|
{
|
|
192
211
|
ref: activeLineRef,
|
|
193
212
|
className: clsx(`${prefixCls}-tabline`, {
|
|
194
|
-
"bui-tabline-invisible": isMini
|
|
213
|
+
"bui-tabline-invisible": isMini
|
|
195
214
|
}),
|
|
196
215
|
style: {
|
|
197
216
|
transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
|
package/es/Tooltip/Tooltip.js
CHANGED
|
@@ -44,7 +44,6 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
44
44
|
children,
|
|
45
45
|
title,
|
|
46
46
|
defaultOpen,
|
|
47
|
-
offsetSpacing = 0,
|
|
48
47
|
placement = "top",
|
|
49
48
|
trigger = "click",
|
|
50
49
|
onOpenChange,
|
|
@@ -55,7 +54,6 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
55
54
|
"children",
|
|
56
55
|
"title",
|
|
57
56
|
"defaultOpen",
|
|
58
|
-
"offsetSpacing",
|
|
59
57
|
"placement",
|
|
60
58
|
"trigger",
|
|
61
59
|
"onOpenChange",
|
|
@@ -109,7 +107,6 @@ const Tooltip = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
109
107
|
childrenRef,
|
|
110
108
|
arrowDirection,
|
|
111
109
|
arrowLocation,
|
|
112
|
-
offsetSpacing,
|
|
113
110
|
selector: `[data-id="tt_${ttId}"]`
|
|
114
111
|
});
|
|
115
112
|
if (!result)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bifrostui/react",
|
|
3
|
-
"version": "1.4.2
|
|
3
|
+
"version": "1.4.2",
|
|
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.2
|
|
37
|
-
"@bifrostui/styles": "1.4.2
|
|
38
|
-
"@bifrostui/types": "1.4.2
|
|
39
|
-
"@bifrostui/utils": "1.4.2
|
|
36
|
+
"@bifrostui/icons": "1.4.2",
|
|
37
|
+
"@bifrostui/styles": "1.4.2",
|
|
38
|
+
"@bifrostui/types": "1.4.2",
|
|
39
|
+
"@bifrostui/utils": "1.4.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@tarojs/components": "^3.0.0",
|