@rebasepro/cms 0.25.1 → 0.26.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.
Files changed (111) hide show
  1. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
  2. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
  4. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +9 -2
  5. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  6. package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
  7. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  8. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
  9. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  10. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
  11. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  12. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
  13. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
  14. package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
  15. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  16. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
  17. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  18. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
  19. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
  20. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
  21. package/dist/components/CollectionsScopeContext.d.ts +5 -1
  22. package/dist/components/CollectionsScopeContext.js +10 -2
  23. package/dist/components/CollectionsScopeContext.js.map +1 -1
  24. package/dist/components/DefaultAppBar.js +2 -1
  25. package/dist/components/DefaultAppBar.js.map +1 -1
  26. package/dist/components/DefaultDrawer.js +16 -4
  27. package/dist/components/DefaultDrawer.js.map +1 -1
  28. package/dist/components/DefaultMissingReference.d.ts +8 -0
  29. package/dist/components/DefaultMissingReference.js +13 -0
  30. package/dist/components/DefaultMissingReference.js.map +1 -0
  31. package/dist/components/EntityFormPanel.d.ts +7 -2
  32. package/dist/components/EntityFormPanel.js +72 -29
  33. package/dist/components/EntityFormPanel.js.map +1 -1
  34. package/dist/components/HomePage/ContentHomePage.js +4 -3
  35. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  36. package/dist/components/HomePage/HomePageDnD.js +3 -1
  37. package/dist/components/HomePage/HomePageDnD.js.map +1 -1
  38. package/dist/components/HomePage/SmallNavigationCard.js +25 -0
  39. package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
  40. package/dist/components/RebaseAuthGate.js +3 -2
  41. package/dist/components/RebaseAuthGate.js.map +1 -1
  42. package/dist/components/RebaseLayout.d.ts +4 -1
  43. package/dist/components/RebaseLayout.js +7 -1
  44. package/dist/components/RebaseLayout.js.map +1 -1
  45. package/dist/components/RebaseShell.d.ts +4 -1
  46. package/dist/components/RebaseShell.js.map +1 -1
  47. package/dist/components/SideDialogs.js +10 -4
  48. package/dist/components/SideDialogs.js.map +1 -1
  49. package/dist/components/app/Scaffold.js +5 -1
  50. package/dist/components/app/Scaffold.js.map +1 -1
  51. package/dist/components/field_configs.js +1 -1
  52. package/dist/components/history/EntityHistoryView.js +6 -4
  53. package/dist/components/history/EntityHistoryView.js.map +1 -1
  54. package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
  55. package/dist/data_export/export/export.d.ts +2 -13
  56. package/dist/data_export/export/export.js +1 -36
  57. package/dist/data_export/export/export.js.map +1 -1
  58. package/dist/form/EntityForm.d.ts +1 -1
  59. package/dist/form/EntityForm.js +17 -13
  60. package/dist/form/EntityForm.js.map +1 -1
  61. package/dist/form/EntityFormBinding.d.ts +1 -1
  62. package/dist/form/EntityFormBinding.js +42 -4
  63. package/dist/form/EntityFormBinding.js.map +1 -1
  64. package/dist/form/PropertyFieldBinding.js +1 -1
  65. package/dist/form/components/FieldBlock.d.ts +8 -1
  66. package/dist/form/components/FieldBlock.js +16 -2
  67. package/dist/form/components/FieldBlock.js.map +1 -1
  68. package/dist/form/components/FormSections.js +1 -1
  69. package/dist/form/components/FormSections.js.map +1 -1
  70. package/dist/form/components/LabelWithIcon.js +5 -2
  71. package/dist/form/components/LabelWithIcon.js.map +1 -1
  72. package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
  73. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  74. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
  75. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  76. package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
  77. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  78. package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
  79. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  80. package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
  81. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  82. package/dist/form/field_bindings/TextFieldBinding.js +8 -6
  83. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  84. package/dist/form/form_utils.d.ts +18 -1
  85. package/dist/form/form_utils.js +38 -2
  86. package/dist/form/form_utils.js.map +1 -1
  87. package/dist/form/index.d.ts +1 -1
  88. package/dist/form/label_placement.d.ts +23 -0
  89. package/dist/form/label_placement.js +71 -0
  90. package/dist/form/label_placement.js.map +1 -0
  91. package/dist/form/resolve_form_properties.d.ts +35 -3
  92. package/dist/form/resolve_form_properties.js +67 -6
  93. package/dist/form/resolve_form_properties.js.map +1 -1
  94. package/dist/hooks/useHistory.d.ts +5 -0
  95. package/dist/hooks/useHistory.js +22 -6
  96. package/dist/hooks/useHistory.js.map +1 -1
  97. package/dist/index.d.ts +50 -0
  98. package/dist/index.js +34 -7
  99. package/dist/preview/components/ReferencePreview.js +1 -1
  100. package/dist/preview/components/ReferencePreview.js.map +1 -1
  101. package/dist/preview/components/RelationPreview.js +1 -1
  102. package/dist/preview/components/RelationPreview.js.map +1 -1
  103. package/dist/types/components/EntityFormProps.d.ts +11 -0
  104. package/package.json +11 -10
  105. package/recipes/README.md +131 -0
  106. package/recipes/bulk-set-status.tsx +62 -0
  107. package/recipes/calendar-view.tsx +123 -0
  108. package/recipes/custom-login.tsx +60 -0
  109. package/recipes/my-preferences.tsx +68 -0
  110. package/recipes/orders-dashboard.tsx +125 -0
  111. package/recipes/site-settings.tsx +63 -0
