@yorkjs/hive-ui 2.2.9 → 2.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorkjs/hive-ui",
3
- "version": "2.2.9",
3
+ "version": "2.3.1",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -22,20 +22,11 @@
22
22
  position absolute
23
23
  top -6PX
24
24
  right -6PX
25
- width 16PX
26
- height 16PX
27
- line-height 16PX
28
- text-align center
29
- border-radius 50%
30
25
  z-index 2
31
-
32
- .delete-icon
33
- position absolute
34
- top 50%
35
- left 50%
36
- transform translate(-50%, -50%)
37
- line-height 1
38
- display block
26
+ width 17PX
27
+ height 17PX
28
+ line-height 1
29
+ flexHVCenter()
39
30
 
40
31
  .text-block
41
32
  background-color var(--containerCard)
@@ -97,9 +97,10 @@ const RichTextEditor: React.FC<RichTextEditorProps> = (props) => {
97
97
  const textareaRefs = useRef<Record<number, any>>({})
98
98
  const skipHeightSyncRef = useRef(false)
99
99
 
100
- const deleteBtnStyle = useMemo(() => ({
101
- backgroundColor: themeSelect('rgba(0, 0, 0, 0.5)', 'rgba(255, 255, 255, 0.5)'),
102
- }), [themeSelect])
100
+ const deleteIconColor = useMemo(
101
+ () => themeSelect('rgba(0, 0, 0, 0.5)', 'rgba(255, 255, 255, 0.5)'),
102
+ [themeSelect]
103
+ )
103
104
 
104
105
  const updateBlock = useCallback((index: number, patch: Partial<RichTextBlock>) => {
105
106
  onChange?.(
@@ -175,14 +176,12 @@ const RichTextEditor: React.FC<RichTextEditorProps> = (props) => {
175
176
  >
176
177
  <View
177
178
  className={styles['delete-btn']}
178
- style={deleteBtnStyle}
179
179
  onClick={(e) => handleDelete(e, index)}
180
180
  >
181
181
  <Icon
182
- name='close'
183
- size={10}
184
- color="var(--containerCard)"
185
- className={styles['delete-icon']}
182
+ name="close-circle-fill"
183
+ size={17}
184
+ color={deleteIconColor}
186
185
  />
187
186
  </View>
188
187
 
@@ -21,6 +21,8 @@ export interface TableColumn<T extends object> {
21
21
  render?: (value: T[keyof T], record: T, index: number) => React.ReactNode
22
22
  }
23
23
 
24
+ export type TableTextAlign = 'left' | 'center' | 'right'
25
+
24
26
  export interface TableProps<T extends object> {
25
27
  /** 列配置 */
26
28
  columns: TableColumn<T>[]
@@ -30,6 +32,10 @@ export interface TableProps<T extends object> {
30
32
  rowKey: keyof T
31
33
  /** 表头背景色 */
32
34
  headerBackgroundColor?: string
35
+ /** 表头文字加粗 */
36
+ headerTextBold?: boolean
37
+ /** 表格文字对齐方式 */
38
+ textAlign?: TableTextAlign
33
39
  /** 自定义类名 */
34
40
  className?: string
35
41
  /** 自定义样式 */
@@ -48,16 +54,29 @@ function formatWidth(width?: number | string) {
48
54
  }
49
55
 
50
56
  /**
51
- * 根据列宽生成单元格 flex 样式;未指定宽度时均分剩余空间
57
+ * 根据列宽和对齐方式生成单元格样式;未指定宽度时均分剩余空间
52
58
  */
53
- function getCellStyle(width?: number | string): React.CSSProperties {
59
+ function getCellStyle(width?: number | string, align: TableTextAlign = 'left'): React.CSSProperties {
54
60
  const formattedWidth = formatWidth(width)
61
+ const justifyContent = align === 'center'
62
+ ? 'center'
63
+ : align === 'right'
64
+ ? 'flex-end'
65
+ : 'flex-start'
55
66
 
56
67
  if (formattedWidth) {
57
- return { flex: `0 0 ${formattedWidth}` }
68
+ return {
69
+ flex: `0 0 ${formattedWidth}`,
70
+ justifyContent,
71
+ textAlign: align,
72
+ }
58
73
  }
59
74
 
60
- return { flex: 1 }
75
+ return {
76
+ flex: 1,
77
+ justifyContent,
78
+ textAlign: align,
79
+ }
61
80
  }
62
81
 
63
82
  /**
@@ -84,10 +103,14 @@ function getRowKey<T extends object>(
84
103
  /**
85
104
  * 渲染文本节点;字符串/数字包一层 Text,其它节点原样返回
86
105
  */
87
- function renderText(content: React.ReactNode, className: string) {
106
+ function renderText(
107
+ content: React.ReactNode,
108
+ className: string,
109
+ style?: React.CSSProperties,
110
+ ) {
88
111
  if (typeof content === 'string' || typeof content === 'number') {
89
112
  return (
90
- <Text className={className}>
113
+ <Text className={className} style={style}>
91
114
  {content}
92
115
  </Text>
93
116
  )
@@ -102,6 +125,8 @@ function Table<T extends object>(props: TableProps<T>) {
102
125
  columns,
103
126
  rowKey,
104
127
  headerBackgroundColor,
128
+ headerTextBold = false,
129
+ textAlign = 'left',
105
130
  className,
106
131
  style,
107
132
  } = props
@@ -124,9 +149,13 @@ function Table<T extends object>(props: TableProps<T>) {
124
149
  <View
125
150
  key={String(column.dataIndex)}
126
151
  className={styles['table-cell']}
127
- style={getCellStyle(column.width)}
152
+ style={getCellStyle(column.width, textAlign)}
128
153
  >
129
- {renderText(column.title, styles['table-header-text'])}
154
+ {renderText(
155
+ column.title,
156
+ styles['table-header-text'],
157
+ headerTextBold ? { fontWeight: 500 } : undefined,
158
+ )}
130
159
  </View>
131
160
  ))
132
161
  }
@@ -153,9 +182,13 @@ function Table<T extends object>(props: TableProps<T>) {
153
182
  <View
154
183
  key={`${currentRowKey}-${String(column.dataIndex)}`}
155
184
  className={styles['table-cell']}
156
- style={getCellStyle(column.width)}
185
+ style={getCellStyle(column.width, textAlign)}
157
186
  >
158
- {renderText(content as React.ReactNode, styles['table-cell-text'])}
187
+ {renderText(
188
+ content as React.ReactNode,
189
+ styles['table-cell-text'],
190
+ { textAlign },
191
+ )}
159
192
  </View>
160
193
  )
161
194
  })