pollination-react-io 1.24.0 → 1.24.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.
@@ -1,6 +1,6 @@
1
1
  export interface RadioListProps {
2
2
  items: string[];
3
3
  name: string;
4
- defaultValue: string;
5
- onChange: (any: any) => void;
4
+ onChange: (val: any) => void;
5
+ value?: string;
6
6
  }
@@ -3,7 +3,7 @@ export declare function checkDotNet(): boolean;
3
3
  export declare function checkRuby(): boolean;
4
4
  export declare function checkPollinationPanel(): boolean;
5
5
  export declare function sendMessageDotNet(message: PanelMessageIn): PanelMessageIn;
6
- export declare function sendMessageRuby(message: PanelMessageIn): PanelMessageIn;
6
+ export declare function sendMessageRuby(message?: PanelMessageIn): any;
7
7
  export declare function getHost(key?: string, defaultValue?: 'web' | 'rhino' | 'revit' | 'sketchup'): 'web' | 'rhino' | 'revit' | 'sketchup';
8
8
  export declare const recipeLinkFromSource: (source: string) => string;
9
9
  export declare function formatBytes(bytes: any, decimals?: number): string;
@@ -15593,14 +15593,24 @@ var css_248z$9 = ":root {\n --background: #FFFAEE;\n --primary: #1890ff;\n --
15593
15593
  styleInject(css_248z$9);
15594
15594
 
