-
-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(formula): select function, range selector
- Loading branch information
Showing
26 changed files
with
346 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './custom-label'; | ||
export * from './menu'; | ||
export * from './range-selector/RangeSelector'; |
11 changes: 0 additions & 11 deletions
11
packages/base-ui/src/components/range-selector/RangeSelector.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
packages/base-ui/src/components/range-selector/index.module.less
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ages/sheets-plugin-formula-ui/src/views/more-functions/function-params/FunctionParams.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import styles from './index.module.less'; | ||
|
||
interface IParamsProps { | ||
className?: string; | ||
title?: string; | ||
value?: string | React.ReactElement; | ||
} | ||
|
||
export function FunctionParams(props: IParamsProps) { | ||
return ( | ||
<div className={styles.formulaFunctionParams}> | ||
<div className={`${styles.formulaFunctionParamsTitle} ${props.className}`}>{props.title}</div> | ||
<div className={styles.formulaFunctionParamsDetail}>{props.value}</div> | ||
</div> | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/sheets-plugin-formula-ui/src/views/more-functions/function-params/index.module.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.formula-function-params { | ||
margin: var(--margin-xs) 0; | ||
font-size: var(--font-size-xxs); | ||
|
||
&-title { | ||
font-weight: 500; | ||
color: rgb(var(--text-color-secondary)); | ||
} | ||
|
||
&-detail { | ||
font-weight: 400; | ||
color: rgb(var(--text-color)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 38 additions & 10 deletions
48
packages/sheets-plugin-formula-ui/src/views/more-functions/input-params/InputParams.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,52 @@ | ||
import { IFunctionInfo, IFunctionParam } from '@univerjs/base-formula-engine'; | ||
import { RangeSelector } from '@univerjs/base-ui'; | ||
import { RangeSelector } from '@univerjs/ui-plugin-sheets'; | ||
import { useState } from 'react'; | ||
|
||
import { FunctionParams } from '../function-params/FunctionParams'; | ||
import styles from './index.module.less'; | ||
|
||
export interface IInputParamsProps { | ||
functionInfo: IFunctionInfo | null; | ||
onChange: (params: string[]) => void; | ||
} | ||
|
||
export function InputParams(props: IInputParamsProps) { | ||
const { functionInfo } = props; | ||
const { functionInfo, onChange } = props; | ||
const [params, setParams] = useState<string[]>([]); | ||
const [activeIndex, setActiveIndex] = useState(0); | ||
|
||
function handleRangeChange(range: string, paramIndex: number) { | ||
const newParams = [...params]; | ||
newParams[paramIndex] = range; | ||
setParams(newParams); | ||
onChange(newParams); | ||
} | ||
|
||
return ( | ||
<div className={styles.formulaInputParams}> | ||
{functionInfo && | ||
functionInfo.functionParameter && | ||
functionInfo.functionParameter.map((item: IFunctionParam, i: number) => ( | ||
<div key={i}> | ||
{item.name} | ||
<RangeSelector /> | ||
</div> | ||
))} | ||
<div className={styles.formulaInputParamsList}> | ||
{functionInfo && | ||
functionInfo.functionParameter && | ||
functionInfo.functionParameter.map((item: IFunctionParam, i: number) => ( | ||
<div key={i}> | ||
<div className={styles.formulaInputParamsListItemName}>{item.name}</div> | ||
|
||
<div className={styles.formulaInputParamsListItemSelector}> | ||
<RangeSelector | ||
onChange={(range: string) => handleRangeChange(range, i)} | ||
onActive={() => setActiveIndex(i)} | ||
/> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
|
||
<div className={styles.formulaInputParamsInfo}> | ||
<FunctionParams | ||
title={functionInfo?.functionParameter[activeIndex].name} | ||
value={functionInfo?.functionParameter[activeIndex].detail} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
10 changes: 9 additions & 1 deletion
10
packages/sheets-plugin-formula-ui/src/views/more-functions/input-params/index.module.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
.formula-input-params { | ||
padding: var(--padding-xs); | ||
&-list-item{ | ||
&-name{ | ||
font-size: var(--font-size-sm); | ||
} | ||
|
||
&-selector{ | ||
margin: var(--margin-xxs) 0 var(--margin-xs) 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.