@micromag/core 0.2.373 → 0.2.386

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/es/components.js CHANGED
@@ -3332,7 +3332,8 @@ var propTypes$9 = {
3332
3332
  onPrevious: PropTypes$1.func,
3333
3333
  onNext: PropTypes$1.func,
3334
3334
  onEnableInteraction: PropTypes$1.func,
3335
- onDisableInteraction: PropTypes$1.func
3335
+ onDisableInteraction: PropTypes$1.func,
3336
+ getMediaRef: PropTypes$1.func
3336
3337
  };
3337
3338
  var defaultProps$9 = {
3338
3339
  active: false,
@@ -3344,7 +3345,8 @@ var defaultProps$9 = {
3344
3345
  onPrevious: null,
3345
3346
  onNext: null,
3346
3347
  onEnableInteraction: null,
3347
- onDisableInteraction: null
3348
+ onDisableInteraction: null,
3349
+ getMediaRef: null
3348
3350
  };
3349
3351
 
3350
3352
  var Screen = function Screen(_ref) {
@@ -3358,7 +3360,8 @@ var Screen = function Screen(_ref) {
3358
3360
  onPrevious = _ref.onPrevious,
3359
3361
  onNext = _ref.onNext,
3360
3362
  onEnableInteraction = _ref.onEnableInteraction,
3361
- onDisableInteraction = _ref.onDisableInteraction;
3363
+ onDisableInteraction = _ref.onDisableInteraction,
3364
+ getMediaRef = _ref.getMediaRef;
3362
3365
  var type = screen.type;
3363
3366
  var CustomScreenComponent = components !== null ? getComponentFromName(type, components) || null : null;
3364
3367
  var ContextScreenComponent = useScreenComponent(type);
@@ -3374,7 +3377,8 @@ var Screen = function Screen(_ref) {
3374
3377
  onPrevious: onPrevious,
3375
3378
  onNext: onNext,
3376
3379
  onEnableInteraction: onEnableInteraction,
3377
- onDisableInteraction: onDisableInteraction
3380
+ onDisableInteraction: onDisableInteraction,
3381
+ getMediaRef: getMediaRef
3378
3382
  }))) : /*#__PURE__*/React.createElement("div", {
3379
3383
  className: className
3380
3384
  }, component));
package/es/hooks.js CHANGED
@@ -599,6 +599,16 @@ var preventDefault = function preventDefault(event) {
599
599
  return false;
600
600
  };
601
601
 
602
+ var preventClickDefault = function preventClickDefault(e) {
603
+ if (e.preventDefault) {
604
+ e.preventDefault();
605
+ }
606
+
607
+ if (e.stopPropagation) {
608
+ e.stopPropagation();
609
+ }
610
+ };
611
+
602
612
  var useLongPress = function useLongPress() {
603
613
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
604
614
  _ref$onLongPress = _ref.onLongPress,
@@ -608,7 +618,7 @@ var useLongPress = function useLongPress() {
608
618
  _ref$shouldPreventDef = _ref.shouldPreventDefault,
609
619
  shouldPreventDefault = _ref$shouldPreventDef === void 0 ? true : _ref$shouldPreventDef,
610
620
  _ref$delay = _ref.delay,
611
- delay = _ref$delay === void 0 ? 300 : _ref$delay;
621
+ delay = _ref$delay === void 0 ? 350 : _ref$delay;
612
622
 
613
623
  var _useState = useState(false),
614
624
  _useState2 = _slicedToArray(_useState, 2),
@@ -627,6 +637,9 @@ var useLongPress = function useLongPress() {
627
637
  target.current.addEventListener('touchend', preventDefault, {
628
638
  passive: false
629
639
  });
640
+ target.current.addEventListener('click', preventClickDefault, {
641
+ passive: false
642
+ });
630
643
  }
631
644
 
632
645
  if (onLongPress !== null) {
@@ -645,6 +658,9 @@ var useLongPress = function useLongPress() {
645
658
  } else if (shouldPreventDefault && target.current !== null) {
646
659
  preventDefault(event);
647
660
  target.current.removeEventListener('touchend', preventDefault);
661
+ setTimeout(function () {
662
+ target.current.removeEventListener('click', preventClickDefault);
663
+ }, 10);
648
664
  }
649
665
 
650
666
  if (shouldTriggerClick && !longPressTriggered && onClick !== null) {
@@ -1109,21 +1125,30 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
1109
1125
  var fullWidth = width !== null ? width : calculatedWidth;
1110
1126
  var fullHeight = height !== null ? height : calculatedHeight;
1111
1127
  var landscape = fullHeight > 0 && fullWidth > fullHeight;
1112
- var _opts$withoutMaxSize = opts.withoutMaxSize,
1113
- withoutMaxSize = _opts$withoutMaxSize === void 0 ? false : _opts$withoutMaxSize;
1128
+
1129
+ var _ref6 = opts || {},
1130
+ _ref6$withoutMaxSize = _ref6.withoutMaxSize,
1131
+ withoutMaxSize = _ref6$withoutMaxSize === void 0 ? false : _ref6$withoutMaxSize,
1132
+ _ref6$desktopHeightTh = _ref6.desktopHeightThreshold,
1133
+ desktopHeightThreshold = _ref6$desktopHeightTh === void 0 ? 600 : _ref6$desktopHeightTh,
1134
+ _ref6$desktopHeightRa = _ref6.desktopHeightRatio,
1135
+ desktopHeightRatio = _ref6$desktopHeightRa === void 0 ? 3 / 4 : _ref6$desktopHeightRa,
1136
+ _ref6$screenRatio = _ref6.screenRatio,
1137
+ screenRatio = _ref6$screenRatio === void 0 ? 2 / 3 : _ref6$screenRatio;
1138
+
1114
1139
  var landscapeWithMaxSize = landscape && !withoutMaxSize;
1115
1140
  var finalWidth = fullWidth;
1116
1141
  var finalHeight = fullHeight;
1117
1142
  var menuOverScreen = !landscape;
1118
1143
 
1119
1144
  if (landscapeWithMaxSize) {
1120
- if (fullHeight < 600) {
1145
+ if (fullHeight < desktopHeightThreshold) {
1121
1146
  menuOverScreen = true;
1122
1147
  } else {
1123
- finalHeight = Math.round(fullHeight * 3 / 4);
1148
+ finalHeight = Math.round(fullHeight * desktopHeightRatio);
1124
1149
  }
1125
1150
 
1126
- finalWidth = Math.round(finalHeight * 2 / 3);
1151
+ finalWidth = Math.round(finalHeight * screenRatio);
1127
1152
  }
1128
1153
 
1129
1154
  if (finalWidth % 2 === 1) {
package/lib/components.js CHANGED
@@ -3355,7 +3355,8 @@ var propTypes$9 = {
3355
3355
  onPrevious: PropTypes__default["default"].func,
3356
3356
  onNext: PropTypes__default["default"].func,
3357
3357
  onEnableInteraction: PropTypes__default["default"].func,
3358
- onDisableInteraction: PropTypes__default["default"].func
3358
+ onDisableInteraction: PropTypes__default["default"].func,
3359
+ getMediaRef: PropTypes__default["default"].func
3359
3360
  };
3360
3361
  var defaultProps$9 = {
3361
3362
  active: false,
@@ -3367,7 +3368,8 @@ var defaultProps$9 = {
3367
3368
  onPrevious: null,
3368
3369
  onNext: null,
3369
3370
  onEnableInteraction: null,
3370
- onDisableInteraction: null
3371
+ onDisableInteraction: null,
3372
+ getMediaRef: null
3371
3373
  };
3372
3374
 
3373
3375
  var Screen = function Screen(_ref) {
@@ -3381,7 +3383,8 @@ var Screen = function Screen(_ref) {
3381
3383
  onPrevious = _ref.onPrevious,
3382
3384
  onNext = _ref.onNext,
3383
3385
  onEnableInteraction = _ref.onEnableInteraction,
3384
- onDisableInteraction = _ref.onDisableInteraction;
3386
+ onDisableInteraction = _ref.onDisableInteraction,
3387
+ getMediaRef = _ref.getMediaRef;
3385
3388
  var type = screen.type;
3386
3389
  var CustomScreenComponent = components !== null ? utils.getComponentFromName(type, components) || null : null;
3387
3390
  var ContextScreenComponent = contexts.useScreenComponent(type);
@@ -3397,7 +3400,8 @@ var Screen = function Screen(_ref) {
3397
3400
  onPrevious: onPrevious,
3398
3401
  onNext: onNext,
3399
3402
  onEnableInteraction: onEnableInteraction,
3400
- onDisableInteraction: onDisableInteraction
3403
+ onDisableInteraction: onDisableInteraction,
3404
+ getMediaRef: getMediaRef
3401
3405
  }))) : /*#__PURE__*/React__default["default"].createElement("div", {
3402
3406
  className: className
3403
3407
  }, component));
package/lib/hooks.js CHANGED
@@ -635,6 +635,16 @@ var preventDefault = function preventDefault(event) {
635
635
  return false;
636
636
  };
637
637
 
638
+ var preventClickDefault = function preventClickDefault(e) {
639
+ if (e.preventDefault) {
640
+ e.preventDefault();
641
+ }
642
+
643
+ if (e.stopPropagation) {
644
+ e.stopPropagation();
645
+ }
646
+ };
647
+
638
648
  var useLongPress = function useLongPress() {
639
649
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
640
650
  _ref$onLongPress = _ref.onLongPress,
@@ -644,7 +654,7 @@ var useLongPress = function useLongPress() {
644
654
  _ref$shouldPreventDef = _ref.shouldPreventDefault,
645
655
  shouldPreventDefault = _ref$shouldPreventDef === void 0 ? true : _ref$shouldPreventDef,
646
656
  _ref$delay = _ref.delay,
647
- delay = _ref$delay === void 0 ? 300 : _ref$delay;
657
+ delay = _ref$delay === void 0 ? 350 : _ref$delay;
648
658
 
649
659
  var _useState = react.useState(false),
650
660
  _useState2 = _slicedToArray__default["default"](_useState, 2),
@@ -663,6 +673,9 @@ var useLongPress = function useLongPress() {
663
673
  target.current.addEventListener('touchend', preventDefault, {
664
674
  passive: false
665
675
  });
676
+ target.current.addEventListener('click', preventClickDefault, {
677
+ passive: false
678
+ });
666
679
  }
667
680
 
668
681
  if (onLongPress !== null) {
@@ -681,6 +694,9 @@ var useLongPress = function useLongPress() {
681
694
  } else if (shouldPreventDefault && target.current !== null) {
682
695
  preventDefault(event);
683
696
  target.current.removeEventListener('touchend', preventDefault);
697
+ setTimeout(function () {
698
+ target.current.removeEventListener('click', preventClickDefault);
699
+ }, 10);
684
700
  }
685
701
 
686
702
  if (shouldTriggerClick && !longPressTriggered && onClick !== null) {
@@ -1145,21 +1161,30 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
1145
1161
  var fullWidth = width !== null ? width : calculatedWidth;
1146
1162
  var fullHeight = height !== null ? height : calculatedHeight;
1147
1163
  var landscape = fullHeight > 0 && fullWidth > fullHeight;
1148
- var _opts$withoutMaxSize = opts.withoutMaxSize,
1149
- withoutMaxSize = _opts$withoutMaxSize === void 0 ? false : _opts$withoutMaxSize;
1164
+
1165
+ var _ref6 = opts || {},
1166
+ _ref6$withoutMaxSize = _ref6.withoutMaxSize,
1167
+ withoutMaxSize = _ref6$withoutMaxSize === void 0 ? false : _ref6$withoutMaxSize,
1168
+ _ref6$desktopHeightTh = _ref6.desktopHeightThreshold,
1169
+ desktopHeightThreshold = _ref6$desktopHeightTh === void 0 ? 600 : _ref6$desktopHeightTh,
1170
+ _ref6$desktopHeightRa = _ref6.desktopHeightRatio,
1171
+ desktopHeightRatio = _ref6$desktopHeightRa === void 0 ? 3 / 4 : _ref6$desktopHeightRa,
1172
+ _ref6$screenRatio = _ref6.screenRatio,
1173
+ screenRatio = _ref6$screenRatio === void 0 ? 2 / 3 : _ref6$screenRatio;
1174
+
1150
1175
  var landscapeWithMaxSize = landscape && !withoutMaxSize;
1151
1176
  var finalWidth = fullWidth;
1152
1177
  var finalHeight = fullHeight;
1153
1178
  var menuOverScreen = !landscape;
1154
1179
 
1155
1180
  if (landscapeWithMaxSize) {
1156
- if (fullHeight < 600) {
1181
+ if (fullHeight < desktopHeightThreshold) {
1157
1182
  menuOverScreen = true;
1158
1183
  } else {
1159
- finalHeight = Math.round(fullHeight * 3 / 4);
1184
+ finalHeight = Math.round(fullHeight * desktopHeightRatio);
1160
1185
  }
1161
1186
 
1162
- finalWidth = Math.round(finalHeight * 2 / 3);
1187
+ finalWidth = Math.round(finalHeight * screenRatio);
1163
1188
  }
1164
1189
 
1165
1190
  if (finalWidth % 2 === 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.2.373",
3
+ "version": "0.2.386",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -43,7 +43,8 @@
43
43
  "./scss/variables": "./scss/_variables.scss",
44
44
  "./scss/styles": "./scss/styles.scss",
45
45
  "./scss/upload": "./scss/upload.scss",
46
- "./scss/vendor": "./scss/vendor.scss"
46
+ "./scss/vendor": "./scss/vendor.scss",
47
+ "./assets/css/styles.css": "./assets/css/styles.css"
47
48
  },
48
49
  "browser": {
49
50
  ".": "./es/index.js",
@@ -124,5 +125,5 @@
124
125
  "publishConfig": {
125
126
  "access": "public"
126
127
  },
127
- "gitHead": "613451a824d273954763eaf3a739ec16ac6feb9b"
128
+ "gitHead": "ea1fb37b6e8b421e8df78c50d392187420cadc70"
128
129
  }