@talxis/base-controls 1.2406.2 → 1.2406.3

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.
Files changed (178) hide show
  1. package/examples/Currency/package.json +1 -1
  2. package/examples/DateTime/package.json +1 -1
  3. package/examples/Decimal/package.json +1 -1
  4. package/examples/Duration/package.json +1 -1
  5. package/examples/Grid/package.json +1 -1
  6. package/examples/Lookup/package.json +1 -1
  7. package/examples/MultiSelectOptionSet/package.json +1 -1
  8. package/examples/OptionSet/package.json +1 -1
  9. package/examples/TwoOptions/package.json +1 -1
  10. package/package.json +1 -1
  11. package/.env +0 -1
  12. package/.eslintrc +0 -117
  13. package/.npmgitignore +0 -9
  14. package/.vscode/settings.json +0 -3
  15. package/.yalcignore +0 -2
  16. package/azure-pipelines.yml +0 -44
  17. package/examples/Currency/package-lock.json +0 -15900
  18. package/examples/Currency/tsconfig.json +0 -7
  19. package/examples/DateTime/package-lock.json +0 -15900
  20. package/examples/DateTime/tsconfig.json +0 -7
  21. package/examples/Decimal/package-lock.json +0 -15900
  22. package/examples/Decimal/tsconfig.json +0 -7
  23. package/examples/Duration/package-lock.json +0 -15900
  24. package/examples/Duration/tsconfig.json +0 -7
  25. package/examples/Grid/package-lock.json +0 -15901
  26. package/examples/Grid/tsconfig.json +0 -7
  27. package/examples/Lookup/package-lock.json +0 -15900
  28. package/examples/Lookup/tsconfig.json +0 -8
  29. package/examples/MultiSelectOptionSet/package-lock.json +0 -15900
  30. package/examples/MultiSelectOptionSet/tsconfig.json +0 -7
  31. package/examples/OptionSet/package-lock.json +0 -15900
  32. package/examples/OptionSet/tsconfig.json +0 -7
  33. package/examples/TwoOptions/package-lock.json +0 -15900
  34. package/examples/TwoOptions/tsconfig.json +0 -7
  35. package/public/index.html +0 -43
  36. package/public/manifest.json +0 -25
  37. package/rollup.config.js +0 -44
  38. package/src/components/DateTime/DateTime.tsx +0 -97
  39. package/src/components/DateTime/components/Calendar.tsx +0 -80
  40. package/src/components/DateTime/hooks/useDateTime.ts +0 -144
  41. package/src/components/DateTime/index.ts +0 -2
  42. package/src/components/DateTime/interfaces.ts +0 -22
  43. package/src/components/DateTime/styles.ts +0 -37
  44. package/src/components/DateTime/translations.ts +0 -18
  45. package/src/components/Decimal/Decimal.tsx +0 -120
  46. package/src/components/Decimal/index.ts +0 -2
  47. package/src/components/Decimal/interfaces.ts +0 -20
  48. package/src/components/Duration/Duration.tsx +0 -143
  49. package/src/components/Duration/index.ts +0 -2
  50. package/src/components/Duration/interfaces.ts +0 -22
  51. package/src/components/Duration/translations.ts +0 -30
  52. package/src/components/Grid/Grid.tsx +0 -24
  53. package/src/components/Grid/core/components/AgGrid/AgGrid.tsx +0 -206
  54. package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.tsx +0 -16
  55. package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.ts +0 -20
  56. package/src/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.tsx +0 -7
  57. package/src/components/Grid/core/components/AgGrid/controllers/useAgGridController.ts +0 -68
  58. package/src/components/Grid/core/components/AgGrid/model/AgGrid.ts +0 -100
  59. package/src/components/Grid/core/components/AgGrid/styles.ts +0 -72
  60. package/src/components/Grid/core/components/Cell/Commands/Commands.tsx +0 -32
  61. package/src/components/Grid/core/components/Cell/Commands/Icon.tsx +0 -17
  62. package/src/components/Grid/core/components/Cell/Commands/styles.ts +0 -21
  63. package/src/components/Grid/core/components/Cell/Commands/useCommands.tsx +0 -53
  64. package/src/components/Grid/core/components/Cell/EditableCell/EditableCell.tsx +0 -140
  65. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx +0 -176
  66. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx +0 -67
  67. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.ts +0 -24
  68. package/src/components/Grid/core/components/Cell/ReadOnlyCell/styles.ts +0 -56
  69. package/src/components/Grid/core/components/ColumnHeader/ColumnHeader.tsx +0 -71
  70. package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.tsx +0 -31
  71. package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.ts +0 -16
  72. package/src/components/Grid/core/components/ColumnHeader/styles.ts +0 -40
  73. package/src/components/Grid/core/components/Component/Component.tsx +0 -59
  74. package/src/components/Grid/core/components/Component/controller/useComponentController.ts +0 -39
  75. package/src/components/Grid/core/components/Component/model/Component.ts +0 -251
  76. package/src/components/Grid/core/components/Dialog/Constants.tsx +0 -8
  77. package/src/components/Grid/core/components/Dialog/Styles.tsx +0 -61
  78. package/src/components/Grid/core/components/Dialog/index.tsx +0 -22
  79. package/src/components/Grid/core/components/Dialog/interfaces/index.d.ts +0 -7
  80. package/src/components/Grid/core/components/Save/Save.tsx +0 -74
  81. package/src/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.tsx +0 -63
  82. package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx +0 -153
  83. package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.ts +0 -52
  84. package/src/components/Grid/core/components/Save/components/ChangeEditor/styles.ts +0 -34
  85. package/src/components/Grid/core/components/Save/hooks/useSave.ts +0 -59
  86. package/src/components/Grid/core/components/Save/styles.ts +0 -41
  87. package/src/components/Grid/core/controllers/useGridController.ts +0 -46
  88. package/src/components/Grid/core/enums/ConditionOperator.ts +0 -46
  89. package/src/components/Grid/core/enums/DataType.ts +0 -25
  90. package/src/components/Grid/core/hooks/useGridInstance.ts +0 -7
  91. package/src/components/Grid/core/hooks/useRefreshCallback.ts +0 -20
  92. package/src/components/Grid/core/hooks/useRerender.ts +0 -15
  93. package/src/components/Grid/core/interfaces/IGridColumn.ts +0 -19
  94. package/src/components/Grid/core/interfaces/IGridContext.ts +0 -7
  95. package/src/components/Grid/core/model/Grid.ts +0 -250
  96. package/src/components/Grid/core/model/GridDependency.ts +0 -34
  97. package/src/components/Grid/core/model/Metadata.ts +0 -20
  98. package/src/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.ts +0 -36
  99. package/src/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.ts +0 -222
  100. package/src/components/Grid/filtering/components/FilterCallout/FilterCallout.tsx +0 -83
  101. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.tsx +0 -66
  102. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.tsx +0 -48
  103. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.ts +0 -120
  104. package/src/components/Grid/filtering/components/FilterCallout/styles.ts +0 -37
  105. package/src/components/Grid/filtering/constants.ts +0 -48
  106. package/src/components/Grid/filtering/controller/useColumnFilterConditionController.ts +0 -63
  107. package/src/components/Grid/filtering/model/Condition.ts +0 -309
  108. package/src/components/Grid/filtering/model/Filtering.ts +0 -78
  109. package/src/components/Grid/filtering/utils/FilteringUtilts.ts +0 -190
  110. package/src/components/Grid/interfaces.ts +0 -109
  111. package/src/components/Grid/paging/components/Paging/Paging.tsx +0 -76
  112. package/src/components/Grid/paging/components/Paging/styles.ts +0 -38
  113. package/src/components/Grid/paging/controllers/usePagingController.ts +0 -34
  114. package/src/components/Grid/paging/model/Paging.ts +0 -49
  115. package/src/components/Grid/selection/controllers/useSelectionController.ts +0 -25
  116. package/src/components/Grid/selection/model/Selection.ts +0 -60
  117. package/src/components/Grid/sorting/Sorting.ts +0 -30
  118. package/src/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.tsx +0 -126
  119. package/src/components/Grid/sorting/components/SortingContextualMenu/styles.ts +0 -12
  120. package/src/components/Grid/sorting/controllers/useColumnSortingController.ts +0 -26
  121. package/src/components/Grid/translations.ts +0 -80
  122. package/src/components/Grid/validation/controllers/useRecordValidationController.ts +0 -31
  123. package/src/components/Grid/validation/model/ColumnValidation.ts +0 -81
  124. package/src/components/Lookup/Lookup.tsx +0 -199
  125. package/src/components/Lookup/components/RecordCreator.tsx +0 -53
  126. package/src/components/Lookup/components/TargetSelector.tsx +0 -43
  127. package/src/components/Lookup/hooks/useFetchXml.ts +0 -31
  128. package/src/components/Lookup/hooks/useLoadedEntities.ts +0 -23
  129. package/src/components/Lookup/hooks/useLookup.ts +0 -126
  130. package/src/components/Lookup/index.ts +0 -2
  131. package/src/components/Lookup/interfaces.ts +0 -45
  132. package/src/components/Lookup/lib.ts +0 -3110
  133. package/src/components/Lookup/styles.ts +0 -106
  134. package/src/components/Lookup/translations.ts +0 -28
  135. package/src/components/MultiSelectOptionSet/MultiSelectOptionSet.tsx +0 -83
  136. package/src/components/MultiSelectOptionSet/index.ts +0 -2
  137. package/src/components/MultiSelectOptionSet/interfaces.ts +0 -14
  138. package/src/components/OptionSet/OptionSet.tsx +0 -67
  139. package/src/components/OptionSet/index.ts +0 -2
  140. package/src/components/OptionSet/interfaces.ts +0 -17
  141. package/src/components/TextField/TextField.tsx +0 -58
  142. package/src/components/TextField/hooks/useTextField.ts +0 -42
  143. package/src/components/TextField/index.ts +0 -2
  144. package/src/components/TextField/interfaces.ts +0 -20
  145. package/src/components/TwoOptions/TwoOptions.tsx +0 -43
  146. package/src/components/TwoOptions/index.ts +0 -2
  147. package/src/components/TwoOptions/interfaces.ts +0 -17
  148. package/src/hooks/index.ts +0 -1
  149. package/src/hooks/useComponent.ts +0 -83
  150. package/src/hooks/useFocusIn.ts +0 -23
  151. package/src/hooks/useInputBasedComponent.ts +0 -71
  152. package/src/hooks/useMouseOver.ts +0 -23
  153. package/src/index.tsx +0 -12
  154. package/src/interfaces/context.ts +0 -21
  155. package/src/interfaces/index.ts +0 -12
  156. package/src/interfaces/parameters.ts +0 -26
  157. package/src/interfaces/property.ts +0 -111
  158. package/src/sandbox/index.tsx +0 -137
  159. package/src/sandbox/mock/Context.ts +0 -18
  160. package/src/sandbox/mock/Formatting.ts +0 -186
  161. package/src/sandbox/mock/Mode.ts +0 -25
  162. package/src/sandbox/mock/UserSettings.ts +0 -31
  163. package/src/sandbox/mock/Utility.ts +0 -14
  164. package/src/sandbox/shared/durationList.tsx +0 -24
  165. package/src/sandbox/shared/multiSelectOptionList.tsx +0 -5
  166. package/src/sandbox/shared/optionList.tsx +0 -5
  167. package/src/stories/Introduction.stories.mdx +0 -122
  168. package/src/stories/assets/code-brackets.svg +0 -1
  169. package/src/stories/assets/colors.svg +0 -1
  170. package/src/stories/assets/comments.svg +0 -1
  171. package/src/stories/assets/direction.svg +0 -1
  172. package/src/stories/assets/flow.svg +0 -1
  173. package/src/stories/assets/plugin.svg +0 -1
  174. package/src/stories/assets/repo.svg +0 -1
  175. package/src/stories/assets/stackalt.svg +0 -1
  176. package/src/types/index.ts +0 -3
  177. package/src/utils/NumeralPCF.ts +0 -62
  178. package/tsconfig.json +0 -28
