+ {itemFields.map((field) => {
+ const fieldVal = item[field];
+ if (typeof fieldVal === 'boolean') {
+ return (
+
+ );
+ }
+ if (typeof fieldVal === 'number') {
+ return (
+
+
+ {
+ actions.setProp(selectedId, (props: any) => {
+ const updated = [...(props[propKey] || [])];
+ updated[index] = { ...updated[index], [field]: parseFloat(e.target.value) || 0 };
+ props[propKey] = updated;
+ });
+ }} style={smallInputStyle} />
+
+ );
+ }
+ // color fields
+ if (/color/i.test(field) && typeof fieldVal === 'string') {
+ return (
+
+
+ {
+ actions.setProp(selectedId, (props: any) => {
+ const updated = [...(props[propKey] || [])];
+ updated[index] = { ...updated[index], [field]: e.target.value };
+ props[propKey] = updated;
+ });
+ }} style={{ width: 24, height: 20, border: 'none', cursor: 'pointer', background: 'none', padding: 0 }} />
+
+ );
+ }
+ // long text
+ const strVal = String(fieldVal ?? '');
+ const isLongField = strVal.length > 50 || field === 'description' || field === 'text' || field === 'content';
+ return (
+
+
+ {isLongField ? (
+
+ );
+ })}
+
+ );
+ }}
+ emptyItem={typeof sampleItem === 'object' && sampleItem !== null
+ ? Object.fromEntries(itemFields.map((f) => [f, typeof sampleItem[f] === 'number' ? 0 : typeof sampleItem[f] === 'boolean' ? false : '']))
+ : ''
+ }
+ />
+