Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Supported localization for numbers. #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/components/duet-date-picker/date-picker-day.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { h, FunctionalComponent } from "@stencil/core"
import { isEqual, isEqualMonth } from "./date-utils"
import { DuetLocalizedText } from "./date-localization"

export type DatePickerDayProps = {
focusedDay: Date
Expand All @@ -12,6 +13,7 @@ export type DatePickerDayProps = {
onDaySelect: (event: MouseEvent, day: Date) => void
onKeyboardNavigation: (event: KeyboardEvent) => void
focusedDayRef?: (element: HTMLElement) => void
localization: DuetLocalizedText
}

export const DatePickerDay: FunctionalComponent<DatePickerDayProps> = ({
Expand All @@ -25,6 +27,7 @@ export const DatePickerDay: FunctionalComponent<DatePickerDayProps> = ({
inRange,
isSelected,
dateFormatter,
localization,
}) => {
const isToday = isEqual(day, today)
const isMonth = isEqualMonth(day, focusedDay)
Expand Down Expand Up @@ -57,7 +60,7 @@ export const DatePickerDay: FunctionalComponent<DatePickerDayProps> = ({
}
}}
>
<span aria-hidden="true">{day.getDate()}</span>
<span aria-hidden="true">{Number(day.getDate()).toLocaleString(localization.locale)}</span>
<span class="duet-date__vhidden">{dateFormatter.format(day)}</span>
</button>
)
Expand Down
1 change: 1 addition & 0 deletions src/components/duet-date-picker/date-picker-month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const DatePickerMonth: FunctionalComponent<DatePickerMonthProps> = ({
dateFormatter={dateFormatter}
onKeyboardNavigation={onKeyboardNavigation}
focusedDayRef={focusedDayRef}
localization={localization}
/>
</td>
))}
Expand Down
10 changes: 7 additions & 3 deletions src/components/duet-date-picker/duet-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,17 @@ export class DuetDatePicker implements ComponentInterface {
<div class="duet-date__select">
<select id={this.yearSelectId} class="duet-date__select--year" onChange={this.handleYearSelect}>
{range(minYear, maxYear).map(year => (
<option key={year} selected={year === focusedYear}>
{year}
<option key={year} selected={year === focusedYear} value={year}>
{Number(year).toLocaleString(this.localization.locale, { useGrouping: false })}
</option>
))}
</select>
<div class="duet-date__select-label" aria-hidden="true">
<span>{this.focusedDay.getFullYear()}</span>
<span>
{Number(this.focusedDay.getFullYear()).toLocaleString(this.localization.locale, {
useGrouping: false,
})}
</span>
<svg
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
Expand Down