lost-sia 0.9.0 → 1.0.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/CHANGELOG.md +15 -0
- package/dist/index.css +3 -3
- package/dist/index.es.js +3353 -179
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3351 -177
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var React__default = _interopDefault(React);
|
|
7
7
|
var semanticUiReact = require('semantic-ui-react');
|
|
8
8
|
var _ = _interopDefault(require('lodash'));
|
|
9
|
+
var reactDom = _interopDefault(require('react-dom'));
|
|
9
10
|
|
|
10
11
|
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
11
12
|
|
|
@@ -199,20 +200,23 @@ function getTopPoint(data) {
|
|
|
199
200
|
* correct the annotation
|
|
200
201
|
* @param {object} data
|
|
201
202
|
* @param {object} image
|
|
203
|
+
* @param {object} imageOffset
|
|
202
204
|
*/
|
|
203
|
-
function correctAnnotation(data, image) {
|
|
205
|
+
function correctAnnotation(data, image, imageOffset) {
|
|
206
|
+
var imgWidth = image.width - 2 * imageOffset.x;
|
|
207
|
+
var imgHeight = image.height - 2 * imageOffset.y;
|
|
204
208
|
var corrected = data.map(function (el) {
|
|
205
209
|
var x = el.x;
|
|
206
210
|
var y = el.y;
|
|
207
|
-
if (el.x <=
|
|
208
|
-
x =
|
|
209
|
-
} else if (el.x >
|
|
210
|
-
x =
|
|
211
|
+
if (el.x <= imageOffset.x) {
|
|
212
|
+
x = imageOffset.x;
|
|
213
|
+
} else if (el.x > imgWidth + imageOffset.x) {
|
|
214
|
+
x = imgWidth + imageOffset.x;
|
|
211
215
|
}
|
|
212
|
-
if (el.y <
|
|
213
|
-
y =
|
|
214
|
-
} else if (el.y >
|
|
215
|
-
y =
|
|
216
|
+
if (el.y < imageOffset.y) {
|
|
217
|
+
y = imageOffset.y;
|
|
218
|
+
} else if (el.y > imgHeight + imageOffset.y) {
|
|
219
|
+
y = imgHeight + imageOffset.y;
|
|
216
220
|
}
|
|
217
221
|
return { x: x, y: y };
|
|
218
222
|
});
|
|
@@ -524,7 +528,7 @@ function styleInject(css, ref) {
|
|
|
524
528
|
}
|
|
525
529
|
}
|
|
526
530
|
|
|
527
|
-
var css = ".Annotation_sel-area-off__3caGM {\n fill: none; }\n\n.Annotation_sel-area-on__fPaTl {\n fill: blue;\n fill-opacity: 0.001; }\n\n.Annotation_selected__36wA1 {\n fill-opacity: 0.01;\n cursor: grab; }\n\ncircle.Annotation_selected__36wA1 {\n fill-opacity: 1.0; }\n\n.Annotation_not-selected__1QCgV {\n fill-opacity: 0.3; }\n\ncircle.Annotation_not-selected__1QCgV {\n fill-opacity: 1.0; }\n\n.Annotation_node-halo-on__1ala6 {\n fill: orange;\n stroke: orange;\n fill-opacity: 0.
|
|
531
|
+
var css = ".Annotation_sel-area-off__3caGM {\n fill: none; }\n\n.Annotation_sel-area-on__fPaTl {\n fill: blue;\n fill-opacity: 0.001; }\n\n.Annotation_selected__36wA1 {\n fill-opacity: 0.01;\n cursor: grab; }\n\ncircle.Annotation_selected__36wA1 {\n fill-opacity: 1.0; }\n\n.Annotation_not-selected__1QCgV {\n fill-opacity: 0.3; }\n\ncircle.Annotation_not-selected__1QCgV {\n fill-opacity: 1.0; }\n\n.Annotation_node-halo-on__1ala6 {\n fill: orange;\n stroke: orange;\n fill-opacity: 0.1;\n stroke-opacity: 0.2;\n cursor: grab; }\n\n.Annotation_node-halo-off__1tASR {\n fill: none;\n stroke: none; }\n";
|
|
528
532
|
styleInject(css);
|
|
529
533
|
|
|
530
534
|
var CREATE_NODE = "crosshair";
|
|
@@ -877,6 +881,15 @@ var ANNO_LABEL_UPDATE = 'annoLabelUpdate';
|
|
|
877
881
|
var ANNO_CREATED_NODE = 'annoCreatedNode';
|
|
878
882
|
var ANNO_CREATED_FINAL_NODE = 'annoCreatedFinalNode';
|
|
879
883
|
var ANNO_START_CREATING = 'annoStartCreating';
|
|
884
|
+
var ANNO_COMMENT_UPDATE = 'annoCommentUpdate';
|
|
885
|
+
var ANNO_MARK_EXAMPLE = 'annoMarkExample';
|
|
886
|
+
|
|
887
|
+
var CANVAS_SVG_UPDATE = 'canvasSvgUpdate';
|
|
888
|
+
var CANVAS_UI_CONFIG_UPDATE = 'canvasUiConfigUpdate';
|
|
889
|
+
var CANVAS_AUTO_SAVE = 'canvasAutoSave';
|
|
890
|
+
var CANVAS_LABEL_INPUT_CLOSE = 'canvasLabelInputClose';
|
|
891
|
+
var CANVAS_IMG_LOADED = 'canvasImgLoaded';
|
|
892
|
+
var CANVAS_IMGBAR_CLOSE = 'canvasImgbarClose';
|
|
880
893
|
|
|
881
894
|
//Image actions
|
|
882
895
|
var IMG_LABEL_UPDATE = 'imgLabelUpdate';
|
|
@@ -2268,6 +2281,15 @@ var Annotation$1 = function (_Component) {
|
|
|
2268
2281
|
}
|
|
2269
2282
|
}
|
|
2270
2283
|
}
|
|
2284
|
+
if (this.props.showSingleAnno === undefined) {
|
|
2285
|
+
if (this.state.anno.visible !== undefined) {
|
|
2286
|
+
if (this.state.anno.visible) {
|
|
2287
|
+
this.setVisible(true);
|
|
2288
|
+
} else {
|
|
2289
|
+
this.setVisible(false);
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2271
2293
|
}
|
|
2272
2294
|
|
|
2273
2295
|
/*************
|
|
@@ -2345,7 +2367,7 @@ var Annotation$1 = function (_Component) {
|
|
|
2345
2367
|
case ANNO_MOVED:
|
|
2346
2368
|
case ANNO_CREATED:
|
|
2347
2369
|
// Check if annoation is within image bounds
|
|
2348
|
-
var corrected = correctAnnotation(anno.data, this.props.svg);
|
|
2370
|
+
var corrected = correctAnnotation(anno.data, this.props.svg, this.props.imageOffset);
|
|
2349
2371
|
var newAnno = _extends$5({}, anno, { data: corrected });
|
|
2350
2372
|
var area = getArea(corrected, this.props.svg, anno.type, this.props.image);
|
|
2351
2373
|
if (area !== undefined) {
|
|
@@ -3165,11 +3187,11 @@ var ImgBar = function (_Component) {
|
|
|
3165
3187
|
}, {
|
|
3166
3188
|
key: 'renderImgDescription',
|
|
3167
3189
|
value: function renderImgDescription() {
|
|
3168
|
-
if (this.props.
|
|
3190
|
+
if (this.props.imageMeta.description) {
|
|
3169
3191
|
return React__default.createElement(
|
|
3170
3192
|
semanticUiReact.Menu.Item,
|
|
3171
3193
|
null,
|
|
3172
|
-
this.props.
|
|
3194
|
+
this.props.imageMeta.description
|
|
3173
3195
|
);
|
|
3174
3196
|
} else {
|
|
3175
3197
|
return null;
|
|
@@ -3181,7 +3203,7 @@ var ImgBar = function (_Component) {
|
|
|
3181
3203
|
var _this3 = this;
|
|
3182
3204
|
|
|
3183
3205
|
if (!this.props.visible) return null;
|
|
3184
|
-
if (!this.props.
|
|
3206
|
+
if (!this.props.imageMeta) return null;
|
|
3185
3207
|
// if (!this.props.annos.image.url) return null
|
|
3186
3208
|
return React__default.createElement(
|
|
3187
3209
|
'div',
|
|
@@ -3203,12 +3225,12 @@ var ImgBar = function (_Component) {
|
|
|
3203
3225
|
React__default.createElement(
|
|
3204
3226
|
semanticUiReact.Menu.Item,
|
|
3205
3227
|
null,
|
|
3206
|
-
"ID: " + this.props.
|
|
3228
|
+
"ID: " + this.props.imageMeta.id
|
|
3207
3229
|
),
|
|
3208
3230
|
React__default.createElement(
|
|
3209
3231
|
semanticUiReact.Menu.Item,
|
|
3210
3232
|
null,
|
|
3211
|
-
this.props.
|
|
3233
|
+
this.props.imageMeta.number + " / " + this.props.imageMeta.amount
|
|
3212
3234
|
),
|
|
3213
3235
|
this.renderImgLabels()
|
|
3214
3236
|
)
|
|
@@ -3269,7 +3291,7 @@ var Prompt = function (_Component) {
|
|
|
3269
3291
|
semanticUiReact.Dimmer,
|
|
3270
3292
|
{ page: true,
|
|
3271
3293
|
active: this.state.active,
|
|
3272
|
-
style: { zIndex:
|
|
3294
|
+
style: { zIndex: 7000 },
|
|
3273
3295
|
onClick: function onClick(e) {
|
|
3274
3296
|
return _this2.handleClick(e);
|
|
3275
3297
|
}
|
|
@@ -3541,6 +3563,7 @@ var COPY_ANNOTATION = 'copyAnnotation';
|
|
|
3541
3563
|
var PASTE_ANNOTATION = 'pasteAnnotation';
|
|
3542
3564
|
var RECREATE_ANNO = 'recreateAnnotation';
|
|
3543
3565
|
var DELETE_ANNO_IN_CREATION = 'deleteAnnoInCreation';
|
|
3566
|
+
var TOGGLE_ANNO_COMMENT_INPUT = 'toggleAnnoCommentInput';
|
|
3544
3567
|
|
|
3545
3568
|
var KeyMapper = function () {
|
|
3546
3569
|
function KeyMapper() {
|
|
@@ -3600,6 +3623,8 @@ var KeyMapper = function () {
|
|
|
3600
3623
|
case 'c':
|
|
3601
3624
|
if (this.controlDown) {
|
|
3602
3625
|
this.triggerKeyAction(COPY_ANNOTATION);
|
|
3626
|
+
} else {
|
|
3627
|
+
this.triggerKeyAction(TOGGLE_ANNO_COMMENT_INPUT);
|
|
3603
3628
|
}
|
|
3604
3629
|
break;
|
|
3605
3630
|
case 'v':
|
|
@@ -3763,21 +3788,2975 @@ function getZoomTranslation(w0, svg, s1) {
|
|
|
3763
3788
|
return translation;
|
|
3764
3789
|
}
|
|
3765
3790
|
|
|
3766
|
-
var css$1 = ".SIA_sia-fullscreen__1P3FS {\n position: fixed;\n top: 0;\n left: 0;\n z-index:
|
|
3791
|
+
var css$1 = ".SIA_sia-fullscreen__1P3FS {\n position: fixed;\n top: 0;\n left: 0;\n z-index: 6000;\n width: 100%;\n height: 100%;\n background-color: #FFFF; }\n";
|
|
3767
3792
|
styleInject(css$1);
|
|
3768
3793
|
|
|
3794
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3795
|
+
|
|
3796
|
+
function createCommonjsModule(fn, module) {
|
|
3797
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
var reactDraggable = createCommonjsModule(function (module, exports) {
|
|
3801
|
+
(function (global, factory) {
|
|
3802
|
+
module.exports = factory(reactDom, React__default);
|
|
3803
|
+
})(commonjsGlobal, function (ReactDOM, React$$1) {
|
|
3804
|
+
|
|
3805
|
+
ReactDOM = ReactDOM && ReactDOM.hasOwnProperty('default') ? ReactDOM['default'] : ReactDOM;
|
|
3806
|
+
React$$1 = React$$1 && React$$1.hasOwnProperty('default') ? React$$1['default'] : React$$1;
|
|
3807
|
+
|
|
3808
|
+
function createCommonjsModule$$1(fn, module) {
|
|
3809
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
/**
|
|
3813
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3814
|
+
*
|
|
3815
|
+
* This source code is licensed under the MIT license found in the
|
|
3816
|
+
* LICENSE file in the root directory of this source tree.
|
|
3817
|
+
*
|
|
3818
|
+
*
|
|
3819
|
+
*/
|
|
3820
|
+
|
|
3821
|
+
function makeEmptyFunction(arg) {
|
|
3822
|
+
return function () {
|
|
3823
|
+
return arg;
|
|
3824
|
+
};
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3827
|
+
/**
|
|
3828
|
+
* This function accepts and discards inputs; it has no side effects. This is
|
|
3829
|
+
* primarily useful idiomatically for overridable function endpoints which
|
|
3830
|
+
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
3831
|
+
*/
|
|
3832
|
+
var emptyFunction = function emptyFunction() {};
|
|
3833
|
+
|
|
3834
|
+
emptyFunction.thatReturns = makeEmptyFunction;
|
|
3835
|
+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
3836
|
+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
3837
|
+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
3838
|
+
emptyFunction.thatReturnsThis = function () {
|
|
3839
|
+
return this;
|
|
3840
|
+
};
|
|
3841
|
+
emptyFunction.thatReturnsArgument = function (arg) {
|
|
3842
|
+
return arg;
|
|
3843
|
+
};
|
|
3844
|
+
|
|
3845
|
+
var emptyFunction_1 = emptyFunction;
|
|
3846
|
+
|
|
3847
|
+
/**
|
|
3848
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3849
|
+
*
|
|
3850
|
+
* This source code is licensed under the MIT license found in the
|
|
3851
|
+
* LICENSE file in the root directory of this source tree.
|
|
3852
|
+
*
|
|
3853
|
+
*/
|
|
3854
|
+
|
|
3855
|
+
/**
|
|
3856
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
3857
|
+
*
|
|
3858
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
3859
|
+
* to provide information about what broke and what you were
|
|
3860
|
+
* expecting.
|
|
3861
|
+
*
|
|
3862
|
+
* The invariant message will be stripped in production, but the invariant
|
|
3863
|
+
* will remain to ensure logic does not differ in production.
|
|
3864
|
+
*/
|
|
3865
|
+
|
|
3866
|
+
var validateFormat = function validateFormat(format) {};
|
|
3867
|
+
|
|
3868
|
+
{
|
|
3869
|
+
validateFormat = function validateFormat(format) {
|
|
3870
|
+
if (format === undefined) {
|
|
3871
|
+
throw new Error('invariant requires an error message argument');
|
|
3872
|
+
}
|
|
3873
|
+
};
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
function invariant(condition, format, a, b, c, d, e, f) {
|
|
3877
|
+
validateFormat(format);
|
|
3878
|
+
|
|
3879
|
+
if (!condition) {
|
|
3880
|
+
var error;
|
|
3881
|
+
if (format === undefined) {
|
|
3882
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
3883
|
+
} else {
|
|
3884
|
+
var args = [a, b, c, d, e, f];
|
|
3885
|
+
var argIndex = 0;
|
|
3886
|
+
error = new Error(format.replace(/%s/g, function () {
|
|
3887
|
+
return args[argIndex++];
|
|
3888
|
+
}));
|
|
3889
|
+
error.name = 'Invariant Violation';
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3892
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
3893
|
+
throw error;
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
var invariant_1 = invariant;
|
|
3898
|
+
|
|
3899
|
+
/**
|
|
3900
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
3901
|
+
* This can be used to log issues in development environments in critical
|
|
3902
|
+
* paths. Removing the logging code for production environments will keep the
|
|
3903
|
+
* same logic and follow the same code paths.
|
|
3904
|
+
*/
|
|
3905
|
+
|
|
3906
|
+
var warning = emptyFunction_1;
|
|
3907
|
+
|
|
3908
|
+
{
|
|
3909
|
+
var printWarning = function printWarning(format) {
|
|
3910
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
3911
|
+
args[_key - 1] = arguments[_key];
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3914
|
+
var argIndex = 0;
|
|
3915
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
3916
|
+
return args[argIndex++];
|
|
3917
|
+
});
|
|
3918
|
+
if (typeof console !== 'undefined') {
|
|
3919
|
+
console.error(message);
|
|
3920
|
+
}
|
|
3921
|
+
try {
|
|
3922
|
+
// --- Welcome to debugging React ---
|
|
3923
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
3924
|
+
// to find the callsite that caused this warning to fire.
|
|
3925
|
+
throw new Error(message);
|
|
3926
|
+
} catch (x) {}
|
|
3927
|
+
};
|
|
3928
|
+
|
|
3929
|
+
warning = function warning(condition, format) {
|
|
3930
|
+
if (format === undefined) {
|
|
3931
|
+
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
3935
|
+
return; // Ignore CompositeComponent proptype check.
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
if (!condition) {
|
|
3939
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
3940
|
+
args[_key2 - 2] = arguments[_key2];
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
printWarning.apply(undefined, [format].concat(args));
|
|
3944
|
+
}
|
|
3945
|
+
};
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
var warning_1 = warning;
|
|
3949
|
+
|
|
3950
|
+
/*
|
|
3951
|
+
object-assign
|
|
3952
|
+
(c) Sindre Sorhus
|
|
3953
|
+
@license MIT
|
|
3954
|
+
*/
|
|
3955
|
+
/* eslint-disable no-unused-vars */
|
|
3956
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
3957
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3958
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
3959
|
+
|
|
3960
|
+
function toObject(val) {
|
|
3961
|
+
if (val === null || val === undefined) {
|
|
3962
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
return Object(val);
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
function shouldUseNative() {
|
|
3969
|
+
try {
|
|
3970
|
+
if (!Object.assign) {
|
|
3971
|
+
return false;
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
3975
|
+
|
|
3976
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
3977
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
3978
|
+
test1[5] = 'de';
|
|
3979
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
3980
|
+
return false;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
3984
|
+
var test2 = {};
|
|
3985
|
+
for (var i = 0; i < 10; i++) {
|
|
3986
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
3987
|
+
}
|
|
3988
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
3989
|
+
return test2[n];
|
|
3990
|
+
});
|
|
3991
|
+
if (order2.join('') !== '0123456789') {
|
|
3992
|
+
return false;
|
|
3993
|
+
}
|
|
3994
|
+
|
|
3995
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
3996
|
+
var test3 = {};
|
|
3997
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
3998
|
+
test3[letter] = letter;
|
|
3999
|
+
});
|
|
4000
|
+
if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
|
|
4001
|
+
return false;
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
return true;
|
|
4005
|
+
} catch (err) {
|
|
4006
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
4007
|
+
return false;
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
4012
|
+
var from;
|
|
4013
|
+
var to = toObject(target);
|
|
4014
|
+
var symbols;
|
|
4015
|
+
|
|
4016
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
4017
|
+
from = Object(arguments[s]);
|
|
4018
|
+
|
|
4019
|
+
for (var key in from) {
|
|
4020
|
+
if (hasOwnProperty.call(from, key)) {
|
|
4021
|
+
to[key] = from[key];
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
if (getOwnPropertySymbols) {
|
|
4026
|
+
symbols = getOwnPropertySymbols(from);
|
|
4027
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
4028
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
4029
|
+
to[symbols[i]] = from[symbols[i]];
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
return to;
|
|
4036
|
+
};
|
|
4037
|
+
|
|
4038
|
+
/**
|
|
4039
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
4040
|
+
*
|
|
4041
|
+
* This source code is licensed under the MIT license found in the
|
|
4042
|
+
* LICENSE file in the root directory of this source tree.
|
|
4043
|
+
*/
|
|
4044
|
+
|
|
4045
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
4046
|
+
|
|
4047
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
4048
|
+
|
|
4049
|
+
{
|
|
4050
|
+
var invariant$1 = invariant_1;
|
|
4051
|
+
var warning$1 = warning_1;
|
|
4052
|
+
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
4053
|
+
var loggedTypeFailures = {};
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
/**
|
|
4057
|
+
* Assert that the values match with the type specs.
|
|
4058
|
+
* Error messages are memorized and will only be shown once.
|
|
4059
|
+
*
|
|
4060
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
4061
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
4062
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
4063
|
+
* @param {string} componentName Name of the component for error messages.
|
|
4064
|
+
* @param {?Function} getStack Returns the component stack.
|
|
4065
|
+
* @private
|
|
4066
|
+
*/
|
|
4067
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
4068
|
+
{
|
|
4069
|
+
for (var typeSpecName in typeSpecs) {
|
|
4070
|
+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
4071
|
+
var error;
|
|
4072
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
4073
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
4074
|
+
// After these have been cleaned up, we'll let them throw.
|
|
4075
|
+
try {
|
|
4076
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
4077
|
+
// behavior as without this statement except with a better message.
|
|
4078
|
+
invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
|
4079
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
|
4080
|
+
} catch (ex) {
|
|
4081
|
+
error = ex;
|
|
4082
|
+
}
|
|
4083
|
+
warning$1(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
|
|
4084
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
4085
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
4086
|
+
// same error.
|
|
4087
|
+
loggedTypeFailures[error.message] = true;
|
|
4088
|
+
|
|
4089
|
+
var stack = getStack ? getStack() : '';
|
|
4090
|
+
|
|
4091
|
+
warning$1(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
var checkPropTypes_1 = checkPropTypes;
|
|
4099
|
+
|
|
4100
|
+
var factoryWithTypeCheckers = function (isValidElement, throwOnDirectAccess) {
|
|
4101
|
+
/* global Symbol */
|
|
4102
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
4103
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
4104
|
+
|
|
4105
|
+
/**
|
|
4106
|
+
* Returns the iterator method function contained on the iterable object.
|
|
4107
|
+
*
|
|
4108
|
+
* Be sure to invoke the function with the iterable as context:
|
|
4109
|
+
*
|
|
4110
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
4111
|
+
* if (iteratorFn) {
|
|
4112
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
4113
|
+
* ...
|
|
4114
|
+
* }
|
|
4115
|
+
*
|
|
4116
|
+
* @param {?object} maybeIterable
|
|
4117
|
+
* @return {?function}
|
|
4118
|
+
*/
|
|
4119
|
+
function getIteratorFn(maybeIterable) {
|
|
4120
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
4121
|
+
if (typeof iteratorFn === 'function') {
|
|
4122
|
+
return iteratorFn;
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
/**
|
|
4127
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
4128
|
+
* supplied to React components. Example usage:
|
|
4129
|
+
*
|
|
4130
|
+
* var Props = require('ReactPropTypes');
|
|
4131
|
+
* var MyArticle = React.createClass({
|
|
4132
|
+
* propTypes: {
|
|
4133
|
+
* // An optional string prop named "description".
|
|
4134
|
+
* description: Props.string,
|
|
4135
|
+
*
|
|
4136
|
+
* // A required enum prop named "category".
|
|
4137
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
4138
|
+
*
|
|
4139
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
4140
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
4141
|
+
* },
|
|
4142
|
+
* render: function() { ... }
|
|
4143
|
+
* });
|
|
4144
|
+
*
|
|
4145
|
+
* A more formal specification of how these methods are used:
|
|
4146
|
+
*
|
|
4147
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
4148
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
4149
|
+
*
|
|
4150
|
+
* Each and every declaration produces a function with the same signature. This
|
|
4151
|
+
* allows the creation of custom validation functions. For example:
|
|
4152
|
+
*
|
|
4153
|
+
* var MyLink = React.createClass({
|
|
4154
|
+
* propTypes: {
|
|
4155
|
+
* // An optional string or URI prop named "href".
|
|
4156
|
+
* href: function(props, propName, componentName) {
|
|
4157
|
+
* var propValue = props[propName];
|
|
4158
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
4159
|
+
* !(propValue instanceof URI)) {
|
|
4160
|
+
* return new Error(
|
|
4161
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
4162
|
+
* componentName
|
|
4163
|
+
* );
|
|
4164
|
+
* }
|
|
4165
|
+
* }
|
|
4166
|
+
* },
|
|
4167
|
+
* render: function() {...}
|
|
4168
|
+
* });
|
|
4169
|
+
*
|
|
4170
|
+
* @internal
|
|
4171
|
+
*/
|
|
4172
|
+
|
|
4173
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
4174
|
+
|
|
4175
|
+
// Important!
|
|
4176
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
4177
|
+
var ReactPropTypes = {
|
|
4178
|
+
array: createPrimitiveTypeChecker('array'),
|
|
4179
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
4180
|
+
func: createPrimitiveTypeChecker('function'),
|
|
4181
|
+
number: createPrimitiveTypeChecker('number'),
|
|
4182
|
+
object: createPrimitiveTypeChecker('object'),
|
|
4183
|
+
string: createPrimitiveTypeChecker('string'),
|
|
4184
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
4185
|
+
|
|
4186
|
+
any: createAnyTypeChecker(),
|
|
4187
|
+
arrayOf: createArrayOfTypeChecker,
|
|
4188
|
+
element: createElementTypeChecker(),
|
|
4189
|
+
instanceOf: createInstanceTypeChecker,
|
|
4190
|
+
node: createNodeChecker(),
|
|
4191
|
+
objectOf: createObjectOfTypeChecker,
|
|
4192
|
+
oneOf: createEnumTypeChecker,
|
|
4193
|
+
oneOfType: createUnionTypeChecker,
|
|
4194
|
+
shape: createShapeTypeChecker,
|
|
4195
|
+
exact: createStrictShapeTypeChecker
|
|
4196
|
+
};
|
|
4197
|
+
|
|
4198
|
+
/**
|
|
4199
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
4200
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
4201
|
+
*/
|
|
4202
|
+
/*eslint-disable no-self-compare*/
|
|
4203
|
+
function is(x, y) {
|
|
4204
|
+
// SameValue algorithm
|
|
4205
|
+
if (x === y) {
|
|
4206
|
+
// Steps 1-5, 7-10
|
|
4207
|
+
// Steps 6.b-6.e: +0 != -0
|
|
4208
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
4209
|
+
} else {
|
|
4210
|
+
// Step 6.a: NaN == NaN
|
|
4211
|
+
return x !== x && y !== y;
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
/*eslint-enable no-self-compare*/
|
|
4215
|
+
|
|
4216
|
+
/**
|
|
4217
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
4218
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
4219
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
4220
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
4221
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
4222
|
+
*/
|
|
4223
|
+
function PropTypeError(message) {
|
|
4224
|
+
this.message = message;
|
|
4225
|
+
this.stack = '';
|
|
4226
|
+
}
|
|
4227
|
+
// Make `instanceof Error` still work for returned errors.
|
|
4228
|
+
PropTypeError.prototype = Error.prototype;
|
|
4229
|
+
|
|
4230
|
+
function createChainableTypeChecker(validate) {
|
|
4231
|
+
{
|
|
4232
|
+
var manualPropTypeCallCache = {};
|
|
4233
|
+
var manualPropTypeWarningCount = 0;
|
|
4234
|
+
}
|
|
4235
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
4236
|
+
componentName = componentName || ANONYMOUS;
|
|
4237
|
+
propFullName = propFullName || propName;
|
|
4238
|
+
|
|
4239
|
+
if (secret !== ReactPropTypesSecret_1) {
|
|
4240
|
+
if (throwOnDirectAccess) {
|
|
4241
|
+
// New behavior only for users of `prop-types` package
|
|
4242
|
+
invariant_1(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
|
4243
|
+
} else if (typeof console !== 'undefined') {
|
|
4244
|
+
// Old behavior for people using React.PropTypes
|
|
4245
|
+
var cacheKey = componentName + ':' + propName;
|
|
4246
|
+
if (!manualPropTypeCallCache[cacheKey] &&
|
|
4247
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
4248
|
+
manualPropTypeWarningCount < 3) {
|
|
4249
|
+
warning_1(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);
|
|
4250
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
4251
|
+
manualPropTypeWarningCount++;
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
if (props[propName] == null) {
|
|
4256
|
+
if (isRequired) {
|
|
4257
|
+
if (props[propName] === null) {
|
|
4258
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
4259
|
+
}
|
|
4260
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
4261
|
+
}
|
|
4262
|
+
return null;
|
|
4263
|
+
} else {
|
|
4264
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
|
|
4268
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
4269
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
4270
|
+
|
|
4271
|
+
return chainedCheckType;
|
|
4272
|
+
}
|
|
4273
|
+
|
|
4274
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
4275
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
4276
|
+
var propValue = props[propName];
|
|
4277
|
+
var propType = getPropType(propValue);
|
|
4278
|
+
if (propType !== expectedType) {
|
|
4279
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
4280
|
+
// check, but we can offer a more precise error message here rather than
|
|
4281
|
+
// 'of type `object`'.
|
|
4282
|
+
var preciseType = getPreciseType(propValue);
|
|
4283
|
+
|
|
4284
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
4285
|
+
}
|
|
4286
|
+
return null;
|
|
4287
|
+
}
|
|
4288
|
+
return createChainableTypeChecker(validate);
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
function createAnyTypeChecker() {
|
|
4292
|
+
return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
4296
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4297
|
+
if (typeof typeChecker !== 'function') {
|
|
4298
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
4299
|
+
}
|
|
4300
|
+
var propValue = props[propName];
|
|
4301
|
+
if (!Array.isArray(propValue)) {
|
|
4302
|
+
var propType = getPropType(propValue);
|
|
4303
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
4304
|
+
}
|
|
4305
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
4306
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
|
4307
|
+
if (error instanceof Error) {
|
|
4308
|
+
return error;
|
|
4309
|
+
}
|
|
4310
|
+
}
|
|
4311
|
+
return null;
|
|
4312
|
+
}
|
|
4313
|
+
return createChainableTypeChecker(validate);
|
|
4314
|
+
}
|
|
4315
|
+
|
|
4316
|
+
function createElementTypeChecker() {
|
|
4317
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4318
|
+
var propValue = props[propName];
|
|
4319
|
+
if (!isValidElement(propValue)) {
|
|
4320
|
+
var propType = getPropType(propValue);
|
|
4321
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
4322
|
+
}
|
|
4323
|
+
return null;
|
|
4324
|
+
}
|
|
4325
|
+
return createChainableTypeChecker(validate);
|
|
4326
|
+
}
|
|
4327
|
+
|
|
4328
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
4329
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4330
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
4331
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
4332
|
+
var actualClassName = getClassName(props[propName]);
|
|
4333
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
4334
|
+
}
|
|
4335
|
+
return null;
|
|
4336
|
+
}
|
|
4337
|
+
return createChainableTypeChecker(validate);
|
|
4338
|
+
}
|
|
4339
|
+
|
|
4340
|
+
function createEnumTypeChecker(expectedValues) {
|
|
4341
|
+
if (!Array.isArray(expectedValues)) {
|
|
4342
|
+
warning_1(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
|
|
4343
|
+
return emptyFunction_1.thatReturnsNull;
|
|
4344
|
+
}
|
|
4345
|
+
|
|
4346
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4347
|
+
var propValue = props[propName];
|
|
4348
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
4349
|
+
if (is(propValue, expectedValues[i])) {
|
|
4350
|
+
return null;
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
|
|
4354
|
+
var valuesString = JSON.stringify(expectedValues);
|
|
4355
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
4356
|
+
}
|
|
4357
|
+
return createChainableTypeChecker(validate);
|
|
4358
|
+
}
|
|
4359
|
+
|
|
4360
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
4361
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4362
|
+
if (typeof typeChecker !== 'function') {
|
|
4363
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
4364
|
+
}
|
|
4365
|
+
var propValue = props[propName];
|
|
4366
|
+
var propType = getPropType(propValue);
|
|
4367
|
+
if (propType !== 'object') {
|
|
4368
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
4369
|
+
}
|
|
4370
|
+
for (var key in propValue) {
|
|
4371
|
+
if (propValue.hasOwnProperty(key)) {
|
|
4372
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
4373
|
+
if (error instanceof Error) {
|
|
4374
|
+
return error;
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
}
|
|
4378
|
+
return null;
|
|
4379
|
+
}
|
|
4380
|
+
return createChainableTypeChecker(validate);
|
|
4381
|
+
}
|
|
4382
|
+
|
|
4383
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
4384
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
4385
|
+
warning_1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
|
|
4386
|
+
return emptyFunction_1.thatReturnsNull;
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4389
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
4390
|
+
var checker = arrayOfTypeCheckers[i];
|
|
4391
|
+
if (typeof checker !== 'function') {
|
|
4392
|
+
warning_1(false, 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i);
|
|
4393
|
+
return emptyFunction_1.thatReturnsNull;
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
|
|
4397
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4398
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
4399
|
+
var checker = arrayOfTypeCheckers[i];
|
|
4400
|
+
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
|
4401
|
+
return null;
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
4406
|
+
}
|
|
4407
|
+
return createChainableTypeChecker(validate);
|
|
4408
|
+
}
|
|
4409
|
+
|
|
4410
|
+
function createNodeChecker() {
|
|
4411
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4412
|
+
if (!isNode(props[propName])) {
|
|
4413
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
4414
|
+
}
|
|
4415
|
+
return null;
|
|
4416
|
+
}
|
|
4417
|
+
return createChainableTypeChecker(validate);
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4420
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
4421
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4422
|
+
var propValue = props[propName];
|
|
4423
|
+
var propType = getPropType(propValue);
|
|
4424
|
+
if (propType !== 'object') {
|
|
4425
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
4426
|
+
}
|
|
4427
|
+
for (var key in shapeTypes) {
|
|
4428
|
+
var checker = shapeTypes[key];
|
|
4429
|
+
if (!checker) {
|
|
4430
|
+
continue;
|
|
4431
|
+
}
|
|
4432
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
4433
|
+
if (error) {
|
|
4434
|
+
return error;
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
return null;
|
|
4438
|
+
}
|
|
4439
|
+
return createChainableTypeChecker(validate);
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
4443
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
4444
|
+
var propValue = props[propName];
|
|
4445
|
+
var propType = getPropType(propValue);
|
|
4446
|
+
if (propType !== 'object') {
|
|
4447
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
4448
|
+
}
|
|
4449
|
+
// We need to check all keys in case some are required but missing from
|
|
4450
|
+
// props.
|
|
4451
|
+
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
4452
|
+
for (var key in allKeys) {
|
|
4453
|
+
var checker = shapeTypes[key];
|
|
4454
|
+
if (!checker) {
|
|
4455
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
|
|
4456
|
+
}
|
|
4457
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
4458
|
+
if (error) {
|
|
4459
|
+
return error;
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
return null;
|
|
4463
|
+
}
|
|
4464
|
+
|
|
4465
|
+
return createChainableTypeChecker(validate);
|
|
4466
|
+
}
|
|
4467
|
+
|
|
4468
|
+
function isNode(propValue) {
|
|
4469
|
+
switch (typeof propValue) {
|
|
4470
|
+
case 'number':
|
|
4471
|
+
case 'string':
|
|
4472
|
+
case 'undefined':
|
|
4473
|
+
return true;
|
|
4474
|
+
case 'boolean':
|
|
4475
|
+
return !propValue;
|
|
4476
|
+
case 'object':
|
|
4477
|
+
if (Array.isArray(propValue)) {
|
|
4478
|
+
return propValue.every(isNode);
|
|
4479
|
+
}
|
|
4480
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
4481
|
+
return true;
|
|
4482
|
+
}
|
|
4483
|
+
|
|
4484
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
4485
|
+
if (iteratorFn) {
|
|
4486
|
+
var iterator = iteratorFn.call(propValue);
|
|
4487
|
+
var step;
|
|
4488
|
+
if (iteratorFn !== propValue.entries) {
|
|
4489
|
+
while (!(step = iterator.next()).done) {
|
|
4490
|
+
if (!isNode(step.value)) {
|
|
4491
|
+
return false;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
} else {
|
|
4495
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
4496
|
+
while (!(step = iterator.next()).done) {
|
|
4497
|
+
var entry = step.value;
|
|
4498
|
+
if (entry) {
|
|
4499
|
+
if (!isNode(entry[1])) {
|
|
4500
|
+
return false;
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
} else {
|
|
4506
|
+
return false;
|
|
4507
|
+
}
|
|
4508
|
+
|
|
4509
|
+
return true;
|
|
4510
|
+
default:
|
|
4511
|
+
return false;
|
|
4512
|
+
}
|
|
4513
|
+
}
|
|
4514
|
+
|
|
4515
|
+
function isSymbol(propType, propValue) {
|
|
4516
|
+
// Native Symbol.
|
|
4517
|
+
if (propType === 'symbol') {
|
|
4518
|
+
return true;
|
|
4519
|
+
}
|
|
4520
|
+
|
|
4521
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
4522
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
4523
|
+
return true;
|
|
4524
|
+
}
|
|
4525
|
+
|
|
4526
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
4527
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
4528
|
+
return true;
|
|
4529
|
+
}
|
|
4530
|
+
|
|
4531
|
+
return false;
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4534
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
4535
|
+
function getPropType(propValue) {
|
|
4536
|
+
var propType = typeof propValue;
|
|
4537
|
+
if (Array.isArray(propValue)) {
|
|
4538
|
+
return 'array';
|
|
4539
|
+
}
|
|
4540
|
+
if (propValue instanceof RegExp) {
|
|
4541
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
4542
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
4543
|
+
// passes PropTypes.object.
|
|
4544
|
+
return 'object';
|
|
4545
|
+
}
|
|
4546
|
+
if (isSymbol(propType, propValue)) {
|
|
4547
|
+
return 'symbol';
|
|
4548
|
+
}
|
|
4549
|
+
return propType;
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
4553
|
+
// See `createPrimitiveTypeChecker`.
|
|
4554
|
+
function getPreciseType(propValue) {
|
|
4555
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
4556
|
+
return '' + propValue;
|
|
4557
|
+
}
|
|
4558
|
+
var propType = getPropType(propValue);
|
|
4559
|
+
if (propType === 'object') {
|
|
4560
|
+
if (propValue instanceof Date) {
|
|
4561
|
+
return 'date';
|
|
4562
|
+
} else if (propValue instanceof RegExp) {
|
|
4563
|
+
return 'regexp';
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
return propType;
|
|
4567
|
+
}
|
|
4568
|
+
|
|
4569
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
4570
|
+
// For example, "undefined" or "of type array"
|
|
4571
|
+
function getPostfixForTypeWarning(value) {
|
|
4572
|
+
var type = getPreciseType(value);
|
|
4573
|
+
switch (type) {
|
|
4574
|
+
case 'array':
|
|
4575
|
+
case 'object':
|
|
4576
|
+
return 'an ' + type;
|
|
4577
|
+
case 'boolean':
|
|
4578
|
+
case 'date':
|
|
4579
|
+
case 'regexp':
|
|
4580
|
+
return 'a ' + type;
|
|
4581
|
+
default:
|
|
4582
|
+
return type;
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
|
|
4586
|
+
// Returns class name of the object, if any.
|
|
4587
|
+
function getClassName(propValue) {
|
|
4588
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
4589
|
+
return ANONYMOUS;
|
|
4590
|
+
}
|
|
4591
|
+
return propValue.constructor.name;
|
|
4592
|
+
}
|
|
4593
|
+
|
|
4594
|
+
ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
|
4595
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
4596
|
+
|
|
4597
|
+
return ReactPropTypes;
|
|
4598
|
+
};
|
|
4599
|
+
|
|
4600
|
+
var propTypes = createCommonjsModule$$1(function (module) {
|
|
4601
|
+
/**
|
|
4602
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
4603
|
+
*
|
|
4604
|
+
* This source code is licensed under the MIT license found in the
|
|
4605
|
+
* LICENSE file in the root directory of this source tree.
|
|
4606
|
+
*/
|
|
4607
|
+
|
|
4608
|
+
{
|
|
4609
|
+
var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') || 0xeac7;
|
|
4610
|
+
|
|
4611
|
+
var isValidElement = function (object) {
|
|
4612
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
4613
|
+
};
|
|
4614
|
+
|
|
4615
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
4616
|
+
// http://fb.me/prop-types-in-prod
|
|
4617
|
+
var throwOnDirectAccess = true;
|
|
4618
|
+
module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
|
|
4619
|
+
}
|
|
4620
|
+
});
|
|
4621
|
+
|
|
4622
|
+
var classnames = createCommonjsModule$$1(function (module) {
|
|
4623
|
+
/*!
|
|
4624
|
+
Copyright (c) 2016 Jed Watson.
|
|
4625
|
+
Licensed under the MIT License (MIT), see
|
|
4626
|
+
http://jedwatson.github.io/classnames
|
|
4627
|
+
*/
|
|
4628
|
+
/* global define */
|
|
4629
|
+
|
|
4630
|
+
(function () {
|
|
4631
|
+
|
|
4632
|
+
var hasOwn = {}.hasOwnProperty;
|
|
4633
|
+
|
|
4634
|
+
function classNames() {
|
|
4635
|
+
var classes = [];
|
|
4636
|
+
|
|
4637
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
4638
|
+
var arg = arguments[i];
|
|
4639
|
+
if (!arg) continue;
|
|
4640
|
+
|
|
4641
|
+
var argType = typeof arg;
|
|
4642
|
+
|
|
4643
|
+
if (argType === 'string' || argType === 'number') {
|
|
4644
|
+
classes.push(arg);
|
|
4645
|
+
} else if (Array.isArray(arg)) {
|
|
4646
|
+
classes.push(classNames.apply(null, arg));
|
|
4647
|
+
} else if (argType === 'object') {
|
|
4648
|
+
for (var key in arg) {
|
|
4649
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
4650
|
+
classes.push(key);
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4656
|
+
return classes.join(' ');
|
|
4657
|
+
}
|
|
4658
|
+
|
|
4659
|
+
if (module.exports) {
|
|
4660
|
+
module.exports = classNames;
|
|
4661
|
+
} else {
|
|
4662
|
+
window.classNames = classNames;
|
|
4663
|
+
}
|
|
4664
|
+
})();
|
|
4665
|
+
});
|
|
4666
|
+
|
|
4667
|
+
// @credits https://gist.github.com/rogozhnikoff/a43cfed27c41e4e68cdc
|
|
4668
|
+
function findInArray(array /*: Array<any> | TouchList*/, callback /*: Function*/) /*: any*/{
|
|
4669
|
+
for (var i = 0, length = array.length; i < length; i++) {
|
|
4670
|
+
if (callback.apply(callback, [array[i], i, array])) return array[i];
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
|
|
4674
|
+
function isFunction(func /*: any*/) /*: boolean*/{
|
|
4675
|
+
return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]';
|
|
4676
|
+
}
|
|
4677
|
+
|
|
4678
|
+
function isNum(num /*: any*/) /*: boolean*/{
|
|
4679
|
+
return typeof num === 'number' && !isNaN(num);
|
|
4680
|
+
}
|
|
4681
|
+
|
|
4682
|
+
function int(a /*: string*/) /*: number*/{
|
|
4683
|
+
return parseInt(a, 10);
|
|
4684
|
+
}
|
|
4685
|
+
|
|
4686
|
+
function dontSetMe(props /*: Object*/, propName /*: string*/, componentName /*: string*/) {
|
|
4687
|
+
if (props[propName]) {
|
|
4688
|
+
return new Error('Invalid prop ' + propName + ' passed to ' + componentName + ' - do not set this, set it on the child.');
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
var prefixes = ['Moz', 'Webkit', 'O', 'ms'];
|
|
4693
|
+
function getPrefix() /*: string*/{
|
|
4694
|
+
var prop /*: string*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform';
|
|
4695
|
+
|
|
4696
|
+
// Checking specifically for 'window.document' is for pseudo-browser server-side
|
|
4697
|
+
// environments that define 'window' as the global context.
|
|
4698
|
+
// E.g. React-rails (see https://github.com/reactjs/react-rails/pull/84)
|
|
4699
|
+
if (typeof window === 'undefined' || typeof window.document === 'undefined') return '';
|
|
4700
|
+
|
|
4701
|
+
var style = window.document.documentElement.style;
|
|
4702
|
+
|
|
4703
|
+
if (prop in style) return '';
|
|
4704
|
+
|
|
4705
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
4706
|
+
if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
|
|
4707
|
+
}
|
|
4708
|
+
|
|
4709
|
+
return '';
|
|
4710
|
+
}
|
|
4711
|
+
|
|
4712
|
+
function browserPrefixToKey(prop /*: string*/, prefix /*: string*/) /*: string*/{
|
|
4713
|
+
return prefix ? '' + prefix + kebabToTitleCase(prop) : prop;
|
|
4714
|
+
}
|
|
4715
|
+
|
|
4716
|
+
function kebabToTitleCase(str /*: string*/) /*: string*/{
|
|
4717
|
+
var out = '';
|
|
4718
|
+
var shouldCapitalize = true;
|
|
4719
|
+
for (var i = 0; i < str.length; i++) {
|
|
4720
|
+
if (shouldCapitalize) {
|
|
4721
|
+
out += str[i].toUpperCase();
|
|
4722
|
+
shouldCapitalize = false;
|
|
4723
|
+
} else if (str[i] === '-') {
|
|
4724
|
+
shouldCapitalize = true;
|
|
4725
|
+
} else {
|
|
4726
|
+
out += str[i];
|
|
4727
|
+
}
|
|
4728
|
+
}
|
|
4729
|
+
return out;
|
|
4730
|
+
}
|
|
4731
|
+
|
|
4732
|
+
// Default export is the prefix itself, like 'Moz', 'Webkit', etc
|
|
4733
|
+
// Note that you may have to re-test for certain things; for instance, Chrome 50
|
|
4734
|
+
// can handle unprefixed `transform`, but not unprefixed `user-select`
|
|
4735
|
+
var browserPrefix = getPrefix();
|
|
4736
|
+
|
|
4737
|
+
var classCallCheck = function (instance, Constructor) {
|
|
4738
|
+
if (!(instance instanceof Constructor)) {
|
|
4739
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4740
|
+
}
|
|
4741
|
+
};
|
|
4742
|
+
|
|
4743
|
+
var createClass = function () {
|
|
4744
|
+
function defineProperties(target, props) {
|
|
4745
|
+
for (var i = 0; i < props.length; i++) {
|
|
4746
|
+
var descriptor = props[i];
|
|
4747
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
4748
|
+
descriptor.configurable = true;
|
|
4749
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
4750
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
|
|
4754
|
+
return function (Constructor, protoProps, staticProps) {
|
|
4755
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
4756
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
4757
|
+
return Constructor;
|
|
4758
|
+
};
|
|
4759
|
+
}();
|
|
4760
|
+
|
|
4761
|
+
var defineProperty = function (obj, key, value) {
|
|
4762
|
+
if (key in obj) {
|
|
4763
|
+
Object.defineProperty(obj, key, {
|
|
4764
|
+
value: value,
|
|
4765
|
+
enumerable: true,
|
|
4766
|
+
configurable: true,
|
|
4767
|
+
writable: true
|
|
4768
|
+
});
|
|
4769
|
+
} else {
|
|
4770
|
+
obj[key] = value;
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
return obj;
|
|
4774
|
+
};
|
|
4775
|
+
|
|
4776
|
+
var _extends = Object.assign || function (target) {
|
|
4777
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
4778
|
+
var source = arguments[i];
|
|
4779
|
+
|
|
4780
|
+
for (var key in source) {
|
|
4781
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
4782
|
+
target[key] = source[key];
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
4786
|
+
|
|
4787
|
+
return target;
|
|
4788
|
+
};
|
|
4789
|
+
|
|
4790
|
+
var inherits = function (subClass, superClass) {
|
|
4791
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
4792
|
+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
4793
|
+
}
|
|
4794
|
+
|
|
4795
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
4796
|
+
constructor: {
|
|
4797
|
+
value: subClass,
|
|
4798
|
+
enumerable: false,
|
|
4799
|
+
writable: true,
|
|
4800
|
+
configurable: true
|
|
4801
|
+
}
|
|
4802
|
+
});
|
|
4803
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
4804
|
+
};
|
|
4805
|
+
|
|
4806
|
+
var possibleConstructorReturn = function (self, call) {
|
|
4807
|
+
if (!self) {
|
|
4808
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4809
|
+
}
|
|
4810
|
+
|
|
4811
|
+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
4812
|
+
};
|
|
4813
|
+
|
|
4814
|
+
var slicedToArray = function () {
|
|
4815
|
+
function sliceIterator(arr, i) {
|
|
4816
|
+
var _arr = [];
|
|
4817
|
+
var _n = true;
|
|
4818
|
+
var _d = false;
|
|
4819
|
+
var _e = undefined;
|
|
4820
|
+
|
|
4821
|
+
try {
|
|
4822
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
4823
|
+
_arr.push(_s.value);
|
|
4824
|
+
|
|
4825
|
+
if (i && _arr.length === i) break;
|
|
4826
|
+
}
|
|
4827
|
+
} catch (err) {
|
|
4828
|
+
_d = true;
|
|
4829
|
+
_e = err;
|
|
4830
|
+
} finally {
|
|
4831
|
+
try {
|
|
4832
|
+
if (!_n && _i["return"]) _i["return"]();
|
|
4833
|
+
} finally {
|
|
4834
|
+
if (_d) throw _e;
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
|
|
4838
|
+
return _arr;
|
|
4839
|
+
}
|
|
4840
|
+
|
|
4841
|
+
return function (arr, i) {
|
|
4842
|
+
if (Array.isArray(arr)) {
|
|
4843
|
+
return arr;
|
|
4844
|
+
} else if (Symbol.iterator in Object(arr)) {
|
|
4845
|
+
return sliceIterator(arr, i);
|
|
4846
|
+
} else {
|
|
4847
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
4848
|
+
}
|
|
4849
|
+
};
|
|
4850
|
+
}();
|
|
4851
|
+
|
|
4852
|
+
/*:: import type {ControlPosition, PositionOffsetControlPosition, MouseTouchEvent} from './types';*/
|
|
4853
|
+
|
|
4854
|
+
var matchesSelectorFunc = '';
|
|
4855
|
+
function matchesSelector(el /*: Node*/, selector /*: string*/) /*: boolean*/{
|
|
4856
|
+
if (!matchesSelectorFunc) {
|
|
4857
|
+
matchesSelectorFunc = findInArray(['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'], function (method) {
|
|
4858
|
+
// $FlowIgnore: Doesn't think elements are indexable
|
|
4859
|
+
return isFunction(el[method]);
|
|
4860
|
+
});
|
|
4861
|
+
}
|
|
4862
|
+
|
|
4863
|
+
// Might not be found entirely (not an Element?) - in that case, bail
|
|
4864
|
+
// $FlowIgnore: Doesn't think elements are indexable
|
|
4865
|
+
if (!isFunction(el[matchesSelectorFunc])) return false;
|
|
4866
|
+
|
|
4867
|
+
// $FlowIgnore: Doesn't think elements are indexable
|
|
4868
|
+
return el[matchesSelectorFunc](selector);
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4871
|
+
// Works up the tree to the draggable itself attempting to match selector.
|
|
4872
|
+
function matchesSelectorAndParentsTo(el /*: Node*/, selector /*: string*/, baseNode /*: Node*/) /*: boolean*/{
|
|
4873
|
+
var node = el;
|
|
4874
|
+
do {
|
|
4875
|
+
if (matchesSelector(node, selector)) return true;
|
|
4876
|
+
if (node === baseNode) return false;
|
|
4877
|
+
node = node.parentNode;
|
|
4878
|
+
} while (node);
|
|
4879
|
+
|
|
4880
|
+
return false;
|
|
4881
|
+
}
|
|
4882
|
+
|
|
4883
|
+
function addEvent(el /*: ?Node*/, event /*: string*/, handler /*: Function*/) /*: void*/{
|
|
4884
|
+
if (!el) {
|
|
4885
|
+
return;
|
|
4886
|
+
}
|
|
4887
|
+
if (el.attachEvent) {
|
|
4888
|
+
el.attachEvent('on' + event, handler);
|
|
4889
|
+
} else if (el.addEventListener) {
|
|
4890
|
+
el.addEventListener(event, handler, true);
|
|
4891
|
+
} else {
|
|
4892
|
+
// $FlowIgnore: Doesn't think elements are indexable
|
|
4893
|
+
el['on' + event] = handler;
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
|
|
4897
|
+
function removeEvent(el /*: ?Node*/, event /*: string*/, handler /*: Function*/) /*: void*/{
|
|
4898
|
+
if (!el) {
|
|
4899
|
+
return;
|
|
4900
|
+
}
|
|
4901
|
+
if (el.detachEvent) {
|
|
4902
|
+
el.detachEvent('on' + event, handler);
|
|
4903
|
+
} else if (el.removeEventListener) {
|
|
4904
|
+
el.removeEventListener(event, handler, true);
|
|
4905
|
+
} else {
|
|
4906
|
+
// $FlowIgnore: Doesn't think elements are indexable
|
|
4907
|
+
el['on' + event] = null;
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
|
|
4911
|
+
function outerHeight(node /*: HTMLElement*/) /*: number*/{
|
|
4912
|
+
// This is deliberately excluding margin for our calculations, since we are using
|
|
4913
|
+
// offsetTop which is including margin. See getBoundPosition
|
|
4914
|
+
var height = node.clientHeight;
|
|
4915
|
+
var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
|
|
4916
|
+
height += int(computedStyle.borderTopWidth);
|
|
4917
|
+
height += int(computedStyle.borderBottomWidth);
|
|
4918
|
+
return height;
|
|
4919
|
+
}
|
|
4920
|
+
|
|
4921
|
+
function outerWidth(node /*: HTMLElement*/) /*: number*/{
|
|
4922
|
+
// This is deliberately excluding margin for our calculations, since we are using
|
|
4923
|
+
// offsetLeft which is including margin. See getBoundPosition
|
|
4924
|
+
var width = node.clientWidth;
|
|
4925
|
+
var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
|
|
4926
|
+
width += int(computedStyle.borderLeftWidth);
|
|
4927
|
+
width += int(computedStyle.borderRightWidth);
|
|
4928
|
+
return width;
|
|
4929
|
+
}
|
|
4930
|
+
function innerHeight(node /*: HTMLElement*/) /*: number*/{
|
|
4931
|
+
var height = node.clientHeight;
|
|
4932
|
+
var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
|
|
4933
|
+
height -= int(computedStyle.paddingTop);
|
|
4934
|
+
height -= int(computedStyle.paddingBottom);
|
|
4935
|
+
return height;
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4938
|
+
function innerWidth(node /*: HTMLElement*/) /*: number*/{
|
|
4939
|
+
var width = node.clientWidth;
|
|
4940
|
+
var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
|
|
4941
|
+
width -= int(computedStyle.paddingLeft);
|
|
4942
|
+
width -= int(computedStyle.paddingRight);
|
|
4943
|
+
return width;
|
|
4944
|
+
}
|
|
4945
|
+
|
|
4946
|
+
// Get from offsetParent
|
|
4947
|
+
function offsetXYFromParent(evt /*: {clientX: number, clientY: number}*/, offsetParent /*: HTMLElement*/) /*: ControlPosition*/{
|
|
4948
|
+
var isBody = offsetParent === offsetParent.ownerDocument.body;
|
|
4949
|
+
var offsetParentRect = isBody ? { left: 0, top: 0 } : offsetParent.getBoundingClientRect();
|
|
4950
|
+
|
|
4951
|
+
var x = evt.clientX + offsetParent.scrollLeft - offsetParentRect.left;
|
|
4952
|
+
var y = evt.clientY + offsetParent.scrollTop - offsetParentRect.top;
|
|
4953
|
+
|
|
4954
|
+
return { x: x, y: y };
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
function createCSSTransform(controlPos /*: ControlPosition*/, positionOffset /*: PositionOffsetControlPosition*/) /*: Object*/{
|
|
4958
|
+
var translation = getTranslation(controlPos, positionOffset, 'px');
|
|
4959
|
+
return defineProperty({}, browserPrefixToKey('transform', browserPrefix), translation);
|
|
4960
|
+
}
|
|
4961
|
+
|
|
4962
|
+
function createSVGTransform(controlPos /*: ControlPosition*/, positionOffset /*: PositionOffsetControlPosition*/) /*: string*/{
|
|
4963
|
+
var translation = getTranslation(controlPos, positionOffset, '');
|
|
4964
|
+
return translation;
|
|
4965
|
+
}
|
|
4966
|
+
function getTranslation(_ref2, positionOffset /*: PositionOffsetControlPosition*/, unitSuffix /*: string*/) /*: string*/{
|
|
4967
|
+
var x = _ref2.x,
|
|
4968
|
+
y = _ref2.y;
|
|
4969
|
+
|
|
4970
|
+
var translation = 'translate(' + x + unitSuffix + ',' + y + unitSuffix + ')';
|
|
4971
|
+
if (positionOffset) {
|
|
4972
|
+
var defaultX = '' + (typeof positionOffset.x === 'string' ? positionOffset.x : positionOffset.x + unitSuffix);
|
|
4973
|
+
var defaultY = '' + (typeof positionOffset.y === 'string' ? positionOffset.y : positionOffset.y + unitSuffix);
|
|
4974
|
+
translation = 'translate(' + defaultX + ', ' + defaultY + ')' + translation;
|
|
4975
|
+
}
|
|
4976
|
+
return translation;
|
|
4977
|
+
}
|
|
4978
|
+
|
|
4979
|
+
function getTouch(e /*: MouseTouchEvent*/, identifier /*: number*/) /*: ?{clientX: number, clientY: number}*/{
|
|
4980
|
+
return e.targetTouches && findInArray(e.targetTouches, function (t) {
|
|
4981
|
+
return identifier === t.identifier;
|
|
4982
|
+
}) || e.changedTouches && findInArray(e.changedTouches, function (t) {
|
|
4983
|
+
return identifier === t.identifier;
|
|
4984
|
+
});
|
|
4985
|
+
}
|
|
4986
|
+
|
|
4987
|
+
function getTouchIdentifier(e /*: MouseTouchEvent*/) /*: ?number*/{
|
|
4988
|
+
if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
|
|
4989
|
+
if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
|
|
4990
|
+
}
|
|
4991
|
+
|
|
4992
|
+
// User-select Hacks:
|
|
4993
|
+
//
|
|
4994
|
+
// Useful for preventing blue highlights all over everything when dragging.
|
|
4995
|
+
|
|
4996
|
+
// Note we're passing `document` b/c we could be iframed
|
|
4997
|
+
function addUserSelectStyles(doc /*: ?Document*/) {
|
|
4998
|
+
if (!doc) return;
|
|
4999
|
+
var styleEl = doc.getElementById('react-draggable-style-el');
|
|
5000
|
+
if (!styleEl) {
|
|
5001
|
+
styleEl = doc.createElement('style');
|
|
5002
|
+
styleEl.type = 'text/css';
|
|
5003
|
+
styleEl.id = 'react-draggable-style-el';
|
|
5004
|
+
styleEl.innerHTML = '.react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n';
|
|
5005
|
+
styleEl.innerHTML += '.react-draggable-transparent-selection *::selection {all: inherit;}\n';
|
|
5006
|
+
doc.getElementsByTagName('head')[0].appendChild(styleEl);
|
|
5007
|
+
}
|
|
5008
|
+
if (doc.body) addClassName(doc.body, 'react-draggable-transparent-selection');
|
|
5009
|
+
}
|
|
5010
|
+
|
|
5011
|
+
function removeUserSelectStyles(doc /*: ?Document*/) {
|
|
5012
|
+
try {
|
|
5013
|
+
if (doc && doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection');
|
|
5014
|
+
// $FlowIgnore: IE
|
|
5015
|
+
if (doc.selection) {
|
|
5016
|
+
// $FlowIgnore: IE
|
|
5017
|
+
doc.selection.empty();
|
|
5018
|
+
} else {
|
|
5019
|
+
window.getSelection().removeAllRanges(); // remove selection caused by scroll
|
|
5020
|
+
}
|
|
5021
|
+
} catch (e) {
|
|
5022
|
+
// probably IE
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
function styleHacks() /*: Object*/{
|
|
5027
|
+
var childStyle /*: Object*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5028
|
+
|
|
5029
|
+
// Workaround IE pointer events; see #51
|
|
5030
|
+
// https://github.com/mzabriskie/react-draggable/issues/51#issuecomment-103488278
|
|
5031
|
+
return _extends({
|
|
5032
|
+
touchAction: 'none'
|
|
5033
|
+
}, childStyle);
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
function addClassName(el /*: HTMLElement*/, className /*: string*/) {
|
|
5037
|
+
if (el.classList) {
|
|
5038
|
+
el.classList.add(className);
|
|
5039
|
+
} else {
|
|
5040
|
+
if (!el.className.match(new RegExp('(?:^|\\s)' + className + '(?!\\S)'))) {
|
|
5041
|
+
el.className += ' ' + className;
|
|
5042
|
+
}
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5046
|
+
function removeClassName(el /*: HTMLElement*/, className /*: string*/) {
|
|
5047
|
+
if (el.classList) {
|
|
5048
|
+
el.classList.remove(className);
|
|
5049
|
+
} else {
|
|
5050
|
+
el.className = el.className.replace(new RegExp('(?:^|\\s)' + className + '(?!\\S)', 'g'), '');
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
|
|
5054
|
+
/*:: import type Draggable from '../Draggable';*/
|
|
5055
|
+
/*:: import type {Bounds, ControlPosition, DraggableData, MouseTouchEvent} from './types';*/
|
|
5056
|
+
/*:: import type DraggableCore from '../DraggableCore';*/
|
|
5057
|
+
|
|
5058
|
+
function getBoundPosition(draggable /*: Draggable*/, x /*: number*/, y /*: number*/) /*: [number, number]*/{
|
|
5059
|
+
// If no bounds, short-circuit and move on
|
|
5060
|
+
if (!draggable.props.bounds) return [x, y];
|
|
5061
|
+
|
|
5062
|
+
// Clone new bounds
|
|
5063
|
+
var bounds = draggable.props.bounds;
|
|
5064
|
+
|
|
5065
|
+
bounds = typeof bounds === 'string' ? bounds : cloneBounds(bounds);
|
|
5066
|
+
var node = findDOMNode(draggable);
|
|
5067
|
+
|
|
5068
|
+
if (typeof bounds === 'string') {
|
|
5069
|
+
var ownerDocument = node.ownerDocument;
|
|
5070
|
+
|
|
5071
|
+
var ownerWindow = ownerDocument.defaultView;
|
|
5072
|
+
var boundNode = void 0;
|
|
5073
|
+
if (bounds === 'parent') {
|
|
5074
|
+
boundNode = node.parentNode;
|
|
5075
|
+
} else {
|
|
5076
|
+
boundNode = ownerDocument.querySelector(bounds);
|
|
5077
|
+
}
|
|
5078
|
+
if (!(boundNode instanceof ownerWindow.HTMLElement)) {
|
|
5079
|
+
throw new Error('Bounds selector "' + bounds + '" could not find an element.');
|
|
5080
|
+
}
|
|
5081
|
+
var nodeStyle = ownerWindow.getComputedStyle(node);
|
|
5082
|
+
var boundNodeStyle = ownerWindow.getComputedStyle(boundNode);
|
|
5083
|
+
// Compute bounds. This is a pain with padding and offsets but this gets it exactly right.
|
|
5084
|
+
bounds = {
|
|
5085
|
+
left: -node.offsetLeft + int(boundNodeStyle.paddingLeft) + int(nodeStyle.marginLeft),
|
|
5086
|
+
top: -node.offsetTop + int(boundNodeStyle.paddingTop) + int(nodeStyle.marginTop),
|
|
5087
|
+
right: innerWidth(boundNode) - outerWidth(node) - node.offsetLeft + int(boundNodeStyle.paddingRight) - int(nodeStyle.marginRight),
|
|
5088
|
+
bottom: innerHeight(boundNode) - outerHeight(node) - node.offsetTop + int(boundNodeStyle.paddingBottom) - int(nodeStyle.marginBottom)
|
|
5089
|
+
};
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
// Keep x and y below right and bottom limits...
|
|
5093
|
+
if (isNum(bounds.right)) x = Math.min(x, bounds.right);
|
|
5094
|
+
if (isNum(bounds.bottom)) y = Math.min(y, bounds.bottom);
|
|
5095
|
+
|
|
5096
|
+
// But above left and top limits.
|
|
5097
|
+
if (isNum(bounds.left)) x = Math.max(x, bounds.left);
|
|
5098
|
+
if (isNum(bounds.top)) y = Math.max(y, bounds.top);
|
|
5099
|
+
|
|
5100
|
+
return [x, y];
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
function snapToGrid(grid /*: [number, number]*/, pendingX /*: number*/, pendingY /*: number*/) /*: [number, number]*/{
|
|
5104
|
+
var x = Math.round(pendingX / grid[0]) * grid[0];
|
|
5105
|
+
var y = Math.round(pendingY / grid[1]) * grid[1];
|
|
5106
|
+
return [x, y];
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5109
|
+
function canDragX(draggable /*: Draggable*/) /*: boolean*/{
|
|
5110
|
+
return draggable.props.axis === 'both' || draggable.props.axis === 'x';
|
|
5111
|
+
}
|
|
5112
|
+
|
|
5113
|
+
function canDragY(draggable /*: Draggable*/) /*: boolean*/{
|
|
5114
|
+
return draggable.props.axis === 'both' || draggable.props.axis === 'y';
|
|
5115
|
+
}
|
|
5116
|
+
|
|
5117
|
+
// Get {x, y} positions from event.
|
|
5118
|
+
function getControlPosition(e /*: MouseTouchEvent*/, touchIdentifier /*: ?number*/, draggableCore /*: DraggableCore*/) /*: ?ControlPosition*/{
|
|
5119
|
+
var touchObj = typeof touchIdentifier === 'number' ? getTouch(e, touchIdentifier) : null;
|
|
5120
|
+
if (typeof touchIdentifier === 'number' && !touchObj) return null; // not the right touch
|
|
5121
|
+
var node = findDOMNode(draggableCore);
|
|
5122
|
+
// User can provide an offsetParent if desired.
|
|
5123
|
+
var offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
|
|
5124
|
+
return offsetXYFromParent(touchObj || e, offsetParent);
|
|
5125
|
+
}
|
|
5126
|
+
|
|
5127
|
+
// Create an data object exposed by <DraggableCore>'s events
|
|
5128
|
+
function createCoreData(draggable /*: DraggableCore*/, x /*: number*/, y /*: number*/) /*: DraggableData*/{
|
|
5129
|
+
var state = draggable.state;
|
|
5130
|
+
var isStart = !isNum(state.lastX);
|
|
5131
|
+
var node = findDOMNode(draggable);
|
|
5132
|
+
|
|
5133
|
+
if (isStart) {
|
|
5134
|
+
// If this is our first move, use the x and y as last coords.
|
|
5135
|
+
return {
|
|
5136
|
+
node: node,
|
|
5137
|
+
deltaX: 0, deltaY: 0,
|
|
5138
|
+
lastX: x, lastY: y,
|
|
5139
|
+
x: x, y: y
|
|
5140
|
+
};
|
|
5141
|
+
} else {
|
|
5142
|
+
// Otherwise calculate proper values.
|
|
5143
|
+
return {
|
|
5144
|
+
node: node,
|
|
5145
|
+
deltaX: x - state.lastX, deltaY: y - state.lastY,
|
|
5146
|
+
lastX: state.lastX, lastY: state.lastY,
|
|
5147
|
+
x: x, y: y
|
|
5148
|
+
};
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
|
|
5152
|
+
// Create an data exposed by <Draggable>'s events
|
|
5153
|
+
function createDraggableData(draggable /*: Draggable*/, coreData /*: DraggableData*/) /*: DraggableData*/{
|
|
5154
|
+
var scale = draggable.props.scale;
|
|
5155
|
+
return {
|
|
5156
|
+
node: coreData.node,
|
|
5157
|
+
x: draggable.state.x + coreData.deltaX / scale,
|
|
5158
|
+
y: draggable.state.y + coreData.deltaY / scale,
|
|
5159
|
+
deltaX: coreData.deltaX / scale,
|
|
5160
|
+
deltaY: coreData.deltaY / scale,
|
|
5161
|
+
lastX: draggable.state.x,
|
|
5162
|
+
lastY: draggable.state.y
|
|
5163
|
+
};
|
|
5164
|
+
}
|
|
5165
|
+
|
|
5166
|
+
// A lot faster than stringify/parse
|
|
5167
|
+
function cloneBounds(bounds /*: Bounds*/) /*: Bounds*/{
|
|
5168
|
+
return {
|
|
5169
|
+
left: bounds.left,
|
|
5170
|
+
top: bounds.top,
|
|
5171
|
+
right: bounds.right,
|
|
5172
|
+
bottom: bounds.bottom
|
|
5173
|
+
};
|
|
5174
|
+
}
|
|
5175
|
+
|
|
5176
|
+
function findDOMNode(draggable /*: Draggable | DraggableCore*/) /*: HTMLElement*/{
|
|
5177
|
+
var node = ReactDOM.findDOMNode(draggable);
|
|
5178
|
+
if (!node) {
|
|
5179
|
+
throw new Error('<DraggableCore>: Unmounted during event!');
|
|
5180
|
+
}
|
|
5181
|
+
// $FlowIgnore we can't assert on HTMLElement due to tests... FIXME
|
|
5182
|
+
return node;
|
|
5183
|
+
}
|
|
5184
|
+
|
|
5185
|
+
/*eslint no-console:0*/
|
|
5186
|
+
function log() {}
|
|
5187
|
+
|
|
5188
|
+
/*:: import type {EventHandler, MouseTouchEvent} from './utils/types';*/
|
|
5189
|
+
|
|
5190
|
+
// Simple abstraction for dragging events names.
|
|
5191
|
+
/*:: import type {Element as ReactElement} from 'react';*/
|
|
5192
|
+
var eventsFor = {
|
|
5193
|
+
touch: {
|
|
5194
|
+
start: 'touchstart',
|
|
5195
|
+
move: 'touchmove',
|
|
5196
|
+
stop: 'touchend'
|
|
5197
|
+
},
|
|
5198
|
+
mouse: {
|
|
5199
|
+
start: 'mousedown',
|
|
5200
|
+
move: 'mousemove',
|
|
5201
|
+
stop: 'mouseup'
|
|
5202
|
+
}
|
|
5203
|
+
};
|
|
5204
|
+
|
|
5205
|
+
// Default to mouse events.
|
|
5206
|
+
var dragEventFor = eventsFor.mouse;
|
|
5207
|
+
|
|
5208
|
+
/*:: type DraggableCoreState = {
|
|
5209
|
+
dragging: boolean,
|
|
5210
|
+
lastX: number,
|
|
5211
|
+
lastY: number,
|
|
5212
|
+
touchIdentifier: ?number
|
|
5213
|
+
};*/
|
|
5214
|
+
/*:: export type DraggableBounds = {
|
|
5215
|
+
left: number,
|
|
5216
|
+
right: number,
|
|
5217
|
+
top: number,
|
|
5218
|
+
bottom: number,
|
|
5219
|
+
};*/
|
|
5220
|
+
/*:: export type DraggableData = {
|
|
5221
|
+
node: HTMLElement,
|
|
5222
|
+
x: number, y: number,
|
|
5223
|
+
deltaX: number, deltaY: number,
|
|
5224
|
+
lastX: number, lastY: number,
|
|
5225
|
+
};*/
|
|
5226
|
+
/*:: export type DraggableEventHandler = (e: MouseEvent, data: DraggableData) => void;*/
|
|
5227
|
+
/*:: export type ControlPosition = {x: number, y: number};*/
|
|
5228
|
+
/*:: export type PositionOffsetControlPosition = {x: number|string, y: number|string};*/
|
|
5229
|
+
|
|
5230
|
+
//
|
|
5231
|
+
// Define <DraggableCore>.
|
|
5232
|
+
//
|
|
5233
|
+
// <DraggableCore> is for advanced usage of <Draggable>. It maintains minimal internal state so it can
|
|
5234
|
+
// work well with libraries that require more control over the element.
|
|
5235
|
+
//
|
|
5236
|
+
|
|
5237
|
+
/*:: export type DraggableCoreProps = {
|
|
5238
|
+
allowAnyClick: boolean,
|
|
5239
|
+
cancel: string,
|
|
5240
|
+
children: ReactElement<any>,
|
|
5241
|
+
disabled: boolean,
|
|
5242
|
+
enableUserSelectHack: boolean,
|
|
5243
|
+
offsetParent: HTMLElement,
|
|
5244
|
+
grid: [number, number],
|
|
5245
|
+
handle: string,
|
|
5246
|
+
onStart: DraggableEventHandler,
|
|
5247
|
+
onDrag: DraggableEventHandler,
|
|
5248
|
+
onStop: DraggableEventHandler,
|
|
5249
|
+
onMouseDown: (e: MouseEvent) => void,
|
|
5250
|
+
};*/
|
|
5251
|
+
|
|
5252
|
+
var DraggableCore = function (_React$Component) {
|
|
5253
|
+
inherits(DraggableCore, _React$Component);
|
|
5254
|
+
|
|
5255
|
+
function DraggableCore() {
|
|
5256
|
+
var _ref;
|
|
5257
|
+
|
|
5258
|
+
var _temp, _this, _ret;
|
|
5259
|
+
|
|
5260
|
+
classCallCheck(this, DraggableCore);
|
|
5261
|
+
|
|
5262
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
5263
|
+
args[_key] = arguments[_key];
|
|
5264
|
+
}
|
|
5265
|
+
|
|
5266
|
+
return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = DraggableCore.__proto__ || Object.getPrototypeOf(DraggableCore)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
|
5267
|
+
dragging: false,
|
|
5268
|
+
// Used while dragging to determine deltas.
|
|
5269
|
+
lastX: NaN, lastY: NaN,
|
|
5270
|
+
touchIdentifier: null
|
|
5271
|
+
}, _this.handleDragStart = function (e) {
|
|
5272
|
+
// Make it possible to attach event handlers on top of this one.
|
|
5273
|
+
_this.props.onMouseDown(e);
|
|
5274
|
+
|
|
5275
|
+
// Only accept left-clicks.
|
|
5276
|
+
if (!_this.props.allowAnyClick && typeof e.button === 'number' && e.button !== 0) return false;
|
|
5277
|
+
|
|
5278
|
+
// Get nodes. Be sure to grab relative document (could be iframed)
|
|
5279
|
+
var thisNode = ReactDOM.findDOMNode(_this);
|
|
5280
|
+
if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) {
|
|
5281
|
+
throw new Error('<DraggableCore> not mounted on DragStart!');
|
|
5282
|
+
}
|
|
5283
|
+
var ownerDocument = thisNode.ownerDocument;
|
|
5284
|
+
|
|
5285
|
+
// Short circuit if handle or cancel prop was provided and selector doesn't match.
|
|
5286
|
+
|
|
5287
|
+
if (_this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || _this.props.handle && !matchesSelectorAndParentsTo(e.target, _this.props.handle, thisNode) || _this.props.cancel && matchesSelectorAndParentsTo(e.target, _this.props.cancel, thisNode)) {
|
|
5288
|
+
return;
|
|
5289
|
+
}
|
|
5290
|
+
|
|
5291
|
+
// Set touch identifier in component state if this is a touch event. This allows us to
|
|
5292
|
+
// distinguish between individual touches on multitouch screens by identifying which
|
|
5293
|
+
// touchpoint was set to this element.
|
|
5294
|
+
var touchIdentifier = getTouchIdentifier(e);
|
|
5295
|
+
_this.setState({ touchIdentifier: touchIdentifier });
|
|
5296
|
+
|
|
5297
|
+
// Get the current drag point from the event. This is used as the offset.
|
|
5298
|
+
var position = getControlPosition(e, touchIdentifier, _this);
|
|
5299
|
+
if (position == null) return; // not possible but satisfies flow
|
|
5300
|
+
var x = position.x,
|
|
5301
|
+
y = position.y;
|
|
5302
|
+
|
|
5303
|
+
// Create an event object with all the data parents need to make a decision here.
|
|
5304
|
+
|
|
5305
|
+
var coreEvent = createCoreData(_this, x, y);
|
|
5306
|
+
|
|
5307
|
+
// Call event handler. If it returns explicit false, cancel.
|
|
5308
|
+
log('calling', _this.props.onStart);
|
|
5309
|
+
var shouldUpdate = _this.props.onStart(e, coreEvent);
|
|
5310
|
+
if (shouldUpdate === false) return;
|
|
5311
|
+
|
|
5312
|
+
// Add a style to the body to disable user-select. This prevents text from
|
|
5313
|
+
// being selected all over the page.
|
|
5314
|
+
if (_this.props.enableUserSelectHack) addUserSelectStyles(ownerDocument);
|
|
5315
|
+
|
|
5316
|
+
// Initiate dragging. Set the current x and y as offsets
|
|
5317
|
+
// so we know how much we've moved during the drag. This allows us
|
|
5318
|
+
// to drag elements around even if they have been moved, without issue.
|
|
5319
|
+
_this.setState({
|
|
5320
|
+
dragging: true,
|
|
5321
|
+
|
|
5322
|
+
lastX: x,
|
|
5323
|
+
lastY: y
|
|
5324
|
+
});
|
|
5325
|
+
|
|
5326
|
+
// Add events to the document directly so we catch when the user's mouse/touch moves outside of
|
|
5327
|
+
// this element. We use different events depending on whether or not we have detected that this
|
|
5328
|
+
// is a touch-capable device.
|
|
5329
|
+
addEvent(ownerDocument, dragEventFor.move, _this.handleDrag);
|
|
5330
|
+
addEvent(ownerDocument, dragEventFor.stop, _this.handleDragStop);
|
|
5331
|
+
}, _this.handleDrag = function (e) {
|
|
5332
|
+
|
|
5333
|
+
// Prevent scrolling on mobile devices, like ipad/iphone.
|
|
5334
|
+
if (e.type === 'touchmove') e.preventDefault();
|
|
5335
|
+
|
|
5336
|
+
// Get the current drag point from the event. This is used as the offset.
|
|
5337
|
+
var position = getControlPosition(e, _this.state.touchIdentifier, _this);
|
|
5338
|
+
if (position == null) return;
|
|
5339
|
+
var x = position.x,
|
|
5340
|
+
y = position.y;
|
|
5341
|
+
|
|
5342
|
+
// Snap to grid if prop has been provided
|
|
5343
|
+
|
|
5344
|
+
if (Array.isArray(_this.props.grid)) {
|
|
5345
|
+
var _deltaX = x - _this.state.lastX,
|
|
5346
|
+
_deltaY = y - _this.state.lastY;
|
|
5347
|
+
|
|
5348
|
+
var _snapToGrid = snapToGrid(_this.props.grid, _deltaX, _deltaY);
|
|
5349
|
+
|
|
5350
|
+
var _snapToGrid2 = slicedToArray(_snapToGrid, 2);
|
|
5351
|
+
|
|
5352
|
+
_deltaX = _snapToGrid2[0];
|
|
5353
|
+
_deltaY = _snapToGrid2[1];
|
|
5354
|
+
|
|
5355
|
+
if (!_deltaX && !_deltaY) return; // skip useless drag
|
|
5356
|
+
x = _this.state.lastX + _deltaX, y = _this.state.lastY + _deltaY;
|
|
5357
|
+
}
|
|
5358
|
+
|
|
5359
|
+
var coreEvent = createCoreData(_this, x, y);
|
|
5360
|
+
|
|
5361
|
+
// Call event handler. If it returns explicit false, trigger end.
|
|
5362
|
+
var shouldUpdate = _this.props.onDrag(e, coreEvent);
|
|
5363
|
+
if (shouldUpdate === false) {
|
|
5364
|
+
try {
|
|
5365
|
+
// $FlowIgnore
|
|
5366
|
+
_this.handleDragStop(new MouseEvent('mouseup'));
|
|
5367
|
+
} catch (err) {
|
|
5368
|
+
// Old browsers
|
|
5369
|
+
var event = document.createEvent('MouseEvents') /*: any*/;
|
|
5370
|
+
// I see why this insanity was deprecated
|
|
5371
|
+
// $FlowIgnore
|
|
5372
|
+
event.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
5373
|
+
_this.handleDragStop(event);
|
|
5374
|
+
}
|
|
5375
|
+
return;
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
_this.setState({
|
|
5379
|
+
lastX: x,
|
|
5380
|
+
lastY: y
|
|
5381
|
+
});
|
|
5382
|
+
}, _this.handleDragStop = function (e) {
|
|
5383
|
+
if (!_this.state.dragging) return;
|
|
5384
|
+
|
|
5385
|
+
var position = getControlPosition(e, _this.state.touchIdentifier, _this);
|
|
5386
|
+
if (position == null) return;
|
|
5387
|
+
var x = position.x,
|
|
5388
|
+
y = position.y;
|
|
5389
|
+
|
|
5390
|
+
var coreEvent = createCoreData(_this, x, y);
|
|
5391
|
+
|
|
5392
|
+
var thisNode = ReactDOM.findDOMNode(_this);
|
|
5393
|
+
if (thisNode) {
|
|
5394
|
+
// Remove user-select hack
|
|
5395
|
+
if (_this.props.enableUserSelectHack) removeUserSelectStyles(thisNode.ownerDocument);
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
// Reset the el.
|
|
5399
|
+
_this.setState({
|
|
5400
|
+
dragging: false,
|
|
5401
|
+
lastX: NaN,
|
|
5402
|
+
lastY: NaN
|
|
5403
|
+
});
|
|
5404
|
+
|
|
5405
|
+
// Call event handler
|
|
5406
|
+
_this.props.onStop(e, coreEvent);
|
|
5407
|
+
|
|
5408
|
+
if (thisNode) {
|
|
5409
|
+
removeEvent(thisNode.ownerDocument, dragEventFor.move, _this.handleDrag);
|
|
5410
|
+
removeEvent(thisNode.ownerDocument, dragEventFor.stop, _this.handleDragStop);
|
|
5411
|
+
}
|
|
5412
|
+
}, _this.onMouseDown = function (e) {
|
|
5413
|
+
dragEventFor = eventsFor.mouse; // on touchscreen laptops we could switch back to mouse
|
|
5414
|
+
|
|
5415
|
+
return _this.handleDragStart(e);
|
|
5416
|
+
}, _this.onMouseUp = function (e) {
|
|
5417
|
+
dragEventFor = eventsFor.mouse;
|
|
5418
|
+
|
|
5419
|
+
return _this.handleDragStop(e);
|
|
5420
|
+
}, _this.onTouchStart = function (e) {
|
|
5421
|
+
// We're on a touch device now, so change the event handlers
|
|
5422
|
+
dragEventFor = eventsFor.touch;
|
|
5423
|
+
|
|
5424
|
+
return _this.handleDragStart(e);
|
|
5425
|
+
}, _this.onTouchEnd = function (e) {
|
|
5426
|
+
// We're on a touch device now, so change the event handlers
|
|
5427
|
+
dragEventFor = eventsFor.touch;
|
|
5428
|
+
|
|
5429
|
+
return _this.handleDragStop(e);
|
|
5430
|
+
}, _temp), possibleConstructorReturn(_this, _ret);
|
|
5431
|
+
}
|
|
5432
|
+
|
|
5433
|
+
createClass(DraggableCore, [{
|
|
5434
|
+
key: 'componentWillUnmount',
|
|
5435
|
+
value: function componentWillUnmount() {
|
|
5436
|
+
// Remove any leftover event handlers. Remove both touch and mouse handlers in case
|
|
5437
|
+
// some browser quirk caused a touch event to fire during a mouse move, or vice versa.
|
|
5438
|
+
var thisNode = ReactDOM.findDOMNode(this);
|
|
5439
|
+
if (thisNode) {
|
|
5440
|
+
var ownerDocument = thisNode.ownerDocument;
|
|
5441
|
+
|
|
5442
|
+
removeEvent(ownerDocument, eventsFor.mouse.move, this.handleDrag);
|
|
5443
|
+
removeEvent(ownerDocument, eventsFor.touch.move, this.handleDrag);
|
|
5444
|
+
removeEvent(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
|
|
5445
|
+
removeEvent(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
|
|
5446
|
+
if (this.props.enableUserSelectHack) removeUserSelectStyles(ownerDocument);
|
|
5447
|
+
}
|
|
5448
|
+
}
|
|
5449
|
+
|
|
5450
|
+
// Same as onMouseDown (start drag), but now consider this a touch device.
|
|
5451
|
+
|
|
5452
|
+
}, {
|
|
5453
|
+
key: 'render',
|
|
5454
|
+
value: function render() {
|
|
5455
|
+
// Reuse the child provided
|
|
5456
|
+
// This makes it flexible to use whatever element is wanted (div, ul, etc)
|
|
5457
|
+
return React$$1.cloneElement(React$$1.Children.only(this.props.children), {
|
|
5458
|
+
style: styleHacks(this.props.children.props.style),
|
|
5459
|
+
|
|
5460
|
+
// Note: mouseMove handler is attached to document so it will still function
|
|
5461
|
+
// when the user drags quickly and leaves the bounds of the element.
|
|
5462
|
+
onMouseDown: this.onMouseDown,
|
|
5463
|
+
onTouchStart: this.onTouchStart,
|
|
5464
|
+
onMouseUp: this.onMouseUp,
|
|
5465
|
+
onTouchEnd: this.onTouchEnd
|
|
5466
|
+
});
|
|
5467
|
+
}
|
|
5468
|
+
}]);
|
|
5469
|
+
return DraggableCore;
|
|
5470
|
+
}(React$$1.Component);
|
|
5471
|
+
|
|
5472
|
+
DraggableCore.displayName = 'DraggableCore';
|
|
5473
|
+
DraggableCore.propTypes = {
|
|
5474
|
+
/**
|
|
5475
|
+
* `allowAnyClick` allows dragging using any mouse button.
|
|
5476
|
+
* By default, we only accept the left button.
|
|
5477
|
+
*
|
|
5478
|
+
* Defaults to `false`.
|
|
5479
|
+
*/
|
|
5480
|
+
allowAnyClick: propTypes.bool,
|
|
5481
|
+
|
|
5482
|
+
/**
|
|
5483
|
+
* `disabled`, if true, stops the <Draggable> from dragging. All handlers,
|
|
5484
|
+
* with the exception of `onMouseDown`, will not fire.
|
|
5485
|
+
*/
|
|
5486
|
+
disabled: propTypes.bool,
|
|
5487
|
+
|
|
5488
|
+
/**
|
|
5489
|
+
* By default, we add 'user-select:none' attributes to the document body
|
|
5490
|
+
* to prevent ugly text selection during drag. If this is causing problems
|
|
5491
|
+
* for your app, set this to `false`.
|
|
5492
|
+
*/
|
|
5493
|
+
enableUserSelectHack: propTypes.bool,
|
|
5494
|
+
|
|
5495
|
+
/**
|
|
5496
|
+
* `offsetParent`, if set, uses the passed DOM node to compute drag offsets
|
|
5497
|
+
* instead of using the parent node.
|
|
5498
|
+
*/
|
|
5499
|
+
offsetParent: function offsetParent(props /*: DraggableCoreProps*/, propName /*: $Keys<DraggableCoreProps>*/) {
|
|
5500
|
+
if (props[propName] && props[propName].nodeType !== 1) {
|
|
5501
|
+
throw new Error('Draggable\'s offsetParent must be a DOM Node.');
|
|
5502
|
+
}
|
|
5503
|
+
},
|
|
5504
|
+
|
|
5505
|
+
/**
|
|
5506
|
+
* `grid` specifies the x and y that dragging should snap to.
|
|
5507
|
+
*/
|
|
5508
|
+
grid: propTypes.arrayOf(propTypes.number),
|
|
5509
|
+
|
|
5510
|
+
/**
|
|
5511
|
+
* `scale` specifies the scale of the area you are dragging inside of. It allows
|
|
5512
|
+
* the drag deltas to scale correctly with how far zoomed in/out you are.
|
|
5513
|
+
*/
|
|
5514
|
+
scale: propTypes.number,
|
|
5515
|
+
|
|
5516
|
+
/**
|
|
5517
|
+
* `handle` specifies a selector to be used as the handle that initiates drag.
|
|
5518
|
+
*
|
|
5519
|
+
* Example:
|
|
5520
|
+
*
|
|
5521
|
+
* ```jsx
|
|
5522
|
+
* let App = React.createClass({
|
|
5523
|
+
* render: function () {
|
|
5524
|
+
* return (
|
|
5525
|
+
* <Draggable handle=".handle">
|
|
5526
|
+
* <div>
|
|
5527
|
+
* <div className="handle">Click me to drag</div>
|
|
5528
|
+
* <div>This is some other content</div>
|
|
5529
|
+
* </div>
|
|
5530
|
+
* </Draggable>
|
|
5531
|
+
* );
|
|
5532
|
+
* }
|
|
5533
|
+
* });
|
|
5534
|
+
* ```
|
|
5535
|
+
*/
|
|
5536
|
+
handle: propTypes.string,
|
|
5537
|
+
|
|
5538
|
+
/**
|
|
5539
|
+
* `cancel` specifies a selector to be used to prevent drag initialization.
|
|
5540
|
+
*
|
|
5541
|
+
* Example:
|
|
5542
|
+
*
|
|
5543
|
+
* ```jsx
|
|
5544
|
+
* let App = React.createClass({
|
|
5545
|
+
* render: function () {
|
|
5546
|
+
* return(
|
|
5547
|
+
* <Draggable cancel=".cancel">
|
|
5548
|
+
* <div>
|
|
5549
|
+
* <div className="cancel">You can't drag from here</div>
|
|
5550
|
+
* <div>Dragging here works fine</div>
|
|
5551
|
+
* </div>
|
|
5552
|
+
* </Draggable>
|
|
5553
|
+
* );
|
|
5554
|
+
* }
|
|
5555
|
+
* });
|
|
5556
|
+
* ```
|
|
5557
|
+
*/
|
|
5558
|
+
cancel: propTypes.string,
|
|
5559
|
+
|
|
5560
|
+
/**
|
|
5561
|
+
* Called when dragging starts.
|
|
5562
|
+
* If this function returns the boolean false, dragging will be canceled.
|
|
5563
|
+
*/
|
|
5564
|
+
onStart: propTypes.func,
|
|
5565
|
+
|
|
5566
|
+
/**
|
|
5567
|
+
* Called while dragging.
|
|
5568
|
+
* If this function returns the boolean false, dragging will be canceled.
|
|
5569
|
+
*/
|
|
5570
|
+
onDrag: propTypes.func,
|
|
5571
|
+
|
|
5572
|
+
/**
|
|
5573
|
+
* Called when dragging stops.
|
|
5574
|
+
* If this function returns the boolean false, the drag will remain active.
|
|
5575
|
+
*/
|
|
5576
|
+
onStop: propTypes.func,
|
|
5577
|
+
|
|
5578
|
+
/**
|
|
5579
|
+
* A workaround option which can be passed if onMouseDown needs to be accessed,
|
|
5580
|
+
* since it'll always be blocked (as there is internal use of onMouseDown)
|
|
5581
|
+
*/
|
|
5582
|
+
onMouseDown: propTypes.func,
|
|
5583
|
+
|
|
5584
|
+
/**
|
|
5585
|
+
* These properties should be defined on the child, not here.
|
|
5586
|
+
*/
|
|
5587
|
+
className: dontSetMe,
|
|
5588
|
+
style: dontSetMe,
|
|
5589
|
+
transform: dontSetMe
|
|
5590
|
+
};
|
|
5591
|
+
DraggableCore.defaultProps = {
|
|
5592
|
+
allowAnyClick: false, // by default only accept left click
|
|
5593
|
+
cancel: null,
|
|
5594
|
+
disabled: false,
|
|
5595
|
+
enableUserSelectHack: true,
|
|
5596
|
+
offsetParent: null,
|
|
5597
|
+
handle: null,
|
|
5598
|
+
grid: null,
|
|
5599
|
+
transform: null,
|
|
5600
|
+
onStart: function onStart() {},
|
|
5601
|
+
onDrag: function onDrag() {},
|
|
5602
|
+
onStop: function onStop() {},
|
|
5603
|
+
onMouseDown: function onMouseDown() {}
|
|
5604
|
+
};
|
|
5605
|
+
|
|
5606
|
+
/*:: import type {DraggableEventHandler} from './utils/types';*/
|
|
5607
|
+
/*:: import type {Element as ReactElement} from 'react';*/
|
|
5608
|
+
/*:: type DraggableState = {
|
|
5609
|
+
dragging: boolean,
|
|
5610
|
+
dragged: boolean,
|
|
5611
|
+
x: number, y: number,
|
|
5612
|
+
slackX: number, slackY: number,
|
|
5613
|
+
isElementSVG: boolean
|
|
5614
|
+
};*/
|
|
5615
|
+
|
|
5616
|
+
//
|
|
5617
|
+
// Define <Draggable>
|
|
5618
|
+
//
|
|
5619
|
+
|
|
5620
|
+
/*:: export type DraggableProps = {
|
|
5621
|
+
...$Exact<DraggableCoreProps>,
|
|
5622
|
+
axis: 'both' | 'x' | 'y' | 'none',
|
|
5623
|
+
bounds: DraggableBounds | string | false,
|
|
5624
|
+
defaultClassName: string,
|
|
5625
|
+
defaultClassNameDragging: string,
|
|
5626
|
+
defaultClassNameDragged: string,
|
|
5627
|
+
defaultPosition: ControlPosition,
|
|
5628
|
+
positionOffset: PositionOffsetControlPosition,
|
|
5629
|
+
position: ControlPosition,
|
|
5630
|
+
scale: number
|
|
5631
|
+
};*/
|
|
5632
|
+
|
|
5633
|
+
var Draggable = function (_React$Component) {
|
|
5634
|
+
inherits(Draggable, _React$Component);
|
|
5635
|
+
|
|
5636
|
+
function Draggable(props /*: DraggableProps*/) {
|
|
5637
|
+
classCallCheck(this, Draggable);
|
|
5638
|
+
|
|
5639
|
+
var _this = possibleConstructorReturn(this, (Draggable.__proto__ || Object.getPrototypeOf(Draggable)).call(this, props));
|
|
5640
|
+
|
|
5641
|
+
_this.onDragStart = function (e, coreData) {
|
|
5642
|
+
|
|
5643
|
+
// Short-circuit if user's callback killed it.
|
|
5644
|
+
var shouldStart = _this.props.onStart(e, createDraggableData(_this, coreData));
|
|
5645
|
+
// Kills start event on core as well, so move handlers are never bound.
|
|
5646
|
+
if (shouldStart === false) return false;
|
|
5647
|
+
|
|
5648
|
+
_this.setState({ dragging: true, dragged: true });
|
|
5649
|
+
};
|
|
5650
|
+
|
|
5651
|
+
_this.onDrag = function (e, coreData) {
|
|
5652
|
+
if (!_this.state.dragging) return false;
|
|
5653
|
+
|
|
5654
|
+
var uiData = createDraggableData(_this, coreData);
|
|
5655
|
+
|
|
5656
|
+
var newState /*: $Shape<DraggableState>*/ = {
|
|
5657
|
+
x: uiData.x,
|
|
5658
|
+
y: uiData.y
|
|
5659
|
+
};
|
|
5660
|
+
|
|
5661
|
+
// Keep within bounds.
|
|
5662
|
+
if (_this.props.bounds) {
|
|
5663
|
+
// Save original x and y.
|
|
5664
|
+
var _x = newState.x,
|
|
5665
|
+
_y = newState.y;
|
|
5666
|
+
|
|
5667
|
+
// Add slack to the values used to calculate bound position. This will ensure that if
|
|
5668
|
+
// we start removing slack, the element won't react to it right away until it's been
|
|
5669
|
+
// completely removed.
|
|
5670
|
+
|
|
5671
|
+
newState.x += _this.state.slackX;
|
|
5672
|
+
newState.y += _this.state.slackY;
|
|
5673
|
+
|
|
5674
|
+
// Get bound position. This will ceil/floor the x and y within the boundaries.
|
|
5675
|
+
|
|
5676
|
+
var _getBoundPosition = getBoundPosition(_this, newState.x, newState.y),
|
|
5677
|
+
_getBoundPosition2 = slicedToArray(_getBoundPosition, 2),
|
|
5678
|
+
newStateX = _getBoundPosition2[0],
|
|
5679
|
+
newStateY = _getBoundPosition2[1];
|
|
5680
|
+
|
|
5681
|
+
newState.x = newStateX;
|
|
5682
|
+
newState.y = newStateY;
|
|
5683
|
+
|
|
5684
|
+
// Recalculate slack by noting how much was shaved by the boundPosition handler.
|
|
5685
|
+
newState.slackX = _this.state.slackX + (_x - newState.x);
|
|
5686
|
+
newState.slackY = _this.state.slackY + (_y - newState.y);
|
|
5687
|
+
|
|
5688
|
+
// Update the event we fire to reflect what really happened after bounds took effect.
|
|
5689
|
+
uiData.x = newState.x;
|
|
5690
|
+
uiData.y = newState.y;
|
|
5691
|
+
uiData.deltaX = newState.x - _this.state.x;
|
|
5692
|
+
uiData.deltaY = newState.y - _this.state.y;
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
// Short-circuit if user's callback killed it.
|
|
5696
|
+
var shouldUpdate = _this.props.onDrag(e, uiData);
|
|
5697
|
+
if (shouldUpdate === false) return false;
|
|
5698
|
+
|
|
5699
|
+
_this.setState(newState);
|
|
5700
|
+
};
|
|
5701
|
+
|
|
5702
|
+
_this.onDragStop = function (e, coreData) {
|
|
5703
|
+
if (!_this.state.dragging) return false;
|
|
5704
|
+
|
|
5705
|
+
// Short-circuit if user's callback killed it.
|
|
5706
|
+
var shouldStop = _this.props.onStop(e, createDraggableData(_this, coreData));
|
|
5707
|
+
if (shouldStop === false) return false;
|
|
5708
|
+
|
|
5709
|
+
var newState /*: $Shape<DraggableState>*/ = {
|
|
5710
|
+
dragging: false,
|
|
5711
|
+
slackX: 0,
|
|
5712
|
+
slackY: 0
|
|
5713
|
+
};
|
|
5714
|
+
|
|
5715
|
+
// If this is a controlled component, the result of this operation will be to
|
|
5716
|
+
// revert back to the old position. We expect a handler on `onDragStop`, at the least.
|
|
5717
|
+
var controlled = Boolean(_this.props.position);
|
|
5718
|
+
if (controlled) {
|
|
5719
|
+
var _this$props$position = _this.props.position,
|
|
5720
|
+
_x2 = _this$props$position.x,
|
|
5721
|
+
_y2 = _this$props$position.y;
|
|
5722
|
+
|
|
5723
|
+
newState.x = _x2;
|
|
5724
|
+
newState.y = _y2;
|
|
5725
|
+
}
|
|
5726
|
+
|
|
5727
|
+
_this.setState(newState);
|
|
5728
|
+
};
|
|
5729
|
+
|
|
5730
|
+
_this.state = {
|
|
5731
|
+
// Whether or not we are currently dragging.
|
|
5732
|
+
dragging: false,
|
|
5733
|
+
|
|
5734
|
+
// Whether or not we have been dragged before.
|
|
5735
|
+
dragged: false,
|
|
5736
|
+
|
|
5737
|
+
// Current transform x and y.
|
|
5738
|
+
x: props.position ? props.position.x : props.defaultPosition.x,
|
|
5739
|
+
y: props.position ? props.position.y : props.defaultPosition.y,
|
|
5740
|
+
|
|
5741
|
+
// Used for compensating for out-of-bounds drags
|
|
5742
|
+
slackX: 0, slackY: 0,
|
|
5743
|
+
|
|
5744
|
+
// Can only determine if SVG after mounting
|
|
5745
|
+
isElementSVG: false
|
|
5746
|
+
};
|
|
5747
|
+
|
|
5748
|
+
if (props.position && !(props.onDrag || props.onStop)) {
|
|
5749
|
+
// eslint-disable-next-line no-console
|
|
5750
|
+
console.warn('A `position` was applied to this <Draggable>, without drag handlers. This will make this ' + 'component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the ' + '`position` of this element.');
|
|
5751
|
+
}
|
|
5752
|
+
return _this;
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5755
|
+
createClass(Draggable, [{
|
|
5756
|
+
key: 'componentDidMount',
|
|
5757
|
+
value: function componentDidMount() {
|
|
5758
|
+
// Check to see if the element passed is an instanceof SVGElement
|
|
5759
|
+
if (typeof window.SVGElement !== 'undefined' && ReactDOM.findDOMNode(this) instanceof window.SVGElement) {
|
|
5760
|
+
this.setState({ isElementSVG: true });
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5763
|
+
}, {
|
|
5764
|
+
key: 'componentWillReceiveProps',
|
|
5765
|
+
value: function componentWillReceiveProps(nextProps /*: Object*/) {
|
|
5766
|
+
// Set x/y if position has changed
|
|
5767
|
+
if (nextProps.position && (!this.props.position || nextProps.position.x !== this.props.position.x || nextProps.position.y !== this.props.position.y)) {
|
|
5768
|
+
this.setState({ x: nextProps.position.x, y: nextProps.position.y });
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
}, {
|
|
5772
|
+
key: 'componentWillUnmount',
|
|
5773
|
+
value: function componentWillUnmount() {
|
|
5774
|
+
this.setState({ dragging: false }); // prevents invariant if unmounted while dragging
|
|
5775
|
+
}
|
|
5776
|
+
}, {
|
|
5777
|
+
key: 'render',
|
|
5778
|
+
value: function render() /*: ReactElement<any>*/{
|
|
5779
|
+
var _classNames;
|
|
5780
|
+
|
|
5781
|
+
var style = {},
|
|
5782
|
+
svgTransform = null;
|
|
5783
|
+
|
|
5784
|
+
// If this is controlled, we don't want to move it - unless it's dragging.
|
|
5785
|
+
var controlled = Boolean(this.props.position);
|
|
5786
|
+
var draggable = !controlled || this.state.dragging;
|
|
5787
|
+
|
|
5788
|
+
var position = this.props.position || this.props.defaultPosition;
|
|
5789
|
+
var transformOpts = {
|
|
5790
|
+
// Set left if horizontal drag is enabled
|
|
5791
|
+
x: canDragX(this) && draggable ? this.state.x : position.x,
|
|
5792
|
+
|
|
5793
|
+
// Set top if vertical drag is enabled
|
|
5794
|
+
y: canDragY(this) && draggable ? this.state.y : position.y
|
|
5795
|
+
};
|
|
5796
|
+
|
|
5797
|
+
// If this element was SVG, we use the `transform` attribute.
|
|
5798
|
+
if (this.state.isElementSVG) {
|
|
5799
|
+
svgTransform = createSVGTransform(transformOpts, this.props.positionOffset);
|
|
5800
|
+
} else {
|
|
5801
|
+
// Add a CSS transform to move the element around. This allows us to move the element around
|
|
5802
|
+
// without worrying about whether or not it is relatively or absolutely positioned.
|
|
5803
|
+
// If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
|
|
5804
|
+
// has a clean slate.
|
|
5805
|
+
style = createCSSTransform(transformOpts, this.props.positionOffset);
|
|
5806
|
+
}
|
|
5807
|
+
|
|
5808
|
+
var _props = this.props,
|
|
5809
|
+
defaultClassName = _props.defaultClassName,
|
|
5810
|
+
defaultClassNameDragging = _props.defaultClassNameDragging,
|
|
5811
|
+
defaultClassNameDragged = _props.defaultClassNameDragged;
|
|
5812
|
+
|
|
5813
|
+
var children = React$$1.Children.only(this.props.children);
|
|
5814
|
+
|
|
5815
|
+
// Mark with class while dragging
|
|
5816
|
+
var className = classnames(children.props.className || '', defaultClassName, (_classNames = {}, defineProperty(_classNames, defaultClassNameDragging, this.state.dragging), defineProperty(_classNames, defaultClassNameDragged, this.state.dragged), _classNames));
|
|
5817
|
+
|
|
5818
|
+
// Reuse the child provided
|
|
5819
|
+
// This makes it flexible to use whatever element is wanted (div, ul, etc)
|
|
5820
|
+
return React$$1.createElement(DraggableCore, _extends({}, this.props, { onStart: this.onDragStart, onDrag: this.onDrag, onStop: this.onDragStop }), React$$1.cloneElement(children, {
|
|
5821
|
+
className: className,
|
|
5822
|
+
style: _extends({}, children.props.style, style),
|
|
5823
|
+
transform: svgTransform
|
|
5824
|
+
}));
|
|
5825
|
+
}
|
|
5826
|
+
}]);
|
|
5827
|
+
return Draggable;
|
|
5828
|
+
}(React$$1.Component);
|
|
5829
|
+
|
|
5830
|
+
Draggable.displayName = 'Draggable';
|
|
5831
|
+
Draggable.propTypes = _extends({}, DraggableCore.propTypes, {
|
|
5832
|
+
|
|
5833
|
+
/**
|
|
5834
|
+
* `axis` determines which axis the draggable can move.
|
|
5835
|
+
*
|
|
5836
|
+
* Note that all callbacks will still return data as normal. This only
|
|
5837
|
+
* controls flushing to the DOM.
|
|
5838
|
+
*
|
|
5839
|
+
* 'both' allows movement horizontally and vertically.
|
|
5840
|
+
* 'x' limits movement to horizontal axis.
|
|
5841
|
+
* 'y' limits movement to vertical axis.
|
|
5842
|
+
* 'none' limits all movement.
|
|
5843
|
+
*
|
|
5844
|
+
* Defaults to 'both'.
|
|
5845
|
+
*/
|
|
5846
|
+
axis: propTypes.oneOf(['both', 'x', 'y', 'none']),
|
|
5847
|
+
|
|
5848
|
+
/**
|
|
5849
|
+
* `bounds` determines the range of movement available to the element.
|
|
5850
|
+
* Available values are:
|
|
5851
|
+
*
|
|
5852
|
+
* 'parent' restricts movement within the Draggable's parent node.
|
|
5853
|
+
*
|
|
5854
|
+
* Alternatively, pass an object with the following properties, all of which are optional:
|
|
5855
|
+
*
|
|
5856
|
+
* {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
|
|
5857
|
+
*
|
|
5858
|
+
* All values are in px.
|
|
5859
|
+
*
|
|
5860
|
+
* Example:
|
|
5861
|
+
*
|
|
5862
|
+
* ```jsx
|
|
5863
|
+
* let App = React.createClass({
|
|
5864
|
+
* render: function () {
|
|
5865
|
+
* return (
|
|
5866
|
+
* <Draggable bounds={{right: 300, bottom: 300}}>
|
|
5867
|
+
* <div>Content</div>
|
|
5868
|
+
* </Draggable>
|
|
5869
|
+
* );
|
|
5870
|
+
* }
|
|
5871
|
+
* });
|
|
5872
|
+
* ```
|
|
5873
|
+
*/
|
|
5874
|
+
bounds: propTypes.oneOfType([propTypes.shape({
|
|
5875
|
+
left: propTypes.number,
|
|
5876
|
+
right: propTypes.number,
|
|
5877
|
+
top: propTypes.number,
|
|
5878
|
+
bottom: propTypes.number
|
|
5879
|
+
}), propTypes.string, propTypes.oneOf([false])]),
|
|
5880
|
+
|
|
5881
|
+
defaultClassName: propTypes.string,
|
|
5882
|
+
defaultClassNameDragging: propTypes.string,
|
|
5883
|
+
defaultClassNameDragged: propTypes.string,
|
|
5884
|
+
|
|
5885
|
+
/**
|
|
5886
|
+
* `defaultPosition` specifies the x and y that the dragged item should start at
|
|
5887
|
+
*
|
|
5888
|
+
* Example:
|
|
5889
|
+
*
|
|
5890
|
+
* ```jsx
|
|
5891
|
+
* let App = React.createClass({
|
|
5892
|
+
* render: function () {
|
|
5893
|
+
* return (
|
|
5894
|
+
* <Draggable defaultPosition={{x: 25, y: 25}}>
|
|
5895
|
+
* <div>I start with transformX: 25px and transformY: 25px;</div>
|
|
5896
|
+
* </Draggable>
|
|
5897
|
+
* );
|
|
5898
|
+
* }
|
|
5899
|
+
* });
|
|
5900
|
+
* ```
|
|
5901
|
+
*/
|
|
5902
|
+
defaultPosition: propTypes.shape({
|
|
5903
|
+
x: propTypes.number,
|
|
5904
|
+
y: propTypes.number
|
|
5905
|
+
}),
|
|
5906
|
+
positionOffset: propTypes.shape({
|
|
5907
|
+
x: propTypes.oneOfType([propTypes.number, propTypes.string]),
|
|
5908
|
+
y: propTypes.oneOfType([propTypes.number, propTypes.string])
|
|
5909
|
+
}),
|
|
5910
|
+
|
|
5911
|
+
/**
|
|
5912
|
+
* `position`, if present, defines the current position of the element.
|
|
5913
|
+
*
|
|
5914
|
+
* This is similar to how form elements in React work - if no `position` is supplied, the component
|
|
5915
|
+
* is uncontrolled.
|
|
5916
|
+
*
|
|
5917
|
+
* Example:
|
|
5918
|
+
*
|
|
5919
|
+
* ```jsx
|
|
5920
|
+
* let App = React.createClass({
|
|
5921
|
+
* render: function () {
|
|
5922
|
+
* return (
|
|
5923
|
+
* <Draggable position={{x: 25, y: 25}}>
|
|
5924
|
+
* <div>I start with transformX: 25px and transformY: 25px;</div>
|
|
5925
|
+
* </Draggable>
|
|
5926
|
+
* );
|
|
5927
|
+
* }
|
|
5928
|
+
* });
|
|
5929
|
+
* ```
|
|
5930
|
+
*/
|
|
5931
|
+
position: propTypes.shape({
|
|
5932
|
+
x: propTypes.number,
|
|
5933
|
+
y: propTypes.number
|
|
5934
|
+
}),
|
|
5935
|
+
|
|
5936
|
+
/**
|
|
5937
|
+
* These properties should be defined on the child, not here.
|
|
5938
|
+
*/
|
|
5939
|
+
className: dontSetMe,
|
|
5940
|
+
style: dontSetMe,
|
|
5941
|
+
transform: dontSetMe
|
|
5942
|
+
});
|
|
5943
|
+
Draggable.defaultProps = _extends({}, DraggableCore.defaultProps, {
|
|
5944
|
+
axis: 'both',
|
|
5945
|
+
bounds: false,
|
|
5946
|
+
defaultClassName: 'react-draggable',
|
|
5947
|
+
defaultClassNameDragging: 'react-draggable-dragging',
|
|
5948
|
+
defaultClassNameDragged: 'react-draggable-dragged',
|
|
5949
|
+
defaultPosition: { x: 0, y: 0 },
|
|
5950
|
+
position: null,
|
|
5951
|
+
scale: 1
|
|
5952
|
+
});
|
|
5953
|
+
|
|
5954
|
+
// Previous versions of this lib exported <Draggable> as the root export. As to not break
|
|
5955
|
+
// them, or TypeScript, we export *both* as the root and as 'default'.
|
|
5956
|
+
// See https://github.com/mzabriskie/react-draggable/pull/254
|
|
5957
|
+
// and https://github.com/mzabriskie/react-draggable/issues/266
|
|
5958
|
+
Draggable.default = Draggable;
|
|
5959
|
+
Draggable.DraggableCore = DraggableCore;
|
|
5960
|
+
|
|
5961
|
+
return Draggable;
|
|
5962
|
+
});
|
|
5963
|
+
|
|
5964
|
+
});
|
|
5965
|
+
|
|
3769
5966
|
var _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
3770
5967
|
|
|
3771
5968
|
var _createClass$g = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
3772
5969
|
|
|
3773
|
-
function _toConsumableArray$4(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
3774
|
-
|
|
3775
5970
|
function _classCallCheck$g(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3776
5971
|
|
|
3777
5972
|
function _possibleConstructorReturn$e(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
3778
5973
|
|
|
3779
5974
|
function _inherits$e(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
3780
5975
|
|
|
5976
|
+
var InfoBox = function (_Component) {
|
|
5977
|
+
_inherits$e(InfoBox, _Component);
|
|
5978
|
+
|
|
5979
|
+
function InfoBox(props) {
|
|
5980
|
+
_classCallCheck$g(this, InfoBox);
|
|
5981
|
+
|
|
5982
|
+
var _this = _possibleConstructorReturn$e(this, (InfoBox.__proto__ || Object.getPrototypeOf(InfoBox)).call(this, props));
|
|
5983
|
+
|
|
5984
|
+
_this.state = {
|
|
5985
|
+
style: {
|
|
5986
|
+
position: 'fixed',
|
|
5987
|
+
top: 200,
|
|
5988
|
+
left: 200,
|
|
5989
|
+
width: 250
|
|
5990
|
+
}
|
|
5991
|
+
};
|
|
5992
|
+
return _this;
|
|
5993
|
+
}
|
|
5994
|
+
|
|
5995
|
+
_createClass$g(InfoBox, [{
|
|
5996
|
+
key: 'componentDidMount',
|
|
5997
|
+
value: function componentDidMount() {
|
|
5998
|
+
this.updateStyle();
|
|
5999
|
+
}
|
|
6000
|
+
}, {
|
|
6001
|
+
key: 'componentDidUpdate',
|
|
6002
|
+
value: function componentDidUpdate(prevProps) {
|
|
6003
|
+
if (this.props.defaultPos !== prevProps.defaultPos) {
|
|
6004
|
+
this.updateStyle();
|
|
6005
|
+
}
|
|
6006
|
+
}
|
|
6007
|
+
}, {
|
|
6008
|
+
key: 'handleOnStop',
|
|
6009
|
+
value: function handleOnStop(e) {
|
|
6010
|
+
if (this.props.onStop) {
|
|
6011
|
+
this.props.onStop(e);
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
}, {
|
|
6015
|
+
key: 'updateStyle',
|
|
6016
|
+
value: function updateStyle() {
|
|
6017
|
+
this.setState({
|
|
6018
|
+
style: _extends$9({}, this.state.style, this.props.defaultPos)
|
|
6019
|
+
});
|
|
6020
|
+
}
|
|
6021
|
+
}, {
|
|
6022
|
+
key: 'onDismiss',
|
|
6023
|
+
value: function onDismiss(e) {
|
|
6024
|
+
if (this.props.onDismiss) {
|
|
6025
|
+
this.props.onDismiss(e);
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
}, {
|
|
6029
|
+
key: 'render',
|
|
6030
|
+
value: function render() {
|
|
6031
|
+
var _this2 = this;
|
|
6032
|
+
|
|
6033
|
+
if (!this.props.visible) return null;
|
|
6034
|
+
return React__default.createElement(
|
|
6035
|
+
reactDraggable,
|
|
6036
|
+
{ handle: '.handle', onStop: function onStop(e) {
|
|
6037
|
+
return _this2.handleOnStop(e);
|
|
6038
|
+
}
|
|
6039
|
+
},
|
|
6040
|
+
React__default.createElement(
|
|
6041
|
+
'div',
|
|
6042
|
+
{
|
|
6043
|
+
style: this.state.style },
|
|
6044
|
+
React__default.createElement(
|
|
6045
|
+
semanticUiReact.Message,
|
|
6046
|
+
{
|
|
6047
|
+
style: { opacity: 0.98 },
|
|
6048
|
+
onDismiss: function onDismiss(e) {
|
|
6049
|
+
_this2.onDismiss(e);
|
|
6050
|
+
},
|
|
6051
|
+
size: 'small'
|
|
6052
|
+
},
|
|
6053
|
+
React__default.createElement(
|
|
6054
|
+
semanticUiReact.Header,
|
|
6055
|
+
{ textAlign: 'center', as: 'h5', className: 'handle', style: { cursor: 'grab' } },
|
|
6056
|
+
this.props.header
|
|
6057
|
+
),
|
|
6058
|
+
React__default.createElement(semanticUiReact.Divider, null),
|
|
6059
|
+
React__default.createElement(
|
|
6060
|
+
semanticUiReact.Message.Content,
|
|
6061
|
+
null,
|
|
6062
|
+
this.props.content
|
|
6063
|
+
)
|
|
6064
|
+
)
|
|
6065
|
+
)
|
|
6066
|
+
);
|
|
6067
|
+
}
|
|
6068
|
+
}]);
|
|
6069
|
+
|
|
6070
|
+
return InfoBox;
|
|
6071
|
+
}(React.Component);
|
|
6072
|
+
|
|
6073
|
+
var SiaPopup = function SiaPopup(_ref) {
|
|
6074
|
+
var content = _ref.content,
|
|
6075
|
+
trigger = _ref.trigger;
|
|
6076
|
+
|
|
6077
|
+
|
|
6078
|
+
return React__default.createElement(semanticUiReact.Popup, { inverted: true, style: { opacity: 0.9 }, content: content, trigger: trigger });
|
|
6079
|
+
};
|
|
6080
|
+
|
|
6081
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
6082
|
+
|
|
6083
|
+
var AnnoDetails = function AnnoDetails(props) {
|
|
6084
|
+
var _useState = React.useState(''),
|
|
6085
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6086
|
+
comment = _useState2[0],
|
|
6087
|
+
setComment = _useState2[1];
|
|
6088
|
+
|
|
6089
|
+
var _useState3 = React.useState(false),
|
|
6090
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
6091
|
+
example = _useState4[0],
|
|
6092
|
+
setExample = _useState4[1];
|
|
6093
|
+
|
|
6094
|
+
var _useState5 = React.useState(false),
|
|
6095
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
6096
|
+
showSaveBtn = _useState6[0],
|
|
6097
|
+
setShowSaveBtn = _useState6[1];
|
|
6098
|
+
|
|
6099
|
+
var tARef = React.useRef();
|
|
6100
|
+
React.useEffect(function () {
|
|
6101
|
+
if (props.anno) {
|
|
6102
|
+
if (props.anno.comment) {
|
|
6103
|
+
setComment(props.anno.comment);
|
|
6104
|
+
} else {
|
|
6105
|
+
setComment('');
|
|
6106
|
+
}
|
|
6107
|
+
}
|
|
6108
|
+
}, [props.anno]);
|
|
6109
|
+
|
|
6110
|
+
React.useEffect(function () {
|
|
6111
|
+
if (tARef.current) {
|
|
6112
|
+
tARef.current.focus();
|
|
6113
|
+
}
|
|
6114
|
+
}, [props.commentInputTrigger]);
|
|
6115
|
+
|
|
6116
|
+
var _onDismiss = function _onDismiss() {
|
|
6117
|
+
if (props.onDismiss) {
|
|
6118
|
+
props.onDismiss();
|
|
6119
|
+
}
|
|
6120
|
+
};
|
|
6121
|
+
|
|
6122
|
+
var onCommentUpdate = function onCommentUpdate() {
|
|
6123
|
+
if (props.onCommentUpdate) {
|
|
6124
|
+
props.onCommentUpdate(comment);
|
|
6125
|
+
}
|
|
6126
|
+
setShowSaveBtn(false);
|
|
6127
|
+
};
|
|
6128
|
+
|
|
6129
|
+
var onMarkExampleClick = function onMarkExampleClick() {
|
|
6130
|
+
// setExample(!example)
|
|
6131
|
+
if (props.onMarkExample) {
|
|
6132
|
+
props.onMarkExample(props.anno);
|
|
6133
|
+
}
|
|
6134
|
+
};
|
|
6135
|
+
|
|
6136
|
+
var renderSaveBtn = function renderSaveBtn() {
|
|
6137
|
+
if (showSaveBtn) {
|
|
6138
|
+
return React__default.createElement(semanticUiReact.Label, { as: 'a', corner: 'right', icon: 'save', color: 'red' });
|
|
6139
|
+
}
|
|
6140
|
+
};
|
|
6141
|
+
|
|
6142
|
+
var renderComment = function renderComment() {
|
|
6143
|
+
return React__default.createElement(
|
|
6144
|
+
'div',
|
|
6145
|
+
null,
|
|
6146
|
+
React__default.createElement(
|
|
6147
|
+
semanticUiReact.Form,
|
|
6148
|
+
{ onClick: function onClick() {} },
|
|
6149
|
+
renderSaveBtn(),
|
|
6150
|
+
React__default.createElement(semanticUiReact.TextArea, {
|
|
6151
|
+
placeholder: 'Write a comment',
|
|
6152
|
+
ref: tARef,
|
|
6153
|
+
value: comment,
|
|
6154
|
+
rows: 2,
|
|
6155
|
+
onBlur: function onBlur() {
|
|
6156
|
+
return onCommentUpdate();
|
|
6157
|
+
},
|
|
6158
|
+
onFocus: function onFocus() {
|
|
6159
|
+
return setShowSaveBtn(true);
|
|
6160
|
+
},
|
|
6161
|
+
onChange: function onChange(e) {
|
|
6162
|
+
return setComment(e.target.value);
|
|
6163
|
+
}
|
|
6164
|
+
})
|
|
6165
|
+
)
|
|
6166
|
+
);
|
|
6167
|
+
};
|
|
6168
|
+
var renderLabels = function renderLabels() {
|
|
6169
|
+
if (props.anno) {
|
|
6170
|
+
var selectedLabelIds = props.anno.labelIds;
|
|
6171
|
+
if (!selectedLabelIds) return 'No Label';
|
|
6172
|
+
|
|
6173
|
+
var lbls = '';
|
|
6174
|
+
props.anno.labelIds.forEach(function (lbl, idx) {
|
|
6175
|
+
var labelObject = props.possibleLabels.find(function (el) {
|
|
6176
|
+
return el.id === lbl;
|
|
6177
|
+
});
|
|
6178
|
+
if (idx > 0) lbls += ', ';
|
|
6179
|
+
lbls += labelObject.label;
|
|
6180
|
+
});
|
|
6181
|
+
if (!lbls) return 'No Label';
|
|
6182
|
+
return lbls;
|
|
6183
|
+
} else {
|
|
6184
|
+
return 'No Label';
|
|
6185
|
+
}
|
|
6186
|
+
};
|
|
6187
|
+
|
|
6188
|
+
var renderExampleMark = function renderExampleMark() {
|
|
6189
|
+
if (!props.allowedToMarkExample) return null;
|
|
6190
|
+
var color = 'grey';
|
|
6191
|
+
var iconName = 'bookmark outline';
|
|
6192
|
+
if (props.anno) {
|
|
6193
|
+
if (props.anno.isExample) {
|
|
6194
|
+
color = 'yellow';
|
|
6195
|
+
iconName = 'bookmark';
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
var mark = React__default.createElement(
|
|
6199
|
+
semanticUiReact.Label,
|
|
6200
|
+
{
|
|
6201
|
+
as: 'a',
|
|
6202
|
+
color: color,
|
|
6203
|
+
style: { opacity: 0.8 },
|
|
6204
|
+
size: 'medium',
|
|
6205
|
+
corner: 'left',
|
|
6206
|
+
onClick: function onClick() {
|
|
6207
|
+
onMarkExampleClick();
|
|
6208
|
+
}
|
|
6209
|
+
},
|
|
6210
|
+
React__default.createElement(semanticUiReact.Icon, { name: iconName })
|
|
6211
|
+
);
|
|
6212
|
+
return React__default.createElement(SiaPopup, {
|
|
6213
|
+
content: 'Mark this annotation as example for other annotators',
|
|
6214
|
+
trigger: mark
|
|
6215
|
+
});
|
|
6216
|
+
};
|
|
6217
|
+
|
|
6218
|
+
var renderDescription = function renderDescription() {
|
|
6219
|
+
if (props.anno) {
|
|
6220
|
+
return React__default.createElement(
|
|
6221
|
+
'div',
|
|
6222
|
+
null,
|
|
6223
|
+
renderExampleMark(),
|
|
6224
|
+
React__default.createElement(
|
|
6225
|
+
semanticUiReact.List,
|
|
6226
|
+
null,
|
|
6227
|
+
React__default.createElement(semanticUiReact.List.Item, { icon: 'at', content: props.anno.id }),
|
|
6228
|
+
React__default.createElement(semanticUiReact.List.Item, { icon: 'tag', content: renderLabels() }),
|
|
6229
|
+
React__default.createElement(semanticUiReact.List.Item, {
|
|
6230
|
+
icon: 'time',
|
|
6231
|
+
content: props.anno.annoTime.toLocaleString('us', {
|
|
6232
|
+
minimumFractionDigits: 2,
|
|
6233
|
+
maximumFractionDigits: 2
|
|
6234
|
+
}) + ' seconds'
|
|
6235
|
+
})
|
|
6236
|
+
),
|
|
6237
|
+
renderComment()
|
|
6238
|
+
);
|
|
6239
|
+
} else {
|
|
6240
|
+
return 'No annotation selected!';
|
|
6241
|
+
}
|
|
6242
|
+
};
|
|
6243
|
+
|
|
6244
|
+
return React__default.createElement(InfoBox, {
|
|
6245
|
+
header: 'Annotation Details',
|
|
6246
|
+
content: renderDescription(),
|
|
6247
|
+
visible: props.visible,
|
|
6248
|
+
defaultPos: props.defaultPos,
|
|
6249
|
+
onDismiss: function onDismiss(e) {
|
|
6250
|
+
return _onDismiss();
|
|
6251
|
+
}
|
|
6252
|
+
});
|
|
6253
|
+
};
|
|
6254
|
+
|
|
6255
|
+
var _slicedToArray$1 = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
6256
|
+
|
|
6257
|
+
function _toConsumableArray$4(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
6258
|
+
// import actions from '../../../../actions'
|
|
6259
|
+
// import * as transform from '../utils/transform'
|
|
6260
|
+
// const { siaShowImgBar } = actions
|
|
6261
|
+
|
|
6262
|
+
var AnnoStats = function AnnoStats(props) {
|
|
6263
|
+
var _useState = React.useState([]),
|
|
6264
|
+
_useState2 = _slicedToArray$1(_useState, 2),
|
|
6265
|
+
hideList = _useState2[0],
|
|
6266
|
+
setHideList = _useState2[1];
|
|
6267
|
+
|
|
6268
|
+
React.useEffect(function () {
|
|
6269
|
+
setHideList([]);
|
|
6270
|
+
}, [props.imgLoadCount]);
|
|
6271
|
+
|
|
6272
|
+
var _onDismiss = function _onDismiss() {
|
|
6273
|
+
if (props.onDismiss) {
|
|
6274
|
+
props.onDismiss();
|
|
6275
|
+
}
|
|
6276
|
+
};
|
|
6277
|
+
|
|
6278
|
+
var onLblClick = function onLblClick(lbl) {
|
|
6279
|
+
var hideLbl = false;
|
|
6280
|
+
if (hideList.includes(lbl.id)) {
|
|
6281
|
+
setHideList(hideList.filter(function (e) {
|
|
6282
|
+
return e !== lbl.id;
|
|
6283
|
+
}));
|
|
6284
|
+
hideLbl = false;
|
|
6285
|
+
} else {
|
|
6286
|
+
// hideList.push(lbl.id)
|
|
6287
|
+
setHideList([].concat(_toConsumableArray$4(hideList), [lbl.id]));
|
|
6288
|
+
hideLbl = true;
|
|
6289
|
+
}
|
|
6290
|
+
if (props.onHideLbl) {
|
|
6291
|
+
props.onHideLbl(lbl, hideLbl);
|
|
6292
|
+
}
|
|
6293
|
+
};
|
|
6294
|
+
|
|
6295
|
+
var renderRow = function renderRow(s) {
|
|
6296
|
+
|
|
6297
|
+
var opacity = hideList.includes(s.id) ? 0.5 : 1.0;
|
|
6298
|
+
return React__default.createElement(
|
|
6299
|
+
semanticUiReact.List.Item,
|
|
6300
|
+
{ key: s.id },
|
|
6301
|
+
React__default.createElement(
|
|
6302
|
+
semanticUiReact.List.Content,
|
|
6303
|
+
null,
|
|
6304
|
+
React__default.createElement(
|
|
6305
|
+
semanticUiReact.Label,
|
|
6306
|
+
{ as: 'a', tag: true, style: { background: s.color, opacity: opacity },
|
|
6307
|
+
onClick: function onClick() {
|
|
6308
|
+
return onLblClick(s);
|
|
6309
|
+
}
|
|
6310
|
+
},
|
|
6311
|
+
s.label,
|
|
6312
|
+
React__default.createElement(
|
|
6313
|
+
semanticUiReact.Label.Detail,
|
|
6314
|
+
null,
|
|
6315
|
+
s.amount
|
|
6316
|
+
)
|
|
6317
|
+
)
|
|
6318
|
+
)
|
|
6319
|
+
);
|
|
6320
|
+
};
|
|
6321
|
+
|
|
6322
|
+
var renderRows = function renderRows() {
|
|
6323
|
+
var stats = {};
|
|
6324
|
+
props.annos.forEach(function (a) {
|
|
6325
|
+
// console.log('render rows', a)
|
|
6326
|
+
if (a.status !== 'deleted') {
|
|
6327
|
+
a.labelIds.forEach(function (lblId) {
|
|
6328
|
+
if (lblId in stats) {
|
|
6329
|
+
stats[lblId] += 1;
|
|
6330
|
+
} else {
|
|
6331
|
+
stats[lblId] = 1;
|
|
6332
|
+
}
|
|
6333
|
+
});
|
|
6334
|
+
if (a.labelIds.length === 0) {
|
|
6335
|
+
if (-1 in stats) {
|
|
6336
|
+
stats[-1] += 1;
|
|
6337
|
+
} else {
|
|
6338
|
+
stats[-1] = 1;
|
|
6339
|
+
}
|
|
6340
|
+
}
|
|
6341
|
+
}
|
|
6342
|
+
});
|
|
6343
|
+
var res = Object.entries(stats).map(function (_ref) {
|
|
6344
|
+
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
6345
|
+
key = _ref2[0],
|
|
6346
|
+
value = _ref2[1];
|
|
6347
|
+
|
|
6348
|
+
var lbl = props.possibleLabels.find(function (e) {
|
|
6349
|
+
return e.id === parseInt(key);
|
|
6350
|
+
});
|
|
6351
|
+
if (!lbl) {
|
|
6352
|
+
lbl = { 'id': -1, 'label': 'No Label', 'color': getDefaultColor() };
|
|
6353
|
+
}
|
|
6354
|
+
|
|
6355
|
+
lbl.amount = value;
|
|
6356
|
+
// return renderRow({class:idToLbl[key], amount:value, color:idToColor[key]})
|
|
6357
|
+
return renderRow(lbl);
|
|
6358
|
+
});
|
|
6359
|
+
return res;
|
|
6360
|
+
};
|
|
6361
|
+
var renderDescription = function renderDescription() {
|
|
6362
|
+
return React__default.createElement(
|
|
6363
|
+
semanticUiReact.List,
|
|
6364
|
+
null,
|
|
6365
|
+
renderRows()
|
|
6366
|
+
);
|
|
6367
|
+
};
|
|
6368
|
+
|
|
6369
|
+
return React__default.createElement(InfoBox, {
|
|
6370
|
+
header: 'Annotations per Label',
|
|
6371
|
+
content: renderDescription(),
|
|
6372
|
+
visible: props.visible,
|
|
6373
|
+
defaultPos: props.defaultPos,
|
|
6374
|
+
onDismiss: function onDismiss(e) {
|
|
6375
|
+
return _onDismiss();
|
|
6376
|
+
}
|
|
6377
|
+
});
|
|
6378
|
+
};
|
|
6379
|
+
|
|
6380
|
+
var LabelExampleViewer = function LabelExampleViewer(props) {
|
|
6381
|
+
|
|
6382
|
+
var requestExample = function requestExample(e) {
|
|
6383
|
+
e.stopPropagation();
|
|
6384
|
+
if (props.onRequestExample) {
|
|
6385
|
+
props.onRequestExample();
|
|
6386
|
+
}
|
|
6387
|
+
};
|
|
6388
|
+
var renderContent = function renderContent() {
|
|
6389
|
+
if (!props.lbl) return null;
|
|
6390
|
+
if (!props.exampleImg) return null;
|
|
6391
|
+
var description = React__default.createElement(
|
|
6392
|
+
'div',
|
|
6393
|
+
null,
|
|
6394
|
+
props.lbl.description,
|
|
6395
|
+
React__default.createElement(
|
|
6396
|
+
semanticUiReact.Divider,
|
|
6397
|
+
{ horizontal: true },
|
|
6398
|
+
' comment '
|
|
6399
|
+
),
|
|
6400
|
+
props.exampleImg.anno ? props.exampleImg.anno.comment : "no comment"
|
|
6401
|
+
);
|
|
6402
|
+
return React__default.createElement(
|
|
6403
|
+
'div',
|
|
6404
|
+
null,
|
|
6405
|
+
React__default.createElement(
|
|
6406
|
+
semanticUiReact.Card
|
|
6407
|
+
|
|
6408
|
+
// image={props.exampleImg.img}
|
|
6409
|
+
// description={props.lbl.description}
|
|
6410
|
+
// header={props.lbl.label}
|
|
6411
|
+
// // description={props.exampleImg.anno.comment}
|
|
6412
|
+
// extra={props.exampleImg.anno.comment}
|
|
6413
|
+
,
|
|
6414
|
+
null,
|
|
6415
|
+
React__default.createElement(semanticUiReact.Image, { onClick: function onClick(e) {
|
|
6416
|
+
return requestExample(e);
|
|
6417
|
+
}, src: props.exampleImg.img, wrapped: true, ui: false }),
|
|
6418
|
+
React__default.createElement(
|
|
6419
|
+
semanticUiReact.Card.Content,
|
|
6420
|
+
null,
|
|
6421
|
+
React__default.createElement(
|
|
6422
|
+
semanticUiReact.Card.Header,
|
|
6423
|
+
null,
|
|
6424
|
+
props.lbl.label
|
|
6425
|
+
),
|
|
6426
|
+
React__default.createElement(
|
|
6427
|
+
semanticUiReact.Card.Description,
|
|
6428
|
+
null,
|
|
6429
|
+
description
|
|
6430
|
+
)
|
|
6431
|
+
)
|
|
6432
|
+
)
|
|
6433
|
+
);
|
|
6434
|
+
};
|
|
6435
|
+
|
|
6436
|
+
var handlePromptClick = function handlePromptClick() {
|
|
6437
|
+
if (props.onClose) {
|
|
6438
|
+
props.onClose();
|
|
6439
|
+
}
|
|
6440
|
+
};
|
|
6441
|
+
|
|
6442
|
+
return React__default.createElement(Prompt, { onClick: function onClick() {
|
|
6443
|
+
handlePromptClick();
|
|
6444
|
+
},
|
|
6445
|
+
active: props.active, content: renderContent()
|
|
6446
|
+
});
|
|
6447
|
+
};
|
|
6448
|
+
|
|
6449
|
+
var _slicedToArray$2 = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
6450
|
+
var LabelInfo = function LabelInfo(props) {
|
|
6451
|
+
var _useState = React.useState(false),
|
|
6452
|
+
_useState2 = _slicedToArray$2(_useState, 2),
|
|
6453
|
+
showExampleViewer = _useState2[0],
|
|
6454
|
+
setShowExampleViewer = _useState2[1];
|
|
6455
|
+
|
|
6456
|
+
var _useState3 = React.useState(undefined),
|
|
6457
|
+
_useState4 = _slicedToArray$2(_useState3, 2),
|
|
6458
|
+
myLbl = _useState4[0],
|
|
6459
|
+
setMyLbl = _useState4[1];
|
|
6460
|
+
// const { data: exampleImg, mutate: getAnnoExample } = exampleApi.useGetAnnoExampleImg({})
|
|
6461
|
+
|
|
6462
|
+
|
|
6463
|
+
React.useEffect(function () {
|
|
6464
|
+
if (props.selectedAnno) {
|
|
6465
|
+
var selectedLabelIds = props.selectedAnno.labelIds;
|
|
6466
|
+
if (selectedLabelIds) {
|
|
6467
|
+
var lbl = props.possibleLabels.find(function (e) {
|
|
6468
|
+
return selectedLabelIds[0] === e.id;
|
|
6469
|
+
});
|
|
6470
|
+
if (lbl) {
|
|
6471
|
+
if (lbl !== myLbl) {
|
|
6472
|
+
setMyLbl(lbl);
|
|
6473
|
+
if (props.visible)
|
|
6474
|
+
// getAnnoExample({llId:lbl.id, type:'annoBased', drawAnno: true, addContext:0.05})
|
|
6475
|
+
requestImg(lbl, props.selectedAnno);
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6479
|
+
}
|
|
6480
|
+
}, [props.selectedAnno]);
|
|
6481
|
+
var _onDismiss = function _onDismiss() {
|
|
6482
|
+
if (props.onDismiss) {
|
|
6483
|
+
props.onDismiss();
|
|
6484
|
+
}
|
|
6485
|
+
};
|
|
6486
|
+
|
|
6487
|
+
var requestImg = function requestImg(lbl, anno) {
|
|
6488
|
+
if (props.onGetAnnoExample) {
|
|
6489
|
+
props.onGetAnnoExample({ lbl: lbl, anno: anno });
|
|
6490
|
+
}
|
|
6491
|
+
};
|
|
6492
|
+
|
|
6493
|
+
var handleImgClick = function handleImgClick() {
|
|
6494
|
+
console.log('clicked img');
|
|
6495
|
+
// setShowExampleViewer(true)
|
|
6496
|
+
// requestImg(myLbl, props.selectedAnno)
|
|
6497
|
+
|
|
6498
|
+
setShowExampleViewer(true);
|
|
6499
|
+
// getAnnoExample({llId:myLbl.id, type:'annoBased', drawAnno: true, addContext:0.05})
|
|
6500
|
+
};
|
|
6501
|
+
|
|
6502
|
+
var renderExampleImg = function renderExampleImg() {
|
|
6503
|
+
if (!props.exampleImg) return null;
|
|
6504
|
+
return React__default.createElement(
|
|
6505
|
+
'div',
|
|
6506
|
+
null,
|
|
6507
|
+
React__default.createElement(
|
|
6508
|
+
semanticUiReact.Divider,
|
|
6509
|
+
{ onClick: function onClick() {
|
|
6510
|
+
return handleImgClick();
|
|
6511
|
+
}, horizontal: true },
|
|
6512
|
+
' Example '
|
|
6513
|
+
),
|
|
6514
|
+
React__default.createElement(SiaPopup, { trigger: React__default.createElement(semanticUiReact.Image, { src: props.exampleImg.img, rounded: true, centered: true, size: 'medium',
|
|
6515
|
+
onClick: function onClick() {
|
|
6516
|
+
return handleImgClick();
|
|
6517
|
+
}
|
|
6518
|
+
}),
|
|
6519
|
+
content: 'Click on image to view more examples' })
|
|
6520
|
+
);
|
|
6521
|
+
};
|
|
6522
|
+
|
|
6523
|
+
var renderDescription = function renderDescription() {
|
|
6524
|
+
// if (props.selectedAnno){
|
|
6525
|
+
// if (myLbl){
|
|
6526
|
+
// const selectedLabelIds = props.selectedAnno.labelIds
|
|
6527
|
+
// if (!selectedLabelIds) return 'No Label'
|
|
6528
|
+
// const lbl = props.possibleLabels.find( e => {
|
|
6529
|
+
// return selectedLabelIds[0] === e.id
|
|
6530
|
+
// })
|
|
6531
|
+
if (!myLbl) return "No Label";
|
|
6532
|
+
return React__default.createElement(
|
|
6533
|
+
'div',
|
|
6534
|
+
null,
|
|
6535
|
+
React__default.createElement(
|
|
6536
|
+
semanticUiReact.Header,
|
|
6537
|
+
null,
|
|
6538
|
+
myLbl.label
|
|
6539
|
+
),
|
|
6540
|
+
React__default.createElement('div', { dangerouslySetInnerHTML: { __html: myLbl.description } }),
|
|
6541
|
+
renderExampleImg(),
|
|
6542
|
+
React__default.createElement(LabelExampleViewer, { onRequestExample: function onRequestExample() {
|
|
6543
|
+
return requestImg(myLbl, props.selectedAnno);
|
|
6544
|
+
}, onClose: function onClose() {
|
|
6545
|
+
setShowExampleViewer(false);
|
|
6546
|
+
}, active: showExampleViewer, lbl: myLbl, exampleImg: props.exampleImg })
|
|
6547
|
+
);
|
|
6548
|
+
// } else {
|
|
6549
|
+
// return 'No Label'
|
|
6550
|
+
// }
|
|
6551
|
+
};
|
|
6552
|
+
|
|
6553
|
+
return React__default.createElement(InfoBox, {
|
|
6554
|
+
header: 'Label Info',
|
|
6555
|
+
content: renderDescription(),
|
|
6556
|
+
visible: props.visible,
|
|
6557
|
+
defaultPos: props.defaultPos,
|
|
6558
|
+
onDismiss: function onDismiss() {
|
|
6559
|
+
return _onDismiss();
|
|
6560
|
+
}
|
|
6561
|
+
});
|
|
6562
|
+
};
|
|
6563
|
+
|
|
6564
|
+
var _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
6565
|
+
|
|
6566
|
+
var _createClass$h = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
6567
|
+
|
|
6568
|
+
function _classCallCheck$h(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6569
|
+
|
|
6570
|
+
function _possibleConstructorReturn$f(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
6571
|
+
|
|
6572
|
+
function _inherits$f(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
6573
|
+
// import actions from '../../../../actions'
|
|
6574
|
+
// const { siaShowImgBar, siaSetUIConfig } = actions
|
|
6575
|
+
|
|
6576
|
+
var InfoBoxes = function (_Component) {
|
|
6577
|
+
_inherits$f(InfoBoxes, _Component);
|
|
6578
|
+
|
|
6579
|
+
function InfoBoxes(props) {
|
|
6580
|
+
_classCallCheck$h(this, InfoBoxes);
|
|
6581
|
+
|
|
6582
|
+
var _this = _possibleConstructorReturn$f(this, (InfoBoxes.__proto__ || Object.getPrototypeOf(InfoBoxes)).call(this, props));
|
|
6583
|
+
|
|
6584
|
+
_this.state = {
|
|
6585
|
+
position: {
|
|
6586
|
+
top: 0,
|
|
6587
|
+
left: 0
|
|
6588
|
+
}
|
|
6589
|
+
};
|
|
6590
|
+
return _this;
|
|
6591
|
+
}
|
|
6592
|
+
|
|
6593
|
+
_createClass$h(InfoBoxes, [{
|
|
6594
|
+
key: 'componentDidMount',
|
|
6595
|
+
value: function componentDidMount() {
|
|
6596
|
+
this.updateLayout();
|
|
6597
|
+
}
|
|
6598
|
+
}, {
|
|
6599
|
+
key: 'componentDidUpdate',
|
|
6600
|
+
value: function componentDidUpdate(prevProps) {
|
|
6601
|
+
|
|
6602
|
+
if (this.props.layoutUpdate !== prevProps.layoutUpdate) {
|
|
6603
|
+
this.updateLayout();
|
|
6604
|
+
}
|
|
6605
|
+
if (this.props.commentInputTrigger !== prevProps.commentInputTrigger) {
|
|
6606
|
+
if (!this.props.uiConfig.annoDetails.visible) {
|
|
6607
|
+
this.showAnnoDetails(true);
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
}
|
|
6611
|
+
}, {
|
|
6612
|
+
key: 'updateLayout',
|
|
6613
|
+
value: function updateLayout() {
|
|
6614
|
+
if (this.props.container.current) {
|
|
6615
|
+
var container = this.props.container.current.getBoundingClientRect();
|
|
6616
|
+
this.setState({
|
|
6617
|
+
position: _extends$a({}, this.state.position, {
|
|
6618
|
+
left: container.right - 250,
|
|
6619
|
+
top: container.top
|
|
6620
|
+
})
|
|
6621
|
+
});
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6624
|
+
}, {
|
|
6625
|
+
key: 'showAnnoDetails',
|
|
6626
|
+
value: function showAnnoDetails() {
|
|
6627
|
+
var show = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
6628
|
+
|
|
6629
|
+
this.props.onUiConfigUpdate(_extends$a({}, this.props.uiConfig, {
|
|
6630
|
+
annoDetails: _extends$a({}, this.props.uiConfig.annoDetails, {
|
|
6631
|
+
visible: show
|
|
6632
|
+
})
|
|
6633
|
+
}));
|
|
6634
|
+
}
|
|
6635
|
+
}, {
|
|
6636
|
+
key: 'onDismiss',
|
|
6637
|
+
value: function onDismiss(type) {
|
|
6638
|
+
if (this.props.onUiConfigUpdate) {
|
|
6639
|
+
switch (type) {
|
|
6640
|
+
case 'AnnoDetails':
|
|
6641
|
+
this.showAnnoDetails(false);
|
|
6642
|
+
break;
|
|
6643
|
+
case 'LabelInfo':
|
|
6644
|
+
this.props.onUiConfigUpdate(_extends$a({}, this.props.uiConfig, {
|
|
6645
|
+
labelInfo: _extends$a({}, this.props.uiConfig.labelInfo, {
|
|
6646
|
+
visible: false
|
|
6647
|
+
})
|
|
6648
|
+
}));
|
|
6649
|
+
break;
|
|
6650
|
+
case 'AnnoStats':
|
|
6651
|
+
this.props.onUiConfigUpdate(_extends$a({}, this.props.uiConfig, {
|
|
6652
|
+
annoStats: _extends$a({}, this.props.uiConfig.annoStats, {
|
|
6653
|
+
visible: false
|
|
6654
|
+
})
|
|
6655
|
+
}));
|
|
6656
|
+
break;
|
|
6657
|
+
default:
|
|
6658
|
+
break;
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
}
|
|
6662
|
+
}, {
|
|
6663
|
+
key: 'onCommentUpdate',
|
|
6664
|
+
value: function onCommentUpdate(comment) {
|
|
6665
|
+
if (this.props.onCommentUpdate) {
|
|
6666
|
+
this.props.onCommentUpdate(comment);
|
|
6667
|
+
}
|
|
6668
|
+
}
|
|
6669
|
+
}, {
|
|
6670
|
+
key: 'onMarkExample',
|
|
6671
|
+
value: function onMarkExample(anno) {
|
|
6672
|
+
if (this.props.onMarkExample) {
|
|
6673
|
+
this.props.onMarkExample(anno);
|
|
6674
|
+
}
|
|
6675
|
+
}
|
|
6676
|
+
}, {
|
|
6677
|
+
key: 'onHideLbl',
|
|
6678
|
+
value: function onHideLbl(lbl, hide) {
|
|
6679
|
+
if (this.props.onHideLbl) {
|
|
6680
|
+
this.props.onHideLbl(lbl, hide);
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
}, {
|
|
6684
|
+
key: 'render',
|
|
6685
|
+
value: function render() {
|
|
6686
|
+
var _this2 = this;
|
|
6687
|
+
|
|
6688
|
+
if (!this.props.annos) return null;
|
|
6689
|
+
// if (!this.props.selectedAnno) return null
|
|
6690
|
+
return React__default.createElement(
|
|
6691
|
+
'div',
|
|
6692
|
+
null,
|
|
6693
|
+
React__default.createElement(LabelInfo, { selectedAnno: this.props.selectedAnno,
|
|
6694
|
+
possibleLabels: this.props.possibleLabels,
|
|
6695
|
+
defaultPos: this.state.position,
|
|
6696
|
+
onDismiss: function onDismiss() {
|
|
6697
|
+
return _this2.onDismiss('LabelInfo');
|
|
6698
|
+
},
|
|
6699
|
+
visible: this.props.uiConfig.labelInfo.visible,
|
|
6700
|
+
onGetAnnoExample: function onGetAnnoExample(exampleArgs) {
|
|
6701
|
+
return _this2.props.onGetAnnoExample ? _this2.props.onGetAnnoExample(exampleArgs) : {};
|
|
6702
|
+
},
|
|
6703
|
+
exampleImg: this.props.exampleImg
|
|
6704
|
+
}),
|
|
6705
|
+
React__default.createElement(AnnoDetails, { anno: this.props.selectedAnno,
|
|
6706
|
+
possibleLabels: this.props.possibleLabels,
|
|
6707
|
+
defaultPos: {
|
|
6708
|
+
left: this.state.position.left - 300,
|
|
6709
|
+
top: this.state.position.top
|
|
6710
|
+
},
|
|
6711
|
+
onDismiss: function onDismiss() {
|
|
6712
|
+
return _this2.onDismiss('AnnoDetails');
|
|
6713
|
+
},
|
|
6714
|
+
onCommentUpdate: function onCommentUpdate(comment) {
|
|
6715
|
+
return _this2.onCommentUpdate(comment);
|
|
6716
|
+
},
|
|
6717
|
+
onMarkExample: function onMarkExample(anno) {
|
|
6718
|
+
return _this2.onMarkExample(anno);
|
|
6719
|
+
},
|
|
6720
|
+
allowedToMarkExample: this.props.allowedToMarkExample,
|
|
6721
|
+
commentInputTrigger: this.props.commentInputTrigger,
|
|
6722
|
+
visible: this.props.uiConfig.annoDetails.visible
|
|
6723
|
+
}),
|
|
6724
|
+
React__default.createElement(AnnoStats, { selectedAnno: this.props.selectedAnno,
|
|
6725
|
+
annos: this.props.annos,
|
|
6726
|
+
possibleLabels: this.props.possibleLabels,
|
|
6727
|
+
defaultPos: {
|
|
6728
|
+
left: this.state.position.left,
|
|
6729
|
+
top: this.state.position.top + 400
|
|
6730
|
+
}
|
|
6731
|
+
// defaultPos={this.state.position}
|
|
6732
|
+
, onDismiss: function onDismiss() {
|
|
6733
|
+
return _this2.onDismiss('AnnoStats');
|
|
6734
|
+
},
|
|
6735
|
+
onHideLbl: function onHideLbl(lbl, hide) {
|
|
6736
|
+
return _this2.onHideLbl(lbl, hide);
|
|
6737
|
+
},
|
|
6738
|
+
visible: this.props.uiConfig.annoStats.visible,
|
|
6739
|
+
imgLoadCount: this.props.imgLoadCount
|
|
6740
|
+
})
|
|
6741
|
+
);
|
|
6742
|
+
}
|
|
6743
|
+
}]);
|
|
6744
|
+
|
|
6745
|
+
return InfoBoxes;
|
|
6746
|
+
}(React.Component);
|
|
6747
|
+
|
|
6748
|
+
var _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
6749
|
+
|
|
6750
|
+
var _createClass$i = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
6751
|
+
|
|
6752
|
+
function _toConsumableArray$5(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
6753
|
+
|
|
6754
|
+
function _classCallCheck$i(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6755
|
+
|
|
6756
|
+
function _possibleConstructorReturn$g(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
6757
|
+
|
|
6758
|
+
function _inherits$g(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
6759
|
+
|
|
3781
6760
|
/**
|
|
3782
6761
|
* SIA Canvas element that handles annotations within an image
|
|
3783
6762
|
*
|
|
@@ -3815,10 +6794,16 @@ function _inherits$e(subClass, superClass) { if (typeof superClass !== "function
|
|
|
3815
6794
|
* label: str, (name of the label)
|
|
3816
6795
|
* color: str (color is optional)
|
|
3817
6796
|
* }
|
|
3818
|
-
* @param {
|
|
3819
|
-
* {id: int, data: blob}
|
|
6797
|
+
* @param {blob} imageBlob - The actual image blob that will be displayed
|
|
3820
6798
|
* @param {object} uiConfig - User interface configs
|
|
3821
|
-
* {
|
|
6799
|
+
* {
|
|
6800
|
+
* nodesRadius: int, strokeWidth: int,
|
|
6801
|
+
* layoutOffset: {left:int, top:int, right:int, bottom:int}, -> Offset of the canvas inside the container
|
|
6802
|
+
* imgBarVisible: bool,
|
|
6803
|
+
* imgLabelInputVisible: bool,
|
|
6804
|
+
* centerCanvasInContainer: bool, -> Center the canvas in the middle of the container.
|
|
6805
|
+
* maxCanvas: bool -> Maximize Canvas Size. Do not fit canvas to image size.
|
|
6806
|
+
* }
|
|
3822
6807
|
* @param {int} layoutUpdate - A counter that triggers a layout update
|
|
3823
6808
|
* everytime it is incremented.
|
|
3824
6809
|
* @param {string} selectedTool - The tool that is selected to draw an
|
|
@@ -3846,44 +6831,43 @@ function _inherits$e(subClass, superClass) { if (typeof superClass !== "function
|
|
|
3846
6831
|
* actions: {
|
|
3847
6832
|
* label: bool,
|
|
3848
6833
|
* }
|
|
3849
|
-
* }
|
|
6834
|
+
* },
|
|
6835
|
+
* allowedToMarkExample: bool, -> Indicates wether the current user is allowed to mark an annotation as example.
|
|
6836
|
+
* autoSaveInterval: int -> Interval in seconds when an autosave will be requested by canvas
|
|
3850
6837
|
* }
|
|
3851
|
-
* @param {bool} imgBarVisible - Controls visibility of the ImgBar
|
|
3852
|
-
* @param {bool} imgLabelInputVisible - Controls visibility of the ImgLabelInputPrompt
|
|
3853
|
-
* @param {object} layoutOffset - Offset of the canvas inside the container:
|
|
3854
|
-
* {left:int, top:int, right:int, bottom:int} values in pixels.
|
|
3855
|
-
* @param {bool} centerCanvasInContainer - Center the canvas in the
|
|
3856
|
-
* middle of the container.
|
|
3857
|
-
* @param {bool} maxCanvas - Maximize Canvas Size. Do not fit canvas to image size
|
|
3858
6838
|
* @param {str or int} defaultLabel (optional) - Name or ID of the default label that is used
|
|
3859
6839
|
* when no label was selected by the annotator. If not set "no label" will be used.
|
|
3860
6840
|
* If ID is used, it needs to be one of the possible label ids.
|
|
3861
6841
|
* @param {bool} blocked Block canvas view with loading dimmer.
|
|
6842
|
+
* @param {int} nextAnnoId Id that will be used for the next annotation that
|
|
6843
|
+
* will be created. If undefined, the canvas will create its own ids.
|
|
3862
6844
|
* @param {bool} lockedAnnos A list of AnnoIds of annos that should only be displayed.
|
|
3863
6845
|
* Such annos can not be edited in any way.
|
|
3864
|
-
* @event onSVGUpdate - Fires when the svg in canvas changed.
|
|
3865
|
-
* args: {width: int, height: int, scale: float, translateX: float,
|
|
3866
|
-
* translateY:float}
|
|
3867
|
-
* @event onImageLoaded - Fires when an image was loaded into the canvas
|
|
3868
|
-
* @event onAnnoSelect - Fires when an annotation was selected or if the
|
|
3869
|
-
* selected annotation was updated.
|
|
3870
|
-
* @event onImgBarClose - Fires when close button on ImgBar was hit.
|
|
3871
|
-
* @event onImgLabelInputClose - ImgLabelInput requests to be closed.
|
|
3872
6846
|
* @event onNotification - Callback for Notification messages
|
|
3873
6847
|
* args: {title: str, message: str, type: str}
|
|
3874
6848
|
* @event onKeyDown - Fires for keyDown on canvas
|
|
3875
6849
|
* @event onKeyUp - Fires for keyUp on canvas
|
|
3876
|
-
* @event
|
|
3877
|
-
* args: {
|
|
6850
|
+
* @event onAnnoEvent - Fires when an anno performed an action
|
|
6851
|
+
* args: {anno: annoObject, newAnnos: list of annoObjects, pAction: str}
|
|
6852
|
+
* @event onCanvasEvent - Fires on canvas event
|
|
6853
|
+
* args: {action: action, data: dataObject}
|
|
6854
|
+
* action -> CANVAS_SVG_UPDATE
|
|
6855
|
+
* data: {width: int, height: int, scale: float, translateX: float,
|
|
6856
|
+
* translateY:float}
|
|
6857
|
+
* action -> CANVAS_UI_CONFIG_UPDATE
|
|
6858
|
+
* action -> CANVAS_LABEL_INPUT_CLOSE
|
|
6859
|
+
* action -> CANVAS_IMG_LOADED
|
|
6860
|
+
* action -> CANVAS_IMGBAR_CLOSE
|
|
6861
|
+
* @event onImgBarClose - Fires when close button on ImgBar was hit.
|
|
3878
6862
|
*/
|
|
3879
6863
|
|
|
3880
6864
|
var Canvas = function (_Component) {
|
|
3881
|
-
_inherits$
|
|
6865
|
+
_inherits$g(Canvas, _Component);
|
|
3882
6866
|
|
|
3883
6867
|
function Canvas(props) {
|
|
3884
|
-
_classCallCheck$
|
|
6868
|
+
_classCallCheck$i(this, Canvas);
|
|
3885
6869
|
|
|
3886
|
-
var _this = _possibleConstructorReturn$
|
|
6870
|
+
var _this = _possibleConstructorReturn$g(this, (Canvas.__proto__ || Object.getPrototypeOf(Canvas)).call(this, props));
|
|
3887
6871
|
|
|
3888
6872
|
_this.state = {
|
|
3889
6873
|
|
|
@@ -3916,11 +6900,13 @@ var Canvas = function (_Component) {
|
|
|
3916
6900
|
imgLoadTimestamp: 0,
|
|
3917
6901
|
performedImageInit: false,
|
|
3918
6902
|
prevLabel: [],
|
|
3919
|
-
|
|
6903
|
+
imageBlob: undefined,
|
|
3920
6904
|
isJunk: false,
|
|
3921
6905
|
imgBarVisible: false,
|
|
3922
6906
|
annoToolBarVisible: false,
|
|
3923
|
-
possibleLabels: undefined
|
|
6907
|
+
possibleLabels: undefined,
|
|
6908
|
+
annoCommentInputTrigger: 0
|
|
6909
|
+
// showAnnoCommentInput: false
|
|
3924
6910
|
};
|
|
3925
6911
|
_this.img = React__default.createRef();
|
|
3926
6912
|
_this.svg = React__default.createRef();
|
|
@@ -3931,17 +6917,52 @@ var Canvas = function (_Component) {
|
|
|
3931
6917
|
});
|
|
3932
6918
|
_this.mousePosAbs = undefined;
|
|
3933
6919
|
_this.clipboard = undefined;
|
|
6920
|
+
_this.autoSaveI = undefined;
|
|
3934
6921
|
return _this;
|
|
3935
6922
|
}
|
|
3936
6923
|
|
|
3937
|
-
_createClass$
|
|
6924
|
+
_createClass$i(Canvas, [{
|
|
3938
6925
|
key: 'componentDidMount',
|
|
3939
6926
|
value: function componentDidMount() {
|
|
6927
|
+
var _this2 = this;
|
|
6928
|
+
|
|
3940
6929
|
this.updatePossibleLabels();
|
|
3941
6930
|
if (Number.isInteger(this.props.defaultLabel)) {
|
|
3942
6931
|
|
|
3943
6932
|
this.setState({ prevLabel: [this.props.defaultLabel] });
|
|
3944
6933
|
}
|
|
6934
|
+
if (this.props.canvasConfig.autoSaveInterval) {
|
|
6935
|
+
this.autoSaveI = setInterval(function () {
|
|
6936
|
+
// console.log('AutoSave')
|
|
6937
|
+
// this.props.onAutoSave()
|
|
6938
|
+
_this2.triggerCanvasEvent(CANVAS_AUTO_SAVE);
|
|
6939
|
+
}, this.props.canvasConfig.autoSaveInterval * 1000);
|
|
6940
|
+
}
|
|
6941
|
+
if (this.props.onGetFunction) {
|
|
6942
|
+
this.props.onGetFunction({
|
|
6943
|
+
'deleteAllAnnos': function deleteAllAnnos() {
|
|
6944
|
+
return _this2.deleteAllAnnos();
|
|
6945
|
+
},
|
|
6946
|
+
'unloadImage': function unloadImage() {
|
|
6947
|
+
return _this2.unloadImage();
|
|
6948
|
+
},
|
|
6949
|
+
'resetZoom': function resetZoom() {
|
|
6950
|
+
return _this2.resetZoom();
|
|
6951
|
+
},
|
|
6952
|
+
'getAnnos': function getAnnos(annos, removeFrontendIds) {
|
|
6953
|
+
return _this2.getAnnos(annos, removeFrontendIds);
|
|
6954
|
+
}
|
|
6955
|
+
});
|
|
6956
|
+
// this.props.onGetFunction(
|
|
6957
|
+
// () => this.deleteAllAnnos()
|
|
6958
|
+
// )
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
}, {
|
|
6962
|
+
key: 'componentWillUnmount',
|
|
6963
|
+
value: function componentWillUnmount() {
|
|
6964
|
+
clearInterval(this.autoSaveI);
|
|
6965
|
+
console.log('Cleard auto save interval!');
|
|
3945
6966
|
}
|
|
3946
6967
|
}, {
|
|
3947
6968
|
key: 'componentDidUpdate',
|
|
@@ -3949,19 +6970,21 @@ var Canvas = function (_Component) {
|
|
|
3949
6970
|
// if (this.props.image.id !== prevProps.image.id){
|
|
3950
6971
|
|
|
3951
6972
|
// }
|
|
3952
|
-
if (prevProps.
|
|
6973
|
+
if (prevProps.imageMeta !== this.props.imageMeta) {
|
|
3953
6974
|
this.setState({
|
|
3954
|
-
imgLabelIds: this.props.
|
|
3955
|
-
imgAnnoTime: this.props.
|
|
6975
|
+
imgLabelIds: this.props.imageMeta.labelIds,
|
|
6976
|
+
imgAnnoTime: this.props.imageMeta.annoTime,
|
|
3956
6977
|
imgLoadTimestamp: performance.now()
|
|
3957
6978
|
// isJunk: this.props.annos.image.isJunk
|
|
3958
6979
|
});
|
|
3959
|
-
|
|
3960
|
-
|
|
6980
|
+
}
|
|
6981
|
+
if (prevProps.annos !== this.props.annos) {
|
|
6982
|
+
if (this.state.imageBlob) {
|
|
6983
|
+
this.updateCanvasView(fixBackendAnnos(this.props.annos));
|
|
3961
6984
|
}
|
|
3962
6985
|
// this.setState({
|
|
3963
6986
|
// imageLoaded: false,
|
|
3964
|
-
// //
|
|
6987
|
+
// // imageBlob: undefined
|
|
3965
6988
|
// })
|
|
3966
6989
|
}
|
|
3967
6990
|
if (prevProps.isJunk !== this.props.isJunk) {
|
|
@@ -3971,8 +6994,8 @@ var Canvas = function (_Component) {
|
|
|
3971
6994
|
});
|
|
3972
6995
|
}
|
|
3973
6996
|
}
|
|
3974
|
-
if (this.state.
|
|
3975
|
-
this.setState({
|
|
6997
|
+
if (this.state.imageBlob !== this.props.imageBlob) {
|
|
6998
|
+
this.setState({ imageBlob: this.props.imageBlob });
|
|
3976
6999
|
}
|
|
3977
7000
|
// if (!this.state.imageLoaded){
|
|
3978
7001
|
// if(this.props.annos.image.id === this.props.image.id){
|
|
@@ -3993,11 +7016,11 @@ var Canvas = function (_Component) {
|
|
|
3993
7016
|
performedImageInit: false,
|
|
3994
7017
|
annoToolBarVisible: false
|
|
3995
7018
|
});
|
|
3996
|
-
if (this.props.imgBarVisible) {
|
|
7019
|
+
if (this.props.uiConfig.imgBarVisible) {
|
|
3997
7020
|
this.setState({ imgBarVisible: true });
|
|
3998
7021
|
}
|
|
3999
7022
|
this.hist.clearHist();
|
|
4000
|
-
this.hist.push(_extends$
|
|
7023
|
+
this.hist.push(_extends$b({}, this.getAnnos(), {
|
|
4001
7024
|
selectedAnnoId: undefined
|
|
4002
7025
|
}), 'init');
|
|
4003
7026
|
}
|
|
@@ -4005,11 +7028,13 @@ var Canvas = function (_Component) {
|
|
|
4005
7028
|
// Selected annotation should be on top
|
|
4006
7029
|
this.putSelectedOnTop(prevState);
|
|
4007
7030
|
if (prevState.imgLoadCount !== this.state.imgLoadCount) {
|
|
4008
|
-
this.updateCanvasView(fixBackendAnnos(this.props.annos
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
7031
|
+
this.updateCanvasView(fixBackendAnnos(this.props.annos));
|
|
7032
|
+
if (this.props.imageMeta) {
|
|
7033
|
+
this.setImageLabels(this.props.imageMeta.labelIds);
|
|
7034
|
+
this.setState({
|
|
7035
|
+
performedImageInit: true
|
|
7036
|
+
});
|
|
7037
|
+
}
|
|
4013
7038
|
}
|
|
4014
7039
|
if (prevProps.layoutUpdate !== this.props.layoutUpdate) {
|
|
4015
7040
|
this.selectAnnotation(undefined);
|
|
@@ -4029,9 +7054,10 @@ var Canvas = function (_Component) {
|
|
|
4029
7054
|
showSingleAnno: undefined,
|
|
4030
7055
|
selectedAnnoId: undefined
|
|
4031
7056
|
});
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
7057
|
+
this.triggerCanvasEvent(CANVAS_IMG_LOADED);
|
|
7058
|
+
// if (this.props.onImageLoaded){
|
|
7059
|
+
// this.props.onImageLoaded()
|
|
7060
|
+
// }
|
|
4035
7061
|
}
|
|
4036
7062
|
}, {
|
|
4037
7063
|
key: 'onMouseOver',
|
|
@@ -4064,7 +7090,7 @@ var Canvas = function (_Component) {
|
|
|
4064
7090
|
} else {
|
|
4065
7091
|
newTranslation = getZoomTranslation(mousePos, this.state.svg, nextScale);
|
|
4066
7092
|
}
|
|
4067
|
-
this.setState({ svg: _extends$
|
|
7093
|
+
this.setState({ svg: _extends$b({}, this.state.svg, {
|
|
4068
7094
|
scale: nextScale,
|
|
4069
7095
|
// translateX: -1*(mousePos.x * nextScale - mousePos.x)/nextScale,
|
|
4070
7096
|
// translateY: -1*(mousePos.y * nextScale - mousePos.y)/nextScale
|
|
@@ -4119,6 +7145,24 @@ var Canvas = function (_Component) {
|
|
|
4119
7145
|
break;
|
|
4120
7146
|
}
|
|
4121
7147
|
}
|
|
7148
|
+
|
|
7149
|
+
// handleAnnoCommentInputClose(comment){
|
|
7150
|
+
// const anno = this.findAnno(this.state.selectedAnnoId)
|
|
7151
|
+
// anno.comment = comment
|
|
7152
|
+
// this.stopAnnotimeMeasure(anno)
|
|
7153
|
+
// this.updateSelectedAnno(anno, modes.VIEW)
|
|
7154
|
+
// console.log('handleAnnoCommentInputClose', comment)
|
|
7155
|
+
// }
|
|
7156
|
+
|
|
7157
|
+
}, {
|
|
7158
|
+
key: 'updateAnnoComment',
|
|
7159
|
+
value: function updateAnnoComment(comment) {
|
|
7160
|
+
var anno = this.findAnno(this.state.selectedAnnoId);
|
|
7161
|
+
anno.comment = comment;
|
|
7162
|
+
this.handleAnnoEvent(anno, ANNO_COMMENT_UPDATE);
|
|
7163
|
+
// this.stopAnnotimeMeasure(anno)
|
|
7164
|
+
// console.log('updateAnnoComment', comment)
|
|
7165
|
+
}
|
|
4122
7166
|
}, {
|
|
4123
7167
|
key: 'handleKeyAction',
|
|
4124
7168
|
value: function handleKeyAction(action) {
|
|
@@ -4141,6 +7185,13 @@ var Canvas = function (_Component) {
|
|
|
4141
7185
|
case DELETE_ANNO:
|
|
4142
7186
|
this.deleteAnnotation(anno);
|
|
4143
7187
|
break;
|
|
7188
|
+
case TOGGLE_ANNO_COMMENT_INPUT:
|
|
7189
|
+
if (this.state.selectedAnnoId) {
|
|
7190
|
+
this.setState({ annoCommentInputTrigger: this.state.annoCommentInputTrigger + 1 });
|
|
7191
|
+
// this.startAnnotimeMeasure(anno)
|
|
7192
|
+
// this.showSingleAnno(this.state.selectedAnnoId)
|
|
7193
|
+
}
|
|
7194
|
+
break;
|
|
4144
7195
|
case DELETE_ANNO_IN_CREATION:
|
|
4145
7196
|
this.deleteAnnoInCreationMode(anno);
|
|
4146
7197
|
break;
|
|
@@ -4227,6 +7278,20 @@ var Canvas = function (_Component) {
|
|
|
4227
7278
|
this.removeSelectedAnno();
|
|
4228
7279
|
}
|
|
4229
7280
|
|
|
7281
|
+
/**
|
|
7282
|
+
* Trigger canvas event
|
|
7283
|
+
* @param {String} action Action that was performed
|
|
7284
|
+
* @param {Object} data Data object of the action
|
|
7285
|
+
*/
|
|
7286
|
+
|
|
7287
|
+
}, {
|
|
7288
|
+
key: 'triggerCanvasEvent',
|
|
7289
|
+
value: function triggerCanvasEvent(action, data) {
|
|
7290
|
+
if (this.props.onCanvasEvent) {
|
|
7291
|
+
this.props.onCanvasEvent(action, data);
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
|
|
4230
7295
|
/**
|
|
4231
7296
|
* Handle actions that have been performed by an annotation
|
|
4232
7297
|
* @param {Number} anno Id of the annotation
|
|
@@ -4234,12 +7299,20 @@ var Canvas = function (_Component) {
|
|
|
4234
7299
|
*/
|
|
4235
7300
|
|
|
4236
7301
|
}, {
|
|
4237
|
-
key: '
|
|
4238
|
-
value: function
|
|
7302
|
+
key: 'handleAnnoEvent',
|
|
7303
|
+
value: function handleAnnoEvent(anno, pAction) {
|
|
4239
7304
|
var newAnnos = undefined;
|
|
4240
7305
|
switch (pAction) {
|
|
7306
|
+
case ANNO_MARK_EXAMPLE:
|
|
7307
|
+
newAnnos = this.updateSelectedAnno(anno, VIEW);
|
|
7308
|
+
this.pushHist(newAnnos, anno.id, pAction, this.state.showSingleAnno);
|
|
7309
|
+
break;
|
|
4241
7310
|
case ANNO_SELECTED:
|
|
4242
7311
|
this.selectAnnotation(anno.id);
|
|
7312
|
+
// this.pushHist(
|
|
7313
|
+
// this.state.annos, anno.id,
|
|
7314
|
+
// pAction, this.state.showSingleAnno
|
|
7315
|
+
// )
|
|
4243
7316
|
break;
|
|
4244
7317
|
case ANNO_START_CREATING:
|
|
4245
7318
|
newAnnos = this.updateSelectedAnno(anno);
|
|
@@ -4296,6 +7369,18 @@ var Canvas = function (_Component) {
|
|
|
4296
7369
|
this.showSingleAnno(undefined);
|
|
4297
7370
|
this.pushHist(newAnnos, undefined, pAction, this.state.showSingleAnno);
|
|
4298
7371
|
break;
|
|
7372
|
+
case ANNO_COMMENT_UPDATE:
|
|
7373
|
+
newAnnos = this.updateSelectedAnno(anno, VIEW);
|
|
7374
|
+
// newAnnos = this.updateSelectedAnno(anno, modes.DELETED)
|
|
7375
|
+
// this.selectAnnotation(undefined)
|
|
7376
|
+
// this.showSingleAnno(undefined)
|
|
7377
|
+
this.pushHist(newAnnos, anno.id, pAction, this.state.showSingleAnno);
|
|
7378
|
+
this.handleNotification({
|
|
7379
|
+
title: "Saved comment",
|
|
7380
|
+
message: 'Saved comment: ' + anno.comment,
|
|
7381
|
+
type: SUCCESS
|
|
7382
|
+
});
|
|
7383
|
+
break;
|
|
4299
7384
|
case ANNO_LABEL_UPDATE:
|
|
4300
7385
|
anno = this.stopAnnotimeMeasure(anno);
|
|
4301
7386
|
if (!this.checkAnnoLength(anno)) {
|
|
@@ -4322,8 +7407,8 @@ var Canvas = function (_Component) {
|
|
|
4322
7407
|
console.warn('Action not handeled', pAction);
|
|
4323
7408
|
break;
|
|
4324
7409
|
}
|
|
4325
|
-
if (this.props.
|
|
4326
|
-
this.props.
|
|
7410
|
+
if (this.props.onAnnoEvent) {
|
|
7411
|
+
this.props.onAnnoEvent(anno, newAnnos, pAction);
|
|
4327
7412
|
}
|
|
4328
7413
|
}
|
|
4329
7414
|
}, {
|
|
@@ -4338,14 +7423,15 @@ var Canvas = function (_Component) {
|
|
|
4338
7423
|
this.showLabelInput(false);
|
|
4339
7424
|
this.showSingleAnno(undefined);
|
|
4340
7425
|
var anno = this.findAnno(this.state.selectedAnnoId);
|
|
4341
|
-
this.
|
|
7426
|
+
this.handleAnnoEvent(anno, ANNO_LABEL_UPDATE);
|
|
4342
7427
|
}
|
|
4343
7428
|
}, {
|
|
4344
7429
|
key: 'handleImgBarClose',
|
|
4345
7430
|
value: function handleImgBarClose() {
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
7431
|
+
this.triggerCanvasEvent(CANVAS_IMGBAR_CLOSE);
|
|
7432
|
+
// if (this.props.onImgBarClose){
|
|
7433
|
+
// this.props.onImgBarClose()
|
|
7434
|
+
// }
|
|
4349
7435
|
}
|
|
4350
7436
|
}, {
|
|
4351
7437
|
key: 'handleImgLabelUpdate',
|
|
@@ -4359,7 +7445,7 @@ var Canvas = function (_Component) {
|
|
|
4359
7445
|
}, {
|
|
4360
7446
|
key: 'handleCanvasClick',
|
|
4361
7447
|
value: function handleCanvasClick(e) {
|
|
4362
|
-
if (this.props.imgBarVisible) {
|
|
7448
|
+
if (this.props.uiConfig.imgBarVisible) {
|
|
4363
7449
|
this.setState({ imgBarVisible: true });
|
|
4364
7450
|
}
|
|
4365
7451
|
}
|
|
@@ -4371,10 +7457,16 @@ var Canvas = function (_Component) {
|
|
|
4371
7457
|
}, {
|
|
4372
7458
|
key: 'handleImgLabelInputClose',
|
|
4373
7459
|
value: function handleImgLabelInputClose() {
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
7460
|
+
this.triggerCanvasEvent(CANVAS_LABEL_INPUT_CLOSE);
|
|
7461
|
+
// if (this.props.onImgLabelInputClose){
|
|
7462
|
+
// this.props.onImgLabelInputClose()
|
|
7463
|
+
// }
|
|
4377
7464
|
}
|
|
7465
|
+
|
|
7466
|
+
// handleAnnoCommentInputClose(e){
|
|
7467
|
+
// this.showAnnoCommentInputField(false)
|
|
7468
|
+
// }
|
|
7469
|
+
|
|
4378
7470
|
}, {
|
|
4379
7471
|
key: 'handleSvgMouseMove',
|
|
4380
7472
|
value: function handleSvgMouseMove(e) {
|
|
@@ -4387,6 +7479,48 @@ var Canvas = function (_Component) {
|
|
|
4387
7479
|
this.props.onNotification(messageObj);
|
|
4388
7480
|
}
|
|
4389
7481
|
}
|
|
7482
|
+
}, {
|
|
7483
|
+
key: 'handleHideLbl',
|
|
7484
|
+
value: function handleHideLbl(lbl, hide) {
|
|
7485
|
+
var _this3 = this;
|
|
7486
|
+
|
|
7487
|
+
// console.log('hide lbl', lbl, hide)
|
|
7488
|
+
var hiddenSelected = false;
|
|
7489
|
+
var newAnnos = this.state.annos.map(function (anno) {
|
|
7490
|
+
// console.log('map annos', anno)
|
|
7491
|
+
var newAnno = _extends$b({}, anno);
|
|
7492
|
+
if (anno.labelIds.includes(lbl.id)) {
|
|
7493
|
+
newAnno.visible = !hide;
|
|
7494
|
+
if (anno.id === _this3.state.selectedAnnoId) hiddenSelected = true;
|
|
7495
|
+
} else if (anno.labelIds.length === 0) {
|
|
7496
|
+
// no label case
|
|
7497
|
+
if (lbl.id === -1) {
|
|
7498
|
+
// -1 indicates no label
|
|
7499
|
+
newAnno.visible = !hide;
|
|
7500
|
+
if (anno.id === _this3.state.selectedAnnoId) hiddenSelected = true;
|
|
7501
|
+
}
|
|
7502
|
+
}
|
|
7503
|
+
return newAnno;
|
|
7504
|
+
});
|
|
7505
|
+
// console.log('newAnnos', newAnnos)
|
|
7506
|
+
this.setState({ annos: newAnnos });
|
|
7507
|
+
if (hiddenSelected) {
|
|
7508
|
+
this.selectAnnotation(undefined);
|
|
7509
|
+
}
|
|
7510
|
+
}
|
|
7511
|
+
}, {
|
|
7512
|
+
key: 'handleMarkExample',
|
|
7513
|
+
value: function handleMarkExample(anno) {
|
|
7514
|
+
var newAnno = _extends$b({}, anno);
|
|
7515
|
+
if (newAnno.isExample == undefined) {
|
|
7516
|
+
newAnno.isExample = true;
|
|
7517
|
+
} else if (newAnno.isExample) {
|
|
7518
|
+
newAnno.isExample = false;
|
|
7519
|
+
} else {
|
|
7520
|
+
newAnno.isExample = true;
|
|
7521
|
+
}
|
|
7522
|
+
this.handleAnnoEvent(newAnno, ANNO_MARK_EXAMPLE);
|
|
7523
|
+
}
|
|
4390
7524
|
|
|
4391
7525
|
/*************
|
|
4392
7526
|
* LOGIC *
|
|
@@ -4408,9 +7542,9 @@ var Canvas = function (_Component) {
|
|
|
4408
7542
|
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
4409
7543
|
|
|
4410
7544
|
if (this.clipboard) {
|
|
4411
|
-
var annos = [].concat(_toConsumableArray$
|
|
7545
|
+
var annos = [].concat(_toConsumableArray$5(this.state.annos));
|
|
4412
7546
|
var uid = _.uniqueId('new');
|
|
4413
|
-
annos.push(_extends$
|
|
7547
|
+
annos.push(_extends$b({}, this.clipboard, {
|
|
4414
7548
|
id: uid,
|
|
4415
7549
|
annoTime: 0,
|
|
4416
7550
|
status: NEW,
|
|
@@ -4474,13 +7608,13 @@ var Canvas = function (_Component) {
|
|
|
4474
7608
|
var lbls = this.props.possibleLabels;
|
|
4475
7609
|
lbls = lbls.map(function (e) {
|
|
4476
7610
|
if (!('color' in e)) {
|
|
4477
|
-
return _extends$
|
|
7611
|
+
return _extends$b({}, e, { color: getColor(e.id) });
|
|
4478
7612
|
} else {
|
|
4479
|
-
return _extends$
|
|
7613
|
+
return _extends$b({}, e);
|
|
4480
7614
|
}
|
|
4481
7615
|
});
|
|
4482
7616
|
this.setState({
|
|
4483
|
-
possibleLabels: [].concat(_toConsumableArray$
|
|
7617
|
+
possibleLabels: [].concat(_toConsumableArray$5(lbls))
|
|
4484
7618
|
});
|
|
4485
7619
|
}
|
|
4486
7620
|
}, {
|
|
@@ -4491,7 +7625,7 @@ var Canvas = function (_Component) {
|
|
|
4491
7625
|
if (anno === undefined) {
|
|
4492
7626
|
myAnno = this.findAnno(this.state.selectedAnnoId);
|
|
4493
7627
|
} else {
|
|
4494
|
-
myAnno = _extends$
|
|
7628
|
+
myAnno = _extends$b({}, anno);
|
|
4495
7629
|
}
|
|
4496
7630
|
myAnno = this.startAnnotimeMeasure(myAnno);
|
|
4497
7631
|
this.showLabelInput();
|
|
@@ -4535,7 +7669,7 @@ var Canvas = function (_Component) {
|
|
|
4535
7669
|
value: function pushHist(annos, selectedAnnoId, pAction, showSingleAnno) {
|
|
4536
7670
|
var imgLabelIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.state.imgLabelIds;
|
|
4537
7671
|
|
|
4538
|
-
this.hist.push(_extends$
|
|
7672
|
+
this.hist.push(_extends$b({}, this.getAnnos(annos, false), {
|
|
4539
7673
|
selectedAnnoId: selectedAnnoId,
|
|
4540
7674
|
showSingleAnno: showSingleAnno,
|
|
4541
7675
|
imgLabelIds: imgLabelIds
|
|
@@ -4565,7 +7699,7 @@ var Canvas = function (_Component) {
|
|
|
4565
7699
|
var ar = this.findAnnoRef(this.state.selectedAnnoId);
|
|
4566
7700
|
if (ar !== undefined) ar.current.myAnno.current.removeLastNode();
|
|
4567
7701
|
} else {
|
|
4568
|
-
this.
|
|
7702
|
+
this.handleAnnoEvent(anno, ANNO_DELETED);
|
|
4569
7703
|
}
|
|
4570
7704
|
}
|
|
4571
7705
|
}
|
|
@@ -4576,7 +7710,7 @@ var Canvas = function (_Component) {
|
|
|
4576
7710
|
if (anno.mode === CREATE) {
|
|
4577
7711
|
// const ar = this.findAnnoRef(this.state.selectedAnnoId)
|
|
4578
7712
|
// if (ar !== undefined) ar.current.myAnno.current.removeLastNode()
|
|
4579
|
-
this.
|
|
7713
|
+
this.handleAnnoEvent(anno, ANNO_DELETED);
|
|
4580
7714
|
}
|
|
4581
7715
|
}
|
|
4582
7716
|
}
|
|
@@ -4586,7 +7720,7 @@ var Canvas = function (_Component) {
|
|
|
4586
7720
|
var newAnnos = [];
|
|
4587
7721
|
this.state.annos.forEach(function (e) {
|
|
4588
7722
|
if (typeof e.id !== "string") {
|
|
4589
|
-
newAnnos.push(_extends$
|
|
7723
|
+
newAnnos.push(_extends$b({}, e, { status: DELETED$1 }));
|
|
4590
7724
|
}
|
|
4591
7725
|
});
|
|
4592
7726
|
this.pushHist(newAnnos, undefined, 'deletedAllAnnos', this.state.showSingleAnno, this.state.imgLabelIds);
|
|
@@ -4608,8 +7742,8 @@ var Canvas = function (_Component) {
|
|
|
4608
7742
|
}, {
|
|
4609
7743
|
key: 'setCanvasState',
|
|
4610
7744
|
value: function setCanvasState(annotations, imgLabelIds, selectedAnnoId, showSingleAnno) {
|
|
4611
|
-
this.updateCanvasView(_extends$
|
|
4612
|
-
this.setImageLabels([].concat(_toConsumableArray$
|
|
7745
|
+
this.updateCanvasView(_extends$b({}, annotations));
|
|
7746
|
+
this.setImageLabels([].concat(_toConsumableArray$5(imgLabelIds)));
|
|
4613
7747
|
this.selectAnnotation(selectedAnnoId);
|
|
4614
7748
|
this.setState({ showSingleAnno: showSingleAnno });
|
|
4615
7749
|
}
|
|
@@ -4655,10 +7789,10 @@ var Canvas = function (_Component) {
|
|
|
4655
7789
|
this.onAnnoLabelInputClose();
|
|
4656
7790
|
}
|
|
4657
7791
|
}
|
|
4658
|
-
if
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
}
|
|
7792
|
+
// if(this.props.onAnnoSelect){
|
|
7793
|
+
// const anno = this.findAnno(annoId)
|
|
7794
|
+
// this.props.onAnnoSelect(anno)
|
|
7795
|
+
// }
|
|
4662
7796
|
}
|
|
4663
7797
|
|
|
4664
7798
|
/**
|
|
@@ -4668,18 +7802,18 @@ var Canvas = function (_Component) {
|
|
|
4668
7802
|
}, {
|
|
4669
7803
|
key: 'traverseAnnos',
|
|
4670
7804
|
value: function traverseAnnos() {
|
|
4671
|
-
var
|
|
7805
|
+
var _this4 = this;
|
|
4672
7806
|
|
|
4673
7807
|
if (this.state.annos.length > 0) {
|
|
4674
7808
|
var myAnnos = this.state.annos.filter(function (e) {
|
|
4675
|
-
return e.status !== DELETED$1 && !
|
|
7809
|
+
return e.status !== DELETED$1 && !_this4.isLocked(e.id) && !(e.visible === false);
|
|
4676
7810
|
});
|
|
4677
7811
|
if (myAnnos.length > 0) {
|
|
4678
7812
|
if (!this.state.selectedAnnoId) {
|
|
4679
7813
|
this.selectAnnotation(myAnnos[0].id);
|
|
4680
7814
|
} else {
|
|
4681
7815
|
var currentIdx = myAnnos.findIndex(function (e) {
|
|
4682
|
-
return e.id ===
|
|
7816
|
+
return e.id === _this4.state.selectedAnnoId;
|
|
4683
7817
|
});
|
|
4684
7818
|
if (currentIdx + 1 < myAnnos.length) {
|
|
4685
7819
|
this.selectAnnotation(myAnnos[currentIdx + 1].id);
|
|
@@ -4700,12 +7834,12 @@ var Canvas = function (_Component) {
|
|
|
4700
7834
|
// const backendFormat = this.getAnnoBackendFormat(removeFrontedIds, myAnnos)
|
|
4701
7835
|
var backendFormat = canvasToBackendAnnos(myAnnos, this.state.svg, removeFrontedIds, this.state.imageOffset);
|
|
4702
7836
|
var finalData = {
|
|
4703
|
-
imgId: this.props.
|
|
7837
|
+
imgId: this.props.imageMeta.id,
|
|
4704
7838
|
imgLabelIds: this.state.imgLabelIds,
|
|
4705
7839
|
imgLabelChanged: this.state.imgLabelChanged,
|
|
4706
7840
|
annotations: backendFormat,
|
|
4707
7841
|
isJunk: this.state.isJunk,
|
|
4708
|
-
annoTime: this.props.
|
|
7842
|
+
annoTime: this.props.imageMeta.annoTime + (performance.now() - this.state.imgLoadTimestamp) / 1000
|
|
4709
7843
|
};
|
|
4710
7844
|
return finalData;
|
|
4711
7845
|
}
|
|
@@ -4717,7 +7851,7 @@ var Canvas = function (_Component) {
|
|
|
4717
7851
|
}, {
|
|
4718
7852
|
key: 'resetZoom',
|
|
4719
7853
|
value: function resetZoom() {
|
|
4720
|
-
this.setState({ svg: _extends$
|
|
7854
|
+
this.setState({ svg: _extends$b({}, this.state.svg, {
|
|
4721
7855
|
translateX: 0,
|
|
4722
7856
|
translateY: 0,
|
|
4723
7857
|
scale: 1.0
|
|
@@ -4744,7 +7878,7 @@ var Canvas = function (_Component) {
|
|
|
4744
7878
|
} else if (vRight.vY <= yXMax) {
|
|
4745
7879
|
trans_y = this.state.svg.translateY + 5;
|
|
4746
7880
|
}
|
|
4747
|
-
this.setState({ svg: _extends$
|
|
7881
|
+
this.setState({ svg: _extends$b({}, this.state.svg, {
|
|
4748
7882
|
translateX: trans_x,
|
|
4749
7883
|
translateY: trans_y
|
|
4750
7884
|
}) });
|
|
@@ -4819,7 +7953,7 @@ var Canvas = function (_Component) {
|
|
|
4819
7953
|
var mousePos = this.getMousePosition(e);
|
|
4820
7954
|
// const selAnno = this.findAnno(this.state.selectedAnnoId)
|
|
4821
7955
|
var newAnno = {
|
|
4822
|
-
id: _.uniqueId('new'),
|
|
7956
|
+
id: this.props.nextAnnoId ? this.props.nextAnnoId : _.uniqueId('new'),
|
|
4823
7957
|
type: this.props.selectedTool,
|
|
4824
7958
|
data: [{
|
|
4825
7959
|
x: mousePos.x,
|
|
@@ -4836,7 +7970,7 @@ var Canvas = function (_Component) {
|
|
|
4836
7970
|
};
|
|
4837
7971
|
newAnno = this.startAnnotimeMeasure(newAnno);
|
|
4838
7972
|
this.setState({
|
|
4839
|
-
annos: [].concat(_toConsumableArray$
|
|
7973
|
+
annos: [].concat(_toConsumableArray$5(this.state.annos), [newAnno]),
|
|
4840
7974
|
selectedAnnoId: newAnno.id,
|
|
4841
7975
|
showSingleAnno: newAnno.id,
|
|
4842
7976
|
annoToolBarVisible: false
|
|
@@ -4889,7 +8023,7 @@ var Canvas = function (_Component) {
|
|
|
4889
8023
|
|
|
4890
8024
|
newAnno = this.startAnnotimeMeasure(newAnno);
|
|
4891
8025
|
this.setState({
|
|
4892
|
-
annos: [].concat(_toConsumableArray$
|
|
8026
|
+
annos: [].concat(_toConsumableArray$5(this.state.annos), [newAnno]),
|
|
4893
8027
|
selectedAnnoId: newAnno.id,
|
|
4894
8028
|
showSingleAnno: newAnno.id,
|
|
4895
8029
|
annoToolBarVisible: false
|
|
@@ -4900,20 +8034,20 @@ var Canvas = function (_Component) {
|
|
|
4900
8034
|
}, {
|
|
4901
8035
|
key: 'putSelectedOnTop',
|
|
4902
8036
|
value: function putSelectedOnTop(prevState) {
|
|
4903
|
-
var
|
|
8037
|
+
var _this5 = this;
|
|
4904
8038
|
|
|
4905
8039
|
// The selected annotation need to be rendered as last one in
|
|
4906
8040
|
// oder to be above all other annotations.
|
|
4907
8041
|
if (this.state.selectedAnnoId) {
|
|
4908
8042
|
if (prevState.selectedAnnoId !== this.state.selectedAnnoId) {
|
|
4909
8043
|
var annos = this.state.annos.filter(function (el) {
|
|
4910
|
-
return el.id !==
|
|
8044
|
+
return el.id !== _this5.state.selectedAnnoId;
|
|
4911
8045
|
});
|
|
4912
8046
|
var lastAnno = this.state.annos.find(function (el) {
|
|
4913
|
-
return el.id ===
|
|
8047
|
+
return el.id === _this5.state.selectedAnnoId;
|
|
4914
8048
|
});
|
|
4915
8049
|
annos.push(lastAnno);
|
|
4916
|
-
this.setState({ annos: [].concat(_toConsumableArray$
|
|
8050
|
+
this.setState({ annos: [].concat(_toConsumableArray$5(annos)) });
|
|
4917
8051
|
}
|
|
4918
8052
|
}
|
|
4919
8053
|
}
|
|
@@ -4963,11 +8097,11 @@ var Canvas = function (_Component) {
|
|
|
4963
8097
|
selectedAnnoId: anno.id,
|
|
4964
8098
|
prevLabel: anno.labelIds
|
|
4965
8099
|
});
|
|
4966
|
-
if
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
}
|
|
8100
|
+
// if(this.props.onAnnoSelect){
|
|
8101
|
+
// if (newAnno !== null){
|
|
8102
|
+
// this.props.onAnnoSelect(newAnno)
|
|
8103
|
+
// }
|
|
8104
|
+
// }
|
|
4971
8105
|
return newAnnos;
|
|
4972
8106
|
}
|
|
4973
8107
|
}, {
|
|
@@ -4980,27 +8114,27 @@ var Canvas = function (_Component) {
|
|
|
4980
8114
|
});
|
|
4981
8115
|
var newAnno = void 0;
|
|
4982
8116
|
if (mode) {
|
|
4983
|
-
newAnno = _extends$
|
|
8117
|
+
newAnno = _extends$b({}, anno, { mode: mode });
|
|
4984
8118
|
if (mode === DELETED) {
|
|
4985
8119
|
if (anno.status !== NEW) {
|
|
4986
|
-
newAnno = _extends$
|
|
8120
|
+
newAnno = _extends$b({}, newAnno, {
|
|
4987
8121
|
status: DELETED$1
|
|
4988
8122
|
});
|
|
4989
8123
|
} else {
|
|
4990
8124
|
newAnno = null;
|
|
4991
8125
|
}
|
|
4992
8126
|
} else {
|
|
4993
|
-
newAnno = _extends$
|
|
8127
|
+
newAnno = _extends$b({}, newAnno, {
|
|
4994
8128
|
status: anno.status !== NEW ? CHANGED : NEW
|
|
4995
8129
|
});
|
|
4996
8130
|
}
|
|
4997
8131
|
} else {
|
|
4998
|
-
newAnno = _extends$
|
|
8132
|
+
newAnno = _extends$b({}, anno);
|
|
4999
8133
|
}
|
|
5000
8134
|
if (newAnno !== null) {
|
|
5001
8135
|
filtered.push(newAnno);
|
|
5002
8136
|
}
|
|
5003
|
-
var newAnnos = [].concat(_toConsumableArray$
|
|
8137
|
+
var newAnnos = [].concat(_toConsumableArray$5(filtered));
|
|
5004
8138
|
return { newAnnos: newAnnos, newAnno: newAnno };
|
|
5005
8139
|
}
|
|
5006
8140
|
}, {
|
|
@@ -5027,11 +8161,12 @@ var Canvas = function (_Component) {
|
|
|
5027
8161
|
var canvasLeft;
|
|
5028
8162
|
var maxImgHeight;
|
|
5029
8163
|
var maxImgWidth;
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
8164
|
+
var layoutOffset = this.props.uiConfig.layoutOffset;
|
|
8165
|
+
if (layoutOffset) {
|
|
8166
|
+
canvasTop = container.top + layoutOffset.top;
|
|
8167
|
+
canvasLeft = container.left + layoutOffset.left;
|
|
8168
|
+
maxImgHeight = clientHeight - container.top - layoutOffset.bottom - layoutOffset.top;
|
|
8169
|
+
maxImgWidth = container.right - canvasLeft - layoutOffset.right;
|
|
5035
8170
|
} else {
|
|
5036
8171
|
canvasTop = container.top;
|
|
5037
8172
|
canvasLeft = container.left;
|
|
@@ -5051,15 +8186,15 @@ var Canvas = function (_Component) {
|
|
|
5051
8186
|
}
|
|
5052
8187
|
var svg;
|
|
5053
8188
|
var imgOffset = { x: 0, y: 0 };
|
|
5054
|
-
if (this.props.maxCanvas) {
|
|
8189
|
+
if (this.props.uiConfig.maxCanvas) {
|
|
5055
8190
|
imgOffset.x = (maxImgWidth - imgWidth) / 2;
|
|
5056
8191
|
imgOffset.y = (maxImgHeight - imgHeight) / 2;
|
|
5057
8192
|
console.log('imgOffset: ', imgOffset);
|
|
5058
|
-
svg = _extends$
|
|
8193
|
+
svg = _extends$b({}, this.state.svg, { width: maxImgWidth, height: maxImgHeight,
|
|
5059
8194
|
left: canvasLeft, top: canvasTop
|
|
5060
8195
|
});
|
|
5061
8196
|
} else {
|
|
5062
|
-
if (this.props.centerCanvasInContainer) {
|
|
8197
|
+
if (this.props.uiConfig.centerCanvasInContainer) {
|
|
5063
8198
|
var resSpaceX = maxImgWidth - imgWidth;
|
|
5064
8199
|
if (resSpaceX > 2) {
|
|
5065
8200
|
canvasLeft = canvasLeft + resSpaceX / 2;
|
|
@@ -5069,7 +8204,7 @@ var Canvas = function (_Component) {
|
|
|
5069
8204
|
canvasTop = canvasTop + resSpaceY / 2;
|
|
5070
8205
|
}
|
|
5071
8206
|
}
|
|
5072
|
-
svg = _extends$
|
|
8207
|
+
svg = _extends$b({}, this.state.svg, { width: imgWidth, height: imgHeight,
|
|
5073
8208
|
left: canvasLeft, top: canvasTop
|
|
5074
8209
|
});
|
|
5075
8210
|
}
|
|
@@ -5087,9 +8222,10 @@ var Canvas = function (_Component) {
|
|
|
5087
8222
|
}, {
|
|
5088
8223
|
key: 'svgUpdate',
|
|
5089
8224
|
value: function svgUpdate(svg) {
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
8225
|
+
this.triggerCanvasEvent(CANVAS_SVG_UPDATE, svg);
|
|
8226
|
+
// if(this.props.onSVGUpdate){
|
|
8227
|
+
// this.props.onSVGUpdate(svg)
|
|
8228
|
+
// }
|
|
5093
8229
|
}
|
|
5094
8230
|
}, {
|
|
5095
8231
|
key: 'setImageLabels',
|
|
@@ -5107,40 +8243,41 @@ var Canvas = function (_Component) {
|
|
|
5107
8243
|
//for svg should be calculated
|
|
5108
8244
|
if (annotations) {
|
|
5109
8245
|
var imgSize = this.updateImageSize();
|
|
5110
|
-
this.setState({ annos: [].concat(_toConsumableArray$
|
|
8246
|
+
this.setState({ annos: [].concat(_toConsumableArray$5(backendAnnosToCanvas(annotations, { width: imgSize.imgWidth, height: imgSize.imgHeight }, imgSize.imgOffset))) });
|
|
5111
8247
|
}
|
|
5112
8248
|
}
|
|
5113
8249
|
}, {
|
|
5114
8250
|
key: 'renderAnnotations',
|
|
5115
8251
|
value: function renderAnnotations() {
|
|
5116
|
-
var
|
|
8252
|
+
var _this6 = this;
|
|
5117
8253
|
|
|
5118
8254
|
// Do not render annotations while moving the camera!
|
|
5119
8255
|
if (this.state.mode !== CAMERA_MOVE) {
|
|
5120
8256
|
this.annoRefs = [];
|
|
5121
8257
|
var annos = this.state.annos.map(function (el) {
|
|
5122
|
-
|
|
8258
|
+
_this6.annoRefs.push(React__default.createRef());
|
|
5123
8259
|
return React__default.createElement(Annotation$1, { type: el.type,
|
|
5124
|
-
data: el, key: el.id, svg: _extends$
|
|
5125
|
-
|
|
8260
|
+
data: el, key: el.id, svg: _extends$b({}, _this6.state.svg),
|
|
8261
|
+
imageOffset: _this6.state.imageOffset,
|
|
8262
|
+
ref: _this6.annoRefs[_this6.annoRefs.length - 1],
|
|
5126
8263
|
onMouseDown: function onMouseDown(e) {
|
|
5127
|
-
return
|
|
8264
|
+
return _this6.onAnnoMouseDown(e);
|
|
5128
8265
|
},
|
|
5129
8266
|
onAction: function onAction(anno, pAction) {
|
|
5130
|
-
return
|
|
8267
|
+
return _this6.handleAnnoEvent(anno, pAction);
|
|
5131
8268
|
},
|
|
5132
|
-
selectedAnno:
|
|
8269
|
+
selectedAnno: _this6.state.selectedAnnoId
|
|
5133
8270
|
// onModeChange={(anno) => this.onAnnoModeChange(anno)}
|
|
5134
|
-
, showSingleAnno:
|
|
5135
|
-
uiConfig:
|
|
5136
|
-
allowedActions:
|
|
5137
|
-
possibleLabels:
|
|
5138
|
-
image:
|
|
5139
|
-
canvasConfig:
|
|
8271
|
+
, showSingleAnno: _this6.state.showSingleAnno,
|
|
8272
|
+
uiConfig: _this6.props.uiConfig,
|
|
8273
|
+
allowedActions: _this6.props.canvasConfig.annos.actions,
|
|
8274
|
+
possibleLabels: _this6.state.possibleLabels,
|
|
8275
|
+
image: _this6.state.image,
|
|
8276
|
+
canvasConfig: _this6.props.canvasConfig,
|
|
5140
8277
|
onNotification: function onNotification(messageObj) {
|
|
5141
|
-
return
|
|
8278
|
+
return _this6.handleNotification(messageObj);
|
|
5142
8279
|
},
|
|
5143
|
-
defaultLabel:
|
|
8280
|
+
defaultLabel: _this6.props.defaultLabel
|
|
5144
8281
|
});
|
|
5145
8282
|
});
|
|
5146
8283
|
return React__default.createElement(
|
|
@@ -5155,14 +8292,14 @@ var Canvas = function (_Component) {
|
|
|
5155
8292
|
}, {
|
|
5156
8293
|
key: 'renderImgLabelInput',
|
|
5157
8294
|
value: function renderImgLabelInput() {
|
|
5158
|
-
var
|
|
8295
|
+
var _this7 = this;
|
|
5159
8296
|
|
|
5160
|
-
if (!this.props.
|
|
8297
|
+
if (!this.props.imageMeta) return null;
|
|
5161
8298
|
return React__default.createElement(Prompt, {
|
|
5162
8299
|
onClick: function onClick() {
|
|
5163
|
-
return
|
|
8300
|
+
return _this7.handleImgLabelInputClose();
|
|
5164
8301
|
},
|
|
5165
|
-
active: this.props.imgLabelInputVisible,
|
|
8302
|
+
active: this.props.uiConfig.imgLabelInputVisible,
|
|
5166
8303
|
header: React__default.createElement(
|
|
5167
8304
|
'div',
|
|
5168
8305
|
null,
|
|
@@ -5177,11 +8314,11 @@ var Canvas = function (_Component) {
|
|
|
5177
8314
|
// relatedId={this.props.annos.image.id}
|
|
5178
8315
|
, visible: true,
|
|
5179
8316
|
onLabelUpdate: function onLabelUpdate(label) {
|
|
5180
|
-
return
|
|
8317
|
+
return _this7.handleImgLabelUpdate(label);
|
|
5181
8318
|
},
|
|
5182
8319
|
possibleLabels: this.state.possibleLabels,
|
|
5183
8320
|
initLabelIds: this.state.imgLabelIds,
|
|
5184
|
-
relatedId: this.props.
|
|
8321
|
+
relatedId: this.props.imageMeta.id,
|
|
5185
8322
|
defaultLabel: this.props.defaultLabel
|
|
5186
8323
|
// disabled={!this.props.allowedActions.label}
|
|
5187
8324
|
// renderPopup
|
|
@@ -5190,7 +8327,7 @@ var Canvas = function (_Component) {
|
|
|
5190
8327
|
semanticUiReact.Button,
|
|
5191
8328
|
{ basic: true, color: 'green', inverted: true,
|
|
5192
8329
|
onClick: function onClick() {
|
|
5193
|
-
return
|
|
8330
|
+
return _this7.handleImgLabelInputClose();
|
|
5194
8331
|
}
|
|
5195
8332
|
},
|
|
5196
8333
|
React__default.createElement(semanticUiReact.Icon, { name: 'check' }),
|
|
@@ -5202,7 +8339,7 @@ var Canvas = function (_Component) {
|
|
|
5202
8339
|
}, {
|
|
5203
8340
|
key: 'renderAnnoToolBar',
|
|
5204
8341
|
value: function renderAnnoToolBar(selectedAnno) {
|
|
5205
|
-
var
|
|
8342
|
+
var _this8 = this;
|
|
5206
8343
|
|
|
5207
8344
|
var visible = this.state.annoToolBarVisible;
|
|
5208
8345
|
if (this.state.mode === CAMERA_MOVE) visible = false;
|
|
@@ -5210,7 +8347,7 @@ var Canvas = function (_Component) {
|
|
|
5210
8347
|
selectedAnno: selectedAnno,
|
|
5211
8348
|
svg: this.state.svg,
|
|
5212
8349
|
onClick: function onClick() {
|
|
5213
|
-
return
|
|
8350
|
+
return _this8.editAnnoLabel();
|
|
5214
8351
|
},
|
|
5215
8352
|
color: this.getAnnoColor()
|
|
5216
8353
|
});
|
|
@@ -5218,22 +8355,22 @@ var Canvas = function (_Component) {
|
|
|
5218
8355
|
}, {
|
|
5219
8356
|
key: 'renderAnnoLabelInpput',
|
|
5220
8357
|
value: function renderAnnoLabelInpput(selectedAnno) {
|
|
5221
|
-
var
|
|
8358
|
+
var _this9 = this;
|
|
5222
8359
|
|
|
5223
8360
|
var visible = this.state.showLabelInput;
|
|
5224
8361
|
if (this.state.mode === CAMERA_MOVE) visible = false;
|
|
5225
8362
|
return React__default.createElement(AnnoLabelInput, { svg: this.state.svg
|
|
5226
8363
|
// svgRef={this.svg}
|
|
5227
8364
|
, onClose: function onClose() {
|
|
5228
|
-
return
|
|
8365
|
+
return _this9.onAnnoLabelInputClose();
|
|
5229
8366
|
},
|
|
5230
8367
|
onDeleteClick: function onDeleteClick(annoId) {
|
|
5231
|
-
return
|
|
8368
|
+
return _this9.onLabelInputDeleteClick(annoId);
|
|
5232
8369
|
},
|
|
5233
8370
|
selectedAnno: selectedAnno,
|
|
5234
8371
|
visible: visible,
|
|
5235
8372
|
onLabelUpdate: function onLabelUpdate(anno) {
|
|
5236
|
-
return
|
|
8373
|
+
return _this9.onAnnoLabelInputUpdate(anno);
|
|
5237
8374
|
},
|
|
5238
8375
|
possibleLabels: this.state.possibleLabels,
|
|
5239
8376
|
allowedActions: this.props.canvasConfig.annos.actions,
|
|
@@ -5243,10 +8380,19 @@ var Canvas = function (_Component) {
|
|
|
5243
8380
|
// multilabels={true}
|
|
5244
8381
|
});
|
|
5245
8382
|
}
|
|
8383
|
+
|
|
8384
|
+
// renderAnnoCommentInput(selectedAnno){
|
|
8385
|
+
// return <AnnoCommentInput
|
|
8386
|
+
// triggerInput={this.state.annoCommentInputTrigger}
|
|
8387
|
+
// onClose={comment => this.handleAnnoCommentInputClose(comment)}
|
|
8388
|
+
// iniComment={selectedAnno ? selectedAnno.comment : ''}
|
|
8389
|
+
// />
|
|
8390
|
+
// }
|
|
8391
|
+
|
|
5246
8392
|
}, {
|
|
5247
8393
|
key: 'render',
|
|
5248
8394
|
value: function render() {
|
|
5249
|
-
var
|
|
8395
|
+
var _this10 = this;
|
|
5250
8396
|
|
|
5251
8397
|
var selectedAnno = this.findAnno(this.state.selectedAnnoId);
|
|
5252
8398
|
return React__default.createElement(
|
|
@@ -5263,8 +8409,9 @@ var Canvas = function (_Component) {
|
|
|
5263
8409
|
possibleLabels: this.state.possibleLabels,
|
|
5264
8410
|
annos: this.props.annos,
|
|
5265
8411
|
svg: this.state.svg,
|
|
8412
|
+
imageMeta: this.props.imageMeta,
|
|
5266
8413
|
onClose: function onClose() {
|
|
5267
|
-
return
|
|
8414
|
+
return _this10.handleImgBarClose();
|
|
5268
8415
|
},
|
|
5269
8416
|
imgLabelIds: this.state.imgLabelIds
|
|
5270
8417
|
// onLabelUpdate={label => this.handleImgLabelUpdate(label)}
|
|
@@ -5272,7 +8419,7 @@ var Canvas = function (_Component) {
|
|
|
5272
8419
|
// multilabels={this.props.canvasConfig.img.multilabels}
|
|
5273
8420
|
// allowedActions={this.props.canvasConfig.img.actions}
|
|
5274
8421
|
, onMouseEnter: function onMouseEnter(e) {
|
|
5275
|
-
return
|
|
8422
|
+
return _this10.handleImgBarMouseEnter(e);
|
|
5276
8423
|
}
|
|
5277
8424
|
}),
|
|
5278
8425
|
React__default.createElement(
|
|
@@ -5296,21 +8443,47 @@ var Canvas = function (_Component) {
|
|
|
5296
8443
|
),
|
|
5297
8444
|
this.renderAnnoToolBar(selectedAnno),
|
|
5298
8445
|
this.renderAnnoLabelInpput(selectedAnno),
|
|
8446
|
+
React__default.createElement(InfoBoxes, { container: this.props.container,
|
|
8447
|
+
layoutUpdate: this.props.layoutUpdate,
|
|
8448
|
+
annos: this.state.annos,
|
|
8449
|
+
selectedAnno: selectedAnno,
|
|
8450
|
+
possibleLabels: this.state.possibleLabels,
|
|
8451
|
+
allowedToMarkExample: this.props.canvasConfig.allowedToMarkExample,
|
|
8452
|
+
uiConfig: this.props.uiConfig,
|
|
8453
|
+
imgLoadCount: this.state.imgLoadCount,
|
|
8454
|
+
onCommentUpdate: function onCommentUpdate(comment) {
|
|
8455
|
+
return _this10.updateAnnoComment(comment);
|
|
8456
|
+
},
|
|
8457
|
+
onUiConfigUpdate: function onUiConfigUpdate(e) {
|
|
8458
|
+
return _this10.triggerCanvasEvent(CANVAS_UI_CONFIG_UPDATE, e);
|
|
8459
|
+
},
|
|
8460
|
+
onHideLbl: function onHideLbl(lbl, hide) {
|
|
8461
|
+
return _this10.handleHideLbl(lbl, hide);
|
|
8462
|
+
},
|
|
8463
|
+
onMarkExample: function onMarkExample(anno) {
|
|
8464
|
+
return _this10.handleMarkExample(anno);
|
|
8465
|
+
},
|
|
8466
|
+
commentInputTrigger: this.state.annoCommentInputTrigger,
|
|
8467
|
+
onGetAnnoExample: function onGetAnnoExample(exampleArgs) {
|
|
8468
|
+
return _this10.props.onGetAnnoExample ? _this10.props.onGetAnnoExample(exampleArgs) : {};
|
|
8469
|
+
},
|
|
8470
|
+
exampleImg: this.props.exampleImg
|
|
8471
|
+
}),
|
|
5299
8472
|
React__default.createElement(
|
|
5300
8473
|
'svg',
|
|
5301
8474
|
{ ref: this.svg, width: this.state.svg.width,
|
|
5302
8475
|
height: this.state.svg.height,
|
|
5303
8476
|
onKeyDown: function onKeyDown(e) {
|
|
5304
|
-
return
|
|
8477
|
+
return _this10.onKeyDown(e);
|
|
5305
8478
|
},
|
|
5306
8479
|
onKeyUp: function onKeyUp(e) {
|
|
5307
|
-
return
|
|
8480
|
+
return _this10.onKeyUp(e);
|
|
5308
8481
|
},
|
|
5309
8482
|
onClick: function onClick(e) {
|
|
5310
|
-
return
|
|
8483
|
+
return _this10.handleCanvasClick(e);
|
|
5311
8484
|
},
|
|
5312
8485
|
onMouseMove: function onMouseMove(e) {
|
|
5313
|
-
return
|
|
8486
|
+
return _this10.handleSvgMouseMove(e);
|
|
5314
8487
|
},
|
|
5315
8488
|
tabIndex: '0'
|
|
5316
8489
|
},
|
|
@@ -5319,26 +8492,27 @@ var Canvas = function (_Component) {
|
|
|
5319
8492
|
{
|
|
5320
8493
|
transform: 'scale(' + this.state.svg.scale + ') translate(' + this.state.svg.translateX + ', ' + this.state.svg.translateY + ')',
|
|
5321
8494
|
onMouseOver: function onMouseOver() {
|
|
5322
|
-
|
|
5323
|
-
}
|
|
5324
|
-
|
|
5325
|
-
|
|
8495
|
+
_this10.onMouseOver();
|
|
8496
|
+
}
|
|
8497
|
+
// onMouseEnter={() => this.svg.current.focus()}
|
|
8498
|
+
, onMouseUp: function onMouseUp(e) {
|
|
8499
|
+
_this10.onMouseUp(e);
|
|
5326
8500
|
},
|
|
5327
8501
|
onWheel: function onWheel(e) {
|
|
5328
|
-
return
|
|
8502
|
+
return _this10.onWheel(e);
|
|
5329
8503
|
},
|
|
5330
8504
|
onMouseMove: function onMouseMove(e) {
|
|
5331
|
-
|
|
8505
|
+
_this10.onMouseMove(e);
|
|
5332
8506
|
}
|
|
5333
8507
|
},
|
|
5334
8508
|
React__default.createElement('image', {
|
|
5335
8509
|
onContextMenu: function onContextMenu(e) {
|
|
5336
|
-
return
|
|
8510
|
+
return _this10.onRightClick(e);
|
|
5337
8511
|
},
|
|
5338
8512
|
onMouseDown: function onMouseDown(e) {
|
|
5339
|
-
return
|
|
8513
|
+
return _this10.onMouseDown(e);
|
|
5340
8514
|
},
|
|
5341
|
-
href: this.props.
|
|
8515
|
+
href: this.props.imageBlob,
|
|
5342
8516
|
width: this.state.svg.width,
|
|
5343
8517
|
height: this.state.svg.height
|
|
5344
8518
|
}),
|
|
@@ -5348,8 +8522,8 @@ var Canvas = function (_Component) {
|
|
|
5348
8522
|
React__default.createElement('img', {
|
|
5349
8523
|
alt: 'sia', style: { display: 'none' }, ref: this.img,
|
|
5350
8524
|
onLoad: function onLoad() {
|
|
5351
|
-
|
|
5352
|
-
}, src: this.state.
|
|
8525
|
+
_this10.onImageLoad();
|
|
8526
|
+
}, src: this.state.imageBlob,
|
|
5353
8527
|
width: '100%', height: '100%'
|
|
5354
8528
|
})
|
|
5355
8529
|
),
|