@bifrostui/react 1.2.0 → 1.2.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.
@@ -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 | "open" | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, "open" | keyof import("@bifrostui/types").ICommonProps | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Modal;
package/dist/Tabs/Tabs.js CHANGED
@@ -143,12 +143,24 @@ const Tabs = import_react.default.forwardRef((props, ref) => {
143
143
  }, [active]);
144
144
  (0, import_utils.useDidMountEffect)(() => {
145
145
  animate({ transitionInUse: true });
146
- }, [active, tabs]);
146
+ }, [active, tabs, children]);
147
147
  const safeValue = () => {
148
148
  var _a2;
149
149
  let defaultIndex = value;
150
+ const childs = import_react.default.Children.toArray(children);
151
+ const hasSameChild = !!childs.length && childs.some(
152
+ (child) => {
153
+ var _a3;
154
+ return import_react.default.isValidElement(child) && child.type === import_Tab.default && ((_a3 = child == null ? void 0 : child.props) == null ? void 0 : _a3.index) === value;
155
+ }
156
+ );
150
157
  if (!!tabs.length && !tabs.some((item) => item.index === value)) {
151
158
  defaultIndex = (_a2 = tabs[0]) == null ? void 0 : _a2.index;
159
+ } else if (children && !hasSameChild) {
160
+ const childNode = childs[0];
161
+ if (import_react.default.isValidElement(childNode)) {
162
+ defaultIndex = childNode.props.index;
163
+ }
152
164
  }
153
165
  return defaultIndex;
154
166
  };
@@ -194,7 +206,7 @@ const Tabs = import_react.default.forwardRef((props, ref) => {
194
206
  const providerValue = (0, import_react.useMemo)(() => {
195
207
  const v = safeValue();
196
208
  return { value: v, align, triggerChange: handleClick };
197
- }, [value, align, handleClick]);
209
+ }, [value, align, children, handleClick]);
198
210
  return /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(prefixCls, className) }, others), /* @__PURE__ */ import_react.default.createElement(
199
211
  "div",
200
212
  {
package/es/Tabs/Tabs.js CHANGED
@@ -124,12 +124,24 @@ const Tabs = React.forwardRef((props, ref) => {
124
124
  }, [active]);
125
125
  useDidMountEffect(() => {
126
126
  animate({ transitionInUse: true });
127
- }, [active, tabs]);
127
+ }, [active, tabs, children]);
128
128
  const safeValue = () => {
129
129
  var _a2;
130
130
  let defaultIndex = value;
131
+ const childs = React.Children.toArray(children);
132
+ const hasSameChild = !!childs.length && childs.some(
133
+ (child) => {
134
+ var _a3;
135
+ return React.isValidElement(child) && child.type === Tab && ((_a3 = child == null ? void 0 : child.props) == null ? void 0 : _a3.index) === value;
136
+ }
137
+ );
131
138
  if (!!tabs.length && !tabs.some((item) => item.index === value)) {
132
139
  defaultIndex = (_a2 = tabs[0]) == null ? void 0 : _a2.index;
140
+ } else if (children && !hasSameChild) {
141
+ const childNode = childs[0];
142
+ if (React.isValidElement(childNode)) {
143
+ defaultIndex = childNode.props.index;
144
+ }
133
145
  }
134
146
  return defaultIndex;
135
147
  };
@@ -175,7 +187,7 @@ const Tabs = React.forwardRef((props, ref) => {
175
187
  const providerValue = useMemo(() => {
176
188
  const v = safeValue();
177
189
  return { value: v, align, triggerChange: handleClick };
178
- }, [value, align, handleClick]);
190
+ }, [value, align, children, handleClick]);
179
191
  return /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), /* @__PURE__ */ React.createElement(
180
192
  "div",
181
193
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/react",
3
- "version": "1.2.0",
3
+ "version": "1.2.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/utils": "1.2.0",
37
- "@bifrostui/types": "1.2.0",
38
- "@bifrostui/icons": "1.2.0",
39
- "@bifrostui/styles": "1.2.0"
36
+ "@bifrostui/styles": "1.2.2",
37
+ "@bifrostui/utils": "1.2.2",
38
+ "@bifrostui/icons": "1.2.2",
39
+ "@bifrostui/types": "1.2.2"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@tarojs/components": "^3.0.0",