Skip to content

Commit

Permalink
✨ Kan styre autocomplete, er default av
Browse files Browse the repository at this point in the history
  • Loading branch information
steoiv committed Feb 3, 2025
1 parent ff81a71 commit a3caf4e
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 12 deletions.
2 changes: 2 additions & 0 deletions packages/aap-felles-css/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.3.0

## 4.2.8

## 4.2.7
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-css/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.8",
"version": "4.3.0",
"name": "@navikt/aap-felles-css",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
2 changes: 2 additions & 0 deletions packages/aap-felles-prettier/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.3.0

## 4.2.8

## 4.2.7
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@navikt/aap-felles-prettier",
"author": "NAV",
"version": "4.2.8",
"version": "4.3.0",
"main": "index.json",
"license": "MIT",
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/aap-felles-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 4.3.0

### Minor Changes

- Kan styre autocomplete. Default av.

## 4.2.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-react/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.8",
"version": "4.3.0",
"name": "@navikt/aap-felles-react",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
9 changes: 7 additions & 2 deletions packages/aap-felles-react/src/Form/FormField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react';
import React, { HTMLInputAutoCompleteAttribute, ReactNode } from 'react';
import { UseFormReturn } from 'react-hook-form';
import { FieldValues } from 'react-hook-form/dist/types';

Expand Down Expand Up @@ -26,10 +26,11 @@ interface Props<FormFieldIds extends FieldValues> {
horizontalRadio?: boolean;
size?: 'small' | 'medium';
className?: string;
autocomplete?: HTMLInputAutoCompleteAttribute;
}

