Skip to content

Commit

Permalink
fix(range-selector): placeholder flush
Browse files Browse the repository at this point in the history
  • Loading branch information
Gggpound committed Jun 24, 2024
1 parent 2d5de98 commit cfa9c8d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,65 +91,65 @@ export const RuleEdit = (props: IRuleEditProps) => {
return defaultType;
}
switch (type) {
case CFRuleType.highlightCell:{
case CFRuleType.highlightCell: {
const subType = props.rule?.rule.subType;
switch (subType) {
case CFSubRuleType.number:
case CFSubRuleType.text:
case CFSubRuleType.duplicateValues:
case CFSubRuleType.uniqueValues:
case CFSubRuleType.timePeriod:{
case CFSubRuleType.timePeriod: {
return '1';
}
case CFSubRuleType.average:
case CFSubRuleType.rank:{
case CFSubRuleType.rank: {
return '2';
}
case CFSubRuleType.formula:{
case CFSubRuleType.formula: {
return '5';
}
}
break;
}
case CFRuleType.dataBar:{
case CFRuleType.dataBar: {
return '3';
}
case CFRuleType.colorScale:{
case CFRuleType.colorScale: {
return '4';
}
case CFRuleType.iconSet:{
case CFRuleType.iconSet: {
return '6';
}
}
return defaultType;
});
const result = useRef < Parameters<IStyleEditorProps['onChange']>>();
const result = useRef<Parameters<IStyleEditorProps['onChange']>>();
const interceptorManager = useMemo(() => {
const _interceptorManager = new InterceptorManager({ beforeSubmit, submit });
return _interceptorManager;
}, []);

const StyleEditor = useMemo(() => {
switch (ruleType) {
case '1':{
case '1': {
return HighlightCellStyleEditor;
}
case '2':{
case '2': {
return RankStyleEditor;
}
case '3':{
case '3': {
return DataBarStyleEditor;
}
case '4':{
case '4': {
return ColorScaleStyleEditor;
}
case '5':{
case '5': {
return FormulaStyleEditor;
}
case '6':{
case '6': {
return IconSet;
}
default :{
default: {
return HighlightCellStyleEditor;
}
}
Expand Down Expand Up @@ -224,7 +224,15 @@ export const RuleEdit = (props: IRuleEditProps) => {
<div className={styles.cfRuleStyleEditor}>
<div className={styleBase.title}>{localeService.t('sheet.cf.panel.range')}</div>
<div className={`${styleBase.mTBase}`}>
<RangeSelector placeholder={localeService.t('sheet.cf.form.rangeSelector')} width={'100%' as unknown as number} openForSheetSubUnitId={subUnitId} openForSheetUnitId={unitId} value={rangeString} id={createInternalEditorID(`${SHEET_CONDITIONAL_FORMATTING_PLUGIN}_rangeSelector`)} onChange={onRangeSelectorChange} />
<RangeSelector
placeholder={localeService.t('sheet.cf.form.rangeSelector')}
width={'100%' as unknown as number}
openForSheetSubUnitId={subUnitId}
openForSheetUnitId={unitId}
value={rangeString}
id={createInternalEditorID(`${SHEET_CONDITIONAL_FORMATTING_PLUGIN}_rangeSelector`)}
onChange={onRangeSelectorChange}
/>
</div>
<div className={styleBase.title}>{localeService.t('sheet.cf.panel.styleType')}</div>
<div className={styleBase.mTBase}>
Expand Down
7 changes: 5 additions & 2 deletions packages/ui/src/components/editor/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC

onValid,

placeholder = '',

isValueValid = true,
} = props;

const editorService = useDependency(IEditorService);

const localeService = useDependency(LocaleService);

const [placeholder, placeholderSet] = useState('');

const [validationContent, setValidationContent] = useState<string>('');

const [validationVisible, setValidationVisible] = useState(isValueValid);
Expand Down Expand Up @@ -171,6 +171,9 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onC
},
editor);

editorService.setValueNoRefresh(props.value || '', id);
placeholderSet(props.placeholder || '');

const activeChange = debounce((state: boolean) => {
setActive(state);
onActive && onActive(state);
Expand Down

0 comments on commit cfa9c8d

Please sign in to comment.