@talxis/base-controls 1.2502.1 → 1.2503.2
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/dist/components/DatasetControl/DatasetControl.js +21 -34
- package/dist/components/DatasetControl/DatasetControl.js.map +1 -1
- package/dist/components/DatasetControl/ErrorBoundary.js +33 -0
- package/dist/components/DatasetControl/ErrorBoundary.js.map +1 -0
- package/dist/components/DatasetControl/QuickFind/QuickFind.d.ts +10 -0
- package/dist/components/DatasetControl/QuickFind/QuickFind.js +38 -0
- package/dist/components/DatasetControl/QuickFind/QuickFind.js.map +1 -0
- package/dist/components/DatasetControl/styles.d.ts +3 -1
- package/dist/components/DatasetControl/styles.js +2 -2
- package/dist/components/DatasetControl/styles.js.map +1 -1
- package/dist/components/DatasetControl/translations.d.ts +8 -0
- package/dist/components/DatasetControl/translations.js +3 -1
- package/dist/components/DatasetControl/translations.js.map +1 -1
- package/dist/components/DateTime/DateTime.js +2 -1
- package/dist/components/DateTime/DateTime.js.map +1 -1
- package/dist/components/DateTime/components/Calendar.d.ts +2 -1
- package/dist/components/DateTime/components/Calendar.js +4 -4
- package/dist/components/DateTime/components/Calendar.js.map +1 -1
- package/dist/components/DateTime/hooks/useDateTime.js +18 -17
- package/dist/components/DateTime/hooks/useDateTime.js.map +1 -1
- package/dist/components/Decimal/Decimal.js +5 -1
- package/dist/components/Decimal/Decimal.js.map +1 -1
- package/dist/components/Duration/Duration.js +49 -26
- package/dist/components/Duration/Duration.js.map +1 -1
- package/dist/components/Grid/Grid.js +1 -1
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js +78 -174
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/context.d.ts +3 -0
- package/dist/components/Grid/core/components/AgGrid/context.js +6 -0
- package/dist/components/Grid/core/components/AgGrid/context.js.map +1 -0
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +40 -5
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js +235 -49
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/model/Comparator.d.ts +9 -0
- package/dist/components/Grid/core/components/AgGrid/model/Comparator.js +86 -0
- package/dist/components/Grid/core/components/AgGrid/model/Comparator.js.map +1 -0
- package/dist/components/Grid/core/components/AgGrid/styles.d.ts +28 -32
- package/dist/components/Grid/core/components/AgGrid/styles.js +31 -35
- package/dist/components/Grid/core/components/AgGrid/styles.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/Cell.d.ts +13 -0
- package/dist/components/Grid/core/components/Cell/Cell.js +145 -0
- package/dist/components/Grid/core/components/Cell/Cell.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/CellContent/CellContent.d.ts +3 -0
- package/dist/components/Grid/core/components/Cell/CellContent/CellContent.js +212 -0
- package/dist/components/Grid/core/components/Cell/CellContent/CellContent.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/CellContent/styles.d.ts +33 -0
- package/dist/components/Grid/core/components/Cell/CellContent/styles.js +39 -0
- package/dist/components/Grid/core/components/Cell/CellContent/styles.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/Commands/Commands.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/Notifications/Notifications.d.ts +12 -0
- package/dist/components/Grid/core/components/Cell/Notifications/Notifications.js +112 -0
- package/dist/components/Grid/core/components/Cell/Notifications/Notifications.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/Notifications/styles.d.ts +39 -0
- package/dist/components/Grid/core/components/Cell/Notifications/styles.js +46 -0
- package/dist/components/Grid/core/components/Cell/Notifications/styles.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/styles.d.ts +40 -0
- package/dist/components/Grid/core/components/Cell/styles.js +59 -0
- package/dist/components/Grid/core/components/Cell/styles.js.map +1 -0
- package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.js +3 -2
- package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.js.map +1 -1
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.js +31 -13
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.js.map +1 -1
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.d.ts +3 -2
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.js +5 -4
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.js.map +1 -1
- package/dist/components/Grid/core/components/ColumnHeader/styles.d.ts +3 -1
- package/dist/components/Grid/core/components/ColumnHeader/styles.js +4 -2
- package/dist/components/Grid/core/components/ColumnHeader/styles.js.map +1 -1
- package/dist/components/Grid/core/components/Save/Save.js +5 -6
- package/dist/components/Grid/core/components/Save/Save.js.map +1 -1
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.js +10 -7
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.js.map +1 -1
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.d.ts +1 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.js +26 -7
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.js.map +1 -1
- package/dist/components/Grid/core/controllers/useGridController.js +8 -2
- package/dist/components/Grid/core/controllers/useGridController.js.map +1 -1
- package/dist/components/Grid/core/interfaces/IGridColumn.d.ts +2 -0
- package/dist/components/Grid/core/model/Grid.d.ts +16 -7
- package/dist/components/Grid/core/model/Grid.js +230 -45
- package/dist/components/Grid/core/model/Grid.js.map +1 -1
- package/dist/components/Grid/core/model/Metadata.d.ts +2 -1
- package/dist/components/Grid/core/services/KeyListener.d.ts +2 -0
- package/dist/components/Grid/core/services/KeyListener.js +6 -3
- package/dist/components/Grid/core/services/KeyListener.js.map +1 -1
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.js +3 -3
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.js.map +1 -1
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.d.ts +19 -7
- package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/Component.d.ts +2 -2
- package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/Component.js +9 -9
- package/dist/components/Grid/filtering/components/FilterCallout/components/LegacyControlRendering/Component.js.map +1 -0
- package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/controller/useComponentController.d.ts +2 -2
- package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/controller/useComponentController.js +1 -1
- package/dist/components/Grid/filtering/components/FilterCallout/components/LegacyControlRendering/controller/useComponentController.js.map +1 -0
- package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/model/Component.d.ts +2 -2
- package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/model/Component.js +15 -19
- package/dist/components/Grid/filtering/components/FilterCallout/components/LegacyControlRendering/model/Component.js.map +1 -0
- package/dist/components/Grid/filtering/model/Condition.js +1 -1
- package/dist/components/Grid/filtering/model/Condition.js.map +1 -1
- package/dist/components/Grid/selection/model/Selection.d.ts +3 -4
- package/dist/components/Grid/selection/model/Selection.js +8 -26
- package/dist/components/Grid/selection/model/Selection.js.map +1 -1
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js +1 -1
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js.map +1 -1
- package/dist/components/GridCellRenderer/DefaultContentRenderer/DefaultContentRenderer.d.ts +2 -0
- package/dist/components/GridCellRenderer/DefaultContentRenderer/DefaultContentRenderer.js +11 -0
- package/dist/components/GridCellRenderer/DefaultContentRenderer/DefaultContentRenderer.js.map +1 -0
- package/dist/components/GridCellRenderer/DefaultContentRenderer/index.d.ts +1 -0
- package/dist/components/GridCellRenderer/DefaultContentRenderer/index.js +2 -0
- package/dist/components/GridCellRenderer/DefaultContentRenderer/index.js.map +1 -0
- package/dist/components/GridCellRenderer/GridCellRenderer.d.ts +3 -0
- package/dist/components/GridCellRenderer/GridCellRenderer.js +252 -0
- package/dist/components/GridCellRenderer/GridCellRenderer.js.map +1 -0
- package/dist/components/GridCellRenderer/OptionSet/OptionSet.d.ts +5 -0
- package/dist/components/GridCellRenderer/OptionSet/OptionSet.js +69 -0
- package/dist/components/GridCellRenderer/OptionSet/OptionSet.js.map +1 -0
- package/dist/components/GridCellRenderer/OptionSet/index.d.ts +1 -0
- package/dist/components/GridCellRenderer/OptionSet/index.js +2 -0
- package/dist/components/GridCellRenderer/OptionSet/index.js.map +1 -0
- package/dist/components/{Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet → GridCellRenderer/OptionSet}/styles.d.ts +10 -12
- package/dist/components/GridCellRenderer/OptionSet/styles.js +29 -0
- package/dist/components/GridCellRenderer/OptionSet/styles.js.map +1 -0
- package/dist/components/GridCellRenderer/index.d.ts +1 -0
- package/dist/components/GridCellRenderer/index.js +2 -0
- package/dist/components/GridCellRenderer/index.js.map +1 -0
- package/dist/components/GridCellRenderer/interfaces.d.ts +53 -0
- package/dist/components/GridCellRenderer/styles.d.ts +72 -0
- package/dist/components/GridCellRenderer/styles.js +105 -0
- package/dist/components/GridCellRenderer/styles.js.map +1 -0
- package/dist/components/GridCellRenderer/translations.d.ts +6 -0
- package/dist/components/GridCellRenderer/translations.js +11 -0
- package/dist/components/GridCellRenderer/translations.js.map +1 -0
- package/dist/components/GridCellRenderer/useComponentProps.d.ts +6 -0
- package/dist/components/GridCellRenderer/useComponentProps.js +10 -0
- package/dist/components/GridCellRenderer/useComponentProps.js.map +1 -0
- package/dist/components/Lookup/Lookup.js +8 -3
- package/dist/components/Lookup/Lookup.js.map +1 -1
- package/dist/components/Lookup/styles.d.ts +19 -7
- package/dist/components/Lookup/styles.js +22 -8
- package/dist/components/Lookup/styles.js.map +1 -1
- package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js +51 -28
- package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js.map +1 -1
- package/dist/components/NestedControlRenderer/NestedControl.d.ts +86 -0
- package/dist/components/NestedControlRenderer/NestedControl.js +456 -0
- package/dist/components/NestedControlRenderer/NestedControl.js.map +1 -0
- package/dist/components/NestedControlRenderer/NestedControlError.d.ts +4 -0
- package/dist/components/NestedControlRenderer/NestedControlError.js +13 -0
- package/dist/components/NestedControlRenderer/NestedControlError.js.map +1 -0
- package/dist/components/NestedControlRenderer/NestedControlRenderer.d.ts +3 -0
- package/dist/components/NestedControlRenderer/NestedControlRenderer.js +194 -0
- package/dist/components/NestedControlRenderer/NestedControlRenderer.js.map +1 -0
- package/dist/components/NestedControlRenderer/index.d.ts +1 -0
- package/dist/components/NestedControlRenderer/index.js +2 -0
- package/dist/components/NestedControlRenderer/index.js.map +1 -0
- package/dist/components/NestedControlRenderer/interfaces.d.ts +122 -0
- package/dist/components/NestedControlRenderer/manifest/Control.d.ts +16 -0
- package/dist/components/NestedControlRenderer/manifest/Control.js +40 -0
- package/dist/components/NestedControlRenderer/manifest/Control.js.map +1 -0
- package/dist/components/NestedControlRenderer/manifest/Manifest.d.ts +5 -0
- package/dist/components/NestedControlRenderer/manifest/Manifest.js +12 -0
- package/dist/components/NestedControlRenderer/manifest/Manifest.js.map +1 -0
- package/dist/components/NestedControlRenderer/manifest/TypeGroup.d.ts +6 -0
- package/dist/components/NestedControlRenderer/manifest/TypeGroup.js +13 -0
- package/dist/components/NestedControlRenderer/manifest/TypeGroup.js.map +1 -0
- package/dist/components/NestedControlRenderer/manifest/index.d.ts +1 -0
- package/dist/components/NestedControlRenderer/manifest/index.js +2 -0
- package/dist/components/NestedControlRenderer/manifest/index.js.map +1 -0
- package/dist/components/NestedControlRenderer/manifest/property/Property.d.ts +16 -0
- package/dist/components/NestedControlRenderer/manifest/property/Property.js +34 -0
- package/dist/components/NestedControlRenderer/manifest/property/Property.js.map +1 -0
- package/dist/components/NestedControlRenderer/manifest/property/Value.d.ts +8 -0
- package/dist/components/NestedControlRenderer/manifest/property/Value.js +12 -0
- package/dist/components/NestedControlRenderer/manifest/property/Value.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/DateProperty.d.ts +5 -0
- package/dist/components/NestedControlRenderer/properties/DateProperty.js +20 -0
- package/dist/components/NestedControlRenderer/properties/DateProperty.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/FileProperty.d.ts +5 -0
- package/dist/components/NestedControlRenderer/properties/FileProperty.js +14 -0
- package/dist/components/NestedControlRenderer/properties/FileProperty.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/LookupProperty.d.ts +6 -0
- package/dist/components/NestedControlRenderer/properties/LookupProperty.js +35 -0
- package/dist/components/NestedControlRenderer/properties/LookupProperty.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/NumberProperty.d.ts +5 -0
- package/dist/components/NestedControlRenderer/properties/NumberProperty.js +15 -0
- package/dist/components/NestedControlRenderer/properties/NumberProperty.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/OptionSetProperty.d.ts +5 -0
- package/dist/components/NestedControlRenderer/properties/OptionSetProperty.js +22 -0
- package/dist/components/NestedControlRenderer/properties/OptionSetProperty.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/Property.d.ts +17 -0
- package/dist/components/NestedControlRenderer/properties/Property.js +46 -0
- package/dist/components/NestedControlRenderer/properties/Property.js.map +1 -0
- package/dist/components/NestedControlRenderer/properties/TextProperty.d.ts +5 -0
- package/dist/components/NestedControlRenderer/properties/TextProperty.js +15 -0
- package/dist/components/NestedControlRenderer/properties/TextProperty.js.map +1 -0
- package/dist/components/NestedControlRenderer/styles.d.ts +14 -0
- package/dist/components/NestedControlRenderer/styles.js +21 -0
- package/dist/components/NestedControlRenderer/styles.js.map +1 -0
- package/dist/components/NestedControlRenderer/translations.d.ts +14 -0
- package/dist/components/NestedControlRenderer/translations.js +19 -0
- package/dist/components/NestedControlRenderer/translations.js.map +1 -0
- package/dist/components/OptionSet/OptionSet.js +3 -3
- package/dist/components/OptionSet/OptionSet.js.map +1 -1
- package/dist/components/OptionSet/useComboBoxTheme.js +17 -17
- package/dist/components/OptionSet/useComboBoxTheme.js.map +1 -1
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/interfaces.d.ts +2 -2
- package/dist/components/TwoOptions/TwoOptions.js +2 -1
- package/dist/components/TwoOptions/TwoOptions.js.map +1 -1
- package/dist/components/index.d.ts +13 -0
- package/dist/components/index.js +15 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useControl.d.ts +1 -7
- package/dist/hooks/useControl.js +12 -40
- package/dist/hooks/useControl.js.map +1 -1
- package/dist/hooks/useControlLabels.d.ts +14 -0
- package/dist/hooks/useControlLabels.js +47 -0
- package/dist/hooks/useControlLabels.js.map +1 -0
- package/dist/hooks/useInputBasedControl.d.ts +2 -1
- package/dist/hooks/useInputBasedControl.js +3 -5
- package/dist/hooks/useInputBasedControl.js.map +1 -1
- package/dist/hooks/usePrevious.d.ts +1 -0
- package/dist/index.d.ts +456 -140
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/context.d.ts +2 -1
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/property.d.ts +5 -0
- package/dist/utils/BaseControls.d.ts +16 -0
- package/dist/utils/BaseControls.js +82 -0
- package/dist/utils/BaseControls.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/theme/ControlTheme.d.ts +1 -1
- package/dist/utils/theme/ControlTheme.js +1 -1
- package/dist/utils/theme/ControlTheme.js.map +1 -1
- package/dist/utils/theme/components/ThemeWrapper.d.ts +9 -0
- package/dist/utils/theme/components/ThemeWrapper.js +11 -0
- package/dist/utils/theme/components/ThemeWrapper.js.map +1 -0
- package/dist/utils/theme/components/index.d.ts +1 -0
- package/dist/utils/theme/components/index.js +2 -0
- package/dist/utils/theme/components/index.js.map +1 -0
- package/dist/utils/theme/hooks/useControlTheme.d.ts +1 -1
- package/dist/utils/theme/hooks/useControlTheme.js.map +1 -1
- package/dist/utils/theme/index.d.ts +1 -0
- package/dist/utils/theme/index.js +1 -0
- package/dist/utils/theme/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.d.ts +0 -10
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js +0 -82
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js.map +0 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.d.ts +0 -11
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js +0 -93
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js.map +0 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.d.ts +0 -36
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.js +0 -42
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.js.map +0 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.d.ts +0 -11
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js +0 -221
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js.map +0 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.d.ts +0 -10
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.js +0 -49
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.js.map +0 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.js +0 -27
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.js.map +0 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.d.ts +0 -99
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.js +0 -123
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.js.map +0 -1
- package/dist/components/Grid/core/components/Component/Component.js.map +0 -1
- package/dist/components/Grid/core/components/Component/controller/useComponentController.js.map +0 -1
- package/dist/components/Grid/core/components/Component/model/Component.js.map +0 -1
- package/dist/components/Grid/core/model/Metadata.js +0 -26
- package/dist/components/Grid/core/model/Metadata.js.map +0 -1
- package/dist/components/Grid/selection/controllers/useSelectionController.d.ts +0 -11
- package/dist/components/Grid/selection/controllers/useSelectionController.js +0 -21
- package/dist/components/Grid/selection/controllers/useSelectionController.js.map +0 -1
- package/dist/hooks/useRerender.d.ts +0 -1
- package/dist/hooks/useRerender.js +0 -9
- package/dist/hooks/useRerender.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import { ThemeProvider } from '@fluentui/react';
|
|
4
|
-
import { TextField } from '@talxis/react-components';
|
|
2
|
+
import { useRef, useMemo } from 'react';
|
|
3
|
+
import { ThemeProvider, MessageBar, MessageBarButton, MessageBarType } from '@fluentui/react';
|
|
5
4
|
import { datasetControlTranslations } from './translations.js';
|
|
6
5
|
import { getDatasetControlStyles } from './styles.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { QuickFind } from './QuickFind/QuickFind.js';
|
|
7
|
+
import { ErrorBoundary } from './ErrorBoundary.js';
|
|
8
|
+
import { useRerender } from '@talxis/react-components';
|
|
9
9
|
import { Grid } from '../Grid/Grid.js';
|
|
10
|
+
import { useControl } from '../../hooks/useControl.js';
|
|
10
11
|
|
|
11
12
|
const DatasetControl = (props) => {
|
|
12
13
|
const { labels, theme } = useControl('DatasetControl', props, datasetControlTranslations);
|
|
13
|
-
const [query, setQuery] = useState("");
|
|
14
14
|
const rerender = useRerender();
|
|
15
15
|
const dataset = props.parameters.Grid;
|
|
16
16
|
const injectedContextRef = useRef(props.context);
|
|
@@ -20,8 +20,21 @@ const DatasetControl = (props) => {
|
|
|
20
20
|
dataset._setRenderer(() => rerender());
|
|
21
21
|
//we need to have a way to customize the init behavior from above
|
|
22
22
|
const componentProps = onOverrideComponentProps({
|
|
23
|
-
onDatasetInit: () =>
|
|
23
|
+
onDatasetInit: () => {
|
|
24
|
+
if (dataset.paging.pageNumber > 1) {
|
|
25
|
+
dataset.paging.loadExactPage(dataset.paging.pageNumber);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
dataset.refresh();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
24
31
|
});
|
|
32
|
+
const renderErrorMessageBar = (onReset) => {
|
|
33
|
+
jsx(MessageBar, { isMultiline: false, actions: jsx(MessageBarButton, { className: styles.messageBarBtn, text: labels.reload(), onClick: () => {
|
|
34
|
+
onReset?.();
|
|
35
|
+
dataset.refresh();
|
|
36
|
+
} }), messageBarType: MessageBarType.error, children: dataset.errorMessage || labels.generalError() });
|
|
37
|
+
};
|
|
25
38
|
useMemo(() => {
|
|
26
39
|
//@ts-ignore - private property
|
|
27
40
|
injectedContextRef.current = dataset._patchContext(props.context);
|
|
@@ -29,34 +42,8 @@ const DatasetControl = (props) => {
|
|
|
29
42
|
useMemo(() => {
|
|
30
43
|
componentProps.onDatasetInit();
|
|
31
44
|
}, []);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
setQuery(dataset.getSearchQuery?.() ?? '');
|
|
34
|
-
}, [dataset.getSearchQuery?.()]);
|
|
35
|
-
const onSearch = (query) => {
|
|
36
|
-
dataset.setSearchQuery?.(query ?? "");
|
|
37
|
-
dataset.refresh();
|
|
38
|
-
};
|
|
39
45
|
return (jsxs(ThemeProvider, { theme: theme, applyTo: "none", className: styles.root, children: [props.parameters.EnableQuickFind?.raw &&
|
|
40
|
-
jsx(
|
|
41
|
-
key: 'delete',
|
|
42
|
-
iconProps: {
|
|
43
|
-
iconName: 'Cancel'
|
|
44
|
-
},
|
|
45
|
-
onClick: () => {
|
|
46
|
-
setQuery("");
|
|
47
|
-
onSearch(undefined);
|
|
48
|
-
}
|
|
49
|
-
} : undefined, suffixItems: [{
|
|
50
|
-
key: 'search',
|
|
51
|
-
iconProps: {
|
|
52
|
-
iconName: 'Search'
|
|
53
|
-
},
|
|
54
|
-
onClick: () => onSearch(query)
|
|
55
|
-
}], onKeyUp: (e) => {
|
|
56
|
-
if (e.key === 'Enter') {
|
|
57
|
-
onSearch(query);
|
|
58
|
-
}
|
|
59
|
-
}, onChange: (e, newValue) => setQuery(newValue) }), jsx(Grid, { ...props, context: injectedContextRef.current })] }));
|
|
46
|
+
jsx(QuickFind, { dataset: dataset, labels: labels }), jsx(ErrorBoundary, { fallback: (resetError) => { renderErrorMessageBar(() => resetError()); }, children: jsx(Grid, { ...props, context: injectedContextRef.current }) })] }));
|
|
60
47
|
};
|
|
61
48
|
|
|
62
49
|
export { DatasetControl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasetControl.js","sources":["../../../src/components/DatasetControl/DatasetControl.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Grid } from \"../Grid\";\nimport { useControl } from \"../../hooks\";\nimport { ThemeProvider } from \"@fluentui/react\";\nimport {
|
|
1
|
+
{"version":3,"file":"DatasetControl.js","sources":["../../../src/components/DatasetControl/DatasetControl.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Grid } from \"../Grid\";\nimport { useControl } from \"../../hooks\";\nimport { MessageBar, MessageBarButton, MessageBarType, ThemeProvider } from \"@fluentui/react\";\nimport { datasetControlTranslations } from \"./translations\";\nimport { getDatasetControlStyles } from \"./styles\";\nimport { IDatasetControl } from \"./interfaces\";\nimport { QuickFind } from \"./QuickFind/QuickFind\";\nimport { ErrorBoundary } from \"./ErrorBoundary\";\nimport { useRerender } from \"@talxis/react-components\";\n\nexport const DatasetControl = (props: IDatasetControl) => {\n const { labels, theme } = useControl('DatasetControl', props, datasetControlTranslations);\n const rerender = useRerender();\n const dataset = props.parameters.Grid;\n const injectedContextRef = useRef(props.context);\n const styles = useMemo(() => getDatasetControlStyles(), []);\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n //@ts-ignore - private property\n dataset._setRenderer(() => rerender());\n\n //we need to have a way to customize the init behavior from above\n const componentProps = onOverrideComponentProps({\n onDatasetInit: () => {\n if (dataset.paging.pageNumber > 1) {\n dataset.paging.loadExactPage(dataset.paging.pageNumber)\n }\n else {\n dataset.refresh();\n }\n }\n });\n\n const renderErrorMessageBar = (onReset?: () => void) => {\n <MessageBar\n isMultiline={false}\n actions={<MessageBarButton className={styles.messageBarBtn} text={labels.reload()} onClick={() => {\n onReset?.();\n dataset.refresh();\n }} />}\n messageBarType={MessageBarType.error}>\n {dataset.errorMessage || labels.generalError()}\n </MessageBar>\n }\n\n useMemo(() => {\n //@ts-ignore - private property\n injectedContextRef.current = dataset._patchContext(props.context);\n }, [props.context]);\n\n useMemo(() => {\n componentProps.onDatasetInit();\n }, []);\n\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\" className={styles.root}>\n {props.parameters.EnableQuickFind?.raw &&\n <QuickFind dataset={dataset} labels={labels} />\n }\n {/* {dataset.error && renderErrorMessageBar()} */}\n <ErrorBoundary fallback={(resetError: () => void) => { renderErrorMessageBar(() => resetError()) }}>\n <Grid\n {...props}\n context={injectedContextRef.current} />\n </ErrorBoundary>\n </ThemeProvider>\n )\n}"],"names":["_jsx","_jsxs"],"mappings":";;;;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;AACpB,iBAAC,GAAI,EACL,cAAc,EAAE,cAAc,CAAC,KAAK,EAAA,QAAA,EACnC,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,EAAE,GACnC,CAAA;AACf,KAAC,CAAA;IAED,OAAO,CAAC,MAAK;;QAEX,kBAAkB,CAAC,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACpE,KAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpB,OAAO,CAAC,MAAK;QACX,cAAc,CAAC,aAAa,EAAE,CAAC;KAChC,EAAE,EAAE,CAAC,CAAC;IAGP,QACEC,IAAC,CAAA,aAAa,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAC/D,QAAA,EAAA,CAAA,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG;gBACpCD,GAAC,CAAA,SAAS,IAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAA,CAAI,EAGjDA,GAAC,CAAA,aAAa,IAAC,QAAQ,EAAE,CAAC,UAAsB,KAAI,EAAG,qBAAqB,CAAC,MAAM,UAAU,EAAE,CAAC,CAAA,EAAE,EAChG,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAA,GACC,KAAK,EACT,OAAO,EAAE,kBAAkB,CAAC,OAAO,EAAI,CAAA,EAAA,CAC3B,CACF,EAAA,CAAA,EACjB;AACH;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
class ErrorBoundary extends React__default.Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.state = { hasError: false };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static getDerivedStateFromError(error) {
|
|
10
|
+
// Update state so the next render will show the fallback UI.
|
|
11
|
+
return { hasError: true };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
componentDidCatch(error, info) {
|
|
15
|
+
console.error(error);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
resetError() {
|
|
19
|
+
this.setState({ hasError: false });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
render() {
|
|
23
|
+
if (this.state.hasError) {
|
|
24
|
+
// You can render any custom fallback UI
|
|
25
|
+
return this.props.fallback(() => this.resetError());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return this.props.children;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { ErrorBoundary };
|
|
33
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sources":["../../../src/components/DatasetControl/ErrorBoundary.js"],"sourcesContent":["import React from 'react';\n\nexport class ErrorBoundary extends React.Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false };\n }\n \n static getDerivedStateFromError(error) {\n // Update state so the next render will show the fallback UI.\n return { hasError: true };\n }\n \n componentDidCatch(error, info) {\n console.error(error);\n }\n\n resetError() {\n this.setState({ hasError: false });\n }\n \n render() {\n if (this.state.hasError) {\n // You can render any custom fallback UI\n return this.props.fallback(() => this.resetError());\n }\n \n return this.props.children;\n }\n }"],"names":["React"],"mappings":";;AAEO,MAAM,aAAa,SAASA,cAAK,CAAC,SAAS,CAAC;AACnD,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;AACnB,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACvC,KAAK;AACL;AACA,IAAI,OAAO,wBAAwB,CAAC,KAAK,EAAE;AAC3C;AACA,MAAM,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChC,KAAK;AACL;AACA,IAAI,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE;AACnC,QAAQ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7B,KAAK;AACL;AACA,IAAI,UAAU,GAAG;AACjB,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACzC,KAAK;AACL;AACA,IAAI,MAAM,GAAG;AACb,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;AAC/B;AACA,QAAQ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;AAC5D,OAAO;AACP;AACA,MAAM,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;AACjC,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IDataset } from "@talxis/client-libraries";
|
|
3
|
+
import { datasetControlTranslations } from "../translations";
|
|
4
|
+
import { ITranslation } from "../../../hooks";
|
|
5
|
+
interface IQuickFindProps {
|
|
6
|
+
labels: ITranslation<typeof datasetControlTranslations>;
|
|
7
|
+
dataset: IDataset;
|
|
8
|
+
}
|
|
9
|
+
export declare const QuickFind: (props: IQuickFindProps) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { TextField } from '@talxis/react-components';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
const QuickFind = (props) => {
|
|
6
|
+
const { dataset, labels } = { ...props };
|
|
7
|
+
const [query, setQuery] = useState('');
|
|
8
|
+
const onSearch = (query) => {
|
|
9
|
+
dataset.setSearchQuery?.(query ?? "");
|
|
10
|
+
dataset.refresh();
|
|
11
|
+
};
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setQuery(dataset.getSearchQuery?.() ?? '');
|
|
14
|
+
}, [dataset.getSearchQuery?.()]);
|
|
15
|
+
return jsx(TextField, { value: query, placeholder: `${labels.search()} ${dataset.getMetadata()?.DisplayCollectionName ?? labels.records()}...`, deleteButtonProps: query ? {
|
|
16
|
+
key: 'delete',
|
|
17
|
+
iconProps: {
|
|
18
|
+
iconName: 'Cancel'
|
|
19
|
+
},
|
|
20
|
+
onClick: () => {
|
|
21
|
+
setQuery("");
|
|
22
|
+
onSearch(undefined);
|
|
23
|
+
}
|
|
24
|
+
} : undefined, suffixItems: [{
|
|
25
|
+
key: 'search',
|
|
26
|
+
iconProps: {
|
|
27
|
+
iconName: 'Search'
|
|
28
|
+
},
|
|
29
|
+
onClick: () => onSearch(query)
|
|
30
|
+
}], onKeyUp: (e) => {
|
|
31
|
+
if (e.key === 'Enter') {
|
|
32
|
+
onSearch(query);
|
|
33
|
+
}
|
|
34
|
+
}, onChange: (e, newValue) => setQuery(newValue ?? '') });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { QuickFind };
|
|
38
|
+
//# sourceMappingURL=QuickFind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuickFind.js","sources":["../../../../src/components/DatasetControl/QuickFind/QuickFind.tsx"],"sourcesContent":["import { IDataset } from \"@talxis/client-libraries\";\nimport { TextField } from \"@talxis/react-components\";\nimport { datasetControlTranslations } from \"../translations\";\nimport { ITranslation } from \"../../../hooks\";\nimport { useEffect, useState } from \"react\";\n\ninterface IQuickFindProps {\n labels: ITranslation<typeof datasetControlTranslations>\n dataset: IDataset;\n}\n\nexport const QuickFind = (props: IQuickFindProps) => {\n const {dataset, labels} = {...props};\n const [query, setQuery] = useState<string>('');\n\n const onSearch = (query?: string) => {\n dataset.setSearchQuery?.(query ?? \"\");\n dataset.refresh();\n }\n\n useEffect(() => {\n setQuery(dataset.getSearchQuery?.() ?? '');\n }, [dataset.getSearchQuery?.()])\n\n return <TextField\n value={query}\n placeholder={`${labels.search()} ${dataset.getMetadata()?.DisplayCollectionName ?? labels.records()}...`}\n deleteButtonProps={query ? {\n key: 'delete',\n iconProps: {\n iconName: 'Cancel'\n },\n onClick: () => {\n setQuery(\"\");\n onSearch(undefined);\n }\n } : undefined}\n suffixItems={[{\n key: 'search',\n iconProps: {\n iconName: 'Search'\n },\n onClick: () => onSearch(query)\n }]}\n onKeyUp={(e) => {\n if (e.key === 'Enter') {\n onSearch(query);\n }\n }}\n onChange={(e, newValue) => setQuery(newValue ?? '')} />\n}"],"names":["_jsx"],"mappings":";;;;AAWa,MAAA,SAAS,GAAG,CAAC,KAAsB,KAAI;IAChD,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,EAAC,GAAG,KAAK,EAAC,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;AAE/C,IAAA,MAAM,QAAQ,GAAG,CAAC,KAAc,KAAI;QAChC,OAAO,CAAC,cAAc,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,OAAO,EAAE,CAAC;AACtB,KAAC,CAAA;IAED,SAAS,CAAC,MAAK;QACX,QAAQ,CAAC,OAAO,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC,CAAC;KAC9C,EAAE,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC,CAAA;AAEhC,IAAA,OAAOA,GAAC,CAAA,SAAS,EACjB,EAAA,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,CAAG,EAAA,MAAM,CAAC,MAAM,EAAE,CAAI,CAAA,EAAA,OAAO,CAAC,WAAW,EAAE,EAAE,qBAAqB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAA,GAAA,CAAK,EACxG,iBAAiB,EAAE,KAAK,GAAG;AACvB,YAAA,GAAG,EAAE,QAAQ;AACb,YAAA,SAAS,EAAE;AACP,gBAAA,QAAQ,EAAE,QAAQ;AACrB,aAAA;YACD,OAAO,EAAE,MAAK;gBACV,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACb,QAAQ,CAAC,SAAS,CAAC,CAAC;aACvB;AACJ,SAAA,GAAG,SAAS,EACb,WAAW,EAAE,CAAC;AACV,gBAAA,GAAG,EAAE,QAAQ;AACb,gBAAA,SAAS,EAAE;AACP,oBAAA,QAAQ,EAAE,QAAQ;AACrB,iBAAA;AACD,gBAAA,OAAO,EAAE,MAAM,QAAQ,CAAC,KAAK,CAAC;AACjC,aAAA,CAAC,EACF,OAAO,EAAE,CAAC,CAAC,KAAI;AACX,YAAA,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;gBACnB,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnB,aAAA;AACL,SAAC,EACD,QAAQ,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC,GAAI,CAAA;AAC3D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../../src/components/DatasetControl/styles.ts"],"sourcesContent":["import { mergeStyleSets } from \"@fluentui/react\"\n\nexport const getDatasetControlStyles = () => {\n return mergeStyleSets({\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 15\n },\n
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../src/components/DatasetControl/styles.ts"],"sourcesContent":["import { mergeStyleSets } from \"@fluentui/react\"\n\nexport const getDatasetControlStyles = () => {\n return mergeStyleSets({\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 15\n },\n messageBarBtn: {\n minHeight: 'inherit'\n }\n });\n}"],"names":[],"mappings":";;AAEO,MAAM,uBAAuB,GAAG,MAAK;AACxC,IAAA,OAAO,cAAc,CAAC;AAClB,QAAA,IAAI,EAAE;AACF,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,aAAa,EAAE,QAAQ;AACvB,YAAA,GAAG,EAAE,EAAE;AACV,SAAA;AACD,QAAA,aAAa,EAAE;AACX,YAAA,SAAS,EAAE,SAAS;AACvB,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const datasetControlTranslations = {
|
|
2
2
|
"search": { 1029: "Vyhledat", 1033: "Search" },
|
|
3
|
-
"records": { 1029: "záznamy", 1033: "records" }
|
|
3
|
+
"records": { 1029: "záznamy", 1033: "records" },
|
|
4
|
+
"generalError": { 1029: "Během načítání ovládacího prvku došlo k nečekané chybě", 1033: "An unexpected error occurred while loading the control." },
|
|
5
|
+
"reload": { 1029: "Obnovit", 1033: "Reload" }
|
|
4
6
|
};
|
|
5
7
|
|
|
6
8
|
export { datasetControlTranslations };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.js","sources":["../../../src/components/DatasetControl/translations.ts"],"sourcesContent":["export const datasetControlTranslations = {\n \"search\": { 1029: \"Vyhledat\", 1033: \"Search\" },\n \"records\": { 1029: \"záznamy\", 1033: \"records\" }\n};\n \n"],"names":[],"mappings":"AAAa,MAAA,0BAA0B,GAAG;IACtC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9C,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;;;;;"}
|
|
1
|
+
{"version":3,"file":"translations.js","sources":["../../../src/components/DatasetControl/translations.ts"],"sourcesContent":["export const datasetControlTranslations = {\n \"search\": { 1029: \"Vyhledat\", 1033: \"Search\" },\n \"records\": { 1029: \"záznamy\", 1033: \"records\" },\n \"generalError\": { 1029: \"Během načítání ovládacího prvku došlo k nečekané chybě\", 1033: \"An unexpected error occurred while loading the control.\" },\n \"reload\": { 1029: \"Obnovit\", 1033: \"Reload\" }\n};\n \n"],"names":[],"mappings":"AAAa,MAAA,0BAA0B,GAAG;IACtC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9C,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IAC/C,cAAc,EAAE,EAAE,IAAI,EAAE,wDAAwD,EAAE,IAAI,EAAE,yDAAyD,EAAE;IACnJ,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;;;;;"}
|
|
@@ -94,7 +94,8 @@ const DateTime = (componentProps) => {
|
|
|
94
94
|
strings: {
|
|
95
95
|
invalidInputErrorMessage: labels.invalidTimeInput()
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
},
|
|
98
|
+
theme: componentProps.context.fluentDesignLanguage?.applicationTheme ?? theme
|
|
98
99
|
};
|
|
99
100
|
if (isDateTime) {
|
|
100
101
|
calendarProps.onSelectDate = (newDate) => date.set(newDate);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sources":["../../../src/components/DateTime/DateTime.tsx"],"sourcesContent":["\nimport { IDateTime } from \"./interfaces\";\nimport { ICalendarDayGridStyles, IDatePicker, IProcessedStyleSet, ThemeProvider } from \"@fluentui/react\";\nimport { useEffect, useRef } from \"react\";\nimport { getDateTimeStyles } from \"./styles\";\nimport { useDateTime } from \"./hooks/useDateTime\";\nimport { Calendar, IInternalCalendarProps } from \"./components/Calendar\";\nimport { DatePicker } from \"@talxis/react-components\";\nimport React from 'react';\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const DateTime = (componentProps: IDateTime) => {\n const ref = useRef<HTMLDivElement>(null);\n const datePickerRef = useRef<IDatePicker>(null);\n const context = componentProps.context;\n const parameters = componentProps.parameters;\n const [isDateTime, theme, labels, date, patterns] = useDateTime(componentProps, ref);\n const styles = getDateTimeStyles(theme);\n const { height, width } = useControlSizing(componentProps.context.mode);\n const lastInputedTimeString = useRef<string>();\n\n useEffect(() => {\n if (componentProps.parameters.AutoFocus?.raw === true) {\n datePickerRef.current?.showDatePickerPopup();\n }\n }, []);\n\n const getRestrictedDates = (): Date[] | undefined => {\n if(!parameters.RestrictedDates?.raw) {\n return undefined;\n }\n return JSON.parse(parameters.RestrictedDates?.raw).map((x: string) => new Date(x))\n }\n const onOverrideDayCellProps = (element: HTMLElement, date: Date, classNames: IProcessedStyleSet<ICalendarDayGridStyles>) => {\n if(!element || !parameters.RestrictedDaysOfWeek?.raw) {\n return;\n }\n const weekDaysToExclude: number[] = JSON.parse(parameters.RestrictedDaysOfWeek.raw);\n if(weekDaysToExclude.includes(date.getDay())) {\n element.setAttribute('data-is-focusable', 'false');\n element.classList?.add(classNames.dayOutsideBounds!);\n (element.children[0] as HTMLButtonElement).disabled = true;\n }\n }\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\" ref={ref}>\n <DatePicker\n className={styles.datePicker}\n componentRef={datePickerRef}\n hideErrorMessage={!parameters.ShowErrorMessage?.raw}\n keepCalendarOpenAfterDaySelect={isDateTime}\n readOnly={context.mode.isControlDisabled}\n //@ts-ignore - this is a hack to close the calendar when dates get selected on date only fields\n onSelectDate={isDateTime ? undefined : (newDate) => date.set(newDate!)}\n //disable so the user cannot input restricted Dates\n allowTextInput={!parameters.RestrictedDates?.raw && !parameters.RestrictedDaysOfWeek?.raw}\n // Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN\n minDate={new Date('1753-01-01T00:00:00.000Z')}\n firstDayOfWeek={componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek}\n deleteButtonProps={parameters.EnableDeleteButton?.raw === true ? {\n key: 'Delete',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Cancel'\n },\n onClick: () => date.clear()\n } : undefined}\n clickToCopyProps={ parameters.EnableCopyButton?.raw === true ? {\n key: 'copy',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Copy'\n }\n } : undefined}\n calendarAs={(props) =>\n {\n const calendarProps: IInternalCalendarProps = {\n ...props,\n isMonthPickerVisible: parameters.EnableMonthPicker?.raw !== false,\n isDayPickerVisible: parameters.EnableDayPicker?.raw !== false,\n calendarDayProps: {\n restrictedDates: getRestrictedDates(),\n customDayCellRef: onOverrideDayCellProps\n },\n value: date.get(),\n strings: {\n goToToday: labels.goToToday(),\n days: JSON.parse(labels.days()),\n months: JSON.parse(labels.months()),\n shortDays: JSON.parse(labels.shortDays()),\n shortMonths: JSON.parse(labels.shortMonths())\n },\n timePickerProps: {\n dateTimeFormat: patterns.fullDateTimePattern,\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n timeFormat: patterns.shortTimePattern,\n label: labels.time(),\n visible: isDateTime,\n errorMessage: labels.invalidTimeInput(),\n lastInputedTimeString: lastInputedTimeString.current,\n useHour12: patterns.shortTimePattern.endsWith('A'),\n onChange: (time?: string) => {\n date.set(undefined, time);\n lastInputedTimeString.current = time;\n },\n value: date.get(),\n formattedDateTime: date.getFormatted() ?? \"\",\n strings: {\n invalidInputErrorMessage: labels.invalidTimeInput()\n }\n }\n };\n if(isDateTime) {\n calendarProps.onSelectDate = (newDate) => date.set(newDate)\n }\n return <Calendar {...calendarProps} />\n }\n }\n errorMessage={parameters.value.errorMessage}\n textField={{\n value: date.getFormatted() ?? \"\",\n onChange: (e, value) => {\n if(isDateTime) {\n const datePart = dayjs(value, patterns.shortDatePattern).format(patterns.shortDatePattern);\n const time = value?.split(datePart).pop()?.substring(1);\n lastInputedTimeString.current = time;\n }\n date.setDateString(value)\n },\n placeholder: '---',\n onNotifyValidationResult: () => null,\n noValidate: true,\n styles: {\n fieldGroup: {\n height: height,\n width: width\n }\n }\n }\n }\n value={date.get() ?? undefined}\n />\n </ThemeProvider>\n );\n};\n\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAYa,MAAA,QAAQ,GAAG,CAAC,cAAyB,KAAI;AAClD,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACzC,IAAA,MAAM,aAAa,GAAG,MAAM,CAAc,IAAI,CAAC,C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C3F,wBAAA,MAAM,IAAI,GAAG,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,wBAAA,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC;AACxC,qBAAA;AACD,oBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;iBAC5B;AACD,gBAAA,WAAW,EAAE,KAAK;AAClB,gBAAA,wBAAwB,EAAE,MAAM,IAAI;AACpC,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,MAAM,EAAE;AACJ,oBAAA,UAAU,EAAE;AACR,wBAAA,MAAM,EAAE,MAAM;AACd,wBAAA,KAAK,EAAE,KAAK;AACf,qBAAA;AACJ,iBAAA;aACJ,EAED,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,SAAS,EAAA,CAChC,EACU,CAAA,EAClB;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"DateTime.js","sources":["../../../src/components/DateTime/DateTime.tsx"],"sourcesContent":["\nimport { IDateTime } from \"./interfaces\";\nimport { ICalendarDayGridStyles, IDatePicker, IProcessedStyleSet, ThemeProvider } from \"@fluentui/react\";\nimport { useEffect, useRef } from \"react\";\nimport { getDateTimeStyles } from \"./styles\";\nimport { useDateTime } from \"./hooks/useDateTime\";\nimport { Calendar, IInternalCalendarProps } from \"./components/Calendar\";\nimport { DatePicker } from \"@talxis/react-components\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const DateTime = (componentProps: IDateTime) => {\n const ref = useRef<HTMLDivElement>(null);\n const datePickerRef = useRef<IDatePicker>(null);\n const context = componentProps.context;\n const parameters = componentProps.parameters;\n const [isDateTime, theme, labels, date, patterns] = useDateTime(componentProps, ref);\n const styles = getDateTimeStyles(theme);\n const { height, width } = useControlSizing(componentProps.context.mode);\n const lastInputedTimeString = useRef<string>();\n\n useEffect(() => {\n if (componentProps.parameters.AutoFocus?.raw === true) {\n datePickerRef.current?.showDatePickerPopup();\n }\n }, []);\n\n const getRestrictedDates = (): Date[] | undefined => {\n if(!parameters.RestrictedDates?.raw) {\n return undefined;\n }\n return JSON.parse(parameters.RestrictedDates?.raw).map((x: string) => new Date(x))\n }\n const onOverrideDayCellProps = (element: HTMLElement, date: Date, classNames: IProcessedStyleSet<ICalendarDayGridStyles>) => {\n if(!element || !parameters.RestrictedDaysOfWeek?.raw) {\n return;\n }\n const weekDaysToExclude: number[] = JSON.parse(parameters.RestrictedDaysOfWeek.raw);\n if(weekDaysToExclude.includes(date.getDay())) {\n element.setAttribute('data-is-focusable', 'false');\n element.classList?.add(classNames.dayOutsideBounds!);\n (element.children[0] as HTMLButtonElement).disabled = true;\n }\n }\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\" ref={ref}>\n <DatePicker\n className={styles.datePicker}\n componentRef={datePickerRef}\n hideErrorMessage={!parameters.ShowErrorMessage?.raw}\n keepCalendarOpenAfterDaySelect={isDateTime}\n readOnly={context.mode.isControlDisabled}\n //@ts-ignore - this is a hack to close the calendar when dates get selected on date only fields\n onSelectDate={isDateTime ? undefined : (newDate) => date.set(newDate!)}\n //disable so the user cannot input restricted Dates\n allowTextInput={!parameters.RestrictedDates?.raw && !parameters.RestrictedDaysOfWeek?.raw}\n // Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN\n minDate={new Date('1753-01-01T00:00:00.000Z')}\n firstDayOfWeek={componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek}\n deleteButtonProps={parameters.EnableDeleteButton?.raw === true ? {\n key: 'Delete',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Cancel'\n },\n onClick: () => date.clear()\n } : undefined}\n clickToCopyProps={ parameters.EnableCopyButton?.raw === true ? {\n key: 'copy',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Copy'\n }\n } : undefined}\n calendarAs={(props) =>\n {\n const calendarProps: IInternalCalendarProps = {\n ...props,\n isMonthPickerVisible: parameters.EnableMonthPicker?.raw !== false,\n isDayPickerVisible: parameters.EnableDayPicker?.raw !== false,\n calendarDayProps: {\n restrictedDates: getRestrictedDates(),\n customDayCellRef: onOverrideDayCellProps\n },\n value: date.get(),\n strings: {\n goToToday: labels.goToToday(),\n days: JSON.parse(labels.days()),\n months: JSON.parse(labels.months()),\n shortDays: JSON.parse(labels.shortDays()),\n shortMonths: JSON.parse(labels.shortMonths())\n },\n timePickerProps: {\n dateTimeFormat: patterns.fullDateTimePattern,\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n timeFormat: patterns.shortTimePattern,\n label: labels.time(),\n visible: isDateTime,\n errorMessage: labels.invalidTimeInput(),\n lastInputedTimeString: lastInputedTimeString.current,\n useHour12: patterns.shortTimePattern.endsWith('A'),\n onChange: (time?: string) => {\n date.set(undefined, time);\n lastInputedTimeString.current = time;\n },\n value: date.get(),\n formattedDateTime: date.getFormatted() ?? \"\",\n strings: {\n invalidInputErrorMessage: labels.invalidTimeInput()\n }\n },\n theme: componentProps.context.fluentDesignLanguage?.applicationTheme ?? theme\n };\n if(isDateTime) {\n calendarProps.onSelectDate = (newDate) => date.set(newDate)\n }\n return <Calendar {...calendarProps} />\n }\n }\n errorMessage={parameters.value.errorMessage}\n textField={{\n value: date.getFormatted() ?? \"\",\n onChange: (e, value) => {\n if(isDateTime) {\n const datePart = dayjs(value, patterns.shortDatePattern).format(patterns.shortDatePattern);\n const time = value?.split(datePart).pop()?.substring(1);\n lastInputedTimeString.current = time;\n }\n date.setDateString(value)\n },\n placeholder: '---',\n onNotifyValidationResult: () => null,\n noValidate: true,\n styles: {\n fieldGroup: {\n height: height,\n width: width\n }\n }\n }\n }\n value={date.get() ?? undefined}\n />\n </ThemeProvider>\n );\n};\n\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAWa,MAAA,QAAQ,GAAG,CAAC,cAAyB,KAAI;AAClD,IAAA,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,KAAK,KAAI;AACnB,oBAAA,IAAG,UAAU,EAAE;AACX,wBAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAC3F,wBAAA,MAAM,IAAI,GAAG,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,wBAAA,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC;AACxC,qBAAA;AACD,oBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;iBAC5B;AACD,gBAAA,WAAW,EAAE,KAAK;AAClB,gBAAA,wBAAwB,EAAE,MAAM,IAAI;AACpC,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,MAAM,EAAE;AACJ,oBAAA,UAAU,EAAE;AACR,wBAAA,MAAM,EAAE,MAAM;AACd,wBAAA,KAAK,EAAE,KAAK;AACf,qBAAA;AACJ,iBAAA;aACJ,EAED,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,SAAS,EAAA,CAChC,EACU,CAAA,EAClB;AACN;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ICalendarProps } from "@fluentui/react";
|
|
2
|
+
import { ICalendarProps, ITheme } from "@fluentui/react";
|
|
3
3
|
import { ITimePickerProps } from "@talxis/react-components";
|
|
4
4
|
interface IInternalTimePickerProps extends Omit<ITimePickerProps, 'onChange' | 'defaultValue'> {
|
|
5
5
|
formattedDateTime: string;
|
|
@@ -7,6 +7,7 @@ interface IInternalTimePickerProps extends Omit<ITimePickerProps, 'onChange' | '
|
|
|
7
7
|
timeFormat: string;
|
|
8
8
|
dateTimeFormat: string;
|
|
9
9
|
lastInputedTimeString?: string;
|
|
10
|
+
theme?: ITheme;
|
|
10
11
|
onChange: (time?: string) => void;
|
|
11
12
|
}
|
|
12
13
|
export interface IInternalCalendarProps extends ICalendarProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useTheme } from '@fluentui/react';
|
|
2
|
+
import { useTheme, ThemeProvider } from '@fluentui/react';
|
|
3
3
|
import { Calendar as Calendar$1 } from '@fluentui/react/lib/Calendar';
|
|
4
4
|
import { useRef, useState, useEffect } from 'react';
|
|
5
5
|
import { getDateTimeStyles } from '../styles.js';
|
|
@@ -51,12 +51,12 @@ const Calendar = (props) => {
|
|
|
51
51
|
setError(true);
|
|
52
52
|
}
|
|
53
53
|
}, [formattedDateTime]);
|
|
54
|
-
return (jsxs(
|
|
55
|
-
jsx(TimePicker, { ...timePickerProps, errorMessage: error ? timePickerProps.errorMessage : undefined, componentRef: timePickerRef, onFormatDate: (date) => dayjs(date).format(timePickerProps.timeFormat), onChange: onChange, useComboBoxAsMenuWidth: true, styles: {
|
|
54
|
+
return (jsxs(ThemeProvider, { theme: props.theme, className: styles.calendarCallout, children: [jsx(Calendar$1, { ...props, value: props.value }), jsx("hr", {}), timePickerProps.visible &&
|
|
55
|
+
jsx(TimePicker, { ...timePickerProps, errorMessage: error ? timePickerProps.errorMessage : undefined, componentRef: timePickerRef, onFormatDate: (date) => dayjs(date).format(timePickerProps.timeFormat), onChange: onChange, allowFreeform: true, onClick: () => timePickerRef.current?.focus(true), useComboBoxAsMenuWidth: true, styles: {
|
|
56
56
|
callout: {
|
|
57
57
|
maxHeight: '300px !important'
|
|
58
58
|
}
|
|
59
|
-
}, increments: 15
|
|
59
|
+
}, increments: 15 })] }));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export { Calendar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","sources":["../../../../src/components/DateTime/components/Calendar.tsx"],"sourcesContent":["import { ICalendarProps, IComboBox } from \"@fluentui/react\";\nimport { useTheme } from \"@fluentui/react\";\nimport { Calendar as CalendarBase } from '@fluentui/react/lib/Calendar';\nimport { useEffect, useRef, useState } from \"react\";\nimport { getDateTimeStyles } from \"../styles\";\nimport { ITimePickerProps, TimePicker } from \"@talxis/react-components\";\nimport dayjs from \"dayjs\";\nimport React from 'react';\n\ninterface IInternalTimePickerProps extends Omit<ITimePickerProps, 'onChange' | 'defaultValue'> {\n formattedDateTime: string;\n visible: boolean;\n timeFormat: string;\n dateTimeFormat: string;\n lastInputedTimeString?: string;\n onChange: (time?: string) => void;\n}\n\nexport interface IInternalCalendarProps extends ICalendarProps {\n timePickerProps: IInternalTimePickerProps;\n}\n\nexport const Calendar = (props: IInternalCalendarProps) => {\n const timePickerProps = props.timePickerProps;\n const formattedDateTime = timePickerProps.formattedDateTime;\n const theme = useTheme();\n const styles = getDateTimeStyles(theme);\n const timePickerRef = useRef<IComboBox>(null);\n const [error, setError] = useState(false);\n\n const getFormattedTime = () => {\n const dayjsDate = dayjs(formattedDateTime, timePickerProps.dateTimeFormat, true);\n if (!dayjsDate.isValid()) {\n return timePickerProps.lastInputedTimeString;\n }\n return dayjsDate.format(timePickerProps.timeFormat) ?? \"\";\n };\n\n const onChange = (event: React.FormEvent<IComboBox>, time: Date) => {\n const dayjsDate = dayjs(time);\n let timeValue;\n if (!dayjsDate.isValid()) {\n //@ts-ignore - need to access internals to properly show error values\n timeValue = timePickerRef.current.state.currentPendingValue;\n }\n else {\n timeValue = dayjsDate.format(timePickerProps.timeFormat);\n }\n //@ts-ignore - need to access internals to properly show error values\n timePickerProps.onChange(timeValue);\n\n }\n\n useEffect(() => {\n setError(false);\n if (!timePickerProps.visible) {\n return;\n }\n const formattedTime = getFormattedTime();\n //@ts-ignore - need to access internals to properly show error values\n timePickerRef.current.setState({\n currentPendingValue: getFormattedTime()\n })\n if(!formattedTime || !formattedDateTime) {\n return;\n }\n const time = dayjs(formattedTime, timePickerProps.timeFormat, true);\n if (!time.isValid()) {\n setError(true);\n }\n }, [formattedDateTime]);\n\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"Calendar.js","sources":["../../../../src/components/DateTime/components/Calendar.tsx"],"sourcesContent":["import { ICalendarProps, IComboBox, ITheme, ThemeProvider } from \"@fluentui/react\";\nimport { useTheme } from \"@fluentui/react\";\nimport { Calendar as CalendarBase } from '@fluentui/react/lib/Calendar';\nimport { useEffect, useRef, useState } from \"react\";\nimport { getDateTimeStyles } from \"../styles\";\nimport { ITimePickerProps, TimePicker } from \"@talxis/react-components\";\nimport dayjs from \"dayjs\";\nimport React from 'react';\n\ninterface IInternalTimePickerProps extends Omit<ITimePickerProps, 'onChange' | 'defaultValue'> {\n formattedDateTime: string;\n visible: boolean;\n timeFormat: string;\n dateTimeFormat: string;\n lastInputedTimeString?: string;\n theme?: ITheme\n onChange: (time?: string) => void;\n}\n\nexport interface IInternalCalendarProps extends ICalendarProps {\n timePickerProps: IInternalTimePickerProps;\n}\n\nexport const Calendar = (props: IInternalCalendarProps) => {\n const timePickerProps = props.timePickerProps;\n const formattedDateTime = timePickerProps.formattedDateTime;\n const theme = useTheme();\n const styles = getDateTimeStyles(theme);\n const timePickerRef = useRef<IComboBox>(null);\n const [error, setError] = useState(false);\n\n const getFormattedTime = () => {\n const dayjsDate = dayjs(formattedDateTime, timePickerProps.dateTimeFormat, true);\n if (!dayjsDate.isValid()) {\n return timePickerProps.lastInputedTimeString;\n }\n return dayjsDate.format(timePickerProps.timeFormat) ?? \"\";\n };\n\n const onChange = (event: React.FormEvent<IComboBox>, time: Date) => {\n const dayjsDate = dayjs(time);\n let timeValue;\n if (!dayjsDate.isValid()) {\n //@ts-ignore - need to access internals to properly show error values\n timeValue = timePickerRef.current.state.currentPendingValue;\n }\n else {\n timeValue = dayjsDate.format(timePickerProps.timeFormat);\n }\n //@ts-ignore - need to access internals to properly show error values\n timePickerProps.onChange(timeValue);\n\n }\n\n useEffect(() => {\n setError(false);\n if (!timePickerProps.visible) {\n return;\n }\n const formattedTime = getFormattedTime();\n //@ts-ignore - need to access internals to properly show error values\n timePickerRef.current.setState({\n currentPendingValue: getFormattedTime()\n })\n if(!formattedTime || !formattedDateTime) {\n return;\n }\n const time = dayjs(formattedTime, timePickerProps.timeFormat, true);\n if (!time.isValid()) {\n setError(true);\n }\n }, [formattedDateTime]);\n\n\n return (\n <ThemeProvider theme={props.theme} className={styles.calendarCallout}>\n <CalendarBase {...props} value={props.value} />\n <hr />\n {timePickerProps.visible &&\n <TimePicker\n {...timePickerProps}\n errorMessage={error ? timePickerProps.errorMessage : undefined}\n componentRef={timePickerRef}\n onFormatDate={(date) => dayjs(date).format(timePickerProps.timeFormat)}\n onChange={onChange}\n allowFreeform\n onClick={() => timePickerRef.current?.focus(true)}\n useComboBoxAsMenuWidth\n styles={{\n callout: {\n maxHeight: '300px !important'\n }\n }}\n increments={15}\n />\n }\n </ThemeProvider>\n );\n};\n"],"names":["_jsxs","_jsx","CalendarBase"],"mappings":";;;;;;;;AAuBa,MAAA,QAAQ,GAAG,CAAC,KAA6B,KAAI;AACtD,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;AAC9C,IAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;AAC5D,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AACzB,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACxC,IAAA,MAAM,aAAa,GAAG,MAAM,CAAY,IAAI,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,gBAAgB,GAAG,MAAK;AAC1B,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,iBAAiB,EAAE,eAAe,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACjF,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE;YACtB,OAAO,eAAe,CAAC,qBAAqB,CAAC;AAChD,SAAA;QACD,OAAO,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,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,eAAe,EAAA,QAAA,EAAA,CAChEC,GAAC,CAAAC,UAAY,EAAK,EAAA,GAAA,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAA,CAAI,EAC/CD,GAAA,CAAA,IAAA,EAAA,EAAA,CAAM,EACL,eAAe,CAAC,OAAO;AACpB,gBAAAA,GAAA,CAAC,UAAU,EAAA,EAAA,GACH,eAAe,EACnB,YAAY,EAAE,KAAK,GAAG,eAAe,CAAC,YAAY,GAAG,SAAS,EAC9D,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EACtE,QAAQ,EAAE,QAAQ,EAClB,aAAa,QACb,OAAO,EAAE,MAAM,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EACjD,sBAAsB,EAAA,IAAA,EACtB,MAAM,EAAE;AACJ,wBAAA,OAAO,EAAE;AACL,4BAAA,SAAS,EAAE,kBAAkB;AAChC,yBAAA;AACJ,qBAAA,EACD,UAAU,EAAE,EAAE,EAChB,CAAA,CAAA,EAAA,CAEM,EAClB;AACN;;;;"}
|
|
@@ -11,7 +11,7 @@ const useDateTime = (props, ref) => {
|
|
|
11
11
|
const boundValue = props.parameters.value;
|
|
12
12
|
const context = props.context;
|
|
13
13
|
const behavior = boundValue.attributes.Behavior;
|
|
14
|
-
const format = boundValue.attributes.Format;
|
|
14
|
+
const format = boundValue.attributes.Format ?? boundValue.type;
|
|
15
15
|
const dateFormattingInfo = context.userSettings.dateFormattingInfo;
|
|
16
16
|
const lastValidDateRef = useRef(undefined);
|
|
17
17
|
const isDateTime = (() => {
|
|
@@ -46,22 +46,6 @@ const useDateTime = (props, ref) => {
|
|
|
46
46
|
}
|
|
47
47
|
return date;
|
|
48
48
|
};
|
|
49
|
-
const { value, labels, theme, setValue, onNotifyOutputChanged } = useInputBasedControl('DateTime', props, {
|
|
50
|
-
formatter: formatDate,
|
|
51
|
-
defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)
|
|
52
|
-
});
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
const onBlur = () => {
|
|
55
|
-
onNotifyOutputChanged({
|
|
56
|
-
value: dateExtractor(value)
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
const input = ref.current?.querySelector('input');
|
|
60
|
-
input?.addEventListener('blur', onBlur);
|
|
61
|
-
return () => {
|
|
62
|
-
input?.removeEventListener('blur', onBlur);
|
|
63
|
-
};
|
|
64
|
-
}, [value]);
|
|
65
49
|
useEffect(() => {
|
|
66
50
|
if (boundValue.raw instanceof Date) {
|
|
67
51
|
lastValidDateRef.current = boundValue.raw;
|
|
@@ -125,6 +109,23 @@ const useDateTime = (props, ref) => {
|
|
|
125
109
|
value: dateExtractor(invalidDateString ?? dayjsDate.toDate())
|
|
126
110
|
});
|
|
127
111
|
};
|
|
112
|
+
const { value, labels, theme, setValue, onNotifyOutputChanged } = useInputBasedControl('DateTime', props, {
|
|
113
|
+
formatter: formatDate,
|
|
114
|
+
valueExtractor: dateExtractor,
|
|
115
|
+
defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)
|
|
116
|
+
});
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const onBlur = () => {
|
|
119
|
+
onNotifyOutputChanged({
|
|
120
|
+
value: dateExtractor(value)
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
const input = ref.current?.querySelector('input');
|
|
124
|
+
input?.addEventListener('blur', onBlur);
|
|
125
|
+
return () => {
|
|
126
|
+
input?.removeEventListener('blur', onBlur);
|
|
127
|
+
};
|
|
128
|
+
}, [value]);
|
|
128
129
|
return [
|
|
129
130
|
isDateTime,
|
|
130
131
|
theme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDateTime.js","sources":["../../../../src/components/DateTime/hooks/useDateTime.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useInputBasedControl } from \"../../../hooks/useInputBasedControl\";\nimport { IDateTime, IDateTimeOutputs, IDateTimeParameters} from \"../interfaces\";\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { getDefaultDateTimeTranslations } from \"../translations\";\nimport {ITranslation } from \"../../../hooks\";\nimport { ITheme } from \"@talxis/react-components\";\n\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\n\nexport const useDateTime = (props: IDateTime, ref: React.RefObject<HTMLDivElement>): [\n boolean,\n ITheme,\n ITranslation<Required<IDateTime>['translations']>,\n {\n get: () => Date | undefined;\n getFormatted: () => string | undefined;\n set: (date?: Date, time?: string) => void;\n setDateString: (value: string | undefined) => void;\n clear: () => void;\n },\n {\n shortDatePattern: string\n shortTimePattern: string;\n fullDateTimePattern: string;\n },\n] => {\n\n const boundValue = props.parameters.value;\n const context = props.context;\n const behavior = boundValue.attributes.Behavior;\n const format = boundValue.attributes.Format;\n const dateFormattingInfo = context.userSettings.dateFormattingInfo;\n const lastValidDateRef = useRef<Date | undefined>(undefined);\n \n const isDateTime = (() => {\n switch (format) {\n case 'DateAndTime':\n case 'Date and Time':\n case 'DateAndTime.DateAndTime':\n case 'datetime': {\n return true;\n }\n default: {\n return false;\n }\n }\n })();\n\n //MS returns the pattern without correct separator and they do this during formatting\n const shortDatePattern = dateFormattingInfo.shortDatePattern.replace(/\\//g, dateFormattingInfo.dateSeparator).toUpperCase();\n const shortTimePattern = dateFormattingInfo.shortTimePattern.replace(/:/g, dateFormattingInfo.timeSeparator).replace('tt', 'A');\n const formatting = (() => {\n if (isDateTime) {\n return `${shortDatePattern} ${shortTimePattern}`;\n }\n return shortDatePattern;\n })();\n\n const formatDate = (date: Date | undefined | null | string): string | undefined | null => {\n if (date instanceof Date) {\n if (isDateTime) {\n //should handle the time zone conversion\n return context.formatting.formatTime(date, behavior);\n }\n return context.formatting.formatDateShort(date);\n }\n return date;\n };\n\n const {value, labels, theme, setValue, onNotifyOutputChanged} = useInputBasedControl<string | undefined, IDateTimeParameters, IDateTimeOutputs, Required<IDateTime>['translations']>('DateTime', props, {\n formatter: formatDate,\n defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)\n });\n\n useEffect(() => {\n const onBlur = () => {\n onNotifyOutputChanged({\n value: dateExtractor(value!) as any\n });\n };\n const input = ref.current?.querySelector('input');\n input?.addEventListener('blur', onBlur);\n return () => {\n input?.removeEventListener('blur', onBlur);\n };\n }, [value]);\n\n useEffect(() => {\n if (boundValue.raw instanceof Date) {\n lastValidDateRef.current = boundValue.raw;\n }\n }, [boundValue.raw]);\n\n const getDate = (): Date | undefined => {\n if (boundValue.raw instanceof Date) {\n if (behavior === 3) {\n //the date in javascript gets automatically adjusted to local time zone\n //this will make it think that the date already came in local time, thus not adjusting the time\n const date = new Date(boundValue.raw.toISOString().replace('Z', ''));\n return date;\n }\n return boundValue.raw;\n }\n if(boundValue.error) {\n return lastValidDateRef.current;\n }\n return undefined;\n };\n\n const dateExtractor = (value: string | Date): Date | string => {\n if (value instanceof Date) {\n return value;\n }\n const dayjsDate = dayjs(value, formatting, true);\n if (!dayjsDate.isValid()) {\n const dayJsDateNoWhiteSpace = dayjs(value?.replaceAll(' ', ''), formatting.replaceAll(' ', ''));\n if(!dayJsDateNoWhiteSpace.isValid()) {\n return value;\n }\n else {\n return dayJsDateNoWhiteSpace.toDate();\n }\n }\n return dayjsDate.toDate();\n };\n\n const clearDate = () => {\n onNotifyOutputChanged({\n value: undefined\n });\n };\n\n const selectDate = (date?: Date, time?: string) => {\n //onSelectDate can trigger on initial click with empty date, do not continue in this case\n //for clearing dates, date.clear should be used\n if(!date && !time) {\n return;\n }\n let dayjsDate = dayjs(date ?? getDate());\n //date selected from calendar, keep the original time\n if (!time) {\n time = dayjs(getDate()).format(shortTimePattern);\n }\n const dayjsTime = dayjs(time, shortTimePattern, true);\n let invalidDateString;\n if(!dayjsTime.isValid()) {\n invalidDateString = `${dayjsDate.format(shortDatePattern)} ${time}`\n }\n dayjsDate = dayjsDate.hour(dayjsTime.hour());\n dayjsDate = dayjsDate.minute(dayjsTime.minute());\n onNotifyOutputChanged({\n value: dateExtractor(invalidDateString ?? dayjsDate.toDate()) as any\n });\n };\n return [\n isDateTime,\n theme,\n labels,\n {\n get: getDate,\n clear: clearDate,\n getFormatted: () => value,\n set: selectDate,\n setDateString: setValue\n },\n {\n shortDatePattern: shortDatePattern,\n shortTimePattern: shortTimePattern,\n fullDateTimePattern: `${shortDatePattern} ${shortTimePattern}`\n }\n ]\n};"],"names":[],"mappings":";;;;;;;AAUA,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;MAEL,WAAW,GAAG,CAAC,KAAgB,EAAE,GAAoC,KAgB9E;AAEA,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;AAC1C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC;AAChD,IAAA,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;AAC5C,IAAA,MAAM,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC;AACnE,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAmB,SAAS,CAAC,CAAC;AAE7D,IAAA,MAAM,UAAU,GAAG,CAAC,MAAK;AACrB,QAAA,QAAQ,MAAM;AACV,YAAA,KAAK,aAAa,CAAC;AACnB,YAAA,KAAK,eAAe,CAAC;AACrB,YAAA,KAAK,yBAAyB,CAAC;YAC/B,KAAK,UAAU,EAAE;AACb,gBAAA,OAAO,IAAI,CAAC;AACf,aAAA;AACD,YAAA,S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,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,CAAA;AACtE,SAAA;QACD,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7C,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;AACjD,QAAA,qBAAqB,CAAC;YAClB,KAAK,EAAE,aAAa,CAAC,iBAAiB,IAAI,SAAS,CAAC,MAAM,EAAE,CAAQ;AACvE,SAAA,CAAC,CAAC;AACP,KAAC,CAAC;IACF,OAAO;QACH,UAAU;QACV,KAAK;QACL,MAAM;AACN,QAAA;AACI,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,YAAY,EAAE,MAAM,KAAK;AACzB,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,aAAa,EAAE,QAAQ;AAC1B,SAAA;AACD,QAAA;AACI,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,mBAAmB,EAAE,CAAA,EAAG,gBAAgB,CAAA,CAAA,EAAI,gBAAgB,CAAE,CAAA;AACjE,SAAA;KACJ,CAAA;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"useDateTime.js","sources":["../../../../src/components/DateTime/hooks/useDateTime.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useInputBasedControl } from \"../../../hooks/useInputBasedControl\";\nimport { IDateTime, IDateTimeOutputs, IDateTimeParameters} from \"../interfaces\";\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { getDefaultDateTimeTranslations } from \"../translations\";\nimport {ITranslation } from \"../../../hooks\";\nimport { ITheme } from \"@talxis/react-components\";\n\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\n\nexport const useDateTime = (props: IDateTime, ref: React.RefObject<HTMLDivElement>): [\n boolean,\n ITheme,\n ITranslation<Required<IDateTime>['translations']>,\n {\n get: () => Date | undefined;\n getFormatted: () => string | undefined;\n set: (date?: Date, time?: string) => void;\n setDateString: (value: string | undefined) => void;\n clear: () => void;\n },\n {\n shortDatePattern: string\n shortTimePattern: string;\n fullDateTimePattern: string;\n },\n] => {\n\n const boundValue = props.parameters.value;\n const context = props.context;\n const behavior = boundValue.attributes.Behavior;\n const format = boundValue.attributes.Format ?? boundValue.type;\n const dateFormattingInfo = context.userSettings.dateFormattingInfo;\n const lastValidDateRef = useRef<Date | undefined>(undefined);\n \n const isDateTime = (() => {\n switch (format) {\n case 'DateAndTime':\n case 'Date and Time':\n case 'DateAndTime.DateAndTime':\n case 'datetime': {\n return true;\n }\n default: {\n return false;\n }\n }\n })();\n\n //MS returns the pattern without correct separator and they do this during formatting\n const shortDatePattern = dateFormattingInfo.shortDatePattern.replace(/\\//g, dateFormattingInfo.dateSeparator).toUpperCase();\n const shortTimePattern = dateFormattingInfo.shortTimePattern.replace(/:/g, dateFormattingInfo.timeSeparator).replace('tt', 'A');\n const formatting = (() => {\n if (isDateTime) {\n return `${shortDatePattern} ${shortTimePattern}`;\n }\n return shortDatePattern;\n })();\n\n const formatDate = (date: Date | undefined | null | string): string | undefined | null => {\n if (date instanceof Date) {\n if (isDateTime) {\n //should handle the time zone conversion\n return context.formatting.formatTime(date, behavior);\n }\n return context.formatting.formatDateShort(date);\n }\n return date;\n };\n\n useEffect(() => {\n if (boundValue.raw instanceof Date) {\n lastValidDateRef.current = boundValue.raw;\n }\n }, [boundValue.raw]);\n\n const getDate = (): Date | undefined => {\n if (boundValue.raw instanceof Date) {\n if (behavior === 3) {\n //the date in javascript gets automatically adjusted to local time zone\n //this will make it think that the date already came in local time, thus not adjusting the time\n const date = new Date(boundValue.raw.toISOString().replace('Z', ''));\n return date;\n }\n return boundValue.raw;\n }\n if(boundValue.error) {\n return lastValidDateRef.current;\n }\n return undefined;\n };\n\n const dateExtractor = (value: string | Date): Date | string => {\n if (value instanceof Date) {\n return value;\n }\n const dayjsDate = dayjs(value, formatting, true);\n if (!dayjsDate.isValid()) {\n const dayJsDateNoWhiteSpace = dayjs(value?.replaceAll(' ', ''), formatting.replaceAll(' ', ''));\n if(!dayJsDateNoWhiteSpace.isValid()) {\n return value;\n }\n else {\n return dayJsDateNoWhiteSpace.toDate();\n }\n }\n return dayjsDate.toDate();\n };\n\n const clearDate = () => {\n onNotifyOutputChanged({\n value: undefined\n });\n };\n\n const selectDate = (date?: Date, time?: string) => {\n //onSelectDate can trigger on initial click with empty date, do not continue in this case\n //for clearing dates, date.clear should be used\n if(!date && !time) {\n return;\n }\n let dayjsDate = dayjs(date ?? getDate());\n //date selected from calendar, keep the original time\n if (!time) {\n time = dayjs(getDate()).format(shortTimePattern);\n }\n const dayjsTime = dayjs(time, shortTimePattern, true);\n let invalidDateString;\n if(!dayjsTime.isValid()) {\n invalidDateString = `${dayjsDate.format(shortDatePattern)} ${time}`\n }\n dayjsDate = dayjsDate.hour(dayjsTime.hour());\n dayjsDate = dayjsDate.minute(dayjsTime.minute());\n onNotifyOutputChanged({\n value: dateExtractor(invalidDateString ?? dayjsDate.toDate()) as any\n });\n };\n const {value, labels, theme, setValue, onNotifyOutputChanged} = useInputBasedControl<string | undefined, IDateTimeParameters, IDateTimeOutputs, Required<IDateTime>['translations']>('DateTime', props, {\n formatter: formatDate,\n valueExtractor: dateExtractor,\n defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)\n });\n\n\n useEffect(() => {\n const onBlur = () => {\n onNotifyOutputChanged({\n value: dateExtractor(value!) as any\n });\n };\n const input = ref.current?.querySelector('input');\n input?.addEventListener('blur', onBlur);\n return () => {\n input?.removeEventListener('blur', onBlur);\n };\n }, [value]);\n\n return [\n isDateTime,\n theme,\n labels,\n {\n get: getDate,\n clear: clearDate,\n getFormatted: () => value,\n set: selectDate,\n setDateString: setValue\n },\n {\n shortD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,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/C,SAAC,CAAC;AACN,KAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO;QACH,UAAU;QACV,KAAK;QACL,MAAM;AACN,QAAA;AACI,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,YAAY,EAAE,MAAM,KAAK;AACzB,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,aAAa,EAAE,QAAQ;AAC1B,SAAA;AACD,QAAA;AACI,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,mBAAmB,EAAE,CAAA,EAAG,gBAAgB,CAAA,CAAA,EAAI,gBAAgB,CAAE,CAAA;AACjE,SAAA;KACJ,CAAA;AACL;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { TextField } from '@talxis/react-components';
|
|
3
3
|
import { useInputBasedControl } from '../../hooks/useInputBasedControl.js';
|
|
4
|
-
import { useRef,
|
|
4
|
+
import { useRef, useMemo, useEffect } from 'react';
|
|
5
5
|
import numeral from 'numeral';
|
|
6
6
|
import { CURRENCY_POSITIVE_PATTERN, CURRENCY_NEGATIVE_PATTERN, NUMBER_NEGATIVE_PATTERN } from '../../constants.js';
|
|
7
7
|
import { ThemeProvider } from '@fluentui/react';
|
|
@@ -51,6 +51,9 @@ const Decimal = (props) => {
|
|
|
51
51
|
if (typeof value === 'number') {
|
|
52
52
|
return value;
|
|
53
53
|
}
|
|
54
|
+
if (value === initialFormattedValue) {
|
|
55
|
+
return boundValue.raw;
|
|
56
|
+
}
|
|
54
57
|
const str = value?.replace(/\s/g, '');
|
|
55
58
|
Numeral.decimal(numberFormatting);
|
|
56
59
|
let positivePattern;
|
|
@@ -92,6 +95,7 @@ const Decimal = (props) => {
|
|
|
92
95
|
formatter: formatter,
|
|
93
96
|
valueExtractor: extractNumericPart
|
|
94
97
|
});
|
|
98
|
+
const initialFormattedValue = useMemo(() => value, []);
|
|
95
99
|
const getSuffixItems = () => {
|
|
96
100
|
if (context.mode.isControlDisabled || !parameters.EnableSpinButton?.raw) {
|
|
97
101
|
return undefined;
|