Skip to content

Commit 104fc5e

Browse files
committed
feat(Forms): default Field.InstallmentDate to days 1–28 with last day of month
Days 29–31 do not exist in every month (31 is missing from 5 months; 29/30 from February). Norwegian payment processing (Gjeldsbrevloven § 5; AvtaleGiro) pushes late-month due dates that land on weekends/holidays forward, which can roll charges into the next month for days near month end. 1–28 covers Norwegian paydays (12th state, 15th private, 25th retail). Month-end-payday customers (hourly workers, barnetrygd recipients) are served by the 'Last day of month' option, which the payment system resolves to the correct last day each month. - Default range: 1–31 → 1–28 - showLastDay default: false → true (29 options total) - days prop still allows any custom set - showLastDay={false} still hides the option - No pre-selected value (unchanged)
1 parent 3664f1e commit 104fc5e

6 files changed

Lines changed: 26 additions & 24 deletions

File tree

‎packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/InstallmentDate/Examples.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export const ConstrainedDays = () => {
3030
)
3131
}
3232

33-
export const WithLastDay = () => {
33+
export const WithoutLastDay = () => {
3434
return (
3535
<ComponentBox>
3636
<Field.InstallmentDate
37-
showLastDay
37+
showLastDay={false}
3838
onChange={(value) => console.log('onChange', value)}
3939
/>
4040
</ComponentBox>

‎packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/InstallmentDate/demos.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as Examples from './Examples'
88

99
### Default
1010

11-
All 31 days shown.
11+
Days 1–28 with "Last day of month".
1212

1313
<Examples.Default />
1414

@@ -22,11 +22,11 @@ Use the `days` prop to limit available options to specific days.
2222

2323
<Examples.ConstrainedDays />
2424

25-
### With last day of month
25+
### Without last day of month
2626

27-
Use `showLastDay` to append a "Last day of month" option.
27+
Use `showLastDay={false}` to hide the "Last day of month" option.
2828

29-
<Examples.WithLastDay />
29+
<Examples.WithoutLastDay />
3030

3131
### Constrained days with last day
3232

‎packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/InstallmentDate/info.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ render(<Field.InstallmentDate />)
1313

1414
`Field.InstallmentDate` is a dropdown-based field for selecting a day of the month, designed for recurring payment scenarios such as loan installments or standing orders.
1515

16-
By default it shows days 1–31. Use the `days` prop to constrain available options, and `showLastDay` to add a "Last day of month" option.
16+
By default it shows days 1–28 plus a "Last day of month" option. Days 29–31 are excluded because they do not exist in every month, and late-month dates can roll into the next month on weekends/holidays. The "Last day of month" option serves customers paid at month end. Use the `days` prop to override the available days, and `showLastDay={false}` to remove the last day option.
1717

1818
The value type is `number | 'last'`.
1919

‎packages/dnb-eufemia/src/extensions/forms/Field/InstallmentDate/InstallmentDate.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export type FieldInstallmentDateProps = Omit<
2828
size?: DropdownAllProps['size']
2929

3030
/**
31-
* Constrains which days are available for selection. When not provided, days 1–31 are shown.
31+
* Constrains which days are available for selection. When not provided, days 1–28 are shown.
3232
*/
3333
days?: number[]
3434

3535
/**
36-
* If set to `true`, a "Last day of month" option is appended to the list. Defaults to `false`.
36+
* If set to `true`, a "Last day of month" option is appended to the list. Defaults to `true`.
3737
*/
3838
showLastDay?: boolean
3939
}
@@ -73,13 +73,13 @@ function InstallmentDate(props: FieldInstallmentDateProps) {
7373
} = useFieldProps(preparedProps)
7474

7575
const data = useMemo(() => {
76-
const dayList = days ?? Array.from({ length: 31 }, (_, i) => i + 1)
76+
const dayList = days ?? Array.from({ length: 28 }, (_, i) => i + 1)
7777
const items = dayList.map((day) => ({
7878
selectedKey: String(day),
7979
content: String(day),
8080
}))
8181

82-
if (showLastDay) {
82+
if (showLastDay !== false) {
8383
items.push({
8484
selectedKey: 'last',
8585
content: lastDayLabel,

‎packages/dnb-eufemia/src/extensions/forms/Field/InstallmentDate/InstallmentDateDocs.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export const InstallmentDateProperties: PropertiesTableProps = {
1212
status: 'optional',
1313
},
1414
days: {
15-
doc: 'Constrains which days are available for selection. When not provided, days 1–31 are shown.',
15+
doc: 'Constrains which days are available for selection. When not provided, days 1\u201328 are shown.',
1616
type: 'number[]',
1717
status: 'optional',
1818
},
1919
showLastDay: {
20-
doc: 'If set to `true`, a "Last day of month" option is appended to the list. Defaults to `false`.',
20+
doc: 'If set to `true`, a "Last day of month" option is appended to the list. Defaults to `true`.',
2121
type: 'boolean',
2222
status: 'optional',
2323
},

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@ describe('Field.InstallmentDate', () => {
2020
expect(label).toHaveTextContent('Custom label')
2121
})
2222

23-
it('should render 31 options', () => {
23+
it('should render 29 options by default (28 days + last day)', () => {
2424
render(<Field.InstallmentDate />)
2525

26-
// Open dropdown
2726
const button = document.querySelector(
2827
'.dnb-dropdown__trigger'
2928
) as HTMLElement
3029
fireEvent.click(button)
3130

3231
const options = document.querySelectorAll('.dnb-drawer-list__option')
33-
expect(options).toHaveLength(31)
32+
expect(options).toHaveLength(29)
3433
})
3534

36-
it('should render options from 1 to 31', () => {
35+
it('should render days 1 to 28 plus last day label by default', () => {
3736
render(<Field.InstallmentDate />)
3837

3938
const button = document.querySelector(
@@ -44,7 +43,8 @@ describe('Field.InstallmentDate', () => {
4443
const options = document.querySelectorAll('.dnb-drawer-list__option')
4544
expect(options[0]).toHaveTextContent('1')
4645
expect(options[14]).toHaveTextContent('15')
47-
expect(options[30]).toHaveTextContent('31')
46+
expect(options[27]).toHaveTextContent('28')
47+
expect(options[28]).toHaveTextContent(nb.lastDayLabel)
4848
})
4949

5050
it('should display selected value', () => {
@@ -134,7 +134,9 @@ describe('Field.InstallmentDate', () => {
134134
})
135135

136136
it('should render only specified days when days prop is given', () => {
137-
render(<Field.InstallmentDate days={[1, 10, 15, 20]} />)
137+
render(
138+
<Field.InstallmentDate days={[1, 10, 15, 20]} showLastDay={false} />
139+
)
138140

139141
const button = document.querySelector(
140142
'.dnb-dropdown__trigger'
@@ -149,17 +151,17 @@ describe('Field.InstallmentDate', () => {
149151
expect(options[3]).toHaveTextContent('20')
150152
})
151153

152-
it('should show last day option when showLastDay is true', () => {
153-
render(<Field.InstallmentDate showLastDay />)
154+
it('should hide last day option when showLastDay is false', () => {
155+
render(<Field.InstallmentDate showLastDay={false} />)
154156

155157
const button = document.querySelector(
156158
'.dnb-dropdown__trigger'
157159
) as HTMLElement
158160
fireEvent.click(button)
159161

160162
const options = document.querySelectorAll('.dnb-drawer-list__option')
161-
expect(options).toHaveLength(32)
162-
expect(options[31]).toHaveTextContent(nb.lastDayLabel)
163+
expect(options).toHaveLength(28)
164+
expect(options[27]).toHaveTextContent('28')
163165
})
164166

165167
it('should show last day option with constrained days', () => {
@@ -178,7 +180,7 @@ describe('Field.InstallmentDate', () => {
178180
})
179181

180182
it('should display last day label when value is "last"', () => {
181-
render(<Field.InstallmentDate value="last" showLastDay />)
183+
render(<Field.InstallmentDate value="last" />)
182184

183185
const text = document.querySelector('.dnb-dropdown__text__inner')
184186
expect(text).toHaveTextContent(nb.lastDayLabel)

0 commit comments

Comments
 (0)