@open-mercato/ui 0.8.1-develop.7261.1.5d42353f61 → 0.8.1-develop.7266.1.8e520bbe03

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.
@@ -1,3 +1,3 @@
1
1
  Generated lucide registry with 170 icons -> /home/runner/work/open-mercato/open-mercato/packages/ui/src/backend/icons/lucideRegistry.generated.tsx
2
- [build:ui] found 450 entry points
2
+ [build:ui] found 451 entry points
3
3
  [build:ui] built successfully
@@ -191,6 +191,7 @@ function readByDotPath(source, path) {
191
191
  return current;
192
192
  }
193
193
  const PROTO_POLLUTING_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
194
+ const EMPTY_HIDDEN_GROUP_IDS = /* @__PURE__ */ new Set();
194
195
  function isProtoPollutingKey(key) {
195
196
  return PROTO_POLLUTING_KEYS.has(key);
196
197
  }
@@ -383,6 +384,7 @@ function CrudForm({
383
384
  entityId,
384
385
  entityIds,
385
386
  groups,
387
+ hiddenGroupIds,
386
388
  isLoading = false,
387
389
  loadingMessage,
388
390
  customEntity = false,
@@ -1367,6 +1369,46 @@ function CrudForm({
1367
1369
  }
1368
1370
  return hidden;
1369
1371
  }, [fields, values]);
1372
+ const hiddenGroupIdsKey = (hiddenGroupIds ?? []).join("\0");
1373
+ const hiddenGroupIdSet = React.useMemo(
1374
+ () => hiddenGroupIdsKey ? new Set(hiddenGroupIdsKey.split("\0")) : EMPTY_HIDDEN_GROUP_IDS,
1375
+ [hiddenGroupIdsKey]
1376
+ );
1377
+ const placedCustomFieldIds = React.useMemo(() => {
1378
+ const placed = /* @__PURE__ */ new Set();
1379
+ for (const other of groups ?? []) {
1380
+ if (other.kind === "customFields" || !other.fields) continue;
1381
+ for (const entry of other.fields) {
1382
+ if (typeof entry === "string") placed.add(entry);
1383
+ else if (entry && typeof entry.id === "string") placed.add(entry.id);
1384
+ }
1385
+ }
1386
+ return placed;
1387
+ }, [groups]);
1388
+ const hiddenGroupFieldIds = React.useMemo(() => {
1389
+ if (hiddenGroupIdSet.size === 0) return EMPTY_HIDDEN_GROUP_IDS;
1390
+ const groupFieldIds = (group) => {
1391
+ if (group.kind === "customFields") {
1392
+ return cfFields.filter((field) => !placedCustomFieldIds.has(field.id)).map((field) => field.id);
1393
+ }
1394
+ return (group.fields ?? []).map((entry) => typeof entry === "string" ? entry : entry.id);
1395
+ };
1396
+ const declaredGroups = groups ?? [];
1397
+ const hidden = /* @__PURE__ */ new Set();
1398
+ const visible = /* @__PURE__ */ new Set();
1399
+ for (const group of declaredGroups) {
1400
+ const target = hiddenGroupIdSet.has(group.id) ? hidden : visible;
1401
+ for (const fieldId of groupFieldIds(group)) target.add(fieldId);
1402
+ }
1403
+ const declaredGroupIds = new Set(declaredGroups.map((group) => group.id));
1404
+ const fallbackGroupId = declaredGroups[declaredGroups.length - 1]?.id;
1405
+ for (const definition of injectedFieldDefinitions) {
1406
+ const targetGroupId = definition.group && declaredGroupIds.has(definition.group) ? definition.group : fallbackGroupId;
1407
+ if (targetGroupId && hiddenGroupIdSet.has(targetGroupId)) hidden.add(definition.id);
1408
+ }
1409
+ for (const fieldId of visible) hidden.delete(fieldId);
1410
+ return hidden;
1411
+ }, [cfFields, groups, hiddenGroupIdSet, injectedFieldDefinitions, placedCustomFieldIds]);
1370
1412
  const hiddenInjectedFieldIds = React.useMemo(() => {
1371
1413
  const hidden = /* @__PURE__ */ new Set();
1372
1414
  for (const definition of injectedFieldDefinitions) {
@@ -1442,6 +1484,7 @@ function CrudForm({
1442
1484
  const field = fieldById.get(fieldId);
1443
1485
  if (!field || field.disabled) return;
1444
1486
  if (hiddenBaseFieldIds.has(fieldId) || hiddenInjectedFieldIds.has(fieldId)) return;
1487
+ if (hiddenGroupFieldIds.has(fieldId)) return;
1445
1488
  if (!everEditedFieldIdsRef.current.has(fieldId)) return;
1446
1489
  const nextValues = sourceValues ?? valuesRef.current;
1447
1490
  const nextFieldErrors = {};
@@ -1521,6 +1564,7 @@ function CrudForm({
1521
1564
  fieldById,
1522
1565
  formReadOnly,
1523
1566
  hiddenBaseFieldIds,
1567
+ hiddenGroupFieldIds,
1524
1568
  hiddenInjectedFieldIds,
1525
1569
  injectedFieldIdSet,
1526
1570
  mapDefsForValidation,
@@ -1584,13 +1628,26 @@ function CrudForm({
1584
1628
  return cloned;
1585
1629
  }, [groups, injectedFieldDefinitions]);
1586
1630
  const shouldAutoGroup = (!groupsWithInjectedFields || groupsWithInjectedFields.length === 0) && injectionGroupCards.length > 0;
1587
- const resolvedGroupsForLayout = React.useMemo(() => {
1631
+ const declaredGroupsForLayout = React.useMemo(() => {
1588
1632
  const baseGroups = groupsWithInjectedFields && groupsWithInjectedFields.length ? groupsWithInjectedFields : [];
1589
1633
  const autoGroup = shouldAutoGroup ? [{ id: "__auto-fields__", fields: allFields }] : [];
1590
1634
  return [...baseGroups.length ? baseGroups : autoGroup, ...injectionGroupCards];
1591
1635
  }, [allFields, groupsWithInjectedFields, injectionGroupCards, shouldAutoGroup]);
1592
- const useGroupedLayout = resolvedGroupsForLayout.length > 0;
1593
- const defaultGroupIds = React.useMemo(() => resolvedGroupsForLayout.map((g) => g.id), [resolvedGroupsForLayout]);
1636
+ const resolvedGroupsForLayout = React.useMemo(() => {
1637
+ if (hiddenGroupIdSet.size === 0) return declaredGroupsForLayout;
1638
+ return declaredGroupsForLayout.filter((group) => !hiddenGroupIdSet.has(group.id));
1639
+ }, [declaredGroupsForLayout, hiddenGroupIdSet]);
1640
+ React.useEffect(() => {
1641
+ if (process.env.NODE_ENV === "production" || hiddenGroupIdSet.size === 0) return;
1642
+ const declaredIds = new Set(declaredGroupsForLayout.map((group) => group.id));
1643
+ for (const hiddenId of hiddenGroupIdSet) {
1644
+ if (!declaredIds.has(hiddenId)) {
1645
+ logger.warn("hiddenGroupIds names a group that does not exist on this form", { groupId: hiddenId });
1646
+ }
1647
+ }
1648
+ }, [declaredGroupsForLayout, hiddenGroupIdSet]);
1649
+ const useGroupedLayout = declaredGroupsForLayout.length > 0;
1650
+ const defaultGroupIds = React.useMemo(() => declaredGroupsForLayout.map((g) => g.id), [declaredGroupsForLayout]);
1594
1651
  const { orderedIds: sortedGroupIds, reorder: reorderGroups } = useGroupOrder(
1595
1652
  sortablePageType,
1596
1653
  defaultGroupIds
@@ -1621,17 +1678,6 @@ function CrudForm({
1621
1678
  () => (injectionWidgets ?? []).filter((widget) => (widget.placement?.kind ?? "stack") === "stack"),
1622
1679
  [injectionWidgets]
1623
1680
  );
1624
- const placedCustomFieldIds = React.useMemo(() => {
1625
- const placed = /* @__PURE__ */ new Set();
1626
- for (const other of groups ?? []) {
1627
- if (other.kind === "customFields" || !other.fields) continue;
1628
- for (const entry of other.fields) {
1629
- if (typeof entry === "string") placed.add(entry);
1630
- else if (entry && typeof entry.id === "string") placed.add(entry.id);
1631
- }
1632
- }
1633
- return placed;
1634
- }, [groups]);
1635
1681
  const resolveGroupFields = React.useCallback((g) => {
1636
1682
  if (g.kind === "customFields") {
1637
1683
  return cfFields.filter((f) => !placedCustomFieldIds.has(f.id));
@@ -1683,10 +1729,10 @@ function CrudForm({
1683
1729
  if (fromCol2) return fromCol2;
1684
1730
  }
1685
1731
  for (const field of allFields) {
1686
- if (field?.id && !field.disabled) return field.id;
1732
+ if (field?.id && !field.disabled && !hiddenGroupFieldIds.has(field.id)) return field.id;
1687
1733
  }
1688
1734
  return null;
1689
- }, [allFields, resolveGroupFields, resolvedGroupsForLayout, useGroupedLayout]);
1735
+ }, [allFields, hiddenGroupFieldIds, resolveGroupFields, resolvedGroupsForLayout, useGroupedLayout]);
1690
1736
  const requestSubmit = React.useCallback(() => {
1691
1737
  if (formReadOnly) return;
1692
1738
  if (typeof document === "undefined") return;
@@ -2137,6 +2183,7 @@ function CrudForm({
2137
2183
  if (!field.required) continue;
2138
2184
  if (field.disabled) continue;
2139
2185
  if (hiddenBaseFieldIds.has(field.id) || hiddenInjectedFieldIds.has(field.id)) continue;
2186
+ if (hiddenGroupFieldIds.has(field.id)) continue;
2140
2187
  const v = values[field.id];
2141
2188
  const isArray = Array.isArray(v);
2142
2189
  const isString = typeof v === "string";