superdesk-ui-framework 4.0.41 → 4.0.43

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.
Files changed (174) hide show
  1. package/app-typescript/components/DatePicker.tsx +37 -27
  2. package/app-typescript/components/DurationInput.tsx +1 -1
  3. package/app-typescript/components/Form/InputWrapper.tsx +6 -2
  4. package/app-typescript/index.ts +1 -1
  5. package/app-typescript/localization.tsx +17 -0
  6. package/dist/examples.bundle.js +79384 -58003
  7. package/dist/superdesk-ui.bundle.js +76267 -55966
  8. package/dist/vendor.bundle.js +20 -20
  9. package/package.json +7 -5
  10. package/react/components/Alert.js +17 -7
  11. package/react/components/Autocomplete.js +18 -9
  12. package/react/components/Badge.js +17 -7
  13. package/react/components/Button.js +17 -7
  14. package/react/components/ButtonGroup.js +17 -7
  15. package/react/components/Card.js +17 -7
  16. package/react/components/Carousel.js +17 -7
  17. package/react/components/CheckButtonGroup.js +17 -7
  18. package/react/components/CheckGroup.js +17 -7
  19. package/react/components/Checkbox.js +17 -7
  20. package/react/components/CheckboxButton.js +17 -7
  21. package/react/components/ContentDivider.js +17 -7
  22. package/react/components/CreateButton.js +17 -7
  23. package/react/components/DatePicker.d.ts +4 -3
  24. package/react/components/DatePicker.js +48 -23
  25. package/react/components/DateTimePicker.js +17 -7
  26. package/react/components/Divider.js +17 -7
  27. package/react/components/DonutChart.js +17 -7
  28. package/react/components/DragHandle.js +17 -7
  29. package/react/components/DragHandleDots.js +17 -7
  30. package/react/components/DropZone.js +17 -7
  31. package/react/components/Dropdown.js +17 -7
  32. package/react/components/DropdownFirst.js +17 -7
  33. package/react/components/DurationInput.js +20 -10
  34. package/react/components/EmptyState.js +17 -7
  35. package/react/components/Form/FormGroup.js +17 -7
  36. package/react/components/Form/FormItem.js +17 -7
  37. package/react/components/Form/FormLabel.js +17 -7
  38. package/react/components/Form/FormRow.js +17 -7
  39. package/react/components/Form/FormRowNew.js +17 -7
  40. package/react/components/Form/FormText.js +17 -7
  41. package/react/components/Form/InputBase.js +18 -9
  42. package/react/components/Form/InputNew.js +18 -9
  43. package/react/components/Form/InputWrapper.d.ts +1 -0
  44. package/react/components/Form/InputWrapper.js +19 -10
  45. package/react/components/FormLabel.js +17 -7
  46. package/react/components/GridItem.js +17 -7
  47. package/react/components/GridList.js +17 -7
  48. package/react/components/HeadingText.js +17 -7
  49. package/react/components/HelloWorld.js +17 -7
  50. package/react/components/Icon.js +17 -7
  51. package/react/components/IconButton.js +17 -7
  52. package/react/components/IconLabel.js +17 -7
  53. package/react/components/IconPicker.js +17 -7
  54. package/react/components/IllustrationButton.js +17 -7
  55. package/react/components/Input.js +17 -7
  56. package/react/components/Label.js +17 -7
  57. package/react/components/Layouts/AuthorinInnerSideBar.js +17 -7
  58. package/react/components/Layouts/AuthoringContainer.js +17 -7
  59. package/react/components/Layouts/AuthoringFrame.js +17 -7
  60. package/react/components/Layouts/AuthoringFrameContainer.js +17 -7
  61. package/react/components/Layouts/AuthoringFrameLeftBar.js +17 -7
  62. package/react/components/Layouts/AuthoringFrameMain.js +17 -7
  63. package/react/components/Layouts/AuthoringFrameNavBar.js +17 -7
  64. package/react/components/Layouts/AuthoringFrameOverlay.js +17 -7
  65. package/react/components/Layouts/AuthoringFrameRightBar.js +17 -7
  66. package/react/components/Layouts/AuthoringFrameSidePanel.js +17 -7
  67. package/react/components/Layouts/AuthoringFrameSidePanelOverlay.js +17 -7
  68. package/react/components/Layouts/AuthoringInnerBody.js +17 -7
  69. package/react/components/Layouts/AuthoringInnerHeader.js +17 -7
  70. package/react/components/Layouts/AuthoringMain.js +17 -7
  71. package/react/components/Layouts/AuthoringMainContainer.js +17 -7
  72. package/react/components/Layouts/AuthoringMainContent.js +17 -7
  73. package/react/components/Layouts/AuthoringMainToolBar.js +17 -7
  74. package/react/components/Layouts/BottomBarAction.js +17 -7
  75. package/react/components/Layouts/Container.js +17 -7
  76. package/react/components/Layouts/ContentSplitter.js +17 -7
  77. package/react/components/Layouts/CoreLayout.js +17 -7
  78. package/react/components/Layouts/CoreLayoutContainer.js +17 -7
  79. package/react/components/Layouts/CoreLayoutFooter.js +17 -7
  80. package/react/components/Layouts/CoreLayoutMain.js +17 -7
  81. package/react/components/Layouts/CoreLayoutOverlay.js +17 -7
  82. package/react/components/Layouts/CoreLayoutSlideInMenu.js +17 -7
  83. package/react/components/Layouts/CoreLayoutTopMenu.js +17 -7
  84. package/react/components/Layouts/HamburgerButton.js +17 -7
  85. package/react/components/Layouts/HeaderPanel.js +17 -7
  86. package/react/components/Layouts/Layout.js +17 -7
  87. package/react/components/Layouts/LayoutContainer.js +17 -7
  88. package/react/components/Layouts/LeftPanel.js +17 -7
  89. package/react/components/Layouts/MainMenu.js +17 -7
  90. package/react/components/Layouts/MainPanel.js +17 -7
  91. package/react/components/Layouts/NotificationPanel.js +17 -7
  92. package/react/components/Layouts/OverlayPanel.js +17 -7
  93. package/react/components/Layouts/PageLayout.js +17 -7
  94. package/react/components/Layouts/Panel.js +17 -7
  95. package/react/components/Layouts/RightPanel.js +17 -7
  96. package/react/components/LeftMenu.js +17 -7
  97. package/react/components/ListItemLoader.js +17 -7
  98. package/react/components/Lists/BoxedList.js +17 -7
  99. package/react/components/Lists/CalendarWeekDayItem.js +17 -7
  100. package/react/components/Lists/ContentList.js +17 -7
  101. package/react/components/Lists/SimpleList.js +17 -7
  102. package/react/components/Lists/TableList.js +17 -7
  103. package/react/components/Loader.js +17 -7
  104. package/react/components/Menu.js +17 -7
  105. package/react/components/Modal.js +17 -7
  106. package/react/components/MultiSelect.js +17 -7
  107. package/react/components/NavButton.js +17 -7
  108. package/react/components/Navigation/BottomNav.js +17 -7
  109. package/react/components/Navigation/QuickNavBar.js +17 -7
  110. package/react/components/Navigation/SideBarMenu.js +17 -7
  111. package/react/components/Navigation/SideBarTabs.js +17 -7
  112. package/react/components/Popover.js +17 -7
  113. package/react/components/PropsList.js +17 -7
  114. package/react/components/RadioButtonGroup.js +17 -7
  115. package/react/components/RadioGroup.js +17 -7
  116. package/react/components/ResizablePanels.js +17 -7
  117. package/react/components/Rotate.js +17 -7
  118. package/react/components/SearchBar.js +17 -7
  119. package/react/components/Select.js +17 -7
  120. package/react/components/SelectGrid.js +17 -7
  121. package/react/components/SelectPreview.js +17 -7
  122. package/react/components/SelectWithTemplate.js +17 -7
  123. package/react/components/ShowPopup.js +19 -9
  124. package/react/components/SingleAndDoubleClickFunction.d.ts +0 -1
  125. package/react/components/SingleAndDoubleClickFunction.js +1 -2
  126. package/react/components/Skeleton.js +17 -7
  127. package/react/components/SlidingToolbar.js +17 -7
  128. package/react/components/Spinner.js +17 -7
  129. package/react/components/StrechBar.js +17 -7
  130. package/react/components/SubNav.js +17 -7
  131. package/react/components/SvgIconIllustration.js +17 -7
  132. package/react/components/Switch.js +17 -7
  133. package/react/components/SwitchGroup.js +17 -7
  134. package/react/components/TabCustom.js +17 -7
  135. package/react/components/TabList.js +17 -7
  136. package/react/components/Tag.js +17 -7
  137. package/react/components/TagInput.js +17 -7
  138. package/react/components/Text/Heading.js +17 -7
  139. package/react/components/Text/Text.js +17 -7
  140. package/react/components/Text/Time.js +17 -7
  141. package/react/components/ThemeSelector.js +17 -7
  142. package/react/components/TimePicker.js +17 -7
  143. package/react/components/TimePickerV2.js +17 -7
  144. package/react/components/Toast.js +17 -7
  145. package/react/components/ToastMessage.js +17 -7
  146. package/react/components/ToastText.js +17 -7
  147. package/react/components/ToastWrapper.js +17 -7
  148. package/react/components/ToggleBox/CustomHeaderToggleBox.js +18 -9
  149. package/react/components/ToggleBox/SimpleToggleBox.js +18 -9
  150. package/react/components/ToggleBox/index.js +17 -7
  151. package/react/components/Tooltip.js +17 -7
  152. package/react/components/TreeMenu.js +17 -7
  153. package/react/components/TreeSelect/TreeSelect.js +17 -7
  154. package/react/components/TreeSelect/TreeSelectItem.js +19 -9
  155. package/react/components/TreeSelect/TreeSelectPill.js +17 -7
  156. package/react/components/WithPagination.js +19 -9
  157. package/react/components/WithPopover.js +17 -7
  158. package/react/components/WithPortal.js +19 -9
  159. package/react/components/WithSizeObserver.js +17 -7
  160. package/react/components/_Positioner.js +17 -7
  161. package/react/components/avatar/avatar-action-add.js +17 -7
  162. package/react/components/avatar/avatar-group.js +17 -7
  163. package/react/components/avatar/avatar-image.js +17 -7
  164. package/react/components/avatar/avatar-number.js +17 -7
  165. package/react/components/avatar/avatar-placeholder.js +17 -7
  166. package/react/components/avatar/avatar-text.js +17 -7
  167. package/react/components/avatar/avatar-wrapper.js +17 -7
  168. package/react/components/avatar/avatar.js +17 -7
  169. package/react/helpers.js +3 -4
  170. package/react/index.d.ts +1 -1
  171. package/react/index.js +3 -1
  172. package/react/localization.d.ts +9 -0
  173. package/react/localization.js +13 -0
  174. package/react/zIndex.js +2 -2
