resourceformdialog 1.0.0
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.
- package/.babelrc +13 -0
- package/dist/index.js +145 -0
- package/index.js +91 -0
- package/package.json +24 -0
- package/styles.css +201 -0
package/.babelrc
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = ResourceFormDialog;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
var _excluded = ["idRole", "users"];
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
13
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
14
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
18
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
19
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
25
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
26
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
27
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
28
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
29
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
30
|
+
function ResourceFormDialog(_ref) {
|
|
31
|
+
var open = _ref.open,
|
|
32
|
+
onClose = _ref.onClose,
|
|
33
|
+
title = _ref.title,
|
|
34
|
+
_ref$fields = _ref.fields,
|
|
35
|
+
fields = _ref$fields === void 0 ? [] : _ref$fields,
|
|
36
|
+
_ref$editing = _ref.editing,
|
|
37
|
+
editing = _ref$editing === void 0 ? null : _ref$editing,
|
|
38
|
+
onCreate = _ref.onCreate,
|
|
39
|
+
onEdit = _ref.onEdit,
|
|
40
|
+
onSaved = _ref.onSaved,
|
|
41
|
+
_ref$idKey = _ref.idKey,
|
|
42
|
+
idKey = _ref$idKey === void 0 ? "id" : _ref$idKey;
|
|
43
|
+
var _useState = (0, _react.useState)({}),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
form = _useState2[0],
|
|
46
|
+
setForm = _useState2[1];
|
|
47
|
+
(0, _react.useEffect)(function () {
|
|
48
|
+
setForm(editing ? _objectSpread({}, editing) : {});
|
|
49
|
+
}, [editing]);
|
|
50
|
+
var handleChange = function handleChange(name, value) {
|
|
51
|
+
setForm(function (prev) {
|
|
52
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, name, value));
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var handleSave = /*#__PURE__*/function () {
|
|
56
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
57
|
+
var data, idRole, users, rest, _t;
|
|
58
|
+
return _regenerator().w(function (_context) {
|
|
59
|
+
while (1) switch (_context.p = _context.n) {
|
|
60
|
+
case 0:
|
|
61
|
+
data = _objectSpread({}, form); // Auto-parse JSON fields
|
|
62
|
+
fields.forEach(function (f) {
|
|
63
|
+
if (f.type === "json" && typeof data[f.name] === "string") {
|
|
64
|
+
try {
|
|
65
|
+
data[f.name] = JSON.parse(data[f.name]);
|
|
66
|
+
} catch (_unused) {
|
|
67
|
+
/* ignore */
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
_context.p = 1;
|
|
72
|
+
if (!(editing && onEdit)) {
|
|
73
|
+
_context.n = 3;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
idRole = data.idRole, users = data.users, rest = _objectWithoutProperties(data, _excluded);
|
|
77
|
+
_context.n = 2;
|
|
78
|
+
return onEdit(editing[idKey], rest);
|
|
79
|
+
case 2:
|
|
80
|
+
_context.n = 4;
|
|
81
|
+
break;
|
|
82
|
+
case 3:
|
|
83
|
+
if (!(!editing && onCreate)) {
|
|
84
|
+
_context.n = 4;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
_context.n = 4;
|
|
88
|
+
return onCreate(data);
|
|
89
|
+
case 4:
|
|
90
|
+
onSaved === null || onSaved === void 0 || onSaved();
|
|
91
|
+
_context.n = 6;
|
|
92
|
+
break;
|
|
93
|
+
case 5:
|
|
94
|
+
_context.p = 5;
|
|
95
|
+
_t = _context.v;
|
|
96
|
+
console.error("Save failed:", _t);
|
|
97
|
+
case 6:
|
|
98
|
+
return _context.a(2);
|
|
99
|
+
}
|
|
100
|
+
}, _callee, null, [[1, 5]]);
|
|
101
|
+
}));
|
|
102
|
+
return function handleSave() {
|
|
103
|
+
return _ref2.apply(this, arguments);
|
|
104
|
+
};
|
|
105
|
+
}();
|
|
106
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
107
|
+
open: open,
|
|
108
|
+
onClose: onClose,
|
|
109
|
+
fullWidth: true,
|
|
110
|
+
maxWidth: "sm",
|
|
111
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
112
|
+
children: editing ? "\u270F\uFE0F Edit ".concat(title) : "\u2728 Create ".concat(title)
|
|
113
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
114
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
115
|
+
display: "flex",
|
|
116
|
+
flexDirection: "column",
|
|
117
|
+
gap: 2,
|
|
118
|
+
mt: 1,
|
|
119
|
+
children: fields.map(function (field) {
|
|
120
|
+
var _form$field$name;
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
122
|
+
label: field.label,
|
|
123
|
+
value: (_form$field$name = form[field.name]) !== null && _form$field$name !== void 0 ? _form$field$name : "",
|
|
124
|
+
onChange: function onChange(e) {
|
|
125
|
+
return handleChange(field.name, e.target.value);
|
|
126
|
+
},
|
|
127
|
+
fullWidth: true,
|
|
128
|
+
multiline: field.multiline || field.type === "json",
|
|
129
|
+
minRows: field.multiline || field.type === "json" ? 4 : 1,
|
|
130
|
+
disabled: field.disabled
|
|
131
|
+
}, field.name);
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
135
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
136
|
+
onClick: onClose,
|
|
137
|
+
children: "Cancel"
|
|
138
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
139
|
+
variant: "contained",
|
|
140
|
+
onClick: handleSave,
|
|
141
|
+
children: editing ? "💾 Update" : "✨ Create"
|
|
142
|
+
})]
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogTitle,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogActions,
|
|
7
|
+
Button,
|
|
8
|
+
TextField,
|
|
9
|
+
Box,
|
|
10
|
+
} from "@mui/material";
|
|
11
|
+
|
|
12
|
+
export default function ResourceFormDialog({
|
|
13
|
+
open,
|
|
14
|
+
onClose,
|
|
15
|
+
title,
|
|
16
|
+
fields = [],
|
|
17
|
+
editing = null,
|
|
18
|
+
onCreate,
|
|
19
|
+
onEdit,
|
|
20
|
+
onSaved,
|
|
21
|
+
idKey = "id",
|
|
22
|
+
}) {
|
|
23
|
+
const [form, setForm] = useState({});
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setForm(editing ? { ...editing } : {});
|
|
27
|
+
}, [editing]);
|
|
28
|
+
|
|
29
|
+
const handleChange = (name, value) => {
|
|
30
|
+
setForm((prev) => ({ ...prev, [name]: value }));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleSave = async () => {
|
|
34
|
+
const data = { ...form };
|
|
35
|
+
|
|
36
|
+
// Auto-parse JSON fields
|
|
37
|
+
fields.forEach((f) => {
|
|
38
|
+
if (f.type === "json" && typeof data[f.name] === "string") {
|
|
39
|
+
try {
|
|
40
|
+
data[f.name] = JSON.parse(data[f.name]);
|
|
41
|
+
} catch {
|
|
42
|
+
/* ignore */
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
if (editing && onEdit) {
|
|
49
|
+
const{idRole,users,...rest}=data
|
|
50
|
+
await onEdit(editing[idKey], rest);
|
|
51
|
+
} else if (!editing && onCreate) {
|
|
52
|
+
await onCreate(data);
|
|
53
|
+
}
|
|
54
|
+
onSaved?.();
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error("Save failed:", err);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Dialog open={open} onClose={onClose} fullWidth maxWidth="sm">
|
|
62
|
+
<DialogTitle>
|
|
63
|
+
{editing ? `✏️ Edit ${title}` : `✨ Create ${title}`}
|
|
64
|
+
</DialogTitle>
|
|
65
|
+
|
|
66
|
+
<DialogContent>
|
|
67
|
+
<Box display="flex" flexDirection="column" gap={2} mt={1}>
|
|
68
|
+
{fields.map((field) => (
|
|
69
|
+
<TextField
|
|
70
|
+
key={field.name}
|
|
71
|
+
label={field.label}
|
|
72
|
+
value={form[field.name] ?? ""}
|
|
73
|
+
onChange={(e) => handleChange(field.name, e.target.value)}
|
|
74
|
+
fullWidth
|
|
75
|
+
multiline={field.multiline || field.type === "json"}
|
|
76
|
+
minRows={field.multiline || field.type === "json" ? 4 : 1}
|
|
77
|
+
disabled={field.disabled}
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
80
|
+
</Box>
|
|
81
|
+
</DialogContent>
|
|
82
|
+
|
|
83
|
+
<DialogActions>
|
|
84
|
+
<Button onClick={onClose}>Cancel</Button>
|
|
85
|
+
<Button variant="contained" onClick={handleSave}>
|
|
86
|
+
{editing ? "💾 Update" : "✨ Create"}
|
|
87
|
+
</Button>
|
|
88
|
+
</DialogActions>
|
|
89
|
+
</Dialog>
|
|
90
|
+
);
|
|
91
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "resourceformdialog",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Form modal",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "babel index.js --out-dir dist",
|
|
8
|
+
"prepare": "npm run build",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"author": "CodeLusitan",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"babel": "^6.23.0",
|
|
15
|
+
"mui": "^0.0.1",
|
|
16
|
+
"react": "^19.2.4"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/cli": "^7.24.1",
|
|
20
|
+
"@babel/core": "^7.24.0",
|
|
21
|
+
"@babel/preset-env": "^7.24.0",
|
|
22
|
+
"@babel/preset-react": "^7.23.3"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/styles.css
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* ResourceFormDialog.css - Resource Form Modal Styles */
|
|
2
|
+
|
|
3
|
+
/* Dialog Container */
|
|
4
|
+
.resource-dialog .MuiDialog-paper {
|
|
5
|
+
border-radius: 12px;
|
|
6
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Dialog Title */
|
|
10
|
+
.resource-dialog .MuiDialogTitle-root {
|
|
11
|
+
background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
|
|
12
|
+
color: #fff;
|
|
13
|
+
padding: 1.5rem 2rem;
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
font-size: 1.5rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Dialog Content */
|
|
19
|
+
.resource-dialog .MuiDialogContent-root {
|
|
20
|
+
padding: 2rem;
|
|
21
|
+
background-color: #fafafa;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Dialog Actions */
|
|
25
|
+
.resource-dialog .MuiDialogActions-root {
|
|
26
|
+
padding: 1.5rem 2rem;
|
|
27
|
+
background-color: #f5f5f5;
|
|
28
|
+
border-top: 1px solid #e0e0e0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Form Fields Container */
|
|
32
|
+
.resource-form-container {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
gap: 1.5rem;
|
|
36
|
+
margin-top: 1rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Text Fields */
|
|
40
|
+
.resource-dialog .MuiTextField-root {
|
|
41
|
+
background-color: #fff;
|
|
42
|
+
border-radius: 8px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.resource-dialog .MuiOutlinedInput-root {
|
|
46
|
+
border-radius: 8px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.resource-dialog .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline {
|
|
50
|
+
border-color: #1e293b;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.resource-dialog .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {
|
|
54
|
+
border-color: #1e293b;
|
|
55
|
+
border-width: 2px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Input Labels */
|
|
59
|
+
.resource-dialog .MuiInputLabel-root {
|
|
60
|
+
font-weight: 500;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.resource-dialog .MuiInputLabel-root.Mui-focused {
|
|
64
|
+
color: #1e293b;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Multiline Text Field */
|
|
68
|
+
.resource-dialog .MuiTextField-root textarea {
|
|
69
|
+
font-family: 'Monaco', 'Courier New', monospace;
|
|
70
|
+
font-size: 0.875rem;
|
|
71
|
+
line-height: 1.6;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* JSON Editor Field */
|
|
75
|
+
.resource-json-editor {
|
|
76
|
+
background-color: #f8fafc !important;
|
|
77
|
+
border-radius: 8px !important;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.resource-json-editor textarea {
|
|
81
|
+
font-family: 'Monaco', 'Courier New', 'Consolas', monospace !important;
|
|
82
|
+
font-size: 0.875rem !important;
|
|
83
|
+
line-height: 1.6 !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Action Buttons */
|
|
87
|
+
.resource-dialog .MuiDialogActions-root .MuiButton-root {
|
|
88
|
+
padding: 0.625rem 1.5rem;
|
|
89
|
+
border-radius: 8px;
|
|
90
|
+
text-transform: none;
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
font-size: 0.95rem;
|
|
93
|
+
transition: all 0.2s ease;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.resource-dialog .MuiDialogActions-root .MuiButton-text {
|
|
97
|
+
color: #64748b;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.resource-dialog .MuiDialogActions-root .MuiButton-text:hover {
|
|
101
|
+
background-color: #f1f5f9;
|
|
102
|
+
color: #1e293b;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.resource-dialog .MuiDialogActions-root .MuiButton-contained {
|
|
106
|
+
background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
|
|
107
|
+
color: white;
|
|
108
|
+
box-shadow: 0 2px 8px rgba(30, 41, 59, 0.25);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.resource-dialog .MuiDialogActions-root .MuiButton-contained:hover {
|
|
112
|
+
box-shadow: 0 4px 12px rgba(30, 41, 59, 0.35);
|
|
113
|
+
transform: translateY(-1px);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Focus States */
|
|
117
|
+
.resource-dialog .MuiOutlinedInput-root.Mui-focused {
|
|
118
|
+
box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Scrollbar Styling */
|
|
122
|
+
.resource-dialog .MuiDialogContent-root::-webkit-scrollbar {
|
|
123
|
+
width: 8px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.resource-dialog .MuiDialogContent-root::-webkit-scrollbar-track {
|
|
127
|
+
background: #f1f5f9;
|
|
128
|
+
border-radius: 4px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.resource-dialog .MuiDialogContent-root::-webkit-scrollbar-thumb {
|
|
132
|
+
background: #cbd5e1;
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.resource-dialog .MuiDialogContent-root::-webkit-scrollbar-thumb:hover {
|
|
137
|
+
background: #94a3b8;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Responsive Design */
|
|
141
|
+
@media (max-width: 768px) {
|
|
142
|
+
.resource-dialog .MuiDialogTitle-root {
|
|
143
|
+
padding: 1.25rem 1.5rem;
|
|
144
|
+
font-size: 1.25rem;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.resource-dialog .MuiDialogContent-root {
|
|
148
|
+
padding: 1.5rem;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.resource-dialog .MuiDialogActions-root {
|
|
152
|
+
padding: 1.25rem 1.5rem;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.resource-form-container {
|
|
156
|
+
gap: 1.25rem;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Loading State */
|
|
161
|
+
.resource-dialog-loading {
|
|
162
|
+
position: relative;
|
|
163
|
+
pointer-events: none;
|
|
164
|
+
opacity: 0.6;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.resource-dialog-loading::after {
|
|
168
|
+
content: "";
|
|
169
|
+
position: absolute;
|
|
170
|
+
top: 50%;
|
|
171
|
+
left: 50%;
|
|
172
|
+
width: 40px;
|
|
173
|
+
height: 40px;
|
|
174
|
+
margin: -20px 0 0 -20px;
|
|
175
|
+
border: 3px solid #f3f4f6;
|
|
176
|
+
border-top-color: #1e293b;
|
|
177
|
+
border-radius: 50%;
|
|
178
|
+
animation: resource-spin 0.8s linear infinite;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@keyframes resource-spin {
|
|
182
|
+
to {
|
|
183
|
+
transform: rotate(360deg);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* Field Animation */
|
|
188
|
+
@keyframes fadeIn {
|
|
189
|
+
from {
|
|
190
|
+
opacity: 0;
|
|
191
|
+
transform: translateY(-5px);
|
|
192
|
+
}
|
|
193
|
+
to {
|
|
194
|
+
opacity: 1;
|
|
195
|
+
transform: translateY(0);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.resource-dialog .MuiTextField-root {
|
|
200
|
+
animation: fadeIn 0.3s ease-out;
|
|
201
|
+
}
|