tachybase_todo/packages/plugins/excel-formula-field/src/client/index.tsx
chenos 883f1e6fd1
fix: eslint (#1759)
* fix: eslint

* fix: eslint --fix

* fix: changelog
2023-04-25 13:12:14 +08:00

35 lines
1.1 KiB
TypeScript

import { CollectionManagerContext, registerField, SchemaComponentOptions } from '@nocobase/client';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { excelFormula } from './excel-formula';
import { ExcelFormula } from './ExcelFormula';
registerField(excelFormula.group, 'excelFormula', excelFormula);
export default React.memo((props) => {
const ctx = useContext(CollectionManagerContext);
const { t } = useTranslation();
return (
<SchemaComponentOptions
scope={{
excelExpressionDescription: (
<div>
{t('Syntax see', { ns: 'math-formula-field' })}{' '}
<a target={'_blank'} href={'https://formulajs.info/functions/'} rel="noreferrer">
formula.js
</a>
</div>
),
}}
components={{
ExcelFormula,
}}
>
<CollectionManagerContext.Provider value={{ ...ctx, interfaces: { ...ctx.interfaces, excelFormula } }}>
{props.children}
</CollectionManagerContext.Provider>
</SchemaComponentOptions>
);
});