@micromag/core 0.4.27 → 0.4.28
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 +11 -6
- package/es/contexts.d.ts +2 -2
- package/es/contexts.js +8 -28
- package/lib/components.js +11 -6
- package/lib/contexts.js +8 -28
- package/package.json +2 -2
package/es/components.js
CHANGED
|
@@ -7,6 +7,7 @@ import classNames from 'classnames';
|
|
|
7
7
|
import { Link as Link$1 } from 'wouter';
|
|
8
8
|
import { FormattedMessage, defineMessages, FormattedDate, FormattedTime } from 'react-intl';
|
|
9
9
|
import { isMessage, getFieldFromPath, getComponentFromName, setFieldValue, validateFields, getDisplayName, pascalCase, convertStyleToString } from '@micromag/core/utils';
|
|
10
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
10
11
|
import { faClose } from '@fortawesome/free-solid-svg-icons/faClose';
|
|
11
12
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
12
13
|
import { faAngleDown } from '@fortawesome/free-solid-svg-icons/faAngleDown';
|
|
@@ -14,7 +15,6 @@ import { faAngleUp } from '@fortawesome/free-solid-svg-icons/faAngleUp';
|
|
|
14
15
|
import dayjs from 'dayjs';
|
|
15
16
|
import throttle from 'lodash/throttle';
|
|
16
17
|
import { useForm, useDocumentEvent, useIntersectionObserver, useDimensionObserver, useDevicePixelRatio } from '@micromag/core/hooks';
|
|
17
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
18
18
|
import get from 'lodash/get';
|
|
19
19
|
import { useFieldsManager, useFieldComponent, FieldContextProvider, useFieldContext, withModals, useModals, withPanels, usePanels, ScreenSizeProvider, useScreenComponent, ScreenProvider, useScreenRenderContext, useScreenSize } from '@micromag/core/contexts';
|
|
20
20
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -172,7 +172,7 @@ function Button$1(_ref) {
|
|
|
172
172
|
|
|
173
173
|
var styles$x = {"container":"micromag-core-buttons-container"};
|
|
174
174
|
|
|
175
|
-
var _excluded$b = ["className", "onClick", "theme"];
|
|
175
|
+
var _excluded$b = ["id", "name", "className", "onClick", "theme"];
|
|
176
176
|
var emptyArray$a = [];
|
|
177
177
|
function Buttons(_ref) {
|
|
178
178
|
var _ref$buttons = _ref.buttons,
|
|
@@ -193,7 +193,9 @@ function Buttons(_ref) {
|
|
|
193
193
|
className: classNames(['btn-group', _defineProperty({}, "btn-group-".concat(size), size !== null), styles$x.container, _defineProperty({}, className, className !== null)]),
|
|
194
194
|
role: "group"
|
|
195
195
|
}, buttons.map(function (button, index) {
|
|
196
|
-
var
|
|
196
|
+
var id = button.id;
|
|
197
|
+
button.name;
|
|
198
|
+
var _button$className = button.className,
|
|
197
199
|
customClassName = _button$className === void 0 ? null : _button$className,
|
|
198
200
|
_button$onClick = button.onClick,
|
|
199
201
|
_onClick = _button$onClick === void 0 ? null : _button$onClick,
|
|
@@ -201,7 +203,6 @@ function Buttons(_ref) {
|
|
|
201
203
|
buttonTheme = _button$theme === void 0 ? null : _button$theme,
|
|
202
204
|
buttonProps = _objectWithoutProperties(button, _excluded$b);
|
|
203
205
|
var fixedProps = {
|
|
204
|
-
key: "button-".concat(index),
|
|
205
206
|
className: classNames([styles$x.button, _defineProperty(_defineProperty({}, buttonClassName, buttonClassName !== null), customClassName, customClassName !== null)]),
|
|
206
207
|
onClick: function onClick(e) {
|
|
207
208
|
if (_onClick !== null) {
|
|
@@ -213,7 +214,12 @@ function Buttons(_ref) {
|
|
|
213
214
|
},
|
|
214
215
|
theme: buttonTheme || theme
|
|
215
216
|
};
|
|
216
|
-
|
|
217
|
+
var buttonKey = id || "button-".concat(index);
|
|
218
|
+
return renderButton !== null ? renderButton(button, index, _objectSpread({
|
|
219
|
+
key: buttonKey
|
|
220
|
+
}, fixedProps)) : /*#__PURE__*/React.createElement(Button$1, Object.assign({
|
|
221
|
+
key: buttonKey
|
|
222
|
+
}, fixedProps, buttonProps));
|
|
217
223
|
}));
|
|
218
224
|
}
|
|
219
225
|
|
|
@@ -875,7 +881,6 @@ function PlayIcon(_ref) {
|
|
|
875
881
|
color = _ref$color === void 0 ? '#fff' : _ref$color,
|
|
876
882
|
_ref$className = _ref.className,
|
|
877
883
|
className = _ref$className === void 0 ? null : _ref$className;
|
|
878
|
-
console.log('color', color);
|
|
879
884
|
return /*#__PURE__*/React.createElement("svg", {
|
|
880
885
|
width: "40",
|
|
881
886
|
height: "45.1",
|
package/es/contexts.d.ts
CHANGED
|
@@ -165,8 +165,8 @@ declare function PanelsProvider({ children, container: initialContainer }: {
|
|
|
165
165
|
|
|
166
166
|
declare const PlaybackContext: any;
|
|
167
167
|
declare const usePlaybackContext: () => unknown;
|
|
168
|
-
declare const usePlaybackMediaRef: (active?: boolean, background?: boolean) => {
|
|
169
|
-
ref: React.RefObject<
|
|
168
|
+
declare const usePlaybackMediaRef: (active?: boolean, background?: boolean, updateKey?: any) => {
|
|
169
|
+
ref: React.RefObject<HTMLMediaElement>;
|
|
170
170
|
isCurrent: boolean;
|
|
171
171
|
};
|
|
172
172
|
declare function PlaybackProvider({ muted: initialMuted, playing: initialPlaying, paused, controls: initialControls, controlsSuggestPlay: initialControlsSuggestPlay, controlsVisible: initialControlsVisible, controlsTheme: initialControlsTheme, currentQualityLevel: initialCurrentQualityLevel, children, }: {
|
package/es/contexts.js
CHANGED
|
@@ -1013,51 +1013,31 @@ var usePlaybackContext = function usePlaybackContext() {
|
|
|
1013
1013
|
var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
1014
1014
|
var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1015
1015
|
var background = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1016
|
+
var updateKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1016
1017
|
var _usePlaybackContext = usePlaybackContext(),
|
|
1017
1018
|
setMedia = _usePlaybackContext.setMedia,
|
|
1018
1019
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1019
1020
|
media = _usePlaybackContext.media;
|
|
1020
1021
|
var mediaRef = useRef(null);
|
|
1022
|
+
|
|
1023
|
+
// Cleanup: only clear if this ref owns the current media registration
|
|
1021
1024
|
useEffect(function () {
|
|
1022
1025
|
return function () {
|
|
1023
|
-
if (active) {
|
|
1026
|
+
if (active && mediaRef.current !== null && mediaRef.current === media) {
|
|
1024
1027
|
setMedia(null);
|
|
1025
1028
|
setIsBackground(false);
|
|
1026
1029
|
}
|
|
1027
1030
|
};
|
|
1028
|
-
}, [active]);
|
|
1031
|
+
}, [active, setMedia, setIsBackground, media]);
|
|
1032
|
+
|
|
1033
|
+
// Register media with context when active and no media is registered
|
|
1029
1034
|
useEffect(function () {
|
|
1030
1035
|
if (!active || mediaRef.current === null || media !== null) {
|
|
1031
1036
|
return;
|
|
1032
1037
|
}
|
|
1033
1038
|
setIsBackground(background);
|
|
1034
1039
|
setMedia(mediaRef.current);
|
|
1035
|
-
}, [active, background, media]);
|
|
1036
|
-
|
|
1037
|
-
// const shouldSetMedia = active && media === null && mediaRef.current !== null;
|
|
1038
|
-
// useEffect(
|
|
1039
|
-
// () => () => {
|
|
1040
|
-
// if (active) {
|
|
1041
|
-
// console.log('DESTROY unset media');
|
|
1042
|
-
// setMedia(null);
|
|
1043
|
-
// setIsBackground(false);
|
|
1044
|
-
// }
|
|
1045
|
-
// },
|
|
1046
|
-
// [active],
|
|
1047
|
-
// );
|
|
1048
|
-
|
|
1049
|
-
// useEffect(() => {
|
|
1050
|
-
// if (active && mediaRef.current !== null && media === null) {
|
|
1051
|
-
// console.log('SET media');
|
|
1052
|
-
// setIsBackground(background);
|
|
1053
|
-
// setMedia(mediaRef.current);
|
|
1054
|
-
// } else if (!active && mediaRef.current === media && media !== null) {
|
|
1055
|
-
// console.log('Unset media');
|
|
1056
|
-
// setMedia(null);
|
|
1057
|
-
// setIsBackground(false);
|
|
1058
|
-
// }
|
|
1059
|
-
// }, [active, background, media]);
|
|
1060
|
-
|
|
1040
|
+
}, [active, background, media, updateKey, setMedia, setIsBackground]);
|
|
1061
1041
|
return {
|
|
1062
1042
|
ref: mediaRef,
|
|
1063
1043
|
isCurrent: mediaRef.current === media
|
package/lib/components.js
CHANGED
|
@@ -9,6 +9,7 @@ var classNames = require('classnames');
|
|
|
9
9
|
var wouter = require('wouter');
|
|
10
10
|
var reactIntl = require('react-intl');
|
|
11
11
|
var utils = require('@micromag/core/utils');
|
|
12
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
12
13
|
var faClose = require('@fortawesome/free-solid-svg-icons/faClose');
|
|
13
14
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
14
15
|
var faAngleDown = require('@fortawesome/free-solid-svg-icons/faAngleDown');
|
|
@@ -16,7 +17,6 @@ var faAngleUp = require('@fortawesome/free-solid-svg-icons/faAngleUp');
|
|
|
16
17
|
var dayjs = require('dayjs');
|
|
17
18
|
var throttle = require('lodash/throttle');
|
|
18
19
|
var hooks = require('@micromag/core/hooks');
|
|
19
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
20
20
|
var get = require('lodash/get');
|
|
21
21
|
var contexts = require('@micromag/core/contexts');
|
|
22
22
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
@@ -174,7 +174,7 @@ function Button$1(_ref) {
|
|
|
174
174
|
|
|
175
175
|
var styles$x = {"container":"micromag-core-buttons-container"};
|
|
176
176
|
|
|
177
|
-
var _excluded$b = ["className", "onClick", "theme"];
|
|
177
|
+
var _excluded$b = ["id", "name", "className", "onClick", "theme"];
|
|
178
178
|
var emptyArray$a = [];
|
|
179
179
|
function Buttons(_ref) {
|
|
180
180
|
var _ref$buttons = _ref.buttons,
|
|
@@ -195,7 +195,9 @@ function Buttons(_ref) {
|
|
|
195
195
|
className: classNames(['btn-group', _defineProperty({}, "btn-group-".concat(size), size !== null), styles$x.container, _defineProperty({}, className, className !== null)]),
|
|
196
196
|
role: "group"
|
|
197
197
|
}, buttons.map(function (button, index) {
|
|
198
|
-
var
|
|
198
|
+
var id = button.id;
|
|
199
|
+
button.name;
|
|
200
|
+
var _button$className = button.className,
|
|
199
201
|
customClassName = _button$className === void 0 ? null : _button$className,
|
|
200
202
|
_button$onClick = button.onClick,
|
|
201
203
|
_onClick = _button$onClick === void 0 ? null : _button$onClick,
|
|
@@ -203,7 +205,6 @@ function Buttons(_ref) {
|
|
|
203
205
|
buttonTheme = _button$theme === void 0 ? null : _button$theme,
|
|
204
206
|
buttonProps = _objectWithoutProperties(button, _excluded$b);
|
|
205
207
|
var fixedProps = {
|
|
206
|
-
key: "button-".concat(index),
|
|
207
208
|
className: classNames([styles$x.button, _defineProperty(_defineProperty({}, buttonClassName, buttonClassName !== null), customClassName, customClassName !== null)]),
|
|
208
209
|
onClick: function onClick(e) {
|
|
209
210
|
if (_onClick !== null) {
|
|
@@ -215,7 +216,12 @@ function Buttons(_ref) {
|
|
|
215
216
|
},
|
|
216
217
|
theme: buttonTheme || theme
|
|
217
218
|
};
|
|
218
|
-
|
|
219
|
+
var buttonKey = id || "button-".concat(index);
|
|
220
|
+
return renderButton !== null ? renderButton(button, index, _objectSpread({
|
|
221
|
+
key: buttonKey
|
|
222
|
+
}, fixedProps)) : /*#__PURE__*/React.createElement(Button$1, Object.assign({
|
|
223
|
+
key: buttonKey
|
|
224
|
+
}, fixedProps, buttonProps));
|
|
219
225
|
}));
|
|
220
226
|
}
|
|
221
227
|
|
|
@@ -877,7 +883,6 @@ function PlayIcon(_ref) {
|
|
|
877
883
|
color = _ref$color === void 0 ? '#fff' : _ref$color,
|
|
878
884
|
_ref$className = _ref.className,
|
|
879
885
|
className = _ref$className === void 0 ? null : _ref$className;
|
|
880
|
-
console.log('color', color);
|
|
881
886
|
return /*#__PURE__*/React.createElement("svg", {
|
|
882
887
|
width: "40",
|
|
883
888
|
height: "45.1",
|
package/lib/contexts.js
CHANGED
|
@@ -1013,51 +1013,31 @@ var usePlaybackContext = function usePlaybackContext() {
|
|
|
1013
1013
|
var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
1014
1014
|
var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1015
1015
|
var background = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1016
|
+
var updateKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1016
1017
|
var _usePlaybackContext = usePlaybackContext(),
|
|
1017
1018
|
setMedia = _usePlaybackContext.setMedia,
|
|
1018
1019
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1019
1020
|
media = _usePlaybackContext.media;
|
|
1020
1021
|
var mediaRef = React.useRef(null);
|
|
1022
|
+
|
|
1023
|
+
// Cleanup: only clear if this ref owns the current media registration
|
|
1021
1024
|
React.useEffect(function () {
|
|
1022
1025
|
return function () {
|
|
1023
|
-
if (active) {
|
|
1026
|
+
if (active && mediaRef.current !== null && mediaRef.current === media) {
|
|
1024
1027
|
setMedia(null);
|
|
1025
1028
|
setIsBackground(false);
|
|
1026
1029
|
}
|
|
1027
1030
|
};
|
|
1028
|
-
}, [active]);
|
|
1031
|
+
}, [active, setMedia, setIsBackground, media]);
|
|
1032
|
+
|
|
1033
|
+
// Register media with context when active and no media is registered
|
|
1029
1034
|
React.useEffect(function () {
|
|
1030
1035
|
if (!active || mediaRef.current === null || media !== null) {
|
|
1031
1036
|
return;
|
|
1032
1037
|
}
|
|
1033
1038
|
setIsBackground(background);
|
|
1034
1039
|
setMedia(mediaRef.current);
|
|
1035
|
-
}, [active, background, media]);
|
|
1036
|
-
|
|
1037
|
-
// const shouldSetMedia = active && media === null && mediaRef.current !== null;
|
|
1038
|
-
// useEffect(
|
|
1039
|
-
// () => () => {
|
|
1040
|
-
// if (active) {
|
|
1041
|
-
// console.log('DESTROY unset media');
|
|
1042
|
-
// setMedia(null);
|
|
1043
|
-
// setIsBackground(false);
|
|
1044
|
-
// }
|
|
1045
|
-
// },
|
|
1046
|
-
// [active],
|
|
1047
|
-
// );
|
|
1048
|
-
|
|
1049
|
-
// useEffect(() => {
|
|
1050
|
-
// if (active && mediaRef.current !== null && media === null) {
|
|
1051
|
-
// console.log('SET media');
|
|
1052
|
-
// setIsBackground(background);
|
|
1053
|
-
// setMedia(mediaRef.current);
|
|
1054
|
-
// } else if (!active && mediaRef.current === media && media !== null) {
|
|
1055
|
-
// console.log('Unset media');
|
|
1056
|
-
// setMedia(null);
|
|
1057
|
-
// setIsBackground(false);
|
|
1058
|
-
// }
|
|
1059
|
-
// }, [active, background, media]);
|
|
1060
|
-
|
|
1040
|
+
}, [active, background, media, updateKey, setMedia, setIsBackground]);
|
|
1061
1041
|
return {
|
|
1062
1042
|
ref: mediaRef,
|
|
1063
1043
|
isCurrent: mediaRef.current === media
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.28",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -161,6 +161,6 @@
|
|
|
161
161
|
"access": "public",
|
|
162
162
|
"registry": "https://registry.npmjs.org/"
|
|
163
163
|
},
|
|
164
|
-
"gitHead": "
|
|
164
|
+
"gitHead": "1b14d4403eb5decff05346870eb849a96f636604",
|
|
165
165
|
"types": "es/index.d.ts"
|
|
166
166
|
}
|