@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1110044191 → 16.0.0-alpha.1110245265
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/Components/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
- package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
- package/Components/AudioPlayer/tv/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -1
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +35 -6
- package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +163 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +314 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +395 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +763 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +653 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +874 -0
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +89 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +11 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +199 -0
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +383 -42
- package/Components/ModalComponent/Button/index.tsx +5 -3
- package/Components/ModalComponent/Header/index.tsx +20 -7
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
- package/Components/ModalComponent/SortableList.tsx +142 -0
- package/Components/ModalComponent/SortableList.web.tsx +102 -0
- package/Components/ModalComponent/TextInputContent.tsx +100 -0
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +238 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +120 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +11 -0
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +66 -0
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
- package/Components/ModalComponent/presets/index.ts +27 -0
- package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
- package/Components/ModalComponent/presets/standardCell.tsx +41 -0
- package/Components/ModalComponent/presets/types.ts +35 -0
- package/Components/ModalComponent/showTextInput.ts +43 -0
- package/Components/ModalComponent/utils.ts +76 -20
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +11 -7
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +1 -1
- package/package.json +6 -5
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@testing-library/react-native";
|
|
3
3
|
|
|
4
|
+
let mockContent = { title: null, summary: null };
|
|
5
|
+
|
|
6
|
+
// Read lazily inside the factory: `jest.mock` is hoisted above the `let` above,
|
|
7
|
+
// so capturing the value eagerly would freeze it at `undefined`.
|
|
8
|
+
jest.mock(
|
|
9
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerContent",
|
|
10
|
+
() => ({ usePlayerContent: () => mockContent })
|
|
11
|
+
);
|
|
12
|
+
|
|
4
13
|
import { AudioPlayerTV } from "..";
|
|
5
14
|
|
|
6
15
|
jest.mock("@applicaster/zapp-react-native-utils/audioPlayerUtils", () => ({
|
|
@@ -51,7 +60,17 @@ const audioPlayerProps = {
|
|
|
51
60
|
|
|
52
61
|
describe("<AudioPlayerTV />", () => {
|
|
53
62
|
it("renders correctly", () => {
|
|
63
|
+
// AudioPlayerTV no longer resolves its own title/summary from
|
|
64
|
+
// audio_item - it reads them from the player manager's content channel.
|
|
65
|
+
// Publishing the same values `audio_item.title`/`.summary` used to resolve
|
|
66
|
+
// to keeps this snapshot byte-for-byte identical to before that change.
|
|
67
|
+
mockContent = {
|
|
68
|
+
title: audioPlayerProps.audio_item.title,
|
|
69
|
+
summary: audioPlayerProps.audio_item.summary,
|
|
70
|
+
};
|
|
71
|
+
|
|
54
72
|
const { toJSON } = render(<AudioPlayerTV {...audioPlayerProps} />);
|
|
73
|
+
|
|
55
74
|
expect(toJSON()).toMatchSnapshot();
|
|
56
75
|
});
|
|
57
76
|
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
import { AudioPlayerTV } from "..";
|
|
5
|
+
|
|
6
|
+
jest.mock("@applicaster/zapp-react-native-utils/audioPlayerUtils", () => ({
|
|
7
|
+
useArtworkImage: jest.fn(() => "artwork_url"),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
let mockContent: {
|
|
11
|
+
title: Option<string | number>;
|
|
12
|
+
summary: Option<string | number>;
|
|
13
|
+
} = { title: null, summary: null };
|
|
14
|
+
|
|
15
|
+
// Read lazily inside the factory: `jest.mock` is hoisted above the `let`
|
|
16
|
+
// above, so capturing the value eagerly would freeze it at `undefined`.
|
|
17
|
+
jest.mock(
|
|
18
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerContent",
|
|
19
|
+
() => ({ usePlayerContent: () => mockContent })
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const baseAudioItem = {
|
|
23
|
+
title: "tittle",
|
|
24
|
+
summary: "Summary",
|
|
25
|
+
content: {
|
|
26
|
+
src: "https://example.com",
|
|
27
|
+
},
|
|
28
|
+
media_group: [
|
|
29
|
+
{
|
|
30
|
+
type: "audio",
|
|
31
|
+
media_item: [
|
|
32
|
+
{
|
|
33
|
+
type: "audio",
|
|
34
|
+
src: "https://example.com",
|
|
35
|
+
key: "base_code",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
extensions: {
|
|
41
|
+
audio_player_artwork_aspect_ratio: "1:1",
|
|
42
|
+
audio_player_background_image: "https://example.com",
|
|
43
|
+
audio_player_background_color: "black",
|
|
44
|
+
audio_player_channel_icon: "https://example.com",
|
|
45
|
+
audio_player_title_color: "white",
|
|
46
|
+
audio_player_summary_color: "white",
|
|
47
|
+
audio_player_rtl: true,
|
|
48
|
+
start_time: "10:10",
|
|
49
|
+
end_time: "11:11",
|
|
50
|
+
episode_name: "Episode Custom Title",
|
|
51
|
+
episode_summary: "Episode Custom Summary",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const basePluginConfiguration = {
|
|
56
|
+
audio_player_background_color: "black",
|
|
57
|
+
audio_player_title_color: "white",
|
|
58
|
+
audio_player_summary_color: "white",
|
|
59
|
+
audio_player_rtl: true,
|
|
60
|
+
audio_player_background_image: "https://example.com",
|
|
61
|
+
audio_player_artwork_aspect_ratio: "1:1",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function renderAudioPlayer(
|
|
65
|
+
plugin_configuration,
|
|
66
|
+
content: {
|
|
67
|
+
title?: Option<string | number>;
|
|
68
|
+
summary?: Option<string | number>;
|
|
69
|
+
} = {}
|
|
70
|
+
) {
|
|
71
|
+
mockContent = {
|
|
72
|
+
title: content.title ?? null,
|
|
73
|
+
summary: content.summary ?? null,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return render(
|
|
77
|
+
<AudioPlayerTV
|
|
78
|
+
audio_item={baseAudioItem}
|
|
79
|
+
plugin_configuration={plugin_configuration}
|
|
80
|
+
style={{}}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
describe("<AudioPlayerTV /> player content", () => {
|
|
86
|
+
it("renders the title and summary published by the player manager", () => {
|
|
87
|
+
const { getByText } = renderAudioPlayer(basePluginConfiguration, {
|
|
88
|
+
title: "Episode Custom Title",
|
|
89
|
+
summary: "Episode Custom Summary",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(getByText("Episode Custom Title")).toBeTruthy();
|
|
93
|
+
expect(getByText("Episode Custom Summary")).toBeTruthy();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("renders nothing for title/summary when the player published neither", () => {
|
|
97
|
+
const { queryByText } = renderAudioPlayer(basePluginConfiguration);
|
|
98
|
+
|
|
99
|
+
expect(queryByText("tittle")).toBeNull();
|
|
100
|
+
expect(queryByText("Summary")).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("renders blank rather than crashing when no player is active", () => {
|
|
104
|
+
// `usePlayerContent` returns `{ title: null, summary: null }` when there is
|
|
105
|
+
// no player. A regression here means AudioPlayerTV crashes instead of
|
|
106
|
+
// rendering blank.
|
|
107
|
+
mockContent = { title: null, summary: null };
|
|
108
|
+
|
|
109
|
+
const { queryByText } = render(
|
|
110
|
+
<AudioPlayerTV
|
|
111
|
+
audio_item={baseAudioItem}
|
|
112
|
+
plugin_configuration={basePluginConfiguration}
|
|
113
|
+
style={{}}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(queryByText("tittle")).toBeNull();
|
|
118
|
+
expect(queryByText("Summary")).toBeNull();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -3,6 +3,8 @@ import React, { useCallback, useMemo } from "react";
|
|
|
3
3
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
4
|
import { useArtworkImage } from "@applicaster/zapp-react-native-utils/audioPlayerUtils";
|
|
5
5
|
|
|
6
|
+
import { usePlayerContent } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerContent";
|
|
7
|
+
|
|
6
8
|
import { AudioPlayerTVLayout } from "./Layout";
|
|
7
9
|
|
|
8
10
|
import { Channel } from "./Channel";
|
|
@@ -15,10 +17,12 @@ import { Props } from "../types";
|
|
|
15
17
|
|
|
16
18
|
export function AudioPlayerTV(props: Props) {
|
|
17
19
|
const { audio_item, plugin_configuration, style = {} } = props;
|
|
18
|
-
const { extensions
|
|
20
|
+
const { extensions } = audio_item;
|
|
19
21
|
|
|
20
22
|
const artwork = useArtworkImage(audio_item);
|
|
21
23
|
|
|
24
|
+
const { title, summary } = usePlayerContent();
|
|
25
|
+
|
|
22
26
|
const getProp = useCallback(
|
|
23
27
|
getPropertyFromEntryOrConfig({
|
|
24
28
|
entry: audio_item,
|
|
@@ -56,6 +56,7 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
56
56
|
props: Props
|
|
57
57
|
) {
|
|
58
58
|
const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
|
|
59
|
+
|
|
59
60
|
const actionContext = useActions(action?.identifier);
|
|
60
61
|
|
|
61
62
|
// TODO: add subscription API for action availability
|
|
@@ -82,7 +83,7 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
82
83
|
setActionState(state);
|
|
83
84
|
},
|
|
84
85
|
});
|
|
85
|
-
}, [actionState, actionContext
|
|
86
|
+
}, [actionState, actionContext, item]);
|
|
86
87
|
|
|
87
88
|
useEffect(() => {
|
|
88
89
|
if (typeof actionContext?.addListener === "function") {
|
package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts
CHANGED
|
@@ -6,28 +6,54 @@ import {
|
|
|
6
6
|
describe("ActionButtonsCore placement", () => {
|
|
7
7
|
const buttons = { type: "View", name: "buttons" };
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
{ name: "
|
|
11
|
-
{ name: "
|
|
12
|
-
{ name: "
|
|
9
|
+
const slots = [
|
|
10
|
+
{ name: "text_label_1", element: { type: "View", id: "label_1" } },
|
|
11
|
+
{ name: "text_label_2", element: { type: "View", id: "label_2" } },
|
|
12
|
+
{ name: "text_label_3", element: { type: "View", id: "label_3" } },
|
|
13
13
|
];
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
{ name: "below_label_1" },
|
|
17
|
-
{ name: "below_label_2" },
|
|
18
|
-
{ name: "below_label_3" },
|
|
19
|
-
];
|
|
15
|
+
const labels = slots.map((slot) => slot.element);
|
|
20
16
|
|
|
21
17
|
it("inserts buttons after the matching label", () => {
|
|
22
18
|
expect(
|
|
23
|
-
insertBetweenLabels({ position: "
|
|
24
|
-
).toEqual([
|
|
19
|
+
insertBetweenLabels({ position: "below_text_label_2" }, buttons, slots)
|
|
20
|
+
).toEqual([labels[0], labels[1], buttons, labels[2]]);
|
|
25
21
|
});
|
|
26
22
|
|
|
27
23
|
it("inserts buttons before the matching label", () => {
|
|
28
24
|
expect(
|
|
29
|
-
insertBetweenLabels({ position: "
|
|
30
|
-
).toEqual([
|
|
25
|
+
insertBetweenLabels({ position: "above_text_label_2" }, buttons, slots)
|
|
26
|
+
).toEqual([labels[0], buttons, labels[1], labels[2]]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("inserts buttons after the matching label on a plain name match", () => {
|
|
30
|
+
expect(
|
|
31
|
+
insertBetweenLabels({ position: "text_label_2" }, buttons, slots)
|
|
32
|
+
).toEqual([labels[0], labels[1], buttons, labels[2]]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("keeps the slot when its label is empty (null element)", () => {
|
|
36
|
+
const slotsWithEmpty = [
|
|
37
|
+
{ name: "text_label_1", element: { id: "label_1" } },
|
|
38
|
+
{ name: "text_label_2", element: null },
|
|
39
|
+
{ name: "text_label_3", element: { id: "label_3" } },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
insertBetweenLabels(
|
|
44
|
+
{ position: "above_text_label_2" },
|
|
45
|
+
buttons,
|
|
46
|
+
slotsWithEmpty
|
|
47
|
+
)
|
|
48
|
+
).toEqual([{ id: "label_1" }, buttons, { id: "label_3" }]);
|
|
49
|
+
|
|
50
|
+
expect(
|
|
51
|
+
insertBetweenLabels(
|
|
52
|
+
{ position: "below_text_label_2" },
|
|
53
|
+
buttons,
|
|
54
|
+
slotsWithEmpty
|
|
55
|
+
)
|
|
56
|
+
).toEqual([{ id: "label_1" }, buttons, { id: "label_3" }]);
|
|
31
57
|
});
|
|
32
58
|
|
|
33
59
|
it("prepends buttons only when on_top is allowed", () => {
|
|
@@ -35,17 +61,17 @@ describe("ActionButtonsCore placement", () => {
|
|
|
35
61
|
insertBetweenLabels(
|
|
36
62
|
{ position: "on_top", allowOnTop: true },
|
|
37
63
|
buttons,
|
|
38
|
-
|
|
64
|
+
slots
|
|
39
65
|
)
|
|
40
|
-
).toEqual([buttons, ...
|
|
66
|
+
).toEqual([buttons, ...labels]);
|
|
41
67
|
|
|
42
68
|
expect(
|
|
43
69
|
insertBetweenLabels(
|
|
44
70
|
{ position: "on_top", allowOnTop: false },
|
|
45
71
|
buttons,
|
|
46
|
-
|
|
72
|
+
slots
|
|
47
73
|
)
|
|
48
|
-
).toEqual(
|
|
74
|
+
).toEqual(labels);
|
|
49
75
|
});
|
|
50
76
|
|
|
51
77
|
it("appends buttons when appendWhenMissing is enabled", () => {
|
|
@@ -53,9 +79,9 @@ describe("ActionButtonsCore placement", () => {
|
|
|
53
79
|
insertBetweenLabels(
|
|
54
80
|
{ position: "unknown", appendWhenMissing: true },
|
|
55
81
|
buttons,
|
|
56
|
-
|
|
82
|
+
slots
|
|
57
83
|
)
|
|
58
|
-
).toEqual([...
|
|
84
|
+
).toEqual([...labels, buttons]);
|
|
59
85
|
});
|
|
60
86
|
|
|
61
87
|
it("returns labels unchanged when appendWhenMissing is disabled", () => {
|
|
@@ -63,9 +89,9 @@ describe("ActionButtonsCore placement", () => {
|
|
|
63
89
|
insertBetweenLabels(
|
|
64
90
|
{ position: "unknown", appendWhenMissing: false },
|
|
65
91
|
buttons,
|
|
66
|
-
|
|
92
|
+
slots
|
|
67
93
|
)
|
|
68
|
-
).toEqual(
|
|
94
|
+
).toEqual(labels);
|
|
69
95
|
});
|
|
70
96
|
|
|
71
97
|
const labelContainers = [
|
|
@@ -17,6 +17,11 @@ type InsertOptions = {
|
|
|
17
17
|
appendWhenMissing?: boolean;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
type Slot = {
|
|
21
|
+
name: string;
|
|
22
|
+
element?: unknown;
|
|
23
|
+
};
|
|
24
|
+
|
|
20
25
|
const hasLabelName = (value: unknown): value is Label =>
|
|
21
26
|
!!value &&
|
|
22
27
|
typeof value === "object" &&
|
|
@@ -100,8 +105,14 @@ const containsNestedLabel = (
|
|
|
100
105
|
export const insertBetweenLabels = (
|
|
101
106
|
{ position, allowOnTop = false, appendWhenMissing = false }: InsertOptions,
|
|
102
107
|
buttons: unknown,
|
|
103
|
-
|
|
108
|
+
slots: Slot[] = []
|
|
104
109
|
) => {
|
|
110
|
+
// Slots are defined by the canonical label list, so an empty (null) label
|
|
111
|
+
// still keeps its position — buttons placed above/below it survive.
|
|
112
|
+
const labels = slots
|
|
113
|
+
.map((slot) => slot.element)
|
|
114
|
+
.filter((element) => element != null);
|
|
115
|
+
|
|
105
116
|
if (buttons == null) {
|
|
106
117
|
return labels;
|
|
107
118
|
}
|
|
@@ -110,14 +121,31 @@ export const insertBetweenLabels = (
|
|
|
110
121
|
return [buttons, ...labels];
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
|
|
114
|
-
const
|
|
124
|
+
let inserted = false;
|
|
125
|
+
const result: unknown[] = [];
|
|
126
|
+
|
|
127
|
+
for (const { name, element } of slots) {
|
|
128
|
+
if (position === `above_${name}`) {
|
|
129
|
+
result.push(buttons);
|
|
130
|
+
inserted = true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (element != null) {
|
|
134
|
+
result.push(element);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Insert after on `below_*` or a plain label-name match.
|
|
138
|
+
if (position === `below_${name}` || position === name) {
|
|
139
|
+
result.push(buttons);
|
|
140
|
+
inserted = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
115
143
|
|
|
116
|
-
if (!inserted
|
|
117
|
-
return [...labels, buttons];
|
|
144
|
+
if (!inserted) {
|
|
145
|
+
return appendWhenMissing ? [...labels, buttons] : labels;
|
|
118
146
|
}
|
|
119
147
|
|
|
120
|
-
return
|
|
148
|
+
return result;
|
|
121
149
|
};
|
|
122
150
|
|
|
123
151
|
export const insertBetweenLabelContainers = (
|