@ticatec/uniface-element 0.3.8 → 0.3.10

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.
@@ -11,6 +11,7 @@
11
11
  import ActionPanel from "./parts/ActionsPanel.svelte";
12
12
  import {OrderDirection} from "./lib/OrderDirection";
13
13
  import type {CompareFunction} from "./lib/CompareFunction";
14
+ import type {GetRowFontStyle} from "./lib/types";
14
15
 
15
16
  export let columns: Array<DataColumn>;
16
17
  export let actionsColumn: ActionsColumn | null = null;
@@ -22,6 +23,7 @@
22
23
  export let rowBorder: boolean = false;
23
24
  export let colBorder: boolean = false;
24
25
  export let emptyIndicator: string | undefined = undefined;
26
+ export let getRowFontStyle: GetRowFontStyle | undefined = undefined;
25
27
 
26
28
  export let style: string = '';
27
29
 
@@ -114,7 +116,7 @@
114
116
  <ContentPanel columns={dataColumns} {orderDirection} {orderColumn} {handleWidthChange} {handleCellClick} {tabWidth} bind:rows
115
117
  bind:scrollTop {expandRow} {rowHeight} {list} {table} {inlineComponent} bind:inlineRowHeight {emptyIndicator}
116
118
  displayHorizontalScroll={actionsColumn!=null || indicatorColumn != null || fixedCols.length > 0}
117
- showVerticalScroll={actionsColumn == null}/>
119
+ showVerticalScroll={actionsColumn == null} {getRowFontStyle}/>
118
120
  {/if}
119
121
 