export const FormField = <FormFieldIds extends FieldValues>(props: Props<FormFieldIds>) => {
const { formField, form, children, className, horizontalRadio, size } = props;
const { formField, form, children, className, horizontalRadio, size, autocomplete = 'off' } = props;

return (
<>
Expand All @@ -45,6 +46,7 @@ export const FormField = <FormFieldIds extends FieldValues>(props: Props<FormFie
description={formField.description}
readOnly={formField.readOnly}
className={className}
autocomplete={autocomplete}
/>
)}
{formField.type === 'textarea' && (
Expand All @@ -58,6 +60,7 @@ export const FormField = <FormFieldIds extends FieldValues>(props: Props<FormFie
description={formField.description}
readOnly={formField.readOnly}
className={className}
autocomplete={autocomplete}
/>
)}
{formField.type === 'radio' && (
Expand Down Expand Up @@ -107,6 +110,7 @@ export const FormField = <FormFieldIds extends FieldValues>(props: Props<FormFie
description={formField.description}
readOnly={formField.readOnly}
className={className}
autocomplete={autocomplete}
/>
)}
{formField.type === 'checkbox' && (
Expand Down Expand Up @@ -139,6 +143,7 @@ export const FormField = <FormFieldIds extends FieldValues>(props: Props<FormFie
size={size}
readOnly={formField.readOnly}
className={className}
autocomplete={autocomplete}
>
{formField.options.map(mapToValuePair).map((option) => (
<option key={option.value} value={option.value}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextField } from '@navikt/ds-react';
import React from 'react';
import React, { HTMLInputAutoCompleteAttribute } from 'react';
import { ReactNode } from 'react';
import { Control, Controller, FieldPath, FieldValues, RegisterOptions } from 'react-hook-form';
import { mapShortDateToDateString } from './dateMapper';
Expand All @@ -14,6 +14,7 @@ export type DateInputWrapperProps<FormFieldValues extends FieldValues> = {
rules?: RegisterOptions<FormFieldValues>;
readOnly?: boolean;
className?: string;
autocomplete?: HTMLInputAutoCompleteAttribute;
};

export const DateInputWrapper = <FormFieldValues extends FieldValues>({
Expand All @@ -26,6 +27,7 @@ export const DateInputWrapper = <FormFieldValues extends FieldValues>({
size = 'small',
className,
hideLabel,
autocomplete,
}: DateInputWrapperProps<FormFieldValues>) => {
const classNames = `aap_date_input ${className}`;
const transform = (input: React.FormEvent<HTMLInputElement>) => mapShortDateToDateString(input.currentTarget.value);
Expand All @@ -49,6 +51,7 @@ export const DateInputWrapper = <FormFieldValues extends FieldValues>({
description={description}
readOnly={readOnly}
className={classNames}
autoComplete={autocomplete}
/>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Select } from '@navikt/ds-react';
import React, { ReactNode } from 'react';
import React, { HTMLInputAutoCompleteAttribute, ReactNode } from 'react';
import { Control, Controller, RegisterOptions } from 'react-hook-form';
import { FieldPath, FieldValues } from 'react-hook-form/dist/types';

Expand All @@ -14,6 +14,7 @@ export interface SelectProps<FormFieldValues extends FieldValues> {
description?: ReactNode;
readOnly?: boolean;
className?: string;
autocomplete?: HTMLInputAutoCompleteAttribute;
}

export const SelectWrapper = <FormFieldValues extends FieldValues>({
Expand All @@ -27,6 +28,7 @@ export const SelectWrapper = <FormFieldValues extends FieldValues>({
children,
readOnly,
className,
autocomplete,
}: SelectProps<FormFieldValues>) => (
<Controller
name={name}
Expand All @@ -45,6 +47,7 @@ export const SelectWrapper = <FormFieldValues extends FieldValues>({
error={error?.message}
readOnly={readOnly}
className={className}
autoComplete={autocomplete}
>
{children}
</Select>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Textarea } from '@navikt/ds-react';
import React from 'react';
import React, { HTMLInputAutoCompleteAttribute } from 'react';
import { Control, Controller, FieldValues, RegisterOptions } from 'react-hook-form';
import { FieldPath } from 'react-hook-form/dist/types';

Expand All @@ -14,6 +14,7 @@ export interface TextAreaProps<FormFieldValues extends FieldValues> {
maxLength?: number;
readOnly?: boolean;
className?: string;
autocomplete?: HTMLInputAutoCompleteAttribute;
}

export const TextAreaWrapper = <FormFieldValues extends FieldValues>({
Expand All @@ -27,6 +28,7 @@ export const TextAreaWrapper = <FormFieldValues extends FieldValues>({
rules,
readOnly,
className,
autocomplete,
}: TextAreaProps<FormFieldValues>) => (
<Controller
name={name}
Expand All @@ -46,6 +48,7 @@ export const TextAreaWrapper = <FormFieldValues extends FieldValues>({
maxLength={maxLength}
readOnly={readOnly}
className={className}
autoComplete={autocomplete}
/>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextField } from '@navikt/ds-react';
import React from 'react';
import React, { HTMLInputAutoCompleteAttribute } from 'react';
import { Control, Controller, FieldValues, RegisterOptions } from 'react-hook-form';
import { FieldPath } from 'react-hook-form/dist/types';

Expand All @@ -14,6 +14,7 @@ export interface TextFieldProps<FormFieldValues extends FieldValues> {
rules?: RegisterOptions<FormFieldValues>;
readOnly?: boolean;
className?: string;
autocomplete?: HTMLInputAutoCompleteAttribute;
}

export const TextFieldWrapper = <FormFieldValues extends FieldValues>({
Expand All @@ -27,6 +28,7 @@ export const TextFieldWrapper = <FormFieldValues extends FieldValues>({
rules,
readOnly,
className,
autocomplete,
}: TextFieldProps<FormFieldValues>) => (
<Controller
name={name}
Expand All @@ -46,6 +48,7 @@ export const TextFieldWrapper = <FormFieldValues extends FieldValues>({
description={description}
readOnly={readOnly}
className={className}
autoComplete={autocomplete}
/>
)}
/>
Expand Down
2 changes: 2 additions & 0 deletions packages/aap-felles-utils-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.3.0

## 4.2.8

## 4.2.7
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-utils-client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.8",
"version": "4.3.0",
"name": "@navikt/aap-felles-utils-client",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
2 changes: 2 additions & 0 deletions packages/aap-felles-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.3.0

## 4.2.8

## 4.2.7
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.8",
"version": "4.3.0",
"name": "@navikt/aap-felles-utils",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-aap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.3.0

## 4.2.8

## 4.2.7
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-aap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@navikt/eslint-config-aap",
"author": "NAV",
"version": "4.2.8",
"version": "4.3.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\"",
Expand Down

0 comments on commit a3caf4e

Please sign in to comment.