@@ -8,8 +8,9 @@ import nextId from "react-id-generator";
8
8
  import { InputWrapper } from './Form';
9
9
  import { IInputWrapper } from './Form/InputWrapper';
10
10
  import {Button} from './Button';
11
-
12
- export type DatePickerLocaleSettings = Omit<LocaleSettings, 'today' | 'clear'>;
11
+ import {getWeekStartByLocale} from 'weekstart';
12
+ import {getMonthNames, getWeekdayNames} from '@sourcefabric/common';
13
+ import {localization} from '../localization';
13
14
 
14
15
  interface IDatePickerBase extends IInputWrapper {
15
16
  dateFormat: string; // a combination of YYYY, MM, and DD with a custom separator e.g. 'MM/DD/YYYY'
@@ -18,21 +19,9 @@ interface IDatePickerBase extends IInputWrapper {
18
19
  // for example [{label: 'tomorrow', days: 1}, {label: 'yesterday', days: -1}]
19
20
  headerButtonBar?: Array<{days: number, label: string}>;
20
21
 
21
- // ability to provide localisation. for example (see https://primefaces.org/primereact/showcase/#/calendar):
22
- /*
23
- locale={{
24
- firstDayOfWeek: 1,
25
- dayNames: ["domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"],
26
- dayNamesShort: ["dom", "lun", "mar", "mié", "jue", "vie", "sáb"],
27
- dayNamesMin: ["D", "L", "M", "X", "J", "V", "S"],
28
- monthNames: [
29
- "enero", "febrero", "marzo", "abril", "mayo", "junio",
30
- "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"
31
- ],
32
- monthNamesShort: ["ene", "feb", "mar", "abr", "may", "jun", "jul", "ago", "sep", "oct", "nov", "dic"],
33
- }}
34
- */
35
- locale?: DatePickerLocaleSettings;
22
+ locale?: {
23
+ code: string;
24
+ };
36
25
 
37
26
  hideClearButton?: boolean;
38
27
  }
@@ -81,6 +70,36 @@ function parseToPrimeReactCalendarFormat(value: IDatePicker['value']): CalendarP
81
70
  return value === null ? undefined : value;
82
71
  }
