@unpunnyfuns/swatchbook-blocks 0.51.1 → 0.52.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.
- package/dist/index.d.mts +18 -31
- package/dist/index.mjs +19 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _$react from "react";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
import { Axis, Diagnostic, Permutation, Preset } from "@unpunnyfuns/swatchbook-core";
|
|
3
4
|
|
|
4
5
|
//#region src/format-color.d.ts
|
|
5
6
|
/**
|
|
@@ -48,34 +49,24 @@ declare function formatColor(value: unknown, format: ColorFormat, fallback?: str
|
|
|
48
49
|
//#endregion
|
|
49
50
|
//#region src/contexts.d.ts
|
|
50
51
|
/**
|
|
51
|
-
* Typed shape of the addon's `virtual:swatchbook/tokens` module
|
|
52
|
-
* as value-importable interfaces so consumers outside the addon's Vite
|
|
53
|
-
* plugin (unit tests, custom React apps) can construct a snapshot by hand.
|
|
52
|
+
* Typed shape of the addon's `virtual:swatchbook/tokens` module.
|
|
54
53
|
*
|
|
55
|
-
* The
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* The axis / permutation / diagnostic / preset entries are deliberate
|
|
55
|
+
* type-aliases of core's authoritative shapes — the virtual module
|
|
56
|
+
* publishes those shapes verbatim, so single-sourcing the types prevents
|
|
57
|
+
* silent drift the moment core grows a field the plugin doesn't
|
|
58
|
+
* serialise.
|
|
59
|
+
*
|
|
60
|
+
* Token / listing shapes stay as narrowed interfaces because blocks
|
|
61
|
+
* only read a subset of Terrazzo's full token / listing structure; the
|
|
62
|
+
* narrower shape documents what's actually relied on.
|
|
63
|
+
*
|
|
64
|
+
* The ambient `declare module 'virtual:swatchbook/tokens'` declarations
|
|
65
|
+
* in `packages/addon/src/virtual.d.ts` describe the same payload.
|
|
58
66
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
default: string;
|
|
63
|
-
description?: string;
|
|
64
|
-
source: 'resolver' | 'layered' | 'synthetic';
|
|
65
|
-
}
|
|
66
|
-
interface VirtualPermutationShape {
|
|
67
|
-
name: string;
|
|
68
|
-
input: Record<string, string>;
|
|
69
|
-
sources: string[];
|
|
70
|
-
}
|
|
71
|
-
interface VirtualDiagnosticShape {
|
|
72
|
-
severity: 'error' | 'warn' | 'info';
|
|
73
|
-
group: string;
|
|
74
|
-
message: string;
|
|
75
|
-
filename?: string;
|
|
76
|
-
line?: number;
|
|
77
|
-
column?: number;
|
|
78
|
-
}
|
|
67
|
+
type VirtualAxisShape = Axis;
|
|
68
|
+
type VirtualPermutationShape = Permutation;
|
|
69
|
+
type VirtualDiagnosticShape = Diagnostic;
|
|
79
70
|
interface VirtualTokenShape {
|
|
80
71
|
$type?: string;
|
|
81
72
|
$value?: unknown;
|
|
@@ -112,11 +103,7 @@ interface VirtualTokenListingShape {
|
|
|
112
103
|
};
|
|
113
104
|
};
|
|
114
105
|
}
|
|
115
|
-
|
|
116
|
-
name: string;
|
|
117
|
-
axes: Partial<Record<string, string>>;
|
|
118
|
-
description?: string;
|
|
119
|
-
}
|
|
106
|
+
type VirtualPresetShape = Preset;
|
|
120
107
|
/**
|
|
121
108
|
* Full project data read by blocks. Populated by the addon's preview
|
|
122
109
|
* decorator (from the virtual module) or constructed by hand in
|
package/dist/index.mjs
CHANGED
|
@@ -1844,6 +1844,21 @@ function FontFamilySample({ filter, sample = "The quick brown fox jumps over the
|
|
|
1844
1844
|
});
|
|
1845
1845
|
}
|
|
1846
1846
|
//#endregion
|
|
1847
|
+
//#region src/internal/css-var-style.ts
|
|
1848
|
+
/**
|
|
1849
|
+
* Coerce a CSS `var(--…)` reference into the numeric slot of a React
|
|
1850
|
+
* inline-style property.
|
|
1851
|
+
*
|
|
1852
|
+
* React's `CSSProperties` types unitless properties (`fontWeight`,
|
|
1853
|
+
* `lineHeight`, `zIndex`, …) as `number`. The DOM accepts a string at
|
|
1854
|
+
* runtime — the rendered stylesheet just receives whatever React passes —
|
|
1855
|
+
* so a `var(--font-weight)` reference works functionally. TypeScript still
|
|
1856
|
+
* complains. Centralising the type assertion in one named helper keeps
|
|
1857
|
+
* the gap visible (and greppable) instead of scattering casts across
|
|
1858
|
+
* block components that want CSS-var-driven typography or layout values.
|
|
1859
|
+
*/
|
|
1860
|
+
const cssVarAsNumber = (varRef) => varRef;
|
|
1861
|
+
//#endregion
|
|
1847
1862
|
//#region src/FontWeightScale.tsx
|
|
1848
1863
|
function toWeight(raw) {
|
|
1849
1864
|
if (typeof raw === "number") return raw;
|
|
@@ -1904,7 +1919,7 @@ function FontWeightScale({ filter, sample = "Aa", caption, sortBy = "value", sor
|
|
|
1904
1919
|
}),
|
|
1905
1920
|
/* @__PURE__ */ jsx("div", {
|
|
1906
1921
|
className: "sb-font-weight-scale__sample",
|
|
1907
|
-
style: { fontWeight: row.cssVar },
|
|
1922
|
+
style: { fontWeight: cssVarAsNumber(row.cssVar) },
|
|
1908
1923
|
children: sample
|
|
1909
1924
|
}),
|
|
1910
1925
|
/* @__PURE__ */ jsx("span", {
|
|
@@ -3241,8 +3256,8 @@ function CompositePreviewContent({ type, cssVar, rawValue }) {
|
|
|
3241
3256
|
style: {
|
|
3242
3257
|
fontFamily: `var(${base}-font-family)`,
|
|
3243
3258
|
fontSize: `var(${base}-font-size)`,
|
|
3244
|
-
fontWeight: `var(${base}-font-weight)
|
|
3245
|
-
lineHeight: `var(${base}-line-height)
|
|
3259
|
+
fontWeight: cssVarAsNumber(`var(${base}-font-weight)`),
|
|
3260
|
+
lineHeight: cssVarAsNumber(`var(${base}-line-height)`),
|
|
3246
3261
|
letterSpacing: `var(${base}-letter-spacing)`
|
|
3247
3262
|
},
|
|
3248
3263
|
children: PANGRAM
|
|
@@ -3275,7 +3290,7 @@ function CompositePreviewContent({ type, cssVar, rawValue }) {
|
|
|
3275
3290
|
});
|
|
3276
3291
|
if (type === "fontWeight") return /* @__PURE__ */ jsx("div", {
|
|
3277
3292
|
className: "sb-token-detail__font-weight-sample",
|
|
3278
|
-
style: { fontWeight: cssVar },
|
|
3293
|
+
style: { fontWeight: cssVarAsNumber(cssVar) },
|
|
3279
3294
|
children: "Aa"
|
|
3280
3295
|
});
|
|
3281
3296
|
if (type === "cubicBezier") return /* @__PURE__ */ jsx(TransitionSample, { transition: `left 800ms ${cssVar}` });
|