create-prisma-php-app 2.0.0-beta.15 → 2.0.0-beta.16
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.
- package/dist/src/Lib/PHPX/TwMerge.php +13 -24
- package/package.json +1 -1
|
@@ -96,12 +96,12 @@ class TwMerge
|
|
|
96
96
|
"text-decoration" => ["text-decoration"],
|
|
97
97
|
// **Opacity conflict group**
|
|
98
98
|
"opacity" => ["opacity"],
|
|
99
|
-
// **Flexbox alignment conflict
|
|
99
|
+
// **Flexbox alignment conflict groups**
|
|
100
100
|
"justify" => ["justify"],
|
|
101
101
|
// **Flexbox alignment conflict group**
|
|
102
102
|
"items" => ["items"],
|
|
103
103
|
// **Width conflict group**
|
|
104
|
-
"w" => ["w",
|
|
104
|
+
"w" => ["w"], // Only conflicts with other width classes.
|
|
105
105
|
// **Max-width conflict group**
|
|
106
106
|
"max-w" => ["max-w"],
|
|
107
107
|
// **Add other conflict groups as needed**
|
|
@@ -118,16 +118,16 @@ class TwMerge
|
|
|
118
118
|
$classArray = [];
|
|
119
119
|
|
|
120
120
|
foreach ($classes as $class) {
|
|
121
|
-
// Handle arrays by flattening them into strings
|
|
121
|
+
// Handle arrays by flattening them into strings.
|
|
122
122
|
$classList = is_array($class) ? $class : [$class];
|
|
123
123
|
foreach ($classList as $item) {
|
|
124
124
|
if (!empty(trim($item))) {
|
|
125
|
-
// Split the classes by any whitespace characters
|
|
125
|
+
// Split the classes by any whitespace characters.
|
|
126
126
|
$splitClasses = preg_split("/\s+/", $item);
|
|
127
127
|
foreach ($splitClasses as $individualClass) {
|
|
128
128
|
$classKey = self::getClassGroup($individualClass);
|
|
129
129
|
|
|
130
|
-
// If the class is non-responsive (no colon), remove any responsive variants for the same base
|
|
130
|
+
// If the class is non-responsive (no colon), remove any responsive variants for the same base.
|
|
131
131
|
if (strpos($classKey, ':') === false) {
|
|
132
132
|
$baseGroup = $classKey;
|
|
133
133
|
foreach ($classArray as $existingKey => $existingClass) {
|
|
@@ -137,58 +137,47 @@ class TwMerge
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
//
|
|
141
|
-
$baseClassKey = preg_replace("/^(?:[a-z-]+:)+/", "", $classKey);
|
|
142
|
-
if ($baseClassKey === "max-w") {
|
|
143
|
-
if (preg_match("/^((?:[a-z-]+:)*)max-w$/", $classKey, $prefixMatches)) {
|
|
144
|
-
$prefix = $prefixMatches[1] ?? "";
|
|
145
|
-
} else {
|
|
146
|
-
$prefix = "";
|
|
147
|
-
}
|
|
148
|
-
$wKey = $prefix . "w";
|
|
149
|
-
if (isset($classArray[$wKey])) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Remove conflicting classes based on the conflict groups
|
|
140
|
+
// Remove conflicting classes based on the conflict groups.
|
|
155
141
|
$conflictingKeys = self::getConflictingKeys($classKey);
|
|
156
142
|
foreach ($conflictingKeys as $key) {
|
|
157
143
|
unset($classArray[$key]);
|
|
158
144
|
}
|
|
159
145
|
|
|
160
|
-
// Update the array, prioritizing the last occurrence
|
|
146
|
+
// Update the array, prioritizing the last occurrence.
|
|
161
147
|
$classArray[$classKey] = $individualClass;
|
|
162
148
|
}
|
|
163
149
|
}
|
|
164
150
|
}
|
|
165
151
|
}
|
|
166
152
|
|
|
167
|
-
// Combine the final classes into a single string
|
|
153
|
+
// Combine the final classes into a single string.
|
|
168
154
|
return implode(" ", array_values($classArray));
|
|
169
155
|
}
|
|
170
156
|
|
|
171
157
|
private static function getClassGroup($class)
|
|
172
158
|
{
|
|
173
|
-
// Match optional prefixes (responsive and variants)
|
|
159
|
+
// Match optional prefixes (responsive and variants).
|
|
174
160
|
$pattern = '/^((?:[a-z-]+:)*)(.+)$/';
|
|
175
161
|
if (preg_match($pattern, $class, $matches)) {
|
|
176
162
|
$prefixes = $matches[1];
|
|
177
163
|
$utilityClass = $matches[2];
|
|
178
164
|
|
|
165
|
+
// Match the utilityClass against patterns.
|
|
179
166
|
foreach (self::$classGroupPatterns as $groupKey => $regex) {
|
|
180
167
|
if (preg_match($regex, $utilityClass)) {
|
|
181
168
|
return $prefixes . $groupKey;
|
|
182
169
|
}
|
|
183
170
|
}
|
|
171
|
+
// If no match, use the full class.
|
|
184
172
|
return $prefixes . $utilityClass;
|
|
185
173
|
}
|
|
174
|
+
// For classes without a recognizable prefix, return the class itself.
|
|
186
175
|
return $class;
|
|
187
176
|
}
|
|
188
177
|
|
|
189
178
|
private static function getConflictingKeys($classKey)
|
|
190
179
|
{
|
|
191
|
-
// Remove any responsive or variant prefixes
|
|
180
|
+
// Remove any responsive or variant prefixes.
|
|
192
181
|
$baseClassKey = preg_replace("/^(?:[a-z-]+:)+/", "", $classKey);
|
|
193
182
|
if (isset(self::$conflictGroups[$baseClassKey])) {
|
|
194
183
|
$prefix = preg_replace("/" . preg_quote($baseClassKey, "/") . '$/', "", $classKey);
|