Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weishaodaren/polaris-react-formula
极星公式库 ✨
https://github.com/weishaodaren/polaris-react-formula
antd codemirror formula pnpm react typescript vite
Last synced: 1 day ago
JSON representation
极星公式库 ✨
- Host: GitHub
- URL: https://github.com/weishaodaren/polaris-react-formula
- Owner: weishaodaren
- License: mit
- Created: 2022-11-02T02:39:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-19T05:13:30.000Z (over 1 year ago)
- Last Synced: 2025-01-31T08:08:39.454Z (6 days ago)
- Topics: antd, codemirror, formula, pnpm, react, typescript, vite
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/polaris-react-formula
- Size: 454 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 极星公式库 polaris-react-formula
> Formula compiler core.
See our website https://app.startable.cn/
### 📕 Install
Using npm:
```js
npm install --save polaris-react-formula
```or using yarn:
```js
yarn add polaris-react-formula
```or useing pnpm:
```js
pnpm install polaris-react-formula
```### 📘 Type
|Property|Type|Description|Default Value|
|----|----|---|----|
|visible|`boolean`|控制Modal显示隐藏|`false`|
|value|`string`|公式值|`''`|
|className|`string`|类名|`''`|
|style|`React.CSSProperties`|类名|`''`|
|field|`IColumn`|字段 列||
|onClose|`(() => void)`|关闭Modal||
|onChange|`(formula: string, formulaField: string ) => void)`|获取计算值 回调|`undefined`|
|onLink|`(() => void)`|跳转外链|`undefined`|### 📖 Usage
```js
import React, { useCallback, useState } from 'react';
import FormulaEditor, { useFormula } from 'polaris-react-formula';function App() {
const [visible, setVisible] = useState(true);
const [value, setValue] = useState('IF({title} = "刘123建", {title}, {ownerId})');const onCalc = useCallback((formula: string, formulaField: string) => {
setValue(formulaField);
console.log('%c Formula:', 'color: pink', formula);
console.log('%c Field:', 'color: orange', formulaField);const res = useFormula(formula, dataSource[0]);
console.log('%c Result:', 'color: yellow', res);
}, []);const onClose = useCallback(() => {
setVisible(false);
}, []);return (
<>
setVisible(true)}>Click Me
>
);
}```