@micromag/core 0.4.60 → 0.4.63
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/assets/css/vendor.css +2 -2
- package/es/components.d.ts +6 -6
- package/es/components.js +4 -4
- package/es/contexts.d.ts +32 -4
- package/es/contexts.js +21 -17
- package/es/hooks.d.ts +19 -1
- package/lib/components.js +4 -4
- package/lib/contexts.js +21 -17
- package/package.json +2 -2
package/es/components.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { CSSProperties, MouseEventHandler, ForwardedRef } from 'react';
|
|
3
3
|
|
|
4
|
+
type ButtonElement = HTMLButtonElement | HTMLAnchorElement;
|
|
4
5
|
interface ButtonProps {
|
|
5
|
-
type?:
|
|
6
|
+
type?: 'button' | 'submit' | 'reset';
|
|
6
7
|
theme?: ButtonTheme | null;
|
|
7
8
|
size?: ButtonSize | null;
|
|
8
9
|
href?: string | null;
|
|
@@ -26,13 +27,12 @@ interface ButtonProps {
|
|
|
26
27
|
withoutTheme?: boolean;
|
|
27
28
|
outline?: boolean;
|
|
28
29
|
asLink?: boolean;
|
|
30
|
+
style?: CSSProperties;
|
|
29
31
|
className?: string | null;
|
|
30
32
|
iconClassName?: string | null;
|
|
31
33
|
labelClassName?: string | null;
|
|
32
|
-
onClick?:
|
|
33
|
-
refButton?:
|
|
34
|
-
current?: unknown;
|
|
35
|
-
}) | null;
|
|
34
|
+
onClick?: MouseEventHandler<ButtonElement> | null;
|
|
35
|
+
refButton?: ForwardedRef<ButtonElement> | null;
|
|
36
36
|
}
|
|
37
37
|
declare function Button$2({ type, theme, size, href, external, direct, target, label, children, focusable, active, icon, iconPosition, disabled, loading, disableOnLoading, small, big, withShadow, withoutStyle, withoutBootstrapStyles, withoutTheme, asLink, outline, onClick, className, iconClassName, labelClassName, refButton, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
38
38
|
|
package/es/components.js
CHANGED
|
@@ -158,12 +158,12 @@ function Button$1(_ref) {
|
|
|
158
158
|
disabled: disabled
|
|
159
159
|
}, styles$y.linkDisabled, disabled)]);
|
|
160
160
|
return external || direct ? /*#__PURE__*/jsx("a", _objectSpread(_objectSpread({}, props), {}, {
|
|
161
|
-
href: disabled ?
|
|
161
|
+
href: !disabled ? href : undefined,
|
|
162
162
|
className: linkClassNames,
|
|
163
163
|
onClick: onClick,
|
|
164
|
-
target: external ? target :
|
|
164
|
+
target: external ? target : undefined,
|
|
165
165
|
ref: refButton,
|
|
166
|
-
tabIndex: focusable ?
|
|
166
|
+
tabIndex: !focusable ? -1 : undefined,
|
|
167
167
|
children: content
|
|
168
168
|
})) : /*#__PURE__*/jsx(Link$1, {
|
|
169
169
|
href: href,
|
|
@@ -180,7 +180,7 @@ function Button$1(_ref) {
|
|
|
180
180
|
onClick: onClick,
|
|
181
181
|
disabled: disabled || disableOnLoading && loading,
|
|
182
182
|
ref: refButton,
|
|
183
|
-
tabIndex: focusable ?
|
|
183
|
+
tabIndex: !focusable ? -1 : undefined,
|
|
184
184
|
children: content
|
|
185
185
|
}));
|
|
186
186
|
}
|
package/es/contexts.d.ts
CHANGED
|
@@ -354,14 +354,42 @@ interface PanelsProviderProps {
|
|
|
354
354
|
}
|
|
355
355
|
declare function PanelsProvider({ children, container: initialContainer }: PanelsProviderProps): react_jsx_runtime.JSX.Element;
|
|
356
356
|
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
interface PlaybackControlsTheme {
|
|
358
|
+
seekBarOnly?: boolean;
|
|
359
|
+
color?: unknown;
|
|
360
|
+
progressColor?: unknown;
|
|
361
|
+
}
|
|
362
|
+
type MediaElement = HTMLVideoElement | HTMLAudioElement | HTMLMediaElement;
|
|
363
|
+
interface PlaybackContext {
|
|
364
|
+
playing: boolean;
|
|
365
|
+
completed: boolean;
|
|
366
|
+
muted: boolean;
|
|
367
|
+
controls: boolean;
|
|
368
|
+
controlsSuggestPlay: boolean;
|
|
369
|
+
controlsVisible: boolean;
|
|
370
|
+
media: MediaElement | null;
|
|
371
|
+
hasAudio: boolean | null;
|
|
372
|
+
controlsTheme: PlaybackControlsTheme | null;
|
|
373
|
+
currentQualityLevel: number | null;
|
|
374
|
+
setMuted: (muted: boolean) => void;
|
|
375
|
+
setPlaying: (playing: boolean) => void;
|
|
376
|
+
setControls: (hasControls: boolean) => void;
|
|
377
|
+
setControlsVisible: (visible: boolean) => void;
|
|
378
|
+
setControlsTheme: (theme: PlaybackControlsTheme | null) => void;
|
|
379
|
+
showControls: () => void;
|
|
380
|
+
hideControls: () => void;
|
|
381
|
+
setMedia: (media: MediaElement | null) => void;
|
|
382
|
+
setCurrentQualityLevel: (qualityLevel: number | null, fromRef?: MediaElement | null) => void;
|
|
383
|
+
setIsBackground: (isBackground: boolean) => void;
|
|
384
|
+
}
|
|
385
|
+
declare const PlaybackContext: React.Context<PlaybackContext>;
|
|
386
|
+
declare const usePlaybackContext: () => PlaybackContext;
|
|
359
387
|
declare const usePlaybackMediaRef: (active?: boolean, background?: boolean, updateKey?: any) => {
|
|
360
388
|
ref: React.RefObject<HTMLMediaElement>;
|
|
361
389
|
isCurrent: boolean;
|
|
362
390
|
};
|
|
363
391
|
interface PlaybackProviderProps {
|
|
364
|
-
children:
|
|
392
|
+
children: ReactNode;
|
|
365
393
|
controls?: boolean;
|
|
366
394
|
controlsSuggestPlay?: boolean;
|
|
367
395
|
controlsVisible?: boolean;
|
|
@@ -373,7 +401,7 @@ interface PlaybackProviderProps {
|
|
|
373
401
|
muted?: boolean;
|
|
374
402
|
playing?: boolean;
|
|
375
403
|
paused?: boolean;
|
|
376
|
-
currentQualityLevel?: number;
|
|
404
|
+
currentQualityLevel?: number | null;
|
|
377
405
|
}
|
|
378
406
|
declare function PlaybackProvider({ muted: initialMuted, playing: initialPlaying, paused, controls: initialControls, controlsSuggestPlay: initialControlsSuggestPlay, controlsVisible: initialControlsVisible, controlsTheme: initialControlsTheme, currentQualityLevel: initialCurrentQualityLevel, children, }: PlaybackProviderProps): react_jsx_runtime.JSX.Element;
|
|
379
407
|
|
package/es/contexts.js
CHANGED
|
@@ -1011,30 +1011,28 @@ var defaultControlsThemeValue = {
|
|
|
1011
1011
|
color: null,
|
|
1012
1012
|
progressColor: null
|
|
1013
1013
|
};
|
|
1014
|
-
var
|
|
1014
|
+
var PlaybackContext = /*#__PURE__*/createContext({
|
|
1015
1015
|
playing: false,
|
|
1016
|
-
paused: false,
|
|
1017
1016
|
completed: false,
|
|
1018
1017
|
muted: true,
|
|
1019
1018
|
controls: false,
|
|
1020
1019
|
controlsSuggestPlay: false,
|
|
1021
1020
|
controlsVisible: false,
|
|
1021
|
+
hasAudio: false,
|
|
1022
1022
|
media: null,
|
|
1023
1023
|
controlsTheme: defaultControlsThemeValue,
|
|
1024
|
-
currentQualityLevel: null
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
setControlsVisible: function setControlsVisible() {},
|
|
1031
|
-
setControlsTheme: function setControlsTheme() {},
|
|
1024
|
+
currentQualityLevel: null,
|
|
1025
|
+
setMuted: function setMuted(muted) {},
|
|
1026
|
+
setPlaying: function setPlaying(playing) {},
|
|
1027
|
+
setControls: function setControls(hasControls) {},
|
|
1028
|
+
setControlsVisible: function setControlsVisible(visible) {},
|
|
1029
|
+
setControlsTheme: function setControlsTheme(theme) {},
|
|
1032
1030
|
showControls: function showControls() {},
|
|
1033
1031
|
hideControls: function hideControls() {},
|
|
1034
|
-
setMedia: function setMedia() {},
|
|
1035
|
-
setCurrentQualityLevel: function setCurrentQualityLevel() {},
|
|
1036
|
-
setIsBackground: function setIsBackground() {}
|
|
1037
|
-
})
|
|
1032
|
+
setMedia: function setMedia(media) {},
|
|
1033
|
+
setCurrentQualityLevel: function setCurrentQualityLevel(qualityLevel, fromRef) {},
|
|
1034
|
+
setIsBackground: function setIsBackground(isBackground) {}
|
|
1035
|
+
});
|
|
1038
1036
|
var usePlaybackContext = function usePlaybackContext() {
|
|
1039
1037
|
return useContext(PlaybackContext);
|
|
1040
1038
|
};
|
|
@@ -1045,29 +1043,35 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1045
1043
|
var _usePlaybackContext = usePlaybackContext(),
|
|
1046
1044
|
setMedia = _usePlaybackContext.setMedia,
|
|
1047
1045
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1048
|
-
media = _usePlaybackContext.media
|
|
1046
|
+
media = _usePlaybackContext.media,
|
|
1047
|
+
isBackground = _usePlaybackContext.isBackground;
|
|
1049
1048
|
var mediaRef = useRef(null);
|
|
1050
1049
|
|
|
1051
1050
|
// Cleanup: clear media registration when this screen deactivates or unmounts.
|
|
1052
1051
|
// Note: we cannot check mediaRef.current here because React clears callback refs
|
|
1053
1052
|
// before running effect cleanups, so mediaRef.current is always null at this point.
|
|
1054
1053
|
useEffect(function () {
|
|
1054
|
+
var currentMedia = mediaRef.current;
|
|
1055
1055
|
return function () {
|
|
1056
1056
|
if (active) {
|
|
1057
|
+
var playing = currentMedia !== null && !!(currentMedia.currentTime > 0 && !currentMedia.paused && !currentMedia.ended && currentMedia.readyState > 2);
|
|
1057
1058
|
setMedia(null);
|
|
1058
1059
|
setIsBackground(false);
|
|
1060
|
+
if (playing) {
|
|
1061
|
+
currentMedia.pause();
|
|
1062
|
+
}
|
|
1059
1063
|
}
|
|
1060
1064
|
};
|
|
1061
1065
|
}, [active, setMedia, setIsBackground, updateKey]);
|
|
1062
1066
|
|
|
1063
1067
|
// Register media with context when active and no media is registered
|
|
1064
1068
|
useEffect(function () {
|
|
1065
|
-
if (!active || mediaRef.current === null || media
|
|
1069
|
+
if (!active || mediaRef.current === null || mediaRef.current === media && background === isBackground) {
|
|
1066
1070
|
return;
|
|
1067
1071
|
}
|
|
1068
1072
|
setIsBackground(background);
|
|
1069
1073
|
setMedia(mediaRef.current);
|
|
1070
|
-
}, [active, background, media, updateKey, setMedia, setIsBackground]);
|
|
1074
|
+
}, [active, background, media, updateKey, setMedia, setIsBackground, isBackground]);
|
|
1071
1075
|
return {
|
|
1072
1076
|
ref: mediaRef,
|
|
1073
1077
|
isCurrent: mediaRef.current === media
|
package/es/hooks.d.ts
CHANGED
|
@@ -46,7 +46,25 @@ declare function useDragProgress({ progress: wantedProgress, onTap, disabled, dr
|
|
|
46
46
|
declare const useForm: ({ fields: providedFields, injectInFields, ...opts }?: {
|
|
47
47
|
fields?: any[];
|
|
48
48
|
injectInFields?: boolean;
|
|
49
|
-
}) =>
|
|
49
|
+
}) => {
|
|
50
|
+
fields: any[];
|
|
51
|
+
status: any;
|
|
52
|
+
response: unknown;
|
|
53
|
+
errors: Record<string, string | string[]>;
|
|
54
|
+
generalError: string;
|
|
55
|
+
success: boolean;
|
|
56
|
+
loading: boolean;
|
|
57
|
+
error: boolean;
|
|
58
|
+
value: Record<string, unknown>;
|
|
59
|
+
setValue: (value: Record<string, unknown>) => void;
|
|
60
|
+
setErrors: (errors: Record<string, string | string[]>) => void;
|
|
61
|
+
setGeneralError: (error: string | null) => void;
|
|
62
|
+
csrfToken: string;
|
|
63
|
+
submit: (submitValue?: Record<string, unknown>) => void;
|
|
64
|
+
onSubmit: (e: {
|
|
65
|
+
preventDefault: () => void;
|
|
66
|
+
}) => void;
|
|
67
|
+
};
|
|
50
68
|
|
|
51
69
|
declare const useFormTransition: (initialPaths?: any, initialStyles?: {}) => {
|
|
52
70
|
direction: string;
|
package/lib/components.js
CHANGED
|
@@ -160,12 +160,12 @@ function Button$1(_ref) {
|
|
|
160
160
|
disabled: disabled
|
|
161
161
|
}, styles$y.linkDisabled, disabled)]);
|
|
162
162
|
return external || direct ? /*#__PURE__*/jsxRuntime.jsx("a", _objectSpread(_objectSpread({}, props), {}, {
|
|
163
|
-
href: disabled ?
|
|
163
|
+
href: !disabled ? href : undefined,
|
|
164
164
|
className: linkClassNames,
|
|
165
165
|
onClick: onClick,
|
|
166
|
-
target: external ? target :
|
|
166
|
+
target: external ? target : undefined,
|
|
167
167
|
ref: refButton,
|
|
168
|
-
tabIndex: focusable ?
|
|
168
|
+
tabIndex: !focusable ? -1 : undefined,
|
|
169
169
|
children: content
|
|
170
170
|
})) : /*#__PURE__*/jsxRuntime.jsx(wouter.Link, {
|
|
171
171
|
href: href,
|
|
@@ -182,7 +182,7 @@ function Button$1(_ref) {
|
|
|
182
182
|
onClick: onClick,
|
|
183
183
|
disabled: disabled || disableOnLoading && loading,
|
|
184
184
|
ref: refButton,
|
|
185
|
-
tabIndex: focusable ?
|
|
185
|
+
tabIndex: !focusable ? -1 : undefined,
|
|
186
186
|
children: content
|
|
187
187
|
}));
|
|
188
188
|
}
|
package/lib/contexts.js
CHANGED
|
@@ -1011,30 +1011,28 @@ var defaultControlsThemeValue = {
|
|
|
1011
1011
|
color: null,
|
|
1012
1012
|
progressColor: null
|
|
1013
1013
|
};
|
|
1014
|
-
var
|
|
1014
|
+
var PlaybackContext = /*#__PURE__*/React.createContext({
|
|
1015
1015
|
playing: false,
|
|
1016
|
-
paused: false,
|
|
1017
1016
|
completed: false,
|
|
1018
1017
|
muted: true,
|
|
1019
1018
|
controls: false,
|
|
1020
1019
|
controlsSuggestPlay: false,
|
|
1021
1020
|
controlsVisible: false,
|
|
1021
|
+
hasAudio: false,
|
|
1022
1022
|
media: null,
|
|
1023
1023
|
controlsTheme: defaultControlsThemeValue,
|
|
1024
|
-
currentQualityLevel: null
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
setControlsVisible: function setControlsVisible() {},
|
|
1031
|
-
setControlsTheme: function setControlsTheme() {},
|
|
1024
|
+
currentQualityLevel: null,
|
|
1025
|
+
setMuted: function setMuted(muted) {},
|
|
1026
|
+
setPlaying: function setPlaying(playing) {},
|
|
1027
|
+
setControls: function setControls(hasControls) {},
|
|
1028
|
+
setControlsVisible: function setControlsVisible(visible) {},
|
|
1029
|
+
setControlsTheme: function setControlsTheme(theme) {},
|
|
1032
1030
|
showControls: function showControls() {},
|
|
1033
1031
|
hideControls: function hideControls() {},
|
|
1034
|
-
setMedia: function setMedia() {},
|
|
1035
|
-
setCurrentQualityLevel: function setCurrentQualityLevel() {},
|
|
1036
|
-
setIsBackground: function setIsBackground() {}
|
|
1037
|
-
})
|
|
1032
|
+
setMedia: function setMedia(media) {},
|
|
1033
|
+
setCurrentQualityLevel: function setCurrentQualityLevel(qualityLevel, fromRef) {},
|
|
1034
|
+
setIsBackground: function setIsBackground(isBackground) {}
|
|
1035
|
+
});
|
|
1038
1036
|
var usePlaybackContext = function usePlaybackContext() {
|
|
1039
1037
|
return React.useContext(PlaybackContext);
|
|
1040
1038
|
};
|
|
@@ -1045,29 +1043,35 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1045
1043
|
var _usePlaybackContext = usePlaybackContext(),
|
|
1046
1044
|
setMedia = _usePlaybackContext.setMedia,
|
|
1047
1045
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1048
|
-
media = _usePlaybackContext.media
|
|
1046
|
+
media = _usePlaybackContext.media,
|
|
1047
|
+
isBackground = _usePlaybackContext.isBackground;
|
|
1049
1048
|
var mediaRef = React.useRef(null);
|
|
1050
1049
|
|
|
1051
1050
|
// Cleanup: clear media registration when this screen deactivates or unmounts.
|
|
1052
1051
|
// Note: we cannot check mediaRef.current here because React clears callback refs
|
|
1053
1052
|
// before running effect cleanups, so mediaRef.current is always null at this point.
|
|
1054
1053
|
React.useEffect(function () {
|
|
1054
|
+
var currentMedia = mediaRef.current;
|
|
1055
1055
|
return function () {
|
|
1056
1056
|
if (active) {
|
|
1057
|
+
var playing = currentMedia !== null && !!(currentMedia.currentTime > 0 && !currentMedia.paused && !currentMedia.ended && currentMedia.readyState > 2);
|
|
1057
1058
|
setMedia(null);
|
|
1058
1059
|
setIsBackground(false);
|
|
1060
|
+
if (playing) {
|
|
1061
|
+
currentMedia.pause();
|
|
1062
|
+
}
|
|
1059
1063
|
}
|
|
1060
1064
|
};
|
|
1061
1065
|
}, [active, setMedia, setIsBackground, updateKey]);
|
|
1062
1066
|
|
|
1063
1067
|
// Register media with context when active and no media is registered
|
|
1064
1068
|
React.useEffect(function () {
|
|
1065
|
-
if (!active || mediaRef.current === null || media
|
|
1069
|
+
if (!active || mediaRef.current === null || mediaRef.current === media && background === isBackground) {
|
|
1066
1070
|
return;
|
|
1067
1071
|
}
|
|
1068
1072
|
setIsBackground(background);
|
|
1069
1073
|
setMedia(mediaRef.current);
|
|
1070
|
-
}, [active, background, media, updateKey, setMedia, setIsBackground]);
|
|
1074
|
+
}, [active, background, media, updateKey, setMedia, setIsBackground, isBackground]);
|
|
1071
1075
|
return {
|
|
1072
1076
|
ref: mediaRef,
|
|
1073
1077
|
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.63",
|
|
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": "0a6df1a5352c067c3296377d26fadb9b71244345",
|
|
165
165
|
"types": "es/index.d.ts"
|
|
166
166
|
}
|