Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitde4bbee

Browse files
committed
remove unnecessary code
1 parenta4af806 commitde4bbee

File tree

1 file changed

+7
-82
lines changed

1 file changed

+7
-82
lines changed

‎client/packages/lowcoder/src/comps/comps/tagsComp/tagsCompView.tsx‎

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -137,42 +137,15 @@ const multiTags = (function () {
137137
color: inherit;
138138
`;
139139

140-
constTagIcon=styled.span`
141-
display: inline-flex;
142-
align-items: center;
143-
margin-right: 4px;
144-
145-
&.icon-right {
146-
margin-right: 0;
147-
margin-left: 4px;
148-
}
149-
`;
150-
151-
constTagContent=styled.span`
152-
display: inline-flex;
153-
align-items: center;
154-
`;
155-
156-
157-
158140
constchildrenMap={
159-
options:TagsCompOptionsControl,// initial tags (PropertyView)
141+
options:TagsCompOptionsControl,
160142
style:styleControl(InputLikeStyle,"style"),
161143
onEvent:ButtonEventHandlerControl,
162-
editable:BoolControl,// editable switch field
163-
preventDuplicates:BoolCodeControl,// runtime de-dupe
164-
allowEmptyEdits:BoolCodeControl,// allow blank labels on edit
165-
maxTags:BoolCodeControl,// truthy => 50 (or provide number if your control supports)
166-
selectedTagIndex:stateComp<number>(-1),// tracks which tag was clicked (-1 = none)
167-
runtimeOptions:stateComp<JSONValue>([]),// runtime tags array for CRUD and saving
144+
editable:BoolControl,
145+
selectedTagIndex:stateComp<number>(-1),
146+
runtimeOptions:stateComp<JSONValue>([]),
168147
};
169148

170-
consttoMax=(val:any):number|undefined=>{
171-
if(val===false||val===undefined||val===null)returnundefined;
172-
if(typeofval==="number"&&!Number.isNaN(val)&&val>0)returnval;
173-
if(val===true)return50;
174-
returnundefined;
175-
};
176149

177150
returnnewUICompBuilder(childrenMap,(props,dispatch)=>{
178151
const{ message}=App.useApp?.()||{message:{warning:()=>{}}asany};
@@ -183,10 +156,7 @@ const multiTags = (function () {
183156
const[editValue,setEditValue]=useState<string>("");
184157
const[draft,setDraft]=useState<string>("");// typing buffer for creating a new tag
185158
constcontainerRef=useRef<HTMLDivElement>(null);
186-
187-
constpreventDuplicates=!!props.preventDuplicates;
188-
constallowEmptyEdits=!!props.allowEmptyEdits;
189-
constmaxTags=toMax(props.maxTags);
159+
190160

191161

192162
constdisplayOptions=(propsasany).runtimeOptions?.length&&props.editable
@@ -215,14 +185,6 @@ const multiTags = (function () {
215185
constaddTag=(raw:string)=>{
216186
constlabel=normalize(raw);
217187
if(!label)return;
218-
if(maxTags&&displayOptions.length>=maxTags){
219-
message?.warning?.(`Maximum${maxTags} tags allowed.`);
220-
return;
221-
}
222-
if(preventDuplicates&&exists(label)){
223-
message?.warning?.("Duplicate tag.");
224-
return;
225-
}
226188
constnewTag:TagOption={
227189
label,
228190
colorType:"default",
@@ -250,14 +212,6 @@ const multiTags = (function () {
250212

251213
constconfirmEdit=(index:number)=>{
252214
constval=normalize(editValue);
253-
if(!val&&!allowEmptyEdits){
254-
cancelEdit();
255-
return;
256-
}
257-
if(preventDuplicates&&exists(val,index)){
258-
message?.warning?.("Duplicate tag.");
259-
return;
260-
}
261215
constprev=displayOptions[index]?.label??"";
262216
constnext=displayOptions.map((t,i)=>(i===index ?{ ...t,label:val} :t));
263217
dispatch(changeChildAction("runtimeOptions",next,false));
@@ -386,22 +340,12 @@ const multiTags = (function () {
386340
<>
387341
<Sectionname={sectionNames.basic}>
388342
{children.options.propertyView({label:"Initial Tags (PropertyView)"})}
389-
{children.editable.propertyView({label:"Editable"})}
390-
{children.preventDuplicates.propertyView({label:"Prevent Duplicates (Runtime)"})}
391-
{children.allowEmptyEdits.propertyView({label:"Allow Empty Edit (Runtime)"})}
392-
{children.maxTags.propertyView({label:"Set Max Tags (Runtime) — true=50"})}
343+
{children.editable.propertyView({label:"Editable"})}
393344
</Section>
394345

395346
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(
396347
<Sectionname={sectionNames.interaction}>
397-
{children.onEvent.getPropertyView({
398-
// Events:
399-
// "change" (payload.value = TagOption[]),
400-
// "add" (label, value),
401-
// "edit" (from, to, index, value),
402-
// "delete" (removed, index, value),
403-
// "click" (tag, index, value)
404-
})}
348+
{children.onEvent.getPropertyView()}
405349
{hiddenPropertyView(children)}
406350
{showDataLoadingIndicatorsPropertyView(children)}
407351
</Section>
@@ -432,25 +376,6 @@ export const MultiTagsComp = withExposingConfigs(
432376
returnnull;
433377
}
434378
}),
435-
depsConfig({
436-
name:"selectedTagIndex",
437-
desc:"Index of currently selected tag (-1 if none)",
438-
depKeys:["selectedTagIndex"],
439-
func:(input)=>input.selectedTagIndex
440-
}),
441-
depsConfig({
442-
name:"selectedTagLabel",
443-
desc:"Label of currently selected tag",
444-
depKeys:["selectedTagIndex","runtimeOptions"],
445-
func:(input)=>{
446-
constindex=input.selectedTagIndex;
447-
constoptions=Array.isArray(input.runtimeOptions) ?(input.runtimeOptionsasany[]) :[];
448-
if(index>=0&&index<options.length){
449-
returnoptions[index]?.label||"";
450-
}
451-
return"";
452-
}
453-
}),
454379
depsConfig({
455380
name:"options",
456381
desc:"Current tags array (updates based on editable prop)",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp