@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,67 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Text } from '@fluentui/react/lib/Text';
|
|
4
|
+
import { optionSetStyles } from "./styles";
|
|
5
|
+
import color from 'color';
|
|
6
|
+
import { useTheme } from "@fluentui/react";
|
|
7
|
+
import { IGridColumn } from "../../../../interfaces/IGridColumn";
|
|
8
|
+
import { useGridInstance } from "../../../../hooks/useGridInstance";
|
|
9
|
+
import { DataType } from "../../../../enums/DataType";
|
|
10
|
+
|
|
11
|
+
interface IReadOnlyOptionSet {
|
|
12
|
+
column: IGridColumn;
|
|
13
|
+
record: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord;
|
|
14
|
+
defaultRender: () => ReactElement
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ReadOnlyOptionSet = (props: IReadOnlyOptionSet) => {
|
|
18
|
+
const grid = useGridInstance();
|
|
19
|
+
const { record, column, defaultRender } = { ...props }
|
|
20
|
+
const [options, setOptions] = useState<ComponentFramework.PropertyHelper.OptionMetadata[] | null>(null);
|
|
21
|
+
const theme = useTheme();
|
|
22
|
+
const defaultColor = theme.palette.neutralLight;
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
(async () => {
|
|
26
|
+
const getOptions = async (): Promise<ComponentFramework.PropertyHelper.OptionMetadata[]> => {
|
|
27
|
+
const [defaultValue, options] = await grid.metadata.getOptions(column);
|
|
28
|
+
let value: any = record.getValue(column.key);
|
|
29
|
+
if (column.dataType === DataType.OPTIONSET) {
|
|
30
|
+
value = value ? [parseInt(value)] : null;
|
|
31
|
+
}
|
|
32
|
+
if (column.dataType === DataType.MULTI_SELECT_OPTIONSET) {
|
|
33
|
+
value = value ? value.split(',').map((value: string) => parseInt(value)) : null;
|
|
34
|
+
}
|
|
35
|
+
if (column.dataType === DataType.TWO_OPTIONS) {
|
|
36
|
+
value = [parseInt(value)];
|
|
37
|
+
}
|
|
38
|
+
return options.filter(option => value?.includes(option.Value)) ?? [];
|
|
39
|
+
}
|
|
40
|
+
const results = await getOptions();
|
|
41
|
+
setOptions(results);
|
|
42
|
+
})();
|
|
43
|
+
}, [record.getValue(column.key)]);
|
|
44
|
+
|
|
45
|
+
//options not loaded yet
|
|
46
|
+
if (options === null) {
|
|
47
|
+
return <></>
|
|
48
|
+
}
|
|
49
|
+
//options loaded but either no value selected or no colors are present
|
|
50
|
+
if (options.length === 0 || !options.find(x => x.Color)) {
|
|
51
|
+
return defaultRender();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return (
|
|
55
|
+
<div className={optionSetStyles.root}>
|
|
56
|
+
{options.map(x => <div
|
|
57
|
+
key={x.Value}
|
|
58
|
+
title={x.Label}
|
|
59
|
+
className={optionSetStyles.option}
|
|
60
|
+
style={{ backgroundColor: x.Color ?? defaultColor, color: new color(x.Color ?? defaultColor).isDark() ? 'white' : 'black' }}>
|
|
61
|
+
<Text>{x.Label}</Text>
|
|
62
|
+
</div>)}
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mergeStyleSets } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
export const optionSetStyles = mergeStyleSets({
|
|
4
|
+
root: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
gap: 5,
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
'--light': 80,
|
|
9
|
+
'--threshold': 60,
|
|
10
|
+
flexGrow: 1
|
|
11
|
+
},
|
|
12
|
+
option: {
|
|
13
|
+
borderRadius: 5,
|
|
14
|
+
paddingLeft: 4,
|
|
15
|
+
paddingRight: 4,
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
textOverflow: 'ellipsis',
|
|
18
|
+
flexGrow: 1,
|
|
19
|
+
textAlign: 'center',
|
|
20
|
+
'>span': {
|
|
21
|
+
color: 'inherit',
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ITheme, mergeStyleSets, keyframes } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
const shimmer = keyframes({
|
|
4
|
+
'100%': {
|
|
5
|
+
backgroundPosition: '150px 0'
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const getReadOnlyCellStyles = (theme: ITheme) => {
|
|
10
|
+
return mergeStyleSets({
|
|
11
|
+
root: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
height: '100%',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
gap: 10
|
|
16
|
+
},
|
|
17
|
+
text: {
|
|
18
|
+
fontSize: 14,
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
textOverflow: 'ellipsis'
|
|
21
|
+
},
|
|
22
|
+
link: {
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
textOverflow: 'ellipsis'
|
|
26
|
+
},
|
|
27
|
+
fileWrapper: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
gap: 3
|
|
30
|
+
},
|
|
31
|
+
image: {
|
|
32
|
+
marginRight: 5,
|
|
33
|
+
'img': {
|
|
34
|
+
width: 32
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
cellContent: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
height: '100%',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
flexGrow: 1,
|
|
42
|
+
overflow: 'hidden',
|
|
43
|
+
':has([data-align="right"])': {
|
|
44
|
+
justifyContent: 'flex-end',
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
loadingLine: {
|
|
48
|
+
height: 7,
|
|
49
|
+
borderRadius: 5,
|
|
50
|
+
width: '100%',
|
|
51
|
+
animation: `${shimmer} 2s infinite`,
|
|
52
|
+
backgroundSize: '1000px 100%',
|
|
53
|
+
background: `linear-gradient(to right, color-mix(in oklab, ${theme.palette.white}, ${theme.palette.black} 8%) 4%, color-mix(in oklab, ${theme.palette.white}, ${theme.palette.black} 5%) 25%, color-mix(in oklab, ${theme.palette.white}, ${theme.palette.black} 8%) 36%)`
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { CommandBarButton, Icon, Label, useTheme } from '@fluentui/react';
|
|
3
|
+
import { FilterCallout, IFilterCallout } from '../../../filtering/components/FilterCallout/FilterCallout';
|
|
4
|
+
import { IGridColumn } from '../../interfaces/IGridColumn';
|
|
5
|
+
import { ISortingContextualMenu, SortingContextualMenu } from '../../../sorting/components/SortingContextualMenu/SortingContextualMenu';
|
|
6
|
+
import { getColumnHeaderStyles } from './styles';
|
|
7
|
+
import { useGridInstance } from '../../hooks/useGridInstance';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
export interface IColumnHeader {
|
|
11
|
+
baseColumn: IGridColumn;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ColumnHeader = (props: IColumnHeader) => {
|
|
15
|
+
console.log(props);
|
|
16
|
+
const grid = useGridInstance();
|
|
17
|
+
const column = props.baseColumn;
|
|
18
|
+
const [columnHeaderContextualMenuProps, setColumnHeaderContextualMenuProps] = useState<ISortingContextualMenu | null>(null);
|
|
19
|
+
const [filterCalloutProps, setFilterCalloutProps] = useState<IFilterCallout | null>(null);
|
|
20
|
+
const columnHeaderStyles = getColumnHeaderStyles(useTheme());
|
|
21
|
+
const buttonRef = useRef<HTMLElement>(null);
|
|
22
|
+
|
|
23
|
+
const onClick = () => {
|
|
24
|
+
if ((column.isFilterable === false && column.isSortable === false)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
setColumnHeaderContextualMenuProps({
|
|
28
|
+
column: column,
|
|
29
|
+
onDismiss: (e, dismissAll, showFilterCallout) => {
|
|
30
|
+
setColumnHeaderContextualMenuProps(null);
|
|
31
|
+
if (!showFilterCallout) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setFilterCalloutProps({
|
|
35
|
+
column: column,
|
|
36
|
+
onDismiss: () => {
|
|
37
|
+
setFilterCalloutProps(null)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<CommandBarButton
|
|
46
|
+
elementRef={buttonRef}
|
|
47
|
+
title={column.displayName}
|
|
48
|
+
className={columnHeaderStyles.root}
|
|
49
|
+
onClick={onClick}
|
|
50
|
+
>
|
|
51
|
+
{grid.isEditable && !column.isEditable && <Icon className={columnHeaderStyles.editIcon} iconName='Uneditable' />}
|
|
52
|
+
<div className={columnHeaderStyles.labelWrapper}>
|
|
53
|
+
<Label className={columnHeaderStyles.label}>{column.displayName}</Label>
|
|
54
|
+
{column.isRequired &&
|
|
55
|
+
<span className={columnHeaderStyles.requiredSymbol}>*</span>
|
|
56
|
+
}
|
|
57
|
+
</div>
|
|
58
|
+
<div className={columnHeaderStyles.filterSortIcons}>
|
|
59
|
+
{column.isSorted && <Icon iconName={column.isSortedDescending ? 'SortDown' : 'SortUp'} />}
|
|
60
|
+
{column.isFiltered && <Icon iconName='Filter' />}
|
|
61
|
+
</div>
|
|
62
|
+
</CommandBarButton>
|
|
63
|
+
{columnHeaderContextualMenuProps &&
|
|
64
|
+
<SortingContextualMenu target={buttonRef} {...columnHeaderContextualMenuProps} />
|
|
65
|
+
}
|
|
66
|
+
{filterCalloutProps &&
|
|
67
|
+
<FilterCallout target={buttonRef} {...filterCalloutProps} />
|
|
68
|
+
}
|
|
69
|
+
</>
|
|
70
|
+
)
|
|
71
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Checkbox, useTheme } from "@fluentui/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useSelectionController } from "../../../../../selection/controllers/useSelectionController";
|
|
4
|
+
import { useGridInstance } from "../../../../hooks/useGridInstance";
|
|
5
|
+
import { getGlobalCheckboxStyles } from "./styles";
|
|
6
|
+
|
|
7
|
+
export const GlobalCheckBox = () => {
|
|
8
|
+
const grid = useGridInstance();
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const styles = getGlobalCheckboxStyles(theme);
|
|
11
|
+
const selection = useSelectionController();
|
|
12
|
+
if(grid.dataset.sortedRecordIds.length === 0) {
|
|
13
|
+
return <></>
|
|
14
|
+
}
|
|
15
|
+
return (
|
|
16
|
+
<div className={styles.root}>
|
|
17
|
+
{selection.type === 'multiple' &&
|
|
18
|
+
<Checkbox
|
|
19
|
+
checked={selection.allRecordsSelected}
|
|
20
|
+
indeterminate={selection.selectedRecordIds.length > 0 && !selection.allRecordsSelected}
|
|
21
|
+
onChange={(e, checked) => {
|
|
22
|
+
if(checked) {
|
|
23
|
+
selection.selectAll()
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
selection.clear();
|
|
27
|
+
}} />
|
|
28
|
+
}
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ITheme, mergeStyleSets } from "@fluentui/react"
|
|
2
|
+
|
|
3
|
+
export const getGlobalCheckboxStyles = (theme: ITheme) => {
|
|
4
|
+
return mergeStyleSets({
|
|
5
|
+
root: {
|
|
6
|
+
backgroundColor: theme.palette.white,
|
|
7
|
+
flexGrow: 1,
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
height: '100%',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
position: 'relative',
|
|
13
|
+
left: 1
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ITheme, mergeStyleSets } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
export const getColumnHeaderStyles = (theme: ITheme) => {
|
|
4
|
+
return mergeStyleSets({
|
|
5
|
+
root: {
|
|
6
|
+
width: '100%',
|
|
7
|
+
textAlign: 'left',
|
|
8
|
+
height: 42,
|
|
9
|
+
paddingLeft: 10,
|
|
10
|
+
paddingRight: 10,
|
|
11
|
+
'.ms-Button-flexContainer': {
|
|
12
|
+
justifyContent: 'flex-start',
|
|
13
|
+
gap: 2
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
labelWrapper: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
minWidth: 0
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
overflow: 'hidden',
|
|
23
|
+
textOverflow: 'ellipsis',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
},
|
|
26
|
+
requiredSymbol: {
|
|
27
|
+
color: theme.semanticColors.errorIcon,
|
|
28
|
+
position: 'relative',
|
|
29
|
+
top: 4,
|
|
30
|
+
left: 2
|
|
31
|
+
},
|
|
32
|
+
filterSortIcons: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
gap: 2
|
|
35
|
+
},
|
|
36
|
+
editIcon: {
|
|
37
|
+
marginRight: 3
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IParameters } from "../../../../../interfaces/parameters";
|
|
2
|
+
import { DateTime } from "../../../../DateTime/DateTime";
|
|
3
|
+
import { Decimal } from "../../../../Decimal/Decimal";
|
|
4
|
+
import { Lookup } from "../../../../Lookup/Lookup";
|
|
5
|
+
import { MultiSelectOptionSet } from "../../../../MultiSelectOptionSet/MultiSelectOptionSet";
|
|
6
|
+
import { OptionSet } from "../../../../OptionSet/OptionSet";
|
|
7
|
+
import { TextField } from "../../../../TextField/TextField";
|
|
8
|
+
import { TwoOptions } from "../../../../TwoOptions/TwoOptions";
|
|
9
|
+
import { Duration } from "../../../../Duration/Duration";
|
|
10
|
+
import { DataType } from "../../enums/DataType";
|
|
11
|
+
import { IGridColumn } from "../../interfaces/IGridColumn";
|
|
12
|
+
import { useComponentController } from "./controller/useComponentController";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
|
|
15
|
+
export interface IComponentProps {
|
|
16
|
+
column: IGridColumn;
|
|
17
|
+
value: any;
|
|
18
|
+
formattedValue?: string;
|
|
19
|
+
onNotifyOutputChanged: (value: any) => void;
|
|
20
|
+
additionalParameters?: IParameters;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const Component = (props: IComponentProps) => {
|
|
24
|
+
const controller = useComponentController(props);
|
|
25
|
+
const {column, componentProps} = {...controller};
|
|
26
|
+
if(!column) {
|
|
27
|
+
return <></>
|
|
28
|
+
}
|
|
29
|
+
switch(column.dataType) {
|
|
30
|
+
case DataType.TWO_OPTIONS: {
|
|
31
|
+
return <TwoOptions {...componentProps!} />
|
|
32
|
+
}
|
|
33
|
+
case DataType.OPTIONSET: {
|
|
34
|
+
return <OptionSet {...componentProps!} />
|
|
35
|
+
}
|
|
36
|
+
case DataType.MULTI_SELECT_OPTIONSET: {
|
|
37
|
+
return <MultiSelectOptionSet {...componentProps!} />
|
|
38
|
+
}
|
|
39
|
+
case DataType.DATE_AND_TIME_DATE_AND_TIME:
|
|
40
|
+
case DataType.DATE_AND_TIME_DATE_ONLY: {
|
|
41
|
+
return <DateTime {...componentProps!} />
|
|
42
|
+
}
|
|
43
|
+
case DataType.DECIMAL:
|
|
44
|
+
case DataType.WHOLE_NONE:
|
|
45
|
+
case DataType.CURRENCY: {
|
|
46
|
+
return <Decimal {...componentProps!} />
|
|
47
|
+
}
|
|
48
|
+
case DataType.LOOKUP_SIMPLE:
|
|
49
|
+
case DataType.LOOKUP_OWNER: {
|
|
50
|
+
return <Lookup {...componentProps!} />
|
|
51
|
+
}
|
|
52
|
+
case DataType.WHOLE_DURATION: {
|
|
53
|
+
return <Duration {...componentProps!} />
|
|
54
|
+
}
|
|
55
|
+
default: {
|
|
56
|
+
return <TextField {...componentProps!} />
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useMemo,useRef,useState } from "react"
|
|
2
|
+
import { IComponentProps } from "../Component";
|
|
3
|
+
import { Component } from '../model/Component';
|
|
4
|
+
import { useGridInstance } from "../../../hooks/useGridInstance";
|
|
5
|
+
import { IComponent } from "../../../../../../interfaces/context";
|
|
6
|
+
import { IGridColumn } from "../../../interfaces/IGridColumn";
|
|
7
|
+
|
|
8
|
+
interface IComponentController {
|
|
9
|
+
column: IGridColumn;
|
|
10
|
+
componentProps: IComponent<any, any, any>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useComponentController = (props: IComponentProps): IComponentController | undefined => {
|
|
14
|
+
const grid = useGridInstance();
|
|
15
|
+
const component = useMemo(() => new Component(grid), []);
|
|
16
|
+
const [controller, setController] = useState<IComponentController>();
|
|
17
|
+
const mountedRef = useRef<boolean>(true);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
(async () => {
|
|
21
|
+
const componentProps = await component.getControlProps(props);
|
|
22
|
+
if(!mountedRef.current) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
setController({
|
|
26
|
+
column: props.column,
|
|
27
|
+
componentProps: componentProps
|
|
28
|
+
})
|
|
29
|
+
})();
|
|
30
|
+
}, [props]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
return () => {
|
|
34
|
+
mountedRef.current = false;
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
return controller;
|
|
39
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { IComponent } from "../../../../../../interfaces/context";
|
|
3
|
+
import { IParameters } from "../../../../../../interfaces/parameters";
|
|
4
|
+
import { IDateTime } from "../../../../../DateTime/interfaces";
|
|
5
|
+
import { IDecimal } from "../../../../../Decimal/interfaces";
|
|
6
|
+
import { IDuration } from "../../../../../Duration";
|
|
7
|
+
import { ILookup } from "../../../../../Lookup/interfaces";
|
|
8
|
+
import { IMultiSelectOptionSet } from "../../../../../MultiSelectOptionSet/interfaces";
|
|
9
|
+
import { IOptionSet } from "../../../../../OptionSet/interfaces";
|
|
10
|
+
import { ITextField } from "../../../../../TextField/interfaces";
|
|
11
|
+
import { ITwoOptions } from "../../../../../TwoOptions/interfaces";
|
|
12
|
+
import { ColumnValidation } from "../../../../validation/model/ColumnValidation";
|
|
13
|
+
import { DataType } from "../../../enums/DataType";
|
|
14
|
+
import { GridDependency } from "../../../model/GridDependency";
|
|
15
|
+
import { IComponentProps } from "../Component";
|
|
16
|
+
|
|
17
|
+
// Debounce utility function with async/await
|
|
18
|
+
const debounce = (func: (...args: any[]) => Promise<any>, wait: number) => {
|
|
19
|
+
let timeout: NodeJS.Timeout | null = null;
|
|
20
|
+
let promiseCache: Promise<any> | null = null;
|
|
21
|
+
|
|
22
|
+
return async (...args: any[]) => {
|
|
23
|
+
if (!promiseCache) {
|
|
24
|
+
promiseCache = func(...args);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (timeout) clearTimeout(timeout);
|
|
28
|
+
|
|
29
|
+
timeout = setTimeout(() => {
|
|
30
|
+
promiseCache = null;
|
|
31
|
+
}, wait);
|
|
32
|
+
|
|
33
|
+
return promiseCache;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class Component extends GridDependency {
|
|
38
|
+
private _debouncedGetLookupValue = debounce(this._getLookupValue.bind(this), 50);
|
|
39
|
+
private static _lookupSavedQueriesCache = new Map<string, Promise<ComponentFramework.WebApi.Entity>>;
|
|
40
|
+
|
|
41
|
+
public async getControlProps(props: IComponentProps): Promise<IComponent<any, any, any>> {
|
|
42
|
+
const { column, value, onNotifyOutputChanged, additionalParameters, formattedValue } = { ...props };
|
|
43
|
+
const [isValid, validationErrorMessage] = new ColumnValidation(this._grid, props.column).validate(value);
|
|
44
|
+
switch (column.dataType) {
|
|
45
|
+
case DataType.LOOKUP_SIMPLE:
|
|
46
|
+
case DataType.LOOKUP_OWNER: {
|
|
47
|
+
const columnMetadata = await this._grid.metadata.get(column);
|
|
48
|
+
const targets = columnMetadata.Attributes.get(column.attributeName).attributeDescriptor.Targets ?? [];
|
|
49
|
+
if (column.dataType === DataType.LOOKUP_OWNER) {
|
|
50
|
+
targets.push('systemuser', 'team')
|
|
51
|
+
}
|
|
52
|
+
const result = {
|
|
53
|
+
context: this._getInjectedContext(additionalParameters),
|
|
54
|
+
parameters: {
|
|
55
|
+
value: {
|
|
56
|
+
getAllViews: async (entityName: string) => {
|
|
57
|
+
if (!Component._lookupSavedQueriesCache.get(entityName)) {
|
|
58
|
+
Component._lookupSavedQueriesCache.set(entityName, new Promise(async (resolve) => {
|
|
59
|
+
const response = await this._pcfContext.webAPI.retrieveMultipleRecords('savedquery', `?$filter=returnedtypecode eq '${entityName}' and querytype eq 64&$select=name,savedqueryid,fetchxml`);
|
|
60
|
+
resolve(response.entities[0])
|
|
61
|
+
}))
|
|
62
|
+
}
|
|
63
|
+
const result = await Component._lookupSavedQueriesCache.get(entityName)!;
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
isDefault: true,
|
|
67
|
+
viewName: result.name,
|
|
68
|
+
viewId: result.savedqueryid,
|
|
69
|
+
fetchXml: result.fetchxml
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
raw: await this._debouncedGetLookupValue(targets, value),
|
|
74
|
+
attributes: {
|
|
75
|
+
Targets: targets
|
|
76
|
+
},
|
|
77
|
+
error: !isValid,
|
|
78
|
+
errorMessage: validationErrorMessage,
|
|
79
|
+
},
|
|
80
|
+
...additionalParameters
|
|
81
|
+
},
|
|
82
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
83
|
+
|
|
84
|
+
} as ILookup;
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
case DataType.TWO_OPTIONS: {
|
|
88
|
+
const twoOptionsValue = value as boolean | undefined | null;
|
|
89
|
+
const [defaultValue, options] = await this._grid.metadata.getOptions(column)
|
|
90
|
+
return {
|
|
91
|
+
context: this._getInjectedContext(additionalParameters),
|
|
92
|
+
parameters: {
|
|
93
|
+
value: {
|
|
94
|
+
raw: twoOptionsValue === true ? true : false,
|
|
95
|
+
error: !isValid,
|
|
96
|
+
errorMessage: validationErrorMessage,
|
|
97
|
+
attributes: {
|
|
98
|
+
Options: options
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
...additionalParameters
|
|
102
|
+
},
|
|
103
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
104
|
+
} as ITwoOptions
|
|
105
|
+
}
|
|
106
|
+
case DataType.OPTIONSET: {
|
|
107
|
+
const optionSetValue = value as number | null | undefined;
|
|
108
|
+
const [defaultValue, options] = await this._grid.metadata.getOptions(column)
|
|
109
|
+
return {
|
|
110
|
+
context: this._getInjectedContext(additionalParameters),
|
|
111
|
+
parameters: {
|
|
112
|
+
value: {
|
|
113
|
+
raw: optionSetValue ?? null,
|
|
114
|
+
error: !isValid,
|
|
115
|
+
errorMessage: validationErrorMessage,
|
|
116
|
+
attributes: {
|
|
117
|
+
Options: options
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
...additionalParameters
|
|
121
|
+
},
|
|
122
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
123
|
+
} as IOptionSet;
|
|
124
|
+
}
|
|
125
|
+
case DataType.MULTI_SELECT_OPTIONSET: {
|
|
126
|
+
const [defaultValue, options] = await this._grid.metadata.getOptions(column)
|
|
127
|
+
const optionSetValue = value as number[] | null | undefined;
|
|
128
|
+
return {
|
|
129
|
+
context: this._getInjectedContext(additionalParameters),
|
|
130
|
+
parameters: {
|
|
131
|
+
value: {
|
|
132
|
+
raw: optionSetValue ?? null,
|
|
133
|
+
error: !isValid,
|
|
134
|
+
errorMessage: validationErrorMessage,
|
|
135
|
+
attributes: {
|
|
136
|
+
Options: options
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
...additionalParameters
|
|
140
|
+
},
|
|
141
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
142
|
+
} as IMultiSelectOptionSet
|
|
143
|
+
}
|
|
144
|
+
case DataType.DATE_AND_TIME_DATE_AND_TIME:
|
|
145
|
+
case DataType.DATE_AND_TIME_DATE_ONLY: {
|
|
146
|
+
const dateTimeValue = value as Date | null | undefined;
|
|
147
|
+
const metadata = await this._grid.metadata.get(column);
|
|
148
|
+
const date = dayjs(dateTimeValue);
|
|
149
|
+
return {
|
|
150
|
+
context: this._getInjectedContext(additionalParameters),
|
|
151
|
+
parameters: {
|
|
152
|
+
value: {
|
|
153
|
+
raw: date.isValid() ? date.toDate() : dateTimeValue,
|
|
154
|
+
error: !isValid,
|
|
155
|
+
errorMessage: validationErrorMessage,
|
|
156
|
+
attributes: {
|
|
157
|
+
Behavior: metadata.Attributes.get(column.attributeName).Behavior,
|
|
158
|
+
Format: column.dataType
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
...additionalParameters
|
|
162
|
+
},
|
|
163
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
164
|
+
} as IDateTime;
|
|
165
|
+
}
|
|
166
|
+
case DataType.WHOLE_NONE:
|
|
167
|
+
case DataType.DECIMAL:
|
|
168
|
+
case DataType.CURRENCY:
|
|
169
|
+
case DataType.WHOLE_DURATION: {
|
|
170
|
+
const decimalValue = value as number | null | undefined
|
|
171
|
+
const metadata = await this._grid.metadata.get(column);
|
|
172
|
+
const precision = metadata.Attributes.get(column.attributeName).Precision;
|
|
173
|
+
return {
|
|
174
|
+
context: this._getInjectedContext(additionalParameters),
|
|
175
|
+
parameters: {
|
|
176
|
+
value: {
|
|
177
|
+
raw: decimalValue ?? null,
|
|
178
|
+
error: !isValid,
|
|
179
|
+
//formatted value is only used for currency => there is no way to get the currency symbol so the formatCurrency method is useless
|
|
180
|
+
formatted: formattedValue,
|
|
181
|
+
errorMessage: validationErrorMessage,
|
|
182
|
+
type: column.dataType,
|
|
183
|
+
attributes: {
|
|
184
|
+
Precision: precision
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
NotifyOutputChangedOnUnmount: {
|
|
188
|
+
raw: true,
|
|
189
|
+
},
|
|
190
|
+
...additionalParameters
|
|
191
|
+
},
|
|
192
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
193
|
+
|
|
194
|
+
} as IDecimal;
|
|
195
|
+
}
|
|
196
|
+
default: {
|
|
197
|
+
return {
|
|
198
|
+
context: this._getInjectedContext(additionalParameters),
|
|
199
|
+
parameters: {
|
|
200
|
+
isResizable: {
|
|
201
|
+
raw: false
|
|
202
|
+
},
|
|
203
|
+
NotifyOutputChangedOnUnmount: {
|
|
204
|
+
raw: true,
|
|
205
|
+
},
|
|
206
|
+
value: {
|
|
207
|
+
raw: value,
|
|
208
|
+
error: !isValid,
|
|
209
|
+
errorMessage: validationErrorMessage
|
|
210
|
+
},
|
|
211
|
+
...additionalParameters
|
|
212
|
+
},
|
|
213
|
+
onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)
|
|
214
|
+
} as ITextField
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
private _getInjectedContext(additionalParameters?: IParameters) {
|
|
219
|
+
return {
|
|
220
|
+
...this._pcfContext,
|
|
221
|
+
mode: {
|
|
222
|
+
...this._pcfContext.mode,
|
|
223
|
+
allocatedHeight: additionalParameters?.Height?.raw ?? this._pcfContext.mode.allocatedHeight,
|
|
224
|
+
allocatedWidth: additionalParameters?.Width?.raw ?? this._pcfContext.mode.allocatedWidth
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
private async _getLookupValue(targets: string[], value: ComponentFramework.LookupValue[] | null | undefined): Promise<ComponentFramework.LookupValue[]> {
|
|
229
|
+
if (!value || value.length === 0) {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
//this is case from filters where we only have the id to work it => we need to go through targets and search for the records
|
|
233
|
+
if (!value[0].entityType) {
|
|
234
|
+
for (const lookup of value) {
|
|
235
|
+
for (const target of targets) {
|
|
236
|
+
try {
|
|
237
|
+
const lookupEntityMetadata = await this._pcfContext.utils.getEntityMetadata(target, []);
|
|
238
|
+
const response = await this._pcfContext.webAPI.retrieveRecord(target, lookup.id, `?$select=${lookupEntityMetadata.PrimaryNameAttribute}`);
|
|
239
|
+
lookup.entityType = target;
|
|
240
|
+
lookup.name = response[lookupEntityMetadata.PrimaryNameAttribute];
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return value;
|
|
250
|
+
}
|
|
251
|
+
}
|