@houssemdi2000/design-system 1.4.9 → 1.5.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/dist/index.esm.js
CHANGED
|
@@ -972,5 +972,37 @@ const AccordionPanel = ({ item, isOpen, toggle, iconColor, }) => {
|
|
|
972
972
|
var css_248z = ".input-field{background:#fff;border:1px solid var(--in-border-color,#ccc);border-radius:6px;font-size:15px;outline:none;padding:10px 12px;transition:.2s ease-in-out}.input-field.dark-mode{background:#333!important;color:#fff!important}.input-field:focus,.input-field:hover{border-color:var(--in-focus-border,#007bff)}.input-field:focus{box-shadow:0 0 3px var(--in-focus-shadow,rgba(0,123,255,.4))}.input-field.error{border-color:#e63946!important;box-shadow:0 0 2px rgba(230,57,70,.4)}.input-field:disabled{background:#f0f0f0;cursor:not-allowed;opacity:.7}.input-error{background-color:#f44343;border-radius:4px;color:#ece6e6;font-family:sans-serif;font-size:12px;margin-top:4px;padding:8px}";
|
|
973
973
|
styleInject(css_248z);
|
|
974
974
|
|
|
975
|
-
|
|
975
|
+
const EditableField = ({ label, value, error, editable = true, icon, onSave, renderValue, isDarkMode = false, borderColor = "#ccc", focusBorder = "#007bff", focusShadow = "rgba(0, 123, 255, 0.4)", fullWidth = false, style = {}, }) => {
|
|
976
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
977
|
+
const [draft, setDraft] = useState(value);
|
|
978
|
+
const startEditing = () => {
|
|
979
|
+
if (!editable)
|
|
980
|
+
return;
|
|
981
|
+
setDraft(value);
|
|
982
|
+
setIsEditing(true);
|
|
983
|
+
};
|
|
984
|
+
const save = () => {
|
|
985
|
+
if (draft !== value) {
|
|
986
|
+
onSave(draft);
|
|
987
|
+
}
|
|
988
|
+
setIsEditing(false);
|
|
989
|
+
};
|
|
990
|
+
const cancel = () => {
|
|
991
|
+
setDraft(value);
|
|
992
|
+
setIsEditing(false);
|
|
993
|
+
};
|
|
994
|
+
return (jsxs("div", { style: {
|
|
995
|
+
display: "flex",
|
|
996
|
+
flexDirection: "column",
|
|
997
|
+
gap: "4px",
|
|
998
|
+
fontFamily: "sans-serif",
|
|
999
|
+
}, children: [label && label, jsx("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: isEditing ? (jsx("input", { value: draft, autoFocus: true, onChange: (e) => setDraft(e.target.value), className: `input-field ${error ? "error" : ""} ${isDarkMode ? "dark-mode" : ""}`, style: Object.assign(Object.assign({}, style), { ["--in-border-color"]: isDarkMode ? "black" : borderColor, ["--in-focus-border"]: focusBorder, ["--in-focus-shadow"]: focusShadow }), onBlur: save, onKeyDown: (e) => {
|
|
1000
|
+
if (e.key === "Enter")
|
|
1001
|
+
save();
|
|
1002
|
+
if (e.key === "Escape")
|
|
1003
|
+
cancel();
|
|
1004
|
+
} })) : (jsxs(Fragment, { children: [jsx("div", { style: { flex: 1 }, children: renderValue ? renderValue(value) : value }), editable && (jsx("span", { style: { cursor: "pointer", opacity: 0.7 }, onClick: startEditing, children: icon !== null && icon !== void 0 ? icon : "✏️" }))] })) })] }));
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
export { Accordion, Avatar, Bloc, Button, Card, CardSheet, Center, Checkbox, Colors, Column, Container, Divider, DragDrop, EditableField, Footer, FormBuilder, Grid, Layout, Loading, Modal, Navbar, Pagination, ProfileMenu, QuicklyLogin, Radio, Row, SecureText, Select, Sidebar, SmartCarousel, SmartTable, SmartTimeline, Spacer, TableFilterBar, Tag, Text, TextField, ThemeProvider, ToastProvider, tco, useTheme, useToast };
|
|
976
1008
|
//# sourceMappingURL=index.esm.js.map
|