@nxds/core 0.9.1 → 0.10.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/README.md +2 -2
- package/dist/runtime/catalogue.cjs +79 -21
- package/dist/runtime/catalogue.cjs.map +1 -1
- package/dist/runtime/catalogue.d.cts +6 -5
- package/dist/runtime/catalogue.d.ts +6 -5
- package/dist/runtime/catalogue.js +79 -21
- package/dist/runtime/catalogue.js.map +1 -1
- package/dist/runtime/index.cjs +30 -4
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +8 -1
- package/dist/runtime/index.d.ts +8 -1
- package/dist/runtime/index.js +29 -4
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/palette.cjs +26 -3
- package/dist/runtime/palette.cjs.map +1 -1
- package/dist/runtime/palette.d.cts +3 -1402
- package/dist/runtime/palette.d.ts +3 -1402
- package/dist/runtime/palette.js +26 -3
- package/dist/runtime/palette.js.map +1 -1
- package/dist/runtime/token-scales.generated-CCNkHJ3I.d.cts +9 -0
- package/dist/runtime/token-scales.generated-CCNkHJ3I.d.ts +9 -0
- package/package.json +3 -2
|
@@ -15,8 +15,8 @@ type DeepReadonly<T> = T extends object ? {
|
|
|
15
15
|
type CatalogueFamily = 'borderwidth' | 'breakpoint' | 'color' | 'motion' | 'radius' | 'shadow' | 'spacing' | 'typography' | 'z-index';
|
|
16
16
|
/**
|
|
17
17
|
* Canonical identity: an identifier in the `--nx-*` custom property scheme.
|
|
18
|
-
* Most tokens declare it in the generated CSS. Typography and
|
|
19
|
-
*
|
|
18
|
+
* Most tokens declare it in the generated CSS. Typography styles and
|
|
19
|
+
* breakpoints do not; they declare a utility or a theme property instead.
|
|
20
20
|
*/
|
|
21
21
|
type CatalogueTokenName = `--nx-${string}`;
|
|
22
22
|
/** Another name that maps onto the canonical token. */
|
|
@@ -52,7 +52,7 @@ interface CatalogueDeclaration {
|
|
|
52
52
|
interface CatalogueVariant {
|
|
53
53
|
/**
|
|
54
54
|
* The theme mode the value applies in (`light` / `dark` for a runtime
|
|
55
|
-
* colour or a shadow
|
|
55
|
+
* colour or a shadow), or `null` when it applies in both.
|
|
56
56
|
*/
|
|
57
57
|
readonly mode: Mode | null;
|
|
58
58
|
/**
|
|
@@ -68,8 +68,8 @@ interface CatalogueVariant {
|
|
|
68
68
|
readonly authoredValue: TokenValue | null;
|
|
69
69
|
/**
|
|
70
70
|
* What the generated CSS declares: one custom property for a scalar or a
|
|
71
|
-
* shadow style (`--nx-spacing-4`, or `--breakpoint-md`
|
|
72
|
-
* a token declared only under `@theme`), or the `@utility` body for a
|
|
71
|
+
* shadow style (`--nx-spacing-4`, `--nx-shadow-sm`, or `--breakpoint-md`
|
|
72
|
+
* for a token declared only under `@theme`), or the `@utility` body for a
|
|
73
73
|
* typography style.
|
|
74
74
|
*/
|
|
75
75
|
readonly declarations: readonly CatalogueDeclaration[];
|
|
@@ -106,6 +106,7 @@ interface CatalogueToken {
|
|
|
106
106
|
/**
|
|
107
107
|
* Every nxds token, identified by its `--nx-*` name: primitives, runtime
|
|
108
108
|
* colours, spacing, z-index, breakpoints, and typography and shadow styles.
|
|
109
|
+
* Shadow layer primitives only compose the shadow styles.
|
|
109
110
|
* Runtime colours are computed from `DEFAULT_NXDS_APPEARANCE` in explicit
|
|
110
111
|
* light and dark modes; each variant records the appearance it used.
|
|
111
112
|
*/
|
|
@@ -15,8 +15,8 @@ type DeepReadonly<T> = T extends object ? {
|
|
|
15
15
|
type CatalogueFamily = 'borderwidth' | 'breakpoint' | 'color' | 'motion' | 'radius' | 'shadow' | 'spacing' | 'typography' | 'z-index';
|
|
16
16
|
/**
|
|
17
17
|
* Canonical identity: an identifier in the `--nx-*` custom property scheme.
|
|
18
|
-
* Most tokens declare it in the generated CSS. Typography and
|
|
19
|
-
*
|
|
18
|
+
* Most tokens declare it in the generated CSS. Typography styles and
|
|
19
|
+
* breakpoints do not; they declare a utility or a theme property instead.
|
|
20
20
|
*/
|
|
21
21
|
type CatalogueTokenName = `--nx-${string}`;
|
|
22
22
|
/** Another name that maps onto the canonical token. */
|
|
@@ -52,7 +52,7 @@ interface CatalogueDeclaration {
|
|
|
52
52
|
interface CatalogueVariant {
|
|
53
53
|
/**
|
|
54
54
|
* The theme mode the value applies in (`light` / `dark` for a runtime
|
|
55
|
-
* colour or a shadow
|
|
55
|
+
* colour or a shadow), or `null` when it applies in both.
|
|
56
56
|
*/
|
|
57
57
|
readonly mode: Mode | null;
|
|
58
58
|
/**
|
|
@@ -68,8 +68,8 @@ interface CatalogueVariant {
|
|
|
68
68
|
readonly authoredValue: TokenValue | null;
|
|
69
69
|
/**
|
|
70
70
|
* What the generated CSS declares: one custom property for a scalar or a
|
|
71
|
-
* shadow style (`--nx-spacing-4`, or `--breakpoint-md`
|
|
72
|
-
* a token declared only under `@theme`), or the `@utility` body for a
|
|
71
|
+
* shadow style (`--nx-spacing-4`, `--nx-shadow-sm`, or `--breakpoint-md`
|
|
72
|
+
* for a token declared only under `@theme`), or the `@utility` body for a
|
|
73
73
|
* typography style.
|
|
74
74
|
*/
|
|
75
75
|
readonly declarations: readonly CatalogueDeclaration[];
|
|
@@ -106,6 +106,7 @@ interface CatalogueToken {
|
|
|
106
106
|
/**
|
|
107
107
|
* Every nxds token, identified by its `--nx-*` name: primitives, runtime
|
|
108
108
|
* colours, spacing, z-index, breakpoints, and typography and shadow styles.
|
|
109
|
+
* Shadow layer primitives only compose the shadow styles.
|
|
109
110
|
* Runtime colours are computed from `DEFAULT_NXDS_APPEARANCE` in explicit
|
|
110
111
|
* light and dark modes; each variant records the appearance it used.
|
|
111
112
|
*/
|
|
@@ -2502,10 +2502,33 @@ var color_default = {
|
|
|
2502
2502
|
}
|
|
2503
2503
|
};
|
|
2504
2504
|
|
|
2505
|
+
// src/lib/token-scales.generated.ts
|
|
2506
|
+
var PRIMITIVE_PALETTE_NAMES = [
|
|
2507
|
+
"green",
|
|
2508
|
+
"emerald",
|
|
2509
|
+
"teal",
|
|
2510
|
+
"cyan",
|
|
2511
|
+
"sky",
|
|
2512
|
+
"indigo",
|
|
2513
|
+
"violet",
|
|
2514
|
+
"purple",
|
|
2515
|
+
"fuchsia",
|
|
2516
|
+
"pink",
|
|
2517
|
+
"slate",
|
|
2518
|
+
"rose",
|
|
2519
|
+
"lime",
|
|
2520
|
+
"yellow",
|
|
2521
|
+
"blue",
|
|
2522
|
+
"gray",
|
|
2523
|
+
"zinc",
|
|
2524
|
+
"neutral",
|
|
2525
|
+
"stone",
|
|
2526
|
+
"red",
|
|
2527
|
+
"orange",
|
|
2528
|
+
"amber"
|
|
2529
|
+
];
|
|
2530
|
+
|
|
2505
2531
|
// src/lib/primitive-palette.ts
|
|
2506
|
-
var PRIMITIVE_PALETTE_NAMES = Object.keys(color_default).filter(
|
|
2507
|
-
(name) => name !== "white" && name !== "black"
|
|
2508
|
-
);
|
|
2509
2532
|
var rampCache = /* @__PURE__ */ new Map();
|
|
2510
2533
|
function getPaletteRamp(palette) {
|
|
2511
2534
|
if (!PRIMITIVE_PALETTE_NAMES.includes(palette)) {
|
|
@@ -3168,6 +3191,15 @@ function formatShadowStyle(tokenPath, value, primitiveMap) {
|
|
|
3168
3191
|
const isInset = tokenPath.length === 1 && tokenPath[0] === "inner";
|
|
3169
3192
|
return formatShadowComposite(value, primitiveMap, isInset);
|
|
3170
3193
|
}
|
|
3194
|
+
function inlineVariables(value, values) {
|
|
3195
|
+
return value.replace(/var\((--[\w-]+)\)/g, (reference, name) => {
|
|
3196
|
+
const literal = values.get(name);
|
|
3197
|
+
if (literal === void 0) {
|
|
3198
|
+
throw new Error(`inlineVariables: ${reference} has no value`);
|
|
3199
|
+
}
|
|
3200
|
+
return literal;
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3171
3203
|
var TYPOGRAPHY_PROPERTIES = [
|
|
3172
3204
|
["fontFamily", "font-family"],
|
|
3173
3205
|
["fontSize", "font-size"],
|
|
@@ -11208,21 +11240,46 @@ function typographyStyleEntry(lookup) {
|
|
|
11208
11240
|
};
|
|
11209
11241
|
};
|
|
11210
11242
|
}
|
|
11211
|
-
function
|
|
11212
|
-
|
|
11243
|
+
function shadowLayerSets(layers, lookup) {
|
|
11244
|
+
const sets = /* @__PURE__ */ new Map();
|
|
11245
|
+
for (const { preset, mode, leaf } of layers) {
|
|
11246
|
+
const key = `${preset}/${mode}`;
|
|
11247
|
+
const set = sets.get(key) ?? { preset, mode, values: /* @__PURE__ */ new Map() };
|
|
11248
|
+
set.values.set(
|
|
11249
|
+
primitiveName("shadow", leaf.path),
|
|
11250
|
+
resolveValue(leaf.value, lookup, leaf.type, leaf.path)
|
|
11251
|
+
);
|
|
11252
|
+
sets.set(key, set);
|
|
11253
|
+
}
|
|
11254
|
+
return [...sets.values()];
|
|
11255
|
+
}
|
|
11256
|
+
function shadowStyleTokens(layers, lookup) {
|
|
11257
|
+
const sets = shadowLayerSets(layers, lookup);
|
|
11258
|
+
return styleLeaves("shadow", SHADOW_STYLES_FILE).map(({ leaf }) => {
|
|
11213
11259
|
const key = pathToCssVarPrefixed(leaf.path, "shadow");
|
|
11214
|
-
const
|
|
11260
|
+
const name = `--nx-${key}`;
|
|
11261
|
+
const composite = formatShadowStyle(leaf.path, leaf.value, lookup);
|
|
11215
11262
|
return {
|
|
11216
|
-
name
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11263
|
+
name,
|
|
11264
|
+
family: "shadow",
|
|
11265
|
+
group: leafGroup("shadow", leaf.path),
|
|
11266
|
+
type: leaf.type,
|
|
11267
|
+
description: leaf.description ?? null,
|
|
11268
|
+
aliases: [cssVariable(`--${key}`)],
|
|
11269
|
+
control: PRESET_CONTROLS.shadow ?? null,
|
|
11270
|
+
variants: sets.map(({ preset, mode, values }) => ({
|
|
11271
|
+
mode,
|
|
11272
|
+
preset,
|
|
11273
|
+
source: { file: SHADOW_STYLES_FILE, path: leaf.path },
|
|
11274
|
+
appearance: null,
|
|
11275
|
+
authoredValue: structuredClone(leaf.value),
|
|
11276
|
+
declarations: [
|
|
11277
|
+
{ property: name, value: inlineVariables(composite, values) }
|
|
11278
|
+
],
|
|
11279
|
+
references: []
|
|
11280
|
+
}))
|
|
11224
11281
|
};
|
|
11225
|
-
};
|
|
11282
|
+
});
|
|
11226
11283
|
}
|
|
11227
11284
|
function styleLeaves(family, file) {
|
|
11228
11285
|
return fileLeaves(family, file, SINGLE_SOURCE).filter(
|
|
@@ -11284,8 +11341,13 @@ function runtimeColorTokens() {
|
|
|
11284
11341
|
function createTokenCatalogue() {
|
|
11285
11342
|
const primitives = PRIMITIVE_FAMILIES.flatMap(primitiveLeaves);
|
|
11286
11343
|
const lookup = primitiveLookup(primitives);
|
|
11344
|
+
const shadowLayers = primitives.filter(({ family }) => family === "shadow");
|
|
11287
11345
|
return [
|
|
11288
|
-
...authoredTokens(
|
|
11346
|
+
...authoredTokens(
|
|
11347
|
+
primitives.filter((leaf) => leaf.family !== "shadow"),
|
|
11348
|
+
lookup,
|
|
11349
|
+
primitiveEntry(lookup)
|
|
11350
|
+
),
|
|
11289
11351
|
...runtimeColorTokens(),
|
|
11290
11352
|
...authoredTokens(spacingLeaves(), lookup, spacingEntry),
|
|
11291
11353
|
...authoredTokens(
|
|
@@ -11303,11 +11365,7 @@ function createTokenCatalogue() {
|
|
|
11303
11365
|
lookup,
|
|
11304
11366
|
typographyStyleEntry(lookup)
|
|
11305
11367
|
),
|
|
11306
|
-
...
|
|
11307
|
-
styleLeaves("shadow", SHADOW_STYLES_FILE),
|
|
11308
|
-
lookup,
|
|
11309
|
-
shadowStyleEntry(lookup)
|
|
11310
|
-
)
|
|
11368
|
+
...shadowStyleTokens(shadowLayers, lookup)
|
|
11311
11369
|
];
|
|
11312
11370
|
}
|
|
11313
11371
|
export {
|