@phcdevworks/spectre-ui 0.1.0 → 0.2.1
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 +74 -1
- package/dist/components.css +165 -0
- package/dist/index.cjs +214 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -24
- package/dist/index.d.ts +31 -24
- package/dist/index.js +213 -56
- package/dist/index.js.map +1 -1
- package/dist/tailwind/index.cjs +84 -0
- package/dist/tailwind/index.cjs.map +1 -0
- package/dist/tailwind/index.d.cts +26 -0
- package/dist/tailwind/index.d.ts +26 -0
- package/dist/tailwind/index.js +81 -0
- package/dist/tailwind/index.js.map +1 -0
- package/dist/utilities.css +7 -8
- package/package.json +7 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/tailwind/theme.ts
|
|
4
|
+
function createSpectreTailwindTheme(options) {
|
|
5
|
+
const mergedTokens = {
|
|
6
|
+
...options.tokens ?? {},
|
|
7
|
+
...options.overrides ?? {}
|
|
8
|
+
};
|
|
9
|
+
const t = mergedTokens;
|
|
10
|
+
const colors = t.colors ?? t.color ?? t.palette ?? {};
|
|
11
|
+
const spacing = t.spacing ?? t.space ?? {};
|
|
12
|
+
const borderRadius = t.radii ?? t.radius ?? {};
|
|
13
|
+
const boxShadow = t.shadows ?? t.shadow ?? {};
|
|
14
|
+
const fontFamily = t.typography?.families ?? t.fonts ?? {};
|
|
15
|
+
const fontSize = t.typography?.scale ?? t.fontSize ?? {};
|
|
16
|
+
const theme = {
|
|
17
|
+
colors,
|
|
18
|
+
spacing,
|
|
19
|
+
borderRadius,
|
|
20
|
+
boxShadow,
|
|
21
|
+
fontFamily,
|
|
22
|
+
fontSize
|
|
23
|
+
};
|
|
24
|
+
return { theme };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/tailwind/preset.ts
|
|
28
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29
|
+
var deepMerge = (base, overrides) => {
|
|
30
|
+
if (!overrides) return base;
|
|
31
|
+
const result = { ...base };
|
|
32
|
+
for (const [key, overrideValue] of Object.entries(overrides)) {
|
|
33
|
+
const baseValue = result[key];
|
|
34
|
+
if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {
|
|
35
|
+
result[key] = deepMerge(baseValue, overrideValue);
|
|
36
|
+
} else {
|
|
37
|
+
result[key] = overrideValue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
var cachedTokens = null;
|
|
43
|
+
var getRequire = () => {
|
|
44
|
+
try {
|
|
45
|
+
return Function("return typeof require !== 'undefined' ? require : null")();
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var resolveTokens = (tokens) => {
|
|
51
|
+
if (tokens) return tokens;
|
|
52
|
+
if (cachedTokens) return cachedTokens;
|
|
53
|
+
const req = getRequire();
|
|
54
|
+
if (!req) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
"[spectre-ui] Unable to load spectre tokens; pass tokens to createSpectreTailwindPreset."
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const mod = req("../tokens");
|
|
60
|
+
cachedTokens = mod.spectreTokens;
|
|
61
|
+
return cachedTokens;
|
|
62
|
+
};
|
|
63
|
+
var createSpectreTailwindPreset = (options = {}) => {
|
|
64
|
+
const tokens = resolveTokens(options.tokens);
|
|
65
|
+
const { theme } = createSpectreTailwindTheme({ tokens });
|
|
66
|
+
const mergedTheme = deepMerge(
|
|
67
|
+
theme,
|
|
68
|
+
options.themeOverrides
|
|
69
|
+
);
|
|
70
|
+
const basePreset = {
|
|
71
|
+
content: [],
|
|
72
|
+
theme: mergedTheme
|
|
73
|
+
// theme is guaranteed non-undefined now
|
|
74
|
+
};
|
|
75
|
+
return deepMerge(
|
|
76
|
+
basePreset,
|
|
77
|
+
options.presetOverrides
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.createSpectreTailwindPreset = createSpectreTailwindPreset;
|
|
82
|
+
exports.createSpectreTailwindTheme = createSpectreTailwindTheme;
|
|
83
|
+
//# sourceMappingURL=index.cjs.map
|
|
84
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tailwind/theme.ts","../../src/tailwind/preset.ts"],"names":[],"mappings":";;;AAkBO,SAAS,2BACd,OAAA,EACsB;AACtB,EAAA,MAAM,YAAA,GAAe;AAAA,IACnB,GAAI,OAAA,CAAQ,MAAA,IAAW,EAAC;AAAA,IACxB,GAAI,OAAA,CAAQ,SAAA,IAAa;AAAC,GAC5B;AAIA,EAAA,MAAM,CAAA,GAAS,YAAA;AAEf,EAAA,MAAM,SAAU,CAAA,CAAE,MAAA,IAAU,EAAE,KAAA,IAAS,CAAA,CAAE,WAAW,EAAC;AACrD,EAAA,MAAM,OAAA,GAAW,CAAA,CAAE,OAAA,IAAW,CAAA,CAAE,SAAS,EAAC;AAC1C,EAAA,MAAM,YAAA,GAAgB,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,UAAU,EAAC;AAC9C,EAAA,MAAM,SAAA,GAAa,CAAA,CAAE,OAAA,IAAW,CAAA,CAAE,UAAU,EAAC;AAC7C,EAAA,MAAM,aAAc,CAAA,CAAE,UAAA,EAAY,QAAA,IAAY,CAAA,CAAE,SAAS,EAAC;AAC1D,EAAA,MAAM,WAAY,CAAA,CAAE,UAAA,EAAY,KAAA,IAAS,CAAA,CAAE,YAAY,EAAC;AAExD,EAAA,MAAM,KAAA,GAAuB;AAAA,IAC3B,MAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAM;AACjB;;;ACnCA,IAAM,aAAA,GAAgB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,GAAA,CAAI,aAAA;AACnB,EAAA,OAAO,YAAA;AACT,CAAA;AAEO,IAAM,2BAAA,GAA8B,CACzC,OAAA,GAA8C,EAAC,KAC5B;AACnB,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,OAAA,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,0BAAA,CAA2B,EAAE,QAAQ,CAAA;AACvD,EAAA,MAAM,WAAA,GAAc,SAAA;AAAA,IAClB,KAAA;AAAA,IACA,OAAA,CAAQ;AAAA,GACV;AAEA,EAAA,MAAM,UAAA,GAA6B;AAAA,IACjC,SAAS,EAAC;AAAA,IACV,KAAA,EAAO;AAAA;AAAA,GACT;AAEA,EAAA,OAAO,SAAA;AAAA,IACL,UAAA;AAAA,IACA,OAAA,CAAQ;AAAA,GACV;AACF","file":"index.cjs","sourcesContent":["import type { Config as TailwindConfig } from \"tailwindcss\";\nimport type { SpectreTokens } from \"../tokens\";\n\ntype TailwindTheme = NonNullable<TailwindConfig[\"theme\"]>;\n\nexport interface SpectreTailwindTheme {\n theme: TailwindTheme;\n}\n\nexport interface CreateSpectreTailwindThemeOptions {\n tokens: SpectreTokens;\n overrides?: Partial<SpectreTokens>;\n}\n\n/**\n * Minimal, type-safe theme mapper.\n * Important: theme is NEVER undefined (fixes exactOptionalPropertyTypes + DTS).\n */\nexport function createSpectreTailwindTheme(\n options: CreateSpectreTailwindThemeOptions\n): SpectreTailwindTheme {\n const mergedTokens = {\n ...(options.tokens ?? ({} as SpectreTokens)),\n ...(options.overrides ?? {}),\n } as SpectreTokens;\n\n // We keep mapping shallow + permissive because token shapes will evolve.\n // Tailwind accepts nested objects of strings for colors.\n const t: any = mergedTokens;\n\n const colors = (t.colors ?? t.color ?? t.palette ?? {}) as Record<string, any>;\n const spacing = (t.spacing ?? t.space ?? {}) as Record<string, any>;\n const borderRadius = (t.radii ?? t.radius ?? {}) as Record<string, any>;\n const boxShadow = (t.shadows ?? t.shadow ?? {}) as Record<string, any>;\n const fontFamily = (t.typography?.families ?? t.fonts ?? {}) as Record<string, any>;\n const fontSize = (t.typography?.scale ?? t.fontSize ?? {}) as Record<string, any>;\n\n const theme: TailwindTheme = {\n colors: colors as any,\n spacing: spacing as any,\n borderRadius: borderRadius as any,\n boxShadow: boxShadow as any,\n fontFamily: fontFamily as any,\n fontSize: fontSize as any,\n };\n\n return { theme };\n}\n","import type { Config as TailwindConfig } from \"tailwindcss\";\nimport type { SpectreTokens } from \"../tokens\";\nimport { createSpectreTailwindTheme } from \"./theme\";\n\ntype TailwindTheme = NonNullable<TailwindConfig[\"theme\"]>;\n\nexport interface CreateSpectreTailwindPresetOptions {\n tokens?: SpectreTokens;\n themeOverrides?: TailwindTheme;\n presetOverrides?: TailwindConfig;\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n// Deep-merge plain objects only; arrays and primitives replace by override.\nconst deepMerge = <T extends Record<string, unknown>>(\n base: T,\n overrides?: Record<string, unknown>\n): T => {\n if (!overrides) return base;\n\n const result: Record<string, unknown> = { ...base };\n\n for (const [key, overrideValue] of Object.entries(overrides)) {\n const baseValue = result[key];\n if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {\n result[key] = deepMerge(baseValue, overrideValue);\n } else {\n result[key] = overrideValue;\n }\n }\n\n return result as T;\n};\n\nlet cachedTokens: SpectreTokens | null = null;\n\nconst getRequire = (): ((id: string) => unknown) | null => {\n try {\n // eslint-disable-next-line no-new-func\n return Function(\"return typeof require !== 'undefined' ? require : null\")() as\n | ((id: string) => unknown)\n | null;\n } catch {\n return null;\n }\n};\n\nconst resolveTokens = (tokens?: SpectreTokens): SpectreTokens => {\n if (tokens) return tokens;\n if (cachedTokens) return cachedTokens;\n\n const req = getRequire();\n if (!req) {\n throw new Error(\n \"[spectre-ui] Unable to load spectre tokens; pass tokens to createSpectreTailwindPreset.\"\n );\n }\n\n const mod = req(\"../tokens\") as { spectreTokens: SpectreTokens };\n cachedTokens = mod.spectreTokens;\n return cachedTokens;\n};\n\nexport const createSpectreTailwindPreset = (\n options: CreateSpectreTailwindPresetOptions = {}\n): TailwindConfig => {\n const tokens = resolveTokens(options.tokens);\n const { theme } = createSpectreTailwindTheme({ tokens });\n const mergedTheme = deepMerge(\n theme as Record<string, unknown>,\n options.themeOverrides as Record<string, unknown> | undefined\n );\n\n const basePreset: TailwindConfig = {\n content: [],\n theme: mergedTheme, // theme is guaranteed non-undefined now\n };\n\n return deepMerge(\n basePreset as Record<string, unknown>,\n options.presetOverrides as Record<string, unknown> | undefined\n ) as TailwindConfig;\n};\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Config } from 'tailwindcss';
|
|
2
|
+
import { SpectreTokens } from '@phcdevworks/spectre-tokens';
|
|
3
|
+
|
|
4
|
+
type TailwindTheme$1 = NonNullable<Config["theme"]>;
|
|
5
|
+
interface SpectreTailwindTheme {
|
|
6
|
+
theme: TailwindTheme$1;
|
|
7
|
+
}
|
|
8
|
+
interface CreateSpectreTailwindThemeOptions {
|
|
9
|
+
tokens: SpectreTokens;
|
|
10
|
+
overrides?: Partial<SpectreTokens>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Minimal, type-safe theme mapper.
|
|
14
|
+
* Important: theme is NEVER undefined (fixes exactOptionalPropertyTypes + DTS).
|
|
15
|
+
*/
|
|
16
|
+
declare function createSpectreTailwindTheme(options: CreateSpectreTailwindThemeOptions): SpectreTailwindTheme;
|
|
17
|
+
|
|
18
|
+
type TailwindTheme = NonNullable<Config["theme"]>;
|
|
19
|
+
interface CreateSpectreTailwindPresetOptions {
|
|
20
|
+
tokens?: SpectreTokens;
|
|
21
|
+
themeOverrides?: TailwindTheme;
|
|
22
|
+
presetOverrides?: Config;
|
|
23
|
+
}
|
|
24
|
+
declare const createSpectreTailwindPreset: (options?: CreateSpectreTailwindPresetOptions) => Config;
|
|
25
|
+
|
|
26
|
+
export { type CreateSpectreTailwindThemeOptions, type SpectreTailwindTheme, createSpectreTailwindPreset, createSpectreTailwindTheme };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Config } from 'tailwindcss';
|
|
2
|
+
import { SpectreTokens } from '@phcdevworks/spectre-tokens';
|
|
3
|
+
|
|
4
|
+
type TailwindTheme$1 = NonNullable<Config["theme"]>;
|
|
5
|
+
interface SpectreTailwindTheme {
|
|
6
|
+
theme: TailwindTheme$1;
|
|
7
|
+
}
|
|
8
|
+
interface CreateSpectreTailwindThemeOptions {
|
|
9
|
+
tokens: SpectreTokens;
|
|
10
|
+
overrides?: Partial<SpectreTokens>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Minimal, type-safe theme mapper.
|
|
14
|
+
* Important: theme is NEVER undefined (fixes exactOptionalPropertyTypes + DTS).
|
|
15
|
+
*/
|
|
16
|
+
declare function createSpectreTailwindTheme(options: CreateSpectreTailwindThemeOptions): SpectreTailwindTheme;
|
|
17
|
+
|
|
18
|
+
type TailwindTheme = NonNullable<Config["theme"]>;
|
|
19
|
+
interface CreateSpectreTailwindPresetOptions {
|
|
20
|
+
tokens?: SpectreTokens;
|
|
21
|
+
themeOverrides?: TailwindTheme;
|
|
22
|
+
presetOverrides?: Config;
|
|
23
|
+
}
|
|
24
|
+
declare const createSpectreTailwindPreset: (options?: CreateSpectreTailwindPresetOptions) => Config;
|
|
25
|
+
|
|
26
|
+
export { type CreateSpectreTailwindThemeOptions, type SpectreTailwindTheme, createSpectreTailwindPreset, createSpectreTailwindTheme };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/tailwind/theme.ts
|
|
2
|
+
function createSpectreTailwindTheme(options) {
|
|
3
|
+
const mergedTokens = {
|
|
4
|
+
...options.tokens ?? {},
|
|
5
|
+
...options.overrides ?? {}
|
|
6
|
+
};
|
|
7
|
+
const t = mergedTokens;
|
|
8
|
+
const colors = t.colors ?? t.color ?? t.palette ?? {};
|
|
9
|
+
const spacing = t.spacing ?? t.space ?? {};
|
|
10
|
+
const borderRadius = t.radii ?? t.radius ?? {};
|
|
11
|
+
const boxShadow = t.shadows ?? t.shadow ?? {};
|
|
12
|
+
const fontFamily = t.typography?.families ?? t.fonts ?? {};
|
|
13
|
+
const fontSize = t.typography?.scale ?? t.fontSize ?? {};
|
|
14
|
+
const theme = {
|
|
15
|
+
colors,
|
|
16
|
+
spacing,
|
|
17
|
+
borderRadius,
|
|
18
|
+
boxShadow,
|
|
19
|
+
fontFamily,
|
|
20
|
+
fontSize
|
|
21
|
+
};
|
|
22
|
+
return { theme };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/tailwind/preset.ts
|
|
26
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
|
+
var deepMerge = (base, overrides) => {
|
|
28
|
+
if (!overrides) return base;
|
|
29
|
+
const result = { ...base };
|
|
30
|
+
for (const [key, overrideValue] of Object.entries(overrides)) {
|
|
31
|
+
const baseValue = result[key];
|
|
32
|
+
if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {
|
|
33
|
+
result[key] = deepMerge(baseValue, overrideValue);
|
|
34
|
+
} else {
|
|
35
|
+
result[key] = overrideValue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var cachedTokens = null;
|
|
41
|
+
var getRequire = () => {
|
|
42
|
+
try {
|
|
43
|
+
return Function("return typeof require !== 'undefined' ? require : null")();
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var resolveTokens = (tokens) => {
|
|
49
|
+
if (tokens) return tokens;
|
|
50
|
+
if (cachedTokens) return cachedTokens;
|
|
51
|
+
const req = getRequire();
|
|
52
|
+
if (!req) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"[spectre-ui] Unable to load spectre tokens; pass tokens to createSpectreTailwindPreset."
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
const mod = req("../tokens");
|
|
58
|
+
cachedTokens = mod.spectreTokens;
|
|
59
|
+
return cachedTokens;
|
|
60
|
+
};
|
|
61
|
+
var createSpectreTailwindPreset = (options = {}) => {
|
|
62
|
+
const tokens = resolveTokens(options.tokens);
|
|
63
|
+
const { theme } = createSpectreTailwindTheme({ tokens });
|
|
64
|
+
const mergedTheme = deepMerge(
|
|
65
|
+
theme,
|
|
66
|
+
options.themeOverrides
|
|
67
|
+
);
|
|
68
|
+
const basePreset = {
|
|
69
|
+
content: [],
|
|
70
|
+
theme: mergedTheme
|
|
71
|
+
// theme is guaranteed non-undefined now
|
|
72
|
+
};
|
|
73
|
+
return deepMerge(
|
|
74
|
+
basePreset,
|
|
75
|
+
options.presetOverrides
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { createSpectreTailwindPreset, createSpectreTailwindTheme };
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tailwind/theme.ts","../../src/tailwind/preset.ts"],"names":[],"mappings":";AAkBO,SAAS,2BACd,OAAA,EACsB;AACtB,EAAA,MAAM,YAAA,GAAe;AAAA,IACnB,GAAI,OAAA,CAAQ,MAAA,IAAW,EAAC;AAAA,IACxB,GAAI,OAAA,CAAQ,SAAA,IAAa;AAAC,GAC5B;AAIA,EAAA,MAAM,CAAA,GAAS,YAAA;AAEf,EAAA,MAAM,SAAU,CAAA,CAAE,MAAA,IAAU,EAAE,KAAA,IAAS,CAAA,CAAE,WAAW,EAAC;AACrD,EAAA,MAAM,OAAA,GAAW,CAAA,CAAE,OAAA,IAAW,CAAA,CAAE,SAAS,EAAC;AAC1C,EAAA,MAAM,YAAA,GAAgB,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,UAAU,EAAC;AAC9C,EAAA,MAAM,SAAA,GAAa,CAAA,CAAE,OAAA,IAAW,CAA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AA,EAG5E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAA;AAEA,IAAM,aAAA,GAAgB,CAAC,MAAA,KAA0C;AAC/D,EAAA,IAAI,QAAQ,OAAO,MAAA;AACnB,EAAA,IAAI,cAAc,OAAO,YAAA;AAEzB,EAAA,MAAM,MAAM,UAAA,EAAW;AACvB,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAEA,EAAA,MAAM,GAAA,GAAM,IAAI,WAAW,CAAA;AAC3B,EAAA,YAAA,GAAe,GAAA,CAAI,aAAA;AACnB,EAAA,OAAO,YAAA;AACT,CAAA;AAEO,IAAM,2BAAA,GAA8B,CACzC,OAAA,GAA8C,EAAC,KAC5B;AACnB,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,OAAA,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,0BAAA,CAA2B,EAAE,QAAQ,CAAA;AACvD,EAAA,MAAM,WAAA,GAAc,SAAA;AAAA,IAClB,KAAA;AAAA,IACA,OAAA,CAAQ;AAAA,GACV;AAEA,EAAA,MAAM,UAAA,GAA6B;AAAA,IACjC,SAAS,EAAC;AAAA,IACV,KAAA,EAAO;AAAA;AAAA,GACT;AAEA,EAAA,OAAO,SAAA;AAAA,IACL,UAAA;AAAA,IACA,OAAA,CAAQ;AAAA,GACV;AACF","file":"index.js","sourcesContent":["import type { Config as TailwindConfig } from \"tailwindcss\";\nimport type { SpectreTokens } from \"../tokens\";\n\ntype TailwindTheme = NonNullable<TailwindConfig[\"theme\"]>;\n\nexport interface SpectreTailwindTheme {\n theme: TailwindTheme;\n}\n\nexport interface CreateSpectreTailwindThemeOptions {\n tokens: SpectreTokens;\n overrides?: Partial<SpectreTokens>;\n}\n\n/**\n * Minimal, type-safe theme mapper.\n * Important: theme is NEVER undefined (fixes exactOptionalPropertyTypes + DTS).\n */\nexport function createSpectreTailwindTheme(\n options: CreateSpectreTailwindThemeOptions\n): SpectreTailwindTheme {\n const mergedTokens = {\n ...(options.tokens ?? ({} as SpectreTokens)),\n ...(options.overrides ?? {}),\n } as SpectreTokens;\n\n // We keep mapping shallow + permissive because token shapes will evolve.\n // Tailwind accepts nested objects of strings for colors.\n const t: any = mergedTokens;\n\n const colors = (t.colors ?? t.color ?? t.palette ?? {}) as Record<string, any>;\n const spacing = (t.spacing ?? t.space ?? {}) as Record<string, any>;\n const borderRadius = (t.radii ?? t.radius ?? {}) as Record<string, any>;\n const boxShadow = (t.shadows ?? t.shadow ?? {}) as Record<string, any>;\n const fontFamily = (t.typography?.families ?? t.fonts ?? {}) as Record<string, any>;\n const fontSize = (t.typography?.scale ?? t.fontSize ?? {}) as Record<string, any>;\n\n const theme: TailwindTheme = {\n colors: colors as any,\n spacing: spacing as any,\n borderRadius: borderRadius as any,\n boxShadow: boxShadow as any,\n fontFamily: fontFamily as any,\n fontSize: fontSize as any,\n };\n\n return { theme };\n}\n","import type { Config as TailwindConfig } from \"tailwindcss\";\nimport type { SpectreTokens } from \"../tokens\";\nimport { createSpectreTailwindTheme } from \"./theme\";\n\ntype TailwindTheme = NonNullable<TailwindConfig[\"theme\"]>;\n\nexport interface CreateSpectreTailwindPresetOptions {\n tokens?: SpectreTokens;\n themeOverrides?: TailwindTheme;\n presetOverrides?: TailwindConfig;\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n// Deep-merge plain objects only; arrays and primitives replace by override.\nconst deepMerge = <T extends Record<string, unknown>>(\n base: T,\n overrides?: Record<string, unknown>\n): T => {\n if (!overrides) return base;\n\n const result: Record<string, unknown> = { ...base };\n\n for (const [key, overrideValue] of Object.entries(overrides)) {\n const baseValue = result[key];\n if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {\n result[key] = deepMerge(baseValue, overrideValue);\n } else {\n result[key] = overrideValue;\n }\n }\n\n return result as T;\n};\n\nlet cachedTokens: SpectreTokens | null = null;\n\nconst getRequire = (): ((id: string) => unknown) | null => {\n try {\n // eslint-disable-next-line no-new-func\n return Function(\"return typeof require !== 'undefined' ? require : null\")() as\n | ((id: string) => unknown)\n | null;\n } catch {\n return null;\n }\n};\n\nconst resolveTokens = (tokens?: SpectreTokens): SpectreTokens => {\n if (tokens) return tokens;\n if (cachedTokens) return cachedTokens;\n\n const req = getRequire();\n if (!req) {\n throw new Error(\n \"[spectre-ui] Unable to load spectre tokens; pass tokens to createSpectreTailwindPreset.\"\n );\n }\n\n const mod = req(\"../tokens\") as { spectreTokens: SpectreTokens };\n cachedTokens = mod.spectreTokens;\n return cachedTokens;\n};\n\nexport const createSpectreTailwindPreset = (\n options: CreateSpectreTailwindPresetOptions = {}\n): TailwindConfig => {\n const tokens = resolveTokens(options.tokens);\n const { theme } = createSpectreTailwindTheme({ tokens });\n const mergedTheme = deepMerge(\n theme as Record<string, unknown>,\n options.themeOverrides as Record<string, unknown> | undefined\n );\n\n const basePreset: TailwindConfig = {\n content: [],\n theme: mergedTheme, // theme is guaranteed non-undefined now\n };\n\n return deepMerge(\n basePreset as Record<string, unknown>,\n options.presetOverrides as Record<string, unknown> | undefined\n ) as TailwindConfig;\n};\n"]}
|
package/dist/utilities.css
CHANGED
|
@@ -2,29 +2,28 @@
|
|
|
2
2
|
.sp-stack {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
|
-
gap: var(--sp-space-md, 1rem);
|
|
5
|
+
gap: var(--sp-layout-stack-gap-md, var(--sp-space-md, 1rem));
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.sp-hstack {
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: row;
|
|
11
11
|
align-items: center;
|
|
12
|
-
gap: var(--sp-space-md, 1rem);
|
|
12
|
+
gap: var(--sp-layout-stack-gap-md, var(--sp-space-md, 1rem));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.sp-container {
|
|
16
16
|
width: 100%;
|
|
17
17
|
margin-left: auto;
|
|
18
18
|
margin-right: auto;
|
|
19
|
-
padding-left: var(--sp-space-md, 1rem);
|
|
20
|
-
padding-right: var(--sp-space-md, 1rem);
|
|
21
|
-
max-width: var(--sp-container-max-width,
|
|
22
|
-
var(--sp-breakpoint-2xl, 72rem));
|
|
19
|
+
padding-left: var(--sp-layout-container-padding-inline-md, var(--sp-space-md, 1rem));
|
|
20
|
+
padding-right: var(--sp-layout-container-padding-inline-md, var(--sp-space-md, 1rem));
|
|
21
|
+
max-width: var(--sp-container-max-width, 72rem);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
.sp-section {
|
|
26
|
-
padding-top: var(--sp-space-2xl, 3rem);
|
|
27
|
-
padding-bottom: var(--sp-space-2xl, 3rem);
|
|
25
|
+
padding-top: var(--sp-layout-section-padding-md, var(--sp-space-2xl, 3rem));
|
|
26
|
+
padding-bottom: var(--sp-layout-section-padding-md, var(--sp-space-2xl, 3rem));
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
.sp-shadow-soft {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phcdevworks/spectre-ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Framework-agnostic UI layer for the Spectre design system. Provides base CSS, component classes, utilities, and a Tailwind preset powered by @phcdevworks/spectre-tokens.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"phcdevworks",
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"import": "./dist/index.js",
|
|
48
48
|
"require": "./dist/index.cjs"
|
|
49
49
|
},
|
|
50
|
+
"./tailwind": {
|
|
51
|
+
"types": "./dist/tailwind/index.d.ts",
|
|
52
|
+
"import": "./dist/tailwind/index.js",
|
|
53
|
+
"require": "./dist/tailwind/index.cjs"
|
|
54
|
+
},
|
|
50
55
|
"./index.css": "./dist/index.css",
|
|
51
56
|
"./base.css": "./dist/base.css",
|
|
52
57
|
"./components.css": "./dist/components.css",
|
|
@@ -71,7 +76,7 @@
|
|
|
71
76
|
"tailwindcss": "^3.4.0 || ^4.0.0"
|
|
72
77
|
},
|
|
73
78
|
"dependencies": {
|
|
74
|
-
"@phcdevworks/spectre-tokens": "^0.
|
|
79
|
+
"@phcdevworks/spectre-tokens": "^0.2.0"
|
|
75
80
|
},
|
|
76
81
|
"devDependencies": {
|
|
77
82
|
"autoprefixer": "^10.4.20",
|