@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.
Files changed (111) hide show
  1. package/dist/components/AuditLog/AuditLog.js +345 -1
  2. package/dist/components/AuditLog/index.js +4 -1
  3. package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
  4. package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
  5. package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
  6. package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
  7. package/dist/components/Json/Json.js +235 -1
  8. package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
  9. package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
  10. package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
  11. package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
  12. package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
  13. package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
  14. package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
  15. package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
  16. package/dist/components/ListActive/ListActive.js +126 -1
  17. package/dist/components/ListActive/ListBoolean.js +124 -1
  18. package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
  19. package/dist/components/NotificationPreferences/index.js +7 -1
  20. package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
  21. package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
  22. package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
  23. package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
  24. package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
  25. package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
  26. package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
  27. package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
  28. package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
  29. package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
  30. package/dist/components/Upload/SingleImageUploader.js +40 -1
  31. package/dist/components/custom/PackageCopyMethod.js +78 -1
  32. package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
  33. package/dist/components/dialog/Basic.js +8 -1
  34. package/dist/components/dialog/Correct.js +14 -1
  35. package/dist/components/dialog/Error.js +14 -1
  36. package/dist/components/dialog/Info.js +14 -1
  37. package/dist/components/dialog/InfoV2.js +21 -1
  38. package/dist/components/dialog/NotFound.js +14 -1
  39. package/dist/components/dialog/QuickSearch.js +117 -1
  40. package/dist/components/notifications/NotificationsCenter.js +597 -1
  41. package/dist/components/notifications/index.js +24 -1
  42. package/dist/components/tables/PaginationComponent.js +36 -1
  43. package/dist/components/theme/AppLoadingFallback.js +38 -2
  44. package/dist/components/theme/ErrorBoundary.js +52 -1
  45. package/dist/components/theme/InitialLoader.js +13 -1
  46. package/dist/components/theme/NotFound.js +136 -1
  47. package/dist/components/theme/NotResults.js +38 -1
  48. package/dist/hooks/useDraggable.js +6 -1
  49. package/dist/hooks/useNotifications.js +8 -1
  50. package/dist/hooks/useQuickSearch.js +26 -1
  51. package/dist/index.js +66 -5567
  52. package/dist/utils/setNativeValue.js +17 -1
  53. package/package.json +149 -132
  54. package/src/components/AuditLog/AuditLog.tsx +476 -0
  55. package/src/components/AuditLog/index.ts +2 -0
  56. package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
  57. package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
  58. package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
  59. package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
  60. package/src/components/Json/Json.tsx +312 -0
  61. package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
  62. package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
  63. package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
  64. package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
  65. package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
  66. package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
  67. package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
  68. package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
  69. package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
  70. package/src/components/ListActive/ListActive.tsx +106 -0
  71. package/src/components/ListActive/ListBoolean.tsx +96 -0
  72. package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
  73. package/src/components/NotificationPreferences/index.tsx +2 -0
  74. package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
  75. package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
  76. package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
  77. package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
  78. package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
  79. package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
  80. package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
  81. package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
  82. package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
  83. package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
  84. package/src/components/Upload/SingleImageUploader.tsx +55 -0
  85. package/src/components/custom/PackageCopyMethod.tsx +109 -0
  86. package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
  87. package/src/components/dialog/Basic.tsx +11 -0
  88. package/src/components/dialog/Correct.tsx +16 -0
  89. package/src/components/dialog/Error.tsx +15 -0
  90. package/src/components/dialog/Info.tsx +15 -0
  91. package/src/components/dialog/InfoV2.tsx +35 -0
  92. package/src/components/dialog/NotFound.tsx +18 -0
  93. package/src/components/dialog/QuickSearch.tsx +115 -0
  94. package/src/components/notifications/NotificationsCenter.tsx +792 -0
  95. package/src/components/notifications/index.ts +42 -0
  96. package/src/components/tables/PaginationComponent.tsx +17 -0
  97. package/src/components/theme/AppLoadingFallback.tsx +42 -0
  98. package/src/components/theme/ErrorBoundary.tsx +57 -0
  99. package/src/components/theme/InitialLoader.tsx +16 -0
  100. package/src/components/theme/NotFound.tsx +124 -0
  101. package/src/components/theme/NotResults.tsx +54 -0
  102. package/src/hooks/useDraggable.ts +11 -0
  103. package/src/hooks/useNotifications.ts +14 -0
  104. package/src/hooks/useQuickSearch.tsx +29 -0
  105. package/src/index.tsx +77 -0
  106. package/src/utils/setNativeValue.tsx +23 -0
  107. package/dist/color-thief-CTwGFhOB.js +0 -272
  108. /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
  109. /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
  110. /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
  111. /package/{dist → src}/styles/index.less +0 -0
