@huibo-ui/react-antd 1.0.0
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/lib/components/Affix.d.ts +6 -0
- package/lib/components/Affix.js +5 -0
- package/lib/components/Alert.d.ts +10 -0
- package/lib/components/Alert.js +5 -0
- package/lib/components/Anchor.d.ts +7 -0
- package/lib/components/Anchor.js +5 -0
- package/lib/components/App.d.ts +4 -0
- package/lib/components/App.js +6 -0
- package/lib/components/Avatar.d.ts +8 -0
- package/lib/components/Avatar.js +6 -0
- package/lib/components/BackTop.d.ts +6 -0
- package/lib/components/BackTop.js +5 -0
- package/lib/components/Badge.d.ts +9 -0
- package/lib/components/Badge.js +5 -0
- package/lib/components/Breadcrumb.d.ts +12 -0
- package/lib/components/Breadcrumb.js +10 -0
- package/lib/components/Button.d.ts +14 -0
- package/lib/components/Button.js +7 -0
- package/lib/components/Card.d.ts +11 -0
- package/lib/components/Card.js +5 -0
- package/lib/components/Cascader.d.ts +12 -0
- package/lib/components/Cascader.js +5 -0
- package/lib/components/Checkbox.d.ts +18 -0
- package/lib/components/Checkbox.js +10 -0
- package/lib/components/Collapse.d.ts +11 -0
- package/lib/components/Collapse.js +7 -0
- package/lib/components/ConfigProvider.d.ts +27 -0
- package/lib/components/ConfigProvider.js +80 -0
- package/lib/components/DatePicker.d.ts +35 -0
- package/lib/components/DatePicker.js +15 -0
- package/lib/components/Descriptions.d.ts +12 -0
- package/lib/components/Descriptions.js +13 -0
- package/lib/components/Divider.d.ts +8 -0
- package/lib/components/Divider.js +5 -0
- package/lib/components/Drawer.d.ts +11 -0
- package/lib/components/Drawer.js +6 -0
- package/lib/components/Dropdown.d.ts +10 -0
- package/lib/components/Dropdown.js +5 -0
- package/lib/components/Empty.d.ts +10 -0
- package/lib/components/Empty.js +14 -0
- package/lib/components/FloatButton.d.ts +8 -0
- package/lib/components/FloatButton.js +5 -0
- package/lib/components/Form.d.ts +79 -0
- package/lib/components/Form.js +97 -0
- package/lib/components/Image.d.ts +9 -0
- package/lib/components/Image.js +5 -0
- package/lib/components/Input.d.ts +39 -0
- package/lib/components/Input.js +37 -0
- package/lib/components/InputNumber.d.ts +13 -0
- package/lib/components/InputNumber.js +5 -0
- package/lib/components/Layout.d.ts +46 -0
- package/lib/components/Layout.js +85 -0
- package/lib/components/Menu.d.ts +39 -0
- package/lib/components/Menu.js +32 -0
- package/lib/components/Modal.d.ts +26 -0
- package/lib/components/Modal.js +76 -0
- package/lib/components/PageHeader.d.ts +8 -0
- package/lib/components/PageHeader.js +5 -0
- package/lib/components/Pagination.d.ts +11 -0
- package/lib/components/Pagination.js +5 -0
- package/lib/components/Popconfirm.d.ts +10 -0
- package/lib/components/Popconfirm.js +5 -0
- package/lib/components/Popover.d.ts +8 -0
- package/lib/components/Popover.js +5 -0
- package/lib/components/Progress.d.ts +10 -0
- package/lib/components/Progress.js +5 -0
- package/lib/components/QRCode.d.ts +14 -0
- package/lib/components/QRCode.js +10 -0
- package/lib/components/Radio.d.ts +24 -0
- package/lib/components/Radio.js +23 -0
- package/lib/components/Rate.d.ts +9 -0
- package/lib/components/Rate.js +5 -0
- package/lib/components/Result.d.ts +8 -0
- package/lib/components/Result.js +5 -0
- package/lib/components/Segmented.d.ts +11 -0
- package/lib/components/Segmented.js +5 -0
- package/lib/components/Select.d.ts +30 -0
- package/lib/components/Select.js +43 -0
- package/lib/components/Skeleton.d.ts +19 -0
- package/lib/components/Skeleton.js +20 -0
- package/lib/components/Slider.d.ts +11 -0
- package/lib/components/Slider.js +5 -0
- package/lib/components/Space.d.ts +12 -0
- package/lib/components/Space.js +12 -0
- package/lib/components/Spin.d.ts +8 -0
- package/lib/components/Spin.js +8 -0
- package/lib/components/Statistic.d.ts +9 -0
- package/lib/components/Statistic.js +5 -0
- package/lib/components/Steps.d.ts +13 -0
- package/lib/components/Steps.js +7 -0
- package/lib/components/Switch.d.ts +10 -0
- package/lib/components/Switch.js +5 -0
- package/lib/components/Table.d.ts +55 -0
- package/lib/components/Table.js +187 -0
- package/lib/components/Tabs.d.ts +21 -0
- package/lib/components/Tabs.js +7 -0
- package/lib/components/Tag.d.ts +8 -0
- package/lib/components/Tag.js +6 -0
- package/lib/components/TimePicker.d.ts +11 -0
- package/lib/components/TimePicker.js +5 -0
- package/lib/components/Timeline.d.ts +7 -0
- package/lib/components/Timeline.js +5 -0
- package/lib/components/Tooltip.d.ts +7 -0
- package/lib/components/Tooltip.js +5 -0
- package/lib/components/Tour.d.ts +6 -0
- package/lib/components/Tour.js +5 -0
- package/lib/components/Tree.d.ts +22 -0
- package/lib/components/Tree.js +45 -0
- package/lib/components/TreeSelect.d.ts +11 -0
- package/lib/components/TreeSelect.js +5 -0
- package/lib/components/Typography.d.ts +10 -0
- package/lib/components/Typography.js +19 -0
- package/lib/components/Upload.d.ts +18 -0
- package/lib/components/Upload.js +12 -0
- package/lib/components/Watermark.d.ts +13 -0
- package/lib/components/Watermark.js +5 -0
- package/lib/components/message.d.ts +19 -0
- package/lib/components/message.js +32 -0
- package/lib/components/notification.d.ts +19 -0
- package/lib/components/notification.js +28 -0
- package/lib/index.d.ts +219 -0
- package/lib/index.js +123 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Radio(props: {
|
|
3
|
+
value?: any;
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
onChange?: (e: any) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export declare namespace Radio {
|
|
10
|
+
var Group: any;
|
|
11
|
+
var Button: any;
|
|
12
|
+
}
|
|
13
|
+
export declare function RadioGroup(props: {
|
|
14
|
+
value?: any;
|
|
15
|
+
onChange?: (value: any) => void;
|
|
16
|
+
options?: {
|
|
17
|
+
value: any;
|
|
18
|
+
label: React.ReactNode;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbRadio } from '@huibo-ui/react';
|
|
3
|
+
export function Radio(props) {
|
|
4
|
+
return _jsx(HbRadio, { value: props.value, checked: props.checked, disabled: props.disabled, label: props.children, onHbChange: (e) => props.onChange?.({ target: { value: e.detail } }), children: props.children });
|
|
5
|
+
}
|
|
6
|
+
// RadioGroup:huibo-ui 无独立 hb-radio-group 组件,用 div + 多个 hb-radio 实现
|
|
7
|
+
export function RadioGroup(props) {
|
|
8
|
+
const { value, onChange, options, disabled } = props;
|
|
9
|
+
if (options) {
|
|
10
|
+
return (_jsx("div", { style: props.style, children: options.map((opt, i) => (_jsx(HbRadio, { value: opt.value, checked: value === opt.value, disabled: disabled || opt.disabled, label: opt.label, onHbChange: (e) => onChange?.(e.detail) }, i))) }));
|
|
11
|
+
}
|
|
12
|
+
// children 模式:透传(用户自己用 <Radio> 子元素)
|
|
13
|
+
return _jsx("div", { style: props.style, "data-value": value, children: props.children });
|
|
14
|
+
}
|
|
15
|
+
// 挂上 antd 静态子组件(Radio.Group / Radio.Button)
|
|
16
|
+
Radio.Group = RadioGroup;
|
|
17
|
+
/**
|
|
18
|
+
* Radio.Button —— 样式变体,huibo hb-radio 无 button 形态;
|
|
19
|
+
* 这里复用 Radio 渲染(功能可用,视觉非按钮)。
|
|
20
|
+
*/
|
|
21
|
+
Radio.Button = function RadioButton(props) {
|
|
22
|
+
return _jsx(Radio, { ...props });
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbRate } from '@huibo-ui/react';
|
|
3
|
+
export function Rate(props) {
|
|
4
|
+
return _jsx(HbRate, { modelValue: props.value ?? 0, max: props.count ?? 5, allowHalf: props.allowHalf, disabled: props.disabled, onHbChange: (e) => props.onChange?.(e.detail), style: props.style });
|
|
5
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Result(props: {
|
|
3
|
+
status?: 'success' | 'error' | 'info' | 'warning' | '404' | '403' | '500';
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
subTitle?: React.ReactNode;
|
|
6
|
+
extra?: React.ReactNode;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { HbResult } from '@huibo-ui/react';
|
|
3
|
+
export function Result(props) {
|
|
4
|
+
return _jsxs(HbResult, { status: props.status, title: typeof props.title === 'string' ? props.title : '', subTitle: typeof props.subTitle === 'string' ? props.subTitle : '', children: [props.extra, props.children] });
|
|
5
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Segmented(props: {
|
|
3
|
+
options?: {
|
|
4
|
+
value: string;
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
}[];
|
|
7
|
+
value?: string;
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
block?: boolean;
|
|
10
|
+
size?: 'small' | 'middle' | 'large';
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbSegmented } from '@huibo-ui/react';
|
|
3
|
+
export function Segmented(props) {
|
|
4
|
+
return _jsx(HbSegmented, { options: props.options, modelValue: props.value, block: props.block, size: props.size === 'middle' ? 'default' : props.size, onHbChange: (e) => props.onChange?.(e.detail) });
|
|
5
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
value: string | number;
|
|
4
|
+
label: React.ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface SelectProps {
|
|
8
|
+
value?: string | number | (string | number)[];
|
|
9
|
+
defaultValue?: string | number | (string | number)[];
|
|
10
|
+
onChange?: (value: any, option: any) => void;
|
|
11
|
+
options?: SelectOption[];
|
|
12
|
+
mode?: 'multiple' | 'tags';
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
size?: 'small' | 'middle' | 'large';
|
|
16
|
+
allowClear?: boolean;
|
|
17
|
+
showSearch?: boolean;
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
className?: string;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
virtual?: boolean;
|
|
23
|
+
onSearch?: (value: string) => void;
|
|
24
|
+
onDropdownVisibleChange?: (open: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function Select(props: SelectProps): React.JSX.Element;
|
|
27
|
+
export declare namespace Select {
|
|
28
|
+
var Option: any;
|
|
29
|
+
var OptGroup: any;
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HbSelect } from '@huibo-ui/react';
|
|
4
|
+
/**
|
|
5
|
+
* 把 antd 声明式 children(<Select.Option value>label</Select.Option>)转成 options 数组。
|
|
6
|
+
* hb-select 只认 options,不认 option 子节点。
|
|
7
|
+
*/
|
|
8
|
+
function optionsFromChildren(children) {
|
|
9
|
+
const opts = [];
|
|
10
|
+
React.Children.forEach(children, child => {
|
|
11
|
+
if (!React.isValidElement(child))
|
|
12
|
+
return;
|
|
13
|
+
const props = child.props || {};
|
|
14
|
+
// Select.Option 或 Select.OptGroup
|
|
15
|
+
if (child.type === SelectOptionComponent || child.type === Select.Option) {
|
|
16
|
+
opts.push({ value: props.value, label: props.label ?? props.children, disabled: props.disabled });
|
|
17
|
+
}
|
|
18
|
+
else if (props.options && Array.isArray(props.options)) {
|
|
19
|
+
// OptGroup: { label, options: [{value,label}] }
|
|
20
|
+
props.options.forEach((o) => opts.push({ value: o.value, label: o.label ?? o.value }));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return opts;
|
|
24
|
+
}
|
|
25
|
+
function SelectOptionComponent(_props) {
|
|
26
|
+
// Select.Option 不实际渲染(由父 Select 收集为 options)
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
export function Select(props) {
|
|
30
|
+
const { value, onChange, options, mode, placeholder, disabled, size, allowClear, showSearch, virtual, style, children, } = props;
|
|
31
|
+
// 优先用 options prop;否则从 <Select.Option> children 提取
|
|
32
|
+
const resolvedOptions = options && options.length > 0 ? options : optionsFromChildren(children);
|
|
33
|
+
return (_jsx(HbSelect, { modelValue: value, options: resolvedOptions, multiple: mode === 'multiple' || mode === 'tags', placeholder: placeholder, disabled: disabled, size: size === 'middle' ? 'default' : size, clearable: allowClear, filterable: showSearch, virtual: virtual, style: style, onHbChange: (e) => {
|
|
34
|
+
if (onChange)
|
|
35
|
+
onChange(e.detail, undefined);
|
|
36
|
+
}, onHbVisibleChange: (e) => {
|
|
37
|
+
if (props.onDropdownVisibleChange)
|
|
38
|
+
props.onDropdownVisibleChange(e.detail);
|
|
39
|
+
} }));
|
|
40
|
+
}
|
|
41
|
+
// Select.Option / Select.OptGroup —— 声明式用法占位(值由父 Select 收集)
|
|
42
|
+
Select.Option = SelectOptionComponent;
|
|
43
|
+
Select.OptGroup = SelectOptionComponent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Skeleton(props: {
|
|
3
|
+
active?: boolean;
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
avatar?: boolean;
|
|
6
|
+
paragraph?: {
|
|
7
|
+
rows?: number;
|
|
8
|
+
width?: any;
|
|
9
|
+
};
|
|
10
|
+
title?: boolean;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
export declare namespace Skeleton {
|
|
15
|
+
var Input: any;
|
|
16
|
+
var Button: any;
|
|
17
|
+
var Avatar: any;
|
|
18
|
+
var Image: any;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbSkeleton } from '@huibo-ui/react';
|
|
3
|
+
export function Skeleton(props) {
|
|
4
|
+
return (_jsx(HbSkeleton, { loading: props.loading ?? true, animated: props.active, rows: props.paragraph?.rows, children: props.children }));
|
|
5
|
+
}
|
|
6
|
+
Skeleton.Input = function SkeletonInput({ active, style }) {
|
|
7
|
+
return _jsx("div", { style: { height: 32, width: '100%', background: 'rgba(0,0,0,0.06)', borderRadius: 6, ...style } });
|
|
8
|
+
};
|
|
9
|
+
Skeleton.Button = function SkeletonButton({ active, size, style }) {
|
|
10
|
+
const h = size === 'small' ? 24 : size === 'large' ? 40 : 32;
|
|
11
|
+
const w = size === 'small' ? 48 : size === 'large' ? 64 : 56;
|
|
12
|
+
return _jsx("div", { style: { width: w, height: h, background: 'rgba(0,0,0,0.06)', borderRadius: 6, ...style } });
|
|
13
|
+
};
|
|
14
|
+
Skeleton.Avatar = function SkeletonAvatar({ active, size, style }) {
|
|
15
|
+
const s = size ?? 32;
|
|
16
|
+
return _jsx("div", { style: { width: s, height: s, borderRadius: '50%', background: 'rgba(0,0,0,0.06)', ...style } });
|
|
17
|
+
};
|
|
18
|
+
Skeleton.Image = function SkeletonImage({ active, style }) {
|
|
19
|
+
return _jsx("div", { style: { width: 96, height: 96, background: 'rgba(0,0,0,0.06)', ...style } });
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Slider(props: {
|
|
3
|
+
value?: number;
|
|
4
|
+
onChange?: (value: number) => void;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
vertical?: boolean;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbSlider } from '@huibo-ui/react';
|
|
3
|
+
export function Slider(props) {
|
|
4
|
+
return _jsx(HbSlider, { modelValue: props.value ?? 0, min: props.min ?? 0, max: props.max ?? 100, step: props.step ?? 1, disabled: props.disabled, vertical: props.vertical, onHbChange: (e) => props.onChange?.(e.detail), style: props.style });
|
|
5
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Space(props: {
|
|
3
|
+
size?: 'small' | 'middle' | 'large' | number;
|
|
4
|
+
direction?: 'horizontal' | 'vertical';
|
|
5
|
+
align?: 'start' | 'center' | 'end';
|
|
6
|
+
wrap?: boolean;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
export declare namespace Space {
|
|
11
|
+
var Compact: any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbSpace } from '@huibo-ui/react';
|
|
3
|
+
export function Space(props) {
|
|
4
|
+
return _jsx(HbSpace, { size: props.size === 'middle' ? 'default' : props.size, direction: props.direction, align: props.align, wrap: props.wrap, style: props.style, children: props.children });
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Space.Compact —— 紧凑布局(antd 子组件)。huibo 无对应形态,
|
|
8
|
+
* 这里直接透传 children(间距为 0)。
|
|
9
|
+
*/
|
|
10
|
+
Space.Compact = function Compact(props) {
|
|
11
|
+
return _jsx("div", { style: { display: 'inline-flex', ...props.style }, children: props.children });
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { HbLoading } from '@huibo-ui/react';
|
|
3
|
+
export function Spin(props) {
|
|
4
|
+
if (props.children) {
|
|
5
|
+
return _jsxs("div", { style: { position: 'relative' }, children: [props.spinning && _jsx(HbLoading, { size: props.size === 'middle' ? 'default' : props.size, fullscreen: false }), props.children] });
|
|
6
|
+
}
|
|
7
|
+
return _jsx(HbLoading, { size: props.size === 'middle' ? 'default' : props.size });
|
|
8
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbStatistic } from '@huibo-ui/react';
|
|
3
|
+
export function Statistic(props) {
|
|
4
|
+
return _jsx(HbStatistic, { title: typeof props.title === 'string' ? props.title : '', value: props.value ?? 0, precision: props.precision, prefix: props.prefix, suffix: props.suffix, style: props.style });
|
|
5
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Steps(props: {
|
|
3
|
+
current?: number;
|
|
4
|
+
items?: any[];
|
|
5
|
+
direction?: 'horizontal' | 'vertical';
|
|
6
|
+
size?: 'small' | 'default';
|
|
7
|
+
status?: 'process' | 'finish' | 'error' | 'wait';
|
|
8
|
+
type?: 'default' | 'navigation' | 'inline';
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
export declare namespace Steps {
|
|
12
|
+
var Step: any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HbSteps, HbStep } from '@huibo-ui/react';
|
|
4
|
+
export function Steps(props) {
|
|
5
|
+
return _jsx(HbSteps, { active: props.current ?? 0, items: props.items, direction: props.direction, type: props.type, processStatus: props.status, size: props.size, children: props.children });
|
|
6
|
+
}
|
|
7
|
+
Steps.Step = function Step(props) { return React.createElement(HbStep, { title: props.title, description: props.description, status: props.status }, props.children); };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Switch(props: {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
onChange?: (checked: boolean) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
size?: 'small' | 'middle' | 'large';
|
|
7
|
+
checkedChildren?: React.ReactNode;
|
|
8
|
+
unCheckedChildren?: React.ReactNode;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbSwitch } from '@huibo-ui/react';
|
|
3
|
+
export function Switch(props) {
|
|
4
|
+
return _jsx(HbSwitch, { modelValue: props.checked ?? false, disabled: props.disabled, size: props.size === 'middle' ? 'default' : props.size, activeText: props.checkedChildren, inactiveText: props.unCheckedChildren, onHbChange: (e) => props.onChange?.(e.detail) });
|
|
5
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ColumnType<T = any> {
|
|
3
|
+
title?: React.ReactNode | (() => React.ReactNode);
|
|
4
|
+
dataIndex?: string;
|
|
5
|
+
key?: string | number;
|
|
6
|
+
width?: string | number;
|
|
7
|
+
minWidth?: string | number;
|
|
8
|
+
align?: 'left' | 'center' | 'right';
|
|
9
|
+
fixed?: 'left' | 'right' | boolean;
|
|
10
|
+
sorter?: boolean | ((a: T, b: T) => number);
|
|
11
|
+
sortOrder?: 'ascend' | 'descend' | null;
|
|
12
|
+
filters?: {
|
|
13
|
+
text: React.ReactNode;
|
|
14
|
+
value: string | number;
|
|
15
|
+
}[];
|
|
16
|
+
filteredValue?: (string | number)[];
|
|
17
|
+
onFilter?: (value: any, record: T) => boolean;
|
|
18
|
+
render?: (value: any, record: T, index: number) => React.ReactNode;
|
|
19
|
+
ellipsis?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface TableProps<T = any> {
|
|
22
|
+
dataSource?: T[];
|
|
23
|
+
columns?: ColumnType<T>[];
|
|
24
|
+
rowKey?: string | ((record: T) => string | number);
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
size?: 'small' | 'middle' | 'large';
|
|
27
|
+
bordered?: boolean;
|
|
28
|
+
pagination?: false | {
|
|
29
|
+
current?: number;
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
total?: number;
|
|
32
|
+
showSizeChanger?: boolean;
|
|
33
|
+
pageSizeOptions?: string[];
|
|
34
|
+
showTotal?: (total: number) => React.ReactNode;
|
|
35
|
+
onChange?: (page: number, pageSize: number) => void;
|
|
36
|
+
};
|
|
37
|
+
rowSelection?: {
|
|
38
|
+
type?: 'checkbox' | 'radio';
|
|
39
|
+
selectedRowKeys?: React.Key[];
|
|
40
|
+
onChange?: (selectedRowKeys: React.Key[], selectedRows: T[]) => void;
|
|
41
|
+
getCheckboxProps?: (record: T) => {
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
scroll?: {
|
|
46
|
+
x?: number | string;
|
|
47
|
+
y?: number | string;
|
|
48
|
+
};
|
|
49
|
+
onChange?: (pagination: any, filters: any, sorter: any) => void;
|
|
50
|
+
expandedRowRender?: (record: T, index: number) => React.ReactNode;
|
|
51
|
+
style?: React.CSSProperties;
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function Table<T = any>(props: TableProps<T>): React.JSX.Element;
|
|
55
|
+
export type ColumnsType<T = any> = ColumnType<T>[];
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { HbTable } from '@huibo-ui/react';
|
|
6
|
+
/**
|
|
7
|
+
* 兼容层 Table 单元格 portal sentinel。
|
|
8
|
+
* hb-table 的 render 返回此常量时,会渲染出一个带 data-row-key / data-col /
|
|
9
|
+
* data-row-index 的空 <span class="hb-table__cell-portal">,并在 componentDidRender
|
|
10
|
+
* 发出 hbCellsRendered 事件。本组件据此用 React createRoot 把「带事件 handler 的」
|
|
11
|
+
* 真正内容挂进该 span —— 从而让表格单元格里 Switch / 按钮等交互控件保留可点击性
|
|
12
|
+
* (旧实现 renderToStaticMarkup 会把事件 handler 全部剥掉,控件渲染但点不动)。
|
|
13
|
+
*/
|
|
14
|
+
const CELL_PORTAL_SENTINEL = '__HB_TABLE_CELL_PORTAL__';
|
|
15
|
+
/**
|
|
16
|
+
* 把 render 返回的 React 元素拍平成 HTML 字符串。
|
|
17
|
+
* Stencil hb-table 的 renderCell 直接把值塞进 vdom,若值是 React 元素(被冻结),
|
|
18
|
+
* Stencil 会把它当 vnode patch → "Cannot add property $elm$"。
|
|
19
|
+
* 所以这里转成 HTML 字符串再传给 hb-table(单元格内通常是小段文字/标签/图标,可接受)。
|
|
20
|
+
*/
|
|
21
|
+
function renderToHtml(node) {
|
|
22
|
+
if (node == null || node === false || node === true)
|
|
23
|
+
return '';
|
|
24
|
+
if (typeof node === 'string' || typeof node === 'number')
|
|
25
|
+
return String(node);
|
|
26
|
+
try {
|
|
27
|
+
return renderToStaticMarkup(node);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function Table(props) {
|
|
34
|
+
const { dataSource = [], columns = [], rowKey, loading, size, bordered, pagination, rowSelection, scroll, onChange } = props;
|
|
35
|
+
// antd columns → huibo columns
|
|
36
|
+
const huiboColumns = columns.map(c => ({
|
|
37
|
+
prop: c.dataIndex || c.key || '',
|
|
38
|
+
// 支持 antd 动态表头:title 为函数时先调用取返回值(否则 React 会把函数当子节点 →
|
|
39
|
+
// "Functions are not valid as a React child" 警告且表头为空)
|
|
40
|
+
label: renderToHtml(typeof c.title === 'function' ? c.title() : c.title),
|
|
41
|
+
width: c.width ? String(c.width).replace('px', '') + 'px' : undefined,
|
|
42
|
+
minWidth: c.minWidth ? String(c.minWidth) : undefined,
|
|
43
|
+
align: c.align,
|
|
44
|
+
fixed: c.fixed,
|
|
45
|
+
sortable: typeof c.sorter === 'boolean' ? c.sorter : !!c.sorter,
|
|
46
|
+
sorter: typeof c.sorter === 'function' ? c.sorter : undefined,
|
|
47
|
+
sortOrder: c.sortOrder === 'ascend' ? 'ascending' : c.sortOrder === 'descend' ? 'descending' : undefined,
|
|
48
|
+
filters: c.filters?.map((f) => ({ label: String(f.text), value: f.value })),
|
|
49
|
+
filteredValue: c.filteredValue,
|
|
50
|
+
onFilter: c.onFilter ? (row, val) => c.onFilter(val, row) : undefined,
|
|
51
|
+
// 有 render 的列走 portal:hb-table 渲染空 sentinel span,再由本组件用 React
|
|
52
|
+
// createRoot 挂入真正的交互内容(保留事件 handler)。无 render 的列走原值快路径。
|
|
53
|
+
render: c.render ? () => CELL_PORTAL_SENTINEL : undefined,
|
|
54
|
+
ellipsis: c.ellipsis,
|
|
55
|
+
}));
|
|
56
|
+
// rowKey 函数 → 字符串
|
|
57
|
+
const huiboRowKey = typeof rowKey === 'string' ? rowKey : '';
|
|
58
|
+
// pagination 适配
|
|
59
|
+
const huiboPagination = pagination === false ? undefined : pagination ? {
|
|
60
|
+
current: pagination.current,
|
|
61
|
+
pageSize: pagination.pageSize,
|
|
62
|
+
pageSizes: pagination.pageSizeOptions?.map((s) => parseInt(s)),
|
|
63
|
+
showTotal: !!pagination.showTotal,
|
|
64
|
+
} : undefined;
|
|
65
|
+
// rowSelection 适配
|
|
66
|
+
const huiboRowSelection = rowSelection ? {
|
|
67
|
+
type: rowSelection.type || 'checkbox',
|
|
68
|
+
selectedRowKeys: rowSelection.selectedRowKeys,
|
|
69
|
+
getCheckboxProps: rowSelection.getCheckboxProps,
|
|
70
|
+
} : undefined;
|
|
71
|
+
// ===== 单元格 portal:把含交互内容的单元格用 React createRoot 挂进 hb-table 的 sentinel span =====
|
|
72
|
+
// 用 callback ref 稳定拿到 hb-table CE 节点(输出目标 forwardRef 模板兼容)。
|
|
73
|
+
const tableHostRef = React.useRef(null);
|
|
74
|
+
const setTableHost = React.useCallback((el) => {
|
|
75
|
+
tableHostRef.current = el;
|
|
76
|
+
}, []);
|
|
77
|
+
// key = `${rowKey}::${colProp}` → { root, node };node 用于检测 span 是否被 hb-table 重建
|
|
78
|
+
const cellRootsRef = React.useRef(new Map());
|
|
79
|
+
// colProp → { col },仅含有 render 的列
|
|
80
|
+
const colRenderMap = React.useMemo(() => {
|
|
81
|
+
const m = new Map();
|
|
82
|
+
columns.forEach(c => {
|
|
83
|
+
if (c.render)
|
|
84
|
+
m.set(c.dataIndex || c.key || '', { col: c });
|
|
85
|
+
});
|
|
86
|
+
return m;
|
|
87
|
+
}, [columns]);
|
|
88
|
+
// hb-table 每次 componentDidRender 发 hbCellsRendered 后,扫描 sentinel span,
|
|
89
|
+
// 把真正的 React 内容(含事件 handler)挂进去。
|
|
90
|
+
const reconcileCellPortals = React.useCallback(() => {
|
|
91
|
+
const host = tableHostRef.current;
|
|
92
|
+
const sr = host && host.shadowRoot;
|
|
93
|
+
if (!sr)
|
|
94
|
+
return;
|
|
95
|
+
const spans = Array.from(sr.querySelectorAll('.hb-table__cell-portal'));
|
|
96
|
+
const seen = new Set();
|
|
97
|
+
const rkStr = typeof rowKey === 'string' ? rowKey : '';
|
|
98
|
+
for (const span of spans) {
|
|
99
|
+
const rk = span.getAttribute('data-row-key') || '';
|
|
100
|
+
const colProp = span.getAttribute('data-col') || '';
|
|
101
|
+
const key = `${rk}::${colProp}`;
|
|
102
|
+
seen.add(key);
|
|
103
|
+
const info = colRenderMap.get(colProp);
|
|
104
|
+
if (!info)
|
|
105
|
+
continue;
|
|
106
|
+
// 行数据定位:受控 rowKey 用字段匹配,否则用 rowIndex
|
|
107
|
+
let index = -1;
|
|
108
|
+
if (rkStr) {
|
|
109
|
+
index = dataSource.findIndex(r => String(r[rkStr]) === rk);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const n = Number(rk);
|
|
113
|
+
index = Number.isFinite(n) ? n : -1;
|
|
114
|
+
}
|
|
115
|
+
if (index < 0 || index >= dataSource.length)
|
|
116
|
+
continue;
|
|
117
|
+
const row = dataSource[index];
|
|
118
|
+
let node;
|
|
119
|
+
try {
|
|
120
|
+
node = info.col.render(row[info.col.dataIndex ?? colProp], row, index);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
node = '';
|
|
124
|
+
}
|
|
125
|
+
// 基本类型:直接 textContent(格式化列走快路径,无需 React root)
|
|
126
|
+
if (node == null || typeof node === 'string' || typeof node === 'number') {
|
|
127
|
+
const prev = cellRootsRef.current.get(key);
|
|
128
|
+
if (prev) {
|
|
129
|
+
prev.root.unmount();
|
|
130
|
+
cellRootsRef.current.delete(key);
|
|
131
|
+
}
|
|
132
|
+
const txt = node == null ? '' : String(node);
|
|
133
|
+
if (span.textContent !== txt)
|
|
134
|
+
span.textContent = txt;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// React 元素:createRoot 挂载/更新,保留事件 handler(交互控件可点击)
|
|
138
|
+
let entry = cellRootsRef.current.get(key);
|
|
139
|
+
if (!entry || entry.node !== span) {
|
|
140
|
+
if (entry)
|
|
141
|
+
entry.root.unmount();
|
|
142
|
+
entry = { root: createRoot(span), node: span };
|
|
143
|
+
cellRootsRef.current.set(key, entry);
|
|
144
|
+
}
|
|
145
|
+
entry.root.render(node);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// 清理已消失的单元格 root,防泄漏
|
|
149
|
+
for (const [key, entry] of cellRootsRef.current) {
|
|
150
|
+
if (!seen.has(key)) {
|
|
151
|
+
entry.root.unmount();
|
|
152
|
+
cellRootsRef.current.delete(key);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, [colRenderMap, dataSource, rowKey]);
|
|
156
|
+
React.useEffect(() => {
|
|
157
|
+
const host = tableHostRef.current;
|
|
158
|
+
if (!host)
|
|
159
|
+
return;
|
|
160
|
+
const onRendered = () => reconcileCellPortals();
|
|
161
|
+
host.addEventListener('hbCellsRendered', onRendered);
|
|
162
|
+
reconcileCellPortals();
|
|
163
|
+
return () => {
|
|
164
|
+
host.removeEventListener('hbCellsRendered', onRendered);
|
|
165
|
+
};
|
|
166
|
+
}, [reconcileCellPortals]);
|
|
167
|
+
// 卸载清理
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
return () => {
|
|
170
|
+
cellRootsRef.current.forEach(e => e.root.unmount());
|
|
171
|
+
cellRootsRef.current.clear();
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
return (_jsx(HbTable, { ref: setTableHost, data: dataSource, columns: huiboColumns, rowKey: huiboRowKey, loading: loading, size: size === 'middle' ? 'default' : size || 'default', border: bordered, stripe: false, pagination: huiboPagination, rowSelection: huiboRowSelection, tableScroll: scroll ? { x: scroll.x ? String(scroll.x) : undefined, y: scroll.y ? String(scroll.y) : undefined } : undefined, onHbPageChange: (e) => {
|
|
175
|
+
if (pagination && pagination.onChange)
|
|
176
|
+
pagination.onChange(e.detail.current, e.detail.pageSize);
|
|
177
|
+
}, onHbSelectionChange: (e) => {
|
|
178
|
+
if (rowSelection?.onChange) {
|
|
179
|
+
const rows = e.detail;
|
|
180
|
+
const keys = huiboRowKey ? rows.map((r) => r[huiboRowKey]) : rows.map((_, i) => i);
|
|
181
|
+
rowSelection.onChange(keys, rows);
|
|
182
|
+
}
|
|
183
|
+
}, onHbSortChange: (e) => {
|
|
184
|
+
if (onChange)
|
|
185
|
+
onChange({}, {}, { field: e.detail.prop, order: e.detail.order === 'ascending' ? 'ascend' : e.detail.order === 'descending' ? 'descend' : undefined });
|
|
186
|
+
}, style: props.style }));
|
|
187
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TabItemType {
|
|
3
|
+
key: string;
|
|
4
|
+
label: React.ReactNode;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function Tabs(props: {
|
|
9
|
+
items?: TabItemType[];
|
|
10
|
+
activeKey?: string;
|
|
11
|
+
defaultActiveKey?: string;
|
|
12
|
+
onChange?: (key: string) => void;
|
|
13
|
+
type?: 'line' | 'card';
|
|
14
|
+
size?: 'small' | 'middle' | 'large';
|
|
15
|
+
tabPosition?: 'top' | 'bottom' | 'left' | 'right';
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
}): React.JSX.Element;
|
|
19
|
+
export declare namespace Tabs {
|
|
20
|
+
var TabPane: any;
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HbTabs, HbTabPane } from '@huibo-ui/react';
|
|
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 });
|
|
6
|
+
}
|
|
7
|
+
Tabs.TabPane = function TabPane(props) { return React.createElement(HbTabPane, { key: props.tabKey || props.key, label: props.tab }, props.children); };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HbTag } from '@huibo-ui/react';
|
|
3
|
+
const colorMap = { success: 'success', processing: 'info', error: 'danger', default: 'info', warning: 'warning', blue: 'primary', green: 'success', red: 'danger', orange: 'warning' };
|
|
4
|
+
export function Tag(props) {
|
|
5
|
+
return _jsx(HbTag, { type: (colorMap[props.color || 'default'] || 'default'), closable: props.closable, onHbClose: () => props.onClose?.(), style: props.style, children: props.children });
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function TimePicker(props: {
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange?: (value: any) => void;
|
|
5
|
+
format?: string;
|
|
6
|
+
allowClear?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
size?: 'small' | 'middle' | 'large';
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}): React.JSX.Element;
|