@talxis/base-controls 1.2406.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/.env +1 -0
- package/.eslintrc +117 -0
- package/.npmgitignore +9 -0
- package/.vscode/settings.json +3 -0
- package/.yalcignore +2 -0
- package/README.md +18 -0
- package/azure-pipelines.yml +44 -0
- package/dist/Lookup-eb1505b3.js +1 -0
- package/dist/NumeralPCF-a609b7be.js +1 -0
- package/dist/components/DateTime/DateTime.d.ts +3 -0
- package/dist/components/DateTime/DateTime.js +1 -0
- package/dist/components/DateTime/components/Calendar.d.ts +12 -0
- package/dist/components/DateTime/hooks/useDateTime.d.ts +6 -0
- package/dist/components/DateTime/index.d.ts +2 -0
- package/dist/components/DateTime/interfaces.d.ts +31 -0
- package/dist/components/DateTime/styles.d.ts +34 -0
- package/dist/components/DateTime/translations.d.ts +3 -0
- package/dist/components/Decimal/Decimal.d.ts +3 -0
- package/dist/components/Decimal/Decimal.js +1 -0
- package/dist/components/Decimal/index.d.ts +2 -0
- package/dist/components/Decimal/interfaces.d.ts +13 -0
- package/dist/components/Duration/Duration.d.ts +3 -0
- package/dist/components/Duration/Duration.js +1 -0
- package/dist/components/Duration/index.d.ts +2 -0
- package/dist/components/Duration/interfaces.d.ts +31 -0
- package/dist/components/Duration/translations.d.ts +2 -0
- package/dist/components/Grid/Grid.d.ts +5 -0
- package/dist/components/Grid/Grid.js +10 -0
- package/dist/components/Grid/core/components/AgGrid/AgGrid.d.ts +2 -0
- package/dist/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.d.ts +2 -0
- package/dist/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.d.ts +18 -0
- package/dist/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.d.ts +2 -0
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.d.ts +12 -0
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +13 -0
- package/dist/components/Grid/core/components/AgGrid/styles.d.ts +69 -0
- package/dist/components/Grid/core/components/Cell/Commands/Commands.d.ts +7 -0
- package/dist/components/Grid/core/components/Cell/Commands/Icon.d.ts +7 -0
- package/dist/components/Grid/core/components/Cell/Commands/styles.d.ts +19 -0
- package/dist/components/Grid/core/components/Cell/Commands/useCommands.d.ts +5 -0
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.d.ts +10 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.d.ts +11 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.d.ts +10 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.d.ts +22 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.d.ts +47 -0
- package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.d.ts +6 -0
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.d.ts +2 -0
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.d.ts +13 -0
- package/dist/components/Grid/core/components/ColumnHeader/styles.d.ts +37 -0
- package/dist/components/Grid/core/components/Component/Component.d.ts +11 -0
- package/dist/components/Grid/core/components/Component/controller/useComponentController.d.ts +9 -0
- package/dist/components/Grid/core/components/Component/model/Component.d.ts +10 -0
- package/dist/components/Grid/core/components/Dialog/Constants.d.ts +2 -0
- package/dist/components/Grid/core/components/Dialog/Styles.d.ts +2 -0
- package/dist/components/Grid/core/components/Dialog/index.d.ts +4 -0
- package/dist/components/Grid/core/components/Save/Save.d.ts +2 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.d.ts +3 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.d.ts +7 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.d.ts +48 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/styles.d.ts +31 -0
- package/dist/components/Grid/core/components/Save/hooks/useSave.d.ts +12 -0
- package/dist/components/Grid/core/components/Save/styles.d.ts +37 -0
- package/dist/components/Grid/core/controllers/useGridController.d.ts +9 -0
- package/dist/components/Grid/core/enums/ConditionOperator.d.ts +46 -0
- package/dist/components/Grid/core/enums/DataType.d.ts +24 -0
- package/dist/components/Grid/core/hooks/useGridInstance.d.ts +2 -0
- package/dist/components/Grid/core/hooks/useRefreshCallback.d.ts +2 -0
- package/dist/components/Grid/core/hooks/useRerender.d.ts +1 -0
- package/dist/components/Grid/core/interfaces/IGridColumn.d.ts +18 -0
- package/dist/components/Grid/core/interfaces/IGridContext.d.ts +4 -0
- package/dist/components/Grid/core/model/Grid.d.ts +51 -0
- package/dist/components/Grid/core/model/GridDependency.d.ts +13 -0
- package/dist/components/Grid/core/model/Metadata.d.ts +7 -0
- package/dist/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.d.ts +14 -0
- package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.d.ts +30 -0
- package/dist/components/Grid/filtering/components/FilterCallout/FilterCallout.d.ts +8 -0
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.d.ts +7 -0
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.d.ts +7 -0
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.d.ts +30 -0
- package/dist/components/Grid/filtering/components/FilterCallout/styles.d.ts +35 -0
- package/dist/components/Grid/filtering/constants.d.ts +5 -0
- package/dist/components/Grid/filtering/controller/useColumnFilterConditionController.d.ts +19 -0
- package/dist/components/Grid/filtering/model/Condition.d.ts +47 -0
- package/dist/components/Grid/filtering/model/Filtering.d.ts +11 -0
- package/dist/components/Grid/filtering/utils/FilteringUtilts.d.ts +34 -0
- package/dist/components/Grid/interfaces.d.ts +254 -0
- package/dist/components/Grid/paging/components/Paging/Paging.d.ts +2 -0
- package/dist/components/Grid/paging/components/Paging/styles.d.ts +35 -0
- package/dist/components/Grid/paging/controllers/usePagingController.d.ts +16 -0
- package/dist/components/Grid/paging/model/Paging.d.ts +15 -0
- package/dist/components/Grid/selection/controllers/useSelectionController.d.ts +11 -0
- package/dist/components/Grid/selection/model/Selection.d.ts +13 -0
- package/dist/components/Grid/sorting/Sorting.d.ts +9 -0
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.d.ts +8 -0
- package/dist/components/Grid/sorting/components/SortingContextualMenu/styles.d.ts +9 -0
- package/dist/components/Grid/sorting/controllers/useColumnSortingController.d.ts +8 -0
- package/dist/components/Grid/translations.d.ts +2 -0
- package/dist/components/Grid/validation/controllers/useRecordValidationController.d.ts +8 -0
- package/dist/components/Grid/validation/model/ColumnValidation.d.ts +11 -0
- package/dist/components/Lookup/Lookup.d.ts +3 -0
- package/dist/components/Lookup/Lookup.js +1 -0
- package/dist/components/Lookup/components/RecordCreator.d.ts +10 -0
- package/dist/components/Lookup/components/TargetSelector.d.ts +10 -0
- package/dist/components/Lookup/hooks/useFetchXml.d.ts +3 -0
- package/dist/components/Lookup/hooks/useLoadedEntities.d.ts +6 -0
- package/dist/components/Lookup/hooks/useLookup.d.ts +8 -0
- package/dist/components/Lookup/index.d.ts +2 -0
- package/dist/components/Lookup/interfaces.d.ts +52 -0
- package/dist/components/Lookup/lib.d.ts +1164 -0
- package/dist/components/Lookup/styles.d.ts +90 -0
- package/dist/components/Lookup/translations.d.ts +2 -0
- package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.d.ts +3 -0
- package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js +1 -0
- package/dist/components/MultiSelectOptionSet/index.d.ts +2 -0
- package/dist/components/MultiSelectOptionSet/interfaces.d.ts +11 -0
- package/dist/components/OptionSet/OptionSet.d.ts +3 -0
- package/dist/components/OptionSet/OptionSet.js +1 -0
- package/dist/components/OptionSet/index.d.ts +2 -0
- package/dist/components/OptionSet/interfaces.d.ts +13 -0
- package/dist/components/TextField/TextField.d.ts +3 -0
- package/dist/components/TextField/TextField.js +1 -0
- package/dist/components/TextField/hooks/useTextField.d.ts +2 -0
- package/dist/components/TextField/index.d.ts +2 -0
- package/dist/components/TextField/interfaces.d.ts +15 -0
- package/dist/components/TwoOptions/TwoOptions.d.ts +3 -0
- package/dist/components/TwoOptions/TwoOptions.js +1 -0
- package/dist/components/TwoOptions/index.d.ts +2 -0
- package/dist/components/TwoOptions/interfaces.d.ts +13 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useComponent.d.ts +7 -0
- package/dist/hooks/useComponent.js +1 -0
- package/dist/hooks/useFocusIn.d.ts +1 -0
- package/dist/hooks/useFocusIn.js +1 -0
- package/dist/hooks/useInputBasedComponent.d.ts +32 -0
- package/dist/hooks/useInputBasedComponent.js +1 -0
- package/dist/hooks/useMouseOver.d.ts +1 -0
- package/dist/hooks/useMouseOver.js +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/interfaces/context.d.ts +20 -0
- package/dist/interfaces/index.d.ts +9 -0
- package/dist/interfaces/parameters.d.ts +23 -0
- package/dist/interfaces/property.d.ts +100 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/utils/NumeralPCF.d.ts +6 -0
- package/examples/Currency/Currency/ControlManifest.Input.xml +53 -0
- package/examples/Currency/Currency/index.ts +66 -0
- package/examples/Currency/Currency.pcfproj +46 -0
- package/examples/Currency/package-lock.json +15900 -0
- package/examples/Currency/package.json +29 -0
- package/examples/Currency/pcfconfig.json +3 -0
- package/examples/Currency/tsconfig.json +7 -0
- package/examples/DateTime/DateTime/ControlManifest.Input.xml +58 -0
- package/examples/DateTime/DateTime/index.ts +69 -0
- package/examples/DateTime/DateTime.pcfproj +46 -0
- package/examples/DateTime/package-lock.json +15900 -0
- package/examples/DateTime/package.json +29 -0
- package/examples/DateTime/pcfconfig.json +3 -0
- package/examples/DateTime/tsconfig.json +7 -0
- package/examples/Decimal/Decimal/ControlManifest.Input.xml +66 -0
- package/examples/Decimal/Decimal/index.ts +66 -0
- package/examples/Decimal/Decimal.pcfproj +46 -0
- package/examples/Decimal/package-lock.json +15900 -0
- package/examples/Decimal/package.json +28 -0
- package/examples/Decimal/pcfconfig.json +3 -0
- package/examples/Decimal/tsconfig.json +7 -0
- package/examples/Duration/Duration/ControlManifest.Input.xml +53 -0
- package/examples/Duration/Duration/index.ts +66 -0
- package/examples/Duration/Duration.pcfproj +46 -0
- package/examples/Duration/package-lock.json +15900 -0
- package/examples/Duration/package.json +29 -0
- package/examples/Duration/pcfconfig.json +3 -0
- package/examples/Duration/tsconfig.json +7 -0
- package/examples/Grid/Grid/ControlManifest.Input.xml +28 -0
- package/examples/Grid/Grid/index.ts +100 -0
- package/examples/Grid/Grid.pcfproj +46 -0
- package/examples/Grid/package-lock.json +15901 -0
- package/examples/Grid/package.json +30 -0
- package/examples/Grid/pcfconfig.json +3 -0
- package/examples/Grid/tsconfig.json +7 -0
- package/examples/Lookup/Lookup/ControlManifest.Input.xml +51 -0
- package/examples/Lookup/Lookup/index.ts +90 -0
- package/examples/Lookup/Lookup.pcfproj +46 -0
- package/examples/Lookup/package-lock.json +15900 -0
- package/examples/Lookup/package.json +29 -0
- package/examples/Lookup/pcfconfig.json +3 -0
- package/examples/Lookup/tsconfig.json +8 -0
- package/examples/MultiSelectOptionSet/MultiSelectOptionSet/ControlManifest.Input.xml +53 -0
- package/examples/MultiSelectOptionSet/MultiSelectOptionSet/index.ts +86 -0
- package/examples/MultiSelectOptionSet/MultiSelectOptionSet.pcfproj +46 -0
- package/examples/MultiSelectOptionSet/package-lock.json +15900 -0
- package/examples/MultiSelectOptionSet/package.json +31 -0
- package/examples/MultiSelectOptionSet/pcfconfig.json +3 -0
- package/examples/MultiSelectOptionSet/tsconfig.json +7 -0
- package/examples/OptionSet/OptionSet/ControlManifest.Input.xml +53 -0
- package/examples/OptionSet/OptionSet/index.ts +70 -0
- package/examples/OptionSet/OptionSet.pcfproj +46 -0
- package/examples/OptionSet/package-lock.json +15900 -0
- package/examples/OptionSet/package.json +29 -0
- package/examples/OptionSet/pcfconfig.json +3 -0
- package/examples/OptionSet/tsconfig.json +7 -0
- package/examples/TwoOptions/TwoOptions/ControlManifest.Input.xml +53 -0
- package/examples/TwoOptions/TwoOptions/index.ts +69 -0
- package/examples/TwoOptions/TwoOptions.pcfproj +46 -0
- package/examples/TwoOptions/package-lock.json +15900 -0
- package/examples/TwoOptions/package.json +29 -0
- package/examples/TwoOptions/pcfconfig.json +3 -0
- package/examples/TwoOptions/tsconfig.json +7 -0
- package/package.json +94 -0
- package/public/index.html +43 -0
- package/public/manifest.json +25 -0
- package/rollup.config.js +44 -0
- package/src/components/DateTime/DateTime.tsx +97 -0
- package/src/components/DateTime/components/Calendar.tsx +80 -0
- package/src/components/DateTime/hooks/useDateTime.ts +144 -0
- package/src/components/DateTime/index.ts +2 -0
- package/src/components/DateTime/interfaces.ts +22 -0
- package/src/components/DateTime/styles.ts +37 -0
- package/src/components/DateTime/translations.ts +18 -0
- package/src/components/Decimal/Decimal.tsx +120 -0
- package/src/components/Decimal/index.ts +2 -0
- package/src/components/Decimal/interfaces.ts +20 -0
- package/src/components/Duration/Duration.tsx +143 -0
- package/src/components/Duration/index.ts +2 -0
- package/src/components/Duration/interfaces.ts +22 -0
- package/src/components/Duration/translations.ts +30 -0
- package/src/components/Grid/Grid.tsx +24 -0
- package/src/components/Grid/core/components/AgGrid/AgGrid.tsx +206 -0
- package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.tsx +16 -0
- package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.ts +20 -0
- package/src/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.tsx +7 -0
- package/src/components/Grid/core/components/AgGrid/controllers/useAgGridController.ts +68 -0
- package/src/components/Grid/core/components/AgGrid/model/AgGrid.ts +100 -0
- package/src/components/Grid/core/components/AgGrid/styles.ts +72 -0
- package/src/components/Grid/core/components/Cell/Commands/Commands.tsx +32 -0
- package/src/components/Grid/core/components/Cell/Commands/Icon.tsx +17 -0
- package/src/components/Grid/core/components/Cell/Commands/styles.ts +21 -0
- package/src/components/Grid/core/components/Cell/Commands/useCommands.tsx +53 -0
- package/src/components/Grid/core/components/Cell/EditableCell/EditableCell.tsx +140 -0
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx +176 -0
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx +67 -0
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.ts +24 -0
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/styles.ts +56 -0
- package/src/components/Grid/core/components/ColumnHeader/ColumnHeader.tsx +71 -0
- package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.tsx +31 -0
- package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.ts +16 -0
- package/src/components/Grid/core/components/ColumnHeader/styles.ts +40 -0
- package/src/components/Grid/core/components/Component/Component.tsx +59 -0
- package/src/components/Grid/core/components/Component/controller/useComponentController.ts +39 -0
- package/src/components/Grid/core/components/Component/model/Component.ts +251 -0
- package/src/components/Grid/core/components/Dialog/Constants.tsx +8 -0
- package/src/components/Grid/core/components/Dialog/Styles.tsx +61 -0
- package/src/components/Grid/core/components/Dialog/index.tsx +22 -0
- package/src/components/Grid/core/components/Dialog/interfaces/index.d.ts +7 -0
- package/src/components/Grid/core/components/Save/Save.tsx +74 -0
- package/src/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.tsx +63 -0
- package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx +153 -0
- package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.ts +52 -0
- package/src/components/Grid/core/components/Save/components/ChangeEditor/styles.ts +34 -0
- package/src/components/Grid/core/components/Save/hooks/useSave.ts +59 -0
- package/src/components/Grid/core/components/Save/styles.ts +41 -0
- package/src/components/Grid/core/controllers/useGridController.ts +46 -0
- package/src/components/Grid/core/enums/ConditionOperator.ts +46 -0
- package/src/components/Grid/core/enums/DataType.ts +25 -0
- package/src/components/Grid/core/hooks/useGridInstance.ts +7 -0
- package/src/components/Grid/core/hooks/useRefreshCallback.ts +20 -0
- package/src/components/Grid/core/hooks/useRerender.ts +15 -0
- package/src/components/Grid/core/interfaces/IGridColumn.ts +19 -0
- package/src/components/Grid/core/interfaces/IGridContext.ts +7 -0
- package/src/components/Grid/core/model/Grid.ts +250 -0
- package/src/components/Grid/core/model/GridDependency.ts +34 -0
- package/src/components/Grid/core/model/Metadata.ts +20 -0
- package/src/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.ts +36 -0
- package/src/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.ts +222 -0
- package/src/components/Grid/filtering/components/FilterCallout/FilterCallout.tsx +83 -0
- package/src/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.tsx +66 -0
- package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.tsx +48 -0
- package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.ts +120 -0
- package/src/components/Grid/filtering/components/FilterCallout/styles.ts +37 -0
- package/src/components/Grid/filtering/constants.ts +48 -0
- package/src/components/Grid/filtering/controller/useColumnFilterConditionController.ts +63 -0
- package/src/components/Grid/filtering/model/Condition.ts +309 -0
- package/src/components/Grid/filtering/model/Filtering.ts +78 -0
- package/src/components/Grid/filtering/utils/FilteringUtilts.ts +190 -0
- package/src/components/Grid/interfaces.ts +109 -0
- package/src/components/Grid/paging/components/Paging/Paging.tsx +76 -0
- package/src/components/Grid/paging/components/Paging/styles.ts +38 -0
- package/src/components/Grid/paging/controllers/usePagingController.ts +34 -0
- package/src/components/Grid/paging/model/Paging.ts +49 -0
- package/src/components/Grid/selection/controllers/useSelectionController.ts +25 -0
- package/src/components/Grid/selection/model/Selection.ts +60 -0
- package/src/components/Grid/sorting/Sorting.ts +30 -0
- package/src/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.tsx +126 -0
- package/src/components/Grid/sorting/components/SortingContextualMenu/styles.ts +12 -0
- package/src/components/Grid/sorting/controllers/useColumnSortingController.ts +26 -0
- package/src/components/Grid/translations.ts +80 -0
- package/src/components/Grid/validation/controllers/useRecordValidationController.ts +31 -0
- package/src/components/Grid/validation/model/ColumnValidation.ts +81 -0
- package/src/components/Lookup/Lookup.tsx +199 -0
- package/src/components/Lookup/components/RecordCreator.tsx +53 -0
- package/src/components/Lookup/components/TargetSelector.tsx +43 -0
- package/src/components/Lookup/hooks/useFetchXml.ts +31 -0
- package/src/components/Lookup/hooks/useLoadedEntities.ts +23 -0
- package/src/components/Lookup/hooks/useLookup.ts +126 -0
- package/src/components/Lookup/index.ts +2 -0
- package/src/components/Lookup/interfaces.ts +45 -0
- package/src/components/Lookup/lib.ts +3110 -0
- package/src/components/Lookup/styles.ts +106 -0
- package/src/components/Lookup/translations.ts +28 -0
- package/src/components/MultiSelectOptionSet/MultiSelectOptionSet.tsx +83 -0
- package/src/components/MultiSelectOptionSet/index.ts +2 -0
- package/src/components/MultiSelectOptionSet/interfaces.ts +14 -0
- package/src/components/OptionSet/OptionSet.tsx +67 -0
- package/src/components/OptionSet/index.ts +2 -0
- package/src/components/OptionSet/interfaces.ts +17 -0
- package/src/components/TextField/TextField.tsx +58 -0
- package/src/components/TextField/hooks/useTextField.ts +42 -0
- package/src/components/TextField/index.ts +2 -0
- package/src/components/TextField/interfaces.ts +20 -0
- package/src/components/TwoOptions/TwoOptions.tsx +43 -0
- package/src/components/TwoOptions/index.ts +2 -0
- package/src/components/TwoOptions/interfaces.ts +17 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useComponent.ts +83 -0
- package/src/hooks/useFocusIn.ts +23 -0
- package/src/hooks/useInputBasedComponent.ts +71 -0
- package/src/hooks/useMouseOver.ts +23 -0
- package/src/index.tsx +12 -0
- package/src/interfaces/context.ts +21 -0
- package/src/interfaces/index.ts +12 -0
- package/src/interfaces/parameters.ts +26 -0
- package/src/interfaces/property.ts +111 -0
- package/src/sandbox/index.tsx +137 -0
- package/src/sandbox/mock/Context.ts +18 -0
- package/src/sandbox/mock/Formatting.ts +186 -0
- package/src/sandbox/mock/Mode.ts +25 -0
- package/src/sandbox/mock/UserSettings.ts +31 -0
- package/src/sandbox/mock/Utility.ts +14 -0
- package/src/sandbox/shared/durationList.tsx +24 -0
- package/src/sandbox/shared/multiSelectOptionList.tsx +5 -0
- package/src/sandbox/shared/optionList.tsx +5 -0
- package/src/stories/Introduction.stories.mdx +122 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/types/index.ts +3 -0
- package/src/utils/NumeralPCF.ts +62 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pcf-project",
|
|
3
|
+
"version": "1.2406.2",
|
|
4
|
+
"description": "Project containing your PowerApps Component Framework (PCF) control.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "pcf-scripts build",
|
|
7
|
+
"clean": "pcf-scripts clean",
|
|
8
|
+
"lint": "pcf-scripts lint",
|
|
9
|
+
"lint:fix": "pcf-scripts lint fix",
|
|
10
|
+
"rebuild": "pcf-scripts rebuild",
|
|
11
|
+
"start": "pcf-scripts start",
|
|
12
|
+
"start:watch": "pcf-scripts start watch",
|
|
13
|
+
"refreshTypes": "pcf-scripts refreshTypes"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@microsoft/eslint-plugin-power-apps": "^0.2.6",
|
|
17
|
+
"@types/node": "^18.8.2",
|
|
18
|
+
"@types/powerapps-component-framework": "^1.3.4",
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
20
|
+
"@typescript-eslint/parser": "^5.39.0",
|
|
21
|
+
"eslint": "^8.24.0",
|
|
22
|
+
"eslint-plugin-import": "^2.26.0",
|
|
23
|
+
"eslint-plugin-node": "^11.1.0",
|
|
24
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
25
|
+
"pcf-scripts": "^1",
|
|
26
|
+
"pcf-start": "^1",
|
|
27
|
+
"typescript": "^4.9.5"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@talxis/base-controls",
|
|
3
|
+
"version": "1.2406.2",
|
|
4
|
+
"description": "Set of React components that natively work with Power Apps Component Framework API's",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@babel/core": "^7.16.12",
|
|
11
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
12
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
13
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
14
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
15
|
+
"@testing-library/react": "^12.1.2",
|
|
16
|
+
"@testing-library/user-event": "^13.5.0",
|
|
17
|
+
"@types/color": "^3.0.6",
|
|
18
|
+
"@types/jest": "^27.4.0",
|
|
19
|
+
"@types/lodash.clonedeep": "^4.5.7",
|
|
20
|
+
"@types/node": "^17.0.14",
|
|
21
|
+
"@types/numeral": "^2.0.5",
|
|
22
|
+
"@types/powerapps-component-framework": "^1.3.5",
|
|
23
|
+
"@types/react": "^17.0.38",
|
|
24
|
+
"@types/react-dom": "^17.0.11",
|
|
25
|
+
"babel-loader": "^8.2.3",
|
|
26
|
+
"esbuild": "^0.13.9",
|
|
27
|
+
"postcss": "^8.3.11",
|
|
28
|
+
"react-scripts": "5.0.0",
|
|
29
|
+
"rollup": "^2.58.1",
|
|
30
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
31
|
+
"rollup-plugin-dts": "^4.0.0",
|
|
32
|
+
"rollup-plugin-esbuild": "^4.6.0",
|
|
33
|
+
"rollup-plugin-multi-input": "^1.3.1",
|
|
34
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
35
|
+
"rollup-plugin-postcss": "^4.0.1",
|
|
36
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
37
|
+
"typescript": "^4.5.2",
|
|
38
|
+
"web-vitals": "^2.1.4",
|
|
39
|
+
"webpack": "^5.68.0",
|
|
40
|
+
"@types/validator": "^13.11.9"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@fluentui/react": "8.51.0 || 8.29.0",
|
|
44
|
+
"@talxis/client-libraries": "^1.2402.3",
|
|
45
|
+
"color": "^4.2.3",
|
|
46
|
+
"dayjs": "^1.11.10",
|
|
47
|
+
"external-svg-loader": "^1.7.1",
|
|
48
|
+
"fast-deep-equal": "^3.1.3",
|
|
49
|
+
"humanize-duration": "^3.32.0",
|
|
50
|
+
"liquidjs": "^9.43.0",
|
|
51
|
+
"lodash.clonedeep": "^4.5.0",
|
|
52
|
+
"merge-anything": "^5.1.7",
|
|
53
|
+
"numeral": "^2.0.6",
|
|
54
|
+
"react": "^16.8.6 || ^17.0.2",
|
|
55
|
+
"react-dom": "^16.8.6 || ^17.0.2",
|
|
56
|
+
"use-debounce": "^10.0.1",
|
|
57
|
+
"validator": "^13.11.9",
|
|
58
|
+
"@talxis/react-components": "^1.2404.1"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "rollup -c",
|
|
62
|
+
"test": "react-scripts test",
|
|
63
|
+
"eject": "react-scripts eject",
|
|
64
|
+
"documentation": "start-storybook -p 6006",
|
|
65
|
+
"sandbox": "react-scripts start",
|
|
66
|
+
"build-documentation": "build-storybook",
|
|
67
|
+
"lint": "eslint \"./src/**\"",
|
|
68
|
+
"lint:fix": "eslint \"./src/**\" --fix"
|
|
69
|
+
},
|
|
70
|
+
"eslintConfig": {
|
|
71
|
+
"extends": [
|
|
72
|
+
"react-app",
|
|
73
|
+
"react-app/jest"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"browserslist": {
|
|
77
|
+
"production": [
|
|
78
|
+
">0.2%",
|
|
79
|
+
"not dead",
|
|
80
|
+
"not op_mini all"
|
|
81
|
+
],
|
|
82
|
+
"development": [
|
|
83
|
+
"last 1 chrome version",
|
|
84
|
+
"last 1 firefox version",
|
|
85
|
+
"last 1 safari version"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"dependencies": {
|
|
89
|
+
"@ag-grid-community/client-side-row-model": "^31.3.2",
|
|
90
|
+
"@ag-grid-community/core": "^31.3.2",
|
|
91
|
+
"@ag-grid-community/react": "^31.3.2",
|
|
92
|
+
"@ag-grid-community/styles": "^31.3.2"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#000000" />
|
|
8
|
+
<meta
|
|
9
|
+
name="description"
|
|
10
|
+
content="Web site created using create-react-app"
|
|
11
|
+
/>
|
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
+
<!--
|
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
+
-->
|
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
+
<!--
|
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
+
|
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
+
-->
|
|
27
|
+
<title>React App</title>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<!--
|
|
33
|
+
This HTML file is a template.
|
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
|
35
|
+
|
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
+
|
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
+
-->
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "logo192.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "192x192"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "logo512.png",
|
|
17
|
+
"type": "image/png",
|
|
18
|
+
"sizes": "512x512"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"start_url": ".",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"theme_color": "#000000",
|
|
24
|
+
"background_color": "#ffffff"
|
|
25
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
+
import typescript from '@rollup/plugin-typescript';
|
|
3
|
+
import { terser } from 'rollup-plugin-terser';
|
|
4
|
+
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
5
|
+
import postcss from 'rollup-plugin-postcss';
|
|
6
|
+
import dts from 'rollup-plugin-dts';
|
|
7
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
8
|
+
import multiInput from 'rollup-plugin-multi-input';
|
|
9
|
+
import del from 'rollup-plugin-delete';
|
|
10
|
+
|
|
11
|
+
export default [
|
|
12
|
+
{
|
|
13
|
+
input: [
|
|
14
|
+
'src/components/*/*.tsx',
|
|
15
|
+
'src/hooks/*.ts'
|
|
16
|
+
],
|
|
17
|
+
output: [
|
|
18
|
+
{
|
|
19
|
+
dir: 'dist',
|
|
20
|
+
format: 'esm',
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
plugins: [
|
|
24
|
+
commonjs(),
|
|
25
|
+
peerDepsExternal('./package.json'),
|
|
26
|
+
resolve(),
|
|
27
|
+
typescript({
|
|
28
|
+
tsconfig: './tsconfig.json',
|
|
29
|
+
}),
|
|
30
|
+
postcss(),
|
|
31
|
+
multiInput(),
|
|
32
|
+
terser()
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
input: ['dist/index.d.ts'],
|
|
37
|
+
output: [{ file: 'dist/index.d.ts', format: "esm"}],
|
|
38
|
+
external: [/\.css$/],
|
|
39
|
+
plugins: [
|
|
40
|
+
dts(),
|
|
41
|
+
del({ hook: "buildEnd", targets: ['dist/stories', 'dist/sandbox'] })
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
import { IDateTime } from "./interfaces";
|
|
3
|
+
import { IDatePicker, useTheme } from "@fluentui/react";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { getDateTimeStyles } from "./styles";
|
|
6
|
+
import { useDateTime } from "./hooks/useDateTime";
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
import { Calendar } from "./components/Calendar";
|
|
9
|
+
import { DatePicker } from "@talxis/react-components/dist/components/DatePicker";
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
export const DateTime = (componentProps: IDateTime) => {
|
|
13
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
14
|
+
const datePickerRef = useRef<IDatePicker>(null);
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
const styles = getDateTimeStyles(theme);
|
|
17
|
+
const context = componentProps.context;
|
|
18
|
+
const parameters = componentProps.parameters;
|
|
19
|
+
const [date, stringDate, isDateTime, patterns, labels, setStringDate, selectDate, clearDate] = useDateTime(componentProps, ref);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if(componentProps.parameters.AutoFocus?.raw === true) {
|
|
23
|
+
datePickerRef.current?.showDatePickerPopup();
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
return (
|
|
27
|
+
<div ref={ref}>
|
|
28
|
+
<DatePicker
|
|
29
|
+
className={styles.datePicker}
|
|
30
|
+
componentRef={datePickerRef}
|
|
31
|
+
keepCalendarOpenAfterDaySelect={isDateTime}
|
|
32
|
+
allowTextInput
|
|
33
|
+
calendarProps={{
|
|
34
|
+
//needs to be here as the internal picker does not call the function passed in calendarAs
|
|
35
|
+
onSelectDate: (date) => selectDate(date),
|
|
36
|
+
}}
|
|
37
|
+
// Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN
|
|
38
|
+
minDate={new Date('1753-01-01T00:00:00.000Z')}
|
|
39
|
+
firstDayOfWeek={componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek}
|
|
40
|
+
calendarAs={(props) =>
|
|
41
|
+
<Calendar {...props}
|
|
42
|
+
strings={{
|
|
43
|
+
goToToday: labels.goToToday(),
|
|
44
|
+
days: JSON.parse(labels.days()),
|
|
45
|
+
months: JSON.parse(labels.months()),
|
|
46
|
+
shortDays: JSON.parse(labels.shortDays()),
|
|
47
|
+
shortMonths: JSON.parse(labels.shortMonths())
|
|
48
|
+
}}
|
|
49
|
+
timePickerProps={{
|
|
50
|
+
autoComplete: "off",
|
|
51
|
+
autoCapitalize: "off",
|
|
52
|
+
timeFormat: patterns.shortTimePattern,
|
|
53
|
+
label: labels.time(),
|
|
54
|
+
visible: isDateTime && !parameters.value.errorMessage,
|
|
55
|
+
useHour12: patterns.shortTimePattern.endsWith('A'),
|
|
56
|
+
onChange: (e, date) => selectDate(undefined, dayjs(date).format('HH:mm')),
|
|
57
|
+
defaultValue: date
|
|
58
|
+
}} />
|
|
59
|
+
}
|
|
60
|
+
textField={{
|
|
61
|
+
value: stringDate ?? "",
|
|
62
|
+
onChange: (e, value) => setStringDate(value),
|
|
63
|
+
placeholder: '---',
|
|
64
|
+
onNotifyValidationResult: () => null,
|
|
65
|
+
noValidate: true,
|
|
66
|
+
borderless: parameters.EnableBorder?.raw === false,
|
|
67
|
+
errorMessage: parameters.value.errorMessage,
|
|
68
|
+
styles:{
|
|
69
|
+
fieldGroup: {
|
|
70
|
+
height: context.mode.allocatedHeight || undefined,
|
|
71
|
+
width: context.mode.allocatedWidth || undefined
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
//@ts-ignore - TODO: fix types in shared components
|
|
75
|
+
deleteButtonProps: parameters.EnableDeleteButton?.raw === true ? {
|
|
76
|
+
key: 'Delete',
|
|
77
|
+
onClick: clearDate,
|
|
78
|
+
showOnlyOnHover: true,
|
|
79
|
+
iconProps: {
|
|
80
|
+
iconName: 'Cancel'
|
|
81
|
+
}
|
|
82
|
+
} : undefined,
|
|
83
|
+
clickToCopyProps: parameters.EnableCopyButton?.raw === true ? {
|
|
84
|
+
key: 'copy',
|
|
85
|
+
showOnlyOnHover: true,
|
|
86
|
+
iconProps: {
|
|
87
|
+
iconName: 'Copy'
|
|
88
|
+
}
|
|
89
|
+
} : undefined
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//undefined will break the calendar => it wont reflect date change in it's UI
|
|
93
|
+
value={date ?? new Date()}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ICalendarProps } from "@fluentui/react/lib/components/Calendar/Calendar.types";
|
|
2
|
+
import { IAutofill } from "@fluentui/react/lib/components/pickers/AutoFill/BaseAutoFill.types";
|
|
3
|
+
import { ITimePickerProps } from "@fluentui/react/lib/components/TimePicker/TimePicker.types";
|
|
4
|
+
import { useTheme } from "@fluentui/react/lib/utilities/ThemeProvider/useTheme";
|
|
5
|
+
import { Calendar as CalendarBase } from '@fluentui/react/lib/Calendar';
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
7
|
+
import { getDateTimeStyles } from "../styles";
|
|
8
|
+
import { TimePicker } from "@talxis/react-components/dist/components/TimePicker";
|
|
9
|
+
import { Text } from '@fluentui/react/lib/Text';
|
|
10
|
+
import dayjs from "dayjs";
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { FocusTrapZone } from "@fluentui/react";
|
|
13
|
+
|
|
14
|
+
interface IInternalTimePickerProps extends ITimePickerProps {
|
|
15
|
+
visible: boolean;
|
|
16
|
+
timeFormat: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface IInternalCalendarProps extends ICalendarProps {
|
|
20
|
+
timePickerProps: IInternalTimePickerProps;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const Calendar = (props: IInternalCalendarProps) => {
|
|
24
|
+
const theme = useTheme();
|
|
25
|
+
const styles = getDateTimeStyles(theme);
|
|
26
|
+
const timePickerRef = useRef<IAutofill>(null);
|
|
27
|
+
const [isTimePickerControlled, setIsTimePickerControlled] = useState<boolean>(true);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
//@ts-ignore - we need to use the internal method to display exact time, otherwise the shown value would always get rounded to the next 15 min
|
|
30
|
+
timePickerRef.current?._updateValue(getFormattedTime());
|
|
31
|
+
setIsTimePickerControlled(false);
|
|
32
|
+
|
|
33
|
+
}, [props.timePickerProps.defaultValue]);
|
|
34
|
+
|
|
35
|
+
const getFormattedTime = () => {
|
|
36
|
+
return dayjs(props.timePickerProps.defaultValue).format(props.timePickerProps.timeFormat);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
//hack to focus the selected date for keyboard support
|
|
41
|
+
const day = document.querySelector('.ms-CalendarDay-daySelected') as HTMLButtonElement;
|
|
42
|
+
day?.focus();
|
|
43
|
+
}, [props]);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className={styles.calendarCallout}>
|
|
47
|
+
<CalendarBase {...props} />
|
|
48
|
+
<hr />
|
|
49
|
+
{props.timePickerProps.visible &&
|
|
50
|
+
<TimePicker
|
|
51
|
+
{...props.timePickerProps}
|
|
52
|
+
onChange={(e, time) => {
|
|
53
|
+
setIsTimePickerControlled(true);
|
|
54
|
+
props.timePickerProps.onChange!(e, time);
|
|
55
|
+
}}
|
|
56
|
+
defaultValue={dayjs(new Date()).startOf('day').toDate()}
|
|
57
|
+
useComboBoxAsMenuWidth
|
|
58
|
+
styles={{
|
|
59
|
+
callout: {
|
|
60
|
+
maxHeight: '300px !important'
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
autofill={{
|
|
64
|
+
componentRef: timePickerRef,
|
|
65
|
+
//hack to prevent blinking on prop updates
|
|
66
|
+
value: isTimePickerControlled ? getFormattedTime() : undefined
|
|
67
|
+
}}
|
|
68
|
+
buttonIconProps={{
|
|
69
|
+
iconName: 'Clock'
|
|
70
|
+
}}
|
|
71
|
+
onRenderOption={(option) => {
|
|
72
|
+
//the timepicker displays 24 instead of 00 during the option displaying for some reason
|
|
73
|
+
return <Text>{option?.text.replace('24', '00')}</Text>;
|
|
74
|
+
}}
|
|
75
|
+
increments={15}
|
|
76
|
+
allowFreeform />
|
|
77
|
+
}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
import { useInputBasedComponent } from "../../../hooks/useInputBasedComponent";
|
|
3
|
+
import { IDateTime, IDateTimeOutputs, IDateTimeParameters, IDateTimeTranslations } from "../interfaces";
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import utc from 'dayjs/plugin/utc';
|
|
6
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
7
|
+
import { getDefaultDateTimeTranslations } from "../translations";
|
|
8
|
+
import { StringProps } from "../../../types";
|
|
9
|
+
dayjs.extend(customParseFormat);
|
|
10
|
+
dayjs.extend(utc);
|
|
11
|
+
|
|
12
|
+
export const useDateTime = (props: IDateTime, ref: React.RefObject<HTMLDivElement>): [
|
|
13
|
+
Date | undefined,
|
|
14
|
+
string | undefined,
|
|
15
|
+
boolean,
|
|
16
|
+
{
|
|
17
|
+
shortDatePattern: string
|
|
18
|
+
shortTimePattern: string;
|
|
19
|
+
},
|
|
20
|
+
Required<StringProps<IDateTimeTranslations>>,
|
|
21
|
+
(value: string | undefined) => void,
|
|
22
|
+
(date: Date | undefined, time?: string) => void,
|
|
23
|
+
() => void
|
|
24
|
+
|
|
25
|
+
] => {
|
|
26
|
+
|
|
27
|
+
const boundValue = props.parameters.value;
|
|
28
|
+
const context = props.context;
|
|
29
|
+
const behavior = boundValue.attributes.Behavior;
|
|
30
|
+
const format = boundValue.attributes.Format;
|
|
31
|
+
const dateFormattingInfo = context.userSettings.dateFormattingInfo;
|
|
32
|
+
|
|
33
|
+
const isDateTime = (() => {
|
|
34
|
+
switch (format) {
|
|
35
|
+
case 'DateAndTime':
|
|
36
|
+
case 'Date and Time':
|
|
37
|
+
case 'DateAndTime.DateAndTime':
|
|
38
|
+
case 'datetime': {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
default: {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
|
|
47
|
+
//MS returns the pattern without correct separator and they do this during formatting
|
|
48
|
+
const shortDatePattern = dateFormattingInfo.shortDatePattern.replace(/\//g, dateFormattingInfo.dateSeparator).toUpperCase();
|
|
49
|
+
const shortTimePattern = dateFormattingInfo.shortTimePattern.replace(/:/g, dateFormattingInfo.timeSeparator).replace('tt', 'A');
|
|
50
|
+
const formatting = (() => {
|
|
51
|
+
if (isDateTime) {
|
|
52
|
+
return `${shortDatePattern} ${shortTimePattern}`;
|
|
53
|
+
}
|
|
54
|
+
return shortDatePattern;
|
|
55
|
+
})();
|
|
56
|
+
|
|
57
|
+
const formatDate = (date: Date | undefined | null | string): string | undefined => {
|
|
58
|
+
if (date == undefined) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
if (typeof date === 'string') {
|
|
62
|
+
const dayjsDate = dayjs(date, formatting);
|
|
63
|
+
//error situation
|
|
64
|
+
if (!dayjsDate.isValid()) {
|
|
65
|
+
return date;
|
|
66
|
+
}
|
|
67
|
+
date = dayjsDate.toDate();
|
|
68
|
+
}
|
|
69
|
+
if (isDateTime) {
|
|
70
|
+
//should handle the time zone conversion
|
|
71
|
+
return context.formatting.formatTime(date, behavior);
|
|
72
|
+
}
|
|
73
|
+
return context.formatting.formatDateShort(date);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const [dateStringValue, labels, setDateStringValue, notifyOutputChanged] = useInputBasedComponent<string | undefined, IDateTimeParameters, IDateTimeOutputs, IDateTimeTranslations>('DateTime', props, {
|
|
77
|
+
formatter: formatDate,
|
|
78
|
+
defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const onBlur = () => {
|
|
83
|
+
if (formatDate(boundValue.raw) === dateStringValue) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
notifyOutputChanged({
|
|
87
|
+
value: dateExtractor(dateStringValue!) as any
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const input = ref.current?.querySelector('input');
|
|
91
|
+
input?.addEventListener('blur', onBlur);
|
|
92
|
+
return () => {
|
|
93
|
+
input?.removeEventListener('blur', onBlur);
|
|
94
|
+
};
|
|
95
|
+
}, [dateStringValue]);
|
|
96
|
+
|
|
97
|
+
const getDate = (): Date | undefined => {
|
|
98
|
+
if (boundValue.raw instanceof Date) {
|
|
99
|
+
if (behavior === 3) {
|
|
100
|
+
//the date in javascript gets automatically adjusted to local time zone
|
|
101
|
+
//this will make it think that the date already came in local time, thus not adjusting the time
|
|
102
|
+
const date = new Date(boundValue.raw.toISOString().replace('Z', ''));
|
|
103
|
+
return date;
|
|
104
|
+
}
|
|
105
|
+
return boundValue.raw;
|
|
106
|
+
}
|
|
107
|
+
//this scenario should only happen in cases of error or null value
|
|
108
|
+
return undefined;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const dateExtractor = (value: string | Date): Date | string => {
|
|
112
|
+
if (value instanceof Date) {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
const dayjsDate = dayjs(value, formatting);
|
|
116
|
+
if (!dayjsDate.isValid()) {
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
return dayjsDate.toDate();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const clearDate = () => {
|
|
123
|
+
notifyOutputChanged({
|
|
124
|
+
value: undefined
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const selectDate = (date?: Date, time?: string) => {
|
|
129
|
+
let dayjsDate = dayjs(date ?? getDate());
|
|
130
|
+
let _time = time;
|
|
131
|
+
//date selected from calendar, keep the original time
|
|
132
|
+
if (!_time) {
|
|
133
|
+
_time = dayjs(getDate()).format('HH:mm');
|
|
134
|
+
}
|
|
135
|
+
const [hours, minutes] = _time.split(':');
|
|
136
|
+
dayjsDate = dayjsDate.hour(parseInt(hours));
|
|
137
|
+
dayjsDate = dayjsDate.minute(parseInt(minutes));
|
|
138
|
+
notifyOutputChanged({
|
|
139
|
+
value: dayjsDate.toDate()
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return [getDate(), dateStringValue, isDateTime, { shortDatePattern, shortTimePattern }, labels, setDateStringValue, selectDate, clearDate];
|
|
144
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDateTimeProperty } from "../../interfaces";
|
|
2
|
+
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
+
import { IBaseParameters, IInputParameters } from "../../interfaces/parameters";
|
|
4
|
+
|
|
5
|
+
export interface IDateTime extends IComponent<IDateTimeParameters, IDateTimeOutputs, IDateTimeTranslations> {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IDateTimeParameters extends IInputParameters {
|
|
9
|
+
value: IDateTimeProperty;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IDateTimeOutputs extends IOutputs {
|
|
13
|
+
value?: Date;
|
|
14
|
+
}
|
|
15
|
+
export interface IDateTimeTranslations extends ITranslations {
|
|
16
|
+
time?: {[LCID: number]: string}
|
|
17
|
+
goToToday?: {[LCID: number]: string}
|
|
18
|
+
days?: {[LCID: number]: string[]} | string[];
|
|
19
|
+
months?: {[LCID: number]: string[]} | string[];
|
|
20
|
+
shortDays?: {[LCID: number]: string[]} | string[];
|
|
21
|
+
shortMonths?: {[LCID: number]: string[]} | string[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ITheme, mergeStyleSets } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
export const getDateTimeStyles = (theme: ITheme) => {
|
|
4
|
+
return mergeStyleSets({
|
|
5
|
+
datePicker: {
|
|
6
|
+
'[class^="statusMessage"]': {
|
|
7
|
+
display: 'none'
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
calendarCallout: {
|
|
11
|
+
'.TALXIS__timepicker__root': {
|
|
12
|
+
padding: 12,
|
|
13
|
+
'label': {
|
|
14
|
+
paddingTop: 0
|
|
15
|
+
},
|
|
16
|
+
'i': {
|
|
17
|
+
fontSize: 16
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
'hr': {
|
|
21
|
+
margin: 0,
|
|
22
|
+
border: 'none',
|
|
23
|
+
height: 1,
|
|
24
|
+
backgroundColor: theme.semanticColors.bodyDivider
|
|
25
|
+
},
|
|
26
|
+
'[class^="monthAndYear"], [class*="weekDayLabelCell"]': {
|
|
27
|
+
animationDuration: '0s'
|
|
28
|
+
},
|
|
29
|
+
'[class^="dayCell"]:focus': {
|
|
30
|
+
outline: `solid 1px !important`
|
|
31
|
+
},
|
|
32
|
+
'.ms-DatePicker': {
|
|
33
|
+
animationDuration: '0s'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IDateTimeTranslations } from "./interfaces";
|
|
2
|
+
|
|
3
|
+
export const getDefaultDateTimeTranslations = (dateFormattingInfo: ComponentFramework.UserSettingApi.DateFormattingInfo): Required<IDateTimeTranslations> => {
|
|
4
|
+
return {
|
|
5
|
+
time: {
|
|
6
|
+
1029: 'Čas',
|
|
7
|
+
1033: 'Time'
|
|
8
|
+
},
|
|
9
|
+
goToToday: {
|
|
10
|
+
1029: 'Přejít na dnešek',
|
|
11
|
+
1033: 'Go to today'
|
|
12
|
+
},
|
|
13
|
+
days: dateFormattingInfo.dayNames,
|
|
14
|
+
months: dateFormattingInfo.monthNames,
|
|
15
|
+
shortDays: dateFormattingInfo.shortestDayNames,
|
|
16
|
+
shortMonths: dateFormattingInfo.abbreviatedMonthNames,
|
|
17
|
+
};
|
|
18
|
+
};
|