@abidibo/react-cam-roi 0.7.0 → 0.8.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.
package/README.md CHANGED
@@ -61,7 +61,8 @@ export type RoiEditorProps = {
61
61
  onSubmit: (data: Output) => void
62
62
  // initial imported data
63
63
  initialData?: Output
64
- // default preset name
64
+ // allow partial save: no error notified but errors are returned
65
+ allowPartialSave?: boolean
65
66
  }
66
67
 
67
68
  export const enum ToolEnum {
@@ -157,6 +158,7 @@ export interface Output {
157
158
  presetName: string
158
159
  presetDescription: string
159
160
  rois: OutputRoi[]
161
+ errors?: string[]
160
162
  }
161
163
  ```
162
164
 
package/dist/index.cjs.js CHANGED
@@ -1691,7 +1691,7 @@ var TopBar = function () {
1691
1691
  // https://github.com/n-mazaheri/image-editor
1692
1692
  var RoiEditor = function (_a) {
1693
1693
  var _b, _c, _d, _e, _f;
1694
- var imageUrl = _a.imageUrl, configuration = _a.configuration, onSubmit = _a.onSubmit, onUpdate = _a.onUpdate, initialData = _a.initialData, editorId = _a.editorId;
1694
+ var imageUrl = _a.imageUrl, configuration = _a.configuration, onSubmit = _a.onSubmit, onUpdate = _a.onUpdate, initialData = _a.initialData, editorId = _a.editorId, allowPartialSave = _a.allowPartialSave;
1695
1695
  log('info', true, 'react-cam-roi', 'React', React);
1696
1696
  var firstUpdate = React.useRef(0);
1697
1697
  var canvasRef = React.useRef(null);
@@ -1765,14 +1765,16 @@ var RoiEditor = function (_a) {
1765
1765
  }, [metadata, shapes, onUpdate, prepareOutput]);
1766
1766
  var handleSubmit = React.useCallback(function () {
1767
1767
  var _a = validate(configuration, presetName, shapes, metadata, strings), isValid = _a[0], errors = _a[1];
1768
- console.log('CAZZ', errors, presetName);
1769
1768
  if (isValid) {
1770
1769
  onSubmit(prepareOutput(metadata, shapes, presetName, presetDescription));
1771
1770
  }
1771
+ else if (allowPartialSave) {
1772
+ onSubmit(__assign(__assign({}, prepareOutput(metadata, shapes, presetName, presetDescription)), { errors: errors }));
1773
+ }
1772
1774
  else {
1773
1775
  notify.error(strings.invalidSubmission + '\n' + errors.map(function (e) { return "- ".concat(e); }).join('\n'));
1774
1776
  }
1775
- }, [onSubmit, configuration, shapes, metadata, prepareOutput, strings, notify, presetName]);
1777
+ }, [onSubmit, configuration, shapes, metadata, prepareOutput, strings, notify, presetName, presetDescription]);
1776
1778
  log('info', enableLogs, 'react-cam-roi', 'active tool', activeTool);
1777
1779
  log('info', enableLogs, 'react-cam-roi', 'canvas size', canvasSize);
1778
1780
  log('info', enableLogs, 'react-cam-roi', 'metadata', metadata);