@cayuse-test/react 1.0.8 → 1.0.10
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/{chunk-M2L7SQBQ.js → chunk-6DB5M6WN.js} +3 -3
- package/dist/chunk-6DB5M6WN.js.map +1 -0
- package/dist/{chunk-SYDHZCBD.js → chunk-RJUCILWA.js} +48 -46
- package/dist/chunk-RJUCILWA.js.map +1 -0
- package/dist/{chunk-BVB7EXJY.js → chunk-XVA4YFXM.js} +2 -2
- package/dist/chunk-XVA4YFXM.js.map +1 -0
- package/dist/components/index.css +11 -19
- package/dist/components/index.css.map +1 -1
- package/dist/components/index.js +3 -3
- package/dist/hooks/index.js +1 -1
- package/dist/index.css +11 -19
- package/dist/index.css.map +1 -1
- package/dist/index.js +3 -3
- package/dist/services/upload-s3/index.d.ts +2 -2
- package/dist/services/upload-s3/index.js +1 -1
- package/package.json +13 -16
- package/dist/chunk-BVB7EXJY.js.map +0 -1
- package/dist/chunk-M2L7SQBQ.js.map +0 -1
- package/dist/chunk-SYDHZCBD.js.map +0 -1
|
@@ -11,7 +11,7 @@ var UploadError = class extends Error {
|
|
|
11
11
|
this.stack = e?.stack;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
var
|
|
14
|
+
var serviceDefaultProps = {
|
|
15
15
|
shouldUseMultipart: (fileSize) => fileSize > 10 * 2 ** 20,
|
|
16
16
|
maxConcurrentUploads: 5,
|
|
17
17
|
request: fetch
|
|
@@ -22,7 +22,7 @@ var throwIfFalse = (condition, message) => {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
var createUploadService = (props) => {
|
|
25
|
-
const options = { ...
|
|
25
|
+
const options = { ...serviceDefaultProps, ...props || {} };
|
|
26
26
|
const limit = pLimit(options.maxConcurrentUploads);
|
|
27
27
|
const calcNumberOfParts = (fileSize) => Math.floor(fileSize / (5 * 2 ** 20));
|
|
28
28
|
const createMultipartPresignedUrls = async (fileName, fileSize) => {
|
|
@@ -202,4 +202,4 @@ export {
|
|
|
202
202
|
createUploadService,
|
|
203
203
|
UploadService
|
|
204
204
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-6DB5M6WN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../packages/services/upload-s3/UploadService.ts"],"sourcesContent":["import pLimit from 'p-limit';\n\nexport class UploadError extends Error {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcause: any;\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tconstructor(message: string, e?: any) {\n\t\tsuper(message);\n\t\tthis.name = 'UploadError';\n\t\tthis.cause = e;\n\t\tthis.stack = e?.stack;\n\t}\n}\n\ntype SimpleUploadData = {\n\tpreSignedUrl: string;\n\tuploadMetadataId: string;\n};\n\ntype UploadData = {\n\tuploadMetadataId: string;\n\tuploadUrls: string[];\n\tuploadId?: string;\n};\n\ntype ETag = {\n\tpartNumber: number;\n\tetagId: string;\n};\n\nexport type UploadMetadataResource = {\n\tid: string;\n\ttenantId: string;\n\tfileName: string;\n\tcreatedAt: Date;\n\tfinalizedAt: Date;\n\tcompletedAt: Date;\n\tuploadedBy: string;\n\tfileSize: number;\n};\n\nexport type ProgressState = {\n\tstatus:\n\t\t| 'ready'\n\t\t| 'preparing'\n\t\t| 'uploading'\n\t\t| 'finalizing'\n\t\t| 'completed'\n\t\t| 'error'\n\t\t| 'cancelled';\n\tuploaded: number;\n\ttotalSize: number;\n\terror?: UploadError;\n};\n\nexport type IUploadService = {\n\tupload: (\n\t\tfile: File,\n\t\tonProgress: (progress: ProgressState) => void,\n\t) => Promise<UploadMetadataResource>;\n\tdownloadUrl: (fileId: string) => Promise<string>;\n\tdownload: (fileId: string, fileName: string) => Promise<void>;\n};\n\nconst serviceDefaultProps = {\n\tshouldUseMultipart: (fileSize: number) => fileSize > 10 * 2 ** 20,\n\tmaxConcurrentUploads: 5,\n\trequest: fetch,\n};\n\nexport type UploadServiceProps = Partial<typeof serviceDefaultProps>;\n\nconst throwIfFalse = (condition: boolean, message: string) => {\n\tif (!condition) {\n\t\tthrow new UploadError(message);\n\t}\n};\n\nexport const createUploadService = (props?: UploadServiceProps): IUploadService => {\n\tconst options = { ...serviceDefaultProps, ...(props || {}) };\n\n\tconst limit = pLimit(options.maxConcurrentUploads);\n\tconst calcNumberOfParts = (fileSize: number) =>\n\t\tMath.floor(fileSize / (5 * 2 ** 20));\n\n\tconst createMultipartPresignedUrls = async (\n\t\tfileName: string,\n\t\tfileSize: number,\n\t): Promise<UploadData> => {\n\t\tconst numberOfParts = calcNumberOfParts(fileSize);\n\n\t\tconst response = await options.request('/api/v2/attachments/multipart/upload', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tbody: JSON.stringify({ fileName, fileSize, numberOfParts }),\n\t\t});\n\n\t\treturn await response.json();\n\t};\n\n\tconst downloadUrl = async (fileId: string): Promise<string> => {\n\t\tconst response = await options.request(\n\t\t\t`/api/v2/attachments/download?uploadMetadataId=${fileId}`,\n\t\t);\n\n\t\treturn response.json();\n\t};\n\n\tconst download = async (fileId: string, fileName: string): Promise<void> => {\n\t\tconst url = await downloadUrl(fileId);\n\t\tconst link = document.createElement('a');\n\t\tlink.href = url;\n\t\tlink.download = fileName;\n\t\tlink.click();\n\t};\n\n\tconst createSinglePresignedUrl = async (\n\t\tfileName: string,\n\t\tfileSize: number,\n\t): Promise<SimpleUploadData> => {\n\t\tconst response = await options.request('/api/v2/attachments/upload', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tbody: JSON.stringify({ fileName, fileSize }),\n\t\t});\n\n\t\treturn await response.json();\n\t};\n\n\tconst preparePart = (blob: Blob, partNumber: number, partSize: number): Blob => {\n\t\tconst start = (partNumber - 1) * partSize;\n\t\tconst end = Math.min(start + partSize, blob.size);\n\n\t\treturn blob.slice(start, end);\n\t};\n\n\tconst uploadPart = async (uploadUrl: string, part: Blob) => {\n\t\tconst response = await fetch(uploadUrl, {\n\t\t\tmethod: 'PUT',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/octet-stream',\n\t\t\t},\n\t\t\tbody: part,\n\t\t});\n\n\t\treturn response.headers.get('ETag');\n\t};\n\n\tconst completeUpload = async (\n\t\tuploadData: UploadData,\n\t\teTags: ETag[],\n\t): Promise<UploadMetadataResource> => {\n\t\tconst handle = async (response: Response) => {\n\t\t\tconst obj = await response.json();\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new UploadError(obj?.message || 'Unknown error occured');\n\t\t\t}\n\n\t\t\treturn obj;\n\t\t};\n\n\t\tif (eTags && eTags.length > 1) {\n\t\t\tconst response = await options.request(\n\t\t\t\t`/api/v2/attachments/multipart/upload/${uploadData.uploadMetadataId}/complete`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tuploadId: uploadData.uploadId,\n\t\t\t\t\t\tetags: eTags,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn await handle(response);\n\t\t}\n\t\tconst response = await options.request(\n\t\t\t`/api/v2/attachments/upload/${uploadData.uploadMetadataId}/complete`,\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t},\n\t\t);\n\n\t\treturn await handle(response);\n\t};\n\n\tconst createPresignedUrls = async (file: File): Promise<UploadData> => {\n\t\tif (options.shouldUseMultipart(file.size)) {\n\t\t\treturn await createMultipartPresignedUrls(file.name, file.size);\n\t\t}\n\t\tconst data = await createSinglePresignedUrl(file.name, file.size);\n\n\t\treturn {\n\t\t\tuploadMetadataId: data.uploadMetadataId,\n\t\t\tuploadUrls: [data.preSignedUrl],\n\t\t};\n\t};\n\n\tconst createState = <T>(\n\t\tinitialState: T,\n\t\tonStateChange: (state: T) => void,\n\t): [T, (s: Partial<T>) => void] => {\n\t\tconst state = {};\n\n\t\tconst setState = (newState: Partial<T>): void => {\n\t\t\tObject.assign(state, newState);\n\t\t\tonStateChange({ ...(state as T) });\n\t\t};\n\n\t\tsetState(initialState); // initial state\n\n\t\treturn [state as T, setState];\n\t};\n\n\tconst uploadFile = async (\n\t\tfile: File,\n\t\tonProgress: (progress: ProgressState) => void,\n\t): Promise<UploadMetadataResource> => {\n\t\tconst initialState: ProgressState = {\n\t\t\tuploaded: 0,\n\t\t\ttotalSize: file.size,\n\t\t\tstatus: 'ready',\n\t\t};\n\t\tconst [state, setState] = createState(initialState, onProgress);\n\n\t\tsetState({ status: 'preparing' });\n\n\t\ttry {\n\t\t\tconst uploadData = await createPresignedUrls(file);\n\t\t\tsetState({ status: 'uploading' });\n\n\t\t\tconst numberOfParts = uploadData.uploadUrls.length;\n\t\t\tconst partSize = Math.ceil(file.size / numberOfParts);\n\n\t\t\t// prepare parts\n\t\t\tconst queuedParts = uploadData.uploadUrls.map((uploadUrl, index) =>\n\t\t\t\tlimit(async () => {\n\t\t\t\t\tconst partNumber = index + 1;\n\t\t\t\t\tconst part = preparePart(file, partNumber, partSize);\n\t\t\t\t\tconst etagId = await uploadPart(uploadUrl, part);\n\t\t\t\t\tsetState({\n\t\t\t\t\t\tuploaded: Math.min(state.uploaded + partSize, state.totalSize),\n\t\t\t\t\t});\n\n\t\t\t\t\treturn { partNumber, etagId };\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tconst results = await Promise.all(queuedParts);\n\n\t\t\tconst parts = results.filter((x) => !!x.etagId) as ETag[];\n\n\t\t\t// complete upload\n\t\t\tconst fileMetadata = await completeUpload(uploadData, parts);\n\t\t\tsetState({ status: 'completed' });\n\n\t\t\treturn fileMetadata;\n\t\t} catch (e) {\n\t\t\tif (e instanceof UploadError) {\n\t\t\t\tsetState({ status: 'error', error: e });\n\t\t\t\tthrow e;\n\t\t\t} else {\n\t\t\t\tconst overrideErr = new UploadError(\n\t\t\t\t\t'An error occurred while uploading the file',\n\t\t\t\t\te,\n\t\t\t\t);\n\t\t\t\tsetState({ status: 'error', error: overrideErr });\n\t\t\t\tthrow overrideErr;\n\t\t\t}\n\t\t}\n\t};\n\n\tconst getFilextension = (filename: string) => {\n\t\tconst parts = filename.toLocaleLowerCase().split('.');\n\t\tif (parts.length === 1) return;\n\t\treturn parts.pop();\n\t};\n\n\tconst upload = (\n\t\tfile: File,\n\t\tonProgress: (progress: ProgressState) => void,\n\t): Promise<UploadMetadataResource> => {\n\t\tthrowIfFalse(file.name.length > 0, 'File name must not be blank');\n\t\tthrowIfFalse(file.size > 0, 'File must not be blank');\n\t\tthrowIfFalse(file.size <= 75 * 2 ** 20, 'File size must be less than 75MB');\n\t\tthrowIfFalse(\n\t\t\tgetFilextension(file.name) !== 'exe',\n\t\t\t'Attachments with filetype .exe cannot be accepted. Please try a different file type.',\n\t\t);\n\n\t\treturn uploadFile(file, onProgress);\n\t};\n\n\treturn {\n\t\tdownloadUrl,\n\t\tdownload,\n\t\tupload,\n\t};\n};\n\nexport const UploadService = createUploadService({\n\trequest: (url, options) => {\n\t\tconst storedToken = localStorage?.getItem('fk_accessToken');\n\n\t\tconst opt = { headers: {}, ...(options ?? {}) };\n\n\t\treturn fetch(url, {\n\t\t\t...opt,\n\t\t\theaders: {\n\t\t\t\t...opt.headers,\n\t\t\t\tAuthorization: `Bearer ${storedToken}`,\n\t\t\t},\n\t\t});\n\t},\n});\n\nexport default UploadService;\n"],"mappings":";AAAA,OAAO,YAAY;AAEZ,IAAM,cAAN,cAA0B,MAAM;AAAA;AAAA,EAEtC;AAAA;AAAA,EAGA,YAAY,SAAiB,GAAS;AACrC,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,QAAQ,GAAG;AAAA,EACjB;AACD;AAoDA,IAAM,sBAAsB;AAAA,EAC3B,oBAAoB,CAAC,aAAqB,WAAW,KAAK,KAAK;AAAA,EAC/D,sBAAsB;AAAA,E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"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MAX_FILE_SIZE_75_MB,
|
|
3
3
|
useClickOutside
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XVA4YFXM.js";
|
|
5
5
|
import {
|
|
6
6
|
capitalizeAndJoin,
|
|
7
7
|
flushStorage,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from "./chunk-MJBMK4OG.js";
|
|
35
35
|
import {
|
|
36
36
|
UploadService
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-6DB5M6WN.js";
|
|
38
38
|
|
|
39
39
|
// packages/components/attachments-form/attachments-form.tsx
|
|
40
40
|
import React10, { useState as useState2, useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo2, useRef } from "react";
|
|
@@ -2326,15 +2326,16 @@ function SelectableCell({
|
|
|
2326
2326
|
row,
|
|
2327
2327
|
isMultiSelect,
|
|
2328
2328
|
onRowSelectionChange,
|
|
2329
|
-
rowAriaLabel
|
|
2329
|
+
rowAriaLabel,
|
|
2330
|
+
tableId
|
|
2330
2331
|
}) {
|
|
2331
2332
|
if (!row._isSelectable) {
|
|
2332
2333
|
return /* @__PURE__ */ jsx34("td", {});
|
|
2333
2334
|
}
|
|
2334
2335
|
const rowLabel = isFunction(rowAriaLabel) ? rowAriaLabel({ row }) : "";
|
|
2335
2336
|
function onSelect(event) {
|
|
2336
|
-
event
|
|
2337
|
-
event
|
|
2337
|
+
event?.preventDefault();
|
|
2338
|
+
event?.stopPropagation();
|
|
2338
2339
|
if (!row._isDisabledForSelection) {
|
|
2339
2340
|
onRowSelectionChange({
|
|
2340
2341
|
rows: [row],
|
|
@@ -2357,7 +2358,7 @@ function SelectableCell({
|
|
|
2357
2358
|
return /* @__PURE__ */ jsx34("td", { className: "dynamic-table__selectable-cell", onClick: onSelect, children: /* @__PURE__ */ jsx34(
|
|
2358
2359
|
Radio,
|
|
2359
2360
|
{
|
|
2360
|
-
name:
|
|
2361
|
+
name: `table-single-select-${tableId}`,
|
|
2361
2362
|
className: "dynamic-table__single-select",
|
|
2362
2363
|
checked: row._isSelected,
|
|
2363
2364
|
onChange: onSelect,
|
|
@@ -2377,6 +2378,7 @@ function SelectableCell({
|
|
|
2377
2378
|
import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2378
2379
|
function RowContent(props) {
|
|
2379
2380
|
const {
|
|
2381
|
+
tableId,
|
|
2380
2382
|
row,
|
|
2381
2383
|
rowIndex,
|
|
2382
2384
|
subRowIndex,
|
|
@@ -2426,6 +2428,7 @@ function RowContent(props) {
|
|
|
2426
2428
|
SelectableCell,
|
|
2427
2429
|
{
|
|
2428
2430
|
row,
|
|
2431
|
+
tableId,
|
|
2429
2432
|
isMultiSelect,
|
|
2430
2433
|
onRowSelectionChange,
|
|
2431
2434
|
rowAriaLabel
|
|
@@ -2456,6 +2459,7 @@ function RowContent(props) {
|
|
|
2456
2459
|
import { Fragment as Fragment4, jsx as jsx36, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2457
2460
|
function TableBodyContent(props) {
|
|
2458
2461
|
const {
|
|
2462
|
+
tableId,
|
|
2459
2463
|
isLoading,
|
|
2460
2464
|
isRefresh,
|
|
2461
2465
|
headers,
|
|
@@ -2488,6 +2492,7 @@ function TableBodyContent(props) {
|
|
|
2488
2492
|
/* @__PURE__ */ jsx36(
|
|
2489
2493
|
RowContent,
|
|
2490
2494
|
{
|
|
2495
|
+
tableId,
|
|
2491
2496
|
headers,
|
|
2492
2497
|
row,
|
|
2493
2498
|
rowIndex,
|
|
@@ -2510,6 +2515,7 @@ function TableBodyContent(props) {
|
|
|
2510
2515
|
/* @__PURE__ */ jsx36(
|
|
2511
2516
|
RowContent,
|
|
2512
2517
|
{
|
|
2518
|
+
tableId,
|
|
2513
2519
|
headers,
|
|
2514
2520
|
row: subRow,
|
|
2515
2521
|
rowIndex,
|
|
@@ -2619,8 +2625,10 @@ var DynamicTable = forwardRef4(
|
|
|
2619
2625
|
children
|
|
2620
2626
|
} = props;
|
|
2621
2627
|
const tableHeaders = headers.filter((h) => isNonEmptyObject(h));
|
|
2622
|
-
const rootRef = useRef4(null);
|
|
2623
2628
|
const captionId = useId3();
|
|
2629
|
+
const tId = useId3();
|
|
2630
|
+
const tableId = id || tId;
|
|
2631
|
+
const rootRef = useRef4(null);
|
|
2624
2632
|
const [expandedRows, setExpandedRows] = useState4([]);
|
|
2625
2633
|
function toggleExpandableRow(event) {
|
|
2626
2634
|
const rowIndex = Number(event.currentTarget.dataset.rowIndex);
|
|
@@ -2715,7 +2723,7 @@ var DynamicTable = forwardRef4(
|
|
|
2715
2723
|
/* @__PURE__ */ jsx38("div", { className: "dynamic-table__wrapper", children: /* @__PURE__ */ jsxs24(
|
|
2716
2724
|
"table",
|
|
2717
2725
|
{
|
|
2718
|
-
id,
|
|
2726
|
+
id: tableId,
|
|
2719
2727
|
className: "dynamic-table",
|
|
2720
2728
|
"data-exapandable": isExpandable,
|
|
2721
2729
|
"data-selectable": isSelectable,
|
|
@@ -2773,6 +2781,7 @@ var DynamicTable = forwardRef4(
|
|
|
2773
2781
|
children: /* @__PURE__ */ jsx38(
|
|
2774
2782
|
TableBodyContent,
|
|
2775
2783
|
{
|
|
2784
|
+
tableId,
|
|
2776
2785
|
rows: tableRows,
|
|
2777
2786
|
headers: tableHeaders,
|
|
2778
2787
|
isLoading,
|
|
@@ -4042,11 +4051,10 @@ function AttachmentsSection({
|
|
|
4042
4051
|
setAttachmentType
|
|
4043
4052
|
}) {
|
|
4044
4053
|
return /* @__PURE__ */ jsxs34("div", { className: "attachments-section", children: [
|
|
4045
|
-
/* @__PURE__ */ jsx53(
|
|
4054
|
+
/* @__PURE__ */ jsx53(
|
|
4046
4055
|
Combobox,
|
|
4047
4056
|
{
|
|
4048
4057
|
label: dictionary.attachmentTypeSelector?.label,
|
|
4049
|
-
className: "attachmentType",
|
|
4050
4058
|
onChange: setAttachmentType,
|
|
4051
4059
|
options: attachmentTypes.filter((attachment2) => attachment2.active).map((attachment2) => ({
|
|
4052
4060
|
value: attachment2.value,
|
|
@@ -4056,7 +4064,7 @@ function AttachmentsSection({
|
|
|
4056
4064
|
isSearchable: true,
|
|
4057
4065
|
value: attachmentType
|
|
4058
4066
|
}
|
|
4059
|
-
)
|
|
4067
|
+
),
|
|
4060
4068
|
/* @__PURE__ */ jsx53("div", { className: "fileUploadWrapper", children: /* @__PURE__ */ jsx53(
|
|
4061
4069
|
MultiFileUpload,
|
|
4062
4070
|
{
|
|
@@ -4298,9 +4306,9 @@ var initialUpdates = {
|
|
|
4298
4306
|
removedAttachments: []
|
|
4299
4307
|
};
|
|
4300
4308
|
var EditNoteModal = ({
|
|
4301
|
-
attachments,
|
|
4302
|
-
attachmentTypes,
|
|
4303
|
-
dictionary,
|
|
4309
|
+
attachments = [],
|
|
4310
|
+
attachmentTypes = [],
|
|
4311
|
+
dictionary = dictionaryDefaults,
|
|
4304
4312
|
note,
|
|
4305
4313
|
isVisible,
|
|
4306
4314
|
onClose,
|
|
@@ -4310,7 +4318,7 @@ var EditNoteModal = ({
|
|
|
4310
4318
|
}) => {
|
|
4311
4319
|
const { message, noteId } = note;
|
|
4312
4320
|
const [attachmentType, setAttachmentType] = useState9(
|
|
4313
|
-
findFirstActiveAttachmentType(attachmentTypes)
|
|
4321
|
+
() => findFirstActiveAttachmentType(attachmentTypes)
|
|
4314
4322
|
);
|
|
4315
4323
|
const [updates, setUpdates] = useState9({
|
|
4316
4324
|
...initialUpdates,
|
|
@@ -4453,13 +4461,6 @@ var EditNoteModal = ({
|
|
|
4453
4461
|
] }) })
|
|
4454
4462
|
] });
|
|
4455
4463
|
};
|
|
4456
|
-
EditNoteModal.defaultProps = {
|
|
4457
|
-
attachments: [],
|
|
4458
|
-
attachmentTypes: [],
|
|
4459
|
-
dictionary: {
|
|
4460
|
-
...dictionaryDefaults
|
|
4461
|
-
}
|
|
4462
|
-
};
|
|
4463
4464
|
|
|
4464
4465
|
// packages/components/form-note-attachments-view/form-note-attachments-view.tsx
|
|
4465
4466
|
import { jsx as jsx56, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
@@ -4545,7 +4546,7 @@ function FormNoteAttachmentsView({
|
|
|
4545
4546
|
const dictionary = merge4({}, baseDictionary3, externalDictionary);
|
|
4546
4547
|
const [newNoteMessage, setNewNoteMessage] = useState10("");
|
|
4547
4548
|
const [attachmentType, setAttachmentType] = useState10(
|
|
4548
|
-
findFirstActiveAttachmentType(attachmentTypes)
|
|
4549
|
+
() => findFirstActiveAttachmentType(attachmentTypes)
|
|
4549
4550
|
);
|
|
4550
4551
|
const [attachments, setAttachments] = useState10([]);
|
|
4551
4552
|
const [reloadItems, setReloadItems] = useState10(true);
|
|
@@ -8952,8 +8953,29 @@ var TableRow2 = (props) => {
|
|
|
8952
8953
|
|
|
8953
8954
|
// packages/components/task-form/comments/table-comment-list.tsx
|
|
8954
8955
|
import { jsx as jsx90, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
8956
|
+
var defaultDictionary10 = {
|
|
8957
|
+
columns: ["Comment History", "Date and Time"],
|
|
8958
|
+
removeCommentButtonLabel: "Remove comment",
|
|
8959
|
+
editCommentButtonLabel: "Edit comment",
|
|
8960
|
+
removeCommentDialog: {
|
|
8961
|
+
title: "Delete your comment?",
|
|
8962
|
+
cancelText: "Cancel",
|
|
8963
|
+
confirmText: "Delete Comment"
|
|
8964
|
+
},
|
|
8965
|
+
cancelCommentEditingDialog: {
|
|
8966
|
+
title: "Discard Changes?",
|
|
8967
|
+
description: "There are unsaved changes. Are you sure you want to discard your changes?",
|
|
8968
|
+
cancelText: "Cancel",
|
|
8969
|
+
confirmText: "Discard Changes"
|
|
8970
|
+
}
|
|
8971
|
+
};
|
|
8955
8972
|
var TableCommentList = (props) => {
|
|
8956
|
-
const {
|
|
8973
|
+
const {
|
|
8974
|
+
comments: comments2 = [],
|
|
8975
|
+
disabled = false,
|
|
8976
|
+
dictionary: d,
|
|
8977
|
+
allowToRemoveByRoles
|
|
8978
|
+
} = props;
|
|
8957
8979
|
const [order, setOrder] = useState28("descending");
|
|
8958
8980
|
const { values } = useFormContext();
|
|
8959
8981
|
if (!comments2 || comments2?.length === 0) {
|
|
@@ -8973,7 +8995,7 @@ var TableCommentList = (props) => {
|
|
|
8973
8995
|
}
|
|
8974
8996
|
return order === "ascending" ? leftCreatedAt - rightCreatedAt : rightCreatedAt - leftCreatedAt;
|
|
8975
8997
|
});
|
|
8976
|
-
const dictionary = merge7({},
|
|
8998
|
+
const dictionary = merge7({}, defaultDictionary10, d);
|
|
8977
8999
|
const recordIdsToRemove = new Set(values.commentsToRemove || []);
|
|
8978
9000
|
return /* @__PURE__ */ jsxs62("table", { className: "ui sortable fixed table table-comment-list", children: [
|
|
8979
9001
|
/* @__PURE__ */ jsx90("thead", { children: /* @__PURE__ */ jsxs62("tr", { children: [
|
|
@@ -9015,26 +9037,6 @@ var TableCommentList = (props) => {
|
|
|
9015
9037
|
})
|
|
9016
9038
|
] });
|
|
9017
9039
|
};
|
|
9018
|
-
TableCommentList.defaultProps = {
|
|
9019
|
-
disabled: false,
|
|
9020
|
-
comments: [],
|
|
9021
|
-
dictionary: {
|
|
9022
|
-
columns: ["Comment History", "Date and Time"],
|
|
9023
|
-
removeCommentButtonLabel: "Remove comment",
|
|
9024
|
-
editCommentButtonLabel: "Edit comment",
|
|
9025
|
-
removeCommentDialog: {
|
|
9026
|
-
title: "Delete your comment?",
|
|
9027
|
-
cancelText: "Cancel",
|
|
9028
|
-
confirmText: "Delete Comment"
|
|
9029
|
-
},
|
|
9030
|
-
cancelCommentEditingDialog: {
|
|
9031
|
-
title: "Discard Changes?",
|
|
9032
|
-
description: "There are unsaved changes. Are you sure you want to discard your changes?",
|
|
9033
|
-
cancelText: "Cancel",
|
|
9034
|
-
confirmText: "Discard Changes"
|
|
9035
|
-
}
|
|
9036
|
-
}
|
|
9037
|
-
};
|
|
9038
9040
|
|
|
9039
9041
|
// packages/components/task-form/comments/comments.tsx
|
|
9040
9042
|
import { jsx as jsx91, jsxs as jsxs63 } from "react/jsx-runtime";
|
|
@@ -10407,4 +10409,4 @@ export {
|
|
|
10407
10409
|
MilestoneProgress2 as MilestoneProgress,
|
|
10408
10410
|
TaskFormHeader
|
|
10409
10411
|
};
|
|
10410
|
-
//# sourceMappingURL=chunk-
|
|
10412
|
+
//# sourceMappingURL=chunk-RJUCILWA.js.map
|