Skip to content

Commit

Permalink
Fix/fix icons crash error (#22)
Browse files Browse the repository at this point in the history
* fix: update file

* fix: update file
  • Loading branch information
ranglang committed Nov 10, 2023
1 parent e46d858 commit 7bf9667
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 77 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.2.1",
"version": "1.2.2",
"description": "my apitable widget chart",
"engines": {
"node": ">=8.x"
Expand Down Expand Up @@ -36,10 +36,10 @@
},
"dependencies": {
"@antv/g2plot": "^2.3.39",
"@apitable/components": "latest",
"@apitable/components": "^1.4.0",
"@apitable/core": "latest",
"@apitable/icons": "latest",
"@apitable/widget-sdk": "^0.0.2",
"@apitable/icons": "^1.4.0",
"@apitable/widget-sdk": "^1.4.0",
"@rjsf/core": "^2.4.0",
"@types/react": "^16.9.43",
"@types/react-dom": "^16.9.8",
Expand Down
61 changes: 2 additions & 59 deletions src/custom_form_components/field_select.tsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,11 @@
import { WidgetProps } from '@rjsf/core';
import { applyDefaultTheme, ITheme, DropdownSelect as Select, IOption, useTheme } from '@apitable/components';
import { FieldType, Field, useFields, useField } from '@apitable/widget-sdk';
import { Field, useFields, useField, FieldIconMap} from '@apitable/widget-sdk';
import React from 'react';
import {
ColumnAttachmentFilled,
ColumnAutonumberFilled,
AccountFilled,
ColumnCheckboxFilled,
ColumnLastmodifiedtimeFilled,
ColumnTextFilled,
ColumnCreatedbyFilled,
ColumnCreatedtimeFilled,
ColumnSingleFilled,
ColumnCurrencyFilled,
ColumnEmailFilled,
ColumnFormulaFilled,
ColumnPercentFilled,
ColumnFigureFilled,
ColumnMultipleFilled,
ColumnCalendarFilled,
ColumnUrlOutlined,
ColumnLastmodifiedbyFilled,
ColumnLongtextFilled,
ColumnPhoneFilled,
ColumnLookupFilled,
ColumnRatingFilled,
CascadeOutlined,
OneWayLinkOutlined,
TwoWayLinkOutlined
} from '@apitable/icons';
import { SELECT_OPEN_SEARCH_COUNT } from '../const';
import styled from 'styled-components';
import { Strings, t } from '../i18n';

const FieldIconMap = {
// [FieldType.DeniedField]: LockFilled,
[FieldType.Text]: ColumnLongtextFilled, // FIXME: There is a problem with the icon naming.
[FieldType.Number]: ColumnFigureFilled, // FIXME: There is a problem with the icon naming.
[FieldType.SingleSelect]: ColumnSingleFilled,
[FieldType.MultiSelect]: ColumnMultipleFilled,
[FieldType.DateTime]: ColumnCalendarFilled, // FIXME: There is a problem with the icon naming.
[FieldType.Attachment]: ColumnAttachmentFilled,
[FieldType.OneWayLink]: OneWayLinkOutlined,
[FieldType.TwoWayLink]: TwoWayLinkOutlined,
[FieldType.MagicLink]: TwoWayLinkOutlined, // ?
[FieldType.URL]: ColumnUrlOutlined,
[FieldType.Email]: ColumnEmailFilled,
[FieldType.Phone]: ColumnPhoneFilled,
[FieldType.Checkbox]: ColumnCheckboxFilled,
[FieldType.Rating]: ColumnRatingFilled,
[FieldType.Member]: AccountFilled,
[FieldType.MagicLookUp]: ColumnLookupFilled,
[FieldType.Formula]: ColumnFormulaFilled,
[FieldType.Currency]: ColumnCurrencyFilled,
[FieldType.Percent]: ColumnPercentFilled,
[FieldType.SingleText]: ColumnTextFilled,
[FieldType.AutoNumber]: ColumnAutonumberFilled,
[FieldType.CreatedTime]: ColumnCreatedtimeFilled,
[FieldType.LastModifiedTime]: ColumnLastmodifiedtimeFilled,
[FieldType.CreatedBy]: ColumnCreatedbyFilled,
[FieldType.LastModifiedBy]: ColumnLastmodifiedbyFilled,
[FieldType.Cascader]: CascadeOutlined
};

const transformOptions = (enumOptions: { label: string, value: any }[], theme: ITheme, fields: Field[]) => {
const fieldMap = new Map(fields.map(field => [field.id, field]));
return enumOptions.map(option => {
Expand All @@ -74,7 +17,7 @@ const transformOptions = (enumOptions: { label: string, value: any }[], theme: I
if (!field) {
return res;
}
const FieldIcon = FieldIconMap[field.type];
const FieldIcon = FieldIconMap[field.type] ?? '';
return {
...res,
// disabled: field.type === FieldType.DeniedField,
Expand Down
Loading

0 comments on commit 7bf9667

Please sign in to comment.