-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(Forms): add toolbarVariant="minimumOneItem"
to Iterate.Toolbar for hiding buttons when there is only one item in the array
#3919
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
…make `Iterate.Toolbar` fully customizable (#3877) - This PR allows a dev to fully customize the buttons for the edit and view container toolbar. - I also auto-opens the edit container, when there is a validation error. - A followup-up PR #3919 has been created. Quick example of a fully customized Toolbar: ```tsx <Form.Handler> <Iterate.Array path="/countries" defaultValue={[null]}> <Iterate.ViewContainer toolbar={ <Iterate.Toolbar> {({ items }) => { if (items.length === 1) { return <Iterate.ViewContainer.EditButton /> } return ( <> <Iterate.ViewContainer.EditButton /> <Iterate.ViewContainer.RemoveButton /> </> ) }} </Iterate.Toolbar> } > <Value.SelectCountry label="Land du er statsborger i" itemPath="/" /> </Iterate.ViewContainer> <Iterate.EditContainer toolbar={ <Iterate.Toolbar> {({ items }) => { if (items.length === 1) { return null } return ( <> <Iterate.EditContainer.DoneButton /> <Iterate.EditContainer.CancelButton /> </> ) }} </Iterate.Toolbar> } > <Field.SelectCountry label="Land du er statsborger i" itemPath="/" required /> </Iterate.EditContainer> </Iterate.Array> <Iterate.PushButton path="/countries" pushValue={null} text="Legg til flere statsborgerskap" /> </Form.Handler> ``` --------- Co-authored-by: Anders <[email protected]>
2dbea3f
to
dd48787
Compare
...ages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/EditContainer/info.mdx
Show resolved
Hide resolved
…en there is only one item in the array
dd48787
to
7dadc26
Compare
toolbarVariant="minimumOneItem"
to Iterate.Toolbar for hiding the buttons when there is only one item in the array
toolbarVariant="minimumOneItem"
to Iterate.Toolbar for hiding the buttons when there is only one item in the arraytoolbarVariant="minimumOneItem"
to Iterate.Toolbar for hiding buttons when there is only one item in the array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Array/demos.mdx
Outdated
Show resolved
Hide resolved
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Array/demos.mdx
Outdated
Show resolved
Hide resolved
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/changelog.mdx
Outdated
Show resolved
Hide resolved
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/changelog.mdx
Outdated
Show resolved
Hide resolved
…rms/Iterate/Array/demos.mdx
…rms/Iterate/Array/demos.mdx
…rms/changelog.mdx
…rms/changelog.mdx
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Array/demos.mdx
Outdated
Show resolved
Hide resolved
…rms/Iterate/Array/demos.mdx
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
## [10.48.0](v10.47.0...v10.48.0) (2024-09-12) ### 🐛 Bug Fixes * **countries:** Fixes wrong country code for Martinique [#3915](#3915) ([a9f86e4](a9f86e4)) * **countries:** Remove outdated countries [#3915](#3915) ([36ef5cf](36ef5cf)) * **Forms:** rename 'Macedonia' to 'North Macedonia' ([#3918](#3918)) ([a4eb8a4](a4eb8a4)) * **Forms:** rename "Hviterussland" to "Belarus" ([#3917](#3917)) ([702118a](702118a)) * removes outdated countries based on ISO 3166-1 alpha-2 ([#3916](#3916)) ([a045acd](a045acd)) ### ✨ Features * **Forms:** add `toolbarVariant="minimumOneItem"` to Iterate.Toolbar for hiding buttons when there is only one item in the array ([#3919](#3919)) ([3367a77](3367a77)), closes [#3877](#3877) * **Forms:** add `validator` support to Iterate.Array ([#3926](#3926)) ([6fd439e](6fd439e)) * **Forms:** auto-open Form.Section container when fields have errors and add `validateInitially` prop ([#3878](#3878)) ([9b49006](9b49006)) * **Forms:** auto-open iterate containers when validation errors and make `Iterate.Toolbar` fully customizable ([#3877](#3877)) ([52326bf](52326bf)), closes [#3919](#3919) * **Forms:** show optional label when a field uses `required={false}` and add `labelSuffix` prop to each field ([#3921](#3921)) ([60e440a](60e440a)) * **Wizard:** add `preventNavigation` callback function to `onStepChange` ([#3924](#3924)) ([5ec2772](5ec2772))
🎉 This PR is included in version 10.48.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Based on #3877
Quick example using the new Toolbar variant: