chore: 🎨 update project with the new uwil cms installation
This commit is contained in:
parent
217343e38f
commit
2752b418b7
164 changed files with 5533 additions and 6605 deletions
|
|
@ -20,5 +20,5 @@ indent_size = 4
|
|||
[*.scss]
|
||||
indent_size = 2
|
||||
|
||||
[*.{tsx,ts,cjs}]
|
||||
[*.{tsx,ts,cjs,js}]
|
||||
indent_size = 2
|
||||
|
|
|
|||
118
.env.example
118
.env.example
|
|
@ -1,65 +1,65 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
# APP
|
||||
APP_NAME=
|
||||
APP_ENV=
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_DEBUG=
|
||||
APP_URL=
|
||||
APP_LOCALE=
|
||||
APP_FALLBACK_LOCALE=
|
||||
APP_FAKER_LOCALE=
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
# DATABASE
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=
|
||||
DB_PORT=
|
||||
DB_DATABASE=
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
# MAILS
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=
|
||||
MAIL_PORT=
|
||||
MAIL_USERNAME=
|
||||
MAIL_PASSWORD=
|
||||
MAIL_ENCRYPTION=
|
||||
MAIL_FROM_ADDRESS=
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
# SENTRY
|
||||
SENTRY_LARAVEL_DSN=
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
# ADMIN SECURE
|
||||
LDC_WEB_API_ENDPOINT=
|
||||
LDC_WEB_API_KEY=
|
||||
LDC_WEB_CIDR_MANUAL_ALLOWED_LIST=
|
||||
|
||||
## TELESCOPE
|
||||
TELESCOPE_ENABLED=true
|
||||
|
||||
# REDIS
|
||||
REDIS_HOST=
|
||||
REDIS_PORT=
|
||||
REDIS_USERNAME=
|
||||
REDIS_PASSWORD=
|
||||
REDIS_PREFIX=
|
||||
REDIS_SCHEME=
|
||||
|
||||
# OTHERS
|
||||
LOG_CHANNEL=
|
||||
LOG_DEPRECATIONS_CHANNEL=
|
||||
LOG_LEVEL=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
|
||||
CACHE_DRIVER=file
|
||||
CACHE_STORE=file
|
||||
|
||||
FILESYSTEM_DISK=local
|
||||
|
||||
QUEUE_CONNECTION=sync
|
||||
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
node_modules
|
||||
public
|
||||
vendor
|
||||
resources/ts/components/ui/
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
module.exports = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
sourceType: "module",
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
},
|
||||
"import/resolver": {
|
||||
typescript: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
alias: {
|
||||
map: [
|
||||
["@", "./resources/ts"],
|
||||
["&", "./resources/assets"],
|
||||
],
|
||||
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
||||
},
|
||||
},
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:jsx-a11y/recommended",
|
||||
"plugin:react-hooks/recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"airbnb",
|
||||
"airbnb/hooks",
|
||||
"plugin:prettier/recommended",
|
||||
],
|
||||
plugins: [
|
||||
"react",
|
||||
"react-hooks",
|
||||
"jsx-a11y",
|
||||
"@typescript-eslint",
|
||||
"prettier",
|
||||
],
|
||||
rules: {
|
||||
"react/jsx-filename-extension": ["error", { extensions: [".tsx", ".jsx"] }],
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react/prop-types": "off",
|
||||
"react/require-default-props": "off",
|
||||
"import/extensions": [
|
||||
"error",
|
||||
"ignorePackages",
|
||||
{
|
||||
ts: "never",
|
||||
tsx: "never",
|
||||
js: "never",
|
||||
jsx: "never",
|
||||
},
|
||||
],
|
||||
"import/order": "off",
|
||||
"prettier/prettier": "error",
|
||||
"no-console": [
|
||||
"warn",
|
||||
{
|
||||
allow: ["warn", "error"],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
27
.gitignore
vendored
27
.gitignore
vendored
|
|
@ -1,13 +1,38 @@
|
|||
*.log
|
||||
.env
|
||||
.env.backup
|
||||
.env.example
|
||||
.env.production
|
||||
/auth.json
|
||||
/.npmrc
|
||||
/bootstrap/ssr
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/favicons-back
|
||||
/public/storage
|
||||
/public/favicons-back
|
||||
/public/android-icon-36x36.png
|
||||
/public/android-icon-48x48.png
|
||||
/public/android-icon-72x72.png
|
||||
/public/android-icon-96x96.png
|
||||
/public/android-icon-144x144.png
|
||||
/public/android-icon-192x192.png
|
||||
/public/apple-icon-57x57.png
|
||||
/public/apple-icon-60x60.png
|
||||
/public/apple-icon-72x72.png
|
||||
/public/apple-icon-76x76.png
|
||||
/public/apple-icon-114x114.png
|
||||
/public/apple-icon-120x120.png
|
||||
/public/apple-icon-144x144.png
|
||||
/public/apple-icon-152x152.png
|
||||
/public/apple-icon-180x180.png
|
||||
/public/favicon-16x16.png
|
||||
/public/favicon-32x32.png
|
||||
/public/favicon.ico
|
||||
/public/manifest.json
|
||||
/public/ms-icon-70x70.png
|
||||
/public/ms-icon-144x144.png
|
||||
/public/ms-icon-150x150.png
|
||||
/public/ms-icon-310x310.png
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ trait HasUserRequestRules
|
|||
'isClient' => $role === UserRoleRegistry::get('client')->value,
|
||||
'isProjectManager' => $role === UserRoleRegistry::get('project-manager')->value,
|
||||
'isDevelopper' => $role === UserRoleRegistry::get('developper')->value,
|
||||
'isConceptor' => $role === UserRoleRegistry::get('conceptor')->value,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -37,11 +36,9 @@ trait HasUserRequestRules
|
|||
'isClient' => $isClient,
|
||||
'isProjectManager' => $isProjectManager,
|
||||
'isDevelopper' => $isDevelopper,
|
||||
'isConceptor' => $isConceptor,
|
||||
] = $this->resolveRoleFlags();
|
||||
$userRole = auth('backend')->user()->role->value === $isConceptor;
|
||||
|
||||
if ($userRole && ($isProjectManager || $isDevelopper)) {
|
||||
] = $this->resolveRoleFlags();
|
||||
$authIsConceptor = auth('backend')->user()->role->value === UserRoleRegistry::get('conceptor')->value;
|
||||
if ($authIsConceptor && ($isProjectManager || $isDevelopper)) {
|
||||
$this->merge([
|
||||
'gitlab_id' => $this->input('gitlab_id'),
|
||||
]);
|
||||
|
|
@ -64,15 +61,14 @@ trait HasUserRequestRules
|
|||
'isClient' => $isClient,
|
||||
'isProjectManager' => $isProjectManager,
|
||||
'isDevelopper' => $isDevelopper,
|
||||
'isConceptor' => $isConceptor,
|
||||
] = $this->resolveRoleFlags();
|
||||
$userRole = auth('backend')->user()->role->value === $isConceptor;
|
||||
] = $this->resolveRoleFlags();
|
||||
$authIsConceptor = auth('backend')->user()->role->value === UserRoleRegistry::get('conceptor')->value;
|
||||
|
||||
return [
|
||||
'gitlab_id' => $userRole && ($isProjectManager || $isDevelopper)
|
||||
'gitlab_id' => $authIsConceptor && ($isProjectManager || $isDevelopper)
|
||||
? 'required|integer|min:1'
|
||||
: 'nullable|integer|min:1',
|
||||
'sites' => $userRole && $isClient ? 'required|array' : 'nullable|array',
|
||||
'sites' => $authIsConceptor && $isClient ? 'required|array' : 'nullable|array',
|
||||
'sites.*' => 'integer|exists:sites,id|distinct',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,20 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||
Route::middleware(['web', 'throttle:5,2'])
|
||||
->post('/csp-report', function (): void {
|
||||
$isCspRequest = request()->header('Content-Type') === 'application/csp-report';
|
||||
abort_if(! $isCspRequest or ! request()->json('csp-report') or ! is_array(request()->json('csp-report')), 401);
|
||||
abort_if(
|
||||
! $isCspRequest or ! request()->json('csp-report') or ! is_array(request()->json('csp-report')),
|
||||
401,
|
||||
);
|
||||
|
||||
/** @var array<string, mixed> $rawReport */
|
||||
$rawReport = request()->json('csp-report');
|
||||
|
||||
// * Flatten if needed.
|
||||
$cspReport = collect(request()->json('csp-report'))
|
||||
->flatMap(fn ($v, $k) => [$k => is_array($v) ? collect($v)->flatten()->implode(', ') : $v])->all();
|
||||
$cspReport = collect($rawReport)
|
||||
->flatMap(fn (mixed $v, string $k) => [
|
||||
$k => is_array($v) ? collect($v)->flatten()->implode(', ') : (string) $v,
|
||||
])->all();
|
||||
|
||||
// * Filter array keys.
|
||||
$cspReport = collect(array_intersect_key($cspReport, [
|
||||
'blocked-uri' => '',
|
||||
|
|
@ -43,6 +53,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||
'referrer' => '',
|
||||
'violated-directive' => '',
|
||||
]));
|
||||
|
||||
Log::warning(sprintf(
|
||||
"CSP REPORT for %s : \n %s",
|
||||
$cspReport->get('document-uri'),
|
||||
|
|
|
|||
|
|
@ -3,13 +3,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
use Uwil\K8S\Laravel\K8SServiceProvider;
|
||||
use Uwil\LaravelCommon\Providers\AppServiceProvider as CommonAppServiceProvider;
|
||||
use Uwil\LaravelCommon\Providers\TranslationServiceProvider;
|
||||
|
||||
return [
|
||||
CommonAppServiceProvider::class,
|
||||
TranslationServiceProvider::class,
|
||||
K8SServiceProvider::class,
|
||||
AppServiceProvider::class,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,29 +7,29 @@
|
|||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.5",
|
||||
"diglactic/laravel-breadcrumbs": "^10.0",
|
||||
"inertiajs/inertia-laravel": "^2.0",
|
||||
"laravel/framework": "^13.0",
|
||||
"diglactic/laravel-breadcrumbs": "^10.1",
|
||||
"inertiajs/inertia-laravel": "^3.1",
|
||||
"laravel/framework": "^13.8",
|
||||
"laravel/telescope": "^5.7",
|
||||
"laravel/tinker": "^3.0",
|
||||
"monolog/monolog": "^3.0",
|
||||
"monolog/monolog": "^3.10",
|
||||
"psr/log": "^3.0",
|
||||
"tightenco/ziggy": "^2.5",
|
||||
"scaler-tech/laravel-saml2": "^2.7",
|
||||
"tightenco/ziggy": "^2.6",
|
||||
"uwil/admin-secure-laravel": "^5.1",
|
||||
"uwil/laravel-backend": "^6.0",
|
||||
"uwil/laravel-common": "^7.0"
|
||||
"uwil/laravel-backend": "^7.0",
|
||||
"uwil/laravel-common": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"driftingly/rector-laravel": "^2.4",
|
||||
"fakerphp/faker": "^1.23",
|
||||
"larastan/larastan": "^3.4",
|
||||
"laravel/breeze": "^2.3.0",
|
||||
"larastan/larastan": "^3.10",
|
||||
"laravel/pail": "^1.2.5",
|
||||
"laravel/pint": "^1.29",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^12.5.12",
|
||||
"slevomat/coding-standard": "^8.22"
|
||||
"slevomat/coding-standard": "^8.29"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan config:clear --ansi @no_additional_args",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
|
|
@ -83,15 +83,6 @@
|
|||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
],
|
||||
"phpcs": [
|
||||
"./vendor/bin/phpcs"
|
||||
],
|
||||
"phpstan": [
|
||||
"./vendor/bin/phpstan"
|
||||
],
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
|
|
|
|||
378
composer.lock
generated
378
composer.lock
generated
|
|
@ -4,27 +4,26 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "bda62fde2ae3e616ee4f60eba120306a",
|
||||
"content-hash": "65c8f46d36f1be44d385f2fb232aded1",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.14.8",
|
||||
"version": "0.17.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/brick/math.git",
|
||||
"reference": "63422359a44b7f06cae63c3b429b59e8efcc0629"
|
||||
"reference": "8189e751995f9e15729c1aa2f89fa8f166ffe818"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/brick/math/zipball/63422359a44b7f06cae63c3b429b59e8efcc0629",
|
||||
"reference": "63422359a44b7f06cae63c3b429b59e8efcc0629",
|
||||
"url": "https://api.github.com/repos/brick/math/zipball/8189e751995f9e15729c1aa2f89fa8f166ffe818",
|
||||
"reference": "8189e751995f9e15729c1aa2f89fa8f166ffe818",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.2",
|
||||
"phpstan/phpstan": "2.1.22",
|
||||
"phpunit/phpunit": "^11.5"
|
||||
},
|
||||
|
|
@ -56,7 +55,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/brick/math/issues",
|
||||
"source": "https://github.com/brick/math/tree/0.14.8"
|
||||
"source": "https://github.com/brick/math/tree/0.17.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -64,7 +63,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-02-10T14:33:43+00:00"
|
||||
"time": "2026-05-25T20:34:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "carbonphp/carbon-doctrine-types",
|
||||
|
|
@ -923,22 +922,22 @@
|
|||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.11.1",
|
||||
"version": "7.12.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "5af96f374e0ab4ebd747b8310888c99d3adb0a8c"
|
||||
"reference": "d34627490fbc03bf5c5d7cfed81f2faa19519425"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/5af96f374e0ab4ebd747b8310888c99d3adb0a8c",
|
||||
"reference": "5af96f374e0ab4ebd747b8310888c99d3adb0a8c",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d34627490fbc03bf5c5d7cfed81f2faa19519425",
|
||||
"reference": "d34627490fbc03bf5c5d7cfed81f2faa19519425",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^2.5",
|
||||
"guzzlehttp/psr7": "^2.11",
|
||||
"guzzlehttp/psr7": "^2.12.1",
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"symfony/deprecation-contracts": "^2.5 || ^3.0",
|
||||
|
|
@ -951,7 +950,7 @@
|
|||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"ext-curl": "*",
|
||||
"guzzle/client-integration-tests": "3.0.2",
|
||||
"guzzlehttp/test-server": "^0.5",
|
||||
"guzzlehttp/test-server": "^0.5.1",
|
||||
"php-http/message-factory": "^1.1",
|
||||
"phpunit/phpunit": "^8.5.52 || ^9.6.34",
|
||||
"psr/log": "^1.1 || ^2.0 || ^3.0"
|
||||
|
|
@ -1031,7 +1030,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.11.1"
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.12.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -1047,7 +1046,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-06-07T22:54:06+00:00"
|
||||
"time": "2026-06-18T14:12:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
|
|
@ -1135,16 +1134,16 @@
|
|||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "2.11.0",
|
||||
"version": "2.12.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "bbb5e61349fa5cb822b3e87842b951088b76b81f"
|
||||
"reference": "172ef2f4e9824c1e058b7f30be8ae25a02c0f2b7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/bbb5e61349fa5cb822b3e87842b951088b76b81f",
|
||||
"reference": "bbb5e61349fa5cb822b3e87842b951088b76b81f",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/172ef2f4e9824c1e058b7f30be8ae25a02c0f2b7",
|
||||
"reference": "172ef2f4e9824c1e058b7f30be8ae25a02c0f2b7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1234,7 +1233,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/psr7/issues",
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.11.0"
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.12.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -1250,20 +1249,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-06-02T12:30:48+00:00"
|
||||
"time": "2026-06-18T09:49:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/uri-template",
|
||||
"version": "v1.0.6",
|
||||
"version": "v1.0.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/uri-template.git",
|
||||
"reference": "eef7f87bab6f204eba3c39224d8075c70c637946"
|
||||
"reference": "7fe811c23a9e3cd712b4389eaeb50b5456d8c529"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/uri-template/zipball/eef7f87bab6f204eba3c39224d8075c70c637946",
|
||||
"reference": "eef7f87bab6f204eba3c39224d8075c70c637946",
|
||||
"url": "https://api.github.com/repos/guzzle/uri-template/zipball/7fe811c23a9e3cd712b4389eaeb50b5456d8c529",
|
||||
"reference": "7fe811c23a9e3cd712b4389eaeb50b5456d8c529",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1320,7 +1319,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/uri-template/issues",
|
||||
"source": "https://github.com/guzzle/uri-template/tree/v1.0.6"
|
||||
"source": "https://github.com/guzzle/uri-template/tree/v1.0.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -1336,27 +1335,27 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-05-23T22:00:21+00:00"
|
||||
"time": "2026-06-12T21:33:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "inertiajs/inertia-laravel",
|
||||
"version": "v2.0.24",
|
||||
"version": "v3.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/inertiajs/inertia-laravel.git",
|
||||
"reference": "ea345adad12f110edbbc4bef03b69c2374a535d4"
|
||||
"reference": "f588ce4a5beb25d166f4e372bac0c7f46a4f52ac"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/inertiajs/inertia-laravel/zipball/ea345adad12f110edbbc4bef03b69c2374a535d4",
|
||||
"reference": "ea345adad12f110edbbc4bef03b69c2374a535d4",
|
||||
"url": "https://api.github.com/repos/inertiajs/inertia-laravel/zipball/f588ce4a5beb25d166f4e372bac0c7f46a4f52ac",
|
||||
"reference": "f588ce4a5beb25d166f4e372bac0c7f46a4f52ac",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"laravel/framework": "^10.0|^11.0|^12.0|^13.0",
|
||||
"php": "^8.1.0",
|
||||
"symfony/console": "^6.2|^7.0|^8.0"
|
||||
"laravel/framework": "^11.0|^12.0|^13.0",
|
||||
"php": "^8.2.0",
|
||||
"symfony/console": "^7.0|^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"laravel/boost": "<2.2.0"
|
||||
|
|
@ -1366,8 +1365,8 @@
|
|||
"larastan/larastan": "^3.0",
|
||||
"laravel/pint": "^1.16",
|
||||
"mockery/mockery": "^1.3.3",
|
||||
"orchestra/testbench": "^8.0|^9.2|^10.0|^11.0",
|
||||
"phpunit/phpunit": "^10.4|^11.5|^12.0",
|
||||
"orchestra/testbench": "^9.2|^10.0|^11.0",
|
||||
"phpunit/phpunit": "^11.5|^12.0",
|
||||
"roave/security-advisories": "dev-master"
|
||||
},
|
||||
"suggest": {
|
||||
|
|
@ -1407,9 +1406,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/inertiajs/inertia-laravel/issues",
|
||||
"source": "https://github.com/inertiajs/inertia-laravel/tree/v2.0.24"
|
||||
"source": "https://github.com/inertiajs/inertia-laravel/tree/v3.1.0"
|
||||
},
|
||||
"time": "2026-04-10T14:36:44+00:00"
|
||||
"time": "2026-04-30T15:30:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jean85/pretty-package-versions",
|
||||
|
|
@ -1473,16 +1472,16 @@
|
|||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v13.15.0",
|
||||
"version": "v13.16.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "7e23b2aa4e1133a43835c93a810b4bedc40e425b"
|
||||
"reference": "6135650d69bd9442e470bb1b343422081b076f1e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/7e23b2aa4e1133a43835c93a810b4bedc40e425b",
|
||||
"reference": "7e23b2aa4e1133a43835c93a810b4bedc40e425b",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/6135650d69bd9442e470bb1b343422081b076f1e",
|
||||
"reference": "6135650d69bd9442e470bb1b343422081b076f1e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1693,7 +1692,7 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2026-06-09T13:45:51+00:00"
|
||||
"time": "2026-06-16T16:07:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/prompts",
|
||||
|
|
@ -2827,16 +2826,16 @@
|
|||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "3.11.4",
|
||||
"version": "3.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/CarbonPHP/carbon.git",
|
||||
"reference": "e890471a3494740f7d9326d72ce6a8c559ffee60"
|
||||
"reference": "40f6618f052df16b545f626fbf9a878e6497d16a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/e890471a3494740f7d9326d72ce6a8c559ffee60",
|
||||
"reference": "e890471a3494740f7d9326d72ce6a8c559ffee60",
|
||||
"url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/40f6618f052df16b545f626fbf9a878e6497d16a",
|
||||
"reference": "40f6618f052df16b545f626fbf9a878e6497d16a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2928,7 +2927,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-04-07T09:57:54+00:00"
|
||||
"time": "2026-06-18T13:49:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nette/schema",
|
||||
|
|
@ -3452,16 +3451,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "2.0.54",
|
||||
"version": "2.0.55",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "a96a835067c39ee7a709329fe70869817da18081"
|
||||
"reference": "d73c9e019a895be83b18a2ccccfa7e2b0a648743"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/a96a835067c39ee7a709329fe70869817da18081",
|
||||
"reference": "a96a835067c39ee7a709329fe70869817da18081",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d73c9e019a895be83b18a2ccccfa7e2b0a648743",
|
||||
"reference": "d73c9e019a895be83b18a2ccccfa7e2b0a648743",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3542,7 +3541,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/phpseclib/phpseclib/issues",
|
||||
"source": "https://github.com/phpseclib/phpseclib/tree/2.0.54"
|
||||
"source": "https://github.com/phpseclib/phpseclib/tree/2.0.55"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -3558,7 +3557,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-04-27T06:59:24+00:00"
|
||||
"time": "2026-06-14T19:53:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/clock",
|
||||
|
|
@ -4173,20 +4172,20 @@
|
|||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"version": "4.9.2",
|
||||
"version": "4.9.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/uuid.git",
|
||||
"reference": "8429c78ca35a09f27565311b98101e2826affde0"
|
||||
"reference": "1df15849d00943a67d677dc9cfd80795f038c9f8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/8429c78ca35a09f27565311b98101e2826affde0",
|
||||
"reference": "8429c78ca35a09f27565311b98101e2826affde0",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/1df15849d00943a67d677dc9cfd80795f038c9f8",
|
||||
"reference": "1df15849d00943a67d677dc9cfd80795f038c9f8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.8.16 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14",
|
||||
"brick/math": ">=0.8.16 <=0.18",
|
||||
"php": "^8.0",
|
||||
"ramsey/collection": "^1.2 || ^2.0"
|
||||
},
|
||||
|
|
@ -4245,9 +4244,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/uuid/issues",
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.9.2"
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.9.3"
|
||||
},
|
||||
"time": "2025-12-14T04:43:48+00:00"
|
||||
"time": "2026-06-18T03:57:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "robrichards/xmlseclibs",
|
||||
|
|
@ -7531,24 +7530,18 @@
|
|||
},
|
||||
{
|
||||
"name": "uwil/laravel-activity-logs",
|
||||
"version": "7.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@lab.s-web.fr:ldc-web/projets/laravel-activity-logs.git",
|
||||
"reference": "2194080a67e94d8f775fb9f336819bab209687ff"
|
||||
},
|
||||
"version": "8.0.0",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://lab.s-web.fr/api/v4/projects/229/packages/composer/archives/uwil/laravel-activity-logs.zip?sha=2194080a67e94d8f775fb9f336819bab209687ff",
|
||||
"reference": "2194080a67e94d8f775fb9f336819bab209687ff",
|
||||
"shasum": ""
|
||||
"type": "path",
|
||||
"url": "packages/laravel-activity-logs",
|
||||
"reference": "9c2a701948cd38ec55607cae78fb3155f880e1b7"
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "~13",
|
||||
"laravel/framework": "~13",
|
||||
"php": "^8.5",
|
||||
"uwil/laravel-backend": "^6.0",
|
||||
"uwil/laravel-common": "^7.0"
|
||||
"uwil/laravel-backend": "^7.0",
|
||||
"uwil/laravel-common": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"driftingly/rector-laravel": "^2.3",
|
||||
|
|
@ -7572,17 +7565,17 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
|
||||
],
|
||||
"phpcs": [
|
||||
"./vendor/bin/phpcs"
|
||||
],
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
],
|
||||
"phpstan": [
|
||||
"./vendor/bin/phpstan"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
|
|
@ -7597,33 +7590,31 @@
|
|||
"support": {
|
||||
"email": "digital@ldc.fr",
|
||||
"issues": "https://lab.s-web.fr/ldc-web/projets/laravel-activity-logs/-/issues"
|
||||
},
|
||||
"transport-options": {
|
||||
"symlink": true,
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "uwil/laravel-backend",
|
||||
"version": "6.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@lab.s-web.fr:ldc-web/projets/laravel-backend.git",
|
||||
"reference": "890c8b1353c2925216ebb52d744ac0f6ea136ecc"
|
||||
},
|
||||
"version": "7.0.0",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://lab.s-web.fr/api/v4/projects/228/packages/composer/archives/uwil/laravel-backend.zip?sha=890c8b1353c2925216ebb52d744ac0f6ea136ecc",
|
||||
"reference": "890c8b1353c2925216ebb52d744ac0f6ea136ecc",
|
||||
"shasum": ""
|
||||
"type": "path",
|
||||
"url": "packages/laravel-backend",
|
||||
"reference": "63d7e32e80b674985285e055e1dbca8ac2a519ce"
|
||||
},
|
||||
"require": {
|
||||
"diglactic/laravel-breadcrumbs": "^10.0",
|
||||
"illuminate/support": "~13",
|
||||
"inertiajs/inertia-laravel": "^2.0",
|
||||
"inertiajs/inertia-laravel": "^3.1",
|
||||
"laravel/framework": "~13",
|
||||
"laravel/telescope": "^5.7",
|
||||
"php": "^8.5",
|
||||
"scaler-tech/laravel-saml2": "^2.7",
|
||||
"sentry/sentry-laravel": "^4.10",
|
||||
"uwil/laravel-activity-logs": "^7.0",
|
||||
"uwil/laravel-common": "^7.0"
|
||||
"uwil/laravel-activity-logs": "^8.0",
|
||||
"uwil/laravel-common": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"driftingly/rector-laravel": "^2.3",
|
||||
|
|
@ -7653,17 +7644,17 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"@php ./vendor/bin/testbench package:discover --ansi"
|
||||
],
|
||||
"phpcs": [
|
||||
"./vendor/bin/phpcs"
|
||||
],
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
],
|
||||
"phpstan": [
|
||||
"./vendor/bin/phpstan"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"@php ./vendor/bin/testbench package:discover --ansi"
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
|
|
@ -7678,30 +7669,30 @@
|
|||
"support": {
|
||||
"email": "digital@ldc.fr",
|
||||
"issues": "https://lab.s-web.fr/ldc-web/projets/laravel-backend/-/issues"
|
||||
},
|
||||
"transport-options": {
|
||||
"symlink": true,
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "uwil/laravel-common",
|
||||
"version": "7.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@lab.s-web.fr:ldc-web/projets/laravel-common.git",
|
||||
"reference": "d8b21235c38441417f5ac91a45caf45ef7a0cee2"
|
||||
},
|
||||
"version": "8.0.0",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://lab.s-web.fr/api/v4/projects/215/packages/composer/archives/uwil/laravel-common.zip?sha=d8b21235c38441417f5ac91a45caf45ef7a0cee2",
|
||||
"reference": "d8b21235c38441417f5ac91a45caf45ef7a0cee2",
|
||||
"shasum": ""
|
||||
"type": "path",
|
||||
"url": "packages/laravel-common",
|
||||
"reference": "902f1dc94c65d5896a495605e3829f0168998ca7"
|
||||
},
|
||||
"require": {
|
||||
"diglactic/laravel-breadcrumbs": "^10.0",
|
||||
"illuminate/support": "~13",
|
||||
"inertiajs/inertia-laravel": "^3.1",
|
||||
"laravel/framework": "~13",
|
||||
"mews/purifier": "^3.4",
|
||||
"php": "^8.5",
|
||||
"sentry/sentry-laravel": "^4.10",
|
||||
"uwil/laravel-i18n": "^4.0",
|
||||
"tightenco/ziggy": "^2.6",
|
||||
"uwil/laravel-i18n": "^5.0",
|
||||
"uwil/laravel-k8s": "^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
@ -7721,12 +7712,12 @@
|
|||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Helpers/methods.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Uwil\\LaravelCommon\\": "src/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"src/Helpers/methods.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
|
@ -7734,17 +7725,17 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"@php ./vendor/bin/testbench package:discover --ansi"
|
||||
],
|
||||
"phpcs": [
|
||||
"./vendor/bin/phpcs"
|
||||
],
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
],
|
||||
"phpstan": [
|
||||
"./vendor/bin/phpstan"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"@php ./vendor/bin/testbench package:discover --ansi"
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
|
|
@ -7759,21 +7750,19 @@
|
|||
"support": {
|
||||
"email": "digital@ldc.fr",
|
||||
"issues": "https://lab.s-web.fr/ldc-web/projets/laravel-common/-/issues"
|
||||
},
|
||||
"transport-options": {
|
||||
"symlink": true,
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "uwil/laravel-i18n",
|
||||
"version": "4.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@lab.s-web.fr:ldc-web/projets/laravel-i18n.git",
|
||||
"reference": "0411ebd90b3ce561e27a23f363466695596c9674"
|
||||
},
|
||||
"version": "5.0.0",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://lab.s-web.fr/api/v4/projects/252/packages/composer/archives/uwil/laravel-i18n.zip?sha=0411ebd90b3ce561e27a23f363466695596c9674",
|
||||
"reference": "0411ebd90b3ce561e27a23f363466695596c9674",
|
||||
"shasum": ""
|
||||
"type": "path",
|
||||
"url": "packages/laravel-i18n",
|
||||
"reference": "1aa16f09d900188cf938694ed9f224d0c1cc5a9e"
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "~13",
|
||||
|
|
@ -7781,7 +7770,7 @@
|
|||
"mcamara/laravel-localization": "^2.3",
|
||||
"php": "^8.5",
|
||||
"spatie/laravel-translatable": "^6.11",
|
||||
"uwil/laravel-common": "^7.0"
|
||||
"uwil/laravel-common": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"driftingly/rector-laravel": "^2.3",
|
||||
|
|
@ -7805,17 +7794,17 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
|
||||
],
|
||||
"phpcs": [
|
||||
"./vendor/bin/phpcs"
|
||||
],
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
],
|
||||
"phpstan": [
|
||||
"./vendor/bin/phpstan"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
|
||||
"rector": [
|
||||
"./vendor/bin/rector"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
|
|
@ -7830,6 +7819,10 @@
|
|||
"support": {
|
||||
"email": "digital@ldc.fr",
|
||||
"issues": "https://lab.s-web.fr/ldc-web/projets/laravel-i18n/-/issues"
|
||||
},
|
||||
"transport-options": {
|
||||
"symlink": true,
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -8513,67 +8506,6 @@
|
|||
],
|
||||
"time": "2026-05-28T08:00:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/breeze",
|
||||
"version": "v2.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/breeze.git",
|
||||
"reference": "4f20e7b2cc8d25daa85d8647241a89c8e0930305"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/breeze/zipball/4f20e7b2cc8d25daa85d8647241a89c8e0930305",
|
||||
"reference": "4f20e7b2cc8d25daa85d8647241a89c8e0930305",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "^11.0|^12.0|^13.0",
|
||||
"illuminate/filesystem": "^11.0|^12.0|^13.0",
|
||||
"illuminate/support": "^11.0|^12.0|^13.0",
|
||||
"illuminate/validation": "^11.0|^12.0|^13.0",
|
||||
"php": "^8.2.0",
|
||||
"symfony/console": "^7.0|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/framework": "^11.0|^12.0|^13.0",
|
||||
"orchestra/testbench-core": "^9.0|^10.0|^11.0",
|
||||
"phpstan/phpstan": "^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Breeze\\BreezeServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Breeze\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Minimal Laravel authentication scaffolding with Blade and Tailwind.",
|
||||
"keywords": [
|
||||
"auth",
|
||||
"laravel"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/breeze/issues",
|
||||
"source": "https://github.com/laravel/breeze"
|
||||
},
|
||||
"time": "2026-05-14T16:54:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/pail",
|
||||
"version": "v1.2.7",
|
||||
|
|
@ -8656,16 +8588,16 @@
|
|||
},
|
||||
{
|
||||
"name": "laravel/pint",
|
||||
"version": "v1.29.1",
|
||||
"version": "v1.29.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/pint.git",
|
||||
"reference": "0770e9b7fafd50d4586881d456d6eb41c9247a80"
|
||||
"reference": "da1d1111a6aa2e082d2a388b194afe1ba0a05d14"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/pint/zipball/0770e9b7fafd50d4586881d456d6eb41c9247a80",
|
||||
"reference": "0770e9b7fafd50d4586881d456d6eb41c9247a80",
|
||||
"url": "https://api.github.com/repos/laravel/pint/zipball/da1d1111a6aa2e082d2a388b194afe1ba0a05d14",
|
||||
"reference": "da1d1111a6aa2e082d2a388b194afe1ba0a05d14",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -8676,14 +8608,14 @@
|
|||
"php": "^8.2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.95.1",
|
||||
"illuminate/view": "^12.56.0",
|
||||
"larastan/larastan": "^3.9.6",
|
||||
"friendsofphp/php-cs-fixer": "^3.95.8",
|
||||
"illuminate/view": "^12.62.0",
|
||||
"larastan/larastan": "^3.10.0",
|
||||
"laravel-zero/framework": "^12.1.0",
|
||||
"laravel/agent-detector": "^2.0.2",
|
||||
"mockery/mockery": "^1.6.12",
|
||||
"nunomaduro/termwind": "^2.4.0",
|
||||
"pestphp/pest": "^3.8.6",
|
||||
"shipfastlabs/agent-detector": "^1.1.3"
|
||||
"pestphp/pest": "^3.8.6"
|
||||
},
|
||||
"bin": [
|
||||
"builds/pint"
|
||||
|
|
@ -8720,7 +8652,7 @@
|
|||
"issues": "https://github.com/laravel/pint/issues",
|
||||
"source": "https://github.com/laravel/pint"
|
||||
},
|
||||
"time": "2026-04-20T15:26:14+00:00"
|
||||
"time": "2026-06-16T15:34:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mockery/mockery",
|
||||
|
|
@ -9537,16 +9469,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "12.5.29",
|
||||
"version": "12.5.30",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "9aa66a47db3ea70f1a468e66dd969f67e594945a"
|
||||
"reference": "900400a5b616d6fb306f9549f6da33ba615d3fbb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9aa66a47db3ea70f1a468e66dd969f67e594945a",
|
||||
"reference": "9aa66a47db3ea70f1a468e66dd969f67e594945a",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/900400a5b616d6fb306f9549f6da33ba615d3fbb",
|
||||
"reference": "900400a5b616d6fb306f9549f6da33ba615d3fbb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -9615,7 +9547,7 @@
|
|||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.29"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.30"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -9623,25 +9555,25 @@
|
|||
"type": "other"
|
||||
}
|
||||
],
|
||||
"time": "2026-06-04T06:14:42+00:00"
|
||||
"time": "2026-06-15T13:12:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "2.4.5",
|
||||
"version": "2.4.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "cbd86024be5014d3c14d9f0b3f7aae8ecbffd62c"
|
||||
"reference": "9b9e5c76618e4d359f65b54ca2eabcad3d1761ee"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/cbd86024be5014d3c14d9f0b3f7aae8ecbffd62c",
|
||||
"reference": "cbd86024be5014d3c14d9f0b3f7aae8ecbffd62c",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/9b9e5c76618e4d359f65b54ca2eabcad3d1761ee",
|
||||
"reference": "9b9e5c76618e4d359f65b54ca2eabcad3d1761ee",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4|^8.0",
|
||||
"phpstan/phpstan": "^2.1.56"
|
||||
"phpstan/phpstan": "^2.2.2"
|
||||
},
|
||||
"conflict": {
|
||||
"rector/rector-doctrine": "*",
|
||||
|
|
@ -9675,7 +9607,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.4.5"
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.4.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -9683,7 +9615,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-05-26T21:03:22+00:00"
|
||||
"time": "2026-06-17T11:56:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
|
@ -10842,16 +10774,16 @@
|
|||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozarts/assert.git",
|
||||
"reference": "9007ea6f45ecf352a9422b36644e4bfc039b9155"
|
||||
"reference": "2ccb7c2e821038c03a3e6e1700c570c158c55f70"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozarts/assert/zipball/9007ea6f45ecf352a9422b36644e4bfc039b9155",
|
||||
"reference": "9007ea6f45ecf352a9422b36644e4bfc039b9155",
|
||||
"url": "https://api.github.com/repos/webmozarts/assert/zipball/2ccb7c2e821038c03a3e6e1700c570c158c55f70",
|
||||
"reference": "2ccb7c2e821038c03a3e6e1700c570c158c55f70",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -10902,9 +10834,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/webmozarts/assert/issues",
|
||||
"source": "https://github.com/webmozarts/assert/tree/2.4.0"
|
||||
"source": "https://github.com/webmozarts/assert/tree/2.4.1"
|
||||
},
|
||||
"time": "2026-05-20T13:07:01+00:00"
|
||||
"time": "2026-06-15T15:31:57+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ return [
|
|||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [],
|
||||
'servers' => [
|
||||
'options' => [],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
|
|
@ -98,7 +98,6 @@ return [
|
|||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -178,7 +178,5 @@ return [
|
|||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -21,9 +21,66 @@ return [
|
|||
*/
|
||||
'ssr' => [
|
||||
|
||||
'enabled' => false,
|
||||
'enabled' => (bool) env('INERTIA_SSR_ENABLED', true),
|
||||
|
||||
'url' => env('APP_URL', 'https://localhost'),
|
||||
'runtime' => env('INERTIA_SSR_RUNTIME', 'node'),
|
||||
|
||||
'ensure_runtime_exists' => (bool) env('INERTIA_SSR_ENSURE_RUNTIME_EXISTS', false),
|
||||
|
||||
'url' => env('INERTIA_SSR_URL', 'http://127.0.0.1:13714'),
|
||||
|
||||
'ensure_bundle_exists' => (bool) env('INERTIA_SSR_ENSURE_BUNDLE_EXISTS', true),
|
||||
|
||||
'bundle' => base_path('bootstrap/ssr/ssr.js'),
|
||||
|
||||
/**
|
||||
*--------------------------------------------------------------------------
|
||||
* SSR Error Handling
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* When SSR rendering fails, Inertia gracefully falls back to client-side
|
||||
* rendering. Set throw_on_error to true to throw an exception instead.
|
||||
* This is useful for E2E testing where you want SSR errors to fail loudly.
|
||||
*
|
||||
* You can also listen for the Inertia\Ssr\SsrRenderFailed event to handle
|
||||
* failures in your own way (e.g., logging, error tracking service).
|
||||
*/
|
||||
'throw_on_error' => (bool) env('INERTIA_SSR_THROW_ON_ERROR', false),
|
||||
|
||||
],
|
||||
|
||||
/**
|
||||
*--------------------------------------------------------------------------
|
||||
* Pages
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* Set `ensure_pages_exist` to true if you want to enforce that Inertia page
|
||||
* components exist on disk when rendering a page. This is useful for
|
||||
* catching missing or misnamed components.
|
||||
*
|
||||
* The `paths` and `extensions` options define where to look for page
|
||||
* components and which file extensions to consider.
|
||||
*/
|
||||
'pages' => [
|
||||
|
||||
'ensure_pages_exist' => true,
|
||||
|
||||
'paths' => [
|
||||
|
||||
resource_path('ts'),
|
||||
|
||||
],
|
||||
|
||||
'extensions' => [
|
||||
|
||||
'js',
|
||||
'jsx',
|
||||
'svelte',
|
||||
'ts',
|
||||
'tsx',
|
||||
'vue',
|
||||
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
|
|
@ -32,29 +89,44 @@ return [
|
|||
* Testing
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* The values described here are used to locate Inertia components on the
|
||||
* filesystem. For instance, when using `assertInertia`, the assertion
|
||||
* attempts to locate the component as a file relative to any of the
|
||||
* paths AND with any of the extensions specified here.
|
||||
* When using `assertInertia`, the assertion attempts to locate the
|
||||
* component as a file relative to the `pages.paths` AND with any of
|
||||
* the `pages.extensions` specified above.
|
||||
*
|
||||
* You can disable this behavior by setting `ensure_pages_exist`
|
||||
* to false.
|
||||
*/
|
||||
'testing' => [
|
||||
|
||||
'ensure_pages_exist' => true,
|
||||
|
||||
'page_paths' => [],
|
||||
|
||||
'page_extensions' => [
|
||||
'js',
|
||||
'jsx',
|
||||
'svelte',
|
||||
'ts',
|
||||
'tsx',
|
||||
'vue',
|
||||
],
|
||||
],
|
||||
|
||||
/**
|
||||
*--------------------------------------------------------------------------
|
||||
* Expose Shared Prop Keys
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* When enabled, each page response includes a `sharedProps` metadata key
|
||||
* listing the top-level prop keys that were registered via `Inertia::share`.
|
||||
* The frontend can use this to carry shared props over during instant visits.
|
||||
*/
|
||||
'expose_shared_prop_keys' => true,
|
||||
|
||||
/**
|
||||
*--------------------------------------------------------------------------
|
||||
* History
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* Enable `encrypt` to encrypt page data before it is stored in the
|
||||
* browser's history state, preventing sensitive information from
|
||||
* being accessible after logout. Can also be enabled per-request
|
||||
* or via the `inertia.encrypt` middleware.
|
||||
*/
|
||||
'history' => [
|
||||
'encrypt' => false,
|
||||
|
||||
'encrypt' => (bool) env('INERTIA_ENCRYPT_HISTORY', false),
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ return [
|
|||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'deprecations' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/deprecations.log'),
|
||||
|
|
@ -107,8 +108,8 @@ return [
|
|||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
|
|
@ -133,21 +134,5 @@ return [
|
|||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
'stdout' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDOUT_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stdout',
|
||||
],
|
||||
],
|
||||
|
||||
'k8s' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['daily', 'stdout'],
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ return [
|
|||
*
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
'default' => env('MAIL_MAILER', 'smtp'),
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ return [
|
|||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
@ -127,5 +126,4 @@ return [
|
|||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -36,5 +36,4 @@ return [
|
|||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -22,6 +22,16 @@ return [
|
|||
'name' => 'back.',
|
||||
],
|
||||
|
||||
/**
|
||||
*--------------------------------------------------------------------------
|
||||
* Redirects
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* This option may be used to edit redirects.
|
||||
* - redirect_logout: string.
|
||||
*/
|
||||
'redirect_logout' => 'back.login',
|
||||
|
||||
/**
|
||||
*--------------------------------------------------------------------------
|
||||
* Saml
|
||||
|
|
|
|||
118
eslint.config.js
Normal file
118
eslint.config.js
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
||||
import importX from "eslint-plugin-import-x";
|
||||
import jsxA11y from "eslint-plugin-jsx-a11y";
|
||||
import prettier from "eslint-plugin-prettier/recommended";
|
||||
import react from "eslint-plugin-react";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import globals from "globals";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
files: ["resources/ts/**/*.{ts,tsx,js,jsx}"],
|
||||
},
|
||||
{
|
||||
ignores: [
|
||||
"node_modules/**",
|
||||
"public/**",
|
||||
"vendor/**",
|
||||
"packages/**",
|
||||
"resources/ts/components/ui/**",
|
||||
],
|
||||
},
|
||||
tseslint.configs.recommended,
|
||||
tseslint.configs.strictTypeChecked,
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2021,
|
||||
...globals.node,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
sourceType: "module",
|
||||
ecmaFeatures: { jsx: true },
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
...react.configs.flat.recommended,
|
||||
...react.configs.flat["jsx-runtime"],
|
||||
settings: {
|
||||
react: { version: "19.0" },
|
||||
},
|
||||
rules: {
|
||||
...react.configs.flat.recommended.rules,
|
||||
...react.configs.flat["jsx-runtime"].rules,
|
||||
"react/jsx-filename-extension": "off",
|
||||
"react/prop-types": "off",
|
||||
"react/require-default-props": "off",
|
||||
},
|
||||
},
|
||||
reactHooks.configs.flat.recommended,
|
||||
{
|
||||
plugins: { "jsx-a11y": jsxA11y },
|
||||
rules: { ...jsxA11y.configs.recommended.rules },
|
||||
},
|
||||
{
|
||||
plugins: { "import-x": importX },
|
||||
settings: {
|
||||
"import-x/resolver-next": [
|
||||
createTypeScriptImportResolver({
|
||||
project: "./tsconfig.json",
|
||||
}),
|
||||
],
|
||||
},
|
||||
rules: {
|
||||
...importX.configs.recommended.rules,
|
||||
...importX.configs.typescript.rules,
|
||||
"import-x/extensions": [
|
||||
"error",
|
||||
"ignorePackages",
|
||||
{ ts: "never", tsx: "never", js: "never", jsx: "never" },
|
||||
],
|
||||
"import-x/order": [
|
||||
"error",
|
||||
{
|
||||
groups: [
|
||||
"builtin",
|
||||
"external",
|
||||
"internal",
|
||||
"parent",
|
||||
"sibling",
|
||||
"index",
|
||||
],
|
||||
"newlines-between": "always",
|
||||
alphabetize: { order: "asc", caseInsensitive: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
||||
],
|
||||
"@typescript-eslint/consistent-type-imports": [
|
||||
"error",
|
||||
{ prefer: "type-imports", fixStyle: "inline-type-imports" },
|
||||
],
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["*.js", "*.ts", "*.cjs", "*.mjs"],
|
||||
extends: [tseslint.configs.disableTypeChecked],
|
||||
},
|
||||
prettier,
|
||||
);
|
||||
|
|
@ -24,6 +24,7 @@ data:
|
|||
MAIL_ENCRYPTION: "${APP_MAIL_ENCRYPTION}"
|
||||
MAIL_FROM_ADDRESS: "${APP_MAIL_FROM_ADDRESS}"
|
||||
MAIL_FROM_NAME: "${APP_APP_NAME}"
|
||||
MAIL_MAILER: "${APP_MAIL_MAILER}"
|
||||
SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}"
|
||||
TELESCOPE_ENABLED: "${APP_TELESCOPE_ENABLED}"
|
||||
CRM_ENDPOINT: "${APP_CRM_ENDPOINT}"
|
||||
|
|
|
|||
6516
package-lock.json
generated
6516
package-lock.json
generated
File diff suppressed because it is too large
Load diff
178
package.json
178
package.json
|
|
@ -3,123 +3,141 @@
|
|||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite",
|
||||
"prod": "vite build --mode production",
|
||||
"eslint": "node ./node_modules/.bin/eslint --config './.eslintrc.cjs' --max-warnings 0 'resources/ts/**/*.{ts,tsx}'",
|
||||
"eslint-fix": "node ./node_modules/.bin/eslint --config './.eslintrc.cjs' --max-warnings 0 'resources/ts/**/*.{ts,tsx}' --fix",
|
||||
"eslint-ci": "node ./node_modules/.bin/eslint --config './.eslintrc.cjs' --max-warnings 0 'resources/ts/**/*.{ts,tsx}' -f junit",
|
||||
"prod": "vite build --mode production && vite build --mode production --ssr",
|
||||
"dev": "NODE_ENV=development vite build -d --mode development",
|
||||
"eslint": "node ./node_modules/.bin/eslint --config './eslint.config.js' --max-warnings 0 'resources/ts/**/*.{ts,tsx}'",
|
||||
"eslint-fix": "node ./node_modules/.bin/eslint --config './eslint.config.js' --max-warnings 0 'resources/ts/**/*.{ts,tsx}' --fix",
|
||||
"eslint-ci": "node ./node_modules/.bin/eslint --config './eslint.config.js' --max-warnings 0 'resources/ts/**/*.{ts,tsx}' -f junit",
|
||||
"stylelint": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 'resources/sass/**/*.scss'",
|
||||
"stylelint-fix": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 'resources/sass/**/*.scss' --fix",
|
||||
"stylelint-ci": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 'resources/sass/**/*.scss' -f json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@headlessui/react": "^2.2.10",
|
||||
"@radix-ui/react-accordion": "^1.2.12",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-collapsible": "^1.1.12",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.8",
|
||||
"@radix-ui/react-popover": "^1.1.15",
|
||||
"@radix-ui/react-progress": "^1.1.8",
|
||||
"@radix-ui/react-scroll-area": "^1.2.10",
|
||||
"@radix-ui/react-select": "^2.2.6",
|
||||
"@radix-ui/react-separator": "^1.1.8",
|
||||
"@radix-ui/react-slider": "^1.3.6",
|
||||
"@radix-ui/react-slot": "^1.2.4",
|
||||
"@radix-ui/react-switch": "^1.2.6",
|
||||
"@radix-ui/react-toast": "^1.2.15",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@radix-ui/react-accordion": "^1.2.14",
|
||||
"@radix-ui/react-checkbox": "^1.3.5",
|
||||
"@radix-ui/react-collapsible": "^1.1.14",
|
||||
"@radix-ui/react-dialog": "^1.1.17",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.18",
|
||||
"@radix-ui/react-label": "^2.1.10",
|
||||
"@radix-ui/react-popover": "^1.1.17",
|
||||
"@radix-ui/react-progress": "^1.1.10",
|
||||
"@radix-ui/react-scroll-area": "^1.2.12",
|
||||
"@radix-ui/react-select": "^2.3.1",
|
||||
"@radix-ui/react-separator": "^1.1.10",
|
||||
"@radix-ui/react-slider": "^1.4.1",
|
||||
"@radix-ui/react-slot": "^1.3.0",
|
||||
"@radix-ui/react-switch": "^1.3.1",
|
||||
"@radix-ui/react-toast": "^1.2.17",
|
||||
"@radix-ui/react-tooltip": "^1.2.10",
|
||||
"@tailwindcss/forms": "^0.5.11",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@tailwindcss/typography": "^0.5.20",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"@types/node": "^25.9.3",
|
||||
"@types/react-color": "^3.0.13",
|
||||
"@typescript-eslint/eslint-plugin": "^8.59.0",
|
||||
"@typescript-eslint/parser": "^8.59.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
||||
"@typescript-eslint/parser": "^8.61.1",
|
||||
"@uwil/husky-config": "^1.0.1",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"@vitejs/plugin-react": "^6.0.2",
|
||||
"autoprefixer": "^10.5.0",
|
||||
"concurrently": "^9.2.1",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"concurrently": "^9.2.3",
|
||||
"eslint": "^10.5.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-import-resolver-typescript": "^4.4.4",
|
||||
"eslint-import-resolver-typescript": "^4.4.5",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-import-x": "^4.16.2",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"eslint-plugin-prettier": "^5.5.6",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^4.6.2",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"flag-icons": "^7.5.0",
|
||||
"pluralize": "^8.0.0",
|
||||
"prettier": "^3.8.3",
|
||||
"react": "^19.2.5",
|
||||
"prettier": "^3.8.4",
|
||||
"react": "^19.2.7",
|
||||
"react-day-picker": "^9.14.0",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-dom": "^19.2.7",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"sass-embedded": "^1.99.0",
|
||||
"stylelint": "^16.26.1",
|
||||
"stylelint-config-idiomatic-order": "^10.0.0",
|
||||
"stylelint-config-sass-guidelines": "^12.1.0",
|
||||
"stylelint-config-standard-scss": "^14.0.0",
|
||||
"stylelint-scss": "^6.14.0",
|
||||
"sass-embedded": "^1.100.0",
|
||||
"stylelint": "^17.13.0",
|
||||
"stylelint-config-idiomatic-order": "github:ream88/stylelint-config-idiomatic-order",
|
||||
"stylelint-config-sass-guidelines": "^13.0.0",
|
||||
"stylelint-config-standard-scss": "^17.0.0",
|
||||
"stylelint-scss": "^7.2.0",
|
||||
"tailwindcss": "^3.4.19",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"vite": "^6.4.2"
|
||||
"typescript-eslint": "^8.61.1",
|
||||
"vite": "^8.0.16",
|
||||
"vite-plugin-eslint": "^1.8.1",
|
||||
"vite-plugin-stylelint": "^6.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@inertiajs/core": "^2.1.5",
|
||||
"@inertiajs/react": "^2.3.21",
|
||||
"@inertiajs/core": "^3.4.0",
|
||||
"@inertiajs/react": "^3.4.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tiptap/core": "^3.22.4",
|
||||
"@tiptap/extension-blockquote": "^3.22.4",
|
||||
"@tiptap/extension-bold": "^3.22.4",
|
||||
"@tiptap/extension-bullet-list": "^3.22.4",
|
||||
"@tiptap/extension-color": "^3.22.4",
|
||||
"@tiptap/extension-heading": "^3.22.4",
|
||||
"@tiptap/extension-history": "^3.22.4",
|
||||
"@tiptap/extension-horizontal-rule": "^3.22.4",
|
||||
"@tiptap/extension-image": "^3.22.4",
|
||||
"@tiptap/extension-invisible-characters": "^3.22.4",
|
||||
"@tiptap/extension-italic": "^3.22.4",
|
||||
"@tiptap/extension-link": "^3.22.4",
|
||||
"@tiptap/extension-list": "^3.22.4",
|
||||
"@tiptap/extension-ordered-list": "^3.22.4",
|
||||
"@tiptap/extension-placeholder": "^3.22.4",
|
||||
"@tiptap/extension-strike": "^3.22.4",
|
||||
"@tiptap/extension-subscript": "^3.22.4",
|
||||
"@tiptap/extension-superscript": "^3.22.4",
|
||||
"@tiptap/extension-table": "^3.22.4",
|
||||
"@tiptap/extension-table-cell": "^3.22.4",
|
||||
"@tiptap/extension-table-header": "^3.22.4",
|
||||
"@tiptap/extension-table-row": "^3.22.4",
|
||||
"@tiptap/extension-text-align": "^3.22.4",
|
||||
"@tiptap/extension-underline": "^3.22.4",
|
||||
"@tiptap/react": "^3.22.4",
|
||||
"@tiptap/starter-kit": "^3.22.4",
|
||||
"@tiptap/core": "^3.27.0",
|
||||
"@tiptap/extension-blockquote": "^3.27.0",
|
||||
"@tiptap/extension-bold": "^3.27.0",
|
||||
"@tiptap/extension-bullet-list": "^3.27.0",
|
||||
"@tiptap/extension-color": "^3.27.0",
|
||||
"@tiptap/extension-heading": "^3.27.0",
|
||||
"@tiptap/extension-history": "^3.27.0",
|
||||
"@tiptap/extension-horizontal-rule": "^3.27.0",
|
||||
"@tiptap/extension-image": "^3.27.0",
|
||||
"@tiptap/extension-invisible-characters": "^3.27.0",
|
||||
"@tiptap/extension-italic": "^3.27.0",
|
||||
"@tiptap/extension-link": "^3.27.0",
|
||||
"@tiptap/extension-list": "^3.27.0",
|
||||
"@tiptap/extension-ordered-list": "^3.27.0",
|
||||
"@tiptap/extension-placeholder": "^3.27.0",
|
||||
"@tiptap/extension-strike": "^3.27.0",
|
||||
"@tiptap/extension-subscript": "^3.27.0",
|
||||
"@tiptap/extension-superscript": "^3.27.0",
|
||||
"@tiptap/extension-table": "^3.27.0",
|
||||
"@tiptap/extension-table-cell": "^3.27.0",
|
||||
"@tiptap/extension-table-header": "^3.27.0",
|
||||
"@tiptap/extension-table-row": "^3.27.0",
|
||||
"@tiptap/extension-text-align": "^3.27.0",
|
||||
"@tiptap/extension-underline": "^3.27.0",
|
||||
"@tiptap/react": "^3.27.0",
|
||||
"@tiptap/starter-kit": "^3.27.0",
|
||||
"@types/pluralize": "^0.0.33",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"axios": "^1.15.2",
|
||||
"axios": "^1.18.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"json-edit-react": "^1.29.0",
|
||||
"laravel-vite-plugin": "^1.3.0",
|
||||
"date-fns": "^4.4.0",
|
||||
"globals": "^17.6.0",
|
||||
"json-edit-react": "^1.30.1",
|
||||
"laravel-vite-plugin": "^3.1.0",
|
||||
"lucide-react": "^0.503.0",
|
||||
"motion": "^12.38.0",
|
||||
"motion": "^12.40.0",
|
||||
"prosemirror-state": "^1.4.4",
|
||||
"react-color": "^2.19.3",
|
||||
"react-dropzone": "^14.4.1",
|
||||
"react-image-crop": "^11.0.10",
|
||||
"slugify": "^1.6.9",
|
||||
"tailwind-merge": "^3.5.0",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"ziggy-js": "^2.6.2",
|
||||
"zod": "^4.3.6",
|
||||
"zustand": "^5.0.12"
|
||||
}
|
||||
"zod": "^4.4.3",
|
||||
"zustand": "^5.0.14"
|
||||
},
|
||||
"overrides": {
|
||||
"eslint-plugin-jsx-a11y": {
|
||||
"eslint": "^10.4.1"
|
||||
},
|
||||
"eslint-plugin-react": {
|
||||
"eslint": "^10.4.1"
|
||||
},
|
||||
"eslint-plugin-import": {
|
||||
"eslint": "^10.4.1"
|
||||
}
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"@uwil/husky-config"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/storage/*</exclude-pattern>
|
||||
<exclude-pattern>*/packages/*</exclude-pattern>
|
||||
<exclude-pattern>_ide_helper.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">*.blade.php</exclude-pattern>
|
||||
|
||||
<rule ref="PSR12"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ includes:
|
|||
parameters:
|
||||
paths:
|
||||
- app/
|
||||
- bootstrap/
|
||||
- config/
|
||||
- database/factories/
|
||||
- database/
|
||||
- lang/
|
||||
- routes/
|
||||
|
||||
level: 7
|
||||
|
|
|
|||
|
|
@ -1,24 +1,34 @@
|
|||
import { createInertiaApp } from "@inertiajs/react";
|
||||
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import axios from "axios";
|
||||
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
|
||||
import type { ComponentType } from "react";
|
||||
import { createRoot, hydrateRoot } from "react-dom/client";
|
||||
|
||||
// @ts-expect-error Env is always present.
|
||||
const appName = import.meta.env.VITE_APP_NAME || "Laravel";
|
||||
type PageComponent = ComponentType<Record<string, unknown>>;
|
||||
|
||||
createInertiaApp({
|
||||
interface PageModule {
|
||||
default: PageComponent;
|
||||
}
|
||||
|
||||
const appName: string = (import.meta.env as Record<string, string>)
|
||||
.VITE_APP_NAME;
|
||||
const appPages = import.meta.glob<PageModule>("./*/Pages/**/*.tsx");
|
||||
|
||||
void createInertiaApp({
|
||||
title: (title) => `${title} - ${appName}`,
|
||||
resolve: (name) =>
|
||||
resolvePageComponent(
|
||||
resolve: async (name) => {
|
||||
const page = await resolvePageComponent<PageModule>(
|
||||
`./${name}.tsx`,
|
||||
// @ts-expect-error Glob error.
|
||||
import.meta.glob("./*/Pages/**/*.tsx"),
|
||||
),
|
||||
appPages,
|
||||
);
|
||||
return page.default;
|
||||
},
|
||||
setup({ el, App, props }) {
|
||||
const root = createRoot(el);
|
||||
|
||||
// eslint-disable-next-line react/jsx-filename-extension, react/jsx-props-no-spreading
|
||||
root.render(<App {...props} />);
|
||||
if (el.childElementCount > 0) {
|
||||
hydrateRoot(el, <App {...props} />);
|
||||
} else {
|
||||
createRoot(el).render(<App {...props} />);
|
||||
}
|
||||
},
|
||||
progress: {
|
||||
color: "#4B5563",
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
// * Packages
|
||||
import { Link, usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
// * Other
|
||||
import { useTheme } from "@/back/providers/ThemeProvider";
|
||||
import logoUwilSupportLight from "&/images/logos/uwil-support-light.svg";
|
||||
|
||||
import logoUwilSupportDark from "&/images/logos/uwil-support-dark.svg";
|
||||
import logoTinyUwilSupport from "&/images/logos/uwil-support-light-icon.svg";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import logoUwilSupportLight from "&/images/logos/uwil-support-light.svg";
|
||||
import { useTheme } from "@/back/providers/ThemeProvider";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
|
||||
type ApplicationLogoProps = {
|
||||
interface ApplicationLogoProps {
|
||||
forceLight?: boolean;
|
||||
isCollapsed?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the logo.
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
// * Packages
|
||||
import { Link } from "@inertiajs/react";
|
||||
import { type VariantProps } from "class-variance-authority";
|
||||
import {
|
||||
ButtonHTMLAttributes,
|
||||
CSSProperties,
|
||||
MouseEventHandler,
|
||||
ReactNode,
|
||||
type ButtonHTMLAttributes,
|
||||
type CSSProperties,
|
||||
type MouseEventHandler,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { VariantProps } from "class-variance-authority";
|
||||
// * Components shadcn
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
|
||||
import { Button, type buttonVariants } from "@/components/ui/button";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
|
|
@ -19,7 +18,7 @@ type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
|||
type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
||||
type ButtonType = ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
||||
|
||||
type BtnOptionnalLinkWithTooltipProps = {
|
||||
interface BtnOptionnalLinkWithTooltipProps {
|
||||
link?: string | null;
|
||||
content: ReactNode;
|
||||
tooltipContent: ReactNode;
|
||||
|
|
@ -31,7 +30,7 @@ type BtnOptionnalLinkWithTooltipProps = {
|
|||
disabled?: boolean;
|
||||
style?: CSSProperties;
|
||||
onClick?: MouseEventHandler<HTMLButtonElement>;
|
||||
};
|
||||
}
|
||||
|
||||
export default function BtnOptionnalLinkWithTooltip({
|
||||
link = null,
|
||||
|
|
@ -75,7 +74,6 @@ export default function BtnOptionnalLinkWithTooltip({
|
|||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
style={style}
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...props}
|
||||
>
|
||||
{innerContent}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
// * Packages
|
||||
import { router, usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { LoaderCircleIcon, SendIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
// * Other
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import {
|
||||
type AuthProp,
|
||||
type ConfigBackend,
|
||||
type UserModel,
|
||||
} from "@/back/types/global";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { AuthProp, ConfigBackend, UserModel } from "@/back/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function BtnResetPassword({ model }: { model: UserModel }) {
|
||||
|
|
@ -31,7 +33,7 @@ export default function BtnResetPassword({ model }: { model: UserModel }) {
|
|||
const handleSendResetLink = () => {
|
||||
setIsSending(true);
|
||||
router.post(
|
||||
route(`${routes.name}users.send-reset-password-link`, model),
|
||||
route(`${routes.name}users.send-reset-password-link`, { id: model.id }),
|
||||
{},
|
||||
{
|
||||
onSuccess: () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// * Packages
|
||||
import { PanelRightOpenIcon, PanelRightCloseIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useSidebar } from "@/components/ui/sidebar";
|
||||
import {
|
||||
|
|
@ -8,17 +8,18 @@ import {
|
|||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
// * Other
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function CustomSidebarTrigger() {
|
||||
const { toggleSidebar, state } = useSidebar();
|
||||
|
||||
if (state === "collapsed") {
|
||||
localStorage.setItem("vite-ui-collapsed", "true");
|
||||
} else {
|
||||
localStorage.removeItem("vite-ui-collapsed");
|
||||
}
|
||||
useEffect(() => {
|
||||
if (state === "collapsed") {
|
||||
localStorage.setItem("vite-ui-collapsed", "true");
|
||||
} else {
|
||||
localStorage.removeItem("vite-ui-collapsed");
|
||||
}
|
||||
}, [state]);
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// * Packages
|
||||
import { ReactNode } from "react";
|
||||
// * Components shadcn
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
|
@ -8,7 +7,6 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
// * Other
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export default function FieldsetWrapper({
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
// * Packages
|
||||
import { route } from "ziggy-js";
|
||||
// * Other
|
||||
import EnumSelect from "@/back/Components/Inputs/EnumSelect";
|
||||
import { LaravelEnum } from "@/types/global";
|
||||
import AddFilterToUrl from "@/back/lib/filters";
|
||||
import { type LaravelEnum } from "@/types/global";
|
||||
|
||||
type Props = {
|
||||
interface Props {
|
||||
enums: LaravelEnum;
|
||||
fieldName: string;
|
||||
modelRoute: string;
|
||||
prefixRoute: string;
|
||||
label: string;
|
||||
placeholder: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function EnumFilter({
|
||||
enums,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
// * Packages
|
||||
import { route } from "ziggy-js";
|
||||
// * Other
|
||||
import { ModelSelect } from "@/back/Components/Inputs/ModelSelect";
|
||||
import AddFilterToUrl from "@/back/lib/filters";
|
||||
|
||||
type Props = {
|
||||
interface Props {
|
||||
fieldName: string;
|
||||
modelRoute: string;
|
||||
prefixRoute: string;
|
||||
|
|
@ -12,7 +9,7 @@ type Props = {
|
|||
placeholder: string;
|
||||
/** Model target to display options */
|
||||
targetModel?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function MultiSelectRelationFilter({
|
||||
targetModel,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
// * Packages
|
||||
import { route } from "ziggy-js";
|
||||
// * Other
|
||||
import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch";
|
||||
import AddFilterToUrl from "@/back/lib/filters";
|
||||
|
||||
type Props = {
|
||||
interface Props {
|
||||
label: string;
|
||||
fieldName: string;
|
||||
modelRoute: string;
|
||||
prefixRoute: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SwitchFilter({
|
||||
label,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// * Packages
|
||||
import { Filter } from "lucide-react";
|
||||
import { ReactNode } from "react";
|
||||
// * Components shadcn
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import {
|
||||
Sheet,
|
||||
SheetContent,
|
||||
|
|
@ -10,10 +10,8 @@ import {
|
|||
SheetTitle,
|
||||
SheetTrigger,
|
||||
} from "@/components/ui/sheet";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
function FiltersWrapper({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { ExternalLinkIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
// * Other
|
||||
import { AppEnv } from "@/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
interface GoToFrontViewProps {
|
||||
/** Model Name used to translate the helper */
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// * Packages
|
||||
import { AlertCircleIcon } from "lucide-react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { AlertCircleIcon } from "lucide-react";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
// * Other
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
|
|
@ -16,7 +14,7 @@ export default function InputError({
|
|||
}) {
|
||||
const { errors } = usePage().props;
|
||||
const errorsTrans = useTrans("uwil-backend::back.errors");
|
||||
let messages = {} as Array<string>;
|
||||
let messages = {} as string[];
|
||||
if (message) {
|
||||
messages = Object.values([message]);
|
||||
} else if (Object.values(errors).length && all) {
|
||||
|
|
@ -26,7 +24,7 @@ export default function InputError({
|
|||
return (
|
||||
<Alert
|
||||
variant="destructive"
|
||||
className={cn("text-left ", { "mb-4": all })}
|
||||
className={cn("text-left col-span-2", { "mb-4": all })}
|
||||
>
|
||||
<AlertCircleIcon className="h-4 w-4" />
|
||||
{all && <AlertTitle>{errorsTrans}</AlertTitle>}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,25 @@
|
|||
// * Packages
|
||||
import { ReactNode, useCallback, useEffect, useState } from "react";
|
||||
import { FileCheck, RefreshCwIcon, Trash, UploadIcon } from "lucide-react";
|
||||
import { ErrorCode, FileWithPath, useDropzone } from "react-dropzone";
|
||||
import "react-image-crop/dist/ReactCrop.css";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { FileCheck, RefreshCwIcon, Trash, UploadIcon } from "lucide-react";
|
||||
import { type ReactNode, useCallback, useEffect, useState } from "react";
|
||||
import { ErrorCode, type FileWithPath, useDropzone } from "react-dropzone";
|
||||
import "react-image-crop/dist/ReactCrop.css";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import ImageCropper from "@/back/Components/Inputs/ImageCropper";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import str from "@/hooks/use-string";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
type FileWithPreview = FileWithPath & {
|
||||
preview: string;
|
||||
};
|
||||
|
||||
type FileValidation = {
|
||||
interface FileValidation {
|
||||
validationRules?: {
|
||||
width: string | null;
|
||||
height: string | null;
|
||||
|
|
@ -29,9 +27,8 @@ type FileValidation = {
|
|||
maxFileSize: string | null;
|
||||
allowedFormats: string | null;
|
||||
inputType?: "image" | "file";
|
||||
};
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */
|
||||
type CompleteInputFileProps = FileValidation & {
|
||||
name: string;
|
||||
value?: string | File | null;
|
||||
|
|
@ -48,14 +45,13 @@ type CompleteInputFileProps = FileValidation & {
|
|||
reset: (name?: string) => void;
|
||||
hasFile?: (hasFile: boolean) => void;
|
||||
};
|
||||
/* eslint-enable no-unused-vars, @typescript-eslint/no-unused-vars */
|
||||
|
||||
export default function CompleteInputFile(props: CompleteInputFileProps) {
|
||||
const {
|
||||
value,
|
||||
setData,
|
||||
originalData,
|
||||
name = "defaultName",
|
||||
name,
|
||||
onRefreshFile,
|
||||
label = "defaultLabel",
|
||||
required = false,
|
||||
|
|
@ -73,11 +69,7 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
const { errors } = usePage().props;
|
||||
const { url } = usePage().props.appEnv as AppEnv;
|
||||
const [isReset, setIsReset] = useState<boolean>(false);
|
||||
const [isDialogOpen, setDialogOpen] = useState(false);
|
||||
const [accept, setAccept] = useState<Record<string, Array<string>>>({
|
||||
"image/*": [],
|
||||
});
|
||||
const [extensions, setExtensions] = useState<string>();
|
||||
const [isDialogOpen, setDialogOpen] = useState<boolean>(false);
|
||||
|
||||
const finalFileName = `${fileName}.png`;
|
||||
const isRefreshDisabled = value != null && typeof value === "string";
|
||||
|
|
@ -86,7 +78,7 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
const localValidationRules = {
|
||||
width: validationRules?.width ? parseInt(validationRules.width, 10) : 250,
|
||||
height: validationRules?.height
|
||||
? parseInt(validationRules?.height, 10)
|
||||
? parseInt(validationRules.height, 10)
|
||||
: 250,
|
||||
};
|
||||
|
||||
|
|
@ -140,7 +132,7 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const currentSize = sizes[i];
|
||||
const currentBytes = parseFloat((bytes / k ** i).toFixed(2));
|
||||
return `${currentBytes} ${currentSize}`;
|
||||
return `${String(currentBytes)} ${currentSize}`;
|
||||
};
|
||||
|
||||
// Translations
|
||||
|
|
@ -162,7 +154,7 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
"uwil-backend::back.image_cropper.validation.rules_weight",
|
||||
{
|
||||
params: {
|
||||
size: formatFileSize(localMaxFileSize).toString(),
|
||||
size: formatFileSize(localMaxFileSize),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -184,11 +176,13 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
.value();
|
||||
};
|
||||
|
||||
const buildDropzoneAccept = (): Record<string, string[]> => {
|
||||
if (!allowedFormats) return {};
|
||||
function buildDropzoneAccept(allowedFormats: string | null): {
|
||||
accept: Record<string, string[]>;
|
||||
extensions: string;
|
||||
} {
|
||||
if (!allowedFormats) return { accept: {}, extensions: "" };
|
||||
|
||||
const currentExtensions = allowedFormats.split(",");
|
||||
setExtensions(allowedFormats);
|
||||
const mimeMap: Record<string, string> = {
|
||||
jpg: "image/jpeg",
|
||||
jpeg: "image/jpeg",
|
||||
|
|
@ -200,31 +194,28 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
};
|
||||
|
||||
const result: Record<string, Set<string>> = {};
|
||||
|
||||
currentExtensions.forEach((ext) => {
|
||||
const cleanExt = ext.trim().toLowerCase();
|
||||
const mime = mimeMap[cleanExt];
|
||||
if (mime) {
|
||||
if (!result[mime]) {
|
||||
result[mime] = new Set();
|
||||
}
|
||||
result[mime] ??= new Set();
|
||||
result[mime].add(`.${cleanExt}`);
|
||||
}
|
||||
});
|
||||
|
||||
// Convert Set to Array for React Dropzone
|
||||
const currentAccept: Record<string, string[]> = {};
|
||||
const accept: Record<string, string[]> = {};
|
||||
Object.entries(result).forEach(([mime, extSet]) => {
|
||||
currentAccept[mime] = Array.from(extSet);
|
||||
accept[mime] = Array.from(extSet);
|
||||
});
|
||||
setAccept(currentAccept);
|
||||
return currentAccept;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
buildDropzoneAccept();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
return { accept, extensions: allowedFormats };
|
||||
}
|
||||
|
||||
const { accept: initialAccept, extensions: initialExtensions } =
|
||||
buildDropzoneAccept(allowedFormats);
|
||||
const [accept] = useState<Record<string, string[]>>(initialAccept);
|
||||
const [extensions] = useState<string>(initialExtensions);
|
||||
|
||||
useEffect(() => {
|
||||
hasFile?.(!!selectedFile);
|
||||
|
|
@ -262,7 +253,7 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
|
||||
const onDrop = useCallback(
|
||||
(acceptedFiles: FileWithPath[]) => {
|
||||
const file = acceptedFiles[0];
|
||||
const file = acceptedFiles[0] as FileWithPath | null;
|
||||
if (!file) {
|
||||
toast({
|
||||
title: "Oups !",
|
||||
|
|
@ -291,7 +282,7 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
maxSize: localMaxFileSize,
|
||||
onDropRejected: (fileRejections) => {
|
||||
const rejection = fileRejections[0];
|
||||
const rejectionCode = rejection?.errors?.[0]?.code;
|
||||
const rejectionCode = rejection.errors[0]?.code as ErrorCode | undefined;
|
||||
if (rejectionCode === ErrorCode.FileTooLarge) {
|
||||
toast({
|
||||
title: "Oups !",
|
||||
|
|
@ -379,10 +370,8 @@ export default function CompleteInputFile(props: CompleteInputFileProps) {
|
|||
"flex border border-dashed overflow-hidden whitespace-normal [&_svg]:!pointer-events-auto [&_svg]:!size-auto [&_svg]:!shrink text-muted-foreground w-full h-36",
|
||||
{ "border-destructive": localErrors[name] },
|
||||
)}
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...getRootProps()}
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||
<input name={name} {...getInputProps()} />
|
||||
<div className="flex flex-col justify-center items-center">
|
||||
<UploadIcon />
|
||||
|
|
|
|||
|
|
@ -1,25 +1,23 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { CheckIcon, ChevronsUpDownIcon, SearchIcon, XIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { useState } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import { cn } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
type EnumSelectProps = {
|
||||
interface EnumSelectProps {
|
||||
name: string;
|
||||
label: string;
|
||||
options?: Record<string, { label: string; name: string; value: number }>;
|
||||
|
|
@ -29,11 +27,9 @@ type EnumSelectProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: number | null) => void;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onSelectValue?: (value: number | null) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function EnumSelect({
|
||||
name,
|
||||
|
|
@ -52,25 +48,26 @@ export default function EnumSelect({
|
|||
const { errors } = usePage().props;
|
||||
const localErrors = parentErrors ?? errors;
|
||||
|
||||
// List of options.
|
||||
const initalOptions = Object.fromEntries(
|
||||
Object.entries(options).filter(([, item]) => !exclude.includes(item.value)),
|
||||
);
|
||||
const [currentOptions, setCurrentOptions] =
|
||||
useState<Record<string, { label: string; name: string; value: number }>>(
|
||||
initalOptions,
|
||||
);
|
||||
|
||||
// Model key selected.
|
||||
const initial =
|
||||
selected === 0 || selected === null || selected === undefined
|
||||
? null
|
||||
: Number(selected);
|
||||
const initial = selected && selected !== 0 ? selected : null;
|
||||
const [selectedEnum, setSelectedEnum] = useState<number | null>(initial);
|
||||
|
||||
// String research in models collection.
|
||||
const [search, setSearch] = useState<string>("");
|
||||
|
||||
// List of options.
|
||||
const initalOptions = Object.fromEntries(
|
||||
Object.entries(options).filter(([, item]) => !exclude.includes(item.value)),
|
||||
);
|
||||
const currentOptions =
|
||||
search.length === 0
|
||||
? initalOptions
|
||||
: Object.fromEntries(
|
||||
Object.entries(initalOptions).filter(([, item]) =>
|
||||
item.label.toLowerCase().includes(search),
|
||||
),
|
||||
);
|
||||
|
||||
// Component states.
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
|
||||
|
|
@ -124,25 +121,6 @@ export default function EnumSelect({
|
|||
setSearch("");
|
||||
};
|
||||
|
||||
// Fetch with debounce.
|
||||
useEffect(() => {
|
||||
// Reset options list if empty search or null
|
||||
if (search.length === 0) {
|
||||
setCurrentOptions(initalOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
const optionsFiltered = Object.fromEntries(
|
||||
Object.entries(initalOptions).filter(([, item]) =>
|
||||
item.label.toLowerCase().includes(search),
|
||||
),
|
||||
);
|
||||
|
||||
// Get updated options list with search.
|
||||
setCurrentOptions(optionsFiltered);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [search, options]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col w-full gap-1.5">
|
||||
<Label htmlFor={name} className="flex items-center gap-1.5">
|
||||
|
|
@ -179,7 +157,9 @@ export default function EnumSelect({
|
|||
placeholder={placeholder}
|
||||
value={search}
|
||||
disabled={disabled}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setSearch(e.target.value);
|
||||
}}
|
||||
className="w-[calc(100%-2.5rem-40px)] border-0 mx-9"
|
||||
/>
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
|
|
@ -216,7 +196,9 @@ export default function EnumSelect({
|
|||
className="w-full h-auto min-h-10 justify-between whitespace-normal text-start"
|
||||
variant="ghost"
|
||||
disabled={disabled}
|
||||
onClick={() => handleSelect(option.value)}
|
||||
onClick={() => {
|
||||
handleSelect(option.value);
|
||||
}}
|
||||
>
|
||||
<span>{str(option.label).ucFirst().value()}</span>
|
||||
{selectedEnum === option.value && <CheckIcon />}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,4 @@
|
|||
// * Packages
|
||||
import {
|
||||
Dispatch,
|
||||
MouseEvent,
|
||||
SetStateAction,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type SyntheticEvent,
|
||||
} from "react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
CropIcon,
|
||||
|
|
@ -21,13 +12,26 @@ import {
|
|||
ZoomOutIcon,
|
||||
RefreshCwIcon,
|
||||
} from "lucide-react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import {
|
||||
type Dispatch,
|
||||
type MouseEvent,
|
||||
type SetStateAction,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type SyntheticEvent,
|
||||
} from "react";
|
||||
import { type FileWithPath } from "react-dropzone";
|
||||
import ReactCrop, { type Crop, type PixelCrop } from "react-image-crop";
|
||||
import { FileWithPath } from "react-dropzone";
|
||||
import "react-image-crop/dist/ReactCrop.css";
|
||||
import { route } from "ziggy-js";
|
||||
// * Components shadcn
|
||||
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleContent,
|
||||
CollapsibleTrigger,
|
||||
} from "@/components/ui/collapsible";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -37,23 +41,16 @@ import {
|
|||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleContent,
|
||||
CollapsibleTrigger,
|
||||
} from "@/components/ui/collapsible";
|
||||
import { Slider } from "@/components/ui/slider";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
// * Other
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useDeviceType from "@/hooks/use-device-type";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
|
||||
interface CropValidationRules {
|
||||
width: number;
|
||||
|
|
@ -64,7 +61,6 @@ type FileWithPreview = FileWithPath & {
|
|||
preview: string;
|
||||
};
|
||||
|
||||
/* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */
|
||||
interface ImageCropperProps {
|
||||
dialogOpen: boolean;
|
||||
name: string;
|
||||
|
|
@ -79,7 +75,6 @@ interface ImageCropperProps {
|
|||
reset: (name?: string) => void;
|
||||
setIsReset: (value: boolean) => void;
|
||||
}
|
||||
/* eslint-enable no-unused-vars, @typescript-eslint/no-unused-vars */
|
||||
|
||||
export default function ImageCropper({
|
||||
dialogOpen,
|
||||
|
|
@ -141,7 +136,10 @@ export default function ImageCropper({
|
|||
const canvas = document.createElement("canvas");
|
||||
canvas.width = validationRules.width;
|
||||
canvas.height = validationRules.height;
|
||||
const ctx = canvas.getContext("2d")!;
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) {
|
||||
throw new Error("canvas context missing.");
|
||||
}
|
||||
|
||||
// Calculer le ratio entre l'affichage et les dimensions originales
|
||||
const displayScale = scaleFactor * (1 + zoom);
|
||||
|
|
@ -177,12 +175,16 @@ export default function ImageCropper({
|
|||
const tmpCanvas = document.createElement("canvas");
|
||||
tmpCanvas.width = tmpWidth;
|
||||
tmpCanvas.height = tmpHeight;
|
||||
const tmpCtx = tmpCanvas.getContext("2d")!;
|
||||
|
||||
const tmpCtx = tmpCanvas.getContext("2d");
|
||||
if (!tmpCtx) {
|
||||
throw new Error("canvas context missing.");
|
||||
}
|
||||
|
||||
tmpCtx.save();
|
||||
|
||||
// Appliquer les filtres
|
||||
tmpCtx.filter = `brightness(${brightness}%) contrast(${contrast}%) saturate(${saturation}%) sepia(${sepia}%) grayscale(${grayscale}%)`;
|
||||
tmpCtx.filter = `brightness(${String(brightness)}%) contrast(${String(contrast)}%) saturate(${String(saturation)}%) sepia(${String(sepia)}%) grayscale(${String(grayscale)}%)`;
|
||||
|
||||
// Translater au centre du canvas temporaire
|
||||
tmpCtx.translate(tmpWidth / 2, tmpHeight / 2);
|
||||
|
|
@ -231,9 +233,7 @@ export default function ImageCropper({
|
|||
*/
|
||||
function urlToBase64(
|
||||
targetUrl: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
callback: (base64: string | ArrayBuffer | null) => void,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
errorCallback?: (error: string) => void,
|
||||
): void {
|
||||
fetch(targetUrl)
|
||||
|
|
@ -241,11 +241,13 @@ export default function ImageCropper({
|
|||
.then((blob) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onloadend = () => callback(reader.result);
|
||||
reader.onloadend = () => {
|
||||
callback(reader.result);
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (errorCallback) errorCallback(error);
|
||||
.catch((error: unknown) => {
|
||||
if (errorCallback) errorCallback(String(error));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +259,7 @@ export default function ImageCropper({
|
|||
*/
|
||||
function base64ToFile(dataUrl: string): File {
|
||||
const [meta, base64] = dataUrl.split(",");
|
||||
const mimeMatch = meta.match(/:(.*?);/);
|
||||
const mimeMatch = /:(.*?);/.exec(meta);
|
||||
const mime = mimeMatch ? mimeMatch[1] : "image/png";
|
||||
const decodedBase64 = atob(base64);
|
||||
const { length } = decodedBase64;
|
||||
|
|
@ -294,13 +296,14 @@ export default function ImageCropper({
|
|||
|
||||
// Reset de la position et dimensions quand l'image change
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
setImagePosition({ x: 0, y: 0 });
|
||||
setOriginalDimensions({ width: 0, height: 0 });
|
||||
}, [selectedFile]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!value || !isDuplicating) return;
|
||||
const pathFileBase = `${url}/${value}`;
|
||||
const pathFileBase = `${url}/${typeof value === "object" ? value.name : value}`;
|
||||
urlToBase64(
|
||||
pathFileBase,
|
||||
(base64) => {
|
||||
|
|
@ -309,16 +312,18 @@ export default function ImageCropper({
|
|||
setData(name, file);
|
||||
}
|
||||
},
|
||||
(err) => console.error(err),
|
||||
(err) => {
|
||||
console.error(err);
|
||||
},
|
||||
);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Crop the image with all options.
|
||||
* @return Promise<void>
|
||||
* @return void
|
||||
*/
|
||||
async function onCrop(): Promise<void> {
|
||||
function onCrop(): void {
|
||||
try {
|
||||
if (imgRef.current && cropZone) {
|
||||
// Recalculer les coordonnées en pixels à partir de cropZone actuel
|
||||
|
|
@ -350,8 +355,8 @@ export default function ImageCropper({
|
|||
}
|
||||
setDialogOpen(false);
|
||||
}
|
||||
} catch (error: Error | unknown) {
|
||||
throw new Error(`Something went wrong : ${error}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Something went wrong : ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -451,7 +456,7 @@ export default function ImageCropper({
|
|||
if (value) setIsReset(true);
|
||||
|
||||
// Recalculer et forcer le centrage de l'image ET de la zone de crop
|
||||
if (imgRef.current && originalDimensions.width > 0) {
|
||||
if (originalDimensions.width > 0) {
|
||||
const displayedWidth = originalDimensions.width * scaleFactor;
|
||||
const displayedHeight = originalDimensions.height * scaleFactor;
|
||||
|
||||
|
|
@ -540,7 +545,7 @@ export default function ImageCropper({
|
|||
// Filters (brightness, contrast, saturation, sepia, grayscale).
|
||||
const imageFilterOptions = [
|
||||
{
|
||||
label: () => `${transBrightness}: ${brightness}%`,
|
||||
label: () => `${transBrightness}: ${String(brightness)}%`,
|
||||
tooltip: "brightness",
|
||||
slider: {
|
||||
min: 0,
|
||||
|
|
@ -554,7 +559,7 @@ export default function ImageCropper({
|
|||
},
|
||||
},
|
||||
{
|
||||
label: () => `${transContrast}: ${contrast}%`,
|
||||
label: () => `${transContrast}: ${String(contrast)}%`,
|
||||
tooltip: "contrast",
|
||||
slider: {
|
||||
min: 0,
|
||||
|
|
@ -568,7 +573,7 @@ export default function ImageCropper({
|
|||
},
|
||||
},
|
||||
{
|
||||
label: () => `${transSaturation}: ${saturation}%`,
|
||||
label: () => `${transSaturation}: ${String(saturation)}%`,
|
||||
tooltip: "saturation",
|
||||
slider: {
|
||||
min: 0,
|
||||
|
|
@ -582,7 +587,7 @@ export default function ImageCropper({
|
|||
},
|
||||
},
|
||||
{
|
||||
label: () => `${transSepia}: ${sepia}%`,
|
||||
label: () => `${transSepia}: ${String(sepia)}%`,
|
||||
tooltip: "sepia",
|
||||
slider: {
|
||||
min: 0,
|
||||
|
|
@ -596,7 +601,7 @@ export default function ImageCropper({
|
|||
},
|
||||
},
|
||||
{
|
||||
label: () => `${transGrayscale}: ${grayscale}%`,
|
||||
label: () => `${transGrayscale}: ${String(grayscale)}%`,
|
||||
tooltip: "grayscale",
|
||||
slider: {
|
||||
min: 0,
|
||||
|
|
@ -614,7 +619,7 @@ export default function ImageCropper({
|
|||
// Main options (rotation, zoom).
|
||||
const mainOptions = [
|
||||
{
|
||||
label: () => `${transRotation}: ${rotation}°`,
|
||||
label: () => `${transRotation}: ${String(rotation)}°`,
|
||||
tooltip: "rotation",
|
||||
slider: {
|
||||
min: -180,
|
||||
|
|
@ -630,17 +635,21 @@ export default function ImageCropper({
|
|||
{
|
||||
icon: RotateCcwIcon,
|
||||
tooltip: "rotation_back",
|
||||
fn: () => setRotation((r) => r - 10),
|
||||
fn: () => {
|
||||
setRotation((r) => r - 10);
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: RotateCwIcon,
|
||||
tooltip: "rotation_forward",
|
||||
fn: () => setRotation((r) => r + 10),
|
||||
fn: () => {
|
||||
setRotation((r) => r + 10);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: () => `${transZoom}: ${Math.round((1 + zoom) * 100)}%`,
|
||||
label: () => `${transZoom}: ${String(Math.round((1 + zoom) * 100))}%`,
|
||||
tooltip: "zoom",
|
||||
slider: {
|
||||
min: -0.99,
|
||||
|
|
@ -683,12 +692,16 @@ export default function ImageCropper({
|
|||
const otherOptions = [
|
||||
{
|
||||
icon: FlipHorizontalIcon,
|
||||
fn: () => setFlipX((prev) => !prev),
|
||||
fn: () => {
|
||||
setFlipX((prev) => !prev);
|
||||
},
|
||||
tooltip: "horizontal_flip",
|
||||
},
|
||||
{
|
||||
icon: FlipVerticalIcon,
|
||||
fn: () => setFlipY((prev) => !prev),
|
||||
fn: () => {
|
||||
setFlipY((prev) => !prev);
|
||||
},
|
||||
tooltip: "vertical_flip",
|
||||
},
|
||||
{
|
||||
|
|
@ -737,7 +750,9 @@ export default function ImageCropper({
|
|||
>
|
||||
<ReactCrop
|
||||
crop={cropZone}
|
||||
onChange={(_, percentCrop) => setCropZone(percentCrop)}
|
||||
onChange={(_, percentCrop) => {
|
||||
setCropZone(percentCrop);
|
||||
}}
|
||||
aspect={aspect}
|
||||
className="w-full"
|
||||
locked
|
||||
|
|
@ -763,18 +778,18 @@ export default function ImageCropper({
|
|||
)}
|
||||
style={{
|
||||
position: "absolute",
|
||||
left: `${imagePosition.x}px`,
|
||||
top: `${imagePosition.y}px`,
|
||||
left: `${String(imagePosition.x)}px`,
|
||||
top: `${String(imagePosition.y)}px`,
|
||||
width:
|
||||
originalDimensions.width > 0
|
||||
? `${originalDimensions.width * scaleFactor}px`
|
||||
? `${String(originalDimensions.width * scaleFactor)}px`
|
||||
: "auto",
|
||||
height:
|
||||
originalDimensions.height > 0
|
||||
? `${originalDimensions.height * scaleFactor}px`
|
||||
? `${String(originalDimensions.height * scaleFactor)}px`
|
||||
: "auto",
|
||||
transform: `scale(${1 + zoom}) rotate(${rotation}deg) scaleX(${flipX ? -1 : 1}) scaleY(${flipY ? -1 : 1})`,
|
||||
filter: `brightness(${brightness}%) contrast(${contrast}%) saturate(${saturation}%) sepia(${sepia}%) grayscale(${grayscale}%)`,
|
||||
transform: `scale(${String(1 + zoom)}) rotate(${String(rotation)}deg) scaleX(${String(flipX ? -1 : 1)}) scaleY(${String(flipY ? -1 : 1)})`,
|
||||
filter: `brightness(${String(brightness)}%) contrast(${String(contrast)}%) saturate(${String(saturation)}%) sepia(${String(sepia)}%) grayscale(${String(grayscale)}%)`,
|
||||
transformOrigin: "center center",
|
||||
transition: !isDragging
|
||||
? "transform 0.2s ease, filter 0.2s ease"
|
||||
|
|
@ -795,8 +810,11 @@ export default function ImageCropper({
|
|||
"uwil-backend::back.image_cropper.modale_description",
|
||||
)}
|
||||
</DialogDescription>
|
||||
{mainOptions.map((option) => (
|
||||
<div className="flex items-center gap-2 w-full mb-4">
|
||||
{mainOptions.map((option, optionIndex) => (
|
||||
<div
|
||||
key={optionIndex}
|
||||
className="flex items-center gap-2 w-full mb-4"
|
||||
>
|
||||
<div className="flex flex-col w-full items-start">
|
||||
<label htmlFor="rotation" className="mb-2 text-sm">
|
||||
{option.label()}
|
||||
|
|
@ -823,8 +841,8 @@ export default function ImageCropper({
|
|||
</Tooltip>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
{option.buttons.map((currentOption) => (
|
||||
<Tooltip>
|
||||
{option.buttons.map((currentOption, currentOptionIndex) => (
|
||||
<Tooltip key={currentOptionIndex}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
|
|
@ -872,8 +890,11 @@ export default function ImageCropper({
|
|||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="space-y-4 pt-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{imageFilterOptions.map((option) => (
|
||||
<div className="flex flex-col items-start">
|
||||
{imageFilterOptions.map((option, optionIndex) => (
|
||||
<div
|
||||
key={optionIndex}
|
||||
className="flex flex-col items-start"
|
||||
>
|
||||
<label
|
||||
htmlFor={str(option.label()).slug().value()}
|
||||
className="mb-2 text-sm"
|
||||
|
|
@ -908,9 +929,9 @@ export default function ImageCropper({
|
|||
</Collapsible>
|
||||
{/* Others actions */}
|
||||
<div className="flex flex-row justify-center gap-2 mb-4">
|
||||
{otherOptions.map((option) => {
|
||||
{otherOptions.map((option, optionKey) => {
|
||||
return (
|
||||
<Tooltip>
|
||||
<Tooltip key={optionKey}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button variant="outline" size="sm" onClick={option.fn}>
|
||||
<option.icon />
|
||||
|
|
|
|||
|
|
@ -1,18 +1,5 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import {
|
||||
ButtonHTMLAttributes,
|
||||
CSSProperties,
|
||||
forwardRef,
|
||||
KeyboardEvent,
|
||||
ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useId,
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import axios, { isAxiosError } from "axios";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import {
|
||||
CheckIcon,
|
||||
|
|
@ -24,17 +11,29 @@ import {
|
|||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from "lucide-react";
|
||||
import axios, { isAxiosError } from "axios";
|
||||
import { route } from "ziggy-js";
|
||||
// * Components shadcn
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
type ButtonHTMLAttributes,
|
||||
type CSSProperties,
|
||||
forwardRef,
|
||||
type KeyboardEvent,
|
||||
type ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useId,
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import {
|
||||
type DefaultModel,
|
||||
type Paginator,
|
||||
type ConfigBackend,
|
||||
} from "@/back/types/global";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
|
|
@ -42,16 +41,18 @@ import {
|
|||
CommandItem,
|
||||
CommandList,
|
||||
} from "@/components/ui/command";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import str from "@/hooks/use-string";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import { DefaultModel, Paginator, ConfigBackend } from "@/back/types/global";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
/**
|
||||
* Animation types and configurations
|
||||
|
|
@ -110,14 +111,12 @@ interface ModelSelectProps
|
|||
* Callback function triggered when the selected values change.
|
||||
* Receives an array of the new selected values.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onValueChange?: (value: number[]) => void;
|
||||
|
||||
/**
|
||||
* Callback function triggered when the selected values change.
|
||||
* Receives a single or array of selected Model(s).
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onModelChange?: (value: DefaultModel[]) => void;
|
||||
|
||||
/** The default selected values when the component mounts. */
|
||||
|
|
@ -158,7 +157,6 @@ interface ModelSelectProps
|
|||
* If true, renders the multi-select component as a child of another component.
|
||||
* Optional, defaults to false.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||
asChild?: boolean;
|
||||
|
||||
/**
|
||||
|
|
@ -292,7 +290,6 @@ interface ModelSelectProps
|
|||
/**
|
||||
* The fonction to set the data in useForm inertia
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: number[] | number | null) => void;
|
||||
|
||||
/**
|
||||
|
|
@ -362,7 +359,6 @@ export interface ModelSelectRef {
|
|||
/**
|
||||
* Set selected values programmatically
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setSelectedValues: (values: number[]) => void;
|
||||
/**
|
||||
* Clear all selected values
|
||||
|
|
@ -394,7 +390,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
animationConfig,
|
||||
maxCount = 3,
|
||||
modalPopover = false,
|
||||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
asChild = false,
|
||||
className,
|
||||
hideSelectAll = false,
|
||||
|
|
@ -471,7 +467,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
const csrfToken =
|
||||
document
|
||||
.querySelector('meta[name="csrf-token"]')
|
||||
?.getAttribute("content") || "";
|
||||
?.getAttribute("content") ?? "";
|
||||
|
||||
const response = await axios.post(
|
||||
route(`${routes.name}model.list`),
|
||||
|
|
@ -494,7 +490,11 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
},
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
return response.data as {
|
||||
items: Paginator;
|
||||
field: string;
|
||||
model: DefaultModel[] | null;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -508,43 +508,37 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
const requestId = requestIdRef.current;
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = (await fetchOptions(pageNumber)) as {
|
||||
items: Paginator;
|
||||
field: string;
|
||||
model: DefaultModel[];
|
||||
};
|
||||
const data = await fetchOptions(pageNumber);
|
||||
// Ignore obsolete answers.
|
||||
if (requestId !== requestIdRef.current) return;
|
||||
const dataModel: DefaultModel[] = data.model
|
||||
? Object.values(data.model)
|
||||
: [];
|
||||
const dataItems: DefaultModel[] = Array.isArray(data?.items?.data)
|
||||
const dataModel = data.model ? Object.values(data.model) : [];
|
||||
const dataItems: DefaultModel[] = Array.isArray(data.items.data)
|
||||
? data.items.data
|
||||
: [];
|
||||
setOptionsMerged(() => {
|
||||
const merged = [...dataModel, ...dataItems]
|
||||
// Supprime les éléments undefined ou sans id
|
||||
.filter(
|
||||
(item): item is DefaultModel => !!item && item.id !== undefined,
|
||||
)
|
||||
// Supprime les doublons par id
|
||||
.filter(
|
||||
(item, index, self) =>
|
||||
index === self.findIndex((i) => i.id === item.id),
|
||||
index ===
|
||||
self.findIndex((selfIndex) => selfIndex.id === item.id),
|
||||
);
|
||||
return merged;
|
||||
});
|
||||
setSelectedModels(dataModel);
|
||||
setDynamicField(data.field);
|
||||
setOptions(data.items.data ?? []);
|
||||
setOptions(data.items.data);
|
||||
setPage(data.items.current_page);
|
||||
setLastPage(data.items.last_page ?? 1);
|
||||
setLastPage(data.items.last_page);
|
||||
} catch (err: unknown) {
|
||||
// Ignore obsolete errors.
|
||||
if (requestId !== requestIdRef.current) return;
|
||||
console.error(err);
|
||||
if (isAxiosError(err) && err.response?.data?.errors) {
|
||||
setErrorsAjax(err.response?.data?.errors);
|
||||
if (isAxiosError(err) && err.response?.data) {
|
||||
const responseData = err.response.data as {
|
||||
errors: Record<string, string>;
|
||||
} | null;
|
||||
if (responseData) setErrorsAjax(responseData.errors);
|
||||
}
|
||||
|
||||
setOptions([]);
|
||||
|
|
@ -575,7 +569,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
|
||||
// Reset options list if empty search or null
|
||||
if (targetModel && searchValue.length === 0) {
|
||||
getData();
|
||||
void getData();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
@ -583,15 +577,11 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (searchValue.length < 3) return undefined;
|
||||
|
||||
// Get updated options list with search.
|
||||
const handler = setTimeout(() => getData(), 300);
|
||||
const handler = setTimeout(() => void getData(), 300);
|
||||
|
||||
function cleanup(): void {
|
||||
if (handler) {
|
||||
clearTimeout(handler);
|
||||
}
|
||||
}
|
||||
|
||||
return cleanup;
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [searchValue, targetModel]);
|
||||
|
||||
|
|
@ -599,10 +589,14 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
(message: string, priority: "polite" | "assertive" = "polite") => {
|
||||
if (priority === "assertive") {
|
||||
setAssertiveMessage(message);
|
||||
setTimeout(() => setAssertiveMessage(""), 100);
|
||||
setTimeout(() => {
|
||||
setAssertiveMessage("");
|
||||
}, 100);
|
||||
} else {
|
||||
setPoliteMessage(message);
|
||||
setTimeout(() => setPoliteMessage(""), 100);
|
||||
setTimeout(() => {
|
||||
setPoliteMessage("");
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
[],
|
||||
|
|
@ -748,9 +742,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
};
|
||||
const currentSettings = defaultResponsive[screenSize];
|
||||
return {
|
||||
maxCount: currentSettings?.maxCount ?? maxCount,
|
||||
hideIcons: currentSettings?.hideIcons ?? false,
|
||||
compactMode: currentSettings?.compactMode ?? false,
|
||||
maxCount: currentSettings.maxCount,
|
||||
hideIcons: currentSettings.hideIcons,
|
||||
compactMode: currentSettings.compactMode,
|
||||
};
|
||||
}
|
||||
const currentSettings = responsive[screenSize];
|
||||
|
|
@ -824,7 +818,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
uniqueOptions.push(option);
|
||||
}
|
||||
});
|
||||
if (process.env.NODE_ENV === "development" && duplicates.length > 0) {
|
||||
if (import.meta.env.MODE === "development" && duplicates.length > 0) {
|
||||
const action = deduplicateOptions
|
||||
? "automatically removed"
|
||||
: "detected";
|
||||
|
|
@ -832,11 +826,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
`MultiSelect: Duplicate option values ${action}: ${duplicates.join(
|
||||
", ",
|
||||
)}. ` +
|
||||
`${
|
||||
deduplicateOptions
|
||||
? "Duplicates have been removed automatically."
|
||||
: "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."
|
||||
}`,
|
||||
(deduplicateOptions
|
||||
? "Duplicates have been removed automatically."
|
||||
: "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."),
|
||||
);
|
||||
}
|
||||
return deduplicateOptions ? uniqueOptions : allOptions;
|
||||
|
|
@ -845,9 +837,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
const getOptionByValue = useCallback(
|
||||
(id: number): DefaultModel | undefined => {
|
||||
const option = getAllOptions().find((opt) => opt.id === id);
|
||||
if (!option && process.env.NODE_ENV === "development") {
|
||||
if (!option && import.meta.env.MODE === "development") {
|
||||
console.warn(
|
||||
`MultiSelect: Option with value "${id}" not found in options list`,
|
||||
`MultiSelect: Option with value "${String(id)}" not found in options list`,
|
||||
);
|
||||
}
|
||||
return option;
|
||||
|
|
@ -886,14 +878,14 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (onValueChange) {
|
||||
onValueChange(newSelectedValues);
|
||||
}
|
||||
const newSelectedModels = selectedModels?.includes(option)
|
||||
const newSelectedModels = selectedModels.includes(option)
|
||||
? []
|
||||
: [option];
|
||||
setSelectedModels(newSelectedModels);
|
||||
if (onModelChange) {
|
||||
onModelChange(newSelectedModels);
|
||||
}
|
||||
setData(name, multiple ? newSelectedValues : newSelectedValues[0]);
|
||||
setData(name, newSelectedValues[0]);
|
||||
if (closeOnSelect) {
|
||||
setIsPopoverOpen(false);
|
||||
}
|
||||
|
|
@ -906,7 +898,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (isCurrentlySelected) {
|
||||
if (minSelection && selectedValues.length <= minSelection) {
|
||||
announce(
|
||||
`Minimum ${minSelection} selection(s) required`,
|
||||
`Minimum ${String(minSelection)} selection(s) required`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
|
|
@ -918,18 +910,21 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (onValueChange) {
|
||||
onValueChange(newSelectedValues);
|
||||
}
|
||||
const newSelectedModels = selectedModels?.filter(
|
||||
const newSelectedModels = selectedModels.filter(
|
||||
(value) => value.id !== option.id,
|
||||
);
|
||||
if (onModelChange) {
|
||||
onModelChange(newSelectedModels ?? []);
|
||||
onModelChange(newSelectedModels);
|
||||
}
|
||||
setSelectedModels(newSelectedModels);
|
||||
|
||||
setData(name, multiple ? newSelectedValues : newSelectedValues[0]);
|
||||
setData(name, newSelectedValues);
|
||||
} else {
|
||||
if (maxSelection && selectedValues.length >= maxSelection) {
|
||||
announce(`Maximum ${maxSelection} selection(s) allowed`, "assertive");
|
||||
announce(
|
||||
`Maximum ${String(maxSelection)} selection(s) allowed`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const newSelectedValues = [...selectedValues, option.id];
|
||||
|
|
@ -938,12 +933,12 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (onValueChange) {
|
||||
onValueChange(newSelectedValues);
|
||||
}
|
||||
const newSelectedModels = [...(selectedModels || []), option];
|
||||
const newSelectedModels = [...selectedModels, option];
|
||||
if (onModelChange) {
|
||||
onModelChange(newSelectedModels);
|
||||
}
|
||||
setSelectedModels(newSelectedModels);
|
||||
setData(name, multiple ? newSelectedValues : newSelectedValues[0]);
|
||||
setData(name, newSelectedValues);
|
||||
}
|
||||
if (closeOnSelect) {
|
||||
setIsPopoverOpen(false);
|
||||
|
|
@ -953,7 +948,10 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
const handleClear = () => {
|
||||
if (disabled) return;
|
||||
if (multiple && minSelection && minSelection > 0) {
|
||||
announce(`Minimum ${minSelection} selection(s) required`, "assertive");
|
||||
announce(
|
||||
`Minimum ${String(minSelection)} selection(s) required`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
}
|
||||
setSelectedValues([]);
|
||||
|
|
@ -1001,7 +999,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (selectedValues.length === allOptions.length) {
|
||||
if (minSelection && minSelection > 0) {
|
||||
announce(
|
||||
`Minimum ${minSelection} selection(s) required`,
|
||||
`Minimum ${String(minSelection)} selection(s) required`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
|
|
@ -1010,7 +1008,10 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
} else {
|
||||
const allValues = allOptions.map((option) => option.id);
|
||||
if (maxSelection && allValues.length > maxSelection) {
|
||||
announce(`Maximum ${maxSelection} selection(s) allowed`, "assertive");
|
||||
announce(
|
||||
`Maximum ${String(maxSelection)} selection(s) allowed`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
}
|
||||
setSelectedValues(allValues);
|
||||
|
|
@ -1021,7 +1022,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (onModelChange) {
|
||||
onModelChange(allOptions);
|
||||
}
|
||||
setData(name, multiple ? allValues : allValues[0]);
|
||||
setData(name, allValues);
|
||||
}
|
||||
|
||||
if (closeOnSelect) {
|
||||
|
|
@ -1042,8 +1043,8 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
|
||||
const getWidthConstraints = () => {
|
||||
const defaultMinWidth = screenSize === "mobile" ? "0px" : "200px";
|
||||
const effectiveMinWidth = minWidth || defaultMinWidth;
|
||||
const effectiveMaxWidth = maxWidth || "100%";
|
||||
const effectiveMinWidth = minWidth ?? defaultMinWidth;
|
||||
const effectiveMaxWidth = maxWidth ?? "100%";
|
||||
return {
|
||||
minWidth: effectiveMinWidth,
|
||||
maxWidth: effectiveMaxWidth,
|
||||
|
|
@ -1069,26 +1070,24 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (diff > 0) {
|
||||
const addedItems = selectedValues.slice(-diff);
|
||||
const addedLabels = addedItems
|
||||
.map(
|
||||
(value) =>
|
||||
allOptions.find((opt) => opt.id === value)?.[
|
||||
dynamicField as keyof DefaultModel
|
||||
],
|
||||
)
|
||||
.filter(Boolean);
|
||||
.map((value) => {
|
||||
const opt = allOptions.find((o) => o.id === value);
|
||||
return opt ? getModelField(opt) : undefined;
|
||||
})
|
||||
.filter((v): v is string => v !== undefined);
|
||||
|
||||
if (addedLabels.length === 1) {
|
||||
announce(
|
||||
`${addedLabels[0]} selected. ${selectedCount} of ${totalOptions} options selected.`,
|
||||
`${addedLabels[0]} selected. ${String(selectedCount)} of ${String(totalOptions)} options selected.`,
|
||||
);
|
||||
} else {
|
||||
announce(
|
||||
`${addedLabels.length} options selected. ${selectedCount} of ${totalOptions} total selected.`,
|
||||
`${String(addedLabels.length)} options selected. ${String(selectedCount)} of ${String(totalOptions)} total selected.`,
|
||||
);
|
||||
}
|
||||
} else if (diff < 0) {
|
||||
announce(
|
||||
`Option removed. ${selectedCount} of ${totalOptions} options selected.`,
|
||||
`Option removed. ${String(selectedCount)} of ${String(totalOptions)} options selected.`,
|
||||
);
|
||||
}
|
||||
prevSelectedCount.current = selectedCount;
|
||||
|
|
@ -1097,7 +1096,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
if (isPopoverOpen !== prevIsOpen.current) {
|
||||
if (isPopoverOpen) {
|
||||
announce(
|
||||
`Dropdown opened. ${totalOptions} options available. Use arrow keys to navigate.`,
|
||||
`Dropdown opened. ${String(totalOptions)} options available. Use arrow keys to navigate.`,
|
||||
);
|
||||
} else {
|
||||
announce("Dropdown closed.");
|
||||
|
|
@ -1105,15 +1104,12 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
prevIsOpen.current = isPopoverOpen;
|
||||
}
|
||||
|
||||
if (
|
||||
searchValue !== prevSearchValue.current &&
|
||||
searchValue !== undefined
|
||||
) {
|
||||
if (searchValue !== prevSearchValue.current) {
|
||||
if (searchValue && isPopoverOpen) {
|
||||
const filteredCount = allOptions.length;
|
||||
|
||||
announce(
|
||||
`${filteredCount} option${
|
||||
`${String(filteredCount)} option${
|
||||
filteredCount === 1 ? "" : "s"
|
||||
} found for "${searchValue}"`,
|
||||
);
|
||||
|
|
@ -1155,8 +1151,8 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
const value = option[dynamicField as keyof DefaultModel] as unknown as
|
||||
| Record<string, string>
|
||||
| string;
|
||||
if (typeof value === "object") return String(value[locale] ?? "");
|
||||
return String(value ?? "");
|
||||
if (typeof value === "object") return value[locale] ?? "";
|
||||
return value;
|
||||
};
|
||||
|
||||
const buttonProps = {
|
||||
|
|
@ -1193,7 +1189,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
<div id={selectedCountId} className="sr-only" aria-live="polite">
|
||||
{selectedValues.length === 0
|
||||
? "No options selected"
|
||||
: `${selectedValues.length} option${
|
||||
: `${String(selectedValues.length)} option${
|
||||
selectedValues.length === 1 ? "" : "s"
|
||||
} selected: ${selectedValues
|
||||
.map((value) => {
|
||||
|
|
@ -1207,7 +1203,6 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
ref={buttonRef}
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...buttonProps}
|
||||
onClick={handleTogglePopover}
|
||||
disabled={disabled}
|
||||
|
|
@ -1217,14 +1212,14 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
aria-haspopup="listbox"
|
||||
aria-controls={isPopoverOpen ? listboxId : undefined}
|
||||
aria-describedby={`${triggerDescriptionId} ${selectedCountId}`}
|
||||
aria-label={`Multi-select: ${selectedValues.length} of ${
|
||||
getAllOptions().length
|
||||
} options selected. ${placeholder}`}
|
||||
aria-label={`Multi-select: ${String(selectedValues.length)} of ${String(
|
||||
getAllOptions().length,
|
||||
)} options selected. ${placeholder}`}
|
||||
className={cn(
|
||||
"group/button flex rounded-md border min-h-10 h-auto items-center justify-between [&_svg]:pointer-events-auto gap-2 px-4 py-2",
|
||||
autoSize ? "w-auto" : "w-full",
|
||||
responsiveSettings.compactMode && "min-h-8 text-sm",
|
||||
screenSize === "mobile" && "min-h-10 text-base",
|
||||
screenSize === "mobile" && "min-h-12 text-base",
|
||||
disabled && "opacity-50 cursor-not-allowed",
|
||||
{ "border-destructive/50": localErrors[name] },
|
||||
className,
|
||||
|
|
@ -1264,7 +1259,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
return null;
|
||||
}
|
||||
const badgeStyle: CSSProperties = {
|
||||
animationDuration: `${animation}s`,
|
||||
animationDuration: `${String(animation)}s`,
|
||||
};
|
||||
return multiple ? (
|
||||
<Badge
|
||||
|
|
@ -1272,7 +1267,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
className={cn(
|
||||
getBadgeAnimationClass(),
|
||||
modelSelectVariants({
|
||||
variant: multiple ? variant : "ghost",
|
||||
variant: variant,
|
||||
}),
|
||||
responsiveSettings.compactMode &&
|
||||
"text-xs px-1.5 py-0.5",
|
||||
|
|
@ -1283,10 +1278,10 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
)}
|
||||
style={{
|
||||
...badgeStyle,
|
||||
animationDuration: `${
|
||||
animationConfig?.duration || animation
|
||||
}s`,
|
||||
animationDelay: `${animationConfig?.delay || 0}s`,
|
||||
animationDuration: `${String(
|
||||
animationConfig?.duration ?? animation,
|
||||
)}s`,
|
||||
animationDelay: `${String(animationConfig?.delay ?? 0)}s`,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
|
|
@ -1313,7 +1308,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
toggleOption(option);
|
||||
}
|
||||
}}
|
||||
aria-label={`Remove ${option[dynamicField as keyof DefaultModel]} from selection`}
|
||||
aria-label={`Remove ${getModelField(option)} from selection`}
|
||||
className="ml-2 h-4 w-4 cursor-pointer hover:bg-white/20 rounded-sm -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50"
|
||||
>
|
||||
<XCircleIcon
|
||||
|
|
@ -1356,13 +1351,13 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
"[&>svg]:pointer-events-auto",
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${animationConfig?.duration || animation}s`,
|
||||
animationDelay: `${animationConfig?.delay || 0}s`,
|
||||
animationDuration: `${String(animationConfig?.duration ?? animation)}s`,
|
||||
animationDelay: `${String(animationConfig?.delay ?? 0)}s`,
|
||||
}}
|
||||
>
|
||||
{`+ ${
|
||||
selectedValues.length - responsiveSettings.maxCount
|
||||
} ${transMore}`}
|
||||
{`+ ${String(
|
||||
selectedValues.length - responsiveSettings.maxCount,
|
||||
)} ${transMore}`}
|
||||
<XCircleIcon
|
||||
className={cn(
|
||||
"ml-2 h-4 w-4 cursor-pointer",
|
||||
|
|
@ -1393,7 +1388,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
handleClear();
|
||||
}
|
||||
}}
|
||||
aria-label={`Clear all ${selectedValues.length} selected options`}
|
||||
aria-label={`Clear all ${String(selectedValues.length)} selected options`}
|
||||
className="flex items-center justify-center h-4 w-4 p-0 me-2 cursor-pointer transition-opacity opacity-50 group-hover:opacity-60 hover:opacity-100 rounded-sm"
|
||||
>
|
||||
<XIcon className="h-4 w-4" />
|
||||
|
|
@ -1423,14 +1418,16 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
popoverClassName,
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${animationConfig?.duration || animation}s`,
|
||||
animationDelay: `${animationConfig?.delay || 0}s`,
|
||||
animationDuration: `${String(animationConfig?.duration ?? animation)}s`,
|
||||
animationDelay: `${String(animationConfig?.delay ?? 0)}s`,
|
||||
maxWidth: `min(${widthConstraints.maxWidth}, 85vw)`,
|
||||
maxHeight: screenSize === "mobile" ? "70vh" : "60vh",
|
||||
touchAction: "manipulation",
|
||||
}}
|
||||
align="start"
|
||||
onEscapeKeyDown={() => setIsPopoverOpen(false)}
|
||||
onEscapeKeyDown={() => {
|
||||
setIsPopoverOpen(false);
|
||||
}}
|
||||
>
|
||||
<Command className="overflow-visible">
|
||||
{searchable && (
|
||||
|
|
@ -1443,7 +1440,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
placeholder={str(transSearchOptions).ucFirst().value()}
|
||||
value={searchValue}
|
||||
disabled={disabled}
|
||||
onChange={(e) => setSearchValue(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setSearchValue(e.target.value);
|
||||
}}
|
||||
onKeyDown={handleInputKeyDown}
|
||||
className="w-[calc(100%-2.5rem-40px)] border-0 mx-9"
|
||||
/>
|
||||
|
|
@ -1454,7 +1453,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
variant="ghost"
|
||||
size="icon"
|
||||
className="absolute top-1/2 right-0 transform -translate-y-1/2 text-muted-foreground"
|
||||
onClick={() => setSearchValue("")}
|
||||
onClick={() => {
|
||||
setSearchValue("");
|
||||
}}
|
||||
disabled={searchValue.length < 1 || disabled}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -1467,7 +1468,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
<CommandList className="border-t p-1">
|
||||
{!loading && !initialLoading && (
|
||||
<CommandEmpty>
|
||||
{emptyIndicator || transNoResults}
|
||||
{emptyIndicator ?? transNoResults}
|
||||
</CommandEmpty>
|
||||
)}
|
||||
{/* First option for select all items */}
|
||||
|
|
@ -1480,9 +1481,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
aria-selected={
|
||||
selectedValues.length === getAllOptions().length
|
||||
}
|
||||
aria-label={`Select all ${
|
||||
getAllOptions().length
|
||||
} options`}
|
||||
aria-label={`Select all ${String(
|
||||
getAllOptions().length,
|
||||
)} options`}
|
||||
className="cursor-pointer gap-1.5 px-4 py-2 w-full h-auto min-h-10"
|
||||
>
|
||||
<div
|
||||
|
|
@ -1502,7 +1503,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
<span>
|
||||
({str(transSelectAll).ucFirst().value()}
|
||||
{getAllOptions().length > 20
|
||||
? ` - ${getAllOptions().length} options`
|
||||
? ` - ${String(getAllOptions().length)} options`
|
||||
: ""}
|
||||
)
|
||||
</span>
|
||||
|
|
@ -1512,8 +1513,8 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
{/* List of items */}
|
||||
<CommandGroup className="p-0">
|
||||
{loading
|
||||
? [...Array(pageSize)].map(() => (
|
||||
<Skeleton className="h-9 mb-1" />
|
||||
? Array.from({ length: pageSize }).map((_, index) => (
|
||||
<Skeleton key={index} className="h-9 mb-1" />
|
||||
))
|
||||
: options.map((option) => {
|
||||
const isSelected = selectedValues.includes(option.id);
|
||||
|
|
@ -1527,8 +1528,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
aria-selected={isSelected}
|
||||
aria-label={`${getModelField(option)}${
|
||||
isSelected ? ", selected" : ", not selected"
|
||||
}
|
||||
`}
|
||||
}`}
|
||||
className={cn(
|
||||
"cursor-pointer gap-1.5 px-4 py-2 w-full h-auto min-h-10",
|
||||
)}
|
||||
|
|
@ -1553,7 +1553,6 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
})}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
|
||||
{/* Pagination boutons */}
|
||||
{options.length > 0 && lastPage !== 1 && (
|
||||
<div className="border-t flex flex-col lg:flex-row justify-between items-center gap-1.5 p-1">
|
||||
|
|
@ -1579,7 +1578,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => goToPage(page - 1)}
|
||||
onClick={() => void goToPage(page - 1)}
|
||||
disabled={page <= 1 || loading}
|
||||
/>
|
||||
{loading ? (
|
||||
|
|
@ -1613,7 +1612,7 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => goToPage(page + 1)}
|
||||
onClick={() => void goToPage(page + 1)}
|
||||
disabled={page >= lastPage || loading}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -1653,7 +1652,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsPopoverOpen(false)}
|
||||
onClick={() => {
|
||||
setIsPopoverOpen(false);
|
||||
}}
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -1668,7 +1669,9 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
"cursor-pointer my-2 text-foreground bg-background w-3 h-3",
|
||||
isAnimating ? "" : "text-muted-foreground",
|
||||
)}
|
||||
onClick={() => setIsAnimating(!isAnimating)}
|
||||
onClick={() => {
|
||||
setIsAnimating(!isAnimating);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Popover>
|
||||
|
|
@ -1682,4 +1685,5 @@ export const ModelSelect = forwardRef<ModelSelectRef, ModelSelectProps>(
|
|||
);
|
||||
|
||||
ModelSelect.displayName = "ModelSelect";
|
||||
|
||||
export type { ModelSelectProps };
|
||||
|
|
|
|||
|
|
@ -1,20 +1,4 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import {
|
||||
ButtonHTMLAttributes,
|
||||
ComponentType,
|
||||
CSSProperties,
|
||||
forwardRef,
|
||||
KeyboardEvent,
|
||||
ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useId,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import {
|
||||
CheckIcon,
|
||||
|
|
@ -24,15 +8,26 @@ import {
|
|||
SearchIcon,
|
||||
ChevronsUpDownIcon,
|
||||
} from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
type ButtonHTMLAttributes,
|
||||
type ComponentType,
|
||||
type CSSProperties,
|
||||
forwardRef,
|
||||
type KeyboardEvent,
|
||||
type ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useId,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
|
|
@ -40,13 +35,16 @@ import {
|
|||
CommandItem,
|
||||
CommandList,
|
||||
} from "@/components/ui/command";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/**
|
||||
|
|
@ -142,7 +140,7 @@ interface MultiSelectProps
|
|||
* Callback function triggered when the selected values change.
|
||||
* Receives an array of the new selected values.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
onValueChange?: (value: string[]) => void;
|
||||
|
||||
/** The default selected values when the component mounts. */
|
||||
|
|
@ -183,7 +181,7 @@ interface MultiSelectProps
|
|||
* If true, renders the multi-select component as a child of another component.
|
||||
* Optional, defaults to false.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||
|
||||
asChild?: boolean;
|
||||
|
||||
/**
|
||||
|
|
@ -317,7 +315,7 @@ interface MultiSelectProps
|
|||
/**
|
||||
* The fonction to set the data in useForm inertia
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
setData: (name: string, value: string[]) => void;
|
||||
|
||||
/**
|
||||
|
|
@ -365,7 +363,7 @@ export interface MultiSelectRef {
|
|||
/**
|
||||
* Set selected values programmatically
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
setSelectedValues: (values: string[]) => void;
|
||||
/**
|
||||
* Clear all selected values
|
||||
|
|
@ -397,7 +395,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
animationConfig,
|
||||
maxCount = 3,
|
||||
modalPopover = false,
|
||||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
asChild = false,
|
||||
className,
|
||||
hideSelectAll = false,
|
||||
|
|
@ -420,12 +418,12 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
) => {
|
||||
const [selectedValues, setSelectedValues] =
|
||||
useState<string[]>(defaultValue);
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
const [isAnimating, setIsAnimating] = useState(false);
|
||||
const [searchValue, setSearchValue] = useState("");
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
|
||||
const [isAnimating, setIsAnimating] = useState<boolean>(false);
|
||||
const [searchValue, setSearchValue] = useState<string>("");
|
||||
const [politeMessage, setPoliteMessage] = useState<string>("");
|
||||
const [assertiveMessage, setAssertiveMessage] = useState<string>("");
|
||||
|
||||
const [politeMessage, setPoliteMessage] = useState("");
|
||||
const [assertiveMessage, setAssertiveMessage] = useState("");
|
||||
const prevSelectedCount = useRef(selectedValues.length);
|
||||
const prevIsOpen = useRef(isPopoverOpen);
|
||||
const prevSearchValue = useRef(searchValue);
|
||||
|
|
@ -436,10 +434,14 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
(message: string, priority: "polite" | "assertive" = "polite") => {
|
||||
if (priority === "assertive") {
|
||||
setAssertiveMessage(message);
|
||||
setTimeout(() => setAssertiveMessage(""), 100);
|
||||
setTimeout(() => {
|
||||
setAssertiveMessage("");
|
||||
}, 100);
|
||||
} else {
|
||||
setPoliteMessage(message);
|
||||
setTimeout(() => setPoliteMessage(""), 100);
|
||||
setTimeout(() => {
|
||||
setPoliteMessage("");
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
[],
|
||||
|
|
@ -592,9 +594,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
};
|
||||
const currentSettings = defaultResponsive[screenSize];
|
||||
return {
|
||||
maxCount: currentSettings?.maxCount ?? maxCount,
|
||||
hideIcons: currentSettings?.hideIcons ?? false,
|
||||
compactMode: currentSettings?.compactMode ?? false,
|
||||
maxCount: currentSettings.maxCount,
|
||||
hideIcons: currentSettings.hideIcons,
|
||||
compactMode: currentSettings.compactMode,
|
||||
};
|
||||
}
|
||||
const currentSettings = responsive[screenSize];
|
||||
|
|
@ -673,7 +675,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
uniqueOptions.push(option);
|
||||
}
|
||||
});
|
||||
if (process.env.NODE_ENV === "development" && duplicates.length > 0) {
|
||||
if (import.meta.env.MODE === "development" && duplicates.length > 0) {
|
||||
const action = deduplicateOptions
|
||||
? "automatically removed"
|
||||
: "detected";
|
||||
|
|
@ -681,11 +683,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
`MultiSelect: Duplicate option values ${action}: ${duplicates.join(
|
||||
", ",
|
||||
)}. ` +
|
||||
`${
|
||||
deduplicateOptions
|
||||
? "Duplicates have been removed automatically."
|
||||
: "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."
|
||||
}`,
|
||||
(deduplicateOptions
|
||||
? "Duplicates have been removed automatically."
|
||||
: "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."),
|
||||
);
|
||||
}
|
||||
return deduplicateOptions ? uniqueOptions : allOptions;
|
||||
|
|
@ -694,7 +694,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
const getOptionByValue = useCallback(
|
||||
(value: string): MultiSelectOption | undefined => {
|
||||
const option = getAllOptions().find((opt) => opt.value === value);
|
||||
if (!option && process.env.NODE_ENV === "development") {
|
||||
if (!option && import.meta.env.MODE === "development") {
|
||||
console.warn(
|
||||
`MultiSelect: Option with value "${value}" not found in options list`,
|
||||
);
|
||||
|
|
@ -769,7 +769,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
if (isCurrentlySelected) {
|
||||
if (minSelection && selectedValues.length <= minSelection) {
|
||||
announce(
|
||||
`Minimum ${minSelection} selection(s) required`,
|
||||
`Minimum ${String(minSelection)} selection(s) required`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
|
|
@ -784,7 +784,10 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
setData(name, newSelectedValues);
|
||||
} else {
|
||||
if (maxSelection && selectedValues.length >= maxSelection) {
|
||||
announce(`Maximum ${maxSelection} selection(s) allowed`, "assertive");
|
||||
announce(
|
||||
`Maximum ${String(maxSelection)} selection(s) allowed`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const newSelectedValues = [...selectedValues, optionValue];
|
||||
|
|
@ -803,7 +806,10 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
const handleClear = () => {
|
||||
if (disabled) return;
|
||||
if (multiple && minSelection && minSelection > 0) {
|
||||
announce(`Minimum ${minSelection} selection(s) required`, "assertive");
|
||||
announce(
|
||||
`Minimum ${String(minSelection)} selection(s) required`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
}
|
||||
setSelectedValues([]);
|
||||
|
|
@ -838,7 +844,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
if (selectedValues.length === allOptions.length) {
|
||||
if (minSelection && minSelection > 0) {
|
||||
announce(
|
||||
`Minimum ${minSelection} selection(s) required`,
|
||||
`Minimum ${String(minSelection)} selection(s) required`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
|
|
@ -847,7 +853,10 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
} else {
|
||||
const allValues = allOptions.map((option) => option.value);
|
||||
if (maxSelection && allValues.length > maxSelection) {
|
||||
announce(`Maximum ${maxSelection} selection(s) allowed`, "assertive");
|
||||
announce(
|
||||
`Maximum ${String(maxSelection)} selection(s) allowed`,
|
||||
"assertive",
|
||||
);
|
||||
return;
|
||||
}
|
||||
setSelectedValues(allValues);
|
||||
|
|
@ -875,8 +884,8 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
|
||||
const getWidthConstraints = () => {
|
||||
const defaultMinWidth = screenSize === "mobile" ? "0px" : "200px";
|
||||
const effectiveMinWidth = minWidth || defaultMinWidth;
|
||||
const effectiveMaxWidth = maxWidth || "100%";
|
||||
const effectiveMinWidth = minWidth ?? defaultMinWidth;
|
||||
const effectiveMaxWidth = maxWidth ?? "100%";
|
||||
return {
|
||||
minWidth: effectiveMinWidth,
|
||||
maxWidth: effectiveMaxWidth,
|
||||
|
|
@ -908,16 +917,16 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
|
||||
if (addedLabels.length === 1) {
|
||||
announce(
|
||||
`${addedLabels[0]} selected. ${selectedCount} of ${totalOptions} options selected.`,
|
||||
`${addedLabels[0] ?? ""} selected. ${String(selectedCount)} of ${String(totalOptions)} options selected.`,
|
||||
);
|
||||
} else {
|
||||
announce(
|
||||
`${addedLabels.length} options selected. ${selectedCount} of ${totalOptions} total selected.`,
|
||||
`${String(addedLabels.length)} options selected. ${String(selectedCount)} of ${String(totalOptions)} total selected.`,
|
||||
);
|
||||
}
|
||||
} else if (diff < 0) {
|
||||
announce(
|
||||
`Option removed. ${selectedCount} of ${totalOptions} options selected.`,
|
||||
`Option removed. ${String(selectedCount)} of ${String(totalOptions)} options selected.`,
|
||||
);
|
||||
}
|
||||
prevSelectedCount.current = selectedCount;
|
||||
|
|
@ -926,7 +935,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
if (isPopoverOpen !== prevIsOpen.current) {
|
||||
if (isPopoverOpen) {
|
||||
announce(
|
||||
`Dropdown opened. ${totalOptions} options available. Use arrow keys to navigate.`,
|
||||
`Dropdown opened. ${String(totalOptions)} options available. Use arrow keys to navigate.`,
|
||||
);
|
||||
} else {
|
||||
announce("Dropdown closed.");
|
||||
|
|
@ -934,10 +943,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
prevIsOpen.current = isPopoverOpen;
|
||||
}
|
||||
|
||||
if (
|
||||
searchValue !== prevSearchValue.current &&
|
||||
searchValue !== undefined
|
||||
) {
|
||||
if (searchValue !== prevSearchValue.current) {
|
||||
if (searchValue && isPopoverOpen) {
|
||||
const filteredCount = allOptions.filter(
|
||||
(opt) =>
|
||||
|
|
@ -946,7 +952,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
).length;
|
||||
|
||||
announce(
|
||||
`${filteredCount} option${
|
||||
`${String(filteredCount)} option${
|
||||
filteredCount === 1 ? "" : "s"
|
||||
} found for "${searchValue}"`,
|
||||
);
|
||||
|
|
@ -1007,7 +1013,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
<div id={selectedCountId} className="sr-only" aria-live="polite">
|
||||
{selectedValues.length === 0
|
||||
? "No options selected"
|
||||
: `${selectedValues.length} option${
|
||||
: `${String(selectedValues.length)} option${
|
||||
selectedValues.length === 1 ? "" : "s"
|
||||
} selected: ${selectedValues
|
||||
.map((value) => getOptionByValue(value)?.label)
|
||||
|
|
@ -1017,7 +1023,6 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
ref={buttonRef}
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...props}
|
||||
onClick={handleTogglePopover}
|
||||
disabled={disabled}
|
||||
|
|
@ -1027,9 +1032,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
aria-haspopup="listbox"
|
||||
aria-controls={isPopoverOpen ? listboxId : undefined}
|
||||
aria-describedby={`${triggerDescriptionId} ${selectedCountId}`}
|
||||
aria-label={`Multi-select: ${selectedValues.length} of ${
|
||||
getAllOptions().length
|
||||
} options selected. ${placeholder}`}
|
||||
aria-label={`Multi-select: ${String(selectedValues.length)} of ${String(
|
||||
getAllOptions().length,
|
||||
)} options selected. ${placeholder}`}
|
||||
className={cn(
|
||||
"group/button flex rounded-md border min-h-10 h-auto items-center justify-between [&_svg]:pointer-events-auto gap-2 px-4 py-2",
|
||||
autoSize ? "w-auto" : "w-full",
|
||||
|
|
@ -1065,7 +1070,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
return null;
|
||||
}
|
||||
const badgeStyle: CSSProperties = {
|
||||
animationDuration: `${animation}s`,
|
||||
animationDuration: `${String(animation)}s`,
|
||||
...(customStyle?.badgeColor && {
|
||||
backgroundColor: customStyle.badgeColor,
|
||||
}),
|
||||
|
|
@ -1092,10 +1097,10 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
)}
|
||||
style={{
|
||||
...badgeStyle,
|
||||
animationDuration: `${
|
||||
animationConfig?.duration || animation
|
||||
}s`,
|
||||
animationDelay: `${animationConfig?.delay || 0}s`,
|
||||
animationDuration: `${String(
|
||||
animationConfig?.duration ?? animation,
|
||||
)}s`,
|
||||
animationDelay: `${String(animationConfig?.delay ?? 0)}s`,
|
||||
}}
|
||||
>
|
||||
{IconComponent &&
|
||||
|
|
@ -1108,7 +1113,6 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
customStyle?.iconColor &&
|
||||
"text-current",
|
||||
)}
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...(customStyle?.iconColor && {
|
||||
style: {
|
||||
color: customStyle.iconColor,
|
||||
|
|
@ -1157,12 +1161,12 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
.filter(Boolean)
|
||||
: selectedValues
|
||||
.slice(0, responsiveSettings.maxCount)
|
||||
.map((value) => {
|
||||
.map((value, valueIndex) => {
|
||||
const option = getOptionByValue(value);
|
||||
if (!option) {
|
||||
return null;
|
||||
}
|
||||
return <span>{option.label}</span>;
|
||||
return <span key={valueIndex}>{option.label}</span>;
|
||||
})}
|
||||
{multiple &&
|
||||
selectedValues.length > responsiveSettings.maxCount && (
|
||||
|
|
@ -1179,13 +1183,13 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
"[&>svg]:pointer-events-auto",
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${animationConfig?.duration || animation}s`,
|
||||
animationDelay: `${animationConfig?.delay || 0}s`,
|
||||
animationDuration: `${String(animationConfig?.duration ?? animation)}s`,
|
||||
animationDelay: `${String(animationConfig?.delay ?? 0)}s`,
|
||||
}}
|
||||
>
|
||||
{`+ ${
|
||||
selectedValues.length - responsiveSettings.maxCount
|
||||
} ${transMore}`}
|
||||
{`+ ${String(
|
||||
selectedValues.length - responsiveSettings.maxCount,
|
||||
)} ${transMore}`}
|
||||
<XCircleIcon
|
||||
className={cn(
|
||||
"ml-2 h-4 w-4 cursor-pointer",
|
||||
|
|
@ -1217,7 +1221,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
handleClear();
|
||||
}
|
||||
}}
|
||||
aria-label={`Clear all ${selectedValues.length} selected options`}
|
||||
aria-label={`Clear all ${String(selectedValues.length)} selected options`}
|
||||
className="flex items-center justify-center h-4 w-4 p-0 me-2 cursor-pointer transition-opacity opacity-50 group-hover:opacity-60 hover:opacity-100 rounded-sm"
|
||||
>
|
||||
<XIcon className="h-4 w-4" />
|
||||
|
|
@ -1253,14 +1257,16 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
popoverClassName,
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${animationConfig?.duration || animation}s`,
|
||||
animationDelay: `${animationConfig?.delay || 0}s`,
|
||||
animationDuration: `${String(animationConfig?.duration ?? animation)}s`,
|
||||
animationDelay: `${String(animationConfig?.delay ?? 0)}s`,
|
||||
maxWidth: `min(${widthConstraints.maxWidth}, 85vw)`,
|
||||
maxHeight: screenSize === "mobile" ? "70vh" : "60vh",
|
||||
touchAction: "manipulation",
|
||||
}}
|
||||
align="start"
|
||||
onEscapeKeyDown={() => setIsPopoverOpen(false)}
|
||||
onEscapeKeyDown={() => {
|
||||
setIsPopoverOpen(false);
|
||||
}}
|
||||
>
|
||||
<Command className="overflow-visible">
|
||||
{searchable && (
|
||||
|
|
@ -1273,7 +1279,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
placeholder={str(transSearchOptions).ucFirst().value()}
|
||||
value={searchValue}
|
||||
disabled={disabled}
|
||||
onChange={(e) => setSearchValue(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setSearchValue(e.target.value);
|
||||
}}
|
||||
onKeyDown={handleInputKeyDown}
|
||||
className="w-[calc(100%-2.5rem-40px)] border-0 mx-9"
|
||||
/>
|
||||
|
|
@ -1284,7 +1292,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
variant="ghost"
|
||||
size="icon"
|
||||
className="absolute top-1/2 right-0 transform -translate-y-1/2 text-muted-foreground"
|
||||
onClick={() => setSearchValue("")}
|
||||
onClick={() => {
|
||||
setSearchValue("");
|
||||
}}
|
||||
disabled={searchValue.length < 1 || disabled}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -1295,7 +1305,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
</div>
|
||||
)}
|
||||
<CommandList className="border-t p-1">
|
||||
<CommandEmpty>{emptyIndicator || transNoResults}</CommandEmpty>
|
||||
<CommandEmpty>{emptyIndicator ?? transNoResults}</CommandEmpty>
|
||||
{/* First option for select all items */}
|
||||
{!hideSelectAll && !searchValue && multiple && (
|
||||
<CommandGroup className="p-0">
|
||||
|
|
@ -1307,9 +1317,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
selectedValues.length ===
|
||||
getAllOptions().filter((opt) => !opt.disabled).length
|
||||
}
|
||||
aria-label={`Select all ${
|
||||
getAllOptions().length
|
||||
} options`}
|
||||
aria-label={`Select all ${String(
|
||||
getAllOptions().length,
|
||||
)} options`}
|
||||
className="cursor-pointer gap-1.5 px-4 py-2 w-full h-auto min-h-10"
|
||||
>
|
||||
<div
|
||||
|
|
@ -1331,7 +1341,7 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
<span>
|
||||
({str(transSelectAll).ucFirst().value()}
|
||||
{getAllOptions().length > 20
|
||||
? ` - ${getAllOptions().length} options`
|
||||
? ` - ${String(getAllOptions().length)} options`
|
||||
: ""}
|
||||
)
|
||||
</span>
|
||||
|
|
@ -1353,7 +1363,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
return (
|
||||
<CommandItem
|
||||
key={option.value}
|
||||
onSelect={() => toggleOption(option.value)}
|
||||
onSelect={() => {
|
||||
toggleOption(option.value);
|
||||
}}
|
||||
role="option"
|
||||
aria-selected={isSelected}
|
||||
aria-disabled={option.disabled}
|
||||
|
|
@ -1400,7 +1412,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
return (
|
||||
<CommandItem
|
||||
key={option.value}
|
||||
onSelect={() => toggleOption(option.value)}
|
||||
onSelect={() => {
|
||||
toggleOption(option.value);
|
||||
}}
|
||||
role="option"
|
||||
aria-selected={isSelected}
|
||||
aria-disabled={option.disabled}
|
||||
|
|
@ -1473,7 +1487,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
type="button"
|
||||
variant="ghost"
|
||||
size="default"
|
||||
onClick={() => setIsPopoverOpen(false)}
|
||||
onClick={() => {
|
||||
setIsPopoverOpen(false);
|
||||
}}
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -1488,7 +1504,9 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
"cursor-pointer my-2 text-foreground bg-background w-3 h-3",
|
||||
isAnimating ? "" : "text-muted-foreground",
|
||||
)}
|
||||
onClick={() => setIsAnimating(!isAnimating)}
|
||||
onClick={() => {
|
||||
setIsAnimating(!isAnimating);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Popover>
|
||||
|
|
@ -1500,4 +1518,5 @@ export const MultiSelect = forwardRef<MultiSelectRef, MultiSelectProps>(
|
|||
);
|
||||
|
||||
MultiSelect.displayName = "MultiSelect";
|
||||
|
||||
export type { MultiSelectOption, MultiSelectGroup, MultiSelectProps };
|
||||
|
|
|
|||
|
|
@ -1,25 +1,23 @@
|
|||
// * Packages
|
||||
import { useState, useEffect, useRef, ReactNode } from "react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { SketchPicker, ColorResult } from "react-color";
|
||||
import { RefreshCwIcon, TrashIcon, ShuffleIcon } from "lucide-react";
|
||||
import { PresetColor } from "react-color/lib/components/sketch/Sketch";
|
||||
// * Components shadcn
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useState, useEffect, type ReactNode } from "react";
|
||||
import { SketchPicker, type ColorResult } from "react-color";
|
||||
import { type PresetColor } from "react-color/lib/components/sketch/Sketch";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
} from "@/components/ui/popover";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SimpleColorPickerProps = {
|
||||
interface SimpleColorPickerProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
id?: string;
|
||||
|
|
@ -31,16 +29,15 @@ type SimpleColorPickerProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
/* eslint-disable no-unused-vars */
|
||||
setData: (name: string, value: string | null) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleColorPicker({
|
||||
className,
|
||||
name,
|
||||
id = name,
|
||||
label,
|
||||
value = null,
|
||||
value,
|
||||
placeholder = "#ffffffff",
|
||||
presetColors = [
|
||||
"#000000", // Black
|
||||
|
|
@ -65,7 +62,7 @@ export default function SimpleColorPicker({
|
|||
|
||||
// Colors.
|
||||
const [color, setColor] = useState<string | null>(value);
|
||||
const initialColor = useRef<string | null>(value ?? "#ffffffff");
|
||||
const [initialColor] = useState<string>(value ?? "#ffffffff");
|
||||
|
||||
// Popover status.
|
||||
const [open, setOpen] = useState(false);
|
||||
|
|
@ -95,10 +92,9 @@ export default function SimpleColorPicker({
|
|||
const r = targetColor.rgb.r.toString(16).padStart(2, "0");
|
||||
const g = targetColor.rgb.g.toString(16).padStart(2, "0");
|
||||
const b = targetColor.rgb.b.toString(16).padStart(2, "0");
|
||||
const a =
|
||||
Math.round((targetColor.rgb.a ?? 1) * 255)
|
||||
.toString(16)
|
||||
.padStart(2, "0") ?? "ff";
|
||||
const a = Math.round((targetColor.rgb.a ?? 1) * 255)
|
||||
.toString(16)
|
||||
.padStart(2, "0");
|
||||
return `#${r}${g}${b}${a}`;
|
||||
}
|
||||
|
||||
|
|
@ -159,8 +155,8 @@ export default function SimpleColorPicker({
|
|||
* @return void
|
||||
*/
|
||||
function handleReset(): void {
|
||||
setColor(initialColor.current);
|
||||
setData(name, initialColor.current);
|
||||
setColor(initialColor);
|
||||
setData(name, initialColor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -195,6 +191,7 @@ export default function SimpleColorPicker({
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
if (value !== color) setColor(value);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
|
|
@ -218,7 +215,7 @@ export default function SimpleColorPicker({
|
|||
className="w-10 h-10 border-0"
|
||||
disabled={disabled}
|
||||
style={{
|
||||
background: color || "transparent",
|
||||
background: color ?? "transparent",
|
||||
outline: "1px solid hsl(var(--input))",
|
||||
}}
|
||||
/>
|
||||
|
|
@ -227,7 +224,9 @@ export default function SimpleColorPicker({
|
|||
<Input
|
||||
id={id}
|
||||
value={color ?? ""}
|
||||
onChange={(e) => handleInput(e.target.value)}
|
||||
onChange={(e) => {
|
||||
handleInput(e.target.value);
|
||||
}}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
className="flex-1"
|
||||
|
|
@ -235,11 +234,13 @@ export default function SimpleColorPicker({
|
|||
{/* POPUP CONTENT */}
|
||||
<PopoverContent className="p-2">
|
||||
<SketchPicker
|
||||
color={String(color || initialColor.current)}
|
||||
onChange={(newColor) => handleChange(newColor)}
|
||||
onChangeComplete={(newCompleteColor) =>
|
||||
handleChangeComplete(newCompleteColor)
|
||||
}
|
||||
color={color ?? initialColor}
|
||||
onChange={(newColor) => {
|
||||
handleChange(newColor);
|
||||
}}
|
||||
onChangeComplete={(newCompleteColor) => {
|
||||
handleChangeComplete(newCompleteColor);
|
||||
}}
|
||||
disableAlpha={false}
|
||||
presetColors={presetColors}
|
||||
/>
|
||||
|
|
@ -253,7 +254,9 @@ export default function SimpleColorPicker({
|
|||
type="button"
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
onClick={() => handleRandom()}
|
||||
onClick={() => {
|
||||
handleRandom();
|
||||
}}
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -264,7 +267,9 @@ export default function SimpleColorPicker({
|
|||
type="button"
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
onClick={() => handleReset()}
|
||||
onClick={() => {
|
||||
handleReset();
|
||||
}}
|
||||
disabled={disabled}
|
||||
/>
|
||||
{!required && (
|
||||
|
|
@ -274,12 +279,14 @@ export default function SimpleColorPicker({
|
|||
type="button"
|
||||
variant="destructive"
|
||||
size="icon"
|
||||
onClick={() => handleClear()}
|
||||
onClick={() => {
|
||||
handleClear();
|
||||
}}
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<InputError message={localErrors?.[name]} />
|
||||
<InputError message={localErrors[name]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,25 @@
|
|||
// * Other
|
||||
import { fr, enUS } from "date-fns/locale";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { fr, enUS } from "date-fns/locale";
|
||||
import { CalendarIcon, RefreshCcw } from "lucide-react";
|
||||
import { ReactNode } from "react";
|
||||
// * Components shadcn
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Calendar } from "@/components/ui/calendar";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||
// * Other
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { cn, GetFormatedDate } from "@/lib/utils";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import str from "@/hooks/use-string";
|
||||
import useLocale from "@/store/use-locale-store";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetFormatedDate } from "@/lib/utils";
|
||||
import useLocale from "@/store/use-locale-store";
|
||||
|
||||
type SimpleDatePickerProps = {
|
||||
interface SimpleDatePickerProps {
|
||||
name: string;
|
||||
placeholder?: string;
|
||||
date?: Date | null;
|
||||
|
|
@ -31,9 +29,9 @@ type SimpleDatePickerProps = {
|
|||
label: ReactNode | string;
|
||||
hasTime?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
setData: (name: string, value: Date | null) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleDatePicker({
|
||||
name,
|
||||
|
|
@ -74,12 +72,12 @@ export default function SimpleDatePicker({
|
|||
};
|
||||
|
||||
function handleTimeChange(type: "hour" | "minute", value: string) {
|
||||
const currentDate = parsedDate || new Date();
|
||||
const currentDate = parsedDate ?? new Date();
|
||||
const newDate = new Date(currentDate);
|
||||
if (type === "hour") {
|
||||
const hour = parseInt(value, 10);
|
||||
newDate.setHours(hour);
|
||||
} else if (type === "minute") {
|
||||
} else {
|
||||
newDate.setMinutes(parseInt(value, 10));
|
||||
}
|
||||
setData(name, newDate);
|
||||
|
|
@ -106,9 +104,9 @@ export default function SimpleDatePicker({
|
|||
disabled={disabled}
|
||||
>
|
||||
<span>
|
||||
{date && date !== undefined
|
||||
{date
|
||||
? GetFormatedDate(
|
||||
date?.toString(),
|
||||
date.toString(),
|
||||
useLocale.use.timezone(),
|
||||
hasTime,
|
||||
)
|
||||
|
|
@ -140,18 +138,16 @@ export default function SimpleDatePicker({
|
|||
key={hour}
|
||||
size="icon"
|
||||
variant={
|
||||
parsedDate && parsedDate.getHours() === hour
|
||||
? "default"
|
||||
: "ghost"
|
||||
parsedDate?.getHours() === hour ? "default" : "ghost"
|
||||
}
|
||||
className="sm:w-full shrink-0 aspect-square"
|
||||
onClick={() =>
|
||||
handleTimeChange("hour", hour.toString())
|
||||
}
|
||||
onClick={() => {
|
||||
handleTimeChange("hour", hour.toString());
|
||||
}}
|
||||
>
|
||||
<p
|
||||
className={cn(
|
||||
parsedDate && parsedDate.getHours() === hour
|
||||
parsedDate?.getHours() === hour
|
||||
? "text-primary-foreground"
|
||||
: "",
|
||||
)}
|
||||
|
|
@ -170,18 +166,18 @@ export default function SimpleDatePicker({
|
|||
key={minute}
|
||||
size="icon"
|
||||
variant={
|
||||
parsedDate && parsedDate.getMinutes() === minute
|
||||
parsedDate?.getMinutes() === minute
|
||||
? "default"
|
||||
: "ghost"
|
||||
}
|
||||
className="sm:w-full shrink-0 aspect-square"
|
||||
onClick={() =>
|
||||
handleTimeChange("minute", minute.toString())
|
||||
}
|
||||
onClick={() => {
|
||||
handleTimeChange("minute", minute.toString());
|
||||
}}
|
||||
>
|
||||
<p
|
||||
className={cn(
|
||||
parsedDate && parsedDate.getMinutes() === minute
|
||||
parsedDate?.getMinutes() === minute
|
||||
? "text-primary-foreground"
|
||||
: "",
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,27 @@
|
|||
// * Packages
|
||||
import { useState, useEffect, ReactNode } from "react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { useState, type ReactNode } from "react";
|
||||
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
// * Other
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { type MinMax } from "@/hooks/use-laravel-validation";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SimpleNumberProps = {
|
||||
interface SimpleNumberProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
label: ReactNode | string;
|
||||
value?: number;
|
||||
id?: string;
|
||||
step?: number;
|
||||
limits?: Record<string, number>;
|
||||
limits?: MinMax;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleNumber({
|
||||
className,
|
||||
|
|
@ -43,21 +41,15 @@ export default function SimpleNumber({
|
|||
const localErrors = parentErrors ?? errors;
|
||||
|
||||
const localLimits = {
|
||||
min: limits?.min ? limits.min : 1,
|
||||
max: limits?.max ? limits.max : 1000,
|
||||
min: limits?.min ?? 1,
|
||||
max: limits?.max ?? 1000,
|
||||
};
|
||||
const safeValue =
|
||||
value >= localLimits.min && value <= localLimits.max
|
||||
? value
|
||||
: localLimits.min;
|
||||
|
||||
const [inputValue, setInputValue] = useState(safeValue);
|
||||
|
||||
useEffect(() => {
|
||||
setInputValue(safeValue);
|
||||
setData(name, String(safeValue));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [safeValue]);
|
||||
const [inputValue, setInputValue] = useState<number>(safeValue);
|
||||
|
||||
return (
|
||||
<div className={cn("flex flex-col w-full gap-1.5", className)}>
|
||||
|
|
@ -76,7 +68,12 @@ export default function SimpleNumber({
|
|||
max={localLimits.max}
|
||||
step={step}
|
||||
onChange={(e) => {
|
||||
setInputValue(Number(e.target.value));
|
||||
const num = Number(e.target.value);
|
||||
const clamped = Math.min(
|
||||
localLimits.max,
|
||||
Math.max(localLimits.min, num),
|
||||
);
|
||||
setInputValue(clamped);
|
||||
setData(name, e.target.value);
|
||||
}}
|
||||
required={required}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
// * Packages
|
||||
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
||||
import { useState, useEffect, useRef, ReactNode } from "react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
||||
import { useState, useEffect, useRef, type ReactNode } from "react";
|
||||
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import WordCounter from "@/back/Components/WordCounter";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SimpleStringProps = {
|
||||
interface SimpleStringProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
label: ReactNode | string;
|
||||
|
|
@ -27,9 +25,8 @@ type SimpleStringProps = {
|
|||
pattern?: string;
|
||||
checkVisibility?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleString({
|
||||
className,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { ReactNode } from "react";
|
||||
// * Components shadcn
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
// * Other
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SimpleSwitchProps = {
|
||||
interface SimpleSwitchProps {
|
||||
id?: string;
|
||||
name: string;
|
||||
checked?: boolean;
|
||||
|
|
@ -19,9 +17,8 @@ type SimpleSwitchProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: boolean) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleSwitch({
|
||||
name,
|
||||
|
|
@ -52,7 +49,9 @@ export default function SimpleSwitch({
|
|||
<Switch
|
||||
id={id}
|
||||
name={name}
|
||||
onCheckedChange={(value) => setData(name, value)}
|
||||
onCheckedChange={(value) => {
|
||||
setData(name, value);
|
||||
}}
|
||||
required={required}
|
||||
checked={checked}
|
||||
disabled={disabled}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
// * Other
|
||||
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import WordCounter from "@/back/Components/WordCounter";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SimpleTextareaProps = {
|
||||
interface SimpleTextareaProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
label: string;
|
||||
|
|
@ -20,9 +18,8 @@ type SimpleTextareaProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleTextarea({
|
||||
className,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// * Other
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
type SimpleVimeoIdProps = {
|
||||
interface SimpleVimeoIdProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
|
|
@ -11,9 +10,8 @@ type SimpleVimeoIdProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleVimeoId(props: SimpleVimeoIdProps) {
|
||||
const pattern = "^[0-9]{8,10}$";
|
||||
|
|
@ -21,6 +19,5 @@ export default function SimpleVimeoId(props: SimpleVimeoIdProps) {
|
|||
.ucFirst()
|
||||
.value();
|
||||
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
return <SimpleString pattern={pattern} label={label} {...props} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// * Other
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
type SimpleYoutubeIdProps = {
|
||||
interface SimpleYoutubeIdProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
|
|
@ -11,9 +10,8 @@ type SimpleYoutubeIdProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleYoutubeId(props: SimpleYoutubeIdProps) {
|
||||
const pattern = "^[0-9A-Za-z_\\-]{10}[048AEIMQUYcgkosw]$";
|
||||
|
|
@ -21,6 +19,5 @@ export default function SimpleYoutubeId(props: SimpleYoutubeIdProps) {
|
|||
.ucFirst()
|
||||
.value();
|
||||
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
return <SimpleString pattern={pattern} label={label} {...props} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
// * Packages
|
||||
import { GavelIcon } from "lucide-react";
|
||||
// * Other
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
|
|
@ -11,7 +10,6 @@ interface SlugifycatorProps {
|
|||
targetValue: string;
|
||||
wordCounter?: boolean;
|
||||
disabled?: boolean;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +48,9 @@ export default function Slugifycator(props: SlugifycatorProps) {
|
|||
.value()}
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => setData("slug", str(targetValue).slug().value())}
|
||||
onClick={() => {
|
||||
setData("slug", str(targetValue).slug().value());
|
||||
}}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { useEffect } from "react";
|
||||
// * Other
|
||||
|
||||
import EnumSelect from "@/back/Components/Inputs/EnumSelect";
|
||||
import { LaravelEnum } from "@/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type LaravelEnum } from "@/types/global";
|
||||
|
||||
interface Props {
|
||||
name: string;
|
||||
selected: number;
|
||||
required: boolean;
|
||||
label: string;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: number | null) => void;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
// * Packages
|
||||
import { Image as TiptapImage } from "@tiptap/extension-image";
|
||||
import { ReactNodeViewRenderer } from "@tiptap/react";
|
||||
// * Other
|
||||
|
||||
import ImageNodeView, {
|
||||
FLOAT_STYLES,
|
||||
FloatOption,
|
||||
type FloatOption,
|
||||
} from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageNodeView";
|
||||
import { imageDetails } from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageUtils";
|
||||
|
||||
|
|
@ -38,19 +37,23 @@ const Image = TiptapImage.extend({
|
|||
// Specific selector for a figure with his image and an optional figcaption.
|
||||
tag: "figure:has(img[src])",
|
||||
getAttrs: (element: HTMLElement) => {
|
||||
const img = element.querySelector("img") as HTMLImageElement;
|
||||
const img = element.querySelector("img");
|
||||
const figcaption = element.querySelector("figcaption");
|
||||
|
||||
if (!img) {
|
||||
throw new Error("Missing tag img.");
|
||||
}
|
||||
|
||||
return {
|
||||
src: img.src,
|
||||
alt: img.getAttribute("alt"),
|
||||
title: img.getAttribute("title"),
|
||||
width: parseInt(
|
||||
img.getAttribute("width") || imageDetails.width,
|
||||
img.getAttribute("width") ?? imageDetails.width,
|
||||
10,
|
||||
),
|
||||
height: parseInt(
|
||||
img.getAttribute("height") || imageDetails.height,
|
||||
img.getAttribute("height") ?? imageDetails.height,
|
||||
10,
|
||||
),
|
||||
style: null,
|
||||
|
|
@ -67,9 +70,10 @@ const Image = TiptapImage.extend({
|
|||
// Define the structure of the render.
|
||||
// Use for render html in front files.
|
||||
renderHTML({ node, HTMLAttributes }) {
|
||||
const src = HTMLAttributes.src as string;
|
||||
const attrsCopy: AttrsType = {
|
||||
...HTMLAttributes,
|
||||
src: HTMLAttributes.src.replace(/^https?:\/\/[^/]+/, ""),
|
||||
src: src.replace(/^https?:\/\/[^/]+/, ""),
|
||||
};
|
||||
|
||||
delete attrsCopy.caption;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
// * Packages
|
||||
import { useEffect, useState } from "react";
|
||||
import { type Editor } from "@tiptap/react";
|
||||
import axios from "axios";
|
||||
import { route } from "ziggy-js";
|
||||
import { ImageUpIcon } from "lucide-react";
|
||||
import { Editor } from "@tiptap/react";
|
||||
import { useState } from "react";
|
||||
import { z } from "zod";
|
||||
// * Components shadcn
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import CompleteInputFile from "@/back/Components/Inputs/CompleteInputFile";
|
||||
import ImageInputs from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs";
|
||||
import {
|
||||
imageTextSchema,
|
||||
imageDetails,
|
||||
} from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageUtils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogDescription,
|
||||
|
|
@ -16,35 +22,27 @@ import {
|
|||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import ImageInputs from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs";
|
||||
import {
|
||||
imageTextSchema,
|
||||
imageDetails,
|
||||
} from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageUtils";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import CompleteInputFile from "@/back/Components/Inputs/CompleteInputFile";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
type ImageProps = {
|
||||
type ImageFormat = "landscape" | "portrait" | "square";
|
||||
|
||||
interface ImageType {
|
||||
name: ImageFormat;
|
||||
style: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface ImageProps {
|
||||
/** Wysiwyg editor instance. */
|
||||
editor: Editor;
|
||||
/** Route name prefix. */
|
||||
routeName: string;
|
||||
/** Disable trigger button. */
|
||||
disabled: boolean;
|
||||
};
|
||||
|
||||
type ImageFormat = "landscape" | "portrait" | "square";
|
||||
type ImageType = {
|
||||
name: ImageFormat;
|
||||
style: string;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ImageButton({
|
||||
editor,
|
||||
|
|
@ -52,9 +50,10 @@ export default function ImageButton({
|
|||
disabled,
|
||||
}: ImageProps) {
|
||||
// Get all editor options define with customOptions in the parent SimpleWysiwyg.
|
||||
const editorOptions = editor.options.editorProps?.attributes as {
|
||||
[name: string]: string;
|
||||
};
|
||||
const editorOptions = editor.options.editorProps.attributes as Record<
|
||||
string,
|
||||
string
|
||||
>;
|
||||
|
||||
// State of the plugin modal.
|
||||
const [open, setOpen] = useState(false);
|
||||
|
|
@ -245,7 +244,7 @@ export default function ImageButton({
|
|||
const csrfToken =
|
||||
document
|
||||
.querySelector('meta[name="csrf-token"]')
|
||||
?.getAttribute("content") || "";
|
||||
?.getAttribute("content") ?? "";
|
||||
|
||||
// Prepare the form data.
|
||||
const data = new FormData();
|
||||
|
|
@ -265,7 +264,7 @@ export default function ImageButton({
|
|||
"X-CSRF-TOKEN": csrfToken,
|
||||
},
|
||||
});
|
||||
return response.data.url;
|
||||
return (response.data as { url: string }).url;
|
||||
} catch (error: unknown) {
|
||||
setNewErrors(error);
|
||||
return null;
|
||||
|
|
@ -311,7 +310,9 @@ export default function ImageButton({
|
|||
height: String(inputType.height),
|
||||
});
|
||||
setOpen(false);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
setNewErrors(error);
|
||||
|
|
@ -337,26 +338,20 @@ export default function ImageButton({
|
|||
*/
|
||||
const handleCancelImage = (): void => {
|
||||
setOpen(false);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
};
|
||||
|
||||
// Set default value to the caption.
|
||||
useEffect(() => {
|
||||
setInputText({
|
||||
alt: inputText.alt,
|
||||
title: inputText.title,
|
||||
caption: inputText.hasCaption ? inputText.caption : null,
|
||||
hasCaption: inputText.hasCaption,
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [inputText.hasCaption]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={(status) => {
|
||||
setOpen(status);
|
||||
if (!status) setTimeout(() => resetComponent(), animationTime);
|
||||
if (!status)
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
}}
|
||||
>
|
||||
{/* Button trigger in wysiwyg navigation. */}
|
||||
|
|
@ -390,7 +385,9 @@ export default function ImageButton({
|
|||
{Object.values(ImageTypes).map((type) => (
|
||||
<Button
|
||||
key={type.name}
|
||||
onClick={() => setInputType(type)}
|
||||
onClick={() => {
|
||||
setInputType(type);
|
||||
}}
|
||||
className="flex flex-col items-center gap-1.5 w-full h-fit"
|
||||
variant={
|
||||
inputType.name === type.name ? "default" : "secondary"
|
||||
|
|
@ -424,7 +421,9 @@ export default function ImageButton({
|
|||
.ucFirst()
|
||||
.value()}
|
||||
setData={handleSetImage}
|
||||
reset={() => {}}
|
||||
reset={() => {
|
||||
/* empty */
|
||||
}}
|
||||
value={null}
|
||||
required
|
||||
maxFileSize="5120"
|
||||
|
|
@ -437,7 +436,12 @@ export default function ImageButton({
|
|||
/>
|
||||
<ImageInputs
|
||||
value={inputText}
|
||||
onChange={setInputText}
|
||||
onChange={(newValue) => {
|
||||
setInputText({
|
||||
...newValue,
|
||||
caption: newValue.hasCaption ? newValue.caption : null,
|
||||
});
|
||||
}}
|
||||
disabled={disabled || loading}
|
||||
errors={errors}
|
||||
/>
|
||||
|
|
@ -470,7 +474,7 @@ export default function ImageButton({
|
|||
type="button"
|
||||
size="default"
|
||||
disabled={loading}
|
||||
onClick={handleAddImage}
|
||||
onClick={void handleAddImage}
|
||||
/>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
// * Other
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
type ImageInputsProps = {
|
||||
interface ImageInputsProps {
|
||||
value: {
|
||||
alt: string;
|
||||
title: string;
|
||||
caption: string | null;
|
||||
hasCaption: boolean;
|
||||
};
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onChange: (value: ImageInputsProps["value"]) => void;
|
||||
errors?: Record<string, string>;
|
||||
loading?: boolean;
|
||||
disabled?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ImageInputs({
|
||||
value,
|
||||
|
|
@ -40,7 +38,9 @@ export default function ImageInputs({
|
|||
placeholder="ex: John Doe"
|
||||
required
|
||||
value={value.alt}
|
||||
setData={(_, currentValue) => onChange({ ...value, alt: currentValue })}
|
||||
setData={(_, currentValue) => {
|
||||
onChange({ ...value, alt: currentValue });
|
||||
}}
|
||||
disabled={disabled || loading}
|
||||
parentErrors={errors}
|
||||
/>
|
||||
|
|
@ -53,9 +53,9 @@ export default function ImageInputs({
|
|||
placeholder="ex: John Doe"
|
||||
required
|
||||
value={value.title}
|
||||
setData={(_, currentValue) =>
|
||||
onChange({ ...value, title: currentValue })
|
||||
}
|
||||
setData={(_, currentValue) => {
|
||||
onChange({ ...value, title: currentValue });
|
||||
}}
|
||||
disabled={disabled || loading}
|
||||
parentErrors={errors}
|
||||
/>
|
||||
|
|
@ -72,13 +72,13 @@ export default function ImageInputs({
|
|||
name="hasCaption"
|
||||
checked={value.hasCaption}
|
||||
className="justify-center"
|
||||
setData={(_, currentValue) =>
|
||||
setData={(_, currentValue) => {
|
||||
onChange({
|
||||
...value,
|
||||
hasCaption: currentValue,
|
||||
caption: currentValue ? value.caption : null,
|
||||
})
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
{/* Input caption of the image. */}
|
||||
{value.hasCaption && (
|
||||
|
|
@ -88,9 +88,9 @@ export default function ImageInputs({
|
|||
placeholder="ex: John Doe"
|
||||
required={false}
|
||||
value={value.caption ?? ""}
|
||||
setData={(_, currentValue) =>
|
||||
onChange({ ...value, caption: currentValue })
|
||||
}
|
||||
setData={(_, currentValue) => {
|
||||
onChange({ ...value, caption: currentValue });
|
||||
}}
|
||||
disabled={disabled || loading}
|
||||
parentErrors={errors}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// * Packages
|
||||
import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { type NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
||||
import {
|
||||
MoveDiagonal2Icon,
|
||||
AlignLeftIcon,
|
||||
|
|
@ -13,8 +13,13 @@ import {
|
|||
import { useEffect, useRef, useState } from "react";
|
||||
import type { MouseEvent as ReactMouseEvent } from "react";
|
||||
import z from "zod";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import ImageInputs from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs";
|
||||
import {
|
||||
imageDetails,
|
||||
imageTextSchema,
|
||||
} from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageUtils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
|
|
@ -30,18 +35,11 @@ import {
|
|||
SelectItem,
|
||||
SelectTrigger,
|
||||
} from "@/components/ui/select";
|
||||
// * Other
|
||||
import ImageInputs from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs";
|
||||
import {
|
||||
imageDetails,
|
||||
imageTextSchema,
|
||||
} from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageUtils";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { parseStyleString } from "@/hooks/use-inline-style";
|
||||
import { AppEnv } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
export type AllowedAligns = "left" | "center" | "right";
|
||||
|
||||
|
|
@ -81,7 +79,7 @@ const PLACEMENT_STYLES: Record<PlacementValue, string> = {
|
|||
"float-right": FLOAT_STYLES.right,
|
||||
};
|
||||
|
||||
type ImageAttrs = {
|
||||
interface ImageAttrs {
|
||||
src: string;
|
||||
alt: string;
|
||||
title: string;
|
||||
|
|
@ -90,7 +88,7 @@ type ImageAttrs = {
|
|||
caption: string | null;
|
||||
style: string;
|
||||
float: FloatOption;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ImageNodeView(props: NodeViewProps) {
|
||||
const { node, updateAttributes, editor, selected } = props;
|
||||
|
|
@ -168,10 +166,11 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
*/
|
||||
const getCurrentPlacement = (): PlacementValue | null => {
|
||||
if (attrs.float === "left") return "float-left";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (attrs.float === "right") return "float-right";
|
||||
if (attrs.style?.includes(ALIGN_STYLES.left)) return "align-left";
|
||||
if (attrs.style?.includes(ALIGN_STYLES.center)) return "align-center";
|
||||
if (attrs.style?.includes(ALIGN_STYLES.right)) return "align-right";
|
||||
if (attrs.style.includes(ALIGN_STYLES.left)) return "align-left";
|
||||
if (attrs.style.includes(ALIGN_STYLES.center)) return "align-center";
|
||||
if (attrs.style.includes(ALIGN_STYLES.right)) return "align-right";
|
||||
|
||||
return null;
|
||||
};
|
||||
|
|
@ -323,7 +322,7 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
* @param status boolean
|
||||
* @return void
|
||||
*/
|
||||
const closeModal = (status: boolean = false): void => {
|
||||
const closeModal = (status = false): void => {
|
||||
setOpen(status);
|
||||
setEditorFocused(false);
|
||||
};
|
||||
|
|
@ -357,8 +356,6 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
|
||||
// Update the focus on @tiptap editor.
|
||||
useEffect(() => {
|
||||
if (!editor) return undefined;
|
||||
|
||||
editor.on("focus", handleFocus);
|
||||
editor.on("blur", handleBlur);
|
||||
|
||||
|
|
@ -382,31 +379,24 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isResizing]);
|
||||
|
||||
// Set default value to the caption.
|
||||
useEffect(() => {
|
||||
setInputText({
|
||||
alt: inputText.alt,
|
||||
title: inputText.title,
|
||||
caption: inputText.hasCaption ? inputText.caption : null,
|
||||
hasCaption: inputText.hasCaption,
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [inputText.hasCaption]);
|
||||
|
||||
// Set height of header + @tiptap toolbar editor with resize event.
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
const currentHeaderHeight =
|
||||
document.querySelector("header")?.clientHeight ?? 0;
|
||||
const currentToolbarHeight =
|
||||
document.querySelectorAll(".tiptap-toolbar")[0].clientHeight ?? 0;
|
||||
const firstToolbar = document.querySelectorAll(
|
||||
".tiptap-toolbar",
|
||||
)[0] as HTMLElement | null;
|
||||
const currentToolbarHeight = firstToolbar?.clientHeight ?? 0;
|
||||
setTopSticky(currentHeaderHeight + currentToolbarHeight);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
handleResize();
|
||||
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
@ -427,7 +417,7 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
}}
|
||||
>
|
||||
<span className="absolute top-2 left-2 bg-background backdrop-blur-sm rounded-md border shadow-md m-0 p-1">
|
||||
{`${attrs.width || imageDetails.width}x${attrs.height || imageDetails.height}`}
|
||||
{`${String(attrs.width || imageDetails.width)}x${String(attrs.height || imageDetails.height)}`}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -444,7 +434,7 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
<div className="absolute bottom-2 right-2 flex flex-col gap-1 bg-background backdrop-blur-sm rounded-md border shadow-md p-1">
|
||||
{/* Placement dropdown */}
|
||||
<Select
|
||||
value={getCurrentPlacement() || "default"}
|
||||
value={getCurrentPlacement() ?? "default"}
|
||||
onValueChange={handlePlacementChange}
|
||||
>
|
||||
<SelectTrigger
|
||||
|
|
@ -510,7 +500,9 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
variant="outline"
|
||||
size="icon"
|
||||
onMouseDown={onMouseDown}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
className={cn("cursor-nw-resize", {
|
||||
"bg-accent text-accent-foreground": isResizing,
|
||||
})}
|
||||
|
|
@ -530,7 +522,12 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
</figcaption>
|
||||
)}
|
||||
{/* Dialog Shadcn */}
|
||||
<Dialog open={open} onOpenChange={(status) => closeModal(status)}>
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={(status) => {
|
||||
closeModal(status);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="p-4">
|
||||
<DialogHeader className="px-2 pt-2">
|
||||
<DialogTitle>
|
||||
|
|
@ -543,7 +540,12 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
<div className="overflow-y-scroll max-h-[70vh] flex flex-col gap-4 px-2">
|
||||
<ImageInputs
|
||||
value={inputText}
|
||||
onChange={setInputText}
|
||||
onChange={(newValue) => {
|
||||
setInputText({
|
||||
...newValue,
|
||||
caption: newValue.hasCaption ? newValue.caption : null,
|
||||
});
|
||||
}}
|
||||
errors={errors}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -558,7 +560,9 @@ export default function ImageNodeView(props: NodeViewProps) {
|
|||
)
|
||||
.ucFirst()
|
||||
.value()}
|
||||
onClick={() => closeModal()}
|
||||
onClick={() => {
|
||||
closeModal();
|
||||
}}
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size="default"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// * Packages
|
||||
import { z } from "zod";
|
||||
|
||||
// Set image details.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
// * Packages
|
||||
import "@tiptap/core";
|
||||
|
||||
// Set custom function attributes.
|
||||
declare module "@tiptap/core" {
|
||||
interface Commands<ReturnType> {
|
||||
Image: {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setImage: (attrs: {
|
||||
src: string;
|
||||
alt: string;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
// * Packages
|
||||
import { Plugin, PluginKey, TextSelection } from "prosemirror-state";
|
||||
import { mergeAttributes, getMarkRange } from "@tiptap/react";
|
||||
import type { LinkOptions as TiptapLinkOptions } from "@tiptap/extension-link";
|
||||
import { Link as TiptapLink } from "@tiptap/extension-link";
|
||||
import { mergeAttributes, getMarkRange } from "@tiptap/react";
|
||||
import { type Mark } from "prosemirror-model";
|
||||
import { Plugin, PluginKey, TextSelection } from "prosemirror-state";
|
||||
|
||||
export type LinkAttrs = {
|
||||
export interface LinkAttrs {
|
||||
text: string;
|
||||
blank: boolean;
|
||||
modelToken: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export const Link = TiptapLink.extend<TiptapLinkOptions>({
|
||||
addCommands() {
|
||||
|
|
@ -20,25 +20,23 @@ export const Link = TiptapLink.extend<TiptapLinkOptions>({
|
|||
const { from, to } = state.selection;
|
||||
|
||||
// Check if there is a selected link.
|
||||
let linkFound = false;
|
||||
let linkFound = false as boolean;
|
||||
state.doc.nodesBetween(from, to, (node) => {
|
||||
if (node.marks) {
|
||||
const found = node.marks.find((m) => m.type.name === this.name);
|
||||
if (found) linkFound = true;
|
||||
}
|
||||
const found: Mark | undefined = node.marks.find(
|
||||
(m) => m.type.name === this.name,
|
||||
);
|
||||
if (found) linkFound = true;
|
||||
});
|
||||
|
||||
if (linkFound) {
|
||||
return commands.command(({ tr, state: editorState, dispatch }) => {
|
||||
// Get the existing mark.
|
||||
let existingMark = null;
|
||||
let existingMark = null as Mark | null;
|
||||
editorState.doc.nodesBetween(from, to, (node) => {
|
||||
if (node.marks) {
|
||||
const found = node.marks.find(
|
||||
(m) => m.type.name === this.name,
|
||||
);
|
||||
if (found) existingMark = found;
|
||||
}
|
||||
const found: Mark | undefined = node.marks.find(
|
||||
(m) => m.type.name === this.name,
|
||||
);
|
||||
if (found) existingMark = found;
|
||||
});
|
||||
|
||||
if (!existingMark) return false;
|
||||
|
|
@ -104,7 +102,7 @@ export const Link = TiptapLink.extend<TiptapLinkOptions>({
|
|||
modelToken: {
|
||||
default: null,
|
||||
parseHTML: (el) => el.getAttribute("data-model") ?? null,
|
||||
renderHTML: (attrs) =>
|
||||
renderHTML: (attrs: { modelToken: string }) =>
|
||||
attrs.modelToken ? { "data-model": attrs.modelToken } : {},
|
||||
},
|
||||
};
|
||||
|
|
@ -127,7 +125,7 @@ export const Link = TiptapLink.extend<TiptapLinkOptions>({
|
|||
"a",
|
||||
mergeAttributes(
|
||||
{
|
||||
"data-model": HTMLAttributes.modelToken,
|
||||
"data-model": HTMLAttributes.modelToken as string,
|
||||
},
|
||||
HTMLAttributes,
|
||||
),
|
||||
|
|
@ -146,7 +144,7 @@ export const Link = TiptapLink.extend<TiptapLinkOptions>({
|
|||
const link = target.closest("a");
|
||||
if (!link) return false;
|
||||
|
||||
// Find the exact position of the gat <a>.
|
||||
// Find the exact position of the tag <a>.
|
||||
const { state } = view;
|
||||
const $pos = state.doc.resolve(pos);
|
||||
|
||||
|
|
@ -164,7 +162,7 @@ export const Link = TiptapLink.extend<TiptapLinkOptions>({
|
|||
this.editor.emit("open-link-editor", {
|
||||
href: link.getAttribute("href") ?? "",
|
||||
blank: link.getAttribute("target") === "_blank",
|
||||
text: link.textContent ?? "",
|
||||
text: link.textContent,
|
||||
modelToken: link.getAttribute("data-model") ?? null,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
// * Packages
|
||||
import { useEffect, useState } from "react";
|
||||
import axios, { isAxiosError } from "axios";
|
||||
import { route } from "ziggy-js";
|
||||
import { ExternalLinkIcon, LinkIcon, TrashIcon } from "lucide-react";
|
||||
import { Editor } from "@tiptap/react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { type Editor } from "@tiptap/react";
|
||||
import axios, { isAxiosError } from "axios";
|
||||
import { ExternalLinkIcon, LinkIcon, TrashIcon } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { z } from "zod";
|
||||
// * Components shadcn
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import GoToFrontView from "@/back/Components/GoToFrontView";
|
||||
import EnumSelect from "@/back/Components/Inputs/EnumSelect";
|
||||
import { ModelSelect } from "@/back/Components/Inputs/ModelSelect";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogDescription,
|
||||
|
|
@ -16,19 +22,15 @@ import {
|
|||
DialogTrigger,
|
||||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import EnumSelect from "@/back/Components/Inputs/EnumSelect";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch";
|
||||
import GoToFrontView from "@/back/Components/GoToFrontView";
|
||||
import { ModelSelect } from "@/back/Components/Inputs/ModelSelect";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import { AppEnv, LaravelEnum } from "@/types/global";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { type AppEnv, type LaravelEnum } from "@/types/global";
|
||||
|
||||
// Custom type for axios error.
|
||||
interface AxiosErrorResponse {
|
||||
errors: Record<string, string>;
|
||||
}
|
||||
|
||||
// Custom type with field entry.
|
||||
type AddFieldToRecord<T extends Record<string, object>> = {
|
||||
|
|
@ -43,20 +45,20 @@ type AddFieldToRecord<T extends Record<string, object>> = {
|
|||
type LaravelEnumWithField = AddFieldToRecord<LaravelEnum>;
|
||||
|
||||
// Return type of model access response.
|
||||
type ModelAccessResponse = {
|
||||
interface ModelAccessResponse {
|
||||
/** Url to access a specific model. */
|
||||
url: string;
|
||||
/** Crypted token for model id and model name. */
|
||||
token: string;
|
||||
};
|
||||
}
|
||||
|
||||
// Return type of retrieve from token response.
|
||||
type RetrieveFromTokenResponse = {
|
||||
interface RetrieveFromTokenResponse {
|
||||
/** Name of the selected model. */
|
||||
modelName: string;
|
||||
/** Id of the selected model. */
|
||||
modelId: number;
|
||||
};
|
||||
}
|
||||
|
||||
// All link types.
|
||||
const LinkType = {
|
||||
|
|
@ -67,12 +69,12 @@ const LinkType = {
|
|||
type LinkTypeValue = (typeof LinkType)[keyof typeof LinkType];
|
||||
|
||||
// Component props.
|
||||
type LinkProps = {
|
||||
interface LinkProps {
|
||||
/** Wysiwyg editor instance. */
|
||||
editor: Editor;
|
||||
/** Disable trigger button. */
|
||||
disabled: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export default function LinkButton({ editor, disabled }: LinkProps) {
|
||||
// Current domain of the projet.
|
||||
|
|
@ -80,14 +82,15 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
// Backend configuration.
|
||||
const { routes } = usePage().props.configBackend as ConfigBackend;
|
||||
// All models from global enum.
|
||||
const enumModelsList = usePage().props.enumModelsList as LaravelEnumWithField;
|
||||
const enumModelsList = usePage().props
|
||||
.enumModelsList as LaravelEnumWithField | null;
|
||||
|
||||
// State of the plugin modal.
|
||||
const [open, setOpen] = useState(false);
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
// State of editing link.
|
||||
const [editingLink, setEditingLink] = useState(false);
|
||||
const [editingLink, setEditingLink] = useState<boolean>(false);
|
||||
// Hack to actualize states.
|
||||
const [resetState, setResetState] = useState(1);
|
||||
const [resetState, setResetState] = useState<number>(1);
|
||||
// Token of the selected link.
|
||||
const [modelToken, setModelToken] = useState<string | null>(null);
|
||||
|
||||
|
|
@ -112,7 +115,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
const [inputBlank, setInputBlank] = useState<boolean>(false);
|
||||
|
||||
// State of the loader.
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
// Value of errors.
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
|
||||
|
|
@ -200,7 +203,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
const csrfToken =
|
||||
document
|
||||
.querySelector('meta[name="csrf-token"]')
|
||||
?.getAttribute("content") || "";
|
||||
?.getAttribute("content") ?? "";
|
||||
|
||||
// Base ajax call.
|
||||
const response = await axios.post(
|
||||
|
|
@ -216,7 +219,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
},
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
return response.data as ModelAccessResponse | RetrieveFromTokenResponse;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -288,6 +291,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
blank: parsed.inputBlank,
|
||||
modelToken: modelToken ?? null,
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
} else if (selectedType === LinkType.external) {
|
||||
const parsed = externalLinkSchema.parse({
|
||||
inputText,
|
||||
|
|
@ -303,7 +307,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
}
|
||||
|
||||
setOpen(false);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
} catch (err) {
|
||||
// Get zod error validations.
|
||||
if (err instanceof z.ZodError) {
|
||||
|
|
@ -335,7 +341,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
const handleDeleteLink = (): void => {
|
||||
editor.commands.unsetLink();
|
||||
setOpen(false);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -370,7 +378,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
setModelToken(data.token);
|
||||
} catch (err: unknown) {
|
||||
console.error(err);
|
||||
if (isAxiosError(err) && err.response?.data?.errors) {
|
||||
if (isAxiosError<AxiosErrorResponse>(err) && err.response?.data.errors) {
|
||||
setErrors((prev) => ({
|
||||
...prev,
|
||||
...err.response?.data.errors,
|
||||
|
|
@ -419,7 +427,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
*/
|
||||
const handleCancelLink = (): void => {
|
||||
setOpen(false);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -434,7 +444,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
const handler = async ({
|
||||
href,
|
||||
text,
|
||||
modelToken, // eslint-disable-line no-shadow
|
||||
modelToken,
|
||||
blank,
|
||||
}: {
|
||||
href: string;
|
||||
|
|
@ -474,7 +484,10 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
setModelToken(modelToken);
|
||||
} catch (err: unknown) {
|
||||
console.error(err);
|
||||
if (isAxiosError(err) && err.response?.data?.errors) {
|
||||
if (
|
||||
isAxiosError<AxiosErrorResponse>(err) &&
|
||||
err.response?.data.errors
|
||||
) {
|
||||
setErrors((prev) => ({
|
||||
...prev,
|
||||
...err.response?.data.errors,
|
||||
|
|
@ -512,7 +525,10 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
open={open}
|
||||
onOpenChange={(status) => {
|
||||
setOpen(status);
|
||||
if (!status) setTimeout(() => resetComponent(), animationTime);
|
||||
if (!status)
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
}}
|
||||
>
|
||||
{/* Button trigger in wysiwyg navigation. */}
|
||||
|
|
@ -541,7 +557,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
onClick={() => setSelectedType(LinkType.external)}
|
||||
onClick={() => {
|
||||
setSelectedType(LinkType.external);
|
||||
}}
|
||||
className={cn(
|
||||
"w-1/2",
|
||||
selectedType === LinkType.external
|
||||
|
|
@ -554,7 +572,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
onClick={() => setSelectedType(LinkType.internal)}
|
||||
onClick={() => {
|
||||
setSelectedType(LinkType.internal);
|
||||
}}
|
||||
className={cn(
|
||||
"w-1/2",
|
||||
selectedType === LinkType.internal
|
||||
|
|
@ -587,8 +607,10 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
options={enumModelsList}
|
||||
required
|
||||
disabled={loading}
|
||||
setData={() => {}}
|
||||
onSelectValue={(value) => handleSelectEnum(value)}
|
||||
setData={(_name: string, _value: number | null) => undefined}
|
||||
onSelectValue={(value) => {
|
||||
handleSelectEnum(value);
|
||||
}}
|
||||
parentErrors={errors}
|
||||
/>
|
||||
{/* Selected entry. */}
|
||||
|
|
@ -614,7 +636,7 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
required
|
||||
disabled={selectedEnumValue === null || loading}
|
||||
setData={(_, value) =>
|
||||
handleSelectEntry(
|
||||
void handleSelectEntry(
|
||||
Array.isArray(value) ? (value[0] ?? null) : value,
|
||||
)
|
||||
}
|
||||
|
|
@ -645,7 +667,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
value={inputUrl}
|
||||
type="url"
|
||||
disabled={loading}
|
||||
setData={(_, value) => handleUpdateUrl(value)}
|
||||
setData={(_, value) => {
|
||||
handleUpdateUrl(value);
|
||||
}}
|
||||
pattern="https?://.+"
|
||||
placeholder="ex: https://example.com"
|
||||
parentErrors={errors}
|
||||
|
|
@ -672,7 +696,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
label={GetTranslation("uwil-backend::back.wysiwyg.link.text")}
|
||||
value={inputText}
|
||||
disabled={loading}
|
||||
setData={(_, value) => handleUpdateText(value)}
|
||||
setData={(_, value) => {
|
||||
handleUpdateText(value);
|
||||
}}
|
||||
parentErrors={errors}
|
||||
/>
|
||||
{/* Boolean input. */}
|
||||
|
|
@ -681,7 +707,9 @@ export default function LinkButton({ editor, disabled }: LinkProps) {
|
|||
name="link-blank"
|
||||
checked={inputBlank}
|
||||
disabled={loading}
|
||||
setData={(_, value) => handleUpdateBlank(value)}
|
||||
setData={(_, value) => {
|
||||
handleUpdateBlank(value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
// * Packages
|
||||
import "@tiptap/core";
|
||||
|
||||
declare module "@tiptap/core" {
|
||||
interface Commands<ReturnType> {
|
||||
Link: {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setLink: (attrs: {
|
||||
href: string;
|
||||
text: string;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// * Packages
|
||||
import "@tiptap/core";
|
||||
|
||||
declare module "@tiptap/core" {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
// * Packages
|
||||
import { useState } from "react";
|
||||
import { Editor } from "@tiptap/react";
|
||||
import { type Editor } from "@tiptap/react";
|
||||
import { ReplaceIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { useState } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
|
|
@ -12,13 +14,9 @@ import {
|
|||
DialogTrigger,
|
||||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Label } from "@/components/ui/label";
|
||||
// * Other
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
|
@ -46,9 +44,11 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
|||
* @param status boolean
|
||||
* @return void
|
||||
*/
|
||||
const closeModal = (status: boolean = false): void => {
|
||||
const closeModal = (status = false): void => {
|
||||
setOpen(status);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
|||
* @return void
|
||||
*/
|
||||
const handleReplaceAll = (): void => {
|
||||
if (!editor || !searchText) return;
|
||||
if (!searchText) return;
|
||||
|
||||
// Get all editor content.
|
||||
const html = editor.getHTML();
|
||||
|
|
@ -76,7 +76,12 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
|||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(status) => closeModal(status)}>
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={(status) => {
|
||||
closeModal(status);
|
||||
}}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
content={<ReplaceIcon className="w-4 h-4 m-auto" />}
|
||||
|
|
@ -106,7 +111,9 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
|||
placeholder="ex: John Doe"
|
||||
required
|
||||
value={searchText}
|
||||
setData={(_, value) => setSearchText(value)}
|
||||
setData={(_, value) => {
|
||||
setSearchText(value);
|
||||
}}
|
||||
/>
|
||||
<SimpleString
|
||||
name="value"
|
||||
|
|
@ -114,13 +121,17 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
|||
placeholder="ex: John Doe"
|
||||
required
|
||||
value={replaceText}
|
||||
setData={(_, value) => setReplaceText(value)}
|
||||
setData={(_, value) => {
|
||||
setReplaceText(value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex items-center gap-2 pb-1">
|
||||
<Checkbox
|
||||
id="match-case"
|
||||
checked={matchCase}
|
||||
onCheckedChange={(val) => setMatchCase(Boolean(val))}
|
||||
onCheckedChange={(val) => {
|
||||
setMatchCase(Boolean(val));
|
||||
}}
|
||||
/>
|
||||
<Label htmlFor="match-case">
|
||||
{useTrans("uwil-backend::back.wysiwyg.replace.match_case")}
|
||||
|
|
@ -136,7 +147,9 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) {
|
|||
)
|
||||
.ucFirst()
|
||||
.value()}
|
||||
onClick={() => closeModal()}
|
||||
onClick={() => {
|
||||
closeModal();
|
||||
}}
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size="default"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// * Packages
|
||||
import { Extension } from "@tiptap/core";
|
||||
import { Plugin } from "prosemirror-state";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// * Packages
|
||||
import { useEffect, useState } from "react";
|
||||
import { Editor } from "@tiptap/react";
|
||||
import { type Editor } from "@tiptap/react";
|
||||
import { TableIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
|
|
@ -13,30 +14,25 @@ import {
|
|||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Label } from "@/components/ui/label";
|
||||
// * Other
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
const BASE = 5;
|
||||
const MAX = 12;
|
||||
|
||||
type TableProps = {
|
||||
interface TableProps {
|
||||
editor: Editor;
|
||||
disabled: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export default function TableButton({ editor, disabled }: TableProps) {
|
||||
const [rows, setRows] = useState(3);
|
||||
const [cols, setCols] = useState(3);
|
||||
const [hover, setHover] = useState<{
|
||||
row: number;
|
||||
column: number;
|
||||
} | null>(null);
|
||||
const [header, setHeader] = useState(true);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [rows, setRows] = useState<number>(3);
|
||||
const [cols, setCols] = useState<number>(3);
|
||||
const [header, setHeader] = useState<boolean>(true);
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
|
||||
const hover = { row: rows, column: cols };
|
||||
|
||||
// Duration of modal closing animation.
|
||||
const animationTime = 200;
|
||||
|
|
@ -48,15 +44,12 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
BASE,
|
||||
rows + 1,
|
||||
cols + 1,
|
||||
hover?.row ? hover.row + 1 : 0,
|
||||
hover?.column ? hover.column + 1 : 0,
|
||||
hover.row ? hover.row + 1 : 0,
|
||||
hover.column ? hover.column + 1 : 0,
|
||||
),
|
||||
);
|
||||
|
||||
const insert = (
|
||||
expectedRows: number | undefined = undefined,
|
||||
expectedCols: number | undefined = undefined,
|
||||
): void => {
|
||||
const insert = (expectedRows?: number, expectedCols?: number): void => {
|
||||
if (!editor.can().insertTable()) return;
|
||||
|
||||
// Insert the expected table in the editor.
|
||||
|
|
@ -82,7 +75,6 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
const resetComponent = (): void => {
|
||||
setRows(3);
|
||||
setCols(3);
|
||||
setHover({ row: 3, column: 3 });
|
||||
setHeader(true);
|
||||
};
|
||||
|
||||
|
|
@ -93,7 +85,9 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
*/
|
||||
const closeModal = (): void => {
|
||||
setOpen(false);
|
||||
setTimeout(() => resetComponent(), animationTime);
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -106,17 +100,12 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
closeModal();
|
||||
};
|
||||
|
||||
// Set size of the current table on hover.
|
||||
useEffect(() => {
|
||||
setHover({ row: rows, column: cols });
|
||||
}, [rows, cols]);
|
||||
|
||||
// Press the key event to use the arrow keys to set the table size.
|
||||
useEffect(() => {
|
||||
if (!open) return undefined;
|
||||
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
const active = document.activeElement as HTMLInputElement;
|
||||
const active = document.activeElement as HTMLInputElement | null;
|
||||
|
||||
// Check if the focus is on inputs to get the basic behavior.
|
||||
if (active?.tagName === "INPUT" && active.type === "number") {
|
||||
|
|
@ -171,7 +160,9 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
|
||||
// Redefine the keydown event due to table resize.
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
return () => window.removeEventListener("keydown", onKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [open]);
|
||||
|
||||
|
|
@ -180,7 +171,10 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
open={open}
|
||||
onOpenChange={(status) => {
|
||||
setOpen(status);
|
||||
if (!status) setTimeout(() => resetComponent(), animationTime);
|
||||
if (!status)
|
||||
setTimeout(() => {
|
||||
resetComponent();
|
||||
}, animationTime);
|
||||
}}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
|
|
@ -215,7 +209,9 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
min={1}
|
||||
max={MAX}
|
||||
value={rows}
|
||||
onChange={(event) => setRows(Number(event.target.value) || 1)}
|
||||
onChange={(event) => {
|
||||
setRows(Number(event.target.value) || 1);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
|
|
@ -228,14 +224,18 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
min={1}
|
||||
max={MAX}
|
||||
value={cols}
|
||||
onChange={(event) => setCols(Number(event.target.value) || 1)}
|
||||
onChange={(event) => {
|
||||
setCols(Number(event.target.value) || 1);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1 flex justify-center items-center gap-1.5">
|
||||
<Checkbox
|
||||
id="header-input"
|
||||
checked={header}
|
||||
onCheckedChange={(event) => setHeader(Boolean(event))}
|
||||
onCheckedChange={(event) => {
|
||||
setHeader(Boolean(event));
|
||||
}}
|
||||
/>
|
||||
<Label htmlFor="header-input">
|
||||
{useTrans("uwil-backend::back.wysiwyg.table.show_header")}
|
||||
|
|
@ -255,27 +255,27 @@ export default function TableButton({ editor, disabled }: TableProps) {
|
|||
<div
|
||||
className="grid gap-1"
|
||||
style={{
|
||||
gridTemplateColumns: `repeat(${gridSize}, 1fr)`,
|
||||
gridTemplateColumns: `repeat(${String(gridSize)}, 1fr)`,
|
||||
}}
|
||||
>
|
||||
{Array.from({ length: gridSize * gridSize }).map((_, i) => {
|
||||
const row = Math.floor(i / gridSize) + 1;
|
||||
const column = (i % gridSize) + 1;
|
||||
|
||||
const active =
|
||||
hover && row <= hover.row && column <= hover.column;
|
||||
const active = row <= hover.row && column <= hover.column;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={`${row}-${column}`}
|
||||
key={`${String(row)}-${String(column)}`}
|
||||
type="button"
|
||||
aria-label={`${row} x ${column}`}
|
||||
aria-label={`${String(row)} x ${String(column)}`}
|
||||
onMouseEnter={() => {
|
||||
setHover({ row, column });
|
||||
setRows(row);
|
||||
setCols(column);
|
||||
}}
|
||||
onClick={() => insert(row, column)}
|
||||
onClick={() => {
|
||||
insert(row, column);
|
||||
}}
|
||||
className={[
|
||||
"aspect-square border cursor-pointer",
|
||||
active ? "bg-primary/30 border-primary" : "bg-muted",
|
||||
|
|
|
|||
|
|
@ -1,32 +1,30 @@
|
|||
// * Packages
|
||||
import { Editor, EditorContent } from "@tiptap/react";
|
||||
import { Table } from "@tiptap/extension-table";
|
||||
import { TaskItem } from "@tiptap/extension-list/task-item";
|
||||
import { TaskList } from "@tiptap/extension-list/task-list";
|
||||
import { ReactNode, useEffect, useMemo, useState } from "react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import InvisibleCharacters from "@tiptap/extension-invisible-characters";
|
||||
import { TaskItem } from "@tiptap/extension-list/task-item";
|
||||
import { TaskList } from "@tiptap/extension-list/task-list";
|
||||
import Placeholder from "@tiptap/extension-placeholder";
|
||||
import StarterKit from "@tiptap/starter-kit";
|
||||
import Subscript from "@tiptap/extension-subscript";
|
||||
import Superscript from "@tiptap/extension-superscript";
|
||||
import { Table } from "@tiptap/extension-table";
|
||||
import TableCell from "@tiptap/extension-table-cell";
|
||||
import TableHeader from "@tiptap/extension-table-header";
|
||||
import TableRow from "@tiptap/extension-table-row";
|
||||
import TextAlign from "@tiptap/extension-text-align";
|
||||
// * Components shadcn
|
||||
import { Label } from "@/components/ui/label";
|
||||
// * Other
|
||||
import ShortcutBoundary from "@/back/Components/Inputs/Wysiwyg/Extensions/ShortCuts/ShortcutBoundary";
|
||||
import { Link } from "@/back/Components/Inputs/Wysiwyg/Extensions/Link/Link";
|
||||
import Image from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/Image";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import WordCounter from "@/back/Components/WordCounter";
|
||||
import Toolbar from "@/back/Components/Inputs/Wysiwyg/Toolbar";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import { Editor, EditorContent } from "@tiptap/react";
|
||||
import StarterKit from "@tiptap/starter-kit";
|
||||
import { type ReactNode, useEffect, useMemo, useState } from "react";
|
||||
|
||||
type SimpleWysiwygProps = {
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import Image from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/Image";
|
||||
import { Link } from "@/back/Components/Inputs/Wysiwyg/Extensions/Link/Link";
|
||||
import ShortcutBoundary from "@/back/Components/Inputs/Wysiwyg/Extensions/ShortCuts/ShortcutBoundary";
|
||||
import Toolbar from "@/back/Components/Inputs/Wysiwyg/Toolbar";
|
||||
import WordCounter from "@/back/Components/WordCounter";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
|
||||
interface SimpleWysiwygProps {
|
||||
className?: string;
|
||||
name: string;
|
||||
tableName: string;
|
||||
|
|
@ -38,13 +36,12 @@ type SimpleWysiwygProps = {
|
|||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
parentErrors?: Record<string, string> | null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setData: (name: string, value: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export default function SimpleWysiwyg({
|
||||
className,
|
||||
value = undefined,
|
||||
value,
|
||||
tableName,
|
||||
name,
|
||||
label,
|
||||
|
|
@ -61,7 +58,6 @@ export default function SimpleWysiwyg({
|
|||
const { errors } = usePage().props;
|
||||
const localErrors = parentErrors ?? errors;
|
||||
|
||||
const [editor, setEditor] = useState<Editor | null>(null);
|
||||
const [content, setContent] = useState(value);
|
||||
|
||||
/**
|
||||
|
|
@ -126,21 +122,26 @@ export default function SimpleWysiwyg({
|
|||
[],
|
||||
);
|
||||
|
||||
const [editor] = useState<Editor | null>(
|
||||
() =>
|
||||
new Editor({
|
||||
content: value ?? undefined,
|
||||
extensions,
|
||||
editable: !disabled,
|
||||
editorProps: {
|
||||
attributes: { id, required: String(required), tableName },
|
||||
},
|
||||
onUpdate: ({ editor: currentEditor }) => {
|
||||
onChangeContent(currentEditor.getHTML());
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
// Init editor only once.
|
||||
useEffect(() => {
|
||||
const e = new Editor({
|
||||
content: value || undefined,
|
||||
extensions,
|
||||
editable: !disabled,
|
||||
editorProps: {
|
||||
attributes: { id, required: String(required), tableName },
|
||||
},
|
||||
onUpdate: ({ editor: currentEditor }) =>
|
||||
onChangeContent(currentEditor.getHTML()),
|
||||
});
|
||||
setEditor(e);
|
||||
|
||||
return () => e.destroy();
|
||||
return () => {
|
||||
editor?.destroy();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
// * Packages
|
||||
import { Editor } from "@tiptap/react";
|
||||
import { ElementType, useEffect, useState } from "react";
|
||||
import { type Editor } from "@tiptap/react";
|
||||
import {
|
||||
AlignCenterIcon,
|
||||
AlignJustifyIcon,
|
||||
|
|
@ -25,13 +23,13 @@ import {
|
|||
UnderlineIcon,
|
||||
UndoIcon,
|
||||
} from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { type ElementType, useEffect, useState } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import ImageButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageButton";
|
||||
import LinkButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Link/LinkButton";
|
||||
import FindReplaceButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Replace/FindReplaceButton";
|
||||
import TableButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Table/TableButton";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
|
|
@ -39,12 +37,12 @@ import {
|
|||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
// * Other
|
||||
import ImageButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageButton";
|
||||
import LinkButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Link/LinkButton";
|
||||
import TableButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Table/TableButton";
|
||||
import FindReplaceButton from "@/back/Components/Inputs/Wysiwyg/Extensions/Replace/FindReplaceButton";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import str from "@/hooks/use-string";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
|
||||
|
|
@ -52,10 +50,10 @@ type AllowedHeadings = 1 | 2 | 3 | 4 | 5 | 6;
|
|||
|
||||
type AllowedAlignements = "left" | "center" | "right" | "justify";
|
||||
|
||||
type ToolbarProps = {
|
||||
interface ToolbarProps {
|
||||
editor: Editor;
|
||||
routeName: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
||||
const [, forceUpdate] = useState<number>(0);
|
||||
|
|
@ -108,9 +106,9 @@ export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
|||
|
||||
// Force re-render editor on select to update activated extensions.
|
||||
useEffect(() => {
|
||||
if (!editor) return undefined;
|
||||
|
||||
const update = () => forceUpdate((value) => value + 1);
|
||||
const update = () => {
|
||||
forceUpdate((value) => value + 1);
|
||||
};
|
||||
|
||||
editor.on("selectionUpdate", () => {
|
||||
update();
|
||||
|
|
@ -131,7 +129,9 @@ export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
|||
window.addEventListener("resize", handleResize);
|
||||
handleResize();
|
||||
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
@ -252,7 +252,9 @@ export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
|||
<Separator orientation="vertical" className="!h-auto" />
|
||||
<Select
|
||||
value={currentHeadingLevel.toString()}
|
||||
onValueChange={(value) => handleHeadingChange(value)}
|
||||
onValueChange={(value) => {
|
||||
handleHeadingChange(value);
|
||||
}}
|
||||
disabled={docSelected}
|
||||
>
|
||||
<Tooltip>
|
||||
|
|
@ -268,7 +270,7 @@ export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
|||
>
|
||||
<HeadingIcon className="w-4 h-4" />
|
||||
{currentHeadingLevel && (
|
||||
<SelectValue>{currentHeadingLevel?.toString()}</SelectValue>
|
||||
<SelectValue>{currentHeadingLevel.toString()}</SelectValue>
|
||||
)}
|
||||
</SelectTrigger>
|
||||
</TooltipTrigger>
|
||||
|
|
@ -345,7 +347,7 @@ export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
|||
/>
|
||||
<Separator orientation="vertical" className="!h-auto" />
|
||||
<Select
|
||||
value={currentTextAlign.value.toString()}
|
||||
value={currentTextAlign.value}
|
||||
onValueChange={(value) => {
|
||||
const align = value as AllowedAlignements;
|
||||
editor.chain().focus().setTextAlign(align).run();
|
||||
|
|
@ -372,7 +374,7 @@ export default function Toolbar({ editor, routeName }: ToolbarProps) {
|
|||
</Tooltip>
|
||||
<SelectContent>
|
||||
{textAligns.map((align) => (
|
||||
<SelectItem key={align.value} value={align.value.toString()}>
|
||||
<SelectItem key={align.value} value={align.value}>
|
||||
<div className="flex flex-row jsutify-center items-center gap-1.5">
|
||||
<align.icon className="w-4 h-4" />
|
||||
{GetTranslation(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// * Packages
|
||||
import "@tiptap/core";
|
||||
|
||||
declare module "@tiptap/core" {
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
// * Packages
|
||||
import { Link, usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
|
||||
import {
|
||||
Breadcrumb,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbList,
|
||||
BreadcrumbSeparator,
|
||||
} from "@/components/ui/breadcrumb";
|
||||
// * Other
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export default function AppBreadcrumbs({ className }: { className: string }) {
|
||||
const breadcrumbs = usePage().props.breadcrumbs as Array<{
|
||||
const breadcrumbs = usePage().props.breadcrumbs as {
|
||||
title: string;
|
||||
url: string;
|
||||
}>;
|
||||
}[];
|
||||
return (
|
||||
breadcrumbs && (
|
||||
breadcrumbs.length && (
|
||||
<Breadcrumb className={cn("md:border-s md:ms-1 px-4", className)}>
|
||||
<BreadcrumbList>
|
||||
{breadcrumbs.map((breadcrumb, breadcrumbIndex) => (
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
// * Other
|
||||
import { AppEnv } from "@/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
export default function AppFooter() {
|
||||
const appName = (usePage().props.appEnv as AppEnv).name;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
// * Packages
|
||||
import { Link, usePage } from "@inertiajs/react";
|
||||
import { CircleUserRoundIcon, LogOutIcon, UserIcon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
// * Components shadcn
|
||||
|
||||
import CustomSidebarTrigger from "@/back/Components/CustomSidebarTrigger";
|
||||
import AppBreadcrumbs from "@/back/Components/Layout/AppBreadcrumbs";
|
||||
import AppSettings from "@/back/Components/Layout/Settings/AppSettings";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -10,12 +13,6 @@ import {
|
|||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
// * Other
|
||||
import AppBreadcrumbs from "@/back/Components/Layout/AppBreadcrumbs";
|
||||
import AppSettings from "@/back/Components/Layout/Settings/AppSettings";
|
||||
import CustomSidebarTrigger from "@/back/Components/CustomSidebarTrigger";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function AppHeader() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// * Packages
|
||||
import { SettingsIcon } from "lucide-react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { SettingsIcon } from "lucide-react";
|
||||
|
||||
import SettingRegistry from "@/back/Components/Layout/Settings/SettingRegistry";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
|
|
@ -9,15 +10,12 @@ import {
|
|||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
// * Other
|
||||
import SettingRegistry from "@/back/Components/Layout/Settings/SettingRegistry";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
type AppSettingsProps = {
|
||||
interface AppSettingsProps {
|
||||
className?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function AppSettings({ className = "" }: AppSettingsProps) {
|
||||
const { appEnv, configBackend } = usePage().props as unknown as {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
// * Packages
|
||||
import { route } from "ziggy-js";
|
||||
import { FormEvent } from "react";
|
||||
import { useForm } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { type SubmitEvent } from "react";
|
||||
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
// * Other
|
||||
import { AppEnv } from "@/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
export default function Languages(
|
||||
appEnv: AppEnv,
|
||||
|
|
@ -21,7 +18,7 @@ export default function Languages(
|
|||
lang: "system",
|
||||
});
|
||||
const transLanguage = useTrans("uwil-i18n::trans.languages");
|
||||
const submit = (e: FormEvent<HTMLFormElement>) => {
|
||||
const submit = (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
post(route(`${routes.name}lang.set`));
|
||||
};
|
||||
|
|
@ -75,7 +72,9 @@ export default function Languages(
|
|||
<DropdownMenuItem
|
||||
key={language.name}
|
||||
className="p-0"
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
onSelect={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
className={cn("w-full", {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
// * Packages
|
||||
import { MoonIcon, SunIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
|
||||
import { useTheme } from "@/back/providers/ThemeProvider";
|
||||
import { type Theme } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
// * Other
|
||||
import { Theme } from "@/back/types/global";
|
||||
import { useTheme } from "@/back/providers/ThemeProvider";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { cn, GetTranslation } from "@/lib/utils";
|
||||
|
||||
|
|
@ -36,14 +34,18 @@ export default function Themes() {
|
|||
<DropdownMenuItem
|
||||
key={mod.name}
|
||||
className="p-0"
|
||||
onSelect={(e) => e.preventDefault()}
|
||||
onSelect={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
className={cn("w-full", {
|
||||
"bg-secondary": theme === mod.theme,
|
||||
})}
|
||||
variant="ghost"
|
||||
onClick={() => setTheme(mod.theme as Theme)}
|
||||
onClick={() => {
|
||||
setTheme(mod.theme as Theme);
|
||||
}}
|
||||
>
|
||||
<mod.icon />
|
||||
{GetTranslation(mod.name)}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,36 @@
|
|||
// * Packages
|
||||
import { ReactNode } from "react";
|
||||
// * Other
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
type SettingResolver = (
|
||||
appEnv: AppEnv,
|
||||
configBackend: ConfigBackend,
|
||||
) => ReactNode;
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
||||
export default class SettingRegistry {
|
||||
private static resolvers: SettingResolver[] = [];
|
||||
const resolvers: SettingResolver[] = [];
|
||||
|
||||
static add(resolver: SettingResolver) {
|
||||
this.resolvers.push(resolver);
|
||||
}
|
||||
|
||||
static getAll(appEnv: AppEnv, configBackend: ConfigBackend): ReactNode[] {
|
||||
return this.resolvers.map((resolver) => resolver(appEnv, configBackend));
|
||||
}
|
||||
}
|
||||
const SettingRegistry = {
|
||||
add(resolver: SettingResolver) {
|
||||
resolvers.push(resolver);
|
||||
},
|
||||
getAll(appEnv: AppEnv, configBackend: ConfigBackend): ReactNode[] {
|
||||
return resolvers.map((resolver) => resolver(appEnv, configBackend));
|
||||
},
|
||||
};
|
||||
|
||||
// Add all sections presents in files to the registry.
|
||||
// @ts-expect-error Glob error.
|
||||
const modules = import.meta.glob("./Sections/*.tsx", {
|
||||
eager: true,
|
||||
}) as Record<
|
||||
string,
|
||||
const modules = import.meta.glob<{ default: SettingResolver }>(
|
||||
"./Sections/*.tsx",
|
||||
{
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
default: (appEnv: AppEnv, configBackend: ConfigBackend) => ReactNode;
|
||||
}
|
||||
>;
|
||||
eager: true,
|
||||
},
|
||||
);
|
||||
|
||||
Object.entries(modules)
|
||||
.sort(([pathA], [pathB]) => pathA.localeCompare(pathB))
|
||||
.forEach(([, module]) => {
|
||||
SettingRegistry.add(module.default);
|
||||
});
|
||||
|
||||
export default SettingRegistry;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,32 @@
|
|||
// * Packages
|
||||
import { Link, usePage } from "@inertiajs/react";
|
||||
import { ElementType, ReactNode, useEffect, useRef } from "react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
MoreHorizontalIcon,
|
||||
HomeIcon,
|
||||
TelescopeIcon,
|
||||
} from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
// * Components shadcn
|
||||
import { type ElementType, type ReactNode, useEffect, useRef } from "react";
|
||||
|
||||
import ApplicationLogo from "@/back/Components/ApplicationLogo";
|
||||
import { SidebarRegistry } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import {
|
||||
type AuthProp,
|
||||
type UserModel,
|
||||
type ConfigBackend,
|
||||
} from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleTrigger,
|
||||
CollapsibleContent,
|
||||
} from "@/components/ui/collapsible";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarHeader,
|
||||
|
|
@ -22,34 +40,17 @@ import {
|
|||
SidebarMenuAction,
|
||||
useSidebar,
|
||||
} from "@/components/ui/sidebar";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleTrigger,
|
||||
CollapsibleContent,
|
||||
} from "@/components/ui/collapsible";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import ApplicationLogo from "@/back/Components/ApplicationLogo";
|
||||
import { SidebarRegistry } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { AuthProp, UserModel, ConfigBackend } from "@/back/types/global";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
export type NavListLinksProps = {
|
||||
export interface NavListLinksProps {
|
||||
/** Title of the button. */
|
||||
title: string;
|
||||
/** Main model of the button (used for route checking). */
|
||||
|
|
@ -63,18 +64,17 @@ export type NavListLinksProps = {
|
|||
/** Lucide icon of the button. */
|
||||
icon: ElementType;
|
||||
/** Define some actions in side popover (like create/trash). */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
actions?: (model: string) => ReactNode;
|
||||
};
|
||||
}
|
||||
|
||||
export type NavListProps = Array<{
|
||||
export type NavListProps = {
|
||||
/** Title of the group. */
|
||||
title: string;
|
||||
/** Condition to set the visibility of the group. */
|
||||
show: boolean;
|
||||
/** Links presents in the group. */
|
||||
links: Array<NavListLinksProps>;
|
||||
}>;
|
||||
links: NavListLinksProps[];
|
||||
}[];
|
||||
|
||||
/**
|
||||
* Get sidenav actions.
|
||||
|
|
@ -111,7 +111,6 @@ export const filterActions = ({
|
|||
href={route(`${configBackend.routes.name}${model}.create`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
<Views.CREATION.icon />
|
||||
{transDefaultSideAction}
|
||||
</Link>
|
||||
|
|
@ -165,7 +164,7 @@ export default function AppSidebar() {
|
|||
},
|
||||
{
|
||||
title: str(transAdmin).plural().value(),
|
||||
show: auth.user.role.value === isConceptor!.value,
|
||||
show: auth.user.role.value === isConceptor?.value,
|
||||
links: [
|
||||
...SidebarRegistry.getAll(auth, configBackend, "admin"),
|
||||
{
|
||||
|
|
@ -222,10 +221,11 @@ export default function AppSidebar() {
|
|||
{navGroup.links
|
||||
.filter((navLink) => navLink.show)
|
||||
.map((navLink) => {
|
||||
const isActive =
|
||||
route().current(
|
||||
`${configBackend.routes.name}${navLink.model}.*`,
|
||||
) || navLink.activeCondition?.some(Boolean);
|
||||
const isActive = navLink.model
|
||||
? route().current(
|
||||
`${configBackend.routes.name}${navLink.model}.*`,
|
||||
)
|
||||
: navLink.activeCondition?.some(Boolean);
|
||||
const sidebarButton = (
|
||||
<SidebarMenuButton
|
||||
className={
|
||||
|
|
@ -246,9 +246,13 @@ export default function AppSidebar() {
|
|||
</a>
|
||||
) : (
|
||||
<Link
|
||||
href={route(
|
||||
`${configBackend.routes.name}${navLink.model}.index`,
|
||||
)}
|
||||
href={
|
||||
navLink.model
|
||||
? route(
|
||||
`${configBackend.routes.name}${navLink.model}.index`,
|
||||
)
|
||||
: "#"
|
||||
}
|
||||
className="bg-transparent"
|
||||
>
|
||||
<navLink.icon />
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// * Packages
|
||||
import { HistoryIcon } from "lucide-react";
|
||||
// * Other
|
||||
import { NavListLinksProps } from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp } from "@/back/types/global";
|
||||
|
||||
import { type NavListLinksProps } from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { type AuthProp } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
// * Packages
|
||||
import { BriefcaseBusinessIcon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { BriefcaseBusinessIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
type NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function SidebarLinkBrands(
|
||||
auth: AuthProp,
|
||||
|
|
@ -55,7 +52,7 @@ export default function SidebarLinkBrands(
|
|||
href={route(`${routeName}${model}.create`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.CREATION.icon />
|
||||
{transCreate}
|
||||
</Link>
|
||||
|
|
@ -69,7 +66,7 @@ export default function SidebarLinkBrands(
|
|||
href={route(`${routeName}${model}.trash`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.ARCHIVATION.icon />
|
||||
{transArchives}
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
// * Packages
|
||||
import { Building2Icon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { Building2Icon } from "lucide-react";
|
||||
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
type NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function SidebarLinkInvoiceCompanies(
|
||||
auth: AuthProp,
|
||||
|
|
@ -55,7 +52,7 @@ export default function SidebarLinkInvoiceCompanies(
|
|||
href={route(`${routeName}${model}.create`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.CREATION.icon />
|
||||
{transCreate}
|
||||
</Link>
|
||||
|
|
@ -69,7 +66,7 @@ export default function SidebarLinkInvoiceCompanies(
|
|||
href={route(`${routeName}${model}.trash`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.ARCHIVATION.icon />
|
||||
{transArchives}
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
// * Packages
|
||||
import { HandCoinsIcon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { HandCoinsIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
type NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function SidebarLinkInvoicePackages(
|
||||
auth: AuthProp,
|
||||
|
|
@ -55,7 +52,7 @@ export default function SidebarLinkInvoicePackages(
|
|||
href={route(`${routeName}${model}.create`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.CREATION.icon />
|
||||
{transCreate}
|
||||
</Link>
|
||||
|
|
@ -69,7 +66,7 @@ export default function SidebarLinkInvoicePackages(
|
|||
href={route(`${routeName}${model}.trash`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.ARCHIVATION.icon />
|
||||
{transArchives}
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
// * Packages
|
||||
import { InfoIcon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { InfoIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
type NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function SidebarLinkNotices(
|
||||
auth: AuthProp,
|
||||
|
|
@ -55,7 +52,7 @@ export default function SidebarLinkNotices(
|
|||
href={route(`${routeName}${model}.create`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.CREATION.icon />
|
||||
{transCreate}
|
||||
</Link>
|
||||
|
|
@ -69,7 +66,7 @@ export default function SidebarLinkNotices(
|
|||
href={route(`${routeName}${model}.trash`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.ARCHIVATION.icon />
|
||||
{transArchives}
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
// * Packages
|
||||
import { GlobeIcon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import { GlobeIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
type NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import Views from "@/back/lib/actions";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function SidebarLinkSites(
|
||||
auth: AuthProp,
|
||||
|
|
@ -55,7 +52,7 @@ export default function SidebarLinkSites(
|
|||
href={route(`${routeName}${model}.create`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.CREATION.icon />
|
||||
{transCreate}
|
||||
</Link>
|
||||
|
|
@ -69,7 +66,7 @@ export default function SidebarLinkSites(
|
|||
href={route(`${routeName}${model}.trash`)}
|
||||
className="w-full"
|
||||
>
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
{}
|
||||
<Views.ARCHIVATION.icon />
|
||||
{transArchives}
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
// * Packages
|
||||
import { UsersIcon } from "lucide-react";
|
||||
// * Other
|
||||
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
type NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,30 @@
|
|||
import { NavListLinksProps } from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { AuthProp, ConfigBackend } from "@/back/types/global";
|
||||
import { type NavListLinksProps } from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { type AuthProp, type ConfigBackend } from "@/back/types/global";
|
||||
|
||||
export type SidebarGroupType = "pages" | "admin" | "modules";
|
||||
|
||||
export type SidebarGroupLink = {
|
||||
export interface SidebarGroupLink {
|
||||
link: NavListLinksProps;
|
||||
group: SidebarGroupType;
|
||||
};
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
export type LinkResolver = (
|
||||
auth: AuthProp,
|
||||
configBackend: ConfigBackend,
|
||||
) => SidebarGroupLink;
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
||||
export class SidebarRegistry {
|
||||
private static resolvers: LinkResolver[] = [];
|
||||
const resolvers: LinkResolver[] = [];
|
||||
|
||||
static add(resolver: LinkResolver) {
|
||||
this.resolvers.push(resolver);
|
||||
}
|
||||
|
||||
static getAll(
|
||||
export const SidebarRegistry = {
|
||||
add(resolver: LinkResolver) {
|
||||
resolvers.push(resolver);
|
||||
},
|
||||
getAll(
|
||||
auth: AuthProp,
|
||||
configBackend: ConfigBackend,
|
||||
group: SidebarGroupType,
|
||||
): NavListLinksProps[] {
|
||||
return this.resolvers
|
||||
return resolvers
|
||||
.map((resolver) => resolver(auth, configBackend))
|
||||
.filter((sidebarGroupLink) => sidebarGroupLink.group === group)
|
||||
.sort((a, b) =>
|
||||
|
|
@ -36,20 +33,13 @@ export class SidebarRegistry {
|
|||
}),
|
||||
)
|
||||
.map((sidebarGroupLink) => sidebarGroupLink.link);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Add all links presents in files to the registry.
|
||||
// @ts-expect-error Glob error.
|
||||
const modules = import.meta.glob("./Links/*.tsx", {
|
||||
const modules = import.meta.glob<{ default: LinkResolver }>("./Links/*.tsx", {
|
||||
eager: true,
|
||||
}) as Record<
|
||||
string,
|
||||
{
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
default: (auth: AuthProp, configBackend: ConfigBackend) => SidebarGroupLink;
|
||||
}
|
||||
>;
|
||||
});
|
||||
|
||||
Object.values(modules).forEach((module) => {
|
||||
SidebarRegistry.add(module.default);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
// * Packages
|
||||
import { Link, useForm, usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { FormEvent, ReactNode, useState } from "react";
|
||||
import { MoreHorizontalIcon } from "lucide-react";
|
||||
import type { VisitOptions } from "@inertiajs/core";
|
||||
// * Components shadcn
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Link, useForm, usePage } from "@inertiajs/react";
|
||||
import { MoreHorizontalIcon } from "lucide-react";
|
||||
import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
type SubmitEvent,
|
||||
type ReactNode,
|
||||
useState,
|
||||
type SetStateAction,
|
||||
type Dispatch,
|
||||
} from "react";
|
||||
|
||||
import Views from "@/back/lib/actions";
|
||||
import {
|
||||
type DefaultModel,
|
||||
type Views as ViewsType,
|
||||
type ConfigBackend,
|
||||
} from "@/back/types/global";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -23,18 +27,20 @@ import {
|
|||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
// * Other
|
||||
import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
type ToastActionElement,
|
||||
type ToastProps,
|
||||
} from "@/components/ui/toast";
|
||||
import { useFormatedDate } from "@/hooks/use-formated-value";
|
||||
import str from "@/hooks/use-string";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import str from "@/hooks/use-string";
|
||||
import {
|
||||
DefaultModel,
|
||||
Views as ViewsType,
|
||||
ConfigBackend,
|
||||
} from "@/back/types/global";
|
||||
import Views from "@/back/lib/actions";
|
||||
import { ToastActionElement, ToastProps } from "@/components/ui/toast";
|
||||
|
||||
interface Translations {
|
||||
successfulArchivation: string;
|
||||
|
|
@ -93,7 +99,7 @@ function GetAction({
|
|||
|
||||
/**
|
||||
* Action call on model.
|
||||
* @param event FormEvent<HTMLFormElement>
|
||||
* @param event SubmitEvent
|
||||
* @param action ViewsType[number]
|
||||
* @param modelRoute string
|
||||
* @param model DefaultModel
|
||||
|
|
@ -102,8 +108,7 @@ function GetAction({
|
|||
* @param toast
|
||||
*/
|
||||
const actionOnModel = (
|
||||
/* eslint-disable no-unused-vars */
|
||||
event: FormEvent<HTMLFormElement>,
|
||||
event: SubmitEvent,
|
||||
action: ViewsType[number],
|
||||
nameRoute: string,
|
||||
modelRoute: string,
|
||||
|
|
@ -117,7 +122,6 @@ const actionOnModel = (
|
|||
},
|
||||
destroy: (url: string, options?: VisitOptions) => void,
|
||||
patch: (url: string, options?: VisitOptions) => void,
|
||||
/* eslint-enable no-unused-vars */
|
||||
) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
|
@ -172,9 +176,6 @@ const actionOnModel = (
|
|||
|
||||
// Check if route exist.
|
||||
const config = actionMap[action.label];
|
||||
if (!config) {
|
||||
throw new Error(`Unknown action: ${action.label}`);
|
||||
}
|
||||
|
||||
// Close the dropdown.
|
||||
setOpen(false);
|
||||
|
|
@ -204,7 +205,6 @@ function PostAction({
|
|||
action: ViewsType[number];
|
||||
modelRoute: string;
|
||||
model: DefaultModel;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setOpen: (value: boolean) => void;
|
||||
}) {
|
||||
const { delete: destroy, patch } = useForm();
|
||||
|
|
@ -298,7 +298,7 @@ function PostAction({
|
|||
</Button>
|
||||
</DialogClose>
|
||||
<form
|
||||
onSubmit={(event) =>
|
||||
onSubmit={(event) => {
|
||||
actionOnModel(
|
||||
event,
|
||||
action,
|
||||
|
|
@ -310,8 +310,8 @@ function PostAction({
|
|||
toast,
|
||||
destroy,
|
||||
patch,
|
||||
)
|
||||
}
|
||||
);
|
||||
}}
|
||||
className="w-fit mb-2 sm:mb-0"
|
||||
>
|
||||
<Button type="submit" variant={btnVariantType}>
|
||||
|
|
@ -324,6 +324,64 @@ function PostAction({
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all action buttons.
|
||||
* @returns Element[]
|
||||
*/
|
||||
const AllBtnActions = ({
|
||||
allowedActions,
|
||||
model,
|
||||
modelRoute,
|
||||
routes,
|
||||
inDialog,
|
||||
setOpen,
|
||||
}: {
|
||||
allowedActions: ViewsType;
|
||||
model: DefaultModel;
|
||||
modelRoute: string;
|
||||
routes: ConfigBackend["routes"];
|
||||
inDialog: boolean;
|
||||
setOpen: Dispatch<SetStateAction<boolean>>;
|
||||
}) => {
|
||||
const postActionValues = new Set([
|
||||
Views.ARCHIVATION.value,
|
||||
Views.RESTORATION.value,
|
||||
Views.DELETION.value,
|
||||
Views.FORCEDELETION.value,
|
||||
]);
|
||||
|
||||
return allowedActions.map((action) => {
|
||||
const isPostAction = postActionValues.has(action.value);
|
||||
const showSeparator =
|
||||
inDialog && isPostAction && action.value !== allowedActions[0].value;
|
||||
|
||||
const content = isPostAction ? (
|
||||
<>
|
||||
{showSeparator && <DropdownMenuSeparator />}
|
||||
<PostAction
|
||||
action={action}
|
||||
model={model}
|
||||
modelRoute={modelRoute}
|
||||
setOpen={setOpen}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<GetAction
|
||||
action={action}
|
||||
model={model}
|
||||
modelRoute={modelRoute}
|
||||
routes={routes}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div key={`${action.value}-${action.label}`} className="w-full">
|
||||
{content}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
interface ModelActionsProps {
|
||||
actions?: ViewsType;
|
||||
modelRoute: string;
|
||||
|
|
@ -342,57 +400,13 @@ export default function ModelActions({
|
|||
message = "uwil-backend::back.model_action_updated_at",
|
||||
}: ModelActionsProps) {
|
||||
const { routes } = usePage().props.configBackend as ConfigBackend;
|
||||
const [open, setOpen] = useState(false);
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const messageTrans = useTrans(message);
|
||||
const formattedDate = useFormatedDate(modelUpdatedAt);
|
||||
const allowedActions = actions.filter(
|
||||
(action) => model.policies[action.policy as keyof typeof model.policies],
|
||||
);
|
||||
|
||||
/**
|
||||
* Get all action buttons.
|
||||
* @returns Element[]
|
||||
*/
|
||||
const AllBtnActions = () => {
|
||||
const postActionValues = new Set([
|
||||
Views.ARCHIVATION.value,
|
||||
Views.RESTORATION.value,
|
||||
Views.DELETION.value,
|
||||
Views.FORCEDELETION.value,
|
||||
]);
|
||||
|
||||
return allowedActions.map((action) => {
|
||||
const isPostAction = postActionValues.has(action.value);
|
||||
const showSeparator =
|
||||
inDialog && isPostAction && action.value !== allowedActions[0].value;
|
||||
|
||||
const content = isPostAction ? (
|
||||
<>
|
||||
{showSeparator && <DropdownMenuSeparator />}
|
||||
<PostAction
|
||||
action={action}
|
||||
model={model}
|
||||
modelRoute={modelRoute}
|
||||
setOpen={setOpen}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<GetAction
|
||||
action={action}
|
||||
model={model}
|
||||
modelRoute={modelRoute}
|
||||
routes={routes}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div key={`${action.value}-${action.label}`} className="w-full">
|
||||
{content}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex justify-between items-center ${
|
||||
|
|
@ -423,11 +437,25 @@ export default function ModelActions({
|
|||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent side="right" align="start">
|
||||
<AllBtnActions />
|
||||
<AllBtnActions
|
||||
allowedActions={allowedActions}
|
||||
model={model}
|
||||
modelRoute={modelRoute}
|
||||
routes={routes}
|
||||
setOpen={setOpen}
|
||||
inDialog={inDialog}
|
||||
/>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
<AllBtnActions />
|
||||
<AllBtnActions
|
||||
allowedActions={allowedActions}
|
||||
model={model}
|
||||
modelRoute={modelRoute}
|
||||
routes={routes}
|
||||
setOpen={setOpen}
|
||||
inDialog={inDialog}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
// * Packages
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
|
||||
import { type PaginatorLink } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
PaginationItem,
|
||||
} from "@/components/ui/pagination";
|
||||
// * Other
|
||||
import { PaginatorLink } from "@/back/types/global";
|
||||
|
||||
type PaginationCustomProps = {
|
||||
links: Array<PaginatorLink>;
|
||||
};
|
||||
interface PaginationCustomProps {
|
||||
links: PaginatorLink[];
|
||||
}
|
||||
|
||||
export default function PaginationCustom({ links }: PaginationCustomProps) {
|
||||
const page =
|
||||
Number(new URLSearchParams(window.location.search).get("page")) || 1;
|
||||
Number(
|
||||
new URLSearchParams(new URL(window.location.href).search).get("page"),
|
||||
) || 1;
|
||||
const lastPage = links.length - 1;
|
||||
|
||||
if (links.length > 3) {
|
||||
|
|
@ -56,7 +56,6 @@ export default function PaginationCustom({ links }: PaginationCustomProps) {
|
|||
/>
|
||||
) : (
|
||||
<span
|
||||
// eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: link.label,
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// * Packages
|
||||
import { router, usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
|
|
@ -10,7 +9,6 @@ import {
|
|||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
// * Other
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function PaginationPerPage({
|
||||
|
|
@ -41,7 +39,9 @@ export default function PaginationPerPage({
|
|||
total > enumMinValue && (
|
||||
<Select
|
||||
value={String(perPage)}
|
||||
onValueChange={(value) => handleSelectChange(value)}
|
||||
onValueChange={(value) => {
|
||||
handleSelectChange(value);
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="w-[4.5rem]">
|
||||
<SelectValue placeholder={paginationListTrans} />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// * Other
|
||||
import { Paginator } from "@/back/types/global";
|
||||
import PaginationCustom from "@/back/Components/Pagination/PaginationCustom";
|
||||
import PaginationPerPage from "@/back/Components/Pagination/PaginationPerPage";
|
||||
import { type Paginator } from "@/back/types/global";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
|
||||
export default function PaginationWrapper({
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// * Packages
|
||||
import { AlertCircle } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
// * Other
|
||||
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function SoftdeleteWarning() {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,21 @@
|
|||
// * Packages
|
||||
import { useState } from "react";
|
||||
import {
|
||||
ColumnDef,
|
||||
SortingState,
|
||||
type ColumnDef,
|
||||
type SortingState,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getSortedRowModel,
|
||||
useReactTable,
|
||||
} from "@tanstack/react-table";
|
||||
// * Components shadcn
|
||||
import { useState } from "react";
|
||||
|
||||
import ModelActions from "@/back/Components/ModelActions";
|
||||
import PaginationWrapper from "@/back/Components/Pagination/PaginationWrapper";
|
||||
import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton";
|
||||
import {
|
||||
type DefaultModel,
|
||||
type Resource,
|
||||
type Views,
|
||||
} from "@/back/types/global";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -17,11 +24,6 @@ import {
|
|||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
// * Other
|
||||
import { DefaultModel, Resource, Views } from "@/back/types/global";
|
||||
import ModelActions from "@/back/Components/ModelActions";
|
||||
import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton";
|
||||
import PaginationWrapper from "@/back/Components/Pagination/PaginationWrapper";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function DataTable<TData, TValue>({
|
||||
|
|
@ -37,6 +39,8 @@ export default function DataTable<TData, TValue>({
|
|||
}) {
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const data = modelsPaginate.data as TData[];
|
||||
|
||||
// eslint-disable-next-line react-hooks/incompatible-library
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
|
|
@ -77,7 +81,7 @@ export default function DataTable<TData, TValue>({
|
|||
))}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{table.getRowModel().rows?.length ? (
|
||||
{table.getRowModel().rows.length ? (
|
||||
table.getRowModel().rows.map((row) => (
|
||||
<TableRow
|
||||
key={row.id}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
// * Packages
|
||||
import { router } from "@inertiajs/react";
|
||||
import {
|
||||
ArrowDownIcon,
|
||||
ArrowUpIcon,
|
||||
ArrowUpDownIcon,
|
||||
EraserIcon,
|
||||
} from "lucide-react";
|
||||
import { router } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
// * Other
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function DataTableFilterButton({
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
// * Packages
|
||||
import { DeleteIcon } from "lucide-react";
|
||||
import { FormEvent, ReactNode, useState } from "react";
|
||||
import { route } from "ziggy-js";
|
||||
// * Other
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import { type SubmitEvent, type ReactNode, useState } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import AddFilterToUrl from "@/back/lib/filters";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
type DataTableSearchProps = {
|
||||
interface DataTableSearchProps {
|
||||
modelRoute: string;
|
||||
prefixRoute: string;
|
||||
searchFields: string;
|
||||
isArchiveRoute?: boolean;
|
||||
children?: ReactNode;
|
||||
};
|
||||
}
|
||||
|
||||
export default function DataTableSearch({
|
||||
modelRoute,
|
||||
|
|
@ -24,11 +22,9 @@ export default function DataTableSearch({
|
|||
isArchiveRoute = false,
|
||||
children,
|
||||
}: DataTableSearchProps) {
|
||||
const [search, setSearch] = useState<string | null>(
|
||||
route().params.search ?? null,
|
||||
);
|
||||
const [search, setSearch] = useState<string | null>(route().params.search);
|
||||
|
||||
const submit = (e: FormEvent<HTMLFormElement>) => {
|
||||
const submit = (e: SubmitEvent<HTMLFormElement>) => {
|
||||
if (!search) return;
|
||||
e.preventDefault();
|
||||
const params = {
|
||||
|
|
@ -36,8 +32,8 @@ export default function DataTableSearch({
|
|||
search,
|
||||
};
|
||||
AddFilterToUrl({
|
||||
modelRoute,
|
||||
prefixRoute,
|
||||
modelRoute: modelRoute,
|
||||
prefixRoute: prefixRoute,
|
||||
params,
|
||||
isArchiveRoute,
|
||||
});
|
||||
|
|
@ -49,8 +45,8 @@ export default function DataTableSearch({
|
|||
search: undefined,
|
||||
};
|
||||
AddFilterToUrl({
|
||||
modelRoute,
|
||||
prefixRoute,
|
||||
modelRoute: modelRoute,
|
||||
prefixRoute: prefixRoute,
|
||||
params,
|
||||
isArchiveRoute,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// * Packages
|
||||
import { ReactNode } from "react";
|
||||
// * Components shadcn
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import { type DefaultModel } from "@/back/types/global";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -9,15 +9,12 @@ import {
|
|||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
// * Other
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { DefaultModel } from "@/back/types/global";
|
||||
|
||||
interface DetailsTableProps {
|
||||
columns: {
|
||||
accessorKey: keyof DefaultModel;
|
||||
header: string;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
cell?: (params: { value: unknown }) => ReactNode;
|
||||
}[];
|
||||
model: DefaultModel;
|
||||
|
|
@ -44,7 +41,7 @@ export default function DetailsTable({
|
|||
const rawValue = model[accessorKey];
|
||||
|
||||
const renderValue = (): ReactNode => {
|
||||
if (rawValue === null || rawValue === undefined) {
|
||||
if (rawValue === null) {
|
||||
return (
|
||||
<span className="text-sm italic text-muted-foreground">
|
||||
{tableNotKnownTrans}
|
||||
|
|
@ -76,7 +73,7 @@ export default function DetailsTable({
|
|||
};
|
||||
|
||||
return (
|
||||
<TableRow key={String(accessorKey)}>
|
||||
<TableRow key={accessorKey}>
|
||||
<TableCell>{header}</TableCell>
|
||||
<TableCell>{renderValue()}</TableCell>
|
||||
</TableRow>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,32 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { ReactNode } from "react";
|
||||
// * Other
|
||||
import { AppEnv } from "@/types/global";
|
||||
import { TranslationField } from "@/back/types/i18n";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import { type TranslationField } from "@/back/types/i18n";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
const PREVIEW_LENGTH = 50;
|
||||
|
||||
/**
|
||||
* Get a normalize preview of a target string.
|
||||
*
|
||||
* @param value - Translated value
|
||||
* @return A string with limited length
|
||||
*/
|
||||
function normalizePreview(value: string): string {
|
||||
return str(value).normalize().value().substring(0, PREVIEW_LENGTH);
|
||||
return str(value).normalize().value().substring(0, 50);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the best translation value for the current locale.
|
||||
*
|
||||
* Priority:
|
||||
* 1. Value for the current app locale
|
||||
* 2. First non-empty available translation (fallback)
|
||||
*
|
||||
* @param value - Translation field containing localized values
|
||||
* @return An object with the resolved value and optional fallback locale,
|
||||
* or null if no translation is available
|
||||
*/
|
||||
function useGetTranslationValue(
|
||||
value?: TranslationField,
|
||||
): { value: string; locale?: string } | null {
|
||||
|
|
@ -23,7 +37,7 @@ function useGetTranslationValue(
|
|||
const local = value[appEnv.locale];
|
||||
if (local) return { value: local };
|
||||
|
||||
const fallback = Object.entries(value).find(([, v]) => v?.trim());
|
||||
const fallback = Object.entries(value).find(([, v]) => v.trim());
|
||||
if (!fallback) return null;
|
||||
|
||||
return { value: fallback[1], locale: fallback[0] };
|
||||
|
|
@ -39,13 +53,23 @@ function RenderValue({
|
|||
const preview = normalizePreview(value);
|
||||
|
||||
return renderHtml ? (
|
||||
// eslint-disable-next-line react/no-danger
|
||||
<p dangerouslySetInnerHTML={{ __html: preview }} />
|
||||
) : (
|
||||
preview
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a table cell displaying a translated value.
|
||||
*
|
||||
* - Displays the value directly if it matches the current locale
|
||||
* - Displays "locale: value" when a fallback translation is used
|
||||
* - Displays a "not known" message when no translation is available
|
||||
*
|
||||
* @param value - Translation field containing localized values
|
||||
* @param renderHtml - Render a html value or not (optional)
|
||||
* @return A ReactNode ready to be rendered inside a table cell
|
||||
*/
|
||||
export default function RenderTranslationCell({
|
||||
value,
|
||||
renderHtml = false,
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
// * Packages
|
||||
import { motion } from "motion/react";
|
||||
import { ReactNode, useEffect, useState } from "react";
|
||||
import { Head, usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { motion } from "motion/react";
|
||||
import { type ReactNode, useEffect, useState } from "react";
|
||||
|
||||
import AppFooter from "@/back/Components/Layout/AppFooter";
|
||||
import AppHeader from "@/back/Components/Layout/AppHeader";
|
||||
import AppSidebar from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { ThemeProvider } from "@/back/providers/ThemeProvider";
|
||||
import { SidebarProvider, useSidebar } from "@/components/ui/sidebar";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
// * Other
|
||||
import AppSidebar from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import AppHeader from "@/back/Components/Layout/AppHeader";
|
||||
import AppFooter from "@/back/Components/Layout/AppFooter";
|
||||
import { ThemeProvider } from "@/back/providers/ThemeProvider";
|
||||
|
||||
type AuthenticatedLayoutProps = {
|
||||
interface AuthenticatedLayoutProps {
|
||||
title: string;
|
||||
beforeNode?: ReactNode;
|
||||
afterNode?: ReactNode;
|
||||
children: ReactNode;
|
||||
};
|
||||
}
|
||||
|
||||
function LayoutContent({
|
||||
title,
|
||||
|
|
@ -26,7 +24,11 @@ function LayoutContent({
|
|||
children,
|
||||
}: Omit<AuthenticatedLayoutProps, "children"> & { children: ReactNode }) {
|
||||
const { open } = useSidebar();
|
||||
const [isSm, setIsSm] = useState(false);
|
||||
const [isSm, setIsSm] = useState<boolean>(() =>
|
||||
typeof window !== "undefined"
|
||||
? window.matchMedia("(max-width: 767px)").matches
|
||||
: false,
|
||||
);
|
||||
|
||||
let sidebarVar = "0px";
|
||||
if (!isSm) {
|
||||
|
|
@ -34,12 +36,14 @@ function LayoutContent({
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
const handler = (e: MediaQueryListEvent) => {
|
||||
setIsSm(e.matches);
|
||||
};
|
||||
const mediaQuery = window.matchMedia("(max-width: 767px)");
|
||||
setIsSm(mediaQuery.matches);
|
||||
|
||||
const handler = (e: MediaQueryListEvent) => setIsSm(e.matches);
|
||||
mediaQuery.addEventListener("change", handler);
|
||||
return () => mediaQuery.removeEventListener("change", handler);
|
||||
return () => {
|
||||
mediaQuery.removeEventListener("change", handler);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
@ -89,7 +93,7 @@ export default function AuthenticatedLayout({
|
|||
? localStorage.getItem("vite-ui-collapsed")
|
||||
: null;
|
||||
|
||||
const { locale } = usePage().props.appEnv as unknown as {
|
||||
const { locale } = usePage().props.appEnv as {
|
||||
locale: string;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,22 @@
|
|||
// * Packages
|
||||
import { ReactNode } from "react";
|
||||
// * Components shadcn
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
// * Other
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import ApplicationLogo from "@/back/Components/ApplicationLogo";
|
||||
import AppFooter from "@/back/Components/Layout/AppFooter";
|
||||
import AppSettings from "@/back/Components/Layout/Settings/AppSettings";
|
||||
import { ThemeProvider } from "@/back/providers/ThemeProvider";
|
||||
import AppFooter from "@/back/Components/Layout/AppFooter";
|
||||
import { Card } from "@/components/ui/card";
|
||||
|
||||
export default function GuestLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<ThemeProvider defaultTheme="light" storageKey="vite-ui-theme">
|
||||
<div className="flex flex-col min-h-screen">
|
||||
<div className="flex min-h-screen flex-col justify-center items-center px-8">
|
||||
<AppSettings className="container absolute top-0 start-1/2 transform -translate-x-1/2 text-right my-4" />
|
||||
<section className="flex flex-1 flex-col justify-center items-center pt-4">
|
||||
<section className="flex flex-1 flex-col justify-center items-center gap-y-6 pt-4">
|
||||
<ApplicationLogo />
|
||||
<Card className="text-center shadow-md sm:max-w-md sm:rounded-lg bg-secondary w-full mt-6">
|
||||
<Card className="text-center shadow-md sm:max-w-md sm:rounded-lg bg-secondary w-full">
|
||||
{children}
|
||||
</Card>
|
||||
</section>
|
||||
<Toaster />
|
||||
<AppFooter />
|
||||
</div>
|
||||
</ThemeProvider>
|
||||
|
|
|
|||
|
|
@ -1,33 +1,30 @@
|
|||
// * Packages
|
||||
import { FileTextIcon, UserIcon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Row } from "@tanstack/react-table";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
// * Other
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import DataTable from "@/back/Components/Table/DataTable";
|
||||
import DataTableSearch from "@/back/Components/Table/DataTableSearch";
|
||||
import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton";
|
||||
import { type Row } from "@tanstack/react-table";
|
||||
import { FileTextIcon, UserIcon } from "lucide-react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import { GetFormatedDate, GetTranslation } from "@/lib/utils";
|
||||
import DataTable from "@/back/Components/Table/DataTable";
|
||||
import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton";
|
||||
import DataTableSearch from "@/back/Components/Table/DataTableSearch";
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import { Views } from "@/back/lib/actions";
|
||||
import { ConfigBackend, Resource } from "@/back/types/global";
|
||||
import { ActivityLogModel } from "@/back/types/activity-logs";
|
||||
import { type ActivityLogModel } from "@/back/types/activity-logs";
|
||||
import { type ConfigBackend, type Resource } from "@/back/types/global";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetFormatedDate, GetTranslation } from "@/lib/utils";
|
||||
|
||||
type ActivityLogsEventEnumProps = Record<
|
||||
string,
|
||||
{ value: number; name: string; label: string; tailwindclass: string }
|
||||
>;
|
||||
|
||||
type ActivityLogsIndexProps = {
|
||||
interface ActivityLogsIndexProps {
|
||||
activitylogModels: Resource;
|
||||
searchFields: string;
|
||||
activityLogsEventEnum: ActivityLogsEventEnumProps;
|
||||
};
|
||||
}
|
||||
|
||||
const getColumns = (
|
||||
routeName: string,
|
||||
|
|
|
|||
|
|
@ -1,29 +1,38 @@
|
|||
// * Packages
|
||||
import { ArrowLeftIcon, UserIcon } from "lucide-react";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
// * Components shadcn
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
// * Other
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import DetailsTable from "@/back/Components/Table/DetailsTable";
|
||||
import ModelActions from "@/back/Components/ModelActions";
|
||||
import { ArrowLeftIcon, UserIcon } from "lucide-react";
|
||||
import { type ReactNode } from "react";
|
||||
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import { AuthProp, ConfigBackend, SingleResource } from "@/back/types/global";
|
||||
import { ActivityLogModel } from "@/back/types/activity-logs";
|
||||
import ModelActions from "@/back/Components/ModelActions";
|
||||
import DetailsTable from "@/back/Components/Table/DetailsTable";
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import { type ActivityLogModel } from "@/back/types/activity-logs";
|
||||
import {
|
||||
type DefaultModel,
|
||||
type AuthProp,
|
||||
type ConfigBackend,
|
||||
type SingleResource,
|
||||
} from "@/back/types/global";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { GetFormatedDate, GetTranslation } from "@/lib/utils";
|
||||
|
||||
interface DetailsTableColumn {
|
||||
accessorKey: keyof DefaultModel;
|
||||
header: string;
|
||||
cell?: (params: { value: unknown }) => ReactNode;
|
||||
}
|
||||
|
||||
type ActivityLogsEventEnumProps = Record<
|
||||
string,
|
||||
{ value: number; name: string; label: string; tailwindclass: string }
|
||||
>;
|
||||
|
||||
type ActivityLogsShowProps = {
|
||||
interface ActivityLogsShowProps {
|
||||
data: SingleResource;
|
||||
activityLogsEventEnum: ActivityLogsEventEnumProps;
|
||||
};
|
||||
}
|
||||
|
||||
const getColumns = (
|
||||
routeName: string,
|
||||
|
|
@ -149,7 +158,7 @@ const getColumns = (
|
|||
)
|
||||
.ucFirst()
|
||||
.value(),
|
||||
cell: ({ value }: { value: object }) => {
|
||||
cell: ({ value }: { value: object | null }) => {
|
||||
return value && Object.entries(value).length ? (
|
||||
<ul className="list-disc ps-4">
|
||||
{Object.entries(value).map(([val, text]) => {
|
||||
|
|
@ -225,13 +234,13 @@ export default function Show({
|
|||
>
|
||||
<ModelActions
|
||||
modelRoute={modelName}
|
||||
model={activityLogModel}
|
||||
model={activityLogModel as unknown as DefaultModel}
|
||||
modelUpdatedAt={activityLogModel.created_at.toString()}
|
||||
message={useTrans(`uwil-activity-logs::trans.get_data_message`)}
|
||||
/>
|
||||
<DetailsTable
|
||||
columns={columns}
|
||||
model={activityLogModel}
|
||||
columns={columns as unknown as DetailsTableColumn[]}
|
||||
model={activityLogModel as unknown as DefaultModel}
|
||||
forceRenderValue
|
||||
/>
|
||||
</AuthenticatedLayout>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
// * Packages.
|
||||
import { Head, Link, useForm, usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { LoaderCircleIcon, MoveLeftIcon, SendIcon } from "lucide-react";
|
||||
import { SubmitEvent } from "react";
|
||||
// * Components shadcn.
|
||||
import { type SubmitEvent } from "react";
|
||||
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import GuestLayout from "@/back/Layouts/GuestLayout";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
CardContent,
|
||||
|
|
@ -11,12 +12,8 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
// * Other.
|
||||
import GuestLayout from "@/back/Layouts/GuestLayout";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { toast } from "@/hooks/use-toast";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
export default function ForgotPassword() {
|
||||
const routeName = (usePage().props.configBackend as ConfigBackend).routes
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
// * Packages.
|
||||
import { Head, Link, useForm, usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { SubmitEvent } from "react";
|
||||
import { LoaderCircleIcon, LogInIcon, MoveRightIcon } from "lucide-react";
|
||||
// * Components shadcn.
|
||||
import { type SubmitEvent } from "react";
|
||||
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch";
|
||||
import GuestLayout from "@/back/Layouts/GuestLayout";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
CardContent,
|
||||
|
|
@ -11,14 +13,9 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
// * Other.
|
||||
import GuestLayout from "@/back/Layouts/GuestLayout";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { toast } from "@/hooks/use-toast";
|
||||
import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import { AppEnv } from "@/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { type AppEnv } from "@/types/global";
|
||||
|
||||
export default function Login() {
|
||||
const { appEnv, configBackend } = usePage().props as unknown as {
|
||||
|
|
@ -61,7 +58,7 @@ export default function Login() {
|
|||
<CardDescription
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: useTrans("auth.description", {
|
||||
params: { appName: String(appEnv.name) },
|
||||
params: { appName: appEnv.name },
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
// * Packages.
|
||||
import { SubmitEvent } from "react";
|
||||
import { Head, useForm, usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { LoaderCircleIcon, ShieldCheckIcon } from "lucide-react";
|
||||
// * Components shadcn.
|
||||
import { type SubmitEvent } from "react";
|
||||
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import GuestLayout from "@/back/Layouts/GuestLayout";
|
||||
import { type ConfigBackend } from "@/back/types/global";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
CardContent,
|
||||
|
|
@ -11,17 +12,13 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
// * Other.
|
||||
import GuestLayout from "@/back/Layouts/GuestLayout";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { toast } from "@/hooks/use-toast";
|
||||
import { ConfigBackend } from "@/back/types/global";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
||||
type ResetPasswordProps = {
|
||||
interface ResetPasswordProps {
|
||||
token: string;
|
||||
email: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ResetPassword({ token, email }: ResetPasswordProps) {
|
||||
const routeName = (usePage().props.configBackend as ConfigBackend).routes
|
||||
|
|
@ -82,7 +79,7 @@ export default function ResetPassword({ token, email }: ResetPasswordProps) {
|
|||
placeholder="ex: john.doe@ldc.fr"
|
||||
wordCounter={false}
|
||||
value={email}
|
||||
setData={() => {}}
|
||||
setData={() => void {}}
|
||||
disabled
|
||||
/>
|
||||
<SimpleString
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue