synthesisui 0.16.511 → 0.16.512

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/cn-codegen.js +40 -3
  2. package/package.json +1 -1
@@ -150,7 +150,7 @@ function borderGroup(variants: string, rest: string, cls: string): string {
150
150
  (tail.startsWith("[") && !isArbitraryColor(tail));
151
151
  if (isWidth) return \`\${variants}border\${side}-width\`;
152
152
  if (BORDER_STYLES.has(tail)) return \`\${variants}border-style\`;
153
- if (COLORS.has(tail) || COLOR_KEYWORDS.has(tail) || isArbitraryColor(tail)) {
153
+ if (COLORS.has(tail) || COLOR_KEYWORDS.has(tail) || isPaletteStep(tail) || isArbitraryColor(tail)) {
154
154
  return \`\${variants}border\${side}-color\`;
155
155
  }
156
156
  return \`\${variants}\${cls}\`;
@@ -166,9 +166,32 @@ function isArbitraryColor(v: string): boolean {
166
166
  * Returning the class itself is the safe answer: an unknown class then collides
167
167
  * only with an identical one, so nothing is ever dropped by mistake.
168
168
  */
169
+ /**
170
+ * THE LAST COLON OUTSIDE BRACKETS ends the variants. \`data-[disabled]:[opacity:0.5]\` has a colon INSIDE the
171
+ * arbitrary property, and \`lastIndexOf\` cut there.
172
+ */
173
+ function variantCut(cls: string): number {
174
+ let depth = 0;
175
+ let cut = -1;
176
+ for (let i = 0; i < cls.length; i++) {
177
+ const ch = cls[i];
178
+ if (ch === "[") depth++;
179
+ else if (ch === "]") depth--;
180
+ else if (ch === ":" && depth === 0) cut = i;
181
+ }
182
+ return cut;
183
+ }
184
+
185
+ /** A palette colour with a step - \`sand-900\`, \`moss-600\` - is a colour even when the system does not name it. */
186
+ function isPaletteStep(v: string): boolean {
187
+ return /^[a-z]+(-[a-z]+)*-[0-9]{2,3}$/.test(v);
188
+ }
189
+
190
+ const OUTLINE_STYLES = new Set(["none", "dashed", "dotted", "double", "hidden"]);
191
+
169
192
  function groupOf(cls: string): string {
170
193
  // A variant is part of the identity: \`hover:bg-x\` must not replace \`bg-y\`.
171
- const cut = cls.lastIndexOf(":");
194
+ const cut = variantCut(cls);
172
195
  const variants = cut === -1 ? "" : cls.slice(0, cut + 1);
173
196
  let base = cut === -1 ? cls : cls.slice(cut + 1);
174
197
 
@@ -179,6 +202,10 @@ function groupOf(cls: string): string {
179
202
 
180
203
  if (DISPLAYS.has(base)) return \`\${variants}display\`;
181
204
 
205
+ // \`[transition:…]\` sets exactly the property it names - grouped by it, so the caller's replaces the base's.
206
+ const arbitrary = /^\\[([a-z-]+):/.exec(base);
207
+ if (arbitrary) return \`\${variants}\${arbitrary[1]}\`;
208
+
182
209
  const dash = base.indexOf("-");
183
210
  const head = dash === -1 ? base : base.slice(0, dash);
184
211
  const rest = dash === -1 ? "" : base.slice(dash + 1);
@@ -197,7 +224,7 @@ function groupOf(cls: string): string {
197
224
  // The two families a prefix cannot settle, answered by this system's names.
198
225
  if (head === "text") {
199
226
  if (TEXT_SIZES.has(rest)) return \`\${variants}font-size\`;
200
- if (COLORS.has(rest) || rest.startsWith("[")) return \`\${variants}text-color\`;
227
+ if (COLORS.has(rest) || isPaletteStep(rest) || rest.startsWith("[")) return \`\${variants}text-color\`;
201
228
  return \`\${variants}\${cls}\`;
202
229
  }
203
230
  if (head === "font") {
@@ -206,6 +233,16 @@ function groupOf(cls: string): string {
206
233
  return \`\${variants}\${cls}\`;
207
234
  }
208
235
  if (head === "border") return borderGroup(variants, rest, cls);
236
+ // Every \`transition-*\` sets transition-property, and so does \`[transition:…]\`.
237
+ if (head === "transition") return \`\${variants}transition\`;
238
+ if (head === "outline") {
239
+ if (rest.startsWith("offset")) return \`\${variants}outline-offset\`;
240
+ if (rest === "" || OUTLINE_STYLES.has(rest)) return \`\${variants}outline-style\`;
241
+ if ([...rest].every((ch) => ch >= "0" && ch <= "9")) return \`\${variants}outline-width\`;
242
+ if (COLORS.has(rest) || COLOR_KEYWORDS.has(rest) || isPaletteStep(rest) || isArbitraryColor(rest))
243
+ return \`\${variants}outline-color\`;
244
+ return \`\${variants}\${cls}\`;
245
+ }
209
246
 
210
247
  for (const p of PREFIXES) {
211
248
  if (base === p || base.startsWith(\`\${p}-\`)) return \`\${variants}\${p}\`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synthesisui",
3
- "version": "0.16.511",
3
+ "version": "0.16.512",
4
4
  "description": "Bring SynthesisUI design systems into any project - tokens, typed components, whole pages and an agent-ready CLAUDE.md manifest.",
5
5
  "type": "module",
6
6
  "bin": {