83
72
 
73
+ function getDatePickerLocale(code?: string): LocaleSettings {
74
+ const localeCode = code ?? 'en-US';
75
+ const firstDayOfWeek = getWeekStartByLocale(localeCode);
76
+
77
+ const dayNames: {long: Array<string>; short: Array<string>; narrow: Array<string>} = {
78
+ long: [],
79
+ short: [],
80
+ narrow: [],
81
+ };
82
+
83
+ for (const weekday of getWeekdayNames(0, localeCode)) {
84
+ dayNames.long.push(weekday.nameLong);
85
+ dayNames.short.push(weekday.nameShort);
86
+ dayNames.narrow.push(weekday.nameNarrow);
87
+ }
88
+
89
+ const locale: LocaleSettings = {
90
+ firstDayOfWeek: firstDayOfWeek,
91
+ dayNames: dayNames.long,
92
+ dayNamesShort: dayNames.short,
93
+ dayNamesMin: dayNames.short, // using short instead of narrow on purpose
94
+ monthNames: getMonthNames(localeCode, 'long'),
95
+ monthNamesShort: getMonthNames(localeCode, 'short'),
96
+ today: localization.translations.today,
97
+ clear: localization.translations.clear,
98
+ };
99
+
100
+ return locale;
101
+ }
102
+
84
103
  export class DatePicker extends React.PureComponent<IDatePicker, IState> {
85
104
  private instance: IPrivatePrimeReactCalendarApi | undefined;
86
105
  hidePopupOnScroll: () => void;
@@ -128,15 +147,6 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
128
147
  }
