superdesk-ui-framework 4.0.43 → 4.0.45

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.
@@ -11,6 +11,7 @@ import {Button} from './Button';
11
11
  import {getWeekStartByLocale} from 'weekstart';
12
12
  import {getMonthNames, getWeekdayNames} from '@sourcefabric/common';
13
13
  import {localization} from '../localization';
14
+ import {assertNever} from '../helpers';
14
15
 
15
16
  interface IDatePickerBase extends IInputWrapper {
16
17
  dateFormat: string; // a combination of YYYY, MM, and DD with a custom separator e.g. 'MM/DD/YYYY'
@@ -19,9 +20,7 @@ interface IDatePickerBase extends IInputWrapper {
19
20
  // for example [{label: 'tomorrow', days: 1}, {label: 'yesterday', days: -1}]
20
21
  headerButtonBar?: Array<{days: number, label: string}>;
21
22
 
22
- locale?: {
23
- code: string;
24
- };
23
+ locale?: {type: 'code-only', code: string} | {type: 'full', payload: Omit<LocaleSettings, 'today' | 'clear'>};
25
24
 
26
25
  hideClearButton?: boolean;
27
26
  }
@@ -158,6 +157,22 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
158
157
  );
159
158
  }
160
159
 
160
+ const locale: LocaleSettings | undefined = (() => {
161
+ if (this.props.locale == null) {
162
+ return undefined;
163
+ } else if (this.props.locale.type === 'code-only') {
164
+ return getDatePickerLocale(this.props.locale.code);
165
+ } else if (this.props.locale.type === 'full') {
166
+ return {
167
+ ...this.props.locale.payload,
168
+ today: localization.translations.today,
169
+ clear: localization.translations.clear,
170
+ } satisfies LocaleSettings;
171
+ } else {
172
+ return assertNever(this.props.locale);
173
+ }
174
+ })();
175
+
161
176
  const showClearButton = this.props.required === true
162
177
  ? false
163
178
  : this.props.hideClearButton !== true;
@@ -219,7 +234,7 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
219
234
  this.setState({value: event.value, valid: false});
220
235
  }
221
236
  }}
222
- locale={getDatePickerLocale(this.props.locale?.code)}
237
+ locale={locale}
223
238
  dateFormat={this.props.dateFormat.replace('YYYY', 'yy').replace('MM', 'mm').replace('DD', 'dd')}
224
239
  showIcon={true}
225
240
  icon="icon-calendar"
@@ -25,10 +25,6 @@ interface IProps<T> {
25
25
 
26
26
  export class TreeSelectItem<T> extends React.Component<IProps<T>> {
27
27
  render() {
28
- const ariaLabel = this.props.parentCategory !== undefined
29
- ? `${this.props.getLabel(this.props.option.value)}, parent ${this.props.parentCategory}`
30
- : this.props.getLabel(this.props.option.value);
31
-
32
28
  return (
33
29
  <li
34
30
  className='suggestion-item suggestion-item--multi-select'
@@ -55,7 +51,7 @@ export class TreeSelectItem<T> extends React.Component<IProps<T>> {
55
51
  }}
56
52
  disabled={this.props.disabledItem}
57
53
  data-test-id="option"
58
- role='treeItem'
54
+ role='treeitem'
59
55
  aria-selected={this.props.selectedItem === true}
60
56
  aria-disabled={this.props.disabledItem === true}
61
57
  >
@@ -83,7 +79,6 @@ export class TreeSelectItem<T> extends React.Component<IProps<T>> {
83
79
  }
84
80
  : undefined
85
81
  }
86
- aria-label={ariaLabel}
87
82
  >
88
83
  {this.props.optionTemplate
89
84
  ? this.props.optionTemplate(this.props.option.value)