Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Forms): enhance Getting Started examples #4391

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export const UsingWizard = () => {
return (
<ComponentBox>
{() => {
const MyForm = () => {
function MyForm() {
// Routers like "react-router" are supported as well
Wizard.useQueryLocator('my-wizard')
const { summaryTitle } = Form.useLocale().Step
Expand Down Expand Up @@ -622,7 +622,7 @@ export const UsingIterate = () => {
)
}

const MyForm = () => {
function MyForm() {
return (
<Form.Handler
data={{
Expand Down Expand Up @@ -700,33 +700,37 @@ export const Transformers = () => {

export const QuickStart = () => {
return (
<ComponentBox>
<ComponentBox hideCode>
{() => {
const MyForm = () => {
const existingData = { companyName: 'DNB' }
const existingData = { companyName: 'DNB' }

function MyForm() {
return (
<Form.Handler
defaultData={existingData}
onChange={console.log}
onSubmit={console.log}
onSubmit={async (data) => console.log('onSubmit', data)}
required
>
<Form.MainHeading>Quick start</Form.MainHeading>

<Form.Card>
<Field.Name.Company path="/companyName" required />
<Field.OrganizationNumber
path="/companyOrganizationNumber"
required
/>
<Field.Name.Company path="/companyName" />

<Field.OrganizationNumber path="/companyOrganizationNumber" />

<Field.Selection
path="/postalAddressSelect"
label="Ønsket sted for tilsendt post"
variant="radio"
required={false}
>
<Field.Option
value="companyAddress"
title="Samme som forretningsadresse"
/>
<Field.Option value="other" title="Annet" />
</Field.Selection>

<Form.Visibility
visibleWhen={{
path: '/postalAddressSelect',
Expand All @@ -737,10 +741,10 @@ export const QuickStart = () => {
<Field.String
path="/postalAddress"
label="Sted for tilsendt post"
required
/>
</Form.Visibility>
</Form.Card>
<Form.SubmitButton variant="send" />
</Form.Handler>
)
}
Expand Down
Loading