Skip to content

Commit 51de3a3

Browse files
committed
Initialize tags component
1 parent 18d3e40 commit 51de3a3

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { AnimationStyle, BoolCodeControl, ButtonEventHandlerControl, CommonNameConfig, DropdownOptionControl, IconControl, LinkStyle, NameConfig, NameConfigDisabled, RefControl, Section, SelectOptionControl, StringControl, TabsOptionControl, TagsOptionControl, UICompBuilder, blurMethod, clickMethod, focusWithOptions, migrateOldData, refMethods, sectionNames, stringExposingStateControl, styleControl, withDefault, withExposingConfigs } from "@lowcoder-ee/index.sdk";
2+
import React from "react";
3+
import { trans } from "i18n";
4+
import { buttonRefMethods } from "../buttonComp/buttonCompConstants";
5+
import { Tag } from "antd";
6+
import { autoCompleteRefMethods } from "../autoCompleteComp/autoCompleteConstants";
7+
8+
9+
// const TagsCompView = (function () {
10+
// // const childrenMap = {
11+
// // text: withDefault(StringControl, trans("link.link")),
12+
// // onEvent: ButtonEventHandlerControl,
13+
// // disabled: BoolCodeControl,
14+
// // loading: BoolCodeControl,
15+
16+
// // // style: migrateOldData(styleControl(LinkStyle, 'style')),
17+
// // animationStyle: styleControl(AnimationStyle, 'animationStyle'),
18+
// // prefixIcon: IconControl,
19+
// // suffixIcon: IconControl,
20+
// // viewRef: RefControl<HTMLElement>,
21+
// // };
22+
23+
// const childrenMap = {
24+
// text: stringExposingStateControl("text", "world"),
25+
// // options: TabsOptionControl,
26+
// };
27+
// return new UICompBuilder(childrenMap, (props) => {
28+
// return (
29+
// <Tag>Tag 1</Tag>
30+
// )
31+
// })
32+
// .setPropertyViewFn((children) => {
33+
// return(
34+
// <Section name={sectionNames.basic}>
35+
// {/* {children.options.propertyView({})} */}
36+
// {children.text.propertyView({ label: trans("text") })}
37+
// </Section>
38+
// )
39+
// })
40+
// .build();
41+
// })();
42+
43+
const multiTags = (function () {
44+
const childrenMap = {
45+
text: stringExposingStateControl("text", "world"),
46+
options: TagsOptionControl,
47+
};
48+
49+
return new UICompBuilder(childrenMap, (props) => {
50+
const text = props.text.value;
51+
console.log(props.options)
52+
return (
53+
<>
54+
{props.options.map(tag => (
55+
<Tag>{tag.label}</Tag>
56+
))}
57+
</>
58+
);
59+
})
60+
.setPropertyViewFn((children: any) => {
61+
return (
62+
<Section name="Basic">
63+
{children.options.propertyView({})}
64+
{children.text.propertyView({ label: "Text" })}
65+
</Section>
66+
)
67+
})
68+
.build();
69+
})()
70+
71+
72+
// const childrenMap = {
73+
// text: stringExposingStateControl("text", "world"),
74+
// options: TagsOptionControl,
75+
// };
76+
77+
// const TagsCompView = new UICompBuilder(childrenMap, (props: any) => {
78+
// const text = props.text.value;
79+
// return <div>Hello {text}</div>;
80+
// })
81+
// .setPropertyViewFn((children: any) => {
82+
// return (
83+
// <Section name="Basic">
84+
// {children.options.propertyView({})}
85+
// {children.text.propertyView({ label: "Text" })}
86+
// </Section>
87+
// )
88+
// })
89+
// .build();
90+
91+
export const MultiTagsComp = withExposingConfigs(multiTags, [new NameConfig("text", "")]);
92+

client/packages/lowcoder/src/comps/controls/optionsControl.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ const TabsOption = new MultiCompBuilder(
557557
</>
558558
))
559559
.build();
560+
560561

