@rebasepro/cms 0.25.0 → 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 (125) hide show
  1. package/dist/collection_editor/liveSchemaClient.d.ts +3 -3
  2. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
  4. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
  6. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +61 -50
  7. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  8. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +22 -22
  9. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  10. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +14 -14
  11. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -1
  12. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +24 -24
  13. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -1
  14. package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
  15. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  16. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
  17. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  18. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
  19. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  20. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
  21. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
  22. package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
  23. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  24. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
  25. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  26. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
  27. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
  28. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
  29. package/dist/components/CollectionsScopeContext.d.ts +5 -1
  30. package/dist/components/CollectionsScopeContext.js +10 -2
  31. package/dist/components/CollectionsScopeContext.js.map +1 -1
  32. package/dist/components/DefaultAppBar.js +2 -1
  33. package/dist/components/DefaultAppBar.js.map +1 -1
  34. package/dist/components/DefaultDrawer.js +16 -4
  35. package/dist/components/DefaultDrawer.js.map +1 -1
  36. package/dist/components/DefaultMissingReference.d.ts +8 -0
  37. package/dist/components/DefaultMissingReference.js +13 -0
  38. package/dist/components/DefaultMissingReference.js.map +1 -0
  39. package/dist/components/DeleteEntityDialog.js +9 -9
  40. package/dist/components/DeleteEntityDialog.js.map +1 -1
  41. package/dist/components/EntityFormPanel.d.ts +7 -2
  42. package/dist/components/EntityFormPanel.js +72 -29
  43. package/dist/components/EntityFormPanel.js.map +1 -1
  44. package/dist/components/HomePage/ContentHomePage.js +4 -3
  45. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  46. package/dist/components/HomePage/HomePageDnD.js +3 -1
  47. package/dist/components/HomePage/HomePageDnD.js.map +1 -1
  48. package/dist/components/HomePage/SmallNavigationCard.js +25 -0
  49. package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
  50. package/dist/components/RebaseAuthGate.js +3 -2
  51. package/dist/components/RebaseAuthGate.js.map +1 -1
  52. package/dist/components/RebaseLayout.d.ts +4 -1
  53. package/dist/components/RebaseLayout.js +7 -1
  54. package/dist/components/RebaseLayout.js.map +1 -1
  55. package/dist/components/RebaseShell.d.ts +4 -1
  56. package/dist/components/RebaseShell.js.map +1 -1
  57. package/dist/components/ReferenceTable/SelectionTableBinding.js +4 -3
  58. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  59. package/dist/components/RelationSelector.js +2 -2
  60. package/dist/components/RelationSelector.js.map +1 -1
  61. package/dist/components/SideDialogs.js +10 -4
  62. package/dist/components/SideDialogs.js.map +1 -1
  63. package/dist/components/app/Scaffold.js +5 -1
  64. package/dist/components/app/Scaffold.js.map +1 -1
  65. package/dist/components/field_configs.js +1 -1
  66. package/dist/components/history/EntityHistoryView.js +6 -4
  67. package/dist/components/history/EntityHistoryView.js.map +1 -1
  68. package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
  69. package/dist/data_export/export/export.d.ts +2 -13
  70. package/dist/data_export/export/export.js +1 -36
  71. package/dist/data_export/export/export.js.map +1 -1
  72. package/dist/form/EntityForm.d.ts +1 -1
  73. package/dist/form/EntityForm.js +17 -13
  74. package/dist/form/EntityForm.js.map +1 -1
  75. package/dist/form/EntityFormBinding.d.ts +1 -1
  76. package/dist/form/EntityFormBinding.js +42 -4
  77. package/dist/form/EntityFormBinding.js.map +1 -1
  78. package/dist/form/PropertyFieldBinding.js +1 -1
  79. package/dist/form/components/FieldBlock.d.ts +8 -1
  80. package/dist/form/components/FieldBlock.js +16 -2
  81. package/dist/form/components/FieldBlock.js.map +1 -1
  82. package/dist/form/components/FormSections.js +1 -1
  83. package/dist/form/components/FormSections.js.map +1 -1
  84. package/dist/form/components/LabelWithIcon.js +5 -2
  85. package/dist/form/components/LabelWithIcon.js.map +1 -1
  86. package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
  87. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  88. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
  89. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  90. package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
  91. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  92. package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
  93. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  94. package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
  95. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  96. package/dist/form/field_bindings/TextFieldBinding.js +8 -6
  97. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  98. package/dist/form/form_utils.d.ts +18 -1
  99. package/dist/form/form_utils.js +38 -2
  100. package/dist/form/form_utils.js.map +1 -1
  101. package/dist/form/index.d.ts +1 -1
  102. package/dist/form/label_placement.d.ts +23 -0
  103. package/dist/form/label_placement.js +71 -0
  104. package/dist/form/label_placement.js.map +1 -0
  105. package/dist/form/resolve_form_properties.d.ts +35 -3
  106. package/dist/form/resolve_form_properties.js +67 -6
  107. package/dist/form/resolve_form_properties.js.map +1 -1
  108. package/dist/hooks/useHistory.d.ts +5 -0
  109. package/dist/hooks/useHistory.js +22 -6
  110. package/dist/hooks/useHistory.js.map +1 -1
  111. package/dist/index.d.ts +50 -0
  112. package/dist/index.js +34 -7
  113. package/dist/preview/components/ReferencePreview.js +1 -1
  114. package/dist/preview/components/ReferencePreview.js.map +1 -1
  115. package/dist/preview/components/RelationPreview.js +1 -1
  116. package/dist/preview/components/RelationPreview.js.map +1 -1
  117. package/dist/types/components/EntityFormProps.d.ts +11 -0
  118. package/package.json +11 -10
  119. package/recipes/README.md +131 -0
  120. package/recipes/bulk-set-status.tsx +62 -0
  121. package/recipes/calendar-view.tsx +123 -0
  122. package/recipes/custom-login.tsx +60 -0
  123. package/recipes/my-preferences.tsx +68 -0
  124. package/recipes/orders-dashboard.tsx +125 -0
  125. package/recipes/site-settings.tsx +63 -0
@@ -1 +1 @@
1
- {"version":3,"file":"StringPropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/StringPropertyField.tsx"],"sourcesContent":["import { FieldCaption } from \"../../../_cms_internals\";\nimport React from \"react\";\nimport { StringPropertyValidation } from \"./validation/StringPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\nimport { getIn, useFormex } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\n;\nimport { Select, SelectItem, TextField } from \"@rebasepro/ui\";\n\nexport function StringPropertyField({\n widgetId,\n disabled,\n showErrors\n}: {\n widgetId: \"text_field\" | \"multiline\" | \"email\" | \"user_select\";\n disabled: boolean;\n showErrors: boolean;\n}) {\n\n const { values, setFieldValue, touched, errors } = useFormex();\n const { t } = useTranslation();\n\n const columnTypePath = \"columnType\";\n const columnTypeValue: string | undefined = getIn(values, columnTypePath) as string | undefined;\n const columnTypeError: string | undefined = (getIn(touched, columnTypePath) && getIn(errors, columnTypePath)) as string | undefined;\n\n const isIdPath = \"isId\";\n const isIdValue: string | boolean | undefined = getIn(values, isIdPath) as string | boolean | undefined;\n const isIdError: string | undefined = (getIn(touched, isIdPath) && getIn(errors, isIdPath)) as string | undefined;\n\n return (\n <>\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n\n {widgetId === \"text_field\" &&\n <StringPropertyValidation disabled={disabled}\n length={true}\n lowercase={true}\n matches={true}\n max={true}\n min={true}\n trim={true}\n uppercase={true}\n showErrors={showErrors}/>}\n {widgetId === \"user_select\" &&\n <StringPropertyValidation disabled={disabled}\n showErrors={showErrors}/>}\n\n {widgetId === \"multiline\" &&\n <StringPropertyValidation disabled={disabled}\n length={true}\n lowercase={true}\n max={true}\n min={true}\n trim={true}\n uppercase={true}\n showErrors={showErrors}/>}\n\n {widgetId === \"email\" &&\n <StringPropertyValidation disabled={disabled}\n max={true}\n min={true}\n trim={true}\n showErrors={showErrors}/>}\n\n </ValidationPanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={columnTypePath}\n disabled={disabled || Boolean(isIdValue)}\n fullWidth={true}\n value={isIdValue === \"uuid\" ? \"uuid\" : (columnTypeValue ?? \"_default_\")}\n onValueChange={(v) => setFieldValue(columnTypePath, v === \"_default_\" ? undefined : v)}\n renderValue={(v) => {\n if (isIdValue === \"uuid\") return \"uuid (forced by Primary Key)\";\n switch (v) {\n case \"text\": return \"text (unlimited)\";\n case \"char\": return \"char (fixed length)\";\n case \"varchar\": return \"varchar (variable length)\";\n // No `columnType` is a TEXT column: what the schema\n // planner creates for a string that names none.\n case \"_default_\": return \"Default (text)\";\n default: return \"Default (text)\";\n }\n }}\n error={Boolean(columnTypeError)}\n label={t(\"db_column_type\")}>\n {isIdValue === \"uuid\" && <SelectItem value={\"uuid\"}> uuid (forced by Primary Key) </SelectItem>}\n <SelectItem value={\"_default_\"}> Default (text) </SelectItem>\n <SelectItem value={\"varchar\"}> varchar (variable length) </SelectItem>\n <SelectItem value={\"text\"}> text (unlimited) </SelectItem>\n <SelectItem value={\"char\"}> char (fixed length) </SelectItem>\n </Select>\n <FieldCaption error={Boolean(columnTypeError)}>\n {columnTypeError ?? \"Optional database override for this string field.\"}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={isIdPath}\n disabled={disabled}\n fullWidth={true}\n value={isIdValue === true ? \"true\" : (isIdValue === false ? \"false\" : (isIdValue ?? \"_default_\"))}\n onValueChange={(v) => {\n if (v === \"_default_\" || v === \"false\") setFieldValue(isIdPath, undefined);\n else if (v === \"true\") setFieldValue(isIdPath, true);\n else setFieldValue(isIdPath, v);\n }}\n renderValue={(v) => {\n switch (v) {\n case \"true\": return \"Yes (Auto-generated UUID/String)\";\n case \"manual\": return \"Yes (Manual input)\";\n case \"uuid\": return \"Yes (UUID)\";\n case \"cuid\": return \"Yes (CUID)\";\n case \"false\":\n case \"_default_\": return \"No\";\n default: return `Yes (${v})`;\n }\n }}\n error={Boolean(isIdError)}\n label={t(\"primary_key_unique_id\")}>\n <SelectItem value={\"_default_\"}> No </SelectItem>\n <SelectItem value={\"manual\"}> Yes (Manual input) </SelectItem>\n <SelectItem value={\"true\"}> Yes (Auto-generated UUID/String) </SelectItem>\n <SelectItem value={\"uuid\"}> Yes (UUID) </SelectItem>\n <SelectItem value={\"cuid\"}> Yes (CUID) </SelectItem>\n </Select>\n <FieldCaption error={Boolean(isIdError)}>\n {isIdError ?? \"Set as Primary Key and configure ID generation strategy.\"}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n\n <TextField name={\"defaultValue\"}\n disabled={disabled}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setFieldValue(\"defaultValue\", e.target.value === \"\" ? undefined : e.target.value);\n }}\n label={t(\"default_value\")}\n value={(getIn(values, \"defaultValue\") as string | undefined) ?? \"\"}/>\n\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,oBAAoB,EAChC,UACA,UACA,cAKD;CAEC,MAAM,EAAE,QAAQ,eAAe,SAAS,WAAW,UAAU;CAC7D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,iBAAiB;CACvB,MAAM,kBAAsC,MAAM,QAAQ,cAAc;CACxE,MAAM,kBAAuC,MAAM,SAAS,cAAc,KAAK,MAAM,QAAQ,cAAc;CAE3G,MAAM,WAAW;CACjB,MAAM,YAA0C,MAAM,QAAQ,QAAQ;CACtE,MAAM,YAAiC,MAAM,SAAS,QAAQ,KAAK,MAAM,QAAQ,QAAQ;CAEzF,OACI,qBAAA,UAAA,EAAA,UAAA;EACI,oBAAC,OAAD;GAAK,WAAW;aAEZ,qBAAC,iBAAD,EAAA,UAAA;IAEK,aAAa,gBACV,oBAAC,0BAAD;KAAoC;KAChC,QAAQ;KACR,WAAW;KACX,SAAS;KACT,KAAK;KACL,KAAK;KACL,MAAM;KACN,WAAW;KACC;IAAY,CAAA;IAC/B,aAAa,iBACV,oBAAC,0BAAD;KAAoC;KACpB;IAAY,CAAA;IAE/B,aAAa,eACV,oBAAC,0BAAD;KAAoC;KAChC,QAAQ;KACR,WAAW;KACX,KAAK;KACL,KAAK;KACL,MAAM;KACN,WAAW;KACC;IAAY,CAAA;IAE/B,aAAa,WACV,oBAAC,0BAAD;KAAoC;KAChC,KAAK;KACL,KAAK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K,QAAQ,OAAO;MACpB,KAAK,UAAU,OAAO;MACtB,KAAK,QAAQ,OAAO;MACpB,KAAK,QAAQ,OAAO;MACpB,KAAK;MACL,KAAK,aAAa,OAAO;MACzB,SAAS,OAAO,QAAQ,EAAE;KAC9B;IACJ;IACA,OAAO,QAAQ,SAAS;IACxB,OAAO,EAAE,uBAAuB;cArBpC;KAsBI,oBAAC,YAAD;MAAY,OAAO;gBAAa;KAAgB,CAAA;KAChD,oBAAC,YAAD;MAAY,OAAO;gBAAU;KAAgC,CAAA;KAC7D,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAA8C,CAAA;KACzE,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAAwB,CAAA;KACnD,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAAwB,CAAA;IAC/C;OACR,oBAAC,cAAD;IAAc,OAAO,QAAQ,SAAS;cACjC,aAAa;GACJ,CAAA,CACb;;EAEL,oBAAC,OAAD;GAAK,WAAW;aAEZ,oBAAC,WAAD;IAAW,MAAM;IACH;IACV,WAAW,MAAiE;KACxE,cAAc,gBAAgB,EAAE,OAAO,UAAU,KAAK,KAAA,IAAY,EAAE,OAAO,KAAK;IACpF;IACA,OAAO,EAAE,eAAe;IACxB,OAAQ,MAAM,QAAQ,cAAc,KAA4B;GAAI,CAAA;EAEvE,CAAA;CACP,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"StringPropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/StringPropertyField.tsx"],"sourcesContent":["import { FieldCaption } from \"../../../_cms_internals\";\nimport React from \"react\";\nimport { StringPropertyValidation } from \"./validation/StringPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\nimport { getIn, useFormex } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\n;\nimport { Select, SelectItem, TextField } from \"@rebasepro/ui\";\n\nexport function StringPropertyField({\n widgetId,\n disabled,\n showErrors\n}: {\n widgetId: \"text_field\" | \"multiline\" | \"email\" | \"user_select\";\n disabled: boolean;\n showErrors: boolean;\n}) {\n\n const { values, setFieldValue, touched, errors } = useFormex();\n const { t } = useTranslation();\n\n const columnTypePath = \"columnType\";\n const columnTypeValue: string | undefined = getIn(values, columnTypePath) as string | undefined;\n const columnTypeError: string | undefined = (getIn(touched, columnTypePath) && getIn(errors, columnTypePath)) as string | undefined;\n\n const isIdPath = \"isId\";\n const isIdValue: string | boolean | undefined = getIn(values, isIdPath) as string | boolean | undefined;\n const isIdError: string | undefined = (getIn(touched, isIdPath) && getIn(errors, isIdPath)) as string | undefined;\n\n return (\n <>\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n\n {widgetId === \"text_field\" &&\n <StringPropertyValidation disabled={disabled}\n length={true}\n lowercase={true}\n matches={true}\n max={true}\n min={true}\n trim={true}\n uppercase={true}\n showErrors={showErrors}/>}\n {widgetId === \"user_select\" &&\n <StringPropertyValidation disabled={disabled}\n showErrors={showErrors}/>}\n\n {widgetId === \"multiline\" &&\n <StringPropertyValidation disabled={disabled}\n length={true}\n lowercase={true}\n max={true}\n min={true}\n trim={true}\n uppercase={true}\n showErrors={showErrors}/>}\n\n {widgetId === \"email\" &&\n <StringPropertyValidation disabled={disabled}\n max={true}\n min={true}\n trim={true}\n showErrors={showErrors}/>}\n\n </ValidationPanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={columnTypePath}\n disabled={disabled || Boolean(isIdValue)}\n fullWidth={true}\n value={isIdValue === \"uuid\" ? \"uuid\" : (columnTypeValue ?? \"_default_\")}\n onValueChange={(v) => setFieldValue(columnTypePath, v === \"_default_\" ? undefined : v)}\n renderValue={(v) => {\n if (isIdValue === \"uuid\") return t(\"column_type_uuid_forced\");\n switch (v) {\n case \"text\": return t(\"column_type_text\");\n case \"char\": return t(\"column_type_char\");\n case \"varchar\": return t(\"column_type_varchar\");\n // No `columnType` is a TEXT column: what the schema\n // planner creates for a string that names none.\n case \"_default_\": return t(\"column_type_default\", { type: \"text\" });\n default: return t(\"column_type_default\", { type: \"text\" });\n }\n }}\n error={Boolean(columnTypeError)}\n label={t(\"db_column_type\")}>\n {isIdValue === \"uuid\" && <SelectItem value={\"uuid\"}>{t(\"column_type_uuid_forced\")}</SelectItem>}\n <SelectItem value={\"_default_\"}>{t(\"column_type_default\", { type: \"text\" })}</SelectItem>\n <SelectItem value={\"varchar\"}>{t(\"column_type_varchar\")}</SelectItem>\n <SelectItem value={\"text\"}>{t(\"column_type_text\")}</SelectItem>\n <SelectItem value={\"char\"}>{t(\"column_type_char\")}</SelectItem>\n </Select>\n <FieldCaption error={Boolean(columnTypeError)}>\n {columnTypeError ?? t(\"column_type_caption_string\")}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={isIdPath}\n disabled={disabled}\n fullWidth={true}\n value={isIdValue === true ? \"true\" : (isIdValue === false ? \"false\" : (isIdValue ?? \"_default_\"))}\n onValueChange={(v) => {\n if (v === \"_default_\" || v === \"false\") setFieldValue(isIdPath, undefined);\n else if (v === \"true\") setFieldValue(isIdPath, true);\n else setFieldValue(isIdPath, v);\n }}\n renderValue={(v) => {\n switch (v) {\n case \"true\": return t(\"primary_key_generated_string\");\n case \"manual\": return t(\"primary_key_manual\");\n case \"uuid\": return t(\"primary_key_strategy\", { strategy: \"UUID\" });\n case \"cuid\": return t(\"primary_key_strategy\", { strategy: \"CUID\" });\n case \"false\":\n case \"_default_\": return t(\"no\");\n default: return t(\"primary_key_strategy\", { strategy: v });\n }\n }}\n error={Boolean(isIdError)}\n label={t(\"primary_key_unique_id\")}>\n <SelectItem value={\"_default_\"}>{t(\"no\")}</SelectItem>\n <SelectItem value={\"manual\"}>{t(\"primary_key_manual\")}</SelectItem>\n <SelectItem value={\"true\"}>{t(\"primary_key_generated_string\")}</SelectItem>\n <SelectItem value={\"uuid\"}>{t(\"primary_key_strategy\", { strategy: \"UUID\" })}</SelectItem>\n <SelectItem value={\"cuid\"}>{t(\"primary_key_strategy\", { strategy: \"CUID\" })}</SelectItem>\n </Select>\n <FieldCaption error={Boolean(isIdError)}>\n {isIdError ?? t(\"primary_key_caption\")}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n\n <TextField name={\"defaultValue\"}\n disabled={disabled}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setFieldValue(\"defaultValue\", e.target.value === \"\" ? undefined : e.target.value);\n }}\n label={t(\"default_value\")}\n value={(getIn(values, \"defaultValue\") as string | undefined) ?? \"\"}/>\n\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,oBAAoB,EAChC,UACA,UACA,cAKD;CAEC,MAAM,EAAE,QAAQ,eAAe,SAAS,WAAW,UAAU;CAC7D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,iBAAiB;CACvB,MAAM,kBAAsC,MAAM,QAAQ,cAAc;CACxE,MAAM,kBAAuC,MAAM,SAAS,cAAc,KAAK,MAAM,QAAQ,cAAc;CAE3G,MAAM,WAAW;CACjB,MAAM,YAA0C,MAAM,QAAQ,QAAQ;CACtE,MAAM,YAAiC,MAAM,SAAS,QAAQ,KAAK,MAAM,QAAQ,QAAQ;CAEzF,OACI,qBAAA,UAAA,EAAA,UAAA;EACI,oBAAC,OAAD;GAAK,WAAW;aAEZ,qBAAC,iBAAD,EAAA,UAAA;IAEK,aAAa,gBACV,oBAAC,0BAAD;KAAoC;KAChC,QAAQ;KACR,WAAW;KACX,SAAS;KACT,KAAK;KACL,KAAK;KACL,MAAM;KACN,WAAW;KACC;IAAY,CAAA;IAC/B,aAAa,iBACV,oBAAC,0BAAD;KAAoC;KACpB;IAAY,CAAA;IAE/B,aAAa,eACV,oBAAC,0BAAD;KAAoC;KAChC,QAAQ;KACR,WAAW;KACX,KAAK;KACL,KAAK;KACL,MAAM;KACN,WAAW;KACC;IAAY,CAAA;IAE/B,aAAa,WACV,oBAAC,0BAAD;KAAoC;KAChC,KAAK;KACL,KAAK;KACL,MAAM;KAC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F;IACA,OAAO,EAAE,eAAe;IACxB,OAAQ,MAAM,QAAQ,cAAc,KAA4B;GAAI,CAAA;EAEvE,CAAA;CACP,EAAA,CAAA;AAEV"}
@@ -168,7 +168,9 @@ function useLiveSchemaEditing(options) {
168
168
  setApplyError(err instanceof Error ? err.message : String(err));
169
169
  });