@@ -1,71 +0,0 @@
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
- };
@@ -1,31 +0,0 @@
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
- };
@@ -1,16 +0,0 @@
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
- }
@@ -1,40 +0,0 @@
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
- }
@@ -1,59 +0,0 @@
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
- }
@@ -1,39 +0,0 @@
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
- }
@@ -1,251 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
1
- import { IDialogProps } from "./interfaces";
2
-
3
- export const defaultProps: IDialogProps = {
4
- dialogContentProps: {},
5
- modalProps: {
6
- className: ''
7
- }
8
- };
@@ -1,61 +0,0 @@
1
- import { mergeStyles, getTheme } from "@fluentui/react/lib/Styling";
2
- import { IDialogProps } from './interfaces/index';
3
-
4
- export const getRootStyles = (props: IDialogProps): string => {
5
- const theme = getTheme();
6
- const rootStyles = mergeStyles(({
7
- selectors: {
8
- '.ms-Dialog-main': {
9
- width: props.width,
10
- minHeight: props.minHeight ?? 0,
11
- height: props.height,
12
- },
13
- '@media(max-width: 768px)': {
14
- '.ms-Dialog-main': {
15
- width: '100vw',
16
- height: '100svh',
17
- maxWidth: '100vw',
18
- maxHeight: '100svh'
19
- }
20
- },
21
- '.ms-Dialog-subText': {
22
- color: theme.palette.black
23
- },
24
- '.ms-Dialog-content': {
25
- overflow: 'auto',
26
- paddingBottom: 24,
27
- flex: 1
28
- },
29
- '.ms-Dialog-content, .ms-Dialog-actions': {
30
- paddingLeft: 24,
31
- paddingRight: 24,
32
- width: 'initial'
33
- },
34
- '.ms-Dialog-actions': {
35
- borderTop: `1px solid ${theme.semanticColors.bodyDivider}`,
36
- paddingBottom: 24,
37
- paddingTop: 24,
38
- margin: 'initial',
39
- flex: '0 0 auto'
40
- },
41
- '.ms-Dialog-inner': {
42
- padding: 0,
43
- display: 'flex',
44
- flexDirection: 'column',
45
- flexGrow: 1,
46
- overflow: 'hidden'
47
- },
48
- '.ms-Modal-scrollableContent': {
49
- overflow: 'hidden',
50
- display: 'flex',
51
- '> div': {
52
- display: 'flex',
53
- flexDirection: 'column'
54
- }
55
-
56
- },
57
-
58
- }
59
- }));
60
- return rootStyles;
61
- };
@@ -1,22 +0,0 @@
1
- import React, { useEffect } from 'react';
2
- import { Dialog as DialogBase } from '@fluentui/react/lib/Dialog';
3
- import { IDialogProps } from './interfaces';
4
- import { defaultProps } from './Constants';
5
- import { getRootStyles } from './Styles';
6
-
7
- const Dialog: React.FC<IDialogProps> = (props) => {
8
- return (
9
- <DialogBase
10
- {...props}
11
- modalProps={{
12
- ...props.modalProps,
13
- allowTouchBodyScroll: props.modalProps?.allowTouchBodyScroll ?? matchMedia('(hover: none)').matches ? true : undefined,
14
- className: `${props.modalProps?.className} ${getRootStyles(props)}`
15
- }}
16
- >
17
- {props.children}
18
- </DialogBase>
19
- );
20
- };
21
- export default Dialog;
22
- Dialog.defaultProps = defaultProps;
@@ -1,7 +0,0 @@
1
- import { IDialogProps as IDialogPropsBase } from '@fluentui/react/lib/Dialog';
2
-
3
- export interface IDialogProps extends IDialogPropsBase {
4
- width?: number | string;
5
- height?: number | string;
6
- minHeight?: number;
7
- }