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

feat: blacklist input types for Textfield #2960

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/proud-deers-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@digdir/designsystemet-react": patch
---

Textfield: Blacklist some `input` types for `Textfield`
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,24 @@ export default {
multiline: {
type: 'boolean',
},
// Using argType here to exclude values from React.HTMLInputTypeAttribute
type: {
control: 'select',
/* Only allowed types for Textfield */
options: [
'checkbox',
'date',
'datetime-local',
'email',
'month',
'number',
'password',
'radio',
'search',
'tel',
'text',
'time',
'url',
'week',
// 'button',
'color',
'file',
// 'hidden',
// 'image',
// 'range',
// 'reset',
// 'submit',
],
},
},
Expand Down
14 changes: 14 additions & 0 deletions packages/react/src/components/Textfield/Textfield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ type TextfieldTextareaProps = {
type TextfieldInputProps = {
/** Use to render a `Textarea` instead of `Input` for multiline support */
multiline?: never | false;
/**
* type of the input field
*/
type?: Omit<
InputProps['type'],
| 'button'
| 'image'
| 'range'
| 'reset'
| 'submit'
| 'checkbox'
| 'hidden'
| 'radio'
>;
} & InputProps_;

export type TextfieldProps = SharedTextfieldProps &
Expand Down
Loading