@@ -1 +1,426 @@
1
- import{jsx as t,jsxs as i}from"react/jsx-runtime";import{Box as n,Button as I,TextField as W,Typography as p,Drawer as U,InputAdornment as $,FormControl as N,InputLabel as O,Select as X,MenuItem as f,Tabs as Y,Tab as M,Avatar as _,IconButton as q}from"@mui/material";import J from"@mui/icons-material/Delete";import Q from"@mui/icons-material/Close";import{ChromePicker as Z}from"react-color";import{useState as y,useEffect as ee,useRef as te,useMemo as re}from"react";import{convertColor as ae,getContrastColor as P,rgbArrayToHex as F}from"../helpers/functions";const oe=({open:S,pair:d,onClose:g,onSave:A,onDelete:z,existingKeys:D,updateSingleDomColor:v,extractedColors:w=[]})=>{const[r,b]=y(null),[s,u]=y("hex"),[m,B]=y(""),[C,R]=y(0),T=te(0),E=re(()=>({default:{picker:{width:"100%",boxShadow:"none"}}}),[]);ee(()=>{if(d){b({...d});const e=d.value.toLowerCase().trim();e.startsWith("rgba(")?u("rgba"):e.startsWith("rgb(")?u("rgb"):e.startsWith("hsla(")?u("hsla"):e.startsWith("hsl(")?u("hsl"):e.startsWith("#")&&e.length===9?u("rgba"):u("hex")}B("")},[d]);const V=e=>{if(!r)return;const o=D.some(a=>a===e&&e!==d?.key);B(o?"Key already exists":""),b({...r,key:e})},ne=e=>{const o=e.toLowerCase().trim();if(o.startsWith("rgba(")){const a=o.match(/rgba?\(([^)]+)\)/);if(a){const l=a[1].split(",").map(G=>parseFloat(G.trim())),[c,h,x,k=1]=l;return{r:Math.round(c),g:Math.round(h),b:Math.round(x),a:k}}}else if(o.startsWith("rgb(")){const a=o.match(/rgb\(([^)]+)\)/);if(a){const l=a[1].split(",").map(k=>parseFloat(k.trim())),[c,h,x]=l;return{r:Math.round(c),g:Math.round(h),b:Math.round(x),a:1}}}else{if(o.startsWith("hsla("))return e;if(o.startsWith("hsl("))return e;if(o.startsWith("#")){const a=o.replace("#","");if(a.length===8){const l=parseInt(a.substr(0,2),16),c=parseInt(a.substr(2,2),16),h=parseInt(a.substr(4,2),16),x=parseInt(a.substr(6,2),16)/255;return{r:l,g:c,b:h,a:x}}else if(a.length===6){const l=parseInt(a.substr(0,2),16),c=parseInt(a.substr(2,2),16),h=parseInt(a.substr(4,2),16);return{r:l,g:c,b:h,a:1}}}}return e},K=e=>{if(!r)return;const o={hex:e.hex,rgb:{r:Math.round(e.rgb.r),g:Math.round(e.rgb.g),b:Math.round(e.rgb.b),a:e.rgb.a!==void 0?e.rgb.a:1},hsl:{h:Math.round(e.hsl.h||0),s:e.hsl.s||0,l:e.hsl.l||0,a:e.hsl.a!==void 0?e.hsl.a:e.rgb.a!==void 0?e.rgb.a:1}},a=ae(o,s);b({...r,value:a});const l=Date.now();l-T.current>=16&&(v(r.key,a),T.current=l)},L=e=>{if(!r)return;const o=F(e);b({...r,value:o}),v(r.key,o)},j=()=>{!r||m||!r.key.trim()||(A(r),g())},H=()=>{r&&(z(r.id),g())};return r?i(U,{anchor:"right",open:S,onClose:g,BackdropProps:{invisible:!0},PaperProps:{sx:{width:{xs:"100%",sm:460},maxWidth:"100vw",display:"flex",flexDirection:"column"}},children:[i(n,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t(p,{variant:"h6",sx:{fontWeight:600},children:d?.key?`Edit: ${d.key}`:"Add New Color"}),t(q,{onClick:g,size:"small",children:t(Q,{})})]}),i(n,{sx:{flex:1,overflowY:"auto",px:2,py:2,display:"flex",flexDirection:"column",gap:3},children:[t(W,{fullWidth:!0,label:"Color Name",value:r.key,onChange:e=>V(e.target.value),error:!!m,helperText:m,placeholder:"e.g., primary-color--light, background-dark--dark",size:"small"}),i(N,{fullWidth:!0,size:"small",children:[t(O,{children:"Color Format"}),i(X,{value:s,label:"Color Format",onChange:e=>u(e.target.value),children:[t(f,{value:"hex",children:"HEX"}),t(f,{value:"rgb",children:"RGB"}),t(f,{value:"rgba",children:"RGBA (with alpha)"}),t(f,{value:"hsl",children:"HSL"}),t(f,{value:"hsla",children:"HSLA (with alpha)"})]})]}),i(n,{children:[t(p,{variant:"subtitle2",gutterBottom:!0,children:"Color Picker"}),i(n,{children:[i(Y,{value:C,onChange:(e,o)=>R(o),variant:"fullWidth",children:[t(M,{label:"Picker"}),t(M,{label:"Manual"})]}),C===0&&t(n,{sx:{mt:2,display:"flex",justifyContent:"center"},children:t(Z,{color:r.value,onChange:K,disableAlpha:!1,styles:E})}),C===1&&t(n,{sx:{mt:2},children:t(W,{fullWidth:!0,size:"small",label:`Color Value (${s.toUpperCase()})`,value:r.value,onChange:e=>{const o=e.target.value;b({...r,value:o}),v(r.key,o)},placeholder:s==="hex"?"#ff0000":s==="rgb"?"rgb(255, 0, 0)":s==="rgba"?"rgba(255, 0, 0, 0.5)":s==="hsl"?"hsl(0, 100%, 50%)":"hsla(0, 100%, 50%, 0.5)",helperText:s==="rgba"||s==="hsla"?"Alpha value should be between 0 and 1 (e.g., 0.1, 0.5, 1)":void 0,InputProps:{startAdornment:t($,{position:"start",children:t(n,{sx:{width:20,height:20,backgroundColor:r.value,border:"1px solid #ccc",borderRadius:1,backgroundImage:s==="rgba"||s==="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",backgroundSize:"4px 4px",backgroundPosition:"0 0, 0 2px, 2px -2px, -2px 0px"}})})}})})]})]}),w.length>0&&i(n,{children:[t(p,{variant:"subtitle2",gutterBottom:!0,children:"Extracted Colors"}),t(n,{sx:{display:"flex",flexWrap:"wrap",gap:1,p:2,border:"1px solid",borderColor:"divider",borderRadius:1,backgroundColor:"action.hover"},children:w.map((e,o)=>{const a=F(e),l=r.value===a;return t(_,{sx:{width:36,height:36,backgroundColor:a,border:l?"3px solid #1976d2":"2px solid #ccc",cursor:"pointer",transition:"all 0.2s","&:hover":{transform:"scale(1.1)",boxShadow:2},color:P(a),fontWeight:"bold",fontSize:"0.7rem"},onClick:()=>L(e),title:`Use extracted color: ${a}`,children:o+1},o)})}),t(p,{variant:"caption",color:"textSecondary",sx:{mt:1,display:"block"},children:"Click any color to use it"})]}),i(n,{children:[t(p,{variant:"subtitle2",gutterBottom:!0,children:"Preview"}),t(n,{sx:{width:"100%",height:80,backgroundColor:r.value,border:"1px solid #ccc",borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",backgroundImage:r.value.includes("rgba")||r.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",backgroundSize:"10px 10px",backgroundPosition:"0 0, 0 5px, 5px -5px, -5px 0px"},children:t(n,{sx:{width:"100%",height:"100%",backgroundColor:r.value,borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center"},children:t(p,{variant:"body2",sx:{color:P(r.value),fontWeight:"bold",backgroundColor:"rgba(0,0,0,0.1)",padding:"4px 8px",borderRadius:1},children:r.key||"Color Preview"})})})]})]}),i(n,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1.5,borderTop:"1px solid",borderColor:"divider",flexShrink:0,backgroundColor:"background.paper"},children:[d?.key&&t(I,{onClick:H,color:"error",startIcon:t(J,{}),size:"small",children:"Delete"}),t(n,{sx:{flexGrow:1}}),t(I,{onClick:g,size:"small",children:"Cancel"}),t(I,{onClick:j,variant:"contained",disabled:!!m||!r.key.trim(),size:"small",children:"Save"})]})]}):null};var xe=oe;export{xe as default};
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 as o,jsxs as g}from"react/jsx-runtime";import{Box as a,Chip as r}from"@mui/material";import{getContrastColor as d,getModeIcon as x,parseColorKey as f}from"../helpers/functions";const c=({pair:e,onEdit:l,onDelete:u})=>{const C=d(e.value),{baseChips:i,mode:t}=f(e.key),n=x(t);return g(a,{sx:{aspectRatio:"unset",height:"30px",cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{transform:"translateY(-2px)",boxShadow:3},position:"relative",overflow:"hidden",backgroundColor:e.value,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",padding:"0 8px",gap:.5},onClick:()=>l(e),children:[o(a,{sx:{display:"flex",flexWrap:"wrap",gap:.25,justifyContent:"center"},children:i.map((s,p)=>o(r,{label:s,size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:"rgba(255,255,255,0.9)",color:"#333","& .MuiChip-label":{padding:"0 4px"}}},p))}),t&&o(r,{label:n,size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:"rgba(0,0,0,0.7)",color:"#fff","& .MuiChip-label":{padding:"0 4px"}}})]})};var v=c;export{v as default};
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
+ };