@aatulwork/customform-renderer 1.13.0 → 1.15.0

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/index.d.mts CHANGED
@@ -30,9 +30,8 @@ interface FieldViewProps {
30
30
  field: FormField;
31
31
  value: any;
32
32
  services?: FormServices;
33
- colors?: FormColors;
34
33
  }
35
- declare const FieldView: ({ field, value, services, colors }: FieldViewProps) => react_jsx_runtime.JSX.Element;
34
+ declare const FieldView: ({ field, value, services }: FieldViewProps) => react_jsx_runtime.JSX.Element;
36
35
 
37
36
  interface SimpleSelectOption {
38
37
  value: string | number;
package/dist/index.d.ts CHANGED
@@ -30,9 +30,8 @@ interface FieldViewProps {
30
30
  field: FormField;
31
31
  value: any;
32
32
  services?: FormServices;
33
- colors?: FormColors;
34
33
  }
35
- declare const FieldView: ({ field, value, services, colors }: FieldViewProps) => react_jsx_runtime.JSX.Element;
34
+ declare const FieldView: ({ field, value, services }: FieldViewProps) => react_jsx_runtime.JSX.Element;
36
35
 
37
36
  interface SimpleSelectOption {
38
37
  value: string | number;
package/dist/index.js CHANGED
@@ -1404,8 +1404,9 @@ var getCachedOptions = (key) => {
1404
1404
  var setCachedOptions = (key, options) => {
1405
1405
  referenceOptionsCache.set(key, { options, timestamp: Date.now() });
1406
1406
  };
1407
- var FieldView = ({ field, value, services, colors }) => {
1408
- const formColors = useFormColors(colors);
1407
+ var FieldView = ({ field, value, services }) => {
1408
+ const fieldLabelColor = "rgba(0, 0, 0, 0.6)";
1409
+ const fieldValueColor = "text.secondary";
1409
1410
  const dateFormatter = services?.dateFormatter || defaultDateFormatterService;
1410
1411
  const FileDisplayComponent = services?.FileDisplayComponent;
1411
1412
  const CKEditorDisplayComponent = services?.CKEditorDisplayComponent;
@@ -1424,7 +1425,7 @@ var FieldView = ({ field, value, services, colors }) => {
1424
1425
  borderColor: "divider"
1425
1426
  },
1426
1427
  children: [
1427
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500 }, children: field.label }),
1428
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1428
1429
  /* @__PURE__ */ jsxRuntime.jsx(FileDisplayComponent, { fieldValue: value })
1429
1430
  ]
1430
1431
  },
@@ -1443,15 +1444,57 @@ var FieldView = ({ field, value, services, colors }) => {
1443
1444
  borderColor: "divider"
1444
1445
  },
1445
1446
  children: [
1446
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: formColors.primary }, children: field.label }),
1447
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", sx: { color: "text.secondary" }, children: value ? Array.isArray(value) ? `${value.length} file(s)` : "1 file" : "\u2014" })
1447
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1448
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", sx: { color: fieldValueColor }, children: value ? Array.isArray(value) ? `${value.length} file(s)` : "1 file" : "\u2014" })
1448
1449
  ]
1449
1450
  },
1450
1451
  field.name
1451
1452
  );
1452
1453
  }
1453
1454
  if (field.type === "formReference" || field.type === "apiReference") {
1454
- return /* @__PURE__ */ jsxRuntime.jsx(ReferenceFieldView, { field, value, services });
1455
+ return /* @__PURE__ */ jsxRuntime.jsx(
1456
+ ReferenceFieldView,
1457
+ {
1458
+ field,
1459
+ value,
1460
+ services,
1461
+ fieldLabelColor,
1462
+ fieldValueColor
1463
+ }
1464
+ );
1465
+ }
1466
+ if (field.type === "color") {
1467
+ const colorValue = value && typeof value === "string" ? value : "#000000";
1468
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1469
+ material.Box,
1470
+ {
1471
+ sx: {
1472
+ display: "flex",
1473
+ flexDirection: "column",
1474
+ gap: 0.5,
1475
+ py: 1.5,
1476
+ px: 1,
1477
+ borderColor: "divider"
1478
+ },
1479
+ children: [
1480
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1481
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: value ? /* @__PURE__ */ jsxRuntime.jsx(
1482
+ material.Box,
1483
+ {
1484
+ sx: {
1485
+ width: 30,
1486
+ height: 30,
1487
+ backgroundColor: colorValue,
1488
+ border: "1px solid",
1489
+ borderColor: "divider",
1490
+ borderRadius: 1
1491
+ }
1492
+ }
1493
+ ) : /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", sx: { color: fieldValueColor, fontStyle: "italic" }, children: "\u2014" }) })
1494
+ ]
1495
+ },
1496
+ field.name
1497
+ );
1455
1498
  }
