@homefile/components-v2 2.52.1 → 2.52.3

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.
@@ -3,9 +3,32 @@ import { createElement as _createElement } from "react";
3
3
  import { Box } from '@chakra-ui/react';
4
4
  import { ReadOnlyAppliances, ReadOnlyCollapsible, ReadOnlyDate, ReadOnlyGrid, ReadOnlyGroup, ReadOnlyInput, ReadOnlyNotes, ReadOnlyRating, ReadOnlyTextArea, } from '../../../components';
5
5
  import { fieldIcons } from '../../../helpers';
6
+ /**
7
+ * Coerce a field value into something safe to render. A malformed value that
8
+ * isn't a primitive (e.g. a nested object from AI extraction) must never reach
9
+ * JSX — React throws "Objects are not valid as a React child" and crashes the
10
+ * whole panel. Primitives and Dates pass through; a `SelectItemI` renders its
11
+ * `name`; arrays join their primitive/name parts; anything else is dropped.
12
+ */
13
+ function toSafeValue(value) {
14
+ var _a;
15
+ if (value == null || value instanceof Date)
16
+ return value;
17
+ if (Array.isArray(value)) {
18
+ return value
19
+ .map((v) => { var _a; return (v && typeof v === 'object' ? (_a = v.name) !== null && _a !== void 0 ? _a : '' : v); })
20
+ .filter((v) => v != null && v !== '')
21
+ .join(', ');
22
+ }
23
+ if (typeof value === 'object') {
24
+ return ((_a = value.name) !== null && _a !== void 0 ? _a : '');
25
+ }
26
+ return value;
27
+ }
6
28
  export const ReadOnlyDynamicForm = ({ form: fields, onClick, onEdit, }) => {
7
29
  return (_jsx(Box, { bg: "lightBlue.1", overflow: "scroll", children: fields === null || fields === void 0 ? void 0 : fields.map((field) => {
8
- const { children = [], icon, id, name, type, value } = field;
30
+ const { children = [], icon, id, name, type } = field;
31
+ const value = toSafeValue(field.value);
9
32
  const baseProps = {
10
33
  id,
11
34
  value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.52.1",
3
+ "version": "2.52.3",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",