@hzab/list-render 1.9.2-beta6 → 1.9.3-beta

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # @hzab/list-render@1.9.4
2
+
3
+ feat: 增加主题色配置
4
+
1
5
  # @hzab/list-render@1.9.3
2
6
 
3
7
  feat: 列表请求取消上一次列表请求,解决数据返回先后顺序导致展示异常问题
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/list-render",
3
- "version": "1.9.2-beta6",
3
+ "version": "1.9.3-beta",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -24,6 +24,7 @@
24
24
  "@hzab/form-render": "^1.1.5",
25
25
  "@hzab/schema-descriptions": "^1.0.0",
26
26
  "@hzab/webpack-config": "^0.7.2",
27
+ "@hzab/theme-tools": "^0.0.2",
27
28
  "@types/react": "^17.0.62",
28
29
  "@types/react-dom": "^17.0.20",
29
30
  "antd": "^4.24.12",
@@ -159,7 +159,7 @@ export function FormModal(props, parentRef) {
159
159
  const CModal = modalMode === "drawer" ? Drawer : Modal;
160
160
  const _modalProps = {
161
161
  className: "form-modal",
162
- wrapClassName: "form-modal",
162
+ wrapClassName: `form-modal ${props.schemaScope.className}`,
163
163
  title: title,
164
164
  visible: open,
165
165
  open: open,
@@ -182,6 +182,7 @@ export function FormModal(props, parentRef) {
182
182
  <FormRender
183
183
  {...props.formProps}
184
184
  ref={formRef}
185
+ customTheme={props.customTheme}
185
186
  schema={props.schema}
186
187
  schemaScope={{
187
188
  scenario: scenarioRef.current,
@@ -0,0 +1,308 @@
1
+ @primaryColor: var(--list-render-primary-color); // 主题色
2
+ @textColor: var(--list-render-color); // 字体颜色
3
+ @bgColor: var(--list-render-bg-color); // 背景颜色
4
+ @tableBgColor: var(--list-render-table-bg-color); // 表格背景颜色
5
+ @tableColor: var(--list-render-table-color); // 表格内字体颜色
6
+ @talbeBorderColor: var(--list-render-table-border-color); // 表格边框颜色
7
+ @tableWrapperBorderColor: var(--list-render-table-wrapper-border-color); // 表格表头下边框颜色
8
+ @tableCellHoverBgColor: var(--list-render-table-cell-hover-bg-color); // 表格单元格滑过背景颜色
9
+ @tableCellHoverColor: var(--list-render-table-cell-hover-color); // 表格单元格滑过字体颜色
10
+ @paginationBgColor: var(--list-render-pagination-bg-color); // 分页背景颜色
11
+ @paginationColor: var(--list-render-pagination-color); // 分页字体颜色
12
+ @paginationItemBgColor: var(--list-render-pagination-item-bg-color); // 页码单项背景颜色
13
+ @paginationItemBorderColor: var(--list-render-pagination-item-border-color); // 页面单项边框颜色
14
+ @paginationItemColor: var(--list-render-pagination-item-color); // 页码单项字体颜色
15
+ @paginationOptionActiveBgColor: var(--list-render-pagination-option-active-bg-color); // 页码选中项&滑过项背景颜色
16
+ @btnOkColor: var(--list-render-btn-ok-color); // 确认按钮字体颜色
17
+ @btnOkBgColor: var(--list-render-btn-ok-bg-color); // 确认按钮背景颜色
18
+ @btnOkBorderColor: var(--list-render-btn-ok-border-color); // 确认按钮边框颜色
19
+ @btnOkBgHoverColor: var(--list-render-btn-ok-bg-hover-color); // 确认按钮滑过字体颜色
20
+ @btnDefaultColor: var(--list-render-btn-default-color); // 默认按钮字体颜色
21
+ @btnDefaultBgColor: var(--list-render-btn-default-bg-color); // 默认按钮背景颜色
22
+ @btnDefaultBorderColor: var(--list-render-btn-default-border-color); // 默认按钮边框颜色
23
+ @btnDefaultBgHoverColor: var(--list-render-btn-default-bg-hover-color); // 默认按钮滑过背景颜色
24
+ @inputColor: var(--list-render-input-color); // 输入框字体颜色
25
+ @formLabelColor: var(--list-render-form-label-color); // 表单项label字体颜色
26
+ @formReqiredColor: var(--list-render-form-required-color); // 表单项必填字体颜色
27
+ @inputHoverColor: var(--list-render-input-hover-color); // 输入框滑过字体颜色
28
+ @inputBgColor: var(--list-render-input-bg-color); // 输入框背景颜色
29
+ @inputBorderColor: var(--list-render-input-border-color); // 输入框边框颜色
30
+ @inputBorderHoverColor: var(--list-render-input-border-hover-color); // 输入框滑过边框颜色
31
+ @selectColor: var(--list-render-select-color); // 选择器字体颜色
32
+ @selectHoverColor: var(--list-render-select-hover-color); // 选择器滑过字体颜色
33
+ @selectBgColor: var(--list-render-select-bg-color); // 选择器背景颜色
34
+ @selectBgHoverColor: var(--list-render-select-bg-hover-color); // 选择器滑过背景颜色
35
+ @selectBorderColor: var(--list-render-select-border-color); // 选择器边框颜色
36
+ @iconColor: var(--list-render-icon-color); // icon图标颜色
37
+ @iconHoverColor: var(--list-render-icon-hover-color); // icon图标滑过颜色
38
+ @iconBgColor: var(--list-render-icon-bg-color); // icon背景颜色
39
+ @iconBgHoverColor: var(--list-render-icon-bg-hover-color); // icon滑过背景颜色
40
+
41
+ .mixinColor() {
42
+ .ant-table-cell button.ant-table-row-expand-icon {
43
+ color: @iconColor;
44
+ background-color: @iconBgColor;
45
+
46
+ &:hover {
47
+ color: @iconHoverColor;
48
+ background-color: @iconBgHoverColor;
49
+ }
50
+ }
51
+
52
+ .ant-btn.ant-btn-primary {
53
+ color: @btnOkColor;
54
+ background-color: @btnOkBgColor;
55
+ border-color: @btnOkBorderColor;
56
+
57
+ &:hover,
58
+ &:focus {
59
+ border-color: @primaryColor;
60
+ background-color: @btnOkBgHoverColor;
61
+ }
62
+ }
63
+
64
+ .ant-btn.ant-btn-default {
65
+ color: @btnDefaultColor;
66
+ background-color: @btnDefaultBgColor;
67
+ border-color: @btnDefaultBorderColor;
68
+
69
+ &:hover,
70
+ &:focus {
71
+ color: @primaryColor;
72
+ border-color: @primaryColor;
73
+ background-color: @btnDefaultBgHoverColor;
74
+ }
75
+ }
76
+
77
+ .ant-btn.ant-btn-dashed {
78
+ color: @btnDefaultColor;
79
+ background-color: @btnDefaultBgColor;
80
+ border-color: @btnDefaultBorderColor;
81
+
82
+ &:hover,
83
+ &:focus {
84
+ color: @primaryColor;
85
+ border-color: @primaryColor;
86
+ }
87
+ }
88
+
89
+ .ant-btn {
90
+ color: @textColor;
91
+
92
+ &.ant-btn-link {
93
+ color: @primaryColor;
94
+ }
95
+
96
+ &.ant-btn-dangerous {
97
+ color: var(--ant-error-color);
98
+ }
99
+ }
100
+ }
101
+
102
+
103
+ .table() {
104
+ .table-render {
105
+ border-top-color: @tableWrapperBorderColor;
106
+
107
+ .ant-table {
108
+ background-color: @tableBgColor;
109
+ color: @tableColor;
110
+
111
+ .ant-table-tbody {
112
+ background-color: @bgColor;
113
+ }
114
+
115
+ .ant-table-thead>tr>th {
116
+ background-color: @tableBgColor;
117
+ color: @tableColor;
118
+ }
119
+
120
+ .ant-table-row {
121
+
122
+ // 此处原因:会出现弹窗关闭后,鼠标刚好停留在外表格的某一行,导致ant-table-cell-row-hover类名未正常出现,渲染颜色错误
123
+ &:hover {
124
+ td {
125
+ background-color: @tableCellHoverBgColor;
126
+ color: @tableCellHoverColor;
127
+ }
128
+ }
129
+ }
130
+
131
+ .ant-table-cell {
132
+ border-color: @talbeBorderColor;
133
+ }
134
+
135
+ .ant-table-cell-row-hover {
136
+ background-color: @tableCellHoverBgColor;
137
+ color: @tableCellHoverColor;
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ .list-render-custom-theme {
144
+ background-color: @bgColor;
145
+ color: @textColor;
146
+
147
+ .mixinColor();
148
+
149
+ .table();
150
+
151
+ .ant-pagination {
152
+ background-color: @paginationBgColor;
153
+ color: @paginationColor;
154
+
155
+ .ant-pagination-item,
156
+ .ant-pagination-prev .ant-pagination-item-link,
157
+ .ant-pagination-next .ant-pagination-item-link,
158
+ .ant-pagination-jump-next .ant-pagination-item-link {
159
+ border-color: @paginationItemBorderColor;
160
+ background-color: @paginationItemBgColor;
161
+ color: @paginationItemColor;
162
+
163
+ a,
164
+ .ant-pagination-item-ellipsis {
165
+ color: @paginationItemColor;
166
+ }
167
+
168
+ &:hover {
169
+ border-color: @primaryColor;
170
+ color: @primaryColor;
171
+
172
+ a {
173
+ color: @primaryColor;
174
+ }
175
+ }
176
+
177
+ &:disabled {
178
+ border-color: #d9d9d9;
179
+ color: #d9d9d9;
180
+ }
181
+ }
182
+
183
+ .ant-pagination-item-active {
184
+ border-color: @primaryColor;
185
+
186
+ a {
187
+ color: @primaryColor;
188
+ }
189
+ }
190
+
191
+ .ant-pagination-options {
192
+ .mixinColor();
193
+
194
+ .ant-select:not(.ant-select-disabled) {
195
+ color: @selectColor;
196
+
197
+ &:hover {
198
+ color: @inputHoverColor;
199
+
200
+ .ant-select-selector {
201
+ border-color: @inputBorderHoverColor;
202
+ }
203
+ }
204
+
205
+ .ant-select-selector {
206
+ background-color: @selectBgColor;
207
+
208
+ .ant-btn-icon-only {
209
+ color: @iconColor;
210
+ background-color: @selectBgColor;
211
+
212
+ &:hover {
213
+ color: @iconHoverColor;
214
+ background-color: @inputBgColor;
215
+ border-color: @inputBorderHoverColor;
216
+ }
217
+ }
218
+ }
219
+ }
220
+
221
+ .ant-select-dropdown[class^="ant-select-dropdown-placement-"],
222
+ .ant-select-dropdown[class*=" ant-select-dropdown-placement-"],
223
+ .ant-tree-select-dropdown {
224
+ background-color: @selectBgColor;
225
+
226
+ .ant-select-tree {
227
+ color: @selectColor;
228
+ background-color: @selectBgColor;
229
+
230
+ .ant-select-tree-node-content-wrapper:hover,
231
+ .ant-select-tree-node-content-wrapper.ant-select-tree-node-selected {
232
+ color: @selectHoverColor;
233
+ background-color: @selectBgHoverColor;
234
+ }
235
+ }
236
+
237
+ .ant-select-item {
238
+ color: @selectColor;
239
+ }
240
+
241
+ .ant-select-item.ant-select-item-option-selected,
242
+ .ant-select-item.ant-select-item-option-active {
243
+ color: @selectHoverColor;
244
+ background-color: @selectBgHoverColor;
245
+ }
246
+ }
247
+ }
248
+ }
249
+ }
250
+
251
+ .ant-modal-color() {
252
+ .ant-modal-content {
253
+ background-color: @bgColor;
254
+ color: @textColor;
255
+
256
+ .ant-modal-close {
257
+ color: @textColor;
258
+ }
259
+
260
+ .table();
261
+
262
+ .ant-modal-header,
263
+ .ant-modal-footer {
264
+ background-color: @bgColor;
265
+ border-color: @tableWrapperBorderColor;
266
+
267
+ .ant-modal-title {
268
+ color: @textColor;
269
+ }
270
+ }
271
+ }
272
+ }
273
+
274
+ .list-dialog-custom-theme {
275
+ .mixinColor();
276
+ .table();
277
+ .ant-modal-color();
278
+ }
279
+
280
+ .list-dialog-custom-theme.ant-tree-select-dropdown {
281
+ background-color: @selectBgColor;
282
+
283
+ .ant-select-tree {
284
+ color: @selectColor;
285
+ background-color: @selectBgColor;
286
+
287
+ .ant-select-tree-node-content-wrapper:hover,
288
+ .ant-select-tree-node-content-wrapper.ant-select-tree-node-selected {
289
+ color: @selectHoverColor;
290
+ background-color: @selectBgHoverColor;
291
+ }
292
+ }
293
+
294
+ .ant-select-item {
295
+ color: @selectColor;
296
+ }
297
+
298
+ .ant-select-item.ant-select-item-option-selected,
299
+ .ant-select-item.ant-select-item-option-active {
300
+ color: @selectHoverColor;
301
+ background-color: @selectBgHoverColor;
302
+ }
303
+ }
304
+
305
+ .form-modal.list-dialog-custom-theme,
306
+ .detail-modal.list-dialog-custom-theme {
307
+ .ant-modal-color();
308
+ }
package/src/index.less CHANGED
@@ -3,15 +3,19 @@
3
3
  display: flex;
4
4
  justify-content: space-between;
5
5
  align-items: flex-end;
6
+
6
7
  .header-actions-render {
7
8
  text-align: right;
9
+
8
10
  .ant-btn {
9
11
  margin-bottom: 12px;
10
12
  }
11
- .ant-btn + .ant-btn {
13
+
14
+ .ant-btn+.ant-btn {
12
15
  margin-left: 12px;
13
16
  }
14
17
  }
18
+
15
19
  &.vertical-header {
16
20
  display: block;
17
21
  }
@@ -30,4 +34,4 @@
30
34
  }
31
35
  }
32
36
  }
33
- }
37
+ }
@@ -16,6 +16,7 @@ import DetailModal from "./DetailModal";
16
16
  import { objToFormData } from "./common/utils";
17
17
 
18
18
  import "./index.less";
19
+ import "./custom-theme.less"
19
20
 
20
21
  const ListRender = forwardRef(function (props, parentRef) {
21
22
  const {
@@ -323,9 +324,9 @@ const ListRender = forwardRef(function (props, parentRef) {
323
324
  const onFormModalClose = props.onFormDialogClose ?? props.onFormModalClose;
324
325
  const modalProps = { ...props.dialogProps, ...props.modalProps };
325
326
  const modalFormMount = props.dialogFormMount ?? props.modalFormMount;
326
-
327
+ const className = typeof props.customTheme === 'string' ? `list-render-${props.customTheme}` : props.customTheme === true ? 'list-render-custom-theme' : ''
327
328
  return (
328
- <div className={`list-render ${props.className}`}>
329
+ <div className={`list-render ${props.className} ${className}`}>
329
330
  <div className={`list-header ${props.verticalHeader ? "vertical-header" : ""}`}>
330
331
  {props.hasQuery !== false ? (
331
332
  <QueryRender
@@ -343,6 +344,7 @@ const ListRender = forwardRef(function (props, parentRef) {
343
344
  : queryFormInitialValues
344
345
  }
345
346
  onSearch={onSearch}
347
+ customTheme={props.customTheme}
346
348
  schemaScope={props.schemaScope}
347
349
  components={props.components}
348
350
  i18n={i18n}
@@ -382,7 +384,7 @@ const ListRender = forwardRef(function (props, parentRef) {
382
384
  tableProps={props.tableProps}
383
385
  getFieldListOpt={props.getFieldListOpt}
384
386
  components={props.components}
385
- schemaScope={props.schemaScope}
387
+ schemaScope={{...props.schemaScope, className: props.customTheme === true ? 'list-dialog-custom-theme': typeof props.customTheme === 'string' ? `list-dialog-custom-theme-${props.customTheme}` : ''}}
386
388
  i18n={i18n}
387
389
  />
388
390
  {props.hasPagination !== false ? (
@@ -400,9 +402,10 @@ const ListRender = forwardRef(function (props, parentRef) {
400
402
  schema={schema}
401
403
  formInitialValues={props.formInitialValues}
402
404
  components={props.components}
403
- schemaScope={props.schemaScope}
405
+ schemaScope={{...props.schemaScope, className: props.customTheme === true ? 'list-dialog-custom-theme': typeof props.customTheme === 'string' ? `list-dialog-custom-theme-${props.customTheme}` : ''}}
404
406
  formProps={formProps}
405
407
  modalMode={modalMode}
408
+ customTheme={props.customTheme}
406
409
  modalConf={_modalConf}
407
410
  onClose={onFormModalClose}
408
411
  onSubmit={formState === "edit" ? onEditSubmit : onCreateSubmit}
@@ -417,7 +420,7 @@ const ListRender = forwardRef(function (props, parentRef) {
417
420
  schema={schema}
418
421
  formInitialValues={props.formInitialValues}
419
422
  components={props.detailComponents}
420
- schemaScope={props.schemaScope}
423
+ schemaScope={{...props.schemaScope, className: props.customTheme === true ? 'list-dialog-custom-theme': typeof props.customTheme === 'string' ? `list-dialog-custom-theme-${props.customTheme}` : ''}}
421
424
  detailProps={props.dialogDetailProps || props.modalDetailProps}
422
425
  modalMode={modalMode}
423
426
  modalConf={_modalConf}
@@ -56,15 +56,16 @@ function QueryRender(props, parentRef) {
56
56
  formRef.current?.formRender?.reset();
57
57
  props.onSearch && props.onSearch(_.cloneDeep(formRef?.current?.formRender?.values), "queryRender");
58
58
  }
59
-
59
+ const className = typeof props.customTheme === 'string' ? `list-render-${props.customTheme}` : props.customTheme === true ? 'list-render-custom-theme' : ''
60
60
  return (
61
- <div className="query-render">
61
+ <div className={`query-render ${className}`}>
62
62
  {Object.keys(schema?.schema?.properties || {}).length > 0 ? (
63
63
  <>
64
64
  <FormRender
65
65
  ref={formRef}
66
66
  layout="inline"
67
67
  schema={schema}
68
+ customTheme={props.customTheme}
68
69
  schemaScope={{ scenario: "query", ...(props.schemaScope || {}) }}
69
70
  initialValues={props.queryFormInitialValues}
70
71
  Slots={() => {