Skip to content

Commit

Permalink
✨ Hook up textfield-based builder fields for textfield component
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Apr 11, 2023
1 parent e13a0cb commit dcc7bf0
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/registry/textfield.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {FormattedMessage} from 'react-intl';
import {FormattedMessage, useIntl} from 'react-intl';

import {AutoComplete, Description, Key, Label, Placeholder} from '@components/builder';
import {Tab, TabList, TabPanel, Tabs} from '@components/formio';
import {TextField as BuilderTextField} from '@components/formio';

import {EditFormDefinition, EditFormProps} from '.';

Expand Down Expand Up @@ -56,7 +58,14 @@ const TextField: EditFormDefinition<EditFormProps> = () => {
</TabList>

{/* Basic tab */}
<TabPanel>Basic</TabPanel>
<TabPanel>
<Label />
<Key />
<Description />
<DefaultValue />
<AutoComplete />
<Placeholder />
</TabPanel>

{/* Location tab */}
<TabPanel>Location</TabPanel>
Expand All @@ -83,4 +92,24 @@ TextField.defaultValues = {
defaultValue: '',
};

const DefaultValue = () => {
const intl = useIntl();
const tooltip = intl.formatMessage({
description: "Tooltip for 'Default Value' builder field",
defaultMessage: 'This will be the initial value for this field, before user interaction.',
});
return (
<BuilderTextField
name="defaultValue"
label={
<FormattedMessage
description="Component property 'Default value' label"
defaultMessage="Default Value"
/>
}
tooltip={tooltip}
/>
);
};

export default TextField;

0 comments on commit dcc7bf0

Please sign in to comment.