react-modern-audio-player 1.0.1 → 1.1.3
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/README.md +21 -18
- package/dist/index.cjs +75 -163
- package/dist/index.css +1 -1
- package/dist/index.es.js +133 -206
- package/dist/types/components/AudioPlayer/Context/StateContext/element.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/StateContext/placement.d.ts +1 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/useVolume.d.ts +5 -0
- package/dist/types/components/AudioPlayer/{Player.d.ts → Player/index.d.ts} +1 -1
- package/dist/types/components/AudioPlayer/Player/usePropsStateEffect.d.ts +2 -0
- package/dist/types/components/Dropdown/Dropdown.d.ts +1 -0
- package/package.json +2 -3
package/dist/index.es.js
CHANGED
|
@@ -7920,7 +7920,7 @@ let $bf24a13e98395dd3$export$bca14c5b3b88a9c9 = {
|
|
|
7920
7920
|
const useNonNullableContext = (context) => {
|
|
7921
7921
|
const state = useContext(context);
|
|
7922
7922
|
if (!state)
|
|
7923
|
-
throw new Error(
|
|
7923
|
+
throw new Error(`${context} is not provided or null`);
|
|
7924
7924
|
return state;
|
|
7925
7925
|
};
|
|
7926
7926
|
const defaultInterfacePlacement = {
|
|
@@ -8222,7 +8222,8 @@ const AudioPlayerProvider = ({
|
|
|
8222
8222
|
volume: 1
|
|
8223
8223
|
},
|
|
8224
8224
|
activeUI: {
|
|
8225
|
-
playButton: true
|
|
8225
|
+
playButton: true,
|
|
8226
|
+
volumeSlider: true
|
|
8226
8227
|
},
|
|
8227
8228
|
playListPlacement: "bottom",
|
|
8228
8229
|
interfacePlacement: {
|
|
@@ -8242,141 +8243,43 @@ const AudioPlayerProvider = ({
|
|
|
8242
8243
|
var vars = "";
|
|
8243
8244
|
const GlobalStyle = createGlobalStyle`
|
|
8244
8245
|
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
iframe,
|
|
8252
|
-
h1,
|
|
8253
|
-
h2,
|
|
8254
|
-
h3,
|
|
8255
|
-
h4,
|
|
8256
|
-
h5,
|
|
8257
|
-
h6,
|
|
8258
|
-
p,
|
|
8259
|
-
blockquote,
|
|
8260
|
-
pre,
|
|
8261
|
-
a,
|
|
8262
|
-
abbr,
|
|
8263
|
-
acronym,
|
|
8264
|
-
address,
|
|
8265
|
-
big,
|
|
8266
|
-
cite,
|
|
8267
|
-
code,
|
|
8268
|
-
del,
|
|
8269
|
-
dfn,
|
|
8270
|
-
em,
|
|
8271
|
-
img,
|
|
8272
|
-
ins,
|
|
8273
|
-
kbd,
|
|
8274
|
-
q,
|
|
8275
|
-
s,
|
|
8276
|
-
samp,
|
|
8277
|
-
small,
|
|
8278
|
-
strike,
|
|
8279
|
-
strong,
|
|
8280
|
-
sub,
|
|
8281
|
-
sup,
|
|
8282
|
-
tt,
|
|
8283
|
-
var,
|
|
8284
|
-
b,
|
|
8285
|
-
u,
|
|
8286
|
-
i,
|
|
8287
|
-
center,
|
|
8288
|
-
dl,
|
|
8289
|
-
dt,
|
|
8290
|
-
dd,
|
|
8291
|
-
ol,
|
|
8292
|
-
ul,
|
|
8293
|
-
li,
|
|
8294
|
-
fieldset,
|
|
8295
|
-
form,
|
|
8296
|
-
label,
|
|
8297
|
-
legend,
|
|
8298
|
-
table,
|
|
8299
|
-
caption,
|
|
8300
|
-
tbody,
|
|
8301
|
-
tfoot,
|
|
8302
|
-
thead,
|
|
8303
|
-
tr,
|
|
8304
|
-
th,
|
|
8305
|
-
td,
|
|
8306
|
-
article,
|
|
8307
|
-
aside,
|
|
8308
|
-
canvas,
|
|
8309
|
-
details,
|
|
8310
|
-
embed,
|
|
8311
|
-
figure,
|
|
8312
|
-
figcaption,
|
|
8313
|
-
footer,
|
|
8314
|
-
header,
|
|
8315
|
-
hgroup,
|
|
8316
|
-
menu,
|
|
8317
|
-
nav,
|
|
8318
|
-
output,
|
|
8319
|
-
ruby,
|
|
8320
|
-
section,
|
|
8321
|
-
summary,
|
|
8322
|
-
time,
|
|
8323
|
-
mark,
|
|
8324
|
-
audio,
|
|
8325
|
-
button,
|
|
8326
|
-
video {
|
|
8327
|
-
margin: 0;
|
|
8328
|
-
padding: 0;
|
|
8329
|
-
font: inherit;
|
|
8330
|
-
font-size: 100%;
|
|
8331
|
-
vertical-align: baseline;
|
|
8332
|
-
border: 0;
|
|
8333
|
-
}
|
|
8334
|
-
/* HTML5 display-role reset for older browsers */
|
|
8335
|
-
article,
|
|
8336
|
-
aside,
|
|
8337
|
-
details,
|
|
8338
|
-
figcaption,
|
|
8339
|
-
figure,
|
|
8340
|
-
footer,
|
|
8341
|
-
header,
|
|
8342
|
-
hgroup,
|
|
8343
|
-
menu,
|
|
8344
|
-
nav,
|
|
8345
|
-
section {
|
|
8346
|
-
display: block;
|
|
8347
|
-
}
|
|
8348
|
-
body {
|
|
8349
|
-
line-height: 1;
|
|
8350
|
-
}
|
|
8351
|
-
ol,
|
|
8352
|
-
ul {
|
|
8353
|
-
list-style: none;
|
|
8354
|
-
}
|
|
8355
|
-
blockquote,
|
|
8356
|
-
q {
|
|
8357
|
-
quotes: none;
|
|
8358
|
-
}
|
|
8359
|
-
blockquote:before,
|
|
8360
|
-
blockquote:after,
|
|
8361
|
-
q:before,
|
|
8362
|
-
q:after {
|
|
8363
|
-
content: '';
|
|
8364
|
-
content: none;
|
|
8365
|
-
}
|
|
8366
|
-
table {
|
|
8367
|
-
border-collapse: collapse;
|
|
8368
|
-
border-spacing: 0;
|
|
8369
|
-
}
|
|
8246
|
+
.rm-audio-player-provider {
|
|
8247
|
+
* {
|
|
8248
|
+
box-sizing: border-box;
|
|
8249
|
+
font: inherit;
|
|
8250
|
+
font-size: 100%;
|
|
8251
|
+
}
|
|
8370
8252
|
|
|
8371
|
-
|
|
8253
|
+
ol,
|
|
8254
|
+
ul {
|
|
8255
|
+
list-style: none;
|
|
8256
|
+
margin: 0;
|
|
8257
|
+
padding: 0;
|
|
8258
|
+
}
|
|
8259
|
+
blockquote,
|
|
8260
|
+
q {
|
|
8261
|
+
quotes: none;
|
|
8262
|
+
}
|
|
8263
|
+
blockquote:before,
|
|
8264
|
+
blockquote:after,
|
|
8265
|
+
q:before,
|
|
8266
|
+
q:after {
|
|
8267
|
+
content: '';
|
|
8268
|
+
content: none;
|
|
8269
|
+
}
|
|
8270
|
+
table {
|
|
8271
|
+
border-collapse: collapse;
|
|
8272
|
+
border-spacing: 0;
|
|
8273
|
+
}
|
|
8274
|
+
button {
|
|
8275
|
+
margin: 0;
|
|
8276
|
+
padding: 0;
|
|
8372
8277
|
background: transparent;
|
|
8373
8278
|
cursor: pointer;
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
}
|
|
8379
|
-
`;
|
|
8279
|
+
vertical-align: baseline;
|
|
8280
|
+
border: 0;
|
|
8281
|
+
}
|
|
8282
|
+
}`;
|
|
8380
8283
|
function $parcel$export$1(e, n2, v, s) {
|
|
8381
8284
|
Object.defineProperty(e, n2, { get: v, set: s, enumerable: true, configurable: true });
|
|
8382
8285
|
}
|
|
@@ -12742,6 +12645,12 @@ const useWaveSurfer = () => {
|
|
|
12742
12645
|
const curTime = elementRefs.waveformInst.getCurrentTime();
|
|
12743
12646
|
trackCurTimeEl.innerText = getTimeWithPadStart(curTime);
|
|
12744
12647
|
}, [elementRefs]);
|
|
12648
|
+
const waveEl = document.getElementsByTagName("wave");
|
|
12649
|
+
useEffect(() => {
|
|
12650
|
+
if (waveEl.length > 1) {
|
|
12651
|
+
waveEl[0].setAttribute("style", "display: none");
|
|
12652
|
+
}
|
|
12653
|
+
}, [waveEl]);
|
|
12745
12654
|
const [curAudioData, setCurAudioData] = useState();
|
|
12746
12655
|
useEffect(() => {
|
|
12747
12656
|
if (!(elementRefs == null ? void 0 : elementRefs.waveformInst) || !playList[curIdx])
|
|
@@ -12877,6 +12786,8 @@ const StyledBtn = styled.button`
|
|
|
12877
12786
|
height: 100%;
|
|
12878
12787
|
pointer-events: none;
|
|
12879
12788
|
}
|
|
12789
|
+
|
|
12790
|
+
/** //TODO : animation on off */
|
|
12880
12791
|
&:hover {
|
|
12881
12792
|
transform: scale(1.1);
|
|
12882
12793
|
}
|
|
@@ -12985,7 +12896,7 @@ const PlayBtn = () => {
|
|
|
12985
12896
|
customIcons
|
|
12986
12897
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
12987
12898
|
const audioPlayerDispatch = useNonNullableContext(audioPlayerDispatchContext);
|
|
12988
|
-
const
|
|
12899
|
+
const changePlayState = () => audioPlayerDispatch({
|
|
12989
12900
|
type: "SET_PlAY_STATE"
|
|
12990
12901
|
});
|
|
12991
12902
|
const PlayIcon = useMemo(() => {
|
|
@@ -13000,7 +12911,7 @@ const PlayBtn = () => {
|
|
|
13000
12911
|
});
|
|
13001
12912
|
}, [curAudioState.isPlaying, customIcons == null ? void 0 : customIcons.pause, customIcons == null ? void 0 : customIcons.play]);
|
|
13002
12913
|
return /* @__PURE__ */ jsx(StyledPlayBtn, {
|
|
13003
|
-
onClick,
|
|
12914
|
+
onClick: changePlayState,
|
|
13004
12915
|
className: "play-button",
|
|
13005
12916
|
children: PlayIcon
|
|
13006
12917
|
});
|
|
@@ -13019,7 +12930,7 @@ const PrevNnextBtn = ({
|
|
|
13019
12930
|
customIcons
|
|
13020
12931
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
13021
12932
|
const audioPlayerDispatch = useNonNullableContext(audioPlayerDispatchContext);
|
|
13022
|
-
const
|
|
12933
|
+
const changeAudio = () => {
|
|
13023
12934
|
if (type === "next") {
|
|
13024
12935
|
audioPlayerDispatch({
|
|
13025
12936
|
type: "NEXT_AUDIO"
|
|
@@ -13047,7 +12958,7 @@ const PrevNnextBtn = ({
|
|
|
13047
12958
|
return null;
|
|
13048
12959
|
}, [customIcons == null ? void 0 : customIcons.next, customIcons == null ? void 0 : customIcons.prev, type]);
|
|
13049
12960
|
return visible ? /* @__PURE__ */ jsx(StyledBtn, {
|
|
13050
|
-
onClick:
|
|
12961
|
+
onClick: changeAudio,
|
|
13051
12962
|
className: "prev-n-next-button",
|
|
13052
12963
|
children: PrevNnextIcon
|
|
13053
12964
|
}) : null;
|
|
@@ -13076,11 +12987,10 @@ function TbVolume(props) {
|
|
|
13076
12987
|
const RepeatTypeBtn = () => {
|
|
13077
12988
|
const {
|
|
13078
12989
|
curAudioState,
|
|
13079
|
-
customIcons
|
|
13080
|
-
activeUI
|
|
12990
|
+
customIcons
|
|
13081
12991
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
13082
12992
|
const audioPlayerDispatch = useNonNullableContext(audioPlayerDispatchContext);
|
|
13083
|
-
const
|
|
12993
|
+
const changeRepeatType = useCallback(() => {
|
|
13084
12994
|
switch (curAudioState.repeatType) {
|
|
13085
12995
|
case "ALL":
|
|
13086
12996
|
audioPlayerDispatch({
|
|
@@ -13133,7 +13043,7 @@ const RepeatTypeBtn = () => {
|
|
|
13133
13043
|
}
|
|
13134
13044
|
}, [curAudioState.repeatType, customIcons == null ? void 0 : customIcons.repeatAll, customIcons == null ? void 0 : customIcons.repeatNone, customIcons == null ? void 0 : customIcons.repeatOne, customIcons == null ? void 0 : customIcons.repeatShuffle]);
|
|
13135
13045
|
return /* @__PURE__ */ jsx(StyledBtn, {
|
|
13136
|
-
onClick,
|
|
13046
|
+
onClick: changeRepeatType,
|
|
13137
13047
|
className: "repeat-button",
|
|
13138
13048
|
children: RepeatIcon
|
|
13139
13049
|
});
|
|
@@ -13160,7 +13070,7 @@ const VolumeTriggerBtn = forwardRef((_, ref) => {
|
|
|
13160
13070
|
customIcons
|
|
13161
13071
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
13162
13072
|
const audioPlayerDispatch = useNonNullableContext(audioPlayerDispatchContext);
|
|
13163
|
-
const
|
|
13073
|
+
const changeMuteState = useCallback(() => audioPlayerDispatch({
|
|
13164
13074
|
type: "SET_MUTED",
|
|
13165
13075
|
muted: !curAudioState.muted
|
|
13166
13076
|
}), [audioPlayerDispatch, curAudioState.muted]);
|
|
@@ -13210,7 +13120,7 @@ const VolumeTriggerBtn = forwardRef((_, ref) => {
|
|
|
13210
13120
|
}
|
|
13211
13121
|
}, [curAudioState.muted, curAudioState.volume, customIcons == null ? void 0 : customIcons.volumeMuted, customIcons == null ? void 0 : customIcons.volumeFull, customIcons == null ? void 0 : customIcons.volumeHalf]);
|
|
13212
13122
|
return /* @__PURE__ */ jsx(StyledBtn, {
|
|
13213
|
-
onClick:
|
|
13123
|
+
onClick: changeMuteState,
|
|
13214
13124
|
className: "volume-trigger-container",
|
|
13215
13125
|
ref,
|
|
13216
13126
|
children: VolumeIcon
|
|
@@ -13702,7 +13612,8 @@ const SortableListItem = (props) => {
|
|
|
13702
13612
|
});
|
|
13703
13613
|
};
|
|
13704
13614
|
const SortableListItemContainer = styled.li`
|
|
13705
|
-
border: 2px solid transparent;
|
|
13615
|
+
border-top: 2px solid transparent;
|
|
13616
|
+
border-bottom: 2px solid transparent;
|
|
13706
13617
|
transition: all 0.3s ease-in-out;
|
|
13707
13618
|
|
|
13708
13619
|
& * {
|
|
@@ -14361,6 +14272,7 @@ const Dropdown = ({
|
|
|
14361
14272
|
children,
|
|
14362
14273
|
isOpen: isOpenProp,
|
|
14363
14274
|
placement = "bottom",
|
|
14275
|
+
disabled = false,
|
|
14364
14276
|
onOpenChange
|
|
14365
14277
|
}) => {
|
|
14366
14278
|
const dropdownRef = useRef(null);
|
|
@@ -14391,7 +14303,7 @@ const Dropdown = ({
|
|
|
14391
14303
|
onOpenChange
|
|
14392
14304
|
},
|
|
14393
14305
|
children: /* @__PURE__ */ jsxs(Fragment, {
|
|
14394
|
-
children: [trigger, content]
|
|
14306
|
+
children: [trigger, !disabled && content]
|
|
14395
14307
|
})
|
|
14396
14308
|
})
|
|
14397
14309
|
});
|
|
@@ -14468,7 +14380,7 @@ const DropdownContent = ({
|
|
|
14468
14380
|
onExited,
|
|
14469
14381
|
onEntered,
|
|
14470
14382
|
children: Content
|
|
14471
|
-
}) : Content;
|
|
14383
|
+
}) : isOpen ? Content : null;
|
|
14472
14384
|
};
|
|
14473
14385
|
const DropdownContentContainer = styled.div`
|
|
14474
14386
|
${({
|
|
@@ -14494,23 +14406,39 @@ const DropdownTrigger = ({
|
|
|
14494
14406
|
};
|
|
14495
14407
|
Dropdown.Content = DropdownContent;
|
|
14496
14408
|
Dropdown.Trigger = DropdownTrigger;
|
|
14497
|
-
const
|
|
14498
|
-
|
|
14499
|
-
|
|
14409
|
+
const useVolumeSliderPlacement = ({
|
|
14410
|
+
ref,
|
|
14411
|
+
initialState
|
|
14412
|
+
}) => {
|
|
14413
|
+
const [volumeSliderPlacement, setVolumeSliderPlacement] = useState(initialState);
|
|
14500
14414
|
useEffect(() => {
|
|
14501
|
-
if (
|
|
14415
|
+
if (ref.current) {
|
|
14502
14416
|
const placementValidation = () => {
|
|
14503
|
-
if (
|
|
14417
|
+
if (ref.current.getBoundingClientRect().top < window.innerHeight / 2) {
|
|
14504
14418
|
return "bottom";
|
|
14505
14419
|
}
|
|
14506
14420
|
return "top";
|
|
14507
14421
|
};
|
|
14508
14422
|
setVolumeSliderPlacement(placementValidation());
|
|
14509
14423
|
}
|
|
14510
|
-
}, [
|
|
14424
|
+
}, [ref.current]);
|
|
14425
|
+
return volumeSliderPlacement;
|
|
14426
|
+
};
|
|
14427
|
+
const Volume = () => {
|
|
14428
|
+
const triggerRef = useRef(null);
|
|
14429
|
+
const {
|
|
14430
|
+
activeUI: {
|
|
14431
|
+
volumeSlider: volumeSliderEl
|
|
14432
|
+
}
|
|
14433
|
+
} = useNonNullableContext(audioPlayerStateContext);
|
|
14434
|
+
const volumeSliderPlacement = useVolumeSliderPlacement({
|
|
14435
|
+
ref: triggerRef,
|
|
14436
|
+
initialState: "bottom"
|
|
14437
|
+
});
|
|
14511
14438
|
return /* @__PURE__ */ jsxs(Dropdown, {
|
|
14512
14439
|
placement: volumeSliderPlacement,
|
|
14513
14440
|
triggerType: "hover",
|
|
14441
|
+
disabled: !volumeSliderEl,
|
|
14514
14442
|
children: [/* @__PURE__ */ jsx(Dropdown.Trigger, {
|
|
14515
14443
|
children: /* @__PURE__ */ jsx(VolumeTriggerBtn, {
|
|
14516
14444
|
ref: triggerRef
|
|
@@ -14601,10 +14529,10 @@ const TrackInfoContainer = styled.div`
|
|
|
14601
14529
|
overflow: hidden;
|
|
14602
14530
|
}
|
|
14603
14531
|
.title {
|
|
14604
|
-
font-size:
|
|
14532
|
+
font-size: 16px;
|
|
14605
14533
|
}
|
|
14606
14534
|
.writer {
|
|
14607
|
-
font-size:
|
|
14535
|
+
font-size: 12px;
|
|
14608
14536
|
}
|
|
14609
14537
|
`;
|
|
14610
14538
|
const TrackInfo = () => {
|
|
@@ -14631,18 +14559,10 @@ const TrackTimeCurrent = () => {
|
|
|
14631
14559
|
const {
|
|
14632
14560
|
activeUI
|
|
14633
14561
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
audioPlayerDispatch({
|
|
14639
|
-
type: "SET_ELEMENT_REFS",
|
|
14640
|
-
elementRefs: {
|
|
14641
|
-
trackCurTimeEl
|
|
14642
|
-
}
|
|
14643
|
-
});
|
|
14644
|
-
}
|
|
14645
|
-
}, [trackCurTimeRef.current, audioPlayerDispatch]);
|
|
14562
|
+
useTrackTimeRefDispatchEffect({
|
|
14563
|
+
ref: trackCurTimeRef,
|
|
14564
|
+
refName: "trackCurTimeEl"
|
|
14565
|
+
});
|
|
14646
14566
|
return /* @__PURE__ */ jsx(TrackTimeCurrentContainer, {
|
|
14647
14567
|
type: activeUI.trackTime,
|
|
14648
14568
|
className: "track-time-current-container",
|
|
@@ -14658,18 +14578,10 @@ const TrackTimeDuration = () => {
|
|
|
14658
14578
|
const {
|
|
14659
14579
|
activeUI
|
|
14660
14580
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
audioPlayerDispatch({
|
|
14666
|
-
type: "SET_ELEMENT_REFS",
|
|
14667
|
-
elementRefs: {
|
|
14668
|
-
trackDurationEl
|
|
14669
|
-
}
|
|
14670
|
-
});
|
|
14671
|
-
}
|
|
14672
|
-
}, [trackDurationRef.current, audioPlayerDispatch]);
|
|
14581
|
+
useTrackTimeRefDispatchEffect({
|
|
14582
|
+
ref: trackDurationRef,
|
|
14583
|
+
refName: "trackDurationEl"
|
|
14584
|
+
});
|
|
14673
14585
|
return /* @__PURE__ */ jsx(TrackTimeDurationContainer, {
|
|
14674
14586
|
type: activeUI.trackTime,
|
|
14675
14587
|
className: "track-time-duration-container",
|
|
@@ -14680,13 +14592,30 @@ const TrackTimeDuration = () => {
|
|
|
14680
14592
|
})
|
|
14681
14593
|
});
|
|
14682
14594
|
};
|
|
14595
|
+
const useTrackTimeRefDispatchEffect = ({
|
|
14596
|
+
ref,
|
|
14597
|
+
refName
|
|
14598
|
+
}) => {
|
|
14599
|
+
const audioPlayerDispatch = useNonNullableContext(audioPlayerDispatchContext);
|
|
14600
|
+
useEffect(() => {
|
|
14601
|
+
const trackTimeRef = ref.current;
|
|
14602
|
+
if (trackTimeRef) {
|
|
14603
|
+
audioPlayerDispatch({
|
|
14604
|
+
type: "SET_ELEMENT_REFS",
|
|
14605
|
+
elementRefs: {
|
|
14606
|
+
[refName]: trackTimeRef
|
|
14607
|
+
}
|
|
14608
|
+
});
|
|
14609
|
+
}
|
|
14610
|
+
}, [ref.current, audioPlayerDispatch, refName]);
|
|
14611
|
+
};
|
|
14683
14612
|
const TrackTimeContainer = styled.div`
|
|
14684
14613
|
display: flex;
|
|
14685
14614
|
align-items: center;
|
|
14686
14615
|
justify-content: center;
|
|
14687
14616
|
min-height: 16px;
|
|
14688
|
-
font-family: monospace;
|
|
14689
|
-
font-size:
|
|
14617
|
+
font-family: monospace !important;
|
|
14618
|
+
font-size: 16px !important;
|
|
14690
14619
|
`;
|
|
14691
14620
|
const TrackTimeCurrentContainer = styled(TrackTimeContainer)`
|
|
14692
14621
|
${({
|
|
@@ -14725,7 +14654,7 @@ const Information = () => {
|
|
|
14725
14654
|
curIdx,
|
|
14726
14655
|
activeUI
|
|
14727
14656
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
14728
|
-
const
|
|
14657
|
+
const isTrackInfoActive = Boolean((_e = (_c = (_a2 = playList[curIdx]) == null ? void 0 : _a2.customTrackInfo) != null ? _c : (_b = playList[curIdx]) == null ? void 0 : _b.writer) != null ? _e : (_d = playList[curIdx]) == null ? void 0 : _d.name) && Boolean((_f = activeUI.trackInfo) != null ? _f : activeUI.all);
|
|
14729
14658
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
14730
14659
|
children: [/* @__PURE__ */ jsx(Grid.Item, {
|
|
14731
14660
|
gridArea: ((_g = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _g.artwork) || ((_h = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _h.artwork) || defaultInterfacePlacement.templateArea.artwork,
|
|
@@ -14733,7 +14662,7 @@ const Information = () => {
|
|
|
14733
14662
|
children: /* @__PURE__ */ jsx(Artwork, {})
|
|
14734
14663
|
}), /* @__PURE__ */ jsx(Grid.Item, {
|
|
14735
14664
|
gridArea: ((_k = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _k.trackInfo) || ((_l = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _l.trackInfo) || defaultInterfacePlacement.templateArea.trackInfo,
|
|
14736
|
-
visible:
|
|
14665
|
+
visible: isTrackInfoActive,
|
|
14737
14666
|
children: /* @__PURE__ */ jsx(TrackInfo, {})
|
|
14738
14667
|
}), /* @__PURE__ */ jsx(Grid.Item, {
|
|
14739
14668
|
gridArea: ((_m = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _m.trackTimeCurrent) || ((_n = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _n.trackTimeCurrent) || defaultInterfacePlacement.templateArea.trackTimeCurrent,
|
|
@@ -14811,9 +14740,16 @@ const generateGridTemplateValues = (activeUi, placement) => {
|
|
|
14811
14740
|
return { gridAreas, gridColumns };
|
|
14812
14741
|
};
|
|
14813
14742
|
const InterfaceContainer = styled.div`
|
|
14743
|
+
.interface-grid {
|
|
14744
|
+
background: var(--rm-audio-player-interface-container);
|
|
14745
|
+
}
|
|
14814
14746
|
.interface-grid {
|
|
14815
14747
|
padding: 0.5rem 10px;
|
|
14816
14748
|
}
|
|
14749
|
+
.sortable-play-list {
|
|
14750
|
+
background: var(--rm-audio-player-sortable-list);
|
|
14751
|
+
box-shadow: -5px 2px 4px 0px rgb(0 0 0 / 4%) inset;
|
|
14752
|
+
}
|
|
14817
14753
|
`;
|
|
14818
14754
|
const Interface = () => {
|
|
14819
14755
|
const {
|
|
@@ -14842,13 +14778,13 @@ const Interface = () => {
|
|
|
14842
14778
|
})]
|
|
14843
14779
|
});
|
|
14844
14780
|
};
|
|
14845
|
-
const
|
|
14846
|
-
playList,
|
|
14847
|
-
audioInitialState,
|
|
14781
|
+
const usePropsStateEffect = ({
|
|
14848
14782
|
placement = {},
|
|
14849
14783
|
activeUI,
|
|
14850
|
-
|
|
14851
|
-
|
|
14784
|
+
coverImgsCss,
|
|
14785
|
+
audioInitialState,
|
|
14786
|
+
playList,
|
|
14787
|
+
customIcons
|
|
14852
14788
|
}) => {
|
|
14853
14789
|
const audioPlayerDispatch = useNonNullableContext(audioPlayerDispatchContext);
|
|
14854
14790
|
useLayoutEffect(() => {
|
|
@@ -14866,18 +14802,12 @@ const AudioPlayer = ({
|
|
|
14866
14802
|
}, [audioPlayerDispatch, placement]);
|
|
14867
14803
|
useLayoutEffect(() => {
|
|
14868
14804
|
if (activeUI) {
|
|
14869
|
-
audioPlayerDispatch({
|
|
14870
|
-
type: "SET_ACTIVE_UI",
|
|
14871
|
-
activeUI
|
|
14872
|
-
});
|
|
14805
|
+
audioPlayerDispatch({ type: "SET_ACTIVE_UI", activeUI });
|
|
14873
14806
|
}
|
|
14874
14807
|
}, [activeUI, audioPlayerDispatch]);
|
|
14875
14808
|
useLayoutEffect(() => {
|
|
14876
14809
|
if (coverImgsCss) {
|
|
14877
|
-
audioPlayerDispatch({
|
|
14878
|
-
type: "SET_COVER_IMGS_CSS",
|
|
14879
|
-
coverImgsCss
|
|
14880
|
-
});
|
|
14810
|
+
audioPlayerDispatch({ type: "SET_COVER_IMGS_CSS", coverImgsCss });
|
|
14881
14811
|
}
|
|
14882
14812
|
}, [audioPlayerDispatch, coverImgsCss]);
|
|
14883
14813
|
useEffect(() => {
|
|
@@ -14889,19 +14819,16 @@ const AudioPlayer = ({
|
|
|
14889
14819
|
}
|
|
14890
14820
|
}, [audioInitialState, audioPlayerDispatch]);
|
|
14891
14821
|
useEffect(() => {
|
|
14892
|
-
audioPlayerDispatch({
|
|
14893
|
-
type: "UPDATE_PLAY_LIST",
|
|
14894
|
-
playList
|
|
14895
|
-
});
|
|
14822
|
+
audioPlayerDispatch({ type: "UPDATE_PLAY_LIST", playList });
|
|
14896
14823
|
}, [audioPlayerDispatch, playList]);
|
|
14897
14824
|
useEffect(() => {
|
|
14898
14825
|
if (customIcons) {
|
|
14899
|
-
audioPlayerDispatch({
|
|
14900
|
-
type: "SET_CUSTOM_ICONS",
|
|
14901
|
-
customIcons
|
|
14902
|
-
});
|
|
14826
|
+
audioPlayerDispatch({ type: "SET_CUSTOM_ICONS", customIcons });
|
|
14903
14827
|
}
|
|
14904
14828
|
}, [customIcons, audioPlayerDispatch]);
|
|
14829
|
+
};
|
|
14830
|
+
const AudioPlayer = (props) => {
|
|
14831
|
+
usePropsStateEffect(props);
|
|
14905
14832
|
return /* @__PURE__ */ jsxs($b9606c0c41d55371$export$27a5bd065ad55220, {
|
|
14906
14833
|
id: "rm-audio-player",
|
|
14907
14834
|
UNSAFE_className: "rm-audio-player-container",
|
|
@@ -14915,9 +14842,9 @@ const AudioPlayerWithProvider = ({
|
|
|
14915
14842
|
return /* @__PURE__ */ jsx(AudioPlayerProvider, {
|
|
14916
14843
|
children: /* @__PURE__ */ jsxs(SpectrumProvider, {
|
|
14917
14844
|
rootContainerProps,
|
|
14918
|
-
children: [/* @__PURE__ */ jsx(
|
|
14845
|
+
children: [/* @__PURE__ */ jsx(AudioPlayer, {
|
|
14919
14846
|
...audioPlayProps
|
|
14920
|
-
})]
|
|
14847
|
+
}), /* @__PURE__ */ jsx(GlobalStyle, {})]
|
|
14921
14848
|
})
|
|
14922
14849
|
});
|
|
14923
14850
|
};
|
|
@@ -3,7 +3,7 @@ import { ActiveUI } from "./element";
|
|
|
3
3
|
export declare type PlayListPlacement = "bottom" | "top";
|
|
4
4
|
export declare type PlayerPlacement = "bottom" | "top" | "bottom-left" | "bottom-right" | "top-left" | "top-right";
|
|
5
5
|
export declare const interfacePlacementMaxLength = 10;
|
|
6
|
-
export declare type InterfacePlacementKey = Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime"> | "trackTimeCurrent" | "trackTimeDuration";
|
|
6
|
+
export declare type InterfacePlacementKey = Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime" | "volumeSlider"> | "trackTimeCurrent" | "trackTimeDuration";
|
|
7
7
|
export declare type InterfaceGridTemplateArea = Partial<Record<InterfacePlacementKey, `row${NumbersToUnionNum<typeof interfacePlacementMaxLength>}-${NumbersToUnionNum<typeof interfacePlacementMaxLength>}`>>;
|
|
8
8
|
export declare type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
|
|
9
9
|
export declare type InterfacePlacement = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { ActiveUI, PlayListPlacement, CustomIcons, PlayerPlacement, PlayList, AudioInitialState, InterfacePlacement, CoverImgsCss } from '
|
|
2
|
+
import { ActiveUI, PlayListPlacement, CustomIcons, PlayerPlacement, PlayList, AudioInitialState, InterfacePlacement, CoverImgsCss } from '../../AudioPlayer/Context';
|
|
3
3
|
export interface AudioPlayerProps {
|
|
4
4
|
playList: PlayList;
|
|
5
5
|
audioInitialState?: AudioInitialState;
|
|
@@ -7,6 +7,7 @@ export interface DropdownProps extends Omit<Partial<DropdownContext>, "setIsOpen
|
|
|
7
7
|
triggerType?: "click" | "hover";
|
|
8
8
|
outboundClickActive?: boolean;
|
|
9
9
|
placement?: DropdownContext["placement"];
|
|
10
|
+
disabled?: boolean;
|
|
10
11
|
}
|
|
11
12
|
declare const Dropdown: FC<PropsWithChildren<DropdownProps>>;
|
|
12
13
|
declare type DropdownComponent = typeof Dropdown & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-modern-audio-player",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"homepage": "https://github.com/slash9494/react-modern-audio-player/",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "vite --host",
|
|
18
18
|
"build": "rm -rf dist && tsc && vite build",
|
|
19
|
-
"preview": "vite preview"
|
|
20
|
-
"publish": "npm publish --access public"
|
|
19
|
+
"preview": "vite preview"
|
|
21
20
|
},
|
|
22
21
|
"peerDependencies": {
|
|
23
22
|
"react": ">=16.8.0",
|