@@ -1 +1 @@
1
- {"version":3,"file":"FieldBlock.js","names":[],"sources":["../../../src/form/components/FieldBlock.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertySpan } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { cls, ErrorBoundary, Typography } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\n\n/**\n * Grid placement for a span.\n *\n * Written out as literal class strings rather than composed, because Tailwind\n * scans source text: a template literal would produce classes that exist at\n * runtime and were never generated into the stylesheet.\n *\n * Below the column breakpoint every field takes the single available column, so\n * the side panel, the dialog and mobile all get a plain stack.\n *\n * Lives here rather than in the form, because the read-only rendering of a\n * record places its fields on the same grid — a record that changes shape when\n * you press Edit is the bug this whole layout exists to avoid.\n */\nexport function spanClass(span: PropertySpan): string {\n switch (span) {\n case 1: return \"@2xl/col:col-span-1\";\n case 2: return \"@2xl/col:col-span-2\";\n case 3: return \"@2xl/col:col-span-3\";\n case 4: return \"@2xl/col:col-span-4\";\n }\n}\n\n/**\n * Does this property's editor supply its own heading?\n *\n * Arrays, maps, `oneOf` blocks and key-value editors render as a collapsible\n * panel whose header *is* the label — hiding it would leave a panel you cannot\n * identify or, worse, cannot expand. Those keep their own; everything else gets\n * its label from {@link FieldBlock}, which is what makes a text field and a\n * select finally agree on where a label goes.\n *\n * Exported because the layout resolver's span rules and this rule have to stay\n * in step: the self-labelling types are exactly the ones that take a full row.\n */\nexport function isSelfLabellingProperty(property: Property | undefined): boolean {\n if (!property) return false;\n switch (property.type) {\n case \"map\":\n // `spreadChildren` inlines the children into the parent grid, so\n // there is no panel and therefore no header to reuse as the label.\n return !property.admin?.spreadChildren;\n case \"array\": {\n // Most arrays render as an expandable panel whose header is the\n // label — `repeat`, `block`, `custom_array`, `multi_references`.\n // The exceptions are the ones that resolve to an inline control:\n // an enum array is a multi-select and a storage array is a\n // dropzone, and both take their label from the form.\n //\n // This mirrors `getFieldConfig`'s array branch. Getting it backwards\n // is visible: an array of plain strings is a `repeat` panel, and\n // treating it as inline printed \"Available Locales\" twice, once\n // from the form and once from the panel's own header.\n if (property.oneOf) return true;\n if (Array.isArray(property.of) || !property.of) return true;\n const of = property.of;\n if (of.type === \"string\" && (of.enum || of.storage)) return false;\n if (of.type === \"number\" && of.enum) return false;\n return true;\n }\n default:\n return false;\n }\n}\n\n/**\n * The type icon in a field label, in px.\n *\n * Matched to the label's 13px rather than taken from `iconSize.smallest` (16),\n * which is sized for buttons. Exported so the surfaces that draw a label\n * themselves — the additional-field cards, the rail — can stay in step.\n */\nexport const LABEL_ICON_SIZE = 14;\n\nexport interface FieldBlockProps {\n propertyKey: string;\n property?: Property;\n /** Rendered by the form rather than by the field, unless self-labelling. */\n showLabel: boolean;\n /**\n * Which of the two renderings this block frames.\n *\n * The **label is identical in both** — same size, same weight, same colour,\n * same type icon, same required marker. A field is the same field whether or\n * not you are editing it, and a record whose labels restyle themselves under\n * Edit reads as two different screens.\n *\n * What `\"read\"` drops is the *description*, which is not part of the label:\n * it is input help. \"Sum of all line items before tax and shipping\" under a\n * number that is visibly a sum tells a reader nothing, and a line of it\n * under every field is what a record has instead of room.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Label text, when there is no property to take it from.\n *\n * For additional fields, which are columns a collection computes rather\n * than stores. They go on the same grid as the properties and so have to\n * carry the same label — drawing their own is how they ended up a size out\n * and a couple of pixels off from the field beside them.\n */\n label?: string;\n /** Type icon, when there is no property to derive one from. */\n icon?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * One field's worth of the form grid: label, control, description.\n *\n * The same block frames the read-only rendering of a record, so a field sits in\n * the same place, at the same width, under the same label whether or not you are\n * editing it — see {@link EntityViewBinding}.\n *\n * The label is one size down from the control it names (13px against the body's\n * 14) with its icon matched to it at 14px. Labels are scaffolding: you read them\n * to find the value, then read the value. Setting them at body size made a\n * column of records scan as a column of field names with data attached.\n */\nexport function FieldBlock({\n propertyKey,\n property,\n showLabel,\n mode = \"edit\",\n label,\n icon,\n children\n}: FieldBlockProps) {\n\n const reading = mode === \"read\";\n const description = property?.description?.trim();\n const required = Boolean(property?.validation?.required);\n\n return (\n // Top-aligned: with the description below the control, every label is a\n // single line, so the controls line up on their own. (Bottom-aligning\n // was only needed while the description sat between label and control.)\n <div\n id={`form_field_${propertyKey}`}\n className={\"relative flex flex-col min-w-0\"}>\n\n {showLabel && (\n <div className={cls(\n \"group/label flex items-center gap-1.5 min-w-0 font-medium leading-tight mb-1.5\",\n // Primary, not secondary: the label names the field and the\n // reference sets its labels in the primary ink; the type icon\n // beside it stays muted so the name carries the row.\n \"text-[13px] text-text-primary dark:text-text-primary-dark\"\n )}>\n {/* Small and quiet: enough to tell a number from a\n relation at a glance, not enough to compete with the\n field name. Matched to the label's 13px rather than\n left at the 16px `smallest` token, which put the\n heaviest mark on the row on the least important\n thing in it. */}\n {(property || icon) && (\n <span className={\"shrink-0 text-text-disabled dark:text-text-disabled-dark\"}>\n {property ? getIconForProperty(property, LABEL_ICON_SIZE) : icon}\n </span>\n )}\n <span className={\"truncate\"}>{property?.name ?? label ?? propertyKey}</span>\n {required && <span className={\"text-red-500 dark:text-red-500 -ml-1\"}>*</span>}\n {/* In the row, not over it. This was a tooltip on the\n label and on the control, which opened whenever a\n field took focus and covered the label being read. */}\n {property && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n )}\n\n <div className={\"min-w-0\"}>\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </div>\n\n {/* Under the control, where it reads as a note about the thing you\n just filled in rather than a subtitle of the next label. */}\n {showLabel && description && !reading && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"mt-1.5 ml-0.5 leading-snug\"}>\n {description}\n </Typography>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,UAAU,MAA4B;CAClD,QAAQ,MAAR;EACI,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;CACnB;AACJ;;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAAyC;CAC7E,IAAI,CAAC,UAAU,OAAO;CACtB,QAAQ,SAAS,MAAjB;EACI,KAAK,OAGD,OAAO,CAAC,SAAS,OAAO;EAC5B,KAAK,SAAS;GAWV,IAAI,SAAS,OAAO,OAAO;GAC3B,IAAI,MAAM,QAAQ,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,OAAO;GACvD,MAAM,KAAK,SAAS;GACpB,IAAI,GAAG,SAAS,aAAa,GAAG,QAAQ,GAAG,UAAU,OAAO;GAC5D,IAAI,GAAG,SAAS,YAAY,GAAG,MAAM,OAAO;GAC5C,OAAO;EACX;EACA,SACI,OAAO;CACf;AACJ;;;;;;;;AASA,IAAa,kBAAkB;;;;;;;;;;;;;AA+C/B,SAAgB,WAAW,EACvB,aACA,UACA,WACA,OAAO,QACP,OACA,MACA,YACgB;CAEhB,MAAM,UAAU,SAAS;CACzB,MAAM,cAAc,UAAU,aAAa,KAAK;CAChD,MAAM,WAAW,QAAQ,UAAU,YAAY,QAAQ;CAEvD,OAII,qBAAC,OAAD;EACI,IAAI,cAAc;EAClB,WAAW;YAFf;GAIK,aACG,qBAAC,OAAD;IAAK,WAAW,IACZ,kFAIA,2DACJ;cANA;MAaM,YAAY,SACV,oBAAC,QAAD;MAAM,WAAW;gBACZ,WAAW,mBAAmB,UAAA,EAAyB,IAAI;KAC1D,CAAA;KAEV,oBAAC,QAAD;MAAM,WAAW;gBAAa,UAAU,QAAQ,SAAS;KAAkB,CAAA;KAC1E,YAAY,oBAAC,QAAD;MAAM,WAAW;gBAAwC;KAAO,CAAA;KAI5E,YAAY,oBAAC,iBAAD,EAA8B,YAAa,CAAA;IACvD;;GAGT,oBAAC,OAAD;IAAK,WAAW;cACZ,oBAAC,eAAD,EACK,SACU,CAAA;GACd,CAAA;GAIJ,aAAa,eAAe,CAAC,WAC1B,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV;GACO,CAAA;EAEf;;AAEb"}
1
+ {"version":3,"file":"FieldBlock.js","names":[],"sources":["../../../src/form/components/FieldBlock.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertySpan } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { cls, ErrorBoundary, Typography } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\n\n/**\n * Grid placement for a span.\n *\n * Written out as literal class strings rather than composed, because Tailwind\n * scans source text: a template literal would produce classes that exist at\n * runtime and were never generated into the stylesheet.\n *\n * Below the column breakpoint every field takes the single available column, so\n * the side panel, the dialog and mobile all get a plain stack.\n *\n * Lives here rather than in the form, because the read-only rendering of a\n * record places its fields on the same grid — a record that changes shape when\n * you press Edit is the bug this whole layout exists to avoid.\n */\nexport function spanClass(span: PropertySpan): string {\n switch (span) {\n case 1: return \"@2xl/col:col-span-1\";\n case 2: return \"@2xl/col:col-span-2\";\n case 3: return \"@2xl/col:col-span-3\";\n case 4: return \"@2xl/col:col-span-4\";\n }\n}\n\n/**\n * Does this property's editor supply its own heading?\n *\n * Arrays, maps, `oneOf` blocks and key-value editors render as a collapsible\n * panel whose header *is* the label — hiding it would leave a panel you cannot\n * identify or, worse, cannot expand. Those keep their own; everything else gets\n * its label from {@link FieldBlock}, which is what makes a text field and a\n * select finally agree on where a label goes.\n *\n * Exported because the layout resolver's span rules and this rule have to stay\n * in step: the self-labelling types are exactly the ones that take a full row.\n */\nexport function isSelfLabellingProperty(property: Property | undefined): boolean {\n if (!property) return false;\n switch (property.type) {\n case \"map\":\n // `spreadChildren` inlines the children into the parent grid, so\n // there is no panel and therefore no header to reuse as the label.\n return !property.admin?.spreadChildren;\n case \"array\": {\n // Most arrays render as an expandable panel whose header is the\n // label — `repeat`, `block`, `custom_array`, `multi_references`.\n // The exceptions are the ones that resolve to an inline control:\n // an enum array is a multi-select and a storage array is a\n // dropzone, and both take their label from the form.\n //\n // This mirrors `getFieldConfig`'s array branch. Getting it backwards\n // is visible: an array of plain strings is a `repeat` panel, and\n // treating it as inline printed \"Available Locales\" twice, once\n // from the form and once from the panel's own header.\n if (property.oneOf) return true;\n if (Array.isArray(property.of) || !property.of) return true;\n const of = property.of;\n if (of.type === \"string\" && (of.enum || of.storage)) return false;\n if (of.type === \"number\" && of.enum) return false;\n return true;\n }\n default:\n return false;\n }\n}\n\n/**\n * The type icon in a field label, in px.\n *\n * Matched to the label's 13px rather than taken from `iconSize.smallest` (16),\n * which is sized for buttons. Exported so the surfaces that draw a label\n * themselves — the additional-field cards, the rail — can stay in step.\n */\nexport const LABEL_ICON_SIZE = 14;\n\nexport interface FieldBlockProps {\n propertyKey: string;\n property?: Property;\n /** Rendered by the form rather than by the field, unless self-labelling. */\n showLabel: boolean;\n /**\n * The control draws its label inside its own box — the one-line fields of a\n * record form (see `labelsInsideControl`). The block then draws no label\n * row, but it still owns what goes under the box: the description, indented\n * to the value inside the box, and the property's key, on that same line.\n */\n labelInside?: boolean;\n /**\n * Which of the two renderings this block frames.\n *\n * The **label is identical in both** — same size, same weight, same colour,\n * same type icon, same required marker. A field is the same field whether or\n * not you are editing it, and a record whose labels restyle themselves under\n * Edit reads as two different screens.\n *\n * What `\"read\"` drops is the *description*, which is not part of the label:\n * it is input help. \"Sum of all line items before tax and shipping\" under a\n * number that is visibly a sum tells a reader nothing, and a line of it\n * under every field is what a record has instead of room.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Label text, when there is no property to take it from.\n *\n * For additional fields, which are columns a collection computes rather\n * than stores. They go on the same grid as the properties and so have to\n * carry the same label — drawing their own is how they ended up a size out\n * and a couple of pixels off from the field beside them.\n */\n label?: string;\n /** Type icon, when there is no property to derive one from. */\n icon?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * One field's worth of the form grid: label, control, description.\n *\n * The same block frames the read-only rendering of a record, so a field sits in\n * the same place, at the same width, under the same label whether or not you are\n * editing it — see {@link EntityViewBinding}.\n *\n * The label is one size down from the control it names (13px against the body's\n * 14) with its icon matched to it at 14px. Labels are scaffolding: you read them\n * to find the value, then read the value. Setting them at body size made a\n * column of records scan as a column of field names with data attached.\n */\nexport function FieldBlock({\n propertyKey,\n property,\n showLabel,\n labelInside = false,\n mode = \"edit\",\n label,\n icon,\n children\n}: FieldBlockProps) {\n\n const reading = mode === \"read\";\n const description = property?.description?.trim();\n const required = Boolean(property?.validation?.required);\n const footed = labelInside && !reading;\n\n return (\n // Top-aligned: with the description below the control, every label is a\n // single line, so the controls line up on their own. (Bottom-aligning\n // was only needed while the description sat between label and control.)\n <div\n id={`form_field_${propertyKey}`}\n // With the label inside the control there is no label row to hover\n // for the key; the whole field reveals it instead.\n className={cls(\"relative flex flex-col min-w-0\", footed && \"group/label\")}>\n\n {showLabel && (\n <div className={cls(\n \"group/label flex items-center gap-1.5 min-w-0 font-medium leading-tight mb-1.5\",\n // Primary, not secondary: the label names the field and the\n // reference sets its labels in the primary ink; the type icon\n // beside it stays muted so the name carries the row.\n \"text-[13px] text-text-primary dark:text-text-primary-dark\"\n )}>\n {/* Small and quiet: enough to tell a number from a\n relation at a glance, not enough to compete with the\n field name. Matched to the label's 13px rather than\n left at the 16px `smallest` token, which put the\n heaviest mark on the row on the least important\n thing in it. */}\n {(property || icon) && (\n <span className={\"shrink-0 text-text-disabled dark:text-text-disabled-dark\"}>\n {property ? getIconForProperty(property, LABEL_ICON_SIZE) : icon}\n </span>\n )}\n <span className={\"truncate\"}>{property?.name ?? label ?? propertyKey}</span>\n {required && <span className={\"text-red-500 dark:text-red-500 -ml-1\"}>*</span>}\n {/* In the row, not over it. This was a tooltip on the\n label and on the control, which opened whenever a\n field took focus and covered the label being read. */}\n {property && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n )}\n\n {/* `data-field-control` names the slot for anything measuring the\n control itself. A class cannot: the label row carries\n `min-w-0` too, and a selector for it measured the label. */}\n <div className={\"min-w-0\"} data-field-control={\"\"}>\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </div>\n\n {/* Under the control, where it reads as a note about the thing you\n just filled in rather than a subtitle of the next label. */}\n {showLabel && description && !reading && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"mt-1.5 ml-0.5 leading-snug\"}>\n {description}\n </Typography>\n )}\n\n {/* A label drawn inside the box: the description is indented to\n the value, as the binding's own error line is (`ml-3.5`), and\n the key sits at the end of that line. A field with no\n description has no line to put it on, so the key hangs in the\n row gap below the box rather than reserving a line under every\n field for something only a hover shows. */}\n {footed && (description || property) && (\n <div className={cls(\n \"flex items-start gap-2 min-w-0 ml-3.5\",\n description ? \"mt-1.5\" : \"absolute top-full right-0 mt-1\"\n )}>\n {description && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"grow min-w-0 leading-snug\"}>\n {description}\n </Typography>\n )}\n {property && <PropertyKeyHint propertyKey={propertyKey}\n className={description ? \"ml-auto shrink-0\" : undefined}/>}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,UAAU,MAA4B;CAClD,QAAQ,MAAR;EACI,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;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cAC3C,oBAAC,eAAD,EACK,SACU,CAAA;GACd,CAAA;GAIJ,aAAa,eAAe,CAAC,WAC1B,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV;GACO,CAAA;GASf,WAAW,eAAe,aACvB,qBAAC,OAAD;IAAK,WAAW,IACZ,yCACA,cAAc,WAAW,gCAC7B;cAHA,CAIK,eACG,oBAAC,YAAD;KAAY,SAAS;KACjB,OAAO;KACP,WAAW;eACV;IACO,CAAA,GAEf,YAAY,oBAAC,iBAAD;KAA8B;KACvC,WAAW,cAAc,qBAAqB,KAAA;IAAW,CAAA,CAC5D;;EAER;;AAEb"}
@@ -24,7 +24,7 @@ function FormSections({ sections, collapsed, onToggle, errorKeys, renderField, m
24
24
  children: section.fields.map((field, index) => renderSummaryField(field, index, section.fields.length))
25
25
  }) : /* @__PURE__ */ jsx("div", {
26
26
  id: `form_section_${section.key}`,
27
- className: cls("grid min-w-0", reading ? "gap-x-8 gap-y-7" : "gap-x-4 gap-y-5", "grid-cols-1 @2xl:grid-cols-4"),
27
+ className: cls("grid min-w-0", reading ? "gap-x-8 gap-y-7" : "gap-x-4 gap-y-6", "grid-cols-1 @2xl:grid-cols-4"),
28
28
  children: section.fields.map(renderField)
29
29
  }))]
30
30
  }, section.key);
@@ -1 +1 @@
1
- {"version":3,"file":"FormSections.js","names":[],"sources":["../../../src/form/components/FormSections.tsx"],"sourcesContent":["import type { ResolvedFormField, ResolvedFormSection } from \"@rebasepro/app\";\nimport React from \"react\";\nimport { ChevronDownIcon, cls, defaultBorderMixin, iconSize } from \"@rebasepro/ui\";\n\nexport interface FormSectionsProps {\n sections: ResolvedFormSection[];\n /** Section keys the user has collapsed. */\n collapsed: ReadonlySet<string>;\n onToggle: (key: string) => void;\n /**\n * Field keys currently showing a validation error. A section holding one is\n * forced open — an error that hides inside a collapsed group is a form the\n * user cannot submit and cannot debug.\n */\n errorKeys: ReadonlySet<string>;\n renderField: (field: ResolvedFormField) => React.ReactNode;\n /**\n * Which rendering this is. `\"read\"` opens the gaps up rather than closing\n * them: a control is a bordered 40px box that separates itself from the next\n * one, and a value is bare text that does not. The form can also afford\n * tighter rows because a description usually sits between them; with that\n * gone, the same numbers ran a record's values together into one block.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Renders one field as a summary row, for a section that asked for\n * `readVariant: \"summary\"`. Only the read view supplies it; without it such\n * a section falls back to the grid rather than to nothing.\n */\n renderSummaryField?: (field: ResolvedFormField, index: number, total: number) => React.ReactNode;\n}\n\nexport function FormSections({\n sections,\n collapsed,\n onToggle,\n errorKeys,\n renderField,\n mode = \"edit\",\n renderSummaryField\n}: FormSectionsProps) {\n\n const reading = mode === \"read\";\n\n return (\n <div className={cls(\"flex flex-col\", reading ? \"gap-10\" : \"gap-8\")}>\n {sections.map((section) => {\n\n const hasError = section.fields.some(f => errorKeys.has(f.key));\n const isCollapsed = section.collapsible && collapsed.has(section.key) && !hasError;\n const summary = reading\n && section.readVariant === \"summary\"\n && Boolean(renderSummaryField);\n\n return (\n <section key={section.key} className={\"min-w-0\"}>\n\n {section.title && (\n <Header\n title={section.title}\n collapsible={section.collapsible}\n collapsed={isCollapsed}\n controls={`form_section_${section.key}`}\n onToggle={() => onToggle(section.key)}/>\n )}\n\n {!isCollapsed && (summary\n ? <div id={`form_section_${section.key}`}\n className={\"flex flex-col min-w-0 @2xl:max-w-md @2xl:ml-auto\"}>\n {section.fields.map((field, index) =>\n renderSummaryField!(field, index, section.fields.length))}\n </div>\n // A container query, not a media query: the form is\n // rendered at four very different widths (full\n // screen, side panel, split pane, dialog) inside the\n // same viewport, so spans have to answer to the\n // column they are in, not to the window.\n : <div id={`form_section_${section.key}`}\n className={cls(\n \"grid min-w-0\",\n reading ? \"gap-x-8 gap-y-7\" : \"gap-x-4 gap-y-5\",\n \"grid-cols-1 @2xl:grid-cols-4\"\n )}>\n {section.fields.map(renderField)}\n </div>\n )}\n </section>\n );\n })}\n </div>\n );\n}\n\nfunction Header({\n title,\n collapsible,\n collapsed,\n controls,\n onToggle\n}: {\n title: string;\n collapsible: boolean;\n collapsed: boolean;\n /**\n * Id of the region this header shows and hides. Only referenced while that\n * region exists — a collapsed section unmounts its fields, and pointing\n * `aria-controls` at an id that is not in the document is its own defect.\n */\n controls: string;\n onToggle: () => void;\n}) {\n\n const content = (\n <>\n {collapsible && (\n <ChevronDownIcon\n size={iconSize.smallest}\n className={cls(\n \"text-text-disabled dark:text-text-disabled-dark transition-transform duration-150\",\n collapsed && \"-rotate-90\"\n )}/>\n )}\n <span className={\"text-xs font-semibold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark whitespace-nowrap\"}>\n {title}\n </span>\n <span className={cls(\"flex-1 border-t\", defaultBorderMixin)}/>\n </>\n );\n\n const className = \"flex items-center gap-2.5 w-full mb-3.5\";\n\n if (!collapsible) {\n return <div className={className}>{content}</div>;\n }\n\n return (\n <button type={\"button\"}\n onClick={onToggle}\n aria-expanded={!collapsed}\n aria-controls={collapsed ? undefined : controls}\n className={cls(className, \"text-left hover:opacity-80 transition-opacity\")}>\n {content}\n </button>\n );\n}\n"],"mappings":";;;;AAgCA,SAAgB,aAAa,EACzB,UACA,WACA,UACA,WACA,aACA,OAAO,QACP,sBACkB;CAElB,MAAM,UAAU,SAAS;CAEzB,OACI,oBAAC,OAAD;EAAK,WAAW,IAAI,iBAAiB,UAAU,WAAW,OAAO;YAC5D,SAAS,KAAK,YAAY;GAEvB,MAAM,WAAW,QAAQ,OAAO,MAAK,MAAK,UAAU,IAAI,EAAE,GAAG,CAAC;GAC9D,MAAM,cAAc,QAAQ,eAAe,UAAU,IAAI,QAAQ,GAAG,KAAK,CAAC;GAC1E,MAAM,UAAU,WACT,QAAQ,gBAAgB,aACxB,QAAQ,kBAAkB;GAEjC,OACI,qBAAC,WAAD;IAA2B,WAAW;cAAtC,CAEK,QAAQ,SACL,oBAAC,QAAD;KACI,OAAO,QAAQ;KACf,aAAa,QAAQ;KACrB,WAAW;KACX,UAAU,gBAAgB,QAAQ;KAClC,gBAAgB,SAAS,QAAQ,GAAG;IAAG,CAAA,GAG9C,CAAC,gBAAgB,UACZ,oBAAC,OAAD;KAAK,IAAI,gBAAgB,QAAQ;KAC/B,WAAW;eACV,QAAQ,OAAO,KAAK,OAAO,UACxB,mBAAoB,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;IAC3D,CAAA,IAMH,oBAAC,OAAD;KAAK,IAAI,gBAAgB,QAAQ;KAC/B,WAAW,IACP,gBACA,UAAU,oBAAoB,mBAC9B,8BACJ;eACC,QAAQ,OAAO,IAAI,WAAW;IAC9B,CAAA,EAEJ;MA/BK,QAAQ,GA+Bb;EAEjB,CAAC;CACA,CAAA;AAEb;AAEA,SAAS,OAAO,EACZ,OACA,aACA,WACA,UACA,YAYD;CAEC,MAAM,UACF,qBAAA,UAAA,EAAA,UAAA;EACK,eACG,oBAAC,iBAAD;GACI,MAAM,SAAS;GACf,WAAW,IACP,qFACA,aAAa,YACjB;EAAG,CAAA;EAEX,oBAAC,QAAD;GAAM,WAAW;aACZ;EACC,CAAA;EACN,oBAAC,QAAD,EAAM,WAAW,IAAI,mBAAmB,kBAAkB,EAAG,CAAA;CAC/D,EAAA,CAAA;CAGN,MAAM,YAAY;CAElB,IAAI,CAAC,aACD,OAAO,oBAAC,OAAD;EAAgB;YAAY;CAAa,CAAA;CAGpD,OACI,oBAAC,UAAD;EAAQ,MAAM;EACV,SAAS;EACT,iBAAe,CAAC;EAChB,iBAAe,YAAY,KAAA,IAAY;EACvC,WAAW,IAAI,WAAW,+CAA+C;YACxE;CACG,CAAA;AAEhB"}
1
+ {"version":3,"file":"FormSections.js","names":[],"sources":["../../../src/form/components/FormSections.tsx"],"sourcesContent":["import type { ResolvedFormField, ResolvedFormSection } from \"@rebasepro/app\";\nimport React from \"react\";\nimport { ChevronDownIcon, cls, defaultBorderMixin, iconSize } from \"@rebasepro/ui\";\n\nexport interface FormSectionsProps {\n sections: ResolvedFormSection[];\n /** Section keys the user has collapsed. */\n collapsed: ReadonlySet<string>;\n onToggle: (key: string) => void;\n /**\n * Field keys currently showing a validation error. A section holding one is\n * forced open — an error that hides inside a collapsed group is a form the\n * user cannot submit and cannot debug.\n */\n errorKeys: ReadonlySet<string>;\n renderField: (field: ResolvedFormField) => React.ReactNode;\n /**\n * Which rendering this is. `\"read\"` opens the gaps up rather than closing\n * them: a control is a bordered 40px box that separates itself from the next\n * one, and a value is bare text that does not. The form can also afford\n * tighter rows because a description usually sits between them; with that\n * gone, the same numbers ran a record's values together into one block.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Renders one field as a summary row, for a section that asked for\n * `readVariant: \"summary\"`. Only the read view supplies it; without it such\n * a section falls back to the grid rather than to nothing.\n */\n renderSummaryField?: (field: ResolvedFormField, index: number, total: number) => React.ReactNode;\n}\n\nexport function FormSections({\n sections,\n collapsed,\n onToggle,\n errorKeys,\n renderField,\n mode = \"edit\",\n renderSummaryField\n}: FormSectionsProps) {\n\n const reading = mode === \"read\";\n\n return (\n <div className={cls(\"flex flex-col\", reading ? \"gap-10\" : \"gap-8\")}>\n {sections.map((section) => {\n\n const hasError = section.fields.some(f => errorKeys.has(f.key));\n const isCollapsed = section.collapsible && collapsed.has(section.key) && !hasError;\n const summary = reading\n && section.readVariant === \"summary\"\n && Boolean(renderSummaryField);\n\n return (\n <section key={section.key} className={\"min-w-0\"}>\n\n {section.title && (\n <Header\n title={section.title}\n collapsible={section.collapsible}\n collapsed={isCollapsed}\n controls={`form_section_${section.key}`}\n onToggle={() => onToggle(section.key)}/>\n )}\n\n {!isCollapsed && (summary\n ? <div id={`form_section_${section.key}`}\n className={\"flex flex-col min-w-0 @2xl:max-w-md @2xl:ml-auto\"}>\n {section.fields.map((field, index) =>\n renderSummaryField!(field, index, section.fields.length))}\n </div>\n // A container query, not a media query: the form is\n // rendered at four very different widths (full\n // screen, side panel, split pane, dialog) inside the\n // same viewport, so spans have to answer to the\n // column they are in, not to the window.\n : <div id={`form_section_${section.key}`}\n className={cls(\n \"grid min-w-0\",\n // 24px between rows of filled boxes: with no\n // edge on a field, the gap is what keeps two\n // rows from reading as one block. It also\n // holds a field's key hint, which hangs below\n // a box that has no description line.\n reading ? \"gap-x-8 gap-y-7\" : \"gap-x-4 gap-y-6\",\n \"grid-cols-1 @2xl:grid-cols-4\"\n )}>\n {section.fields.map(renderField)}\n </div>\n )}\n </section>\n );\n })}\n </div>\n );\n}\n\nfunction Header({\n title,\n collapsible,\n collapsed,\n controls,\n onToggle\n}: {\n title: string;\n collapsible: boolean;\n collapsed: boolean;\n /**\n * Id of the region this header shows and hides. Only referenced while that\n * region exists — a collapsed section unmounts its fields, and pointing\n * `aria-controls` at an id that is not in the document is its own defect.\n */\n controls: string;\n onToggle: () => void;\n}) {\n\n const content = (\n <>\n {collapsible && (\n <ChevronDownIcon\n size={iconSize.smallest}\n className={cls(\n \"text-text-disabled dark:text-text-disabled-dark transition-transform duration-150\",\n collapsed && \"-rotate-90\"\n )}/>\n )}\n <span className={\"text-xs font-semibold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark whitespace-nowrap\"}>\n {title}\n </span>\n <span className={cls(\"flex-1 border-t\", defaultBorderMixin)}/>\n </>\n );\n\n const className = \"flex items-center gap-2.5 w-full mb-3.5\";\n\n if (!collapsible) {\n return <div className={className}>{content}</div>;\n }\n\n return (\n <button type={\"button\"}\n onClick={onToggle}\n aria-expanded={!collapsed}\n aria-controls={collapsed ? undefined : controls}\n className={cls(className, \"text-left hover:opacity-80 transition-opacity\")}>\n {content}\n </button>\n );\n}\n"],"mappings":";;;;AAgCA,SAAgB,aAAa,EACzB,UACA,WACA,UACA,WACA,aACA,OAAO,QACP,sBACkB;CAElB,MAAM,UAAU,SAAS;CAEzB,OACI,oBAAC,OAAD;EAAK,WAAW,IAAI,iBAAiB,UAAU,WAAW,OAAO;YAC5D,SAAS,KAAK,YAAY;GAEvB,MAAM,WAAW,QAAQ,OAAO,MAAK,MAAK,UAAU,IAAI,EAAE,GAAG,CAAC;GAC9D,MAAM,cA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AAA;AAEhB"}
@@ -13,10 +13,13 @@ var LabelWithIcon = forwardRef(({ icon, title, small, className, required, label
13
13
  className: cls("group/label align-middle inline-flex items-center min-w-0 my-0.5", small ? "gap-1" : "gap-2", className),
14
14
  children: [
15
15
  icon,
16
- /* @__PURE__ */ jsx("span", {
16
+ /* @__PURE__ */ jsxs("span", {
17
17
  id: labelId,
18
18
  className: `text-start font-medium text-${small ? "base" : "sm"} origin-top-left transform ${small ? "translate-x-2 scale-75" : ""}`,
19
- children: (title ?? "") + (required ? " *" : "")
19
+ children: [title ?? "", required && /* @__PURE__ */ jsx("span", {
20
+ "aria-hidden": true,
21
+ children: " *"
22
+ })]
20
23
  }),
21
24
  propertyKey && /* @__PURE__ */ jsx(PropertyKeyHint, { propertyKey })
22
25
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"LabelWithIcon.js","names":[],"sources":["../../../src/form/components/LabelWithIcon.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { cls } from \"@rebasepro/ui\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\n\ninterface LabelWithIconProps {\n icon: React.ReactNode;\n title?: string;\n small?: boolean;\n className?: string;\n required?: boolean;\n /**\n * `id` for the text of the label, so a control can point at it with\n * `aria-labelledby`.\n *\n * On the *text*, not on the wrapper: the wrapper also holds the property's\n * type icon, and an accessible name assembled from a decorative `<svg>` is\n * a name nobody chose. Deliberately absent by default — an unused `id` is\n * one more thing that can collide.\n */\n labelId?: string;\n /**\n * The property's key, revealed beside the label on hover and copied on\n * click — see {@link PropertyKeyHint}. Leave it out where the label is drawn\n * inside the control it names (a switch, a date field), where a second\n * clickable thing would sit inside the first.\n */\n propertyKey?: string;\n}\n\n/**\n * Render the label of with an icon and the title of a property\n * @group Form custom fields\n */\nexport const LabelWithIcon = forwardRef<HTMLDivElement, LabelWithIconProps>(\n ({\n icon,\n title,\n small,\n className,\n required,\n labelId,\n propertyKey\n }, ref) => {\n return (\n <div\n ref={ref}\n className={cls(\"group/label align-middle inline-flex items-center min-w-0 my-0.5\",\n small ? \"gap-1\" : \"gap-2\",\n className)}\n >\n {icon}\n <span\n id={labelId}\n className={`text-start font-medium text-${small ? \"base\" : \"sm\"} origin-top-left transform ${small ? \"translate-x-2 scale-75\" : \"\"\n }`}\n >\n {(title ?? \"\") + (required ? \" *\" : \"\")}\n </span>\n {propertyKey && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n );\n }\n);\n\nLabelWithIcon.displayName = \"LabelWithIcon\";\n"],"mappings":";;;;;;;;;AAiCA,IAAa,gBAAgB,YACxB,EACG,MACA,OACA,OACA,WACA,UACA,SACA,eACD,QAAQ;CACP,OACI,qBAAC,OAAD;EACS;EACL,WAAW,IAAI,oEACX,QAAQ,UAAU,SAClB,SAAS;YAJjB;GAMK;GACD,oBAAC,QAAD;IACI,IAAI;IACJ,WAAW,+BAA+B,QAAQ,SAAS,KAAK,6BAA6B,QAAQ,2BAA2B;eAG9H,SAAS,OAAO,WAAW,OAAO;GAClC,CAAA;GACL,eAAe,oBAAC,iBAAD,EAA8B,YAAa,CAAA;EAC1D;;AAEb,CACJ;AAEA,cAAc,cAAc"}
1
+ {"version":3,"file":"LabelWithIcon.js","names":[],"sources":["../../../src/form/components/LabelWithIcon.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { cls } from \"@rebasepro/ui\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\n\ninterface LabelWithIconProps {\n icon: React.ReactNode;\n title?: string;\n small?: boolean;\n className?: string;\n required?: boolean;\n /**\n * `id` for the text of the label, so a control can point at it with\n * `aria-labelledby`.\n *\n * On the *text*, not on the wrapper: the wrapper also holds the property's\n * type icon, and an accessible name assembled from a decorative `<svg>` is\n * a name nobody chose. Deliberately absent by default — an unused `id` is\n * one more thing that can collide.\n */\n labelId?: string;\n /**\n * The property's key, revealed beside the label on hover and copied on\n * click — see {@link PropertyKeyHint}. Leave it out where the label is drawn\n * inside the control it names (a switch, a date field), where a second\n * clickable thing would sit inside the first.\n */\n propertyKey?: string;\n}\n\n/**\n * Render the label of with an icon and the title of a property\n * @group Form custom fields\n */\nexport const LabelWithIcon = forwardRef<HTMLDivElement, LabelWithIconProps>(\n ({\n icon,\n title,\n small,\n className,\n required,\n labelId,\n propertyKey\n }, ref) => {\n return (\n <div\n ref={ref}\n className={cls(\"group/label align-middle inline-flex items-center min-w-0 my-0.5\",\n small ? \"gap-1\" : \"gap-2\",\n className)}\n >\n {icon}\n <span\n id={labelId}\n className={`text-start font-medium text-${small ? \"base\" : \"sm\"} origin-top-left transform ${small ? \"translate-x-2 scale-75\" : \"\"\n }`}\n >\n {title ?? \"\"}\n {/* Hidden from the accessible name: a field labelled inside\n its box is named by this label, and \"SKU star\" is not\n its name. */}\n {required && <span aria-hidden={true}> *</span>}\n </span>\n {propertyKey && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n );\n }\n);\n\nLabelWithIcon.displayName = \"LabelWithIcon\";\n"],"mappings":";;;;;;;;;AAiCA,IAAa,gBAAgB,YACxB,EACG,MACA,OACA,OACA,WACA,UACA,SACA,eACD,QAAQ;CACP,OACI,qBAAC,OAAD;EACS;EACL,WAAW,IAAI,oEACX,QAAQ,UAAU,SAClB,SAAS;YAJjB;GAMK;GACD,qBAAC,QAAD;IACI,IAAI;IACJ,WAAW,+BAA+B,QAAQ,SAAS,KAAK,6BAA6B,QAAQ,2BAA2B;cAFpI,CAKK,SAAS,IAIT,YAAY,oBAAC,QAAD;KAAM,eAAa;eAAM;IAAQ,CAAA,CAC5C;;GACL,eAAe,oBAAC,iBAAD,EAA8B,YAAa,CAAA;EAC1D;;AAEb,CACJ;AAEA,cAAc,cAAc"}
@@ -32,7 +32,8 @@ function DateTimeFieldBinding({ propertyKey, value, setValue, autoFocus, error,
32
32
  className: showError ? "text-red-500 dark:text-red-500" : "text-text-secondary dark:text-text-secondary-dark",
33
33
  title: property.name ?? propertyKey
34
34
  }),
35
- "aria-label": hideLabel ? property.name ?? propertyKey : void 0
35
+ "aria-label": hideLabel ? property.name ?? propertyKey : void 0,
36
+ inputClassName: !hideLabel && size === "large" ? "text-base" : void 0
36
37
  }), /* @__PURE__ */ jsx(FieldHelperText, {
37
38
  includeDescription,
38
39
  showError,
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/DateTimeFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { DateProperty } from \"@rebasepro/types\";\nimport React from \"react\";\n\n;\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { useCustomizationController } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { DateTimeField } from \"@rebasepro/ui\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../preview/util\";\n\ntype DateTimeFieldProps = FieldProps<DateProperty>;\n\n/**\n * Field that allows selecting a date\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function DateTimeFieldBinding({\n propertyKey,\n value,\n setValue,\n autoFocus,\n error,\n showError,\n disabled,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: DateTimeFieldProps) {\n\n const { locale } = useCustomizationController();\n const internalValue = value || null;\n\n return (\n <>\n {/* The form's `size`, like every other control. It was dropped\n here, so a date field drew at the kit's own default whatever\n the form asked for: while the form was `small`, 16px taller\n than the 32px text fields beside it. */}\n <DateTimeField\n size={size}\n value={internalValue}\n onChange={(dateValue) => setValue(dateValue)}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n clearable={property.admin?.clearable}\n locale={locale}\n error={showError}\n disabled={disabled}\n label={hideLabel ? undefined : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n className={showError ? \"text-red-500 dark:text-red-500\" : \"text-text-secondary dark:text-text-secondary-dark\"}\n title={property.name ?? propertyKey}/>}\n // The entity form sets `hideLabel` for every field FieldBlock\n // labels on its behalf, and FieldBlock's label is a <span> that\n // points at nothing — so without this the control is nameless.\n aria-label={hideLabel ? (property.name ?? propertyKey) : undefined}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,SAAgB,qBAAqB,EACjC,aACA,OACA,UACA,WACA,OACA,WACA,UACA,SACA,UACA,oBACA,WACA,OAAO,WACY;CAEnB,MAAM,EAAE,WAAW,2BAA2B;CAG9C,OACI,qBAAA,UAAA,EAAA,UAAA,CAKI,oBAAC,eAAD;EACU;EACN,OAVU,SAAS;EAWnB,WAAW,cAAc,SAAS,SAAS;EAC3C,MAAM,oBAAoB,QAAQ;EAClC,UAAU,wBAAwB,QAAQ;EAC1C,WAAW,SAAS,OAAO;EACnB;EACR,OAAO;EACG;EACV,OAAO,YAAY,KAAA,IAAY,oBAAC,eAAD;GAC3B,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,WAAW,YAAY,mCAAmC;GAC1D,OAAO,SAAS,QAAQ;EAAa,CAAA;EAIzC,cAAY,YAAa,SAAS,QAAQ,cAAe,KAAA;CAC5D,CAAA,GAED,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;EACA;CAAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"DateTimeFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/DateTimeFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { DateProperty } from \"@rebasepro/types\";\nimport React from \"react\";\n\n;\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { useCustomizationController } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { DateTimeField } from \"@rebasepro/ui\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../preview/util\";\n\ntype DateTimeFieldProps = FieldProps<DateProperty>;\n\n/**\n * Field that allows selecting a date\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function DateTimeFieldBinding({\n propertyKey,\n value,\n setValue,\n autoFocus,\n error,\n showError,\n disabled,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: DateTimeFieldProps) {\n\n const { locale } = useCustomizationController();\n const internalValue = value || null;\n\n return (\n <>\n {/* The form's `size`, like every other control. It was dropped\n here, so a date field drew at the kit's own default whatever\n the form asked for: while the form was `small`, 16px taller\n than the 32px text fields beside it. */}\n <DateTimeField\n size={size}\n value={internalValue}\n onChange={(dateValue) => setValue(dateValue)}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n clearable={property.admin?.clearable}\n locale={locale}\n error={showError}\n disabled={disabled}\n label={hideLabel ? undefined : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n className={showError ? \"text-red-500 dark:text-red-500\" : \"text-text-secondary dark:text-text-secondary-dark\"}\n title={property.name ?? propertyKey}/>}\n // The entity form sets `hideLabel` for every field FieldBlock\n // labels on its behalf, and FieldBlock's label is a <span> that\n // points at nothing — so without this the control is nameless.\n aria-label={hideLabel ? (property.name ?? propertyKey) : undefined}\n // 16px under the label, as the text field beside it: the 64px\n // labelled box is sized for a 24px line.\n inputClassName={!hideLabel && size === \"large\" ? \"text-base\" : undefined}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,SAAgB,qBAAqB,EACjC,aACA,OACA,UACA,WACA,OACA,WACA,UACA,SACA,UACA,oBACA,WACA,OAAO,WACY;CAEnB,MAAM,EAAE,WAAW,2BAA2B;CAG9C,OACI,qBAAA,UAAA,EAAA,UAAA,CAKI,oBAAC,eAAD;EACU;EACN,OAVU,SAAS;EAWnB,WAAW,cAAc,SAAS,SAAS;EAC3C,MAAM,oBAAoB,QAAQ;EAClC,UAAU,wBAAwB,QAAQ;EAC1C,WAAW,SAAS,OAAO;EACnB;EACR,OAAO;EACG;EACV,OAAO,YAAY,KAAA,IAAY,oBAAC,eAAD;GAC3B,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,WAAW,YAAY,mCAAmC;GAC1D,OAAO,SAAS,QAAQ;EAAa,CAAA;EAIzC,cAAY,YAAa,SAAS,QAAQ,cAAe,KAAA;EAGzD,gBAAgB,CAAC,aAAa,SAAS,UAAU,cAAc,KAAA;CAClE,CAAA,GAED,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;EACA;CAAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
@@ -1,10 +1,11 @@
1
1
  import { getIconForProperty } from "../../util/property_utils.js";
2
+ import { readOnlyLabelsInside } from "../label_placement.js";
2
3
  import { PropertyPreview } from "../../preview/PropertyPreview.js";
3
4
  import { FieldHelperText } from "../components/FieldHelperText.js";
4
5
  import { LabelWithIcon } from "../components/LabelWithIcon.js";
5
6
  import "react";
6
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { ErrorBoundary, cls } from "@rebasepro/ui";
8
+ import { ErrorBoundary, InputLabel, cls } from "@rebasepro/ui";
8
9
  //#region src/form/field_bindings/ReadOnlyFieldBinding.tsx
9
10
  /**
10
11
  *
@@ -16,6 +17,32 @@ import { ErrorBoundary, cls } from "@rebasepro/ui";
16
17
  */
17
18
  function ReadOnlyFieldBinding({ propertyKey, value, error, showError, minimalistView, property, includeDescription, hideLabel, context, size = "large" }) {
18
19
  const skipCardWrapper = property.type === "relation" || property.type === "reference";
20
+ if (!minimalistView && !hideLabel && size === "large" && readOnlyLabelsInside(property)) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
21
+ className: "relative w-full min-h-[66px] rounded-lg border border-hairline-strong px-3 pt-8 pb-2 text-base",
22
+ children: [/* @__PURE__ */ jsx(InputLabel, {
23
+ shrink: true,
24
+ className: "pointer-events-none absolute top-1 left-0 text-text-secondary dark:text-text-secondary-dark",
25
+ children: /* @__PURE__ */ jsx(LabelWithIcon, {
26
+ icon: getIconForProperty(property, "small"),
27
+ required: property.validation?.required,
28
+ title: property.name ?? propertyKey
29
+ })
30
+ }), /* @__PURE__ */ jsx("div", {
31
+ className: "min-h-6 flex items-center overflow-x-auto no-scrollbar opacity-80",
32
+ children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(PropertyPreview, {
33
+ propertyKey,
34
+ value,
35
+ property,
36
+ hideLabel: true,
37
+ size: "medium"
38
+ }) })
39
+ })]
40
+ }), /* @__PURE__ */ jsx(FieldHelperText, {
41
+ includeDescription,
42
+ showError,
43
+ error,
44
+ property
45
+ })] });
19
46
  return /* @__PURE__ */ jsxs(Fragment, { children: [
20
47
  !minimalistView && !hideLabel && /* @__PURE__ */ jsx(LabelWithIcon, {
21
48
  propertyKey,
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ReadOnlyFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport React from \"react\";\n\n;\n\nimport { PropertyPreview } from \"../../preview\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { cls } from \"@rebasepro/ui\";\n\n/**\n *\n * Simply render the non-editable preview of a field\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function ReadOnlyFieldBinding({\n propertyKey,\n value,\n error,\n showError,\n minimalistView,\n property,\n includeDescription,\n hideLabel,\n context,\n size = \"large\"\n}: FieldProps<Property>) {\n\n // if (!context.entityId)\n // throw new Error(\"ReadOnlyFieldBinding: Entity id is null\");\n\n const skipCardWrapper = property.type === \"relation\" || property.type === \"reference\";\n\n return (\n\n <>\n\n {!minimalistView && !hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3\"}/>\n }\n\n <div\n className={cls(\n \"w-full overflow-x-scroll no-scrollbar flex items-center\",\n skipCardWrapper\n ? \"\"\n // `px-3` is what `TextField` gives its input, so a\n // read-only value starts on the same vertical line as\n // the text beside it. It was `px-4 md:px-6`, which in a\n // one-column span spent a sixth of the box on empty\n // margin and pushed short values towards the middle.\n : cls(\"rounded-lg border border-hairline-strong px-3 text-sm opacity-80\", {\n // The height an editable field of the form's `size`\n // renders at — the kit's control height plus its 1px\n // hairline on each side — so a row holding one of\n // each has its baselines and bottom edges agree. This\n // was a fixed `min-h-12` (48px) with the page's 16px\n // text: 2px short of a `large` text field, 14px taller\n // than a `small` one, and a size above every input's\n // `text-sm` at either.\n \"min-h-[34px]\": size === \"small\",\n \"min-h-[42px]\": size === \"medium\",\n \"min-h-[50px]\": size === \"large\"\n })\n )}>\n\n <ErrorBoundary>\n {/* The field is labelled either just above by this\n component, or by the `FieldBlock` that asked for\n `hideLabel` — never by the preview. `BooleanPreview`\n prints the property name beside its checkbox, so a\n read-only boolean read as \"Procesado por LLM\" over a\n checkbox saying \"Procesado por LLM\", wrapped over two\n lines in a one-column span. */}\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel={hideLabel || !minimalistView}\n size={\"medium\"}/>\n </ErrorBoundary>\n\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,SAAgB,qBAAqB,EACjC,aACA,OACA,OACA,WACA,gBACA,UACA,oBACA,WACA,SACA,OAAO,WACc;CAKrB,MAAM,kBAAkB,SAAS,SAAS,cAAc,SAAS,SAAS;CAE1E,OAEI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBAAkB,CAAC,aAAa,oBAAC,eAAD;GACjB;GACb,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;GACxB,WAAW;EAA8D,CAAA;EAG7E,oBAAC,OAAD;GACI,WAAW,IACP,2DACA,kBACM,KAMA,IAAI,oEAAoE;IAStE,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;GAC7B,CAAC,CACT;aAEA,oBAAC,eAAD,EAAA,UAQI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAW,aAAa,CAAC;IACzB,MAAM;GAAU,CAAA,EACT,CAAA;EAEd,CAAA;EAEL,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;EAAU,CAAA;CAE1B,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"ReadOnlyFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ReadOnlyFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport React from \"react\";\n\nimport { PropertyPreview } from \"../../preview\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { cls, ErrorBoundary, InputLabel } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { readOnlyLabelsInside } from \"../label_placement\";\n\n/**\n *\n * Simply render the non-editable preview of a field\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function ReadOnlyFieldBinding({\n propertyKey,\n value,\n error,\n showError,\n minimalistView,\n property,\n includeDescription,\n hideLabel,\n context,\n size = \"large\"\n}: FieldProps<Property>) {\n\n // if (!context.entityId)\n // throw new Error(\"ReadOnlyFieldBinding: Entity id is null\");\n\n const skipCardWrapper = property.type === \"relation\" || property.type === \"reference\";\n\n // A one-line value at the form's size is drawn like the one-line fields\n // around it: the same 64px box, the label shrunk into its top edge. It keeps\n // the outline and drops the fill — that is what says it cannot be edited.\n if (!minimalistView && !hideLabel && size === \"large\" && readOnlyLabelsInside(property)) {\n return (\n <>\n <div className={\"relative w-full min-h-[66px] rounded-lg border border-hairline-strong px-3 pt-8 pb-2 text-base\"}>\n {/* `left-0` is the box's padding edge, where a text field's\n label starts; left to its static position it would\n start after the `px-3`, 12px too far in. */}\n <InputLabel shrink\n className={\"pointer-events-none absolute top-1 left-0 text-text-secondary dark:text-text-secondary-dark\"}>\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>\n </InputLabel>\n <div className={\"min-h-6 flex items-center overflow-x-auto no-scrollbar opacity-80\"}>\n <ErrorBoundary>\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </ErrorBoundary>\n </div>\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n </>\n );\n }\n\n return (\n\n <>\n\n {!minimalistView && !hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3\"}/>\n }\n\n <div\n className={cls(\n \"w-full overflow-x-scroll no-scrollbar flex items-center\",\n skipCardWrapper\n ? \"\"\n // `px-3` is what `TextField` gives its input, so a\n // read-only value starts on the same vertical line as\n // the text beside it. It was `px-4 md:px-6`, which in a\n // one-column span spent a sixth of the box on empty\n // margin and pushed short values towards the middle.\n : cls(\"rounded-lg border border-hairline-strong px-3 text-sm opacity-80\", {\n // The height an editable field of the form's `size`\n // renders at — the kit's control height plus its 1px\n // hairline on each side — so a row holding one of\n // each has its baselines and bottom edges agree. This\n // was a fixed `min-h-12` (48px) with the page's 16px\n // text: 2px short of a `large` text field, 14px taller\n // than a `small` one, and a size above every input's\n // `text-sm` at either.\n \"min-h-[34px]\": size === \"small\",\n \"min-h-[42px]\": size === \"medium\",\n \"min-h-[50px]\": size === \"large\"\n })\n )}>\n\n <ErrorBoundary>\n {/* The field is labelled either just above by this\n component, or by the `FieldBlock` that asked for\n `hideLabel` — never by the preview. `BooleanPreview`\n prints the property name beside its checkbox, so a\n read-only boolean read as \"Procesado por LLM\" over a\n checkbox saying \"Procesado por LLM\", wrapped over two\n lines in a one-column span. */}\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel={hideLabel || !minimalistView}\n size={\"medium\"}/>\n </ErrorBoundary>\n\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAgB,qBAAqB,EACjC,aACA,OACA,OACA,WACA,gBACA,UACA,oBACA,WACA,SACA,OAAO,WACc;CAKrB,MAAM,kBAAkB,SAAS,SAAS,cAAc,SAAS,SAAS;CAK1E,IAAI,CAAC,kBAAkB,CAAC,aAAa,SAAS,WAAW,qBAAqB,QAAQ,GAClF,OACI,qBAAA,UAAA,EAAA,UAAA,CACI,qBAAC,OAAD;EAAK,WAAW;YAAhB,CAII,oBAAC,YAAD;GAAY,QAAA;GACR,WAAW;aACX,oBAAC,eAAD;IACI,MAAM,mBAAmB,UAAU,OAAO;IAC1C,UAAU,SAAS,YAAY;IAC/B,OAAO,SAAS,QAAQ;GAAa,CAAA;EACjC,CAAA,GACZ,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAA;IACA,MAAM;GAAU,CAAA,EACT,CAAA;EACd,CAAA,CACJ;KAEL,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;CAAU,CAAA,CAC1B,EAAA,CAAA;CAIV,OAEI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBAAkB,CAAC,aAAa,oBAAC,eAAD;GACjB;GACb,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;GACxB,WAAW;EAA8D,CAAA;EAG7E,oBAAC,OAAD;GACI,WAAW,IACP,2DACA,kBACM,KAMA,IAAI,oEAAoE;IAStE,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;GAC7B,CAAC,CACT;aAEA,oBAAC,eAAD,EAAA,UAQI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAW,aAAa,CAAC;IACzB,MAAM;GAAU,CAAA,EACT,CAAA;EAEd,CAAA;EAEL,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;EAAU,CAAA;CAE1B,EAAA,CAAA;AAEV"}
@@ -20,15 +20,19 @@ function RelationFieldBinding(props) {
20
20
  const capabilities = collection ? getDataSourceCapabilities(collection.engine) : void 0;
21
21
  if (!collection || !capabilities?.supportsRelations) throw Error("RelationFieldBinding expected a collection whose engine supports relations");
22
22
  const relation = resolveRelationProperty(property, collection, propertyKey);
23
+ const fieldProps = relation && !relation.writable ? {
24
+ ...props,
25
+ disabled: true
26
+ } : props;
23
27
  const manyRelation = relation?.cardinality === "many";
24
28
  if ((property.admin?.widget ?? "select") === "select" && relation) return /* @__PURE__ */ jsx(RelationSelectorBinding, {
25
- ...props,
29
+ ...fieldProps,
26
30
  relation,
27
31
  manyRelation
28
32
  });
29
- if (manyRelation) return /* @__PURE__ */ jsx(MultipleRelationFieldBinding, { ...props });
33
+ if (manyRelation) return /* @__PURE__ */ jsx(MultipleRelationFieldBinding, { ...fieldProps });
30
34
  return /* @__PURE__ */ jsx(SingleRelationFieldBinding, {
31
- ...props,
35
+ ...fieldProps,
32
36
  relation
33
37
  });
34
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RelationFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/RelationFieldBinding.tsx"],"sourcesContent":["import { useSelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { RelationProperty } from \"@rebasepro/types\";\nimport { Entity, getCollectionDataPath, getDataSourceCapabilities, Relation } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport { ErrorView, IconForView, useTranslation } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { getRelationFrom, normalizeToEntityRelation, resolveRelationProperty } from \"@rebasepro/common\";\nimport { cls } from \"@rebasepro/ui\";\nimport { RelationPreview } from \"../../preview\";\nimport { RelationSelector } from \"../../components/RelationSelector\";\nimport { MultipleRelationFieldBinding } from \"./MultipleRelationFieldBinding\";\n\nexport function RelationFieldBinding(props: FieldProps<RelationProperty>) {\n const { property, propertyKey, context } = props;\n\n if (property.type !== \"relation\") {\n throw Error(\"RelationFieldBinding expected a property containing a relation\");\n }\n const collection = context.collection;\n const capabilities = collection ? getDataSourceCapabilities(collection.engine) : undefined;\n // Only two things have to hold here: there is a collection, and its engine\n // has relations at all. Whether *this* property's relation can be resolved\n // is `resolveRelationProperty`'s question, and it answers it across all\n // three forms — a pre-stamped `resolvedRelation`, an inline `relation`, or\n // a lookup by name in the collection's `relations` array — with an error\n // naming the property and the collection when it cannot.\n //\n // This used to demand the `relations` array as well, which the inline form\n // does not produce. That is the documented way to declare a relation, so\n // every collection using it threw here and rendered the error boundary\n // instead of the field.\n if (!collection || !capabilities?.supportsRelations) {\n throw Error(\"RelationFieldBinding expected a collection whose engine supports relations\");\n }\n const resolvedProperty = resolveRelationProperty(property, collection, propertyKey);\n const relation = resolvedProperty;\n\n const manyRelation = relation?.cardinality === \"many\";\n const widget = property.admin?.widget ?? \"select\";\n\n if (widget === \"select\" && relation) {\n return <RelationSelectorBinding {...props} relation={relation} manyRelation={manyRelation} />;\n }\n\n if (manyRelation) {\n return <MultipleRelationFieldBinding {...props} />;\n }\n\n return <SingleRelationFieldBinding {...props} relation={relation} />;\n}\n\nfunction RelationSelectorBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation,\n manyRelation\n}: FieldProps<RelationProperty> & { relation: Relation; manyRelation: boolean }) {\n const normalizedSingle = (!manyRelation && value && !Array.isArray(value)) ? normalizeToEntityRelation(value) : null;\n const singleValue = normalizedSingle ?? null;\n const multipleValue = (manyRelation && Array.isArray(value)) ? value : [];\n\n // Passed straight through. Mapping the form's `large` onto the selector's\n // `medium` produced a 56px box next to 48px text fields — the labels lined\n // up and the boxes did not.\n const selectorSize = size;\n\n return (\n <div className=\"\">\n {!hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>}\n\n <RelationSelector\n relation={relation}\n value={manyRelation ? multipleValue : singleValue}\n onValueChange={(newVal) => {\n if (manyRelation) {\n setValue(Array.isArray(newVal) ? newVal : []);\n } else {\n setValue(!Array.isArray(newVal) ? (newVal ?? null) : null);\n }\n }}\n disabled={disabled || isSubmitting}\n fixedFilter={property.admin?.fixedFilter}\n size={selectorSize}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </div>\n );\n}\n\nfunction SingleRelationFieldBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation\n}: FieldProps<RelationProperty> & { relation: Relation | undefined }) {\n const { t } = useTranslation();\n const normalizedValue = value && !Array.isArray(value) ? normalizeToEntityRelation(value) : null;\n const validValue = !!normalizedValue;\n\n const collection = relation?.target();\n\n if (!collection) {\n throw Error(`Couldn't find the corresponding collection for the relation: ${propertyKey}`);\n }\n\n const onSingleEntitySelected = useCallback((e: Entity<Record<string, unknown>> | null) => {\n setValue(e ? getRelationFrom(e) : null);\n }, [setValue]);\n\n const referenceDialogController = useSelectionDialog({\n multiselect: false,\n path: getCollectionDataPath(collection),\n collection,\n onSingleEntitySelected,\n selectedEntityIds: validValue && normalizedValue ? [normalizedValue.id] : undefined,\n fixedFilter: property.admin?.fixedFilter\n });\n\n const onEntryClick = (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (disabled || isSubmitting) return;\n referenceDialogController.open();\n };\n\n const usedRelation = Array.isArray(value) ? undefined : normalizedValue ?? undefined;\n\n return (\n <>\n {!hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>}\n\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <>\n\n {usedRelation && <RelationPreview\n disabled={!usedRelation}\n previewProperties={property.admin?.previewProperties}\n hover={!disabled}\n size={size}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n relation={usedRelation}\n includeEntityLink={property.admin?.includeEntityLink}\n includeId={property.admin?.includeId}\n />}\n\n {!value && <div className=\"justify-center text-left\">\n <EntityPreviewContainer className={cls(\"px-6 h-12 text-sm font-medium flex items-center gap-6\",\n disabled || isSubmitting\n ? \"text-surface-accent-500\"\n : \"cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-hover group-hover:bg-surface-hover\")}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n size={\"medium\"}>\n <IconForView collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey }).toUpperCase()}\n </EntityPreviewContainer>\n </div>}\n </>}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,OAAqC;CACtE,MAAM,EAAE,UAAU,aAAa,YAAY;CAE3C,IAAI,SAAS,SAAS,YAClB,MAAM,MAAM,gEAAgE;CAEhF,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,aAAa,0BAA0B,WAAW,MAAM,IAAI,KAAA;CAYjF,IAAI,CAAC,cAAc,CAAC,cAAc,mBAC9B,MAAM,MAAM,4EAA4E;CAG5F,MAAM,WADmB,wBAAwB,UAAU,YAAY,WACtD;CAEjB,MAAM,eAAe,UAAU,gBAAgB;CAG/C,KAFe,SAAS,OAAO,UAAU,cAE1B,YAAY,UACvB,OAAO,oBAAC,yBAAD;EAAyB,GAAI;EAAiB;EAAwB;CAAe,CAAA;CAGhG,IAAI,cACA,OAAO,oBAAC,8BAAD,EAA8B,GAAI,MAAQ,CAAA;CAGrD,OAAO,oBAAC,4BAAD;EAA4B,GAAI;EAAiB;CAAW,CAAA;AACvE;AAEA,SAAS,wBAAwB,EAC7B,aACA,OACA,MACA,OACA,WACA,UACA,cACA,UACA,oBACA,WACA,UACA,UACA,gBAC6E;CAE7E,MAAM,eADoB,CAAC,gBAAgB,SAAS,CAAC,MAAM,QAAQ,KAAK,IAAK,0BAA0B,KAAK,IAAI,SACxE;CACxC,MAAM,gBAAiB,gBAAgB,MAAM,QAAQ,KAAK,IAAK,QAAQ,CAAC;CAKxE,MAAM,eAAe;CAErB,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf;GACK,CAAC,aAAa,oBAAC,eAAD;IACE;IACb,MAAM,mBAAmB,UAAU,OAAO;IAC1C,UAAU,SAAS,YAAY;IAC/B,OAAO,SAAS,QAAQ;IACxB,WAAW;GAAg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U,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;GACxB,WAAW;EAAgE,CAAA;EAE9E,CAAC,cAAc,oBAAC,WAAD,EACZ,OAAO,yDAA0D,CAAA;EAEpE,cAAc,qBAAA,UAAA,EAAA,UAAA,CAEV,gBAAgB,oBAAC,iBAAD;GACb,UAAU,CAAC;GACX,mBAAmB,SAAS,OAAO;GACnC,OAAO,CAAC;GACF;GACN,SAAS,YAAY,eAAe,KAAA,IAAY;GAChD,UAAU;GACV,mBAAmB,SAAS,OAAO;GACnC,WAAW,SAAS,OAAO;EAC9B,CAAA,GAEA,CAAC,SAAS,oBAAC,OAAD;GAAK,WAAU;aACtB,qBAAC,wBAAD;IAAwB,WAAW,IAAI,yDACnC,YAAY,eACN,4BACA,yHAAyH;IAC/H,SAAS,YAAY,eAAe,KAAA,IAAY;IAChD,MAAM;cALV,CAMI,oBAAC,aAAD;KAAa,kBAAkB;KAC3B,WAAW;IAA0C,CAAA,GACxD,EAAE,aAAa,EAAE,MAAM,SAAS,QAAQ,YAAY,CAAC,CAAC,CAAC,YAAY,CAChD;;EACvB,CAAA,CACP,EAAA,CAAA;EAEF,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAC1B,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"RelationFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/RelationFieldBinding.tsx"],"sourcesContent":["import { useSelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { RelationProperty } from \"@rebasepro/types\";\nimport { Entity, getCollectionDataPath, getDataSourceCapabilities, Relation } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport { ErrorView, IconForView, useTranslation } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { getRelationFrom, normalizeToEntityRelation, resolveRelationProperty } from \"@rebasepro/common\";\nimport { cls } from \"@rebasepro/ui\";\nimport { RelationPreview } from \"../../preview\";\nimport { RelationSelector } from \"../../components/RelationSelector\";\nimport { MultipleRelationFieldBinding } from \"./MultipleRelationFieldBinding\";\n\nexport function RelationFieldBinding(props: FieldProps<RelationProperty>) {\n const { property, propertyKey, context } = props;\n\n if (property.type !== \"relation\") {\n throw Error(\"RelationFieldBinding expected a property containing a relation\");\n }\n const collection = context.collection;\n const capabilities = collection ? getDataSourceCapabilities(collection.engine) : undefined;\n // Only two things have to hold here: there is a collection, and its engine\n // has relations at all. Whether *this* property's relation can be resolved\n // is `resolveRelationProperty`'s question, and it answers it across all\n // three forms — a pre-stamped `resolvedRelation`, an inline `relation`, or\n // a lookup by name in the collection's `relations` array — with an error\n // naming the property and the collection when it cannot.\n //\n // This used to demand the `relations` array as well, which the inline form\n // does not produce. That is the documented way to declare a relation, so\n // every collection using it threw here and rendered the error boundary\n // instead of the field.\n if (!collection || !capabilities?.supportsRelations) {\n throw Error(\"RelationFieldBinding expected a collection whose engine supports relations\");\n }\n const resolvedProperty = resolveRelationProperty(property, collection, propertyKey);\n const relation = resolvedProperty;\n\n // A multi-hop `via` is read-only (`writable: false`): the server refuses a\n // write naming one (RELATION_NOT_WRITABLE), so its picker could only lead\n // to a failed save. Shown, not offered. A single-hop `via` is writable.\n const fieldProps = relation && !relation.writable ? { ...props, disabled: true } : props;\n\n const manyRelation = relation?.cardinality === \"many\";\n const widget = property.admin?.widget ?? \"select\";\n\n if (widget === \"select\" && relation) {\n return <RelationSelectorBinding {...fieldProps} relation={relation} manyRelation={manyRelation} />;\n }\n\n if (manyRelation) {\n return <MultipleRelationFieldBinding {...fieldProps} />;\n }\n\n return <SingleRelationFieldBinding {...fieldProps} relation={relation} />;\n}\n\nfunction RelationSelectorBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation,\n manyRelation\n}: FieldProps<RelationProperty> & { relation: Relation; manyRelation: boolean }) {\n const normalizedSingle = (!manyRelation && value && !Array.isArray(value)) ? normalizeToEntityRelation(value) : null;\n const singleValue = normalizedSingle ?? null;\n const multipleValue = (manyRelation && Array.isArray(value)) ? value : [];\n\n // Passed straight through. Mapping the form's `large` onto the selector's\n // `medium` produced a 56px box next to 48px text fields — the labels lined\n // up and the boxes did not.\n const selectorSize = size;\n\n return (\n <div className=\"\">\n {!hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>}\n\n <RelationSelector\n relation={relation}\n value={manyRelation ? multipleValue : singleValue}\n onValueChange={(newVal) => {\n if (manyRelation) {\n setValue(Array.isArray(newVal) ? newVal : []);\n } else {\n setValue(!Array.isArray(newVal) ? (newVal ?? null) : null);\n }\n }}\n disabled={disabled || isSubmitting}\n fixedFilter={property.admin?.fixedFilter}\n size={selectorSize}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </div>\n );\n}\n\nfunction SingleRelationFieldBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation\n}: FieldProps<RelationProperty> & { relation: Relation | undefined }) {\n const { t } = useTranslation();\n const normalizedValue = value && !Array.isArray(value) ? normalizeToEntityRelation(value) : null;\n const validValue = !!normalizedValue;\n\n const collection = relation?.target();\n\n if (!collection) {\n throw Error(`Couldn't find the corresponding collection for the relation: ${propertyKey}`);\n }\n\n const onSingleEntitySelected = useCallback((e: Entity<Record<string, unknown>> | null) => {\n setValue(e ? getRelationFrom(e) : null);\n }, [setValue]);\n\n const referenceDialogController = useSelectionDialog({\n multiselect: false,\n path: getCollectionDataPath(collection),\n collection,\n onSingleEntitySelected,\n selectedEntityIds: validValue && normalizedValue ? [normalizedValue.id] : undefined,\n fixedFilter: property.admin?.fixedFilter\n });\n\n const onEntryClick = (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (disabled || isSubmitting) return;\n referenceDialogController.open();\n };\n\n const usedRelation = Array.isArray(value) ? undefined : normalizedValue ?? undefined;\n\n return (\n <>\n {!hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>}\n\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <>\n\n {usedRelation && <RelationPreview\n disabled={!usedRelation}\n previewProperties={property.admin?.previewProperties}\n hover={!disabled}\n size={size}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n relation={usedRelation}\n includeEntityLink={property.admin?.includeEntityLink}\n includeId={property.admin?.includeId}\n />}\n\n {!value && <div className=\"justify-center text-left\">\n <EntityPreviewContainer className={cls(\"px-6 h-12 text-sm font-medium flex items-center gap-6\",\n disabled || isSubmitting\n ? \"text-surface-accent-500\"\n : \"cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-hover group-hover:bg-surface-hover\")}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n size={\"medium\"}>\n <IconForView collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey }).toUpperCase()}\n </EntityPreviewContainer>\n </div>}\n </>}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,OAAqC;CACtE,MAAM,EAAE,UAAU,aAAa,YAAY;CAE3C,IAAI,SAAS,SAAS,YAClB,MAAM,MAAM,gEAAgE;CAEhF,M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;GACnC,OAAO,CAAC;GACF;GACN,SAAS,YAAY,eAAe,KAAA,IAAY;GAChD,UAAU;GACV,mBAAmB,SAAS,OAAO;GACnC,WAAW,SAAS,OAAO;EAC9B,CAAA,GAEA,CAAC,SAAS,oBAAC,OAAD;GAAK,WAAU;aACtB,qBAAC,wBAAD;IAAwB,WAAW,IAAI,yDACnC,YAAY,eACN,4BACA,yHAAyH;IAC/H,SAAS,YAAY,eAAe,KAAA,IAAY;IAChD,MAAM;cALV,CAMI,oBAAC,aAAD;KAAa,kBAAkB;KAC3B,WAAW;IAA0C,CAAA,GACxD,EAAE,aAAa,EAAE,MAAM,SAAS,QAAQ,YAAY,CAAC,CAAC,CAAC,YAAY,CAChD;;EACvB,CAAA,CACP,EAAA,CAAA;EAEF,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAC1B,EAAA,CAAA;AAEV"}
@@ -2,9 +2,9 @@ import { getIconForProperty } from "../../util/property_utils.js";
2
2
  import { EnumValuesChip } from "../../preview/components/EnumValuesChip.js";
3
3
  import { FieldHelperText } from "../components/FieldHelperText.js";
4
4
  import { LabelWithIcon } from "../components/LabelWithIcon.js";
5
- import { useCallback } from "react";
5
+ import { useCallback, useId } from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { IconButton, Select, SelectItem, XIcon, cls } from "@rebasepro/ui";
7
+ import { IconButton, InputLabel, Select, SelectItem, XIcon, cls } from "@rebasepro/ui";
8
8
  import { resolveEnumValues } from "@rebasepro/common";
9
9
  import { useTranslation } from "@rebasepro/app";
10
10
  //#region src/form/field_bindings/SelectFieldBinding.tsx
@@ -24,48 +24,69 @@ function SelectFieldBinding({ propertyKey, value, setValue, error, showError, di
24
24
  e.preventDefault();
25
25
  setValue(null);
26
26
  }, [setValue]);
27
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Select, {
28
- value: value !== void 0 && value != null ? value.toString() : "",
29
- "aria-label": property.name ?? propertyKey,
30
- disabled,
31
- size,
32
- fullWidth: true,
33
- position: "item-aligned",
34
- inputClassName: cls("w-full"),
35
- label: hideLabel ? void 0 : /* @__PURE__ */ jsx(LabelWithIcon, {
36
- icon: getIconForProperty(property, "small"),
37
- required: property.validation?.required,
38
- title: property.name ?? propertyKey,
39
- propertyKey,
40
- className: "h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0"
41
- }),
42
- endAdornment: property.admin?.clearable && !disabled && /* @__PURE__ */ jsx(IconButton, {
43
- "aria-label": t("clear"),
44
- size: "small",
45
- onClick: handleClearClick,
46
- children: /* @__PURE__ */ jsx(XIcon, {})
47
- }),
48
- onValueChange: (updatedValue) => {
49
- return setValue(updatedValue ? property.type === "number" ? parseFloat(updatedValue) : updatedValue : null);
50
- },
51
- renderValue: (enumKey) => {
52
- return /* @__PURE__ */ jsx(EnumValuesChip, {
53
- enumKey,
54
- enumValues,
55
- size
56
- });
57
- },
58
- children: enumValues && enumValues.map((option) => {
59
- return /* @__PURE__ */ jsx(SelectItem, {
60
- value: String(option.id),
61
- textValue: option.label,
62
- children: /* @__PURE__ */ jsx(EnumValuesChip, {
63
- enumKey: String(option.id),
27
+ const triggerId = useId();
28
+ const hasValue = value !== void 0 && value !== null && value !== "";
29
+ const label = hideLabel ? void 0 : /* @__PURE__ */ jsx(LabelWithIcon, {
30
+ icon: getIconForProperty(property, "small"),
31
+ required: property.validation?.required,
32
+ title: property.name ?? propertyKey
33
+ });
34
+ const labelInside = Boolean(label) && size === "large";
35
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
36
+ className: "relative",
37
+ children: [/* @__PURE__ */ jsx(Select, {
38
+ id: triggerId,
39
+ value: value !== void 0 && value != null ? value.toString() : "",
40
+ "aria-label": property.name ?? propertyKey,
41
+ disabled,
42
+ size,
43
+ fullWidth: true,
44
+ position: "item-aligned",
45
+ inputClassName: cls("w-full", labelInside && "min-h-[64px] pl-3"),
46
+ label: label && !labelInside ? /* @__PURE__ */ jsx(LabelWithIcon, {
47
+ icon: getIconForProperty(property, "small"),
48
+ required: property.validation?.required,
49
+ title: property.name ?? propertyKey,
50
+ propertyKey,
51
+ className: "h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0"
52
+ }) : void 0,
53
+ endAdornment: property.admin?.clearable && !disabled && /* @__PURE__ */ jsx(IconButton, {
54
+ "aria-label": t("clear"),
55
+ size: "small",
56
+ onClick: handleClearClick,
57
+ children: /* @__PURE__ */ jsx(XIcon, {})
58
+ }),
59
+ onValueChange: (updatedValue) => {
60
+ return setValue(updatedValue ? property.type === "number" ? parseFloat(updatedValue) : updatedValue : null);
61
+ },
62
+ renderValue: (enumKey) => {
63
+ const chip = /* @__PURE__ */ jsx(EnumValuesChip, {
64
+ enumKey,
64
65
  enumValues,
65
66
  size
66
- })
67
- }, option.id);
68
- })
67
+ });
68
+ return labelInside ? /* @__PURE__ */ jsx("div", {
69
+ className: "pt-6",
70
+ children: chip
71
+ }) : chip;
72
+ },
73
+ children: enumValues && enumValues.map((option) => {
74
+ return /* @__PURE__ */ jsx(SelectItem, {
75
+ value: String(option.id),
76
+ textValue: option.label,
77
+ children: /* @__PURE__ */ jsx(EnumValuesChip, {
78
+ enumKey: String(option.id),
79
+ enumValues,
80
+ size
81
+ })
82
+ }, option.id);
83
+ })
84
+ }), labelInside && /* @__PURE__ */ jsx(InputLabel, {
85
+ htmlFor: triggerId,
86
+ shrink: hasValue,
87
+ className: cls("pointer-events-none absolute top-[5px] left-px", disabled ? "text-text-disabled dark:text-text-disabled-dark" : showError && error ? "text-red-500 dark:text-red-600" : "text-text-secondary dark:text-text-secondary-dark"),
88
+ children: label
89
+ })]
69
90
  }), /* @__PURE__ */ jsx(FieldHelperText, {
70
91
  includeDescription,
71
92
  showError,
@@ -1 +1 @@
1
- {"version":3,"file":"SelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SelectFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { NumberProperty, StringProperty } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\n\n;\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EnumValuesChip } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { cls, IconButton, Select, SelectItem, XIcon } from \"@rebasepro/ui\";\nimport { resolveEnumValues } from \"@rebasepro/common\";\n\n/**\n * If `enumValues` are set in the string config, this field renders a select\n * where each option is a colored chip.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function SelectFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: FieldProps<StringProperty | NumberProperty>) {\n const { t } = useTranslation();\n\n const enumValues = resolveEnumValues(property.enum ?? []);\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }, [setValue]);\n\n return (\n <>\n\n <Select\n value={value !== undefined && value != null ? value.toString() : \"\"}\n // The visible label is an element (icon + tooltip), which the\n // control cannot read a name from, so it announced itself as\n // \"Select an option\" — the same name for every enum field in\n // every form. Named here, where the property is.\n aria-label={property.name ?? propertyKey}\n disabled={disabled}\n size={size}\n fullWidth={true}\n position=\"item-aligned\"\n inputClassName={cls(\"w-full\")}\n label={hideLabel ? undefined : (\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n propertyKey={propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0\"}\n />)}\n endAdornment={\n property.admin?.clearable && !disabled && <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n }\n onValueChange={(updatedValue: string) => {\n const newValue = updatedValue\n ? (property.type === \"number\" ? parseFloat(updatedValue) : updatedValue)\n : null;\n return setValue(newValue);\n }}\n renderValue={(enumKey: string) => {\n return <EnumValuesChip\n enumKey={enumKey}\n enumValues={enumValues}\n size={size}/>;\n }}\n >\n {enumValues && enumValues.map((option) => {\n return <SelectItem\n key={option.id}\n value={String(option.id)}\n textValue={option.label}>\n <EnumValuesChip\n enumKey={String(option.id)}\n enumValues={enumValues}\n size={size}/>\n </SelectItem>\n })}\n </Select>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,OACA,WACA,UACA,WACA,SACA,UACA,oBACA,WACA,OAAO,WACqC;CAC5C,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,aAAa,kBAAkB,SAAS,QAAQ,CAAC,CAAC;CAExD,MAAM,mBAAmB,aAAa,MAAwB;EAC1D,EAAE,gBAAgB;EAClB,EAAE,eAAe;EACjB,SAAS,IAAI;CACjB,GAAG,CAAC,QAAQ,CAAC;CAEb,OACI,qBAAA,UAAA,EAAA,UAAA,CAEI,oBAAC,QAAD;EACI,OAAO,UAAU,KAAA,KAAa,SAAS,OAAO,MAAM,SAAS,IAAI;EAKjE,cAAY,SAAS,QAAQ;EACnB;EACJ;EACN,WAAW;EACX,UAAS;EACT,gBAAgB,IAAI,QAAQ;EAC5B,OAAO,YAAY,KAAA,IACf,oBAAC,eAAD;GACI,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;GACX;GACb,WAAW;EACd,CAAA;EACL,cACI,SAAS,OAAO,aAAa,CAAC,YAAY,oBAAC,YAAD;GAAY,cAAY,EAAE,OAAO;GACvE,MAAK;GACL,SAAS;aACT,oBAAC,OAAD,CAAO,CAAA;EACC,CAAA;EAEhB,gBAAgB,iBAAyB;GAIrC,OAAO,SAHU,eACV,SAAS,SAAS,WAAW,WAAW,YAAY,IAAI,eACzD,IACkB;EAC5B;EACA,cAAc,YAAoB;GAC9B,OAAO,oBAAC,gBAAD;IACM;IACG;IACN;GAAM,CAAA;EACpB;YAEC,cAAc,WAAW,KAAK,WAAW;GACtC,OAAO,oBAAC,YAAD;IAEH,OAAO,OAAO,OAAO,EAAE;IACvB,WAAW,OAAO;cAClB,oBAAC,gBAAD;KACI,SAAS,OAAO,OAAO,EAAE;KACb;KACN;IAAM,CAAA;GACR,GAPH,OAAO,EAOJ;EAChB,CAAC;CACG,CAAA,GAER,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;EACA;CAAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"SelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SelectFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { NumberProperty, StringProperty } from \"@rebasepro/types\";\nimport React, { useCallback, useId } from \"react\";\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EnumValuesChip } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { cls, IconButton, InputLabel, Select, SelectItem, XIcon } from \"@rebasepro/ui\";\nimport { resolveEnumValues } from \"@rebasepro/common\";\n\n/**\n * If `enumValues` are set in the string config, this field renders a select\n * where each option is a colored chip.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function SelectFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: FieldProps<StringProperty | NumberProperty>) {\n const { t } = useTranslation();\n\n const enumValues = resolveEnumValues(property.enum ?? []);\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }, [setValue]);\n\n const triggerId = useId();\n const hasValue = value !== undefined && value !== null && value !== \"\";\n\n // `undefined` rather than an empty element, as in the text field: the box\n // only makes room for a label when there is one to draw.\n const label = hideLabel\n ? undefined\n : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>;\n // Inside the box at the form's size; a smaller select has no room for a\n // label in its top edge, and keeps it above as the kit draws it.\n const labelInside = Boolean(label) && size === \"large\";\n\n return (\n <>\n {/* The label goes INSIDE the box, as a text field's does: the kit's\n own floating label, shrunk into the top edge once there is a\n value and resting in the middle while there is none. `Select`\n can only put a label above its box, so it is laid over the box\n here — `top-[5px] left-px` is where a TextField's label lands,\n 1px in from its border — and the value is pushed down under it.\n Same 64px as a text field, so two of them paired on a row line\n up. */}\n <div className={\"relative\"}>\n <Select\n id={triggerId}\n value={value !== undefined && value != null ? value.toString() : \"\"}\n // The visible label is an element (icon + tooltip), which the\n // control cannot read a name from, so it announced itself as\n // \"Select an option\" — the same name for every enum field in\n // every form. Named here, where the property is.\n aria-label={property.name ?? propertyKey}\n disabled={disabled}\n size={size}\n fullWidth={true}\n position=\"item-aligned\"\n inputClassName={cls(\"w-full\", labelInside && \"min-h-[64px] pl-3\")}\n label={label && !labelInside\n ? <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n propertyKey={propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0\"}/>\n : undefined}\n endAdornment={\n property.admin?.clearable && !disabled && <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n }\n onValueChange={(updatedValue: string) => {\n const newValue = updatedValue\n ? (property.type === \"number\" ? parseFloat(updatedValue) : updatedValue)\n : null;\n return setValue(newValue);\n }}\n renderValue={(enumKey: string) => {\n const chip = <EnumValuesChip\n enumKey={enumKey}\n enumValues={enumValues}\n size={size}/>;\n // Pushed down under the label inside the value slot,\n // not by padding the trigger: the chip lands on the line\n // a text field's value sits on beside it, and the\n // chevron stays centred in the box, where a text\n // field's buttons are.\n return labelInside ? <div className={\"pt-6\"}>{chip}</div> : chip;\n }}\n >\n {enumValues && enumValues.map((option) => {\n return <SelectItem\n key={option.id}\n value={String(option.id)}\n textValue={option.label}>\n <EnumValuesChip\n enumKey={String(option.id)}\n enumValues={enumValues}\n size={size}/>\n </SelectItem>\n })}\n </Select>\n {labelInside && (\n <InputLabel htmlFor={triggerId}\n shrink={hasValue}\n className={cls(\n \"pointer-events-none absolute top-[5px] left-px\",\n disabled\n ? \"text-text-disabled dark:text-text-disabled-dark\"\n : showError && error\n ? \"text-red-500 dark:text-red-600\"\n : \"text-text-secondary dark:text-text-secondary-dark\"\n )}>\n {label}\n </InputLabel>\n )}\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,OACA,WACA,UACA,WACA,SACA,UACA,oBACA,WACA,OAAO,WACqC;CAC5C,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,aAAa,kBAAkB,SAAS,QAAQ,CAAC,CAAC;CAExD,MAAM,mBAAmB,aAAa,MAAwB;EAC1D,EAAE,gBAAgB;EAClB,EAAE,eAAe;EACjB,SAAS,IAAI;CACjB,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,YAAY,MAAM;CACxB,MAAM,WAAW,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU;CAIpE,MAAM,QAAQ,YACR,KAAA,IACA,oBAAC,eAAD;EACE,MAAM,mBAAmB,UAAU,OAAO;EAC1C,UAAU,SAAS,YAAY;EAC/B,OAAO,SAAS,QAAQ;CAAa,CAAA;CAG7C,MAAM,cAAc,QAAQ,KAAK,KAA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AAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
@@ -26,7 +26,8 @@ var SwitchFieldBinding = function SwitchFieldBinding({ propertyKey, value, setVa
26
26
  "aria-label": hideLabel ? property.name ?? propertyKey : void 0,
27
27
  disabled,
28
28
  autoFocus,
29
- size
29
+ size,
30
+ className: !hideLabel && size === "large" ? "min-h-[66px]" : void 0
30
31
  }), /* @__PURE__ */ jsx(FieldHelperText, {
31
32
  includeDescription,
32
33
  showError,
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SwitchFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { BooleanProperty } from \"@rebasepro/types\";\nimport React from \"react\";\n\n;\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { BooleanSwitchWithLabel } from \"@rebasepro/ui\";\n\n/**\n * Simple boolean switch biding to a boolean property.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport const SwitchFieldBinding = function SwitchFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n autoFocus,\n disabled,\n size = \"large\",\n property,\n includeDescription,\n hideLabel\n }: FieldProps<BooleanProperty>) {\n\n return (\n <>\n\n <BooleanSwitchWithLabel\n value={value as boolean | null}\n onValueChange={(v) => setValue(v)}\n error={showError}\n // The control is `justify-between`, so with the label lifted\n // out the switch would drift to the far edge of an otherwise\n // empty box. Anchor it to the start instead.\n position={hideLabel ? \"start\" : undefined}\n label={hideLabel ? undefined : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>}\n // The entity form sets `hideLabel` for every field FieldBlock\n // labels, and FieldBlock's label is not tied to the control —\n // so the switch names itself, as the date field does.\n aria-label={hideLabel ? (property.name ?? propertyKey) : undefined}\n disabled={disabled}\n autoFocus={autoFocus}\n size={size}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAa,qBAAqB,SAAS,mBAAmB,EACI,aACA,OACA,UACA,OACA,WACA,WACA,UACA,OAAO,SACP,UACA,oBACA,aAC4B;CAE1F,OACI,qBAAA,UAAA,EAAA,UAAA,CAEI,oBAAC,wBAAD;EACW;EACP,gBAAgB,MAAM,SAAS,CAAC;EAChC,OAAO;EAIP,UAAU,YAAY,UAAU,KAAA;EAChC,OAAO,YAAY,KAAA,IAAY,oBAAC,eAAD;GAC3B,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;EAAa,CAAA;EAIzC,cAAY,YAAa,SAAS,QAAQ,cAAe,KAAA;EAC/C;EACC;EACL;CACT,CAAA,GAED,oBAAC,iBAAD;EAAqC;EACT;EACJ;EACG;EACA;CAAU,CAAA,CACvC,EAAA,CAAA;AAGV"}
1
+ {"version":3,"file":"SwitchFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SwitchFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { BooleanProperty } from \"@rebasepro/types\";\nimport React from \"react\";\n\n;\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { BooleanSwitchWithLabel } from \"@rebasepro/ui\";\n\n/**\n * Simple boolean switch biding to a boolean property.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport const SwitchFieldBinding = function SwitchFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n autoFocus,\n disabled,\n size = \"large\",\n property,\n includeDescription,\n hideLabel\n }: FieldProps<BooleanProperty>) {\n\n return (\n <>\n\n <BooleanSwitchWithLabel\n value={value as boolean | null}\n onValueChange={(v) => setValue(v)}\n error={showError}\n // The control is `justify-between`, so with the label lifted\n // out the switch would drift to the far edge of an otherwise\n // empty box. Anchor it to the start instead.\n position={hideLabel ? \"start\" : undefined}\n label={hideLabel ? undefined : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>}\n // The entity form sets `hideLabel` for every field FieldBlock\n // labels, and FieldBlock's label is not tied to the control —\n // so the switch names itself, as the date field does.\n aria-label={hideLabel ? (property.name ?? propertyKey) : undefined}\n disabled={disabled}\n autoFocus={autoFocus}\n size={size}\n // With its label inside, a switch stands as tall as a text\n // field whose label is inside: 64px plus the field's 1px\n // (transparent) border top and bottom. Pairing puts switches\n // side by side, and the rail stacks them under selects.\n className={!hideLabel && size === \"large\" ? \"min-h-[66px]\" : undefined}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAa,qBAAqB,SAAS,mBAAmB,EACI,aACA,OACA,UACA,OACA,WACA,WACA,UACA,OAAO,SACP,UACA,oBACA,aAC4B;CAE1F,OACI,qBAAA,UAAA,EAAA,UAAA,CAEI,oBAAC,wBAAD;EACW;EACP,gBAAgB,MAAM,SAAS,CAAC;EAChC,OAAO;EAIP,UAAU,YAAY,UAAU,KAAA;EAChC,OAAO,YAAY,KAAA,IAAY,oBAAC,eAAD;GAC3B,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;EAAa,CAAA;EAIzC,cAAY,YAAa,SAAS,QAAQ,cAAe,KAAA;EAC/C;EACC;EACL;EAKN,WAAW,CAAC,aAAa,SAAS,UAAU,iBAAiB,KAAA;CAChE,CAAA,GAED,oBAAC,iBAAD;EAAqC;EACT;EACJ;EACG;EACA;CAAU,CAAA,CACvC,EAAA,CAAA;AAGV"}
@@ -4,7 +4,7 @@ import { FieldHelperText } from "../components/FieldHelperText.js";
4
4
  import { LabelWithIcon } from "../components/LabelWithIcon.js";
5
5
  import { useCallback } from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { Collapse, IconButton, TextField, TextareaAutosize, XIcon, cls, fieldBackgroundHoverMixin, fieldBackgroundMixin } from "@rebasepro/ui";
7
+ import { Collapse, IconButton, InputLabel, TextField, TextareaAutosize, XIcon, cls, fieldBackgroundHoverMixin, fieldBackgroundMixin } from "@rebasepro/ui";
8
8
  import { useTranslation } from "@rebasepro/app";
9
9
  //#region src/form/field_bindings/TextFieldBinding.tsx
10
10
  /**
@@ -47,13 +47,15 @@ function TextFieldBinding({ propertyKey, value, setValue, error, showError, disa
47
47
  required: property.validation?.required || property.isId === true,
48
48
  title: property.name ?? propertyKey
49
49
  });
50
+ const valueText = label && size === "large" ? "text-base" : void 0;
50
51
  const accessibleName = property.name ?? propertyKey;
51
52
  return /* @__PURE__ */ jsxs(Fragment, { children: [
52
53
  isMultiline ? /* @__PURE__ */ jsxs("div", {
53
- className: cls("rounded-md relative max-w-full min-h-[64px]", fieldBackgroundMixin, fieldBackgroundHoverMixin, showError && error ? "border border-red-500 dark:border-red-600" : ""),
54
+ className: cls("rounded-lg relative max-w-full min-h-[64px]", fieldBackgroundMixin, fieldBackgroundHoverMixin, showError && error ? "border border-red-500 dark:border-red-600" : ""),
54
55
  children: [
55
- label && /* @__PURE__ */ jsx("div", {
56
- className: "pointer-events-none absolute top-1 text-xs font-medium px-3 text-text-secondary dark:text-text-secondary-dark",
56
+ label && /* @__PURE__ */ jsx(InputLabel, {
57
+ shrink: true,
58
+ className: cls("pointer-events-none absolute top-1", showError && error ? "text-red-500 dark:text-red-600" : "text-text-secondary dark:text-text-secondary-dark"),
57
59
  children: label
58
60
  }),
59
61
  /* @__PURE__ */ jsx(TextareaAutosize, {
@@ -62,7 +64,7 @@ function TextFieldBinding({ propertyKey, value, setValue, error, showError, disa
62
64
  autoFocus,
63
65
  disabled,
64
66
  "aria-label": accessibleName,
65
- className: cls("rounded-md resize-none w-full outline-none text-sm bg-transparent min-h-[64px] px-3", label ? "pt-8 pb-2" : "py-2", disabled && "outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500", showError && error ? "text-red-500 dark:text-red-600" : "")
67
+ className: cls("rounded-md resize-none w-full outline-none text-sm bg-transparent min-h-[64px] px-3", valueText, label ? "pt-8 pb-2" : "py-2", disabled && "outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500", showError && error ? "text-red-500 dark:text-red-600" : "")
66
68
  }),
67
69
  property.admin?.clearable && /* @__PURE__ */ jsx("div", {
68
70
  className: "flex flex-row justify-center items-center absolute h-full right-0 top-0 mr-4",
@@ -88,7 +90,7 @@ function TextFieldBinding({ propertyKey, value, setValue, error, showError, disa
88
90
  children: /* @__PURE__ */ jsx(XIcon, {})
89
91
  }),
90
92
  error: showError ? !!error : void 0,
91
- inputClassName: error ? "text-red-500 dark:text-red-600" : ""
93
+ inputClassName: cls(valueText, error && "text-red-500 dark:text-red-600")
92
94
  }),
93
95
  /* @__PURE__ */ jsx(FieldHelperText, {
94
96
  includeDescription,