@glasshome/ui 1.12.0 → 1.14.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.
@@ -40,7 +40,7 @@ export declare function extractItemDefaults(schema: ExtendedJSONSchema): Record<
40
40
  */
41
41
  export declare function switchVariantValue(branch: ExtendedJSONSchema, discriminator: string, kind: string, current: Record<string, unknown>): Record<string, unknown>;
42
42
  interface SchemaFormProps {
43
- schema: JSONSchema7;
43
+ schema: ExtendedJSONSchema;
44
44
  data: Record<string, unknown>;
45
45
  onChange: (data: Record<string, unknown>) => void;
46
46
  errors?: string[];
@@ -5,3 +5,4 @@
5
5
  export * from "./hex.js";
6
6
  export * from "./presets.js";
7
7
  export * from "./theme-colors.js";
8
+ export { contrastRatio, parseThemeBlock } from "./theme-css.js";
@@ -220,4 +220,28 @@ function C(e) {
220
220
  return x.find((t) => t.id === e);
221
221
  }
222
222
  //#endregion
223
- export { g as DEFAULT_THEME_ID, v as FONT_MONO, _ as FONT_SANS, x as THEME_PRESETS, t as clamp, c as deriveDarkFromLight, u as ensureFullThemeColors, S as getAllPresets, C as getPreset, d as oklchToHex, r as parseOklch, s as resolveThemeColors, i as toOklch };
223
+ //#region src/tokens/theme-css.ts
224
+ function w(e, t) {
225
+ let n = e.match(RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\{([^}]*)\\}`));
226
+ if (!n) throw Error(`block not found in theme.css: ${t}`);
227
+ let r = {};
228
+ for (let e of (n[1] ?? "").split("\n")) {
229
+ let [, t, n] = e.match(/^\s*(--[\w-]+):\s*(.+?);\s*$/) ?? [];
230
+ t && n && (r[t] = n);
231
+ }
232
+ return r;
233
+ }
234
+ function T(e) {
235
+ let t = d(e), [n, r, i] = [
236
+ 1,
237
+ 3,
238
+ 5
239
+ ].map((e) => Number.parseInt(t.slice(e, e + 2), 16) / 255).map((e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
240
+ return .2126 * n + .7152 * r + .0722 * i;
241
+ }
242
+ function E(e, t) {
243
+ let [n, r] = [T(e), T(t)];
244
+ return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
245
+ }
246
+ //#endregion
247
+ export { g as DEFAULT_THEME_ID, v as FONT_MONO, _ as FONT_SANS, x as THEME_PRESETS, t as clamp, E as contrastRatio, c as deriveDarkFromLight, u as ensureFullThemeColors, S as getAllPresets, C as getPreset, d as oklchToHex, r as parseOklch, w as parseThemeBlock, s as resolveThemeColors, i as toOklch };
@@ -0,0 +1,4 @@
1
+ /** Every custom property declared in one theme.css block (`:root`, `.dark`). */
2
+ export declare function parseThemeBlock(css: string, block: string): Record<string, string>;
3
+ /** WCAG contrast between two oklch() literals. */
4
+ export declare function contrastRatio(a: string, b: string): number;