@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,68 @@
|
|
|
1
|
+
import { ColDef, GridApi } from "@ag-grid-community/core";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { IEntityRecord } from "../../../../interfaces";
|
|
4
|
+
import { useGridController } from "../../../controllers/useGridController"
|
|
5
|
+
import { useGridInstance } from "../../../hooks/useGridInstance";
|
|
6
|
+
import { EditableCell } from "../../Cell/EditableCell/EditableCell";
|
|
7
|
+
import { ReadOnlyCell } from "../../Cell/ReadOnlyCell/ReadOnlyCell";
|
|
8
|
+
import { ColumnHeader } from "../../ColumnHeader/ColumnHeader";
|
|
9
|
+
import { GlobalCheckBox } from "../../ColumnHeader/components/GlobalCheckbox/GlobalCheckbox";
|
|
10
|
+
import { AgGrid } from "../model/AgGrid";
|
|
11
|
+
import { ModuleRegistry } from '@ag-grid-community/core';
|
|
12
|
+
import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
|
|
13
|
+
import { useDebounce } from 'use-debounce';
|
|
14
|
+
import "@ag-grid-community/styles/ag-grid.css";
|
|
15
|
+
import "@ag-grid-community/styles/ag-theme-balham.css";
|
|
16
|
+
ModuleRegistry.registerModules([ClientSideRowModelModule]);
|
|
17
|
+
|
|
18
|
+
interface IAgGridController {
|
|
19
|
+
agColumns: ColDef[],
|
|
20
|
+
records: IEntityRecord[],
|
|
21
|
+
onGridReady: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const useAgGridController = (gridApiRef: React.MutableRefObject<GridApi<ComponentFramework.PropertyHelper.DataSetApi.EntityRecord> | undefined>): IAgGridController => {
|
|
25
|
+
const grid = useGridInstance();
|
|
26
|
+
const agGridReadyRef = useRef<boolean>(false);
|
|
27
|
+
const agGrid = useMemo(() => new AgGrid(grid, gridApiRef), [])
|
|
28
|
+
const { columns, records } = useGridController();
|
|
29
|
+
const [agColumns, setAgColumns] = useState<ColDef[]>([]);
|
|
30
|
+
//this is to prevent AgGrid from throwing errors in some rerender edge cases - https://github.com/ag-grid/ag-grid/issues/6013
|
|
31
|
+
const [agRecords] = useDebounce(records, 0);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!agGridReadyRef.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
agGrid.selectRows();
|
|
38
|
+
}, [grid.dataset.getSelectedRecordIds().join('')]);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const onGridReady = () => {
|
|
42
|
+
agGridReadyRef.current = true;
|
|
43
|
+
agGrid.selectRows();
|
|
44
|
+
}
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (columns.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const _agColumns = agGrid.columns;
|
|
50
|
+
for (const agColumn of _agColumns) {
|
|
51
|
+
agColumn.cellRenderer = ReadOnlyCell;
|
|
52
|
+
agColumn.cellEditor = EditableCell;
|
|
53
|
+
agColumn.headerComponent = ColumnHeader;
|
|
54
|
+
|
|
55
|
+
if (agColumn.field === '__checkbox') {
|
|
56
|
+
agColumn.lockPosition = 'left';
|
|
57
|
+
agColumn.headerComponent = GlobalCheckBox
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
setAgColumns(_agColumns);
|
|
61
|
+
}, [columns]);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
agColumns: agColumns,
|
|
65
|
+
records: agRecords,
|
|
66
|
+
onGridReady: onGridReady
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ColDef, GridApi, IRowNode } from "@ag-grid-community/core";
|
|
2
|
+
import { Grid } from "../../../model/Grid";
|
|
3
|
+
import { GridDependency } from "../../../model/GridDependency";
|
|
4
|
+
import { DataType } from "../../../enums/DataType";
|
|
5
|
+
import { IGridColumn } from "../../../interfaces/IGridColumn";
|
|
6
|
+
|
|
7
|
+
export class AgGrid extends GridDependency {
|
|
8
|
+
private _gridApiRef: React.MutableRefObject<GridApi<ComponentFramework.PropertyHelper.DataSetApi.EntityRecord> | undefined>
|
|
9
|
+
|
|
10
|
+
constructor(grid: Grid, gridApiRef: React.MutableRefObject<GridApi<ComponentFramework.PropertyHelper.DataSetApi.EntityRecord> | undefined>) {
|
|
11
|
+
super(grid);
|
|
12
|
+
this._gridApiRef = gridApiRef;
|
|
13
|
+
}
|
|
14
|
+
public get columns() {
|
|
15
|
+
const agColumns: ColDef[] = [];
|
|
16
|
+
for (const column of this._grid.columns) {
|
|
17
|
+
const agColumn: ColDef = {
|
|
18
|
+
colId: column.key,
|
|
19
|
+
field: column.key,
|
|
20
|
+
headerName: column.displayName,
|
|
21
|
+
initialWidth: column.width,
|
|
22
|
+
sortable: column.isSortable,
|
|
23
|
+
editable: column.isEditable,
|
|
24
|
+
resizable: column.isResizable,
|
|
25
|
+
suppressMovable: this._grid.props.parameters.ChangeEditorMode ? true : undefined,
|
|
26
|
+
autoHeaderHeight: true,
|
|
27
|
+
suppressSizeToFit: column.key === '__checkbox',
|
|
28
|
+
cellClass: this._getCellClassName(column),
|
|
29
|
+
valueFormatter: (p) => {
|
|
30
|
+
return p.data.getFormattedValue(column.key)
|
|
31
|
+
},
|
|
32
|
+
valueGetter: (p) => {
|
|
33
|
+
return p.data.getValue(column.key)
|
|
34
|
+
},
|
|
35
|
+
cellRendererParams: {
|
|
36
|
+
baseColumn: column
|
|
37
|
+
},
|
|
38
|
+
cellEditorParams: {
|
|
39
|
+
baseColumn: column,
|
|
40
|
+
},
|
|
41
|
+
headerComponentParams: {
|
|
42
|
+
baseColumn: column
|
|
43
|
+
},
|
|
44
|
+
suppressKeyboardEvent: (params) => {
|
|
45
|
+
if (params.event.key !== 'Enter' || params.api.getEditingCells().length === 0) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
switch (column.dataType) {
|
|
49
|
+
case DataType.DATE_AND_TIME_DATE_AND_TIME:
|
|
50
|
+
case DataType.DATE_AND_TIME_DATE_ONLY:
|
|
51
|
+
case DataType.LOOKUP_OWNER:
|
|
52
|
+
case DataType.LOOKUP_SIMPLE:
|
|
53
|
+
case DataType.MULTI_SELECT_OPTIONSET:
|
|
54
|
+
case DataType.OPTIONSET:
|
|
55
|
+
case DataType.TWO_OPTIONS:
|
|
56
|
+
case DataType.WHOLE_DURATION: {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
agColumns.push(agColumn)
|
|
64
|
+
}
|
|
65
|
+
return agColumns;
|
|
66
|
+
}
|
|
67
|
+
public selectRows() {
|
|
68
|
+
if (!this._gridApi) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const nodesToSelect: IRowNode[] = [];
|
|
72
|
+
this._gridApi.deselectAll();
|
|
73
|
+
this._gridApi.forEachNode((node: IRowNode) => {
|
|
74
|
+
if (this._grid.dataset.getSelectedRecordIds().includes(node.data.getRecordId())) {
|
|
75
|
+
nodesToSelect.push(node);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
this._gridApi.setNodesSelected({
|
|
79
|
+
nodes: nodesToSelect,
|
|
80
|
+
newValue: true
|
|
81
|
+
});
|
|
82
|
+
this._gridApi.refreshCells({
|
|
83
|
+
columns: ['__checkbox'],
|
|
84
|
+
force: true
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
private get _gridApi() {
|
|
88
|
+
return this._gridApiRef.current;
|
|
89
|
+
}
|
|
90
|
+
private _getCellClassName(column: IGridColumn) {
|
|
91
|
+
switch (column.dataType) {
|
|
92
|
+
case DataType.CURRENCY:
|
|
93
|
+
case DataType.DECIMAL:
|
|
94
|
+
case DataType.WHOLE_NONE: {
|
|
95
|
+
return 'talxis-cell-align-right';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return 'talxis-cell-align-left';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ITheme, mergeStyleSets } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
export const getGridStyles = (theme: ITheme, numOfRecords?: number) => {
|
|
4
|
+
return mergeStyleSets({
|
|
5
|
+
root: {
|
|
6
|
+
height: '100%',
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
'--height-offset': '64px',
|
|
10
|
+
':has(.ag-body-horizontal-scroll-viewport[style*="height: 0px"])': {
|
|
11
|
+
'--height-offset': '45px'
|
|
12
|
+
} ,
|
|
13
|
+
'--ag-borders': 'none !important',
|
|
14
|
+
'.ag-root-wrapper': {
|
|
15
|
+
maxHeight: '100%',
|
|
16
|
+
'--ag-input-focus-border-color': 'transparent',
|
|
17
|
+
borderBottom: `1px solid ${theme.semanticColors.bodyDivider}`,
|
|
18
|
+
':has(.ag-overlay:not(.ag-hidden) .TALXIS__grid__empty-records)': {
|
|
19
|
+
minHeight: 270
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
'.ag-root-wrapper.ag-layout-normal': {
|
|
23
|
+
height: numOfRecords ? `calc(${numOfRecords} * 42px + var(--height-offset))` : undefined,
|
|
24
|
+
},
|
|
25
|
+
'.ag-body': {
|
|
26
|
+
borderTop: `1px solid ${theme.semanticColors.bodyDivider}`
|
|
27
|
+
},
|
|
28
|
+
'.ag-header-viewport': {
|
|
29
|
+
backgroundColor: `${theme.semanticColors.bodyBackground}`
|
|
30
|
+
},
|
|
31
|
+
'.ag-center-cols-container': {
|
|
32
|
+
minWidth: '100%',
|
|
33
|
+
},
|
|
34
|
+
'.ag-layout-auto-height .ag-center-cols-clipper, .ag-layout-auto-height .ag-center-cols-container, .ag-layout-print .ag-center-cols-clipper, .ag-layout-print .ag-center-cols-container': {
|
|
35
|
+
minHeight: '42px !important'
|
|
36
|
+
},
|
|
37
|
+
'.ag-header-cell': {
|
|
38
|
+
paddingLeft: 0,
|
|
39
|
+
paddingRight: 0,
|
|
40
|
+
backgroundColor: `${theme.semanticColors.bodyBackground} !important`
|
|
41
|
+
},
|
|
42
|
+
'.ag-cell-inline-editing': {
|
|
43
|
+
overflow: 'visible',
|
|
44
|
+
top: -1,
|
|
45
|
+
backgroundColor: 'transparent',
|
|
46
|
+
'input': {
|
|
47
|
+
paddingLeft: 10
|
|
48
|
+
},
|
|
49
|
+
'.TALXIS__error-message__root': {
|
|
50
|
+
display: 'none'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
'.talxis-cell-align-right': {
|
|
54
|
+
'[class^="cellContent"]': {
|
|
55
|
+
justifyContent: 'flex-end',
|
|
56
|
+
},
|
|
57
|
+
'.talxis-cell-text, input': {
|
|
58
|
+
textAlign: 'right'
|
|
59
|
+
},
|
|
60
|
+
'input': {
|
|
61
|
+
paddingRight: 10
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
'.ag-cell-focus:has([data-is-valid="false"])': {
|
|
65
|
+
border: '1px solid red !important;'
|
|
66
|
+
},
|
|
67
|
+
'.TALXIS__combobox__root, [class*="TALXIS__textfield__root"], [class*="TALXIS__tag-picker__root"]': {
|
|
68
|
+
padding: '0px !important'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useCommands } from './useCommands';
|
|
3
|
+
import { CommandBar } from '@talxis/react-components/dist/components/CommandBar';
|
|
4
|
+
import { commandStyles } from './styles';
|
|
5
|
+
import { CommandBarButton } from '@fluentui/react';
|
|
6
|
+
|
|
7
|
+
interface ICommands {
|
|
8
|
+
record: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Commands = ({ record }: ICommands) => {
|
|
12
|
+
const [items] = useCommands(record);
|
|
13
|
+
if (!items) {
|
|
14
|
+
return <></>
|
|
15
|
+
}
|
|
16
|
+
if (items?.length > 0) {
|
|
17
|
+
return <CommandBar className={commandStyles.talxisRoot} overflowButtonProps={{
|
|
18
|
+
styles: {
|
|
19
|
+
root: commandStyles.button,
|
|
20
|
+
rootHovered: commandStyles.button,
|
|
21
|
+
rootPressed: commandStyles.button,
|
|
22
|
+
rootExpanded: commandStyles.button
|
|
23
|
+
}
|
|
24
|
+
}} styles={{
|
|
25
|
+
root: commandStyles.root,
|
|
26
|
+
|
|
27
|
+
}} items={[]}
|
|
28
|
+
farItems={items}
|
|
29
|
+
/>;
|
|
30
|
+
}
|
|
31
|
+
return <></>;
|
|
32
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import 'external-svg-loader';
|
|
3
|
+
import { commandStyles } from './styles';
|
|
4
|
+
|
|
5
|
+
interface IIcon {
|
|
6
|
+
name: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const IconComponent = ({ name }: IIcon) => {
|
|
10
|
+
//@ts-ignore - types
|
|
11
|
+
const src = !window.TALXIS?.Portal ? `https://${window.location.host}${window.Xrm.Utility.getGlobalContext().getWebResourceUrl(name)}` : name;
|
|
12
|
+
return (
|
|
13
|
+
<svg data-src={src} className={commandStyles.icon} />
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Icon = memo(IconComponent);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mergeStyleSets } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
export const commandStyles = mergeStyleSets({
|
|
4
|
+
root: {
|
|
5
|
+
backgroundColor: 'transparent'
|
|
6
|
+
},
|
|
7
|
+
talxisRoot: {
|
|
8
|
+
minWidth: 0,
|
|
9
|
+
flexShrink: 1,
|
|
10
|
+
flexGrow: 1
|
|
11
|
+
},
|
|
12
|
+
button: {
|
|
13
|
+
backgroundColor: 'transparent',
|
|
14
|
+
},
|
|
15
|
+
icon: {
|
|
16
|
+
width: 16,
|
|
17
|
+
height: 16,
|
|
18
|
+
marginLeft: 4,
|
|
19
|
+
marginRight: 4,
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { ICommandBarItemProps } from "@fluentui/react";
|
|
3
|
+
import { Icon } from './Icon';
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { commandStyles } from "./styles";
|
|
6
|
+
import { useGridInstance } from "../../../hooks/useGridInstance";
|
|
7
|
+
|
|
8
|
+
export const useCommands = (record: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord): [
|
|
9
|
+
ICommandBarItemProps[] | null
|
|
10
|
+
] => {
|
|
11
|
+
|
|
12
|
+
const dataset = useGridInstance().dataset
|
|
13
|
+
const [commandBarItems, setCommandBarItems] = useState<ICommandBarItemProps[] | null>(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
setCommandBarItems(await getCommandBarItems());
|
|
17
|
+
})();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
const getCommandBarItems = async () => {
|
|
21
|
+
const items: ICommandBarItemProps[] = [];
|
|
22
|
+
if(!dataset.retrieveRecordCommand) {
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
25
|
+
const commands = await dataset.retrieveRecordCommand([record.getRecordId()]);
|
|
26
|
+
for (const command of commands) {
|
|
27
|
+
if (!command.shouldBeVisible) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
items.push({
|
|
31
|
+
key: command.commandButtonId,
|
|
32
|
+
text: command.label,
|
|
33
|
+
["data-id"]: command.commandButtonId,
|
|
34
|
+
["data-command"]: command.commandId,
|
|
35
|
+
buttonStyles: {
|
|
36
|
+
root: commandStyles.button,
|
|
37
|
+
rootHovered: commandStyles.button,
|
|
38
|
+
rootPressed: commandStyles.button,
|
|
39
|
+
},
|
|
40
|
+
onClick: (e) => {
|
|
41
|
+
e?.stopPropagation();
|
|
42
|
+
command.execute();
|
|
43
|
+
},
|
|
44
|
+
onRenderIcon: command.icon?.includes('.svg') ? () => <Icon name={command.icon} /> : undefined,
|
|
45
|
+
iconProps: command.icon ? {
|
|
46
|
+
iconName: command.icon
|
|
47
|
+
} : undefined
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return items;
|
|
51
|
+
};
|
|
52
|
+
return [commandBarItems];
|
|
53
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { NumeralPCF } from '../../../../../../utils/NumeralPCF';
|
|
3
|
+
import { DataType } from '../../../enums/DataType';
|
|
4
|
+
import { useGridInstance } from '../../../hooks/useGridInstance';
|
|
5
|
+
import { IGridColumn } from '../../../interfaces/IGridColumn';
|
|
6
|
+
import { useRecordUpdateServiceController } from '../../../services/RecordUpdateService/controllers/useRecordUpdateServiceController';
|
|
7
|
+
import { Component } from '../../Component/Component';
|
|
8
|
+
import { ICellEditorParams } from '@ag-grid-community/core';
|
|
9
|
+
import numeral from "numeral";
|
|
10
|
+
import { IEntityRecord } from '../../../../interfaces';
|
|
11
|
+
|
|
12
|
+
interface ICell extends ICellEditorParams {
|
|
13
|
+
baseColumn: IGridColumn;
|
|
14
|
+
data: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const EditableCell = (props: ICell) => {
|
|
18
|
+
const grid = useGridInstance();
|
|
19
|
+
const column = props.baseColumn;
|
|
20
|
+
const recordUpdateService = useRecordUpdateServiceController();
|
|
21
|
+
const mountedRef = React.useRef(true);
|
|
22
|
+
const hasBeenUpdatedRef = React.useRef<boolean>(false);
|
|
23
|
+
const record: IEntityRecord = (() => {
|
|
24
|
+
//this is so we can load the updated record values from state
|
|
25
|
+
const updatedRecord = grid.recordUpdateService.record(props.data.getRecordId()).get() as any;
|
|
26
|
+
return updatedRecord ?? props.data;
|
|
27
|
+
})();
|
|
28
|
+
const valueRef = React.useRef(record.getValue(column.key));
|
|
29
|
+
const [value, setValue] = React.useState(valueRef.current);
|
|
30
|
+
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
return () => {
|
|
33
|
+
mountedRef.current = false;
|
|
34
|
+
if (!hasBeenUpdatedRef.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
recordUpdateService.record(record.getRecordId()).setValue(column.key, getRecordValue(valueRef.current))
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
const getComponentValue = (value: any) => {
|
|
42
|
+
//already is component value;
|
|
43
|
+
if(hasBeenUpdatedRef.current) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
switch(column.dataType) {
|
|
47
|
+
case DataType.TWO_OPTIONS: {
|
|
48
|
+
value = value === '1' ? true : false
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case DataType.OPTIONSET: {
|
|
52
|
+
value = value ? parseInt(value) : null;
|
|
53
|
+
break;
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
case DataType.MULTI_SELECT_OPTIONSET: {
|
|
57
|
+
value = value ? value.split(',').map((value: string) => parseInt(value)) : null;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case DataType.LOOKUP_SIMPLE:
|
|
61
|
+
case DataType.LOOKUP_OWNER: {
|
|
62
|
+
if(value && !Array.isArray(value)) {
|
|
63
|
+
value = [value];
|
|
64
|
+
}
|
|
65
|
+
value = value?.map((x: any) => {
|
|
66
|
+
return {
|
|
67
|
+
entityType: x.etn,
|
|
68
|
+
id: x.id.guid,
|
|
69
|
+
name: x.name
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
//this is just so the setValue API in Power Apps accepts the values that come from the components
|
|
78
|
+
const getRecordValue = (value: any) => {
|
|
79
|
+
switch (column.dataType) {
|
|
80
|
+
case DataType.TWO_OPTIONS: {
|
|
81
|
+
value = value === true ? '1' : '0';
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case DataType.LOOKUP_SIMPLE:
|
|
85
|
+
case DataType.LOOKUP_OWNER: {
|
|
86
|
+
value = value?.map((x: any) => {
|
|
87
|
+
return {
|
|
88
|
+
entityName: x.entityType,
|
|
89
|
+
name: x.name,
|
|
90
|
+
id: x.id
|
|
91
|
+
}
|
|
92
|
+
})?.[0];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const onNotifyOutputChanged = (value: any) => {
|
|
100
|
+
valueRef.current = value;
|
|
101
|
+
hasBeenUpdatedRef.current = true;
|
|
102
|
+
if(!mountedRef.current) {
|
|
103
|
+
recordUpdateService.record(record.getRecordId()).setValue(column.key, getRecordValue(valueRef.current))
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
switch(column.dataType) {
|
|
107
|
+
case DataType.OPTIONSET:
|
|
108
|
+
case DataType.DATE_AND_TIME_DATE_ONLY: {
|
|
109
|
+
props.stopEditing();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
case DataType.LOOKUP_OWNER:
|
|
113
|
+
case DataType.LOOKUP_SIMPLE: {
|
|
114
|
+
if(value?.length > 0) {
|
|
115
|
+
props.stopEditing();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
setValue(valueRef.current);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return <Component
|
|
124
|
+
column={column}
|
|
125
|
+
value={getComponentValue(value)}
|
|
126
|
+
formattedValue={record.getFormattedValue(column.key)}
|
|
127
|
+
onNotifyOutputChanged={onNotifyOutputChanged}
|
|
128
|
+
additionalParameters={{
|
|
129
|
+
AutoFocus: {
|
|
130
|
+
raw: true
|
|
131
|
+
},
|
|
132
|
+
Height: {
|
|
133
|
+
raw: 41
|
|
134
|
+
},
|
|
135
|
+
EnableNavigation: {
|
|
136
|
+
raw: false
|
|
137
|
+
}
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ILinkProps } from '@fluentui/react/lib/components/Link/Link.types';
|
|
3
|
+
import { Link } from '@fluentui/react/lib/components/Link/Link';
|
|
4
|
+
import { Text } from '@fluentui/react/lib/Text';
|
|
5
|
+
import { getReadOnlyCellStyles } from './styles';
|
|
6
|
+
import { Commands } from '../Commands/Commands';
|
|
7
|
+
import { Checkbox, Icon, TooltipHost, useTheme, Image } from '@fluentui/react';
|
|
8
|
+
import { FileAttribute } from '@talxis/client-libraries';
|
|
9
|
+
import { ReadOnlyOptionSet } from './ReadOnlyOptionSet/ReadOnlyOptionSet';
|
|
10
|
+
import { IGridColumn } from '../../../interfaces/IGridColumn';
|
|
11
|
+
import { DataType } from '../../../enums/DataType';
|
|
12
|
+
import { useColumnValidationController } from '../../../../validation/controllers/useRecordValidationController';
|
|
13
|
+
import { useGridInstance } from '../../../hooks/useGridInstance';
|
|
14
|
+
import { useSelectionController } from '../../../../selection/controllers/useSelectionController';
|
|
15
|
+
import { IEntityRecord } from '../../../../interfaces';
|
|
16
|
+
import { ICellRendererParams } from '@ag-grid-community/core';
|
|
17
|
+
|
|
18
|
+
interface ICellProps extends ICellRendererParams {
|
|
19
|
+
baseColumn: IGridColumn;
|
|
20
|
+
data: IEntityRecord;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ReadOnlyCell = (props: ICellProps) => {
|
|
25
|
+
const grid = useGridInstance();
|
|
26
|
+
const column = props.baseColumn;
|
|
27
|
+
const record = props.data;
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
const styles = getReadOnlyCellStyles(theme);
|
|
30
|
+
const tooltipId = React.useMemo(() => Math.random().toString(), []);
|
|
31
|
+
|
|
32
|
+
const [isValid, errorMessage] = useColumnValidationController({
|
|
33
|
+
column: column,
|
|
34
|
+
record: record,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<TooltipHost
|
|
39
|
+
id={tooltipId}
|
|
40
|
+
content={!isValid && !grid.loading ? errorMessage : undefined}>
|
|
41
|
+
<div className={styles.root} data-is-valid={isValid}>
|
|
42
|
+
<div className={styles.cellContent}>
|
|
43
|
+
<InternalReadOnlyCell {...props} />
|
|
44
|
+
</div>
|
|
45
|
+
{!isValid && !grid.loading && <Icon styles={{
|
|
46
|
+
root: {
|
|
47
|
+
color: theme.semanticColors.errorIcon
|
|
48
|
+
}
|
|
49
|
+
}} iconName='Error' />}
|
|
50
|
+
</div>
|
|
51
|
+
</TooltipHost>
|
|
52
|
+
)
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const InternalReadOnlyCell = (props: ICellProps) => {
|
|
56
|
+
const grid = useGridInstance();
|
|
57
|
+
const column = props.baseColumn;
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
const styles = getReadOnlyCellStyles(theme);
|
|
60
|
+
const selection = useSelectionController();
|
|
61
|
+
const record: IEntityRecord = (() => {
|
|
62
|
+
//this is so we can load the updated record values from state
|
|
63
|
+
const updatedRecord = grid.recordUpdateService.record(props.data.getRecordId()).get() as any;
|
|
64
|
+
return updatedRecord ?? props.data;
|
|
65
|
+
})();
|
|
66
|
+
const formattedValue = record.getFormattedValue(column.key);
|
|
67
|
+
|
|
68
|
+
const renderLink = (props: ILinkProps, formattedValue: string): JSX.Element => {
|
|
69
|
+
switch(column.dataType) {
|
|
70
|
+
case DataType.LOOKUP_OWNER:
|
|
71
|
+
case DataType.LOOKUP_SIMPLE: {
|
|
72
|
+
if(!grid.isNavigationEnabled) {
|
|
73
|
+
return renderText();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return (
|
|
78
|
+
<Link {...props} className={styles.link} title={formattedValue}>
|
|
79
|
+
{formattedValue}
|
|
80
|
+
</Link>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
const renderText = (): JSX.Element => {
|
|
84
|
+
if (column.isPrimary && grid.isNavigationEnabled) {
|
|
85
|
+
return renderLink({
|
|
86
|
+
onClick: () => grid.openDatasetItem(record.getNamedReference())
|
|
87
|
+
}, formattedValue);
|
|
88
|
+
}
|
|
89
|
+
return <Text className={`${styles.text} talxis-cell-text`} title={formattedValue}>{formattedValue}</Text>
|
|
90
|
+
}
|
|
91
|
+
const downloadFile = () => {
|
|
92
|
+
const storage = new FileAttribute(grid.pcfContext.webAPI);
|
|
93
|
+
const namedReference = record.getNamedReference();
|
|
94
|
+
storage.downloadFileFromAttribute({
|
|
95
|
+
entityName: namedReference.etn,
|
|
96
|
+
recordId: record.getRecordId(),
|
|
97
|
+
fileAttribute: column.key,
|
|
98
|
+
}, true)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
switch (column.dataType) {
|
|
102
|
+
case DataType.SINGLE_LINE_EMAIL: {
|
|
103
|
+
return renderLink({ href: `mailto:${formattedValue}` }, formattedValue);
|
|
104
|
+
}
|
|
105
|
+
case DataType.SINGLE_LINE_PHONE: {
|
|
106
|
+
return renderLink({ href: `tel:${formattedValue}` }, formattedValue);
|
|
107
|
+
}
|
|
108
|
+
case DataType.SINGLE_LINE_URL: {
|
|
109
|
+
return renderLink({
|
|
110
|
+
href: formattedValue,
|
|
111
|
+
target: '_blank',
|
|
112
|
+
rel: 'noopener noreferrer'
|
|
113
|
+
}, formattedValue);
|
|
114
|
+
}
|
|
115
|
+
case DataType.LOOKUP_SIMPLE:
|
|
116
|
+
case DataType.LOOKUP_OWNER: {
|
|
117
|
+
return renderLink({
|
|
118
|
+
onClick: () => grid.openDatasetItem(record.getValue(column.key) as any)
|
|
119
|
+
}, formattedValue);
|
|
120
|
+
}
|
|
121
|
+
case DataType.FILE: {
|
|
122
|
+
if (!formattedValue) {
|
|
123
|
+
return <></>
|
|
124
|
+
}
|
|
125
|
+
return (
|
|
126
|
+
<div className={styles.fileWrapper}>
|
|
127
|
+
<Icon iconName='Attach' />
|
|
128
|
+
{
|
|
129
|
+
renderLink({
|
|
130
|
+
onClick: downloadFile
|
|
131
|
+
}, 'Download')
|
|
132
|
+
}
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
case DataType.IMAGE: {
|
|
137
|
+
if (!formattedValue) {
|
|
138
|
+
return <></>
|
|
139
|
+
}
|
|
140
|
+
return (
|
|
141
|
+
<div className={styles.fileWrapper}>
|
|
142
|
+
<Image className={styles.image} src={`data:image/png;base64,${formattedValue}`} />
|
|
143
|
+
{
|
|
144
|
+
renderLink({
|
|
145
|
+
onClick: downloadFile
|
|
146
|
+
}, 'Download')
|
|
147
|
+
}
|
|
148
|
+
</div>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
case DataType.OPTIONSET:
|
|
152
|
+
case DataType.MULTI_SELECT_OPTIONSET:
|
|
153
|
+
case DataType.TWO_OPTIONS: {
|
|
154
|
+
return <ReadOnlyOptionSet
|
|
155
|
+
column={column}
|
|
156
|
+
record={record}
|
|
157
|
+
defaultRender={renderText} />
|
|
158
|
+
}
|
|
159
|
+
default: {
|
|
160
|
+
if(column.key === '__checkbox') {
|
|
161
|
+
return <Checkbox
|
|
162
|
+
checked={props.node.isSelected()}
|
|
163
|
+
onChange={(e, checked) => {
|
|
164
|
+
e?.stopPropagation()
|
|
165
|
+
console.log(props.api.getSelectedNodes())
|
|
166
|
+
selection.toggle(record, checked!)
|
|
167
|
+
}} />
|
|
168
|
+
}
|
|
169
|
+
if(column.key === '__ribbon') {
|
|
170
|
+
return <Commands record={record} />
|
|
171
|
+
}
|
|
172
|
+
return renderText()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
}
|