1
1
import { useState } from "react" ;
2
2
import {
3
- antd ,
4
3
styleControl ,
5
4
withDefault ,
6
5
AutoHeightControl ,
@@ -12,6 +11,7 @@ import { useResizeDetector } from "react-resize-detector";
12
11
import styled from "styled-components" ;
13
12
14
13
import { trans } from "./i18n/comps" ;
14
+ import { StoneParcel } from "./vendors" ;
15
15
16
16
export const CompStyles = [
17
17
{
@@ -51,11 +51,6 @@ export const CompStyles = [
51
51
} ,
52
52
] as const ;
53
53
54
- interface Option {
55
- value : string ;
56
- label : string ;
57
- }
58
-
59
54
export default new UICompBuilder (
60
55
{
61
56
styles : styleControl ( CompStyles ) ,
@@ -75,12 +70,12 @@ export default new UICompBuilder(
75
70
data : any [ ] | null | undefined ;
76
71
autoHeight : boolean ;
77
72
} ) => {
78
- const [ formValues , setFormValues ] = useState ( [
73
+ const [ parcelValues , setParcelValues ] = useState ( [
79
74
{ parcel : "" , pieces : 0 , carat : 0 } ,
80
75
] ) ;
81
76
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 } ] ) ;
84
79
}
85
80
} ;
86
81
@@ -104,82 +99,35 @@ export default new UICompBuilder(
104
99
} ) ;
105
100
106
101
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
+ />
177
125
) ) }
178
- < antd . Button
126
+ { /* <antd.Button
179
127
type="primary"
180
128
shape="circle"
181
129
icon={<PlusOutlined />}
182
- > </ antd . Button >
130
+ ></antd.Button> */ }
183
131
</ Container >
184
132
) ;
185
133
} ,
@@ -197,8 +145,12 @@ export default new UICompBuilder(
197
145
. build ( ) ;
198
146
199
147
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%;
202
154
padding: 5px;
203
155
margin: ${ ( props ) => props . $styles . margin } ;
204
156
padding: ${ ( props ) => props . $styles . padding } ;
@@ -210,44 +162,3 @@ const Container = styled.div<{ $styles: any }>`
210
162
border: 1px solid #ddd;
211
163
background-color: white;
212
164
` ;
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