Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Update shadcn admin kit

François Zaninotto178034f41d60
diff --git a/package-lock.json b/package-lock.json
index 35b19563..1269afad 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -27,7 +27,7 @@
"@radix-ui/react-tabs": "^1.1.12",
"@radix-ui/react-tooltip": "^1.2.8",
"@tailwindcss/vite": "^4.1.11",
- "@tanstack/react-query": "^5.90.12",
+ "@tanstack/react-query": "^5.90.16",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
@@ -40,19 +40,19 @@
"next-themes": "^0.4.6",
"papaparse": "^5.5.3",
"query-string": "^7.1.3",
- "ra-core": "^5.13.3",
+ "ra-core": "^5.13.4",
"ra-data-fakerest": "^5.10.0",
- "ra-i18n-polyglot": "^5.13.3",
- "ra-language-english": "^5.13.3",
+ "ra-i18n-polyglot": "^5.13.4",
+ "ra-language-english": "^5.13.4",
"ra-supabase-core": "^3.5.2",
"ra-supabase-language-english": "^3.5.0",
"react": "^19.1.0",
"react-cropper": "^2.3.3",
"react-dom": "^19.1.0",
"react-dropzone": "^14.3.8",
- "react-error-boundary": "^6.0.0",
- "react-hook-form": "^7.68.0",
- "react-router": "^7.10.1",
+ "react-error-boundary": "^6.0.2",
+ "react-hook-form": "^7.70.0",
+ "react-router": "^7.12.0",
"rollup-plugin-visualizer": "^6.0.3",
"sonner": "^2.0.7",
"tailwind-merge": "^3.4.0",
@@ -170,7 +170,6 @@
"integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.27.1",
@@ -771,7 +770,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=12"
},
@@ -840,6 +838,7 @@
"os": [
"aix"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -857,6 +856,7 @@
"os": [
"android"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -874,6 +874,7 @@
"os": [
"android"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -891,6 +892,7 @@
"os": [
"android"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -908,6 +910,7 @@
"os": [
"darwin"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -925,6 +928,7 @@
"os": [
"darwin"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -942,6 +946,7 @@
"os": [
"freebsd"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -959,6 +964,7 @@
"os": [
"freebsd"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -976,6 +982,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -993,6 +1000,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1010,6 +1018,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1027,6 +1036,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1044,6 +1054,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1061,6 +1072,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1078,6 +1090,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1095,6 +1108,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1112,6 +1126,7 @@
"os": [
"linux"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1129,6 +1144,7 @@
"os": [
"netbsd"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1146,6 +1162,7 @@
"os": [
"netbsd"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1163,6 +1180,7 @@
"os": [
"openbsd"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1180,6 +1198,7 @@
"os": [
"openbsd"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1197,6 +1216,7 @@
"os": [
"openharmony"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1214,6 +1234,7 @@
"os": [
"sunos"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1231,6 +1252,7 @@
"os": [
"win32"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1248,6 +1270,7 @@
"os": [
"win32"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1265,6 +1288,7 @@
"os": [
"win32"
],
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -1833,6 +1857,7 @@
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
"license": "MIT",
"optional": true,
+ "peer": true,
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
"@jridgewell/trace-mapping": "^0.3.25"
@@ -2140,7 +2165,6 @@
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": "^14.21.3 || >=16"
},
@@ -3900,7 +3924,8 @@
"resolved": "https://registry.npmjs.org/@storybook/global/-/global-5.0.0.tgz",
"integrity": "sha512-FcOqPAXACP0I3oJ/ws6/rrPT9WGhu915Cg8D02a9YxLo0DE9zI+a9A5gRGvmQ09fiWPukqI8ZAEoQEdWUKMQdQ==",
"dev": true,
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/@supabase/auth-js": {
"version": "2.89.0",
@@ -4501,9 +4526,9 @@
}
},
"node_modules/@tanstack/query-core": {
- "version": "5.90.12",
- "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.90.12.tgz",
- "integrity": "sha512-T1/8t5DhV/SisWjDnaiU2drl6ySvsHj1bHBCWNXd+/T+Hh1cf6JodyEYMd5sgwm+b/mETT4EV3H+zCVczCU5hg==",
+ "version": "5.90.16",
+ "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.90.16.tgz",
+ "integrity": "sha512-MvtWckSVufs/ja463/K4PyJeqT+HMlJWtw6PrCpywznd2NSgO3m4KwO9RqbFqGg6iDE8vVMFWMeQI4Io3eEYww==",
"license": "MIT",
"funding": {
"type": "github",
@@ -4511,13 +4536,12 @@
}
},
"node_modules/@tanstack/react-query": {
- "version": "5.90.12",
- "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.12.tgz",
- "integrity": "sha512-graRZspg7EoEaw0a8faiUASCyJrqjKPdqJ9EwuDRUF9mEYJ1YPczI9H+/agJ0mOJkPCJDk0lsz5QTrLZ/jQ2rg==",
+ "version": "5.90.16",
+ "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.16.tgz",
+ "integrity": "sha512-bpMGOmV4OPmif7TNMteU/Ehf/hoC0Kf98PDc0F4BZkFrEapRMEqI/V6YS0lyzwSV6PQpY1y4xxArUIfBW5LVxQ==",
"license": "MIT",
- "peer": true,
"dependencies": {
- "@tanstack/query-core": "5.90.12"
+ "@tanstack/query-core": "5.90.16"
},
"funding": {
"type": "github",
@@ -4533,6 +4557,7 @@
"integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
@@ -4553,6 +4578,7 @@
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
"dev": true,
"license": "Apache-2.0",
+ "peer": true,
"dependencies": {
"dequal": "^2.0.3"
}
@@ -4562,7 +4588,8 @@
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
"dev": true,
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/@testing-library/jest-dom": {
"version": "6.8.0",
@@ -4590,6 +4617,7 @@
"integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==",
"dev": true,
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=12",
"npm": ">=6"
@@ -4631,7 +4659,8 @@
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
"dev": true,
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/@types/babel__core": {
"version": "7.20.5",
@@ -4826,7 +4855,6 @@
"integrity": "sha512-cMoR+FoAf/Jyq6+Df2/Z41jISvGZZ2eTlnsaJRptmZ76Caldwy1odD4xTr/gNV9VLj0AWgg/nmkevIyUfIIq5w==",
"devOptional": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"csstype": "^3.0.2"
}
@@ -4837,7 +4865,6 @@
"integrity": "sha512-qXRuZaOsAdXKFyOhRBg6Lqqc0yay13vN7KrIg4L7N4aaHN68ma9OK3NE1BoDFgFOTfM7zg+3/8+2n8rLUH3OKQ==",
"devOptional": true,
"license": "MIT",
- "peer": true,
"peerDependencies": {
"@types/react": "^19.0.0"
}
@@ -4910,7 +4937,6 @@
"integrity": "sha512-gTtSdWX9xiMPA/7MV9STjJOOYtWwIJIYxkQxnSV1U3xcE+mnJSH3f6zI0RYP+ew66WSlZ5ed+h0VCxsvdC1jJg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "8.41.0",
"@typescript-eslint/types": "8.41.0",
@@ -5292,7 +5318,6 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"devOptional": true,
"license": "MIT",
- "peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -5514,6 +5539,7 @@
"integrity": "sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"open": "^8.0.4"
},
@@ -5586,7 +5612,6 @@
}
],
"license": "MIT",
- "peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.8.19",
"caniuse-lite": "^1.0.30001751",
@@ -5606,7 +5631,8 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"license": "MIT",
- "optional": true
+ "optional": true,
+ "peer": true
},
"node_modules/bytes": {
"version": "3.1.2",
@@ -6558,6 +6584,7 @@
"integrity": "sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"debug": "^4.3.4"
},
@@ -6600,7 +6627,6 @@
"integrity": "sha512-RNCHRX5EwdrESy3Jc9o8ie8Bog+PeYvvSR8sDGoZxNFTvZ4dlxUB3WzQ3bQMztFrSRODGrLLj8g6OFuGY/aiQg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.12.1",
@@ -8538,6 +8564,7 @@
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"bin": {
"lz-string": "bin/bin.js"
}
@@ -9508,7 +9535,6 @@
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
@@ -9525,6 +9551,7 @@
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
@@ -9540,6 +9567,7 @@
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
"dev": true,
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=10"
},
@@ -9552,7 +9580,8 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true,
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/pretty-ms": {
"version": "9.3.0",
@@ -9690,11 +9719,10 @@
"license": "MIT"
},
"node_modules/ra-core": {
- "version": "5.13.3",
- "resolved": "https://registry.npmjs.org/ra-core/-/ra-core-5.13.3.tgz",
- "integrity": "sha512-EAUIK/PVDTvUv/ZM0uZFrSFBbE7iwGFrPwyGvPrIrqvbvpyYgxzE9AeP9kf3twDM0Ks9RQCIA5zGGraRwH199w==",
+ "version": "5.13.4",
+ "resolved": "https://registry.npmjs.org/ra-core/-/ra-core-5.13.4.tgz",
+ "integrity": "sha512-f8tcZOi6og8VKRbbuictj9+gYzXWE+f4fI7m6hqhLrNHSkVcyqK8/A/Vs/feY16W9R1oMWWW0a0SCrZSdPqfcg==",
"license": "MIT",
- "peer": true,
"dependencies": {
"date-fns": "^3.6.0",
"eventemitter3": "^5.0.1",
@@ -9739,22 +9767,22 @@
}
},
"node_modules/ra-i18n-polyglot": {
- "version": "5.13.3",
- "resolved": "https://registry.npmjs.org/ra-i18n-polyglot/-/ra-i18n-polyglot-5.13.3.tgz",
- "integrity": "sha512-qNKckbYJVmlbBX7P/tOYVQ+SPsDAs4SexGPS5BrEb2JvfWHvT9uUWokyauSLJJLIcorZOpsLwKGxTIkcDIAvFA==",
+ "version": "5.13.4",
+ "resolved": "https://registry.npmjs.org/ra-i18n-polyglot/-/ra-i18n-polyglot-5.13.4.tgz",
+ "integrity": "sha512-ICylRO2/u81xSJH3N4UCqvL4ZIu2jB6vI0XLMhROGEKuzts64IcJJj4j+kLwNdYrdQhAhgB/8BvW/skJ5fJifQ==",
"license": "MIT",
"dependencies": {
"node-polyglot": "^2.2.2",
- "ra-core": "^5.13.3"
+ "ra-core": "^5.13.4"
}
},
"node_modules/ra-language-english": {
- "version": "5.13.3",
- "resolved": "https://registry.npmjs.org/ra-language-english/-/ra-language-english-5.13.3.tgz",
- "integrity": "sha512-50YQfBsPzs7O8rpAd8U0H1g1ZP1H4c0RrRSjlbK1/7Y/bfqLVQEh2Edy7HjHYbc/nQfdaGjVTqG6RzhtWYk8iQ==",
+ "version": "5.13.4",
+ "resolved": "https://registry.npmjs.org/ra-language-english/-/ra-language-english-5.13.4.tgz",
+ "integrity": "sha512-19LmkWFsr1HpiF1Am/vkRUf+h/nwiwS89F04AmJQbCRjm3Gn97/fbv10xW0zwYDSVmiLIrbmuktZ1zO5j068fg==",
"license": "MIT",
"dependencies": {
- "ra-core": "^5.13.3"
+ "ra-core": "^5.13.4"
}
},
"node_modules/ra-supabase-core": {
@@ -9831,7 +9859,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz",
"integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==",
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=0.10.0"
}
@@ -9853,7 +9880,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz",
"integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==",
"license": "MIT",
- "peer": true,
"dependencies": {
"scheduler": "^0.26.0"
},
@@ -9879,23 +9905,20 @@
}
},
"node_modules/react-error-boundary": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-6.0.0.tgz",
- "integrity": "sha512-gdlJjD7NWr0IfkPlaREN2d9uUZUlksrfOx7SX62VRerwXbMY6ftGCIZua1VG1aXFNOimhISsTq+Owp725b9SiA==",
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-6.0.2.tgz",
+ "integrity": "sha512-yvWErn55ag/ywZEFqYpXYX9rxIDPIabXIX25F184KY3F5Szk2x/cVieOflw5R47ltN3KzWOw82Lmlb4vNjyn9A==",
"license": "MIT",
- "dependencies": {
- "@babel/runtime": "^7.12.5"
- },
"peerDependencies": {
- "react": ">=16.13.1"
+ "react": "^18.0.0 || ^19.0.0",
+ "react-dom": "^18.0.0 || ^19.0.0"
}
},
"node_modules/react-hook-form": {
- "version": "7.68.0",
- "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.68.0.tgz",
- "integrity": "sha512-oNN3fjrZ/Xo40SWlHf1yCjlMK417JxoSJVUXQjGdvdRCU07NTFei1i1f8ApUAts+IVh14e4EdakeLEA+BEAs/Q==",
+ "version": "7.70.0",
+ "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.70.0.tgz",
+ "integrity": "sha512-COOMajS4FI3Wuwrs3GPpi/Jeef/5W1DRR84Yl5/ShlT3dKVFUfoGiEZ/QE6Uw8P4T2/CLJdcTVYKvWBMQTEpvw==",
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=18.0.0"
},
@@ -9994,11 +10017,10 @@
}
},
"node_modules/react-router": {
- "version": "7.10.1",
- "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.10.1.tgz",
- "integrity": "sha512-gHL89dRa3kwlUYtRQ+m8NmxGI6CgqN+k4XyGjwcFoQwwCWF6xXpOCUlDovkXClS0d0XJN/5q7kc5W3kiFEd0Yw==",
+ "version": "7.12.0",
+ "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.12.0.tgz",
+ "integrity": "sha512-kTPDYPFzDVGIIGNLS5VJykK0HfHLY5MF3b+xj0/tTyNYL1gF1qs7u67Z9jEhQk2sQ98SUaHxlG31g1JtF7IfVw==",
"license": "MIT",
- "peer": true,
"dependencies": {
"cookie": "^1.0.1",
"set-cookie-parser": "^2.6.0"
@@ -10017,13 +10039,13 @@
}
},
"node_modules/react-router-dom": {
- "version": "7.10.1",
- "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.10.1.tgz",
- "integrity": "sha512-JNBANI6ChGVjA5bwsUIwJk7LHKmqB4JYnYfzFwyp2t12Izva11elds2jx7Yfoup2zssedntwU0oZ5DEmk5Sdaw==",
+ "version": "7.12.0",
+ "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.12.0.tgz",
+ "integrity": "sha512-pfO9fiBcpEfX4Tx+iTYKDtPbrSLLCbwJ5EqP+SPYQu1VYCXdy79GSj0wttR0U4cikVdlImZuEZ/9ZNCgoaxwBA==",
"license": "MIT",
"peer": true,
"dependencies": {
- "react-router": "7.10.1"
+ "react-router": "7.12.0"
},
"engines": {
"node": ">=20.0.0"
@@ -10100,8 +10122,7 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/require-directory": {
"version": "2.1.1",
@@ -10172,7 +10193,6 @@
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.50.0.tgz",
"integrity": "sha512-/Zl4D8zPifNmyGzJS+3kVoyXeDeT/GrsJM94sACNg9RtUE0hrHa1bNPtRSrfHTMH5HjRzce6K7rlTh3Khiw+pw==",
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/estree": "1.0.8"
},
@@ -10643,6 +10663,7 @@
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"license": "MIT",
"optional": true,
+ "peer": true,
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
@@ -10700,6 +10721,7 @@
"integrity": "sha512-kfr6kxQAjA96ADlH6FMALJwJ+eM80UqXy106yVHNgdsAP/CdzkkicglRAhZAvUycXK9AeadF6KZ00CWLtVMN4w==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@storybook/global": "^5.0.0",
"@testing-library/jest-dom": "^6.6.3",
@@ -10736,6 +10758,7 @@
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"dev": true,
"license": "ISC",
+ "peer": true,
"bin": {
"semver": "bin/semver.js"
},
@@ -10998,6 +11021,7 @@
"integrity": "sha512-nIVck8DK+GM/0Frwd+nIhZ84pR/BX7rmXMfYwyg+Sri5oGVE99/E3KvXqpC2xHFxyqXyGHTKBSioxxplrO4I4w==",
"license": "BSD-2-Clause",
"optional": true,
+ "peer": true,
"dependencies": {
"@jridgewell/source-map": "^0.3.3",
"acorn": "^8.15.0",
@@ -11016,7 +11040,8 @@
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"license": "MIT",
- "optional": true
+ "optional": true,
+ "peer": true
},
"node_modules/tiny-invariant": {
"version": "1.3.3",
@@ -11076,7 +11101,6 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=12"
},
@@ -11294,7 +11318,6 @@
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"dev": true,
"license": "Apache-2.0",
- "peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -11509,7 +11532,6 @@
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz",
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
"license": "MIT",
- "peer": true,
"dependencies": {
"esbuild": "^0.27.0",
"fdir": "^6.5.0",
@@ -12097,7 +12119,6 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=12"
},
@@ -12404,7 +12425,6 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
"license": "MIT",
- "peer": true,
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
diff --git a/package.json b/package.json
index ebef19fe..e1cd71c9 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,7 @@
"@radix-ui/react-tabs": "^1.1.12",
"@radix-ui/react-tooltip": "^1.2.8",
"@tailwindcss/vite": "^4.1.11",
- "@tanstack/react-query": "^5.90.12",
+ "@tanstack/react-query": "^5.90.16",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
@@ -53,19 +53,19 @@
"next-themes": "^0.4.6",
"papaparse": "^5.5.3",
"query-string": "^7.1.3",
- "ra-core": "^5.13.3",
+ "ra-core": "^5.13.4",
"ra-data-fakerest": "^5.10.0",
- "ra-i18n-polyglot": "^5.13.3",
- "ra-language-english": "^5.13.3",
+ "ra-i18n-polyglot": "^5.13.4",
+ "ra-language-english": "^5.13.4",
"ra-supabase-core": "^3.5.2",
"ra-supabase-language-english": "^3.5.0",
"react": "^19.1.0",
"react-cropper": "^2.3.3",
"react-dom": "^19.1.0",
"react-dropzone": "^14.3.8",
- "react-error-boundary": "^6.0.0",
- "react-hook-form": "^7.68.0",
- "react-router": "^7.10.1",
+ "react-error-boundary": "^6.0.2",
+ "react-hook-form": "^7.70.0",
+ "react-router": "^7.12.0",
"rollup-plugin-visualizer": "^6.0.3",
"sonner": "^2.0.7",
"tailwind-merge": "^3.4.0",
diff --git a/src/components/admin/array-input.tsx b/src/components/admin/array-input.tsx
index f3328dfc..4e485533 100644
--- a/src/components/admin/array-input.tsx
+++ b/src/components/admin/array-input.tsx
@@ -1,21 +1,12 @@
+import * as React from "react";
+import type { InputProps } from "ra-core";
import {
FieldTitle,
- OptionalResourceContextProvider,
- SourceContextProvider,
- composeSyncValidators,
isRequired,
- useApplyInputDefaultValues,
- useFormGroupContext,
- useFormGroups,
- useGetValidationErrorMessage,
useSourceContext,
sanitizeInputRestProps,
- ArrayInputContext,
+ ArrayInputBase,
} from "ra-core";
-import type { InputProps, SourceContextValue } from "ra-core";
-import * as React from "react";
-import { useEffect } from "react";
-import { useFieldArray, useFormContext } from "react-hook-form";
import { Label } from "@/components/ui/label";
import { cn } from "@/lib/utils";
@@ -72,88 +63,9 @@ export const ArrayInput = (props: ArrayInputProps) => {
...rest
} = props;
- const formGroupName = useFormGroupContext();
- const formGroups = useFormGroups();
const parentSourceContext = useSourceContext();
const finalSource = parentSourceContext.getSource(arraySource);
- const sanitizedValidate = Array.isArray(validate)
- ? composeSyncValidators(validate)
- : validate;
- const getValidationErrorMessage = useGetValidationErrorMessage();
-
- const { getValues } = useFormContext();
-
- const fieldProps = useFieldArray({
- name: finalSource,
- rules: {
- validate: async (value) => {
- if (!sanitizedValidate) return true;
- const error = await sanitizedValidate(value, getValues(), props);
-
- if (!error) return true;
- return getValidationErrorMessage(error);
- },
- },
- });
-
- useEffect(() => {
- if (formGroups && formGroupName != null) {
- formGroups.registerField(finalSource, formGroupName);
- }
-
- return () => {
- if (formGroups && formGroupName != null) {
- formGroups.unregisterField(finalSource, formGroupName);
- }
- };
- }, [finalSource, formGroups, formGroupName]);
-
- useApplyInputDefaultValues({
- inputProps: { ...props, defaultValue },
- isArrayInput: true,
- fieldArrayInputControl: fieldProps,
- });
-
- // The SourceContext will be read by children of ArrayInput to compute their composed source and label
- //
- // <ArrayInput source="orders" /> => SourceContext is "orders"
- // <SimpleFormIterator> => SourceContext is "orders.0"
- // <DateInput source="date" /> => final source for this input will be "orders.0.date"
- // </SimpleFormIterator>
- // </ArrayInput>
- //
- const sourceContext = React.useMemo<SourceContextValue>(
- () => ({
- // source is the source of the ArrayInput child
- getSource: (source: string) => {
- if (!source) {
- // SimpleFormIterator calls getSource('') to get the arraySource
- return parentSourceContext.getSource(arraySource);
- }
-
- // We want to support nesting and composition with other inputs (e.g. TranslatableInputs, ReferenceOneInput, etc),
- // we must also take into account the parent SourceContext
- //
- // <ArrayInput source="orders" /> => SourceContext is "orders"
- // <SimpleFormIterator> => SourceContext is "orders.0"
- // <DateInput source="date" /> => final source for this input will be "orders.0.date"
- // <ArrayInput source="items" /> => SourceContext is "orders.0.items"
- // <SimpleFormIterator> => SourceContext is "orders.0.items.0"
- // <TextInput source="reference" /> => final source for this input will be "orders.0.items.0.reference"
- // </SimpleFormIterator>
- // </ArrayInput>
- // </SimpleFormIterator>
- // </ArrayInput>
- return parentSourceContext.getSource(`${arraySource}.${source}`);
- },
- // if Array source is items, and child source is name, .0.name => resources.orders.fields.items.name
- getLabel: (source: string) =>
- parentSourceContext.getLabel(`${arraySource}.${source}`),
- }),
- [parentSourceContext, arraySource],
- );
-
if (isPending) {
return <Skeleton className="w-full h-9" />;
}
@@ -177,13 +89,9 @@ export const ArrayInput = (props: ArrayInputProps) => {
isRequired={isRequired(validate)}
/>
</Label>
- <ArrayInputContext.Provider value={fieldProps}>
- <OptionalResourceContextProvider value={resourceFromProps}>
- <SourceContextProvider value={sourceContext}>
- {children}
- </SourceContextProvider>
- </OptionalResourceContextProvider>
- </ArrayInputContext.Provider>
+ <ArrayInputBase {...props} defaultValue={defaultValue}>
+ {children}
+ </ArrayInputBase>
<InputHelperText helperText={helperText} />
<FormError />
diff --git a/src/components/admin/list-pagination.tsx b/src/components/admin/list-pagination.tsx
index 845c5671..cbf90f79 100644
--- a/src/components/admin/list-pagination.tsx
+++ b/src/components/admin/list-pagination.tsx
@@ -120,7 +120,7 @@ export const ListPagination = ({
setPerPage(Number(value));
}}
>
- <SelectTrigger className="h-8 w-[70px]">
+ <SelectTrigger className="h-8 w-fit">
<SelectValue placeholder={perPage} />
</SelectTrigger>
<SelectContent side="top">
@@ -149,19 +149,27 @@ export const ListPagination = ({
<Pagination className="-w-full -mx-auto">
<PaginationContent>
<PaginationItem>
- <PaginationLink
- href="#"
- onClick={pageChangeHandler(page - 1)}
- className={cn(
- "gap-1 px-2.5 sm:pr-2.5",
- !hasPreviousPage ? "opacity-50 cursor-not-allowed" : "",
- )}
- aria-label={translate("ra.navigation.previous", {
- _: "Previous",
- })}
- >
- <ChevronLeftIcon />
- </PaginationLink>
+ {hasPreviousPage ? (
+ <PaginationLink
+ href="#"
+ onClick={pageChangeHandler(page - 1)}
+ aria-label={translate("ra.navigation.previous", {
+ _: "Previous",
+ })}
+ >
+ <ChevronLeftIcon />
+ </PaginationLink>
+ ) : (
+ <span className="inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium size-9">
+ <ChevronLeftIcon
+ aria-label={translate("ra.navigation.previous", {
+ _: "Previous",
+ })}
+ size="16"
+ className="text-muted-foreground"
+ />
+ </span>
+ )}
</PaginationItem>
{startPages.map((pageNumber) => (
<PaginationItem key={pageNumber}>
@@ -227,18 +235,28 @@ export const ListPagination = ({
</PaginationItem>
))}
<PaginationItem>
- <PaginationLink
- href="#"
- onClick={pageChangeHandler(page + 1)}
- size="default"
- className={cn(
- "gap-1 px-2.5 sm:pr-2.5",
- !hasNextPage ? "opacity-50 cursor-not-allowed" : "",
- )}
- aria-label={translate("ra.navigation.next", { _: "Next" })}
- >
- <ChevronRightIcon />
- </PaginationLink>
+ {hasNextPage ? (
+ <PaginationLink
+ href="#"
+ onClick={pageChangeHandler(page + 1)}
+ size="default"
+ className={cn(
+ "gap-1 px-2.5 sm:pr-2.5",
+ !hasNextPage ? "opacity-50 cursor-not-allowed" : "",
+ )}
+ aria-label={translate("ra.navigation.next", { _: "Next" })}
+ >
+ <ChevronRightIcon />
+ </PaginationLink>
+ ) : (
+ <span className="inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium size-9">
+ <ChevronRightIcon
+ aria-label={translate("ra.navigation.next", { _: "Next" })}
+ size="16"
+ className="text-muted-foreground"
+ />
+ </span>
+ )}
</PaginationItem>
</PaginationContent>
</Pagination>
diff --git a/src/components/admin/notification.tsx b/src/components/admin/notification.tsx
index caae37fe..81e12835 100644
--- a/src/components/admin/notification.tsx
+++ b/src/components/admin/notification.tsx
@@ -55,9 +55,10 @@ export const Notification = (props: ToasterProps) => {
window.addEventListener("beforeunload", beforeunload);
}
+ const mutation = takeMutation();
+
const handleExited = () => {
if (undoable) {
- const mutation = takeMutation();
if (mutation) {
mutation({ isUndo: false });
}
@@ -66,7 +67,6 @@ export const Notification = (props: ToasterProps) => {
};
const handleUndo = () => {
- const mutation = takeMutation();
if (mutation) {
mutation({ isUndo: true });
}
diff --git a/src/components/admin/simple-form-iterator.tsx b/src/components/admin/simple-form-iterator.tsx
index 4500fd51..230f6708 100644
--- a/src/components/admin/simple-form-iterator.tsx
+++ b/src/components/admin/simple-form-iterator.tsx
@@ -1,29 +1,27 @@
import get from "lodash/get";
import * as React from "react";
-import type { ReactElement, ReactNode } from "react";
-import { Children, useCallback, useMemo, useRef, useState } from "react";
+import type { ReactElement } from "react";
+import { useState } from "react";
import type {
- ArrayInputContextValue,
RaRecord,
- SimpleFormIteratorItemContextValue,
+ SimpleFormIteratorDisableRemoveFunction,
+ SimpleFormIteratorItemBaseProps,
} from "ra-core";
import {
- FormDataConsumer,
RecordContextProvider,
- SimpleFormIteratorContext,
- SimpleFormIteratorItemContext,
- SourceContextProvider,
+ SimpleFormIteratorBase,
+ SimpleFormIteratorItemBase,
useArrayInput,
+ useEvent,
+ useGetArrayInputNewItemDefaults,
useRecordContext,
useResourceContext,
useSimpleFormIterator,
useSimpleFormIteratorItem,
- useSourceContext,
useTranslate,
useWrappedSource,
} from "ra-core";
import type { UseFieldArrayReturn } from "react-hook-form";
-import { useFormContext } from "react-hook-form";
import {
ArrowDownCircle,
ArrowUpCircle,
@@ -88,154 +86,53 @@ export const SimpleFormIterator = (props: SimpleFormIteratorProps) => {
);
}
- const [confirmIsOpen, setConfirmIsOpen] = useState<boolean>(false);
- const { append, fields, move, remove, replace } = useArrayInput(props);
- const { trigger, getValues } = useFormContext();
- const translate = useTranslate();
+ const { fields } = useArrayInput(props);
const record = useRecordContext(props);
- const initialDefaultValue = useRef({});
-
- const removeField = useCallback(
- (index: number) => {
- remove(index);
- const isScalarArray = getValues(finalSource).every(
- (value: any) => typeof value !== "object",
- );
- if (isScalarArray) {
- // Trigger validation on the Array to avoid ghost errors.
- // Otherwise, validation errors on removed fields might still be displayed
- trigger(finalSource);
- }
- },
- [remove, trigger, finalSource, getValues],
- );
-
- if (fields.length > 0) {
- const { id: _id, ...rest } = fields[0];
- initialDefaultValue.current = rest;
- for (const k in initialDefaultValue.current) {
- // @ts-expect-error: reset fields
- initialDefaultValue.current[k] = null;
- }
- }
-
- const addField = useCallback(
- (item: any = undefined) => {
- let defaultValue = item;
- if (item == null) {
- defaultValue = initialDefaultValue.current;
- if (
- Children.count(children) === 1 &&
- React.isValidElement(Children.only(children)) &&
- // @ts-expect-error: Check if the child has a source prop
- !Children.only(children).props.source &&
- // Make sure it's not a FormDataConsumer
- // @ts-expect-error: Check if the child is a FormDataConsumer
- Children.only(children).type !== FormDataConsumer
- ) {
- // ArrayInput used for an array of scalar values
- // (e.g. tags: ['foo', 'bar'])
- defaultValue = "";
- } else {
- // ArrayInput used for an array of objects
- // (e.g. authors: [{ firstName: 'John', lastName: 'Doe' }, { firstName: 'Jane', lastName: 'Doe' }])
- defaultValue = defaultValue || ({} as Record<string, unknown>);
- Children.forEach(children, (input) => {
- if (
- React.isValidElement(input) &&
- input.type !== FormDataConsumer &&
- // @ts-expect-error: Check if the child has a source prop
- input.props.source
- ) {
- // @ts-expect-error: Check if the child has a source prop
- defaultValue[input.props.source] =
- // @ts-expect-error: Check if the child has a source prop
- input.props.defaultValue ?? null;
- }
- });
- }
- }
- append(defaultValue);
- },
- [append, children],
- );
-
- const handleReorder = useCallback(
- (origin: number, destination: number) => {
- move(origin, destination);
- },
- [move],
- );
-
- const handleArrayClear = useCallback(() => {
- replace([]);
- setConfirmIsOpen(false);
- }, [replace]);
const records = get(record, finalSource);
+ const getArrayInputNewItemDefaults = useGetArrayInputNewItemDefaults(fields);
+
+ const getItemDefaults = useEvent((item: any = undefined) => {
+ if (item != null) return item;
+ return getArrayInputNewItemDefaults(children);
+ });
- const context = useMemo(
- () => ({
- total: fields.length,
- add: addField,
- remove: removeField,
- clear: handleArrayClear,
- reOrder: handleReorder,
- source: finalSource,
- }),
- [
- fields.length,
- addField,
- removeField,
- handleArrayClear,
- handleReorder,
- finalSource,
- ],
- );
return fields ? (
- <SimpleFormIteratorContext.Provider value={context}>
+ <SimpleFormIteratorBase getItemDefaults={getItemDefaults} {...props}>
<div className={cn("w-full", disabled && "disabled", className)}>
<ul className="p-0 m-0 flex flex-col gap-2">
{fields.map((member, index) => (
- <SimpleFormIteratorItem
+ <RecordContextProvider
key={member.id}
- disabled={disabled}
- disableRemove={disableRemove}
- disableReordering={disableReordering}
- fields={fields}
- getItemLabel={getItemLabel}
- index={index}
- onRemoveField={removeField}
- onReorder={handleReorder}
- record={(records && records[index]) || {}}
- removeButton={removeButton}
- reOrderButtons={reOrderButtons}
- resource={resource}
- inline={inline}
+ value={(records && records[index]) || {}}
>
- {children}
- </SimpleFormIteratorItem>
+ <SimpleFormIteratorItem
+ disabled={disabled}
+ disableRemove={disableRemove}
+ disableReordering={disableReordering}
+ fields={fields}
+ getItemLabel={getItemLabel}
+ index={index}
+ removeButton={removeButton}
+ reOrderButtons={reOrderButtons}
+ resource={resource}
+ inline={inline}
+ >
+ {children}
+ </SimpleFormIteratorItem>
+ </RecordContextProvider>
))}
</ul>
{!disabled && !(disableAdd && (disableClear || disableRemove)) && (
<div className="flex flex-row items-center gap-2">
{!disableAdd && addButton}
{fields.length > 0 && !disableClear && !disableRemove && (
- <>
- <Confirm
- isOpen={confirmIsOpen}
- title={translate("ra.action.clear_array_input")}
- content={translate("ra.message.clear_array_input")}
- onConfirm={handleArrayClear}
- onClose={() => setConfirmIsOpen(false)}
- />
- <ClearArrayButton onClick={() => setConfirmIsOpen(true)} />
- </>
+ <SimpleFormIteratorClearButton />
)}
</div>
)}
</div>
- </SimpleFormIteratorContext.Provider>
+ </SimpleFormIteratorBase>
) : null;
};
@@ -247,7 +144,7 @@ export interface SimpleFormIteratorProps extends Partial<UseFieldArrayReturn> {
disabled?: boolean;
disableAdd?: boolean;
disableClear?: boolean;
- disableRemove?: boolean | DisableRemoveFunction;
+ disableRemove?: boolean | SimpleFormIteratorDisableRemoveFunction;
disableReordering?: boolean;
fullWidth?: boolean;
getItemLabel?: boolean | GetItemLabelFunc;
@@ -288,7 +185,6 @@ export const SimpleFormIteratorItem = React.forwardRef(
getItemLabel,
index,
inline,
- record,
removeButton = defaultRemoveItemButton,
reOrderButtons = defaultReOrderButtons,
} = props;
@@ -298,7 +194,12 @@ export const SimpleFormIteratorItem = React.forwardRef(
"SimpleFormIteratorItem must be used in a ResourceContextProvider or be passed a resource prop.",
);
}
- const { total, reOrder, remove } = useSimpleFormIterator();
+ const record = useRecordContext(props);
+ if (!record) {
+ throw new Error(
+ "SimpleFormIteratorItem must be used in a RecordContextProvider.",
+ );
+ }
// Returns a boolean to indicate whether to disable the remove button for certain fields.
// If disableRemove is a function, then call the function with the current record to
// determining if the button should be disabled. Otherwise, use a boolean property that
@@ -310,57 +211,11 @@ export const SimpleFormIteratorItem = React.forwardRef(
return disableRemove && disableRemove(record);
};
- const context = useMemo<SimpleFormIteratorItemContextValue>(
- () => ({
- index,
- total,
- reOrder: (newIndex) => reOrder(index, newIndex),
- remove: () => remove(index),
- }),
- [index, total, reOrder, remove],
- );
-
const label =
typeof getItemLabel === "function" ? getItemLabel(index) : getItemLabel;
- const parentSourceContext = useSourceContext();
- const sourceContext = useMemo(
- () => ({
- getSource: (source: string) => {
- if (!source) {
- // source can be empty for scalar values, e.g.
- // <ArrayInput source="tags" /> => SourceContext is "tags"
- // <SimpleFormIterator> => SourceContext is "tags.0"
- // <TextInput /> => use its parent's getSource so finalSource = "tags.0"
- // </SimpleFormIterator>
- // </ArrayInput>
- return parentSourceContext.getSource(`${index}`);
- } else {
- // Normal input with source, e.g.
- // <ArrayInput source="orders" /> => SourceContext is "orders"
- // <SimpleFormIterator> => SourceContext is "orders.0"
- // <DateInput source="date" /> => use its parent's getSource so finalSource = "orders.0.date"
- // </SimpleFormIterator>
- // </ArrayInput>
- return parentSourceContext.getSource(`${index}.${source}`);
- }
- },
- getLabel: (source: string) => {
- // <ArrayInput source="orders" /> => LabelContext is "orders"
- // <SimpleFormIterator> => LabelContext is ALSO "orders"
- // <DateInput source="date" /> => use its parent's getLabel so finalLabel = "orders.date"
- // </SimpleFormIterator>
- // </ArrayInput>
- //
- // we don't prefix with the index to avoid that translation keys contain it
- return parentSourceContext.getLabel(source);
- },
- }),
- [index, parentSourceContext],
- );
-
return (
- <SimpleFormIteratorItemContext.Provider value={context}>
+ <SimpleFormIteratorItemBase {...props}>
<li
ref={ref}
className={cn(
@@ -372,18 +227,14 @@ export const SimpleFormIteratorItem = React.forwardRef(
{label != null && label !== false && (
<p className="text-sm text-muted-foreground mb-2">{label}</p>
)}
- <SourceContextProvider value={sourceContext}>
- <RecordContextProvider value={record}>
- <div
- className={cn(
- "flex flex-1 gap-2",
- inline ? "flex-col sm:flex-row gap-2" : "flex-col",
- )}
- >
- {children}
- </div>
- </RecordContextProvider>
- </SourceContextProvider>
+ <div
+ className={cn(
+ "flex flex-1 gap-2",
+ inline ? "flex-col sm:flex-row gap-2" : "flex-col",
+ )}
+ >
+ {children}
+ </div>
{!disabled && (
<div className="simple-form-iterator-item-actions flex flex-row h-9 items-center gap-1">
{!disableReordering && reOrderButtons}
@@ -391,29 +242,21 @@ export const SimpleFormIteratorItem = React.forwardRef(
</div>
)}
</li>
- </SimpleFormIteratorItemContext.Provider>
+ </SimpleFormIteratorItemBase>
);
},
);
-export type DisableRemoveFunction = (record: RaRecord) => boolean;
-
-export type SimpleFormIteratorItemProps = Partial<ArrayInputContextValue> & {
- children?: ReactNode;
+export interface SimpleFormIteratorItemProps
+ extends SimpleFormIteratorItemBaseProps {
disabled?: boolean;
- disableRemove?: boolean | DisableRemoveFunction;
+ disableRemove?: boolean | SimpleFormIteratorDisableRemoveFunction;
disableReordering?: boolean;
getItemLabel?: boolean | GetItemLabelFunc;
- index: number;
inline?: boolean;
- onRemoveField: (index: number) => void;
- onReorder: (origin: number, destination: number) => void;
- record: RaRecord;
removeButton?: ReactElement;
reOrderButtons?: ReactElement;
- resource?: string;
- source?: string;
-};
+}
/**
* A button to add new items to a SimpleFormIterator.
@@ -502,6 +345,47 @@ export const ReOrderButtons = ({ className }: { className?: string }) => {
);
};
+export const SimpleFormIteratorClearButton = ({
+ className,
+ disableClear,
+ disableRemove,
+}: SimpleFormIteratorClearButtonProp) => {
+ const translate = useTranslate();
+ const [confirmIsOpen, setConfirmIsOpen] = useState<boolean>(false);
+ const { clear, total } = useSimpleFormIterator();
+
+ const handleArrayClear = useEvent(() => {
+ clear();
+ setConfirmIsOpen(false);
+ });
+
+ if (total === 0 || disableClear === true || disableRemove === true) {
+ return null;
+ }
+
+ return (
+ <>
+ <Confirm
+ isOpen={confirmIsOpen}
+ title={translate("ra.action.clear_array_input")}
+ content={translate("ra.message.clear_array_input")}
+ onConfirm={handleArrayClear}
+ onClose={() => setConfirmIsOpen(false)}
+ />
+ <ClearArrayButton
+ className={className}
+ onClick={() => setConfirmIsOpen(true)}
+ />
+ </>
+ );
+};
+
+export interface SimpleFormIteratorClearButtonProp {
+ className?: string;
+ disableClear?: boolean;
+ disableRemove?: boolean | SimpleFormIteratorDisableRemoveFunction;
+}
+
/**
* A button to clear all items from a SimpleFormIterator.
*