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