Skip to content

Commit affbe5b

Browse files
committed
wip: first draft
1 parent 7c3b7e0 commit affbe5b

File tree

1 file changed

+45
-18
lines changed
  • packages/companion-module-base/src/module-api

1 file changed

+45
-18
lines changed

packages/companion-module-base/src/module-api/preset.ts

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,47 @@ import type { CompanionButtonStyleProps } from './style.js'
44
import type { JsonValue } from '../common/json-value.js'
55

66
// Future: Additional types will be added, as part of the graphics overhaul
7-
export type CompanionPresetDefinition = CompanionSimplePresetDefinition // | CompanionSimplePresetMatrix
7+
export type CompanionPresetDefinition = CompanionSimplePresetDefinition
88

9-
// nocommit - is this needed?
10-
// /**
11-
// * The definition of a text preset
12-
// */
13-
// export interface CompanionTextPresetDefinition {
14-
// /** The type of this preset */
15-
// type: 'text'
16-
// /** The category of this preset, for grouping */
17-
// category: string
18-
// /** The name of this preset */
19-
// name: string
20-
// /** The text to display */
21-
// text: string
22-
// }
9+
export type CompanionPresetGroup = CompanionPresetGroupCustom // | CompanionSimplePresetMatrix
2310

24-
export interface CompanionPresetDefinitionBase<TType> {
11+
export interface CompanionPresetGroupBase<TType extends string> {
12+
/**
13+
* Unique identifier for the preset
14+
* This should be stable across updates to the presets
15+
*/
16+
id: string
17+
18+
/**
19+
* The type of the preset group
20+
*/
21+
type: TType
22+
23+
/**
24+
* A name for this preset group
25+
*/
26+
name: string
27+
28+
/**
29+
* A description of the preset group
30+
*/
31+
description?: string
32+
33+
/**
34+
* Tags for the group
35+
* This allows for the UI to group and filter in different ways
36+
*/
37+
tags?: string[]
38+
}
39+
40+
export interface CompanionPresetGroupCustom extends CompanionPresetGroupBase<'custom'> {
41+
/**
42+
* The presets which are part of this group
43+
*/
44+
presets: CompanionPresetDefinition[]
45+
}
46+
47+
export interface CompanionPresetDefinitionBase<TType extends string> {
2548
/**
2649
* Unique identifier for the preset
2750
* This should be stable across updates to the presets
@@ -71,7 +94,8 @@ export interface CompanionSimplePresetDefinition extends CompanionPresetDefiniti
7194
// * A preset which generates a series of buttons from a matrix of values
7295
// * Tip: This allows you to avoid generating repetetive presets which vary just by a few simple values
7396
// */
74-
// export interface CompanionSimplePresetMatrix extends CompanionSimplePresetDefinition {
97+
// export interface CompanionPresetGroupMatrix {
98+
// definition: CompanionPresetDefinition
7599
// /**
76100
// * The matrix of values to generate
77101
// * This will inject values into the local variables you have defined
@@ -123,7 +147,10 @@ export interface CompanionPresetSection {
123147
*/
124148
description?: string
125149

126-
presets: CompanionPresetDefinition[]
150+
/**
151+
* The definitions of presets or groups in this category
152+
*/
153+
definitions: CompanionPresetGroup[] | CompanionPresetDefinition[]
127154

128155
/**
129156
* Tags for the category

0 commit comments

Comments
 (0)