@huibo-ui/react-antd 1.0.7 → 1.0.8

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.
@@ -101,7 +101,7 @@ export const Form = React.forwardRef(function Form(props, ref) {
101
101
  onValuesChange({ [prop]: info?.value }, {});
102
102
  };
103
103
  });
104
- return (_jsx(HbForm, { ref: refCallback, initialValues: initialValues, labelPosition: labelPosition, labelWidth: labelCol?.span ? `${(labelCol.span / 24) * 100}%` : '80px', style: style, className: className, children: children }));
104
+ return (_jsx(HbForm, { ref: refCallback, initialValues: initialValues, labelPosition: labelPosition, inline: layout === 'inline', labelWidth: labelCol?.span ? `${(labelCol.span / 24) * 100}%` : '80px', style: style, className: className, children: children }));
105
105
  });
106
106
  Form.useForm = function useForm() {
107
107
  const [f] = React.useState(createFormInstance);
@@ -1,11 +1,20 @@
1
1
  import React from 'react';
2
+ /**
3
+ * antd Tabs 兼容层(自包含 React 渲染)。
4
+ *
5
+ * 为什么不用 core 的 hb-tabs:hb-tabs 的 items[].content 只接受 string/HTML,
6
+ * 不渲染 React 节点(scrm 权益管理 Tabs items 的 children 是复杂 React 内容 → 空白);
7
+ * 且 items 数组 post-mount 同步不可靠(同 hb-menu 的坑)。故本层纯 React 渲染:
8
+ * items 的 children/label 全部原生,activeKey 受控 + 非受控,type=line/card,tabPosition。
9
+ */
2
10
  export interface TabItemType {
3
11
  key: string;
4
- label: React.ReactNode;
12
+ label?: React.ReactNode;
5
13
  children?: React.ReactNode;
6
14
  disabled?: boolean;
15
+ [k: string]: any;
7
16
  }
8
- export declare function Tabs(props: {
17
+ export interface TabsProps {
9
18
  items?: TabItemType[];
10
19
  activeKey?: string;
11
20
  defaultActiveKey?: string;
@@ -13,9 +22,13 @@ export declare function Tabs(props: {
13
22
  type?: 'line' | 'card';
14
23
  size?: 'small' | 'middle' | 'large';
15
24
  tabPosition?: 'top' | 'bottom' | 'left' | 'right';
16
- children?: React.ReactNode;
25
+ destroyInactiveTabPane?: boolean;
17
26
  style?: React.CSSProperties;
18
- }): React.JSX.Element;
27
+ className?: string;
28
+ children?: React.ReactNode;
29
+ [k: string]: any;
30
+ }
31
+ export declare function Tabs(props: TabsProps): React.JSX.Element;
19
32
  export declare namespace Tabs {
20
33
  var TabPane: any;
21
34
  }
@@ -1,7 +1,67 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { HbTabs, HbTabPane } from '@huibo-ui/react';
3
+ const PRIMARY = 'var(--hb-color-primary, #ff6700)';
4
4
  export function Tabs(props) {
5
- return _jsx(HbTabs, { items: props.items, modelValue: props.activeKey, type: props.type, size: props.size === 'middle' ? 'default' : props.size, tabPosition: props.tabPosition, onHbTabChange: (e) => props.onChange?.(e.detail), style: props.style, children: props.children });
5
+ const { items, activeKey, defaultActiveKey, onChange, type = 'line', size = 'middle', tabPosition = 'top', destroyInactiveTabPane = false, style, className, children, } = props;
6
+ const list = items && items.length > 0 ? items : [];
7
+ const [internal, setInternal] = React.useState(activeKey ?? defaultActiveKey ?? list[0]?.key ?? '');
8
+ const current = activeKey !== undefined ? activeKey : internal;
9
+ const select = (key, disabled) => {
10
+ if (disabled)
11
+ return;
12
+ if (activeKey === undefined)
13
+ setInternal(key);
14
+ onChange?.(key);
15
+ };
16
+ const vertical = tabPosition === 'left' || tabPosition === 'right';
17
+ const card = type === 'card';
18
+ const fontSize = size === 'large' ? 16 : size === 'small' ? 13 : 14;
19
+ const tabPadding = size === 'large' ? '16px 24px' : size === 'small' ? '8px 16px' : '12px 16px';
20
+ const tabBar = (_jsx("div", { style: {
21
+ display: 'flex',
22
+ flexDirection: vertical ? 'column' : 'row',
23
+ borderBottom: vertical || card ? 'none' : '1px solid #f0f0f0',
24
+ [vertical ? 'borderRight' : 'borderBottom']: vertical ? '1px solid #f0f0f0' : undefined,
25
+ gap: vertical ? 0 : 4,
26
+ overflowX: vertical ? 'visible' : 'auto',
27
+ scrollbarWidth: 'thin',
28
+ }, children: list.map(it => {
29
+ const active = it.key === current;
30
+ return (_jsxs("div", { role: "tab", "aria-selected": active, onClick: () => select(it.key, it.disabled), style: {
31
+ padding: tabPadding,
32
+ cursor: it.disabled ? 'not-allowed' : 'pointer',
33
+ color: it.disabled ? 'rgba(0,0,0,0.25)' : active ? PRIMARY : 'rgba(0,0,0,0.88)',
34
+ fontWeight: active ? 500 : 400,
35
+ fontSize,
36
+ whiteSpace: 'nowrap',
37
+ position: 'relative',
38
+ background: card ? (active ? '#fff' : 'transparent') : 'transparent',
39
+ border: card ? '1px solid #f0f0f0' : 'none',
40
+ [vertical ? 'borderBottom' : 'borderBottom']: card ? (active ? '1px solid #fff' : '1px solid #f0f0f0') : 'none',
41
+ marginBottom: card && !vertical ? '-1px' : undefined,
42
+ borderRadius: card ? (vertical ? '4px 0 0 4px' : '4px 4px 0 0') : undefined,
43
+ transition: 'color .2s',
44
+ }, children: [it.label, active && !card && (_jsx("span", { style: {
45
+ position: 'absolute',
46
+ [vertical ? 'right' : 'bottom']: 0,
47
+ [vertical ? 'top' : 'left']: vertical ? 0 : 0,
48
+ [vertical ? 'width' : 'height']: '2px',
49
+ [vertical ? 'height' : 'width']: '100%',
50
+ background: PRIMARY,
51
+ } }))] }, it.key));
52
+ }) }));
53
+ const activeItem = list.find(it => it.key === current);
54
+ const panels = (_jsxs("div", { style: { flex: 1, minWidth: 0, padding: vertical ? '0 16px' : '16px 0' }, children: [destroyInactiveTabPane
55
+ ? activeItem?.children
56
+ : list.map(it => (_jsx("div", { style: { display: it.key === current ? 'block' : 'none' }, children: it.children }, it.key))), !items || items.length === 0 ? children : null] }));
57
+ return (_jsxs("div", { className: className, style: {
58
+ display: 'flex',
59
+ flexDirection: vertical ? 'row' : 'column',
60
+ [tabPosition === 'bottom' ? 'flexDirection' : '']: tabPosition === 'bottom' ? 'column-reverse' : undefined,
61
+ ...style,
62
+ }, children: [tabPosition === 'bottom' ? panels : tabBar, tabPosition === 'bottom' ? tabBar : panels] }));
6
63
  }
7
- Tabs.TabPane = function TabPane(props) { return React.createElement(HbTabPane, { key: props.tabKey || props.key, label: props.tab }, props.children); };
64
+ /** Tabs.TabPane —— antd4 声明式占位(scrm items,这里仅兜底) */
65
+ Tabs.TabPane = function TabPane(_props) {
66
+ return null;
67
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huibo-ui/react-antd",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "antd 兼容层 — 接收 antd 原生 props,内部转换为 huibo-ui,实现丝滑平替",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",