@abidibo/react-cam-roi 0.10.0 → 0.11.0

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
@@ -801,7 +801,7 @@ After cloning the repository and install dependencies (`yarn install`), you can
801
801
 
802
802
  In order to start developing just run the storybook, then make changes to code and the storybook will be updated.
803
803
 
804
- In order to test the library in onother local react project you can:
804
+ In order to test the library in another local react project you can:
805
805
 
806
806
  ```bash
807
807
  cd react-cam-roi
package/dist/index.cjs.js CHANGED
@@ -813,12 +813,13 @@ var handleDoubleClickPolygon = function (editorId, canvas, activeColor, setIsDra
813
813
  }
814
814
  };
815
815
  var renderFullImagePolygon = function (editorId, canvas, activeColor, imageSize) {
816
+ var OFFSET = 5;
816
817
  var id = v4();
817
818
  var points = [
818
- { x: 1, y: 1 },
819
- { x: imageSize.width - 1, y: 0 },
820
- { x: imageSize.width - 1, y: imageSize.height - 1 },
821
- { x: 0, y: imageSize.height - 1 },
819
+ { x: OFFSET, y: OFFSET },
820
+ { x: imageSize.width - OFFSET, y: OFFSET },
821
+ { x: imageSize.width - OFFSET, y: imageSize.height - OFFSET },
822
+ { x: OFFSET, y: imageSize.height - OFFSET },
822
823
  ];
823
824
  var polygon = new oo(points, {
824
825
  fill: 'transparent',
@@ -1549,11 +1550,17 @@ var ParametersModalForm = function (_a) {
1549
1550
  var _a;
1550
1551
  return (__assign(__assign({}, acc), (_a = {}, _a[p.codename] = p.value, _a)));
1551
1552
  }, {});
1553
+ // if not in modal we save at every field change
1554
+ React.useEffect(function () {
1555
+ if (noModal) {
1556
+ handleSubmit();
1557
+ }
1558
+ }, [fields]);
1552
1559
  var handleSubmit = function () {
1553
1560
  if (shapeType && name === '') {
1554
1561
  setErrors({ name: strings.requiredField });
1555
1562
  }
1556
- else if (validateParametersForm(parameters, fields, setErrors, strings)) {
1563
+ else if (!noModal || validateParametersForm(parameters, fields, setErrors, strings)) {
1557
1564
  var data_1 = __spreadArray([], parameters.map(function (p) { return ({ codename: p.codename, value: fields[p.codename] }); }), true);
1558
1565
  if (shapeType) {
1559
1566
  onSubmit(data_1, { name: name, role: role });
@@ -1724,7 +1731,7 @@ var TopBar = function () {
1724
1731
  setMetadata(__assign(__assign({}, metadata), { parameters: data }));
1725
1732
  setForm({ isOpen: false });
1726
1733
  };
1727
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: css('top-bar', styles, themeMode), children: [enableMainMetadata(configuration) && !((_a = configuration.options) === null || _a === void 0 ? void 0 : _a.viewMainParameters) && (jsxRuntime.jsxs(Button, { onClick: function () { return setForm({ isOpen: true }); }, children: [jsxRuntime.jsx(AnnotateIcon, { color: iconColor }), " ", strings.mainParametersMetadata] })), jsxRuntime.jsxs(Button, { primary: true, onClick: onSubmit, children: [jsxRuntime.jsx(SaveIcon, { color: primaryFgColor }), " ", strings.save] }), form.isOpen && (jsxRuntime.jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata }))] }), enableMainMetadata(configuration) && ((_b = configuration.options) === null || _b === void 0 ? void 0 : _b.viewMainParameters) && (jsxRuntime.jsxs("div", { className: css('main-parameters-view', styles, themeMode), children: [jsxRuntime.jsx("div", { className: css('main-parameters-button', styles, themeMode), children: jsxRuntime.jsxs(Button, { onClick: function () { return setForm({ isOpen: true }); }, children: [jsxRuntime.jsx(AnnotateIcon, { color: iconColor }), " ", strings.mainParametersMetadata] }) }), jsxRuntime.jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata, readOnly: true, noModal: true })] }))] }));
1734
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: css('top-bar', styles, themeMode), children: [enableMainMetadata(configuration) && !((_a = configuration.options) === null || _a === void 0 ? void 0 : _a.viewMainParameters) && (jsxRuntime.jsxs(Button, { onClick: function () { return setForm({ isOpen: true }); }, children: [jsxRuntime.jsx(AnnotateIcon, { color: iconColor }), " ", strings.mainParametersMetadata] })), jsxRuntime.jsxs(Button, { primary: true, onClick: onSubmit, children: [jsxRuntime.jsx(SaveIcon, { color: primaryFgColor }), " ", strings.save] }), form.isOpen && (jsxRuntime.jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata }))] }), enableMainMetadata(configuration) && ((_b = configuration.options) === null || _b === void 0 ? void 0 : _b.viewMainParameters) && (jsxRuntime.jsx("div", { className: css('main-parameters-view', styles, themeMode), children: jsxRuntime.jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata, noModal: true }) }))] }));
1728
1735
  };
1729
1736
 
1730
1737
  // https://github.com/n-mazaheri/image-editor