170
170
  }, [client, pending]);
171
- const sourceOnlyOffered = Boolean(plan && !plan.applicable && plan.changes.filter((change) => change.verdict !== "safe").every((change) => change.sourceOnly));
171
+ const provisioningOff = status?.applyRefusedCode === "SCHEMA_EDITING_PROVISIONING_OFF";
172
+ const commitAsSourceOnly = Boolean(provisioningOff && plan?.applicable);
173
+ const sourceOnlyOffered = commitAsSourceOnly || Boolean(plan && !plan.applicable && plan.changes.filter((change) => change.verdict !== "safe").every((change) => change.sourceOnly));
172
174
  const onClose = useCallback(() => {
173
175
  if (applying) return;
174
176
  const settle = pending;
@@ -198,6 +200,7 @@ function useLiveSchemaEditing(options) {
198
200
  onConfirm,
199
201
  onRetry: planError ? onRetry : void 0,
200
202
  onSourceOnly: sourceOnlyOffered ? onSourceOnly : void 0,
203
+ sourceOnlyIsTheCommit: commitAsSourceOnly,
201
204
  onClose,
202
205
  applyRefusedBecause: status && !status.canApply ? status.applyRefusedBecause : void 0,
203
206
  target: status && {
@@ -1 +1 @@
1
- {"version":3,"file":"useLiveSchemaEditing.js","names":[],"sources":["../../src/collection_editor/useLiveSchemaEditing.tsx"],"sourcesContent":["/**\n * The plan-then-confirm flow, as a hook.\n *\n * Owns three things that belong together and nothing else: whether the backend\n * can edit its schema, the plan for the change somebody is making, and the\n * dialog they confirm it in. The config controller calls `reviewChange` and\n * awaits it; everything about *how* the confirmation happens stays here.\n *\n * ## Why `reviewChange` returns a promise that can reject\n *\n * Because the editor needs to know. A save that was cancelled must not leave\n * the form thinking it succeeded — the collection on screen would then differ\n * from the one on disk, and the next save would be computed from the wrong\n * `before`. Rejecting with {@link SchemaChangeCancelled} is how \"the person\n * said no\" reaches the caller as an outcome rather than as silence.\n */\nimport React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { lazyChunk } from \"@rebasepro/ui\";\n\nimport {\n createLiveSchemaClient,\n LiveSchemaError,\n SchemaChangeCancelled,\n type LiveSchemaClient,\n type LiveSchemaPlan,\n type LiveSchemaResult,\n type LiveSchemaStatus,\n type ProposedCollectionChange\n} from \"./liveSchemaClient\";\n\n// Re-exported so the hook stays the one import a caller needs.\nexport { SchemaChangeCancelled, isSchemaChangeCancelled } from \"./liveSchemaClient\";\n\n/**\n * Loaded when a change is actually being reviewed, not before.\n *\n * This hook is reached from the collections config controller, which is\n * constructed on every admin boot — so a static import would put the dialog and\n * the `@rebasepro/ui` surface it draws on into the **eager** bundle: everything\n * a browser downloads before the login screen paints. It cost 14 kB there, for\n * a dialog most sessions never open. The bundle budget caught it.\n */\nconst SchemaChangeDialog = lazyChunk(() =>\n import(\"./ui/collection_editor/SchemaChangeDialog\")\n .then(m => ({ default: m.SchemaChangeDialog }))\n);\n\nexport interface UseLiveSchemaEditingOptions {\n /** Base for the routes, e.g. `https://api.example.com/api/admin/schema`. */\n baseUrl: string;\n getAuthToken?: () => Promise<string | null> | string | null;\n /**\n * Identity of the signed-in user.\n *\n * Only used to re-ask: whether this backend will accept a schema change\n * depends on who is asking, and the answer to an anonymous probe does not\n * survive a sign-in.\n */\n authKey?: string | null;\n /**\n * Whether to ask the backend at all. `false` when the caller cannot be told\n * anything (`/status` needs `schema:read`) or the editor is read-only: the\n * answer is then \"not available\" without a request that could only be\n * refused. Defaults to `true`.\n */\n enabled?: boolean;\n /** Swappable for the tests, which have no server. */\n client?: LiveSchemaClient;\n}\n\n/** The answer when nobody asked. */\nconst NOT_ASKED: LiveSchemaStatus = { enabled: false, canPlan: false, canApply: false };\n\ninterface PendingChange {\n change: ProposedCollectionChange;\n resolve: () => void;\n reject: (err: Error) => void;\n}\n\nexport interface LiveSchemaEditing {\n /** `undefined` until the backend has answered. For rendering. */\n status?: LiveSchemaStatus;\n /**\n * The same answer, for deciding.\n *\n * `status` is undefined for one round trip after mount, and a caller that\n * read it to choose a code path would take the \"not available\" branch for\n * that window — so a save issued quickly after a page load would silently\n * skip the confirmation and write source only, while the same save a second\n * later would not. Timing-dependent behaviour with no visible difference is\n * the worst shape this could have.\n *\n * Resolves once, cached; never rejects, because every way of failing to get\n * an answer means the same thing to whoever is deciding.\n */\n ready: () => Promise<LiveSchemaStatus>;\n /**\n * Plan the change, show it, and settle when the person has decided.\n *\n * Resolves once the change has been applied — or written source-only, if\n * they chose that. Rejects with {@link SchemaChangeCancelled} if they\n * closed the dialog, and with the underlying error if planning or applying\n * failed in a way they did not choose.\n */\n reviewChange: (change: ProposedCollectionChange) => Promise<void>;\n /** Render this once, high enough that a dialog over the editor is not clipped. */\n dialog: React.ReactNode;\n}\n\nexport function useLiveSchemaEditing(options: UseLiveSchemaEditingOptions): LiveSchemaEditing {\n const { baseUrl, authKey } = options;\n const asking = options.enabled !== false;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const client = useMemo(\n () => options.client ?? createLiveSchemaClient({\n baseUrl,\n getAuthToken: () => optionsRef.current.getAuthToken?.() ?? null\n }),\n // `client` is either supplied once by a test or built from the URL. The\n // token getter is read through the ref so a new closure on every render\n // does not rebuild the client underneath an in-flight request.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [baseUrl, options.client]\n );\n\n const [status, setStatus] = useState<LiveSchemaStatus | undefined>();\n const [pending, setPending] = useState<PendingChange | undefined>();\n const [plan, setPlan] = useState<LiveSchemaPlan | undefined>();\n const [planError, setPlanError] = useState<string | undefined>();\n const [result, setResult] = useState<LiveSchemaResult | undefined>();\n const [applying, setApplying] = useState(false);\n const [applyError, setApplyError] = useState<string | undefined>();\n\n // The in-flight probe, so `ready()` can await the same one the effect\n // started rather than issuing a second. Keyed by client+authKey the same way\n // the effect is: a sign-in changes the answer, so it has to be re-asked.\n // `undefined` passed explicitly: React 19's `useRef` takes no zero-argument\n // overload, and omitting it is an error rather than a default.\n const probe = useRef<{ key: unknown[]; promise: Promise<LiveSchemaStatus> } | undefined>(undefined);\n\n /** Which review a plan response belongs to. See `reviewChange`. */\n const reviewToken = useRef(0);\n\n const ready = useCallback((): Promise<LiveSchemaStatus> => {\n if (!asking) return Promise.resolve(NOT_ASKED);\n const key = [client, authKey];\n const current = probe.current;\n if (!current || current.key[0] !== key[0] || current.key[1] !== key[1]) {\n probe.current = { key, promise: client.status() };\n }\n return probe.current!.promise;\n }, [client, authKey, asking]);\n\n useEffect(() => {\n let cancelled = false;\n void ready().then(answer => {\n if (!cancelled) setStatus(answer);\n });\n return () => { cancelled = true; };\n }, [ready]);\n\n /**\n * Ask what the change would do, and ignore an answer that arrives late.\n *\n * Separate from `reviewChange` so it can be issued *again* without starting\n * a new review: a plan that failed on a dropped connection should cost a\n * click, not the whole wizard — the person has already filled in the form,\n * and making them do it twice for a transient failure is the kind of thing\n * that teaches people to distrust the preview.\n */\n const requestPlan = useCallback(async (change: ProposedCollectionChange) => {\n // Identifies the review a response belongs to. A plan that arrives after\n // its review was replaced must not be shown: the dialog would describe\n // the *previous* change while the reader believes it describes this one.\n const token = ++reviewToken.current;\n try {\n const answer = await client.plan(change);\n if (token === reviewToken.current) setPlan(answer);\n } catch (err: unknown) {\n if (token !== reviewToken.current) return;\n setPlanError(\n err instanceof LiveSchemaError || err instanceof Error\n ? err.message\n : String(err)\n );\n }\n }, [client]);\n\n const onRetry = useCallback(() => {\n if (!pending) return;\n setPlanError(undefined);\n setPlan(undefined);\n void requestPlan(pending.change);\n }, [pending, requestPlan]);\n\n const clear = useCallback(() => {\n setPending(undefined);\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n }, []);\n\n const reviewChange = useCallback((change: ProposedCollectionChange) => {\n return new Promise<void>((resolve, reject) => {\n // A second review while one is open — a double-clicked save —\n // replaces the pending one, and the one it replaces has to be\n // settled. `setPending` used to overwrite `resolve`/`reject` with\n // nobody left holding them, so the first caller's promise never\n // settled at all and the editor's save simply never returned.\n setPending(previous => {\n previous?.reject(new SchemaChangeCancelled());\n return { change, resolve, reject };\n });\n\n // Identifies the review a response belongs to. A plan that arrives\n // after its review was replaced must not be shown: the dialog would\n // describe the *previous* change while the reader believes it\n // describes this one, and the SQL on screen would be for something\n // they are not confirming.\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n\n void requestPlan(change);\n });\n // `client` is not listed: this no longer touches it directly, and\n // `requestPlan` already carries that dependency.\n }, [requestPlan]);\n\n const onConfirm = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n void client.apply(pending.change).then(\n answer => {\n setResult(answer);\n setApplying(false);\n // Resolved here, not on close. The change has happened, and the\n // dialog is now a receipt somebody may read for as long as they\n // like — holding the caller open until they close it would\n // leave the editor mid-save for no reason.\n pending.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n /**\n * \"Edit source only\": commit the collection, run nothing.\n *\n * Through the same door as an apply, so it is committed. It used to be a\n * write through the source-only editor that nobody committed, which every\n * later \"Commit and apply\" met as somebody else's work — 409, with the\n * dialog never saying why.\n */\n const onSourceOnly = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n const settle = pending;\n void client.apply({ ...settle.change, sourceOnly: true }).then(\n answer => {\n setResult(answer);\n setApplying(false);\n settle.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n // Offered only when every refused change says what it would leave behind.\n // One that does not may not be written to the source alone.\n const sourceOnlyOffered = Boolean(plan && !plan.applicable &&\n plan.changes.filter(change => change.verdict !== \"safe\").every(change => change.sourceOnly));\n\n const onClose = useCallback(() => {\n // Escape and the backdrop reach this too, and the Cancel *button* is the\n // only one of the three that was disabled while applying. Closing\n // mid-apply rejected the caller as cancelled while the commit and the\n // DDL carried on — reporting that nothing happened while something did,\n // which is the exact failure this whole feature exists to end.\n if (applying) return;\n\n const settle = pending;\n clear();\n // A dialog showing a result has already resolved; closing it is not a\n // cancellation of anything.\n if (settle && !result) settle.reject(new SchemaChangeCancelled());\n }, [applying, pending, result, clear]);\n\n // Not even a Suspense boundary until there is something to review — the\n // chunk is fetched by the first `reviewChange`, and an admin session that\n // never edits a collection never pays for it.\n const open = Boolean(pending) || Boolean(result);\n const dialog = open\n ? (\n <Suspense fallback={null}>\n <SchemaChangeDialog\n open={open}\n collectionId={pending?.change.collectionId ?? \"\"}\n plan={plan}\n planError={planError}\n result={result}\n applying={applying}\n applyError={applyError}\n onConfirm={onConfirm}\n onRetry={planError ? onRetry : undefined}\n onSourceOnly={sourceOnlyOffered ? onSourceOnly : undefined}\n onClose={onClose}\n applyRefusedBecause={\n status && !status.canApply ? status.applyRefusedBecause : undefined\n }\n target={status && {\n repository: status.repository,\n branch: status.branch\n }}\n />\n </Suspense>\n )\n : null;\n\n return { status, ready, reviewChange, dialog };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,qBAAqB,gBACvB,OAAO,+CAA4C,CAC9C,MAAK,OAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,CACtD;;AA0BA,IAAM,YAA8B;CAAE,SAAS;CAAO,SAAS;CAAO,UAAU;AAAM;AAsCtF,SAAgB,qBAAqB,SAAyD;CAC1F,MAAM,EAAE,SAAS,YAAY;CAC7B,MAAM,SAAS,QAAQ,YAAY;CAEnC,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,MAAM,SAAS,cACL,QAAQ,UAAU,uBAAuB;EAC3C;EACA,oBAAoB,WAAW,QAAQ,eAAe,KAAK;CAC/D,CAAC,GAKD,CAAC,SAAS,QAAQ,MAAM,CAC5B;CAEA,MAAM,CAAC,QAAQ,aAAa,SAAuC;CACnE,MA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B,YAAY,KAAK;GACjB,OAAO,QAAQ;GACf,WAAW,KAAA,CAAS;EACxB,IACC,QAAiB;GACd,YAAY,KAAK;GACjB,cAAc,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;EAClE,CACJ;CACJ,GAAG,CAAC,QAAQ,OAAO,CAAC;CAIpB,MAAM,oBAAoB,QAAQ,QAAQ,CAAC,KAAK,cAC5C,KAAK,QAAQ,QAAO,WAAU,OAAO,YAAY,MAAM,CAAC,CAAC,OAAM,WAAU,OAAO,UAAU,CAAC;CAE/F,MAAM,UAAU,kBAAkB;EAM9B,IAAI,UAAU;EAEd,MAAM,SAAS;EACf,MAAM;EAGN,IAAI,UAAU,CAAC,QAAQ,OAAO,OAAO,IAAI,sBAAsB,CAAC;CACpE,GAAG;EAAC;EAAU;EAAS;EAAQ;CAAK,CAAC;CAKrC,MAAM,OAAO,QAAQ,OAAO,KAAK,QAAQ,MAAM;CA4B/C,OAAO;EAAE;EAAQ;EAAO;EAAc,QA3BvB,OAEP,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,oBAAD;IACU;IACN,cAAc,SAAS,OAAO,gBAAgB;IACxC;IACK;IACH;IACE;IACE;IACD;IACX,SAAS,YAAY,UAAU,KAAA;IAC/B,cAAc,oBAAoB,eAAe,KAAA;IACxC;IACT,qBACI,UAAU,CAAC,OAAO,WAAW,OAAO,sBAAsB,KAAA;IAE9D,QAAQ,UAAU;KACd,YAAY,OAAO;KACnB,QAAQ,OAAO;IACnB;GACH,CAAA;EACK,CAAA,IAEZ;CAEuC;AACjD"}
1
+ {"version":3,"file":"useLiveSchemaEditing.js","names":[],"sources":["../../src/collection_editor/useLiveSchemaEditing.tsx"],"sourcesContent":["/**\n * The plan-then-confirm flow, as a hook.\n *\n * Owns three things that belong together and nothing else: whether the backend\n * can edit its schema, the plan for the change somebody is making, and the\n * dialog they confirm it in. The config controller calls `reviewChange` and\n * awaits it; everything about *how* the confirmation happens stays here.\n *\n * ## Why `reviewChange` returns a promise that can reject\n *\n * Because the editor needs to know. A save that was cancelled must not leave\n * the form thinking it succeeded — the collection on screen would then differ\n * from the one on disk, and the next save would be computed from the wrong\n * `before`. Rejecting with {@link SchemaChangeCancelled} is how \"the person\n * said no\" reaches the caller as an outcome rather than as silence.\n */\nimport React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { lazyChunk } from \"@rebasepro/ui\";\n\nimport {\n createLiveSchemaClient,\n LiveSchemaError,\n SchemaChangeCancelled,\n type LiveSchemaClient,\n type LiveSchemaPlan,\n type LiveSchemaResult,\n type LiveSchemaStatus,\n type ProposedCollectionChange\n} from \"./liveSchemaClient\";\n\n// Re-exported so the hook stays the one import a caller needs.\nexport { SchemaChangeCancelled, isSchemaChangeCancelled } from \"./liveSchemaClient\";\n\n/**\n * Loaded when a change is actually being reviewed, not before.\n *\n * This hook is reached from the collections config controller, which is\n * constructed on every admin boot — so a static import would put the dialog and\n * the `@rebasepro/ui` surface it draws on into the **eager** bundle: everything\n * a browser downloads before the login screen paints. It cost 14 kB there, for\n * a dialog most sessions never open. The bundle budget caught it.\n */\nconst SchemaChangeDialog = lazyChunk(() =>\n import(\"./ui/collection_editor/SchemaChangeDialog\")\n .then(m => ({ default: m.SchemaChangeDialog }))\n);\n\nexport interface UseLiveSchemaEditingOptions {\n /** Base for the routes, e.g. `https://api.example.com/api/admin/schema`. */\n baseUrl: string;\n getAuthToken?: () => Promise<string | null> | string | null;\n /**\n * Identity of the signed-in user.\n *\n * Only used to re-ask: whether this backend will accept a schema change\n * depends on who is asking, and the answer to an anonymous probe does not\n * survive a sign-in.\n */\n authKey?: string | null;\n /**\n * Whether to ask the backend at all. `false` when the caller cannot be told\n * anything (`/status` needs `schema:read`) or the editor is read-only: the\n * answer is then \"not available\" without a request that could only be\n * refused. Defaults to `true`.\n */\n enabled?: boolean;\n /** Swappable for the tests, which have no server. */\n client?: LiveSchemaClient;\n}\n\n/** The answer when nobody asked. */\nconst NOT_ASKED: LiveSchemaStatus = { enabled: false, canPlan: false, canApply: false };\n\ninterface PendingChange {\n change: ProposedCollectionChange;\n resolve: () => void;\n reject: (err: Error) => void;\n}\n\nexport interface LiveSchemaEditing {\n /** `undefined` until the backend has answered. For rendering. */\n status?: LiveSchemaStatus;\n /**\n * The same answer, for deciding.\n *\n * `status` is undefined for one round trip after mount, and a caller that\n * read it to choose a code path would take the \"not available\" branch for\n * that window — so a save issued quickly after a page load would silently\n * skip the confirmation and write source only, while the same save a second\n * later would not. Timing-dependent behaviour with no visible difference is\n * the worst shape this could have.\n *\n * Resolves once, cached; never rejects, because every way of failing to get\n * an answer means the same thing to whoever is deciding.\n */\n ready: () => Promise<LiveSchemaStatus>;\n /**\n * Plan the change, show it, and settle when the person has decided.\n *\n * Resolves once the change has been applied — or written source-only, if\n * they chose that. Rejects with {@link SchemaChangeCancelled} if they\n * closed the dialog, and with the underlying error if planning or applying\n * failed in a way they did not choose.\n */\n reviewChange: (change: ProposedCollectionChange) => Promise<void>;\n /** Render this once, high enough that a dialog over the editor is not clipped. */\n dialog: React.ReactNode;\n}\n\nexport function useLiveSchemaEditing(options: UseLiveSchemaEditingOptions): LiveSchemaEditing {\n const { baseUrl, authKey } = options;\n const asking = options.enabled !== false;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const client = useMemo(\n () => options.client ?? createLiveSchemaClient({\n baseUrl,\n getAuthToken: () => optionsRef.current.getAuthToken?.() ?? null\n }),\n // `client` is either supplied once by a test or built from the URL. The\n // token getter is read through the ref so a new closure on every render\n // does not rebuild the client underneath an in-flight request.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [baseUrl, options.client]\n );\n\n const [status, setStatus] = useState<LiveSchemaStatus | undefined>();\n const [pending, setPending] = useState<PendingChange | undefined>();\n const [plan, setPlan] = useState<LiveSchemaPlan | undefined>();\n const [planError, setPlanError] = useState<string | undefined>();\n const [result, setResult] = useState<LiveSchemaResult | undefined>();\n const [applying, setApplying] = useState(false);\n const [applyError, setApplyError] = useState<string | undefined>();\n\n // The in-flight probe, so `ready()` can await the same one the effect\n // started rather than issuing a second. Keyed by client+authKey the same way\n // the effect is: a sign-in changes the answer, so it has to be re-asked.\n // `undefined` passed explicitly: React 19's `useRef` takes no zero-argument\n // overload, and omitting it is an error rather than a default.\n const probe = useRef<{ key: unknown[]; promise: Promise<LiveSchemaStatus> } | undefined>(undefined);\n\n /** Which review a plan response belongs to. See `reviewChange`. */\n const reviewToken = useRef(0);\n\n const ready = useCallback((): Promise<LiveSchemaStatus> => {\n if (!asking) return Promise.resolve(NOT_ASKED);\n const key = [client, authKey];\n const current = probe.current;\n if (!current || current.key[0] !== key[0] || current.key[1] !== key[1]) {\n probe.current = { key, promise: client.status() };\n }\n return probe.current!.promise;\n }, [client, authKey, asking]);\n\n useEffect(() => {\n let cancelled = false;\n void ready().then(answer => {\n if (!cancelled) setStatus(answer);\n });\n return () => { cancelled = true; };\n }, [ready]);\n\n /**\n * Ask what the change would do, and ignore an answer that arrives late.\n *\n * Separate from `reviewChange` so it can be issued *again* without starting\n * a new review: a plan that failed on a dropped connection should cost a\n * click, not the whole wizard — the person has already filled in the form,\n * and making them do it twice for a transient failure is the kind of thing\n * that teaches people to distrust the preview.\n */\n const requestPlan = useCallback(async (change: ProposedCollectionChange) => {\n // Identifies the review a response belongs to. A plan that arrives after\n // its review was replaced must not be shown: the dialog would describe\n // the *previous* change while the reader believes it describes this one.\n const token = ++reviewToken.current;\n try {\n const answer = await client.plan(change);\n if (token === reviewToken.current) setPlan(answer);\n } catch (err: unknown) {\n if (token !== reviewToken.current) return;\n setPlanError(\n err instanceof LiveSchemaError || err instanceof Error\n ? err.message\n : String(err)\n );\n }\n }, [client]);\n\n const onRetry = useCallback(() => {\n if (!pending) return;\n setPlanError(undefined);\n setPlan(undefined);\n void requestPlan(pending.change);\n }, [pending, requestPlan]);\n\n const clear = useCallback(() => {\n setPending(undefined);\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n }, []);\n\n const reviewChange = useCallback((change: ProposedCollectionChange) => {\n return new Promise<void>((resolve, reject) => {\n // A second review while one is open — a double-clicked save —\n // replaces the pending one, and the one it replaces has to be\n // settled. `setPending` used to overwrite `resolve`/`reject` with\n // nobody left holding them, so the first caller's promise never\n // settled at all and the editor's save simply never returned.\n setPending(previous => {\n previous?.reject(new SchemaChangeCancelled());\n return { change, resolve, reject };\n });\n\n // Identifies the review a response belongs to. A plan that arrives\n // after its review was replaced must not be shown: the dialog would\n // describe the *previous* change while the reader believes it\n // describes this one, and the SQL on screen would be for something\n // they are not confirming.\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n\n void requestPlan(change);\n });\n // `client` is not listed: this no longer touches it directly, and\n // `requestPlan` already carries that dependency.\n }, [requestPlan]);\n\n const onConfirm = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n void client.apply(pending.change).then(\n answer => {\n setResult(answer);\n setApplying(false);\n // Resolved here, not on close. The change has happened, and the\n // dialog is now a receipt somebody may read for as long as they\n // like — holding the caller open until they close it would\n // leave the editor mid-save for no reason.\n pending.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n /**\n * \"Edit source only\": commit the collection, run nothing.\n *\n * Through the same door as an apply, so it is committed. It used to be a\n * write through the source-only editor that nobody committed, which every\n * later \"Commit and apply\" met as somebody else's work — 409, with the\n * dialog never saying why.\n */\n const onSourceOnly = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n const settle = pending;\n void client.apply({ ...settle.change, sourceOnly: true }).then(\n answer => {\n setResult(answer);\n setApplying(false);\n settle.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n // A deployment that provisions nothing applies no change from here, and\n // says to commit it as source only: for a change that could be applied,\n // that commit is the way through, and the dialog's main action.\n const provisioningOff = status?.applyRefusedCode === \"SCHEMA_EDITING_PROVISIONING_OFF\";\n const commitAsSourceOnly = Boolean(provisioningOff && plan?.applicable);\n\n // Offered only when every refused change says what it would leave behind.\n // One that does not may not be written to the source alone.\n const sourceOnlyOffered = commitAsSourceOnly || Boolean(plan && !plan.applicable &&\n plan.changes.filter(change => change.verdict !== \"safe\").every(change => change.sourceOnly));\n\n const onClose = useCallback(() => {\n // Escape and the backdrop reach this too, and the Cancel *button* is the\n // only one of the three that was disabled while applying. Closing\n // mid-apply rejected the caller as cancelled while the commit and the\n // DDL carried on — reporting that nothing happened while something did,\n // which is the exact failure this whole feature exists to end.\n if (applying) return;\n\n const settle = pending;\n clear();\n // A dialog showing a result has already resolved; closing it is not a\n // cancellation of anything.\n if (settle && !result) settle.reject(new SchemaChangeCancelled());\n }, [applying, pending, result, clear]);\n\n // Not even a Suspense boundary until there is something to review — the\n // chunk is fetched by the first `reviewChange`, and an admin session that\n // never edits a collection never pays for it.\n const open = Boolean(pending) || Boolean(result);\n const dialog = open\n ? (\n <Suspense fallback={null}>\n <SchemaChangeDialog\n open={open}\n collectionId={pending?.change.collectionId ?? \"\"}\n plan={plan}\n planError={planError}\n result={result}\n applying={applying}\n applyError={applyError}\n onConfirm={onConfirm}\n onRetry={planError ? onRetry : undefined}\n onSourceOnly={sourceOnlyOffered ? onSourceOnly : undefined}\n sourceOnlyIsTheCommit={commitAsSourceOnly}\n onClose={onClose}\n applyRefusedBecause={\n status && !status.canApply ? status.applyRefusedBecause : undefined\n }\n target={status && {\n repository: status.repository,\n branch: status.branch\n }}\n />\n </Suspense>\n )\n : null;\n\n return { status, ready, reviewChange, dialog };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,qBAAqB,gBACvB,OAAO,+CAA4C,CAC9C,MAAK,OAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,CACtD;;AA0BA,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S,YAAY,UAAU,KAAA;IAC/B,cAAc,oBAAoB,eAAe,KAAA;IACjD,uBAAuB;IACd;IACT,qBACI,UAAU,CAAC,OAAO,WAAW,OAAO,sBAAsB,KAAA;IAE9D,QAAQ,UAAU;KACd,YAAY,OAAO;KACnB,QAAQ,OAAO;IACnB;GACH,CAAA;EACK,CAAA,IAEZ;CAEuC;AACjD"}
@@ -1,4 +1,5 @@
1
1
  import { getPreviewSizeFrom } from "../../../preview/util.js";
2
+ import { DefaultMissingReference } from "../../DefaultMissingReference.js";
2
3
  import { useCollectionRegistryController } from "../../../hooks/navigation/contexts/CollectionRegistryContext.js";
3
4
  import { useReferencePaths } from "../../../hooks/useReferencePaths.js";
4
5
  import { ReferencePreview } from "../../../preview/components/ReferencePreview.js";
@@ -9,7 +10,6 @@ import { jsx } from "react/jsx-runtime";
9
10
  import { deepEqual } from "fast-equals";
10
11
  import { CollectionScopeProvider, ErrorView, useComponentOverride } from "@rebasepro/app";
11
12
  //#region src/components/CollectionTableBinding/fields/TableReferenceField.tsx
12
- var DefaultMissingReference = () => null;
13
13
  function TableReferenceFieldResolver(props) {
14
14
  const ResolvedMissingReference = useComponentOverride("Entity.MissingReference", DefaultMissingReference);
15
15
  const { path, collection } = props;
@@ -1 +1 @@
1
- {"version":3,"file":"TableReferenceField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableReferenceField.tsx"],"sourcesContent":["import { useSelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useCallback, useEffect } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ReferencePreview } from \"../../../preview\";\nimport { Entity, EntityReference, FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection } from \"@rebasepro/cms-types\";\n\nimport { getPreviewSizeFrom } from \"../../../preview/util\";\nimport { useComponentOverride, ErrorView, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../../hooks/useReferencePaths\";\nimport { CompactEntityCellField } from \"./CompactEntityCellField\";\n\ntype TableReferenceFieldProps = {\n name: string;\n disabled: boolean;\n internalValue: EntityReference | EntityReference[] | undefined | null;\n updateValue: (newValue: (EntityReference | EntityReference[] | null)) => void;\n size: CollectionSize;\n multiselect: boolean;\n previewProperties?: string[];\n path: string;\n fixedFilter?: FilterValues<string>;\n includeId?: boolean;\n includeEntityLink?: boolean;\n /** The cell is selected. */\n selected?: boolean;\n /**\n * Set by the cell's opener: opens the selection dialog, and is handed\n * back as closed at once — the dialog keeps its own state from there.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\nconst DefaultMissingReference: React.FC<{ path: string }> = () => null;\n\nfunction TableReferenceFieldResolver(props: TableReferenceFieldProps & { collection: AdminCollection | undefined }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const { path, collection } = props;\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={path}/>;\n } else {\n return <ErrorView error={`Collection not found: ${path}`}/>;\n }\n }\n return <TableReferenceFieldInternal {...props} collection={collection}/>;\n}\n\nexport function TableReferenceField(props: TableReferenceFieldProps) {\n const collectionRegistryController = useCollectionRegistryController();\n const { toCollectionPath } = useReferencePaths();\n const path = toCollectionPath(props.path);\n const collection = collectionRegistryController.getCollection(path);\n\n const content = (\n <TableReferenceFieldResolver\n {...props}\n path={path}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nexport const TableReferenceFieldInternal = React.memo(\n function TableReferenceFieldInternal(props: TableReferenceFieldProps & {\n collection: AdminCollection;\n }) {\n const {\n name,\n internalValue,\n updateValue,\n multiselect,\n path,\n size,\n previewProperties,\n disabled,\n fixedFilter,\n collection,\n includeId,\n includeEntityLink,\n selected,\n open,\n onOpenChange\n } = props;\n\n const { referenceTo } = useReferencePaths();\n\n const onSingleEntitySelected = useCallback((entity: Entity<any>) => {\n updateValue(entity ? referenceTo(entity) : null);\n }, [updateValue, referenceTo]);\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {\n updateValue(entities.map((e) => referenceTo(e)));\n }, [updateValue, referenceTo]);\n\n const selectedEntityIds = internalValue\n ? (Array.isArray(internalValue)\n ? internalValue.map((ref) => ref.id)\n : internalValue.id ? [internalValue.id] : [])\n : [];\n\n const referenceDialogController = useSelectionDialog({\n multiselect,\n path,\n collection,\n onMultipleEntitiesSelected,\n onSingleEntitySelected,\n selectedEntityIds,\n fixedFilter\n }\n );\n\n const handleOpen = () => {\n if (disabled)\n return;\n referenceDialogController.open();\n };\n\n // The cell's opener asks for the dialog. It is a request, not a state:\n // the dialog closes itself, so the request is handed straight back.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n handleOpen();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);\n\n if (!collection)\n return <ErrorView error={\"The specified collection does not exist\"}/>;\n\n // One line at every row size: the inline previews (each title opens\n // its record), the cell's opener to pick and a cross to clear. A single\n // record takes the row's preview size; a list stays lines.\n const refs: EntityReference[] = !internalValue ? [] : (Array.isArray(internalValue) ? internalValue : [internalValue]);\n return <CompactEntityCellField empty={valueNotSet}\n disabled={disabled}\n selected={selected}\n onClear={() => updateValue(multiselect ? [] : null)}>\n {refs.map((reference, index) =>\n reference && reference.isEntityReference && reference.isEntityReference()\n ? <ReferencePreview key={`compact_ref_${name}_${index}`}\n size={multiselect ? \"small\" : getPreviewSizeFrom(size)}\n reference={reference}\n hover={false}\n disabled={!path}\n previewProperties={previewProperties}\n includeId={includeId}\n includeEntityLink={includeEntityLink}/>\n : <ErrorView key={`compact_ref_${name}_${index}`} error={\"Value is not a reference\"}/>)}\n </CompactEntityCellField>;\n }, equal);\n"],"mappings":";;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,EAAE,IAAI,CAAC,IAC7C,CAAC;EASH;CACJ,CACA;CAEA,MAAM,mBAAmB;EACrB,IAAI,UACA;EACJ,0BAA0B,KAAK;CACnC;CAIA,gBAAgB;EACZ,IAAI,CAAC,MAAM;EACX,eAAe,KAAK;EACpB,WAAW;CAEf,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,cAAc,CAAC,iBAAkB,MAAM,QAAQ,aAAa,KAAK,cAAc,WAAW;CAEhG,IAAI,CAAC,YACD,OAAO,oBAAC,WAAD,EAAW,OAAO,0CAA2C,CAAA;CAMxE,OAAO,oBAAC,wBAAD;EAAwB,OAAO;EACxB;EACA;EACV,eAAe,YAAY,cAAc,CAAC,IAAI,IAAI;aAJtB,CAAC,gBAAgB,CAAC,IAAK,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa,EAAA,CAK1G,KAAK,WAAW,UAClB,aAAa,UAAU,qBAAqB,UAAU,kBAAkB,IAClE,oBAAC,kBAAD;GACE,MAAM,cAAc,UAAU,mBAAmB,IAAI;GAC1C;GACX,OAAO;GACP,UAAU,CAAC;GACQ;GACR;GACQ;EAAmB,GAPjB,eAAe,KAAK,GAAG,OAON,IACxC,oBAAC,WAAD,EAAgD,OAAO,2BAA4B,GAAnE,eAAe,KAAK,GAAG,OAA4C,CAAC;CAC1E,CAAA;AAC5B,GAAG,SAAK"}
1
+ {"version":3,"file":"TableReferenceField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableReferenceField.tsx"],"sourcesContent":["import { useSelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useCallback, useEffect } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ReferencePreview } from \"../../../preview\";\nimport { Entity, EntityReference, FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection } from \"@rebasepro/cms-types\";\n\nimport { getPreviewSizeFrom } from \"../../../preview/util\";\nimport { useComponentOverride, ErrorView, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../../hooks/useReferencePaths\";\nimport { CompactEntityCellField } from \"./CompactEntityCellField\";\nimport { DefaultMissingReference } from \"../../DefaultMissingReference\";\n\ntype TableReferenceFieldProps = {\n name: string;\n disabled: boolean;\n internalValue: EntityReference | EntityReference[] | undefined | null;\n updateValue: (newValue: (EntityReference | EntityReference[] | null)) => void;\n size: CollectionSize;\n multiselect: boolean;\n previewProperties?: string[];\n path: string;\n fixedFilter?: FilterValues<string>;\n includeId?: boolean;\n includeEntityLink?: boolean;\n /** The cell is selected. */\n selected?: boolean;\n /**\n * Set by the cell's opener: opens the selection dialog, and is handed\n * back as closed at once — the dialog keeps its own state from there.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\n\nfunction TableReferenceFieldResolver(props: TableReferenceFieldProps & { collection: AdminCollection | undefined }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const { path, collection } = props;\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={path}/>;\n } else {\n return <ErrorView error={`Collection not found: ${path}`}/>;\n }\n }\n return <TableReferenceFieldInternal {...props} collection={collection}/>;\n}\n\nexport function TableReferenceField(props: TableReferenceFieldProps) {\n const collectionRegistryController = useCollectionRegistryController();\n const { toCollectionPath } = useReferencePaths();\n const path = toCollectionPath(props.path);\n const collection = collectionRegistryController.getCollection(path);\n\n const content = (\n <TableReferenceFieldResolver\n {...props}\n path={path}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nexport const TableReferenceFieldInternal = React.memo(\n function TableReferenceFieldInternal(props: TableReferenceFieldProps & {\n collection: AdminCollection;\n }) {\n const {\n name,\n internalValue,\n updateValue,\n multiselect,\n path,\n size,\n previewProperties,\n disabled,\n fixedFilter,\n collection,\n includeId,\n includeEntityLink,\n selected,\n open,\n onOpenChange\n } = props;\n\n const { referenceTo } = useReferencePaths();\n\n const onSingleEntitySelected = useCallback((entity: Entity<any>) => {\n updateValue(entity ? referenceTo(entity) : null);\n }, [updateValue, referenceTo]);\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {\n updateValue(entities.map((e) => referenceTo(e)));\n }, [updateValue, referenceTo]);\n\n const selectedEntityIds = internalValue\n ? (Array.isArray(internalValue)\n ? internalValue.map((ref) => ref.id)\n : internalValue.id ? [internalValue.id] : [])\n : [];\n\n const referenceDialogController = useSelectionDialog({\n multiselect,\n path,\n collection,\n onMultipleEntitiesSelected,\n onSingleEntitySelected,\n selectedEntityIds,\n fixedFilter\n }\n );\n\n const handleOpen = () => {\n if (disabled)\n return;\n referenceDialogController.open();\n };\n\n // The cell's opener asks for the dialog. It is a request, not a state:\n // the dialog closes itself, so the request is handed straight back.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n handleOpen();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);\n\n if (!collection)\n return <ErrorView error={\"The specified collection does not exist\"}/>;\n\n // One line at every row size: the inline previews (each title opens\n // its record), the cell's opener to pick and a cross to clear. A single\n // record takes the row's preview size; a list stays lines.\n const refs: EntityReference[] = !internalValue ? [] : (Array.isArray(internalValue) ? internalValue : [internalValue]);\n return <CompactEntityCellField empty={valueNotSet}\n disabled={disabled}\n selected={selected}\n onClear={() => updateValue(multiselect ? [] : null)}>\n {refs.map((reference, index) =>\n reference && reference.isEntityReference && reference.isEntityReference()\n ? <ReferencePreview key={`compact_ref_${name}_${index}`}\n size={multiselect ? \"small\" : getPreviewSizeFrom(size)}\n reference={reference}\n hover={false}\n disabled={!path}\n previewProperties={previewProperties}\n includeId={includeId}\n includeEntityLink={includeEntityLink}/>\n : <ErrorView key={`compact_ref_${name}_${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AQ,IAAI,EAAE,IACjC,cAAc,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,IAC7C,CAAC;EASH;CACJ,CACA;CAEA,MAAM,mBAAmB;EACrB,IAAI,UACA;EACJ,0BAA0B,KAAK;CACnC;CAIA,gBAAgB;EACZ,IAAI,CAAC,MAAM;EACX,eAAe,KAAK;EACpB,WAAW;CAEf,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,cAAc,CAAC,iBAAkB,MAAM,QAAQ,aAAa,KAAK,cAAc,WAAW;CAEhG,IAAI,CAAC,YACD,OAAO,oBAAC,WAAD,EAAW,OAAO,0CAA2C,CAAA;CAMxE,OAAO,oBAAC,wBAAD;EAAwB,OAAO;EACxB;EACA;EACV,eAAe,YAAY,cAAc,CAAC,IAAI,IAAI;aAJtB,CAAC,gBAAgB,CAAC,IAAK,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa,EAAA,CAK1G,KAAK,WAAW,UAClB,aAAa,UAAU,qBAAqB,UAAU,kBAAkB,IAClE,oBAAC,kBAAD;GACE,MAAM,cAAc,UAAU,mBAAmB,IAAI;GAC1C;GACX,OAAO;GACP,UAAU,CAAC;GACQ;GACR;GACQ;EAAmB,GAPjB,eAAe,KAAK,GAAG,OAON,IACxC,oBAAC,WAAD,EAAgD,OAAO,2BAA4B,GAAnE,eAAe,KAAK,GAAG,OAA4C,CAAC;CAC1E,CAAA;AAC5B,GAAG,SAAK"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- interface CollectionTableToolbarProps {
2
+ export interface CollectionTableToolbarProps {
3
3
  loading: boolean;
4
4
  actionsStart?: React.ReactNode;
5
5
  actions?: React.ReactNode;
@@ -32,4 +32,3 @@ interface CollectionTableToolbarProps {
32
32
  */
33
33
  export declare function useToolbarLabels(): boolean;
34
34
  export declare function CollectionTableToolbar({ actions, actionsStart, loading, onTextSearch, title, viewModeToggle, initialSearchText, compact }: CollectionTableToolbarProps): React.JSX.Element;
35
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionTableToolbar.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/CollectionTableToolbar.tsx"],"sourcesContent":["import React, { useContext, useLayoutEffect, useRef, useState } from \"react\";\n\nimport { CircularProgress, cls, SearchBar } from \"@rebasepro/ui\";\nimport { useLargeLayout, useTranslation } from \"@rebasepro/app\";\n\ninterface CollectionTableToolbarProps {\n loading: boolean;\n actionsStart?: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * View mode toggle button, positioned left of the search bar.\n */\n viewModeToggle?: React.ReactNode;\n title?: React.ReactNode,\n onTextSearch?: (searchString?: string) => void;\n /**\n * Initial search string to pre-populate the search bar (e.g. from URL params).\n */\n initialSearchText?: string;\n /**\n * When true the toolbar is in \"compact\" mode for the split-view left panel.\n * - Search bar, loading spinner, and view-mode toggle are hidden.\n * - Secondary actions remain inline (displayed horizontally).\n * - Only `actionsStart` (filters) and the add button (last child of `actions`) remain visible.\n */\n compact?: boolean;\n}\n\nconst ToolbarLabelsContext = React.createContext(true);\n\n/**\n * Whether the toolbar this control sits in has room for its controls' labels\n * (\"Filters\", \"Add existing\", \"Add Tag\"), or wants their icon-only forms.\n *\n * Decided by the toolbar's own width, not the window's: a relation tab beside\n * the split list is a narrow toolbar in a wide window, and its labelled\n * controls overflowed the left group and were drawn over the search bar.\n * `true` outside a toolbar.\n */\nexport function useToolbarLabels(): boolean {\n return useContext(ToolbarLabelsContext);\n}\n\n/**\n * Whether `row` — the toolbar's controls at their natural width — fits in\n * `container`. Once it has not, the width the labelled controls needed is kept,\n * and the labels come back only when the container has that much room again:\n * measured on the icon-only row, they would always seem to fit.\n */\nfunction useLabelsFit(\n container: React.RefObject<HTMLDivElement | null>,\n row: React.RefObject<HTMLDivElement | null>\n): boolean {\n const [labelled, setLabelled] = useState(true);\n const labelledRef = useRef(true);\n const labelledWidth = useRef<number | undefined>(undefined);\n\n useLayoutEffect(() => {\n const containerElement = container.current;\n const rowElement = row.current;\n if (!containerElement || !rowElement || typeof ResizeObserver === \"undefined\") return undefined;\n\n const measure = () => {\n const available = containerElement.clientWidth;\n let next = labelledRef.current;\n if (labelledRef.current) {\n const needed = rowElement.scrollWidth;\n if (needed > available + 1) {\n labelledWidth.current = needed;\n next = false;\n }\n } else if (labelledWidth.current !== undefined && available >= labelledWidth.current) {\n next = true;\n }\n if (next !== labelledRef.current) {\n labelledRef.current = next;\n setLabelled(next);\n }\n };\n\n // The container for the room there is, the row for what the controls\n // take — a selection count appearing widens the row, not the toolbar.\n const observer = new ResizeObserver(measure);\n observer.observe(containerElement);\n observer.observe(rowElement);\n measure();\n return () => observer.disconnect();\n }, [container, row]);\n\n return labelled;\n}\n\nexport function CollectionTableToolbar({\n actions,\n actionsStart,\n loading,\n onTextSearch,\n title,\n viewModeToggle,\n initialSearchText,\n compact = false\n}: CollectionTableToolbarProps) {\n\n const largeLayout = useLargeLayout();\n const { t } = useTranslation();\n\n const containerRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLDivElement>(null);\n const labelled = useLabelsFit(containerRef, rowRef);\n\n // Split actions into \"primary\" (add button = last child) and \"secondary\" (everything else)\n const actionChildren = React.Children.toArray(actions);\n const addButton = actionChildren.length > 0 ? actionChildren[actionChildren.length - 1] : null;\n const secondaryActions = actionChildren.slice(0, -1);\n\n return (\n <div\n ref={containerRef}\n className={cls(\"no-scrollbar min-h-[52px] overflow-x-auto bg-surface-sheet flex w-full\")}>\n\n {/* At least as wide as the toolbar, and never narrower than its\n controls: the two groups cannot be squeezed into each other.\n When even the icon-only controls do not fit, the toolbar\n scrolls. */}\n <div\n ref={rowRef}\n className={\"px-2 md:px-4 flex flex-row justify-between items-center min-w-full w-max\"}>\n\n <ToolbarLabelsContext.Provider value={labelled}>\n\n <div className=\"flex items-center gap-1 md:mr-4 mr-2\">\n\n {/* View toggle — hidden in compact */}\n {!compact && viewModeToggle}\n\n {title && <div className={\"flex items-center\"}>\n {title}\n </div>}\n\n {actionsStart}\n\n </div>\n\n <div className=\"flex items-center gap-1\">\n\n {/* Loading spinner — hidden in compact */}\n {largeLayout && !compact && loading && (\n <div className=\"mr-4\">\n <CircularProgress size={\"smallest\"}/>\n </div>\n )}\n\n {/* Search bar — hidden in compact */}\n {!compact && onTextSearch &&\n <SearchBar\n key={\"search-bar\"}\n size={\"small\"}\n placeholder={t(\"search\")}\n onTextSearch={onTextSearch}\n expandable={true}\n initialValue={initialSearchText}/>}\n\n {/* Secondary actions — always inline */}\n <div className=\"flex items-center gap-1\">\n {secondaryActions}\n </div>\n\n {/* Add button — always visible */}\n {addButton}\n\n </div>\n\n </ToolbarLabelsContext.Provider>\n\n </div>\n\n </div>\n );\n}\n"],"mappings":";;;;;AA4BA,IAAM,uBAAuB,MAAM,cAAc,IAAI;;;;;;;;;;AAWrD,SAAgB,mBAA4B;CACxC,OAAO,WAAW,oBAAoB;AAC1C;;;;;;;AAQA,SAAS,aACL,WACA,KACO;CACP,MAAM,CAAC,UAAU,eAAe,SAAS,IAAI;CAC7C,MAAM,cAAc,OAAO,IAAI;CAC/B,MAAM,gBAAgB,OAA2B,KAAA,CAAS;CAE1D,sBAAsB;EAClB,MAAM,mBAAmB,UAAU;EACnC,MAAM,aAAa,IAAI;EACvB,IAAI,CAAC,oBAAoB,CAAC,cAAc,OAAO,mBAAmB,aAAa,OAAO,KAAA;EAEtF,MAAM,gBAAgB;GAClB,MAAM,YAAY,iBAAiB;GACnC,IAAI,OAAO,YAAY;GACvB,IAAI,YAAY,SAAS;IACrB,MAAM,SAAS,WAAW;IAC1B,IAAI,SAAS,YAAY,GAAG;KACxB,cAAc,UAAU;KACxB,OAAO;IACX;GACJ,OAAO,IAAI,cAAc,YAAY,KAAA,KAAa,aAAa,cAAc,SACzE,OAAO;GAEX,IAAI,SAAS,YAAY,SAAS;IAC9B,YAAY,UAAU;IACtB,YAAY,IAAI;GACpB;EACJ;EAIA,MAAM,WAAW,IAAI,eAAe,OAAO;EAC3C,SAAS,QAAQ,gBAAgB;EACjC,SAAS,QAAQ,UAAU;EAC3B,QAAQ;EACR,aAAa,SAAS,WAAW;CACrC,GAAG,CAAC,WAAW,GAAG,CAAC;CAEnB,OAAO;AACX;AAEA,SAAgB,uBAAuB,EACnC,SACA,cACA,SACA,cACA,OACA,gBACA,mBACA,UAAU,SACkB;CAE5B,MAAM,cAAc,eAAe;CACnC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,SAAS,OAAuB,IAAI;CAC1C,MAAM,WAAW,aAAa,cAAc,MAAM;CAGlD,MAAM,iBAAiB,MAAM,SAAS,QAAQ,OAAO;CACrD,MAAM,YAAY,eAAe,SAAS,IAAI,eAAe,eAAe,SAAS,KAAK;CAC1F,MAAM,mBAAmB,eAAe,MAAM,GAAG,EAAE;CAEnD,OACI,oBAAC,OAAD;EACI,KAAK;EACL,WAAW,IAAI,wEAAwE;YAMvF,oBAAC,OAAD;GACI,KAAK;GACL,WAAW;aAEX,qBAAC,qBAAqB,UAAtB;IAA+B,OAAO;cAAtC,CAEI,qBAAC,OAAD;KAAK,WAAU;eAAf;MAGK,CAAC,WAAW;MAEZ,SAAS,oBAAC,OAAD;OAAK,WAAW;iBACrB;MACA,CAAA;MAEJ;KAEA;QAEL,qBAAC,OAAD;KAAK,WAAU;eAAf;MAGK,eAAe,CAAC,WAAW,WACxB,oBAAC,OAAD;OAAK,WAAU;iBACX,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA;MACnC,CAAA;MAIR,CAAC,WAAW,gBACT,oBAAC,WAAD;OAEI,MAAM;OACN,aAAa,EAAE,QAAQ;OACT;OACd,YAAY;OACZ,cAAc;MAAmB,GAL5B,YAK4B;MAGzC,oBAAC,OAAD;OAAK,WAAU;iBACV;MACA,CAAA;MAGJ;KAEA;MAEsB;;EAE9B,CAAA;CAEJ,CAAA;AAEb"}
1
+ {"version":3,"file":"CollectionTableToolbar.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/CollectionTableToolbar.tsx"],"sourcesContent":["import React, { useContext, useLayoutEffect, useRef, useState } from \"react\";\n\nimport { CircularProgress, cls, SearchBar } from \"@rebasepro/ui\";\nimport { useLargeLayout, useTranslation } from \"@rebasepro/app\";\n\nexport interface CollectionTableToolbarProps {\n loading: boolean;\n actionsStart?: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * View mode toggle button, positioned left of the search bar.\n */\n viewModeToggle?: React.ReactNode;\n title?: React.ReactNode,\n onTextSearch?: (searchString?: string) => void;\n /**\n * Initial search string to pre-populate the search bar (e.g. from URL params).\n */\n initialSearchText?: string;\n /**\n * When true the toolbar is in \"compact\" mode for the split-view left panel.\n * - Search bar, loading spinner, and view-mode toggle are hidden.\n * - Secondary actions remain inline (displayed horizontally).\n * - Only `actionsStart` (filters) and the add button (last child of `actions`) remain visible.\n */\n compact?: boolean;\n}\n\nconst ToolbarLabelsContext = React.createContext(true);\n\n/**\n * Whether the toolbar this control sits in has room for its controls' labels\n * (\"Filters\", \"Add existing\", \"Add Tag\"), or wants their icon-only forms.\n *\n * Decided by the toolbar's own width, not the window's: a relation tab beside\n * the split list is a narrow toolbar in a wide window, and its labelled\n * controls overflowed the left group and were drawn over the search bar.\n * `true` outside a toolbar.\n */\nexport function useToolbarLabels(): boolean {\n return useContext(ToolbarLabelsContext);\n}\n\n/**\n * Whether `row` — the toolbar's controls at their natural width — fits in\n * `container`. Once it has not, the width the labelled controls needed is kept,\n * and the labels come back only when the container has that much room again:\n * measured on the icon-only row, they would always seem to fit.\n */\nfunction useLabelsFit(\n container: React.RefObject<HTMLDivElement | null>,\n row: React.RefObject<HTMLDivElement | null>\n): boolean {\n const [labelled, setLabelled] = useState(true);\n const labelledRef = useRef(true);\n const labelledWidth = useRef<number | undefined>(undefined);\n\n useLayoutEffect(() => {\n const containerElement = container.current;\n const rowElement = row.current;\n if (!containerElement || !rowElement || typeof ResizeObserver === \"undefined\") return undefined;\n\n const measure = () => {\n const available = containerElement.clientWidth;\n let next = labelledRef.current;\n if (labelledRef.current) {\n const needed = rowElement.scrollWidth;\n if (needed > available + 1) {\n labelledWidth.current = needed;\n next = false;\n }\n } else if (labelledWidth.current !== undefined && available >= labelledWidth.current) {\n next = true;\n }\n if (next !== labelledRef.current) {\n labelledRef.current = next;\n setLabelled(next);\n }\n };\n\n // The container for the room there is, the row for what the controls\n // take — a selection count appearing widens the row, not the toolbar.\n const observer = new ResizeObserver(measure);\n observer.observe(containerElement);\n observer.observe(rowElement);\n measure();\n return () => observer.disconnect();\n }, [container, row]);\n\n return labelled;\n}\n\nexport function CollectionTableToolbar({\n actions,\n actionsStart,\n loading,\n onTextSearch,\n title,\n viewModeToggle,\n initialSearchText,\n compact = false\n}: CollectionTableToolbarProps) {\n\n const largeLayout = useLargeLayout();\n const { t } = useTranslation();\n\n const containerRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLDivElement>(null);\n const labelled = useLabelsFit(containerRef, rowRef);\n\n // Split actions into \"primary\" (add button = last child) and \"secondary\" (everything else)\n const actionChildren = React.Children.toArray(actions);\n const addButton = actionChildren.length > 0 ? actionChildren[actionChildren.length - 1] : null;\n const secondaryActions = actionChildren.slice(0, -1);\n\n return (\n <div\n ref={containerRef}\n className={cls(\"no-scrollbar min-h-[52px] overflow-x-auto bg-surface-sheet flex w-full\")}>\n\n {/* At least as wide as the toolbar, and never narrower than its\n controls: the two groups cannot be squeezed into each other.\n When even the icon-only controls do not fit, the toolbar\n scrolls. */}\n <div\n ref={rowRef}\n className={\"px-2 md:px-4 flex flex-row justify-between items-center min-w-full w-max\"}>\n\n <ToolbarLabelsContext.Provider value={labelled}>\n\n <div className=\"flex items-center gap-1 md:mr-4 mr-2\">\n\n {/* View toggle — hidden in compact */}\n {!compact && viewModeToggle}\n\n {title && <div className={\"flex items-center\"}>\n {title}\n </div>}\n\n {actionsStart}\n\n </div>\n\n <div className=\"flex items-center gap-1\">\n\n {/* Loading spinner — hidden in compact */}\n {largeLayout && !compact && loading && (\n <div className=\"mr-4\">\n <CircularProgress size={\"smallest\"}/>\n </div>\n )}\n\n {/* Search bar — hidden in compact */}\n {!compact && onTextSearch &&\n <SearchBar\n key={\"search-bar\"}\n size={\"small\"}\n placeholder={t(\"search\")}\n onTextSearch={onTextSearch}\n expandable={true}\n initialValue={initialSearchText}/>}\n\n {/* Secondary actions — always inline */}\n <div className=\"flex items-center gap-1\">\n {secondaryActions}\n </div>\n\n {/* Add button — always visible */}\n {addButton}\n\n </div>\n\n </ToolbarLabelsContext.Provider>\n\n </div>\n\n </div>\n );\n}\n"],"mappings":";;;;;AA4BA,IAAM,uBAAuB,MAAM,cAAc,IAAI;;;;;;;;;;AAWrD,SAAgB,mBAA4B;CACxC,OAAO,WAAW,oBAAoB;AAC1C;;;;;;;AAQA,SAAS,aACL,WACA,KACO;CACP,MAAM,CAAC,UAAU,eAAe,SAAS,IAAI;CAC7C,MAAM,cAAc,OAAO,IAAI;CAC/B,MAAM,gBAAgB,OAA2B,KAAA,CAAS;CAE1D,sBAAsB;EAClB,MAAM,mBAAmB,UAAU;EACnC,MAAM,aAAa,IAAI;EACvB,IAAI,CAAC,oBAAoB,CAAC,cAAc,OAAO,mBAAmB,aAAa,OAAO,KAAA;EAEtF,MAAM,gBAAgB;GAClB,MAAM,YAAY,iBAAiB;GACnC,IAAI,OAAO,YAAY;GACvB,IAAI,YAAY,SAAS;IACrB,MAAM,SAAS,WAAW;IAC1B,IAAI,SAAS,YAAY,GAAG;KACxB,cAAc,UAAU;KACxB,OAAO;IACX;GACJ,OAAO,IAAI,cAAc,YAAY,KAAA,KAAa,aAAa,cAAc,SACzE,OAAO;GAEX,IAAI,SAAS,YAAY,SAAS;IAC9B,YAAY,UAAU;IACtB,YAAY,IAAI;GACpB;EACJ;EAIA,MAAM,WAAW,IAAI,eAAe,OAAO;EAC3C,SAAS,QAAQ,gBAAgB;EACjC,SAAS,QAAQ,UAAU;EAC3B,QAAQ;EACR,aAAa,SAAS,WAAW;CACrC,GAAG,CAAC,WAAW,GAAG,CAAC;CAEnB,OAAO;AACX;AAEA,SAAgB,uBAAuB,EACnC,SACA,cACA,SACA,cACA,OACA,gBACA,mBACA,UAAU,SACkB;CAE5B,MAAM,cAAc,eAAe;CACnC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,SAAS,OAAuB,IAAI;CAC1C,MAAM,WAAW,aAAa,cAAc,MAAM;CAGlD,MAAM,iBAAiB,MAAM,SAAS,QAAQ,OAAO;CACrD,MAAM,YAAY,eAAe,SAAS,IAAI,eAAe,eAAe,SAAS,KAAK;CAC1F,MAAM,mBAAmB,eAAe,MAAM,GAAG,EAAE;CAEnD,OACI,oBAAC,OAAD;EACI,KAAK;EACL,WAAW,IAAI,wEAAwE;YAMvF,oBAAC,OAAD;GACI,KAAK;GACL,WAAW;aAEX,qBAAC,qBAAqB,UAAtB;IAA+B,OAAO;cAAtC,CAEI,qBAAC,OAAD;KAAK,WAAU;eAAf;MAGK,CAAC,WAAW;MAEZ,SAAS,oBAAC,OAAD;OAAK,WAAW;iBACrB;MACA,CAAA;MAEJ;KAEA;QAEL,qBAAC,OAAD;KAAK,WAAU;eAAf;MAGK,eAAe,CAAC,WAAW,WACxB,oBAAC,OAAD;OAAK,WAAU;iBACX,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA;MACnC,CAAA;MAIR,CAAC,WAAW,gBACT,oBAAC,WAAD;OAEI,MAAM;OACN,aAAa,EAAE,QAAQ;OACT;OACd,YAAY;OACZ,cAAc;MAAmB,GAL5B,YAK4B;MAGzC,oBAAC,OAAD;OAAK,WAAU;iBACV;MACA,CAAA;MAGJ;KAEA;MAEsB;;EAE9B,CAAA;CAEJ,CAAA;AAEb"}
@@ -13,7 +13,7 @@ export interface EntityTableCellOpener {
13
13
  */
14
14
  onToggle: (open: boolean, cellRect: DOMRect | undefined) => void;
15
15
  }
16
- interface EntityTableCellProps {
16
+ export interface EntityTableCellProps {
17
17
  children: React.ReactNode;
18
18
  actions?: React.ReactNode;
19
19
  /**
@@ -52,4 +52,3 @@ interface EntityTableCellProps {
52
52
  /** How many cells are being measured right now — for tests. */
53
53
  export declare function measuredTableCellCount(): number;
54
54
  export declare const EntityTableCell: React.FunctionComponent<EntityTableCellProps>;
55
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"EntityTableCell.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/EntityTableCell.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { cls, Tooltip, iconSize } from \"@rebasepro/ui\";\nimport { ErrorBoundary, MinusCircleIcon } from \"@rebasepro/ui\";\nimport { getRowHeight, TableSize } from \"@rebasepro/app\";\nimport { ErrorTooltip } from \"@rebasepro/app\";\nimport { TableCellOpener, TableCellOpenerKind } from \"./TableCellOpener\";\nimport { RowEntityPreviewLayout } from \"../../EntityPreviewNesting\";\n\nexport interface EntityTableCellOpener {\n kind: TableCellOpenerKind;\n open: boolean;\n /** See {@link TableCellOpener}'s `focusOnSelect`. */\n focusOnSelect: boolean;\n label: string;\n /**\n * Whether the editor should now be open, and the cell's rect for editors\n * positioned against it. The cell is selected before this is called.\n */\n onToggle: (open: boolean, cellRect: DOMRect | undefined) => void;\n}\n\ninterface EntityTableCellProps {\n children: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * The value is used only to check changes and force re-renders\n */\n value?: unknown;\n disabled: boolean;\n savedTimestamp?: number;\n error?: Error;\n allowScroll?: boolean;\n align: \"right\" | \"left\" | \"center\";\n size: TableSize;\n disabledTooltip?: string;\n width: number;\n showExpandIcon?: boolean;\n removePadding?: boolean;\n fullHeight?: boolean;\n selected?: boolean;\n hideOverflow?: boolean;\n /**\n * The control that opens the cell's editor, revealed on hover and kept\n * shown while the cell is selected. The cell keeps a slot for it at its\n * trailing edge either way, so it never moves the value.\n */\n opener?: EntityTableCellOpener;\n /** The cell's element, for editors that float and are positioned against it. */\n cellRef?: React.RefObject<HTMLDivElement | null>;\n onSelect?: (cellRect: DOMRect | undefined) => void;\n // Sortable props for dnd-kit integration\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, string | number | undefined>;\n isDragging?: boolean;\n isDraggable?: boolean;\n frozen?: boolean;\n}\n\n/**\n * One ResizeObserver for every table cell, instead of one per cell.\n *\n * A cell measures its content only to know whether it overflows the row (to\n * fade it, or let it scroll). Each cell ran `react-use-measure` for that: a\n * ResizeObserver, two window listeners, a `getComputedStyle` walk up every\n * ancestor and an extra render once the first measurement landed — ~460 of\n * each for one screen of a 20-column table, and more with every row scrolled\n * in. The observer is created on first use and lives for the page; a cell\n * registers on mount and unregisters on unmount, so nothing is retained for\n * a cell that is gone.\n */\nlet sharedHeightObserver: ResizeObserver | undefined;\nconst heightListeners = new Map<Element, (height: number) => void>();\n\nfunction observeHeight(element: Element, onHeight: (height: number) => void): () => void {\n if (typeof ResizeObserver === \"undefined\") return () => undefined;\n if (!sharedHeightObserver) {\n sharedHeightObserver = new ResizeObserver((entries) => {\n for (const entry of entries)\n heightListeners.get(entry.target)?.(entry.contentRect.height);\n });\n }\n heightListeners.set(element, onHeight);\n sharedHeightObserver.observe(element);\n return () => {\n heightListeners.delete(element);\n sharedHeightObserver?.unobserve(element);\n };\n}\n\n/** How many cells are being measured right now — for tests. */\nexport function measuredTableCellCount(): number {\n return heightListeners.size;\n}\n\n/**\n * Whether the element given to the returned ref is taller than `maxHeight`.\n * State changes only when the answer does, so a cell whose content fits is\n * never drawn again by its measurement.\n */\nfunction useOverflowsHeight(maxHeight: number): [(element: HTMLDivElement | null) => void, boolean] {\n const [overflowing, setOverflowing] = useState(false);\n const heightRef = useRef(0);\n const maxHeightRef = useRef(maxHeight);\n const stopRef = useRef<(() => void) | undefined>(undefined);\n\n useEffect(() => {\n maxHeightRef.current = maxHeight;\n setOverflowing(heightRef.current > maxHeight);\n }, [maxHeight]);\n\n useEffect(() => () => {\n stopRef.current?.();\n stopRef.current = undefined;\n }, []);\n\n const ref = useCallback((element: HTMLDivElement | null) => {\n stopRef.current?.();\n stopRef.current = undefined;\n if (!element) return;\n stopRef.current = observeHeight(element, (height) => {\n heightRef.current = height;\n setOverflowing(height > maxHeightRef.current);\n });\n }, []);\n\n return [ref, overflowing];\n}\n\ntype TableCellInnerProps = {\n justifyContent: string;\n scrollable: boolean;\n faded: boolean;\n fullHeight: boolean;\n children: React.ReactNode;\n}\n\nconst TableCellInner = ({\n justifyContent,\n scrollable,\n faded,\n fullHeight,\n children\n}: TableCellInnerProps) => {\n return (\n <div className={cls(\"flex flex-col max-h-full w-full\",\n {\n \"items-start\": faded || scrollable\n })}\n style={{\n justifyContent,\n height: fullHeight ? \"100%\" : undefined,\n overflow: scrollable ? \"auto\" : undefined,\n WebkitMaskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined,\n maskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined\n }}\n >\n {children}\n </div>\n );\n};\n\nexport const EntityTableCell = React.memo<EntityTableCellProps>(\n function EntityTableCell({\n children,\n actions,\n size,\n selected,\n disabled,\n disabledTooltip,\n savedTimestamp,\n error,\n align,\n allowScroll,\n removePadding,\n fullHeight,\n opener,\n cellRef,\n onSelect,\n width,\n hideOverflow = true,\n showExpandIcon = true,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: EntityTableCellProps) {\n\n const internalRef = useRef<HTMLDivElement>(null);\n const ref = cellRef ?? internalRef;\n\n const maxHeight = useMemo(() => getRowHeight(size), [size]);\n const [measureRef, isOverflowing] = useOverflowsHeight(maxHeight);\n\n const [onHover, setOnHover] = useState(false);\n const [showSaved, setShowSaved] = useState(false);\n\n const showError = !disabled && Boolean(error);\n\n useEffect(() => {\n if (savedTimestamp && savedTimestamp > 0) {\n setShowSaved(true);\n const handler = setTimeout(() => {\n setShowSaved(false);\n }, 400);\n return () => {\n clearTimeout(handler);\n };\n }\n return undefined;\n }, [savedTimestamp]);\n\n let p = 0;\n if (!removePadding) {\n switch (size) {\n case \"l\":\n case \"xl\":\n p = 4;\n break;\n case \"m\":\n p = 2;\n break;\n case \"s\":\n default:\n p = 1;\n break;\n }\n }\n\n let justifyContent;\n switch (align) {\n case \"right\":\n justifyContent = \"flex-end\";\n break;\n case \"center\":\n justifyContent = \"center\";\n break;\n case \"left\":\n default:\n justifyContent = \"flex-start\";\n }\n\n // const onClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {\n // if (event.detail === 3) {\n // doOpenPopup();\n // }\n // }, [doOpenPopup]);\n\n const onSelectCallback = useCallback(() => {\n if (!onSelect) return;\n const cellRect = ref && ref?.current?.getBoundingClientRect();\n if (disabled) {\n onSelect(undefined);\n } else if (!selected && cellRect) {\n onSelect(cellRect);\n }\n }, [ref, onSelect, selected, disabled]);\n\n const onOpenerToggle = useCallback((open: boolean) => {\n if (!opener) return;\n const cellRect = ref.current?.getBoundingClientRect();\n if (open) onSelectCallback();\n opener.onToggle(open, cellRect);\n }, [opener, onSelectCallback, ref]);\n\n const onFocus = useCallback((event: React.SyntheticEvent<HTMLDivElement>) => {\n event.stopPropagation();\n event.preventDefault();\n onSelectCallback();\n }, [onSelectCallback]);\n\n const isSelected = !showError && selected;\n\n const scrollable = !disabled && allowScroll && isOverflowing;\n const faded = !disabled && !allowScroll && isOverflowing;\n\n const setOnHoverTrue = useCallback(() => setOnHover(true), []);\n const setOnHoverFalse = useCallback(() => setOnHover(false), []);\n\n const borderClass = showError\n ? \"border-red-500\"\n : isSelected\n ? \"border-primary\"\n : \"border-transparent\";\n\n // A reference or relation inside a cell is drawn as a line of its row,\n // never as the form's card, which is taller than any row.\n const content = <RowEntityPreviewLayout><ErrorBoundary>\n\n {fullHeight && !faded && children}\n\n {(!fullHeight || faded) && <TableCellInner\n fullHeight={fullHeight ?? false}\n justifyContent={justifyContent}\n scrollable={scrollable ?? false}\n faded={faded}>\n\n {!fullHeight && <div ref={measureRef}\n style={{\n display: \"flex\",\n width: \"100%\",\n justifyContent,\n height: fullHeight ? \"100%\" : undefined\n }}>\n {children}\n </div>}\n\n </TableCellInner>}\n </ErrorBoundary></RowEntityPreviewLayout>;\n\n const result = <>\n <div\n className={cls(\n \"group/cell transition-colors duration-500\",\n `flex relative h-full rounded-md p-${p} border-4`,\n showSaved ? \"bg-primary/20 dark:bg-primary/20\" : (onHover && !disabled ? \"bg-surface-hover\" : \"\"),\n hideOverflow ? \"overflow-hidden\" : \"\",\n isSelected && !showSaved ? \"bg-surface-raised\" : \"\",\n borderClass\n )}\n ref={ref}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined,\n width: width ?? \"100%\",\n textAlign: align\n }}\n tabIndex={selected || disabled ? undefined : 0}\n onFocus={onFocus}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n >\n\n {opener\n // The value and the opener side by side. The wrapper takes\n // over what the cell itself does for a cell without one:\n // aligning the value, and centring it when it fits.\n ? <div className={\"flex flex-1 min-w-0 self-stretch\"}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined\n }}>\n {content}\n </div>\n : content}\n\n {opener && <div className={\"shrink-0 self-center flex items-center pl-1\"}>\n <TableCellOpener kind={opener.kind}\n open={opener.open}\n selected={Boolean(selected)}\n focusOnSelect={opener.focusOnSelect}\n label={opener.label}\n onToggle={onOpenerToggle}/>\n </div>}\n\n {actions}\n\n {/*{disabled && onHover && disabledTooltip &&*/}\n {/* <div className=\"absolute top-1 right-1 text-xs\">*/}\n {/* <Tooltip title={disabledTooltip}>*/}\n {/* <MinusCircleIcon size={iconSize.smallest} color={\"disabled\"} className={\"text-text-disabled\"} />*/}\n {/* </Tooltip>*/}\n {/* </div>}*/}\n\n </div>\n </>;\n\n // Wrap with sortable outer div when sortable props are provided\n // Remove tabIndex from attributes to avoid capturing focus before cell content\n const { tabIndex: _tabIndex, ...sortableAttrsWithoutTabIndex } = sortableAttributes ?? {};\n const sortableContent = sortableNodeRef ? (\n <div\n ref={sortableNodeRef}\n style={sortableStyle}\n className={cls(\n \"flex-shrink-0\",\n frozen && \"sticky left-0 z-10 bg-surface-card\"\n )}\n {...sortableAttrsWithoutTabIndex}\n >\n {showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result}\n </div>\n ) : (\n showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result\n );\n\n return sortableContent;\n }\n // Compared by every prop, its children included. It used to compare a\n // hand-picked list with `value` standing in for what the cell shows, so a\n // cell whose content changed without its value — a new preview for a\n // changed property, an additional column's new builder — kept showing the\n // old one. Its parents (`PropertyTableCell`, the table's cell renderer)\n // are memoised and draw it only when something changed.\n) as React.FunctionComponent<EntityTableCellProps>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwEA,IAAI;AACJ,IAAM,kCAAkB,IAAI,IAAuC;AAEnE,SAAS,cAAc,SAAkB,UAAgD;CACrF,IAAI,OAAO,mBAAmB,aAAa,aAAa,KAAA;CACxD,IAAI,CAAC,sBACD,uBAAuB,IAAI,gBAAgB,YAAY;EACnD,KAAK,MAAM,SAAS,SAChB,gBAAgB,IAAI,MAAM,MAAM,CAAC,GAAG,MAAM,YAAY,MAAM;CACpE,CAAC;CAEL,gBAAgB,IAAI,SAAS,QAAQ;CACrC,qBAAqB,QAAQ,OAAO;CACpC,aAAa;EACT,gBAAgB,OAAO,OAAO;EAC9B,sBAAsB,UAAU,OAAO;CAC3C;AACJ;;;;;;AAYA,SAAS,mBAAmB,WAAwE;CAChG,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CACpD,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,eAAe,OAAO,SAAS;CACrC,MAAM,UAAU,OAAiC,KAAA,CAAS;CAE1D,g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;EACA,GAAI;YAEH,YACG,oBAAC,cAAD;GACI,WAAW;GACX,OAAO;GACP,OAAO,OAAO,WAAW;aACxB;EACS,CAAA,IACd;CACH,CAAA,IAEL,YACI,oBAAC,cAAD;EACI,WAAW;EACX,OAAO;EACP,OAAO,OAAO,WAAW;YACxB;CACS,CAAA,IACd;AAIZ,CAOJ"}
1
+ {"version":3,"file":"EntityTableCell.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/EntityTableCell.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { cls, Tooltip, iconSize } from \"@rebasepro/ui\";\nimport { ErrorBoundary, MinusCircleIcon } from \"@rebasepro/ui\";\nimport { getRowHeight, TableSize } from \"@rebasepro/app\";\nimport { ErrorTooltip } from \"@rebasepro/app\";\nimport { TableCellOpener, TableCellOpenerKind } from \"./TableCellOpener\";\nimport { RowEntityPreviewLayout } from \"../../EntityPreviewNesting\";\n\nexport interface EntityTableCellOpener {\n kind: TableCellOpenerKind;\n open: boolean;\n /** See {@link TableCellOpener}'s `focusOnSelect`. */\n focusOnSelect: boolean;\n label: string;\n /**\n * Whether the editor should now be open, and the cell's rect for editors\n * positioned against it. The cell is selected before this is called.\n */\n onToggle: (open: boolean, cellRect: DOMRect | undefined) => void;\n}\n\nexport interface EntityTableCellProps {\n children: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * The value is used only to check changes and force re-renders\n */\n value?: unknown;\n disabled: boolean;\n savedTimestamp?: number;\n error?: Error;\n allowScroll?: boolean;\n align: \"right\" | \"left\" | \"center\";\n size: TableSize;\n disabledTooltip?: string;\n width: number;\n showExpandIcon?: boolean;\n removePadding?: boolean;\n fullHeight?: boolean;\n selected?: boolean;\n hideOverflow?: boolean;\n /**\n * The control that opens the cell's editor, revealed on hover and kept\n * shown while the cell is selected. The cell keeps a slot for it at its\n * trailing edge either way, so it never moves the value.\n */\n opener?: EntityTableCellOpener;\n /** The cell's element, for editors that float and are positioned against it. */\n cellRef?: React.RefObject<HTMLDivElement | null>;\n onSelect?: (cellRect: DOMRect | undefined) => void;\n // Sortable props for dnd-kit integration\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, string | number | undefined>;\n isDragging?: boolean;\n isDraggable?: boolean;\n frozen?: boolean;\n}\n\n/**\n * One ResizeObserver for every table cell, instead of one per cell.\n *\n * A cell measures its content only to know whether it overflows the row (to\n * fade it, or let it scroll). Each cell ran `react-use-measure` for that: a\n * ResizeObserver, two window listeners, a `getComputedStyle` walk up every\n * ancestor and an extra render once the first measurement landed — ~460 of\n * each for one screen of a 20-column table, and more with every row scrolled\n * in. The observer is created on first use and lives for the page; a cell\n * registers on mount and unregisters on unmount, so nothing is retained for\n * a cell that is gone.\n */\nlet sharedHeightObserver: ResizeObserver | undefined;\nconst heightListeners = new Map<Element, (height: number) => void>();\n\nfunction observeHeight(element: Element, onHeight: (height: number) => void): () => void {\n if (typeof ResizeObserver === \"undefined\") return () => undefined;\n if (!sharedHeightObserver) {\n sharedHeightObserver = new ResizeObserver((entries) => {\n for (const entry of entries)\n heightListeners.get(entry.target)?.(entry.contentRect.height);\n });\n }\n heightListeners.set(element, onHeight);\n sharedHeightObserver.observe(element);\n return () => {\n heightListeners.delete(element);\n sharedHeightObserver?.unobserve(element);\n };\n}\n\n/** How many cells are being measured right now — for tests. */\nexport function measuredTableCellCount(): number {\n return heightListeners.size;\n}\n\n/**\n * Whether the element given to the returned ref is taller than `maxHeight`.\n * State changes only when the answer does, so a cell whose content fits is\n * never drawn again by its measurement.\n */\nfunction useOverflowsHeight(maxHeight: number): [(element: HTMLDivElement | null) => void, boolean] {\n const [overflowing, setOverflowing] = useState(false);\n const heightRef = useRef(0);\n const maxHeightRef = useRef(maxHeight);\n const stopRef = useRef<(() => void) | undefined>(undefined);\n\n useEffect(() => {\n maxHeightRef.current = maxHeight;\n setOverflowing(heightRef.current > maxHeight);\n }, [maxHeight]);\n\n useEffect(() => () => {\n stopRef.current?.();\n stopRef.current = undefined;\n }, []);\n\n const ref = useCallback((element: HTMLDivElement | null) => {\n stopRef.current?.();\n stopRef.current = undefined;\n if (!element) return;\n stopRef.current = observeHeight(element, (height) => {\n heightRef.current = height;\n setOverflowing(height > maxHeightRef.current);\n });\n }, []);\n\n return [ref, overflowing];\n}\n\ntype TableCellInnerProps = {\n justifyContent: string;\n scrollable: boolean;\n faded: boolean;\n fullHeight: boolean;\n children: React.ReactNode;\n}\n\nconst TableCellInner = ({\n justifyContent,\n scrollable,\n faded,\n fullHeight,\n children\n}: TableCellInnerProps) => {\n return (\n <div className={cls(\"flex flex-col max-h-full w-full\",\n {\n \"items-start\": faded || scrollable\n })}\n style={{\n justifyContent,\n height: fullHeight ? \"100%\" : undefined,\n overflow: scrollable ? \"auto\" : undefined,\n WebkitMaskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined,\n maskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined\n }}\n >\n {children}\n </div>\n );\n};\n\nexport const EntityTableCell = React.memo<EntityTableCellProps>(\n function EntityTableCell({\n children,\n actions,\n size,\n selected,\n disabled,\n disabledTooltip,\n savedTimestamp,\n error,\n align,\n allowScroll,\n removePadding,\n fullHeight,\n opener,\n cellRef,\n onSelect,\n width,\n hideOverflow = true,\n showExpandIcon = true,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: EntityTableCellProps) {\n\n const internalRef = useRef<HTMLDivElement>(null);\n const ref = cellRef ?? internalRef;\n\n const maxHeight = useMemo(() => getRowHeight(size), [size]);\n const [measureRef, isOverflowing] = useOverflowsHeight(maxHeight);\n\n const [onHover, setOnHover] = useState(false);\n const [showSaved, setShowSaved] = useState(false);\n\n const showError = !disabled && Boolean(error);\n\n useEffect(() => {\n if (savedTimestamp && savedTimestamp > 0) {\n setShowSaved(true);\n const handler = setTimeout(() => {\n setShowSaved(false);\n }, 400);\n return () => {\n clearTimeout(handler);\n };\n }\n return undefined;\n }, [savedTimestamp]);\n\n let p = 0;\n if (!removePadding) {\n switch (size) {\n case \"l\":\n case \"xl\":\n p = 4;\n break;\n case \"m\":\n p = 2;\n break;\n case \"s\":\n default:\n p = 1;\n break;\n }\n }\n\n let justifyContent;\n switch (align) {\n case \"right\":\n justifyContent = \"flex-end\";\n break;\n case \"center\":\n justifyContent = \"center\";\n break;\n case \"left\":\n default:\n justifyContent = \"flex-start\";\n }\n\n // const onClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {\n // if (event.detail === 3) {\n // doOpenPopup();\n // }\n // }, [doOpenPopup]);\n\n const onSelectCallback = useCallback(() => {\n if (!onSelect) return;\n const cellRect = ref && ref?.current?.getBoundingClientRect();\n if (disabled) {\n onSelect(undefined);\n } else if (!selected && cellRect) {\n onSelect(cellRect);\n }\n }, [ref, onSelect, selected, disabled]);\n\n const onOpenerToggle = useCallback((open: boolean) => {\n if (!opener) return;\n const cellRect = ref.current?.getBoundingClientRect();\n if (open) onSelectCallback();\n opener.onToggle(open, cellRect);\n }, [opener, onSelectCallback, ref]);\n\n const onFocus = useCallback((event: React.SyntheticEvent<HTMLDivElement>) => {\n event.stopPropagation();\n event.preventDefault();\n onSelectCallback();\n }, [onSelectCallback]);\n\n const isSelected = !showError && selected;\n\n const scrollable = !disabled && allowScroll && isOverflowing;\n const faded = !disabled && !allowScroll && isOverflowing;\n\n const setOnHoverTrue = useCallback(() => setOnHover(true), []);\n const setOnHoverFalse = useCallback(() => setOnHover(false), []);\n\n const borderClass = showError\n ? \"border-red-500\"\n : isSelected\n ? \"border-primary\"\n : \"border-transparent\";\n\n // A reference or relation inside a cell is drawn as a line of its row,\n // never as the form's card, which is taller than any row.\n const content = <RowEntityPreviewLayout><ErrorBoundary>\n\n {fullHeight && !faded && children}\n\n {(!fullHeight || faded) && <TableCellInner\n fullHeight={fullHeight ?? false}\n justifyContent={justifyContent}\n scrollable={scrollable ?? false}\n faded={faded}>\n\n {!fullHeight && <div ref={measureRef}\n style={{\n display: \"flex\",\n width: \"100%\",\n justifyContent,\n height: fullHeight ? \"100%\" : undefined\n }}>\n {children}\n </div>}\n\n </TableCellInner>}\n </ErrorBoundary></RowEntityPreviewLayout>;\n\n const result = <>\n <div\n className={cls(\n \"group/cell transition-colors duration-500\",\n `flex relative h-full rounded-md p-${p} border-4`,\n showSaved ? \"bg-primary/20 dark:bg-primary/20\" : (onHover && !disabled ? \"bg-surface-hover\" : \"\"),\n hideOverflow ? \"overflow-hidden\" : \"\",\n isSelected && !showSaved ? \"bg-surface-raised\" : \"\",\n borderClass\n )}\n ref={ref}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined,\n width: width ?? \"100%\",\n textAlign: align\n }}\n tabIndex={selected || disabled ? undefined : 0}\n onFocus={onFocus}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n >\n\n {opener\n // The value and the opener side by side. The wrapper takes\n // over what the cell itself does for a cell without one:\n // aligning the value, and centring it when it fits.\n ? <div className={\"flex flex-1 min-w-0 self-stretch\"}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined\n }}>\n {content}\n </div>\n : content}\n\n {opener && <div className={\"shrink-0 self-center flex items-center pl-1\"}>\n <TableCellOpener kind={opener.kind}\n open={opener.open}\n selected={Boolean(selected)}\n focusOnSelect={opener.focusOnSelect}\n label={opener.label}\n onToggle={onOpenerToggle}/>\n </div>}\n\n {actions}\n\n {/*{disabled && onHover && disabledTooltip &&*/}\n {/* <div className=\"absolute top-1 right-1 text-xs\">*/}\n {/* <Tooltip title={disabledTooltip}>*/}\n {/* <MinusCircleIcon size={iconSize.smallest} color={\"disabled\"} className={\"text-text-disabled\"} />*/}\n {/* </Tooltip>*/}\n {/* </div>}*/}\n\n </div>\n </>;\n\n // Wrap with sortable outer div when sortable props are provided\n // Remove tabIndex from attributes to avoid capturing focus before cell content\n const { tabIndex: _tabIndex, ...sortableAttrsWithoutTabIndex } = sortableAttributes ?? {};\n const sortableContent = sortableNodeRef ? (\n <div\n ref={sortableNodeRef}\n style={sortableStyle}\n className={cls(\n \"flex-shrink-0\",\n frozen && \"sticky left-0 z-10 bg-surface-card\"\n )}\n {...sortableAttrsWithoutTabIndex}\n >\n {showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result}\n </div>\n ) : (\n showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result\n );\n\n return sortableContent;\n }\n // Compared by every prop, its children included. It used to compare a\n // hand-picked list with `value` standing in for what the cell shows, so a\n // cell whose content changed without its value — a new preview for a\n // changed property, an additional column's new builder — kept showing the\n // old one. Its parents (`PropertyTableCell`, the table's cell renderer)\n // are memoised and draw it only when something changed.\n) as React.FunctionComponent<EntityTableCellProps>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwEA,IAAI;AACJ,IAAM,kCAAkB,IAAI,IAAuC;AAEnE,SAAS,cAAc,SAAkB,UAAgD;CACrF,IAAI,OAAO,mBAAmB,aAAa,aAAa,KAAA;CACxD,IAAI,CAAC,sBACD,uBAAuB,IAAI,gBAAgB,YAAY;EACnD,KAAK,MAAM,SAAS,SAChB,gBAAgB,IAAI,MAAM,MAAM,CAAC,GAAG,MAAM,YAAY,MAAM;CACpE,CAAC;CAEL,gBAAgB,IAAI,SAAS,QAAQ;CACrC,qBAAqB,QAAQ,OAAO;CACpC,aAAa;EACT,gBAAgB,OAAO,OAAO;EAC9B,sBAAsB,UAAU,OAAO;CAC3C;AACJ;;;;;;AAYA,SAAS,mBAAmB,WAAwE;CAChG,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CACpD,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,eAAe,OA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;EACI,KAAK;EACL,OAAO;EACP,WAAW,IACP,iBACA,UAAU,oCACd;EACA,GAAI;YAEH,YACG,oBAAC,cAAD;GACI,WAAW;GACX,OAAO;GACP,OAAO,OAAO,WAAW;aACxB;EACS,CAAA,IACd;CACH,CAAA,IAEL,YACI,oBAAC,cAAD;EACI,WAAW;EACX,OAAO;EACP,OAAO,OAAO,WAAW;YACxB;CACS,CAAA,IACd;AAIZ,CAOJ"}
@@ -114,7 +114,7 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
114
114
  fallback: null,
115
115
  children: /* @__PURE__ */ jsx(ImportCollectionAction, { ...actionProps })
116
116
  }) }),
117
- /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
117
+ collection.exportable !== false && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
118
118
  fallback: null,
119
119
  children: /* @__PURE__ */ jsx(ExportCollectionAction, { ...actionProps })
120
120
  }) }),
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionViewActions.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionViewActions.tsx"],"sourcesContent":["\n\nimport React, { Suspense } from \"react\";\n\nimport { useLargeLayout, useTranslation, useSlot, resolveComponentRef } from \"@rebasepro/app\";\nimport { CollectionActionsProps, EntityTableController, SelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Button, IconButton, Tooltip, Popover, iconSize, lazyChunk } from \"@rebasepro/ui\";\nimport { ErrorBoundary, Link2Icon, MoreVerticalIcon, PlusIcon, Trash2Icon, Unlink2Icon } from \"@rebasepro/ui\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\n// Lazy-load import/export — pulls in exceljs only on demand\nconst ImportCollectionAction = lazyChunk(() => import(\"../../data_import/import\").then(m => ({ default: m.ImportCollectionAction })));\nconst ExportCollectionAction = lazyChunk(() => import(\"../../data_export/export\").then(m => ({ default: m.ExportCollectionAction })));\nimport { EditorCollectionAction } from \"../../collection_editor/ui/EditorCollectionAction\";\nimport { useCollectionEditorController } from \"../../collection_editor/useCollectionEditorController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\n\nexport type CollectionViewActionsProps<M extends Record<string, unknown>> = {\n collection: AdminCollection<M>;\n path: string;\n relativePath: string;\n parentCollectionSlugs: string[], parentEntityIds: string[];\n selectionEnabled: boolean;\n onNewClick: () => void;\n /**\n * Attach a row that already exists to this parent. Only supplied for a\n * junction-backed tab, where the parent owns the link rather than the row.\n */\n onAddExistingClick?: () => void;\n onMultipleDeleteClick: () => void;\n /**\n * The rows are shared with other records through a junction, so removing\n * them unlinks them from this record and deletes nothing. The bin says so.\n */\n removeUnlinks?: boolean;\n selectionController: SelectionController<M>;\n tableController: EntityTableController<M>;\n collectionEntitiesCount?: number;\n compact?: boolean;\n children?: React.ReactNode;\n openNewDocument: (defaultValues?: Record<string, unknown>) => void;\n}\n\nexport function CollectionViewActions<M extends Record<string, unknown>>({\n collection,\n relativePath,\n parentCollectionSlugs, parentEntityIds,\n onNewClick,\n onAddExistingClick,\n onMultipleDeleteClick,\n removeUnlinks,\n selectionEnabled,\n path,\n selectionController,\n tableController,\n collectionEntitiesCount,\n compact,\n children,\n openNewDocument\n}: CollectionViewActionsProps<M>) {\n const context = useAdminContext();\n\n const { canCreate, canDelete } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const toolbarLabels = useToolbarLabels();\n // Labelled controls on a wide layout whose toolbar has room for them;\n // their icon-only forms otherwise.\n const labelled = largeLayout && !compact && toolbarLabels;\n const { t } = useTranslation();\n\n // Check if the collection editor context is available (ConfigControllerProvider present)\n const collectionEditorController = useCollectionEditorController();\n const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);\n\n const { selectedCount, hasSelection } = selectionController;\n\n const addButton = canCreate(collection, path) &&\n onNewClick && (labelled\n ? <Button\n id={`add_entity_${path}`}\n onClick={onNewClick}\n startIcon={<PlusIcon size={iconSize.small}/>}\n size=\"small\"\n variant=\"filled\"\n color=\"primary\">\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n // In the compact split-list toolbar the add action is the one filled\n // control: a rounded square, so it reads as a button and not a badge.\n : <IconButton\n id={`add_entity_${path}`}\n onClick={onNewClick}\n variant=\"filled\"\n shape=\"square\"\n size=\"small\"\n aria-label={t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n >\n <PlusIcon size={iconSize.small}/>\n </IconButton>);\n\n // On a junction-backed tab, creating a row is only half of what \"add\" means:\n // the far more common act is attaching one that already exists. There was no\n // way to do that at all — the junction row was only ever written alongside an\n // insert — so a shared vocabulary could only ever grow.\n const linkButton = onAddExistingClick && (labelled\n ? <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n startIcon={<Link2Icon size={iconSize.small}/>}\n size=\"small\"\n variant=\"outlined\"\n color=\"neutral\">\n {t(\"add_existing\")}\n </Button>\n : <Tooltip title={t(\"add_existing\")}>\n <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\">\n <Link2Icon size={iconSize.small}/>\n </Button>\n </Tooltip>);\n\n const multipleDeleteEnabled = canDelete(collection, path, null);\n\n // Only once something is selected. A permanently-disabled bin sat in every\n // collection toolbar — and in the split view, where the toolbar is a narrow\n // strip above the list, it was a third of the visible controls doing\n // nothing. It appears the moment you tick a row, which is when you want it.\n\n // `undefined` is \"every matching row, and nobody knows how many\" — a full\n // selection against an accessor with no `count`. Rendering it as 0 would\n // say the opposite of what is true.\n const countLabel = selectedCount === undefined ? \"…\" : selectedCount.toLocaleString();\n\n let multipleDeleteButton: React.ReactNode | undefined;\n if (hasSelection) {\n const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;\n const button = labelled\n // `min-w`, not `w`. A fixed 80px was enough for the one- and\n // two-digit counts you could reach by ticking rows; \"select all\n // matching\" put six digits in here, and a flex child over its width\n // compresses — so the bin itself was what gave way, shrinking to a\n // sliver beside the number. The width is a floor now, so the\n // control still holds its place in the toolbar when the count is\n // short, and `shrink-0` means the icon can never be the thing that\n // gives.\n ? <Button\n variant={\"text\"}\n disabled={!multipleDeleteEnabled}\n startIcon={<RemoveIcon size={iconSize.small} className={\"shrink-0\"}/>}\n onClick={onMultipleDeleteClick}\n color={\"neutral\"}\n className=\"lg:min-w-20\"\n >\n ({countLabel})\n </Button>\n : <IconButton aria-label={t(\"delete_selected\")}\n size={\"small\"}\n disabled={!multipleDeleteEnabled}\n onClick={onMultipleDeleteClick}>\n <RemoveIcon size={iconSize.small}/>\n </IconButton>;\n multipleDeleteButton =\n <Tooltip\n title={multipleDeleteEnabled\n ? (removeUnlinks ? t(\"remove_from_record\") : t(\"delete\"))\n : t(\"delete_not_allowed\")}>\n {button}\n </Tooltip>\n }\n\n const actionProps: CollectionActionsProps<M> = {\n path,\n relativePath,\n parentCollectionSlugs,\nparentEntityIds,\n collection,\n selectionController,\n context,\n tableController,\n collectionEntitiesCount,\n openNewDocument\n };\n\n const actions = toArray(collection.Actions)\n .map((actionRef, i) => {\n const Action = resolveComponentRef(actionRef);\n if (!Action) return null;\n return (\n <ErrorBoundary key={`actions_${i}`}>\n <Suspense fallback={null}>\n <Action {...actionProps}/>\n </Suspense>\n </ErrorBoundary>\n );\n });\n\n const pluginActions = useSlot(\"collection.actions\", actionProps as CollectionActionsProps);\n\n const secondaryActions = (\n <>\n {children}\n <ErrorBoundary>\n {actions}\n {pluginActions}\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ImportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ExportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n {hasCollectionEditor && (\n <ErrorBoundary>\n <EditorCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </ErrorBoundary>\n )}\n </>\n );\n\n const [overflowOpen, setOverflowOpen] = React.useState(false);\n\n return (\n <div className=\"flex items-center gap-1\">\n {!compact ? (\n secondaryActions\n ) : (\n <Popover\n open={overflowOpen}\n onOpenChange={setOverflowOpen}\n trigger={\n <IconButton aria-label={t(\"more_actions\")} size=\"small\">\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n <div className=\"flex flex-row items-center gap-1 p-2\">\n {secondaryActions}\n </div>\n </Popover>\n )}\n {multipleDeleteButton}\n {linkButton}\n {addButton}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AACpI,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAgCpI,SAAgB,sBAAyD,EACrE,YACA,cACA,uBAAuB,iBACvB,YACA,oBACA,uBACA,eACA,kBACA,MACA,qBACA,iBACA,yBACA,SACA,UACA,mBAC8B;CAC9B,MAAM,UAAU,gBAAgB;CAEhC,MAAM,EAAE,WAAW,cAAc,eAAe;CAEhD,MAAM,cAAc,eAAe;CACnC,MAAM,gBAAgB,iBAAiB;CAGvC,MAAM,WAAW,eAAe,CAAC,WAAW;CAC5C,MAAM,EAAE,MAAM,eAAe;CAG7B,MAAM,6BAA6B,8BAA8B;CACjE,MAAM,sBAAsB,QAAQ,4BAA4B,cAAc;CAE9E,MAAM,EAAE,eAAe,iBAAiB;CAExC,MAAM,YAAY,UAAU,YAAY,IAAI,KACxC,eAAe,WACT,oBAAC,QAAD;EACE,IAAI,cAAc;EAClB,SAAS;EACT,WAAW,oBAAC,UAAD,EAAU,MAAM,SAAS,MAAO,CAAA;EAC3C,MAAK;EACL,SAAQ;EACR,OAAM;YACL,EAAE,gBAAgB,EAAE,MAAM,WAAW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;;AAEb"}
1
+ {"version":3,"file":"CollectionViewActions.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionViewActions.tsx"],"sourcesContent":["\n\nimport React, { Suspense } from \"react\";\n\nimport { useLargeLayout, useTranslation, useSlot, resolveComponentRef } from \"@rebasepro/app\";\nimport { CollectionActionsProps, EntityTableController, SelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Button, IconButton, Tooltip, Popover, iconSize, lazyChunk } from \"@rebasepro/ui\";\nimport { ErrorBoundary, Link2Icon, MoreVerticalIcon, PlusIcon, Trash2Icon, Unlink2Icon } from \"@rebasepro/ui\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\n// Lazy-load import/export — pulls in exceljs only on demand\nconst ImportCollectionAction = lazyChunk(() => import(\"../../data_import/import\").then(m => ({ default: m.ImportCollectionAction })));\nconst ExportCollectionAction = lazyChunk(() => import(\"../../data_export/export\").then(m => ({ default: m.ExportCollectionAction })));\nimport { EditorCollectionAction } from \"../../collection_editor/ui/EditorCollectionAction\";\nimport { useCollectionEditorController } from \"../../collection_editor/useCollectionEditorController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\n\nexport type CollectionViewActionsProps<M extends Record<string, unknown>> = {\n collection: AdminCollection<M>;\n path: string;\n relativePath: string;\n parentCollectionSlugs: string[], parentEntityIds: string[];\n selectionEnabled: boolean;\n onNewClick: () => void;\n /**\n * Attach a row that already exists to this parent. Only supplied for a\n * junction-backed tab, where the parent owns the link rather than the row.\n */\n onAddExistingClick?: () => void;\n onMultipleDeleteClick: () => void;\n /**\n * The rows are shared with other records through a junction, so removing\n * them unlinks them from this record and deletes nothing. The bin says so.\n */\n removeUnlinks?: boolean;\n selectionController: SelectionController<M>;\n tableController: EntityTableController<M>;\n collectionEntitiesCount?: number;\n compact?: boolean;\n children?: React.ReactNode;\n openNewDocument: (defaultValues?: Record<string, unknown>) => void;\n}\n\nexport function CollectionViewActions<M extends Record<string, unknown>>({\n collection,\n relativePath,\n parentCollectionSlugs, parentEntityIds,\n onNewClick,\n onAddExistingClick,\n onMultipleDeleteClick,\n removeUnlinks,\n selectionEnabled,\n path,\n selectionController,\n tableController,\n collectionEntitiesCount,\n compact,\n children,\n openNewDocument\n}: CollectionViewActionsProps<M>) {\n const context = useAdminContext();\n\n const { canCreate, canDelete } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const toolbarLabels = useToolbarLabels();\n // Labelled controls on a wide layout whose toolbar has room for them;\n // their icon-only forms otherwise.\n const labelled = largeLayout && !compact && toolbarLabels;\n const { t } = useTranslation();\n\n // Check if the collection editor context is available (ConfigControllerProvider present)\n const collectionEditorController = useCollectionEditorController();\n const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);\n\n const { selectedCount, hasSelection } = selectionController;\n\n const addButton = canCreate(collection, path) &&\n onNewClick && (labelled\n ? <Button\n id={`add_entity_${path}`}\n onClick={onNewClick}\n startIcon={<PlusIcon size={iconSize.small}/>}\n size=\"small\"\n variant=\"filled\"\n color=\"primary\">\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n // In the compact split-list toolbar the add action is the one filled\n // control: a rounded square, so it reads as a button and not a badge.\n : <IconButton\n id={`add_entity_${path}`}\n onClick={onNewClick}\n variant=\"filled\"\n shape=\"square\"\n size=\"small\"\n aria-label={t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n >\n <PlusIcon size={iconSize.small}/>\n </IconButton>);\n\n // On a junction-backed tab, creating a row is only half of what \"add\" means:\n // the far more common act is attaching one that already exists. There was no\n // way to do that at all — the junction row was only ever written alongside an\n // insert — so a shared vocabulary could only ever grow.\n const linkButton = onAddExistingClick && (labelled\n ? <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n startIcon={<Link2Icon size={iconSize.small}/>}\n size=\"small\"\n variant=\"outlined\"\n color=\"neutral\">\n {t(\"add_existing\")}\n </Button>\n : <Tooltip title={t(\"add_existing\")}>\n <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\">\n <Link2Icon size={iconSize.small}/>\n </Button>\n </Tooltip>);\n\n const multipleDeleteEnabled = canDelete(collection, path, null);\n\n // Only once something is selected. A permanently-disabled bin sat in every\n // collection toolbar — and in the split view, where the toolbar is a narrow\n // strip above the list, it was a third of the visible controls doing\n // nothing. It appears the moment you tick a row, which is when you want it.\n\n // `undefined` is \"every matching row, and nobody knows how many\" — a full\n // selection against an accessor with no `count`. Rendering it as 0 would\n // say the opposite of what is true.\n const countLabel = selectedCount === undefined ? \"…\" : selectedCount.toLocaleString();\n\n let multipleDeleteButton: React.ReactNode | undefined;\n if (hasSelection) {\n const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;\n const button = labelled\n // `min-w`, not `w`. A fixed 80px was enough for the one- and\n // two-digit counts you could reach by ticking rows; \"select all\n // matching\" put six digits in here, and a flex child over its width\n // compresses — so the bin itself was what gave way, shrinking to a\n // sliver beside the number. The width is a floor now, so the\n // control still holds its place in the toolbar when the count is\n // short, and `shrink-0` means the icon can never be the thing that\n // gives.\n ? <Button\n variant={\"text\"}\n disabled={!multipleDeleteEnabled}\n startIcon={<RemoveIcon size={iconSize.small} className={\"shrink-0\"}/>}\n onClick={onMultipleDeleteClick}\n color={\"neutral\"}\n className=\"lg:min-w-20\"\n >\n ({countLabel})\n </Button>\n : <IconButton aria-label={t(\"delete_selected\")}\n size={\"small\"}\n disabled={!multipleDeleteEnabled}\n onClick={onMultipleDeleteClick}>\n <RemoveIcon size={iconSize.small}/>\n </IconButton>;\n multipleDeleteButton =\n <Tooltip\n title={multipleDeleteEnabled\n ? (removeUnlinks ? t(\"remove_from_record\") : t(\"delete\"))\n : t(\"delete_not_allowed\")}>\n {button}\n </Tooltip>\n }\n\n const actionProps: CollectionActionsProps<M> = {\n path,\n relativePath,\n parentCollectionSlugs,\nparentEntityIds,\n collection,\n selectionController,\n context,\n tableController,\n collectionEntitiesCount,\n openNewDocument\n };\n\n const actions = toArray(collection.Actions)\n .map((actionRef, i) => {\n const Action = resolveComponentRef(actionRef);\n if (!Action) return null;\n return (\n <ErrorBoundary key={`actions_${i}`}>\n <Suspense fallback={null}>\n <Action {...actionProps}/>\n </Suspense>\n </ErrorBoundary>\n );\n });\n\n const pluginActions = useSlot(\"collection.actions\", actionProps as CollectionActionsProps);\n\n const secondaryActions = (\n <>\n {children}\n <ErrorBoundary>\n {actions}\n {pluginActions}\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ImportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n {collection.exportable !== false && (\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ExportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n )}\n {hasCollectionEditor && (\n <ErrorBoundary>\n <EditorCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </ErrorBoundary>\n )}\n </>\n );\n\n const [overflowOpen, setOverflowOpen] = React.useState(false);\n\n return (\n <div className=\"flex items-center gap-1\">\n {!compact ? (\n secondaryActions\n ) : (\n <Popover\n open={overflowOpen}\n onOpenChange={setOverflowOpen}\n trigger={\n <IconButton aria-label={t(\"more_actions\")} size=\"small\">\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n <div className=\"flex flex-row items-center gap-1 p-2\">\n {secondaryActions}\n </div>\n </Popover>\n )}\n {multipleDeleteButton}\n {linkButton}\n {addButton}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AACpI,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAgCpI,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GAAK,YAAwC,CAAA;EAC/D,CAAA,EACC,CAAA;EACd,WAAW,eAAe,SACvB,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA;EAC/D,CAAA,EACC,CAAA;EAElB,uBACG,oBAAC,eAAD,EAAA,UACI,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA,EAC1D,CAAA;CAErB,EAAA,CAAA;CAGN,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAE5D,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf;GACK,CAAC,UACE,mBAEA,oBAAC,SAAD;IACI,MAAM;IACN,cAAc;IACd,SACI,oBAAC,YAAD;KAAY,cAAY,EAAE,cAAc;KAAG,MAAK;eAC5C,oBAAC,kBAAD,EAAkB,MAAM,SAAS,SAAU,CAAA;IACnC,CAAA;cAEhB,oBAAC,OAAD;KAAK,WAAU;eACV;IACA,CAAA;GACA,CAAA;GAEZ;GACA;GACA;EACA;;AAEb"}
@@ -25,6 +25,7 @@ import { useChildViewSource } from "../../hooks/useChildViewSource.js";
25
25
  import { SplitListView } from "./SplitListView.js";
