@agilemotion/oui-react-js 1.8.42 → 1.8.43

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.
@@ -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;
@@ -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 = _interopRequireDefault(require("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(false);
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
- _react.default.useLayoutEffect(() => {
51
- const timer = window.setTimeout(() => {
52
- setVisible(true);
53
- }, 1_000);
54
- return () => window.clearTimeout(timer);
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: !(props.readOnly || props.commentsOnly)
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: !(props.readOnly || props.commentsOnly)
409
+ enableToolbar: !props.readOnly || props.commentsOnly
218
410
  }));
219
411
  };
220
412
  var _default = exports.default = WordDocumentViewer;
@@ -15,6 +15,7 @@ var _Toolbar = _interopRequireDefault(require("../Toolbar"));
15
15
  var _Observable = _interopRequireDefault(require("../../event/Observable"));
16
16
  var _DynamicJS = _interopRequireDefault(require("../../DynamicJS"));
17
17
  var _FormHelperText = _interopRequireDefault(require("@mui/material/FormHelperText"));
18
+ var _ApplicationManager = _interopRequireDefault(require("../../ApplicationManager"));
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
20
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
20
21
  function getEditorType(columnName, gridConfig) {
@@ -58,7 +59,8 @@ const GridFieldWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
58
59
  }
59
60
  setCrudToolstripWidth(numCrudButtons * 40 + 'px');
60
61
  try {
61
- let label = _DynamicJS.default.executeScript(props.config.id + 'label', _Utils.default.getComponentAttribute(props.config, 'label', ''), props.config.viewId, true, null, null, false);
62
+ let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
63
+ let label = _ApplicationManager.default.isExpression(parsedConfig.attributes['label']) ? _DynamicJS.default.executeScript(props.config.id + 'label', _Utils.default.getComponentAttribute(parsedConfig, 'label', ''), props.config.viewId, true, null, null, false) : parsedConfig.attributes['label'];
62
64
  setLabel(label);
63
65
  } catch (e) {
64
66
  setLabel(_Utils.default.getComponentAttribute(props.config, 'label', ''));
@@ -13,6 +13,8 @@ var _BaseField = require("./BaseField");
13
13
  var _Utils = _interopRequireDefault(require("../../Utils"));
14
14
  var _FormHelperText = _interopRequireDefault(require("@mui/material/FormHelperText"));
15
15
  var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
16
+ var _DynamicJS = _interopRequireDefault(require("../../DynamicJS"));
17
+ var _ApplicationManager = _interopRequireDefault(require("../../ApplicationManager"));
16
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
19
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
18
20
  const RadioGroupWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
@@ -50,6 +52,7 @@ const RadioGroupWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.d
50
52
  base.handleValueChange(e.target.value);
51
53
  }
52
54
  }, options.map((option, index) => {
55
+ let label = _ApplicationManager.default.isExpression(option.label) ? _DynamicJS.default.executeScript(props.config.id + 'label', option.label, props.config.viewId, true, null, null, false) : option.label;
53
56
  return /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, {
54
57
  key: index,
55
58
  value: option.value,
@@ -57,7 +60,7 @@ const RadioGroupWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.d
57
60
  disabled: base.disabled,
58
61
  checked: option.value === value
59
62
  }),
60
- label: option.label
63
+ label: label
61
64
  });
62
65
  })), base.errorMessage && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, {
63
66
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilemotion/oui-react-js",
3
- "version": "1.8.42",
3
+ "version": "1.8.43",
4
4
  "description": "AgileMotion React UI Component Library - A comprehensive collection of dashboard components, forms, media controls, and more",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -62,6 +62,7 @@
62
62
  "@syncfusion/ej2-react-base": "^26.2.10",
63
63
  "@syncfusion/ej2-react-documenteditor": "^26.2.14",
64
64
  "@syncfusion/ej2-react-popups": "^26.2.11",
65
+ "@syncfusion/ej2-react-splitbuttons": "^31.2.2",
65
66
  "@syncfusion/ej2-splitbuttons": "^26.2.10",
66
67
  "@testing-library/dom": "^10.4.0",
67
68
  "@testing-library/jest-dom": "^6.6.3",
@@ -93,10 +94,10 @@
93
94
  "process": "^0.11.10",
94
95
  "prop-types": "^15.7.2",
95
96
  "react": "^18.3.1",
96
- "react-dom": "^18.3.1",
97
97
  "react-bootstrap": "^1.5.2",
98
98
  "react-bootstrap-switch": "^15.5.3",
99
99
  "react-confirm-alert": "^3.0.6",
100
+ "react-dom": "^18.3.1",
100
101
  "react-draggable": "^4.4.6",
101
102
  "react-feather": "^2.0.10",
102
103
  "react-google-autocomplete": "^2.7.3",