@nestledjs/data-browser 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -447,7 +447,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
447
447
|
"button",
|
|
448
448
|
{
|
|
449
449
|
onClick: () => setShowColumnSelector(!showColumnSelector),
|
|
450
|
-
className: "inline-flex items-center px-3 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
450
|
+
className: "inline-flex items-center px-3 py-2 border border-gray-300 dark:border-gray-600 text-sm font-medium rounded-md text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
451
451
|
children: [
|
|
452
452
|
"Columns",
|
|
453
453
|
/* @__PURE__ */ jsx(
|
|
@@ -470,8 +470,8 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
470
470
|
]
|
|
471
471
|
}
|
|
472
472
|
),
|
|
473
|
-
showColumnSelector && /* @__PURE__ */ jsx("div", { className: "absolute right-0 mt-2 w-80 bg-white rounded-md shadow-lg z-50 border border-gray-200", children: /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
474
|
-
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 mb-3", children: "Visible Columns" }),
|
|
473
|
+
showColumnSelector && /* @__PURE__ */ jsx("div", { className: "absolute right-0 mt-2 w-80 bg-white dark:bg-gray-800 rounded-md shadow-lg z-50 border border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
474
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 dark:text-gray-100 mb-3", children: "Visible Columns" }),
|
|
475
475
|
/* @__PURE__ */ jsx("div", { className: "space-y-2 max-h-64 overflow-y-auto", children: fieldNames.map((field) => /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 cursor-pointer", children: [
|
|
476
476
|
/* @__PURE__ */ jsx(
|
|
477
477
|
"input",
|
|
@@ -483,12 +483,12 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
483
483
|
setVisibleColumns(newColumns);
|
|
484
484
|
AdminLocalStorage.setColumnVisibility(model.name, newColumns);
|
|
485
485
|
},
|
|
486
|
-
className: "h-4 w-4 mt-0.5 flex-shrink-0 text-green-web focus:ring-green-web border-gray-300 rounded"
|
|
486
|
+
className: "h-4 w-4 mt-0.5 flex-shrink-0 text-green-web focus:ring-green-web border-gray-300 dark:border-gray-600 rounded"
|
|
487
487
|
}
|
|
488
488
|
),
|
|
489
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-gray-700 leading-5", children: formatFieldName(field) })
|
|
489
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-gray-700 dark:text-gray-300 leading-5", children: formatFieldName(field) })
|
|
490
490
|
] }, field)) }),
|
|
491
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-3 pt-3 border-t border-gray-200 flex justify-between", children: [
|
|
491
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 flex justify-between", children: [
|
|
492
492
|
/* @__PURE__ */ jsx(
|
|
493
493
|
"button",
|
|
494
494
|
{
|
|
@@ -508,7 +508,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
508
508
|
setVisibleColumns(defaults);
|
|
509
509
|
AdminLocalStorage.setColumnVisibility(model.name, defaults);
|
|
510
510
|
},
|
|
511
|
-
className: "text-xs text-gray-600 hover:text-gray-800",
|
|
511
|
+
className: "text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",
|
|
512
512
|
children: "Reset to Defaults"
|
|
513
513
|
}
|
|
514
514
|
)
|
|
@@ -520,7 +520,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
520
520
|
"button",
|
|
521
521
|
{
|
|
522
522
|
onClick: () => setShowSearchFieldSelector(!showSearchFieldSelector),
|
|
523
|
-
className: "h-full px-3 border-l border-gray-300 text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600",
|
|
523
|
+
className: "h-full px-3 border-l border-gray-300 dark:border-gray-600 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 focus:outline-none focus:text-gray-600 dark:focus:text-gray-300",
|
|
524
524
|
"aria-label": "Configure search fields",
|
|
525
525
|
children: /* @__PURE__ */ jsx(
|
|
526
526
|
"svg",
|
|
@@ -541,8 +541,8 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
541
541
|
)
|
|
542
542
|
}
|
|
543
543
|
),
|
|
544
|
-
showSearchFieldSelector && /* @__PURE__ */ jsx("div", { className: "absolute right-0 mt-2 w-72 bg-white rounded-md shadow-lg z-50 border border-gray-200", children: /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
545
|
-
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 mb-3", children: "Search Fields" }),
|
|
544
|
+
showSearchFieldSelector && /* @__PURE__ */ jsx("div", { className: "absolute right-0 mt-2 w-72 bg-white dark:bg-gray-800 rounded-md shadow-lg z-50 border border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
545
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 dark:text-gray-100 mb-3", children: "Search Fields" }),
|
|
546
546
|
searchableFieldNames.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
547
547
|
/* @__PURE__ */ jsx("div", { className: "space-y-2 max-h-48 overflow-y-auto", children: searchableFieldNames.map((field) => /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 cursor-pointer", children: [
|
|
548
548
|
/* @__PURE__ */ jsx(
|
|
@@ -555,12 +555,12 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
555
555
|
setSearchFields(newFields);
|
|
556
556
|
AdminLocalStorage.setSearchFields(model.name, newFields);
|
|
557
557
|
},
|
|
558
|
-
className: "h-4 w-4 mt-0.5 flex-shrink-0 text-green-web focus:ring-green-web border-gray-300 rounded"
|
|
558
|
+
className: "h-4 w-4 mt-0.5 flex-shrink-0 text-green-web focus:ring-green-web border-gray-300 dark:border-gray-600 rounded"
|
|
559
559
|
}
|
|
560
560
|
),
|
|
561
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-gray-700 leading-5", children: formatFieldName(field) })
|
|
561
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-gray-700 dark:text-gray-300 leading-5", children: formatFieldName(field) })
|
|
562
562
|
] }, field)) }),
|
|
563
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-3 pt-3 border-t border-gray-200 flex justify-between", children: [
|
|
563
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 flex justify-between", children: [
|
|
564
564
|
/* @__PURE__ */ jsx(
|
|
565
565
|
"button",
|
|
566
566
|
{
|
|
@@ -580,17 +580,17 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
580
580
|
setSearchFields(defaults);
|
|
581
581
|
AdminLocalStorage.setSearchFields(model.name, defaults);
|
|
582
582
|
},
|
|
583
|
-
className: "text-xs text-gray-600 hover:text-gray-800",
|
|
583
|
+
className: "text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",
|
|
584
584
|
children: "Reset to Defaults"
|
|
585
585
|
}
|
|
586
586
|
)
|
|
587
587
|
] })
|
|
588
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: "No searchable text fields available" })
|
|
588
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500 dark:text-gray-400", children: "No searchable text fields available" })
|
|
589
589
|
] }) })
|
|
590
590
|
] });
|
|
591
|
-
const filterPanel = showFilters && /* @__PURE__ */ jsxs("div", { className: "mb-4 bg-gray-50 border border-gray-200 rounded-lg p-4", children: [
|
|
591
|
+
const filterPanel = showFilters && /* @__PURE__ */ jsxs("div", { className: "mb-4 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4", children: [
|
|
592
592
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
593
|
-
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900", children: "Filters" }),
|
|
593
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Filters" }),
|
|
594
594
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
595
595
|
/* @__PURE__ */ jsx(
|
|
596
596
|
"button",
|
|
@@ -599,7 +599,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
599
599
|
setFilters({});
|
|
600
600
|
dispatch({ type: "RESET_PAGINATION" });
|
|
601
601
|
},
|
|
602
|
-
className: "text-xs text-gray-600 hover:text-gray-800",
|
|
602
|
+
className: "text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",
|
|
603
603
|
children: "Clear All"
|
|
604
604
|
}
|
|
605
605
|
),
|
|
@@ -607,7 +607,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
607
607
|
"button",
|
|
608
608
|
{
|
|
609
609
|
onClick: () => setShowFilters(false),
|
|
610
|
-
className: "text-gray-400 hover:text-gray-600",
|
|
610
|
+
className: "text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",
|
|
611
611
|
children: /* @__PURE__ */ jsx(
|
|
612
612
|
"svg",
|
|
613
613
|
{
|
|
@@ -712,7 +712,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
712
712
|
{
|
|
713
713
|
id: "search",
|
|
714
714
|
name: "search",
|
|
715
|
-
className: "block w-full pl-10 pr-12 py-2 border border-gray-300 rounded-md leading-5 bg-white placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-1 focus:ring-green-web focus:border-green-web sm:text-sm",
|
|
715
|
+
className: "block w-full pl-10 pr-12 py-2 border border-gray-300 dark:border-gray-600 rounded-md leading-5 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:placeholder-gray-400 dark:focus:placeholder-gray-500 focus:ring-1 focus:ring-green-web focus:border-green-web sm:text-sm",
|
|
716
716
|
placeholder: `Search ${searchFields.length > 0 ? searchFields.map((field) => field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (str) => str.toUpperCase())).join(", ") : getPluralName(model.name).toLowerCase()}...`,
|
|
717
717
|
type: "search",
|
|
718
718
|
value: state.search || "",
|
|
@@ -727,7 +727,7 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
727
727
|
"button",
|
|
728
728
|
{
|
|
729
729
|
onClick: () => setShowFilters(!showFilters),
|
|
730
|
-
className: `inline-flex items-center px-3 py-2 border text-sm font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web ${showFilters || Object.keys(filters).length > 0 ? "border-green-web text-green-web bg-green-50 hover:bg-green-100" : "border-gray-300 text-gray-700 bg-white hover:bg-gray-50"}`,
|
|
730
|
+
className: `inline-flex items-center px-3 py-2 border text-sm font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web ${showFilters || Object.keys(filters).length > 0 ? "border-green-web text-green-web bg-green-50 dark:bg-green-900/30 hover:bg-green-100 dark:hover:bg-green-900/50" : "border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700"}`,
|
|
731
731
|
children: [
|
|
732
732
|
/* @__PURE__ */ jsx("svg", { className: "w-4 h-4 mr-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
|
|
733
733
|
"path",
|
|
@@ -32,5 +32,6 @@ export declare function buildFormFields(sdk: any, model: DatabaseModel, operatio
|
|
|
32
32
|
/**
|
|
33
33
|
* Clean form input data for GraphQL mutations
|
|
34
34
|
* Removes Apollo metadata and system fields
|
|
35
|
+
* Handles Prisma array field update syntax
|
|
35
36
|
*/
|
|
36
37
|
export declare function cleanFormInput(input: Record<string, unknown>, model?: DatabaseModel): Record<string, unknown>;
|
|
@@ -436,11 +436,14 @@ function processNestedObject(value, model) {
|
|
|
436
436
|
return Object.keys(cleanedNested).length > 0 ? cleanedNested : null;
|
|
437
437
|
}
|
|
438
438
|
function cleanFormInput(input, model) {
|
|
439
|
-
var _a, _b, _c;
|
|
439
|
+
var _a, _b, _c, _d, _e;
|
|
440
440
|
const cleaned = {};
|
|
441
441
|
const booleanFields = new Set(
|
|
442
442
|
((_b = (_a = model == null ? void 0 : model.fields) == null ? void 0 : _a.filter((field) => field.type.toLowerCase() === "boolean")) == null ? void 0 : _b.map((field) => field.name)) || []
|
|
443
443
|
);
|
|
444
|
+
const arrayFields = new Map(
|
|
445
|
+
((_d = (_c = model == null ? void 0 : model.fields) == null ? void 0 : _c.filter((field) => field.isList && !field.relationName)) == null ? void 0 : _d.map((field) => [field.name, { isRequired: !field.isOptional }])) || []
|
|
446
|
+
);
|
|
444
447
|
for (const [key, value] of Object.entries(input)) {
|
|
445
448
|
if (booleanFields.has(key) && value === void 0) {
|
|
446
449
|
cleaned[key] = false;
|
|
@@ -449,8 +452,23 @@ function cleanFormInput(input, model) {
|
|
|
449
452
|
if (shouldSkipValue(key, value)) {
|
|
450
453
|
continue;
|
|
451
454
|
}
|
|
455
|
+
const arrayFieldInfo = arrayFields.get(key);
|
|
456
|
+
if (arrayFieldInfo) {
|
|
457
|
+
if (value === null || value === "") {
|
|
458
|
+
cleaned[key] = arrayFieldInfo.isRequired ? { set: [] } : null;
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
let arrayValue;
|
|
462
|
+
if (Array.isArray(value)) {
|
|
463
|
+
arrayValue = value;
|
|
464
|
+
} else {
|
|
465
|
+
arrayValue = [value];
|
|
466
|
+
}
|
|
467
|
+
cleaned[key] = { set: arrayValue };
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
452
470
|
if (typeof value === "string") {
|
|
453
|
-
const field = (
|
|
471
|
+
const field = (_e = model == null ? void 0 : model.fields) == null ? void 0 : _e.find((f) => f.name === key);
|
|
454
472
|
const convertedValue = convertStringValue(value, field);
|
|
455
473
|
cleaned[key] = convertedValue;
|
|
456
474
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestledjs/data-browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Universal admin data browser for Nestled framework projects with full CRUD operations",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@apollo/client": "^4.0.0",
|
|
39
39
|
"@heroicons/react": "^2.0.0",
|
|
40
40
|
"@nestledjs/forms": "^0.5.0",
|
|
41
|
-
"@nestledjs/shared-components": "^1.0.
|
|
41
|
+
"@nestledjs/shared-components": "^1.0.3",
|
|
42
42
|
"react": "^19.0.0",
|
|
43
43
|
"react-router": "^7.0.0"
|
|
44
44
|
},
|