@talxis/base-controls 1.2410.4 → 1.2410.5
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/dist/components/DatasetControl/DatasetControl.js +3 -8
- package/dist/components/DatasetControl/DatasetControl.js.map +1 -1
- package/dist/components/Grid/constants.d.ts +1 -2
- package/dist/components/Grid/constants.js +2 -2
- package/dist/components/Grid/constants.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js +2 -3
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.d.ts +2 -2
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.js +8 -4
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +1 -0
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js +20 -9
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/Commands/Commands.d.ts +2 -2
- package/dist/components/Grid/core/components/Cell/Commands/Commands.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/Commands/Icon.d.ts +2 -2
- package/dist/components/Grid/core/components/Cell/Commands/Icon.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/Commands/useCommands.d.ts +2 -2
- package/dist/components/Grid/core/components/Cell/Commands/useCommands.js +2 -0
- package/dist/components/Grid/core/components/Cell/Commands/useCommands.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js +4 -4
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.d.ts +11 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js +93 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.d.ts +36 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.js +42 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.js.map +1 -0
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.d.ts +2 -2
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js +106 -41
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.d.ts +2 -2
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.js +3 -3
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.d.ts +49 -2
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.js +51 -4
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.js.map +1 -1
- package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.js +1 -1
- package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.js.map +1 -1
- package/dist/components/Grid/core/components/Component/model/Component.js +11 -9
- package/dist/components/Grid/core/components/Component/model/Component.js.map +1 -1
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.js.map +1 -1
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.js +5 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.js.map +1 -1
- package/dist/components/Grid/core/controllers/useGridController.js.map +1 -1
- package/dist/components/Grid/core/interfaces/IGridColumn.d.ts +9 -18
- package/dist/components/Grid/core/model/Grid.d.ts +7 -7
- package/dist/components/Grid/core/model/Grid.js +52 -62
- package/dist/components/Grid/core/model/Grid.js.map +1 -1
- package/dist/components/Grid/core/model/GridDependency.d.ts +1 -1
- package/dist/components/Grid/core/model/Metadata.d.ts +2 -3
- package/dist/components/Grid/core/model/Metadata.js +13 -9
- package/dist/components/Grid/core/model/Metadata.js.map +1 -1
- package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.d.ts +8 -8
- package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.js +21 -25
- package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.js.map +1 -1
- package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.d.ts +16 -16
- package/dist/components/Grid/filtering/model/Condition.js +7 -3
- package/dist/components/Grid/filtering/model/Condition.js.map +1 -1
- package/dist/components/Grid/filtering/model/Filtering.js +4 -4
- package/dist/components/Grid/filtering/model/Filtering.js.map +1 -1
- package/dist/components/Grid/interfaces.d.ts +3 -12
- package/dist/components/Grid/selection/controllers/useSelectionController.d.ts +2 -2
- package/dist/components/Grid/selection/controllers/useSelectionController.js.map +1 -1
- package/dist/components/Grid/selection/model/Selection.d.ts +3 -3
- package/dist/components/Grid/selection/model/Selection.js.map +1 -1
- package/dist/components/Grid/sorting/Sorting.js +3 -3
- package/dist/components/Grid/sorting/Sorting.js.map +1 -1
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js +3 -3
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js.map +1 -1
- package/dist/components/Grid/translations.d.ts +4 -0
- package/dist/components/Grid/translations.js +1 -0
- package/dist/components/Grid/translations.js.map +1 -1
- package/dist/components/Grid/validation/controllers/useRecordValidationController.d.ts +2 -2
- package/dist/components/Grid/validation/controllers/useRecordValidationController.js +2 -2
- package/dist/components/Grid/validation/controllers/useRecordValidationController.js.map +1 -1
- package/dist/hooks/useControl.js +1 -1
- package/dist/hooks/useControl.js.map +1 -1
- package/dist/hooks/useThemeOverride.d.ts +1 -0
- package/dist/hooks/useThemeOverride.js +23 -0
- package/dist/hooks/useThemeOverride.js.map +1 -0
- package/dist/index.d.ts +313 -346
- package/dist/interfaces/property.d.ts +0 -29
- package/dist/utils/Theme.js +26 -0
- package/dist/utils/Theme.js.map +1 -1
- package/package.json +3 -2
package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IAddControlNotificationOptions } from "@talxis/client-libraries";
|
|
3
|
+
interface INotifications {
|
|
4
|
+
notifications: IAddControlNotificationOptions[];
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface INotificationsRef {
|
|
8
|
+
remeasureCommandBar: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const Notifications: import("react").ForwardRefExoticComponent<INotifications & import("react").RefAttributes<INotificationsRef>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useTheme, ThemeProvider, Callout, Text, Link, Icon, PrimaryButton, DefaultButton } from '@fluentui/react';
|
|
3
|
+
import { getNotificationIconStyles } from './styles.js';
|
|
4
|
+
import { forwardRef, useMemo, useState, useRef, useImperativeHandle } from 'react';
|
|
5
|
+
import { CommandBar } from '@talxis/react-components';
|
|
6
|
+
import { useThemeOverride } from '../../../../../../../hooks/useThemeOverride.js';
|
|
7
|
+
|
|
8
|
+
const Notifications = forwardRef((props, ref) => {
|
|
9
|
+
const { notifications } = { ...props };
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const styles = getNotificationIconStyles();
|
|
12
|
+
const iconId = useMemo(() => `icon${crypto.randomUUID()}`, []);
|
|
13
|
+
const [selectedNotification, setSelectedNotification] = useState(null);
|
|
14
|
+
const commandBarRef = useRef(null);
|
|
15
|
+
const overridenTheme = useThemeOverride(theme.palette.themePrimary, 'transparent', theme.semanticColors.bodyText);
|
|
16
|
+
useImperativeHandle(ref, () => {
|
|
17
|
+
return {
|
|
18
|
+
remeasureCommandBar: () => {
|
|
19
|
+
commandBarRef.current?.remeasure();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
const getIconName = (notification) => {
|
|
24
|
+
if (notification.iconName) {
|
|
25
|
+
return notification.iconName;
|
|
26
|
+
}
|
|
27
|
+
return notification.notificationLevel === 'ERROR' ? 'Error' : undefined;
|
|
28
|
+
};
|
|
29
|
+
const renderActionButton = (action, buttonType) => {
|
|
30
|
+
const Button = buttonType === 'primary' ? PrimaryButton : DefaultButton;
|
|
31
|
+
return jsx(Button, { text: action.message, iconProps: action?.iconName ? {
|
|
32
|
+
iconName: action.iconName
|
|
33
|
+
} : undefined, onClick: () => action.actions.map(callback => callback()) });
|
|
34
|
+
};
|
|
35
|
+
const renderActions = (actions) => {
|
|
36
|
+
if (actions.length === 0) {
|
|
37
|
+
return jsx(Fragment, {});
|
|
38
|
+
}
|
|
39
|
+
//render actions as buttons
|
|
40
|
+
if (actions.length < 3) {
|
|
41
|
+
return jsx("div", { className: styles.buttons, children: actions.map((action, i) => renderActionButton(action, i === 0 ? 'primary' : 'default')) });
|
|
42
|
+
}
|
|
43
|
+
return jsx(CommandBar, { items: actions.map((action, i) => {
|
|
44
|
+
return {
|
|
45
|
+
key: i.toString(),
|
|
46
|
+
text: action.message,
|
|
47
|
+
commandBarButtonAs: () => jsxs(Link, { onClick: () => action.actions.map(callback => callback()), className: styles.link, children: [action.iconName &&
|
|
48
|
+
jsx(Icon, { iconName: action.iconName }), action.message] }),
|
|
49
|
+
iconProps: {
|
|
50
|
+
iconName: action.iconName
|
|
51
|
+
},
|
|
52
|
+
onClick: () => {
|
|
53
|
+
action.actions.map(callback => callback());
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}) });
|
|
57
|
+
};
|
|
58
|
+
const onNotificationClick = (notification) => {
|
|
59
|
+
if (notification.actions?.length === 1) {
|
|
60
|
+
notification.actions[0].actions.map(callback => callback());
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
setSelectedNotification(notification);
|
|
64
|
+
};
|
|
65
|
+
return jsxs("div", { className: `${styles.root}${props.className ? ` ${props.className}` : ''}`, children: [jsx(ThemeProvider, { theme: overridenTheme, applyTo: "none", children: jsx(CommandBar, { theme: overridenTheme, id: iconId, componentRef: commandBarRef, items: notifications.map(x => {
|
|
66
|
+
const icon = getIconName(x);
|
|
67
|
+
return {
|
|
68
|
+
key: x.uniqueId,
|
|
69
|
+
text: x.title,
|
|
70
|
+
title: x.title,
|
|
71
|
+
onClick: () => onNotificationClick(x),
|
|
72
|
+
buttonStyles: {
|
|
73
|
+
textContainer: {
|
|
74
|
+
display: x.compact ? 'none' : undefined
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
iconProps: icon ? {
|
|
78
|
+
iconName: icon,
|
|
79
|
+
styles: {
|
|
80
|
+
root: {
|
|
81
|
+
color: x.notificationLevel === 'ERROR' ? `${theme.semanticColors.errorIcon} !important` : undefined
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} : undefined
|
|
85
|
+
};
|
|
86
|
+
}) }) }), selectedNotification &&
|
|
87
|
+
jsxs(Callout, { hidden: !selectedNotification, className: styles.callout, onDismiss: () => setSelectedNotification(null), target: `#${iconId}`, children: [selectedNotification.title &&
|
|
88
|
+
jsx(Text, { title: selectedNotification.title, className: styles.calloutTitle, variant: selectedNotification.messages.length > 0 ? 'xLarge' : undefined, children: selectedNotification.title }), jsx(Text, { children: selectedNotification.messages[0] }), selectedNotification.actions &&
|
|
89
|
+
renderActions(selectedNotification.actions)] })] });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export { Notifications };
|
|
93
|
+
//# sourceMappingURL=Notifications.js.map
|
package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.js","sources":["../../../../../../../../src/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.tsx"],"sourcesContent":["import { Icon, useTheme, Text, Callout, PrimaryButton, DefaultButton, Link, ICommandBar, ThemeProvider } from \"@fluentui/react\"\nimport { getNotificationIconStyles } from \"./styles\";\nimport { forwardRef, useImperativeHandle, useMemo, useRef, useState } from \"react\";\nimport { IAddControlNotificationOptions, IControlNotificationAction } from \"@talxis/client-libraries\";\nimport { CommandBar } from \"@talxis/react-components\";\nimport { useThemeOverride } from \"../../../../../../../hooks/useThemeOverride\";\n\ninterface INotifications {\n notifications: IAddControlNotificationOptions[],\n className?: string;\n}\n\nexport interface INotificationsRef {\n remeasureCommandBar: () => void;\n}\n\n\nexport const Notifications = forwardRef<INotificationsRef, INotifications>((props, ref) => {\n const { notifications } = { ...props };\n const theme = useTheme();\n const styles = getNotificationIconStyles(theme);\n const iconId = useMemo(() => `icon${crypto.randomUUID()}`, []);\n const [selectedNotification, setSelectedNotification] = useState<IAddControlNotificationOptions | null>(null);\n const commandBarRef = useRef<ICommandBar>(null);\n const overridenTheme = useThemeOverride(theme.palette.themePrimary, 'transparent', theme.semanticColors.bodyText)\n\n useImperativeHandle(ref, () => {\n return {\n remeasureCommandBar: () => {\n commandBarRef.current?.remeasure();\n }\n }\n })\n\n const getIconName = (notification: IAddControlNotificationOptions): string | undefined => {\n if (notification.iconName) {\n return notification.iconName;\n }\n return notification.notificationLevel === 'ERROR' ? 'Error' : undefined;\n }\n\n const renderActionButton = (action: IControlNotificationAction, buttonType: 'primary' | 'default') => {\n const Button = buttonType === 'primary' ? PrimaryButton : DefaultButton;\n return <Button\n text={action.message}\n iconProps={action?.iconName ? {\n iconName: action.iconName\n } : undefined}\n onClick={() => action.actions.map(callback => callback())} />\n }\n\n const renderActions = (actions: IControlNotificationAction[]): JSX.Element => {\n if (actions.length === 0) {\n return <></>\n }\n //render actions as buttons\n if (actions.length < 3) {\n return <div className={styles.buttons}>\n {actions.map((action, i) => renderActionButton(action, i === 0 ? 'primary' : 'default'))}\n </div>\n }\n return <CommandBar items={actions.map((action, i) => {\n return {\n key: i.toString(),\n text: action.message,\n commandBarButtonAs: () => <Link onClick={() => action.actions.map(callback => callback())} className={styles.link}>\n {action.iconName &&\n <Icon iconName={action.iconName} />\n }\n {action.message}\n </Link>,\n iconProps: {\n iconName: action.iconName\n },\n onClick: () => {\n action.actions.map(callback => callback())\n }\n }\n })} />\n }\n\n const onNotificationClick = (notification: IAddControlNotificationOptions) => {\n if (notification.actions?.length === 1) {\n notification.actions[0].actions.map(callback => callback());\n return;\n }\n setSelectedNotification(notification);\n }\n\n return <div className={`${styles.root}${props.className ? ` ${props.className}` : ''}`}>\n <ThemeProvider theme={overridenTheme} applyTo=\"none\">\n <CommandBar theme={overridenTheme} id={iconId} componentRef={commandBarRef} items={notifications.map(x => {\n const icon = getIconName(x);\n return {\n key: x.uniqueId,\n text: x.title,\n title: x.title,\n onClick: () => onNotificationClick(x),\n buttonStyles: {\n textContainer: {\n display: x.compact ? 'none' : undefined\n }\n },\n iconProps: icon ? {\n iconName: icon,\n styles: {\n root: {\n color: x.notificationLevel === 'ERROR' ? `${theme.semanticColors.errorIcon} !important` : undefined\n }\n }\n } : undefined\n }\n })} />\n </ThemeProvider>\n {selectedNotification &&\n <Callout\n hidden={!selectedNotification}\n className={styles.callout}\n onDismiss={() => setSelectedNotification(null)}\n target={`#${iconId}`}>\n {selectedNotification.title &&\n <Text title={selectedNotification.title} className={styles.calloutTitle} variant={selectedNotification.messages.length > 0 ? 'xLarge' : undefined}>{selectedNotification.title}</Text>\n }\n <Text>{selectedNotification.messages[0]}</Text>\n {selectedNotification.actions &&\n renderActions(selectedNotification.actions)\n }\n </Callout>\n }\n </div>\n});"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;AAiBa,MAAA,aAAa,GAAG,UAAU,CAAoC,CAAC,KAAK,EAAE,GAAG,KAAI;IACtF,MAAM,EAAE,aAAa,EAAE,GAAG,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me } from "@fluentui/react";
|
|
2
|
+
export declare const getNotificationIconStyles: (theme: ITheme) => import("@fluentui/react").IProcessedStyleSet<{
|
|
3
|
+
callout: {
|
|
4
|
+
width: number;
|
|
5
|
+
padding: string;
|
|
6
|
+
'.ms-Callout-main': {
|
|
7
|
+
display: string;
|
|
8
|
+
flexDirection: string;
|
|
9
|
+
gap: number;
|
|
10
|
+
'.ms-CommandBar-primaryCommand': {
|
|
11
|
+
gap: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
calloutTitle: {
|
|
16
|
+
overflow: string;
|
|
17
|
+
textOverflow: string;
|
|
18
|
+
};
|
|
19
|
+
link: {
|
|
20
|
+
i: {
|
|
21
|
+
position: string;
|
|
22
|
+
top: number;
|
|
23
|
+
marginRight: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
buttons: {
|
|
27
|
+
display: string;
|
|
28
|
+
justifyContent: string;
|
|
29
|
+
gap: number;
|
|
30
|
+
};
|
|
31
|
+
root: {
|
|
32
|
+
'.ms-CommandBar-primaryCommand': {
|
|
33
|
+
justifyContent: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { mergeStyleSets } from '@fluentui/react';
|
|
2
|
+
|
|
3
|
+
const getNotificationIconStyles = (theme) => {
|
|
4
|
+
return mergeStyleSets({
|
|
5
|
+
callout: {
|
|
6
|
+
width: 320,
|
|
7
|
+
padding: '20px 24px',
|
|
8
|
+
'.ms-Callout-main': {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
gap: 20,
|
|
12
|
+
'.ms-CommandBar-primaryCommand': {
|
|
13
|
+
gap: 10
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
calloutTitle: {
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
textOverflow: 'ellipsis'
|
|
20
|
+
},
|
|
21
|
+
link: {
|
|
22
|
+
'i': {
|
|
23
|
+
position: 'relative',
|
|
24
|
+
top: 1,
|
|
25
|
+
marginRight: 3
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
buttons: {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'flex-end',
|
|
31
|
+
gap: 8
|
|
32
|
+
},
|
|
33
|
+
root: {
|
|
34
|
+
'.ms-CommandBar-primaryCommand': {
|
|
35
|
+
justifyContent: 'flex-end'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { getNotificationIconStyles };
|
|
42
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../../../../../../src/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.ts"],"sourcesContent":["import { ITheme, mergeStyleSets } from \"@fluentui/react\"\n\nexport const getNotificationIconStyles = (theme: ITheme) => {\n return mergeStyleSets({\n callout: {\n width: 320,\n padding: '20px 24px',\n '.ms-Callout-main': {\n display: 'flex',\n flexDirection: 'column',\n gap: 20,\n '.ms-CommandBar-primaryCommand': {\n gap: 10\n }\n }\n },\n calloutTitle: {\n overflow: 'hidden',\n textOverflow: 'ellipsis'\n },\n link: {\n 'i': {\n position: 'relative',\n top: 1,\n marginRight: 3\n }\n },\n buttons: {\n display: 'flex',\n justifyContent: 'flex-end',\n gap: 8\n },\n root: {\n '.ms-CommandBar-primaryCommand': {\n justifyContent: 'flex-end'\n }\n }\n })\n}"],"names":[],"mappings":";;AAEa,MAAA,yBAAyB,GAAG,CAAC,KAAa,KAAI;AACvD,IAAA,OAAO,cAAc,CAAC;AAClB,QAAA,OAAO,EAAE;AACL,YAAA,KAAK,EAAE,GAAG;AACV,YAAA,OAAO,EAAE,WAAW;AACpB,YAAA,kBAAkB,EAAE;AAChB,gBAAA,OAAO,EAAE,MAAM;AACf,gBAAA,aAAa,EAAE,QAAQ;AACvB,gBAAA,GAAG,EAAE,EAAE;AACP,gBAAA,+BAA+B,EAAE;AAC7B,oBAAA,GAAG,EAAE,EAAE;AACV,iBAAA;AACJ,aAAA;AACJ,SAAA;AACD,QAAA,YAAY,EAAE;AACV,YAAA,QAAQ,EAAE,QAAQ;AAClB,YAAA,YAAY,EAAE,UAAU;AAC3B,SAAA;AACD,QAAA,IAAI,EAAE;AACF,YAAA,GAAG,EAAE;AACD,gBAAA,QAAQ,EAAE,UAAU;AACpB,gBAAA,GAAG,EAAE,CAAC;AACN,gBAAA,WAAW,EAAE,CAAC;AACjB,aAAA;AACJ,SAAA;AACD,QAAA,OAAO,EAAE;AACL,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,cAAc,EAAE,UAAU;AAC1B,YAAA,GAAG,EAAE,CAAC;AACT,SAAA;AACD,QAAA,IAAI,EAAE;AACF,YAAA,+BAA+B,EAAE;AAC7B,gBAAA,cAAc,EAAE,UAAU;AAC7B,aAAA;AACJ,SAAA;AACJ,KAAA,CAAC,CAAA;AACN;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { IRecord } from '@talxis/client-libraries';
|
|
2
3
|
import { IGridColumn } from '../../../interfaces/IGridColumn';
|
|
3
|
-
import { IEntityRecord } from '../../../../interfaces';
|
|
4
4
|
import { ICellRendererParams } from '@ag-grid-community/core';
|
|
5
5
|
interface ICellProps extends ICellRendererParams {
|
|
6
6
|
baseColumn: IGridColumn;
|
|
7
|
-
data:
|
|
7
|
+
data: IRecord;
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
}
|
|
10
10
|
export declare const ReadOnlyCell: (props: ICellProps) => JSX.Element;
|
|
@@ -1,62 +1,133 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useTheme,
|
|
3
|
+
import { useTheme, Shimmer, Checkbox, Image, Icon, Link, Text } from '@fluentui/react';
|
|
4
4
|
import { getReadOnlyCellStyles } from './styles.js';
|
|
5
5
|
import { Commands } from '../Commands/Commands.js';
|
|
6
|
-
import { FileAttribute } from '@talxis/client-libraries';
|
|
6
|
+
import { Constants, FileAttribute } from '@talxis/client-libraries';
|
|
7
7
|
import { ReadOnlyOptionSet } from './ReadOnlyOptionSet/ReadOnlyOptionSet.js';
|
|
8
8
|
import { DataType } from '../../../enums/DataType.js';
|
|
9
9
|
import { useColumnValidationController } from '../../../../validation/controllers/useRecordValidationController.js';
|
|
10
10
|
import { useGridInstance } from '../../../hooks/useGridInstance.js';
|
|
11
11
|
import { useSelectionController } from '../../../../selection/controllers/useSelectionController.js';
|
|
12
|
-
import {
|
|
12
|
+
import { CHECKBOX_COLUMN_KEY } from '../../../../constants.js';
|
|
13
|
+
import { Notifications } from './Notifications/Notifications.js';
|
|
14
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
13
15
|
|
|
14
16
|
const ReadOnlyCell = (props) => {
|
|
15
17
|
const grid = useGridInstance();
|
|
16
18
|
const column = props.baseColumn;
|
|
17
19
|
const record = props.data;
|
|
18
20
|
const theme = useTheme();
|
|
19
|
-
const styles = getReadOnlyCellStyles(theme);
|
|
20
|
-
const
|
|
21
|
+
const styles = React.useMemo(() => getReadOnlyCellStyles(theme), [theme]);
|
|
22
|
+
const selection = useSelectionController();
|
|
23
|
+
const notifications = record.ui?.getNotifications(column.name);
|
|
24
|
+
const notificationRef = React.useRef(null);
|
|
25
|
+
const MemoizedNotifications = React.useMemo(() => {
|
|
26
|
+
return React.memo(Notifications, (prevProps, nextProps) => {
|
|
27
|
+
const previousIds = prevProps.notifications.map(x => x.uniqueId).join(';');
|
|
28
|
+
const nextIds = nextProps.notifications.map(x => x.uniqueId).join(';');
|
|
29
|
+
if (previousIds !== nextIds) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
const debounceNotificationRemeasure = useDebouncedCallback(() => {
|
|
36
|
+
if (notifications && notifications.length > 0) {
|
|
37
|
+
notificationRef.current?.remeasureCommandBar();
|
|
38
|
+
}
|
|
39
|
+
}, 10);
|
|
21
40
|
const [isValid, errorMessage] = useColumnValidationController({
|
|
22
41
|
column: column,
|
|
23
42
|
record: record,
|
|
24
43
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
debounceNotificationRemeasure();
|
|
45
|
+
const shouldShowNotEditableNotification = () => {
|
|
46
|
+
if (column.isEditable && record.ui?.isEditable(column.name) === false) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
const calculateNotificationsWrapperMinWidth = () => {
|
|
52
|
+
let count = 0;
|
|
53
|
+
if (notifications && notifications.length > 0) {
|
|
54
|
+
count++;
|
|
55
|
+
}
|
|
56
|
+
if (!isValid) {
|
|
57
|
+
count++;
|
|
58
|
+
}
|
|
59
|
+
if (shouldShowNotEditableNotification()) {
|
|
60
|
+
count++;
|
|
61
|
+
}
|
|
62
|
+
return count * 40;
|
|
63
|
+
};
|
|
64
|
+
const shouldRenderNotificationsWrapper = () => {
|
|
65
|
+
if (!isValid) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (shouldShowNotEditableNotification()) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
if (notifications && notifications.length > 0) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
78
|
+
debounceNotificationRemeasure();
|
|
79
|
+
});
|
|
80
|
+
resizeObserver.observe(props.eGridCell);
|
|
81
|
+
}, []);
|
|
82
|
+
if (record.ui?.isLoading(column.name)) {
|
|
83
|
+
return jsx(Shimmer, { className: styles.loading });
|
|
84
|
+
}
|
|
85
|
+
switch (column.name) {
|
|
86
|
+
case CHECKBOX_COLUMN_KEY: {
|
|
87
|
+
return jsx("div", { className: styles.cellContent, children: jsx(Checkbox, { checked: props.node.isSelected(), onChange: (e, checked) => {
|
|
88
|
+
e?.stopPropagation();
|
|
89
|
+
selection.toggle(record, checked);
|
|
90
|
+
} }) });
|
|
91
|
+
}
|
|
92
|
+
case Constants.RIBBON_BUTTONS_COLUMN_NAME: {
|
|
93
|
+
return jsx("div", { className: styles.cellContent, children: jsx(Commands, { record: record }) });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return (jsxs("div", { style: {
|
|
97
|
+
'--test': `${calculateNotificationsWrapperMinWidth()}px`
|
|
98
|
+
}, className: styles.root, "data-is-valid": isValid, children: [jsx("div", { className: styles.cellContentWrapper, children: jsx("div", { className: styles.cellContent, children: jsx(InternalReadOnlyCell, { ...props }) }) }), shouldRenderNotificationsWrapper() &&
|
|
99
|
+
jsxs("div", { className: styles.notificationsWrapper, children: [notifications && notifications.length > 0 &&
|
|
100
|
+
jsx(MemoizedNotifications, { className: styles.notifications, ref: notificationRef, notifications: notifications }), !isValid &&
|
|
101
|
+
jsx(MemoizedNotifications, { notifications: [
|
|
102
|
+
{
|
|
103
|
+
notificationLevel: 'ERROR',
|
|
104
|
+
messages: [],
|
|
105
|
+
iconName: 'Error',
|
|
106
|
+
uniqueId: column.name,
|
|
107
|
+
title: errorMessage,
|
|
108
|
+
compact: true
|
|
109
|
+
}
|
|
110
|
+
] }), shouldShowNotEditableNotification() &&
|
|
111
|
+
jsx(MemoizedNotifications, { className: styles.uneditableNotification, notifications: [{
|
|
112
|
+
iconName: 'Uneditable',
|
|
113
|
+
notificationLevel: 'RECOMMENDATION',
|
|
114
|
+
uniqueId: column.name,
|
|
115
|
+
title: grid.labels['value-not-editable'](),
|
|
116
|
+
compact: true,
|
|
117
|
+
messages: []
|
|
118
|
+
}] })] })] }));
|
|
30
119
|
};
|
|
31
120
|
const InternalReadOnlyCell = (props) => {
|
|
32
121
|
const grid = useGridInstance();
|
|
33
122
|
const column = props.baseColumn;
|
|
34
123
|
const theme = useTheme();
|
|
35
124
|
const styles = getReadOnlyCellStyles(theme);
|
|
36
|
-
const selection = useSelectionController();
|
|
37
125
|
const record = (() => {
|
|
38
126
|
//this is so we can load the updated record values from state
|
|
39
127
|
const updatedRecord = grid.recordUpdateService.record(props.data.getRecordId()).get();
|
|
40
128
|
return updatedRecord ?? props.data;
|
|
41
129
|
})();
|
|
42
|
-
const formattedValue = record.getFormattedValue(column.
|
|
43
|
-
const originalSetValue = record.setValue;
|
|
44
|
-
React.useEffect(() => {
|
|
45
|
-
record.setValue = (columnName, value) => {
|
|
46
|
-
originalSetValue(columnName, value);
|
|
47
|
-
grid.pcfContext.factory.requestRender();
|
|
48
|
-
//so changes propagate when changing values
|
|
49
|
-
//we cannot guarantee a rerender from above because of performance optimizations
|
|
50
|
-
const node = props.api.getRowNode(record.getRecordId());
|
|
51
|
-
if (!node) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
props.api.refreshCells({
|
|
55
|
-
rowNodes: [node],
|
|
56
|
-
force: true
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
}, []);
|
|
130
|
+
const formattedValue = record.getFormattedValue(column.name);
|
|
60
131
|
const renderLink = (props, formattedValue) => {
|
|
61
132
|
switch (column.dataType) {
|
|
62
133
|
case DataType.LOOKUP_OWNER:
|
|
@@ -67,6 +138,9 @@ const InternalReadOnlyCell = (props) => {
|
|
|
67
138
|
}
|
|
68
139
|
}
|
|
69
140
|
}
|
|
141
|
+
if (!formattedValue) {
|
|
142
|
+
return jsx(Fragment, {});
|
|
143
|
+
}
|
|
70
144
|
return (jsx(Link, { ...props, className: styles.link, title: formattedValue, children: formattedValue }));
|
|
71
145
|
};
|
|
72
146
|
const renderText = () => {
|
|
@@ -84,7 +158,7 @@ const InternalReadOnlyCell = (props) => {
|
|
|
84
158
|
//@ts-ignore - PowerApps do not follow the typings
|
|
85
159
|
entityName: namedReference.etn ?? namedReference.entityName,
|
|
86
160
|
recordId: record.getRecordId(),
|
|
87
|
-
fileAttribute: column.
|
|
161
|
+
fileAttribute: column.name,
|
|
88
162
|
}, true);
|
|
89
163
|
};
|
|
90
164
|
switch (column.dataType) {
|
|
@@ -96,7 +170,7 @@ const InternalReadOnlyCell = (props) => {
|
|
|
96
170
|
}
|
|
97
171
|
case DataType.SINGLE_LINE_URL: {
|
|
98
172
|
return renderLink({
|
|
99
|
-
href: formattedValue,
|
|
173
|
+
href: formattedValue ?? "",
|
|
100
174
|
target: '_blank',
|
|
101
175
|
rel: 'noopener noreferrer'
|
|
102
176
|
}, formattedValue);
|
|
@@ -105,7 +179,7 @@ const InternalReadOnlyCell = (props) => {
|
|
|
105
179
|
case DataType.LOOKUP_OWNER:
|
|
106
180
|
case DataType.LOOKUP_CUSTOMER: {
|
|
107
181
|
return renderLink({
|
|
108
|
-
onClick: () => grid.openDatasetItem(record.getValue(column.
|
|
182
|
+
onClick: () => grid.openDatasetItem(record.getValue(column.name))
|
|
109
183
|
}, formattedValue);
|
|
110
184
|
}
|
|
111
185
|
case DataType.FILE: {
|
|
@@ -133,15 +207,6 @@ const InternalReadOnlyCell = (props) => {
|
|
|
133
207
|
return renderText();
|
|
134
208
|
}
|
|
135
209
|
default: {
|
|
136
|
-
if (column.key === '__checkbox') {
|
|
137
|
-
return jsx(Checkbox, { checked: props.node.isSelected(), onChange: (e, checked) => {
|
|
138
|
-
e?.stopPropagation();
|
|
139
|
-
selection.toggle(record, checked);
|
|
140
|
-
} });
|
|
141
|
-
}
|
|
142
|
-
if (column.key === RIBBON_COLUMN_KEY) {
|
|
143
|
-
return jsx(Commands, { record: record });
|
|
144
|
-
}
|
|
145
210
|
return renderText();
|
|
146
211
|
}
|
|
147
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyCell.js","sources":["../../../../../../../src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ILinkProps } from '@fluentui/react';\nimport { Link } from '@fluentui/react';\nimport { Text } from '@fluentui/react';\nimport { getReadOnlyCellStyles } from './styles';\nimport { Commands } from '../Commands/Commands';\nimport { Checkbox, Icon, TooltipHost, useTheme, Image } from '@fluentui/react';\nimport { FileAttribute } from '@talxis/client-libraries';\nimport { ReadOnlyOptionSet } from './ReadOnlyOptionSet/ReadOnlyOptionSet';\nimport { IGridColumn } from '../../../interfaces/IGridColumn';\nimport { DataType } from '../../../enums/DataType';\nimport { useColumnValidationController } from '../../../../validation/controllers/useRecordValidationController';\nimport { useGridInstance } from '../../../hooks/useGridInstance';\nimport { useSelectionController } from '../../../../selection/controllers/useSelectionController';\nimport { IEntityRecord } from '../../../../interfaces';\nimport { ICellRendererParams } from '@ag-grid-community/core';\nimport { RIBBON_COLUMN_KEY } from '../../../../constants';\nimport { useRerender } from '../../../hooks/useRerender';\n\ninterface ICellProps extends ICellRendererParams {\n baseColumn: IGridColumn;\n data: IEntityRecord;\n [key: string]: any;\n}\n\nexport const ReadOnlyCell = (props: ICellProps) => {\n const grid = useGridInstance();\n const column = props.baseColumn;\n const record = props.data;\n const theme = useTheme();\n const styles = getReadOnlyCellStyles(theme);\n const tooltipId = React.useMemo(() => Math.random().toString(), []);\n\n const [isValid, errorMessage] = useColumnValidationController({\n column: column,\n record: record,\n })\n\n return (\n <TooltipHost\n id={tooltipId}\n content={!isValid && !grid.loading ? errorMessage : undefined}>\n <div className={styles.root} data-is-valid={isValid}>\n <div className={styles.cellContent}>\n <InternalReadOnlyCell {...props} />\n </div>\n {!isValid && <Icon styles={{\n root: {\n color: theme.semanticColors.errorIcon\n }\n }} iconName='Error' />}\n </div>\n </TooltipHost>\n )\n};\n\nconst InternalReadOnlyCell = (props: ICellProps) => {\n const grid = useGridInstance();\n const column = props.baseColumn;\n const theme = useTheme();\n const styles = getReadOnlyCellStyles(theme);\n const selection = useSelectionController();\n const record: IEntityRecord = (() => {\n //this is so we can load the updated record values from state\n const updatedRecord = grid.recordUpdateService.record(props.data.getRecordId()).get() as any;\n return updatedRecord ?? props.data;\n })();\n const formattedValue = record.getFormattedValue(column.key);\n const originalSetValue = record.setValue\n\n React.useEffect(() => {\n record.setValue = (columnName, value) => {\n originalSetValue(columnName, value);\n grid.pcfContext.factory.requestRender();\n //so changes propagate when changing values\n //we cannot guarantee a rerender from above because of performance optimizations\n const node = props.api.getRowNode(record.getRecordId());\n if (!node) {\n return;\n }\n props.api.refreshCells({\n rowNodes: [node],\n force: true\n })\n }\n }, []);\n\n const renderLink = (props: ILinkProps, formattedValue: string): JSX.Element => {\n switch (column.dataType) {\n case DataType.LOOKUP_OWNER:\n case DataType.LOOKUP_SIMPLE:\n case DataType.LOOKUP_CUSTOMER: {\n if (!grid.isNavigationEnabled) {\n return renderText();\n }\n }\n }\n return (\n <Link {...props} className={styles.link} title={formattedValue}>\n {formattedValue}\n </Link>\n );\n };\n const renderText = (): JSX.Element => {\n if (column.isPrimary && grid.isNavigationEnabled) {\n return renderLink({\n onClick: () => grid.openDatasetItem(record.getNamedReference())\n }, formattedValue);\n }\n return <Text className={`${styles.text} talxis-cell-text`} title={formattedValue}>{formattedValue}</Text>\n }\n const downloadFile = () => {\n const storage = new FileAttribute(grid.pcfContext.webAPI);\n const namedReference = record.getNamedReference();\n storage.downloadFileFromAttribute({\n //@ts-ignore - PowerApps do not follow the typings\n entityName: namedReference.etn ?? namedReference.entityName,\n recordId: record.getRecordId(),\n fileAttribute: column.key,\n }, true)\n }\n\n switch (column.dataType) {\n case DataType.SINGLE_LINE_EMAIL: {\n return renderLink({ href: `mailto:${formattedValue}` }, formattedValue);\n }\n case DataType.SINGLE_LINE_PHONE: {\n return renderLink({ href: `tel:${formattedValue}` }, formattedValue);\n }\n case DataType.SINGLE_LINE_URL: {\n return renderLink({\n href: formattedValue,\n target: '_blank',\n rel: 'noopener noreferrer'\n }, formattedValue);\n }\n case DataType.LOOKUP_SIMPLE:\n case DataType.LOOKUP_OWNER:\n case DataType.LOOKUP_CUSTOMER: {\n return renderLink({\n onClick: () => grid.openDatasetItem(record.getValue(column.key) as any)\n }, formattedValue);\n }\n case DataType.FILE: {\n if (!formattedValue) {\n return <></>\n }\n return (\n <div className={styles.fileWrapper}>\n <Icon iconName='Attach' />\n {\n renderLink({\n onClick: downloadFile\n }, grid.labels.download())\n }\n </div>\n )\n }\n case DataType.IMAGE: {\n if (!formattedValue) {\n return <></>\n }\n return (\n <div className={styles.fileWrapper}>\n <Image className={styles.image} src={`data:image/png;base64,${formattedValue}`} />\n {\n renderLink({\n onClick: downloadFile\n }, 'Download')\n }\n </div>\n )\n }\n case DataType.OPTIONSET:\n case DataType.MULTI_SELECT_OPTIONSET:\n case DataType.TWO_OPTIONS: {\n if (grid.enableOptionSetColors) {\n return <ReadOnlyOptionSet\n column={column}\n record={record}\n defaultRender={renderText} />\n }\n return renderText();\n }\n default: {\n if (column.key === '__checkbox') {\n return <Checkbox\n checked={props.node.isSelected()}\n onChange={(e, checked) => {\n e?.stopPropagation()\n selection.toggle(record, checked!)\n }} />\n }\n if (column.key === RIBBON_COLUMN_KEY) {\n return <Commands record={record} />\n }\n return renderText()\n }\n\n }\n}"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;AAyBa,MAAA,YAAY,GAAG,CAAC,KAAiB,KAAI;AAC9C,IAAA,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;AAC/B,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC;AAChC,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;AAC1B,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AACzB,IAAA,MAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAC5C,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,E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1
|
+
{"version":3,"file":"ReadOnlyCell.js","sources":["../../../../../../../src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ILinkProps, Shimmer } from '@fluentui/react';\nimport { Link } from '@fluentui/react';\nimport { Text } from '@fluentui/react';\nimport { getReadOnlyCellStyles } from './styles';\nimport { Commands } from '../Commands/Commands';\nimport { Checkbox, Icon, useTheme, Image } from '@fluentui/react';\nimport { Constants, FileAttribute, IRecord } from '@talxis/client-libraries';\nimport { ReadOnlyOptionSet } from './ReadOnlyOptionSet/ReadOnlyOptionSet';\nimport { IGridColumn } from '../../../interfaces/IGridColumn';\nimport { DataType } from '../../../enums/DataType';\nimport { useColumnValidationController } from '../../../../validation/controllers/useRecordValidationController';\nimport { useGridInstance } from '../../../hooks/useGridInstance';\nimport { useSelectionController } from '../../../../selection/controllers/useSelectionController';\nimport { ICellRendererParams } from '@ag-grid-community/core';\nimport { CHECKBOX_COLUMN_KEY } from '../../../../constants';\nimport { INotificationsRef, Notifications } from './Notifications/Notifications';\nimport { useDebouncedCallback } from 'use-debounce';\n\ninterface ICellProps extends ICellRendererParams {\n baseColumn: IGridColumn;\n data: IRecord;\n [key: string]: any;\n}\n\nexport const ReadOnlyCell = (props: ICellProps) => {\n const grid = useGridInstance();\n const column = props.baseColumn;\n const record = props.data;\n const theme = useTheme();\n const styles = React.useMemo(() => getReadOnlyCellStyles(theme), [theme]);\n const selection = useSelectionController();\n const notifications = record.ui?.getNotifications(column.name);\n const notificationRef = React.useRef<INotificationsRef>(null);\n\n const MemoizedNotifications = React.useMemo(() => {\n return React.memo(Notifications, (prevProps, nextProps) => {\n const previousIds = prevProps.notifications.map(x => x.uniqueId).join(';');\n const nextIds = nextProps.notifications.map(x => x.uniqueId).join(';');\n if (previousIds !== nextIds) {\n return false;\n }\n return true;\n });\n }, []);\n\n const debounceNotificationRemeasure = useDebouncedCallback(() => {\n if (notifications && notifications.length > 0) {\n notificationRef.current?.remeasureCommandBar();\n }\n }, 10)\n\n const [isValid, errorMessage] = useColumnValidationController({\n column: column,\n record: record,\n });\n\n debounceNotificationRemeasure();\n\n const shouldShowNotEditableNotification = (): boolean => {\n if (column.isEditable && record.ui?.isEditable(column.name) === false) {\n return true;\n }\n return false;\n }\n\n const calculateNotificationsWrapperMinWidth = (): number => {\n let count = 0;\n if (notifications && notifications.length > 0) {\n count++\n }\n if (!isValid) {\n count++;\n }\n if (shouldShowNotEditableNotification()) {\n count++;\n }\n return count * 40;\n }\n\n const shouldRenderNotificationsWrapper = (): boolean => {\n if (!isValid) {\n return true;\n }\n if (shouldShowNotEditableNotification()) {\n return true;\n }\n if (notifications && notifications.length > 0) {\n return true;\n }\n return false;\n }\n\n React.useEffect(() => {\n const resizeObserver = new ResizeObserver(() => {\n debounceNotificationRemeasure();\n })\n resizeObserver.observe(props.eGridCell);\n }, []);\n\n\n if (record.ui?.isLoading(column.name)) {\n return <Shimmer className={styles.loading} />\n }\n switch (column.name) {\n case CHECKBOX_COLUMN_KEY: {\n return <div className={styles.cellContent}>\n <Checkbox\n checked={props.node.isSelected()}\n onChange={(e, checked) => {\n e?.stopPropagation()\n selection.toggle(record, checked!)\n }} />\n </div>\n }\n case Constants.RIBBON_BUTTONS_COLUMN_NAME: {\n return <div className={styles.cellContent}>\n <Commands record={record} />\n </div>\n }\n }\n\n return (\n <div style={{\n '--test': `${calculateNotificationsWrapperMinWidth()}px`\n } as React.CSSProperties} className={styles.root} data-is-valid={isValid}>\n <div className={styles.cellContentWrapper}>\n <div className={styles.cellContent}>\n <InternalReadOnlyCell {...props} />\n </div>\n </div>\n {shouldRenderNotificationsWrapper() &&\n <div className={styles.notificationsWrapper}>\n {notifications && notifications.length > 0 &&\n <MemoizedNotifications className={styles.notifications} ref={notificationRef} notifications={notifications} />\n }\n {!isValid &&\n <MemoizedNotifications notifications={[\n {\n notificationLevel: 'ERROR',\n messages: [],\n iconName: 'Error',\n uniqueId: column.name,\n title: errorMessage,\n compact: true\n }\n ]} />\n }\n {\n shouldShowNotEditableNotification() &&\n <MemoizedNotifications className={styles.uneditableNotification} notifications={[{\n iconName: 'Uneditable',\n notificationLevel: 'RECOMMENDATION',\n uniqueId: column.name,\n title: grid.labels['value-not-editable'](),\n compact: true,\n messages: []\n }]} />\n }\n </div>\n }\n </div>\n )\n};\n\nconst InternalReadOnlyCell = (props: ICellProps) => {\n const grid = useGridInstance();\n const column = props.baseColumn;\n const theme = useTheme();\n const styles = getReadOnlyCellStyles(theme);\n const record: IRecord = (() => {\n //this is so we can load the updated record values from state\n const updatedRecord = grid.recordUpdateService.record(props.data.getRecordId()).get() as any;\n return updatedRecord ?? props.data;\n })();\n const formattedValue = record.getFormattedValue(column.name);\n\n const renderLink = (props: ILinkProps, formattedValue: string | null): JSX.Element => {\n switch (column.dataType) {\n case DataType.LOOKUP_OWNER:\n case DataType.LOOKUP_SIMPLE:\n case DataType.LOOKUP_CUSTOMER: {\n if (!grid.isNavigationEnabled) {\n return renderText();\n }\n }\n }\n if (!formattedValue) {\n return <></>\n }\n return (\n <Link {...props} className={styles.link} title={formattedValue}>\n {formattedValue}\n </Link>\n );\n };\n const renderText = (): JSX.Element => {\n if (column.isPrimary && grid.isNavigationEnabled) {\n return renderLink({\n onClick: () => grid.openDatasetItem(record.getNamedReference())\n }, formattedValue);\n }\n return <Text className={`${styles.text} talxis-cell-text`} title={formattedValue!}>{formattedValue}</Text>\n }\n const downloadFile = () => {\n const storage = new FileAttribute(grid.pcfContext.webAPI);\n const namedReference = record.getNamedReference();\n storage.downloadFileFromAttribute({\n //@ts-ignore - PowerApps do not follow the typings\n entityName: namedReference.etn ?? namedReference.entityName,\n recordId: record.getRecordId(),\n fileAttribute: column.name,\n }, true)\n }\n\n switch (column.dataType) {\n case DataType.SINGLE_LINE_EMAIL: {\n return renderLink({ href: `mailto:${formattedValue}` }, formattedValue);\n }\n case DataType.SINGLE_LINE_PHONE: {\n return renderLink({ href: `tel:${formattedValue}` }, formattedValue);\n }\n case DataType.SINGLE_LINE_URL: {\n return renderLink({\n href: formattedValue ?? \"\",\n target: '_blank',\n rel: 'noopener noreferrer'\n }, formattedValue);\n }\n case DataType.LOOKUP_SIMPLE:\n case DataType.LOOKUP_OWNER:\n case DataType.LOOKUP_CUSTOMER: {\n return renderLink({\n onClick: () => grid.openDatasetItem(record.getValue(column.name) as any)\n }, formattedValue);\n }\n case DataType.FILE: {\n if (!formattedValue) {\n return <></>\n }\n return (\n <div className={styles.fileWrapper}>\n <Icon iconName='Attach' />\n {\n renderLink({\n onClick: downloadFile\n }, grid.labels.download())\n }\n </div>\n )\n }\n case DataType.IMAGE: {\n if (!formattedValue) {\n return <></>\n }\n return (\n <div className={styles.fileWrapper}>\n <Image className={styles.image} src={`data:image/png;base64,${formattedValue}`} />\n {\n renderLink({\n onClick: downloadFile\n }, 'Download')\n }\n </div>\n )\n }\n case DataType.OPTIONSET:\n case DataType.MULTI_SELECT_OPTIONSET:\n case DataType.TWO_OPTIONS: {\n if (grid.enableOptionSetColors) {\n return <ReadOnlyOptionSet\n column={column}\n record={record}\n defaultRender={renderText} />\n }\n return renderText();\n }\n default: {\n return renderText()\n }\n\n }\n}"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;AAyBa,MAAA,YAAY,GAAG,CAAC,KAAiB,KAAI;AAC9C,IAAA,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;AAC/B,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC;AAChC,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;AAC1B,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AACzB,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1E,IAAA,MAAM,SAAS,GAAG,sBAAsB,EAAE,CAAC;AAC3C,IAAA,MAAM,aAAa,GAAG,MAAM,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,iBAAiB,EACrB,EAAA,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,UAAU,GAAI,CAAA;AACpC,aAAA;YACD,OAAO,UAAU,EAAE,CAAC;AACvB,SAAA;AACD,QAAA,SAAS;YACL,OAAO,UAAU,EAAE,CAAA;AACtB,SAAA;AAEJ,KAAA;AACL,CAAC;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="powerapps-component-framework" />
|
|
2
1
|
import { ReactElement } from "react";
|
|
3
2
|
import { IGridColumn } from "../../../../interfaces/IGridColumn";
|
|
3
|
+
import { IRecord } from "@talxis/client-libraries";
|
|
4
4
|
interface IReadOnlyOptionSet {
|
|
5
5
|
column: IGridColumn;
|
|
6
|
-
record:
|
|
6
|
+
record: IRecord;
|
|
7
7
|
defaultRender: () => ReactElement;
|
|
8
8
|
}
|
|
9
9
|
export declare const ReadOnlyOptionSet: (props: IReadOnlyOptionSet) => JSX.Element;
|
|
@@ -15,8 +15,8 @@ const ReadOnlyOptionSet = (props) => {
|
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
(async () => {
|
|
17
17
|
const getOptions = async () => {
|
|
18
|
-
const [defaultValue, options] = await grid.metadata.getOptions(column);
|
|
19
|
-
let value = record.getValue(column.
|
|
18
|
+
const [defaultValue, options] = await grid.metadata.getOptions(column.name);
|
|
19
|
+
let value = record.getValue(column.name);
|
|
20
20
|
if (column.dataType === DataType.OPTIONSET) {
|
|
21
21
|
value = value ? [parseInt(value)] : null;
|
|
22
22
|
}
|
|
@@ -31,7 +31,7 @@ const ReadOnlyOptionSet = (props) => {
|
|
|
31
31
|
const results = await getOptions();
|
|
32
32
|
setOptions(results);
|
|
33
33
|
})();
|
|
34
|
-
}, [record.getValue(column.
|
|
34
|
+
}, [record.getValue(column.name)]);
|
|
35
35
|
//options not loaded yet
|
|
36
36
|
if (options === null) {
|
|
37
37
|
return jsx(Fragment, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyOptionSet.js","sources":["../../../../../../../../src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport { Text } from '@fluentui/react';\nimport { optionSetStyles } from \"./styles\";\nimport color from 'color';\nimport { useTheme } from \"@fluentui/react\";\nimport { IGridColumn } from \"../../../../interfaces/IGridColumn\";\nimport { useGridInstance } from \"../../../../hooks/useGridInstance\";\nimport { DataType } from \"../../../../enums/DataType\";\n\ninterface IReadOnlyOptionSet {\n column: IGridColumn;\n record:
|
|
1
|
+
{"version":3,"file":"ReadOnlyOptionSet.js","sources":["../../../../../../../../src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport { Text } from '@fluentui/react';\nimport { optionSetStyles } from \"./styles\";\nimport color from 'color';\nimport { useTheme } from \"@fluentui/react\";\nimport { IGridColumn } from \"../../../../interfaces/IGridColumn\";\nimport { useGridInstance } from \"../../../../hooks/useGridInstance\";\nimport { DataType } from \"../../../../enums/DataType\";\nimport { IRecord } from \"@talxis/client-libraries\";\n\ninterface IReadOnlyOptionSet {\n column: IGridColumn;\n record: IRecord\n defaultRender: () => ReactElement\n}\n\nexport const ReadOnlyOptionSet = (props: IReadOnlyOptionSet) => {\n const grid = useGridInstance();\n const { record, column, defaultRender } = { ...props }\n const [options, setOptions] = useState<ComponentFramework.PropertyHelper.OptionMetadata[] | null>(null);\n const theme = useTheme();\n const defaultColor = theme.palette.neutralLight;\n\n useEffect(() => {\n (async () => {\n const getOptions = async (): Promise<ComponentFramework.PropertyHelper.OptionMetadata[]> => {\n const [defaultValue, options] = await grid.metadata.getOptions(column.name);\n let value: any = record.getValue(column.name);\n if (column.dataType === DataType.OPTIONSET) {\n value = value ? [parseInt(value)] : null;\n }\n if (column.dataType === DataType.MULTI_SELECT_OPTIONSET) {\n value = value ? value.split(',').map((value: string) => parseInt(value)) : null;\n }\n if (column.dataType === DataType.TWO_OPTIONS) {\n value = [parseInt(value)];\n }\n return options.filter(option => value?.includes(option.Value)) ?? [];\n }\n const results = await getOptions();\n setOptions(results);\n })();\n }, [record.getValue(column.name)]);\n\n //options not loaded yet\n if (options === null) {\n return <></>\n }\n //options loaded but either no value selected or no colors are present\n if (options.length === 0 || !options.find(x => x.Color)) {\n return defaultRender();\n }\n else {\n return (\n <div className={optionSetStyles.root}>\n {options.map(x => <div\n key={x.Value}\n title={x.Label}\n className={optionSetStyles.option}\n style={{ backgroundColor: x.Color ?? defaultColor, color: new color(x.Color ?? defaultColor).isDark() ? 'white' : 'black' }}>\n <Text>{x.Label}</Text>\n </div>)}\n </div>\n )\n }\n\n}"],"names":["_jsx","color"],"mappings":";;;;;;;;AAiBa,MAAA,iBAAiB,GAAG,CAAC,KAAyB,KAAI;AAC3D,IAAA,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;AAC/B,IAAA,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAA;IACtD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAA4D,IAAI,CAAC,CAAC;AACxG,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AACzB,IAAA,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;IAEhD,SAAS,CAAC,MAAK;QACX,CAAC,YAAW;AACR,YAAA,MAAM,UAAU,GAAG,YAAwE;AACvF,gBAAA,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC5E,IAAI,KAAK,GAAQ,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CA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