pollination-react-io 1.57.2 → 1.58.1

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.
@@ -12,6 +12,7 @@ export interface FileCardProps {
12
12
  description: string;
13
13
  file?: Blob | File | string | undefined;
14
14
  onClicked?: (card: FileCardProps) => any;
15
+ isCloud?: boolean;
15
16
  }
16
17
  export declare const FileCard: React.FC<FileCardProps>;
17
18
  export default FileCard;
@@ -13,4 +13,5 @@ export interface RunContentProps {
13
13
  style?: CSSProperties;
14
14
  getFileCard?: (card: FileCardProps) => any;
15
15
  getFolderCard?: (card: FolderCardProps) => any;
16
+ isCloud?: boolean;
16
17
  }
@@ -17,9 +17,9 @@ export interface RunDetailsProps {
17
17
  projectOwner: string;
18
18
  projectName: string;
19
19
  run?: Run | LocalRun;
20
- runId?: string;
21
20
  client?: APIClient;
22
21
  style?: CSSProperties;
23
22
  getFileCard?: (card: FileCardProps) => any;
24
23
  getFolderCard?: (card: FolderCardProps) => any;
24
+ isCloud?: boolean;
25
25
  }
@@ -49325,26 +49325,27 @@ var CADtypeEnum;
49325
49325
  })(CADtypeEnum || (CADtypeEnum = {}));
49326
49326
  var FileCard = function (_a) {
49327
49327
  var _b, _c;
49328
- var projectOwner = _a.projectOwner, projectName = _a.projectName, client = _a.client, studyId = _a.studyId, runId = _a.runId, label = _a.label, path = _a.path, file = _a.file, description = _a.description, onClicked = _a.onClicked;
49328
+ var projectOwner = _a.projectOwner, projectName = _a.projectName, client = _a.client, studyId = _a.studyId, runId = _a.runId, label = _a.label, path = _a.path, file = _a.file, description = _a.description, onClicked = _a.onClicked, _d = _a.isCloud, isCloud = _d === void 0 ? true : _d;
49329
49329
  var host = getHost();
49330
- var _d = useState(false), open = _d[0], setOpen = _d[1];
49331
- var _e = useState(false), over = _e[0], setOver = _e[1];
49332
- var _f = useState(true), isLoading = _f[0], setIsLoading = _f[1];
49333
- var _g = useState(false), isInactive = _g[0], setIsInactive = _g[1];
49330
+ var fromFileToBase64 = usePollinationPanel().fromFileToBase64;
49331
+ var _e = useState(false), open = _e[0], setOpen = _e[1];
49332
+ var _f = useState(false), over = _f[0], setOver = _f[1];
49333
+ var _g = useState(true), isLoading = _g[0], setIsLoading = _g[1];
49334
+ var _h = useState(false), isInactive = _h[0], setIsInactive = _h[1];
49334
49335
  // Data to use for CAD injections
49335
- var _h = useState(), CADdata = _h[0], setCADdata = _h[1];
49336
+ var _j = useState(), CADdata = _j[0], setCADdata = _j[1];
49336
49337
  // File to send to parent
49337
- var _j = useState(), currFile = _j[0], setCurrFile = _j[1];
49338
- /**
49339
- * Check if run id is a valid UUID or file path (Local sim)
49340
- * @param str run id
49341
- * @returns true or false
49342
- */
49343
- var checkIfValidUUID = function (str) {
49344
- var regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
49345
- return regexExp.test(str);
49346
- };
49347
- var isCloud = useMemo(function () { return checkIfValidUUID(runId); }, [runId]);
49338
+ var _k = useState(), currFile = _k[0], setCurrFile = _k[1];
49339
+ // /**
49340
+ // * Check if run id is a valid UUID or file path (Local sim)
49341
+ // * @param str run id
49342
+ // * @returns true or false
49343
+ // */
49344
+ // const checkIfValidUUID = (str: string): boolean => {
49345
+ // const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
49346
+ // return regexExp.test(str)
49347
+ // }
49348
+ // const isCloud = useMemo(() => checkIfValidUUID(runId), [runId])
49348
49349
  var downloadArtifact = useArtifacts(projectOwner, projectName, client).downloadArtifact;
49349
49350
  var setCADintegration = useCallback(function (file) {
49350
49351
  if (!file)
@@ -49395,9 +49396,42 @@ var FileCard = function (_a) {
49395
49396
  setCADintegration(blob);
49396
49397
  });
49397
49398
  })
