Skip to content

Commit 48c45a4

Browse files
author
Yofriadi Yahya
committed
saving
1 parent bbb66c0 commit 48c45a4

File tree

10 files changed

+191
-678
lines changed

10 files changed

+191
-678
lines changed

lowcoder-comp-stone-parcel-input/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"lowcoder": {
2525
"description": "",
2626
"comps": {
27-
"stone_parcel_input": {
28-
"name": "Stone Parcel Demo",
27+
"stone_parcel": {
28+
"name": "Stone Parcel",
2929
"icon": "./icons/hills.svg",
30-
"description": "Stone Parcel Input Plugin Demo Component"
30+
"description": "Stone Parcel Input Plugin Component"
3131
}
3232
}
3333
},
Lines changed: 35 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useState } from "react";
22
import {
3-
antd,
43
styleControl,
54
withDefault,
65
AutoHeightControl,
@@ -12,6 +11,7 @@ import { useResizeDetector } from "react-resize-detector";
1211
import styled from "styled-components";
1312

1413
import { trans } from "./i18n/comps";
14+
import { StoneParcel } from "./vendors";
1515

1616
export const CompStyles = [
1717
{
@@ -51,11 +51,6 @@ export const CompStyles = [
5151
},
5252
] as const;
5353

54-
interface Option {
55-
value: string;
56-
label: string;
57-
}
58-
5954
export default new UICompBuilder(
6055
{
6156
styles: styleControl(CompStyles),
@@ -75,12 +70,12 @@ export default new UICompBuilder(
7570
data: any[] | null | undefined;
7671
autoHeight: boolean;
7772
}) => {
78-
const [formValues, setFormValues] = useState([
73+
const [parcelValues, setParcelValues] = useState([
7974
{ parcel: "", pieces: 0, carat: 0 },
8075
]);
8176
let handleChange = (i: number) => {
82-
if (i === formValues.length - 1 && i >= 0) {
83-
setFormValues([...formValues, { parcel: "", pieces: 0, carat: 0 }]);
77+
if (i === parcelValues.length - 1) {
78+
setParcelValues([...parcelValues, { parcel: "", pieces: 0, carat: 0 }]);
8479
}
8580
};
8681

@@ -104,82 +99,35 @@ export default new UICompBuilder(
10499
});
105100

106101
return (
107-
<Container $styles={props.styles} ref={conRef}>
108-
{formValues.map((el, i) => (
109-
<Row key={i}>
110-
<Wrapper>
111-
<Label>Parcel</Label>
112-
<antd.Select
113-
showSearch
114-
allowClear
115-
style={{ width: 200, margin: 4 }}
116-
placeholder="Search to Select"
117-
optionFilterProp="children"
118-
filterOption={(input: string, option: Option): boolean =>
119-
(option?.label ?? "").includes(input)
120-
}
121-
filterSort={(optionA: Option, optionB: Option) =>
122-
(optionA?.label ?? "")
123-
.toLowerCase()
124-
.localeCompare((optionB?.label ?? "").toLowerCase())
125-
}
126-
defaultValue={el.parcel}
127-
onSelect={() => handleChange(i)}
128-
options={[
129-
{
130-
value: "1",
131-
label: "Not Identified",
132-
},
133-
{
134-
value: "2",
135-
label: "Closed",
136-
},
137-
{
138-
value: "3",
139-
label: "Communicated",
140-
},
141-
{
142-
value: "4",
143-
label: "Identified",
144-
},
145-
{
146-
value: "5",
147-
label: "Resolved",
148-
},
149-
{
150-
value: "6",
151-
label: "Cancelled",
152-
},
153-
]}
154-
/>
155-
</Wrapper>
156-
<Wrapper>
157-
<Label>Pieces</Label>
158-
<antd.InputNumber
159-
style={{ margin: 3 }}
160-
min={1}
161-
max={10}
162-
defaultValue={el.pieces}
163-
onFocus={() => handleChange(i)}
164-
/>
165-
</Wrapper>
166-
<Wrapper>
167-
<Label>Carat</Label>
168-
<antd.InputNumber
169-
style={{ margin: 3 }}
170-
min={1}
171-
max={10}
172-
defaultValue={el.carat}
173-
onFocus={() => handleChange(i)}
174-
/>
175-
</Wrapper>
176-
</Row>
102+
/* <div
103+
className={styles.wrapper}
104+
style={{
105+
height: "100%",
106+
width: "100%",
107+
backgroundColor: `${props.styles.backgroundColor}`,
108+
borderColor: `${props.styles.border}`,
109+
borderRadius: `${props.styles.radius}`,
110+
borderWidth: `${props.styles.borderWidth}`,
111+
margin: `${props.styles.margin}`,
112+
padding: `${props.styles.padding}`,
113+
fontSize: `${props.styles.textSize}`,
114+
}}
115+
ref={conRef}
116+
> */
117+
<Container $styles={props.styles}>
118+
{parcelValues.map((el, i) => (
119+
<StoneParcel
120+
key={i}
121+
i={i}
122+
parcelValue={el}
123+
onHandleChange={handleChange}
124+
/>
177125
))}
178-
<antd.Button
126+
{/* <antd.Button
179127
type="primary"
180128
shape="circle"
181129
icon={<PlusOutlined />}
182-
></antd.Button>
130+
></antd.Button> */}
183131
</Container>
184132
);
185133
},
@@ -197,8 +145,12 @@ export default new UICompBuilder(
197145
.build();
198146

199147
const Container = styled.div<{ $styles: any }>`
200-
height: auto;
201-
width: auto;
148+
display: flex;
149+
flex-direction: column;
150+
justify-content: center;
151+
align-items: center;
152+
height: 100%;
153+
width: 100%;
202154
padding: 5px;
203155
margin: ${(props) => props.$styles.margin};
204156
padding: ${(props) => props.$styles.padding};
@@ -210,44 +162,3 @@ const Container = styled.div<{ $styles: any }>`
210162
border: 1px solid #ddd;
211163
background-color: white;
212164
`;
213-
214-
const Row = styled.div`
215-
display: flex;
216-
height: 100%;
217-
flex-grow: 1;
218-
width: 100%;
219-
margin-top: 4px;
220-
height: calc(100% - 4px);
221-
align-items: start;
222-
flex-shrink: 0;
223-
`;
224-
225-
const Wrapper = styled.div`
226-
display: flex;
227-
flex-direction: column;
228-
`;
229-
230-
const Label = styled.span`
231-
user-select: none;
232-
font-size: 13px;
233-
color: #222222;
234-
235-
&:hover {
236-
cursor: default;
237-
}
238-
239-
/**
240-
* add this for tooltip
241-
background-image: linear-gradient(to right, #8b8fa3 50%, #fff 0%); */
242-
background-size: 4px 1px;
243-
background-position: 5px bottom;
244-
background-repeat: repeat-x;
245-
padding-left: 5px;
246-
padding-bottom: 2.5px !important;
247-
width: fit-content;
248-
user-select: text;
249-
white-space: nowrap;
250-
text-overflow: ellipsis;
251-
overflow: hidden;
252-
display: inline-block;
253-
`;

0 commit comments

Comments
 (0)