File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
packages/orchestrator-ui-components/src/components/WfoPydanticForm Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import { Row } from './Row';
30
30
import {
31
31
Checkbox ,
32
32
Divider ,
33
+ Integer ,
33
34
Label ,
34
35
Radio ,
35
36
Summary ,
@@ -232,6 +233,17 @@ export const WfoPydanticForm = ({
232
233
) ;
233
234
} ,
234
235
} ,
236
+ {
237
+ id : 'integerfield' ,
238
+ ElementMatch : {
239
+ Element : Integer ,
240
+ isControlledElement : true ,
241
+ } ,
242
+ matcher ( field ) {
243
+ return field . type === PydanticFormFieldType . INTEGER ;
244
+ } ,
245
+ validator : zodValidationPresets . integer ,
246
+ } ,
235
247
...currentMatchers . filter ( ( matcher ) => matcher . id !== 'text' ) ,
236
248
{
237
249
id : 'text' ,
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import type { PydanticFormControlledElement } from 'pydantic-forms' ;
4
+
5
+ import { EuiFieldNumber } from '@elastic/eui' ;
6
+ import { css } from '@emotion/react' ;
7
+
8
+ import type { WfoTheme } from '@/hooks' ;
9
+ import { useWithOrchestratorTheme } from '@/hooks' ;
10
+
11
+ const getFormFieldsBaseStyle = ( { theme } : WfoTheme ) => {
12
+ const formFieldBaseStyle = css ( {
13
+ backgroundColor : theme . colors . body ,
14
+ color : theme . colors . text ,
15
+ '&:focus' : {
16
+ backgroundColor : theme . colors . emptyShade ,
17
+ } ,
18
+ } ) ;
19
+
20
+ return {
21
+ formFieldBaseStyle,
22
+ } ;
23
+ } ;
24
+
25
+ export const Integer : PydanticFormControlledElement = ( {
26
+ pydanticFormField,
27
+ onChange,
28
+ value,
29
+ disabled,
30
+ } ) => {
31
+ const { formFieldBaseStyle } = useWithOrchestratorTheme (
32
+ getFormFieldsBaseStyle ,
33
+ ) ;
34
+
35
+ return (
36
+ < EuiFieldNumber
37
+ css = { formFieldBaseStyle }
38
+ name = { pydanticFormField . id }
39
+ onChange = { ( event ) => onChange ( parseInt ( event . target . value ) ) }
40
+ value = { value }
41
+ disabled = { disabled }
42
+ />
43
+ ) ;
44
+ } ;
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ export * from './Divider';
5
5
export * from './Checkbox' ;
6
6
export * from './Summary' ;
7
7
export * from './Radio' ;
8
+ export * from './Integer' ;
You can’t perform that action at this time.
0 commit comments