Skip to content

Commit 18d23d4

Browse files
authored
feat(SelectCountry): add size property (#4595)
1 parent b82ffff commit 18d23d4

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

packages/dnb-eufemia/src/extensions/forms/Field/SelectCountry/SelectCountry.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import FieldBlock, {
1717
FieldBlockWidth,
1818
} from '../../FieldBlock'
1919
import useTranslation from '../../hooks/useTranslation'
20+
import { AutocompleteAllProps } from '../../../../components/autocomplete/Autocomplete'
2021

2122
export type CountryFilterSet =
2223
| 'Scandinavia'
@@ -50,6 +51,11 @@ export type Props = FieldPropsWithExtraValue<
5051
* The width of the component.
5152
*/
5253
width?: FieldBlockWidth
54+
55+
/**
56+
* The size of the component.
57+
*/
58+
size?: AutocompleteAllProps['size']
5359
}
5460

5561
function SelectCountry(props: Props) {
@@ -112,6 +118,7 @@ function SelectCountry(props: Props) {
112118
countries: ccFilter = 'Prioritized',
113119
hasError,
114120
disabled,
121+
size,
115122
value,
116123
width,
117124
htmlAttributes,
@@ -244,6 +251,7 @@ function SelectCountry(props: Props) {
244251
data={dataRef.current}
245252
value={typeof value === 'string' ? value : null}
246253
disabled={disabled}
254+
size={size}
247255
on_show={fillData}
248256
on_focus={onFocusHandler}
249257
on_blur={handleBlur}

packages/dnb-eufemia/src/extensions/forms/Field/SelectCountry/SelectCountryDocs.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { PropertiesTableProps } from '../../../../shared/types'
22
import { getFieldEventsWithTypes } from '../FieldDocs'
3+
import { autocompleteProperties } from '../../../../components/autocomplete/AutocompleteDocs'
34

45
export const SelectCountryProperties: PropertiesTableProps = {
56
countries: {
@@ -12,6 +13,7 @@ export const SelectCountryProperties: PropertiesTableProps = {
1213
type: 'function',
1314
status: 'optional',
1415
},
16+
size: autocompleteProperties.size,
1517
}
1618

1719
export const SelectCountryGeneralEvents = getFieldEventsWithTypes(

packages/dnb-eufemia/src/extensions/forms/Field/SelectCountry/__tests__/SelectCountry.test.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ describe('Field.SelectCountry', () => {
1515
expect(document.querySelector('input')).toBeInTheDocument()
1616
})
1717

18+
it('should support size', () => {
19+
render(<Field.SelectCountry size="large" />)
20+
21+
const autocompleteElement: HTMLInputElement = document.querySelector(
22+
'.dnb-autocomplete'
23+
)
24+
expect(autocompleteElement.classList).toContain(
25+
'dnb-autocomplete--large'
26+
)
27+
28+
const selectCountryElement: HTMLInputElement = document.querySelector(
29+
'.dnb-forms-field-select-country'
30+
)
31+
expect(selectCountryElement.classList).toContain(
32+
'dnb-forms-field-block--label-height-large'
33+
)
34+
})
35+
1836
it('should return correct value onChange event', () => {
1937
const onChange = jest.fn()
2038
const onBlur = jest.fn()

0 commit comments

Comments
 (0)