@ticatec/topside-elements 1.0.1 → 1.0.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.
@@ -192,9 +192,9 @@ export default interface DataColumn {
192
192
  hint?: CellHint;
193
193
 
194
194
  /**
195
- * 渲染器
195
+ * 自定义单元格渲染器(可为 Svelte 组件或 `{ component, props }` 配置对象)
196
196
  */
197
- render?: any;
197
+ render?: ColumnRender;
198
198
 
199
199
  /**
200
200
  *
@@ -215,6 +215,19 @@ export default interface DataColumn {
215
215
  * 获取表格的样式
216
216
  */
217
217
  cellStyle?: GetCellStyle;
218
+
219
+ /**
220
+ * 合计行里本列的聚合方式:sum / avg / count / min / max / 自定义函数;
221
+ * 'label' 表示在本列显示合计标签(没有指示列时用)。
222
+ * 只要有一列设置了(或 table 的 summaryValues 覆盖了某列),表格底部就会出现合计行。
223
+ */
224
+ summary?: SummaryKind | SummaryFn | 'label';
225
+
226
+ /**
227
+ * 合计值的格式化。不设时:count 显示整数(千分位);其它先用 formatter,再退回数字自动格式化
228
+ * (千分位,小数位取本列数据最大小数位,avg 至少 2 位)
229
+ */
230
+ summaryFormatter?: (value: any, rows: Array<any>) => string;
218
231
  }
219
232
  ```
220
233
 
@@ -236,6 +249,14 @@ export type HrefBuilder = (item: any) => Array<HrefLink> | HrefLink | string;
236
249
  export type CellHint = (value: any) => string;
237
250
  ```
238
251
 
252
+ ### `ColumnRender`
253
+
254
+ ```ts
255
+ export type ColumnRender<Props extends Record<string, any> = Record<string, any>> =
256
+ | Component<any>
257
+ | ColumnRenderObject<Props>;
258
+ ```
259
+
239
260
  ### `CompareFn`
240
261
 
241
262
  ```ts
@@ -248,6 +269,18 @@ export type CompareFn = (o1: any, o2: any) => number;
248
269
  export type GetCellStyle = (data: any) => string;
249
270
  ```
250
271
 
272
+ ### `SummaryKind`
273
+
274
+ ```ts
275
+ export type SummaryKind = 'sum' | 'avg' | 'count' | 'min' | 'max';
276
+ ```
277
+
278
+ ### `SummaryFn`
279
+
280
+ ```ts
281
+ export type SummaryFn = (values: Array<any>, rows: Array<any>) => any;
282
+ ```
283
+
251
284
  ### `HrefLink`
252
285
 
253
286
  ```ts
@@ -263,6 +296,23 @@ export default interface HrefLink {
263
296
  }
264
297
  ```
265
298
 
299
+ ### `ColumnRenderObject`
300
+
301
+ ```ts
302
+ export interface ColumnRenderObject<Props extends Record<string, any> = Record<string, any>> {
303
+ /**
304
+ * 自定义 Svelte 单元格组件。
305
+ * 组件会接收 `props` 中传入的属性,并自动接收当前行的数据 `data`。
306
+ */
307
+ component: Component<any>;
308
+
309
+ /**
310
+ * 传递给自定义组件的额外属性
311
+ */
312
+ props?: Props;
313
+ }
314
+ ```
315
+
266
316
  ### `OnHrefClick`
267
317
 
