@rainbow-oh/yee-c 0.14.2 → 0.14.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-oh/yee-c",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "yee basic components",
5
5
  "keywords": [
6
6
  "react",
package/src/Form/index.ts CHANGED
@@ -34,6 +34,7 @@ export type {
34
34
  FormInstance,
35
35
  FormListProps,
36
36
  FormProps,
37
+ Rule as FormRule,
37
38
  ValidateMessage,
38
39
  } from './interface';
39
40
 
@@ -35,12 +35,15 @@ const getPanelSize = (
35
35
  },
36
36
  ) => {
37
37
  const panelsRect = [] as PanelRect[];
38
- const count = React.Children.count(children);
38
+ // toArray 剔除 null/undefined/boolean(如 `{open ? <Item/> : null}` 条件面板)。
39
+ // Children.count 会把 null 也计为一面板,导致 auto 面板被平分出错误尺寸。
40
+ const items = React.Children.toArray(children);
41
+ const count = items.length;
39
42
 
40
43
  let remainingSize = totalSize;
41
44
  let remainingItem = count;
42
45
 
43
- React.Children.forEach(children, (child) => {
46
+ items.forEach((child) => {
44
47
  if (React.isValidElement(child)) {
45
48
  const { style, size, defaultSize, min, max } = child.props || ({} as any);
46
49
 
@@ -111,6 +114,8 @@ const getPanelSize = (
111
114
 
112
115
  panelsRect.forEach((item) => {
113
116
  if (item.type === 'default') {
117
+ // currentSize 缺失会导致 Wrapper 注入的 flexBasis 为空,defaultSize 失效(宽度由内容撑开)
118
+ item.currentSize = item.size;
114
119
  remainingSize -= item.size || 0;
115
120
  remainingItem--;
116
121
  } else if (item.type === 'percent') {
@@ -124,7 +129,8 @@ const getPanelSize = (
124
129
  if (remainingItem > 0) {
125
130
  panelsRect.forEach((item) => {
126
131
  if (item.type === 'auto') {
127
- item.size = remainingSize / remainingItem;
132
+ // 显式尺寸总和超出 totalSize 时 remainingSize 为负,负 flexBasis 会被浏览器丢弃导致面板回退内容尺寸
133
+ item.size = Math.max(0, remainingSize / remainingItem);
128
134
  item.currentSize = item.size;
129
135
  }
130
136
  });
@@ -145,9 +151,10 @@ const Wrapper = ({ children, itemsSize, onClick, ...props }: any) => {
145
151
  }
146
152
  >
147
153
  >({});
154
+ // 与 getPanelSize 同口径:toArray 剔除 null,index/handler 判断不受条件渲染干扰
148
155
  const arr = React.Children.toArray(children);
149
156
 
150
- React.Children.forEach(children, (child, index) => {
157
+ arr.forEach((child, index) => {
151
158
  if (React.isValidElement(child)) {
152
159
  const n = index + 1;
153
160
  const { style } = child.props || ({} as any);
@@ -178,6 +185,7 @@ const Wrapper = ({ children, itemsSize, onClick, ...props }: any) => {
178
185
  },
179
186
  }),
180
187
  );
188
+
181
189
  const next = arr[index + 1];
182
190
 
183
191
  if (!next || !React.isValidElement(next)) {
package/src/version.ts CHANGED
@@ -4,7 +4,7 @@ declare global {
4
4
  }
5
5
  }
6
6
 
7
- export const version = "0.14.2";
7
+ export const version = "0.14.3";
8
8
 
9
9
  if (typeof window !== 'undefined') {
10
10
  window.__yee_c_version__ = version;