15595
15595
  var RadioList = function (_a) {
15596
- var items = _a.items, name = _a.name, defaultValue = _a.defaultValue, onChange = _a.onChange;
15597
- return (React__default.createElement($f99a8c78507165f7$export$be92b6f5f03c0fe9, { defaultValue: defaultValue, style: {
15596
+ var items = _a.items, name = _a.name, onChange = _a.onChange, value = _a.value;
15597
+ var _b = useState(value), val = _b[0], setVal = _b[1];
15598
+ useEffect(function () {
15599
+ setVal(value);
15600
+ }, [value]);
15601
+ useEffect(function () {
15602
+ onChange && onChange(val);
15603
+ }, [onChange, val]);
15604
+ var handleChange = function (value) {
15605
+ setVal(value);
15606
+ };
15607
+ return (React__default.createElement($f99a8c78507165f7$export$be92b6f5f03c0fe9, { value: val, style: {
15598
15608
  display: 'flex',
15599
15609
  gap: 10,
15600
15610
  flexDirection: 'column',
15601
15611
  padding: '16px 8px',
15602
15612
  borderTop: '1px solid var(--primary)',
15603
- }, name: name, onChange: onChange },
15613
+ }, name: name, onValueChange: handleChange },
15604
15614
  React__default.createElement(React__default.Fragment, null, items.map(function (item, i) {
15605
15615
  return (React__default.createElement("div", { key: "".concat(item, "-").concat(i), style: {
15606
15616
  display: 'flex',
@@ -37772,48 +37782,40 @@ function checkRuby() {
37772
37782
  function checkPollinationPanel() {
37773
37783
  try {
37774
37784
  if (typeof window.parent.chrome === 'undefined') {
37775
- console.error('[POLLINATION-DEBUG]: chrome not found.');
37776
- return false;
37785
+ throw new Error('[POLLINATION-DEBUG]: chrome not found.');
37777
37786
  }
37778
37787
  }
37779
37788
  catch (_a) {
37780
- console.error('[POLLINATION-DEBUG]: chrome not found.');
37781
- return false;
37789
+ throw new Error('[POLLINATION-DEBUG]: chrome not found.');
37782
37790
  }
37783
37791
  try {
37784
37792
  if (typeof window.parent.chrome.webview === 'undefined') {
37785
- console.error('[POLLINATION-DEBUG]: webview not found.');
37786
- return false;
37793
+ throw new Error('[POLLINATION-DEBUG]: webview not found.');
37787
37794
  }
37788
37795
  }
37789
37796
  catch (_b) {
37790
- console.error('[POLLINATION-DEBUG]: webview not found.');
37791
- return false;
37797
+ throw new Error('[POLLINATION-DEBUG]: webview not found.');
37792
37798
  }
37793
37799
  try {
37794
37800
  if (typeof window.parent.chrome.webview.hostObjects === 'undefined') {
37795
- console.error('[POLLINATION-DEBUG]: webview.hostObjects not found.');
37796
- return false;
37801
+ throw new Error('[POLLINATION-DEBUG]: webview.hostObjects not found.');
37797
37802
  }
37798
37803
  }
37799
37804
  catch (_c) {
37800
- console.error('[POLLINATION-DEBUG]: webview.hostObjects not found.');
37801
- return false;
37805
+ throw new Error('[POLLINATION-DEBUG]: webview.hostObjects not found.');
37802
37806
  }
37803
37807
  try {
37804
37808
  if (typeof window.parent.chrome.webview.hostObjects.sync === 'undefined') {
37805
- console.error('[POLLINATION-DEBUG]: webview.hostObjects.sync not found.');
37806
- return false;
37809
+ throw new Error('[POLLINATION-DEBUG]: webview.hostObjects.sync not found.');
37807
37810
  }
37808
37811
  }
37809
37812
  catch (_d) {
37810
- console.error('[POLLINATION-DEBUG]: webview.hostObjects.sync not found.');
37811
- return false;
37813
+ throw new Error('[POLLINATION-DEBUG]: webview.hostObjects.sync not found.');
37812
37814
  }
37813
37815
  return true;
37814
37816
  }
37815
37817
  function sendMessageDotNet(message) {
37816
- if (!checkDotNet())
37818
+ if (!checkPollinationPanel())
37817
37819
  ;
37818
37820
  // const json = JSON.stringify(message)
37819
37821
  var json = message;
@@ -37829,10 +37831,9 @@ function sendMessageDotNet(message) {
37829
37831
  return message;
37830
37832
  }
37831
37833
  function sendMessageRuby(message) {
37832
- if (!checkRuby())
37834
+ if (!checkPollinationPanel())
37833
37835
  ;
37834
- console.error('[POLLINATION-DEBUG]: sendMesssageRuby not yet implemented');
37835
- return message;
37836
+ throw new Error('[POLLINATION-DEBUG]: sendMesssageRuby not yet implemented');
37836
37837
  }
37837
37838
  // not sure if this will work from Streamlit?
37838
37839
  function getHost(key, defaultValue) {
@@ -37881,7 +37882,13 @@ function blobToBase64(blob) {
37881
37882
  }
37882
37883
  var usePollinationPanel = function () {
37883
37884
  var panel = useMemo(function () {
37884
- return checkPollinationPanel() ? window.parent.chrome.webview.hostObjects.sync.study : false;
37885
+ try {
37886
+ checkPollinationPanel();
37887
+ }
37888
+ catch (_a) {
37889
+ return false;
37890
+ }
37891
+ return window.parent.chrome.webview.hostObjects.sync.study;
37885
37892
  }, []);
37886
37893
  var saveFileBase64 = useCallback(function (key, file, subFolder, fileName) { return __awaiter$1(void 0, void 0, void 0, function () {
37887
37894
  var base64;
@@ -44054,7 +44061,7 @@ var RecipeInputsForm = function (_a) {
44054
44061
  if (val === inputDefaults.get(key)) {
44055
44062
  delete data[key];
44056
44063
  }
44057
- if (!inputDefaults.get(key) && !data[key]) {
44064
+ if (!inputDefaults.get(key) && !data[key] && data[key] !== 0) {
44058
44065
  delete data[key];
44059
44066
  }
44060
44067
  });
@@ -44116,11 +44123,7 @@ var RecipeInputsForm = function (_a) {
44116
44123
  var _a;
44117
44124
  switch (input.type) {
44118
44125
  case 'DAGFileInput':
44119
- return React__default.createElement(Controller
44120
- // @ts-ignore
44121
- , {
44122
- // @ts-ignore
44123
- name: input.name, control: control, defaultValue: defaultValue, render: function (_a) {
44126
+ return React__default.createElement(Controller, { name: input.name, control: control, defaultValue: defaultValue, render: function (_a) {
44124
44127
  var _b = _a.field, value = _b.value, onChange = _b.onChange, field = __rest(_b, ["value", "onChange"]);
44125
44128
  return (React__default.createElement(ComboFileSelector, { projectOwner: projectOwner, projectName: projectName, defaultOption: input.extensions &&
44126
44129
  input.extensions.includes('hbjson') &&
@@ -44132,13 +44135,9 @@ var RecipeInputsForm = function (_a) {
44132
44135
  } });
44133
44136
  case 'DAGStringInput':
44134
44137
  return typeof ((_a = input.spec) === null || _a === void 0 ? void 0 : _a.enum) !== 'undefined' ?
44135
- React__default.createElement(Controller
44136
- // @ts-ignore
44137
- , {
44138
- // @ts-ignore
44139
- name: input.name, control: control, render: function (_a) {
44140
- var onChange = _a.field.onChange;
44141
- return (React__default.createElement(RadioList, { items: input.spec.enum, name: input.name, defaultValue: defaultValue, onChange: onChange }));
44138
+ React__default.createElement(Controller, { name: input.name, control: control, defaultValue: defaultValue, render: function (_a) {
44139
+ var _b = _a.field, onChange = _b.onChange, value = _b.value; __rest(_b, ["onChange", "value"]);
44140
+ return (React__default.createElement(RadioList, { items: input.spec.enum, name: input.name, onChange: onChange, value: value }));
44142
44141
  } }) :
44143
44142
  React__default.createElement(TextInput, { inputProps: __assign(__assign({}, inputProps), { defaultValue: defaultValue }), hidden: hidden, reset: handleReset });
44144
44143
  case 'DAGNumberInput':