create-prisma-php-app 3.3.14 → 3.3.15

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.
@@ -68,7 +68,7 @@ class PHPX implements IPHPX
68
68
  unset($chunk);
69
69
 
70
70
  $merged = PrismaPHPSettings::$option->tailwindcss
71
- ? TwMerge::mergeClasses(...$all)
71
+ ? TwMerge::merge(...$all)
72
72
  : $this->mergeClasses(...$all);
73
73
 
74
74
  return str_replace(array_keys($expr), array_values($expr), $merged);
@@ -6,8 +6,6 @@ namespace Lib\PHPX;
6
6
 
7
7
  class TwMerge
8
8
  {
9
- private const IMPORTANT_MODIFIER = '!';
10
-
11
9
  private static array $classGroups = [
12
10
  // Layout
13
11
  'aspect' => ['aspect-auto', 'aspect-square', 'aspect-video', '/^aspect-\[.+\]$/'],
@@ -92,13 +90,13 @@ class TwMerge
92
90
  'space-y' => ['/^-?space-y-(\d+(\.\d+)?|px|reverse|\[.+\])$/'],
93
91
 
94
92
  // Sizing
95
- 'w' => ['/^w-(\d+(\.\d+)?\/\d+|\d+(\.\d+)?|auto|px|full|screen|svw|lvw|dvw|min|max|fit|\[.+\])$/'],
96
- 'min-w' => ['/^min-w-(\d+|px|full|min|max|fit|\[.+\])$/'],
97
- 'max-w' => ['/^max-w-(\d+|px|full|min|max|fit|prose|screen-\w+|\[.+\])$/'],
98
- 'h' => ['/^h-(\d+(\.\d+)?\/\d+|\d+(\.\d+)?|auto|px|full|screen|svh|lvh|dvh|min|max|fit|\[.+\])$/'],
99
- 'min-h' => ['/^min-h-(\d+|px|full|screen|svh|lvh|dvh|min|max|fit|\[.+\])$/'],
100
- 'max-h' => ['/^max-h-(\d+|px|full|screen|svh|lvh|dvh|min|max|fit|\[.+\])$/'],
101
- 'size' => ['/^size-(\d+(\.\d+)?|auto|px|full|\[.+\])$/'],
93
+ 'w' => ['/^w-(?!$).+$/'],
94
+ 'min-w' => ['/^min-w-(?!$).+$/'],
95
+ 'max-w' => ['/^max-w-(?!$).+$/'],
96
+ 'h' => ['/^h-(?!$).+$/'],
97
+ 'min-h' => ['/^min-h-(?!$).+$/'],
98
+ 'max-h' => ['/^max-h-(?!$).+$/'],
99
+ 'size' => ['/^size-(?!$).+$/'],
102
100
 
103
101
  // Typography
104
102
  'font-family' => ['/^font-(sans|serif|mono|\[.+\])$/'],
@@ -114,9 +112,9 @@ class TwMerge
114
112
  'list-style-position' => ['/^list-(inside|outside)$/'],
115
113
  'list-style-type' => ['/^list-(none|disc|decimal|\[.+\])$/'],
116
114
  'text-align' => ['/^text-(left|center|right|justify|start|end)$/'],
117
- 'text-color' => ['/^text-(inherit|current|transparent|black|white|slate-\d+|gray-\d+|zinc-\d+|neutral-\d+|stone-\d+|red-\d+|orange-\d+|amber-\d+|yellow-\d+|lime-\d+|green-\d+|emerald-\d+|teal-\d+|cyan-\d+|sky-\d+|blue-\d+|indigo-\d+|violet-\d+|purple-\d+|fuchsia-\d+|pink-\d+|rose-\d+|\[.+\])$/'],
115
+ 'text-color' => ['/^text-(?!xs$|sm$|base$|lg$|xl$|[2-9]xl$).+$/'],
118
116
  'text-decoration' => ['underline', 'overline', 'line-through', 'no-underline'],
119
- 'text-decoration-color' => ['/^decoration-(inherit|current|transparent|black|white|slate-\d+|gray-\d+|zinc-\d+|neutral-\d+|stone-\d+|red-\d+|orange-\d+|amber-\d+|yellow-\d+|lime-\d+|green-\d+|emerald-\d+|teal-\d+|cyan-\d+|sky-\d+|blue-\d+|indigo-\d+|violet-\d+|purple-\d+|fuchsia-\d+|pink-\d+|rose-\d+|\[.+\])$/'],
117
+ 'text-decoration-color' => ['/^decoration-(?!auto$|from-font$|\d+$|px$).+$/'],
120
118
  'text-decoration-style' => ['/^decoration-(solid|double|dotted|dashed|wavy)$/'],
121
119
  'text-decoration-thickness' => ['/^decoration-(auto|from-font|\d+|px|\[.+\])$/'],
122
120
  'text-underline-offset' => ['/^underline-offset-(auto|\d+|px|\[.+\])$/'],
@@ -132,15 +130,15 @@ class TwMerge
132
130
  // Backgrounds
133
131
  'bg-attachment' => ['/^bg-(fixed|local|scroll)$/'],
134
132
  'bg-clip' => ['/^bg-clip-(border|padding|content|text)$/'],
135
- 'bg-color' => ['/^bg-(inherit|current|transparent|black|white|slate-\d+|gray-\d+|zinc-\d+|neutral-\d+|stone-\d+|red-\d+|orange-\d+|amber-\d+|yellow-\d+|lime-\d+|green-\d+|emerald-\d+|teal-\d+|cyan-\d+|sky-\d+|blue-\d+|indigo-\d+|violet-\d+|purple-\d+|fuchsia-\d+|pink-\d+|rose-\d+|\[.+\])$/'],
133
+ 'bg-color' => ['/^bg-(?!fixed$|local$|scroll$|clip-|origin-|no-repeat$|repeat|auto$|cover$|contain$|none$|gradient-to-).+$/'],
136
134
  'bg-origin' => ['/^bg-origin-(border|padding|content)$/'],
137
135
  'bg-position' => ['/^bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top|\[.+\])$/'],
138
136
  'bg-repeat' => ['/^bg-(no-repeat|repeat|repeat-x|repeat-y|repeat-round|repeat-space)$/'],
139
137
  'bg-size' => ['/^bg-(auto|cover|contain|\[.+\])$/'],
140
138
  'bg-image' => ['/^bg-(none|gradient-to-(t|tr|r|br|b|bl|l|tl)|\[.+\])$/'],
141
- 'gradient-from' => ['/^from-(inherit|current|transparent|black|white|slate-\d+|gray-\d+|zinc-\d+|neutral-\d+|stone-\d+|red-\d+|orange-\d+|amber-\d+|yellow-\d+|lime-\d+|green-\d+|emerald-\d+|teal-\d+|cyan-\d+|sky-\d+|blue-\d+|indigo-\d+|violet-\d+|purple-\d+|fuchsia-\d+|pink-\d+|rose-\d+|\[.+\])$/'],
142
- 'gradient-via' => ['/^via-(inherit|current|transparent|black|white|slate-\d+|gray-\d+|zinc-\d+|neutral-\d+|stone-\d+|red-\d+|orange-\d+|amber-\d+|yellow-\d+|lime-\d+|green-\d+|emerald-\d+|teal-\d+|cyan-\d+|sky-\d+|blue-\d+|indigo-\d+|violet-\d+|purple-\d+|fuchsia-\d+|pink-\d+|rose-\d+|\[.+\])$/'],
143
- 'gradient-to' => ['/^to-(inherit|current|transparent|black|white|slate-\d+|gray-\d+|zinc-\d+|neutral-\d+|stone-\d+|red-\d+|orange-\d+|amber-\d+|yellow-\d+|lime-\d+|green-\d+|emerald-\d+|teal-\d+|cyan-\d+|sky-\d+|blue-\d+|indigo-\d+|violet-\d+|purple-\d+|fuchsia-\d+|pink-\d+|rose-\d+|\[.+\])$/'],
139
+ 'gradient-from' => ['/^from-.+$/'],
140
+ 'gradient-via' => ['/^via-.+$/'],
141
+ 'gradient-to' => ['/^to-.+$/'],
144
142
 
145
143
  // Borders
146
144
  'rounded' => ['/^rounded(-(\w+))?(-(\d+(\.\d+)?|px|full|\[.+\]))?$/'],
@@ -242,6 +240,8 @@ class TwMerge
242
240
  'mx' => ['mr', 'ml'],
243
241
  'my' => ['mt', 'mb'],
244
242
  'font-size' => ['line-height'],
243
+ 'bg-color' => ['bg-color'],
244
+ 'text-color' => ['text-color'],
245
245
  'fvn-normal' => ['fvn-ordinal', 'fvn-slashed-zero', 'fvn-figure', 'fvn-spacing', 'fvn-fraction'],
246
246
  'rounded' => ['rounded-s', 'rounded-e', 'rounded-t', 'rounded-r', 'rounded-b', 'rounded-l', 'rounded-ss', 'rounded-se', 'rounded-ee', 'rounded-es', 'rounded-tl', 'rounded-tr', 'rounded-br', 'rounded-bl'],
247
247
  'rounded-s' => ['rounded-ss', 'rounded-es'],
@@ -269,12 +269,7 @@ class TwMerge
269
269
  'scroll-py' => ['scroll-pt', 'scroll-pb'],
270
270
  ];
271
271
 
272
- public static function merge(string ...$inputs): string
273
- {
274
- return self::twMerge(...$inputs);
275
- }
276
-
277
- public static function twMerge(string|array ...$inputs): string
272
+ public static function merge(string|array ...$inputs): string
278
273
  {
279
274
  $allClasses = [];
280
275
 
@@ -292,7 +287,6 @@ class TwMerge
292
287
 
293
288
  private static function mergeClassList(array $classes): string
294
289
  {
295
- $classGroupsInConflict = [];
296
290
  $result = [];
297
291
 
298
292
  foreach ($classes as $originalClass) {
@@ -300,96 +294,53 @@ class TwMerge
300
294
  continue;
301
295
  }
302
296
 
303
- $modifiersAndClass = self::parseClass($originalClass);
304
- $modifiers = $modifiersAndClass['modifiers'];
305
- $baseClass = $modifiersAndClass['baseClass'];
306
- $hasImportantModifier = $modifiersAndClass['hasImportantModifier'];
307
-
308
- $classGroup = self::getClassGroup($baseClass);
309
- if (!$classGroup) {
310
- $result[] = $originalClass;
311
- continue;
312
- }
313
-
314
- $variantModifier = implode(':', $modifiers);
315
- $modifierId = $hasImportantModifier ? $variantModifier . self::IMPORTANT_MODIFIER : $variantModifier;
316
- $classGroupId = $modifierId . ':' . $classGroup;
317
-
318
- $conflictGroups = self::getConflictingClassGroups($classGroup);
297
+ $classKey = self::getClassGroup($originalClass);
319
298
 
320
- foreach ($conflictGroups as $group) {
321
- $groupId = $modifierId . ':' . $group;
322
- if (isset($classGroupsInConflict[$groupId])) {
323
- unset($result[array_search($classGroupsInConflict[$groupId], $result)]);
324
- }
325
- unset($classGroupsInConflict[$groupId]);
299
+ $conflictingKeys = self::getConflictingKeys($classKey);
300
+ foreach ($conflictingKeys as $key) {
301
+ unset($result[$key]);
326
302
  }
327
303
 
328
- $classGroupsInConflict[$classGroupId] = $originalClass;
329
- $result[] = $originalClass;
304
+ $result[$classKey] = $originalClass;
330
305
  }
331
306
 
332
307
  return implode(' ', array_values($result));
333
308
  }
334
309
 
335
- private static function parseClass(string $className): array
336
- {
337
- $modifiers = [];
338
- $hasImportantModifier = false;
339
- $baseClass = $className;
340
-
341
- if (str_starts_with($className, '!')) {
342
- $hasImportantModifier = true;
343
- $baseClass = substr($className, 1);
344
- }
345
-
346
- $parts = explode(':', $baseClass);
347
- if (count($parts) > 1) {
348
- $baseClass = array_pop($parts);
349
- $modifiers = $parts;
350
- }
351
-
352
- return [
353
- 'modifiers' => $modifiers,
354
- 'baseClass' => $baseClass,
355
- 'hasImportantModifier' => $hasImportantModifier
356
- ];
357
- }
358
-
359
- private static function getClassGroup(string $className): ?string
310
+ private static function getClassGroup(string $class): string
360
311
  {
361
- foreach (self::$classGroups as $groupName => $patterns) {
362
- foreach ($patterns as $pattern) {
363
- if (is_string($pattern) && str_starts_with($pattern, '/')) {
364
- if (preg_match($pattern, $className)) {
365
- return $groupName;
366
- }
367
- } else {
368
- if ($pattern === $className) {
369
- return $groupName;
312
+ $pattern = '/^((?:[^:]+:)*)([^:]+)$/';
313
+ if (preg_match($pattern, $class, $matches)) {
314
+ $prefixes = $matches[1];
315
+ $utilityClass = $matches[2];
316
+
317
+ foreach (self::$classGroups as $groupKey => $patterns) {
318
+ foreach ($patterns as $pattern) {
319
+ if (is_string($pattern) && str_starts_with($pattern, '/')) {
320
+ if (preg_match($pattern, $utilityClass)) {
321
+ return $prefixes . $groupKey;
322
+ }
323
+ } else {
324
+ if ($pattern === $utilityClass) {
325
+ return $prefixes . $groupKey;
326
+ }
370
327
  }
371
328
  }
372
329
  }
330
+ return $prefixes . $utilityClass;
373
331
  }
374
- return null;
332
+ return $class;
375
333
  }
376
334
 
377
- private static function getConflictingClassGroups(string $classGroup): array
335
+ private static function getConflictingKeys(string $classKey): array
378
336
  {
379
- $conflicts = self::$conflictingClassGroups[$classGroup] ?? [];
380
- $allConflicts = [$classGroup];
381
-
382
- foreach ($conflicts as $conflict) {
383
- $allConflicts[] = $conflict;
384
- $nestedConflicts = self::getConflictingClassGroups($conflict);
385
- $allConflicts = array_merge($allConflicts, $nestedConflicts);
337
+ $baseClassKey = preg_replace("/^(?:[^:]+:)+/", "", $classKey);
338
+ if (isset(self::$conflictingClassGroups[$baseClassKey])) {
339
+ $prefix = preg_replace("/" . preg_quote($baseClassKey, "/") . '$/i', "", $classKey);
340
+ return array_map(function ($conflict) use ($prefix) {
341
+ return $prefix . $conflict;
342
+ }, self::$conflictingClassGroups[$baseClassKey]);
386
343
  }
387
-
388
- return array_unique($allConflicts);
389
- }
390
-
391
- public static function mergeClasses(string|array ...$classes): string
392
- {
393
- return self::twMerge(...$classes);
344
+ return [$classKey];
394
345
  }
395
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "3.3.14",
3
+ "version": "3.3.15",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",