@digital-gravy/etch-public-api 0.3.3 → 0.3.4

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/README.md CHANGED
@@ -81,14 +81,23 @@ const classStyles = etch.styles.list({ type: "class" });
81
81
  const myStyle = etch.styles.list().find((s) => s.selector === ".lead");
82
82
  console.log(myStyle?.id); // the id you pass to blocks.addClass etc.
83
83
 
84
- // Global CSS custom properties
84
+ // Global CSS custom properties (default collection)
85
85
  etch.styles.setVariable("--brand", "#0af");
86
86
  etch.styles.getVariable("--brand"); // "#0af"
87
+
88
+ // Variable methods accept an optional collection for multi-collection :root setups
89
+ etch.styles.setVariable("--brand", "#0af", "theme-a");
90
+ etch.styles.getVariable("--brand", "theme-a"); // "#0af"
91
+ etch.styles.listVariables("theme-a");
92
+ etch.styles.removeVariable("--brand", "theme-a");
87
93
  ```
88
94
 
89
- > **Note:** The `collection` field on style objects is an internal implementation
90
- > detail. Always omit the `collection` argument — the default collection is the
91
- > only one supported via the public API.
95
+ > **Note:** The `collection` field on style **objects** (`StyleSummary`) and the
96
+ > `collection` argument on `create` / `update` are internal implementation
97
+ > details — always omit them for regular styles. The four `:root` variable
98
+ > methods (`listVariables`, `getVariable`, `setVariable`, `removeVariable`) are
99
+ > the exception: they accept an optional `collection` parameter, defaulting to
100
+ > `"default"` when omitted.
92
101
 
93
102
  ### Component edit mode
94
103
 
package/dist/index.d.cts CHANGED
@@ -610,14 +610,26 @@ interface EtchStylesApi {
610
610
  update(styleId: string, patch: StylePatch): void;
611
611
  /** Delete a style rule by id. */
612
612
  delete(styleId: string): void;
613
- /** All global CSS custom properties as a `name -> value` record. */
614
- listVariables(): Record<string, string>;
615
- /** Read one global CSS custom property, or `undefined` when unset. */
616
- getVariable(name: string): string | undefined;
617
- /** Set a global CSS custom property (e.g. `('--brand', '#0af')`). */
618
- setVariable(name: string, value: string): void;
619
- /** Remove a global CSS custom property. */
620
- removeVariable(name: string): void;
613
+ /**
614
+ * All global CSS custom properties as a `name -> value` record.
615
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
616
+ */
617
+ listVariables(collection?: string): Record<string, string>;
618
+ /**
619
+ * Read one global CSS custom property, or `undefined` when unset.
620
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
621
+ */
622
+ getVariable(name: string, collection?: string): string | undefined;
623
+ /**
624
+ * Set a global CSS custom property (e.g. `('--brand', '#0af')`).
625
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
626
+ */
627
+ setVariable(name: string, value: string, collection?: string): void;
628
+ /**
629
+ * Remove a global CSS custom property.
630
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
631
+ */
632
+ removeVariable(name: string, collection?: string): void;
621
633
  }
622
634
 
623
635
  /**
package/dist/index.d.ts CHANGED
@@ -610,14 +610,26 @@ interface EtchStylesApi {
610
610
  update(styleId: string, patch: StylePatch): void;
611
611
  /** Delete a style rule by id. */
612
612
  delete(styleId: string): void;
613
- /** All global CSS custom properties as a `name -> value` record. */
614
- listVariables(): Record<string, string>;
615
- /** Read one global CSS custom property, or `undefined` when unset. */
616
- getVariable(name: string): string | undefined;
617
- /** Set a global CSS custom property (e.g. `('--brand', '#0af')`). */
618
- setVariable(name: string, value: string): void;
619
- /** Remove a global CSS custom property. */
620
- removeVariable(name: string): void;
613
+ /**
614
+ * All global CSS custom properties as a `name -> value` record.
615
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
616
+ */
617
+ listVariables(collection?: string): Record<string, string>;
618
+ /**
619
+ * Read one global CSS custom property, or `undefined` when unset.
620
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
621
+ */
622
+ getVariable(name: string, collection?: string): string | undefined;
623
+ /**
624
+ * Set a global CSS custom property (e.g. `('--brand', '#0af')`).
625
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
626
+ */
627
+ setVariable(name: string, value: string, collection?: string): void;
628
+ /**
629
+ * Remove a global CSS custom property.
630
+ * @param collection - The `:root` style collection. Defaults to `"default"`.
631
+ */
632
+ removeVariable(name: string, collection?: string): void;
621
633
  }
622
634
 
623
635
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-gravy/etch-public-api",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "MIT-licensed typed client and contract for the Etch builder scripting API (window.etch). Etch itself is a separate proprietary product governed by its own commercial terms.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,4 +43,4 @@
43
43
  "typescript": "^5.7.2",
44
44
  "vitest": "^3.0.5"
45
45
  }
46
- }
46
+ }