pollination-react-io 1.8.1 → 1.8.2

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.
@@ -21661,7 +21661,7 @@ function getHost(key, defaultValue) {
21661
21661
 
21662
21662
  var useArtifacts = function (owner, name, client) {
21663
21663
  var listArtifacts = useCallback(function (path) {
21664
- if (!(client === null || client === void 0 ? void 0 : client.artifacts))
21664
+ if (!client)
21665
21665
  return;
21666
21666
  // let key: string[] | undefined = undefined
21667
21667
  // if (path) {
@@ -21674,22 +21674,22 @@ var useArtifacts = function (owner, name, client) {
21674
21674
  perPage: 50,
21675
21675
  path: path
21676
21676
  }).then(function (r) { return r.data; });
21677
- }, [client.artifacts, owner, name]);
21677
+ }, [client, owner, name]);
21678
21678
  var downloadArtifact = useCallback(function (path) {
21679
- if (!(client === null || client === void 0 ? void 0 : client.artifacts))
21679
+ if (!client)
21680
21680
  return;
21681
21681
  return client.artifacts.downloadArtifact({
21682
21682
  owner: owner,
21683
21683
  name: name,
21684
21684
  path: path
21685
21685
  }).then(function (r) { return r.data; });
21686
- }, [client.artifacts, owner, name]);
21686
+ }, [client, owner, name]);
21687
21687
  var deleteArtifact = useCallback(function (path) { return __awaiter(void 0, void 0, void 0, function () {
21688
21688
  var key;
21689
21689
  return __generator(this, function (_a) {
21690
21690
  switch (_a.label) {
21691
21691
  case 0:
21692
- if (!(client === null || client === void 0 ? void 0 : client.artifacts))
21692
+ if (!client)
21693
21693
  return [2 /*return*/];
21694
21694
  key = undefined;
21695
21695
  if (path) {
@@ -21705,13 +21705,13 @@ var useArtifacts = function (owner, name, client) {
21705
21705
  return [2 /*return*/];
21706
21706
  }
21707
21707
  });
21708
- }); }, [client.artifacts, owner, name]);
21708
+ }); }, [client, owner, name]);
21709
21709
  var uploadArtifact = useCallback(function (folderRoot, file) { return __awaiter(void 0, void 0, void 0, function () {
21710
21710
  var filePath, rootKey, uploadKey, result, _a, url, fields, payload;
21711
21711
  return __generator(this, function (_b) {
21712
21712
  switch (_b.label) {
21713
21713
  case 0:
21714
- if (!(client === null || client === void 0 ? void 0 : client.artifacts))
21714
+ if (!client)
21715
21715
  return [2 /*return*/];
21716
21716
  filePath = file.path || file.name;
21717
21717
  if (!filePath) {
@@ -21751,7 +21751,7 @@ var useArtifacts = function (owner, name, client) {
21751
21751
  return [2 /*return*/, result.data];
21752
21752
  }
21753
21753
  });
21754
- }); }, [client.artifacts, owner, name]);
21754
+ }); }, [client, owner, name]);
21755
21755
  return {
21756
21756
  listArtifacts: listArtifacts,
21757
21757
  deleteArtifact: deleteArtifact,
@@ -34465,7 +34465,6 @@ var InputDescription = function (_a) {
34465
34465
  width: '100%',
34466
34466
  color: 'var(--slate12)',
34467
34467
  fontSize: '0.8rem',
34468
- textAlign: 'end',
34469
34468
  gap: 4
34470
34469
  } },
34471
34470
  children,
@@ -35583,7 +35582,7 @@ var Label = function (_a) {
35583
35582
  justifyContent: 'flex-start',
35584
35583
  width: '100%'
35585
35584
  } },
35586
- React__default.createElement("label", { htmlFor: name !== null && name !== void 0 ? name : (typeof label === 'string' && slugify(label, { lower: true })), style: __assign$3({ background: 'var(--background)', borderRadius: 4, width: 'fit-content', transform: 'translate(30px, 6px)', zIndex: 100, fontSize: '0.8rem', color: 'var(--primary)', padding: '0px 4px' }, style) }, label)),
35585
+ React__default.createElement("label", { htmlFor: name !== null && name !== void 0 ? name : (typeof label === 'string' && slugify(label, { lower: true })), style: __assign$3({ background: 'var(--background)', borderRadius: 4, width: 'fit-content', transform: 'translate(30px, 6px)', zIndex: 100, fontSize: '0.8rem', color: 'var(--primary)', fill: 'var(--primary)', padding: '0px 4px', marginBottom: 0 }, style) }, label)),
35587
35586
  children));
35588
35587
  };
35589
35588
 
