@itwin/itwinui-react 2.12.5 → 2.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import type { TimePickerProps } from '../TimePicker/index.js';
3
+ export declare type DatePickerLocalizedNames = {
4
+ [key in 'months' | 'shortDays' | 'days']: string[];
5
+ };
3
6
  /**
4
7
  * Generate localized months and days strings using `Intl.DateTimeFormat` for passed locale to use in DatePicker component.
5
8
  * If locale is not passed, browser locale will be used.
6
9
  */
7
- export declare const generateLocalizedStrings: (locale?: string) => {
8
- months: string[];
9
- shortDays: string[];
10
- days: string[];
11
- };
10
+ export declare const generateLocalizedStrings: (locale?: string) => DatePickerLocalizedNames;
12
11
  export declare type DateRangePickerProps = {
13
12
  /**
14
13
  * Enable date range support.
@@ -42,9 +41,7 @@ export declare type DatePickerProps = {
42
41
  * Pass localized week days (start from sunday) and months.
43
42
  * Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
44
43
  */
45
- localizedNames?: {
46
- [key in 'months' | 'shortDays' | 'days']: string[];
47
- };
44
+ localizedNames?: DatePickerLocalizedNames;
48
45
  /**
49
46
  * Set focus on selected day or today.
50
47
  * @default false
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { LabeledInputProps } from '../../../LabeledInput/index.js';
3
+ import type { DatePickerLocalizedNames } from '../../../DatePicker/DatePicker.js';
3
4
  export declare type DatePickerInputProps = {
4
5
  date?: Date;
5
6
  onChange: (date?: Date) => void;
@@ -13,6 +14,10 @@ export declare type DatePickerInputProps = {
13
14
  * The 'to' date for the 'from' DatePickerInput or the 'from' date for the 'to' DatePickerInput
14
15
  */
15
16
  selectedDate?: Date;
17
+ /**
18
+ * Months, short days and days localized names for DatePicker
19
+ */
20
+ localizedNames?: DatePickerLocalizedNames;
16
21
  } & Omit<LabeledInputProps, 'value' | 'onChange' | 'svgIcon' | 'displayStyle'>;
17
22
  declare const DatePickerInput: (props: DatePickerInputProps) => JSX.Element;
18
23
  export default DatePickerInput;
@@ -8,7 +8,7 @@ import { LabeledInput } from '../../../LabeledInput/index.js';
8
8
  import { DatePicker } from '../../../DatePicker/index.js';
9
9
  import { IconButton } from '../../../Buttons/index.js';
10
10
  const DatePickerInput = (props) => {
11
- const { onChange, date, parseInput, formatDate, isFromOrTo, selectedDate, ...rest } = props;
11
+ const { onChange, date, parseInput, formatDate, isFromOrTo, selectedDate, localizedNames, ...rest } = props;
12
12
  const isDateDisabled = (date) => {
13
13
  if (isFromOrTo === 'to') {
14
14
  return isBefore(date, selectedDate);
@@ -43,7 +43,7 @@ const DatePickerInput = (props) => {
43
43
  onChange(parsedDate);
44
44
  }
45
45
  }, [onChange, parseInput]);
46
- return (React.createElement(Popover, { content: React.createElement(DatePicker, { date: date, onChange: onDateSelected, setFocus: true, isDateDisabled: isDateDisabled }), placement: 'bottom', visible: isVisible, onClickOutside: (_, e) => {
46
+ return (React.createElement(Popover, { content: React.createElement(DatePicker, { date: date, onChange: onDateSelected, setFocus: true, isDateDisabled: isDateDisabled, localizedNames: localizedNames }), placement: 'bottom', visible: isVisible, onClickOutside: (_, e) => {
47
47
  var _a;
48
48
  if (!((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
49
49
  close();
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import type { FilterButtonBarTranslation } from '../FilterButtonBar.js';
3
3
  import type { TableFilterProps } from '../types.js';
4
+ import type { DatePickerLocalizedNames } from '../../../DatePicker/DatePicker.js';
4
5
  export declare type DateRangeTranslation = {
5
6
  from: string;
6
7
  to: string;
8
+ datePicker?: DatePickerLocalizedNames;
7
9
  };
8
10
  export declare type DateRangeFilterProps<T extends Record<string, unknown>> = TableFilterProps<T> & {
9
11
  formatDate?: (date: Date) => string;
@@ -58,7 +58,7 @@ export const DateRangeFilter = (props) => {
58
58
  }
59
59
  };
60
60
  return (React.createElement(BaseFilter, null,
61
- React.createElement(DatePickerInput, { label: translatedStrings.from, date: from, onChange: onFromChange, formatDate: formatDate, parseInput: parseInput, onKeyDown: onKeyDown, placeholder: placeholder, selectedDate: to, isFromOrTo: 'from', setFocus: true }),
62
- React.createElement(DatePickerInput, { label: translatedStrings.to, date: to, onChange: onToChange, formatDate: formatDate, parseInput: parseInput, onKeyDown: onKeyDown, placeholder: placeholder, selectedDate: from, isFromOrTo: 'to' }),
61
+ React.createElement(DatePickerInput, { label: translatedStrings.from, date: from, onChange: onFromChange, formatDate: formatDate, parseInput: parseInput, onKeyDown: onKeyDown, placeholder: placeholder, selectedDate: to, isFromOrTo: 'from', localizedNames: translatedStrings.datePicker, setFocus: true }),
62
+ React.createElement(DatePickerInput, { label: translatedStrings.to, date: to, onChange: onToChange, formatDate: formatDate, parseInput: parseInput, onKeyDown: onKeyDown, placeholder: placeholder, selectedDate: from, isFromOrTo: 'to', localizedNames: translatedStrings.datePicker }),
63
63
  React.createElement(FilterButtonBar, { setFilter: () => setFilter([from, to]), clearFilter: clearFilter, translatedLabels: translatedLabels })));
64
64
  };