@vettvangur/design-system 2.0.61 → 2.0.62

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1725,6 +1725,10 @@ function groupColors(variableSet, collectionKey = 'colour') {
1725
1725
  * @generated
1726
1726
  * @module design-system
1727
1727
  */
1728
+ function isFontFamilyKey(key) {
1729
+ // NOTE: accept historical typo "familiy" as well.
1730
+ return key.startsWith('font-family-') || key.startsWith('font-familiy-');
1731
+ }
1728
1732
 
1729
1733
  /**
1730
1734
  * Entries.
@@ -1764,7 +1768,7 @@ function groupTypography(variableSet) {
1764
1768
  console.log('[design-system] typography: token count =', keys.length);
1765
1769
  if (keys.length) {
1766
1770
  console.log('[design-system] typography: token key sample =', keys.slice(0, 25).join(', '));
1767
- const ff = keys.filter(k => k.startsWith('font-family-'));
1771
+ const ff = keys.filter(k => isFontFamilyKey(k));
1768
1772
  console.log('[design-system] typography: font-family key sample =', ff.slice(0, 25).join(', '));
1769
1773
  }
1770
1774
  }
@@ -1776,7 +1780,7 @@ function groupTypography(variableSet) {
1776
1780
  other: {}
1777
1781
  };
1778
1782
  for (const [key, token] of entries$1(toks)) {
1779
- if (key.startsWith('font-family-')) {
1783
+ if (isFontFamilyKey(key)) {
1780
1784
  out.families[key] = token;
1781
1785
  continue;
1782
1786
  }
@@ -2112,6 +2116,10 @@ function normalizeFontKey(rawKey) {
2112
2116
  if (rawKey.startsWith('font-family-')) {
2113
2117
  return rawKey.replace(/^font-family-/, 'font-');
2114
2118
  }
2119
+ // accept common typo
2120
+ if (rawKey.startsWith('font-familiy-')) {
2121
+ return rawKey.replace(/^font-familiy-/, 'font-');
2122
+ }
2115
2123
  if (rawKey.startsWith('font-')) {
2116
2124
  return rawKey;
2117
2125
  }
@@ -2143,6 +2151,37 @@ function normalizeValuesKeys(values) {
2143
2151
  }
2144
2152
  return out;
2145
2153
  }
2154
+ function escapeCssSingleQuotedString(value) {
2155
+ return String(value).replace(/\\/g, '\\\\').replace(/'/g, "\\'");
2156
+ }
2157
+ function formatFontFamilyValue(raw) {
2158
+ if (raw == null) {
2159
+ return raw;
2160
+ }
2161
+ const s = String(raw).trim();
2162
+ if (!s) {
2163
+ return null;
2164
+ }
2165
+
2166
+ // Allow comma-separated stacks and quote parts that would otherwise be parsed as separate identifiers.
2167
+ const parts = s.split(',').map(p => p.trim()).filter(Boolean);
2168
+ const formatted = parts.map(p => {
2169
+ // Keep CSS var() and already-quoted values.
2170
+ if (/^var\(/.test(p)) {
2171
+ return p;
2172
+ }
2173
+ if (p.startsWith("'") && p.endsWith("'") || p.startsWith('"') && p.endsWith('"')) {
2174
+ return p;
2175
+ }
2176
+
2177
+ // Quote anything containing whitespace or special characters.
2178
+ if (/\s/.test(p) || /[^a-zA-Z0-9_-]/.test(p)) {
2179
+ return `'${escapeCssSingleQuotedString(p)}'`;
2180
+ }
2181
+ return p;
2182
+ });
2183
+ return formatted.join(', ');
2184
+ }
2146
2185
 
2147
2186
  /**
2148
2187
  * Generate font family.
@@ -2188,8 +2227,8 @@ async function generateFontFamily(variableSet, config) {
2188
2227
  async function generateFile(variables, config) {
2189
2228
  let css = `/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n` + `@theme {\n`;
2190
2229
  for (const [key, token] of Object.entries(variables || {})) {
2191
- const mobile = token?.values?.mobile;
2192
- const desktop = token?.values?.desktop;
2230
+ const mobile = formatFontFamilyValue(token?.values?.mobile);
2231
+ const desktop = formatFontFamilyValue(token?.values?.desktop);
2193
2232
  if (mobile != null) {
2194
2233
  css += ` --${key}: ${mobile};\n`;
2195
2234
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.61",
3
+ "version": "2.0.62",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",