diff --git a/packages/dnb-design-system-portal/package.json b/packages/dnb-design-system-portal/package.json index d72675ae884..b0c78087c29 100644 --- a/packages/dnb-design-system-portal/package.json +++ b/packages/dnb-design-system-portal/package.json @@ -119,7 +119,7 @@ "stylelint-config-recommended": "12.0.0", "stylelint-config-standard-scss": "9.0.0", "svg-react-loader": "0.4.6", - "typescript": "5.0.4", + "typescript": "5.2.2", "unist-util-visit": "^2" }, "buildVersion": "[LOCAL BUILD]", diff --git a/packages/dnb-eufemia/package.json b/packages/dnb-eufemia/package.json index 3c01ce2259f..1e1cdf4ee80 100644 --- a/packages/dnb-eufemia/package.json +++ b/packages/dnb-eufemia/package.json @@ -273,7 +273,7 @@ "svgo": "3.0.0", "tar": "6.1.11", "traverse": "0.6.6", - "typescript": "5.0.4", + "typescript": "5.2.2", "vd-tool": "4.0.2", "wait-on": "6.0.0" }, diff --git a/packages/dnb-eufemia/src/components/input/Input.d.ts b/packages/dnb-eufemia/src/components/input/Input.d.ts index ace7fbdeee9..4526f764f4c 100644 --- a/packages/dnb-eufemia/src/components/input/Input.d.ts +++ b/packages/dnb-eufemia/src/components/input/Input.d.ts @@ -196,7 +196,7 @@ export default class Input extends React.Component { render(): JSX.Element; } export interface SubmitButtonProps - extends React.HTMLProps { + extends React.HTMLProps { id?: string; /** * The content value of the input. diff --git a/packages/dnb-eufemia/src/extensions/forms/Field/Number/__tests__/Number.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Field/Number/__tests__/Number.test.tsx index 0b8e64e1bf2..f6de675cd84 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Field/Number/__tests__/Number.test.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Field/Number/__tests__/Number.test.tsx @@ -77,11 +77,11 @@ describe('Field.Number', () => { it('renders autoComplete', () => { const { rerender } = render( - + ) expect( document.querySelector('input').getAttribute('autocomplete') - ).toBe('postalCode') + ).toBe('postal-code') rerender() expect(document.querySelector('input').getAttribute('name')).toBe( diff --git a/packages/dnb-eufemia/src/extensions/forms/Field/String/__tests__/String.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Field/String/__tests__/String.test.tsx index de9582d93e8..fd5467b6184 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Field/String/__tests__/String.test.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Field/String/__tests__/String.test.tsx @@ -218,11 +218,11 @@ describe('Field.String', () => { it('renders autoComplete', () => { const { rerender } = render( - + ) expect( document.querySelector('input').getAttribute('autocomplete') - ).toBe('firstName') + ).toBe('given-name') rerender( diff --git a/packages/dnb-eufemia/src/extensions/forms/Value/Number/Number.tsx b/packages/dnb-eufemia/src/extensions/forms/Value/Number/Number.tsx index f8feed482c5..309b7683340 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Value/Number/Number.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Value/Number/Number.tsx @@ -11,18 +11,19 @@ import NumberFormat, { NumberFormatProps, } from '../../../../components/NumberFormat' import { - ToCamelCase, + IncludeCamelCase, convertCamelCaseProps, } from '../../../../shared/helpers/withCamelCaseProps' -export type Props = ValueProps & ToCamelCase +export type Props = ValueProps & + IncludeCamelCase function NumberValue(props: Props) { const { className, label, placeholder, inline, showEmpty, ...rest } = useDataValue(props) const numberFormatProps = convertCamelCaseProps( - omitSpacingProps(omitDataValueProps(rest)) as NumberFormatProps + omitDataValueProps(omitSpacingProps(rest)) ) return ( diff --git a/packages/dnb-eufemia/src/extensions/forms/hooks/useDataValue.ts b/packages/dnb-eufemia/src/extensions/forms/hooks/useDataValue.ts index f679f4087b3..6237ddab507 100644 --- a/packages/dnb-eufemia/src/extensions/forms/hooks/useDataValue.ts +++ b/packages/dnb-eufemia/src/extensions/forms/hooks/useDataValue.ts @@ -26,7 +26,7 @@ import useId from './useId' export default function useDataValue< Value = unknown, Props extends FieldProps = FieldProps, ->(props: Props): Props & ReturnAdditional { +>(props: Props): Props & FieldProps & ReturnAdditional { const { path, itemPath, @@ -675,11 +675,13 @@ export default function useDataValue< warning: !inFieldBlock ? warning : undefined, error: !inFieldBlock ? error : undefined, hasError, - isChanged: changedRef.current, + disabled, autoComplete: props.autoComplete ?? (dataContext.autoComplete === true ? 'on' : 'off'), - disabled, + + // Return additional hook related props (ReturnAdditional) + isChanged: changedRef.current, ariaAttributes, dataContext, setHasFocus, @@ -692,29 +694,21 @@ export default function useDataValue< } interface ReturnAdditional { - id: string - name: string value: Value - error: FieldProps['error'] - warning: FieldProps['warning'] - info: FieldProps['info'] - autoComplete: HTMLInputElement['autocomplete'] - disabled: boolean - hasError: boolean isChanged: boolean - dataContext: ContextState ariaAttributes: AriaAttributes + dataContext: ContextState setHasFocus: (hasFocus: boolean, valueOverride?: unknown) => void handleFocus: () => void handleBlur: () => void - handleChange: FieldProps['onChange'] + handleChange: FieldProps['onChange'] updateValue: (value: Value) => void forceUpdate: () => void } export function omitDataValueProps< - OmittedProps extends ReturnAdditional, ->(props: OmittedProps) { + Props extends FieldProps & ReturnAdditional, +>(props: Props) { // Do not include typical HTML attributes const { name, // eslint-disable-line @@ -734,8 +728,6 @@ export function omitDataValueProps< forceUpdate, // eslint-disable-line ...restProps } = props - return Object.freeze(restProps) as Omit< - OmittedProps, - keyof ReturnAdditional - > + + return restProps } diff --git a/packages/dnb-eufemia/src/shared/helpers/withCamelCaseProps.tsx b/packages/dnb-eufemia/src/shared/helpers/withCamelCaseProps.tsx index 723726990e7..77c45dbe241 100644 --- a/packages/dnb-eufemia/src/shared/helpers/withCamelCaseProps.tsx +++ b/packages/dnb-eufemia/src/shared/helpers/withCamelCaseProps.tsx @@ -82,6 +82,13 @@ export function classWithCamelCaseProps< return Derived } +/** + * Converts camel case props to snake case props. + * + * @template P - The type of the props object. + * @param {P} props - The props object to convert. + * @returns {P} - The converted props object. + */ export function convertCamelCaseProps

(props: P) { const isFrozen = Object.isFrozen(props) const newProps = isFrozen ? { ...props } : props diff --git a/yarn.lock b/yarn.lock index e82d2c40b58..27c509fe4ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3551,7 +3551,7 @@ __metadata: svgo: "npm:3.0.0" tar: "npm:6.1.11" traverse: "npm:0.6.6" - typescript: "npm:5.0.4" + typescript: "npm:5.2.2" vd-tool: "npm:4.0.2" wait-on: "npm:6.0.0" what-input: "npm:5.2.10" @@ -14059,7 +14059,7 @@ __metadata: stylelint-config-recommended: "npm:12.0.0" stylelint-config-standard-scss: "npm:9.0.0" svg-react-loader: "npm:0.4.6" - typescript: "npm:5.0.4" + typescript: "npm:5.2.2" unist-util-visit: "npm:^2" languageName: unknown linkType: soft @@ -33388,23 +33388,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:5.0.4": - version: 5.0.4 - resolution: "typescript@npm:5.0.4" +"typescript@npm:5.2.2": + version: 5.2.2 + resolution: "typescript@npm:5.2.2" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: e5c3adff09a138c0e27d13b5bb2b106ca17a162ffa945d66161669c265c65436309c5817358a2af1abb69d07440d358f8c1ed7cbb63a2c8680e19b9c268fe4ef + checksum: d65e50eb849bd21ff8677e5b9447f9c6e74777e346afd67754934264dcbf4bd59e7d2473f6062d9a015d66bd573311166357e3eb07fea0b52859cf9bb2b58555 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A5.0.4#optional!builtin": - version: 5.0.4 - resolution: "typescript@patch:typescript@npm%3A5.0.4#optional!builtin::version=5.0.4&hash=b5f058" +"typescript@patch:typescript@npm%3A5.2.2#optional!builtin": + version: 5.2.2 + resolution: "typescript@patch:typescript@npm%3A5.2.2#optional!builtin::version=5.2.2&hash=f3b441" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: b1b62606c7ec75efe9edc61e195d9e69f0440cac1bcd111dfa864f839255f0d9a7b79869f2823559c608826fc0c9894d2917ae4063e0aa06f5d0784a35170497 + checksum: f79cc2ba802c94c2b78dbb00d767a10adb67368ae764709737dc277273ec148aa4558033a03ce901406b35fddf4eac46dabc94a1e1d12d2587e2b9cfe5707b4a languageName: node linkType: hard