@variocube/app-ui 1.14.0
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/README.md +65 -0
- package/esm/AppShell/AppShell.d.ts +12 -0
- package/esm/AppShell/AppShell.js +92 -0
- package/esm/AppShell/AppShell.js.map +1 -0
- package/esm/AppShell/index.d.ts +1 -0
- package/esm/AppShell/index.js +2 -0
- package/esm/AppShell/index.js.map +1 -0
- package/esm/ErrorAlert.d.ts +12 -0
- package/esm/ErrorAlert.js +61 -0
- package/esm/ErrorAlert.js.map +1 -0
- package/esm/Input/ActionsMenu.d.ts +9 -0
- package/esm/Input/ActionsMenu.js +29 -0
- package/esm/Input/ActionsMenu.js.map +1 -0
- package/esm/Input/Checkbox.d.ts +9 -0
- package/esm/Input/Checkbox.js +23 -0
- package/esm/Input/Checkbox.js.map +1 -0
- package/esm/Input/EmailSenderField.d.ts +8 -0
- package/esm/Input/EmailSenderField.js +71 -0
- package/esm/Input/EmailSenderField.js.map +1 -0
- package/esm/Input/NumberField.d.ts +10 -0
- package/esm/Input/NumberField.js +94 -0
- package/esm/Input/NumberField.js.map +1 -0
- package/esm/Input/RadioGroup.d.ts +12 -0
- package/esm/Input/RadioGroup.js +20 -0
- package/esm/Input/RadioGroup.js.map +1 -0
- package/esm/Input/Select.d.ts +11 -0
- package/esm/Input/Select.js +19 -0
- package/esm/Input/Select.js.map +1 -0
- package/esm/Input/Selector.d.ts +10 -0
- package/esm/Input/Selector.js +19 -0
- package/esm/Input/Selector.js.map +1 -0
- package/esm/Input/Switch.d.ts +9 -0
- package/esm/Input/Switch.js +23 -0
- package/esm/Input/Switch.js.map +1 -0
- package/esm/Input/TextField.d.ts +7 -0
- package/esm/Input/TextField.js +58 -0
- package/esm/Input/TextField.js.map +1 -0
- package/esm/Input/UrlUploadField.d.ts +9 -0
- package/esm/Input/UrlUploadField.js +43 -0
- package/esm/Input/UrlUploadField.js.map +1 -0
- package/esm/Input/index.d.ts +9 -0
- package/esm/Input/index.js +10 -0
- package/esm/Input/index.js.map +1 -0
- package/esm/LanguageSwitcher/LanguageSwitcher.d.ts +14 -0
- package/esm/LanguageSwitcher/LanguageSwitcher.js +20 -0
- package/esm/LanguageSwitcher/LanguageSwitcher.js.map +1 -0
- package/esm/LanguageSwitcher/index.d.ts +1 -0
- package/esm/LanguageSwitcher/index.js +2 -0
- package/esm/LanguageSwitcher/index.js.map +1 -0
- package/esm/Paging/Paging.d.ts +40 -0
- package/esm/Paging/Paging.js +43 -0
- package/esm/Paging/Paging.js.map +1 -0
- package/esm/Paging/index.d.ts +1 -0
- package/esm/Paging/index.js +2 -0
- package/esm/Paging/index.js.map +1 -0
- package/esm/VCThemeProvider/JetbrainsMonoFont.d.ts +5 -0
- package/esm/VCThemeProvider/JetbrainsMonoFont.js +52 -0
- package/esm/VCThemeProvider/JetbrainsMonoFont.js.map +1 -0
- package/esm/VCThemeProvider/RobotoFont.d.ts +7 -0
- package/esm/VCThemeProvider/RobotoFont.js +49 -0
- package/esm/VCThemeProvider/RobotoFont.js.map +1 -0
- package/esm/VCThemeProvider/ThemeModeSwitcher.d.ts +2 -0
- package/esm/VCThemeProvider/ThemeModeSwitcher.js +14 -0
- package/esm/VCThemeProvider/ThemeModeSwitcher.js.map +1 -0
- package/esm/VCThemeProvider/VCThemeProvider.d.ts +25 -0
- package/esm/VCThemeProvider/VCThemeProvider.js +173 -0
- package/esm/VCThemeProvider/VCThemeProvider.js.map +1 -0
- package/esm/VCThemeProvider/code-colors.d.ts +108 -0
- package/esm/VCThemeProvider/code-colors.js +26 -0
- package/esm/VCThemeProvider/code-colors.js.map +1 -0
- package/esm/VCThemeProvider/index.d.ts +5 -0
- package/esm/VCThemeProvider/index.js +6 -0
- package/esm/VCThemeProvider/index.js.map +1 -0
- package/esm/audit/AuditChanges.d.ts +9 -0
- package/esm/audit/AuditChanges.js +43 -0
- package/esm/audit/AuditChanges.js.map +1 -0
- package/esm/audit/AuditTimeline.d.ts +6 -0
- package/esm/audit/AuditTimeline.js +13 -0
- package/esm/audit/AuditTimeline.js.map +1 -0
- package/esm/audit/AuditTimelineItem.d.ts +10 -0
- package/esm/audit/AuditTimelineItem.js +27 -0
- package/esm/audit/AuditTimelineItem.js.map +1 -0
- package/esm/audit/index.d.ts +4 -0
- package/esm/audit/index.js +5 -0
- package/esm/audit/index.js.map +1 -0
- package/esm/audit/types.d.ts +42 -0
- package/esm/audit/types.js +2 -0
- package/esm/audit/types.js.map +1 -0
- package/esm/breadcrumbs.d.ts +6 -0
- package/esm/breadcrumbs.js +13 -0
- package/esm/breadcrumbs.js.map +1 -0
- package/esm/code/Code.d.ts +10 -0
- package/esm/code/Code.js +19 -0
- package/esm/code/Code.js.map +1 -0
- package/esm/code/CodeBlock.d.ts +4 -0
- package/esm/code/CodeBlock.js +6 -0
- package/esm/code/CodeBlock.js.map +1 -0
- package/esm/code/Json.d.ts +4 -0
- package/esm/code/Json.js +60 -0
- package/esm/code/Json.js.map +1 -0
- package/esm/code/index.d.ts +3 -0
- package/esm/code/index.js +4 -0
- package/esm/code/index.js.map +1 -0
- package/esm/confirm/ConfirmButton.d.ts +16 -0
- package/esm/confirm/ConfirmButton.js +29 -0
- package/esm/confirm/ConfirmButton.js.map +1 -0
- package/esm/confirm/ConfirmDialog.d.ts +16 -0
- package/esm/confirm/ConfirmDialog.js +35 -0
- package/esm/confirm/ConfirmDialog.js.map +1 -0
- package/esm/confirm/ConfirmIconButton.d.ts +14 -0
- package/esm/confirm/ConfirmIconButton.js +29 -0
- package/esm/confirm/ConfirmIconButton.js.map +1 -0
- package/esm/confirm/ConfirmMenuItem.d.ts +15 -0
- package/esm/confirm/ConfirmMenuItem.js +31 -0
- package/esm/confirm/ConfirmMenuItem.js.map +1 -0
- package/esm/confirm/index.d.ts +4 -0
- package/esm/confirm/index.js +5 -0
- package/esm/confirm/index.js.map +1 -0
- package/esm/container/ContainerLayout.d.ts +8 -0
- package/esm/container/ContainerLayout.js +20 -0
- package/esm/container/ContainerLayout.js.map +1 -0
- package/esm/container/ContainerSettingsContext.d.ts +12 -0
- package/esm/container/ContainerSettingsContext.js +46 -0
- package/esm/container/ContainerSettingsContext.js.map +1 -0
- package/esm/container/ContainerWidthControl.d.ts +6 -0
- package/esm/container/ContainerWidthControl.js +12 -0
- package/esm/container/ContainerWidthControl.js.map +1 -0
- package/esm/container/index.d.ts +3 -0
- package/esm/container/index.js +4 -0
- package/esm/container/index.js.map +1 -0
- package/esm/content-table/ContentTable.d.ts +25 -0
- package/esm/content-table/ContentTable.js +87 -0
- package/esm/content-table/ContentTable.js.map +1 -0
- package/esm/content-table/UndrawEmpty.d.ts +2 -0
- package/esm/content-table/UndrawEmpty.js +71 -0
- package/esm/content-table/UndrawEmpty.js.map +1 -0
- package/esm/content-table/index.d.ts +1 -0
- package/esm/content-table/index.js +2 -0
- package/esm/content-table/index.js.map +1 -0
- package/esm/country/countries.d.ts +34 -0
- package/esm/country/countries.js +266 -0
- package/esm/country/countries.js.map +1 -0
- package/esm/country/country-select.d.ts +8 -0
- package/esm/country/country-select.js +18 -0
- package/esm/country/country-select.js.map +1 -0
- package/esm/country/index.d.ts +5 -0
- package/esm/country/index.js +6 -0
- package/esm/country/index.js.map +1 -0
- package/esm/country/locale-select.d.ts +9 -0
- package/esm/country/locale-select.js +15 -0
- package/esm/country/locale-select.js.map +1 -0
- package/esm/country/locales.d.ts +10 -0
- package/esm/country/locales.js +190 -0
- package/esm/country/locales.js.map +1 -0
- package/esm/country/phone-prefix-select.d.ts +9 -0
- package/esm/country/phone-prefix-select.js +18 -0
- package/esm/country/phone-prefix-select.js.map +1 -0
- package/esm/cube/BoxFeatures.d.ts +11 -0
- package/esm/cube/BoxFeatures.js +40 -0
- package/esm/cube/BoxFeatures.js.map +1 -0
- package/esm/cube/BoxMaintenanceChip.d.ts +9 -0
- package/esm/cube/BoxMaintenanceChip.js +15 -0
- package/esm/cube/BoxMaintenanceChip.js.map +1 -0
- package/esm/cube/BoxNumber.d.ts +6 -0
- package/esm/cube/BoxNumber.js +6 -0
- package/esm/cube/BoxNumber.js.map +1 -0
- package/esm/cube/BoxType.d.ts +7 -0
- package/esm/cube/BoxType.js +21 -0
- package/esm/cube/BoxType.js.map +1 -0
- package/esm/cube/CubeConnectedChip.d.ts +9 -0
- package/esm/cube/CubeConnectedChip.js +22 -0
- package/esm/cube/CubeConnectedChip.js.map +1 -0
- package/esm/cube/LockStatusChip.d.ts +11 -0
- package/esm/cube/LockStatusChip.js +40 -0
- package/esm/cube/LockStatusChip.js.map +1 -0
- package/esm/cube/UtilizationBar.d.ts +11 -0
- package/esm/cube/UtilizationBar.js +38 -0
- package/esm/cube/UtilizationBar.js.map +1 -0
- package/esm/cube/accessibility.d.ts +48 -0
- package/esm/cube/accessibility.js +242 -0
- package/esm/cube/accessibility.js.map +1 -0
- package/esm/cube/index.d.ts +8 -0
- package/esm/cube/index.js +9 -0
- package/esm/cube/index.js.map +1 -0
- package/esm/data-table/DataTable.d.ts +63 -0
- package/esm/data-table/DataTable.js +124 -0
- package/esm/data-table/DataTable.js.map +1 -0
- package/esm/data-table/DataTableColumnSettings.d.ts +10 -0
- package/esm/data-table/DataTableColumnSettings.js +98 -0
- package/esm/data-table/DataTableColumnSettings.js.map +1 -0
- package/esm/data-table/DataTableHeader.d.ts +2 -0
- package/esm/data-table/DataTableHeader.js +6 -0
- package/esm/data-table/DataTableHeader.js.map +1 -0
- package/esm/data-table/DataTableToolbar.d.ts +2 -0
- package/esm/data-table/DataTableToolbar.js +6 -0
- package/esm/data-table/DataTableToolbar.js.map +1 -0
- package/esm/data-table/index.d.ts +8 -0
- package/esm/data-table/index.js +9 -0
- package/esm/data-table/index.js.map +1 -0
- package/esm/data-table/useDataTableColumnStorage.d.ts +5 -0
- package/esm/data-table/useDataTableColumnStorage.js +20 -0
- package/esm/data-table/useDataTableColumnStorage.js.map +1 -0
- package/esm/data-table/useDataTableStorage.d.ts +16 -0
- package/esm/data-table/useDataTableStorage.js +19 -0
- package/esm/data-table/useDataTableStorage.js.map +1 -0
- package/esm/data-table/useSpringPage.d.ts +6 -0
- package/esm/data-table/useSpringPage.js +18 -0
- package/esm/data-table/useSpringPage.js.map +1 -0
- package/esm/data-table/useSpringPageable.d.ts +9 -0
- package/esm/data-table/useSpringPageable.js +10 -0
- package/esm/data-table/useSpringPageable.js.map +1 -0
- package/esm/date-pickers/PlainAdapterCommon.d.ts +31 -0
- package/esm/date-pickers/PlainAdapterCommon.js +97 -0
- package/esm/date-pickers/PlainAdapterCommon.js.map +1 -0
- package/esm/date-pickers/PlainDateAdapter.d.ts +30 -0
- package/esm/date-pickers/PlainDateAdapter.js +114 -0
- package/esm/date-pickers/PlainDateAdapter.js.map +1 -0
- package/esm/date-pickers/PlainDatePicker.d.ts +21 -0
- package/esm/date-pickers/PlainDatePicker.js +26 -0
- package/esm/date-pickers/PlainDatePicker.js.map +1 -0
- package/esm/date-pickers/PlainDatePicker.spec.d.ts +1 -0
- package/esm/date-pickers/PlainDatePicker.spec.js +15 -0
- package/esm/date-pickers/PlainDatePicker.spec.js.map +1 -0
- package/esm/date-pickers/PlainDateTimeAdapter.d.ts +30 -0
- package/esm/date-pickers/PlainDateTimeAdapter.js +114 -0
- package/esm/date-pickers/PlainDateTimeAdapter.js.map +1 -0
- package/esm/date-pickers/PlainDateTimePicker.d.ts +20 -0
- package/esm/date-pickers/PlainDateTimePicker.js +26 -0
- package/esm/date-pickers/PlainDateTimePicker.js.map +1 -0
- package/esm/date-pickers/PlainDateTimePicker.spec.d.ts +1 -0
- package/esm/date-pickers/PlainDateTimePicker.spec.js +15 -0
- package/esm/date-pickers/PlainDateTimePicker.spec.js.map +1 -0
- package/esm/date-pickers/PlainTimeAdapter.d.ts +58 -0
- package/esm/date-pickers/PlainTimeAdapter.js +194 -0
- package/esm/date-pickers/PlainTimeAdapter.js.map +1 -0
- package/esm/date-pickers/PlainTimePicker.d.ts +16 -0
- package/esm/date-pickers/PlainTimePicker.js +24 -0
- package/esm/date-pickers/PlainTimePicker.js.map +1 -0
- package/esm/date-pickers/PlainTimePicker.spec.d.ts +1 -0
- package/esm/date-pickers/PlainTimePicker.spec.js +15 -0
- package/esm/date-pickers/PlainTimePicker.spec.js.map +1 -0
- package/esm/date-pickers/TemporalAdapter.d.ts +18 -0
- package/esm/date-pickers/TemporalAdapter.js +109 -0
- package/esm/date-pickers/TemporalAdapter.js.map +1 -0
- package/esm/date-pickers/TimezoneSelect.d.ts +9 -0
- package/esm/date-pickers/TimezoneSelect.js +357 -0
- package/esm/date-pickers/TimezoneSelect.js.map +1 -0
- package/esm/date-pickers/getFormatString.d.ts +11 -0
- package/esm/date-pickers/getFormatString.js +26 -0
- package/esm/date-pickers/getFormatString.js.map +1 -0
- package/esm/date-pickers/index.d.ts +5 -0
- package/esm/date-pickers/index.js +6 -0
- package/esm/date-pickers/index.js.map +1 -0
- package/esm/date-pickers/parse.d.ts +4 -0
- package/esm/date-pickers/parse.js +66 -0
- package/esm/date-pickers/parse.js.map +1 -0
- package/esm/date-pickers/timeframe-picker.d.ts +46 -0
- package/esm/date-pickers/timeframe-picker.js +120 -0
- package/esm/date-pickers/timeframe-picker.js.map +1 -0
- package/esm/date-pickers/useLocale.d.ts +1 -0
- package/esm/date-pickers/useLocale.js +6 -0
- package/esm/date-pickers/useLocale.js.map +1 -0
- package/esm/date-pickers/useRenderInput.d.ts +4 -0
- package/esm/date-pickers/useRenderInput.js +8 -0
- package/esm/date-pickers/useRenderInput.js.map +1 -0
- package/esm/fetch.d.ts +51 -0
- package/esm/fetch.js +138 -0
- package/esm/fetch.js.map +1 -0
- package/esm/filter/Filter.d.ts +38 -0
- package/esm/filter/Filter.js +72 -0
- package/esm/filter/Filter.js.map +1 -0
- package/esm/filter/index.d.ts +1 -0
- package/esm/filter/index.js +2 -0
- package/esm/filter/index.js.map +1 -0
- package/esm/formats/CompactFormat.d.ts +22 -0
- package/esm/formats/CompactFormat.js +21 -0
- package/esm/formats/CompactFormat.js.map +1 -0
- package/esm/formats/CompactFormat.spec.d.ts +1 -0
- package/esm/formats/CompactFormat.spec.js +22 -0
- package/esm/formats/CompactFormat.spec.js.map +1 -0
- package/esm/formats/CurrencyFormat.d.ts +39 -0
- package/esm/formats/CurrencyFormat.js +25 -0
- package/esm/formats/CurrencyFormat.js.map +1 -0
- package/esm/formats/CurrencyFormat.spec.d.ts +1 -0
- package/esm/formats/CurrencyFormat.spec.js +22 -0
- package/esm/formats/CurrencyFormat.spec.js.map +1 -0
- package/esm/formats/DecimalFormat.d.ts +29 -0
- package/esm/formats/DecimalFormat.js +22 -0
- package/esm/formats/DecimalFormat.js.map +1 -0
- package/esm/formats/DecimalFormat.spec.d.ts +1 -0
- package/esm/formats/DecimalFormat.spec.js +22 -0
- package/esm/formats/DecimalFormat.spec.js.map +1 -0
- package/esm/formats/DurationFormat.d.ts +23 -0
- package/esm/formats/DurationFormat.js +35 -0
- package/esm/formats/DurationFormat.js.map +1 -0
- package/esm/formats/DurationFormat.spec.d.ts +1 -0
- package/esm/formats/DurationFormat.spec.js +52 -0
- package/esm/formats/DurationFormat.spec.js.map +1 -0
- package/esm/formats/RelativeTemporalFormat.d.ts +22 -0
- package/esm/formats/RelativeTemporalFormat.js +57 -0
- package/esm/formats/RelativeTemporalFormat.js.map +1 -0
- package/esm/formats/RelativeTemporalFormat.spec.d.ts +1 -0
- package/esm/formats/RelativeTemporalFormat.spec.js +77 -0
- package/esm/formats/RelativeTemporalFormat.spec.js.map +1 -0
- package/esm/formats/SwitchableTemporalFormat.d.ts +5 -0
- package/esm/formats/SwitchableTemporalFormat.js +11 -0
- package/esm/formats/SwitchableTemporalFormat.js.map +1 -0
- package/esm/formats/TemporalFormat.d.ts +27 -0
- package/esm/formats/TemporalFormat.js +19 -0
- package/esm/formats/TemporalFormat.js.map +1 -0
- package/esm/formats/TemporalFormat.spec.d.ts +1 -0
- package/esm/formats/TemporalFormat.spec.js +87 -0
- package/esm/formats/TemporalFormat.spec.js.map +1 -0
- package/esm/formats/TemporalRangeFormat.d.ts +30 -0
- package/esm/formats/TemporalRangeFormat.js +17 -0
- package/esm/formats/TemporalRangeFormat.js.map +1 -0
- package/esm/formats/TemporalRangeFormat.spec.d.ts +1 -0
- package/esm/formats/TemporalRangeFormat.spec.js +87 -0
- package/esm/formats/TemporalRangeFormat.spec.js.map +1 -0
- package/esm/formats/index.d.ts +8 -0
- package/esm/formats/index.js +9 -0
- package/esm/formats/index.js.map +1 -0
- package/esm/formats/types.d.ts +2 -0
- package/esm/formats/types.js +2 -0
- package/esm/formats/types.js.map +1 -0
- package/esm/formats/useDateTimeFormat.d.ts +2 -0
- package/esm/formats/useDateTimeFormat.js +7 -0
- package/esm/formats/useDateTimeFormat.js.map +1 -0
- package/esm/formats/useNumberFormat.d.ts +1 -0
- package/esm/formats/useNumberFormat.js +6 -0
- package/esm/formats/useNumberFormat.js.map +1 -0
- package/esm/formats/useRelativeTimeFormat.d.ts +1 -0
- package/esm/formats/useRelativeTimeFormat.js +6 -0
- package/esm/formats/useRelativeTimeFormat.js.map +1 -0
- package/esm/forms/EditForm.d.ts +13 -0
- package/esm/forms/EditForm.js +22 -0
- package/esm/forms/EditForm.js.map +1 -0
- package/esm/forms/SearchForm.d.ts +7 -0
- package/esm/forms/SearchForm.js +36 -0
- package/esm/forms/SearchForm.js.map +1 -0
- package/esm/forms/SubmitButton.d.ts +9 -0
- package/esm/forms/SubmitButton.js +28 -0
- package/esm/forms/SubmitButton.js.map +1 -0
- package/esm/forms/index.d.ts +4 -0
- package/esm/forms/index.js +5 -0
- package/esm/forms/index.js.map +1 -0
- package/esm/forms/useFormSubmit.d.ts +12 -0
- package/esm/forms/useFormSubmit.js +28 -0
- package/esm/forms/useFormSubmit.js.map +1 -0
- package/esm/getNavigatorLanguages.d.ts +5 -0
- package/esm/getNavigatorLanguages.js +11 -0
- package/esm/getNavigatorLanguages.js.map +1 -0
- package/esm/getSupportedFormatLocale.d.ts +19 -0
- package/esm/getSupportedFormatLocale.js +21 -0
- package/esm/getSupportedFormatLocale.js.map +1 -0
- package/esm/help/HelpButton.d.ts +12 -0
- package/esm/help/HelpButton.js +74 -0
- package/esm/help/HelpButton.js.map +1 -0
- package/esm/help/HelpDrawer.d.ts +3 -0
- package/esm/help/HelpDrawer.js +48 -0
- package/esm/help/HelpDrawer.js.map +1 -0
- package/esm/help/HelpSettingsContext.d.ts +26 -0
- package/esm/help/HelpSettingsContext.js +94 -0
- package/esm/help/HelpSettingsContext.js.map +1 -0
- package/esm/help/index.d.ts +3 -0
- package/esm/help/index.js +4 -0
- package/esm/help/index.js.map +1 -0
- package/esm/icons.d.ts +21 -0
- package/esm/icons.js +22 -0
- package/esm/icons.js.map +1 -0
- package/esm/index.d.ts +34 -0
- package/esm/index.js +35 -0
- package/esm/index.js.map +1 -0
- package/esm/layout/ErrorBoundary.d.ts +46 -0
- package/esm/layout/ErrorBoundary.js +186 -0
- package/esm/layout/ErrorBoundary.js.map +1 -0
- package/esm/layout/NotFound.d.ts +9 -0
- package/esm/layout/NotFound.js +26 -0
- package/esm/layout/NotFound.js.map +1 -0
- package/esm/layout/NotFoundSvg.d.ts +2 -0
- package/esm/layout/NotFoundSvg.js +37 -0
- package/esm/layout/NotFoundSvg.js.map +1 -0
- package/esm/layout/UserNav.d.ts +15 -0
- package/esm/layout/UserNav.js +50 -0
- package/esm/layout/UserNav.js.map +1 -0
- package/esm/layout/index.d.ts +5 -0
- package/esm/layout/index.js +6 -0
- package/esm/layout/index.js.map +1 -0
- package/esm/layout/layout-context.d.ts +9 -0
- package/esm/layout/layout-context.js +23 -0
- package/esm/layout/layout-context.js.map +1 -0
- package/esm/layout/page-title.d.ts +7 -0
- package/esm/layout/page-title.js +41 -0
- package/esm/layout/page-title.js.map +1 -0
- package/esm/list/List.d.ts +14 -0
- package/esm/list/List.js +25 -0
- package/esm/list/List.js.map +1 -0
- package/esm/list/SkeletonListItem.d.ts +14 -0
- package/esm/list/SkeletonListItem.js +11 -0
- package/esm/list/SkeletonListItem.js.map +1 -0
- package/esm/list/index.d.ts +1 -0
- package/esm/list/index.js +2 -0
- package/esm/list/index.js.map +1 -0
- package/esm/localization.d.ts +140 -0
- package/esm/localization.js +200 -0
- package/esm/localization.js.map +1 -0
- package/esm/logo/Logo.d.ts +7 -0
- package/esm/logo/Logo.js +29 -0
- package/esm/logo/Logo.js.map +1 -0
- package/esm/logo/VCAppLogo.d.ts +7 -0
- package/esm/logo/VCAppLogo.js +28 -0
- package/esm/logo/VCAppLogo.js.map +1 -0
- package/esm/logo/VCLogo.d.ts +4 -0
- package/esm/logo/VCLogo.js +33 -0
- package/esm/logo/VCLogo.js.map +1 -0
- package/esm/logo/VCLogoIcon.d.ts +4 -0
- package/esm/logo/VCLogoIcon.js +36 -0
- package/esm/logo/VCLogoIcon.js.map +1 -0
- package/esm/logo/index.d.ts +4 -0
- package/esm/logo/index.js +5 -0
- package/esm/logo/index.js.map +1 -0
- package/esm/splash/index.d.ts +3 -0
- package/esm/splash/index.js +37 -0
- package/esm/splash/index.js.map +1 -0
- package/esm/spring.d.ts +14 -0
- package/esm/spring.js +2 -0
- package/esm/spring.js.map +1 -0
- package/esm/storage/MemoryStorage.d.ts +7 -0
- package/esm/storage/MemoryStorage.js +18 -0
- package/esm/storage/MemoryStorage.js.map +1 -0
- package/esm/storage/index.d.ts +2 -0
- package/esm/storage/index.js +3 -0
- package/esm/storage/index.js.map +1 -0
- package/esm/storage/storage.d.ts +16 -0
- package/esm/storage/storage.js +87 -0
- package/esm/storage/storage.js.map +1 -0
- package/esm/storage/useStorage.d.ts +1 -0
- package/esm/storage/useStorage.js +29 -0
- package/esm/storage/useStorage.js.map +1 -0
- package/esm/tabs/Tabs.d.ts +10 -0
- package/esm/tabs/Tabs.js +95 -0
- package/esm/tabs/Tabs.js.map +1 -0
- package/esm/tabs/index.d.ts +1 -0
- package/esm/tabs/index.js +2 -0
- package/esm/tabs/index.js.map +1 -0
- package/esm/temporal/index.d.ts +2 -0
- package/esm/temporal/index.js +3 -0
- package/esm/temporal/index.js.map +1 -0
- package/esm/temporal/parse.d.ts +4 -0
- package/esm/temporal/parse.js +25 -0
- package/esm/temporal/parse.js.map +1 -0
- package/esm/temporal/polyfill.d.ts +34 -0
- package/esm/temporal/polyfill.js +10 -0
- package/esm/temporal/polyfill.js.map +1 -0
- package/esm/utils/defined.d.ts +1 -0
- package/esm/utils/defined.js +4 -0
- package/esm/utils/defined.js.map +1 -0
- package/esm/utils/index.d.ts +3 -0
- package/esm/utils/index.js +4 -0
- package/esm/utils/index.js.map +1 -0
- package/esm/utils/useFlag.d.ts +1 -0
- package/esm/utils/useFlag.js +9 -0
- package/esm/utils/useFlag.js.map +1 -0
- package/esm/utils/useIsMounted.d.ts +1 -0
- package/esm/utils/useIsMounted.js +12 -0
- package/esm/utils/useIsMounted.js.map +1 -0
- package/esm/view/View.d.ts +9 -0
- package/esm/view/View.js +22 -0
- package/esm/view/View.js.map +1 -0
- package/esm/view/ViewHeader.d.ts +10 -0
- package/esm/view/ViewHeader.js +15 -0
- package/esm/view/ViewHeader.js.map +1 -0
- package/esm/view/index.d.ts +2 -0
- package/esm/view/index.js +3 -0
- package/esm/view/index.js.map +1 -0
- package/package.json +72 -0
- package/src/AppShell/AppShell.tsx +165 -0
- package/src/AppShell/index.tsx +1 -0
- package/src/ErrorAlert.tsx +71 -0
- package/src/Input/ActionsMenu.tsx +102 -0
- package/src/Input/Checkbox.tsx +33 -0
- package/src/Input/EmailSenderField.tsx +64 -0
- package/src/Input/NumberField.tsx +127 -0
- package/src/Input/RadioGroup.tsx +37 -0
- package/src/Input/Select.tsx +33 -0
- package/src/Input/Selector.tsx +21 -0
- package/src/Input/Switch.tsx +33 -0
- package/src/Input/TextField.tsx +69 -0
- package/src/Input/UrlUploadField.tsx +84 -0
- package/src/Input/index.ts +9 -0
- package/src/LanguageSwitcher/LanguageSwitcher.tsx +63 -0
- package/src/LanguageSwitcher/index.ts +1 -0
- package/src/Paging/Paging.ts +77 -0
- package/src/Paging/index.ts +1 -0
- package/src/VCThemeProvider/JetbrainsMonoFont.tsx +55 -0
- package/src/VCThemeProvider/RobotoFont.tsx +52 -0
- package/src/VCThemeProvider/ThemeModeSwitcher.tsx +23 -0
- package/src/VCThemeProvider/VCThemeProvider.tsx +232 -0
- package/src/VCThemeProvider/code-colors.ts +34 -0
- package/src/VCThemeProvider/files.d.ts +2 -0
- package/src/VCThemeProvider/index.ts +5 -0
- package/src/audit/AuditChanges.tsx +82 -0
- package/src/audit/AuditTimeline.tsx +25 -0
- package/src/audit/AuditTimelineItem.tsx +75 -0
- package/src/audit/index.ts +4 -0
- package/src/audit/types.ts +46 -0
- package/src/breadcrumbs.tsx +27 -0
- package/src/code/Code.tsx +53 -0
- package/src/code/CodeBlock.tsx +15 -0
- package/src/code/Json.tsx +73 -0
- package/src/code/index.ts +3 -0
- package/src/confirm/ConfirmButton.tsx +69 -0
- package/src/confirm/ConfirmDialog.tsx +68 -0
- package/src/confirm/ConfirmIconButton.tsx +62 -0
- package/src/confirm/ConfirmMenuItem.tsx +66 -0
- package/src/confirm/index.ts +4 -0
- package/src/container/ContainerLayout.tsx +40 -0
- package/src/container/ContainerSettingsContext.tsx +77 -0
- package/src/container/ContainerWidthControl.tsx +20 -0
- package/src/container/index.ts +3 -0
- package/src/content-table/ContentTable.tsx +214 -0
- package/src/content-table/UndrawEmpty.tsx +285 -0
- package/src/content-table/index.ts +1 -0
- package/src/country/countries.ts +268 -0
- package/src/country/country-select.tsx +48 -0
- package/src/country/index.ts +5 -0
- package/src/country/locale-select.tsx +43 -0
- package/src/country/locales.ts +192 -0
- package/src/country/phone-prefix-select.tsx +50 -0
- package/src/cube/BoxFeatures.tsx +91 -0
- package/src/cube/BoxMaintenanceChip.tsx +33 -0
- package/src/cube/BoxNumber.tsx +10 -0
- package/src/cube/BoxType.tsx +22 -0
- package/src/cube/CubeConnectedChip.tsx +16 -0
- package/src/cube/LockStatusChip.tsx +54 -0
- package/src/cube/UtilizationBar.tsx +94 -0
- package/src/cube/accessibility.tsx +422 -0
- package/src/cube/index.tsx +8 -0
- package/src/data-table/DataTable.tsx +338 -0
- package/src/data-table/DataTableColumnSettings.tsx +204 -0
- package/src/data-table/DataTableHeader.tsx +10 -0
- package/src/data-table/DataTableToolbar.tsx +10 -0
- package/src/data-table/index.tsx +8 -0
- package/src/data-table/useDataTableColumnStorage.ts +26 -0
- package/src/data-table/useDataTableStorage.ts +43 -0
- package/src/data-table/useSpringPage.ts +21 -0
- package/src/data-table/useSpringPageable.ts +25 -0
- package/src/date-pickers/PlainAdapterCommon.ts +125 -0
- package/src/date-pickers/PlainDateAdapter.spec.ts +50 -0
- package/src/date-pickers/PlainDateAdapter.ts +139 -0
- package/src/date-pickers/PlainDatePicker.spec.tsx +22 -0
- package/src/date-pickers/PlainDatePicker.tsx +73 -0
- package/src/date-pickers/PlainDateTimeAdapter.spec.ts +50 -0
- package/src/date-pickers/PlainDateTimeAdapter.ts +140 -0
- package/src/date-pickers/PlainDateTimePicker.spec.tsx +22 -0
- package/src/date-pickers/PlainDateTimePicker.tsx +65 -0
- package/src/date-pickers/PlainTimeAdapter.ts +247 -0
- package/src/date-pickers/PlainTimePicker.spec.tsx +22 -0
- package/src/date-pickers/PlainTimePicker.tsx +45 -0
- package/src/date-pickers/TemporalAdapter.ts +150 -0
- package/src/date-pickers/TimezoneSelect.tsx +387 -0
- package/src/date-pickers/getFormatString.ts +38 -0
- package/src/date-pickers/index.ts +5 -0
- package/src/date-pickers/parse.spec.ts +43 -0
- package/src/date-pickers/parse.ts +72 -0
- package/src/date-pickers/timeframe-picker.tsx +202 -0
- package/src/date-pickers/useLocale.ts +6 -0
- package/src/date-pickers/useRenderInput.tsx +20 -0
- package/src/fetch.spec.ts +85 -0
- package/src/fetch.ts +165 -0
- package/src/filter/Filter.tsx +194 -0
- package/src/filter/index.ts +1 -0
- package/src/formats/CompactFormat.spec.tsx +25 -0
- package/src/formats/CompactFormat.tsx +48 -0
- package/src/formats/CurrencyFormat.spec.tsx +25 -0
- package/src/formats/CurrencyFormat.tsx +77 -0
- package/src/formats/DecimalFormat.spec.tsx +25 -0
- package/src/formats/DecimalFormat.tsx +59 -0
- package/src/formats/DurationFormat.spec.tsx +57 -0
- package/src/formats/DurationFormat.tsx +72 -0
- package/src/formats/RelativeTemporalFormat.spec.tsx +84 -0
- package/src/formats/RelativeTemporalFormat.tsx +86 -0
- package/src/formats/SwitchableTemporalFormat.tsx +17 -0
- package/src/formats/TemporalFormat.spec.tsx +110 -0
- package/src/formats/TemporalFormat.tsx +58 -0
- package/src/formats/TemporalRangeFormat.spec.tsx +159 -0
- package/src/formats/TemporalRangeFormat.tsx +62 -0
- package/src/formats/index.ts +8 -0
- package/src/formats/types.ts +4 -0
- package/src/formats/useDateTimeFormat.ts +7 -0
- package/src/formats/useNumberFormat.ts +6 -0
- package/src/formats/useRelativeTimeFormat.ts +6 -0
- package/src/forms/EditForm.tsx +69 -0
- package/src/forms/SearchForm.tsx +51 -0
- package/src/forms/SubmitButton.tsx +34 -0
- package/src/forms/index.ts +4 -0
- package/src/forms/useFormSubmit.tsx +28 -0
- package/src/getNavigatorLanguages.ts +11 -0
- package/src/getSupportedFormatLocale.ts +24 -0
- package/src/help/HelpButton.tsx +134 -0
- package/src/help/HelpDrawer.tsx +65 -0
- package/src/help/HelpSettingsContext.tsx +178 -0
- package/src/help/index.ts +3 -0
- package/src/icons.ts +23 -0
- package/src/index.ts +34 -0
- package/src/layout/ErrorBoundary.tsx +232 -0
- package/src/layout/NotFound.tsx +51 -0
- package/src/layout/NotFoundSvg.tsx +172 -0
- package/src/layout/UserNav.tsx +107 -0
- package/src/layout/index.ts +5 -0
- package/src/layout/layout-context.tsx +40 -0
- package/src/layout/page-title.tsx +33 -0
- package/src/list/List.tsx +40 -0
- package/src/list/SkeletonListItem.tsx +50 -0
- package/src/list/index.tsx +1 -0
- package/src/localization.tsx +404 -0
- package/src/logo/Logo.tsx +35 -0
- package/src/logo/VCAppLogo.tsx +28 -0
- package/src/logo/VCLogo.tsx +56 -0
- package/src/logo/VCLogoIcon.tsx +55 -0
- package/src/logo/V_C_LOGO.svg +1 -0
- package/src/logo/V_C_LOGO_ICON.svg +1 -0
- package/src/logo/V_C_LOGO_ICON_WHITE.svg +1 -0
- package/src/logo/V_C_LOGO_WHITE.svg +1 -0
- package/src/logo/index.tsx +4 -0
- package/src/splash/index.tsx +34 -0
- package/src/splash/template.html +86 -0
- package/src/spring.ts +15 -0
- package/src/storage/MemoryStorage.ts +21 -0
- package/src/storage/index.ts +2 -0
- package/src/storage/storage.ts +97 -0
- package/src/storage/useStorage.ts +35 -0
- package/src/tabs/Tabs.tsx +187 -0
- package/src/tabs/index.ts +1 -0
- package/src/temporal/index.ts +2 -0
- package/src/temporal/parse.ts +29 -0
- package/src/temporal/polyfill.ts +36 -0
- package/src/utils/defined.ts +4 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/useFlag.ts +9 -0
- package/src/utils/useIsMounted.ts +12 -0
- package/src/view/View.tsx +22 -0
- package/src/view/ViewHeader.tsx +35 -0
- package/src/view/index.ts +2 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type CurrencyDisplay = "symbol" | "name" | "narrowSymbol" | "code";
|
|
3
|
+
export type CurrencySign = "accounting" | "standard";
|
|
4
|
+
export interface CurrencyFormatProps {
|
|
5
|
+
/**
|
|
6
|
+
* The numeric amount of currency.
|
|
7
|
+
*/
|
|
8
|
+
value: number | bigint | null | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The 3-letter currency identifier.
|
|
11
|
+
*/
|
|
12
|
+
currency: string;
|
|
13
|
+
/**
|
|
14
|
+
* How to display the currency. Default depends on the browser.
|
|
15
|
+
*/
|
|
16
|
+
currencyDisplay?: CurrencyDisplay;
|
|
17
|
+
/**
|
|
18
|
+
* The currency sign to use. Default depends on the browser.
|
|
19
|
+
*/
|
|
20
|
+
currencySign?: CurrencySign;
|
|
21
|
+
/**
|
|
22
|
+
* Minimum fraction digits. Default depends on the browser.
|
|
23
|
+
*/
|
|
24
|
+
minimumFractionDigits?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum fraction digits. Default depends on the browser.
|
|
27
|
+
*/
|
|
28
|
+
maximumFractionDigits?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Overrides the user's locale. Use for testing only.
|
|
31
|
+
*/
|
|
32
|
+
locale?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns a string representing the specified `value` in the specified `currency` in the user's locale.
|
|
36
|
+
* @param props
|
|
37
|
+
* @constructor
|
|
38
|
+
*/
|
|
39
|
+
export declare function CurrencyFormat(props: CurrencyFormatProps): JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useNumberFormat } from "./useNumberFormat";
|
|
2
|
+
import { Fragment, useMemo } from "react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Returns a string representing the specified `value` in the specified `currency` in the user's locale.
|
|
6
|
+
* @param props
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
export function CurrencyFormat(props) {
|
|
10
|
+
const { value, currency, currencyDisplay, currencySign, minimumFractionDigits, maximumFractionDigits, locale, } = props;
|
|
11
|
+
const options = useMemo(() => ({
|
|
12
|
+
style: "currency",
|
|
13
|
+
currency,
|
|
14
|
+
currencyDisplay,
|
|
15
|
+
currencySign,
|
|
16
|
+
minimumFractionDigits,
|
|
17
|
+
maximumFractionDigits,
|
|
18
|
+
}), [currency, currencyDisplay, currencySign, minimumFractionDigits, maximumFractionDigits]);
|
|
19
|
+
const numberFormat = useNumberFormat(options, locale);
|
|
20
|
+
const str = useMemo(() => {
|
|
21
|
+
return (typeof value == "number" || typeof value == "bigint") ? numberFormat.format(value) : "";
|
|
22
|
+
}, [numberFormat, value]);
|
|
23
|
+
return React.createElement(Fragment, null, str);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CurrencyFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrencyFormat.js","sourceRoot":"","sources":["../../src/formats/CurrencyFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA0C/B;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACrD,MAAM,EACF,KAAK,EACL,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,GACT,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3B,KAAK,EAAE,UAAU;QACjB,QAAQ;QACR,eAAe;QACf,YAAY;QACZ,qBAAqB;QACrB,qBAAqB;KACxB,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAE7F,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;QACrB,OAAO,CAAC,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpG,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1B,OAAO,oBAAC,QAAQ,QAAE,GAAG,CAAY,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { act, create } from "react-test-renderer";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { CurrencyFormat } from "./CurrencyFormat";
|
|
4
|
+
describe("CurrencyFormat", () => {
|
|
5
|
+
test("render de-AT", () => {
|
|
6
|
+
let element;
|
|
7
|
+
act(() => {
|
|
8
|
+
element = create(React.createElement(CurrencyFormat, { value: 1234.5, currency: "EUR", locale: "de-AT" }));
|
|
9
|
+
});
|
|
10
|
+
const value = element.root.children[0];
|
|
11
|
+
expect(value).toBe("€\u00a01.234,50"); // \u00a0 is a non-breaking space
|
|
12
|
+
});
|
|
13
|
+
test("render en-US", () => {
|
|
14
|
+
let element;
|
|
15
|
+
act(() => {
|
|
16
|
+
element = create(React.createElement(CurrencyFormat, { value: 1234.5, currency: "USD", locale: "en-US" }));
|
|
17
|
+
});
|
|
18
|
+
const value = element.root.children[0];
|
|
19
|
+
expect(value).toBe("$1,234.50");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=CurrencyFormat.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrencyFormat.spec.js","sourceRoot":"","sources":["../../src/formats/CurrencyFormat.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAE5B,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACL,OAAO,GAAG,MAAM,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAC,KAAK,EAAC,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACtF,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,iCAAiC;IAC5E,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACL,OAAO,GAAG,MAAM,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAC,KAAK,EAAC,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACtF,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface DecimalFormatProps {
|
|
3
|
+
/**
|
|
4
|
+
* The numeric amount of currency.
|
|
5
|
+
*/
|
|
6
|
+
value: number | bigint | null | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Minimum fraction digits. Default depends on the browser.
|
|
9
|
+
*/
|
|
10
|
+
minimumFractionDigits?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum fraction digits. Default depends on the browser.
|
|
13
|
+
*/
|
|
14
|
+
maximumFractionDigits?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Fraction digits. Shorthand to set both `minimumFractionDigits` and `maximumFractionDigits`.
|
|
17
|
+
*/
|
|
18
|
+
fractionDigits?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Overrides the user's locale. Use for testing only.
|
|
21
|
+
*/
|
|
22
|
+
locale?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns a string representing the specified `value` formatted according to the user's locale.
|
|
26
|
+
* @param props
|
|
27
|
+
* @constructor
|
|
28
|
+
*/
|
|
29
|
+
export declare function DecimalFormat(props: DecimalFormatProps): JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useNumberFormat } from "./useNumberFormat";
|
|
2
|
+
import { Fragment, useMemo } from "react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Returns a string representing the specified `value` formatted according to the user's locale.
|
|
6
|
+
* @param props
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
export function DecimalFormat(props) {
|
|
10
|
+
const { value, fractionDigits, minimumFractionDigits = fractionDigits, maximumFractionDigits = fractionDigits, locale, } = props;
|
|
11
|
+
const options = useMemo(() => ({
|
|
12
|
+
style: "decimal",
|
|
13
|
+
minimumFractionDigits,
|
|
14
|
+
maximumFractionDigits,
|
|
15
|
+
}), [minimumFractionDigits, maximumFractionDigits]);
|
|
16
|
+
const numberFormat = useNumberFormat(options, locale);
|
|
17
|
+
const str = useMemo(() => {
|
|
18
|
+
return (typeof value == "number" || typeof value == "bigint") ? numberFormat.format(value) : "";
|
|
19
|
+
}, [numberFormat, value]);
|
|
20
|
+
return React.createElement(Fragment, null, str);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=DecimalFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecimalFormat.js","sourceRoot":"","sources":["../../src/formats/DecimalFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA6B/B;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACnD,MAAM,EACF,KAAK,EACL,cAAc,EACd,qBAAqB,GAAG,cAAc,EACtC,qBAAqB,GAAG,cAAc,EACtC,MAAM,GACT,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3B,KAAK,EAAE,SAAS;QAChB,qBAAqB;QACrB,qBAAqB;KACxB,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;QACrB,OAAO,CAAC,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpG,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1B,OAAO,oBAAC,QAAQ,QAAE,GAAG,CAAY,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { act, create } from "react-test-renderer";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { DecimalFormat } from "./DecimalFormat";
|
|
4
|
+
describe("DecimalFormat", () => {
|
|
5
|
+
test("render de-AT", () => {
|
|
6
|
+
let element;
|
|
7
|
+
act(() => {
|
|
8
|
+
element = create(React.createElement(DecimalFormat, { value: 1234.5, locale: "de-AT" }));
|
|
9
|
+
});
|
|
10
|
+
const value = element.root.children[0];
|
|
11
|
+
expect(value).toBe("1\u00a0234,5");
|
|
12
|
+
});
|
|
13
|
+
test("render en-US", () => {
|
|
14
|
+
let element;
|
|
15
|
+
act(() => {
|
|
16
|
+
element = create(React.createElement(DecimalFormat, { value: 1234.5, locale: "en-US" }));
|
|
17
|
+
});
|
|
18
|
+
const value = element.root.children[0];
|
|
19
|
+
expect(value).toBe("1,234.5");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=DecimalFormat.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecimalFormat.spec.js","sourceRoot":"","sources":["../../src/formats/DecimalFormat.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAE3B,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACL,OAAO,GAAG,MAAM,CAAC,oBAAC,aAAa,IAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACtE,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACL,OAAO,GAAG,MAAM,CAAC,oBAAC,aAAa,IAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACtE,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Duration } from "../temporal";
|
|
3
|
+
import { DateStyle, TimeStyle } from "./types";
|
|
4
|
+
interface DurationFormatProps {
|
|
5
|
+
/**
|
|
6
|
+
* The duration value to format.
|
|
7
|
+
*/
|
|
8
|
+
value?: Duration | null | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The style of the date format.
|
|
11
|
+
*/
|
|
12
|
+
dateStyle?: DateStyle | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The style of the time format.
|
|
15
|
+
*/
|
|
16
|
+
timeStyle?: TimeStyle | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides the user's locale. Use for testing only.
|
|
19
|
+
*/
|
|
20
|
+
locale?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function DurationFormat(props: DurationFormatProps): JSX.Element | null;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getSupportedFormatLocale } from "../getSupportedFormatLocale";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Fragment, useMemo } from "react";
|
|
4
|
+
export function DurationFormat(props) {
|
|
5
|
+
const { value, dateStyle, timeStyle, locale: suppliedLocale } = props;
|
|
6
|
+
if (!value) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const options = useMemo(() => ({
|
|
10
|
+
dateStyle,
|
|
11
|
+
timeStyle,
|
|
12
|
+
}), [dateStyle, timeStyle]);
|
|
13
|
+
const locale = useMemo(() => suppliedLocale !== null && suppliedLocale !== void 0 ? suppliedLocale : getSupportedFormatLocale("dateTime"), [suppliedLocale]);
|
|
14
|
+
const strValue = useMemo(() => {
|
|
15
|
+
// TODO: this can only be supported once a polyfill or browser support for DurationFormat is available
|
|
16
|
+
// https://github.com/tc39/proposal-intl-duration-format/
|
|
17
|
+
// In the meantime, we format the duration in a simple neural format.
|
|
18
|
+
return formatDuration(value);
|
|
19
|
+
}, [value, locale, options]);
|
|
20
|
+
return React.createElement(Fragment, null, strValue);
|
|
21
|
+
}
|
|
22
|
+
function formatDuration(value) {
|
|
23
|
+
const parts = ["years", "months", "weeks", "days"]
|
|
24
|
+
.map(prop => [prop, value[prop]])
|
|
25
|
+
.filter(([_, value]) => Boolean(value))
|
|
26
|
+
.map(([prop, value]) => value + prop.charAt(0));
|
|
27
|
+
if (value.hours || value.minutes || value.seconds) {
|
|
28
|
+
const time = [value.hours || 0, value.minutes || 0, value.seconds]
|
|
29
|
+
.map(value => value.toString().padStart(2, "0"))
|
|
30
|
+
.join(":");
|
|
31
|
+
parts.push(time);
|
|
32
|
+
}
|
|
33
|
+
return parts.join(" ");
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=DurationFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DurationFormat.js","sourceRoot":"","sources":["../../src/formats/DurationFormat.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,wBAAwB,EAAC,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAyBxC,MAAM,UAAU,cAAc,CAAC,KAA0B;IACrD,MAAM,EACF,KAAK,EACL,SAAS,EACT,SAAS,EACT,MAAM,EAAE,cAAc,EACzB,GAAG,KAAK,CAAC;IAEV,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3B,SAAS;QACT,SAAS;KACZ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE5B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAEvG,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,sGAAsG;QACtG,yDAAyD;QACzD,qEAAqE;QAC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as React from "react";
|
|
3
|
+
import { DurationFormat } from "./DurationFormat";
|
|
4
|
+
import { Duration, Now } from "../temporal";
|
|
5
|
+
describe("DurationFormat", () => {
|
|
6
|
+
test("render de-AT", () => {
|
|
7
|
+
let element;
|
|
8
|
+
act(() => {
|
|
9
|
+
element = create(React.createElement(DurationFormat, { value: Duration.from({ days: 5, hours: 2, seconds: 2 }), locale: "de-AT" }));
|
|
10
|
+
});
|
|
11
|
+
const value = element.root.children[0];
|
|
12
|
+
expect(value).toBe("5d 02:00:02");
|
|
13
|
+
});
|
|
14
|
+
test("render en-US", () => {
|
|
15
|
+
let element;
|
|
16
|
+
act(() => {
|
|
17
|
+
element = create(React.createElement(DurationFormat, { value: Duration.from({ days: 5, hours: 2, seconds: 2 }), locale: "en-US" }));
|
|
18
|
+
});
|
|
19
|
+
const value = element.root.children[0];
|
|
20
|
+
expect(value).toBe("5d 02:00:02");
|
|
21
|
+
});
|
|
22
|
+
test("balance seconds de-AT", () => {
|
|
23
|
+
let element;
|
|
24
|
+
act(() => {
|
|
25
|
+
const duration = Now.instant().until(Now.instant().add({ seconds: 10000 }))
|
|
26
|
+
.round({ largestUnit: "hours" });
|
|
27
|
+
element = create(React.createElement(DurationFormat, { value: duration, locale: "de-AT" }));
|
|
28
|
+
});
|
|
29
|
+
const value = element.root.children[0];
|
|
30
|
+
expect(value).toBe("02:46:40");
|
|
31
|
+
});
|
|
32
|
+
test("balance days de-AT", () => {
|
|
33
|
+
let element;
|
|
34
|
+
act(() => {
|
|
35
|
+
const duration = Now.instant().until(Now.instant().add({ hours: 5 * 24 }))
|
|
36
|
+
.round({ largestUnit: "days" });
|
|
37
|
+
element = create(React.createElement(DurationFormat, { value: duration, locale: "de-AT" }));
|
|
38
|
+
});
|
|
39
|
+
const value = element.root.children[0];
|
|
40
|
+
expect(value).toBe("5d");
|
|
41
|
+
});
|
|
42
|
+
test("complex de-AT", () => {
|
|
43
|
+
let element;
|
|
44
|
+
act(() => {
|
|
45
|
+
const duration = Duration.from({ years: 3, months: 4, weeks: 1, days: 6 });
|
|
46
|
+
element = create(React.createElement(DurationFormat, { value: duration, locale: "de-AT" }));
|
|
47
|
+
});
|
|
48
|
+
const value = element.root.children[0];
|
|
49
|
+
expect(value).toBe("3y 4m 1w 6d");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=DurationFormat.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DurationFormat.spec.js","sourceRoot":"","sources":["../../src/formats/DurationFormat.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAE,GAAG,EAAC,MAAM,aAAa,CAAC;AAE1C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAE5B,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACL,OAAO,GAAG,MAAM,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC,CAAC,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YAC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,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAC,CAAC,CAAC;iBACnE,KAAK,CAAC,EAAC,WAAW,EAAE,MAAM,EAAC,CAAC,CAAC;YAClC,OAAO,GAAG,MAAM,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACzE,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QACvB,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACL,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC;YACzE,OAAO,GAAG,MAAM,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACzE,CAAC,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Instant, PlainDate, PlainDateTime, ZonedDateTime } from "../temporal";
|
|
3
|
+
export interface RelativeTemporalFormatProps {
|
|
4
|
+
/** The value to format. */
|
|
5
|
+
value?: PlainDate | PlainDateTime | ZonedDateTime | Instant | null | undefined;
|
|
6
|
+
/** The format of output message. */
|
|
7
|
+
numeric?: "always" | "auto" | undefined;
|
|
8
|
+
/** The length of the internationalized message */
|
|
9
|
+
style?: "long" | "short" | "narrow" | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Overrides the user's locale. Use for testing only.
|
|
12
|
+
*/
|
|
13
|
+
locale?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns a Temporal type formatted as relative time.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useRelativeTemporalFormat(props: RelativeTemporalFormatProps): string;
|
|
19
|
+
/**
|
|
20
|
+
* Displays a Temporal type formatted as relative time.
|
|
21
|
+
*/
|
|
22
|
+
export declare function RelativeTemporalFormat(props: RelativeTemporalFormatProps): JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, useMemo } from "react";
|
|
3
|
+
import { Instant, Now, PlainDate, PlainDateTime, ZonedDateTime } from "../temporal";
|
|
4
|
+
import { useRelativeTimeFormat } from "./useRelativeTimeFormat";
|
|
5
|
+
/**
|
|
6
|
+
* Returns a Temporal type formatted as relative time.
|
|
7
|
+
*/
|
|
8
|
+
export function useRelativeTemporalFormat(props) {
|
|
9
|
+
const { value, numeric = "auto", style, locale, } = props;
|
|
10
|
+
const options = useMemo(() => ({
|
|
11
|
+
numeric,
|
|
12
|
+
style,
|
|
13
|
+
}), [numeric, style]);
|
|
14
|
+
// Convert the given value to a duration relative to "now", rounded to the largest unit.
|
|
15
|
+
// Unfortunately this is not straightforward and there might even be bugs in the polyfill.
|
|
16
|
+
const duration = useMemo(() => {
|
|
17
|
+
if (value instanceof PlainDate) {
|
|
18
|
+
const relativeTo = Now.plainDateISO();
|
|
19
|
+
return value.since(relativeTo, { largestUnit: "auto" })
|
|
20
|
+
.round({ largestUnit: "years", relativeTo });
|
|
21
|
+
}
|
|
22
|
+
if (value instanceof PlainDateTime) {
|
|
23
|
+
const relativeTo = Now.plainDateTimeISO();
|
|
24
|
+
return value.since(relativeTo, { largestUnit: "auto" })
|
|
25
|
+
.round({ largestUnit: "years", relativeTo });
|
|
26
|
+
}
|
|
27
|
+
if (value instanceof ZonedDateTime) {
|
|
28
|
+
const relativeTo = Now.zonedDateTimeISO();
|
|
29
|
+
return value.since(relativeTo, { largestUnit: "auto" })
|
|
30
|
+
.round({ largestUnit: "years", relativeTo });
|
|
31
|
+
}
|
|
32
|
+
if (value instanceof Instant) {
|
|
33
|
+
const now = Now.instant();
|
|
34
|
+
const relativeTo = now.toZonedDateTimeISO(Now.timeZone());
|
|
35
|
+
return value.since(now, { largestUnit: "auto" })
|
|
36
|
+
.round({ largestUnit: "years", relativeTo }) // first time rounds to hours
|
|
37
|
+
.round({ largestUnit: "years", relativeTo }); // second time round to years
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}, [value]);
|
|
41
|
+
const format = useRelativeTimeFormat(options, locale);
|
|
42
|
+
return useMemo(() => {
|
|
43
|
+
return duration ? format.format(...convertDuration(duration)) : "";
|
|
44
|
+
}, [format, duration]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Displays a Temporal type formatted as relative time.
|
|
48
|
+
*/
|
|
49
|
+
export function RelativeTemporalFormat(props) {
|
|
50
|
+
return React.createElement(Fragment, null, useRelativeTemporalFormat(props));
|
|
51
|
+
}
|
|
52
|
+
function convertDuration(duration) {
|
|
53
|
+
const props = ["years", "months", "weeks", "days", "hours", "minutes", "seconds"];
|
|
54
|
+
const prop = props.find(prop => Boolean(duration[prop]));
|
|
55
|
+
return prop ? [duration[prop], prop] : [0, "seconds"];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=RelativeTemporalFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelativeTemporalFormat.js","sourceRoot":"","sources":["../../src/formats/RelativeTemporalFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,C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AAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;IAC3F,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { act, create } from "react-test-renderer";
|
|
3
|
+
import { Now } from "../temporal";
|
|
4
|
+
import { RelativeTemporalFormat } from "./RelativeTemporalFormat";
|
|
5
|
+
describe("RelativeTemporalFormat", () => {
|
|
6
|
+
test("plainDate de-AT", () => {
|
|
7
|
+
let element;
|
|
8
|
+
act(() => {
|
|
9
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.plainDateISO().subtract({ days: 1 }), locale: "de-AT" }));
|
|
10
|
+
});
|
|
11
|
+
const value = element.root.children[0];
|
|
12
|
+
expect(value).toBe("gestern");
|
|
13
|
+
});
|
|
14
|
+
test("plainDate en-US", () => {
|
|
15
|
+
let element;
|
|
16
|
+
act(() => {
|
|
17
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.plainDateISO().subtract({ days: 1 }), locale: "en-US" }));
|
|
18
|
+
});
|
|
19
|
+
const value = element.root.children[0];
|
|
20
|
+
expect(value).toBe("yesterday");
|
|
21
|
+
});
|
|
22
|
+
// TODO: Does not round correctly on Node, but works in browser
|
|
23
|
+
test.skip("plainDateTime de-AT", () => {
|
|
24
|
+
let element;
|
|
25
|
+
act(() => {
|
|
26
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.plainDateTimeISO().add({ hours: 3 }), locale: "de-AT" }));
|
|
27
|
+
});
|
|
28
|
+
const value = element.root.children[0];
|
|
29
|
+
expect(value).toBe("in 3 Stunden");
|
|
30
|
+
});
|
|
31
|
+
// TODO: Does not round correctly on Node, but works in browser
|
|
32
|
+
test.skip("plainDateTime en-US", () => {
|
|
33
|
+
let element;
|
|
34
|
+
act(() => {
|
|
35
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.plainDateTimeISO().add({ hours: 3 }), locale: "en-US" }));
|
|
36
|
+
});
|
|
37
|
+
const value = element.root.children[0];
|
|
38
|
+
expect(value).toBe("in 3 hours");
|
|
39
|
+
});
|
|
40
|
+
// TODO: Does not round correctly on Node, but works in browser
|
|
41
|
+
test.skip("zonedDateTime de-AT", () => {
|
|
42
|
+
let element;
|
|
43
|
+
act(() => {
|
|
44
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.zonedDateTimeISO().add({ hours: 3 }), locale: "de-AT" }));
|
|
45
|
+
});
|
|
46
|
+
const value = element.root.children[0];
|
|
47
|
+
expect(value).toBe("in 3 Stunden");
|
|
48
|
+
});
|
|
49
|
+
// TODO: Does not round correctly on Node, but works in browser
|
|
50
|
+
test.skip("zonedDateTime en-US", () => {
|
|
51
|
+
let element;
|
|
52
|
+
act(() => {
|
|
53
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.zonedDateTimeISO().add({ hours: 3 }), locale: "en-US" }));
|
|
54
|
+
});
|
|
55
|
+
const value = element.root.children[0];
|
|
56
|
+
expect(value).toBe("in 3 hours");
|
|
57
|
+
});
|
|
58
|
+
// TODO: Does not round correctly on Node, but works in browser
|
|
59
|
+
test.skip("instant de-AT", () => {
|
|
60
|
+
let element;
|
|
61
|
+
act(() => {
|
|
62
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.instant().add({ hours: 3 }), locale: "de-AT" }));
|
|
63
|
+
});
|
|
64
|
+
const value = element.root.children[0];
|
|
65
|
+
expect(value).toBe("in 3 Stunden");
|
|
66
|
+
});
|
|
67
|
+
// TODO: Does not round correctly on Node, but works in browser
|
|
68
|
+
test.skip("instant en-US", () => {
|
|
69
|
+
let element;
|
|
70
|
+
act(() => {
|
|
71
|
+
element = create(React.createElement(RelativeTemporalFormat, { value: Now.instant().add({ hours: 3 }), locale: "en-US" }));
|
|
72
|
+
});
|
|
73
|
+
const value = element.root.children[0];
|
|
74
|
+
expect(value).toBe("in 3 hours");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=RelativeTemporalFormat.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelativeTemporalFormat.spec.js","sourceRoot":"","sources":["../../src/formats/RelativeTemporalFormat.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,GAAG,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAEhE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACvC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC5B,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACR,OAAO,GAAG,MAAM,CAAC,oBAAC,sBAAsB,IAAC,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QAC5G,CAAC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC5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AC;IAEH,+DAA+D;IAC/D,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QAC/B,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACR,OAAO,GAAG,MAAM,CAAC,oBAAC,sBAAsB,IAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACnG,CAAC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QAC/B,IAAI,OAA0B,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE;YACR,OAAO,GAAG,MAAM,CAAC,oBAAC,sBAAsB,IAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,EAAE,MAAM,EAAC,OAAO,GAAG,CAAC,CAAC;QACnG,CAAC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,OAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RelativeTemporalFormatProps } from "./RelativeTemporalFormat";
|
|
3
|
+
import { TemporalFormatProps } from "./TemporalFormat";
|
|
4
|
+
export type SwitchableTemporalFormatProps = TemporalFormatProps & RelativeTemporalFormatProps;
|
|
5
|
+
export declare function SwitchableTemporalFormat(props: SwitchableTemporalFormatProps): JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useFlag } from "../utils";
|
|
3
|
+
import { useRelativeTemporalFormat } from "./RelativeTemporalFormat";
|
|
4
|
+
import { useTemporalFormat } from "./TemporalFormat";
|
|
5
|
+
export function SwitchableTemporalFormat(props) {
|
|
6
|
+
const [isRelative, , , toggleRelative] = useFlag(true);
|
|
7
|
+
const relative = useRelativeTemporalFormat(props);
|
|
8
|
+
const absolute = useTemporalFormat(props);
|
|
9
|
+
return (React.createElement("abbr", { title: isRelative ? absolute : relative, onClick: toggleRelative }, isRelative ? relative : absolute));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=SwitchableTemporalFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchableTemporalFormat.js","sourceRoot":"","sources":["../../src/formats/SwitchableTemporalFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AACjC,OAAO,EAA8B,yBAAyB,EAAC,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAsB,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAIxE,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC5E,MAAM,CAAC,UAAU,EAAE,AAAD,EAAG,AAAD,EAAG,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,CACN,8BAAM,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,IACpE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAC3B,CACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Formattable } from "../temporal";
|
|
3
|
+
import { DateStyle, TimeStyle } from "./types";
|
|
4
|
+
export interface TemporalFormatProps {
|
|
5
|
+
/**
|
|
6
|
+
* The date value to format.
|
|
7
|
+
*/
|
|
8
|
+
value?: Formattable | null | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The style of the date format.
|
|
11
|
+
*/
|
|
12
|
+
dateStyle?: DateStyle | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The style of the time format.
|
|
15
|
+
*/
|
|
16
|
+
timeStyle?: TimeStyle | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides the user's locale. Use for testing only.
|
|
19
|
+
*/
|
|
20
|
+
locale?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Overrides the user's time zone. Use for testing only.
|
|
23
|
+
*/
|
|
24
|
+
timeZone?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function useTemporalFormat(props: TemporalFormatProps): string;
|
|
27
|
+
export declare function TemporalFormat(props: TemporalFormatProps): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, useMemo } from "react";
|
|
3
|
+
import { useDateTimeFormat } from "./useDateTimeFormat";
|
|
4
|
+
export function useTemporalFormat(props) {
|
|
5
|
+
const { value, dateStyle, timeStyle, locale, timeZone, } = props;
|
|
6
|
+
const options = useMemo(() => ({
|
|
7
|
+
dateStyle,
|
|
8
|
+
timeStyle,
|
|
9
|
+
timeZone,
|
|
10
|
+
}), [dateStyle, timeStyle]);
|
|
11
|
+
const dateTimeFormat = useDateTimeFormat(options, locale);
|
|
12
|
+
return useMemo(() => {
|
|
13
|
+
return value != null ? dateTimeFormat.format(value) : "";
|
|
14
|
+
}, [dateTimeFormat, value]);
|
|
15
|
+
}
|
|
16
|
+
export function TemporalFormat(props) {
|
|
17
|
+
return React.createElement(Fragment, null, useTemporalFormat(props));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=TemporalFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemporalFormat.js","sourceRoot":"","sources":["../../src/formats/TemporalFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AA6BtD,MAAM,UAAU,iBAAiB,CAAC,KAA0B;IAC3D,MAAM,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9B,SAAS;QACT,SAAS;QACT,QAAQ;KACR,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE5B,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAE1D,OAAO,OAAO,CAAC,GAAG,EAAE;QACnB,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAA0B;IACxD,OAAO,oBAAC,QAAQ,QAAE,iBAAiB,CAAC,KAAK,CAAC,CAAY,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|