@apia/components 4.0.41 → 4.0.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.
- package/dist/index.d.ts +21 -12
- package/dist/index.js +573 -545
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import React__default, { createContext, useContext, useEffect, useMemo, useState
|
|
|
4
4
|
import parse, { domToReact, Element } from 'html-react-parser';
|
|
5
5
|
import { Spinner as Spinner$1, Box as Box$1 } from 'theme-ui';
|
|
6
6
|
import { uniqueId as uniqueId$3, cloneDeep, isFunction } from 'lodash-es';
|
|
7
|
-
import { Box, getVariant, useBreakpointIndex, Close, responsive, spacing, Heading, Link, Button, Spinner, createElement, Select, Input, Flex, IconButton as IconButton$1, Image, injectStyles,
|
|
7
|
+
import { Box, getVariant, useBreakpointIndex, Close, responsive, spacing, Heading, Link, Button, Spinner, createElement, Select, Input, Flex, IconButton as IconButton$1, Image, injectStyles, Paragraph, Label as Label$1, Container, Progress, Form, focusOutline, makeStyledComponent, useThemeUI, Grid, Textarea } from '@apia/theme';
|
|
8
8
|
import { BarLoader } from 'react-spinners';
|
|
9
9
|
import uniqueId$2 from 'lodash-es/uniqueId';
|
|
10
|
-
import { findScrollContainer, useUpdateEffect, focus, focusSelector, getFocusSelector, addBoundary, useCombinedRefs, usePrevious, getLabel, isChild, EventEmitter, useUnmount, useMount, StatefulEmitter, shallowEqual as shallowEqual$1, getSpecificParent, getDateFormat, customEvents, uniqueId as uniqueId$4,
|
|
10
|
+
import { findScrollContainer, useUpdateEffect, focus, focusSelector, getFocusSelector, addBoundary, useCombinedRefs, usePrevious, getLabel, isChild, EventEmitter, useUnmount, useMount, StatefulEmitter, shallowEqual as shallowEqual$1, getSpecificParent, getDateFormat, customEvents, decodeBase64ToUtf8, uniqueId as uniqueId$4, AudioRecorder, persistentStorage, disableChildrenFocus, enableChildrenFocus, decodeHTMLEntities, useDebouncedCallback, getIndex, noNaN, useLatest, useSubscription, useMatchScrollDirection, arrayOrArray } from '@apia/util';
|
|
11
11
|
import usePortal from 'react-cool-portal';
|
|
12
12
|
import { CSSTransition } from 'react-transition-group';
|
|
13
13
|
import { uniqueId as uniqueId$1, defaultNotifier, NotificationsList } from '@apia/notifications';
|
|
@@ -930,6 +930,8 @@ const WindowModal = forwardRef(
|
|
|
930
930
|
const handleMouseDown = (ev) => {
|
|
931
931
|
if (ev.target.closest?.(
|
|
932
932
|
'[draggable="true"]'
|
|
933
|
+
) || !ev.target.closest?.(
|
|
934
|
+
".modal__header"
|
|
933
935
|
))
|
|
934
936
|
return;
|
|
935
937
|
if (ev.target.closest(
|
|
@@ -985,7 +987,7 @@ const WindowModal = forwardRef(
|
|
|
985
987
|
};
|
|
986
988
|
}
|
|
987
989
|
},
|
|
988
|
-
[onDragStart, setStyle]
|
|
990
|
+
[dragBounded, onDragStart, setStyle]
|
|
989
991
|
),
|
|
990
992
|
children: [
|
|
991
993
|
!noHeader && /* @__PURE__ */ jsx(
|
|
@@ -1180,6 +1182,7 @@ const Overlay = React.forwardRef(
|
|
|
1180
1182
|
);
|
|
1181
1183
|
Overlay.displayName = "Overlay";
|
|
1182
1184
|
|
|
1185
|
+
let canCloseOnClick = true;
|
|
1183
1186
|
const StaticModal = forwardRef(
|
|
1184
1187
|
({
|
|
1185
1188
|
animationDuration = 150,
|
|
@@ -1234,11 +1237,12 @@ const StaticModal = forwardRef(
|
|
|
1234
1237
|
}
|
|
1235
1238
|
);
|
|
1236
1239
|
const overlayClickedHandle = (event) => {
|
|
1237
|
-
if (shouldCloseOnOverlayClick) {
|
|
1240
|
+
if (shouldCloseOnOverlayClick && canCloseOnClick) {
|
|
1238
1241
|
if (event.target.getAttribute("data-type") === "overlay") {
|
|
1239
1242
|
closeHandler();
|
|
1240
1243
|
}
|
|
1241
1244
|
}
|
|
1245
|
+
canCloseOnClick = true;
|
|
1242
1246
|
};
|
|
1243
1247
|
useEscapeKey({ closeHandler, id: innerId, isOpenInner, shouldCloseOnEsc });
|
|
1244
1248
|
useInitialFocus({
|
|
@@ -1253,6 +1257,8 @@ const StaticModal = forwardRef(
|
|
|
1253
1257
|
return Portal ?? React__default.Fragment;
|
|
1254
1258
|
}, []);
|
|
1255
1259
|
const nodeRef = useRef(null);
|
|
1260
|
+
const uns = useRef(() => {
|
|
1261
|
+
});
|
|
1256
1262
|
return /* @__PURE__ */ jsx(
|
|
1257
1263
|
ModalContext.Provider,
|
|
1258
1264
|
{
|
|
@@ -1290,7 +1296,17 @@ const StaticModal = forwardRef(
|
|
|
1290
1296
|
children: /* @__PURE__ */ jsx(
|
|
1291
1297
|
Box,
|
|
1292
1298
|
{
|
|
1293
|
-
ref:
|
|
1299
|
+
ref: (el) => {
|
|
1300
|
+
nodeRef.current = el;
|
|
1301
|
+
uns.current();
|
|
1302
|
+
if (el) {
|
|
1303
|
+
const handleMouseDown = () => {
|
|
1304
|
+
canCloseOnClick = false;
|
|
1305
|
+
};
|
|
1306
|
+
el.addEventListener("mousedown", handleMouseDown);
|
|
1307
|
+
uns.current = () => el.removeEventListener("mousedown", handleMouseDown);
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1294
1310
|
className: "modal__variantWrapper",
|
|
1295
1311
|
...variant ? getVariant(variant) : {},
|
|
1296
1312
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -1444,7 +1460,7 @@ var __privateWrapper$2 = (obj, member, setter, getter) => ({
|
|
|
1444
1460
|
return __privateGet$9(obj, member, getter);
|
|
1445
1461
|
}
|
|
1446
1462
|
});
|
|
1447
|
-
var _maxId$1, _maxOverlay;
|
|
1463
|
+
var _maxId$1, _maxOverlay, _innerClose;
|
|
1448
1464
|
class ApiaUtilModalHandler {
|
|
1449
1465
|
constructor(close) {
|
|
1450
1466
|
this.close = close;
|
|
@@ -1456,6 +1472,9 @@ class ApiaUtilModals {
|
|
|
1456
1472
|
__publicField$q(this, "modals", []);
|
|
1457
1473
|
__privateAdd$c(this, _maxId$1, 0);
|
|
1458
1474
|
__privateAdd$c(this, _maxOverlay, 0);
|
|
1475
|
+
__privateAdd$c(this, _innerClose, (id) => {
|
|
1476
|
+
this.modals = this.modals.filter((s) => s.id !== id);
|
|
1477
|
+
});
|
|
1459
1478
|
__publicField$q(this, "Component", observer(() => {
|
|
1460
1479
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1461
1480
|
this.modals.map((current) => /* @__PURE__ */ jsx(OpenModal, { ...current }, current.id)),
|
|
@@ -1472,7 +1491,12 @@ class ApiaUtilModals {
|
|
|
1472
1491
|
});
|
|
1473
1492
|
}
|
|
1474
1493
|
close(id) {
|
|
1475
|
-
|
|
1494
|
+
const modal = this.modals.find((s) => s.id === id);
|
|
1495
|
+
if (modal) {
|
|
1496
|
+
modal.onClose?.();
|
|
1497
|
+
modal.onExited?.();
|
|
1498
|
+
}
|
|
1499
|
+
__privateGet$9(this, _innerClose).call(this, id);
|
|
1476
1500
|
}
|
|
1477
1501
|
open(props) {
|
|
1478
1502
|
const id = props.id ?? `modal_${__privateWrapper$2(this, _maxId$1)._++}`;
|
|
@@ -1483,7 +1507,7 @@ class ApiaUtilModals {
|
|
|
1483
1507
|
onClose: props.onClose,
|
|
1484
1508
|
onExited: () => {
|
|
1485
1509
|
props.onExited?.();
|
|
1486
|
-
this.
|
|
1510
|
+
__privateGet$9(this, _innerClose).call(this, id);
|
|
1487
1511
|
}
|
|
1488
1512
|
});
|
|
1489
1513
|
return new ApiaUtilModalHandler(() => {
|
|
@@ -1531,6 +1555,7 @@ class ApiaUtilModals {
|
|
|
1531
1555
|
}
|
|
1532
1556
|
_maxId$1 = new WeakMap();
|
|
1533
1557
|
_maxOverlay = new WeakMap();
|
|
1558
|
+
_innerClose = new WeakMap();
|
|
1534
1559
|
|
|
1535
1560
|
var __defProp$p = Object.defineProperty;
|
|
1536
1561
|
var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -5230,485 +5255,79 @@ const LabelBox = ({
|
|
|
5230
5255
|
);
|
|
5231
5256
|
};
|
|
5232
5257
|
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
}
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
if (messageType === "response")
|
|
5257
|
-
this.messageType = "system";
|
|
5258
|
-
if (typeof message === "string")
|
|
5259
|
-
this.message = message;
|
|
5260
|
-
makeObservable(this, {
|
|
5261
|
-
attachments: observable,
|
|
5262
|
-
message: observable,
|
|
5263
|
-
messageType: observable,
|
|
5264
|
-
reference: observable
|
|
5258
|
+
function importComponent(path) {
|
|
5259
|
+
return lazy(() => {
|
|
5260
|
+
return new Promise((resolve) => {
|
|
5261
|
+
import(
|
|
5262
|
+
/* webpackInclude: /\.tsx?$/ */
|
|
5263
|
+
`/customComponents/${path}`
|
|
5264
|
+
).then((result) => {
|
|
5265
|
+
if (result?.default?.default)
|
|
5266
|
+
resolve(result.default);
|
|
5267
|
+
else if (result?.default)
|
|
5268
|
+
resolve(result);
|
|
5269
|
+
else
|
|
5270
|
+
resolve({
|
|
5271
|
+
default: () => /* @__PURE__ */ jsx(Fragment, { children: "Something went wrong when importing component" })
|
|
5272
|
+
});
|
|
5273
|
+
}).catch((error) => {
|
|
5274
|
+
resolve({
|
|
5275
|
+
default: () => {
|
|
5276
|
+
console.error(error);
|
|
5277
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "Error" });
|
|
5278
|
+
}
|
|
5279
|
+
});
|
|
5280
|
+
});
|
|
5265
5281
|
});
|
|
5266
|
-
}
|
|
5267
|
-
removeAttachment(attachment) {
|
|
5268
|
-
this.attachments = this.attachments.filter(
|
|
5269
|
-
(current) => current !== attachment
|
|
5270
|
-
);
|
|
5271
|
-
}
|
|
5272
|
-
addAttachmentDescription(attachment, description) {
|
|
5273
|
-
const a = this.attachments.find((current) => current === attachment);
|
|
5274
|
-
if (a) {
|
|
5275
|
-
a.description = description;
|
|
5276
|
-
}
|
|
5277
|
-
}
|
|
5282
|
+
});
|
|
5278
5283
|
}
|
|
5279
5284
|
|
|
5280
|
-
const
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
const isNearBottom = () => scrollEl.scrollHeight - (scrollEl.scrollTop + scrollEl.clientHeight) <= threshold;
|
|
5289
|
-
const onWheel = (e) => {
|
|
5290
|
-
if (e.deltaY < 0) {
|
|
5291
|
-
autoScrollEnabled.current = false;
|
|
5292
|
-
} else if (e.deltaY > 0 && isNearBottom()) {
|
|
5293
|
-
autoScrollEnabled.current = true;
|
|
5294
|
-
}
|
|
5295
|
-
};
|
|
5296
|
-
const onScroll = () => {
|
|
5297
|
-
if (isNearBottom()) {
|
|
5298
|
-
autoScrollEnabled.current = true;
|
|
5299
|
-
}
|
|
5300
|
-
};
|
|
5301
|
-
function enable() {
|
|
5302
|
-
autoScrollEnabled.current = true;
|
|
5303
|
-
}
|
|
5304
|
-
scrollEl.addEventListener("wheel", onWheel, { passive: true });
|
|
5305
|
-
scrollEl.addEventListener("scroll", onScroll, { passive: true });
|
|
5306
|
-
document.addEventListener("enableAutoScroll", enable);
|
|
5307
|
-
scrollEl.scrollTo({ top: scrollEl.scrollHeight, behavior: "smooth" });
|
|
5308
|
-
const mo = new MutationObserver(() => {
|
|
5309
|
-
if (autoScrollEnabled.current) {
|
|
5310
|
-
scrollEl.scrollTo({ top: scrollEl.scrollHeight, behavior: "smooth" });
|
|
5311
|
-
}
|
|
5312
|
-
});
|
|
5313
|
-
mo.observe(wrapper, { childList: true, subtree: true });
|
|
5314
|
-
return () => {
|
|
5315
|
-
scrollEl.removeEventListener("wheel", onWheel);
|
|
5316
|
-
scrollEl.removeEventListener("enableAutoScroll", enable);
|
|
5317
|
-
scrollEl.removeEventListener("scroll", onScroll);
|
|
5318
|
-
mo.disconnect();
|
|
5319
|
-
};
|
|
5320
|
-
}, [threshold]);
|
|
5321
|
-
return /* @__PURE__ */ jsx("div", { ref: wrapperRef, className: `${className || ""} autoscrollContainer`, children });
|
|
5285
|
+
const MessageBlock = ({
|
|
5286
|
+
componentData
|
|
5287
|
+
}) => {
|
|
5288
|
+
if (typeof componentData.args === "string") {
|
|
5289
|
+
componentData.args = JSON.parse(componentData.args);
|
|
5290
|
+
}
|
|
5291
|
+
const Component = importComponent(componentData.path);
|
|
5292
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Component, { ...componentData.args }) });
|
|
5322
5293
|
};
|
|
5294
|
+
var MessageBlock$1 = memo(MessageBlock);
|
|
5323
5295
|
|
|
5324
|
-
const
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
const [isDragOver, setIsDragOver] = useState(false);
|
|
5338
|
-
return /* @__PURE__ */ createElement(
|
|
5339
|
-
Box,
|
|
5340
|
-
{
|
|
5341
|
-
...getVariant("layout.common.components.fileCard"),
|
|
5342
|
-
sx: {
|
|
5343
|
-
...sx,
|
|
5344
|
-
width,
|
|
5345
|
-
...isDragOver && onDropFiles ? {
|
|
5346
|
-
border: "2px dashed #1976d2!important",
|
|
5347
|
-
backgroundColor: "#f5faff!important"
|
|
5348
|
-
} : {}
|
|
5349
|
-
},
|
|
5350
|
-
ref,
|
|
5351
|
-
key: name,
|
|
5352
|
-
className: `fileCard ${className ?? ""}`,
|
|
5353
|
-
onDoubleClick,
|
|
5354
|
-
onClick,
|
|
5355
|
-
title: name,
|
|
5356
|
-
tabIndex: 0,
|
|
5357
|
-
onDragOver: (e) => {
|
|
5358
|
-
e.preventDefault();
|
|
5359
|
-
e.stopPropagation();
|
|
5360
|
-
setIsDragOver(true);
|
|
5361
|
-
},
|
|
5362
|
-
onDragLeave: (e) => {
|
|
5363
|
-
e.preventDefault();
|
|
5364
|
-
e.stopPropagation();
|
|
5365
|
-
setIsDragOver(false);
|
|
5366
|
-
},
|
|
5367
|
-
onDrop: (e) => {
|
|
5368
|
-
e.preventDefault();
|
|
5369
|
-
e.stopPropagation();
|
|
5370
|
-
setIsDragOver(false);
|
|
5371
|
-
if (onDropFiles && e.dataTransfer?.files?.length) {
|
|
5372
|
-
const files = Array.from(e.dataTransfer.files);
|
|
5373
|
-
onDropFiles(files);
|
|
5374
|
-
}
|
|
5375
|
-
}
|
|
5376
|
-
},
|
|
5377
|
-
/* @__PURE__ */ jsxs(Box, { className: "fileCard__content", children: [
|
|
5378
|
-
/* @__PURE__ */ jsx(FileIcon, { docName: name, iconSize: iconsSize }),
|
|
5379
|
-
/* @__PURE__ */ jsx(Box, { as: "span", className: "fileCard__name", children: name })
|
|
5380
|
-
] }),
|
|
5381
|
-
/* @__PURE__ */ jsx(Box, { className: "fileCard__additionalButtons", children: additionalButtons?.map((c) => {
|
|
5382
|
-
return /* @__PURE__ */ jsx(
|
|
5383
|
-
IconButton,
|
|
5296
|
+
const AttributeParsers = [
|
|
5297
|
+
/**
|
|
5298
|
+
* Allows to pass javascript event handlers through the format
|
|
5299
|
+
* onEventDispatched, the main difficulty is that the html parser returns the
|
|
5300
|
+
* attributes with lowercase, that's why any attribute of the type
|
|
5301
|
+
* onEventDispatched will be passed to the component as onEventdispatched
|
|
5302
|
+
* (note the lowercase 'd').
|
|
5303
|
+
*/
|
|
5304
|
+
{
|
|
5305
|
+
match: /^(?:data-)?on(.*)$/i,
|
|
5306
|
+
parse([, originalAction], value) {
|
|
5307
|
+
if (value.match(/^__contextMethod/))
|
|
5308
|
+
return [
|
|
5384
5309
|
{
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5310
|
+
newName: `on${originalAction[0].toUpperCase()}${originalAction.slice(
|
|
5311
|
+
1
|
|
5312
|
+
)}`,
|
|
5313
|
+
newValue: value
|
|
5388
5314
|
}
|
|
5389
|
-
|
|
5390
|
-
})
|
|
5391
|
-
|
|
5392
|
-
|
|
5315
|
+
];
|
|
5316
|
+
let newName = `on${originalAction.charAt(0).toUpperCase()}${originalAction.slice(1)}`;
|
|
5317
|
+
const composedEvent = originalAction.match(/^(mouse|key|double)(.*)$/i);
|
|
5318
|
+
if (composedEvent) {
|
|
5319
|
+
newName = `on${composedEvent[1].charAt(0).toUpperCase()}${composedEvent[1].slice(1)}${composedEvent[2].charAt(0).toUpperCase()}${composedEvent[2].slice(1)}`;
|
|
5320
|
+
}
|
|
5321
|
+
return [
|
|
5393
5322
|
{
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
handleClose(name);
|
|
5323
|
+
newName,
|
|
5324
|
+
newValue: (ev) => {
|
|
5325
|
+
const evalString = value.replace(/return [^;\n\r]+/, "");
|
|
5326
|
+
const f = eval(evalString);
|
|
5327
|
+
f(ev);
|
|
5400
5328
|
}
|
|
5401
5329
|
}
|
|
5402
|
-
|
|
5403
|
-
);
|
|
5404
|
-
}
|
|
5405
|
-
);
|
|
5406
|
-
|
|
5407
|
-
const Dropzone = ({
|
|
5408
|
-
sx,
|
|
5409
|
-
className,
|
|
5410
|
-
messageError,
|
|
5411
|
-
progress = 0,
|
|
5412
|
-
defaultLabel = getLabel("btnUploadClass").text,
|
|
5413
|
-
draggingLabel = getLabel("lblDroping").text,
|
|
5414
|
-
onClick,
|
|
5415
|
-
onChange,
|
|
5416
|
-
handleInfoButton
|
|
5417
|
-
}) => {
|
|
5418
|
-
const innerSx = messageError ? { borderLeft: "2px solid", borderColor: "danger" } : {};
|
|
5419
|
-
const fileInputRef = useRef(null);
|
|
5420
|
-
const handleClick = (ev) => {
|
|
5421
|
-
onClick?.(ev);
|
|
5422
|
-
if (!ev.defaultPrevented) {
|
|
5423
|
-
fileInputRef.current?.click();
|
|
5424
|
-
}
|
|
5425
|
-
};
|
|
5426
|
-
const handleDragOver = (e) => {
|
|
5427
|
-
e.preventDefault();
|
|
5428
|
-
};
|
|
5429
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
5430
|
-
const handleDragStart = (_e) => {
|
|
5431
|
-
setIsDragging(true);
|
|
5432
|
-
};
|
|
5433
|
-
const handleDragLeave = (e) => {
|
|
5434
|
-
e.preventDefault();
|
|
5435
|
-
setIsDragging(false);
|
|
5436
|
-
};
|
|
5437
|
-
return /* @__PURE__ */ jsxs(
|
|
5438
|
-
Box,
|
|
5439
|
-
{
|
|
5440
|
-
...getVariant("layout.execution.components.uploader.dropzone"),
|
|
5441
|
-
className: "dropzone__container",
|
|
5442
|
-
children: [
|
|
5443
|
-
/* @__PURE__ */ jsxs(
|
|
5444
|
-
Box,
|
|
5445
|
-
{
|
|
5446
|
-
tabIndex: 0,
|
|
5447
|
-
sx: { ...innerSx, sx },
|
|
5448
|
-
className: `dropzone ${className ?? ""}`,
|
|
5449
|
-
onClick: handleClick,
|
|
5450
|
-
onKeyDown: (ev) => {
|
|
5451
|
-
if (ev.code === "Enter" || ev.code === "Space") {
|
|
5452
|
-
handleClick(ev);
|
|
5453
|
-
}
|
|
5454
|
-
},
|
|
5455
|
-
onDrop: (e) => {
|
|
5456
|
-
e.preventDefault();
|
|
5457
|
-
const newFiles = Array.from(e.dataTransfer.files);
|
|
5458
|
-
setIsDragging(false);
|
|
5459
|
-
onChange?.(newFiles);
|
|
5460
|
-
},
|
|
5461
|
-
onDragEnter: handleDragStart,
|
|
5462
|
-
onDragLeave: handleDragLeave,
|
|
5463
|
-
onDragOver: handleDragOver,
|
|
5464
|
-
children: [
|
|
5465
|
-
progress > 0 && progress < 100 && /* @__PURE__ */ jsx(Progress, { max: 100, value: progress, className: "progressBar" }),
|
|
5466
|
-
messageError ? /* @__PURE__ */ jsx(Box, { color: "danger", children: messageError }) : isDragging ? draggingLabel : defaultLabel,
|
|
5467
|
-
/* @__PURE__ */ jsx(
|
|
5468
|
-
"input",
|
|
5469
|
-
{
|
|
5470
|
-
multiple: true,
|
|
5471
|
-
type: "file",
|
|
5472
|
-
ref: fileInputRef,
|
|
5473
|
-
style: { display: "none" },
|
|
5474
|
-
onChange: (e) => {
|
|
5475
|
-
e.preventDefault();
|
|
5476
|
-
if (e.target.files) {
|
|
5477
|
-
const newFiles = Array.from([...e.target.files]);
|
|
5478
|
-
onChange?.(newFiles);
|
|
5479
|
-
e.target.value = "";
|
|
5480
|
-
}
|
|
5481
|
-
}
|
|
5482
|
-
}
|
|
5483
|
-
)
|
|
5484
|
-
]
|
|
5485
|
-
}
|
|
5486
|
-
),
|
|
5487
|
-
handleInfoButton && /* @__PURE__ */ jsx(
|
|
5488
|
-
IconButton,
|
|
5489
|
-
{
|
|
5490
|
-
className: "info",
|
|
5491
|
-
iconSize: "Sm",
|
|
5492
|
-
icon: "Info",
|
|
5493
|
-
onMouseEnter: handleInfoButton,
|
|
5494
|
-
onClick: handleClick
|
|
5495
|
-
}
|
|
5496
|
-
)
|
|
5497
|
-
]
|
|
5498
|
-
}
|
|
5499
|
-
);
|
|
5500
|
-
};
|
|
5501
|
-
|
|
5502
|
-
var __defProp$e = Object.defineProperty;
|
|
5503
|
-
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5504
|
-
var __publicField$e = (obj, key, value) => {
|
|
5505
|
-
__defNormalProp$e(obj, key + "" , value);
|
|
5506
|
-
return value;
|
|
5507
|
-
};
|
|
5508
|
-
class UploadHandler {
|
|
5509
|
-
constructor(props) {
|
|
5510
|
-
this.props = props;
|
|
5511
|
-
__publicField$e(this, "state", { inProgressFiles: [], uploadedFiles: [] });
|
|
5512
|
-
makeAutoObservable(this);
|
|
5513
|
-
this.state.uploadedFiles = this.props.initialFiles;
|
|
5514
|
-
}
|
|
5515
|
-
delete(file) {
|
|
5516
|
-
this.props.onDelete(file).then((res) => {
|
|
5517
|
-
if (res === true) {
|
|
5518
|
-
this.state.uploadedFiles = this.state.uploadedFiles.filter(
|
|
5519
|
-
(c) => c !== file
|
|
5520
|
-
);
|
|
5521
|
-
} else if (typeof res === "string") {
|
|
5522
|
-
ApiaUtil.instance.notifications.notify({
|
|
5523
|
-
message: res
|
|
5524
|
-
});
|
|
5525
|
-
}
|
|
5526
|
-
});
|
|
5527
|
-
}
|
|
5528
|
-
start(files) {
|
|
5529
|
-
files.forEach((file) => {
|
|
5530
|
-
const newUpload = {
|
|
5531
|
-
abortController: new AbortController(),
|
|
5532
|
-
id: uniqueId$4("file_upload"),
|
|
5533
|
-
file,
|
|
5534
|
-
progress: 0
|
|
5535
|
-
};
|
|
5536
|
-
this.state.inProgressFiles.push(newUpload);
|
|
5537
|
-
this.props.onUpload(newUpload).then((res) => {
|
|
5538
|
-
this.state.inProgressFiles = this.state.inProgressFiles.filter(
|
|
5539
|
-
(c) => c.id !== newUpload.id
|
|
5540
|
-
);
|
|
5541
|
-
if (typeof res === "string") {
|
|
5542
|
-
ApiaUtil.instance.notifications.notify({
|
|
5543
|
-
message: res,
|
|
5544
|
-
icon: ""
|
|
5545
|
-
});
|
|
5546
|
-
} else if (res) {
|
|
5547
|
-
this.state.uploadedFiles.push(res);
|
|
5548
|
-
}
|
|
5549
|
-
});
|
|
5550
|
-
});
|
|
5551
|
-
}
|
|
5552
|
-
}
|
|
5553
|
-
const Uploader = observer(({ handler }) => {
|
|
5554
|
-
return /* @__PURE__ */ jsxs(Box, { className: "file_uploader", children: [
|
|
5555
|
-
/* @__PURE__ */ jsx(Box, { className: "file_uploader__dropzone", children: (handler.props.isMultiple || handler.state.uploadedFiles.length === 0 && handler.state.inProgressFiles.length === 0) && /* @__PURE__ */ jsx(
|
|
5556
|
-
Dropzone,
|
|
5557
|
-
{
|
|
5558
|
-
onChange: (ev) => {
|
|
5559
|
-
handler.start(ev);
|
|
5560
|
-
}
|
|
5561
|
-
}
|
|
5562
|
-
) }),
|
|
5563
|
-
/* @__PURE__ */ jsx(Box, { className: "file_uploader__in_progress", children: handler.state.inProgressFiles.map((c) => /* @__PURE__ */ jsx(
|
|
5564
|
-
Dropzone,
|
|
5565
|
-
{
|
|
5566
|
-
progress: c.progress,
|
|
5567
|
-
messageError: c.error
|
|
5568
|
-
},
|
|
5569
|
-
c.file.name
|
|
5570
|
-
)) }),
|
|
5571
|
-
/* @__PURE__ */ jsx(Box, { className: "file_uploader__files_list", children: handler.state.uploadedFiles.map((c) => /* @__PURE__ */ jsx(
|
|
5572
|
-
FileCard,
|
|
5573
|
-
{
|
|
5574
|
-
name: c.name,
|
|
5575
|
-
handleClose: () => handler.delete(c)
|
|
5576
|
-
},
|
|
5577
|
-
c.id
|
|
5578
|
-
)) })
|
|
5579
|
-
] });
|
|
5580
|
-
});
|
|
5581
|
-
|
|
5582
|
-
const FileAttachment = observer(
|
|
5583
|
-
({
|
|
5584
|
-
attachment,
|
|
5585
|
-
onAddDescription,
|
|
5586
|
-
onRemove
|
|
5587
|
-
}) => {
|
|
5588
|
-
const { ref } = ApiaUtil.instance.tooltips.useHover({
|
|
5589
|
-
preferredOrientationX: "left",
|
|
5590
|
-
preferredOrientationY: "top",
|
|
5591
|
-
minSize: {
|
|
5592
|
-
width: 200,
|
|
5593
|
-
height: 400
|
|
5594
|
-
},
|
|
5595
|
-
attachToMousePosition: true,
|
|
5596
|
-
closeOnMouseLeaveAttachedElement: true,
|
|
5597
|
-
children: /* @__PURE__ */ jsxs(
|
|
5598
|
-
Box,
|
|
5599
|
-
{
|
|
5600
|
-
sx: {
|
|
5601
|
-
display: "flex",
|
|
5602
|
-
alignItems: "center",
|
|
5603
|
-
flexDirection: "column"
|
|
5604
|
-
},
|
|
5605
|
-
children: [
|
|
5606
|
-
/* @__PURE__ */ jsx("h1", { children: attachment.name }),
|
|
5607
|
-
/* @__PURE__ */ jsx("img", { src: attachment.base64 }),
|
|
5608
|
-
attachment.description && /* @__PURE__ */ jsx(Label$1, { children: attachment.description })
|
|
5609
|
-
]
|
|
5610
|
-
}
|
|
5611
|
-
)
|
|
5612
|
-
});
|
|
5613
|
-
return /* @__PURE__ */ jsx(
|
|
5614
|
-
FileCard,
|
|
5615
|
-
{
|
|
5616
|
-
ref,
|
|
5617
|
-
name: attachment.name,
|
|
5618
|
-
handleClose: onRemove,
|
|
5619
|
-
additionalButtons: onAddDescription ? [
|
|
5620
|
-
{
|
|
5621
|
-
icon: "Pencil",
|
|
5622
|
-
onClick: () => {
|
|
5623
|
-
const collector = new Collector();
|
|
5624
|
-
collector.add(
|
|
5625
|
-
new collector.fields.textarea(
|
|
5626
|
-
"desc",
|
|
5627
|
-
getLabel("lblDesc").text,
|
|
5628
|
-
{ initialValue: attachment.description }
|
|
5629
|
-
)
|
|
5630
|
-
);
|
|
5631
|
-
collector.show({
|
|
5632
|
-
onConfirm: (ev) => {
|
|
5633
|
-
if (ev) {
|
|
5634
|
-
onAddDescription(attachment, ev.desc);
|
|
5635
|
-
}
|
|
5636
|
-
return true;
|
|
5637
|
-
},
|
|
5638
|
-
title: getLabel("btnAddComment").text
|
|
5639
|
-
});
|
|
5640
|
-
},
|
|
5641
|
-
variant: "icon-only"
|
|
5642
|
-
}
|
|
5643
|
-
] : []
|
|
5644
|
-
}
|
|
5645
|
-
);
|
|
5646
|
-
}
|
|
5647
|
-
);
|
|
5648
|
-
|
|
5649
|
-
const Attachments = observer(
|
|
5650
|
-
({
|
|
5651
|
-
attachments,
|
|
5652
|
-
onRemove,
|
|
5653
|
-
onAddDescription,
|
|
5654
|
-
className
|
|
5655
|
-
}) => {
|
|
5656
|
-
if (!attachments.length)
|
|
5657
|
-
return null;
|
|
5658
|
-
return /* @__PURE__ */ jsx(
|
|
5659
|
-
Box,
|
|
5660
|
-
{
|
|
5661
|
-
className: `attachments ${className}`,
|
|
5662
|
-
...getVariant("layout.common.chat.attachments"),
|
|
5663
|
-
children: attachments.map((x) => /* @__PURE__ */ jsx(
|
|
5664
|
-
FileAttachment,
|
|
5665
|
-
{
|
|
5666
|
-
attachment: x,
|
|
5667
|
-
onRemove: onRemove ? () => onRemove(x) : void 0,
|
|
5668
|
-
onAddDescription
|
|
5669
|
-
},
|
|
5670
|
-
x.id
|
|
5671
|
-
))
|
|
5672
|
-
}
|
|
5673
|
-
);
|
|
5674
|
-
}
|
|
5675
|
-
);
|
|
5676
|
-
|
|
5677
|
-
const AttributeParsers = [
|
|
5678
|
-
/**
|
|
5679
|
-
* Allows to pass javascript event handlers through the format
|
|
5680
|
-
* onEventDispatched, the main difficulty is that the html parser returns the
|
|
5681
|
-
* attributes with lowercase, that's why any attribute of the type
|
|
5682
|
-
* onEventDispatched will be passed to the component as onEventdispatched
|
|
5683
|
-
* (note the lowercase 'd').
|
|
5684
|
-
*/
|
|
5685
|
-
{
|
|
5686
|
-
match: /^(?:data-)?on(.*)$/i,
|
|
5687
|
-
parse([, originalAction], value) {
|
|
5688
|
-
if (value.match(/^__contextMethod/))
|
|
5689
|
-
return [
|
|
5690
|
-
{
|
|
5691
|
-
newName: `on${originalAction[0].toUpperCase()}${originalAction.slice(
|
|
5692
|
-
1
|
|
5693
|
-
)}`,
|
|
5694
|
-
newValue: value
|
|
5695
|
-
}
|
|
5696
|
-
];
|
|
5697
|
-
let newName = `on${originalAction.charAt(0).toUpperCase()}${originalAction.slice(1)}`;
|
|
5698
|
-
const composedEvent = originalAction.match(/^(mouse|key|double)(.*)$/i);
|
|
5699
|
-
if (composedEvent) {
|
|
5700
|
-
newName = `on${composedEvent[1].charAt(0).toUpperCase()}${composedEvent[1].slice(1)}${composedEvent[2].charAt(0).toUpperCase()}${composedEvent[2].slice(1)}`;
|
|
5701
|
-
}
|
|
5702
|
-
return [
|
|
5703
|
-
{
|
|
5704
|
-
newName,
|
|
5705
|
-
newValue: (ev) => {
|
|
5706
|
-
const evalString = value.replace(/return [^;\n\r]+/, "");
|
|
5707
|
-
const f = eval(evalString);
|
|
5708
|
-
f(ev);
|
|
5709
|
-
}
|
|
5710
|
-
}
|
|
5711
|
-
];
|
|
5330
|
+
];
|
|
5712
5331
|
}
|
|
5713
5332
|
},
|
|
5714
5333
|
{
|
|
@@ -5980,10 +5599,10 @@ const CommentsParsers = [
|
|
|
5980
5599
|
}
|
|
5981
5600
|
];
|
|
5982
5601
|
|
|
5983
|
-
var __defProp$
|
|
5984
|
-
var __defNormalProp$
|
|
5985
|
-
var __publicField$
|
|
5986
|
-
__defNormalProp$
|
|
5602
|
+
var __defProp$f = Object.defineProperty;
|
|
5603
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5604
|
+
var __publicField$f = (obj, key, value) => {
|
|
5605
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5987
5606
|
return value;
|
|
5988
5607
|
};
|
|
5989
5608
|
var __accessCheck$4 = (obj, member, msg) => {
|
|
@@ -6181,8 +5800,8 @@ const parseOptions = (customOptions, commentsData) => {
|
|
|
6181
5800
|
};
|
|
6182
5801
|
const _Templater = class _Templater {
|
|
6183
5802
|
constructor() {
|
|
6184
|
-
__publicField$
|
|
6185
|
-
__publicField$
|
|
5803
|
+
__publicField$f(this, "isDownloadingTemplate", false);
|
|
5804
|
+
__publicField$f(this, "templates", {});
|
|
6186
5805
|
__privateAdd$4(this, _actuallyParse, (html, options) => {
|
|
6187
5806
|
let actualHTML = html;
|
|
6188
5807
|
if (window.onPreParseTemplate) {
|
|
@@ -6327,71 +5946,477 @@ const _Templater = class _Templater {
|
|
|
6327
5946
|
return __privateGet$2(this, _actuallyParse).call(this, this.parseContent("parseStringTemplate", content2, options?.props), parseOptions(options));
|
|
6328
5947
|
}
|
|
6329
5948
|
};
|
|
6330
|
-
_actuallyParse = new WeakMap();
|
|
6331
|
-
__publicField$
|
|
6332
|
-
let Templater = _Templater;
|
|
5949
|
+
_actuallyParse = new WeakMap();
|
|
5950
|
+
__publicField$f(_Templater, "_instance", null);
|
|
5951
|
+
let Templater = _Templater;
|
|
5952
|
+
|
|
5953
|
+
const MDRenderer = ({ str }) => {
|
|
5954
|
+
return /* @__PURE__ */ jsx(Box, { ...getVariant("layout.common.markdown"), children: Templater.instance.parseString(
|
|
5955
|
+
new Remarkable({ linkTarget: "_blank" }).render(str)
|
|
5956
|
+
) });
|
|
5957
|
+
};
|
|
5958
|
+
var MDRenderer$1 = memo(MDRenderer);
|
|
5959
|
+
|
|
5960
|
+
const MessageBlocks = ({ str }) => {
|
|
5961
|
+
const parts = str.split(/(!!\[[^]+])/g).map((c, i) => {
|
|
5962
|
+
if (c.match(/^!!\[[^]+]$/)) {
|
|
5963
|
+
const definition = JSON.parse(
|
|
5964
|
+
decodeBase64ToUtf8(
|
|
5965
|
+
(c.match(/^!!\[([^]+)]$/) ?? [void 0, void 0])[1] ?? ""
|
|
5966
|
+
)
|
|
5967
|
+
);
|
|
5968
|
+
return /* @__PURE__ */ jsx(MessageBlock$1, { componentData: definition }, i);
|
|
5969
|
+
} else {
|
|
5970
|
+
return /* @__PURE__ */ jsx(MDRenderer$1, { str: c }, i);
|
|
5971
|
+
}
|
|
5972
|
+
});
|
|
5973
|
+
return parts;
|
|
5974
|
+
};
|
|
5975
|
+
var MessageBlocks$1 = memo(MessageBlocks);
|
|
5976
|
+
|
|
5977
|
+
var __defProp$e = Object.defineProperty;
|
|
5978
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5979
|
+
var __publicField$e = (obj, key, value) => {
|
|
5980
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5981
|
+
return value;
|
|
5982
|
+
};
|
|
5983
|
+
let maxId = 0;
|
|
5984
|
+
class ChatMessage {
|
|
5985
|
+
constructor(message = "", messageType = "user", attachments = [], reference = null) {
|
|
5986
|
+
this.message = message;
|
|
5987
|
+
this.messageType = messageType;
|
|
5988
|
+
this.attachments = attachments;
|
|
5989
|
+
this.reference = reference;
|
|
5990
|
+
__publicField$e(this, "id");
|
|
5991
|
+
__publicField$e(this, "clone", () => new ChatMessage(
|
|
5992
|
+
this.message,
|
|
5993
|
+
this.messageType,
|
|
5994
|
+
this.attachments.map((x) => {
|
|
5995
|
+
return { ...x };
|
|
5996
|
+
}),
|
|
5997
|
+
this.reference
|
|
5998
|
+
));
|
|
5999
|
+
this.id = maxId++;
|
|
6000
|
+
if (messageType === "response")
|
|
6001
|
+
this.messageType = "system";
|
|
6002
|
+
if (typeof message === "string")
|
|
6003
|
+
this.message = message;
|
|
6004
|
+
makeObservable(this, {
|
|
6005
|
+
attachments: observable,
|
|
6006
|
+
message: observable,
|
|
6007
|
+
messageType: observable,
|
|
6008
|
+
reference: observable
|
|
6009
|
+
});
|
|
6010
|
+
}
|
|
6011
|
+
removeAttachment(attachment) {
|
|
6012
|
+
this.attachments = this.attachments.filter(
|
|
6013
|
+
(current) => current !== attachment
|
|
6014
|
+
);
|
|
6015
|
+
}
|
|
6016
|
+
addAttachmentDescription(attachment, description) {
|
|
6017
|
+
const a = this.attachments.find((current) => current === attachment);
|
|
6018
|
+
if (a) {
|
|
6019
|
+
a.description = description;
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
|
|
6024
|
+
const AutoscrollContainer = ({ children, threshold = 150, className }) => {
|
|
6025
|
+
const wrapperRef = useRef(null);
|
|
6026
|
+
const autoScrollEnabled = useRef(true);
|
|
6027
|
+
useEffect(() => {
|
|
6028
|
+
const wrapper = wrapperRef.current;
|
|
6029
|
+
if (!wrapper)
|
|
6030
|
+
return;
|
|
6031
|
+
const scrollEl = findScrollContainer(wrapper);
|
|
6032
|
+
const isNearBottom = () => scrollEl.scrollHeight - (scrollEl.scrollTop + scrollEl.clientHeight) <= threshold;
|
|
6033
|
+
const onWheel = (e) => {
|
|
6034
|
+
if (e.deltaY < 0) {
|
|
6035
|
+
autoScrollEnabled.current = false;
|
|
6036
|
+
} else if (e.deltaY > 0 && isNearBottom()) {
|
|
6037
|
+
autoScrollEnabled.current = true;
|
|
6038
|
+
}
|
|
6039
|
+
};
|
|
6040
|
+
const onScroll = () => {
|
|
6041
|
+
if (isNearBottom()) {
|
|
6042
|
+
autoScrollEnabled.current = true;
|
|
6043
|
+
}
|
|
6044
|
+
};
|
|
6045
|
+
function enable() {
|
|
6046
|
+
autoScrollEnabled.current = true;
|
|
6047
|
+
}
|
|
6048
|
+
scrollEl.addEventListener("wheel", onWheel, { passive: true });
|
|
6049
|
+
scrollEl.addEventListener("scroll", onScroll, { passive: true });
|
|
6050
|
+
document.addEventListener("enableAutoScroll", enable);
|
|
6051
|
+
scrollEl.scrollTo({ top: scrollEl.scrollHeight, behavior: "smooth" });
|
|
6052
|
+
const mo = new MutationObserver(() => {
|
|
6053
|
+
if (autoScrollEnabled.current) {
|
|
6054
|
+
scrollEl.scrollTo({ top: scrollEl.scrollHeight, behavior: "smooth" });
|
|
6055
|
+
}
|
|
6056
|
+
});
|
|
6057
|
+
mo.observe(wrapper, { childList: true, subtree: true });
|
|
6058
|
+
return () => {
|
|
6059
|
+
scrollEl.removeEventListener("wheel", onWheel);
|
|
6060
|
+
scrollEl.removeEventListener("enableAutoScroll", enable);
|
|
6061
|
+
scrollEl.removeEventListener("scroll", onScroll);
|
|
6062
|
+
mo.disconnect();
|
|
6063
|
+
};
|
|
6064
|
+
}, [threshold]);
|
|
6065
|
+
return /* @__PURE__ */ jsx("div", { ref: wrapperRef, className: `${className || ""} autoscrollContainer`, children });
|
|
6066
|
+
};
|
|
6067
|
+
|
|
6068
|
+
const FileCard = forwardRef(
|
|
6069
|
+
({
|
|
6070
|
+
name,
|
|
6071
|
+
iconsSize,
|
|
6072
|
+
additionalButtons,
|
|
6073
|
+
className,
|
|
6074
|
+
sx,
|
|
6075
|
+
width = "fit-content",
|
|
6076
|
+
handleClose,
|
|
6077
|
+
onDoubleClick,
|
|
6078
|
+
onClick,
|
|
6079
|
+
onDropFiles
|
|
6080
|
+
}, ref) => {
|
|
6081
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
6082
|
+
return /* @__PURE__ */ createElement(
|
|
6083
|
+
Box,
|
|
6084
|
+
{
|
|
6085
|
+
...getVariant("layout.common.components.fileCard"),
|
|
6086
|
+
sx: {
|
|
6087
|
+
...sx,
|
|
6088
|
+
width,
|
|
6089
|
+
...isDragOver && onDropFiles ? {
|
|
6090
|
+
border: "2px dashed #1976d2!important",
|
|
6091
|
+
backgroundColor: "#f5faff!important"
|
|
6092
|
+
} : {}
|
|
6093
|
+
},
|
|
6094
|
+
ref,
|
|
6095
|
+
key: name,
|
|
6096
|
+
className: `fileCard ${className ?? ""}`,
|
|
6097
|
+
onDoubleClick,
|
|
6098
|
+
onClick,
|
|
6099
|
+
title: name,
|
|
6100
|
+
tabIndex: 0,
|
|
6101
|
+
onDragOver: (e) => {
|
|
6102
|
+
e.preventDefault();
|
|
6103
|
+
e.stopPropagation();
|
|
6104
|
+
setIsDragOver(true);
|
|
6105
|
+
},
|
|
6106
|
+
onDragLeave: (e) => {
|
|
6107
|
+
e.preventDefault();
|
|
6108
|
+
e.stopPropagation();
|
|
6109
|
+
setIsDragOver(false);
|
|
6110
|
+
},
|
|
6111
|
+
onDrop: (e) => {
|
|
6112
|
+
e.preventDefault();
|
|
6113
|
+
e.stopPropagation();
|
|
6114
|
+
setIsDragOver(false);
|
|
6115
|
+
if (onDropFiles && e.dataTransfer?.files?.length) {
|
|
6116
|
+
const files = Array.from(e.dataTransfer.files);
|
|
6117
|
+
onDropFiles(files);
|
|
6118
|
+
}
|
|
6119
|
+
}
|
|
6120
|
+
},
|
|
6121
|
+
/* @__PURE__ */ jsxs(Box, { className: "fileCard__content", children: [
|
|
6122
|
+
/* @__PURE__ */ jsx(FileIcon, { docName: name, iconSize: iconsSize }),
|
|
6123
|
+
/* @__PURE__ */ jsx(Box, { as: "span", className: "fileCard__name", children: name })
|
|
6124
|
+
] }),
|
|
6125
|
+
/* @__PURE__ */ jsx(Box, { className: "fileCard__additionalButtons", children: additionalButtons?.map((c) => {
|
|
6126
|
+
return /* @__PURE__ */ jsx(
|
|
6127
|
+
IconButton,
|
|
6128
|
+
{
|
|
6129
|
+
iconSize: "Md",
|
|
6130
|
+
...c,
|
|
6131
|
+
className: `fileCard__additionalButton ${c.className ?? ""}`
|
|
6132
|
+
}
|
|
6133
|
+
);
|
|
6134
|
+
}) }),
|
|
6135
|
+
handleClose && /* @__PURE__ */ jsx(
|
|
6136
|
+
Close,
|
|
6137
|
+
{
|
|
6138
|
+
type: "button",
|
|
6139
|
+
className: "fileCard__delete",
|
|
6140
|
+
onClick: (e) => {
|
|
6141
|
+
e.stopPropagation();
|
|
6142
|
+
e.preventDefault();
|
|
6143
|
+
handleClose(name);
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
)
|
|
6147
|
+
);
|
|
6148
|
+
}
|
|
6149
|
+
);
|
|
6150
|
+
|
|
6151
|
+
const Dropzone = ({
|
|
6152
|
+
sx,
|
|
6153
|
+
className,
|
|
6154
|
+
messageError,
|
|
6155
|
+
progress = 0,
|
|
6156
|
+
defaultLabel = getLabel("btnUploadClass").text,
|
|
6157
|
+
draggingLabel = getLabel("lblDroping").text,
|
|
6158
|
+
onClick,
|
|
6159
|
+
onChange,
|
|
6160
|
+
handleInfoButton
|
|
6161
|
+
}) => {
|
|
6162
|
+
const innerSx = messageError ? { borderLeft: "2px solid", borderColor: "danger" } : {};
|
|
6163
|
+
const fileInputRef = useRef(null);
|
|
6164
|
+
const handleClick = (ev) => {
|
|
6165
|
+
onClick?.(ev);
|
|
6166
|
+
if (!ev.defaultPrevented) {
|
|
6167
|
+
fileInputRef.current?.click();
|
|
6168
|
+
}
|
|
6169
|
+
};
|
|
6170
|
+
const handleDragOver = (e) => {
|
|
6171
|
+
e.preventDefault();
|
|
6172
|
+
};
|
|
6173
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
6174
|
+
const handleDragStart = (_e) => {
|
|
6175
|
+
setIsDragging(true);
|
|
6176
|
+
};
|
|
6177
|
+
const handleDragLeave = (e) => {
|
|
6178
|
+
e.preventDefault();
|
|
6179
|
+
setIsDragging(false);
|
|
6180
|
+
};
|
|
6181
|
+
return /* @__PURE__ */ jsxs(
|
|
6182
|
+
Box,
|
|
6183
|
+
{
|
|
6184
|
+
...getVariant("layout.execution.components.uploader.dropzone"),
|
|
6185
|
+
className: "dropzone__container",
|
|
6186
|
+
children: [
|
|
6187
|
+
/* @__PURE__ */ jsxs(
|
|
6188
|
+
Box,
|
|
6189
|
+
{
|
|
6190
|
+
tabIndex: 0,
|
|
6191
|
+
sx: { ...innerSx, sx },
|
|
6192
|
+
className: `dropzone ${className ?? ""}`,
|
|
6193
|
+
onClick: handleClick,
|
|
6194
|
+
onKeyDown: (ev) => {
|
|
6195
|
+
if (ev.code === "Enter" || ev.code === "Space") {
|
|
6196
|
+
handleClick(ev);
|
|
6197
|
+
}
|
|
6198
|
+
},
|
|
6199
|
+
onDrop: (e) => {
|
|
6200
|
+
e.preventDefault();
|
|
6201
|
+
const newFiles = Array.from(e.dataTransfer.files);
|
|
6202
|
+
setIsDragging(false);
|
|
6203
|
+
onChange?.(newFiles);
|
|
6204
|
+
},
|
|
6205
|
+
onDragEnter: handleDragStart,
|
|
6206
|
+
onDragLeave: handleDragLeave,
|
|
6207
|
+
onDragOver: handleDragOver,
|
|
6208
|
+
children: [
|
|
6209
|
+
progress > 0 && progress < 100 && /* @__PURE__ */ jsx(Progress, { max: 100, value: progress, className: "progressBar" }),
|
|
6210
|
+
messageError ? /* @__PURE__ */ jsx(Box, { color: "danger", children: messageError }) : isDragging ? draggingLabel : defaultLabel,
|
|
6211
|
+
/* @__PURE__ */ jsx(
|
|
6212
|
+
"input",
|
|
6213
|
+
{
|
|
6214
|
+
multiple: true,
|
|
6215
|
+
type: "file",
|
|
6216
|
+
ref: fileInputRef,
|
|
6217
|
+
style: { display: "none" },
|
|
6218
|
+
onChange: (e) => {
|
|
6219
|
+
e.preventDefault();
|
|
6220
|
+
if (e.target.files) {
|
|
6221
|
+
const newFiles = Array.from([...e.target.files]);
|
|
6222
|
+
onChange?.(newFiles);
|
|
6223
|
+
e.target.value = "";
|
|
6224
|
+
}
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
)
|
|
6228
|
+
]
|
|
6229
|
+
}
|
|
6230
|
+
),
|
|
6231
|
+
handleInfoButton && /* @__PURE__ */ jsx(
|
|
6232
|
+
IconButton,
|
|
6233
|
+
{
|
|
6234
|
+
className: "info",
|
|
6235
|
+
iconSize: "Sm",
|
|
6236
|
+
icon: "Info",
|
|
6237
|
+
onMouseEnter: handleInfoButton,
|
|
6238
|
+
onClick: handleClick
|
|
6239
|
+
}
|
|
6240
|
+
)
|
|
6241
|
+
]
|
|
6242
|
+
}
|
|
6243
|
+
);
|
|
6244
|
+
};
|
|
6333
6245
|
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6246
|
+
var __defProp$d = Object.defineProperty;
|
|
6247
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6248
|
+
var __publicField$d = (obj, key, value) => {
|
|
6249
|
+
__defNormalProp$d(obj, key + "" , value);
|
|
6250
|
+
return value;
|
|
6338
6251
|
};
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
});
|
|
6356
|
-
}).catch((error) => {
|
|
6357
|
-
resolve({
|
|
6358
|
-
default: () => {
|
|
6359
|
-
console.error(error);
|
|
6360
|
-
return /* @__PURE__ */ jsx(Fragment, { children: "Error" });
|
|
6361
|
-
}
|
|
6252
|
+
class UploadHandler {
|
|
6253
|
+
constructor(props) {
|
|
6254
|
+
this.props = props;
|
|
6255
|
+
__publicField$d(this, "state", { inProgressFiles: [], uploadedFiles: [] });
|
|
6256
|
+
makeAutoObservable(this);
|
|
6257
|
+
this.state.uploadedFiles = this.props.initialFiles;
|
|
6258
|
+
}
|
|
6259
|
+
delete(file) {
|
|
6260
|
+
this.props.onDelete(file).then((res) => {
|
|
6261
|
+
if (res === true) {
|
|
6262
|
+
this.state.uploadedFiles = this.state.uploadedFiles.filter(
|
|
6263
|
+
(c) => c !== file
|
|
6264
|
+
);
|
|
6265
|
+
} else if (typeof res === "string") {
|
|
6266
|
+
ApiaUtil.instance.notifications.notify({
|
|
6267
|
+
message: res
|
|
6362
6268
|
});
|
|
6269
|
+
}
|
|
6270
|
+
});
|
|
6271
|
+
}
|
|
6272
|
+
start(files) {
|
|
6273
|
+
files.forEach((file) => {
|
|
6274
|
+
const newUpload = {
|
|
6275
|
+
abortController: new AbortController(),
|
|
6276
|
+
id: uniqueId$4("file_upload"),
|
|
6277
|
+
file,
|
|
6278
|
+
progress: 0
|
|
6279
|
+
};
|
|
6280
|
+
this.state.inProgressFiles.push(newUpload);
|
|
6281
|
+
this.props.onUpload(newUpload).then((res) => {
|
|
6282
|
+
this.state.inProgressFiles = this.state.inProgressFiles.filter(
|
|
6283
|
+
(c) => c.id !== newUpload.id
|
|
6284
|
+
);
|
|
6285
|
+
if (typeof res === "string") {
|
|
6286
|
+
ApiaUtil.instance.notifications.notify({
|
|
6287
|
+
message: res,
|
|
6288
|
+
icon: ""
|
|
6289
|
+
});
|
|
6290
|
+
} else if (res) {
|
|
6291
|
+
this.state.uploadedFiles.push(res);
|
|
6292
|
+
}
|
|
6363
6293
|
});
|
|
6364
6294
|
});
|
|
6365
|
-
}
|
|
6295
|
+
}
|
|
6366
6296
|
}
|
|
6297
|
+
const Uploader = observer(({ handler }) => {
|
|
6298
|
+
return /* @__PURE__ */ jsxs(Box, { className: "file_uploader", children: [
|
|
6299
|
+
/* @__PURE__ */ jsx(Box, { className: "file_uploader__dropzone", children: (handler.props.isMultiple || handler.state.uploadedFiles.length === 0 && handler.state.inProgressFiles.length === 0) && /* @__PURE__ */ jsx(
|
|
6300
|
+
Dropzone,
|
|
6301
|
+
{
|
|
6302
|
+
onChange: (ev) => {
|
|
6303
|
+
handler.start(ev);
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
) }),
|
|
6307
|
+
/* @__PURE__ */ jsx(Box, { className: "file_uploader__in_progress", children: handler.state.inProgressFiles.map((c) => /* @__PURE__ */ jsx(
|
|
6308
|
+
Dropzone,
|
|
6309
|
+
{
|
|
6310
|
+
progress: c.progress,
|
|
6311
|
+
messageError: c.error
|
|
6312
|
+
},
|
|
6313
|
+
c.file.name
|
|
6314
|
+
)) }),
|
|
6315
|
+
/* @__PURE__ */ jsx(Box, { className: "file_uploader__files_list", children: handler.state.uploadedFiles.map((c) => /* @__PURE__ */ jsx(
|
|
6316
|
+
FileCard,
|
|
6317
|
+
{
|
|
6318
|
+
name: c.name,
|
|
6319
|
+
handleClose: () => handler.delete(c)
|
|
6320
|
+
},
|
|
6321
|
+
c.id
|
|
6322
|
+
)) })
|
|
6323
|
+
] });
|
|
6324
|
+
});
|
|
6367
6325
|
|
|
6368
|
-
const
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6326
|
+
const FileAttachment = observer(
|
|
6327
|
+
({
|
|
6328
|
+
attachment,
|
|
6329
|
+
onAddDescription,
|
|
6330
|
+
onRemove
|
|
6331
|
+
}) => {
|
|
6332
|
+
const { ref } = ApiaUtil.instance.tooltips.useHover({
|
|
6333
|
+
preferredOrientationX: "left",
|
|
6334
|
+
preferredOrientationY: "top",
|
|
6335
|
+
minSize: {
|
|
6336
|
+
width: 200,
|
|
6337
|
+
height: 400
|
|
6338
|
+
},
|
|
6339
|
+
attachToMousePosition: true,
|
|
6340
|
+
closeOnMouseLeaveAttachedElement: true,
|
|
6341
|
+
children: /* @__PURE__ */ jsxs(
|
|
6342
|
+
Box,
|
|
6343
|
+
{
|
|
6344
|
+
sx: {
|
|
6345
|
+
display: "flex",
|
|
6346
|
+
alignItems: "center",
|
|
6347
|
+
flexDirection: "column"
|
|
6348
|
+
},
|
|
6349
|
+
children: [
|
|
6350
|
+
/* @__PURE__ */ jsx("h1", { children: attachment.name }),
|
|
6351
|
+
/* @__PURE__ */ jsx("img", { src: attachment.base64 }),
|
|
6352
|
+
attachment.description && /* @__PURE__ */ jsx(Label$1, { children: attachment.description })
|
|
6353
|
+
]
|
|
6354
|
+
}
|
|
6355
|
+
)
|
|
6356
|
+
});
|
|
6357
|
+
return /* @__PURE__ */ jsx(
|
|
6358
|
+
FileCard,
|
|
6359
|
+
{
|
|
6360
|
+
ref,
|
|
6361
|
+
name: attachment.name,
|
|
6362
|
+
handleClose: onRemove,
|
|
6363
|
+
additionalButtons: onAddDescription ? [
|
|
6364
|
+
{
|
|
6365
|
+
icon: "Pencil",
|
|
6366
|
+
onClick: () => {
|
|
6367
|
+
const collector = new Collector();
|
|
6368
|
+
collector.add(
|
|
6369
|
+
new collector.fields.textarea(
|
|
6370
|
+
"desc",
|
|
6371
|
+
getLabel("lblDes").text,
|
|
6372
|
+
{ initialValue: attachment.description }
|
|
6373
|
+
)
|
|
6374
|
+
);
|
|
6375
|
+
collector.show({
|
|
6376
|
+
onConfirm: (ev) => {
|
|
6377
|
+
if (ev) {
|
|
6378
|
+
onAddDescription(attachment, ev.desc);
|
|
6379
|
+
}
|
|
6380
|
+
return true;
|
|
6381
|
+
},
|
|
6382
|
+
title: getLabel("btnAddComment").text
|
|
6383
|
+
});
|
|
6384
|
+
},
|
|
6385
|
+
variant: "icon-only"
|
|
6386
|
+
}
|
|
6387
|
+
] : []
|
|
6388
|
+
}
|
|
6389
|
+
);
|
|
6373
6390
|
}
|
|
6374
|
-
|
|
6375
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Component, { ...componentData.args }) });
|
|
6376
|
-
};
|
|
6377
|
-
var MessageBlock$1 = memo(MessageBlock);
|
|
6391
|
+
);
|
|
6378
6392
|
|
|
6379
|
-
const
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
return
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6393
|
+
const Attachments = observer(
|
|
6394
|
+
({
|
|
6395
|
+
attachments,
|
|
6396
|
+
onRemove,
|
|
6397
|
+
onAddDescription,
|
|
6398
|
+
className
|
|
6399
|
+
}) => {
|
|
6400
|
+
if (!attachments.length)
|
|
6401
|
+
return null;
|
|
6402
|
+
return /* @__PURE__ */ jsx(
|
|
6403
|
+
Box,
|
|
6404
|
+
{
|
|
6405
|
+
className: `attachments ${className}`,
|
|
6406
|
+
...getVariant("layout.common.chat.attachments"),
|
|
6407
|
+
children: attachments.map((x) => /* @__PURE__ */ jsx(
|
|
6408
|
+
FileAttachment,
|
|
6409
|
+
{
|
|
6410
|
+
attachment: x,
|
|
6411
|
+
onRemove: onRemove ? () => onRemove(x) : void 0,
|
|
6412
|
+
onAddDescription
|
|
6413
|
+
},
|
|
6414
|
+
x.id
|
|
6415
|
+
))
|
|
6416
|
+
}
|
|
6417
|
+
);
|
|
6418
|
+
}
|
|
6419
|
+
);
|
|
6395
6420
|
|
|
6396
6421
|
const Message = observer(
|
|
6397
6422
|
({
|
|
@@ -8302,13 +8327,16 @@ const LinearSpinnerLock = ({ isLocked }) => isLocked ? /* @__PURE__ */ jsx(
|
|
|
8302
8327
|
className: "locker",
|
|
8303
8328
|
style: {
|
|
8304
8329
|
backgroundColor: "rgb(128 128 128 / 0%)",
|
|
8305
|
-
|
|
8330
|
+
top: 0,
|
|
8331
|
+
left: 0,
|
|
8332
|
+
right: 0,
|
|
8333
|
+
bottom: 0,
|
|
8306
8334
|
position: "fixed",
|
|
8307
8335
|
display: "flex",
|
|
8308
8336
|
alignItems: "center",
|
|
8309
8337
|
justifyContent: "center",
|
|
8310
|
-
zIndex:
|
|
8311
|
-
transition: "background-color
|
|
8338
|
+
zIndex: 1200,
|
|
8339
|
+
transition: "background-color 0.25s"
|
|
8312
8340
|
},
|
|
8313
8341
|
ref: (el) => {
|
|
8314
8342
|
if (el instanceof HTMLElement) {
|
|
@@ -8872,7 +8900,7 @@ const DefaultIconRendererNoMemo = (props) => {
|
|
|
8872
8900
|
return /* @__PURE__ */ jsxs(
|
|
8873
8901
|
Box,
|
|
8874
8902
|
{
|
|
8875
|
-
title: String(props.
|
|
8903
|
+
title: String(props.ariaLabel) || props.label,
|
|
8876
8904
|
className: "iconsList__icon__wrapper",
|
|
8877
8905
|
children: [
|
|
8878
8906
|
/* @__PURE__ */ jsxs(Box, { className: "iconsList__icon__image__wrapper", children: [
|
|
@@ -8887,7 +8915,7 @@ const DefaultIconRendererNoMemo = (props) => {
|
|
|
8887
8915
|
),
|
|
8888
8916
|
props.icon && /* @__PURE__ */ jsx(Icon$1, { icon: props.icon, title: props.ariaLabel })
|
|
8889
8917
|
] }),
|
|
8890
|
-
/* @__PURE__ */ jsx(Box, { className: "iconsList__icon__label", children: props.label })
|
|
8918
|
+
/* @__PURE__ */ jsx(Box, { className: "iconsList__icon__label", title: props.ariaLabel, children: props.label })
|
|
8891
8919
|
]
|
|
8892
8920
|
}
|
|
8893
8921
|
);
|
|
@@ -12014,5 +12042,5 @@ const _FiltersStore = class _FiltersStore {
|
|
|
12014
12042
|
__publicField(_FiltersStore, "instance", new _FiltersStore());
|
|
12015
12043
|
let FiltersStore = _FiltersStore;
|
|
12016
12044
|
|
|
12017
|
-
export { Accordion, AccordionAside, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, ApiaUtil, ApiaUtilModalHandler, ApiaUtilTooltip, Aside, AsideLoader, AsidePanel, AutoEllipsis, Autocomplete, AutocompleteController, AutogrowTextarea, AutoscrollContainer, BaseButton, BodyAside, CalendarModal, Captcha, CenteredHeaderButtons, ChatController, ChatMessage, Checkbox$1 as Checkbox, CollapsiblePanel, Confirm, ConfirmModal, ContainerWithHeader, DateInput, DeadSessionModal, DefaultIconRenderer, DefaultTabsLabelRenderer, DialogButtonBar, Dropzone, FavoriteIcon, FieldErrorMessage, FieldLabel, FileCard, FilterConditionDTO, FilterDTO, FiltersStore, FloatingAside, FloatingChatController, FooterButtons, FooterResponsiveButtons, HamburguerMenu, Header, HeaderButtons, IconButton, IconInput, IconsList, Label, LabelBox, LinearLoader, LinearSpinnerLock, ListSkeletonLoader, Listbox, ListboxItem, LoaderSpinner, MDRenderer$1 as MDRenderer, Modal, NumberInput, Overlay, Pagination, Parameter, ParameterRender, Parameters, ParametersGroup, ParametersStore, ParametersTable, ProgressBar, RequiredMark, ScreenLocker, ShowResponsive, SimpleButton, SortableList, SortableListItem, Tab, Tabs, TabsContent, TabsController, TabsList, Templater, Toolbar, ToolbarController, ToolbarIconButton, ToolbarInput, ToolbarSelect, ToolbarSeparator, ToolbarTextButton, UnstyledSortableList, UploadHandler, Uploader, WaiTypeAhead, getBase64FromBlob, getBase64FromFile, getFieldErrorStyles, getFieldTouchedStyles, getFileExtension, importComponent, isFavoriteIcon, isImage, isParametersGroup, makeResponsiveComponent, menuController, parseNumberInputValueToNumber, parseNumberValueToNumberInput, useAccordionContext, useCurrentTab, useMenu, useModal, useModalContext, useOtherTagButton, useTabsContext };
|
|
12045
|
+
export { Accordion, AccordionAside, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, ApiaUtil, ApiaUtilModalHandler, ApiaUtilTooltip, Aside, AsideLoader, AsidePanel, AutoEllipsis, Autocomplete, AutocompleteController, AutogrowTextarea, AutoscrollContainer, BaseButton, BodyAside, CalendarModal, Captcha, CenteredHeaderButtons, ChatController, ChatMessage, Checkbox$1 as Checkbox, CollapsiblePanel, Confirm, ConfirmModal, ContainerWithHeader, DateInput, DeadSessionModal, DefaultIconRenderer, DefaultTabsLabelRenderer, DialogButtonBar, Dropzone, FavoriteIcon, FieldErrorMessage, FieldLabel, FileCard, FilterConditionDTO, FilterDTO, FiltersStore, FloatingAside, FloatingChatController, FooterButtons, FooterResponsiveButtons, HamburguerMenu, Header, HeaderButtons, IconButton, IconInput, IconsList, Label, LabelBox, LinearLoader, LinearSpinnerLock, ListSkeletonLoader, Listbox, ListboxItem, LoaderSpinner, MDRenderer$1 as MDRenderer, MessageBlock$1 as MessageBlock, MessageBlocks$1 as MessageBlocks, Modal, ModalContext, NumberInput, Overlay, Pagination, Parameter, ParameterRender, Parameters, ParametersGroup, ParametersStore, ParametersTable, ProgressBar, RequiredMark, ScreenLocker, ShowResponsive, SimpleButton, SortableList, SortableListItem, Tab, Tabs, TabsContent, TabsController, TabsList, Templater, Toolbar, ToolbarController, ToolbarIconButton, ToolbarInput, ToolbarSelect, ToolbarSeparator, ToolbarTextButton, UnstyledSortableList, UploadHandler, Uploader, WaiTypeAhead, getBase64FromBlob, getBase64FromFile, getFieldErrorStyles, getFieldTouchedStyles, getFileExtension, importComponent, isFavoriteIcon, isImage, isParametersGroup, makeResponsiveComponent, menuController, parseNumberInputValueToNumber, parseNumberValueToNumberInput, useAccordionContext, useCurrentTab, useMenu, useModal, useModalContext, useOtherTagButton, useTabsContext };
|
|
12018
12046
|
//# sourceMappingURL=index.js.map
|