soma-kit 0.1.7 → 0.1.10

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.
@@ -31,11 +31,11 @@ export interface KitThemeConfig {
31
31
  /** 极性:light / dark / system / soft;缺省 system */
32
32
  mode?: 'light' | 'dark' | 'system' | 'soft';
33
33
  /** 界面规格密度档:compact(默认,中后台紧凑标准)| standard(宽松均衡档) */
34
- density?: 'compact' | 'standard';
34
+ density?: 'compact' | 'standard' | 'COMPACT_DENSE' | 'STANDARD_BALANCED' | 'SPACIOUS_AIRY' | 'comfortable' | 'spacious';
35
35
  }
36
36
 
37
37
  export const KIT_THEME_MODES: readonly string[] = ['light', 'dark', 'system', 'soft'];
38
- export const KIT_THEME_DENSITIES: readonly string[] = ['compact', 'standard'];
38
+ export const KIT_THEME_DENSITIES: readonly string[] = ['compact', 'standard', 'COMPACT_DENSE', 'STANDARD_BALANCED', 'SPACIOUS_AIRY', 'comfortable', 'spacious'];
39
39
  const HEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
40
40
 
41
41
  export interface KitThemeTokensResult {
@@ -57,9 +57,23 @@ function tableDiff(base: Readonly<Record<string, string>>, next: Readonly<Record
57
57
 
58
58
  /** 令牌表 -> CSS 文本(极性决定发哪几块,格式与 soma-lite / soma-ui 同一份 foundation 规则) */
59
59
  export function serializeTokenTables(tables: TokenTables): string {
60
- if (tables.polarity === 'dark') return tokenBlock(':root', tables.dark, ['color-scheme: dark;']);
61
- const parts = [tokenBlock(':root', tables.light, ['color-scheme: light;'])];
62
- const darkOnly = tableDiff(tables.light, tables.dark);
60
+ const light: Record<string, string> = {
61
+ ...tables.light,
62
+ '--soma-border-hairline': 'rgba(15, 23, 42, 0.08)',
63
+ '--soma-border-strong': 'rgba(15, 23, 42, 0.14)',
64
+ '--soma-border-control': 'rgba(15, 23, 42, 0.14)',
65
+ '--soma-border-divider': 'rgba(15, 23, 42, 0.06)',
66
+ };
67
+ const dark: Record<string, string> = {
68
+ ...tables.dark,
69
+ '--soma-border-hairline': 'rgba(255, 255, 255, 0.10)',
70
+ '--soma-border-strong': 'rgba(255, 255, 255, 0.16)',
71
+ '--soma-border-control': 'rgba(255, 255, 255, 0.14)',
72
+ '--soma-border-divider': 'rgba(255, 255, 255, 0.07)',
73
+ };
74
+ if (tables.polarity === 'dark') return tokenBlock(':root', dark, ['color-scheme: dark;']);
75
+ const parts = [tokenBlock(':root', light, ['color-scheme: light;'])];
76
+ const darkOnly = tableDiff(light, dark);
63
77
  const system = tables.polarity === 'system';
64
78
  if (Object.keys(darkOnly).length > 0) {
65
79
  parts.push(...darkSchemeRules(undefined, ['color-scheme: dark;', ...Object.entries(darkOnly).map(([k, v]) => `${k}: ${v};`)], system));