superdesk-ui-framework 4.0.42 → 4.0.44

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 (172) hide show
  1. package/app-typescript/components/DatePicker.tsx +51 -26
  2. package/app-typescript/components/DurationInput.tsx +1 -1
  3. package/app-typescript/index.ts +1 -1
  4. package/app-typescript/localization.tsx +17 -0
  5. package/dist/examples.bundle.js +78790 -57384
  6. package/dist/superdesk-ui.bundle.js +76325 -55999
  7. package/dist/vendor.bundle.js +20 -20
  8. package/package.json +7 -5
  9. package/react/components/Alert.js +17 -7
  10. package/react/components/Autocomplete.js +18 -9
  11. package/react/components/Badge.js +17 -7
  12. package/react/components/Button.js +17 -7
  13. package/react/components/ButtonGroup.js +17 -7
  14. package/react/components/Card.js +17 -7
  15. package/react/components/Carousel.js +17 -7
  16. package/react/components/CheckButtonGroup.js +17 -7
  17. package/react/components/CheckGroup.js +17 -7
  18. package/react/components/Checkbox.js +17 -7
  19. package/react/components/CheckboxButton.js +17 -7
  20. package/react/components/ContentDivider.js +17 -7
  21. package/react/components/CreateButton.js +17 -7
  22. package/react/components/DatePicker.d.ts +7 -2
  23. package/react/components/DatePicker.js +61 -11
  24. package/react/components/DateTimePicker.js +17 -7
  25. package/react/components/Divider.js +17 -7
  26. package/react/components/DonutChart.js +17 -7
  27. package/react/components/DragHandle.js +17 -7
  28. package/react/components/DragHandleDots.js +17 -7
  29. package/react/components/DropZone.js +17 -7
  30. package/react/components/Dropdown.js +17 -7
  31. package/react/components/DropdownFirst.js +17 -7
  32. package/react/components/DurationInput.js +20 -10
  33. package/react/components/EmptyState.js +17 -7
  34. package/react/components/Form/FormGroup.js +17 -7
  35. package/react/components/Form/FormItem.js +17 -7
  36. package/react/components/Form/FormLabel.js +17 -7
  37. package/react/components/Form/FormRow.js +17 -7
  38. package/react/components/Form/FormRowNew.js +17 -7
  39. package/react/components/Form/FormText.js +17 -7
  40. package/react/components/Form/InputBase.js +18 -9
  41. package/react/components/Form/InputNew.js +18 -9
  42. package/react/components/Form/InputWrapper.js +18 -9
  43. package/react/components/FormLabel.js +17 -7
  44. package/react/components/GridItem.js +17 -7
  45. package/react/components/GridList.js +17 -7
  46. package/react/components/HeadingText.js +17 -7
  47. package/react/components/HelloWorld.js +17 -7
  48. package/react/components/Icon.js +17 -7
  49. package/react/components/IconButton.js +17 -7
  50. package/react/components/IconLabel.js +17 -7
  51. package/react/components/IconPicker.js +17 -7
  52. package/react/components/IllustrationButton.js +17 -7
  53. package/react/components/Input.js +17 -7
  54. package/react/components/Label.js +17 -7
  55. package/react/components/Layouts/AuthorinInnerSideBar.js +17 -7
  56. package/react/components/Layouts/AuthoringContainer.js +17 -7
  57. package/react/components/Layouts/AuthoringFrame.js +17 -7
  58. package/react/components/Layouts/AuthoringFrameContainer.js +17 -7
  59. package/react/components/Layouts/AuthoringFrameLeftBar.js +17 -7
  60. package/react/components/Layouts/AuthoringFrameMain.js +17 -7
  61. package/react/components/Layouts/AuthoringFrameNavBar.js +17 -7
  62. package/react/components/Layouts/AuthoringFrameOverlay.js +17 -7
  63. package/react/components/Layouts/AuthoringFrameRightBar.js +17 -7
  64. package/react/components/Layouts/AuthoringFrameSidePanel.js +17 -7
  65. package/react/components/Layouts/AuthoringFrameSidePanelOverlay.js +17 -7
  66. package/react/components/Layouts/AuthoringInnerBody.js +17 -7
  67. package/react/components/Layouts/AuthoringInnerHeader.js +17 -7
  68. package/react/components/Layouts/AuthoringMain.js +17 -7
  69. package/react/components/Layouts/AuthoringMainContainer.js +17 -7
  70. package/react/components/Layouts/AuthoringMainContent.js +17 -7
  71. package/react/components/Layouts/AuthoringMainToolBar.js +17 -7
  72. package/react/components/Layouts/BottomBarAction.js +17 -7
  73. package/react/components/Layouts/Container.js +17 -7
  74. package/react/components/Layouts/ContentSplitter.js +17 -7
  75. package/react/components/Layouts/CoreLayout.js +17 -7
  76. package/react/components/Layouts/CoreLayoutContainer.js +17 -7
  77. package/react/components/Layouts/CoreLayoutFooter.js +17 -7
  78. package/react/components/Layouts/CoreLayoutMain.js +17 -7
  79. package/react/components/Layouts/CoreLayoutOverlay.js +17 -7
  80. package/react/components/Layouts/CoreLayoutSlideInMenu.js +17 -7
  81. package/react/components/Layouts/CoreLayoutTopMenu.js +17 -7
  82. package/react/components/Layouts/HamburgerButton.js +17 -7
  83. package/react/components/Layouts/HeaderPanel.js +17 -7
  84. package/react/components/Layouts/Layout.js +17 -7
  85. package/react/components/Layouts/LayoutContainer.js +17 -7
  86. package/react/components/Layouts/LeftPanel.js +17 -7
  87. package/react/components/Layouts/MainMenu.js +17 -7
  88. package/react/components/Layouts/MainPanel.js +17 -7
  89. package/react/components/Layouts/NotificationPanel.js +17 -7
  90. package/react/components/Layouts/OverlayPanel.js +17 -7
  91. package/react/components/Layouts/PageLayout.js +17 -7
  92. package/react/components/Layouts/Panel.js +17 -7
  93. package/react/components/Layouts/RightPanel.js +17 -7
  94. package/react/components/LeftMenu.js +17 -7
  95. package/react/components/ListItemLoader.js +17 -7
  96. package/react/components/Lists/BoxedList.js +17 -7
  97. package/react/components/Lists/CalendarWeekDayItem.js +17 -7
  98. package/react/components/Lists/ContentList.js +17 -7
  99. package/react/components/Lists/SimpleList.js +17 -7
  100. package/react/components/Lists/TableList.js +17 -7
  101. package/react/components/Loader.js +17 -7
  102. package/react/components/Menu.js +17 -7
  103. package/react/components/Modal.js +17 -7
  104. package/react/components/MultiSelect.js +17 -7
  105. package/react/components/NavButton.js +17 -7
  106. package/react/components/Navigation/BottomNav.js +17 -7
  107. package/react/components/Navigation/QuickNavBar.js +17 -7
  108. package/react/components/Navigation/SideBarMenu.js +17 -7
  109. package/react/components/Navigation/SideBarTabs.js +17 -7
  110. package/react/components/Popover.js +17 -7
  111. package/react/components/PropsList.js +17 -7
  112. package/react/components/RadioButtonGroup.js +17 -7
  113. package/react/components/RadioGroup.js +17 -7
  114. package/react/components/ResizablePanels.js +17 -7
  115. package/react/components/Rotate.js +17 -7
  116. package/react/components/SearchBar.js +17 -7
  117. package/react/components/Select.js +17 -7
  118. package/react/components/SelectGrid.js +17 -7
  119. package/react/components/SelectPreview.js +17 -7
  120. package/react/components/SelectWithTemplate.js +17 -7
  121. package/react/components/ShowPopup.js +19 -9
  122. package/react/components/SingleAndDoubleClickFunction.d.ts +0 -1
  123. package/react/components/SingleAndDoubleClickFunction.js +1 -2
  124. package/react/components/Skeleton.js +17 -7
  125. package/react/components/SlidingToolbar.js +17 -7
  126. package/react/components/Spinner.js +17 -7
  127. package/react/components/StrechBar.js +17 -7
  128. package/react/components/SubNav.js +17 -7
  129. package/react/components/SvgIconIllustration.js +17 -7
  130. package/react/components/Switch.js +17 -7
  131. package/react/components/SwitchGroup.js +17 -7
  132. package/react/components/TabCustom.js +17 -7
  133. package/react/components/TabList.js +17 -7
  134. package/react/components/Tag.js +17 -7
  135. package/react/components/TagInput.js +17 -7
  136. package/react/components/Text/Heading.js +17 -7
  137. package/react/components/Text/Text.js +17 -7
  138. package/react/components/Text/Time.js +17 -7
  139. package/react/components/ThemeSelector.js +17 -7
  140. package/react/components/TimePicker.js +17 -7
  141. package/react/components/TimePickerV2.js +17 -7
  142. package/react/components/Toast.js +17 -7
  143. package/react/components/ToastMessage.js +17 -7
  144. package/react/components/ToastText.js +17 -7
  145. package/react/components/ToastWrapper.js +17 -7
  146. package/react/components/ToggleBox/CustomHeaderToggleBox.js +18 -9
  147. package/react/components/ToggleBox/SimpleToggleBox.js +18 -9
  148. package/react/components/ToggleBox/index.js +17 -7
  149. package/react/components/Tooltip.js +17 -7
  150. package/react/components/TreeMenu.js +17 -7
  151. package/react/components/TreeSelect/TreeSelect.js +17 -7
  152. package/react/components/TreeSelect/TreeSelectItem.js +19 -9
  153. package/react/components/TreeSelect/TreeSelectPill.js +17 -7
  154. package/react/components/WithPagination.js +19 -9
  155. package/react/components/WithPopover.js +17 -7
  156. package/react/components/WithPortal.js +19 -9
  157. package/react/components/WithSizeObserver.js +17 -7
  158. package/react/components/_Positioner.js +17 -7
  159. package/react/components/avatar/avatar-action-add.js +17 -7
  160. package/react/components/avatar/avatar-group.js +17 -7
  161. package/react/components/avatar/avatar-image.js +17 -7
  162. package/react/components/avatar/avatar-number.js +17 -7
  163. package/react/components/avatar/avatar-placeholder.js +17 -7
  164. package/react/components/avatar/avatar-text.js +17 -7
  165. package/react/components/avatar/avatar-wrapper.js +17 -7
  166. package/react/components/avatar/avatar.js +17 -7
  167. package/react/helpers.js +3 -4
  168. package/react/index.d.ts +1 -1
  169. package/react/index.js +3 -1
  170. package/react/localization.d.ts +9 -0
  171. package/react/localization.js +13 -0
  172. package/react/zIndex.js +2 -2
