@popmenu/common-ui 0.16.0 → 0.17.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.
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { AudioPlayerProps } from './AudioPlayerProps';
3
+ export declare const AudioPlayer: FC<AudioPlayerProps>;
@@ -0,0 +1,4 @@
1
+ export interface AudioPlayerProps {
2
+ /** The URL of the audio to embed. */
3
+ src?: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ export { AudioPlayer as default } from './AudioPlayer';
2
+ export { AudioPlayerProps } from './AudioPlayerProps';
@@ -0,0 +1,11 @@
1
+ import { PLAYBACK_STATES, CONTROL_LABELS, AudioPlayerState, AudioPlayerEvent, VOLUME_CONTROL_STATES } from './types';
2
+ export declare const initialAudioPlayerState: {
3
+ playback: PLAYBACK_STATES;
4
+ volumeControls: VOLUME_CONTROL_STATES;
5
+ context: {
6
+ volume: number;
7
+ playbackButtonLabel: CONTROL_LABELS;
8
+ volumeButtonLabel: CONTROL_LABELS;
9
+ };
10
+ };
11
+ export declare const audioPlayerReducer: (state: AudioPlayerState, event: AudioPlayerEvent) => AudioPlayerState;
@@ -0,0 +1 @@
1
+ export declare const formatTime: (time: number, remaning?: boolean) => string;
@@ -0,0 +1,6 @@
1
+ export { audioPlayerReducer, initialAudioPlayerState } from './audioPlayerReducer';
2
+ export { usePlaybackIcon } from './usePlaybackIcon';
3
+ export { useVolumeIcon } from './useVolumeIcon';
4
+ export { formatTime } from './formatTime';
5
+ export { setupAudioRef } from './setupAudioRef';
6
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ import { RefObject } from 'react';
2
+ import { AudioPlayerEvent } from './types';
3
+ interface Config {
4
+ audioRef: RefObject<HTMLAudioElement>;
5
+ send: (event: AudioPlayerEvent) => void;
6
+ }
7
+ export declare const setupAudioRef: (config: Config) => () => () => void;
8
+ export {};
@@ -0,0 +1,74 @@
1
+ import { RefObject } from 'react';
2
+ export declare enum AUDIO_PLAYER_EVENT_TYPES {
3
+ TOGGLE_PLAYBACK = "TOGGLE_PLAYBACK",
4
+ TOGGLE_VOLUME_CONTROL = "TOGGLE_VOLUME_CONTROL",
5
+ TOGGLE_MUTE = "TOGGLE_MUTE",
6
+ VOLUME_CHANGE = "VOLUME_CHANGE",
7
+ TIME_CHANGE = "TIME_CHANGE",
8
+ DURATION_CHANGE = "DURATION_CHANGE",
9
+ SET_TIME = "SET_TIME",
10
+ CAN_PLAY = "CAN_PLAY"
11
+ }
12
+ interface SetVolumeEvent {
13
+ type: AUDIO_PLAYER_EVENT_TYPES.VOLUME_CHANGE;
14
+ context: Pick<AudioPlayerExtendState, 'volume'>;
15
+ }
16
+ interface TogglePlaybackEvent {
17
+ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK;
18
+ }
19
+ interface ToggleVolumeControlEvent {
20
+ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL;
21
+ }
22
+ interface TimeChangeEvent {
23
+ type: AUDIO_PLAYER_EVENT_TYPES.TIME_CHANGE;
24
+ context: {
25
+ currentTime: number;
26
+ };
27
+ }
28
+ interface DurationChangeEvent {
29
+ type: AUDIO_PLAYER_EVENT_TYPES.DURATION_CHANGE;
30
+ context: {
31
+ duration: number;
32
+ };
33
+ }
34
+ interface ToggleMuteEvent {
35
+ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_MUTE;
36
+ }
37
+ interface SetTimeEvent {
38
+ type: AUDIO_PLAYER_EVENT_TYPES.SET_TIME;
39
+ context: {
40
+ time: number;
41
+ };
42
+ }
43
+ interface CanPlayEvent {
44
+ type: AUDIO_PLAYER_EVENT_TYPES.CAN_PLAY;
45
+ }
46
+ export declare type AudioPlayerEvent = TogglePlaybackEvent | ToggleVolumeControlEvent | SetVolumeEvent | TimeChangeEvent | DurationChangeEvent | ToggleMuteEvent | SetTimeEvent | CanPlayEvent;
47
+ export declare enum PLAYBACK_STATES {
48
+ NONE = "NONE",
49
+ PLAYABLE = "PLAYABLE",
50
+ PAUSED = "PAUSED",
51
+ PLAYING = "PLAYING"
52
+ }
53
+ export declare enum CONTROL_LABELS {
54
+ PAUSE = "PAUSE",
55
+ PLAY = "PLAY",
56
+ MUTE = "MUTE",
57
+ UNMUTE = "UNMUTE"
58
+ }
59
+ export declare enum VOLUME_CONTROL_STATES {
60
+ SHOW = "SHOW",
61
+ HIDE = "HIDE"
62
+ }
63
+ export interface AudioPlayerExtendState {
64
+ volume: number;
65
+ audioRef: RefObject<HTMLAudioElement>;
66
+ playbackButtonLabel: CONTROL_LABELS;
67
+ volumeButtonLabel: CONTROL_LABELS;
68
+ }
69
+ export interface AudioPlayerState {
70
+ playback: PLAYBACK_STATES;
71
+ volumeControls: VOLUME_CONTROL_STATES;
72
+ context: AudioPlayerExtendState;
73
+ }
74
+ export {};
@@ -0,0 +1,2 @@
1
+ import { AudioPlayerState } from './types';
2
+ export declare const usePlaybackIcon: (state: AudioPlayerState) => string;
@@ -0,0 +1,2 @@
1
+ import { AudioPlayerState } from './types';
2
+ export declare const useVolumeIcon: (state: AudioPlayerState) => string;
@@ -4,6 +4,7 @@ export { default as AccordionActions, AccordionActionsProps } from './AccordionA
4
4
  export { default as AccordionDetails, AccordionDetailsProps } from './AccordionDetails';
5
5
  export { default as AccordionSummary, AccordionSummaryProps } from './AccordionSummary';
6
6
  export { default as AppBar, AppBarProps } from './AppBar';
7
+ export { default as AudioPlayer, AudioPlayerProps } from './AudioPlayer';
7
8
  export { default as Avatar, AvatarProps } from './Avatar';
8
9
  export { default as Badge, BadgeProps } from './Badge';
9
10
  export { default as Box, BoxProps } from './Box';