@dashadmin/dash-components 1.3.24 → 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,426 @@
|
|
|
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
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import {
|
|
22
|
+
Box,
|
|
23
|
+
Button,
|
|
24
|
+
TextField,
|
|
25
|
+
Typography,
|
|
26
|
+
Drawer,
|
|
27
|
+
InputAdornment,
|
|
28
|
+
FormControl,
|
|
29
|
+
InputLabel,
|
|
30
|
+
Select,
|
|
31
|
+
MenuItem,
|
|
32
|
+
Tabs,
|
|
33
|
+
Tab,
|
|
34
|
+
Avatar,
|
|
35
|
+
IconButton
|
|
36
|
+
} from "@mui/material";
|
|
37
|
+
import DeleteIcon from "@mui/icons-material/Delete";
|
|
38
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
39
|
+
import { ChromePicker } from "react-color";
|
|
40
|
+
import { useState, useEffect, useRef, useMemo } from "react";
|
|
41
|
+
import { convertColor, getContrastColor, rgbArrayToHex } from "../helpers/functions";
|
|
42
|
+
const ColorEditDialog = ({ open, pair, onClose, onSave, onDelete, existingKeys, updateSingleDomColor, extractedColors = [] }) => {
|
|
43
|
+
const [editedPair, setEditedPair] = useState(null);
|
|
44
|
+
const [colorFormat, setColorFormat] = useState("hex");
|
|
45
|
+
const [keyError, setKeyError] = useState("");
|
|
46
|
+
const [tabValue, setTabValue] = useState(0);
|
|
47
|
+
const lastUpdateRef = useRef(0);
|
|
48
|
+
const pickerStyles = useMemo(() => ({
|
|
49
|
+
default: {
|
|
50
|
+
picker: {
|
|
51
|
+
width: "100%",
|
|
52
|
+
boxShadow: "none"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}), []);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (pair) {
|
|
58
|
+
setEditedPair(__spreadValues({}, pair));
|
|
59
|
+
const value = pair.value.toLowerCase().trim();
|
|
60
|
+
if (value.startsWith("rgba(")) {
|
|
61
|
+
setColorFormat("rgba");
|
|
62
|
+
} else if (value.startsWith("rgb(")) {
|
|
63
|
+
setColorFormat("rgb");
|
|
64
|
+
} else if (value.startsWith("hsla(")) {
|
|
65
|
+
setColorFormat("hsla");
|
|
66
|
+
} else if (value.startsWith("hsl(")) {
|
|
67
|
+
setColorFormat("hsl");
|
|
68
|
+
} else if (value.startsWith("#") && value.length === 9) {
|
|
69
|
+
setColorFormat("rgba");
|
|
70
|
+
} else {
|
|
71
|
+
setColorFormat("hex");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
setKeyError("");
|
|
75
|
+
}, [pair]);
|
|
76
|
+
const handleKeyChange = (newKey) => {
|
|
77
|
+
if (!editedPair) return;
|
|
78
|
+
const isDuplicate = existingKeys.some((key) => key === newKey && newKey !== (pair == null ? void 0 : pair.key));
|
|
79
|
+
setKeyError(isDuplicate ? "Key already exists" : "");
|
|
80
|
+
setEditedPair(__spreadProps(__spreadValues({}, editedPair), { key: newKey }));
|
|
81
|
+
};
|
|
82
|
+
const parseColorForPicker = (colorString) => {
|
|
83
|
+
const trimmed = colorString.toLowerCase().trim();
|
|
84
|
+
if (trimmed.startsWith("rgba(")) {
|
|
85
|
+
const match = trimmed.match(/rgba?\(([^)]+)\)/);
|
|
86
|
+
if (match) {
|
|
87
|
+
const values = match[1].split(",").map((v) => parseFloat(v.trim()));
|
|
88
|
+
const [r, g, b, a = 1] = values;
|
|
89
|
+
return {
|
|
90
|
+
r: Math.round(r),
|
|
91
|
+
g: Math.round(g),
|
|
92
|
+
b: Math.round(b),
|
|
93
|
+
a
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
} else if (trimmed.startsWith("rgb(")) {
|
|
97
|
+
const match = trimmed.match(/rgb\(([^)]+)\)/);
|
|
98
|
+
if (match) {
|
|
99
|
+
const values = match[1].split(",").map((v) => parseFloat(v.trim()));
|
|
100
|
+
const [r, g, b] = values;
|
|
101
|
+
return {
|
|
102
|
+
r: Math.round(r),
|
|
103
|
+
g: Math.round(g),
|
|
104
|
+
b: Math.round(b),
|
|
105
|
+
a: 1
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
} else if (trimmed.startsWith("hsla(")) {
|
|
109
|
+
return colorString;
|
|
110
|
+
} else if (trimmed.startsWith("hsl(")) {
|
|
111
|
+
return colorString;
|
|
112
|
+
} else if (trimmed.startsWith("#")) {
|
|
113
|
+
const hex = trimmed.replace("#", "");
|
|
114
|
+
if (hex.length === 8) {
|
|
115
|
+
const r = parseInt(hex.substr(0, 2), 16);
|
|
116
|
+
const g = parseInt(hex.substr(2, 2), 16);
|
|
117
|
+
const b = parseInt(hex.substr(4, 2), 16);
|
|
118
|
+
const a = parseInt(hex.substr(6, 2), 16) / 255;
|
|
119
|
+
return { r, g, b, a };
|
|
120
|
+
} else if (hex.length === 6) {
|
|
121
|
+
const r = parseInt(hex.substr(0, 2), 16);
|
|
122
|
+
const g = parseInt(hex.substr(2, 2), 16);
|
|
123
|
+
const b = parseInt(hex.substr(4, 2), 16);
|
|
124
|
+
return { r, g, b, a: 1 };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return colorString;
|
|
128
|
+
};
|
|
129
|
+
const handleColorChange = (color) => {
|
|
130
|
+
if (!editedPair) return;
|
|
131
|
+
const colorFormatObj = {
|
|
132
|
+
hex: color.hex,
|
|
133
|
+
rgb: {
|
|
134
|
+
r: Math.round(color.rgb.r),
|
|
135
|
+
g: Math.round(color.rgb.g),
|
|
136
|
+
b: Math.round(color.rgb.b),
|
|
137
|
+
a: color.rgb.a !== void 0 ? color.rgb.a : 1
|
|
138
|
+
},
|
|
139
|
+
hsl: {
|
|
140
|
+
h: Math.round(color.hsl.h || 0),
|
|
141
|
+
s: color.hsl.s || 0,
|
|
142
|
+
l: color.hsl.l || 0,
|
|
143
|
+
a: color.hsl.a !== void 0 ? color.hsl.a : color.rgb.a !== void 0 ? color.rgb.a : 1
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const newValue = convertColor(colorFormatObj, colorFormat);
|
|
147
|
+
setEditedPair(__spreadProps(__spreadValues({}, editedPair), { value: newValue }));
|
|
148
|
+
const now = Date.now();
|
|
149
|
+
if (now - lastUpdateRef.current >= 16) {
|
|
150
|
+
updateSingleDomColor(editedPair.key, newValue);
|
|
151
|
+
lastUpdateRef.current = now;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const handleExtractedColorSelect = (colorRgb) => {
|
|
155
|
+
if (!editedPair) return;
|
|
156
|
+
const hexColor = rgbArrayToHex(colorRgb);
|
|
157
|
+
setEditedPair(__spreadProps(__spreadValues({}, editedPair), { value: hexColor }));
|
|
158
|
+
updateSingleDomColor(editedPair.key, hexColor);
|
|
159
|
+
};
|
|
160
|
+
const handleSave = () => {
|
|
161
|
+
if (!editedPair || keyError || !editedPair.key.trim()) return;
|
|
162
|
+
onSave(editedPair);
|
|
163
|
+
onClose();
|
|
164
|
+
};
|
|
165
|
+
const handleDelete = () => {
|
|
166
|
+
if (!editedPair) return;
|
|
167
|
+
onDelete(editedPair.id);
|
|
168
|
+
onClose();
|
|
169
|
+
};
|
|
170
|
+
if (!editedPair) return null;
|
|
171
|
+
return /* @__PURE__ */ jsxs(
|
|
172
|
+
Drawer,
|
|
173
|
+
{
|
|
174
|
+
anchor: "right",
|
|
175
|
+
open,
|
|
176
|
+
onClose,
|
|
177
|
+
BackdropProps: { invisible: true },
|
|
178
|
+
PaperProps: {
|
|
179
|
+
sx: {
|
|
180
|
+
width: { xs: "100%", sm: 460 },
|
|
181
|
+
maxWidth: "100vw",
|
|
182
|
+
display: "flex",
|
|
183
|
+
flexDirection: "column"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsxs(Box, { sx: {
|
|
188
|
+
display: "flex",
|
|
189
|
+
alignItems: "center",
|
|
190
|
+
justifyContent: "space-between",
|
|
191
|
+
px: 2,
|
|
192
|
+
py: 1.5,
|
|
193
|
+
borderBottom: "1px solid",
|
|
194
|
+
borderColor: "divider",
|
|
195
|
+
flexShrink: 0
|
|
196
|
+
}, children: [
|
|
197
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { fontWeight: 600 }, children: (pair == null ? void 0 : pair.key) ? `Edit: ${pair.key}` : "Add New Color" }),
|
|
198
|
+
/* @__PURE__ */ jsx(IconButton, { onClick: onClose, size: "small", children: /* @__PURE__ */ jsx(CloseIcon, {}) })
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ jsxs(Box, { sx: {
|
|
201
|
+
flex: 1,
|
|
202
|
+
overflowY: "auto",
|
|
203
|
+
px: 2,
|
|
204
|
+
py: 2,
|
|
205
|
+
display: "flex",
|
|
206
|
+
flexDirection: "column",
|
|
207
|
+
gap: 3
|
|
208
|
+
}, children: [
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
TextField,
|
|
211
|
+
{
|
|
212
|
+
fullWidth: true,
|
|
213
|
+
label: "Color Name",
|
|
214
|
+
value: editedPair.key,
|
|
215
|
+
onChange: (e) => handleKeyChange(e.target.value),
|
|
216
|
+
error: !!keyError,
|
|
217
|
+
helperText: keyError,
|
|
218
|
+
placeholder: "e.g., primary-color--light, background-dark--dark",
|
|
219
|
+
size: "small"
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ jsxs(FormControl, { fullWidth: true, size: "small", children: [
|
|
223
|
+
/* @__PURE__ */ jsx(InputLabel, { children: "Color Format" }),
|
|
224
|
+
/* @__PURE__ */ jsxs(
|
|
225
|
+
Select,
|
|
226
|
+
{
|
|
227
|
+
value: colorFormat,
|
|
228
|
+
label: "Color Format",
|
|
229
|
+
onChange: (e) => setColorFormat(e.target.value),
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "hex", children: "HEX" }),
|
|
232
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "rgb", children: "RGB" }),
|
|
233
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "rgba", children: "RGBA (with alpha)" }),
|
|
234
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "hsl", children: "HSL" }),
|
|
235
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "hsla", children: "HSLA (with alpha)" })
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
241
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "Color Picker" }),
|
|
242
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
243
|
+
/* @__PURE__ */ jsxs(Tabs, { value: tabValue, onChange: (_, newValue) => setTabValue(newValue), variant: "fullWidth", children: [
|
|
244
|
+
/* @__PURE__ */ jsx(Tab, { label: "Picker" }),
|
|
245
|
+
/* @__PURE__ */ jsx(Tab, { label: "Manual" })
|
|
246
|
+
] }),
|
|
247
|
+
tabValue === 0 && /* @__PURE__ */ jsx(Box, { sx: { mt: 2, display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsx(
|
|
248
|
+
ChromePicker,
|
|
249
|
+
{
|
|
250
|
+
color: editedPair.value,
|
|
251
|
+
onChange: handleColorChange,
|
|
252
|
+
disableAlpha: false,
|
|
253
|
+
styles: pickerStyles
|
|
254
|
+
}
|
|
255
|
+
) }),
|
|
256
|
+
tabValue === 1 && /* @__PURE__ */ jsx(Box, { sx: { mt: 2 }, children: /* @__PURE__ */ jsx(
|
|
257
|
+
TextField,
|
|
258
|
+
{
|
|
259
|
+
fullWidth: true,
|
|
260
|
+
size: "small",
|
|
261
|
+
label: `Color Value (${colorFormat.toUpperCase()})`,
|
|
262
|
+
value: editedPair.value,
|
|
263
|
+
onChange: (e) => {
|
|
264
|
+
const newValue = e.target.value;
|
|
265
|
+
setEditedPair(__spreadProps(__spreadValues({}, editedPair), { value: newValue }));
|
|
266
|
+
updateSingleDomColor(editedPair.key, newValue);
|
|
267
|
+
},
|
|
268
|
+
placeholder: colorFormat === "hex" ? "#ff0000" : colorFormat === "rgb" ? "rgb(255, 0, 0)" : colorFormat === "rgba" ? "rgba(255, 0, 0, 0.5)" : colorFormat === "hsl" ? "hsl(0, 100%, 50%)" : "hsla(0, 100%, 50%, 0.5)",
|
|
269
|
+
helperText: colorFormat === "rgba" ? "Alpha value should be between 0 and 1 (e.g., 0.1, 0.5, 1)" : colorFormat === "hsla" ? "Alpha value should be between 0 and 1 (e.g., 0.1, 0.5, 1)" : void 0,
|
|
270
|
+
InputProps: {
|
|
271
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(
|
|
272
|
+
Box,
|
|
273
|
+
{
|
|
274
|
+
sx: {
|
|
275
|
+
width: 20,
|
|
276
|
+
height: 20,
|
|
277
|
+
backgroundColor: editedPair.value,
|
|
278
|
+
border: "1px solid #ccc",
|
|
279
|
+
borderRadius: 1,
|
|
280
|
+
// Add a checkerboard pattern background for transparency preview
|
|
281
|
+
backgroundImage: colorFormat === "rgba" || colorFormat === "hsla" ? "linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)" : "none",
|
|
282
|
+
backgroundSize: "4px 4px",
|
|
283
|
+
backgroundPosition: "0 0, 0 2px, 2px -2px, -2px 0px"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
) })
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
) })
|
|
290
|
+
] })
|
|
291
|
+
] }),
|
|
292
|
+
extractedColors.length > 0 && /* @__PURE__ */ jsxs(Box, { children: [
|
|
293
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "Extracted Colors" }),
|
|
294
|
+
/* @__PURE__ */ jsx(Box, { sx: {
|
|
295
|
+
display: "flex",
|
|
296
|
+
flexWrap: "wrap",
|
|
297
|
+
gap: 1,
|
|
298
|
+
p: 2,
|
|
299
|
+
border: "1px solid",
|
|
300
|
+
borderColor: "divider",
|
|
301
|
+
borderRadius: 1,
|
|
302
|
+
backgroundColor: "action.hover"
|
|
303
|
+
}, children: extractedColors.map((color, index) => {
|
|
304
|
+
const hexColor = rgbArrayToHex(color);
|
|
305
|
+
const isSelected = editedPair.value === hexColor;
|
|
306
|
+
return /* @__PURE__ */ jsx(
|
|
307
|
+
Avatar,
|
|
308
|
+
{
|
|
309
|
+
sx: {
|
|
310
|
+
width: 36,
|
|
311
|
+
height: 36,
|
|
312
|
+
backgroundColor: hexColor,
|
|
313
|
+
border: isSelected ? "3px solid #1976d2" : "2px solid #ccc",
|
|
314
|
+
cursor: "pointer",
|
|
315
|
+
transition: "all 0.2s",
|
|
316
|
+
"&:hover": {
|
|
317
|
+
transform: "scale(1.1)",
|
|
318
|
+
boxShadow: 2
|
|
319
|
+
},
|
|
320
|
+
color: getContrastColor(hexColor),
|
|
321
|
+
fontWeight: "bold",
|
|
322
|
+
fontSize: "0.7rem"
|
|
323
|
+
},
|
|
324
|
+
onClick: () => handleExtractedColorSelect(color),
|
|
325
|
+
title: `Use extracted color: ${hexColor}`,
|
|
326
|
+
children: index + 1
|
|
327
|
+
},
|
|
328
|
+
index
|
|
329
|
+
);
|
|
330
|
+
}) }),
|
|
331
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "textSecondary", sx: { mt: 1, display: "block" }, children: "Click any color to use it" })
|
|
332
|
+
] }),
|
|
333
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
334
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "Preview" }),
|
|
335
|
+
/* @__PURE__ */ jsx(
|
|
336
|
+
Box,
|
|
337
|
+
{
|
|
338
|
+
sx: {
|
|
339
|
+
width: "100%",
|
|
340
|
+
height: 80,
|
|
341
|
+
backgroundColor: editedPair.value,
|
|
342
|
+
border: "1px solid #ccc",
|
|
343
|
+
borderRadius: 1,
|
|
344
|
+
display: "flex",
|
|
345
|
+
alignItems: "center",
|
|
346
|
+
justifyContent: "center",
|
|
347
|
+
position: "relative",
|
|
348
|
+
// Add checkerboard background for alpha preview
|
|
349
|
+
backgroundImage: editedPair.value.includes("rgba") || editedPair.value.includes("hsla") ? "linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%)" : "none",
|
|
350
|
+
backgroundSize: "10px 10px",
|
|
351
|
+
backgroundPosition: "0 0, 0 5px, 5px -5px, -5px 0px"
|
|
352
|
+
},
|
|
353
|
+
children: /* @__PURE__ */ jsx(
|
|
354
|
+
Box,
|
|
355
|
+
{
|
|
356
|
+
sx: {
|
|
357
|
+
width: "100%",
|
|
358
|
+
height: "100%",
|
|
359
|
+
backgroundColor: editedPair.value,
|
|
360
|
+
borderRadius: 1,
|
|
361
|
+
display: "flex",
|
|
362
|
+
alignItems: "center",
|
|
363
|
+
justifyContent: "center"
|
|
364
|
+
},
|
|
365
|
+
children: /* @__PURE__ */ jsx(
|
|
366
|
+
Typography,
|
|
367
|
+
{
|
|
368
|
+
variant: "body2",
|
|
369
|
+
sx: {
|
|
370
|
+
color: getContrastColor(editedPair.value),
|
|
371
|
+
fontWeight: "bold",
|
|
372
|
+
backgroundColor: "rgba(0,0,0,0.1)",
|
|
373
|
+
padding: "4px 8px",
|
|
374
|
+
borderRadius: 1
|
|
375
|
+
},
|
|
376
|
+
children: editedPair.key || "Color Preview"
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] })
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ jsxs(Box, { sx: {
|
|
386
|
+
display: "flex",
|
|
387
|
+
alignItems: "center",
|
|
388
|
+
gap: 1,
|
|
389
|
+
px: 2,
|
|
390
|
+
py: 1.5,
|
|
391
|
+
borderTop: "1px solid",
|
|
392
|
+
borderColor: "divider",
|
|
393
|
+
flexShrink: 0,
|
|
394
|
+
backgroundColor: "background.paper"
|
|
395
|
+
}, children: [
|
|
396
|
+
(pair == null ? void 0 : pair.key) && /* @__PURE__ */ jsx(
|
|
397
|
+
Button,
|
|
398
|
+
{
|
|
399
|
+
onClick: handleDelete,
|
|
400
|
+
color: "error",
|
|
401
|
+
startIcon: /* @__PURE__ */ jsx(DeleteIcon, {}),
|
|
402
|
+
size: "small",
|
|
403
|
+
children: "Delete"
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
/* @__PURE__ */ jsx(Box, { sx: { flexGrow: 1 } }),
|
|
407
|
+
/* @__PURE__ */ jsx(Button, { onClick: onClose, size: "small", children: "Cancel" }),
|
|
408
|
+
/* @__PURE__ */ jsx(
|
|
409
|
+
Button,
|
|
410
|
+
{
|
|
411
|
+
onClick: handleSave,
|
|
412
|
+
variant: "contained",
|
|
413
|
+
disabled: !!keyError || !editedPair.key.trim(),
|
|
414
|
+
size: "small",
|
|
415
|
+
children: "Save"
|
|
416
|
+
}
|
|
417
|
+
)
|
|
418
|
+
] })
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
var ColorEditDialog_default = ColorEditDialog;
|
|
424
|
+
export {
|
|
425
|
+
ColorEditDialog_default as default
|
|
426
|
+
};
|
|
@@ -1 +1,75 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Chip
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import { getContrastColor, getModeIcon, parseColorKey } from "../helpers/functions";
|
|
7
|
+
const ColorPaletteItem = ({ pair, onEdit, onDelete }) => {
|
|
8
|
+
const textColor = getContrastColor(pair.value);
|
|
9
|
+
const { baseChips, mode } = parseColorKey(pair.key);
|
|
10
|
+
const modeIcon = getModeIcon(mode);
|
|
11
|
+
return /* @__PURE__ */ jsxs(
|
|
12
|
+
Box,
|
|
13
|
+
{
|
|
14
|
+
sx: {
|
|
15
|
+
aspectRatio: "unset",
|
|
16
|
+
height: "30px",
|
|
17
|
+
cursor: "pointer",
|
|
18
|
+
transition: "all 0.2s ease-in-out",
|
|
19
|
+
"&:hover": {
|
|
20
|
+
transform: "translateY(-2px)",
|
|
21
|
+
boxShadow: 3
|
|
22
|
+
},
|
|
23
|
+
position: "relative",
|
|
24
|
+
overflow: "hidden",
|
|
25
|
+
backgroundColor: pair.value,
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "flex-start",
|
|
30
|
+
padding: "0 8px",
|
|
31
|
+
gap: 0.5
|
|
32
|
+
},
|
|
33
|
+
onClick: () => onEdit(pair),
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsx(Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.25, justifyContent: "center" }, children: baseChips.map((chip, index) => /* @__PURE__ */ jsx(
|
|
36
|
+
Chip,
|
|
37
|
+
{
|
|
38
|
+
label: chip,
|
|
39
|
+
size: "small",
|
|
40
|
+
sx: {
|
|
41
|
+
height: 16,
|
|
42
|
+
fontSize: "0.6rem",
|
|
43
|
+
backgroundColor: "rgba(255,255,255,0.9)",
|
|
44
|
+
color: "#333",
|
|
45
|
+
"& .MuiChip-label": {
|
|
46
|
+
padding: "0 4px"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
index
|
|
51
|
+
)) }),
|
|
52
|
+
mode && /* @__PURE__ */ jsx(
|
|
53
|
+
Chip,
|
|
54
|
+
{
|
|
55
|
+
label: modeIcon,
|
|
56
|
+
size: "small",
|
|
57
|
+
sx: {
|
|
58
|
+
height: 16,
|
|
59
|
+
fontSize: "0.6rem",
|
|
60
|
+
backgroundColor: "rgba(0,0,0,0.7)",
|
|
61
|
+
color: "#fff",
|
|
62
|
+
"& .MuiChip-label": {
|
|
63
|
+
padding: "0 4px"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
var ColorPaletteItem_default = ColorPaletteItem;
|
|
73
|
+
export {
|
|
74
|
+
ColorPaletteItem_default as default
|
|
75
|
+
};
|