@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,106 @@
|
|
|
1
|
+
import { ITheme, mergeStyleSets } from "@fluentui/react";
|
|
2
|
+
|
|
3
|
+
export const getTargetSelectorStyles = (theme: ITheme) => {
|
|
4
|
+
return mergeStyleSets({
|
|
5
|
+
targetSelector: {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
paddingLeft: 8,
|
|
8
|
+
paddingRight: 8,
|
|
9
|
+
paddingBottom: 8,
|
|
10
|
+
gap: 8,
|
|
11
|
+
paddingTop: 8,
|
|
12
|
+
'>span': {
|
|
13
|
+
lineHeight: 15,
|
|
14
|
+
minWidth: 'fit-content',
|
|
15
|
+
color: theme.semanticColors.listText,
|
|
16
|
+
fontWeight: 600
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
targetSelectorLinks: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
gap: 5,
|
|
22
|
+
flexWrap: 'wrap'
|
|
23
|
+
},
|
|
24
|
+
targetSelectorLink: {
|
|
25
|
+
color: theme.palette.blackTranslucent40,
|
|
26
|
+
'&[data-selected="true"]': {
|
|
27
|
+
color: theme.semanticColors.link,
|
|
28
|
+
fontWeight: 600
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const getHeight = (height: number) => {
|
|
35
|
+
if(height === -1 || height === 0) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return height;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const getLookupStyles = (theme: ITheme, height: number, isSingleSelect: boolean) => {
|
|
42
|
+
const _height = getHeight(height);
|
|
43
|
+
return mergeStyleSets({
|
|
44
|
+
root: {
|
|
45
|
+
'[class*="TALXIS__tag-picker__search-btn"][class*="TALXIS__tag-picker__search-btn"]': {
|
|
46
|
+
top: 0,
|
|
47
|
+
bottom: 0,
|
|
48
|
+
margin: `auto 0`,
|
|
49
|
+
right: 5
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
'[data-navigation-enabled="true"]': {
|
|
53
|
+
'> span > div > span': {
|
|
54
|
+
color: theme.semanticColors.link,
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
},
|
|
57
|
+
':hover': {
|
|
58
|
+
textDecoration: 'underline',
|
|
59
|
+
cursor: 'pointer !important'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
'.ms-BasePicker-itemsWrapper .ms-CommandBar': {
|
|
63
|
+
height: _height && isSingleSelect ? _height - 6 : undefined
|
|
64
|
+
},
|
|
65
|
+
'.ms-BasePicker-text': {
|
|
66
|
+
minHeight: _height ?? 36,
|
|
67
|
+
height: 'min-content',
|
|
68
|
+
paddingRight: !isSingleSelect ? 36 : undefined,
|
|
69
|
+
alignItems: 'baseline',
|
|
70
|
+
|
|
71
|
+
'input': {
|
|
72
|
+
alignSelf: 'center'
|
|
73
|
+
},
|
|
74
|
+
'.hover-only': {
|
|
75
|
+
animationName: 'none'
|
|
76
|
+
},
|
|
77
|
+
'::after': {
|
|
78
|
+
inset: '0px !important'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
suggestions: {
|
|
83
|
+
'.ms-Suggestions-title': {
|
|
84
|
+
padding: 0,
|
|
85
|
+
display: 'flex',
|
|
86
|
+
flexDirection: 'column',
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
createRecordBtn: {
|
|
90
|
+
height: 38,
|
|
91
|
+
width: '100%',
|
|
92
|
+
'.ms-Button-menuIcon': {
|
|
93
|
+
display: 'none'
|
|
94
|
+
},
|
|
95
|
+
'>.ms-Button-flexContainer.ms-Button-flexContainer': {
|
|
96
|
+
justifyContent: 'flex-start'
|
|
97
|
+
},
|
|
98
|
+
'.ms-Button-textContainer': {
|
|
99
|
+
flexGrow: 'initial',
|
|
100
|
+
'>span': {
|
|
101
|
+
fontWeight: 600,
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ILookupTranslations } from "./interfaces";
|
|
2
|
+
|
|
3
|
+
export const lookupTranslations: ILookupTranslations = {
|
|
4
|
+
search: {
|
|
5
|
+
1033: "Search",
|
|
6
|
+
1029: "Vyhledejte"
|
|
7
|
+
},
|
|
8
|
+
newRecord: {
|
|
9
|
+
1033: "New record",
|
|
10
|
+
1029: "Nový záznam"
|
|
11
|
+
},
|
|
12
|
+
searching: {
|
|
13
|
+
1033: "Searching...",
|
|
14
|
+
1029: "Hledám..."
|
|
15
|
+
},
|
|
16
|
+
noRecordsFound: {
|
|
17
|
+
1033: "No records found",
|
|
18
|
+
1029: "Nebyly nalezeny žádné záznamy"
|
|
19
|
+
},
|
|
20
|
+
resultsFrom: {
|
|
21
|
+
1033: "Results from:",
|
|
22
|
+
1029: "Výsledky z:"
|
|
23
|
+
},
|
|
24
|
+
noName: {
|
|
25
|
+
1033: "(No Name)",
|
|
26
|
+
1029: "(Bez názvu)"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
|
|
2
|
+
import { IMultiSelectOptionSet } from './interfaces';
|
|
3
|
+
import { useComponent } from '../../hooks';
|
|
4
|
+
import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
|
|
5
|
+
import { IComboBox, IComboBoxOption } from '@fluentui/react';
|
|
6
|
+
import React, { useEffect, useRef } from 'react';
|
|
7
|
+
|
|
8
|
+
export const MultiSelectOptionSet = (props: IMultiSelectOptionSet) => {
|
|
9
|
+
const [labels, onNotifyOutputChanged] = useComponent('MultiSelectOptionSet', props);
|
|
10
|
+
const parameters = props.parameters;
|
|
11
|
+
const boundValue = parameters.value;
|
|
12
|
+
const componentRef = useRef<IComboBox>(null);
|
|
13
|
+
const { Options } = parameters.value.attributes;
|
|
14
|
+
const context = props.context;
|
|
15
|
+
const comboBoxOptions: IComboBoxOption[] = Options.map(option => ({
|
|
16
|
+
key: option.Value.toString(),
|
|
17
|
+
text: option.Label,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const handleChange = (option?: IComboBoxOption | null): void => {
|
|
21
|
+
if(!option) {
|
|
22
|
+
onNotifyOutputChanged({
|
|
23
|
+
value: undefined
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const optionKey = option.key.toString();
|
|
28
|
+
const updatedSelectedKeys = new Set(boundValue.raw || []);
|
|
29
|
+
if (option.selected) {
|
|
30
|
+
updatedSelectedKeys.add(+optionKey);
|
|
31
|
+
} else {
|
|
32
|
+
updatedSelectedKeys.delete(+optionKey);
|
|
33
|
+
}
|
|
34
|
+
const updatedSelectedKeysArray = Array.from(updatedSelectedKeys);
|
|
35
|
+
|
|
36
|
+
onNotifyOutputChanged({
|
|
37
|
+
value: updatedSelectedKeysArray.map(key => +key)
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (parameters.AutoFocus?.raw) {
|
|
43
|
+
componentRef.current?.focus(true);
|
|
44
|
+
}
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return <ComboBox
|
|
48
|
+
componentRef={componentRef}
|
|
49
|
+
borderless={parameters.EnableBorder?.raw === false}
|
|
50
|
+
options={comboBoxOptions}
|
|
51
|
+
allowFreeInput={true}
|
|
52
|
+
multiSelect
|
|
53
|
+
autoComplete="on"
|
|
54
|
+
autofill={parameters.AutoFocus?.raw === true ? {
|
|
55
|
+
autoFocus: true
|
|
56
|
+
}: undefined}
|
|
57
|
+
readOnly={context.mode.isControlDisabled}
|
|
58
|
+
errorMessage={boundValue.errorMessage}
|
|
59
|
+
selectedKey={boundValue.raw ? boundValue.raw.map(key => key.toString()) : [-1]}
|
|
60
|
+
useComboBoxAsMenuWidth
|
|
61
|
+
styles={{
|
|
62
|
+
root: {
|
|
63
|
+
height: context.mode.allocatedHeight || undefined,
|
|
64
|
+
width: context.mode.allocatedWidth || undefined,
|
|
65
|
+
display: 'flex',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
},
|
|
68
|
+
callout: {
|
|
69
|
+
maxHeight: '300px !important'
|
|
70
|
+
}
|
|
71
|
+
}}
|
|
72
|
+
deleteButtonProps={{
|
|
73
|
+
key: 'delete',
|
|
74
|
+
showOnlyOnHover: false,
|
|
75
|
+
iconProps: {
|
|
76
|
+
iconName: 'Delete'
|
|
77
|
+
},
|
|
78
|
+
onClick: (e, value) => {
|
|
79
|
+
handleChange(null);
|
|
80
|
+
}
|
|
81
|
+
}}
|
|
82
|
+
onChange={(e, option) => handleChange(option)} />;
|
|
83
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IMultiSelectOptionSetProperty } from "../../interfaces";
|
|
2
|
+
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
+
import { IBaseParameters } from "../../interfaces/parameters";
|
|
4
|
+
|
|
5
|
+
export interface IMultiSelectOptionSet extends IComponent<IMultiSelectOptionSetParameters, IMultiSelectOptionSetOutputs, ITranslations> {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IMultiSelectOptionSetParameters extends IBaseParameters {
|
|
9
|
+
value: IMultiSelectOptionSetProperty;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IMultiSelectOptionSetOutputs extends IOutputs {
|
|
13
|
+
value?: number[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
import { IOptionSet } from './interfaces';
|
|
3
|
+
import { useComponent } from '../../hooks';
|
|
4
|
+
import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
|
|
5
|
+
import { IComboBox, IComboBoxOption } from '@fluentui/react';
|
|
6
|
+
import React, { useEffect, useRef } from 'react';
|
|
7
|
+
|
|
8
|
+
export const OptionSet = (props: IOptionSet) => {
|
|
9
|
+
const [labels, onNotifyOutputChanged] = useComponent('OptionSet', props);
|
|
10
|
+
const componentRef = useRef<IComboBox>(null);
|
|
11
|
+
const parameters = props.parameters;
|
|
12
|
+
const boundValue = parameters.value;
|
|
13
|
+
const { Options } = parameters.value.attributes;
|
|
14
|
+
const context = props.context;
|
|
15
|
+
const comboBoxOptions: IComboBoxOption[] = Options.map(option => ({
|
|
16
|
+
key: option.Value.toString(),
|
|
17
|
+
text: option.Label,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const handleChange = (option?: IComboBoxOption | null): void => {
|
|
21
|
+
let value = undefined;
|
|
22
|
+
if (option) {
|
|
23
|
+
value = parseInt(option.key as string);
|
|
24
|
+
}
|
|
25
|
+
onNotifyOutputChanged({
|
|
26
|
+
value: value
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (parameters.AutoFocus?.raw) {
|
|
32
|
+
componentRef.current?.focus(true);
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
return <ComboBox
|
|
37
|
+
componentRef={componentRef}
|
|
38
|
+
borderless={parameters.EnableBorder?.raw === false}
|
|
39
|
+
options={comboBoxOptions}
|
|
40
|
+
readOnly={context.mode.isControlDisabled}
|
|
41
|
+
//the defaultValue comes in the raw prop directly, no need to look at it
|
|
42
|
+
selectedKey={boundValue.raw?.toString() ?? -1}
|
|
43
|
+
dropdownWidth={context.mode.allocatedWidth || undefined}
|
|
44
|
+
errorMessage={boundValue.errorMessage}
|
|
45
|
+
useComboBoxAsMenuWidth
|
|
46
|
+
styles={{
|
|
47
|
+
root: {
|
|
48
|
+
height: context.mode.allocatedHeight || undefined,
|
|
49
|
+
width: context.mode.allocatedWidth || undefined,
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
},
|
|
53
|
+
callout: {
|
|
54
|
+
maxHeight: '300px !important'
|
|
55
|
+
}
|
|
56
|
+
}}
|
|
57
|
+
deleteButtonProps={{
|
|
58
|
+
key: 'delete',
|
|
59
|
+
showOnlyOnHover: true,
|
|
60
|
+
iconProps: {
|
|
61
|
+
iconName: 'Delete'
|
|
62
|
+
},
|
|
63
|
+
onClick: (e, value) => { handleChange(null); }
|
|
64
|
+
}}
|
|
65
|
+
onChange={(e, option) => handleChange(option)}
|
|
66
|
+
/>;
|
|
67
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IOptionSetProperty } from "../../interfaces";
|
|
2
|
+
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
+
import { IBaseParameters } from "../../interfaces/parameters";
|
|
4
|
+
|
|
5
|
+
export interface IOptionSet extends IComponent<IOptionSetParameters, IOptionSetOutputs, IOptionSetTranslations> {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IOptionSetParameters extends IBaseParameters {
|
|
9
|
+
value: IOptionSetProperty;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IOptionSetOutputs extends IOutputs {
|
|
13
|
+
value?: number
|
|
14
|
+
}
|
|
15
|
+
export interface IOptionSetTranslations extends ITranslations {
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { TextField as TextFieldBase } from '@talxis/react-components/dist/components/TextField';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { useInputBasedComponent } from '../../hooks/useInputBasedComponent';
|
|
4
|
+
import { useTextField } from './hooks/useTextField';
|
|
5
|
+
import { ITextField, ITextFieldOutputs, ITextFieldParameters, ITextFieldTranslations } from './interfaces';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
export const TextField = (props: ITextField) => {
|
|
9
|
+
const context = props.context;
|
|
10
|
+
const parameters = props.parameters;
|
|
11
|
+
const boundValue = parameters.value;
|
|
12
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
13
|
+
const [value, labels, setValue, onNotifyOutputChanged] = useInputBasedComponent<string | undefined, ITextFieldParameters, ITextFieldOutputs, ITextFieldTranslations>('TextField', props);
|
|
14
|
+
const [height] = useTextField(props, ref);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<TextFieldBase
|
|
18
|
+
readOnly={context.mode.isControlDisabled}
|
|
19
|
+
//TODO: should be inherited by the type, eg TextArea = multiline
|
|
20
|
+
multiline={parameters.IsMultiLine?.raw}
|
|
21
|
+
resizable={parameters.isResizable?.raw}
|
|
22
|
+
autoFocus={parameters.AutoFocus?.raw}
|
|
23
|
+
elementRef={ref}
|
|
24
|
+
styles={{
|
|
25
|
+
fieldGroup: {
|
|
26
|
+
height: height,
|
|
27
|
+
width: context.mode.allocatedWidth || undefined
|
|
28
|
+
}
|
|
29
|
+
}}
|
|
30
|
+
borderless={parameters.EnableBorder?.raw === false}
|
|
31
|
+
errorMessage={boundValue.errorMessage}
|
|
32
|
+
deleteButtonProps={parameters.EnableDeleteButton?.raw === true ? {
|
|
33
|
+
key: 'delete',
|
|
34
|
+
showOnlyOnHover: true,
|
|
35
|
+
iconProps: {
|
|
36
|
+
iconName: 'Delete'
|
|
37
|
+
},
|
|
38
|
+
onClick: () => setValue(undefined)
|
|
39
|
+
} : undefined}
|
|
40
|
+
clickToCopyProps={parameters.EnableCopyButton?.raw === true ? {
|
|
41
|
+
key: 'copy',
|
|
42
|
+
showOnlyOnHover: true,
|
|
43
|
+
iconProps: {
|
|
44
|
+
iconName: 'Copy'
|
|
45
|
+
}
|
|
46
|
+
} : undefined}
|
|
47
|
+
value={value ?? ""}
|
|
48
|
+
onBlur={() => {
|
|
49
|
+
onNotifyOutputChanged({
|
|
50
|
+
value: value ?? undefined
|
|
51
|
+
});
|
|
52
|
+
}}
|
|
53
|
+
onChange={(e, value) => {
|
|
54
|
+
setValue(value);
|
|
55
|
+
}} />
|
|
56
|
+
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { ITextField } from "../interfaces";
|
|
3
|
+
|
|
4
|
+
export const useTextField = (props: ITextField, ref: React.RefObject<HTMLDivElement>): [number | undefined] => {
|
|
5
|
+
const getInitialHeight = () => {
|
|
6
|
+
if (props.context.mode.allocatedHeight) {
|
|
7
|
+
return props.context.mode.allocatedHeight;
|
|
8
|
+
}
|
|
9
|
+
if (props.parameters.IsMultiLine?.raw) {
|
|
10
|
+
return 80;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const hasBeenResizedRef = useRef<boolean>(false);
|
|
16
|
+
const [height, setHeight] = useState<number | undefined>(getInitialHeight());
|
|
17
|
+
const firstRenderRef = useRef<boolean>(true);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!props.parameters.IsMultiLine?.raw) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
24
|
+
if (firstRenderRef.current || hasBeenResizedRef.current) {
|
|
25
|
+
firstRenderRef.current = false;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
hasBeenResizedRef.current = true;
|
|
29
|
+
setHeight(undefined);
|
|
30
|
+
});
|
|
31
|
+
const textarea = ref.current?.querySelector('textarea') as HTMLTextAreaElement;
|
|
32
|
+
if (height) {
|
|
33
|
+
textarea.setAttribute('style', `height: ${height}px`);
|
|
34
|
+
}
|
|
35
|
+
resizeObserver.observe(textarea);
|
|
36
|
+
|
|
37
|
+
return () => {
|
|
38
|
+
resizeObserver.disconnect();
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return [height];
|
|
42
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IStringProperty, ITwoOptionsProperty } from "../../interfaces";
|
|
2
|
+
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
+
import { IInputParameters } from "../../interfaces/parameters";
|
|
4
|
+
|
|
5
|
+
export interface ITextField extends IComponent<ITextFieldParameters, ITextFieldOutputs, ITextFieldTranslations> {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ITextFieldParameters extends IInputParameters {
|
|
9
|
+
IsMultiLine?: ITwoOptionsProperty;
|
|
10
|
+
isResizable?: ITwoOptionsProperty;
|
|
11
|
+
value: IStringProperty;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ITextFieldOutputs extends IOutputs {
|
|
15
|
+
value?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ITextFieldTranslations extends ITranslations {
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IRefObject, IToggle, Toggle } from '@fluentui/react';
|
|
2
|
+
import { useComponent } from '../../hooks';
|
|
3
|
+
import { ITwoOptions } from './interfaces';
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
|
+
|
|
6
|
+
export const TwoOptions = (props: ITwoOptions) => {
|
|
7
|
+
const parameters = props.parameters;
|
|
8
|
+
const boundValue = parameters.value;
|
|
9
|
+
const options = boundValue.attributes.Options;
|
|
10
|
+
const [labels, onNotifyOutputChanged] = useComponent('TwoOptions', props);
|
|
11
|
+
const context = props.context;
|
|
12
|
+
const componentRef = useRef<any>(null);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if(parameters.AutoFocus?.raw === true) {
|
|
16
|
+
componentRef.current.focus();
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
const handleChange = (value: boolean | undefined): void => {
|
|
21
|
+
onNotifyOutputChanged({
|
|
22
|
+
value: value
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return <Toggle
|
|
27
|
+
styles={{
|
|
28
|
+
root: {
|
|
29
|
+
height: context.mode.allocatedHeight || undefined,
|
|
30
|
+
width: context.mode.allocatedWidth || undefined,
|
|
31
|
+
},
|
|
32
|
+
container: {
|
|
33
|
+
alignItems: 'center'
|
|
34
|
+
}
|
|
35
|
+
}}
|
|
36
|
+
checked={boundValue.raw}
|
|
37
|
+
componentRef={componentRef}
|
|
38
|
+
inlineLabel
|
|
39
|
+
onText={options.find(option=>option.Value ===1)?.Label || 'Yes'}
|
|
40
|
+
offText={options.find(option=>option.Value ===0)?.Label || 'No'}
|
|
41
|
+
onChange={(e, value) => handleChange(value)}
|
|
42
|
+
/>;
|
|
43
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITwoOptionsProperty } from "../../interfaces";
|
|
2
|
+
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
+
import { IBaseParameters } from "../../interfaces/parameters";
|
|
4
|
+
|
|
5
|
+
export interface ITwoOptions extends IComponent<ITwoOptionsParameters, ITwoOptionsOutputs, ITwoOptionsTranslations> {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ITwoOptionsParameters extends IBaseParameters {
|
|
9
|
+
value: ITwoOptionsProperty
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ITwoOptionsOutputs extends IOutputs {
|
|
13
|
+
value?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ITwoOptionsTranslations extends ITranslations {
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useComponent';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import deepEqual from 'fast-deep-equal/es6';
|
|
4
|
+
import { IComponent, IOutputs, IParameters, ITranslations } from "../interfaces";
|
|
5
|
+
import { merge } from 'merge-anything';
|
|
6
|
+
import { StringProps } from "../types";
|
|
7
|
+
import { Liquid } from "liquidjs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Provides automatic checking if the given outputs are different from the provided inputs. Use the provided method any time you want
|
|
11
|
+
* to notify the framework that you wish to write changes. The hook will notify the framework only if the provided output differs from the current inputs.
|
|
12
|
+
*/
|
|
13
|
+
export const useComponent = <TParameters extends IParameters, TOutputs extends IOutputs, TTranslations extends ITranslations>(name: string, props: IComponent<TParameters, TOutputs, TTranslations>, defaultTranslations?: TTranslations): [
|
|
14
|
+
Required<StringProps<TTranslations>>,
|
|
15
|
+
(outputs: TOutputs) => void,
|
|
16
|
+
] => {
|
|
17
|
+
const parametersRef = useRef<TParameters>(props.parameters);
|
|
18
|
+
const liquid = useMemo(() => new Liquid(), []);
|
|
19
|
+
const labels = useMemo(() => {
|
|
20
|
+
const mergedTranslations = merge(defaultTranslations ?? {}, props.translations ?? {}) as TTranslations;
|
|
21
|
+
return new Proxy(mergedTranslations, {
|
|
22
|
+
get(target, key) {
|
|
23
|
+
return (variables: any) => getLabel(key as string, mergedTranslations, variables)
|
|
24
|
+
}
|
|
25
|
+
}) as any;
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
parametersRef.current = props.parameters;
|
|
30
|
+
}, [props.parameters]);
|
|
31
|
+
|
|
32
|
+
const getLabel = (key: string, translations: TTranslations, variables?: any): string | string[] => {
|
|
33
|
+
const strigify = (value: string | string[]) => {
|
|
34
|
+
if(typeof value === 'string') {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
return JSON.stringify(value);
|
|
38
|
+
};
|
|
39
|
+
const translation = translations[key];
|
|
40
|
+
if (!translation) {
|
|
41
|
+
console.error(`Translation for the ${key} label of the ${name} component has not been defined!`);
|
|
42
|
+
return key;
|
|
43
|
+
}
|
|
44
|
+
if (typeof translation === 'string' || Array.isArray(translation)) {
|
|
45
|
+
return strigify(translation);
|
|
46
|
+
}
|
|
47
|
+
let label = translation[props.context.userSettings.languageId];
|
|
48
|
+
if (!label) {
|
|
49
|
+
console.info(`Translation for the ${key} label of the ${name} component has not been found. Using default Czech label instead.`);
|
|
50
|
+
label = translation[1029];
|
|
51
|
+
}
|
|
52
|
+
if (!label) {
|
|
53
|
+
console.error(`Translation for the ${key} label of the ${name} component does not exists neither for Czech language and current LCID.`);
|
|
54
|
+
label = key;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return liquid.parseAndRenderSync(strigify(label), variables);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const onNotifyOutputChanged = (outputs: TOutputs) => {
|
|
61
|
+
let isDirty = false;
|
|
62
|
+
for (let [key, outputValue] of Object.entries(outputs)) {
|
|
63
|
+
const parameterValue = parametersRef.current[key]?.raw;
|
|
64
|
+
if (!deepEqual(parameterValue, outputValue)) {
|
|
65
|
+
if(outputValue === "") {
|
|
66
|
+
outputValue = null;
|
|
67
|
+
}
|
|
68
|
+
// handles undefined X null
|
|
69
|
+
if (parameterValue == outputValue) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
isDirty = true;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!isDirty) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
//console.log(`Change detected, triggering notifyOutputChanged on component ${name}.`);
|
|
80
|
+
props.onNotifyOutputChanged?.(outputs);
|
|
81
|
+
};
|
|
82
|
+
return [labels, onNotifyOutputChanged];
|
|
83
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export const useFocusIn = (ref: React.RefObject<HTMLElement>): boolean => {
|
|
4
|
+
const [isFocused, setIsFocused] = useState<boolean>(false);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const onFocus = () => {
|
|
8
|
+
setIsFocused(true);
|
|
9
|
+
}
|
|
10
|
+
const onBlur = () => {
|
|
11
|
+
setIsFocused(false);
|
|
12
|
+
}
|
|
13
|
+
ref.current?.addEventListener('focusin', onFocus);
|
|
14
|
+
ref.current?.addEventListener('focusout', onBlur);
|
|
15
|
+
|
|
16
|
+
return () => {
|
|
17
|
+
ref.current?.removeEventListener('focusin', onFocus);
|
|
18
|
+
ref.current?.removeEventListener('focusout', onBlur);
|
|
19
|
+
}
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
return isFocused
|
|
23
|
+
};
|