@scm-js/plugin-api 1.50.0 → 1.51.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.
Files changed (2) hide show
  1. package/index.d.ts +58 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -5048,6 +5048,12 @@ export interface PanelSpec {
5048
5048
  grow?: boolean;
5049
5049
  /** Floating only: the body runs edge to edge, without the panel's padding — for content that draws its own frame. */
5050
5050
  flush?: boolean;
5051
+ /**
5052
+ * Floating only: a button in the title strip (and a double-click on it) makes the panel
5053
+ * fill the map's area, and puts it back. For a window of charts or tables read at length
5054
+ * beside a map that is still there underneath. `PanelHandle.maximize` does the same.
5055
+ */
5056
+ maximizable?: boolean;
5051
5057
  /** Fill `body` (an empty `<div>` inside the panel); return a cleanup if you need one. */
5052
5058
  mount(body: HTMLElement, panel: PanelHandle): void | (() => void);
5053
5059
  /** The panel closed, whichever way. */
@@ -5174,6 +5180,10 @@ export interface PanelHandle {
5174
5180
  close(): void;
5175
5181
  isOpen(): boolean;
5176
5182
  setTitle(title: string): void;
5183
+ /** A `maximizable` panel: fill the map's area (`true`), go back (`false`), or toggle. Nothing for another panel. */
5184
+ maximize(on?: boolean): void;
5185
+ /** Whether it fills the map's area now. */
5186
+ isMaximized(): boolean;
5177
5187
  }
5178
5188
  /**
5179
5189
  * One cell in the status bar (`ui.statusItem`): a line of text with the plugin's icon,
@@ -5822,6 +5832,35 @@ export interface SelectOption {
5822
5832
  label: string;
5823
5833
  disabled?: boolean;
5824
5834
  }
5835
+ /** `widgets.segmented`: the value picked, and a way to pick another. */
5836
+ export type SegmentedElement = HTMLElement & {
5837
+ get(): string;
5838
+ /** Pick `value` without calling `onChange`. */
5839
+ set(value: string | number): void;
5840
+ };
5841
+ export interface TabItem {
5842
+ value: string;
5843
+ label: string;
5844
+ disabled?: boolean;
5845
+ /** Fill the tab's panel, the first time it is shown. What it starts ends with the panel or dialog the tabs are in. */
5846
+ mount(body: HTMLElement): void;
5847
+ }
5848
+ export interface TabsOptions {
5849
+ /** The tab shown first; the first that is not disabled otherwise. */
5850
+ value?: string;
5851
+ onChange?: (value: string) => void;
5852
+ /** Smaller tabs, for a narrow panel. */
5853
+ compact?: boolean;
5854
+ className?: string;
5855
+ }
5856
+ /** `widgets.tabs`: the tab shown, and a way to show another. */
5857
+ export type TabsElement = HTMLElement & {
5858
+ get(): string;
5859
+ /** Show the tab `value` (mounting it the first time) without calling `onChange`. */
5860
+ set(value: string): void;
5861
+ /** The panel of a tab that has been shown, or null. */
5862
+ panel(value: string): HTMLElement | null;
5863
+ };
5825
5864
  export interface SelectOptions extends WidgetOptions {
5826
5865
  value?: string | number;
5827
5866
  onChange?: (value: string) => void;
@@ -6006,6 +6045,25 @@ export interface WidgetsApi {
6006
6045
  text(options?: TextFieldOptions): HTMLInputElement;
6007
6046
  number(options?: NumberFieldOptions): HTMLInputElement;
6008
6047
  select(items: SelectOption[], options?: SelectOptions): HTMLSelectElement;
6048
+ /**
6049
+ * Buttons side by side of which one is on: a choice of a few short options seen at once
6050
+ * ("Both", "Minerals", "Gas"), where a `select` would hide them. `onChange` hears the
6051
+ * value picked; `set` moves the choice without it.
6052
+ */
6053
+ segmented(items: SelectOption[], options?: SelectOptions): SegmentedElement;
6054
+ /**
6055
+ * Tabs in the editor's style: a row of tabs over a panel a tab. A tab's `mount` runs the
6056
+ * first time it is shown and its panel is kept after, so what the user did there stays
6057
+ * when they come back. Arrow keys move between the tabs.
6058
+ *
6059
+ * @example
6060
+ * const tabs = api.ui.widgets.tabs([
6061
+ * { value: "economy", label: "Economy", mount: (body) => body.append(economyView()) },
6062
+ * { value: "army", label: "Army", mount: (body) => body.append(armyView()) },
6063
+ * ], { value: saved.tab, onChange: (tab) => { saved.tab = tab; } });
6064
+ * body.append(tabs);
6065
+ */
6066
+ tabs(items: TabItem[], options?: TabsOptions): TabsElement;
6009
6067
  /** A two-column grid of labelled fields. */
6010
6068
  form(rows: (FormRow | null | undefined | false)[]): HTMLElement;
6011
6069
  /** A titled box (a `fieldset` with a legend, as the dialogs use). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.50.0",
3
+ "version": "1.51.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",