@dashadmin/dash-components 1.3.25 → 1.3.26
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/components/AuditLog/AuditLog.js +345 -1
- package/dist/components/AuditLog/index.js +4 -1
- package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
- package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/Json/Json.js +235 -1
- package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
- package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
- package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
- package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
- package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
- package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
- package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
- package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
- package/dist/components/ListActive/ListActive.js +126 -1
- package/dist/components/ListActive/ListBoolean.js +124 -1
- package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
- package/dist/components/NotificationPreferences/index.js +7 -1
- package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
- package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
- package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
- package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
- package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
- package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
- package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
- package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
- package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
- package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
- package/dist/components/Upload/SingleImageUploader.js +40 -1
- package/dist/components/custom/PackageCopyMethod.js +78 -1
- package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
- package/dist/components/dialog/Basic.js +8 -1
- package/dist/components/dialog/Correct.js +14 -1
- package/dist/components/dialog/Error.js +14 -1
- package/dist/components/dialog/Info.js +14 -1
- package/dist/components/dialog/InfoV2.js +21 -1
- package/dist/components/dialog/NotFound.js +14 -1
- package/dist/components/dialog/QuickSearch.js +117 -1
- package/dist/components/notifications/NotificationsCenter.js +597 -1
- package/dist/components/notifications/index.js +24 -1
- package/dist/components/tables/PaginationComponent.js +36 -1
- package/dist/components/theme/AppLoadingFallback.js +38 -2
- package/dist/components/theme/ErrorBoundary.js +52 -1
- package/dist/components/theme/InitialLoader.js +13 -1
- package/dist/components/theme/NotFound.js +136 -1
- package/dist/components/theme/NotResults.js +38 -1
- package/dist/hooks/useDraggable.js +6 -1
- package/dist/hooks/useNotifications.js +8 -1
- package/dist/hooks/useQuickSearch.js +26 -1
- package/dist/index.js +66 -5567
- package/dist/utils/setNativeValue.js +17 -1
- package/package.json +149 -132
- package/src/components/AuditLog/AuditLog.tsx +476 -0
- package/src/components/AuditLog/index.ts +2 -0
- package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
- package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
- package/src/components/Json/Json.tsx +312 -0
- package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
- package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
- package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
- package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
- package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
- package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
- package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
- package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
- package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
- package/src/components/ListActive/ListActive.tsx +106 -0
- package/src/components/ListActive/ListBoolean.tsx +96 -0
- package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
- package/src/components/NotificationPreferences/index.tsx +2 -0
- package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
- package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
- package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
- package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
- package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
- package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
- package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
- package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
- package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
- package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
- package/src/components/Upload/SingleImageUploader.tsx +55 -0
- package/src/components/custom/PackageCopyMethod.tsx +109 -0
- package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
- package/src/components/dialog/Basic.tsx +11 -0
- package/src/components/dialog/Correct.tsx +16 -0
- package/src/components/dialog/Error.tsx +15 -0
- package/src/components/dialog/Info.tsx +15 -0
- package/src/components/dialog/InfoV2.tsx +35 -0
- package/src/components/dialog/NotFound.tsx +18 -0
- package/src/components/dialog/QuickSearch.tsx +115 -0
- package/src/components/notifications/NotificationsCenter.tsx +792 -0
- package/src/components/notifications/index.ts +42 -0
- package/src/components/tables/PaginationComponent.tsx +17 -0
- package/src/components/theme/AppLoadingFallback.tsx +42 -0
- package/src/components/theme/ErrorBoundary.tsx +57 -0
- package/src/components/theme/InitialLoader.tsx +16 -0
- package/src/components/theme/NotFound.tsx +124 -0
- package/src/components/theme/NotResults.tsx +54 -0
- package/src/hooks/useDraggable.ts +11 -0
- package/src/hooks/useNotifications.ts +14 -0
- package/src/hooks/useQuickSearch.tsx +29 -0
- package/src/index.tsx +77 -0
- package/src/utils/setNativeValue.tsx +23 -0
- package/dist/color-thief-CTwGFhOB.js +0 -272
- /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
- /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
- /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
- /package/{dist → src}/styles/index.less +0 -0
|
@@ -1 +1,283 @@
|
|
|
1
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import {
|
|
23
|
+
Box,
|
|
24
|
+
Button,
|
|
25
|
+
IconButton,
|
|
26
|
+
Typography,
|
|
27
|
+
Card,
|
|
28
|
+
CardMedia,
|
|
29
|
+
CircularProgress,
|
|
30
|
+
Input,
|
|
31
|
+
Alert,
|
|
32
|
+
TextField,
|
|
33
|
+
Divider
|
|
34
|
+
} from "@mui/material";
|
|
35
|
+
import DeleteIcon from "@mui/icons-material/Delete";
|
|
36
|
+
import CloudUploadIcon from "@mui/icons-material/CloudUpload";
|
|
37
|
+
import PaletteIcon from "@mui/icons-material/Palette";
|
|
38
|
+
import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
|
|
39
|
+
import { useState, useEffect, memo, useCallback } from "react";
|
|
40
|
+
import { useAsyncColorThief } from "../useAsyncColorThief";
|
|
41
|
+
import { getContrastColor, rgbArrayToHex } from "../helpers/functions";
|
|
42
|
+
import { useAxios } from "dash-axios-hook";
|
|
43
|
+
const ImageColorExtractor = memo(({ onColorsExtracted, onColorsUpdate, existingPairs = [] }) => {
|
|
44
|
+
const [imageUrl, setImageUrl] = useState(null);
|
|
45
|
+
const [uploadedFile, setUploadedFile] = useState(null);
|
|
46
|
+
const [themePrompt, setThemePrompt] = useState("");
|
|
47
|
+
const [isGeneratingTheme, setIsGeneratingTheme] = useState(false);
|
|
48
|
+
const [themeError, setThemeError] = useState(null);
|
|
49
|
+
const [extractedPalette, setExtractedPalette] = useState([]);
|
|
50
|
+
const axios = useAxios();
|
|
51
|
+
const { dominantColor, palette, loading, error } = useAsyncColorThief(imageUrl, {
|
|
52
|
+
colorCount: 8,
|
|
53
|
+
quality: 10
|
|
54
|
+
});
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (palette && palette.length > 0) {
|
|
57
|
+
setExtractedPalette(palette);
|
|
58
|
+
onColorsExtracted(palette);
|
|
59
|
+
}
|
|
60
|
+
}, [palette, onColorsExtracted]);
|
|
61
|
+
const handleFileSelect = (event) => {
|
|
62
|
+
var _a;
|
|
63
|
+
const file = (_a = event.target.files) == null ? void 0 : _a[0];
|
|
64
|
+
if (file) {
|
|
65
|
+
if (!file.type.startsWith("image/")) {
|
|
66
|
+
alert("Please select a valid image file");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (file.size > 5 * 1024 * 1024) {
|
|
70
|
+
alert("File size must be less than 5MB");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setUploadedFile(file);
|
|
74
|
+
const previewUrl = URL.createObjectURL(file);
|
|
75
|
+
setImageUrl(previewUrl);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const handleImageRemove = () => {
|
|
79
|
+
if (imageUrl && imageUrl.startsWith("blob:")) {
|
|
80
|
+
URL.revokeObjectURL(imageUrl);
|
|
81
|
+
}
|
|
82
|
+
setImageUrl(null);
|
|
83
|
+
setUploadedFile(null);
|
|
84
|
+
setExtractedPalette([]);
|
|
85
|
+
onColorsExtracted([]);
|
|
86
|
+
};
|
|
87
|
+
const handleGenerateTheme = useCallback(() => __async(null, null, function* () {
|
|
88
|
+
if (!extractedPalette || extractedPalette.length === 0) {
|
|
89
|
+
setThemeError("Please extract colors from an image first");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
setIsGeneratingTheme(true);
|
|
93
|
+
setThemeError(null);
|
|
94
|
+
try {
|
|
95
|
+
const response = yield axios.post("/tenant/tenant/settings/theme-generator", {
|
|
96
|
+
colors: extractedPalette,
|
|
97
|
+
prompt: themePrompt,
|
|
98
|
+
output_format: "json"
|
|
99
|
+
});
|
|
100
|
+
if (response.status !== 200) {
|
|
101
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
102
|
+
}
|
|
103
|
+
const result = response.data;
|
|
104
|
+
if (result.success && result.data) {
|
|
105
|
+
const newPairs = Object.entries(result.data).map(([key, value]) => ({
|
|
106
|
+
key,
|
|
107
|
+
value: String(value),
|
|
108
|
+
id: Math.random().toString(36).substring(2, 11)
|
|
109
|
+
}));
|
|
110
|
+
const mergedPairs = [...existingPairs];
|
|
111
|
+
newPairs.forEach((newPair) => {
|
|
112
|
+
const existingIndex = mergedPairs.findIndex((existing) => existing.key === newPair.key);
|
|
113
|
+
if (existingIndex >= 0) {
|
|
114
|
+
mergedPairs[existingIndex] = newPair;
|
|
115
|
+
} else {
|
|
116
|
+
mergedPairs.push(newPair);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (onColorsUpdate) {
|
|
120
|
+
onColorsUpdate(mergedPairs);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error(result.message || "Failed to generate theme");
|
|
124
|
+
}
|
|
125
|
+
} catch (error2) {
|
|
126
|
+
console.error("Theme generation error:", error2);
|
|
127
|
+
setThemeError(error2 instanceof Error ? error2.message : "Failed to generate theme");
|
|
128
|
+
} finally {
|
|
129
|
+
setIsGeneratingTheme(false);
|
|
130
|
+
}
|
|
131
|
+
}), [extractedPalette, themePrompt, existingPairs, onColorsUpdate, axios]);
|
|
132
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { mt: 3, p: 3, borderRadius: 2 }, children: [
|
|
133
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "h6", gutterBottom: true, sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
134
|
+
/* @__PURE__ */ jsx(PaletteIcon, {}),
|
|
135
|
+
"AI Theme Generator"
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ jsx(Divider, { sx: { mb: 3 } }),
|
|
138
|
+
/* @__PURE__ */ jsx(Box, { sx: { mb: 3 }, children: !imageUrl ? /* @__PURE__ */ jsxs(Box, { sx: {
|
|
139
|
+
textAlign: "center",
|
|
140
|
+
py: 4,
|
|
141
|
+
backgroundColor: "rgba(0,0,0,0.02)",
|
|
142
|
+
borderRadius: 1,
|
|
143
|
+
border: "2px dashed #e0e0e0"
|
|
144
|
+
}, children: [
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
Input,
|
|
147
|
+
{
|
|
148
|
+
type: "file",
|
|
149
|
+
inputProps: { accept: "image/*" },
|
|
150
|
+
onChange: handleFileSelect,
|
|
151
|
+
sx: { display: "none" },
|
|
152
|
+
id: "color-extractor-upload"
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", color: "textSecondary", gutterBottom: true, children: "Upload an Image to Extract Colors" }),
|
|
156
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", sx: { mb: 2 }, children: "Select an image file and we'll automatically extract a color palette" }),
|
|
157
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "color-extractor-upload", children: /* @__PURE__ */ jsx(
|
|
158
|
+
Button,
|
|
159
|
+
{
|
|
160
|
+
variant: "contained",
|
|
161
|
+
component: "span",
|
|
162
|
+
startIcon: /* @__PURE__ */ jsx(CloudUploadIcon, {}),
|
|
163
|
+
size: "large",
|
|
164
|
+
children: "Choose Image"
|
|
165
|
+
}
|
|
166
|
+
) })
|
|
167
|
+
] }) : /* @__PURE__ */ jsx(Card, { sx: { maxWidth: 400, mb: 3 }, children: /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
CardMedia,
|
|
170
|
+
{
|
|
171
|
+
component: "img",
|
|
172
|
+
height: "200",
|
|
173
|
+
image: imageUrl,
|
|
174
|
+
alt: "Uploaded image",
|
|
175
|
+
sx: { objectFit: "contain" }
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
IconButton,
|
|
180
|
+
{
|
|
181
|
+
sx: {
|
|
182
|
+
position: "absolute",
|
|
183
|
+
top: 8,
|
|
184
|
+
right: 8,
|
|
185
|
+
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
186
|
+
"&:hover": {
|
|
187
|
+
backgroundColor: "rgba(255, 255, 255, 1)"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
onClick: handleImageRemove,
|
|
191
|
+
size: "small",
|
|
192
|
+
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] }) }) }),
|
|
196
|
+
loading && /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 2, sx: { mb: 3, p: 2, backgroundColor: "rgba(25, 118, 210, 0.04)", borderRadius: 1 }, children: [
|
|
197
|
+
/* @__PURE__ */ jsx(CircularProgress, { size: 20 }),
|
|
198
|
+
/* @__PURE__ */ jsx(Typography, { children: "Extracting colors from image..." })
|
|
199
|
+
] }),
|
|
200
|
+
error && /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mb: 3 }, children: error }),
|
|
201
|
+
themeError && /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mb: 3 }, children: themeError }),
|
|
202
|
+
extractedPalette && extractedPalette.length > 0 && !loading && /* @__PURE__ */ jsxs(Box, { sx: { mb: 3 }, children: [
|
|
203
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", gutterBottom: true, children: [
|
|
204
|
+
"Extracted Colors (",
|
|
205
|
+
extractedPalette.length,
|
|
206
|
+
" colors found)"
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ jsx(Box, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: 2, mb: 3 }, children: extractedPalette.map((color, index) => {
|
|
209
|
+
const hexColor = rgbArrayToHex(color);
|
|
210
|
+
const isDominant = dominantColor && color[0] === dominantColor[0] && color[1] === dominantColor[1] && color[2] === dominantColor[2];
|
|
211
|
+
return /* @__PURE__ */ jsx(
|
|
212
|
+
Box,
|
|
213
|
+
{
|
|
214
|
+
sx: {
|
|
215
|
+
width: 50,
|
|
216
|
+
height: 50,
|
|
217
|
+
backgroundColor: hexColor,
|
|
218
|
+
borderRadius: "50%",
|
|
219
|
+
display: "flex",
|
|
220
|
+
alignItems: "center",
|
|
221
|
+
justifyContent: "center",
|
|
222
|
+
border: isDominant ? "3px solid #4caf50" : "2px solid #ccc",
|
|
223
|
+
cursor: "pointer",
|
|
224
|
+
transition: "transform 0.2s",
|
|
225
|
+
"&:hover": {
|
|
226
|
+
transform: "scale(1.1)"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
title: `${hexColor} ${isDominant ? "(Dominant)" : ""}`,
|
|
230
|
+
children: /* @__PURE__ */ jsx(
|
|
231
|
+
Typography,
|
|
232
|
+
{
|
|
233
|
+
variant: "caption",
|
|
234
|
+
sx: {
|
|
235
|
+
color: getContrastColor(hexColor),
|
|
236
|
+
fontWeight: "bold",
|
|
237
|
+
fontSize: "0.8rem"
|
|
238
|
+
},
|
|
239
|
+
children: index + 1
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
},
|
|
243
|
+
index
|
|
244
|
+
);
|
|
245
|
+
}) }),
|
|
246
|
+
/* @__PURE__ */ jsxs(Box, { sx: { mb: 3 }, children: [
|
|
247
|
+
/* @__PURE__ */ jsx(
|
|
248
|
+
TextField,
|
|
249
|
+
{
|
|
250
|
+
fullWidth: true,
|
|
251
|
+
multiline: true,
|
|
252
|
+
rows: 2,
|
|
253
|
+
placeholder: "Optional: Describe the theme style you want (e.g., 'modern and minimalist', 'warm and cozy', 'professional corporate')",
|
|
254
|
+
value: themePrompt,
|
|
255
|
+
onChange: (e) => setThemePrompt(e.target.value),
|
|
256
|
+
sx: { mb: 2 },
|
|
257
|
+
label: "Theme Description (Optional)"
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx(Box, { sx: { display: "flex", gap: 2, flexWrap: "wrap" }, children: /* @__PURE__ */ jsx(
|
|
261
|
+
Button,
|
|
262
|
+
{
|
|
263
|
+
variant: "contained",
|
|
264
|
+
startIcon: isGeneratingTheme ? /* @__PURE__ */ jsx(CircularProgress, { size: 16 }) : /* @__PURE__ */ jsx(AutoFixHighIcon, {}),
|
|
265
|
+
onClick: handleGenerateTheme,
|
|
266
|
+
disabled: isGeneratingTheme,
|
|
267
|
+
color: "primary",
|
|
268
|
+
children: isGeneratingTheme ? "Generating..." : "Generate AI Theme"
|
|
269
|
+
}
|
|
270
|
+
) })
|
|
271
|
+
] }),
|
|
272
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "textSecondary", sx: { fontStyle: "italic" }, children: [
|
|
273
|
+
"\u2022 ",
|
|
274
|
+
/* @__PURE__ */ jsx("strong", { children: "Generate AI Theme:" }),
|
|
275
|
+
" Uses AI to create a complete color scheme based on extracted colors and your description"
|
|
276
|
+
] })
|
|
277
|
+
] })
|
|
278
|
+
] });
|
|
279
|
+
});
|
|
280
|
+
var ImageColorExtractor_default = ImageColorExtractor;
|
|
281
|
+
export {
|
|
282
|
+
ImageColorExtractor_default as default
|
|
283
|
+
};
|
|
@@ -1 +1,101 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getContrastColor = (color) => {
|
|
2
|
+
let r, g, b, a = 1;
|
|
3
|
+
if (color.startsWith("#")) {
|
|
4
|
+
const hex = color.replace("#", "");
|
|
5
|
+
if (hex.length === 8) {
|
|
6
|
+
r = parseInt(hex.substr(0, 2), 16);
|
|
7
|
+
g = parseInt(hex.substr(2, 2), 16);
|
|
8
|
+
b = parseInt(hex.substr(4, 2), 16);
|
|
9
|
+
a = parseInt(hex.substr(6, 2), 16) / 255;
|
|
10
|
+
} else {
|
|
11
|
+
r = parseInt(hex.substr(0, 2), 16);
|
|
12
|
+
g = parseInt(hex.substr(2, 2), 16);
|
|
13
|
+
b = parseInt(hex.substr(4, 2), 16);
|
|
14
|
+
}
|
|
15
|
+
} else if (color.startsWith("rgb")) {
|
|
16
|
+
const match = color.match(/rgba?\(([^)]+)\)/);
|
|
17
|
+
if (match) {
|
|
18
|
+
const values = match[1].split(",").map((v) => parseFloat(v.trim()));
|
|
19
|
+
[r, g, b, a = 1] = values;
|
|
20
|
+
} else {
|
|
21
|
+
return "#000000";
|
|
22
|
+
}
|
|
23
|
+
} else if (color.startsWith("hsl")) {
|
|
24
|
+
return "#000000";
|
|
25
|
+
} else {
|
|
26
|
+
return "#000000";
|
|
27
|
+
}
|
|
28
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
29
|
+
const effectiveLuminance = luminance * a + (1 - a);
|
|
30
|
+
return effectiveLuminance > 0.5 ? "#000000" : "#ffffff";
|
|
31
|
+
};
|
|
32
|
+
const convertColor = (color, format) => {
|
|
33
|
+
switch (format) {
|
|
34
|
+
case "hex":
|
|
35
|
+
if (color.rgb.a !== void 0 && color.rgb.a < 1) {
|
|
36
|
+
const alpha2 = Math.round(color.rgb.a * 255);
|
|
37
|
+
const alphaHex = alpha2.toString(16).padStart(2, "0");
|
|
38
|
+
return `${color.hex}${alphaHex}`;
|
|
39
|
+
}
|
|
40
|
+
return color.hex;
|
|
41
|
+
case "rgb":
|
|
42
|
+
return `rgb(${Math.round(color.rgb.r)}, ${Math.round(color.rgb.g)}, ${Math.round(color.rgb.b)})`;
|
|
43
|
+
case "rgba":
|
|
44
|
+
const alpha = color.rgb.a !== void 0 ? Number(color.rgb.a.toFixed(2)) : 1;
|
|
45
|
+
return `rgba(${Math.round(color.rgb.r)}, ${Math.round(color.rgb.g)}, ${Math.round(color.rgb.b)}, ${alpha})`;
|
|
46
|
+
case "hsl":
|
|
47
|
+
return `hsl(${Math.round(color.hsl.h)}, ${Math.round(color.hsl.s * 100)}%, ${Math.round(color.hsl.l * 100)}%)`;
|
|
48
|
+
case "hsla":
|
|
49
|
+
const hslaAlpha = color.hsl.a !== void 0 ? Number(color.hsl.a.toFixed(2)) : 1;
|
|
50
|
+
return `hsla(${Math.round(color.hsl.h)}, ${Math.round(color.hsl.s * 100)}%, ${Math.round(color.hsl.l * 100)}%, ${hslaAlpha})`;
|
|
51
|
+
default:
|
|
52
|
+
return color.hex;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const parseColorKey = (key) => {
|
|
56
|
+
const parts = key.split("--");
|
|
57
|
+
const baseName = parts[0];
|
|
58
|
+
const mode = parts[1];
|
|
59
|
+
const baseChips = baseName.split("-").filter((part) => part.length > 0);
|
|
60
|
+
return { baseChips, mode };
|
|
61
|
+
};
|
|
62
|
+
const extractAvailableModes = (pairs) => {
|
|
63
|
+
const modes = /* @__PURE__ */ new Set();
|
|
64
|
+
pairs.forEach((pair) => {
|
|
65
|
+
const { mode } = parseColorKey(pair.key);
|
|
66
|
+
if (mode) {
|
|
67
|
+
modes.add(mode);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return Array.from(modes).sort();
|
|
71
|
+
};
|
|
72
|
+
const getModeIcon = (mode) => {
|
|
73
|
+
if (!mode) return "";
|
|
74
|
+
switch (mode.toLowerCase()) {
|
|
75
|
+
case "light":
|
|
76
|
+
return "\u2600\uFE0F";
|
|
77
|
+
// Sun icon
|
|
78
|
+
case "dark":
|
|
79
|
+
return "\u{1F319}";
|
|
80
|
+
// Moon icon
|
|
81
|
+
default:
|
|
82
|
+
return mode;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const rgbArrayToHex = (rgb) => {
|
|
86
|
+
const [r, g, b] = rgb;
|
|
87
|
+
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
|
|
88
|
+
};
|
|
89
|
+
const rgbArrayToRgbString = (rgb) => {
|
|
90
|
+
const [r, g, b] = rgb;
|
|
91
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
convertColor,
|
|
95
|
+
extractAvailableModes,
|
|
96
|
+
getContrastColor,
|
|
97
|
+
getModeIcon,
|
|
98
|
+
parseColorKey,
|
|
99
|
+
rgbArrayToHex,
|
|
100
|
+
rgbArrayToRgbString
|
|
101
|
+
};
|
|
@@ -1 +1,105 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import { useState, useEffect, useCallback } from "react";
|
|
41
|
+
const useAsyncColorThief = (imageSource, options = {}) => {
|
|
42
|
+
const [result, setResult] = useState({
|
|
43
|
+
dominantColor: null,
|
|
44
|
+
palette: null,
|
|
45
|
+
loading: false,
|
|
46
|
+
error: null
|
|
47
|
+
});
|
|
48
|
+
const extractColors = useCallback((src) => __async(null, null, function* () {
|
|
49
|
+
if (!src) return;
|
|
50
|
+
setResult((prev) => __spreadProps(__spreadValues({}, prev), { loading: true, error: null }));
|
|
51
|
+
try {
|
|
52
|
+
const ColorThief = (yield import("colorthief")).default;
|
|
53
|
+
const img = new Image();
|
|
54
|
+
img.crossOrigin = "anonymous";
|
|
55
|
+
img.onload = () => {
|
|
56
|
+
try {
|
|
57
|
+
const colorThief = new ColorThief();
|
|
58
|
+
const dominantColor = colorThief.getColor(img);
|
|
59
|
+
const palette = colorThief.getPalette(img, options.colorCount || 5, options.quality || 10);
|
|
60
|
+
setResult({
|
|
61
|
+
dominantColor,
|
|
62
|
+
palette,
|
|
63
|
+
loading: false,
|
|
64
|
+
error: null
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error("Color extraction error:", error);
|
|
68
|
+
setResult((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
69
|
+
loading: false,
|
|
70
|
+
error: `Failed to extract colors: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
img.onerror = () => {
|
|
75
|
+
setResult((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
76
|
+
loading: false,
|
|
77
|
+
error: "Failed to load image"
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
img.src = src;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("ColorThief import error:", error);
|
|
83
|
+
setResult((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
84
|
+
loading: false,
|
|
85
|
+
error: `Failed to load Color Thief: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
}), [options.colorCount, options.quality]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (imageSource) {
|
|
91
|
+
extractColors(imageSource);
|
|
92
|
+
} else {
|
|
93
|
+
setResult({
|
|
94
|
+
dominantColor: null,
|
|
95
|
+
palette: null,
|
|
96
|
+
loading: false,
|
|
97
|
+
error: null
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, [imageSource, extractColors]);
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
useAsyncColorThief
|
|
105
|
+
};
|
|
@@ -1 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
41
|
+
import { useCallback, useEffect, useState } from "react";
|
|
42
|
+
import { useRecordContext, useUpdate } from "react-admin";
|
|
43
|
+
import { Switch, Box } from "@mui/material";
|
|
44
|
+
import { AttributeToField } from "dash-auto-admin/src/mui/AttributeToField";
|
|
45
|
+
import AttributeToInput from "dash-auto-admin/src/mui/AttributeToInput";
|
|
46
|
+
const ListActive = ({
|
|
47
|
+
method,
|
|
48
|
+
attribute,
|
|
49
|
+
resourceConfig,
|
|
50
|
+
activeLabel = "Activo",
|
|
51
|
+
inactiveLabel = "Inactivo",
|
|
52
|
+
enableLabel = "Activar",
|
|
53
|
+
disableLabel = "Desactivar",
|
|
54
|
+
showLabel = false
|
|
55
|
+
}) => {
|
|
56
|
+
const [, setLoading] = useState(true);
|
|
57
|
+
const [update, { isLoading: updateLoading }] = useUpdate();
|
|
58
|
+
const record = useRecordContext();
|
|
59
|
+
const [is_active, setIsActive] = useState(false);
|
|
60
|
+
const onError = (error) => {
|
|
61
|
+
console.error(error);
|
|
62
|
+
};
|
|
63
|
+
const onChange = useCallback(
|
|
64
|
+
(value) => __async(null, null, function* () {
|
|
65
|
+
try {
|
|
66
|
+
yield update(
|
|
67
|
+
resourceConfig.model + "/partial/" + record.id,
|
|
68
|
+
{
|
|
69
|
+
id: record.id,
|
|
70
|
+
data: { [attribute.attribute]: value },
|
|
71
|
+
previousData: record,
|
|
72
|
+
meta: {
|
|
73
|
+
method: "POST"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
onSuccess: () => {
|
|
78
|
+
setIsActive(value);
|
|
79
|
+
},
|
|
80
|
+
onSettled: (data, error) => {
|
|
81
|
+
if (error) onError(error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
onError(error);
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
[update, record]
|
|
90
|
+
);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
setLoading(false);
|
|
93
|
+
if (record && attribute && attribute.attribute in record) {
|
|
94
|
+
setIsActive(!!record[attribute.attribute]);
|
|
95
|
+
}
|
|
96
|
+
}, [record, attribute]);
|
|
97
|
+
switch (method) {
|
|
98
|
+
case "create":
|
|
99
|
+
case "edit":
|
|
100
|
+
return AttributeToInput(method, resourceConfig, __spreadProps(__spreadValues({}, attribute), { custom: false, type: Boolean }));
|
|
101
|
+
case "view":
|
|
102
|
+
return AttributeToField(method, resourceConfig, __spreadProps(__spreadValues({}, attribute), { custom: false, type: Boolean }));
|
|
103
|
+
case "list":
|
|
104
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
Switch,
|
|
107
|
+
{
|
|
108
|
+
size: "small",
|
|
109
|
+
onChange: (e, value) => onChange(value),
|
|
110
|
+
checked: is_active
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
showLabel ? is_active ? activeLabel : inactiveLabel : /* @__PURE__ */ jsx(Fragment, {})
|
|
114
|
+
] }) });
|
|
115
|
+
default:
|
|
116
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
117
|
+
attribute.label,
|
|
118
|
+
": ",
|
|
119
|
+
is_active ? activeLabel : inactiveLabel
|
|
120
|
+
] });
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var ListActive_default = ListActive;
|
|
124
|
+
export {
|
|
125
|
+
ListActive_default as default
|
|
126
|
+
};
|