561562
export const TabsOptionControl = manualOptionsControl(TabsOption, {
562563
initOptions: [
@@ -567,6 +568,37 @@ export const TabsOptionControl = manualOptionsControl(TabsOption, {
567568
autoIncField: "id",
568569
});
569570

571+
const TagsOption = new MultiCompBuilder(
572+
{
573+
id: valueComp<number>(-1),
574+
label: StringControl,
575+
icon: IconControl,
576+
iconPosition: withDefault(LeftRightControl, "left"),
577+
hidden: BoolCodeControl,
578+
},
579+
(props) => props
580+
)
581+
.setPropertyViewFn((children) => (
582+
<>
583+
{children.label.propertyView({ label: trans("label") })}
584+
{children.icon.propertyView({ label: trans("icon") })}
585+
{children.iconPosition.propertyView({
586+
label: trans("tabbedContainer.iconPosition"),
587+
radioButton: true,
588+
})}
589+
{hiddenPropertyView(children)}
590+
</>
591+
))
592+
.build();
593+
594+
export const TagsOptionControl = optionsControl(TagsOption, {
595+
initOptions: [
596+
{ id: 0, label: "Option 1" },
597+
{ id: 1, label: "Option 2" },
598+
],
599+
autoIncField: "id",
600+
});
601+
570602
const StyledIcon = styled.span`
571603
margin: 0 4px 0 14px;
572604
`;

client/packages/lowcoder/src/comps/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ import { DrawerComp } from "./hooks/drawerComp";
193193
import { ModalComp } from "./hooks/modalComp";
194194
import { defaultCollapsibleContainerData } from "./comps/containerComp/collapsibleContainerComp";
195195
import { ContainerComp as FloatTextContainerComp } from "./comps/containerComp/textContainerComp";
196+
import { MultiTagsComp } from "./comps/tagsComp/tagsCompView";
196197

197198
type Registry = {
198199
[key in UICompType]?: UICompManifest;
@@ -709,6 +710,19 @@ export var uiCompMap: Registry = {
709710
},
710711
defaultDataFn: defaultGridData,
711712
},
713+
multiTags: {
714+
name: trans("tags"),
715+
enName: "tags",
716+
description: "Desc of Tags",
717+
categories: ["layout"],
718+
icon: FloatingButtonCompIcon,
719+
keywords: trans("uiComp.floatButtonCompKeywords"),
720+
comp: MultiTagsComp,
721+
layoutInfo: {
722+
w: 9,
723+
h: 5,
724+
},
725+
},
712726
modal: {
713727
name: trans("uiComp.modalCompName"),
714728
enName: "Modal",

client/packages/lowcoder/src/comps/uiCompRegistry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export type UICompType =
106106
| "container"
107107
| "pageLayout" // added by Falk Wolsky
108108
| "floatTextContainer"
109+
| "multiTags" // Added by Kamal Qureshi
109110
| "tabbedContainer"
110111
| "modal"
111112
| "listView"

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const en = {
4545
"accessControl": "Access Control",
4646
"copySuccess": "Copied Successfully",
4747
"copyError": "Copy Error",
48+
"tags": "Tags",
4849

4950
"api": {
5051
"publishSuccess": "Published Successfully",

client/packages/lowcoder/src/pages/editor/editorConstants.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export const CompStateIcon: {
237237
step: <MemoizedIcon Icon={StepCompIconSmall} />,
238238
table: <MemoizedIcon Icon={TableCompIconSmall} />,
239239
text: <MemoizedIcon Icon={TextCompIconSmall} />,
240+
multiTags: <MemoizedIcon Icon={TextCompIconSmall} />,
240241
timeline: <MemoizedIcon Icon={TimeLineCompIconSmall} />,
241242
toggleButton: <MemoizedIcon Icon={ToggleButtonCompIconSmall} />,
242243
tour: <MemoizedIcon Icon={TourCompIconSmall} />,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy