create-prisma-php-app 1.26.529 → 1.26.531

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.
@@ -47,41 +47,59 @@ class PHPX implements IPHPX
47
47
  /**
48
48
  * Combines and returns the CSS classes for the component.
49
49
  *
50
- * This method merges the optional base CSS class with additional classes
51
- * defined in the component's `$class` property. If no base class is provided,
52
- * only the component's `$class` property will be used. It ensures that there
53
- * are no duplicate classes and the classes are properly formatted.
50
+ * This method merges the provided classes, which can be either strings or arrays of strings,
51
+ * with the component's `$class` property. It uses the `Utils::mergeClasses` method to ensure
52
+ * that the resulting CSS class string is optimized, with duplicate or conflicting classes removed.
54
53
  *
55
- * @param string $baseClass The optional base CSS class to be merged. Defaults to an empty string.
56
- * @return string The merged CSS class string.
54
+ * ### Features:
55
+ * - Accepts multiple arguments as strings or arrays of strings.
56
+ * - Automatically merges the provided classes with `$this->class`.
57
+ * - Ensures the final CSS class string is well-formatted and free of conflicts.
58
+ *
59
+ * @param string|array ...$classes The CSS classes to be merged. Each argument can be a string or an array of strings.
60
+ * @return string A single CSS class string with the merged and optimized classes, including `$this->class`.
57
61
  */
58
- protected function getMergeClasses(string $baseClass = ''): string
62
+ protected function getMergeClasses(string|array ...$classes): string
59
63
  {
60
- return TwMerge::mergeClasses($baseClass, $this->class);
64
+ return TwMerge::mergeClasses($classes, $this->class);
61
65
  }
62
66
 
63
67
  /**
64
68
  * Generates and returns a string of HTML attributes from the provided props.
65
69
  * Excludes 'class' and 'children' props from being added as attributes.
66
- *
67
- * @return string The generated HTML attributes.
70
+ * Prioritizes attributes from `$this->props` if duplicates are found in `$params`.
71
+ *
72
+ * @param array $params Optional additional attributes to merge with props.
73
+ *
74
+ * @return string The generated HTML attributes as a space-separated string.
68
75
  */
69
- protected function getAttributes(): string
76
+ protected function getAttributes(array $params = []): string
70
77
  {
71
78
  // Filter out 'class' and 'children' props
72
- $filteredProps = array_filter($this->props, function ($key) {
73
- return !in_array($key, ['class', 'children']);
74
- }, ARRAY_FILTER_USE_KEY);
79
+ $filteredProps = array_filter(
80
+ $this->props,
81
+ function ($key) {
82
+ return !in_array($key, ["class", "children"]);
83
+ },
84
+ ARRAY_FILTER_USE_KEY
85
+ );
86
+
87
+ // Merge attributes, prioritizing props in case of duplicates
88
+ $attributes = array_merge($params, $filteredProps);
75
89
 
76
- // Build attributes string by escaping keys and values
77
- $attributes = [];
78
- foreach ($filteredProps as $key => $value) {
79
- $escapedKey = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
80
- $escapedValue = htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
81
- $attributes[] = "$escapedKey='$escapedValue'";
90
+ // Build the attributes string by escaping keys and values
91
+ $attributeStrings = [];
92
+ foreach ($attributes as $key => $value) {
93
+ $escapedKey = htmlspecialchars($key, ENT_QUOTES, "UTF-8");
94
+ $escapedValue = htmlspecialchars(
95
+ (string) $value,
96
+ ENT_QUOTES,
97
+ "UTF-8"
98
+ );
99
+ $attributeStrings[] = "$escapedKey='$escapedValue'";
82
100
  }
83
101
 
84
- return implode(' ', $attributes);
102
+ return implode(" ", $attributeStrings);
85
103
  }
86
104
 
87
105
  /**
@@ -37,6 +37,9 @@ class TemplateCompiler
37
37
  self::initializeClassMappings();
38
38
  }
39
39
 
40
+ // Escape `&` characters that are not part of valid XML entities
41
+ $templateContent = preg_replace('/&(?![a-zA-Z0-9#]+;)/', '&', $templateContent);
42
+
40
43
  $dom = new DOMDocument();
41
44
  libxml_use_internal_errors(true);
42
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.26.529",
3
+ "version": "1.26.531",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",