react-modern-audio-player 1.3.0 → 1.4.0-rc.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.
- package/README.md +64 -2
- package/dist/index.es.js +98 -63
- 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,35 +7868,38 @@ 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, col] = 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
7900
|
row: Number(row.split("row")[1]),
|
|
7889
7901
|
col: Number(col)
|
|
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;
|
|
@@ -7902,7 +7907,7 @@ const useGridTemplate = (activeUI, templateArea) => {
|
|
|
7902
7907
|
var _a, _b, _c;
|
|
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;
|
|
@@ -7955,47 +7960,43 @@ const useGridTemplate = (activeUI, templateArea) => {
|
|
|
7955
7960
|
[]
|
|
7956
7961
|
);
|
|
7957
7962
|
const [curActiveUI, setCurActiveUI] = useState(activeUI);
|
|
7958
|
-
const [
|
|
7959
|
-
|
|
7960
|
-
|
|
7963
|
+
const [curPlacementArea, setCurPlacementArea] = useState({
|
|
7964
|
+
templateArea,
|
|
7965
|
+
customComponentsArea
|
|
7966
|
+
});
|
|
7967
|
+
const [curPlacementAreaValues, setCurPlacementAreaValues] = useState();
|
|
7968
|
+
if (!curPlacementAreaValues) {
|
|
7961
7969
|
const { gridAreas: gridAreas2, gridColumns: gridColumns2 } = generateGridTemplateValues(
|
|
7962
7970
|
curActiveUI,
|
|
7963
|
-
|
|
7971
|
+
curPlacementArea.templateArea,
|
|
7972
|
+
curPlacementArea.customComponentsArea
|
|
7964
7973
|
);
|
|
7965
|
-
|
|
7974
|
+
setCurPlacementAreaValues({ gridAreas: gridAreas2, gridColumns: gridColumns2 });
|
|
7966
7975
|
return [gridAreas2, gridColumns2];
|
|
7967
7976
|
}
|
|
7968
|
-
if (curActiveUI !== activeUI ||
|
|
7977
|
+
if (curActiveUI !== activeUI || curPlacementArea.templateArea !== templateArea || curPlacementArea.customComponentsArea !== customComponentsArea) {
|
|
7969
7978
|
setCurActiveUI(activeUI);
|
|
7970
|
-
|
|
7979
|
+
setCurPlacementArea({ templateArea, customComponentsArea });
|
|
7971
7980
|
const { gridAreas: gridAreas2, gridColumns: gridColumns2 } = generateGridTemplateValues(
|
|
7972
7981
|
activeUI,
|
|
7973
|
-
templateArea
|
|
7982
|
+
templateArea,
|
|
7983
|
+
customComponentsArea
|
|
7974
7984
|
);
|
|
7975
|
-
|
|
7985
|
+
setCurPlacementAreaValues({ gridAreas: gridAreas2, gridColumns: gridColumns2 });
|
|
7976
7986
|
}
|
|
7977
|
-
const { gridAreas, gridColumns } =
|
|
7987
|
+
const { gridAreas, gridColumns } = curPlacementAreaValues;
|
|
7978
7988
|
return [gridAreas, gridColumns];
|
|
7979
7989
|
};
|
|
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 = () => {
|
|
7990
|
+
const Interface = ({
|
|
7991
|
+
children
|
|
7992
|
+
}) => {
|
|
7993
7993
|
const {
|
|
7994
7994
|
interfacePlacement,
|
|
7995
7995
|
activeUI,
|
|
7996
7996
|
playListPlacement
|
|
7997
7997
|
} = useNonNullableContext(audioPlayerStateContext);
|
|
7998
|
-
const
|
|
7998
|
+
const CustomComponents = $k7QOs$react.Children.toArray(children);
|
|
7999
|
+
const [gridAreas, gridColumns] = useGridTemplate(activeUI, interfacePlacement == null ? void 0 : interfacePlacement.templateArea, interfacePlacement == null ? void 0 : interfacePlacement.customComponentsArea);
|
|
7999
8000
|
return /* @__PURE__ */ jsxs(InterfaceContainer, {
|
|
8000
8001
|
className: "interface-container",
|
|
8001
8002
|
children: [playListPlacement === "top" && /* @__PURE__ */ jsx("div", {
|
|
@@ -8007,12 +8008,24 @@ const Interface = () => {
|
|
|
8007
8008
|
minHeight: "30px",
|
|
8008
8009
|
columns: gridColumns,
|
|
8009
8010
|
UNSAFE_className: "interface-grid",
|
|
8010
|
-
children: [/* @__PURE__ */ jsx(Information, {}), /* @__PURE__ */ jsx(Controller, {})]
|
|
8011
|
+
children: [/* @__PURE__ */ jsx(Information, {}), /* @__PURE__ */ jsx(Controller, {}), CustomComponents]
|
|
8011
8012
|
}), playListPlacement === "bottom" && /* @__PURE__ */ jsx("div", {
|
|
8012
8013
|
className: "sortable-play-list"
|
|
8013
8014
|
})]
|
|
8014
8015
|
});
|
|
8015
8016
|
};
|
|
8017
|
+
const InterfaceContainer = styled.div`
|
|
8018
|
+
.interface-grid {
|
|
8019
|
+
background: var(--rm-audio-player-interface-container);
|
|
8020
|
+
}
|
|
8021
|
+
.interface-grid {
|
|
8022
|
+
padding: 0.5rem 10px;
|
|
8023
|
+
}
|
|
8024
|
+
.sortable-play-list {
|
|
8025
|
+
background: var(--rm-audio-player-sortable-list);
|
|
8026
|
+
box-shadow: -5px 2px 4px 0px rgb(0 0 0 / 4%) inset;
|
|
8027
|
+
}
|
|
8028
|
+
`;
|
|
8016
8029
|
const usePropsStateEffect = ({
|
|
8017
8030
|
placement = {},
|
|
8018
8031
|
activeUI,
|
|
@@ -8074,6 +8087,7 @@ const usePropsStateEffect = ({
|
|
|
8074
8087
|
};
|
|
8075
8088
|
const AudioPlayer = ({
|
|
8076
8089
|
audioRef,
|
|
8090
|
+
children,
|
|
8077
8091
|
...restProps
|
|
8078
8092
|
}) => {
|
|
8079
8093
|
usePropsStateEffect(restProps);
|
|
@@ -8082,10 +8096,12 @@ const AudioPlayer = ({
|
|
|
8082
8096
|
UNSAFE_className: "rm-audio-player-container",
|
|
8083
8097
|
children: [/* @__PURE__ */ jsx(Audio, {
|
|
8084
8098
|
audioRef
|
|
8085
|
-
}), /* @__PURE__ */ jsx(Interface, {
|
|
8099
|
+
}), /* @__PURE__ */ jsx(Interface, {
|
|
8100
|
+
children
|
|
8101
|
+
})]
|
|
8086
8102
|
});
|
|
8087
8103
|
};
|
|
8088
|
-
const
|
|
8104
|
+
const AudioPlayerWithProviders = ({
|
|
8089
8105
|
rootContainerProps,
|
|
8090
8106
|
...audioPlayProps
|
|
8091
8107
|
}) => {
|
|
@@ -8099,4 +8115,23 @@ const AudioPlayerWithProvider = ({
|
|
|
8099
8115
|
})
|
|
8100
8116
|
});
|
|
8101
8117
|
};
|
|
8102
|
-
|
|
8118
|
+
const CustomComponent = ({
|
|
8119
|
+
children,
|
|
8120
|
+
id,
|
|
8121
|
+
...gridItemProps
|
|
8122
|
+
}) => {
|
|
8123
|
+
var _a;
|
|
8124
|
+
const audioPlayerState = useNonNullableContext(audioPlayerStateContext);
|
|
8125
|
+
const placement = audioPlayerState.interfacePlacement;
|
|
8126
|
+
const gridArea = (_a = placement == null ? void 0 : placement.customComponentsArea) == null ? void 0 : _a[id];
|
|
8127
|
+
return /* @__PURE__ */ jsx(Grid.Item, {
|
|
8128
|
+
UNSAFE_className: "custom_component",
|
|
8129
|
+
gridArea,
|
|
8130
|
+
...gridItemProps,
|
|
8131
|
+
children: $k7QOs$react.cloneElement(children, {
|
|
8132
|
+
audioPlayerState
|
|
8133
|
+
})
|
|
8134
|
+
});
|
|
8135
|
+
};
|
|
8136
|
+
AudioPlayerWithProviders.CustomComponent = CustomComponent;
|
|
8137
|
+
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";
|