react-modern-audio-player 1.3.0 → 1.4.0-rc.1
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 +64 -2
- package/dist/index.es.js +102 -75
- package/dist/types/components/AudioPlayer/Context/StateContext/placement.d.ts +9 -7
- package/dist/types/components/AudioPlayer/Context/dispatchContext.d.ts +3 -3
- package/dist/types/components/AudioPlayer/Interface/CustomComponent/index.d.ts +7 -0
- package/dist/types/components/AudioPlayer/Interface/index.d.ts +6 -2
- package/dist/types/components/AudioPlayer/Player/index.d.ts +4 -4
- package/dist/types/components/AudioPlayer/Player/usePropsStateEffect.d.ts +1 -1
- package/dist/types/components/AudioPlayer/index.d.ts +9 -3
- package/dist/types/components/Drawer/Drawer.d.ts +1 -2
- package/dist/types/components/Dropdown/Dropdown.d.ts +1 -2
- package/dist/types/components/Grid/Item.d.ts +1 -1
- package/dist/types/components/Provider/AudioPlayerProvider.d.ts +2 -2
- package/dist/types/hooks/useGridTemplate.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ function Player (){
|
|
|
75
75
|
interface AudioPlayerProps {
|
|
76
76
|
playList: PlayList;
|
|
77
77
|
audioInitialState?: AudioInitialState;
|
|
78
|
+
audioRef?: React.MutableRefObject<HTMLAudioElement>;
|
|
78
79
|
activeUI?: ActiveUI;
|
|
79
80
|
customIcons?: CustomIcons;
|
|
80
81
|
coverImgsCss?: CoverImgsCss;
|
|
@@ -194,15 +195,21 @@ type PlayListPlacement = "bottom" | "top";
|
|
|
194
195
|
|
|
195
196
|
type InterfacePlacement = {
|
|
196
197
|
templateArea?: InterfaceGridTemplateArea;
|
|
198
|
+
customComponentsArea?: InterfaceGridCustomComponentsArea<TMaxLength>;
|
|
197
199
|
itemCustomArea?: InterfaceGridItemArea;
|
|
198
200
|
};
|
|
199
201
|
|
|
200
|
-
type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>
|
|
201
202
|
type InterfacePlacementKey =
|
|
202
203
|
| Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime">
|
|
203
204
|
| "trackTimeCurrent"
|
|
204
205
|
| "trackTimeDuration";
|
|
205
|
-
|
|
206
|
+
|
|
207
|
+
type InterfacePlacementValue = "row1-1" | "row1-2" | "row1-3" | "row1-4" | ... more ... | "row9-9"
|
|
208
|
+
/** if you apply custom components, values must be "row1-1" ~ any more */
|
|
209
|
+
|
|
210
|
+
type InterfaceGridTemplateArea = Record<InterfacePlacementKey,InterfacePlacementValue>;
|
|
211
|
+
|
|
212
|
+
type InterfaceGridCustomComponentsArea = Record<componentId,InterfacePlacementValue>;
|
|
206
213
|
|
|
207
214
|
type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
|
|
208
215
|
/** example
|
|
@@ -279,6 +286,61 @@ const defaultInterfacePlacement = {
|
|
|
279
286
|
|
|
280
287
|
// ...spectrum theme palette and so on... //
|
|
281
288
|
```
|
|
289
|
+
# Custom Component
|
|
290
|
+
> you can apply custom component to `AudioPlayer` by `CustomComponent`
|
|
291
|
+
> </br>
|
|
292
|
+
> you can also set `viewProps` to `CustomComponent`
|
|
293
|
+
> </br>
|
|
294
|
+
> (https://react-spectrum.adobe.com/react-spectrum/View.html#props)
|
|
295
|
+
|
|
296
|
+
``` tsx
|
|
297
|
+
const activeUI: ActiveUI = {
|
|
298
|
+
all: true,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const placement = {
|
|
302
|
+
interface: {
|
|
303
|
+
customComponentsArea: {
|
|
304
|
+
playerCustomComponent: "row1-10",
|
|
305
|
+
},
|
|
306
|
+
} as InterfacePlacement<11>,
|
|
307
|
+
/**
|
|
308
|
+
* you should set generic value of `InterfacePlacement` as interfaces max length for auto-complete aria type such as "row-1-10"
|
|
309
|
+
* generic value must plus 1 than interfaces length because of 0 index
|
|
310
|
+
*/
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/** you can get audioPlayerState by props */
|
|
314
|
+
const CustomComponent = ({
|
|
315
|
+
audioPlayerState,
|
|
316
|
+
}: {
|
|
317
|
+
audioPlayerState?: AudioPlayerStateContext;
|
|
318
|
+
}) => {
|
|
319
|
+
const audioEl = audioPlayerState?.elementRefs?.audioEl;
|
|
320
|
+
const handOverTime = () => {
|
|
321
|
+
if (audioEl) {
|
|
322
|
+
audioEl.currentTime += 30;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
return (
|
|
326
|
+
<>
|
|
327
|
+
<button onClick={handOverTime}>+30</button>
|
|
328
|
+
</>
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
<AudioPlayer
|
|
333
|
+
playList={playList}
|
|
334
|
+
placement={placement}
|
|
335
|
+
activeUI={activeUI}
|
|
336
|
+
>
|
|
337
|
+
<AudioPlayer.CustomComponent id="playerCustomComponent">
|
|
338
|
+
<CustomComponent />
|
|
339
|
+
</AudioPlayer.CustomComponent>
|
|
340
|
+
</AudioPlayer>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
|
|
282
344
|
|
|
283
345
|
# ****Example****
|
|
284
346
|
```tsx
|
package/dist/index.es.js
CHANGED
|
@@ -1083,7 +1083,7 @@ const useNonNullableContext = (context) => {
|
|
|
1083
1083
|
throw new Error(`${context} is not provided or null`);
|
|
1084
1084
|
return state;
|
|
1085
1085
|
};
|
|
1086
|
-
const
|
|
1086
|
+
const defaultInterfacePlacementMaxLength = 10;
|
|
1087
1087
|
const defaultInterfacePlacement = {
|
|
1088
1088
|
templateArea: {
|
|
1089
1089
|
artwork: "row1-1",
|
|
@@ -1235,6 +1235,7 @@ const audioPlayerReducer = (state, action) => {
|
|
|
1235
1235
|
var _a, _b, _c, _d;
|
|
1236
1236
|
switch (action.type) {
|
|
1237
1237
|
case "NEXT_AUDIO": {
|
|
1238
|
+
resetAudioValues(state.elementRefs, void 0, true);
|
|
1238
1239
|
if (state.curAudioState.repeatType === "NONE" && state.curIdx + 1 === state.playList.length) {
|
|
1239
1240
|
return {
|
|
1240
1241
|
...state,
|
|
@@ -7608,44 +7609,43 @@ const Volume = () => {
|
|
|
7608
7609
|
});
|
|
7609
7610
|
};
|
|
7610
7611
|
const Controller = () => {
|
|
7611
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
7612
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
7612
7613
|
const {
|
|
7613
7614
|
interfacePlacement,
|
|
7614
7615
|
activeUI
|
|
7615
7616
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
7616
|
-
const volumeComponentKey = (_a = document.querySelector(".rm-audio-player-provider")) == null ? void 0 : _a.getBoundingClientRect().top;
|
|
7617
7617
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
7618
7618
|
children: [/* @__PURE__ */ jsx(Grid.Item, {
|
|
7619
|
-
gridArea: ((
|
|
7619
|
+
gridArea: ((_a = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _a.progress) || ((_b = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _b.progress) || defaultInterfacePlacement.templateArea.progress,
|
|
7620
7620
|
width: "100%",
|
|
7621
7621
|
visible: Boolean(activeUI.progress !== void 0 ? activeUI.progress : activeUI.all),
|
|
7622
7622
|
children: /* @__PURE__ */ jsx(Progress, {})
|
|
7623
7623
|
}), /* @__PURE__ */ jsx(Grid.Item, {
|
|
7624
|
-
gridArea: ((
|
|
7625
|
-
visible: Boolean((
|
|
7624
|
+
gridArea: ((_c = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _c.repeatType) || ((_d = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _d.repeatType) || defaultInterfacePlacement.templateArea.repeatType,
|
|
7625
|
+
visible: Boolean((_e = activeUI.repeatType) != null ? _e : activeUI.all),
|
|
7626
7626
|
children: /* @__PURE__ */ jsx(RepeatTypeBtn, {})
|
|
7627
7627
|
}), /* @__PURE__ */ jsx(Grid.Item, {
|
|
7628
|
-
gridArea: ((
|
|
7629
|
-
visible: Boolean((
|
|
7628
|
+
gridArea: ((_f = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _f.playButton) || ((_g = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _g.playButton) || defaultInterfacePlacement.templateArea.playButton,
|
|
7629
|
+
visible: Boolean((_h = activeUI.playButton) != null ? _h : activeUI.all),
|
|
7630
7630
|
children: /* @__PURE__ */ jsxs($884c64d19340d345$export$f51f4c4ede09e011, {
|
|
7631
7631
|
UNSAFE_className: "btn-wrapper",
|
|
7632
7632
|
alignItems: "center",
|
|
7633
7633
|
gap: "10px",
|
|
7634
7634
|
children: [/* @__PURE__ */ jsx(PrevNnextBtn, {
|
|
7635
7635
|
type: "prev",
|
|
7636
|
-
visible: Boolean((
|
|
7636
|
+
visible: Boolean((_i = activeUI.prevNnext) != null ? _i : activeUI.all)
|
|
7637
7637
|
}), /* @__PURE__ */ jsx(PlayBtn, {}), /* @__PURE__ */ jsx(PrevNnextBtn, {
|
|
7638
7638
|
type: "next",
|
|
7639
|
-
visible: Boolean((
|
|
7639
|
+
visible: Boolean((_j = activeUI.prevNnext) != null ? _j : activeUI.all)
|
|
7640
7640
|
})]
|
|
7641
7641
|
})
|
|
7642
7642
|
}), /* @__PURE__ */ jsx(Grid.Item, {
|
|
7643
|
-
gridArea: ((
|
|
7644
|
-
visible: Boolean((
|
|
7645
|
-
children: /* @__PURE__ */ jsx(Volume, {}
|
|
7643
|
+
gridArea: ((_k = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _k.volume) || ((_l = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _l.volume) || defaultInterfacePlacement.templateArea.volume,
|
|
7644
|
+
visible: Boolean((_m = activeUI.volume) != null ? _m : activeUI.all),
|
|
7645
|
+
children: /* @__PURE__ */ jsx(Volume, {})
|
|
7646
7646
|
}), /* @__PURE__ */ jsx(Grid.Item, {
|
|
7647
|
-
gridArea: ((
|
|
7648
|
-
visible: Boolean((
|
|
7647
|
+
gridArea: ((_n = interfacePlacement == null ? void 0 : interfacePlacement.itemCustomArea) == null ? void 0 : _n.playList) || ((_o = interfacePlacement == null ? void 0 : interfacePlacement.templateArea) == null ? void 0 : _o.playList) || defaultInterfacePlacement.templateArea.playList,
|
|
7648
|
+
visible: Boolean((_p = activeUI.playList) != null ? _p : activeUI.all),
|
|
7649
7649
|
children: /* @__PURE__ */ jsx(SortablePlayList, {})
|
|
7650
7650
|
})]
|
|
7651
7651
|
});
|
|
@@ -7855,10 +7855,12 @@ const Information = () => {
|
|
|
7855
7855
|
}), /* @__PURE__ */ jsx(TrackTime, {})]
|
|
7856
7856
|
});
|
|
7857
7857
|
};
|
|
7858
|
-
const useGridTemplate = (activeUI, templateArea) => {
|
|
7858
|
+
const useGridTemplate = (activeUI, templateArea, customComponentsArea) => {
|
|
7859
7859
|
const generateGridTemplateValues = useCallback(
|
|
7860
|
-
(activeUi,
|
|
7861
|
-
const
|
|
7860
|
+
(activeUi, templatePlacement, customComponentsPlacement) => {
|
|
7861
|
+
const activeUIAllKeys = Object.keys(
|
|
7862
|
+
defaultInterfacePlacement.templateArea
|
|
7863
|
+
).filter((key) => {
|
|
7862
7864
|
if ((key === "trackTimeCurrent" || key === "trackTimeDuration") && activeUi.trackTime === false) {
|
|
7863
7865
|
return false;
|
|
7864
7866
|
}
|
|
@@ -7866,43 +7868,46 @@ const useGridTemplate = (activeUI, templateArea) => {
|
|
|
7866
7868
|
return activeUi[key];
|
|
7867
7869
|
}
|
|
7868
7870
|
return true;
|
|
7869
|
-
})
|
|
7871
|
+
});
|
|
7872
|
+
const activeUIKeysArr = activeUi.all ? activeUIAllKeys : Object.entries(activeUi).filter(([, value]) => value).map(([key]) => key);
|
|
7870
7873
|
const renameTrackTime = () => {
|
|
7871
|
-
if (
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7874
|
+
if (activeUIKeysArr.find((key) => key === "trackTime")) {
|
|
7875
|
+
activeUIKeysArr.splice(activeUIKeysArr.indexOf("trackTime"), 1);
|
|
7876
|
+
activeUIKeysArr.push("trackTimeCurrent");
|
|
7877
|
+
activeUIKeysArr.push("trackTimeDuration");
|
|
7875
7878
|
}
|
|
7876
7879
|
};
|
|
7877
7880
|
renameTrackTime();
|
|
7878
|
-
const
|
|
7881
|
+
const totalTemplatePlacement = {
|
|
7879
7882
|
...defaultInterfacePlacement.templateArea,
|
|
7880
|
-
...
|
|
7883
|
+
...templatePlacement
|
|
7881
7884
|
};
|
|
7885
|
+
const activeTemplatePlacementArr = Object.entries(
|
|
7886
|
+
totalTemplatePlacement
|
|
7887
|
+
).filter(([key]) => activeUIKeysArr.includes(key));
|
|
7882
7888
|
let maxRow = 1;
|
|
7883
7889
|
const colsCntRecord = {};
|
|
7884
|
-
const
|
|
7885
|
-
|
|
7890
|
+
const totalPlacementArr = [
|
|
7891
|
+
...activeTemplatePlacementArr,
|
|
7892
|
+
...Object.entries(customComponentsPlacement || {})
|
|
7893
|
+
].map(([key, value]) => {
|
|
7894
|
+
const [rowWithText, colStrNum] = value.split("-");
|
|
7895
|
+
const row = +rowWithText.split("row")[1];
|
|
7896
|
+
maxRow = Math.max(maxRow, row);
|
|
7897
|
+
colsCntRecord[row] = colsCntRecord[row] ? colsCntRecord[row] + 1 : 1;
|
|
7886
7898
|
return {
|
|
7887
7899
|
key,
|
|
7888
|
-
row
|
|
7889
|
-
col:
|
|
7900
|
+
row,
|
|
7901
|
+
col: +colStrNum
|
|
7890
7902
|
};
|
|
7891
|
-
}).filter(({ key, row }) => {
|
|
7892
|
-
if (activeUIArr.includes(key)) {
|
|
7893
|
-
maxRow = Math.max(maxRow, row);
|
|
7894
|
-
colsCntRecord[row] = colsCntRecord[row] ? colsCntRecord[row] + 1 : 1;
|
|
7895
|
-
return true;
|
|
7896
|
-
}
|
|
7897
|
-
return false;
|
|
7898
7903
|
}).sort((a, b) => a.col - b.col);
|
|
7899
7904
|
const maxCol = Math.max(...Object.values(colsCntRecord));
|
|
7900
7905
|
let progressColIdx;
|
|
7901
7906
|
const gridAreas2 = new Array(maxRow).fill("").map((_, rowIdx) => {
|
|
7902
|
-
var _a
|
|
7907
|
+
var _a;
|
|
7903
7908
|
let cols = "";
|
|
7904
7909
|
let isWithProgress = false;
|
|
7905
|
-
const curRowPlacementArr =
|
|
7910
|
+
const curRowPlacementArr = totalPlacementArr.filter(({ key, row }) => {
|
|
7906
7911
|
if (row === rowIdx + 1) {
|
|
7907
7912
|
if (key === "progress") {
|
|
7908
7913
|
isWithProgress = true;
|
|
@@ -7924,16 +7929,8 @@ const useGridTemplate = (activeUI, templateArea) => {
|
|
|
7924
7929
|
}
|
|
7925
7930
|
}
|
|
7926
7931
|
} else {
|
|
7927
|
-
let extraColCnt = maxCol - curRowPlacementArr.length;
|
|
7928
|
-
let curRowIdx = 0;
|
|
7929
7932
|
for (let i = 0; i < maxCol; i++) {
|
|
7930
|
-
|
|
7931
|
-
curRowIdx++;
|
|
7932
|
-
cols += ` row${rowIdx + 1}-${((_c = curRowPlacementArr[curRowIdx]) == null ? void 0 : _c.col) ? curRowPlacementArr[curRowIdx].col : i + 1}`;
|
|
7933
|
-
} else {
|
|
7934
|
-
extraColCnt--;
|
|
7935
|
-
cols += ` row${rowIdx + 1}-${i + 1}`;
|
|
7936
|
-
}
|
|
7933
|
+
cols += ` row${rowIdx + 1}-${curRowPlacementArr[i] ? curRowPlacementArr[i].col : i + 1}`;
|
|
7937
7934
|
}
|
|
7938
7935
|
}
|
|
7939
7936
|
return cols.trimStart();
|
|
@@ -7955,47 +7952,43 @@ const useGridTemplate = (activeUI, templateArea) => {
|
|
|
7955
7952
|
[]
|
|
7956
7953
|
);
|
|
7957
7954
|
const [curActiveUI, setCurActiveUI] = useState(activeUI);
|
|
7958
|
-
const [
|
|
7959
|
-
|
|
7960
|
-
|
|
7955
|
+
const [curPlacementArea, setCurPlacementArea] = useState({
|
|
7956
|
+
templateArea,
|
|
7957
|
+
customComponentsArea
|
|
7958
|
+
});
|
|
7959
|
+
const [curPlacementAreaValues, setCurPlacementAreaValues] = useState();
|
|
7960
|
+
if (!curPlacementAreaValues) {
|
|
7961
7961
|
const { gridAreas: gridAreas2, gridColumns: gridColumns2 } = generateGridTemplateValues(
|
|
7962
7962
|
curActiveUI,
|
|
7963
|
-
|
|
7963
|
+
curPlacementArea.templateArea,
|
|
7964
|
+
curPlacementArea.customComponentsArea
|
|
7964
7965
|
);
|
|
7965
|
-
|
|
7966
|
+
setCurPlacementAreaValues({ gridAreas: gridAreas2, gridColumns: gridColumns2 });
|
|
7966
7967
|
return [gridAreas2, gridColumns2];
|
|
7967
7968
|
}
|
|
7968
|
-
if (curActiveUI !== activeUI ||
|
|
7969
|
+
if (curActiveUI !== activeUI || curPlacementArea.templateArea !== templateArea || curPlacementArea.customComponentsArea !== customComponentsArea) {
|
|
7969
7970
|
setCurActiveUI(activeUI);
|
|
7970
|
-
|
|
7971
|
+
setCurPlacementArea({ templateArea, customComponentsArea });
|
|
7971
7972
|
const { gridAreas: gridAreas2, gridColumns: gridColumns2 } = generateGridTemplateValues(
|
|
7972
7973
|
activeUI,
|
|
7973
|
-
templateArea
|
|
7974
|
+
templateArea,
|
|
7975
|
+
customComponentsArea
|
|
7974
7976
|
);
|
|
7975
|
-
|
|
7977
|
+
setCurPlacementAreaValues({ gridAreas: gridAreas2, gridColumns: gridColumns2 });
|
|
7976
7978
|
}
|
|
7977
|
-
const { gridAreas, gridColumns } =
|
|
7979
|
+
const { gridAreas, gridColumns } = curPlacementAreaValues;
|
|
7978
7980
|
return [gridAreas, gridColumns];
|
|
7979
7981
|
};
|
|
7980
|
-
const
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
}
|
|
7984
|
-
.interface-grid {
|
|
7985
|
-
padding: 0.5rem 10px;
|
|
7986
|
-
}
|
|
7987
|
-
.sortable-play-list {
|
|
7988
|
-
background: var(--rm-audio-player-sortable-list);
|
|
7989
|
-
box-shadow: -5px 2px 4px 0px rgb(0 0 0 / 4%) inset;
|
|
7990
|
-
}
|
|
7991
|
-
`;
|
|
7992
|
-
const Interface = () => {
|
|
7982
|
+
const Interface = ({
|
|
7983
|
+
children
|
|
7984
|
+
}) => {
|
|
7993
7985
|
const {
|
|
7994
7986
|
interfacePlacement,
|
|
7995
7987
|
activeUI,
|
|
7996
7988
|
playListPlacement
|
|
7997
7989
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
7998
|
-
const
|
|
7990
|
+
const CustomComponents = $k7QOs$react.Children.toArray(children);
|
|
7991
|
+
const [gridAreas, gridColumns] = useGridTemplate(activeUI, interfacePlacement == null ? void 0 : interfacePlacement.templateArea, interfacePlacement == null ? void 0 : interfacePlacement.customComponentsArea);
|
|
7999
7992
|
return /* @__PURE__ */ jsxs(InterfaceContainer, {
|
|
8000
7993
|
className: "interface-container",
|
|
8001
7994
|
children: [playListPlacement === "top" && /* @__PURE__ */ jsx("div", {
|
|
@@ -8007,12 +8000,24 @@ const Interface = () => {
|
|
|
8007
8000
|
minHeight: "30px",
|
|
8008
8001
|
columns: gridColumns,
|
|
8009
8002
|
UNSAFE_className: "interface-grid",
|
|
8010
|
-
children: [/* @__PURE__ */ jsx(Information, {}), /* @__PURE__ */ jsx(Controller, {})]
|
|
8003
|
+
children: [/* @__PURE__ */ jsx(Information, {}), /* @__PURE__ */ jsx(Controller, {}), CustomComponents]
|
|
8011
8004
|
}), playListPlacement === "bottom" && /* @__PURE__ */ jsx("div", {
|
|
8012
8005
|
className: "sortable-play-list"
|
|
8013
8006
|
})]
|
|
8014
8007
|
});
|
|
8015
8008
|
};
|
|
8009
|
+
const InterfaceContainer = styled.div`
|
|
8010
|
+
.interface-grid {
|
|
8011
|
+
background: var(--rm-audio-player-interface-container);
|
|
8012
|
+
}
|
|
8013
|
+
.interface-grid {
|
|
8014
|
+
padding: 0.5rem 10px;
|
|
8015
|
+
}
|
|
8016
|
+
.sortable-play-list {
|
|
8017
|
+
background: var(--rm-audio-player-sortable-list);
|
|
8018
|
+
box-shadow: -5px 2px 4px 0px rgb(0 0 0 / 4%) inset;
|
|
8019
|
+
}
|
|
8020
|
+
`;
|
|
8016
8021
|
const usePropsStateEffect = ({
|
|
8017
8022
|
placement = {},
|
|
8018
8023
|
activeUI,
|
|
@@ -8074,6 +8079,7 @@ const usePropsStateEffect = ({
|
|
|
8074
8079
|
};
|
|
8075
8080
|
const AudioPlayer = ({
|
|
8076
8081
|
audioRef,
|
|
8082
|
+
children,
|
|
8077
8083
|
...restProps
|
|
8078
8084
|
}) => {
|
|
8079
8085
|
usePropsStateEffect(restProps);
|
|
@@ -8082,10 +8088,12 @@ const AudioPlayer = ({
|
|
|
8082
8088
|
UNSAFE_className: "rm-audio-player-container",
|
|
8083
8089
|
children: [/* @__PURE__ */ jsx(Audio, {
|
|
8084
8090
|
audioRef
|
|
8085
|
-
}), /* @__PURE__ */ jsx(Interface, {
|
|
8091
|
+
}), /* @__PURE__ */ jsx(Interface, {
|
|
8092
|
+
children
|
|
8093
|
+
})]
|
|
8086
8094
|
});
|
|
8087
8095
|
};
|
|
8088
|
-
const
|
|
8096
|
+
const AudioPlayerWithProviders = ({
|
|
8089
8097
|
rootContainerProps,
|
|
8090
8098
|
...audioPlayProps
|
|
8091
8099
|
}) => {
|
|
@@ -8099,4 +8107,23 @@ const AudioPlayerWithProvider = ({
|
|
|
8099
8107
|
})
|
|
8100
8108
|
});
|
|
8101
8109
|
};
|
|
8102
|
-
|
|
8110
|
+
const CustomComponent = ({
|
|
8111
|
+
children,
|
|
8112
|
+
id,
|
|
8113
|
+
...gridItemProps
|
|
8114
|
+
}) => {
|
|
8115
|
+
var _a;
|
|
8116
|
+
const audioPlayerState = useNonNullableContext(audioPlayerStateContext);
|
|
8117
|
+
const placement = audioPlayerState.interfacePlacement;
|
|
8118
|
+
const gridArea = (_a = placement == null ? void 0 : placement.customComponentsArea) == null ? void 0 : _a[id];
|
|
8119
|
+
return /* @__PURE__ */ jsx(Grid.Item, {
|
|
8120
|
+
UNSAFE_className: "custom_component",
|
|
8121
|
+
gridArea,
|
|
8122
|
+
...gridItemProps,
|
|
8123
|
+
children: $k7QOs$react.cloneElement(children, {
|
|
8124
|
+
audioPlayerState
|
|
8125
|
+
})
|
|
8126
|
+
});
|
|
8127
|
+
};
|
|
8128
|
+
AudioPlayerWithProviders.CustomComponent = CustomComponent;
|
|
8129
|
+
export { AudioPlayer, SpectrumProvider, audioPlayerDispatchContext, audioPlayerReducer, audioPlayerStateContext, AudioPlayerWithProviders as default, defaultInterfacePlacement, defaultInterfacePlacementMaxLength };
|
|
@@ -4,20 +4,22 @@ import { ActiveUI } from "./element";
|
|
|
4
4
|
export declare type VolumeSliderPlacement = DropdownContentPlacement;
|
|
5
5
|
export declare type PlayListPlacement = "bottom" | "top";
|
|
6
6
|
export declare type PlayerPlacement = "bottom" | "top" | "bottom-left" | "bottom-right" | "top-left" | "top-right" | "static";
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const defaultInterfacePlacementMaxLength = 10;
|
|
8
8
|
export declare type InterfacePlacementKey = Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime" | "volumeSlider"> | "trackTimeCurrent" | "trackTimeDuration";
|
|
9
|
-
export declare type InterfaceGridTemplateArea = Partial<Record<InterfacePlacementKey, `row${NumbersToUnionNum<
|
|
9
|
+
export declare type InterfaceGridTemplateArea<TMaxLength extends number> = Partial<Record<InterfacePlacementKey, `row${NumbersToUnionNum<TMaxLength>}-${NumbersToUnionNum<TMaxLength>}`>>;
|
|
10
|
+
export declare type InterfaceGridCustomComponentsArea<TMaxLength extends number> = Partial<Record<string, `row${NumbersToUnionNum<TMaxLength>}-${NumbersToUnionNum<TMaxLength>}`>>;
|
|
10
11
|
export declare type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
|
|
11
|
-
export declare type InterfacePlacement = {
|
|
12
|
-
templateArea?: InterfaceGridTemplateArea
|
|
12
|
+
export declare type InterfacePlacement<TMaxLength extends number = typeof defaultInterfacePlacementMaxLength> = {
|
|
13
|
+
templateArea?: InterfaceGridTemplateArea<TMaxLength>;
|
|
14
|
+
customComponentsArea?: InterfaceGridCustomComponentsArea<TMaxLength>;
|
|
13
15
|
itemCustomArea?: InterfaceGridItemArea;
|
|
14
16
|
};
|
|
15
17
|
export declare const defaultInterfacePlacement: {
|
|
16
|
-
templateArea: Required<InterfaceGridTemplateArea
|
|
18
|
+
templateArea: Required<InterfaceGridTemplateArea<typeof defaultInterfacePlacementMaxLength>>;
|
|
17
19
|
};
|
|
18
|
-
export interface Placements {
|
|
20
|
+
export interface Placements<TInterfacePlacementLength extends number = typeof defaultInterfacePlacementMaxLength> {
|
|
19
21
|
playListPlacement: PlayListPlacement;
|
|
20
|
-
interfacePlacement: InterfacePlacement
|
|
22
|
+
interfacePlacement: InterfacePlacement<TInterfacePlacementLength>;
|
|
21
23
|
volumeSliderPlacement: VolumeSliderPlacement | undefined;
|
|
22
24
|
playerPlacement: PlayerPlacement | undefined;
|
|
23
25
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
|
-
import { RepeatType, PlayList, PlayListPlacement, PlayerPlacement, ActiveUI, ElementRefs, CustomIcons, AudioInitialState, InterfacePlacement, CoverImgsCss, VolumeSliderPlacement } from "./StateContext";
|
|
3
|
-
export declare type AudioContextAction = {
|
|
2
|
+
import { RepeatType, PlayList, PlayListPlacement, PlayerPlacement, ActiveUI, ElementRefs, CustomIcons, AudioInitialState, InterfacePlacement, CoverImgsCss, VolumeSliderPlacement, defaultInterfacePlacementMaxLength } from "./StateContext";
|
|
3
|
+
export declare type AudioContextAction<TInterfacePlacementLength extends number = typeof defaultInterfacePlacementMaxLength> = {
|
|
4
4
|
type: "NEXT_AUDIO";
|
|
5
5
|
} | {
|
|
6
6
|
type: "PREV_AUDIO";
|
|
@@ -42,7 +42,7 @@ export declare type AudioContextAction = {
|
|
|
42
42
|
type: "SET_PLACEMENTS";
|
|
43
43
|
playerPlacement?: PlayerPlacement;
|
|
44
44
|
playListPlacement?: PlayListPlacement;
|
|
45
|
-
interfacePlacement?: InterfacePlacement
|
|
45
|
+
interfacePlacement?: InterfacePlacement<TInterfacePlacementLength>;
|
|
46
46
|
volumeSliderPlacement?: VolumeSliderPlacement;
|
|
47
47
|
};
|
|
48
48
|
export declare type AudioPlayerDispatchContext = Dispatch<AudioContextAction>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
1
|
import { ActiveUI, PlayListPlacement, CustomIcons, PlayerPlacement, PlayList, AudioInitialState, InterfacePlacement, CoverImgsCss, VolumeSliderPlacement } from '../../AudioPlayer/Context';
|
|
3
|
-
export interface AudioPlayerProps {
|
|
2
|
+
export interface AudioPlayerProps<TInterfacePlacementLength extends number> {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
4
|
playList: PlayList;
|
|
5
5
|
audioInitialState?: AudioInitialState;
|
|
6
6
|
audioRef?: React.MutableRefObject<HTMLAudioElement>;
|
|
@@ -10,8 +10,8 @@ export interface AudioPlayerProps {
|
|
|
10
10
|
placement?: {
|
|
11
11
|
player?: PlayerPlacement;
|
|
12
12
|
playList?: PlayListPlacement;
|
|
13
|
-
interface?: InterfacePlacement
|
|
13
|
+
interface?: InterfacePlacement<TInterfacePlacementLength>;
|
|
14
14
|
volumeSlider?: VolumeSliderPlacement;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export declare const AudioPlayer:
|
|
17
|
+
export declare const AudioPlayer: <TInterfacePlacementLength extends number = 10>({ audioRef, children, ...restProps }: AudioPlayerProps<TInterfacePlacementLength>) => JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AudioPlayerProps } from ".";
|
|
2
|
-
export declare const usePropsStateEffect: ({ placement, activeUI, coverImgsCss, audioInitialState, playList, customIcons, }: AudioPlayerProps) => void;
|
|
2
|
+
export declare const usePropsStateEffect: <TInterfacePlacementLength extends number = 10>({ placement, activeUI, coverImgsCss, audioInitialState, playList, customIcons, }: Omit<AudioPlayerProps<TInterfacePlacementLength>, "children">) => void;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { SpectrumProviderProps } from '../Provider';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultInterfacePlacementMaxLength } from "./Context";
|
|
3
|
+
import { CustomComponent } from "./Interface/CustomComponent";
|
|
3
4
|
import { AudioPlayerProps } from "./Player";
|
|
4
|
-
export declare type RMAudioPlayerProps = AudioPlayerProps & SpectrumProviderProps;
|
|
5
|
-
|
|
5
|
+
export declare type RMAudioPlayerProps<TInterfacePlacementLength extends number = typeof defaultInterfacePlacementMaxLength> = AudioPlayerProps<TInterfacePlacementLength> & SpectrumProviderProps;
|
|
6
|
+
declare const AudioPlayerWithProviders: <TInterfacePlacementLength extends number>({ rootContainerProps, ...audioPlayProps }: RMAudioPlayerProps<TInterfacePlacementLength>) => JSX.Element;
|
|
7
|
+
declare type AudioPlayerComponent = typeof AudioPlayerWithProviders & {
|
|
8
|
+
CustomComponent: typeof CustomComponent;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: AudioPlayerComponent;
|
|
11
|
+
export default _default;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
import { FC } from "react";
|
|
1
|
+
import { PropsWithChildren, FC } from "react";
|
|
3
2
|
import { DrawerContext } from "./DrawerContext";
|
|
4
3
|
import { DrawerTrigger } from "./DrawerTrigger";
|
|
5
4
|
import { DrawerContent } from "./DrawerContent";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
import { FC } from "react";
|
|
1
|
+
import { PropsWithChildren, FC } from "react";
|
|
3
2
|
import { DropdownContext } from "./DropdownContext";
|
|
4
3
|
import { DropdownTrigger } from "./DropdownTrigger";
|
|
5
4
|
import { DropdownContent } from "./DropdownContent";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PropsWithChildren
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
2
|
import { AudioPlayerProps } from "../AudioPlayer/Player";
|
|
3
|
-
export declare const AudioPlayerProvider:
|
|
3
|
+
export declare const AudioPlayerProvider: <TInterfacePlacementLength extends number = 10>({ children, ...props }: PropsWithChildren<AudioPlayerProps<TInterfacePlacementLength>>) => JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActiveUI, InterfacePlacement } from '../components/AudioPlayer/Context';
|
|
2
|
-
export declare const useGridTemplate: (activeUI: ActiveUI, templateArea: InterfacePlacement["templateArea"] | undefined) => readonly [string[], string[]];
|
|
2
|
+
export declare const useGridTemplate: (activeUI: ActiveUI, templateArea: InterfacePlacement["templateArea"] | undefined, customComponentsArea?: InterfacePlacement["customComponentsArea"]) => readonly [string[], string[]];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default
|
|
1
|
+
import AudioPlayerWithProviders from "./components/AudioPlayer";
|
|
2
|
+
export default AudioPlayerWithProviders;
|
|
3
3
|
export * from "./components/AudioPlayer";
|
|
4
4
|
export * from "./components/AudioPlayer/Context";
|
|
5
5
|
export * from "./components/AudioPlayer/Player";
|