@variocube/app-ui 1.15.0 → 1.16.1
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.
- package/esm/AppShell/AppShell.js +12 -12
- package/esm/AppShell/AppShell.js.map +1 -1
- package/esm/AppShell/index.js.map +1 -1
- package/esm/Input/ActionsMenu.js +1 -1
- package/esm/Input/ActionsMenu.js.map +1 -1
- package/esm/Input/EmailSenderField.js +3 -3
- package/esm/Input/EmailSenderField.js.map +1 -1
- package/esm/Input/Selector.js +2 -2
- package/esm/Input/Selector.js.map +1 -1
- package/esm/Paging/Paging.d.ts +1 -1
- package/esm/Paging/Paging.js +5 -5
- package/esm/Paging/Paging.js.map +1 -1
- package/esm/Paging/index.d.ts +2 -1
- package/esm/Paging/index.js.map +1 -1
- package/esm/VCThemeProvider/JetbrainsMonoFont.js +8 -8
- package/esm/VCThemeProvider/JetbrainsMonoFont.js.map +1 -1
- package/esm/VCThemeProvider/RobotoFont.js +8 -8
- package/esm/VCThemeProvider/RobotoFont.js.map +1 -1
- package/esm/VCThemeProvider/ThemeModeSwitcher.js +5 -5
- package/esm/VCThemeProvider/ThemeModeSwitcher.js.map +1 -1
- package/esm/VCThemeProvider/VCThemeProvider.d.ts +1 -1
- package/esm/VCThemeProvider/VCThemeProvider.js +21 -21
- package/esm/VCThemeProvider/VCThemeProvider.js.map +1 -1
- package/esm/audit/AuditChanges.js +9 -5
- package/esm/audit/AuditChanges.js.map +1 -1
- package/esm/audit/AuditTimeline.js +1 -1
- package/esm/audit/AuditTimeline.js.map +1 -1
- package/esm/audit/AuditTimelineItem.js +3 -3
- package/esm/audit/AuditTimelineItem.js.map +1 -1
- package/esm/audit/index.d.ts +1 -1
- package/esm/audit/index.js +1 -1
- package/esm/audit/index.js.map +1 -1
- package/esm/breadcrumbs.d.ts +2 -2
- package/esm/breadcrumbs.js +3 -3
- package/esm/breadcrumbs.js.map +1 -1
- package/esm/code/CodeBlock.d.ts +1 -1
- package/esm/code/CodeBlock.js +1 -1
- package/esm/code/CodeBlock.js.map +1 -1
- package/esm/confirm/ConfirmButton.js.map +1 -1
- package/esm/confirm/ConfirmDialog.js +1 -1
- package/esm/confirm/ConfirmDialog.js.map +1 -1
- package/esm/confirm/ConfirmMenuItem.js +1 -1
- package/esm/confirm/ConfirmMenuItem.js.map +1 -1
- package/esm/container/ContainerLayout.d.ts +1 -1
- package/esm/container/ContainerLayout.js +5 -5
- package/esm/container/ContainerLayout.js.map +1 -1
- package/esm/container/ContainerSettingsContext.d.ts +2 -2
- package/esm/container/ContainerSettingsContext.js +6 -6
- package/esm/container/ContainerSettingsContext.js.map +1 -1
- package/esm/container/ContainerWidthControl.js +2 -2
- package/esm/container/ContainerWidthControl.js.map +1 -1
- package/esm/container/index.d.ts +1 -1
- package/esm/container/index.js +1 -1
- package/esm/container/index.js.map +1 -1
- package/esm/content-table/ContentTable.d.ts +1 -1
- package/esm/content-table/ContentTable.js +26 -19
- package/esm/content-table/ContentTable.js.map +1 -1
- package/esm/content-table/UndrawEmpty.js.map +1 -1
- package/esm/content-table/index.js.map +1 -1
- package/esm/country/country-select.js.map +1 -1
- package/esm/country/index.d.ts +3 -3
- package/esm/country/index.js +3 -3
- package/esm/country/index.js.map +1 -1
- package/esm/country/locale-select.js +1 -1
- package/esm/country/locale-select.js.map +1 -1
- package/esm/country/locales.js +1 -1
- package/esm/country/locales.js.map +1 -1
- package/esm/country/phone-prefix-select.js +1 -1
- package/esm/country/phone-prefix-select.js.map +1 -1
- package/esm/cube/accessibility.js +2 -1
- package/esm/cube/accessibility.js.map +1 -1
- package/esm/data-table/DataTableColumnSettings.d.ts +1 -1
- package/esm/data-table/DataTableColumnSettings.js +2 -2
- package/esm/data-table/DataTableColumnSettings.js.map +1 -1
- package/esm/data-table/DataTableHeader.js +1 -1
- package/esm/data-table/DataTableHeader.js.map +1 -1
- package/esm/data-table/DataTableToolbar.js +1 -1
- package/esm/data-table/DataTableToolbar.js.map +1 -1
- package/esm/data-table/index.d.ts +4 -4
- package/esm/data-table/index.js +4 -4
- package/esm/data-table/index.js.map +1 -1
- package/esm/data-table/useDataTableColumnStorage.d.ts +9 -1
- package/esm/data-table/useDataTableColumnStorage.js +12 -5
- package/esm/data-table/useDataTableColumnStorage.js.map +1 -1
- package/esm/data-table/useDataTableStorage.d.ts +31 -6
- package/esm/data-table/useDataTableStorage.js +25 -5
- package/esm/data-table/useDataTableStorage.js.map +1 -1
- package/esm/date-pickers/PlainAdapterCommon.d.ts +1 -1
- package/esm/date-pickers/PlainAdapterCommon.js.map +1 -1
- package/esm/date-pickers/PlainDateAdapter.js.map +1 -1
- package/esm/date-pickers/PlainDatePicker.js +1 -1
- package/esm/date-pickers/PlainDatePicker.js.map +1 -1
- package/esm/date-pickers/PlainDatePicker.spec.js +2 -2
- package/esm/date-pickers/PlainDatePicker.spec.js.map +1 -1
- package/esm/date-pickers/PlainDateTimeAdapter.js.map +1 -1
- package/esm/date-pickers/PlainDateTimePicker.js +2 -2
- package/esm/date-pickers/PlainDateTimePicker.js.map +1 -1
- package/esm/date-pickers/PlainDateTimePicker.spec.js +2 -2
- package/esm/date-pickers/PlainDateTimePicker.spec.js.map +1 -1
- package/esm/date-pickers/PlainTimeAdapter.js.map +1 -1
- package/esm/date-pickers/PlainTimePicker.js +2 -2
- package/esm/date-pickers/PlainTimePicker.js.map +1 -1
- package/esm/date-pickers/PlainTimePicker.spec.js +2 -2
- package/esm/date-pickers/PlainTimePicker.spec.js.map +1 -1
- package/esm/date-pickers/TemporalAdapter.d.ts +1 -1
- package/esm/date-pickers/TemporalAdapter.js +1 -1
- package/esm/date-pickers/TemporalAdapter.js.map +1 -1
- package/esm/date-pickers/TimezoneSelect.js +348 -348
- package/esm/date-pickers/TimezoneSelect.js.map +1 -1
- package/esm/date-pickers/getFormatString.js.map +1 -1
- package/esm/date-pickers/index.d.ts +2 -1
- package/esm/date-pickers/index.js +1 -1
- package/esm/date-pickers/index.js.map +1 -1
- package/esm/date-pickers/parse.js.map +1 -1
- package/esm/date-pickers/timeframe-picker.js +7 -7
- package/esm/date-pickers/timeframe-picker.js.map +1 -1
- package/esm/date-pickers/useLocale.js.map +1 -1
- package/esm/date-pickers/useRenderInput.js +5 -3
- package/esm/date-pickers/useRenderInput.js.map +1 -1
- package/esm/formats/CompactFormat.js +1 -1
- package/esm/formats/CompactFormat.js.map +1 -1
- package/esm/formats/CompactFormat.spec.js +1 -1
- package/esm/formats/CompactFormat.spec.js.map +1 -1
- package/esm/formats/CurrencyFormat.js +1 -1
- package/esm/formats/CurrencyFormat.js.map +1 -1
- package/esm/formats/CurrencyFormat.spec.js +1 -1
- package/esm/formats/CurrencyFormat.spec.js.map +1 -1
- package/esm/formats/DecimalFormat.js +1 -1
- package/esm/formats/DecimalFormat.js.map +1 -1
- package/esm/formats/DecimalFormat.spec.js +1 -1
- package/esm/formats/DecimalFormat.spec.js.map +1 -1
- package/esm/formats/DurationFormat.js +2 -2
- package/esm/formats/DurationFormat.js.map +1 -1
- package/esm/formats/DurationFormat.spec.js +2 -2
- package/esm/formats/DurationFormat.spec.js.map +1 -1
- package/esm/formats/TemporalFormat.spec.js +2 -2
- package/esm/formats/TemporalFormat.spec.js.map +1 -1
- package/esm/formats/TemporalRangeFormat.js +1 -1
- package/esm/formats/TemporalRangeFormat.js.map +1 -1
- package/esm/formats/TemporalRangeFormat.spec.js +2 -2
- package/esm/formats/TemporalRangeFormat.spec.js.map +1 -1
- package/esm/formats/useDateTimeFormat.js +5 -2
- package/esm/formats/useDateTimeFormat.js.map +1 -1
- package/esm/formats/useNumberFormat.js +1 -1
- package/esm/formats/useNumberFormat.js.map +1 -1
- package/esm/formats/useRelativeTimeFormat.js +4 -2
- package/esm/formats/useRelativeTimeFormat.js.map +1 -1
- package/esm/forms/SearchForm.js +1 -1
- package/esm/forms/SearchForm.js.map +1 -1
- package/esm/getNavigatorLanguages.js.map +1 -1
- package/esm/getSupportedFormatLocale.js.map +1 -1
- package/esm/help/HelpDrawer.js +12 -8
- package/esm/help/HelpDrawer.js.map +1 -1
- package/esm/help/index.d.ts +1 -1
- package/esm/help/index.js +1 -1
- package/esm/help/index.js.map +1 -1
- package/esm/icons.d.ts +13 -13
- package/esm/icons.js +13 -13
- package/esm/icons.js.map +1 -1
- package/esm/layout/ErrorBoundary.js +36 -36
- package/esm/layout/ErrorBoundary.js.map +1 -1
- package/esm/layout/NotFound.js +6 -6
- package/esm/layout/NotFound.js.map +1 -1
- package/esm/layout/NotFoundSvg.js.map +1 -1
- package/esm/layout/UserNav.js +18 -18
- package/esm/layout/UserNav.js.map +1 -1
- package/esm/layout/index.d.ts +2 -2
- package/esm/layout/index.js +2 -2
- package/esm/layout/index.js.map +1 -1
- package/esm/logo/Logo.js +2 -2
- package/esm/logo/Logo.js.map +1 -1
- package/esm/logo/VCAppLogo.js +1 -1
- package/esm/logo/VCAppLogo.js.map +1 -1
- package/esm/logo/index.d.ts +3 -3
- package/esm/logo/index.js +3 -3
- package/esm/logo/index.js.map +1 -1
- package/esm/splash/index.js +2 -2
- package/esm/splash/index.js.map +1 -1
- package/esm/storage/MemoryStorage.d.ts +6 -4
- package/esm/storage/MemoryStorage.js +13 -4
- package/esm/storage/MemoryStorage.js.map +1 -1
- package/esm/storage/index.d.ts +2 -1
- package/esm/storage/index.js +1 -1
- package/esm/storage/index.js.map +1 -1
- package/esm/storage/storage.d.ts +6 -4
- package/esm/storage/storage.js +35 -15
- package/esm/storage/storage.js.map +1 -1
- package/esm/storage/types.d.ts +6 -0
- package/esm/storage/types.js +2 -0
- package/esm/storage/types.js.map +1 -0
- package/esm/storage/useStorage.d.ts +10 -1
- package/esm/storage/useStorage.js +30 -7
- package/esm/storage/useStorage.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +2 -2
- package/esm/tabs/Tabs.js +15 -15
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tabs/index.js.map +1 -1
- package/esm/temporal/index.d.ts +1 -1
- package/esm/temporal/index.js +1 -1
- package/esm/temporal/index.js.map +1 -1
- package/esm/temporal/parse.js.map +1 -1
- package/esm/temporal/polyfill.d.ts +1 -1
- package/esm/temporal/polyfill.js +3 -3
- package/esm/temporal/polyfill.js.map +1 -1
- package/esm/utils/defined.js.map +1 -1
- package/esm/utils/index.d.ts +1 -1
- package/esm/utils/index.js +1 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/useFlag.js.map +1 -1
- package/esm/utils/useIsMounted.js.map +1 -1
- package/package.json +8 -9
- package/src/AppShell/AppShell.tsx +147 -140
- package/src/AppShell/index.tsx +1 -1
- package/src/Input/ActionsMenu.tsx +70 -73
- package/src/Input/EmailSenderField.tsx +59 -52
- package/src/Input/Selector.tsx +15 -15
- package/src/LanguageSwitcher/index.ts +1 -1
- package/src/Paging/Paging.ts +56 -57
- package/src/Paging/index.ts +2 -1
- package/src/VCThemeProvider/JetbrainsMonoFont.tsx +52 -42
- package/src/VCThemeProvider/RobotoFont.tsx +47 -39
- package/src/VCThemeProvider/ThemeModeSwitcher.tsx +17 -17
- package/src/VCThemeProvider/VCThemeProvider.tsx +149 -145
- package/src/audit/AuditChanges.tsx +18 -12
- package/src/audit/AuditTimeline.tsx +16 -17
- package/src/audit/AuditTimelineItem.tsx +58 -61
- package/src/audit/index.ts +2 -2
- package/src/audit/types.ts +27 -28
- package/src/breadcrumbs.tsx +11 -15
- package/src/code/CodeBlock.tsx +10 -10
- package/src/confirm/ConfirmButton.tsx +56 -56
- package/src/confirm/ConfirmDialog.tsx +54 -54
- package/src/confirm/ConfirmMenuItem.tsx +51 -53
- package/src/container/ContainerLayout.tsx +7 -8
- package/src/container/ContainerSettingsContext.tsx +49 -46
- package/src/container/ContainerWidthControl.tsx +11 -9
- package/src/container/index.ts +8 -3
- package/src/content-table/ContentTable.tsx +235 -197
- package/src/content-table/UndrawEmpty.tsx +281 -281
- package/src/content-table/index.ts +1 -1
- package/src/country/country-select.tsx +0 -1
- package/src/country/index.ts +3 -3
- package/src/country/locale-select.tsx +36 -36
- package/src/country/locales.ts +185 -187
- package/src/country/phone-prefix-select.tsx +4 -5
- package/src/cube/accessibility.tsx +2 -1
- package/src/data-table/DataTableColumnSettings.tsx +181 -181
- package/src/data-table/DataTableHeader.tsx +6 -6
- package/src/data-table/DataTableToolbar.tsx +6 -6
- package/src/data-table/index.tsx +4 -4
- package/src/data-table/useDataTableColumnStorage.ts +30 -19
- package/src/data-table/useDataTableStorage.spec.ts +108 -0
- package/src/data-table/useDataTableStorage.ts +91 -36
- package/src/date-pickers/PlainAdapterCommon.ts +118 -120
- package/src/date-pickers/PlainDateAdapter.spec.ts +44 -46
- package/src/date-pickers/PlainDateAdapter.ts +130 -132
- package/src/date-pickers/PlainDatePicker.spec.tsx +17 -18
- package/src/date-pickers/PlainDatePicker.tsx +33 -36
- package/src/date-pickers/PlainDateTimeAdapter.spec.ts +44 -46
- package/src/date-pickers/PlainDateTimeAdapter.ts +141 -134
- package/src/date-pickers/PlainDateTimePicker.spec.tsx +17 -18
- package/src/date-pickers/PlainDateTimePicker.tsx +35 -36
- package/src/date-pickers/PlainTimeAdapter.ts +219 -221
- package/src/date-pickers/PlainTimePicker.spec.tsx +17 -18
- package/src/date-pickers/PlainTimePicker.tsx +35 -34
- package/src/date-pickers/TemporalAdapter.ts +110 -111
- package/src/date-pickers/TimezoneSelect.tsx +375 -375
- package/src/date-pickers/getFormatString.ts +29 -29
- package/src/date-pickers/index.ts +6 -5
- package/src/date-pickers/parse.spec.ts +37 -40
- package/src/date-pickers/parse.ts +44 -47
- package/src/date-pickers/timeframe-picker.tsx +16 -17
- package/src/date-pickers/useLocale.ts +1 -1
- package/src/date-pickers/useRenderInput.tsx +24 -15
- package/src/formats/CompactFormat.spec.tsx +18 -20
- package/src/formats/CompactFormat.tsx +30 -30
- package/src/formats/CurrencyFormat.spec.tsx +18 -20
- package/src/formats/CurrencyFormat.tsx +52 -52
- package/src/formats/DecimalFormat.spec.tsx +18 -20
- package/src/formats/DecimalFormat.tsx +47 -47
- package/src/formats/DurationFormat.spec.tsx +48 -49
- package/src/formats/DurationFormat.tsx +51 -51
- package/src/formats/TemporalFormat.spec.tsx +93 -95
- package/src/formats/TemporalRangeFormat.spec.tsx +143 -144
- package/src/formats/TemporalRangeFormat.tsx +54 -54
- package/src/formats/types.ts +1 -3
- package/src/formats/useDateTimeFormat.ts +5 -2
- package/src/formats/useNumberFormat.ts +3 -3
- package/src/formats/useRelativeTimeFormat.ts +5 -3
- package/src/forms/SearchForm.tsx +37 -38
- package/src/getNavigatorLanguages.ts +4 -5
- package/src/getSupportedFormatLocale.ts +10 -10
- package/src/help/HelpDrawer.tsx +76 -55
- package/src/help/index.ts +3 -3
- package/src/icons.ts +21 -21
- package/src/layout/ErrorBoundary.tsx +226 -215
- package/src/layout/NotFound.tsx +36 -39
- package/src/layout/NotFoundSvg.tsx +193 -169
- package/src/layout/UserNav.tsx +98 -98
- package/src/layout/index.ts +3 -3
- package/src/logo/Logo.tsx +6 -7
- package/src/logo/VCAppLogo.tsx +22 -20
- package/src/logo/index.tsx +3 -3
- package/src/splash/index.tsx +25 -25
- package/src/storage/MemoryStorage.ts +22 -15
- package/src/storage/index.ts +2 -1
- package/src/storage/storage.spec.ts +184 -0
- package/src/storage/storage.ts +37 -15
- package/src/storage/types.ts +6 -0
- package/src/storage/useStorage.ts +32 -7
- package/src/tabs/Tabs.tsx +172 -170
- package/src/tabs/index.ts +1 -1
- package/src/temporal/index.ts +1 -1
- package/src/temporal/parse.ts +1 -2
- package/src/temporal/polyfill.ts +11 -11
- package/src/utils/defined.ts +2 -3
- package/src/utils/index.ts +1 -1
- package/src/utils/useFlag.ts +5 -5
- package/src/utils/useIsMounted.ts +9 -9
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import {DateTimeFormat, PlainDateTime} from "../temporal";
|
|
2
2
|
|
|
3
3
|
interface FormatStringPlaceholder {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
year?: string;
|
|
5
|
+
month?: string;
|
|
6
|
+
day?: string;
|
|
7
|
+
hour?: string;
|
|
8
|
+
minute?: string;
|
|
9
|
+
second?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function getFormatString(format: DateTimeFormat, placeholder: FormatStringPlaceholder) {
|
|
13
|
-
|
|
13
|
+
const {year, month, day, hour, minute, second} = placeholder;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// derive a format string from a fictional date
|
|
16
|
+
let formatString = format.format(new PlainDateTime(9999, 11, 22, 0, 33, 44));
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
if (year) {
|
|
19
|
+
formatString = formatString.replace(/9+/, year);
|
|
20
|
+
}
|
|
21
|
+
if (month) {
|
|
22
|
+
formatString = formatString.replace(/1+/, month);
|
|
23
|
+
}
|
|
24
|
+
if (day) {
|
|
25
|
+
formatString = formatString.replace(/2+/, day);
|
|
26
|
+
}
|
|
27
|
+
if (hour) {
|
|
28
|
+
formatString = formatString.replace(/0+/, hour);
|
|
29
|
+
}
|
|
30
|
+
if (minute) {
|
|
31
|
+
formatString = formatString.replace(/3+/, minute);
|
|
32
|
+
}
|
|
33
|
+
if (second) {
|
|
34
|
+
formatString = formatString.replace(/4+/, second);
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
}
|
|
37
|
+
return formatString;
|
|
38
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export {PlainDatePicker} from "./PlainDatePicker";
|
|
2
|
-
export {PlainDateTimePicker} from "./PlainDateTimePicker";
|
|
3
|
-
export {PlainTimePicker} from "./PlainTimePicker";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { PlainDatePicker } from "./PlainDatePicker";
|
|
2
|
+
export { PlainDateTimePicker } from "./PlainDateTimePicker";
|
|
3
|
+
export { PlainTimePicker } from "./PlainTimePicker";
|
|
4
|
+
export { computeFromUntil, TimeframePicker, TimeFrameType } from "./timeframe-picker";
|
|
5
|
+
export type { FilterTimeFrame } from "./timeframe-picker";
|
|
6
|
+
export { TimezoneSelect } from "./TimezoneSelect";
|
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
import {parsePlainDate} from "./parse";
|
|
2
1
|
import {DateTimeFormat} from "../temporal";
|
|
2
|
+
import {parsePlainDate} from "./parse";
|
|
3
3
|
|
|
4
4
|
describe("parsePlainDate", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
});
|
|
5
|
+
test("can parse locale: de", () => {
|
|
6
|
+
const plainDate = parsePlainDate("31.5.2020", new DateTimeFormat("de", {dateStyle: "short"}));
|
|
7
|
+
expect(plainDate.day).toBe(31);
|
|
8
|
+
expect(plainDate.month).toBe(5);
|
|
9
|
+
expect(plainDate.year).toBe(2020);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("can parse locale: en-US", () => {
|
|
13
|
+
const plainDate = parsePlainDate("9/11/2001", new DateTimeFormat("en-US", {dateStyle: "short"}));
|
|
14
|
+
expect(plainDate.day).toBe(11);
|
|
15
|
+
expect(plainDate.month).toBe(9);
|
|
16
|
+
expect(plainDate.year).toBe(2001);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("can parse locale: fr", () => {
|
|
20
|
+
const plainDate = parsePlainDate("4/7/2022", new DateTimeFormat("fr", {dateStyle: "short"}));
|
|
21
|
+
expect(plainDate.day).toBe(4);
|
|
22
|
+
expect(plainDate.month).toBe(7);
|
|
23
|
+
expect(plainDate.year).toBe(2022);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("throws on non-latn numbering systems", () => {
|
|
27
|
+
expect(() => parsePlainDate("١٩/١٢/٢٠١٢", new DateTimeFormat("ar-EG", {dateStyle: "short"})))
|
|
28
|
+
.toThrow("Parsing numbering systems other than `latn` is not supported");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("throws on invalid date", () => {
|
|
32
|
+
expect(() => parsePlainDate("13/11/2001", new DateTimeFormat("en-US", {dateStyle: "short"})))
|
|
33
|
+
.toThrow();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("throws on parse error", () => {
|
|
37
|
+
expect(() => parsePlainDate("9//2001", new DateTimeFormat("en-US", {dateStyle: "short"})))
|
|
38
|
+
.toThrow();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -2,71 +2,68 @@ import {DateTimeFormat, PlainDate, PlainDateTime, PlainTime} from "../temporal";
|
|
|
2
2
|
import {getFormatString} from "./getFormatString";
|
|
3
3
|
|
|
4
4
|
const PLACEHOLDER = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
year: "year",
|
|
6
|
+
month: "month",
|
|
7
|
+
day: "day",
|
|
8
|
+
hour: "hour",
|
|
9
|
+
minute: "minute",
|
|
10
|
+
second: "second",
|
|
11
11
|
} as const;
|
|
12
12
|
|
|
13
13
|
export function parsePlainDate(value: string, format: DateTimeFormat) {
|
|
14
|
-
|
|
14
|
+
return PlainDate.from(parse(value, format), {overflow: "reject"});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function parsePlainDateTime(value: string, format: DateTimeFormat) {
|
|
18
|
-
|
|
18
|
+
return PlainDateTime.from(parse(value, format), {overflow: "reject"});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function parsePlainTime(value: string, format: DateTimeFormat) {
|
|
22
|
-
|
|
22
|
+
return PlainTime.from(parse(value, format), {overflow: "reject"});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function parse(value: string, format: DateTimeFormat) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
// throw an error on unsupported numbering systems
|
|
27
|
+
if (format.resolvedOptions().numberingSystem != "latn") {
|
|
28
|
+
throw new Error("Parsing numbering systems other than `latn` is not supported");
|
|
29
|
+
}
|
|
30
|
+
const formatString = getFormatString(format, PLACEHOLDER);
|
|
31
|
+
return parseFormat(formatString, Object.values(PLACEHOLDER), value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function parseFormat<F extends string>(format: string, formatParts: F[], value: string) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return parsed;
|
|
35
|
+
const parsed = {} as Record<F, number>;
|
|
36
|
+
for (const token of tokenize(format, formatParts)) {
|
|
37
|
+
if (isFormat(token, formatParts)) {
|
|
38
|
+
const matchStr = value.match(/^\d+/)?.pop();
|
|
39
|
+
if (matchStr) {
|
|
40
|
+
parsed[token] = parseInt(matchStr);
|
|
41
|
+
value = value.substring(matchStr.length);
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error("Could not parse number: " + value);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (value.startsWith(token)) {
|
|
47
|
+
value = value.substring(token.length);
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error(`Expected "${token}", but got "${value[0]}"`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return parsed;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
function tokenize(format: string, formatParts: string[]) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
const tokens = [];
|
|
58
|
+
while (format.length > 0) {
|
|
59
|
+
// match the next format part or single char
|
|
60
|
+
const token = formatParts.find(part => format.startsWith(part)) || format[0];
|
|
61
|
+
tokens.push(token);
|
|
62
|
+
format = format.substring(token.length);
|
|
63
|
+
}
|
|
64
|
+
return tokens;
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
function isFormat<F extends string>(c: string, formatParts: F[]): c is F {
|
|
71
|
-
|
|
72
|
-
}
|
|
68
|
+
return formatParts.includes(c as F);
|
|
69
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Now, PlainDate, tryParsePlainDate} from "../temporal";
|
|
2
|
-
import React, {ChangeEvent, useEffect} from "react";
|
|
3
1
|
import {Box, Grid, MenuItem, TextField} from "@mui/material";
|
|
2
|
+
import React, {ChangeEvent, useEffect} from "react";
|
|
3
|
+
import {Now, PlainDate, tryParsePlainDate} from "../temporal";
|
|
4
4
|
import {PlainDatePicker} from "./PlainDatePicker";
|
|
5
5
|
|
|
6
6
|
export enum TimeFrameType {
|
|
@@ -40,15 +40,15 @@ interface TimeFrameSelectProps {
|
|
|
40
40
|
Last3Months?: string;
|
|
41
41
|
LastYear?: string;
|
|
42
42
|
Custom?: string;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function TimeframePicker({value, onChange, i18n}: TimeFrameSelectProps) {
|
|
48
48
|
const {
|
|
49
49
|
type,
|
|
50
50
|
from,
|
|
51
|
-
until
|
|
51
|
+
until,
|
|
52
52
|
} = value;
|
|
53
53
|
|
|
54
54
|
const fromPlainDate = tryParsePlainDate(from) ?? null;
|
|
@@ -93,7 +93,7 @@ export function TimeframePicker({value, onChange, i18n}: TimeFrameSelectProps) {
|
|
|
93
93
|
timeframeTitle: tTimeframeTitle,
|
|
94
94
|
from: tFrom,
|
|
95
95
|
until: tUntil,
|
|
96
|
-
types: tTypes = {}
|
|
96
|
+
types: tTypes = {},
|
|
97
97
|
} = i18n ?? {};
|
|
98
98
|
|
|
99
99
|
return (
|
|
@@ -104,7 +104,7 @@ export function TimeframePicker({value, onChange, i18n}: TimeFrameSelectProps) {
|
|
|
104
104
|
fullWidth
|
|
105
105
|
select
|
|
106
106
|
variant="outlined"
|
|
107
|
-
label={tTimeframeTitle ??
|
|
107
|
+
label={tTimeframeTitle ?? "Timeframe"}
|
|
108
108
|
value={type}
|
|
109
109
|
onChange={handleTypeChange}
|
|
110
110
|
>
|
|
@@ -115,7 +115,7 @@ export function TimeframePicker({value, onChange, i18n}: TimeFrameSelectProps) {
|
|
|
115
115
|
</Grid>
|
|
116
116
|
<Grid item md={4} xs={12}>
|
|
117
117
|
<PlainDatePicker
|
|
118
|
-
label={tFrom ??
|
|
118
|
+
label={tFrom ?? "From"}
|
|
119
119
|
value={fromPlainDate}
|
|
120
120
|
onChange={handleFromChange}
|
|
121
121
|
disabled={type != TimeFrameType.Custom}
|
|
@@ -124,7 +124,7 @@ export function TimeframePicker({value, onChange, i18n}: TimeFrameSelectProps) {
|
|
|
124
124
|
</Grid>
|
|
125
125
|
<Grid item md={4} xs={12}>
|
|
126
126
|
<PlainDatePicker
|
|
127
|
-
label={tUntil ??
|
|
127
|
+
label={tUntil ?? "Until"}
|
|
128
128
|
value={untilPlainDate}
|
|
129
129
|
onChange={handleUntilChange}
|
|
130
130
|
disabled={type != TimeFrameType.Custom}
|
|
@@ -133,7 +133,7 @@ export function TimeframePicker({value, onChange, i18n}: TimeFrameSelectProps) {
|
|
|
133
133
|
</Grid>
|
|
134
134
|
</Grid>
|
|
135
135
|
</Box>
|
|
136
|
-
)
|
|
136
|
+
);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export function computeFromUntil(type: TimeFrameType, from?: PlainDate | null, until?: PlainDate | null) {
|
|
@@ -154,13 +154,13 @@ export function computeFromUntil(type: TimeFrameType, from?: PlainDate | null, u
|
|
|
154
154
|
return {
|
|
155
155
|
from: today,
|
|
156
156
|
until: today,
|
|
157
|
-
}
|
|
157
|
+
};
|
|
158
158
|
|
|
159
159
|
case TimeFrameType.Yesterday:
|
|
160
160
|
return {
|
|
161
161
|
from: yesterday,
|
|
162
162
|
until: yesterday,
|
|
163
|
-
}
|
|
163
|
+
};
|
|
164
164
|
|
|
165
165
|
case TimeFrameType.Last7Days:
|
|
166
166
|
return {
|
|
@@ -172,13 +172,13 @@ export function computeFromUntil(type: TimeFrameType, from?: PlainDate | null, u
|
|
|
172
172
|
return {
|
|
173
173
|
from: lastWeek.subtract({days: lastWeek.dayOfWeek - 1}),
|
|
174
174
|
until: lastWeek.add({days: 7 - lastWeek.dayOfWeek}),
|
|
175
|
-
}
|
|
175
|
+
};
|
|
176
176
|
|
|
177
177
|
case TimeFrameType.ThisMonth:
|
|
178
178
|
return {
|
|
179
179
|
from: today.with({day: 1}),
|
|
180
180
|
until: today.with({day: lastMonth.daysInMonth}),
|
|
181
|
-
}
|
|
181
|
+
};
|
|
182
182
|
|
|
183
183
|
case TimeFrameType.LastMonth:
|
|
184
184
|
return {
|
|
@@ -190,13 +190,12 @@ export function computeFromUntil(type: TimeFrameType, from?: PlainDate | null, u
|
|
|
190
190
|
return {
|
|
191
191
|
from: lastMonth.subtract({months: 3}).with({day: 1}),
|
|
192
192
|
until: lastMonth.with({day: lastMonth.daysInMonth}),
|
|
193
|
-
}
|
|
193
|
+
};
|
|
194
194
|
|
|
195
195
|
case TimeFrameType.LastYear:
|
|
196
196
|
return {
|
|
197
197
|
from: lastYear.with({day: 1, month: 1}),
|
|
198
198
|
until: lastYear.with({day: 31, month: 12}),
|
|
199
|
-
}
|
|
200
|
-
|
|
199
|
+
};
|
|
201
200
|
}
|
|
202
201
|
}
|
|
@@ -2,5 +2,5 @@ import {useMemo} from "react";
|
|
|
2
2
|
import {getSupportedFormatLocale} from "../getSupportedFormatLocale";
|
|
3
3
|
|
|
4
4
|
export function useLocale(suppliedLocale: string | undefined) {
|
|
5
|
-
|
|
5
|
+
return useMemo(() => suppliedLocale || getSupportedFormatLocale("dateTime"), [suppliedLocale]);
|
|
6
6
|
}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {useCallback} from "react";
|
|
3
|
-
import {TextFieldProps} from "@mui/material/TextField/TextField";
|
|
4
1
|
import {TextField} from "@mui/material";
|
|
2
|
+
import {TextFieldProps} from "@mui/material/TextField/TextField";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {useCallback, useMemo} from "react";
|
|
5
5
|
|
|
6
6
|
export type UseRenderInputProps = Pick<TextFieldProps, "fullWidth" | "helperText" | "size" | "required">;
|
|
7
7
|
|
|
8
8
|
export function useRenderInput(props: UseRenderInputProps) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
9
|
+
const {fullWidth, helperText, size, required} = props;
|
|
10
|
+
|
|
11
|
+
// Create a stable forwardRef component
|
|
12
|
+
const RenderInputComponent = useMemo(
|
|
13
|
+
() =>
|
|
14
|
+
React.forwardRef<any, TextFieldProps>((props, ref) => (
|
|
15
|
+
<TextField
|
|
16
|
+
variant="outlined"
|
|
17
|
+
fullWidth={fullWidth}
|
|
18
|
+
helperText={helperText}
|
|
19
|
+
size={size}
|
|
20
|
+
required={required}
|
|
21
|
+
{...props}
|
|
22
|
+
inputRef={ref}
|
|
23
|
+
/>
|
|
24
|
+
)),
|
|
25
|
+
[fullWidth, helperText, size, required],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return useCallback((props: TextFieldProps) => <RenderInputComponent {...props} />, [RenderInputComponent]);
|
|
29
|
+
}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import {act, create, ReactTestRenderer} from "react-test-renderer";
|
|
2
1
|
import * as React from "react";
|
|
2
|
+
import {act, create, ReactTestRenderer} from "react-test-renderer";
|
|
3
3
|
import {CompactFormat} from "./CompactFormat";
|
|
4
4
|
|
|
5
5
|
describe("CompactFormat", () => {
|
|
6
|
+
test("render de-AT", () => {
|
|
7
|
+
let element: ReactTestRenderer;
|
|
8
|
+
act(() => {
|
|
9
|
+
element = create(<CompactFormat value={99000000} locale="de-AT" />);
|
|
10
|
+
});
|
|
11
|
+
const value = element!.root.children[0];
|
|
12
|
+
expect(value).toBe("99\u00a0Mio.");
|
|
13
|
+
});
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
test("render en-US", () => {
|
|
17
|
-
let element: ReactTestRenderer;
|
|
18
|
-
act(() => {
|
|
19
|
-
element = create(<CompactFormat value={99000000} locale="en-US" />);
|
|
20
|
-
})
|
|
21
|
-
const value = element!.root.children[0];
|
|
22
|
-
expect(value).toBe("99M");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
});
|
|
15
|
+
test("render en-US", () => {
|
|
16
|
+
let element: ReactTestRenderer;
|
|
17
|
+
act(() => {
|
|
18
|
+
element = create(<CompactFormat value={99000000} locale="en-US" />);
|
|
19
|
+
});
|
|
20
|
+
const value = element!.root.children[0];
|
|
21
|
+
expect(value).toBe("99M");
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {useNumberFormat} from "./useNumberFormat";
|
|
2
1
|
import {Fragment, useMemo} from "react";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import {useNumberFormat} from "./useNumberFormat";
|
|
4
4
|
|
|
5
5
|
export type CompactDisplay = "long" | "short";
|
|
6
6
|
|
|
7
7
|
export interface CompactFormatProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The numeric amount of currency.
|
|
10
|
+
*/
|
|
11
|
+
value: number | bigint | null | undefined;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Compact display.
|
|
15
|
+
*/
|
|
16
|
+
compactDisplay?: CompactDisplay;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Overrides the user's locale. Use for testing only.
|
|
20
|
+
*/
|
|
21
|
+
locale?: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -27,22 +27,22 @@ export interface CompactFormatProps {
|
|
|
27
27
|
* @constructor
|
|
28
28
|
*/
|
|
29
29
|
export function CompactFormat(props: CompactFormatProps) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const {
|
|
31
|
+
value,
|
|
32
|
+
compactDisplay,
|
|
33
|
+
locale,
|
|
34
|
+
} = props;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const options = useMemo(() => ({
|
|
37
|
+
notation: "compact",
|
|
38
|
+
compactDisplay,
|
|
39
|
+
} as const), [compactDisplay]);
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const numberFormat = useNumberFormat(options, locale);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const str = useMemo(() => {
|
|
44
|
+
return (typeof value == "number" || typeof value == "bigint") ? numberFormat.format(value) : "";
|
|
45
|
+
}, [numberFormat, value]);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
}
|
|
47
|
+
return <Fragment>{str}</Fragment>;
|
|
48
|
+
}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import {act, create, ReactTestRenderer} from "react-test-renderer";
|
|
2
1
|
import * as React from "react";
|
|
2
|
+
import {act, create, ReactTestRenderer} from "react-test-renderer";
|
|
3
3
|
import {CurrencyFormat} from "./CurrencyFormat";
|
|
4
4
|
|
|
5
5
|
describe("CurrencyFormat", () => {
|
|
6
|
+
test("render de-AT", () => {
|
|
7
|
+
let element: ReactTestRenderer;
|
|
8
|
+
act(() => {
|
|
9
|
+
element = create(<CurrencyFormat value={1234.5} currency="EUR" locale="de-AT" />);
|
|
10
|
+
});
|
|
11
|
+
const value = element!.root.children[0];
|
|
12
|
+
expect(value).toBe("€\u00a01.234,50"); // \u00a0 is a non-breaking space
|
|
13
|
+
});
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
test("render en-US", () => {
|
|
17
|
-
let element: ReactTestRenderer;
|
|
18
|
-
act(() => {
|
|
19
|
-
element = create(<CurrencyFormat value={1234.5} currency="USD" locale="en-US" />);
|
|
20
|
-
})
|
|
21
|
-
const value = element!.root.children[0];
|
|
22
|
-
expect(value).toBe("$1,234.50");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
});
|
|
15
|
+
test("render en-US", () => {
|
|
16
|
+
let element: ReactTestRenderer;
|
|
17
|
+
act(() => {
|
|
18
|
+
element = create(<CurrencyFormat value={1234.5} currency="USD" locale="en-US" />);
|
|
19
|
+
});
|
|
20
|
+
const value = element!.root.children[0];
|
|
21
|
+
expect(value).toBe("$1,234.50");
|
|
22
|
+
});
|
|
23
|
+
});
|