@agilemotion/oui-react-js 1.8.42 → 1.8.44
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/ApplicationManager.js +10 -8
- package/dist/InteractionPortalApp.js +0 -1
- package/dist/InteractionPortalAppHome.js +69 -3
- package/dist/RestService.js +3 -3
- package/dist/Utils.js +7 -0
- package/dist/assets/jss/components/customInputStyle.js +0 -1
- package/dist/assets/jss/components/customInputStyle.jsx +0 -1
- package/dist/components/DataGrid.js +6 -2
- package/dist/components/DocumentTemplateDesignerComponent.css +2 -0
- package/dist/components/DocumentViewer.js +2 -2
- package/dist/components/SocketManager.js +4 -2
- package/dist/components/TitleBar.js +1 -1
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/WordDocumentViewer.js +208 -16
- package/dist/components/customInput/CustomInput.js +4 -1
- package/dist/components/dashboard/FoldingSideTabDashboard.css +3 -0
- package/dist/components/dashboard/FoldingSideTabDashboard.js +24 -12
- package/dist/components/dashboard/SideMenuModuleDashboard.css +6 -5
- package/dist/components/dashboard/SideMenuModuleDashboard.js +5 -2
- package/dist/components/dashboard/components/blackDashboard/sidebar/FoldingTabSidebar.css +94 -0
- package/dist/components/dashboard/components/blackDashboard/sidebar/FoldingTabSidebar.js +111 -203
- package/dist/components/form/BaseField.js +1 -1
- package/dist/components/form/Form.css +2 -3
- package/dist/components/form/Form.js +5 -1
- package/dist/components/form/GridField.js +3 -1
- package/dist/components/form/RadioGroup.js +4 -1
- package/dist/components/layout/Layout.css +8 -0
- package/dist/components/layout/Layout.js +10 -1
- package/dist/components/layout/View.css +20 -6
- package/dist/components/layout/View.js +32 -1
- package/dist/components/layout/Window.js +1 -0
- package/dist/components/media/Chat.css +0 -0
- package/dist/components/media/Chat.js +86 -0
- package/dist/components/media/chat/ChatRoom.js +19 -12
- package/dist/components/signatures/AgilitySignaturePanel.js +2 -1
- package/package.json +3 -2
|
@@ -7,7 +7,6 @@ exports.default = exports.TEMPLATE_TOKEN_REGEX = exports.SYSTEM_EVENT = exports.
|
|
|
7
7
|
var _Observable = _interopRequireDefault(require("./event/Observable"));
|
|
8
8
|
var _Event = _interopRequireDefault(require("./event/Event"));
|
|
9
9
|
var _EventType = _interopRequireDefault(require("./event/EventType"));
|
|
10
|
-
var _Graph = _interopRequireDefault(require("./components/Graph"));
|
|
11
10
|
var _Utils = _interopRequireDefault(require("./Utils"));
|
|
12
11
|
var _DynamicJS = _interopRequireWildcard(require("./DynamicJS"));
|
|
13
12
|
var _TypedValue = _interopRequireDefault(require("./TypedValue"));
|
|
@@ -80,13 +79,7 @@ class ApplicationManager {
|
|
|
80
79
|
return instance.getActiveTenant();
|
|
81
80
|
},
|
|
82
81
|
getUniqueOrgForRole(role) {
|
|
83
|
-
|
|
84
|
-
let roles = profile.organisations.filter(org => org.roles.includes(role)) // Filter organisations by role
|
|
85
|
-
.map(org => org.code);
|
|
86
|
-
if (roles.length > 1) {
|
|
87
|
-
throw new Error("There is more than one organisation for role : [" + role + "]");
|
|
88
|
-
}
|
|
89
|
-
return roles[0];
|
|
82
|
+
return instance.getUniqueOrgForRole(role);
|
|
90
83
|
}
|
|
91
84
|
};
|
|
92
85
|
if (!Array.isArray) {
|
|
@@ -98,6 +91,15 @@ class ApplicationManager {
|
|
|
98
91
|
}
|
|
99
92
|
return ApplicationManager.instance;
|
|
100
93
|
}
|
|
94
|
+
getUniqueOrgForRole(role) {
|
|
95
|
+
let profile = JSON.parse(this.getUserDetails().profile);
|
|
96
|
+
let roles = profile.organisations.filter(org => org.roles.includes(role)) // Filter organisations by role
|
|
97
|
+
.map(org => org.code);
|
|
98
|
+
if (roles.length > 1) {
|
|
99
|
+
throw new Error("There is more than one organisation for role : [" + role + "]");
|
|
100
|
+
}
|
|
101
|
+
return roles[0];
|
|
102
|
+
}
|
|
101
103
|
addApplicationContextSubscription = subscription => {
|
|
102
104
|
return new Promise(resolve => {
|
|
103
105
|
_Observable.default.addApplicationContextSubscription(subscription);
|
|
@@ -36,7 +36,6 @@ const InteractionPortalApp = props => {
|
|
|
36
36
|
if (window.location.pathname !== '/reset-password' && window.location.pathname !== '/login' && window.location.pathname !== '/forgot-password' && window.location.pathname !== '/change-password') {
|
|
37
37
|
navigate("/");
|
|
38
38
|
}
|
|
39
|
-
console.log("\n\n\n\nImpl : ", props.implConfig);
|
|
40
39
|
}, []);
|
|
41
40
|
return /*#__PURE__*/_react.default.createElement(_ThemeProvider.default, {
|
|
42
41
|
theme: agilityTheme
|
|
@@ -12,6 +12,11 @@ var _Utils = _interopRequireDefault(require("./Utils"));
|
|
|
12
12
|
var _reactRouterDom = require("react-router-dom");
|
|
13
13
|
var _RestUtils = require("./RestUtils");
|
|
14
14
|
var _SideMenuModuleDashboard = _interopRequireDefault(require("./components/dashboard/SideMenuModuleDashboard"));
|
|
15
|
+
var _SocketManager = _interopRequireDefault(require("./components/SocketManager"));
|
|
16
|
+
var _FoldingSideTabDashboard = _interopRequireDefault(require("./components/dashboard/FoldingSideTabDashboard"));
|
|
17
|
+
var _material = require("@mui/material");
|
|
18
|
+
var _ThemeProvider = _interopRequireDefault(require("@mui/styles/ThemeProvider"));
|
|
19
|
+
var _react2 = require("@emotion/react");
|
|
15
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
21
|
const location = window.location.protocol + "//" + window.location.hostname;
|
|
17
22
|
const status = response => {
|
|
@@ -49,6 +54,8 @@ const InteractionPortalAppHome = /*#__PURE__*/_react.default.memo((props, ref) =
|
|
|
49
54
|
});
|
|
50
55
|
(0, _RestUtils.sendRequest)(location + _ApplicationManager.default.getContextRoot() + '/auth/api/v1/user/find', response => {
|
|
51
56
|
_ApplicationManager.default.setUserDetails(response);
|
|
57
|
+
_SocketManager.default.init();
|
|
58
|
+
_ApplicationManager.default.setActiveTenant(_ApplicationManager.default.getUniqueOrgForRole('VENDOR'));
|
|
52
59
|
}, e => {
|
|
53
60
|
console.log(e);
|
|
54
61
|
});
|
|
@@ -81,15 +88,74 @@ const InteractionPortalAppHome = /*#__PURE__*/_react.default.memo((props, ref) =
|
|
|
81
88
|
className: "main w-100 h-100 d-inline-block"
|
|
82
89
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
90
|
className: "w-100 h-100"
|
|
84
|
-
}, !loading && !_Utils.default.isNull(dashboardSettings) && !hasClientError ? /*#__PURE__*/_react.default.createElement(
|
|
91
|
+
}, !loading && !_Utils.default.isNull(dashboardSettings) && !hasClientError ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
92
|
+
className: `main w-100 h-100 d-inline-block coj-skin`
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
94
|
+
className: "w-100 h-100"
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement(_react2.ThemeProvider, {
|
|
96
|
+
theme: (0, _material.createTheme)({
|
|
97
|
+
palette: {
|
|
98
|
+
primary: {
|
|
99
|
+
main: props.implConfig.primaryColor
|
|
100
|
+
},
|
|
101
|
+
secondary: {
|
|
102
|
+
main: props.implConfig.secondaryColor
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement(_ThemeProvider.default, {
|
|
107
|
+
theme: (0, _material.createTheme)({
|
|
108
|
+
palette: {
|
|
109
|
+
primary: {
|
|
110
|
+
main: dashboardSettings.systemProfileDto.firstCorporateBrandColor
|
|
111
|
+
},
|
|
112
|
+
secondary: {
|
|
113
|
+
main: dashboardSettings.systemProfileDto.secondCorporateBrandColor
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
components: {
|
|
117
|
+
MuiCssBaseline: {
|
|
118
|
+
styleOverrides: {
|
|
119
|
+
body: {
|
|
120
|
+
// Firefox
|
|
121
|
+
scrollbarColor: 'rgba(100, 100, 100, 0.4) transparent',
|
|
122
|
+
scrollbarWidth: 'thin'
|
|
123
|
+
},
|
|
124
|
+
// WebKit browsers
|
|
125
|
+
'::-webkit-scrollbar': {
|
|
126
|
+
width: '8px',
|
|
127
|
+
height: '8px'
|
|
128
|
+
},
|
|
129
|
+
'::-webkit-scrollbar-track': {
|
|
130
|
+
background: 'transparent'
|
|
131
|
+
},
|
|
132
|
+
'::-webkit-scrollbar-thumb': {
|
|
133
|
+
backgroundColor: 'rgba(100, 100, 100, 0.4)',
|
|
134
|
+
borderRadius: '4px',
|
|
135
|
+
transition: 'background-color 0.3s'
|
|
136
|
+
},
|
|
137
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
138
|
+
backgroundColor: 'rgba(100, 100, 100, 0.6)'
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}, /*#__PURE__*/_react.default.createElement(_material.CssBaseline, null), /*#__PURE__*/_react.default.createElement(_FoldingSideTabDashboard.default, {
|
|
85
145
|
logoutCallBack: () => {
|
|
86
146
|
logout();
|
|
87
147
|
},
|
|
88
148
|
settings: dashboardSettings,
|
|
89
149
|
avatar: !_Utils.default.isNull(avatarUrl) ? avatarUrl : null,
|
|
90
150
|
logo: dashboardSettings.logo,
|
|
91
|
-
|
|
92
|
-
|
|
151
|
+
showDashboardMenu: false,
|
|
152
|
+
appLogoPath: /*dashboardSettings.logo*/null,
|
|
153
|
+
logoStyle: {
|
|
154
|
+
padding: '32px'
|
|
155
|
+
}
|
|
156
|
+
}), /*#__PURE__*/_react.default.createElement(_LoadingIndicator.default, {
|
|
157
|
+
color: loadingColor
|
|
158
|
+
})))))) : hasClientError ? /*#__PURE__*/_react.default.createElement("div", {
|
|
93
159
|
style: "margin: 128px; color: red; font-size: 24px"
|
|
94
160
|
}, "System error - Unknown client") : null), /*#__PURE__*/_react.default.createElement(_LoadingIndicator.default, {
|
|
95
161
|
color: loadingColor
|
package/dist/RestService.js
CHANGED
|
@@ -90,9 +90,9 @@ class RestService {
|
|
|
90
90
|
} else {
|
|
91
91
|
if (!this.isParamValueNull(parameterValue)) {
|
|
92
92
|
requestBody = parameterValue.instanceType === 'TypedValue' ? parameterValue.value : parameterValue;
|
|
93
|
-
if (typeof requestBody === 'object') {
|
|
94
|
-
|
|
95
|
-
}
|
|
93
|
+
/*if (typeof requestBody === 'object') {
|
|
94
|
+
requestBody.type = parameterValue.type;
|
|
95
|
+
}*/
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
package/dist/Utils.js
CHANGED
|
@@ -17,6 +17,13 @@ class Utils {
|
|
|
17
17
|
static isNull(value) {
|
|
18
18
|
return value === null || typeof value === 'undefined';
|
|
19
19
|
}
|
|
20
|
+
static normalizeCssSize(value, fallback) {
|
|
21
|
+
if (value == null) return fallback;
|
|
22
|
+
// allow "72px", "5rem", etc.
|
|
23
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
24
|
+
if (typeof value === "number" && Number.isFinite(value)) return `${value}px`;
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
20
27
|
static getInitials(name) {
|
|
21
28
|
const parts = name.split(' ');
|
|
22
29
|
let initials = '';
|
|
@@ -429,7 +429,9 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
429
429
|
processData(result, conf);
|
|
430
430
|
}).catch(e => {
|
|
431
431
|
console.error(e);
|
|
432
|
-
|
|
432
|
+
if (e.errorType !== 'INVALID_PARAMETER') {
|
|
433
|
+
_Utils.default.publishErrorMessage(e, props.viewId);
|
|
434
|
+
}
|
|
433
435
|
});
|
|
434
436
|
} else {
|
|
435
437
|
throw new Error('Unknown service type : ' + serviceType);
|
|
@@ -591,6 +593,7 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
591
593
|
updateColumnReadOnlyStatus(column, props.rows);
|
|
592
594
|
}
|
|
593
595
|
rowsRef.current = rowValues;
|
|
596
|
+
setSelected([]);
|
|
594
597
|
setRows(rowValues);
|
|
595
598
|
}
|
|
596
599
|
}, [props.rows]);
|
|
@@ -744,6 +747,7 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
744
747
|
}
|
|
745
748
|
return visible && /*#__PURE__*/_react.default.createElement("div", {
|
|
746
749
|
id: props.config.id,
|
|
750
|
+
className: _Utils.default.getComponentAttribute(props.config, 'className', null),
|
|
747
751
|
style: _Utils.default.isNull(props.hasBorder) || props.hasBorder === true ? _Utils.default.mergeStyles({
|
|
748
752
|
margin: '0',
|
|
749
753
|
border: '1px solid #e2e2e2',
|
|
@@ -808,7 +812,7 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
808
812
|
},
|
|
809
813
|
label: "Wrap table text"
|
|
810
814
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
811
|
-
className:
|
|
815
|
+
className: `responsive-table`,
|
|
812
816
|
style: {
|
|
813
817
|
height: props.height
|
|
814
818
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
@import '@syncfusion/ej2-splitbuttons/styles/material.css';
|
|
8
8
|
@import '@syncfusion/ej2-dropdowns/styles/material.css';
|
|
9
9
|
@import "@syncfusion/ej2-react-documenteditor/styles/material.css";
|
|
10
|
+
@import '@syncfusion/ej2-buttons/styles/material.css';
|
|
11
|
+
@import '@syncfusion/ej2-splitbuttons/styles/material.css';
|
|
10
12
|
|
|
11
13
|
.e-de-toolbar.e-toolbar .e-toolbar-items .e-toolbar-item .e-tbar-btn.e-btn {
|
|
12
14
|
}
|
|
@@ -151,7 +151,7 @@ const DocumentViewer = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.defa
|
|
|
151
151
|
}, "Error loading document"), !loading && !hasLoadingError && _Utils.default.prop(parsedConfig.fileType) === 'application/pdf' && !_Utils.default.isNull(value) && /*#__PURE__*/_react.default.createElement(_PDFViewer.default, {
|
|
152
152
|
file: value,
|
|
153
153
|
onDocumentLoadSuccess: () => {}
|
|
154
|
-
}), !loading && !hasLoadingError && _Utils.default.prop(parsedConfig.fileType) === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' && (!_Utils.default.isNull(value) || props.config.enableUpload) && /*#__PURE__*/_react.default.createElement(_WordDocumentViewer.default, {
|
|
154
|
+
}), !loading && !hasLoadingError && _Utils.default.prop(parsedConfig.fileType) === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' && (!_Utils.default.isNull(value) || props.config.enableUpload) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_WordDocumentViewer.default, {
|
|
155
155
|
file: value,
|
|
156
156
|
onDocumentLoadSuccess: () => {},
|
|
157
157
|
valueHandler: wordEditorValueHandler,
|
|
@@ -167,6 +167,6 @@ const DocumentViewer = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.defa
|
|
|
167
167
|
enableUpload: _Utils.default.evaluateBooleanExpression(parsedConfig.enableUpload, props.config.id),
|
|
168
168
|
trackChanges: _Utils.default.evaluateBooleanExpression(parsedConfig.trackChanges, props.config.id),
|
|
169
169
|
id: props.config.id
|
|
170
|
-
}));
|
|
170
|
+
})));
|
|
171
171
|
}));
|
|
172
172
|
var _default = exports.default = DocumentViewer;
|
|
@@ -99,14 +99,16 @@ class SocketManager {
|
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
101
|
registerOnline() {
|
|
102
|
-
console.log('***** REGISTERING ONLINE *****');
|
|
103
102
|
let userDetails = _ApplicationManager.default.getUserDetails();
|
|
103
|
+
// TODO : Resolve the hardcoding
|
|
104
|
+
let profile = typeof JSON.parse(userDetails.profile) === 'string' ? userDetails.profile : 'COJ';
|
|
105
|
+
console.log('***** REGISTERING ONLINE ***** [' + profile + ']');
|
|
104
106
|
this.emitEvent(_SocketRequest.default.REGISTER_ONLINE, {
|
|
105
107
|
user: {
|
|
106
108
|
userId: userDetails.username,
|
|
107
109
|
name: userDetails.name + ' ' + userDetails.surname
|
|
108
110
|
},
|
|
109
|
-
orgCode:
|
|
111
|
+
orgCode: profile
|
|
110
112
|
}).then(data => {
|
|
111
113
|
console.log("REGISTERED ONLINE - " + userDetails.username);
|
|
112
114
|
this.connected = true;
|
|
@@ -58,7 +58,7 @@ const TitleBar = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.fo
|
|
|
58
58
|
className: 'title-bar'
|
|
59
59
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
60
60
|
style: {
|
|
61
|
-
padding: '
|
|
61
|
+
padding: '4px 0 4px 0',
|
|
62
62
|
fontSize: '24px',
|
|
63
63
|
color: '#202124'
|
|
64
64
|
}
|
|
@@ -326,7 +326,7 @@ const Toolbar = props => {
|
|
|
326
326
|
className: 'oui-toolbar',
|
|
327
327
|
style: _Utils.default.mergeStyles({
|
|
328
328
|
borderBottom: '1px solid #e2e2e2',
|
|
329
|
-
padding: '4px 0
|
|
329
|
+
padding: '4px 0',
|
|
330
330
|
overflow: 'hidden'
|
|
331
331
|
}, props.config)
|
|
332
332
|
}, render(props.config));
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.KEY = exports.DOCSVC = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactPromiseTracker = require("react-promise-tracker");
|
|
9
9
|
var _Utils = _interopRequireDefault(require("../Utils"));
|
|
10
10
|
var _ej2ReactDocumenteditor = require("@syncfusion/ej2-react-documenteditor");
|
|
@@ -13,19 +13,83 @@ var _ApplicationManager = _interopRequireDefault(require("../ApplicationManager"
|
|
|
13
13
|
var _ej2Base = require("@syncfusion/ej2-base");
|
|
14
14
|
var _Alert = _interopRequireDefault(require("react-bootstrap/Alert"));
|
|
15
15
|
var _LottieIcon = _interopRequireDefault(require("./LottieIcon"));
|
|
16
|
+
var _ej2ReactSplitbuttons = require("@syncfusion/ej2-react-splitbuttons");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
20
|
const KEY = exports.KEY = 'ORg4AjUWIQA/Gnt2U1hhQlJBfV5AQmBIYVp/TGpJfl96cVxMZVVBJAtUQF1hTX5adkJiWHtWdXBXT2Je';
|
|
18
21
|
(0, _ej2Base.registerLicense)(KEY);
|
|
19
22
|
const DOCSVC = exports.DOCSVC = "https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/";
|
|
20
23
|
_ej2ReactDocumenteditor.DocumentEditorContainerComponent.Inject(_ej2ReactDocumenteditor.Toolbar);
|
|
24
|
+
function useOnFullyVisible(callback) {
|
|
25
|
+
let {
|
|
26
|
+
threshold = 0.1
|
|
27
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
const ref = (0, _react.useRef)(null);
|
|
29
|
+
(0, _react.useEffect)(() => {
|
|
30
|
+
const el = ref.current;
|
|
31
|
+
if (!el) return;
|
|
32
|
+
const nextPaint = () => new Promise(res => requestAnimationFrame(() => requestAnimationFrame(res)));
|
|
33
|
+
const waitImages = () => {
|
|
34
|
+
const imgs = Array.from(el.querySelectorAll('img'));
|
|
35
|
+
const pending = imgs.filter(img => !(img.complete && img.naturalWidth > 0));
|
|
36
|
+
if (!pending.length) return Promise.resolve();
|
|
37
|
+
return Promise.all(pending.map(img => new Promise(r => {
|
|
38
|
+
const done = () => {
|
|
39
|
+
img.removeEventListener('load', done);
|
|
40
|
+
img.removeEventListener('error', done);
|
|
41
|
+
r();
|
|
42
|
+
};
|
|
43
|
+
img.addEventListener('load', done, {
|
|
44
|
+
once: true
|
|
45
|
+
});
|
|
46
|
+
img.addEventListener('error', done, {
|
|
47
|
+
once: true
|
|
48
|
+
});
|
|
49
|
+
})));
|
|
50
|
+
};
|
|
51
|
+
const waitFonts = () => 'fonts' in document && document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
|
|
52
|
+
const io = new IntersectionObserver(async entries => {
|
|
53
|
+
const entry = entries[0];
|
|
54
|
+
const fullyVisible = entry.intersectionRatio >= threshold || entry.intersectionRatio >= 0.99;
|
|
55
|
+
if (fullyVisible) {
|
|
56
|
+
io.disconnect();
|
|
57
|
+
await waitImages();
|
|
58
|
+
await waitFonts();
|
|
59
|
+
await nextPaint();
|
|
60
|
+
callback(el);
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
threshold: [threshold, 0.99]
|
|
64
|
+
});
|
|
65
|
+
io.observe(el);
|
|
66
|
+
return () => io.disconnect();
|
|
67
|
+
}, [callback, threshold]);
|
|
68
|
+
return ref;
|
|
69
|
+
}
|
|
70
|
+
const LEVEL_FMT = ['%1.', '%1.%2.', '%1.%2.%3.'];
|
|
71
|
+
function applyLevel(ed) {
|
|
72
|
+
let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
73
|
+
const depth = Math.max(0, Math.min(level, LEVEL_FMT.length - 1));
|
|
74
|
+
ed.selection.paragraphFormat.listLevelNumber = depth;
|
|
75
|
+
ed.applyNumbering(LEVEL_FMT[depth], 'Arabic');
|
|
76
|
+
}
|
|
21
77
|
const WordDocumentViewer = props => {
|
|
22
78
|
const [container, setContainer] = _react.default.useState(null);
|
|
23
79
|
const [items, setItems] = _react.default.useState(null);
|
|
24
80
|
const [height, setHeight] = _react.default.useState(0);
|
|
25
81
|
const [width, setWidth] = _react.default.useState(0);
|
|
26
|
-
const [visible, setVisible] = _react.default.useState(
|
|
82
|
+
const [visible, setVisible] = _react.default.useState(true);
|
|
83
|
+
const [reRendering, setReRendering] = _react.default.useState(false);
|
|
27
84
|
const [json, setJson] = _react.default.useState(null);
|
|
28
85
|
const [errorMessage, setErrorMessage] = _react.default.useState(null);
|
|
86
|
+
const ref = useOnFullyVisible(el => {
|
|
87
|
+
console.log('Document fully visible & rendered:', el);
|
|
88
|
+
if (!reRendering) {
|
|
89
|
+
setVisible(false);
|
|
90
|
+
setReRendering(true);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
29
93
|
|
|
30
94
|
/*let items = ['Bold', 'Italic', 'Underline', '|', 'Formats', '|', 'CreateLink', '|',
|
|
31
95
|
{
|
|
@@ -47,14 +111,105 @@ const WordDocumentViewer = props => {
|
|
|
47
111
|
_react.default.useEffect(() => {
|
|
48
112
|
props.valueHandler.api = api();
|
|
49
113
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
114
|
+
const numberingItems = [{
|
|
115
|
+
id: 'lvl-0',
|
|
116
|
+
text: '1.'
|
|
117
|
+
}, {
|
|
118
|
+
id: 'lvl-1',
|
|
119
|
+
text: '1.1'
|
|
120
|
+
}, {
|
|
121
|
+
id: 'lvl-2',
|
|
122
|
+
text: '1.1.1'
|
|
123
|
+
}, {
|
|
124
|
+
separator: true
|
|
125
|
+
}, {
|
|
126
|
+
id: 'clear',
|
|
127
|
+
text: 'Clear list'
|
|
128
|
+
}];
|
|
129
|
+
const onNumberingSelect = args => {
|
|
130
|
+
const ed = containerRef.current?.documentEditor?.editor;
|
|
131
|
+
if (!ed) return;
|
|
132
|
+
switch (args.item.id) {
|
|
133
|
+
case 'lvl-0':
|
|
134
|
+
applyLevel(ed, 0);
|
|
135
|
+
break;
|
|
136
|
+
case 'lvl-1':
|
|
137
|
+
applyLevel(ed, 1);
|
|
138
|
+
break;
|
|
139
|
+
case 'lvl-2':
|
|
140
|
+
applyLevel(ed, 2);
|
|
141
|
+
break;
|
|
142
|
+
case 'clear':
|
|
143
|
+
ed.clearList();
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const onCreated = () => {
|
|
150
|
+
const container = containerRef.current;
|
|
151
|
+
const tb = container?.toolbarModule?.toolbar; // EJ2 Toolbar instance
|
|
152
|
+
if (!tb) return;
|
|
153
|
+
|
|
154
|
+
// 1) Add a placeholder button into the toolbar at the end
|
|
155
|
+
tb.addItems([{
|
|
156
|
+
type: 'Separator'
|
|
157
|
+
}, {
|
|
158
|
+
// Use a real HTML template (string) and give it an id
|
|
159
|
+
template: '<button id="numbering-ddb" class="e-btn e-flat" type="button">Numbering</button>',
|
|
160
|
+
tooltipText: 'Numbering styles'
|
|
161
|
+
}], tb.items.length);
|
|
162
|
+
|
|
163
|
+
// 2) Turn that placeholder into a functioning DropDownButton
|
|
164
|
+
const ddb = new DropDownButton({
|
|
165
|
+
content: 'Numbering',
|
|
166
|
+
cssClass: 'e-flat',
|
|
167
|
+
items: [{
|
|
168
|
+
id: 'lvl-0',
|
|
169
|
+
text: '1.'
|
|
170
|
+
}, {
|
|
171
|
+
id: 'lvl-1',
|
|
172
|
+
text: '1.1'
|
|
173
|
+
}, {
|
|
174
|
+
id: 'lvl-2',
|
|
175
|
+
text: '1.1.1'
|
|
176
|
+
}, {
|
|
177
|
+
separator: true
|
|
178
|
+
}, {
|
|
179
|
+
id: 'clear',
|
|
180
|
+
text: 'Clear list'
|
|
181
|
+
}],
|
|
182
|
+
select: args => {
|
|
183
|
+
const ed = container.documentEditor.editor;
|
|
184
|
+
if (!ed) return;
|
|
185
|
+
switch (args.item.id) {
|
|
186
|
+
case 'lvl-0':
|
|
187
|
+
applyLevel(ed, 0);
|
|
188
|
+
break;
|
|
189
|
+
case 'lvl-1':
|
|
190
|
+
applyLevel(ed, 1);
|
|
191
|
+
break;
|
|
192
|
+
case 'lvl-2':
|
|
193
|
+
applyLevel(ed, 2);
|
|
194
|
+
break;
|
|
195
|
+
case 'clear':
|
|
196
|
+
ed.clearList();
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, '#numbering-ddb');
|
|
203
|
+
|
|
204
|
+
// (optional) keep a ref if you want to dispose on unmount
|
|
205
|
+
container._numberingDDB = ddb;
|
|
206
|
+
};
|
|
56
207
|
_react.default.useEffect(() => {
|
|
57
|
-
let toolbarItems = ["Undo", "Redo", "Separator", {
|
|
208
|
+
let toolbarItems = props.commentsOnly ? ["Comments"] : ["Undo", "Redo", "Separator", {
|
|
209
|
+
id: 'bullets',
|
|
210
|
+
text: '• Bullets',
|
|
211
|
+
tooltipText: 'Bulleted list'
|
|
212
|
+
}, "Separator", {
|
|
58
213
|
tooltipText: 'Bold',
|
|
59
214
|
prefixIcon: 'e-icons e-bold',
|
|
60
215
|
command: 'Bold'
|
|
@@ -87,6 +242,14 @@ const WordDocumentViewer = props => {
|
|
|
87
242
|
}));
|
|
88
243
|
}
|
|
89
244
|
}, [props.file]);
|
|
245
|
+
_react.default.useEffect(() => {
|
|
246
|
+
if (reRendering) {
|
|
247
|
+
const timer = window.setTimeout(() => {
|
|
248
|
+
setVisible(true);
|
|
249
|
+
}, 1_000);
|
|
250
|
+
return () => window.clearTimeout(timer);
|
|
251
|
+
}
|
|
252
|
+
}, [reRendering]);
|
|
90
253
|
function setupContainer() {
|
|
91
254
|
container.documentEditor.currentUser = _ApplicationManager.default.getUserDetails().name + " " + _ApplicationManager.default.getUserDetails().surname;
|
|
92
255
|
}
|
|
@@ -144,12 +307,39 @@ const WordDocumentViewer = props => {
|
|
|
144
307
|
//container.documentEditor.isReadOnly = (props.readOnly || props.commentsOnly);
|
|
145
308
|
}
|
|
146
309
|
}, [json, container]);
|
|
310
|
+
const onToolbarClick = args => {
|
|
311
|
+
const ed = container?.documentEditor?.editor;
|
|
312
|
+
if (!ed) return;
|
|
313
|
+
switch (args.item.id) {
|
|
314
|
+
case 'bullets':
|
|
315
|
+
ed.applyBullet('\uf0b7', 'Symbol'); // •
|
|
316
|
+
break;
|
|
317
|
+
case 'numbering':
|
|
318
|
+
ed.applyNumbering('%1.', 'Arabic'); // 1.
|
|
319
|
+
break;
|
|
320
|
+
case 'level-0':
|
|
321
|
+
applyLevel(ed, 0);
|
|
322
|
+
break;
|
|
323
|
+
case 'level-1':
|
|
324
|
+
applyLevel(ed, 1);
|
|
325
|
+
break;
|
|
326
|
+
case 'level-2':
|
|
327
|
+
applyLevel(ed, 2);
|
|
328
|
+
break;
|
|
329
|
+
case 'clear-list':
|
|
330
|
+
ed.clearList();
|
|
331
|
+
break;
|
|
332
|
+
default:
|
|
333
|
+
// let built-ins (Undo/Redo/New/Open) work normally
|
|
334
|
+
}
|
|
335
|
+
};
|
|
147
336
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
148
337
|
className: 'no-margin no-padding',
|
|
149
338
|
style: {
|
|
150
339
|
height: '100%'
|
|
151
340
|
},
|
|
152
|
-
id: `parent-container
|
|
341
|
+
id: `parent-container`,
|
|
342
|
+
ref: ref
|
|
153
343
|
}, !visible && /*#__PURE__*/_react.default.createElement("div", {
|
|
154
344
|
style: {
|
|
155
345
|
height: '100%',
|
|
@@ -178,7 +368,7 @@ const WordDocumentViewer = props => {
|
|
|
178
368
|
style: {
|
|
179
369
|
color: 'rgba(255, 255, 255, 0.8)'
|
|
180
370
|
}
|
|
181
|
-
}, errorMessage))), items && (_Utils.default.isNull(props.trackChanges) || props.trackChanges === true) && /*#__PURE__*/_react.default.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
|
|
371
|
+
}, errorMessage))), visible && items && (_Utils.default.isNull(props.trackChanges) || props.trackChanges === true) && /*#__PURE__*/_react.default.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
|
|
182
372
|
id: `${props.id}-container`,
|
|
183
373
|
height: '690px',
|
|
184
374
|
ref: scope => {
|
|
@@ -191,13 +381,14 @@ const WordDocumentViewer = props => {
|
|
|
191
381
|
}
|
|
192
382
|
},
|
|
193
383
|
enablePersistence: false,
|
|
384
|
+
toolbarClick: onToolbarClick,
|
|
194
385
|
toolbarItems: items,
|
|
195
|
-
restrictEditing: props.readOnly,
|
|
386
|
+
restrictEditing: props.readOnly && !props.commentsOnly,
|
|
196
387
|
showPropertiesPane: false,
|
|
197
388
|
enableTrackChanges: true,
|
|
198
389
|
serviceUrl: DOCSVC,
|
|
199
|
-
enableToolbar: !
|
|
200
|
-
}), items && props.trackChanges === false && /*#__PURE__*/_react.default.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
|
|
390
|
+
enableToolbar: !props.readOnly || props.commentsOnly
|
|
391
|
+
}), visible && items && props.trackChanges === false && /*#__PURE__*/_react.default.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
|
|
201
392
|
id: `${props.id}-container`,
|
|
202
393
|
height: '690px',
|
|
203
394
|
ref: scope => {
|
|
@@ -210,11 +401,12 @@ const WordDocumentViewer = props => {
|
|
|
210
401
|
}
|
|
211
402
|
},
|
|
212
403
|
enablePersistence: false,
|
|
404
|
+
toolbarClick: onToolbarClick,
|
|
213
405
|
toolbarItems: items,
|
|
214
|
-
restrictEditing: props.readOnly,
|
|
406
|
+
restrictEditing: props.readOnly && !props.commentsOnly,
|
|
215
407
|
showPropertiesPane: false,
|
|
216
408
|
serviceUrl: DOCSVC,
|
|
217
|
-
enableToolbar: !
|
|
409
|
+
enableToolbar: !props.readOnly || props.commentsOnly
|
|
218
410
|
}));
|
|
219
411
|
};
|
|
220
412
|
var _default = exports.default = WordDocumentViewer;
|
|
@@ -62,7 +62,10 @@ function CustomInput(props) {
|
|
|
62
62
|
minLength: inputProps && inputProps.minLength ? inputProps.minLength : undefined
|
|
63
63
|
};
|
|
64
64
|
return /*#__PURE__*/_react.default.createElement(_FormControl.default, _extends({}, formControlProps, {
|
|
65
|
-
className: formControlClasses
|
|
65
|
+
className: formControlClasses,
|
|
66
|
+
style: {
|
|
67
|
+
marginTop: '20px'
|
|
68
|
+
}
|
|
66
69
|
}), labelText !== undefined ? /*#__PURE__*/_react.default.createElement(_InputLabel.default, _extends({
|
|
67
70
|
className: classes.labelRoot + " " + labelClasses,
|
|
68
71
|
htmlFor: id
|