Skip to content

Commit a0e6748

Browse files
committed
first commit 🔥
1 parent dfe1706 commit a0e6748

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "laravilt/schemas",
33
"description": "Complete schema system with sections, tabs, grids, and layout components. Organize form fields and information displays with powerful layout components supporting collapsible sections, responsive grids, and nested schemas.",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"type": "library",
66
"license": "MIT",
77
"keywords": [

src/Components/Grid.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ class Grid extends Component
1515

1616
protected array $schema = [];
1717

18+
/**
19+
* Create a new Grid instance.
20+
* Supports both Grid::make('name') and Grid::make(2) or Grid::make(['default' => 1]).
21+
*
22+
* @param string|int|array $nameOrColumns Either a name string or columns configuration
23+
*/
24+
public static function make(string|int|array $nameOrColumns = 'grid'): static
25+
{
26+
// If columns are passed directly (int or array), use a default name
27+
if (is_int($nameOrColumns) || is_array($nameOrColumns)) {
28+
$static = app(static::class);
29+
$static->name = 'grid';
30+
$static->columns = $nameOrColumns;
31+
$static->setUp();
32+
33+
return $static;
34+
}
35+
36+
// Otherwise, use the parent make() with the string name
37+
return parent::make($nameOrColumns);
38+
}
39+
1840
/**
1941
* Set number of columns.
2042
*

src/Schema.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,16 @@ public function getVisibleComponents(): array
270270
// Use getSchema() to ensure context propagation (model, resourceSlug, relationManagerClass)
271271
$schema = $this->getSchema();
272272

273-
return array_filter($schema, function ($item): bool {
273+
// Filter hidden components and re-index with array_values to ensure
274+
// sequential 0-based indices (required for proper JSON array encoding)
275+
return array_values(array_filter($schema, function ($item): bool {
274276
// Support both Components and Actions
275277
if (method_exists($item, 'isHidden')) {
276278
return ! $item->isHidden();
277279
}
278280

279281
return true;
280-
});
282+
}));
281283
}
282284

283285
/**

0 commit comments

Comments
 (0)