268
318
  ```ts
@@ -36,6 +36,8 @@ import DataTable from '@ticatec/topside-elements/DataTable';
36
36
  | `style` | 否 | `string` | 否 | `''` | 否 | 附加到组件根元素的内联样式。 |
37
37
  | `virtual` | 否 | `boolean` | 否 | `false` | 否 | 行虚拟化(窗口化渲染):仅渲染可视区域附近的行,大数据集(数千行以上) 建议开启。要求所有行高度一致(即统一的 rowHeight),因此默认关闭。 |
38
38
  | `overscan` | 否 | `number` | 否 | `8` | 否 | 虚拟化时可视区上下额外渲染的行数。 |
39
+ | `summaryLabel` | 否 | `string` | 否 | `undefined` | 否 | 合计行的标签,默认取 i18n(uniface.dataTable.summaryLabel,"合计" / "Total");传空串则不显示标签 |
40
+ | `summaryValues` | 否 | `Record<string, any> \| null` | 否 | `null` | 否 | 外部提供的合计值,按列 field 取值,优先于列的 summary 在当前 list 上的计算。 分页场景下用它显示服务端算好的全量合计(数字串会按数字格式化)。 |
39
41
 
40
42
  > 组件的“可绑定”表示源码使用了 Svelte 5 的 `$bindable`;服务的“响应式”表示成员使用了 `$state`。复杂类型请同时参考 TypeScript 自动补全。
41
43
 
@@ -143,9 +145,9 @@ export default interface DataColumn {
143
145
  hint?: CellHint;
144
146
 
145
147
  /**
146
- * 渲染器
148
+ * 自定义单元格渲染器(可为 Svelte 组件或 `{ component, props }` 配置对象)
147
149
  */
148
- render?: any;
150
+ render?: ColumnRender;
149
151
 
150
152
  /**
151
153
  *
@@ -166,6 +168,19 @@ export default interface DataColumn {
166
168
  * 获取表格的样式
167
169
  */
168
170
  cellStyle?: GetCellStyle;
171
+
172
+ /**
173
+ * 合计行里本列的聚合方式:sum / avg / count / min / max / 自定义函数;
174
+ * 'label' 表示在本列显示合计标签(没有指示列时用)。
175
+ * 只要有一列设置了(或 table 的 summaryValues 覆盖了某列),表格底部就会出现合计行。
176
+ */
177
+ summary?: SummaryKind | SummaryFn | 'label';
178
+
179
+ /**
180
+ * 合计值的格式化。不设时:count 显示整数(千分位);其它先用 formatter,再退回数字自动格式化
181
+ * (千分位,小数位取本列数据最大小数位,avg 至少 2 位)
182
+ */
183
+ summaryFormatter?: (value: any, rows: Array<any>) => string;
169
184
  }
170
185
  ```
171
186
 
@@ -265,6 +280,14 @@ export type HrefBuilder = (item: any) => Array<HrefLink> | HrefLink | string;
265
280
  export type CellHint = (value: any) => string;
266
281
  ```
267
282
 
283
+ ### `ColumnRender`
284
+
285
+ ```ts
286
+ export type ColumnRender<Props extends Record<string, any> = Record<string, any>> =
287
+ | Component<any>
288
+ | ColumnRenderObject<Props>;
289
+ ```
290
+
268
291
  ### `CompareFn`
269
292
 
270
293
  ```ts
@@ -277,6 +300,18 @@ export type CompareFn = (o1: any, o2: any) => number;
277
300
  export type GetCellStyle = (data: any) => string;
278
301
  ```
279
302
 
303
+ ### `SummaryKind`
304
+
305
+ ```ts
306
+ export type SummaryKind = 'sum' | 'avg' | 'count' | 'min' | 'max';
307
+ ```
308
+
309
+ ### `SummaryFn`
310
+
311
+ ```ts
312
+ export type SummaryFn = (values: Array<any>, rows: Array<any>) => any;
313
+ ```
314
+
280
315
  ### `GetRowActions`
281
316
 
282
317
  ```ts
@@ -317,6 +352,23 @@ export default interface HrefLink {
317
352
  }
