Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix/fix icons crash error" #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2",
"version": "1.2.1",
"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": "^1.4.0",
"@apitable/components": "latest",
"@apitable/core": "latest",
"@apitable/icons": "^1.4.0",
"@apitable/widget-sdk": "^1.4.0",
"@apitable/icons": "latest",
"@apitable/widget-sdk": "^0.0.2",
"@rjsf/core": "^2.4.0",
"@types/react": "^16.9.43",
"@types/react-dom": "^16.9.8",
Expand Down
61 changes: 59 additions & 2 deletions src/custom_form_components/field_select.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,68 @@
import { WidgetProps } from '@rjsf/core';
import { applyDefaultTheme, ITheme, DropdownSelect as Select, IOption, useTheme } from '@apitable/components';
import { Field, useFields, useField, FieldIconMap} from '@apitable/widget-sdk';
import { FieldType, Field, useFields, useField } 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 @@ -17,7 +74,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