26
26
  import { CollectionBoardViewBinding } from "./CollectionBoardViewBinding.js";
27
27
  import { ViewModeToggle } from "./ViewModeToggle.js";
28
+ import { DefaultCollectionEmptyState } from "./DefaultCollectionEmptyState.js";
28
29
  import { resolveCellProperty } from "../../form/resolve_cell_property.js";
29
30
  import { PopupFormField } from "../CollectionTableBinding/internal/popup_field/PopupFormField.js";
30
31
  import { DeleteEntityDialog } from "../DeleteEntityDialog.js";
@@ -32,7 +33,7 @@ import { CollectionViewStartActions } from "./CollectionViewStartActions.js";
32
33
  import React, { useCallback, useEffect, useMemo, useState } from "react";
33
34
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
34
35
  import { deepEqual, shallowEqual } from "fast-equals";
35
- import { Alert, ArrowRightToLineIcon, Button, ErrorBoundary, IconButton, PlusIcon, Popover, SearchIcon, TextField, Tooltip, Typography, cls, focusedDisabled, iconSize } from "@rebasepro/ui";
36
+ import { Alert, ArrowRightToLineIcon, Button, ErrorBoundary, IconButton, Popover, SearchIcon, TextField, Tooltip, Typography, cls, focusedDisabled, iconSize } from "@rebasepro/ui";
36
37
  import { getEntityChildViews, serializeOrderBy } from "@rebasepro/common";