@@ -39482,6 +39481,8 @@ var SelectCloudArtifacts = function (_a) {
39482
39481
  var _g = useState(), selArtifact = _g[0], setSelArtifact = _g[1];
39483
39482
  var folderNavRef = useRef(false);
39484
39483
  useEffect(function () {
39484
+ if (!client)
39485
+ return;
39485
39486
  setLoading(true);
39486
39487
  listArtifacts(path)
39487
39488
  .then(function (facts) {
@@ -39491,7 +39492,7 @@ var SelectCloudArtifacts = function (_a) {
39491
39492
  setArtifacts({ folders: folders, files: files });
39492
39493
  })
39493
39494
  .finally(function () { return setLoading(false); });
39494
- }, [listArtifacts, path]);
39495
+ }, [client, listArtifacts, path]);
39495
39496
  useEffect(function () {
39496
39497
  if (!selArtifact)
39497
39498
  return;
@@ -39665,10 +39666,11 @@ var generateSchema = function (inputs) {
39665
39666
  });
39666
39667
  };
39667
39668
  var RecipeInputsForm = function (_a) {
39669
+ var _b;
39668
39670
  var recipe = _a.recipe, onSubmit = _a.onSubmit, disabled = _a.disabled, projectName = _a.projectName, projectOwner = _a.projectOwner, client = _a.client;
39669
- var _b = useState(false), loading = _b[0], setLoading = _b[1];
39671
+ var _c = useState(false), loading = _c[0], setLoading = _c[1];
39670
39672
  var schema = generateSchema(recipe.inputs);
39671
- var _c = useForm({
39673
+ var _d = useForm({
39672
39674
  // @ts-ignore
39673
39675
  defaultValues: recipe.inputs.reduce(function (p, c) {
39674
39676
  var _a;
@@ -39677,7 +39679,7 @@ var RecipeInputsForm = function (_a) {
39677
39679
  }, {}),
39678
39680
  resolver: Oe(schema),
39679
39681
  mode: 'all'
39680
- }), control = _c.control, register = _c.register, handleSubmit = _c.handleSubmit, reset = _c.reset, getValues = _c.getValues, _d = _c.formState, errors = _d.errors, isValid = _d.isValid, isSubmitSuccessful = _d.isSubmitSuccessful; _c.getFieldState;
39682
+ }), control = _d.control, register = _d.register, handleSubmit = _d.handleSubmit, reset = _d.reset, resetField = _d.resetField; _d.setValue; var _e = _d.formState, errors = _e.errors, isValid = _e.isValid, isSubmitSuccessful = _e.isSubmitSuccessful;
39681
39683
  useEffect(function () {
39682
39684
  if (isSubmitSuccessful) {
39683
39685
  reset();
@@ -39710,9 +39712,6 @@ var RecipeInputsForm = function (_a) {
39710
39712
  });
39711
39713
  }
39712
39714
  };
39713
- // console.log(errors)
39714
- // console.log(isValid)
39715
- // console.log(watch())
39716
39715
  var groups = recipe.inputs.reduce(function (p, c) {
39717
39716
  if (c.required) {
39718
39717
  p[0].push(c);
@@ -39723,7 +39722,9 @@ var RecipeInputsForm = function (_a) {
39723
39722
  return p;
39724
39723
  }, [[], []]);
39725
39724
  return (React__default.createElement(Tabs, { forceRenderTabPanel: true },
39726
- React__default.createElement(TabList, null,
39725
+ React__default.createElement(TabList, { style: {
39726
+ flex: 1
39727
+ } },
39727
39728
  React__default.createElement(Tab, { key: 'required-tab' }, "Required"),
39728
39729
  React__default.createElement(Tab, { key: 'optional-tab' }, "Optional")),
39729
39730
  React__default.createElement("form", { id: recipe.metadata.name, onSubmit: handleSubmit(_onSubmit), style: {
@@ -39740,11 +39741,10 @@ var RecipeInputsForm = function (_a) {
39740
39741
  flexDirection: 'column',
39741
39742
  gap: 8
39742
39743
  } }, g.map(function (input, i) {
39743
- var _a, _b, _c;
39744
+ var _a, _b, _c, _d;
39744
39745
  return (React__default.createElement($409067139f391064$export$be92b6f5f03c0fe9, { style: {
39745
39746
  display: 'flex',
39746
39747
  flexDirection: 'column',
39747
- justifyContent: 'flex-end',
39748
39748
  fontSize: 'inherit',
39749
39749
  color: 'inherit',
39750
39750
  gap: 2
@@ -39771,7 +39771,7 @@ var RecipeInputsForm = function (_a) {
39771
39771
  cursor: 'pointer',
39772
39772
  padding: 0,
39773
39773
  } },
39774
- React__default.createElement(InfoCircle$1, { style: { fill: 'var(--primary)' } }))) },
39774
+ React__default.createElement(InfoCircle$1, { style: { fill: ((_d = errors[input.name]) === null || _d === void 0 ? void 0 : _d.message) ? 'red' : 'var(--primary)' } }))) },
39775
39775
  React__default.createElement(InputDescription, { helpText: React__default.createElement($409067139f391064$export$7c6e2c02157bb7d2, { className: 'collapse-content' }, input && input.description) }, (function () {
39776
39776
  var _a;
39777
39777
  var inputProps = __assign$3({}, register(input.name, {
@@ -39780,13 +39780,8 @@ var RecipeInputsForm = function (_a) {
39780
39780
  max: input.spec && input.spec.maximum ? "".concat(input.name, " must be at least ").concat(input.spec.minimum) : undefined,
39781
39781
  valueAsNumber: input.type === 'DAGNumberInput' || input.type === 'DAGIntegerInput',
39782
39782
  }));
39783
- var handleReset = function () {
39784
- var _a;
39785
- return reset(__assign$3(__assign$3({}, getValues()), (_a = {}, _a[input.name] = input.default, _a)), {
39786
- keepIsValid: true,
39787
- keepTouched: true,
39788
- });
39789
- };
39783
+ // @ts-ignore
39784
+ var handleReset = function () { return resetField(input.name); };
39790
39785
  switch (input.type) {
39791
39786
  case 'DAGFileInput':
39792
39787
  return React__default.createElement(Controller
@@ -39821,12 +39816,20 @@ var RecipeInputsForm = function (_a) {
39821
39816
  React__default.createElement("div", { style: {
39822
39817
  display: 'flex',
39823
39818
  width: '100%',
39824
- justifyContent: 'center',
39825
- padding: '16px 0px 0px'
39819
+ padding: '16px 0px 0px 8px'
39826
39820
  } },
39827
- React__default.createElement(Button, { type: 'submit', form: recipe.metadata.name, disabled: !isValid || disabled, style: {
39828
- width: 'fit-content',
39829
- }, loading: loading }, "Create Study"))));
39821
+ React__default.createElement(InputDescription, { helpText: isValid ? 'Recipe input is valid!' : ((_b = Object.values(errors)) === null || _b === void 0 ? void 0 : _b.length) > 0 ?
39822
+ React__default.createElement("div", null,
39823
+ React__default.createElement("ul", { style: { padding: 0 } }, Object.entries(errors).map(function (_a) {
39824
+ var key = _a[0], val = _a[1];
39825
+ return (
39826
+ // @ts-ignore
39827
+ React__default.createElement("li", { key: key, style: { color: 'red', fontSize: '0.8rem', listStyle: 'none' } }, "".concat(key, " ").concat(val.message, ".")));
39828
+ }))) :
39829
+ 'Recipe input isn\'t valid yet.' },
39830
+ React__default.createElement(Button, { type: 'submit', form: recipe.metadata.name, disabled: !isValid || disabled, style: {
39831
+ width: 'fit-content',
39832
+ }, loading: loading }, "Create Study")))));
39830
39833
  };
39831
39834
 
39832
39835
  var css_248z = ".react-tabs {\n -webkit-tap-highlight-color: transparent;\n}\n\n.react-tabs__tab-list {\n border-bottom: 1px solid #aaa;\n margin: 0 0 10px;\n padding: 0;\n}\n\n.react-tabs__tab {\n display: inline-block;\n border: 1px solid transparent;\n border-bottom: none;\n bottom: -1px;\n position: relative;\n list-style: none;\n padding: 6px 12px;\n cursor: pointer;\n}\n\n.react-tabs__tab--selected {\n background: #fff;\n border-color: #aaa;\n color: black;\n border-radius: 5px 5px 0 0;\n}\n\n.react-tabs__tab--disabled {\n color: GrayText;\n cursor: default;\n}\n\n.react-tabs__tab:focus {\n outline: none;\n}\n\n.react-tabs__tab:focus:after {\n content: '';\n position: absolute;\n height: 5px;\n left: -4px;\n right: -4px;\n bottom: -5px;\n background: #fff;\n}\n\n.react-tabs__tab-panel {\n display: none;\n}\n\n.react-tabs__tab-panel--selected {\n display: block;\n}\n";
@@ -39870,10 +39873,22 @@ var CreateStudy = function (_a) {
39870
39873
  }, [state.recipe]);
39871
39874
  return (React__default.createElement("div", { "data-testid": "CreateProject", style: __assign$3(__assign$3({}, defaultStyle), style) },
39872
39875
  React__default.createElement(Tabs, { selectedIndex: activeTabIndex, onSelect: function (index) { return setActiveTabIndex(index); }, forceRenderTabPanel: true },
39873
- React__default.createElement(TabList, null,
39874
- React__default.createElement(Tab, null, "Select Recipe"),
39876
+ React__default.createElement("div", { style: {
39877
+ display: 'flex',
39878
+ width: '100%',
39879
+ alignItems: 'center',
39880
+ justifyContent: 'space-between'
39881
+ } },
39882
+ React__default.createElement(TabList, { style: {
39883
+ flex: 1
39884
+ } },
39885
+ React__default.createElement(Tab, null, "Select Recipe"),
39886
+ state.recipe &&
39887
+ React__default.createElement(Tab, null, "Recipe Inputs")),
39875
39888
  state.recipe &&
39876
- React__default.createElement(Tab, null, "Recipe Inputs")),
39889
+ React__default.createElement("h5", { style: {
39890
+ marginBottom: 0
39891
+ } }, state.recipe.metadata.name)),
39877
39892
  React__default.createElement(TabPanel, { style: {
39878
39893
  padding: '8px 8px'
39879
39894
  } },