bj-web-components 0.2.16 → 0.2.18

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/README.md CHANGED
@@ -1,205 +1,205 @@
1
- # bu-max-ui
2
-
3
- 企业级 UI 组件库,支持 Web、移动端、小程序三端,基于 React + TypeScript 构建。
4
-
5
- ## 安装
6
-
7
- ```bash
8
- npm install bu-max-ui
9
- # 或
10
- pnpm add bu-max-ui
11
- ```
12
-
13
- ## 快速上手
14
-
15
- 引入组件时需同步引入样式文件:
16
-
17
- ```tsx
18
- import { SkuInputCard } from 'bu-max-ui';
19
- import 'bu-max-ui/style';
20
- ```
21
-
22
- ## Iconfont 图标
23
-
24
- Web 组件中的图标使用 `BuIcon`(与下方 `Iconfont` 实现等价)。宿主应用或文档站需要先加载项目 iconfont symbol:
25
-
26
- ```html
27
- <script src="//at.alicdn.com/t/c/font_5123795_8zzfaepwkju.js"></script>
28
- ```
29
-
30
- 随后通过 `type` 传入 symbol id(不包含 `#`):
31
-
32
- ```tsx
33
- import { BuIcon } from 'bu-max-ui/web';
34
-
35
- <BuIcon type="icon-a-dagouxi" style={{ width: 14, height: 14, color: '#333' }} />
36
- ```
37
-
38
- `BuIcon` 的实现如下:
39
-
40
- ```tsx
41
- import React from 'react';
42
-
43
- function Iconfont({ type, style, onClick, className, ...rest }) {
44
- return (
45
- <svg
46
- style={style}
47
- className={className ? `icon ${className}` : 'icon'}
48
- aria-hidden="true"
49
- onClick={onClick}
50
- {...rest}
51
- >
52
- <use xlinkHref={`#${type}`} />
53
- </svg>
54
- );
55
- }
56
-
57
- export default Iconfont;
58
- ```
59
-
60
- ### 基础用法
61
-
62
- ```tsx
63
- import { useState } from 'react';
64
- import { SkuInputCard } from 'bu-max-ui';
65
- import 'bu-max-ui/style';
66
-
67
- function App() {
68
- const [name, setName] = useState('');
69
- const [lang, setLang] = useState<'zh' | 'en'>('zh');
70
-
71
- return (
72
- <SkuInputCard
73
- mode="bilingual"
74
- name={name}
75
- onNameChange={setName}
76
- activeLang={lang}
77
- onLangChange={setLang}
78
- onDelete={() => setName('')}
79
- />
80
- );
81
- }
82
- ```
83
-
84
- ## 按需引入
85
-
86
- 支持按平台路径单独引入,减少构建体积:
87
-
88
- ```tsx
89
- // Web 组件
90
- import { SkuInputCard } from 'bu-max-ui/web';
91
-
92
- // 移动端组件
93
- import { ... } from 'bu-max-ui/mobile';
94
-
95
- // 小程序组件
96
- import { ... } from 'bu-max-ui/miniapp';
97
-
98
- // 通用组件
99
- import { ... } from 'bu-max-ui/shared';
100
- ```
101
-
102
- ## 组件列表
103
-
104
- ### Web
105
-
106
- | 组件 | 说明 |
107
- |------|------|
108
- | `SkuInputCard` | 商品规格名称输入卡片,支持单语 / 双语模式、拖拽排序、图片上传 |
109
- | `Button` | 按钮 |
110
- | `Input` | 输入框 |
111
- | `Card` | 卡片 |
112
- | `Select` | 选择器 |
113
- | `Tooltip` | 气泡提示 |
114
-
115
- ### Mobile
116
-
117
- | 组件 | 说明 |
118
- |------|------|
119
- | `Button` | 移动端按钮 |
120
- | `Input` | 移动端输入框 |
121
- | `Card` | 移动端卡片 |
122
- | `TabBar` | 底部导航栏 |
123
- | `Navbar` | 顶部导航栏 |
124
- | `ActionSheet` | 动作面板 |
125
- | `Toast` | 轻提示 |
126
-
127
- ### 小程序
128
-
129
- | 组件 | 说明 |
130
- |------|------|
131
- | `Button` | 小程序按钮 |
132
- | `Input` | 小程序输入框 |
133
- | `Card` | 小程序卡片 |
134
- | `TabBar` | 底部导航栏 |
135
- | `Navbar` | 顶部导航栏 |
136
- | `ActionSheet` | 动作面板 |
137
- | `Modal` | 弹窗 |
138
- | `Loading` | 加载态 |
139
- | `Toast` | 轻提示 |
140
- | `Cell` | 单元格列表 |
141
-
142
- ## SkuInputCard Props
143
-
144
- | 参数 | 类型 | 默认值 | 说明 |
145
- |------|------|--------|------|
146
- | `name` | `string` | `''` | 产品名称输入值 |
147
- | `onNameChange` | `(value: string) => void` | — | 名称变更回调 |
148
- | `mode` | `'single' \| 'bilingual'` | `'single'` | 单语或双语模式 |
149
- | `activeLang` | `'zh' \| 'en'` | `'zh'` | 双语模式下当前语言 |
150
- | `onLangChange` | `(lang: 'zh' \| 'en') => void` | — | 语言切换回调 |
151
- | `showBody` | `boolean` | `true` | 是否显示内容区域 |
152
- | `error` | `boolean` | `false` | 错误状态 |
153
- | `onDelete` | `() => void` | — | 点击删除按钮回调 |
154
- | `onUpload` | `(file: File) => string \| Promise<string>` | — | 自定义上传方法,返回图片 URL |
155
- | `images` | `string[]` | — | 外部托管的图片列表 |
156
- | `id` | `string` | — | 拖拽把手 id,供 DnD 库使用 |
157
- | `className` | `string` | — | 自定义类名 |
158
- | `style` | `CSSProperties` | — | 自定义样式 |
159
-
160
- ## 本地开发
161
-
162
- ```bash
163
- # 克隆仓库
164
- git clone <repo-url>
165
- cd bu-max-ui
166
-
167
- # 安装依赖
168
- pnpm install
169
-
170
- # 启动文档站(端口 3000)
171
- pnpm dev
172
-
173
- # 构建组件库
174
- pnpm build:lib
175
-
176
- # 监听模式(开发库时使用)
177
- pnpm build:lib:watch
178
- ```
179
-
180
- ### 项目结构
181
-
182
- ```
183
- ├── lib/ # 组件库源码(npm 包)
184
- │ ├── index.ts
185
- │ ├── web/ # Web 平台组件
186
- │ ├── mobile/ # 移动端组件
187
- │ ├── miniapp/ # 小程序组件
188
- │ ├── react/ # React 通用组件
189
- │ └── shared/ # 共享工具 / 组件
190
- ├── src/ # 文档站源码
191
- │ ├── pages/ # 各组件演示页面
192
- │ └── components/ # 文档站内部组件
193
- └── dist/ # 构建产物(发布到 npm)
194
- ```
195
-
196
- ## 技术栈
197
-
198
- - **框架**: React 19 + TypeScript
199
- - **构建**: Vite 6(双模式:文档站 / 组件库)
200
- - **样式**: Less(BEM 命名规范)
201
- - **文档站**: React Router DOM 6 + Tailwind CSS v4
202
-
203
- ## 许可证
204
-
205
- MIT
1
+ # bu-max-ui
2
+
3
+ 企业级 UI 组件库,支持 Web、移动端、小程序三端,基于 React + TypeScript 构建。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install bu-max-ui
9
+ # 或
10
+ pnpm add bu-max-ui
11
+ ```
12
+
13
+ ## 快速上手
14
+
15
+ 引入组件时需同步引入样式文件:
16
+
17
+ ```tsx
18
+ import { SkuInputCard } from 'bu-max-ui';
19
+ import 'bu-max-ui/style';
20
+ ```
21
+
22
+ ## Iconfont 图标
23
+
24
+ Web 组件中的图标使用 `BuIcon`(与下方 `Iconfont` 实现等价)。宿主应用或文档站需要先加载项目 iconfont symbol:
25
+
26
+ ```html
27
+ <script src="//at.alicdn.com/t/c/font_5123795_8zzfaepwkju.js"></script>
28
+ ```
29
+
30
+ 随后通过 `type` 传入 symbol id(不包含 `#`):
31
+
32
+ ```tsx
33
+ import { BuIcon } from 'bu-max-ui/web';
34
+
35
+ <BuIcon type="icon-a-dagouxi" style={{ width: 14, height: 14, color: '#333' }} />
36
+ ```
37
+
38
+ `BuIcon` 的实现如下:
39
+
40
+ ```tsx
41
+ import React from 'react';
42
+
43
+ function Iconfont({ type, style, onClick, className, ...rest }) {
44
+ return (
45
+ <svg
46
+ style={style}
47
+ className={className ? `icon ${className}` : 'icon'}
48
+ aria-hidden="true"
49
+ onClick={onClick}
50
+ {...rest}
51
+ >
52
+ <use xlinkHref={`#${type}`} />
53
+ </svg>
54
+ );
55
+ }
56
+
57
+ export default Iconfont;
58
+ ```
59
+
60
+ ### 基础用法
61
+
62
+ ```tsx
63
+ import { useState } from 'react';
64
+ import { SkuInputCard } from 'bu-max-ui';
65
+ import 'bu-max-ui/style';
66
+
67
+ function App() {
68
+ const [name, setName] = useState('');
69
+ const [lang, setLang] = useState<'zh' | 'en'>('zh');
70
+
71
+ return (
72
+ <SkuInputCard
73
+ mode="bilingual"
74
+ name={name}
75
+ onNameChange={setName}
76
+ activeLang={lang}
77
+ onLangChange={setLang}
78
+ onDelete={() => setName('')}
79
+ />
80
+ );
81
+ }
82
+ ```
83
+
84
+ ## 按需引入
85
+
86
+ 支持按平台路径单独引入,减少构建体积:
87
+
88
+ ```tsx
89
+ // Web 组件
90
+ import { SkuInputCard } from 'bu-max-ui/web';
91
+
92
+ // 移动端组件
93
+ import { ... } from 'bu-max-ui/mobile';
94
+
95
+ // 小程序组件
96
+ import { ... } from 'bu-max-ui/miniapp';
97
+
98
+ // 通用组件
99
+ import { ... } from 'bu-max-ui/shared';
100
+ ```
101
+
102
+ ## 组件列表
103
+
104
+ ### Web
105
+
106
+ | 组件 | 说明 |
107
+ |------|------|
108
+ | `SkuInputCard` | 商品规格名称输入卡片,支持单语 / 双语模式、拖拽排序、图片上传 |
109
+ | `Button` | 按钮 |
110
+ | `Input` | 输入框 |
111
+ | `Card` | 卡片 |
112
+ | `Select` | 选择器 |
113
+ | `Tooltip` | 气泡提示 |
114
+
115
+ ### Mobile
116
+
117
+ | 组件 | 说明 |
118
+ |------|------|
119
+ | `Button` | 移动端按钮 |
120
+ | `Input` | 移动端输入框 |
121
+ | `Card` | 移动端卡片 |
122
+ | `TabBar` | 底部导航栏 |
123
+ | `Navbar` | 顶部导航栏 |
124
+ | `ActionSheet` | 动作面板 |
125
+ | `Toast` | 轻提示 |
126
+
127
+ ### 小程序
128
+
129
+ | 组件 | 说明 |
130
+ |------|------|
131
+ | `Button` | 小程序按钮 |
132
+ | `Input` | 小程序输入框 |
133
+ | `Card` | 小程序卡片 |
134
+ | `TabBar` | 底部导航栏 |
135
+ | `Navbar` | 顶部导航栏 |
136
+ | `ActionSheet` | 动作面板 |
137
+ | `Modal` | 弹窗 |
138
+ | `Loading` | 加载态 |
139
+ | `Toast` | 轻提示 |
140
+ | `Cell` | 单元格列表 |
141
+
142
+ ## SkuInputCard Props
143
+
144
+ | 参数 | 类型 | 默认值 | 说明 |
145
+ |------|------|--------|------|
146
+ | `name` | `string` | `''` | 产品名称输入值 |
147
+ | `onNameChange` | `(value: string) => void` | — | 名称变更回调 |
148
+ | `mode` | `'single' \| 'bilingual'` | `'single'` | 单语或双语模式 |
149
+ | `activeLang` | `'zh' \| 'en'` | `'zh'` | 双语模式下当前语言 |
150
+ | `onLangChange` | `(lang: 'zh' \| 'en') => void` | — | 语言切换回调 |
151
+ | `showBody` | `boolean` | `true` | 是否显示内容区域 |
152
+ | `error` | `boolean` | `false` | 错误状态 |
153
+ | `onDelete` | `() => void` | — | 点击删除按钮回调 |
154
+ | `onUpload` | `(file: File) => string \| Promise<string>` | — | 自定义上传方法,返回图片 URL |
155
+ | `images` | `string[]` | — | 外部托管的图片列表 |
156
+ | `id` | `string` | — | 拖拽把手 id,供 DnD 库使用 |
157
+ | `className` | `string` | — | 自定义类名 |
158
+ | `style` | `CSSProperties` | — | 自定义样式 |
159
+
160
+ ## 本地开发
161
+
162
+ ```bash
163
+ # 克隆仓库
164
+ git clone <repo-url>
165
+ cd bu-max-ui
166
+
167
+ # 安装依赖
168
+ pnpm install
169
+
170
+ # 启动文档站(端口 3000)
171
+ pnpm dev
172
+
173
+ # 构建组件库
174
+ pnpm build:lib
175
+
176
+ # 监听模式(开发库时使用)
177
+ pnpm build:lib:watch
178
+ ```
179
+
180
+ ### 项目结构
181
+
182
+ ```
183
+ ├── lib/ # 组件库源码(npm 包)
184
+ │ ├── index.ts
185
+ │ ├── web/ # Web 平台组件
186
+ │ ├── mobile/ # 移动端组件
187
+ │ ├── miniapp/ # 小程序组件
188
+ │ ├── react/ # React 通用组件
189
+ │ └── shared/ # 共享工具 / 组件
190
+ ├── src/ # 文档站源码
191
+ │ ├── pages/ # 各组件演示页面
192
+ │ └── components/ # 文档站内部组件
193
+ └── dist/ # 构建产物(发布到 npm)
194
+ ```
195
+
196
+ ## 技术栈
197
+
198
+ - **框架**: React 19 + TypeScript
199
+ - **构建**: Vite 6(双模式:文档站 / 组件库)
200
+ - **样式**: Less(BEM 命名规范)
201
+ - **文档站**: React Router DOM 6 + Tailwind CSS v4
202
+
203
+ ## 许可证
204
+
205
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { CSSProperties } from 'react';
2
+ import { default as default_2 } from 'react';
2
3
  import { FocusEvent as FocusEvent_2 } from 'react';
3
4
  import { FocusEventHandler } from 'react';
4
5
  import { ForwardRefExoticComponent } from 'react';
5
6
  import { HTMLAttributes } from 'react';
6
7
  import { InputHTMLAttributes } from 'react';
7
- import { JSX } from 'react/jsx-runtime';
8
+ import { JSX } from 'react';
8
9
  import { Key } from 'react';
9
10
  import { KeyboardEvent as KeyboardEvent_2 } from 'react';
10
11
  import { KeyboardEventHandler } from 'react';
@@ -246,7 +247,7 @@ export declare const BTable: typeof BTable_2 & {
246
247
  ColumnGroup: typeof ColumnGroup;
247
248
  };
248
249
 
249
- declare function BTable_2<RecordType extends object>({ columns, dataSource, rowKey, rowSelection, pagination, loading, bordered, size, showHeader, emptyText, emptyImage, emptyHeight, t, className, style, rowClassName, sortDirections, onChange, children, title, footer, summary, tableLayout, components, onRow, onHeaderRow, id, scroll, locale, }: TableProps<RecordType>): JSX.Element;
250
+ declare function BTable_2<RecordType extends object>({ columns, dataSource, rowKey, preserveSelectedRowKeys, rowSelection, pagination, loading, bordered, size, showHeader, emptyText, emptyImage, emptyHeight, t, className, style, rowClassName, sortDirections, onChange, children, title, footer, summary, tableLayout, components, onRow, onHeaderRow, id, scroll, locale, groupCollapse, }: TableProps<RecordType>): JSX.Element;
250
251
 
251
252
  export declare function BTabs({ activeKey, children, centered, className, defaultActiveKey, id, items, onChange, onTabClick, style, tabBarGutter, tabBarStyle, tabPosition, type, }: BTabsProps): JSX.Element;
252
253
 
@@ -784,6 +785,25 @@ export declare type GetRowKey<RecordType> = (record: RecordType, index?: number)
784
785
 
785
786
  declare const Group: ForwardRefExoticComponent<BCheckBoxGroupProps & RefAttributes<HTMLDivElement>>;
786
787
 
788
+ export declare interface GroupCollapseConfig<RecordType> {
789
+ /** Identify group header records. Defaults to `record.isGroup`. */
790
+ isGroupRow?: (record: RecordType, index: number) => boolean;
791
+ /** Return the stable key for a group header. Defaults to `record.groupId`. */
792
+ groupKey?: (record: RecordType, index: number) => TableKey;
793
+ /** Return the stable keys of the group's child records. */
794
+ childrenKeys?: (record: RecordType, index: number) => readonly TableKey[];
795
+ expandedKeys?: readonly TableKey[];
796
+ defaultExpandedKeys?: readonly TableKey[];
797
+ onExpandedKeysChange?: (expandedKeys: readonly TableKey[], record: RecordType, expanded: boolean) => void;
798
+ render?: (props: GroupCollapseRenderProps<RecordType>) => ReactNode;
799
+ }
800
+
801
+ export declare interface GroupCollapseRenderProps<RecordType> {
802
+ record: RecordType;
803
+ expanded: boolean;
804
+ onToggle: () => void;
805
+ }
806
+
787
807
  export declare type ModalLang = 'zh' | 'en';
788
808
 
789
809
  export declare type ModalMode = 'standard' | 'bilingual' | 'single';
@@ -848,7 +868,7 @@ export declare interface ProductFieldOption {
848
868
  searchText?: string;
849
869
  }
850
870
 
851
- export declare function ProgressTooltip({ placement, title, progress, className, style, }: ProgressTooltipProps): JSX.Element;
871
+ export declare function ProgressTooltip({ placement, title, progress, className, style, }: ProgressTooltipProps): default_2.JSX.Element;
852
872
 
853
873
  export declare interface ProgressTooltipProps extends BaseTooltipProps {
854
874
  title?: string;
@@ -1001,6 +1021,8 @@ export declare interface TableLocale {
1001
1021
 
1002
1022
  export declare interface TablePaginationConfig extends PaginationProps {
1003
1023
  position?: Array<'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'none'>;
1024
+ /** Render the supplied data as the current server-side page without local slicing. */
1025
+ serverPagination?: boolean;
1004
1026
  }
1005
1027
 
1006
1028
  export declare interface TableProps<RecordType extends object> {
@@ -1008,6 +1030,8 @@ export declare interface TableProps<RecordType extends object> {
1008
1030
  children?: ReactNode;
1009
1031
  dataSource?: readonly RecordType[];
1010
1032
  rowKey?: keyof RecordType | string | GetRowKey<RecordType>;
1033
+ /** Whether to preserve selected keys that are not in the current visible rows after pagination or filtering. */
1034
+ preserveSelectedRowKeys?: boolean;
1011
1035
  rowSelection?: TableRowSelection<RecordType>;
1012
1036
  pagination?: false | TablePaginationConfig;
1013
1037
  loading?: boolean | {
@@ -1050,6 +1074,7 @@ export declare interface TableProps<RecordType extends object> {
1050
1074
  onRow?: GetComponentProps<RecordType>;
1051
1075
  onHeaderRow?: GetComponentProps<readonly ColumnType<RecordType>[]>;
1052
1076
  expandable?: ExpandableConfig<RecordType>;
1077
+ groupCollapse?: GroupCollapseConfig<RecordType>;
1053
1078
  locale?: TableLocale;
1054
1079
  sortDirections?: SortOrder[];
1055
1080
  showSorterTooltip?: boolean | {
@@ -1061,7 +1086,6 @@ export declare interface TableProps<RecordType extends object> {
1061
1086
  }
1062
1087
 
1063
1088
  export declare interface TableRowSelection<RecordType> {
1064
- preserveSelectedRowKeys?: boolean;
1065
1089
  type?: TableSelectionType;
1066
1090
  selectedRowKeys?: TableKey[];
1067
1091
  defaultSelectedRowKeys?: TableKey[];