@stina/extension-api 1.16.0 → 1.18.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.
@@ -1,3 +1,5 @@
1
+ import type { LocalizedString } from './types.localization.js'
2
+
1
3
  // =============================================================================
2
4
  // Icon Names
3
5
  // =============================================================================
@@ -240,15 +242,15 @@ export interface ExtensionPanelDefinition {
240
242
  export interface HeaderProps extends ExtensionComponentData {
241
243
  component: 'Header'
242
244
  level: number
243
- title: string
244
- description?: string | string[]
245
+ title: LocalizedString
246
+ description?: LocalizedString | LocalizedString[]
245
247
  icon?: HugeIconName
246
248
  }
247
249
 
248
250
  /** The extension API properties for the Label component. */
249
251
  export interface LabelProps extends ExtensionComponentData {
250
252
  component: 'Label'
251
- text: string
253
+ text: LocalizedString
252
254
  }
253
255
 
254
256
  /**
@@ -267,17 +269,17 @@ export interface ClockProps extends ExtensionComponentData {
267
269
  /** The extension API properties for the paragraph component. */
268
270
  export interface ParagraphProps extends ExtensionComponentData {
269
271
  component: 'Paragraph'
270
- text: string
272
+ text: LocalizedString
271
273
  }
272
274
 
273
275
  /** The extension API properties for the Button component. */
274
276
  export interface ButtonProps extends ExtensionComponentData {
275
277
  component: 'Button'
276
- text: string
278
+ text: LocalizedString
277
279
  /** Visual style. Defaults to "normal". */
278
280
  type?: 'normal' | 'primary' | 'danger' | 'accent'
279
281
  /** Optional tooltip shown on hover. */
280
- title?: string
282
+ title?: LocalizedString
281
283
  disabled?: boolean
282
284
  onClickAction: ExtensionActionRef
283
285
  }
@@ -285,8 +287,8 @@ export interface ButtonProps extends ExtensionComponentData {
285
287
  /** The extension API properties for the TextInput component. */
286
288
  export interface TextInputProps extends ExtensionComponentData {
287
289
  component: 'TextInput'
288
- label: string
289
- placeholder?: string
290
+ label: LocalizedString
291
+ placeholder?: LocalizedString
290
292
  value?: string
291
293
  onChangeAction?: ExtensionActionRef
292
294
  }
@@ -294,8 +296,8 @@ export interface TextInputProps extends ExtensionComponentData {
294
296
  /** The extension API properties for the PasswordInput component. */
295
297
  export interface PasswordInputProps extends ExtensionComponentData {
296
298
  component: 'PasswordInput'
297
- label: string
298
- placeholder?: string
299
+ label: LocalizedString
300
+ placeholder?: LocalizedString
299
301
  value?: string
300
302
  onChangeAction?: ExtensionActionRef
301
303
  }
@@ -303,8 +305,8 @@ export interface PasswordInputProps extends ExtensionComponentData {
303
305
  /** The extension API properties for the NumberInput component. */
304
306
  export interface NumberInputProps extends ExtensionComponentData {
305
307
  component: 'NumberInput'
306
- label: string
307
- placeholder?: string
308
+ label: LocalizedString
309
+ placeholder?: LocalizedString
308
310
  value?: string | number
309
311
  /** Optional minimum value. */
310
312
  min?: number
@@ -318,8 +320,8 @@ export interface NumberInputProps extends ExtensionComponentData {
318
320
  /** The extension API properties for the TextArea component. */
319
321
  export interface TextAreaProps extends ExtensionComponentData {
320
322
  component: 'TextArea'
321
- label: string
322
- placeholder?: string
323
+ label: LocalizedString
324
+ placeholder?: LocalizedString
323
325
  value?: string
324
326
  /** Number of visible text rows. Defaults to 4. */
325
327
  rows?: number
@@ -329,7 +331,7 @@ export interface TextAreaProps extends ExtensionComponentData {
329
331
  /** The extension API properties for the DateTimeInput component. */
330
332
  export interface DateTimeInputProps extends ExtensionComponentData {
331
333
  component: 'DateTimeInput'
332
- label: string
334
+ label: LocalizedString
333
335
  value?: string
334
336
  onChangeAction?: ExtensionActionRef
335
337
  }
@@ -337,8 +339,8 @@ export interface DateTimeInputProps extends ExtensionComponentData {
337
339
  /** The extension API properties for the Select component. */
338
340
  export interface SelectProps extends ExtensionComponentData {
339
341
  component: 'Select'
340
- label: string
341
- options: Array<{ label: string; value: string }>
342
+ label: LocalizedString
343
+ options: Array<{ label: LocalizedString; value: string }>
342
344
  selectedValue?: string
343
345
  onChangeAction?: ExtensionActionRef
344
346
  }
@@ -346,7 +348,7 @@ export interface SelectProps extends ExtensionComponentData {
346
348
  /** The extension API properties for the IconPicker component. */
347
349
  export interface IconPickerProps extends ExtensionComponentData {
348
350
  component: 'IconPicker'
349
- label?: string
351
+ label?: LocalizedString
350
352
  value?: string
351
353
  onChangeAction?: ExtensionActionRef
352
354
  }
@@ -382,7 +384,7 @@ export interface DividerProps extends ExtensionComponentData {
382
384
  export interface IconProps extends ExtensionComponentData {
383
385
  component: 'Icon'
384
386
  name: HugeIconName
385
- title?: string
387
+ title?: LocalizedString
386
388
  }
387
389
 
388
390
  /** Button type for IconButton. */
@@ -392,7 +394,7 @@ export type IconButtonType = 'normal' | 'primary' | 'danger' | 'accent'
392
394
  export interface IconButtonProps extends ExtensionComponentData {
393
395
  component: 'IconButton'
394
396
  icon: HugeIconName
395
- tooltip: string
397
+ tooltip: LocalizedString
396
398
  active?: boolean
397
399
  disabled?: boolean
398
400
  type?: IconButtonType
@@ -402,7 +404,7 @@ export interface IconButtonProps extends ExtensionComponentData {
402
404
  /** Action button definition for Panel component. */
403
405
  export interface PanelAction {
404
406
  icon: HugeIconName
405
- tooltip: string
407
+ tooltip: LocalizedString
406
408
  action: ExtensionActionRef
407
409
  type?: IconButtonType
408
410
  }
@@ -410,8 +412,8 @@ export interface PanelAction {
410
412
  /** The extension API properties for the Panel component. */
411
413
  export interface PanelProps extends ExtensionComponentData {
412
414
  component: 'Panel'
413
- title: string
414
- description?: string | string[]
415
+ title: LocalizedString
416
+ description?: LocalizedString | LocalizedString[]
415
417
  icon?: HugeIconName
416
418
  actions?: PanelAction[]
417
419
  content?: ExtensionComponentData
@@ -420,8 +422,8 @@ export interface PanelProps extends ExtensionComponentData {
420
422
  /** The extension API properties for the Toggle component. */
421
423
  export interface ToggleProps extends ExtensionComponentData {
422
424
  component: 'Toggle'
423
- label?: string
424
- description?: string
425
+ label?: LocalizedString
426
+ description?: LocalizedString
425
427
  checked?: boolean
426
428
  disabled?: boolean
427
429
  onChangeAction?: ExtensionActionRef
@@ -431,9 +433,9 @@ export interface ToggleProps extends ExtensionComponentData {
431
433
  export interface CollapsibleProps extends ExtensionComponentData {
432
434
  component: 'Collapsible'
433
435
  /** Title displayed in the header. */
434
- title: string
436
+ title: LocalizedString
435
437
  /** Optional description rendered under the title. */
436
- description?: string | string[]
438
+ description?: LocalizedString | LocalizedString[]
437
439
  /** Optional icon shown to the left of the title. */
438
440
  icon?: HugeIconName
439
441
  /** Whether the section is expanded by default. */
@@ -449,7 +451,7 @@ export type PillVariant = 'default' | 'primary' | 'success' | 'warning' | 'dange
449
451
  export interface PillProps extends ExtensionComponentData {
450
452
  component: 'Pill'
451
453
  /** Text to display in the pill. */
452
- text: string
454
+ text: LocalizedString
453
455
  /** Optional icon shown to the left of the text. */
454
456
  icon?: HugeIconName
455
457
  /** Color variant. Defaults to 'default'. */
@@ -460,7 +462,7 @@ export interface PillProps extends ExtensionComponentData {
460
462
  export interface CheckboxProps extends ExtensionComponentData {
461
463
  component: 'Checkbox'
462
464
  /** Label text displayed next to the checkbox. */
463
- label: string
465
+ label: LocalizedString
464
466
  /** Whether the checkbox is checked. */
465
467
  checked?: boolean
466
468
  /** Whether the checkbox is disabled. */
@@ -475,7 +477,7 @@ export interface CheckboxProps extends ExtensionComponentData {
475
477
  export interface MarkdownProps extends ExtensionComponentData {
476
478
  component: 'Markdown'
477
479
  /** Markdown content to render. */
478
- content: string
480
+ content: LocalizedString
479
481
  }
480
482
 
481
483
  /** The extension API properties for the TextPreview component. */
@@ -491,7 +493,7 @@ export interface TextPreviewProps extends ExtensionComponentData {
491
493
  export interface ModalProps extends ExtensionComponentData {
492
494
  component: 'Modal'
493
495
  /** Title displayed in the modal header. */
494
- title: string
496
+ title: LocalizedString
495
497
  /** Whether the modal is open. */
496
498
  open?: boolean
497
499
  /** Optional max width for the modal (e.g., '600px', '80%'). Defaults to '600px'. */
@@ -532,7 +534,7 @@ export type FrameVariant = 'border' | 'solid'
532
534
  export interface FrameProps extends ExtensionComponentData {
533
535
  component: 'Frame'
534
536
  /** Optional title displayed in the header. Can be a plain string or extension components. */
535
- title?: string | ExtensionComponentChildren
537
+ title?: LocalizedString | ExtensionComponentChildren
536
538
  /** Whether the content can be toggled (collapsed/expanded) by clicking the title. Requires title to be set. */
537
539
  collapsible?: boolean
538
540
  /** Whether the frame content is expanded by default. Only used when collapsible is true. Defaults to true. */
@@ -658,7 +660,7 @@ export interface WeatherForecastStep {
658
660
  export interface WeatherForecastProps extends ExtensionComponentData {
659
661
  component: 'WeatherForecast'
660
662
  /** Heading above the row, e.g. "Kommande timmar". */
661
- title?: string
663
+ title?: LocalizedString
662
664
  /** Icon shown to the left of the title. */
663
665
  icon?: HugeIconName
664
666
  /** Written after every temperature. Defaults to `°`. */
@@ -699,7 +701,7 @@ export interface ChartProps extends ExtensionComponentData {
699
701
  /** One per point, along the horizontal axis. */
700
702
  labels?: string[]
701
703
  /** Heading above the plot. With a single series this is what names it, so no legend is drawn. */
702
- title?: string
704
+ title?: LocalizedString
703
705
  /** Icon shown to the left of the title. */
704
706
  icon?: HugeIconName
705
707
  /** Written after every value, e.g. `°`, ` mm`, ` kr`. */
@@ -726,12 +728,12 @@ export type StatTrend = 'up' | 'down' | 'flat'
726
728
  export interface StatTileProps extends ExtensionComponentData {
727
729
  component: 'StatTile'
728
730
  /** What the number is, e.g. "Förbrukning i går". */
729
- label: string
731
+ label: LocalizedString
730
732
  value: string | number
731
733
  /** Written after the value in smaller type, e.g. `kWh`. */
732
734
  unit?: string
733
735
  /** One quiet line under the number. */
734
- caption?: string
736
+ caption?: LocalizedString
735
737
  icon?: HugeIconName
736
738
  /** `flat` draws no arrow. */
737
739
  trend?: StatTrend
@@ -772,7 +774,7 @@ export type ProgressColor = 'accent' | 'success' | 'warning' | 'danger' | 'info'
772
774
  export interface ProgressBarProps extends ExtensionComponentData {
773
775
  component: 'ProgressBar'
774
776
  /** What is being measured, e.g. "Stressnivå". Shown beside the reading. */
775
- label: string
777
+ label: LocalizedString
776
778
  value: number
777
779
  /** Bottom of the range. Defaults to 0. */
778
780
  min?: number
@@ -787,7 +789,7 @@ export interface ProgressBarProps extends ExtensionComponentData {
787
789
  /** The readout in words, when the bare number does not say it. Replaces value and unit. */
788
790
  valueLabel?: string
789
791
  /** One quiet line under the reading. */
790
- caption?: string
792
+ caption?: LocalizedString
791
793
  icon?: HugeIconName
792
794
  }
793
795
 
@@ -848,7 +850,7 @@ export interface TimelineEntry {
848
850
  export interface TimelineProps extends ExtensionComponentData {
849
851
  component: 'Timeline'
850
852
  /** Heading above the rail, e.g. "I dag". */
851
- title?: string
853
+ title?: LocalizedString
852
854
  /** Icon shown to the left of the title. */
853
855
  icon?: HugeIconName
854
856
  entries: TimelineEntry[]
@@ -873,7 +875,7 @@ export type NoteVariant = 'default' | 'accent' | 'success' | 'warning' | 'danger
873
875
  */
874
876
  export interface NoteProps extends ExtensionComponentData {
875
877
  component: 'Note'
876
- title?: string
878
+ title?: LocalizedString
877
879
  /** Icon shown to the left of the title. */
878
880
  icon?: HugeIconName
879
881
  /** Trailing badge next to the title: a source, a category, a time. */
@@ -1004,7 +1006,7 @@ export interface AgendaDay {
1004
1006
  export interface AgendaProps extends ExtensionComponentData {
1005
1007
  component: 'Agenda'
1006
1008
  /** Heading above the days. */
1007
- title?: string
1009
+ title?: LocalizedString
1008
1010
  /** Icon shown to the left of the title. */
1009
1011
  icon?: HugeIconName
1010
1012
  days: AgendaDay[]
@@ -87,6 +87,36 @@ export interface AccountContribution {
87
87
  // Tool Settings Views
88
88
  // ============================================================================
89
89
 
90
+ /**
91
+ * What a settings view is about, which decides where Stina shows it.
92
+ *
93
+ * An extension never picks a place in the settings menu: the menu belongs to Stina and
94
+ * changes between versions. It says what the view is *about*, and Stina puts each topic
95
+ * where it belongs, the way `accounts`, `providers` and `statusCards` already work.
96
+ *
97
+ * - `accounts`: connects Stina to an account or a service (a mailbox, a calendar feed).
98
+ * Shown with the other connected accounts.
99
+ * - `notifications`: when and how the extension may get in touch. Shown with Stina's own
100
+ * notification settings.
101
+ * - `personal`: facts about the user the extension relies on (a home town for the
102
+ * weather). Shown with the profile.
103
+ * - `tracking`: things Stina keeps track of for the user that are worth looking through
104
+ * now and then (people, projects, reminders). Gets its own row in the register.
105
+ *
106
+ * A view without a topic, or with one this version of Stina does not know, is shown on
107
+ * the extension's own page. That is always a working place, only a less fitting one, so
108
+ * a topic added later never breaks an older Stina.
109
+ */
110
+ export type ExtensionSettingsTopic = 'accounts' | 'notifications' | 'personal' | 'tracking'
111
+
112
+ /** Every topic this version of the API knows, in no particular order. */
113
+ export const EXTENSION_SETTINGS_TOPICS: readonly ExtensionSettingsTopic[] = [
114
+ 'accounts',
115
+ 'notifications',
116
+ 'personal',
117
+ 'tracking',
118
+ ]
119
+
90
120
  /**
91
121
  * Tool settings view definition (UI schema)
92
122
  */
@@ -94,9 +124,11 @@ export interface ToolSettingsViewDefinition {
94
124
  /** Unique view ID within the extension */
95
125
  id: string
96
126
  /** Display title */
97
- title: string
127
+ title: LocalizedString
98
128
  /** Help text */
99
- description?: string
129
+ description?: LocalizedString
130
+ /** What the view is about, and so where Stina shows it. See {@link ExtensionSettingsTopic}. */
131
+ topic?: ExtensionSettingsTopic
100
132
  /** View configuration */
101
133
  view: ToolSettingsView
102
134
  }
@@ -155,7 +187,7 @@ export interface ToolSettingsListGroupBy {
155
187
  /** Explicit ordering of group values. Groups not listed appear afterwards, sorted alphabetically. */
156
188
  order?: string[]
157
189
  /** Human-friendly labels per group value (rendered as section headers). Falls back to the raw value if missing. */
158
- labels?: Record<string, string>
190
+ labels?: Record<string, LocalizedString>
159
191
  }
160
192
 
161
193
  /**
@@ -212,7 +244,7 @@ export interface PanelDefinition {
212
244
  /** Unique panel ID within the extension */
213
245
  id: string
214
246
  /** Display title */
215
- title: string
247
+ title: LocalizedString
216
248
  /** Icon name (from huge-icons) */
217
249
  icon?: string
218
250
  /** Panel view schema */
@@ -234,7 +266,7 @@ export interface StatusCardDefinition {
234
266
  /** Unique card ID within the extension */
235
267
  id: string
236
268
  /** What it is called where the user picks it */
237
- title: string
269
+ title: LocalizedString
238
270
  /** Icon name (from huge-icons) */
239
271
  icon?: string
240
272
  /**
package/src/types.ts CHANGED
@@ -24,6 +24,7 @@ export type {
24
24
  ExtensionContributions,
25
25
  // Tool Settings Views
26
26
  ToolSettingsViewDefinition,
27
+ ExtensionSettingsTopic,
27
28
  ToolSettingsView,
28
29
  ToolSettingsListView,
29
30
  ToolSettingsListMapping,
@@ -51,6 +52,7 @@ export type {
51
52
  AccountProvider,
52
53
  AccountContribution,
53
54
  } from './types.contributions.js'
55
+ export { EXTENSION_SETTINGS_TOPICS } from './types.contributions.js'
54
56
 
55
57
  // Manifest
56
58
  export type { ExtensionManifest, Platform } from './types.manifest.js'