318
353
  ```
319
354
 
355
+ ### `ColumnRenderObject`
356
+
357
+ ```ts
358
+ export interface ColumnRenderObject<Props extends Record<string, any> = Record<string, any>> {
359
+ /**
360
+ * 自定义 Svelte 单元格组件。
361
+ * 组件会接收 `props` 中传入的属性,并自动接收当前行的数据 `data`。
362
+ */
363
+ component: Component<any>;
364
+
365
+ /**
366
+ * 传递给自定义组件的额外属性
367
+ */
368
+ props?: Props;
369
+ }
370
+ ```
371
+
320
372
  ### `RowAction`
321
373
 
322
374
  ```ts
@@ -348,12 +400,6 @@ export type OnHrefClick = () => void;
348
400
  export type ButtonType = 'default' | 'primary' | 'secondary' | 'third' | 'forth';
349
401
  ```
350
402
 
351
- ### `ActionHandler`
352
-
353
- ```ts
354
- export type ActionHandler<T = any> = (data: T) => void | Promise<void>;
355
- ```
356
-
357
403
  ## 示例
358
404
 
359
405
  完整示例见 [example.svelte](./example.svelte)。
@@ -21,11 +21,16 @@ import Split from '@ticatec/topside-elements/Split';
21
21
 
22
22
  | 属性 | 重要 | 类型 | 必填 | 默认值 | 可绑定/响应式 | 说明 |
23
23
  | --- | --- | --- | --- | --- | --- | --- |
24
- | `direction` | 否 | `"horizontal" \| "vertical"` | 否 | `"vertical"` | 否 | 可选配置,具体取值范围和数据结构见类型列。 |
25
- | `width` | 否 | `number` | 否 | `2` | 否 | 宽度配置,数值单位为像素。 |
26
- | `bindingPanel` | 否 | `HTMLElement` | 否 | `undefined` | 否 | 可选配置,具体取值范围和数据结构见类型列。 |
27
- | `reverse` | 否 | `boolean` | 否 | `false` | 否 | 可选配置,具体取值范围和数据结构见类型列。 |
28
- | `onResizeEnd` | 否 | `(size: number) => void` | 否 | `undefined` | 否 | 事件或行为回调;参数与返回值以类型签名为准。 |
24
+ | `direction` | 否 | `"horizontal" \| "vertical"` | 否 | `"vertical"` | 否 | 分隔线朝向:vertical 竖线(左右分栏),horizontal 横线(上下分栏) |
25
+ | `width` | 否 | `number` | 否 | `1` | 否 | 可见线条粗细(px),占布局,默认 1 |
26
+ | `bindingPanel` | 否 | `HTMLElement` | 否 | `undefined` | 否 | 被拖动调整尺寸的面板;不传则为固定分隔线 |
27
+ | `reverse` | 否 | `boolean` | 否 | `false` | 否 | 绑定面板在分隔线右侧 / 下方时设为 true |
28
+ | `color` | 否 | `string` | 否 | `undefined` | 否 | 线条底色,默认取 --topside-dividing-line-color |
29
+ | `gripColor` | 否 | `string` | 否 | `undefined` | 否 | 悬停 / 拖动时中间把手的颜色,默认取 --topside-divider-grip-color |
30
+ | `gripSize` | 否 | `number` | 否 | `3` | 否 | 把手粗细(px),默认 3 |
31
+ | `gripLength` | 否 | `number` | 否 | `32` | 否 | 把手长度(px),默认 32;传 0 表示整条加粗 |
32
+ | `hitSize` | 否 | `number` | 否 | `8` | 否 | 鼠标感应区厚度(px),不占布局,默认 8 |
33
+ | `onResizeEnd` | 否 | `(size: number) => void` | 否 | `undefined` | 否 | 拖动结束时回调,参数为绑定面板最终宽 / 高(px) |
29
34
 
30
35
  > 组件的“可绑定”表示源码使用了 Svelte 5 的 `$bindable`;服务的“响应式”表示成员使用了 `$state`。复杂类型请同时参考 TypeScript 自动补全。
31
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/topside-elements",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A comprehensive UI component library for Svelte applications with rich form controls, data tables, layouts and interactive elements",
5
5
  "keywords": [
6
6
  "svelte",