myoperator-ui 0.0.6 → 0.0.8

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 +38 -59
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13,65 +13,43 @@ import ora from "ora";
13
13
  // src/utils/registry.ts
14
14
  function prefixTailwindClasses(content, prefix) {
15
15
  if (!prefix) return content;
16
- const patterns = [
17
- // Layout & Display
18
- /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden|table|contents)\b/g,
19
- // Flexbox & Grid
20
- /\b(items-|justify-|gap-|flex-|grid-|col-|row-|place-|self-|order-)/g,
21
- // Spacing
22
- /\b([mp][trblxy]?-\d+|[mp][trblxy]?-\[)/g,
23
- /\b(space-[xy]-)/g,
24
- // Sizing
25
- /\b([wh]-(full|screen|auto|min|max|fit|\d+|px|\[))/g,
26
- /\b(min-[wh]-|max-[wh]-)/g,
27
- // Typography
28
- /\b(text-(?:xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl|left|center|right|justify|wrap|nowrap|ellipsis|clip))\b/g,
29
- /\b(font-(?:sans|serif|mono|thin|extralight|light|normal|medium|semibold|bold|extrabold|black))\b/g,
30
- /\b(leading-|tracking-|whitespace-)/g,
31
- // Colors (bg, text, border colors)
32
- /\b(bg-|text-|border-|ring-|from-|via-|to-|fill-|stroke-)(?!\[)/g,
33
- // Borders & Rings
34
- /\b(border|rounded|ring|outline)(?:-|$)/g,
35
- // Effects
36
- /\b(shadow|opacity-|blur-|brightness-|contrast-|grayscale|invert|saturate|sepia)/g,
37
- // Transitions & Animations
38
- /\b(transition|duration-|ease-|delay-|animate-)/g,
39
- // Transforms
40
- /\b(scale-|rotate-|translate-|skew-|origin-|transform)/g,
41
- // Interactivity
42
- /\b(cursor-|pointer-events-|resize|select-|scroll-)/g,
43
- // Pseudo-classes prefixes
44
- /\b(hover:|focus:|active:|disabled:|focus-visible:|focus-within:|group-hover:|peer-)/g,
45
- // Responsive prefixes
46
- /\b(sm:|md:|lg:|xl:|2xl:)/g,
47
- // Dark mode
48
- /\b(dark:)/g,
49
- // Other common utilities
50
- /\b(overflow-|z-|relative|absolute|fixed|sticky|inset-|top-|right-|bottom-|left-)/g,
51
- /\b(underline|line-through|no-underline|underline-offset-)/g,
52
- /\b(sr-only|not-sr-only)\b/g
53
- ];
54
- let result = content;
55
- result = result.replace(
56
- /(className=["'`{]|cn\(["'`])([^"'`}]+)(["'`}])/g,
57
- (match, start, classes, end) => {
58
- let prefixedClasses = classes;
59
- prefixedClasses = prefixedClasses.replace(
60
- /(?<=^|\s)([a-z])/g,
61
- (m, char) => `${prefix}${char}`
62
- );
63
- prefixedClasses = prefixedClasses.replace(
64
- /(?<=^|\s)-([a-z])/g,
65
- (m, char) => `-${prefix}${char}`
66
- );
67
- prefixedClasses = prefixedClasses.replace(
68
- new RegExp(`${prefix}(hover|focus|active|disabled|focus-visible|focus-within|group-hover|sm|md|lg|xl|2xl|dark):${prefix}`, "g"),
69
- `${prefix}$1:`
70
- );
71
- return start + prefixedClasses + end;
16
+ return content.replace(/"([^"]+)"/g, (match, classString) => {
17
+ if (classString.includes("/") || classString.includes("::") || classString.includes("import")) {
18
+ return match;
72
19
  }
73
- );
74
- return result;
20
+ if (!classString.includes(" ") && !classString.includes("-") && !classString.includes(":")) {
21
+ return match;
22
+ }
23
+ const prefixedClasses = classString.split(" ").map((cls) => {
24
+ if (!cls) return cls;
25
+ const variantMatch = cls.match(/^([a-z-]+:)+/);
26
+ if (variantMatch) {
27
+ const variants = variantMatch[0];
28
+ const utility = cls.slice(variants.length);
29
+ if (utility.startsWith("-")) {
30
+ return `${variants}-${prefix}${utility.slice(1)}`;
31
+ }
32
+ if (utility.startsWith("[")) {
33
+ return cls;
34
+ }
35
+ return `${variants}${prefix}${utility}`;
36
+ }
37
+ if (cls.startsWith("-")) {
38
+ return `-${prefix}${cls.slice(1)}`;
39
+ }
40
+ if (cls.startsWith("[")) {
41
+ const closeBracket = cls.indexOf("]:");
42
+ if (closeBracket !== -1) {
43
+ const selector = cls.slice(0, closeBracket + 2);
44
+ const utility = cls.slice(closeBracket + 2);
45
+ return `${selector}${prefix}${utility}`;
46
+ }
47
+ return cls;
48
+ }
49
+ return `${prefix}${cls}`;
50
+ }).join(" ");
51
+ return `"${prefixedClasses}"`;
52
+ });
75
53
  }
76
54
  async function getRegistry(prefix = "") {
77
55
  const buttonContent = prefixTailwindClasses(`import * as React from "react"
@@ -354,7 +332,8 @@ var CSS_VARIABLES_V4 = `@import "tailwindcss";
354
332
  --ring: 212.7 26.8% 83.9%;
355
333
  }
356
334
  `;
357
- var CSS_VARIABLES_V4_PREFIXED = `@import "tailwindcss/utilities" layer(utilities);
335
+ var CSS_VARIABLES_V4_PREFIXED = `@import "tailwindcss/theme" layer(theme);
336
+ @import "tailwindcss/utilities" layer(utilities);
358
337
 
359
338
  @theme {
360
339
  --color-background: hsl(0 0% 100%);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",