@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,53 @@
1
- import{jsx as a}from"react/jsx-runtime";const o=({defaultValue:e,...t})=>a(AutocompleteCheckBoxInput,{...t,multiple:!0,defaultValue:e??[]});var d=o;export{d 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
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { jsx } from "react/jsx-runtime";
33
+ const AutocompleteCheckBoxArrayInput = (_a) => {
34
+ var _b = _a, {
35
+ defaultValue
36
+ } = _b, props = __objRest(_b, [
37
+ "defaultValue"
38
+ ]);
39
+ return (
40
+ /* @ts-ignore Expected */
41
+ /* @__PURE__ */ jsx(
42
+ AutocompleteCheckBoxInput,
43
+ __spreadProps(__spreadValues({}, props), {
44
+ multiple: true,
45
+ defaultValue: defaultValue != null ? defaultValue : []
46
+ })
47
+ )
48
+ );
49
+ };
50
+ var AutocompleteCheckBoxArrayInput_default = AutocompleteCheckBoxArrayInput;
51
+ export {
52
+ AutocompleteCheckBoxArrayInput_default as default
53
+ };
@@ -1 +1,235 @@
1
- import{jsx as s,jsxs as m}from"react/jsx-runtime";import{useRecordContext as N}from"react-admin";import{useFormContext as G}from"react-hook-form";import{Box as R,Button as L,IconButton as Q,TextField as A,Typography as P,Table as I,TableBody as D,TableCell as u,TableContainer as F,TableHead as z,TableRow as v,Paper as K}from"@mui/material";import U from"@mui/icons-material/Delete";import X from"@mui/icons-material/Add";import{useState as O,useEffect as Y}from"react";const j=c=>{const{method:b,attribute:r,resourceConfig:f}=c,d=N(),{setValue:C,getValues:y}=G(),l=r.attribute,g=l.startsWith("settings."),h=g?l.split(".").slice(1).join("."):l,[a,T]=O([]),[p,x]=O({});Y(()=>{let t={};if(g&&d?.settings){const i=d.settings||{};t=J(i,h)||{}}else d?.[l]&&(t=d[l]||{});const n=Object.entries(t).map(([i,e])=>({key:i,value:typeof e=="object"?JSON.stringify(e):String(e),id:w()}));T(n)},[d,l]);const J=(t,n)=>n?n.split(".").reduce((e,o)=>e&&e[o]!==void 0?e[o]:{},t):t,W=(t,n,i)=>{if(!n)return i;const e=n.split("."),o=e.pop(),B=e.reduce((S,V)=>(S[V]===void 0&&(S[V]={}),S[V]),t);return o&&(B[o]=i),t},w=()=>Math.random().toString(36).substring(2,11),E=()=>{T([...a,{key:"",value:"",id:w()}])},H=t=>{T(a.filter(n=>n.id!==t)),k(a.filter(n=>n.id!==t))},M=(t,n)=>{const i=a.some(o=>o.id!==t&&o.key===n);x(i?{...p,[t]:"Duplicate key"}:{...p,[t]:""});const e=a.map(o=>o.id===t?{...o,key:n}:o);T(e),k(e)},q=(t,n)=>{const i=a.map(e=>e.id===t?{...e,value:n}:e);T(i),k(i)},k=t=>{const n=t.reduce((i,e)=>{if(e.key.trim()){let o=e.value;try{(e.value.trim().startsWith("{")||e.value.trim().startsWith("[")||e.value.trim()==="true"||e.value.trim()==="false"||!isNaN(Number(e.value.trim())))&&(o=JSON.parse(e.value))}catch{}i[e.key]=o}return i},{});if(g){const i=y("settings")||{},e=W({...i},h,n);C("settings",e,{shouldDirty:!0})}else C(l,n,{shouldDirty:!0})};return m(R,{sx:{mt:1,mb:2},children:[s(P,{variant:"subtitle1",gutterBottom:!0,children:r.label||"Settings Editor"}),s(F,{component:K,sx:{mb:2},children:m(I,{size:"small",children:[s(z,{children:m(v,{children:[s(u,{width:"40%",children:"Key"}),s(u,{width:"50%",children:"Value"}),s(u,{width:"10%",align:"center",children:"Actions"})]})}),s(D,{children:a.map(t=>m(v,{children:[s(u,{children:s(A,{fullWidth:!0,size:"small",value:t.key,onChange:n=>M(t.id,n.target.value),error:!!p[t.id],helperText:p[t.id]})}),s(u,{children:s(A,{fullWidth:!0,size:"small",value:t.value,onChange:n=>q(t.id,n.target.value)})}),s(u,{align:"center",children:s(Q,{size:"small",onClick:()=>H(t.id),color:"error",children:s(U,{fontSize:"small"})})})]},t.id))})]})}),s(L,{startIcon:s(X,{}),variant:"outlined",size:"small",onClick:E,children:"+"})]})},Z=c=>{const{attribute:b}=c,r=N(),f=b.attribute,d=f.startsWith("settings."),C=d?f.split(".").slice(1).join("."):f;let y={};if(d&&r?.settings){const l=r.settings||{};C?y=C.split(".").reduce((h,a)=>h&&h[a]!==void 0?h[a]:{},l):y=l}else r?.[f]&&(y=r[f]);return m(R,{sx:{mt:1,mb:2},children:[s(P,{variant:"subtitle1",gutterBottom:!0,children:b.label||"Settings"}),Object.keys(y).length>0?s(F,{component:K,children:m(I,{size:"small",children:[s(z,{children:m(v,{children:[s(u,{width:"40%",children:"Key"}),s(u,{width:"60%",children:"Value"})]})}),s(D,{children:Object.entries(y).map(([l,g])=>m(v,{children:[s(u,{children:l}),s(u,{children:typeof g=="object"?JSON.stringify(g):String(g)})]},l))})]})}):s(P,{variant:"body2",color:"textSecondary",children:"No settings configured"})]})},_=({method:c,attribute:b,resourceConfig:r})=>{switch(c){case"edit":return s(j,{attribute:b,method:c,resourceConfig:r});case"create":return s(j,{attribute:b,method:c,resourceConfig:r});case"view":return s(Z,{attribute:b,method:c,resourceConfig:r});default:return null}};var rt=_;export{j as JsonEdit,Z as JsonView,rt 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 { useRecordContext } from "react-admin";
22
+ import { useFormContext } from "react-hook-form";
23
+ import {
24
+ Box,
25
+ Button,
26
+ IconButton,
27
+ TextField,
28
+ Typography,
29
+ Table,
30
+ TableBody,
31
+ TableCell,
32
+ TableContainer,
33
+ TableHead,
34
+ TableRow,
35
+ Paper
36
+ } from "@mui/material";
37
+ import DeleteIcon from "@mui/icons-material/Delete";
38
+ import AddIcon from "@mui/icons-material/Add";
39
+ import { useState, useEffect } from "react";
40
+ const JsonEdit = (props) => {
41
+ const { method, attribute, resourceConfig } = props;
42
+ const record = useRecordContext();
43
+ const { setValue, getValues } = useFormContext();
44
+ const attributePath = attribute.attribute;
45
+ const isNestedSetting = attributePath.startsWith("settings.");
46
+ const settingsPath = isNestedSetting ? attributePath.split(".").slice(1).join(".") : attributePath;
47
+ const [pairs, setPairs] = useState([]);
48
+ const [keyError, setKeyError] = useState({});
49
+ useEffect(() => {
50
+ let initialValue = {};
51
+ if (isNestedSetting && (record == null ? void 0 : record.settings)) {
52
+ const settings = record.settings || {};
53
+ initialValue = getNestedValue(settings, settingsPath) || {};
54
+ } else if (record == null ? void 0 : record[attributePath]) {
55
+ initialValue = record[attributePath] || {};
56
+ }
57
+ const initialPairs = Object.entries(initialValue).map(([key, value]) => ({
58
+ key,
59
+ value: typeof value === "object" ? JSON.stringify(value) : String(value),
60
+ id: generateId()
61
+ }));
62
+ setPairs(initialPairs);
63
+ }, [record, attributePath]);
64
+ const getNestedValue = (obj, path) => {
65
+ if (!path) return obj;
66
+ const keys = path.split(".");
67
+ return keys.reduce((o, key) => o && o[key] !== void 0 ? o[key] : {}, obj);
68
+ };
69
+ const setNestedValue = (obj, path, value) => {
70
+ if (!path) return value;
71
+ const keys = path.split(".");
72
+ const lastKey = keys.pop();
73
+ const lastObj = keys.reduce((o, key) => {
74
+ if (o[key] === void 0) o[key] = {};
75
+ return o[key];
76
+ }, obj);
77
+ if (lastKey) {
78
+ lastObj[lastKey] = value;
79
+ }
80
+ return obj;
81
+ };
82
+ const generateId = () => {
83
+ return Math.random().toString(36).substring(2, 11);
84
+ };
85
+ const addPair = () => {
86
+ setPairs([...pairs, { key: "", value: "", id: generateId() }]);
87
+ };
88
+ const removePair = (id) => {
89
+ setPairs(pairs.filter((pair) => pair.id !== id));
90
+ updateFormValue(pairs.filter((pair) => pair.id !== id));
91
+ };
92
+ const handleKeyChange = (id, newKey) => {
93
+ const isDuplicate = pairs.some((pair) => pair.id !== id && pair.key === newKey);
94
+ if (isDuplicate) {
95
+ setKeyError(__spreadProps(__spreadValues({}, keyError), { [id]: "Duplicate key" }));
96
+ } else {
97
+ setKeyError(__spreadProps(__spreadValues({}, keyError), { [id]: "" }));
98
+ }
99
+ const updatedPairs = pairs.map(
100
+ (pair) => pair.id === id ? __spreadProps(__spreadValues({}, pair), { key: newKey }) : pair
101
+ );
102
+ setPairs(updatedPairs);
103
+ updateFormValue(updatedPairs);
104
+ };
105
+ const handleValueChange = (id, newValue) => {
106
+ const updatedPairs = pairs.map(
107
+ (pair) => pair.id === id ? __spreadProps(__spreadValues({}, pair), { value: newValue }) : pair
108
+ );
109
+ setPairs(updatedPairs);
110
+ updateFormValue(updatedPairs);
111
+ };
112
+ const updateFormValue = (currentPairs) => {
113
+ const obj = currentPairs.reduce((acc, pair) => {
114
+ if (pair.key.trim()) {
115
+ let parsedValue = pair.value;
116
+ try {
117
+ if (pair.value.trim().startsWith("{") || pair.value.trim().startsWith("[") || pair.value.trim() === "true" || pair.value.trim() === "false" || !isNaN(Number(pair.value.trim()))) {
118
+ parsedValue = JSON.parse(pair.value);
119
+ }
120
+ } catch (e) {
121
+ }
122
+ acc[pair.key] = parsedValue;
123
+ }
124
+ return acc;
125
+ }, {});
126
+ if (isNestedSetting) {
127
+ const currentSettings = getValues("settings") || {};
128
+ const updatedSettings = setNestedValue(__spreadValues({}, currentSettings), settingsPath, obj);
129
+ setValue("settings", updatedSettings, { shouldDirty: true });
130
+ } else {
131
+ setValue(attributePath, obj, { shouldDirty: true });
132
+ }
133
+ };
134
+ return /* @__PURE__ */ jsxs(Box, { sx: { mt: 1, mb: 2 }, children: [
135
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", gutterBottom: true, children: attribute.label || "Settings Editor" }),
136
+ /* @__PURE__ */ jsx(TableContainer, { component: Paper, sx: { mb: 2 }, children: /* @__PURE__ */ jsxs(Table, { size: "small", children: [
137
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
138
+ /* @__PURE__ */ jsx(TableCell, { width: "40%", children: "Key" }),
139
+ /* @__PURE__ */ jsx(TableCell, { width: "50%", children: "Value" }),
140
+ /* @__PURE__ */ jsx(TableCell, { width: "10%", align: "center", children: "Actions" })
141
+ ] }) }),
142
+ /* @__PURE__ */ jsx(TableBody, { children: pairs.map((pair) => /* @__PURE__ */ jsxs(TableRow, { children: [
143
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
144
+ TextField,
145
+ {
146
+ fullWidth: true,
147
+ size: "small",
148
+ value: pair.key,
149
+ onChange: (e) => handleKeyChange(pair.id, e.target.value),
150
+ error: !!keyError[pair.id],
151
+ helperText: keyError[pair.id]
152
+ }
153
+ ) }),
154
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
155
+ TextField,
156
+ {
157
+ fullWidth: true,
158
+ size: "small",
159
+ value: pair.value,
160
+ onChange: (e) => handleValueChange(pair.id, e.target.value)
161
+ }
162
+ ) }),
163
+ /* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(
164
+ IconButton,
165
+ {
166
+ size: "small",
167
+ onClick: () => removePair(pair.id),
168
+ color: "error",
169
+ children: /* @__PURE__ */ jsx(DeleteIcon, { fontSize: "small" })
170
+ }
171
+ ) })
172
+ ] }, pair.id)) })
173
+ ] }) }),
174
+ /* @__PURE__ */ jsx(
175
+ Button,
176
+ {
177
+ startIcon: /* @__PURE__ */ jsx(AddIcon, {}),
178
+ variant: "outlined",
179
+ size: "small",
180
+ onClick: addPair,
181
+ children: "+"
182
+ }
183
+ )
184
+ ] });
185
+ };
186
+ const JsonView = (props) => {
187
+ const { attribute } = props;
188
+ const record = useRecordContext();
189
+ const attributePath = attribute.attribute;
190
+ const isNestedSetting = attributePath.startsWith("settings.");
191
+ const settingsPath = isNestedSetting ? attributePath.split(".").slice(1).join(".") : attributePath;
192
+ let displayValue = {};
193
+ if (isNestedSetting && (record == null ? void 0 : record.settings)) {
194
+ const settings = record.settings || {};
195
+ if (settingsPath) {
196
+ const keys = settingsPath.split(".");
197
+ displayValue = keys.reduce((o, key) => o && o[key] !== void 0 ? o[key] : {}, settings);
198
+ } else {
199
+ displayValue = settings;
200
+ }
201
+ } else if (record == null ? void 0 : record[attributePath]) {
202
+ displayValue = record[attributePath];
203
+ }
204
+ return /* @__PURE__ */ jsxs(Box, { sx: { mt: 1, mb: 2 }, children: [
205
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", gutterBottom: true, children: attribute.label || "Settings" }),
206
+ Object.keys(displayValue).length > 0 ? /* @__PURE__ */ jsx(TableContainer, { component: Paper, children: /* @__PURE__ */ jsxs(Table, { size: "small", children: [
207
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
208
+ /* @__PURE__ */ jsx(TableCell, { width: "40%", children: "Key" }),
209
+ /* @__PURE__ */ jsx(TableCell, { width: "60%", children: "Value" })
210
+ ] }) }),
211
+ /* @__PURE__ */ jsx(TableBody, { children: Object.entries(displayValue).map(([key, value]) => /* @__PURE__ */ jsxs(TableRow, { children: [
212
+ /* @__PURE__ */ jsx(TableCell, { children: key }),
213
+ /* @__PURE__ */ jsx(TableCell, { children: typeof value === "object" ? JSON.stringify(value) : String(value) })
214
+ ] }, key)) })
215
+ ] }) }) : /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", children: "No settings configured" })
216
+ ] });
217
+ };
218
+ const Json = ({ method, attribute, resourceConfig }) => {
219
+ switch (method) {
220
+ case "edit":
221
+ return /* @__PURE__ */ jsx(JsonEdit, { attribute, method, resourceConfig });
222
+ case "create":
223
+ return /* @__PURE__ */ jsx(JsonEdit, { attribute, method, resourceConfig });
224
+ case "view":
225
+ return /* @__PURE__ */ jsx(JsonView, { attribute, method, resourceConfig });
226
+ default:
227
+ return null;
228
+ }
229
+ };
230
+ var Json_default = Json;
231
+ export {
232
+ JsonEdit,
233
+ JsonView,
234
+ Json_default as default
235
+ };