@@ -8,8 +8,10 @@ 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';
14
+ import {assertNever} from '../helpers';
13
15
 
14
16
  interface IDatePickerBase extends IInputWrapper {
15
17
  dateFormat: string; // a combination of YYYY, MM, and DD with a custom separator e.g. 'MM/DD/YYYY'
@@ -18,21 +20,7 @@ interface IDatePickerBase extends IInputWrapper {
18
20
  // for example [{label: 'tomorrow', days: 1}, {label: 'yesterday', days: -1}]
19
21
  headerButtonBar?: Array<{days: number, label: string}>;
20
22
 
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;
23
+ locale?: {type: 'code-only', code: string} | {type: 'full', payload: Omit<LocaleSettings, 'today' | 'clear'>};
36
24
 
37
25
  hideClearButton?: boolean;
38
26
  }
@@ -81,6 +69,36 @@ function parseToPrimeReactCalendarFormat(value: IDatePicker['value']): CalendarP
81
69
  return value === null ? undefined : value;
82
70
  }
83
71
 
72
+ function getDatePickerLocale(code?: string): LocaleSettings {
73
+ const localeCode = code ?? 'en-US';
74
+ const firstDayOfWeek = getWeekStartByLocale(localeCode);
75
+
76
+ const dayNames: {long: Array<string>; short: Array<string>; narrow: Array<string>} = {
77
+ long: [],
78
+ short: [],
79
+ narrow: [],
80
+ };
81
+
82
+ for (const weekday of getWeekdayNames(0, localeCode)) {
83
+ dayNames.long.push(weekday.nameLong);
84
+ dayNames.short.push(weekday.nameShort);
85
+ dayNames.narrow.push(weekday.nameNarrow);
86
+ }
87
+
88
+ const locale: LocaleSettings = {
89
+ firstDayOfWeek: firstDayOfWeek,
90
+ dayNames: dayNames.long,
91
+ dayNamesShort: dayNames.short,
92
+ dayNamesMin: dayNames.short, // using short instead of narrow on purpose
93
+ monthNames: getMonthNames(localeCode, 'long'),
94
+ monthNamesShort: getMonthNames(localeCode, 'short'),
95
+ today: localization.translations.today,
96
+ clear: localization.translations.clear,
97
+ };
98
+
99
+ return locale;
100
+ }
101
+
84
102
  export class DatePicker extends React.PureComponent<IDatePicker, IState> {
85
103
  private instance: IPrivatePrimeReactCalendarApi | undefined;
86
104
  hidePopupOnScroll: () => void;
@@ -128,15 +146,6 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
128
146
  }
129
147
 
130
148
  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
149
  if (this.props.preview) {
141
150
  return (
142
151
  // We have to do type assertion here because we wrap primereact's component using
@@ -148,6 +157,22 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
148
157
  );
149
158
  }
150
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
+
151
176
  const showClearButton = this.props.required === true
152
177
  ? false
153
178
  : this.props.hideClearButton !== true;
@@ -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,
@@ -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
+ }