Skip to content

Commit 7bf9667

Browse files
author
Caedman Ziwen Lan
authored
Fix/fix icons crash error (#22)
* fix: update file * fix: update file
1 parent e46d858 commit 7bf9667

File tree

3 files changed

+270
-77
lines changed

3 files changed

+270
-77
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.2.1",
2+
"version": "1.2.2",
33
"description": "my apitable widget chart",
44
"engines": {
55
"node": ">=8.x"
@@ -36,10 +36,10 @@
3636
},
3737
"dependencies": {
3838
"@antv/g2plot": "^2.3.39",
39-
"@apitable/components": "latest",
39+
"@apitable/components": "^1.4.0",
4040
"@apitable/core": "latest",
41-
"@apitable/icons": "latest",
42-
"@apitable/widget-sdk": "^0.0.2",
41+
"@apitable/icons": "^1.4.0",
42+
"@apitable/widget-sdk": "^1.4.0",
4343
"@rjsf/core": "^2.4.0",
4444
"@types/react": "^16.9.43",
4545
"@types/react-dom": "^16.9.8",

src/custom_form_components/field_select.tsx

+2-59
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,11 @@
11
import { WidgetProps } from '@rjsf/core';
22
import { applyDefaultTheme, ITheme, DropdownSelect as Select, IOption, useTheme } from '@apitable/components';
3-
import { FieldType, Field, useFields, useField } from '@apitable/widget-sdk';
3+
import { Field, useFields, useField, FieldIconMap} from '@apitable/widget-sdk';
44
import React from 'react';
5-
import {
6-
ColumnAttachmentFilled,
7-
ColumnAutonumberFilled,
8-
AccountFilled,
9-
ColumnCheckboxFilled,
10-
ColumnLastmodifiedtimeFilled,
11-
ColumnTextFilled,
12-
ColumnCreatedbyFilled,
13-
ColumnCreatedtimeFilled,
14-
ColumnSingleFilled,
15-
ColumnCurrencyFilled,
16-
ColumnEmailFilled,
17-
ColumnFormulaFilled,
18-
ColumnPercentFilled,
19-
ColumnFigureFilled,
20-
ColumnMultipleFilled,
21-
ColumnCalendarFilled,
22-
ColumnUrlOutlined,
23-
ColumnLastmodifiedbyFilled,
24-
ColumnLongtextFilled,
25-
ColumnPhoneFilled,
26-
ColumnLookupFilled,
27-
ColumnRatingFilled,
28-
CascadeOutlined,
29-
OneWayLinkOutlined,
30-
TwoWayLinkOutlined
31-
} from '@apitable/icons';
325
import { SELECT_OPEN_SEARCH_COUNT } from '../const';
336
import styled from 'styled-components';
347
import { Strings, t } from '../i18n';
358

36-
const FieldIconMap = {
37-
// [FieldType.DeniedField]: LockFilled,
38-
[FieldType.Text]: ColumnLongtextFilled, // FIXME: There is a problem with the icon naming.
39-
[FieldType.Number]: ColumnFigureFilled, // FIXME: There is a problem with the icon naming.
40-
[FieldType.SingleSelect]: ColumnSingleFilled,
41-
[FieldType.MultiSelect]: ColumnMultipleFilled,
42-
[FieldType.DateTime]: ColumnCalendarFilled, // FIXME: There is a problem with the icon naming.
43-
[FieldType.Attachment]: ColumnAttachmentFilled,
44-
[FieldType.OneWayLink]: OneWayLinkOutlined,
45-
[FieldType.TwoWayLink]: TwoWayLinkOutlined,
46-
[FieldType.MagicLink]: TwoWayLinkOutlined, // ?
47-
[FieldType.URL]: ColumnUrlOutlined,
48-
[FieldType.Email]: ColumnEmailFilled,
49-
[FieldType.Phone]: ColumnPhoneFilled,
50-
[FieldType.Checkbox]: ColumnCheckboxFilled,
51-
[FieldType.Rating]: ColumnRatingFilled,
52-
[FieldType.Member]: AccountFilled,
53-
[FieldType.MagicLookUp]: ColumnLookupFilled,
54-
[FieldType.Formula]: ColumnFormulaFilled,
55-
[FieldType.Currency]: ColumnCurrencyFilled,
56-
[FieldType.Percent]: ColumnPercentFilled,
57-
[FieldType.SingleText]: ColumnTextFilled,
58-
[FieldType.AutoNumber]: ColumnAutonumberFilled,
59-
[FieldType.CreatedTime]: ColumnCreatedtimeFilled,
60-
[FieldType.LastModifiedTime]: ColumnLastmodifiedtimeFilled,
61-
[FieldType.CreatedBy]: ColumnCreatedbyFilled,
62-
[FieldType.LastModifiedBy]: ColumnLastmodifiedbyFilled,
63-
[FieldType.Cascader]: CascadeOutlined
64-
};
65-
669
const transformOptions = (enumOptions: { label: string, value: any }[], theme: ITheme, fields: Field[]) => {
6710
const fieldMap = new Map(fields.map(field => [field.id, field]));
6811
return enumOptions.map(option => {
@@ -74,7 +17,7 @@ const transformOptions = (enumOptions: { label: string, value: any }[], theme: I
7417
if (!field) {
7518
return res;
7619
}
77-
const FieldIcon = FieldIconMap[field.type];
20+
const FieldIcon = FieldIconMap[field.type] ?? '';
7821
return {
7922
...res,
8023
// disabled: field.type === FieldType.DeniedField,

0 commit comments

Comments
 (0)