120
122
  {#if actionsColumn}
@@ -1,6 +1,7 @@
1
1
  import type DataColumn from "./lib/DataColumn";
2
2
  import type ActionsColumn from "./lib/ActionsColumn";
3
3
  import type IndicatorColumn from "./lib/IndicatorColumn";
4
+ import type { GetRowFontStyle } from "./lib/types";
4
5
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
5
6
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
7
  $$bindings?: Bindings;
@@ -25,6 +26,7 @@ declare const DataTable: $$__sveltets_2_IsomorphicComponent<{
25
26
  rowBorder?: boolean;
26
27
  colBorder?: boolean;
27
28
  emptyIndicator?: string | undefined;
29
+ getRowFontStyle?: GetRowFontStyle | undefined;
28
30
  style?: string;
29
31
  }, {
30
32
  [evt: string]: CustomEvent<any>;
@@ -1,6 +1,7 @@
1
1
  import type { CellHint, FormatCell } from "./FormatCell";
2
2
  import type { HrefBuilder } from "./HrefLink";
3
3
  import type { CompareFunction } from "./CompareFunction";
4
+ import type { GetCellStyle } from "./types";
4
5
  export default interface DataColumn {
5
6
  /**
6
7
  * 列头文字
@@ -59,4 +60,8 @@ export default interface DataColumn {
59
60
  *
60
61
  */
61
62
  compareFunction?: CompareFunction;
63
+ /**
64
+ * 获取表格的样式
65
+ */
66
+ cellStyle?: GetCellStyle;
62
67
  }
@@ -0,0 +1,22 @@
1
+ export interface RowFontStyle {
2
+ /**
3
+ * 字体大小
4
+ */
5
+ size?: string;
6
+ /**
7
+ * 字体颜色
8
+ */
9
+ color?: string;
10
+ /**
11
+ * 字重
12
+ */
13
+ weight?: number | string;
14
+ }
15
+ /**
16
+ * 获取cell样式
17
+ */
18
+ export type GetCellStyle = (data: any) => string;
19
+ /**
20
+ * 获取整行的样式
21
+ */
22
+ export type GetRowFontStyle = (data: any) => RowFontStyle;
@@ -0,0 +1 @@
1
+ export {};
@@ -7,6 +7,7 @@
7
7
  import TableHeaderPanel from "./TableHeaderPanel.svelte";
8
8
  import UniDataTable, {type TableEventHandler} from "../UniDataTable";
9
9
  import {OrderDirection} from "../lib/OrderDirection";
10
+ import type {GetRowFontStyle} from "../lib/types";
10
11
 
11
12
 
12
13
  export let columns: Array<DataColumn>;
@@ -14,6 +15,8 @@
14
15
  export let orderColumn: DataColumn ;
15
16
  export let orderDirection: OrderDirection;
16
17
 
18
+ export let getRowFontStyle: GetRowFontStyle | undefined;
19
+
17
20
  export let emptyIndicator: string | null = null;
18
21
 
19
22
  export let list: Array<any>;
@@ -121,7 +124,7 @@
121
124
  {#if rows && rows.length > 0}
122
125
  <div style="box-sizing: border-box; width: {rowWidth}px; top: {top}">
123
126
  {#each rows as row, idx}
124
- <DataRow {rowHeight} {row} {columns} alternative={idx % 2 == 1}/>
127
+ <DataRow fontStyle={getRowFontStyle?.(row.data)} {rowHeight} {row} {columns} alternative={idx % 2 == 1}/>
125
128
  {#if row == expandRow && inlineComponent}
126
129
  <div class="expand-data-row" bind:clientHeight={inlineRowHeight}
127
130
  style="position: relative; box-sizing: content-box; width: 100%; height: auto">
@@ -2,6 +2,7 @@ import type DataColumn from "../lib/DataColumn";
2
2
  import type TableRow from "./TableRow";
3
3
  import UniDataTable, { type TableEventHandler } from "../UniDataTable";
4
4
  import { OrderDirection } from "../lib/OrderDirection";
5
+ import type { GetRowFontStyle } from "../lib/types";
5
6
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
6
7
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
7
8
  $$bindings?: Bindings;
@@ -20,6 +21,7 @@ declare const ContentPanel: $$__sveltets_2_IsomorphicComponent<{
20
21
  rows: Array<TableRow>;
21
22
  orderColumn: DataColumn;
22
23
  orderDirection: OrderDirection;
24
+ getRowFontStyle: GetRowFontStyle | undefined;
23
25
  emptyIndicator?: string | null;
24
26
  list: Array<any>;
25
27
  expandRow: TableRow | null;
@@ -13,15 +13,17 @@
13
13
  let hint: any;
14
14
  let cell: any;
15
15
  let col$class: string ='';
16
+ let style: string = '';
16
17
 
17
18
  $: {
18
19
  hint = column.hint?.(data);
20
+ style = column.cellStyle?.(data) ?? '';
19
21
  }
20
22
 
21
23
  $: col$class = frozen ? `fz_col-${colIdx}` : `col-${colIdx}`;
22
24
 
23
25
  </script>
24
- <div class="data-cell {col$class}">
26
+ <div class="data-cell {col$class}" {style}>
25
27
  <div class="vertical-center">
26
28
  {#if column.render}
27
29
  <svelte:component this={column.render.component} {...column.render.props} {data}/>
@@ -3,15 +3,37 @@
3
3
  import type DataColumn from "../lib/DataColumn";
4
4
  import DataCell from "./DataCell.svelte";
5
5
  import type TableRow from "./TableRow";
6
+ import type {RowFontStyle} from "../lib/types";
6
7
 
7
8
  export let columns: Array<DataColumn>;
8
9
  export let row: TableRow;
9
10
  export let alternative: boolean;
10
- export let rowHeight: number; //{ rowHeight}
11
-
12
- let style: string = '';
13
-
14
- $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
11
+ export let rowHeight: number;
12
+ export let fontStyle: RowFontStyle;
13
+
14
+ /**
15
+ * 获取行样式
16
+ * @param rh
17
+ * @param fs
18
+ */
19
+ const getRowStyle = (rh: number, fs: RowFontStyle) => {
20
+ let rs = '';
21
+ if (rh) {
22
+ rs = `height: ${rowHeight}px`;
23
+ }
24
+ if (fs?.size) {
25
+ rs = `font-size: ${fs.size}; ${rs}`;
26
+ }
27
+ if (fs?.color) {
28
+ rs = `color: ${fs?.color}; ${rs}`;
29
+ }
30
+ if (fs?.weight) {
31
+ rs = `font-weight: ${fs?.weight}; ${rs}`;
32
+ }
33
+ return rs;
34
+ }
35
+
36
+ $: style = getRowStyle(rowHeight, fontStyle)
15
37
 
16
38
 
17
39
  </script>
@@ -1,5 +1,6 @@
1
1
  import type DataColumn from "../lib/DataColumn";
2
2
  import type TableRow from "./TableRow";
3
+ import type { RowFontStyle } from "../lib/types";
3
4
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
5
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
5
6
  $$bindings?: Bindings;
@@ -18,6 +19,7 @@ declare const DataRow: $$__sveltets_2_IsomorphicComponent<{
18
19
  row: TableRow;
19
20
  alternative: boolean;
20
21
  rowHeight: number;
22
+ fontStyle: RowFontStyle;
21
23
  }, {
22
24
  [evt: string]: CustomEvent<any>;
23
25
  }, {}, {}, string>;
package/dist/types.d.ts CHANGED
@@ -4,6 +4,9 @@ import { DisplayMode } from "./common/DisplayMode.js";
4
4
  import { DateContext } from "./base-calendar";
5
5
  import { ModalResult } from "./message-box";
6
6
  import type { LazyLoader } from "./list-box";
7
+ import type { GetRowActions } from "./data-table";
8
+ import type { GetCellStyle } from "./data-table/lib/types";
9
+ import type { GetRowFontStyle, RowFontStyle } from "./data-table/lib/types";
7
10
  /**
8
11
  * 从选中的Option中获取对于的文字值
9
12
  */
@@ -11,3 +14,4 @@ type RetrieveOptionText = (item: any) => string;
11
14
  export { DateContext, ModalResult, DisplayMode };
12
15
  export type { RetrieveOptionText, LazyLoader };
13
16
  export type { OnChangeHandler, MouseClickHandler };
17
+ export type { GetRowActions, GetCellStyle, GetRowFontStyle, RowFontStyle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-element",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
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",