1456
1499
  if (field.type === "ckeditor") {
1457
1500
  if (CKEditorDisplayComponent) {
@@ -1467,7 +1510,7 @@ var FieldView = ({ field, value, services, colors }) => {
1467
1510
  borderColor: "divider"
1468
1511
  },
1469
1512
  children: [
1470
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500 }, children: field.label }),
1513
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1471
1514
  /* @__PURE__ */ jsxRuntime.jsx(
1472
1515
  CKEditorDisplayComponent,
1473
1516
  {
@@ -1493,13 +1536,13 @@ var FieldView = ({ field, value, services, colors }) => {
1493
1536
  borderColor: "divider"
1494
1537
  },
1495
1538
  children: [
1496
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500 }, children: field.label }),
1539
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1497
1540
  /* @__PURE__ */ jsxRuntime.jsx(
1498
1541
  material.Typography,
1499
1542
  {
1500
1543
  variant: "body1",
1501
1544
  sx: {
1502
- color: formattedValue === "\u2014" ? "text.disabled" : "text.primary",
1545
+ color: fieldValueColor,
1503
1546
  fontStyle: formattedValue === "\u2014" ? "italic" : "normal"
1504
1547
  },
1505
1548
  dangerouslySetInnerHTML: { __html: value || "" }
@@ -1522,13 +1565,13 @@ var FieldView = ({ field, value, services, colors }) => {
1522
1565
  borderColor: "divider"
1523
1566
  },
1524
1567
  children: [
1525
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500 }, children: field.label }),
1568
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1526
1569
  /* @__PURE__ */ jsxRuntime.jsx(
1527
1570
  material.Typography,
1528
1571
  {
1529
1572
  variant: "body1",
1530
1573
  sx: {
1531
- color: formattedValue === "\u2014" ? "text.disabled" : "text.primary",
1574
+ color: fieldValueColor,
1532
1575
  fontStyle: formattedValue === "\u2014" ? "italic" : "normal",
1533
1576
  fontWeight: 400,
1534
1577
  fontSize: "0.875rem",
@@ -1545,7 +1588,9 @@ var FieldView = ({ field, value, services, colors }) => {
1545
1588
  var ReferenceFieldView = ({
1546
1589
  field,
1547
1590
  value,
1548
- services
1591
+ services,
1592
+ fieldLabelColor,
1593
+ fieldValueColor
1549
1594
  }) => {
1550
1595
  const [displayLabels, setDisplayLabels] = react.useState(null);
1551
1596
  react.useEffect(() => {
@@ -1609,13 +1654,13 @@ var ReferenceFieldView = ({
1609
1654
  borderColor: "divider"
1610
1655
  },
1611
1656
  children: [
1612
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500 }, children: field.label }),
1657
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { fontWeight: 500, color: fieldLabelColor }, children: field.label }),
1613
1658
  /* @__PURE__ */ jsxRuntime.jsx(
1614
1659
  material.Typography,
1615
1660
  {
1616
1661
  variant: "body1",
1617
1662
  sx: {
1618
- color: displayText === "\u2014" ? "text.disabled" : "text.primary",
1663
+ color: fieldValueColor,
1619
1664
  fontStyle: displayText === "\u2014" ? "italic" : "normal",
1620
1665
  fontWeight: 400,
1621
1666
  fontSize: "0.875rem",
@@ -1670,6 +1715,8 @@ var formatFieldValue = (field, value, dateFormatter, services) => {
1670
1715
  return labels.join(", ");
1671
1716
  }
1672
1717
  return getLabelForValue(values[0]);
1718
+ case "color":
1719
+ return value ? String(value) : "\u2014";
1673
1720
  case "radio":
1674
1721
  if (field.options) {
1675
1722
  const normalizedOptions = normalizeOptions(field.options);
@@ -1715,7 +1762,7 @@ var FormViewMode = ({ formSchema, initialValues, hideTitle = false, services, co
1715
1762
  gridTemplateColumns: isMobile ? "repeat(1, 1fr)" : "repeat(2, 1fr)",
1716
1763
  gap: 1
1717
1764
  },
1718
- children: section.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(FieldView, { field, value: initialValues?.[field.name], services, colors }, field.name))
1765
+ children: section.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(FieldView, { field, value: initialValues?.[field.name], services }, field.name))
1719
1766
  }
1720
1767
  )
1721
1768
  ] })