37
38
  import { CollectionScopeProvider, getRedundantChildViewColumnIds, populateFetchCache, resolveComponentRef, saveEntityWithCallbacks, useAnalyticsController, useAuthController, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataTableController, useLargeLayout, usePermissions, useScrollRestoration, useSlot, useTranslation, useUserConfigurationPersistence } from "@rebasepro/app";
38
39
  import { EntityReference, getCollectionDataPath } from "@rebasepro/types";
@@ -1023,33 +1024,6 @@ var CollectionViewBinding = React.memo(function CollectionViewBinding(props) {
1023
1024
  return content;
1024
1025
  });
1025
1026
  /**
1026
- * Default empty state shown when a collection has no entities.
1027
- * Used as the fallback for the `"Collection.EmptyState"` component override.
1028
- *
1029
- * @internal
1030
- */
1031
- function DefaultCollectionEmptyState({ canCreate, onNewClick, isSearching, isFiltered, searchString }) {
1032
- const { t } = useTranslation();
1033
- if (canCreate) return /* @__PURE__ */ jsxs("div", {
1034
- className: "flex flex-col items-center justify-center",
1035
- children: [/* @__PURE__ */ jsx(Typography, {
1036
- variant: "subtitle2",
1037
- children: t("so_empty")
1038
- }), /* @__PURE__ */ jsxs(Button, {
1039
- onClick: onNewClick,
1040
- className: "mt-4",
1041
- children: [/* @__PURE__ */ jsx(PlusIcon, {}), t("create_your_first_entry")]
1042
- })]
1043
- });
1044
- let message = t("no_entries_found");
1045
- if (isSearching) message = t("no_results_search", { search: searchString });
1046
- else if (isFiltered) message = t("no_results_filter");
1047
- return /* @__PURE__ */ jsx(Typography, {
1048
- variant: "label",
1049
- children: message
1050
- });
1051
- }
1052
- /**
1053
1027
  * Inflight count request deduplication map.
1054
1028
  * Keyed by `path|filterKey|sort|search` so that concurrent
1055
1029
  * callers (e.g. React StrictMode double-mount) share the same promise.