Upgrade to 4.6.0

This commit is contained in:
Bastian Allgeier
2025-01-30 12:15:44 +01:00
parent d71db84033
commit daf499e2e4
179 changed files with 1848 additions and 688 deletions

View File

@@ -29,13 +29,13 @@ return [
/**
* Maximum number of checked boxes
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
/**
* Minimum number of checked boxes
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
'value' => function ($value = null) {

View File

@@ -24,7 +24,7 @@ return [
/**
* Default date when a new page/file/user gets created
*/
'default' => function (string $default = null): string {
'default' => function (string|null $default = null): string {
return $this->toDatetime($default) ?? '';
},
@@ -46,13 +46,13 @@ return [
/**
* Latest date, which can be selected/saved (Y-m-d)
*/
'max' => function (string $max = null): string|null {
'max' => function (string|null $max = null): string|null {
return Date::optional($max);
},
/**
* Earliest date, which can be selected/saved (Y-m-d)
*/
'min' => function (string $min = null): string|null {
'min' => function (string|null $min = null): string|null {
return Date::optional($min);
},

View File

@@ -26,7 +26,7 @@ return [
/**
* Change the design of the info box
*/
'theme' => function (string $theme = null) {
'theme' => function (string|null $theme = null) {
return $theme;
}
],

View File

@@ -16,14 +16,29 @@ return [
* @values 'anchor', 'url, 'page, 'file', 'email', 'tel', 'custom'
*/
'options' => function (array|null $options = null): array {
return $options ?? [
'url',
'page',
'file',
'email',
'tel',
'anchor'
];
// default options
if ($options === null) {
return [
'url',
'page',
'file',
'email',
'tel',
'anchor'
];
}
// validate options
$available = array_keys($this->availableTypes());
if ($unavailable = array_diff($options, $available)) {
throw new InvalidArgumentException([
'key' => 'field.link.options',
'data' => ['options' => implode(', ', $unavailable)]
]);
}
return $options;
},
'value' => function (string|null $value = null) {
return $value ?? '';
@@ -31,9 +46,11 @@ return [
],
'methods' => [
'activeTypes' => function () {
return array_filter($this->availableTypes(), function (string $type) {
return in_array($type, $this->props['options']) === true;
}, ARRAY_FILTER_USE_KEY);
return array_filter(
$this->availableTypes(),
fn (string $type) => in_array($type, $this->props['options']),
ARRAY_FILTER_USE_KEY
);
},
'availableTypes' => function () {
return [

View File

@@ -7,7 +7,7 @@ return [
/**
* Defines a custom format that is used when the field is saved
*/
'format' => function (string $format = null) {
'format' => function (string|null $format = null) {
return $format;
}
],

View File

@@ -23,7 +23,7 @@ return [
/**
* Info text for each item
*/
'info' => function (string $info = null) {
'info' => function (string|null $info = null) {
return $info;
},
@@ -37,14 +37,14 @@ return [
/**
* The minimum number of required selected
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
/**
* The maximum number of allowed selected
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
@@ -58,7 +58,7 @@ return [
/**
* Query for the items to be included in the picker
*/
'query' => function (string $query = null) {
'query' => function (string|null $query = null) {
return $query;
},
@@ -86,7 +86,7 @@ return [
/**
* Main text for each item
*/
'text' => function (string $text = null) {
'text' => function (string|null $text = null) {
return $text;
},
],

View File

@@ -74,7 +74,7 @@ return [
return $map($file, $parent);
});
},
'uploadParent' => function (string $parentQuery = null) {
'uploadParent' => function (string|null $parentQuery = null) {
$parent = $this->model();
if ($parentQuery) {

View File

@@ -13,13 +13,13 @@ return [
/**
* The lowest allowed number
*/
'min' => function (float $min = null) {
'min' => function (float|null $min = null) {
return $min;
},
/**
* The highest allowed number
*/
'max' => function (float $max = null) {
'max' => function (float|null $max = null) {
return $max;
},
/**

View File

@@ -31,7 +31,7 @@ return [
/**
* Optional query to select a specific set of pages
*/
'query' => function (string $query = null) {
'query' => function (string|null $query = null) {
return $query;
},

View File

@@ -13,7 +13,7 @@ return [
/**
* Custom icon to replace the arrow down.
*/
'icon' => function (string $icon = null) {
'icon' => function (string|null $icon = null) {
return $icon;
},
/**

View File

@@ -28,7 +28,7 @@ return [
/**
* Set prefix for the help text
*/
'path' => function (string $path = null) {
'path' => function (string|null $path = null) {
return $path;
},
@@ -36,7 +36,7 @@ return [
* Name of another field that should be used to
* automatically update this field's value
*/
'sync' => function (string $sync = null) {
'sync' => function (string|null $sync = null) {
return $sync;
},

View File

@@ -45,7 +45,7 @@ return [
/**
* Set the default rows for the structure
*/
'default' => function (array $default = null) {
'default' => function (array|null $default = null) {
return $default;
},
@@ -58,38 +58,38 @@ return [
/**
* The number of entries that will be displayed on a single page. Afterwards pagination kicks in.
*/
'limit' => function (int $limit = null) {
'limit' => function (int|null $limit = null) {
return $limit;
},
/**
* Maximum allowed entries in the structure. Afterwards the "Add" button will be switched off.
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
/**
* Minimum required entries in the structure
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
/**
* Toggles adding to the top or bottom of the list
*/
'prepend' => function (bool $prepend = null) {
'prepend' => function (bool|null $prepend = null) {
return $prepend;
},
/**
* Toggles drag & drop sorting
*/
'sortable' => function (bool $sortable = null) {
'sortable' => function (bool|null $sortable = null) {
return $sortable;
},
/**
* Sorts the entries by the given field and order (i.e. `title desc`)
* Drag & drop is disabled in this case
*/
'sortBy' => function (string $sort = null) {
'sortBy' => function (string|null $sort = null) {
return $sort;
}
],

View File

@@ -37,13 +37,13 @@ return [
/**
* Minimum number of required entries/tags
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
/**
* Maximum number of allowed entries/tags
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
/**
@@ -93,7 +93,7 @@ return [
return $value;
}
],
'save' => function (array $value = null): string {
'save' => function (array|null $value = null): string {
return A::join(
$value,
$this->separator() . ' '

View File

@@ -30,28 +30,28 @@ return [
/**
* Sets the font family (sans or monospace)
*/
'font' => function (string $font = null) {
'font' => function (string|null $font = null) {
return $font === 'monospace' ? 'monospace' : 'sans-serif';
},
/**
* Maximum number of allowed characters
*/
'maxlength' => function (int $maxlength = null) {
'maxlength' => function (int|null $maxlength = null) {
return $maxlength;
},
/**
* Minimum number of required characters
*/
'minlength' => function (int $minlength = null) {
'minlength' => function (int|null $minlength = null) {
return $minlength;
},
/**
* A regular expression, which will be used to validate the input
*/
'pattern' => function (string $pattern = null) {
'pattern' => function (string|null $pattern = null) {
return $pattern;
},

View File

@@ -26,7 +26,7 @@ return [
/**
* Sets the default text when a new page/file/user is created
*/
'default' => function (string $default = null) {
'default' => function (string|null $default = null) {
return trim($default ?? '');
},
@@ -48,28 +48,28 @@ return [
/**
* Sets the font family (sans or monospace)
*/
'font' => function (string $font = null) {
'font' => function (string|null $font = null) {
return $font === 'monospace' ? 'monospace' : 'sans-serif';
},
/**
* Maximum number of allowed characters
*/
'maxlength' => function (int $maxlength = null) {
'maxlength' => function (int|null $maxlength = null) {
return $maxlength;
},
/**
* Minimum number of required characters
*/
'minlength' => function (int $minlength = null) {
'minlength' => function (int|null $minlength = null) {
return $minlength;
},
/**
* Changes the size of the textarea. Available sizes: `small`, `medium`, `large`, `huge`
*/
'size' => function (string $size = null) {
'size' => function (string|null $size = null) {
return $size;
},
@@ -80,7 +80,7 @@ return [
return $spellcheck;
},
'value' => function (string $value = null) {
'value' => function (string|null $value = null) {
return trim($value ?? '');
}
],

View File

@@ -36,13 +36,13 @@ return [
/**
* Latest time, which can be selected/saved (H:i or H:i:s)
*/
'max' => function (string $max = null): string|null {
'max' => function (string|null $max = null): string|null {
return Date::optional($max);
},
/**
* Earliest time, which can be selected/saved (H:i or H:i:s)
*/
'min' => function (string $min = null): string|null {
'min' => function (string|null $min = null): string|null {
return Date::optional($min);
},

View File

@@ -36,14 +36,14 @@ return [
/**
* Maximum number of allowed characters
*/
'maxlength' => function (int $maxlength = null) {
'maxlength' => function (int|null $maxlength = null) {
return $maxlength;
},
/**
* Minimum number of required characters
*/
'minlength' => function (int $minlength = null) {
'minlength' => function (int|null $minlength = null) {
return $minlength;
},
/**