@iternio/react-native-auto-play 0.5.9 → 0.5.11

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.
@@ -1,67 +0,0 @@
1
- import type { ImageButton, TextButton } from '../types/Button';
2
- import type { AutoText } from '../types/Text';
3
- import { type NitroAction } from './NitroAction';
4
- import { type GridButton, type NitroGridButton } from './NitroGrid';
5
- import { type DefaultRow, type NitroSection, type RadioRow, type TextRow, type ToggleRow } from './NitroSection';
6
- /** @namespace iOS a whole button grid, same as GridTemplate's own grid. */
7
- export type OptionsPanelGridSection<T> = {
8
- type: 'grid';
9
- title?: string;
10
- buttons: Array<GridButton<T>>;
11
- };
12
- export type ChargingConnector = 'ccs1' | 'ccs2' | 'j1772' | 'chaDeMo' | 'mennekes' | 'gbtDC' | 'gbtAC' | 'nacsDC' | 'nacsAC';
13
- /** @namespace iOS one outlet (`CPChargingStationConnection`) on a charging station. */
14
- export type ChargerOutlet<T> = {
15
- connector: ChargingConnector;
16
- /** volts */
17
- voltage: number;
18
- /** converted to megawatts on the native side above 1000 kW */
19
- powerKw: number;
20
- onPress?: (template: T) => void;
21
- };
22
- /** @namespace iOS a charging station's outlets — a station commonly has several (e.g. CCS2 + Type 2). */
23
- export type OptionsPanelChargerSection<T> = {
24
- type: 'charger';
25
- title?: string;
26
- outlets: Array<ChargerOutlet<T>>;
27
- };
28
- /**
29
- * @namespace iOS a full list: default/toggle/text rows mixed freely, or a mutually-exclusive
30
- * radio group — the item array's own row types carry that distinction, not a section-level tag.
31
- */
32
- export type OptionsPanelListSection<T> = {
33
- type: 'list';
34
- title?: string;
35
- items: Array<DefaultRow<T> | ToggleRow<T> | TextRow> | Array<RadioRow<T>>;
36
- };
37
- /** one kind per section: list, grid, or charger outlet — CarPlay allows mixing kinds, but we don't need that yet. */
38
- export type OptionsPanelSection<T> = OptionsPanelListSection<T> | OptionsPanelGridSection<T> | OptionsPanelChargerSection<T>;
39
- export type OptionsPanelConfig<T> = {
40
- title?: AutoText;
41
- sections: Array<OptionsPanelSection<T>>;
42
- /** @namespace iOS one primary `TextButton` plus one optional icon-only `ImageButton` — nothing more is supported. */
43
- actions?: [TextButton<T>] | [TextButton<T>, ImageButton<T>];
44
- };
45
- export type NitroOptionsPanelGridSection = {
46
- title?: string;
47
- buttons: Array<NitroGridButton>;
48
- };
49
- export type NitroChargerOutlet = {
50
- connector: ChargingConnector;
51
- voltage: number;
52
- powerKw: number;
53
- onPress?: () => void;
54
- };
55
- export type NitroOptionsPanelChargerSection = {
56
- title?: string;
57
- outlets: Array<NitroChargerOutlet>;
58
- };
59
- export type NitroOptionsPanelSection = NitroSection | NitroOptionsPanelGridSection | NitroOptionsPanelChargerSection;
60
- export type NitroOptionsPanelConfig = {
61
- title?: AutoText;
62
- sections: Array<NitroOptionsPanelSection>;
63
- actions?: Array<NitroAction>;
64
- };
65
- export declare const NitroOptionsPanelUtil: {
66
- convert: <T>(template: T, config?: OptionsPanelConfig<T>) => NitroOptionsPanelConfig | undefined;
67
- };
@@ -1,48 +0,0 @@
1
- import { NitroActionUtil } from './NitroAction';
2
- import { NitroGridUtil } from './NitroGrid';
3
- import { NitroSectionUtil, } from './NitroSection';
4
- const convertSection = (template, section) => {
5
- if (section.type === 'grid') {
6
- return {
7
- title: section.title,
8
- buttons: NitroGridUtil.convert(template, section.buttons),
9
- };
10
- }
11
- if (section.type === 'charger') {
12
- return {
13
- title: section.title,
14
- outlets: section.outlets.map((outlet) => ({
15
- connector: outlet.connector,
16
- voltage: outlet.voltage,
17
- powerKw: outlet.powerKw,
18
- onPress: outlet.onPress ? () => outlet.onPress?.(template) : undefined,
19
- })),
20
- };
21
- }
22
- // items is all-radio or all-default/toggle/text, never mixed — translate into MultiSection's
23
- // default/radio shape to reuse NitroSectionUtil.convert's radio-validation logic as-is.
24
- const isRadioGroup = section.items.length > 0 && section.items.every((item) => item.type === 'radio');
25
- const multiSection = isRadioGroup
26
- ? { type: 'radio', title: section.title ?? '', items: section.items }
27
- : {
28
- type: 'default',
29
- title: section.title ?? '',
30
- items: section.items,
31
- };
32
- const [nitroSection] = NitroSectionUtil.convert(template, [multiSection]) ?? [];
33
- if (nitroSection == null) {
34
- throw new Error('converting sections failed');
35
- }
36
- return nitroSection;
37
- };
38
- const convert = (template, config) => {
39
- if (config == null) {
40
- return undefined;
41
- }
42
- return {
43
- title: config.title,
44
- sections: config.sections.map((section) => convertSection(template, section)),
45
- actions: NitroActionUtil.convert(template, config.actions),
46
- };
47
- };
48
- export const NitroOptionsPanelUtil = { convert };