49398
- .catch(function () { })
49399
+ .catch(function (err) {
49400
+ console.error(err);
49401
+ })
49399
49402
  .finally(function () { return setIsLoading(false); });
49400
49403
  };
49404
+ var extension = useMemo(function () {
49405
+ if (!path)
49406
+ return;
49407
+ return path.split('/').reverse()[0];
49408
+ }, [path]);
49409
+ /**
49410
+ * Read local file as Blob - Panel only
49411
+ */
49412
+ var base64AndFetch = function (path) {
49413
+ if (!path)
49414
+ return;
49415
+ var data = fromFileToBase64(path);
49416
+ var base64Data = data === null || data === void 0 ? void 0 : data.data;
49417
+ if (!base64Data)
49418
+ return;
49419
+ // bas64 mapping
49420
+ var t;
49421
+ switch (extension) {
49422
+ case 'zip':
49423
+ t = 'application/zip';
49424
+ break;
49425
+ case 'hbjson':
49426
+ case 'vsf':
49427
+ t = 'text/plain';
49428
+ default:
49429
+ t = 'text/plain';
49430
+ break;
49431
+ }
49432
+ fetchAndSet("data:".concat(t, ";base64,").concat(base64Data));
49433
+ };
49434
+ var isPanel = useMemo(function () { return checkPollinationPanel(); }, []);
49401
49435
  useEffect(function () {
49402
49436
  if (isCloud) {
49403
49437
  // Generate Blob on click
@@ -49406,8 +49440,15 @@ var FileCard = function (_a) {
49406
49440
  .catch(function () { return onClicked({ label: label, path: path, file: undefined, description: description, runId: runId }); });
49407
49441
  }
49408
49442
  else {
49409
- // TODO: Local later...
49410
- onClicked({ label: label, path: path, file: currFile, description: description, runId: runId });
49443
+ if (!isPanel) {
49444
+ setIsInactive(true);
49445
+ setCurrFile(undefined);
49446
+ setCADintegration(undefined);
49447
+ setIsLoading(false);
49448
+ }
49449
+ else {
49450
+ base64AndFetch(path);
49451
+ }
49411
49452
  }
49412
49453
  }, [studyId, runId, label, path]);
49413
49454
  return React__default.createElement("div", { className: isInactive
@@ -49422,7 +49463,7 @@ var FileCard = function (_a) {
49422
49463
  React__default.createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, !isLoading ? React__default.createElement("div", { title: !isInactive
49423
49464
  ? 'Open the viewer'
49424
49465
  : 'File is missing. Check run workspace' },
49425
- React__default.createElement("span", { style: { margin: '0 8px 0 0' } }, getFileIcon(18, ((_c = (_b = path.split('/')
49466
+ React__default.createElement("span", { style: { margin: '0 8px 0 0' } }, path && getFileIcon(18, ((_c = (_b = path.split('/')
49426
49467
  .reverse()[0]) === null || _b === void 0 ? void 0 : _b.split('.')) === null || _c === void 0 ? void 0 : _c.pop()) || '')),
49427
49468
  label)
49428
49469
  : React__default.createElement(LoadingIcon, { size: 14 })),
@@ -49489,11 +49530,11 @@ var css_248z$2 = ":root {\n --background: #FFFAEE;\n --primary: #1890ff;\n --
49489
49530
  styleInject(css_248z$2);
49490
49531
 
49491
49532
  var RunContent = function (_a) {
49492
- var inputData = _a.inputData, projectOwner = _a.projectOwner, projectName = _a.projectName, studyId = _a.studyId, runId = _a.runId, client = _a.client, title = _a.title, style = _a.style, getFileCard = _a.getFileCard, getFolderCard = _a.getFolderCard;
49493
- var _b = useState([]), currData = _b[0], setCurrData = _b[1];
49494
- var _c = useState([]), currParams = _c[0], setCurrParams = _c[1];
49495
- var _d = useState([]), currFiles = _d[0], setCurrFiles = _d[1];
49496
- var _e = useState([]), currFolders = _e[0], setCurrFolders = _e[1];
49533
+ var inputData = _a.inputData, projectOwner = _a.projectOwner, projectName = _a.projectName, studyId = _a.studyId, runId = _a.runId, client = _a.client, title = _a.title, style = _a.style, getFileCard = _a.getFileCard, getFolderCard = _a.getFolderCard, _b = _a.isCloud, isCloud = _b === void 0 ? true : _b;
49534
+ var _c = useState([]), currData = _c[0], setCurrData = _c[1];
49535
+ var _d = useState([]), currParams = _d[0], setCurrParams = _d[1];
49536
+ var _e = useState([]), currFiles = _e[0], setCurrFiles = _e[1];
49537
+ var _f = useState([]), currFolders = _f[0], setCurrFolders = _f[1];
49497
49538
  useEffect(function () { return setCurrData(inputData); }, [inputData]);
49498
49539
  useEffect(function () {
49499
49540
  if (!currData || currData.length == 0)
@@ -49523,11 +49564,11 @@ var RunContent = function (_a) {
49523
49564
  setCurrFiles(files);
49524
49565
  setCurrFolders(folders);
49525
49566
  }, [currData]);
49526
- var checkIfValidUUID = function (str) {
49527
- var regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
49528
- return regexExp.test(str);
49529
- };
49530
- var isCloud = useMemo(function () { return checkIfValidUUID(runId); }, [runId]);
49567
+ // const checkIfValidUUID = (str: string): boolean => {
49568
+ // const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
49569
+ // return regexExp.test(str)
49570
+ // }
49571
+ // const isCloud = useMemo(() => checkIfValidUUID(runId), [runId])
49531
49572
  /**
49532
49573
  * Click event handler of the file card
49533
49574
  * @param card File card props
@@ -49555,7 +49596,7 @@ var RunContent = function (_a) {
49555
49596
  currFiles.length > 0 && projectOwner && projectName && client && runId && React__default.createElement("div", { style: { padding: '20px' } },
49556
49597
  React__default.createElement("div", { className: 'cards' }, currFiles.map(function (_a, index) {
49557
49598
  var label = _a.label, path = _a.path, description = _a.description;
49558
- return React__default.createElement(FileCard, { projectOwner: projectOwner, projectName: projectName, studyId: studyId, runId: runId, client: client, key: "filecard-".concat(index), label: label, path: path, description: description, onClicked: onFileClicked });
49599
+ return React__default.createElement(FileCard, { projectOwner: projectOwner, projectName: projectName, studyId: studyId, runId: runId, client: client, key: "filecard-".concat(index), label: label, path: path, description: description, onClicked: onFileClicked, isCloud: isCloud });
49559
49600
  }))),
49560
49601
  currFolders.length > 0 && React__default.createElement("div", { style: { padding: '20px' } },
49561
49602
  React__default.createElement("div", { className: 'cards' }, currFolders.map(function (_a, index) {
@@ -49571,11 +49612,10 @@ var RunContent = function (_a) {
49571
49612
 
49572
49613
  var RunDetails = function (_a) {
49573
49614
  var projectName = _a.projectName, projectOwner = _a.projectOwner, run = _a.run, // Cloud and Local
49574
- runId = _a.runId, // TODO: delete it if RUN JSON has the field
49575
- client = _a.client, style = _a.style, getFileCard = _a.getFileCard, getFolderCard = _a.getFolderCard;
49576
- var _b = useState([]), extraInputs = _b[0], setExtraInputs = _b[1];
49577
- var _c = useState([]), recipeInputs = _c[0], setRecipeInputs = _c[1];
49578
- var _d = useState([]), outputs = _d[0], setOutputs = _d[1];
49615
+ client = _a.client, style = _a.style, getFileCard = _a.getFileCard, getFolderCard = _a.getFolderCard, _b = _a.isCloud, isCloud = _b === void 0 ? true : _b;
49616
+ var _c = useState([]), extraInputs = _c[0], setExtraInputs = _c[1];
49617
+ var _d = useState([]), recipeInputs = _d[0], setRecipeInputs = _d[1];
49618
+ var _e = useState([]), outputs = _e[0], setOutputs = _e[1];
49579
49619
  useEffect(function () {
49580
49620
  if (!run)
49581
49621
  return;
@@ -49604,11 +49644,11 @@ var RunDetails = function (_a) {
49604
49644
  }, [run]);
49605
49645
  return (React__default.createElement("div", null,
49606
49646
  outputs &&
49607
- React__default.createElement(RunContent, { title: 'Outputs', inputData: outputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id || runId, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard }),
49647
+ React__default.createElement(RunContent, { title: 'Outputs', inputData: outputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard, isCloud: isCloud }),
49608
49648
  recipeInputs &&
49609
- React__default.createElement(RunContent, { title: 'Inputs', inputData: recipeInputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id || runId, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard }),
49649
+ React__default.createElement(RunContent, { title: 'Inputs', inputData: recipeInputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard, isCloud: isCloud }),
49610
49650
  extraInputs && extraInputs.length > 0 &&
49611
- React__default.createElement(RunContent, { title: 'Extra Inputs', inputData: extraInputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id || runId, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard })));
49651
+ React__default.createElement(RunContent, { title: 'Extra Inputs', inputData: extraInputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard, isCloud: isCloud })));
49612
49652
  };
49613
49653
 
49614
49654
  var css_248z$1 = ":root {\n --background: #FFFAEE;\n --primary: #1890ff;\n --primary2: #40a9ff;\n --primary1: #cceefe;\n --primary0: #e6f7ff;\n --secondary: #fff566;\n --primary3: #000;\n --success: #46A758;\n --warning: #F76809;\n --danger: #FF4616;\n /* radix-ui/colors */\n --slate1: hsl(206, 30.0%, 98.8%);\n --slate2: hsl(210, 16.7%, 97.6%);\n --slate3: hsl(209, 13.3%, 95.3%);\n --slate4: hsl(209, 12.2%, 93.2%);\n --slate5: hsl(208, 11.7%, 91.1%);\n --slate6: hsl(208, 11.3%, 88.9%);\n --slate7: hsl(207, 11.1%, 85.9%);\n --slate8: hsl(205, 10.7%, 78.0%);\n --slate9: hsl(206, 6.0%, 56.1%);\n --slate10: hsl(206, 5.8%, 52.3%);\n --slate11: hsl(206, 6.0%, 43.5%);\n --slate12: hsl(206, 24.0%, 9.0%);\n}\n\n@keyframes spin {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(360deg);\n }\n}\n.spin {\n animation: spin 1s linear 0s infinite;\n}\n\n@keyframes Animation {\n 0% {\n background-position: 200%;\n }\n 50% {\n background-position: 100%;\n }\n 100% {\n background-position: 0%;\n }\n}\n.loading {\n background: linear-gradient(45deg, transparent, var(--primary), 12%, transparent);\n background-size: 200%;\n animation: Animation 3s ease infinite;\n}\n\n@keyframes open {\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n}\n@keyframes close {\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n}\n.collapse-content {\n overflow: hidden;\n font-size: inherit;\n color: inherit;\n}\n\n.collapse-content[data-state=open] {\n animation: open 300ms ease-out;\n}\n\n.collapse-content[data-state=closed] {\n animation: close 300ms ease-out;\n}\n\n.run-progress {\n grid-area: runprogress;\n font-size: 0.9rem;\n text-align: left !important;\n}\n\n.run-link {\n grid-area: runlink;\n text-align: right !important;\n font-size: 1rem;\n white-space: nowrap;\n}\n\n.run-details {\n grid-area: rundetails;\n font-size: 0.9rem;\n}\n\n.study-run-container {\n display: grid;\n grid-template-areas: \"runprogress runprogress runprogress runprogress runprogress runlink\" \"rundetails rundetails rundetails rundetails rundetails rundetails\";\n gap: 0.35rem;\n border: 0.1rem solid;\n align-items: center;\n padding: 0.75rem;\n transition: box-shadow 0.3s ease 0s, border-color 0.3s ease 0s;\n grid-template-rows: max-content auto;\n border-radius: 6px;\n line-height: 1.5;\n}\n\n.study-run-container:hover {\n cursor: pointer;\n box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 2px -2px, rgba(0, 0, 0, 0.12) 0px 3px 6px 0px, rgba(0, 0, 0, 0.09) 0px 5px 12px 4px;\n}\n\n.run-navigator {\n display: grid;\n grid-template-columns: min-content auto min-content min-content;\n grid-auto-rows: auto;\n align-items: center;\n grid-gap: 0.9rem;\n}\n\n.run-pg-input {\n margin: 0 4px 0 4px;\n padding: 8px 8px;\n text-align: center;\n color: rgba(0, 0, 0, 0.8509803922);\n width: min-content;\n border-radius: 2px;\n font-size: 12px;\n border: 1px solid rgba(0, 0, 0, 0.125);\n}\n\n.container-scroll {\n display: inline-flex;\n flex-direction: row;\n overflow-x: auto;\n width: 100%;\n}\n\n.blink-effect {\n animation: blinker 5s linear infinite;\n}\n\n@keyframes blinker {\n 50% {\n border: 0.1rem solid white;\n }\n}";