Skip to content

Commit

Permalink
fix: allow float to have decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
Hein Jeong committed Oct 12, 2022
1 parent 89d2fd1 commit 932a29c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4310,6 +4310,7 @@ export default function InputGalleryCreateForm(props) {
isRequired={false}
isReadOnly={false}
type=\\"number\\"
step=\\"any\\"
onChange={(e) => {
let value = parseInt(e.target.value);
if (isNaN(value)) {
Expand Down Expand Up @@ -4349,6 +4350,7 @@ export default function InputGalleryCreateForm(props) {
isRequired={false}
isReadOnly={false}
type=\\"number\\"
step=\\"any\\"
onChange={(e) => {
let value = Number(e.target.value);
if (isNaN(value)) {
Expand Down Expand Up @@ -5062,6 +5064,7 @@ export default function InputGalleryUpdateForm(props) {
isRequired={false}
isReadOnly={false}
type=\\"number\\"
step=\\"any\\"
defaultValue={num}
onChange={(e) => {
let value = parseInt(e.target.value);
Expand Down Expand Up @@ -5102,6 +5105,7 @@ export default function InputGalleryUpdateForm(props) {
isRequired={false}
isReadOnly={false}
type=\\"number\\"
step=\\"any\\"
defaultValue={rootbeer}
onChange={(e) => {
let value = Number(e.target.value);
Expand Down
3 changes: 2 additions & 1 deletion packages/codegen-ui-react/lib/forms/form-renderer-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const addFormAttributes = (component: StudioComponent | StudioComponentCh
);
attributes.push(
...buildComponentSpecificAttributes({
componentType,
componentType: fieldConfig.studioFormComponentType ?? fieldConfig.componentType,
componentName: renderedVariableName,
currentValueIdentifier: fieldConfig.isArray ? getCurrentValueIdentifier(renderedVariableName) : undefined,
}),
Expand Down Expand Up @@ -497,6 +497,7 @@ export const buildComponentSpecificAttributes = ({
factory.createJsxExpression(undefined, valueIdentifier),
),
],
NumberField: [factory.createJsxAttribute(factory.createIdentifier('step'), factory.createStringLiteral('any'))],
};

return componentToAttributesMap[componentType] ?? [];
Expand Down
1 change: 1 addition & 0 deletions packages/codegen-ui/lib/types/form/form-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type FieldConfigMetadata = {
sanitizedFieldName?: string;
isArray?: boolean;
componentType: string;
studioFormComponentType?: string;
};

export type FormMetadata = {
Expand Down
1 change: 1 addition & 0 deletions packages/codegen-ui/lib/utils/form-component-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const mapFormMetadata = (form: StudioForm, formDefinition: FormDefinition
const metadata: FieldConfigMetadata = {
validationRules: [],
componentType: config.componentType,
studioFormComponentType: 'studioFormComponentType' in config ? config.studioFormComponentType : undefined,
isArray: 'isArray' in config && config.isArray,
};
if ('validations' in config && config.validations) {
Expand Down

0 comments on commit 932a29c

Please sign in to comment.