129
148
 
130
149
  render() {
131
- let locale: LocaleSettings | undefined;
132
- if (this.props.locale != null) {
133
- locale = {
134
- ...this.props.locale,
135
- today: 'today',
136
- clear: 'clear',
137
- };
138
- }
139
-
140
150
  if (this.props.preview) {
141
151
  return (
142
152
  // We have to do type assertion here because we wrap primereact's component using
@@ -209,7 +219,7 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
209
219
  this.setState({value: event.value, valid: false});
210
220
  }
211
221
  }}
212
- locale={locale}
222
+ locale={getDatePickerLocale(this.props.locale?.code)}
213
223
  dateFormat={this.props.dateFormat.replace('YYYY', 'yy').replace('MM', 'mm').replace('DD', 'dd')}
214
224
  showIcon={true}
215
225
  icon="icon-calendar"
@@ -85,7 +85,7 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
85
85
  }
86
86
  if (Number(this.minuteRef.current.value) < 0) {
87
87
  this.setState({
88
- hours: this.zeroPad(Number(this.state.hours)) > 0
88
+ hours: parseInt(`${this.zeroPad(Number(this.state.hours))}`, 10) > 0
89
89
  ? this.zeroPad(Number(this.state.hours) - 1)
90
90
  : this.zeroPad(Number(this.state.hours)),
91
91
  minutes: 59,
@@ -28,7 +28,7 @@ export interface IInputWrapper extends IInputCommon {
28
28
 
29
29
  inputWrapper?: {
30
30
  kind: 'custom'; // added to allow union types later
31
- component: React.ComponentType<{label: string; input: React.ReactNode}>;
31
+ component: React.ComponentType<{label: string; input: React.ReactNode; 'data-test-id'?: string}>;
32
32
  };
33
33
  }
34
34
 
@@ -59,7 +59,11 @@ export class InputWrapper extends React.Component<IProps, IState> {
59
59
  const Component = this.props.inputWrapper.component;
60
60
 
61
61
  return (
62
- <Component input={this.props.children} label={this.props.label ?? ''} />
62
+ <Component
63
+ input={this.props.children}
64
+ label={this.props.label ?? ''}
65
+ data-test-id={this.props['data-test-id']}
66
+ />
63
67
  );
64
68
  }
65
69
 
@@ -27,7 +27,6 @@ export { getDurationString } from './components/DurationInput';
27
27
  export { DatePicker } from './components/DatePicker';
28
28
  export { DateTimePicker } from './components/DateTimePicker';
29
29
  export { DatePickerISO } from './components/DatePicker';
30
- export { DatePickerLocaleSettings } from './components/DatePicker';
31
30
  export { TimePicker } from './components/TimePicker';
32
31
  export { TimePickerV2 } from './components/TimePickerV2';
33
32
  export { FormLabel } from './components/FormLabel';
@@ -109,6 +108,7 @@ export { DragHandleDots } from './components/DragHandleDots';
109
108
  export { DragHandle } from './components/DragHandle';
110
109
  export {CalendarWeekDayItem, WeeklyCalendarGrid, WeeklyCalendarGridItem} from './components/Lists/CalendarWeekDayItem';
111
110
  export { getTextColor } from './helpers';
111
+ export { setupLocalization } from './localization';
112
112
 
113
113
  // declare non-typescript exports to prevent errors
114
114
  export declare const ToggleBoxNext: any;
@@ -0,0 +1,17 @@
1
+ interface ILocalization {
2
+ translations: {
3
+ today: string;
4
+ clear: string;
5
+ };
6
+ }
7
+
8
+ export let localization: ILocalization = {
9
+ translations: {
10
+ today: 'today',
11
+ clear: 'clear',
12
+ },
13
+ };
14
+
15
+ export function setupLocalization(val: ILocalization) {
16
+ localization = val;
17
+ }