@rebasepro/cms 0.27.0 → 0.28.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 (63) hide show
  1. package/dist/collection_editor/serializable_utils.js +5 -2
  2. package/dist/collection_editor/serializable_utils.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +17 -0
  4. package/dist/collection_editor/ui/collection_editor/EnumForm.js +31 -17
  5. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  6. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +6 -5
  7. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  8. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +3 -2
  9. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +32 -16
  11. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  12. package/dist/components/DetailViewBinding.js +4 -3
  13. package/dist/components/DetailViewBinding.js.map +1 -1
  14. package/dist/components/EditViewBinding.js +23 -5
  15. package/dist/components/EditViewBinding.js.map +1 -1
  16. package/dist/components/EntityPreviewBinding.js +1 -0
  17. package/dist/components/EntityPreviewBinding.js.map +1 -1
  18. package/dist/components/SelectableTable/filters/StringNumberFilterField.js +3 -3
  19. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  20. package/dist/components/SidePanelBinding.js +7 -6
  21. package/dist/components/SidePanelBinding.js.map +1 -1
  22. package/dist/components/app/Scaffold.js +16 -1
  23. package/dist/components/app/Scaffold.js.map +1 -1
  24. package/dist/components/history/EntityHistoryView.js +2 -1
  25. package/dist/components/history/EntityHistoryView.js.map +1 -1
  26. package/dist/data_export/export/export.js +3 -3
  27. package/dist/data_export/export/export.js.map +1 -1
  28. package/dist/data_import/import/ImportCollectionAction.js +10 -12
  29. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  30. package/dist/data_import/utils/id_column.d.ts +19 -0
  31. package/dist/data_import/utils/id_column.js +19 -1
  32. package/dist/data_import/utils/id_column.js.map +1 -1
  33. package/dist/data_import/utils/transforms.js +24 -7
  34. package/dist/data_import/utils/transforms.js.map +1 -1
  35. package/dist/form/EntityForm.d.ts +1 -1
  36. package/dist/form/EntityForm.js +14 -4
  37. package/dist/form/EntityForm.js.map +1 -1
  38. package/dist/form/EntityFormBinding.js +12 -8
  39. package/dist/form/EntityFormBinding.js.map +1 -1
  40. package/dist/form/components/FieldBlock.js +2 -1
  41. package/dist/form/components/FieldBlock.js.map +1 -1
  42. package/dist/form/field_bindings/KeyValueFieldBinding.js +3 -1
  43. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  44. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +0 -2
  45. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  46. package/dist/form/field_bindings/TextFieldBinding.js +3 -2
  47. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  48. package/dist/form/validation.js +12 -1
  49. package/dist/form/validation.js.map +1 -1
  50. package/dist/hooks/navigation/url_segments.d.ts +33 -0
  51. package/dist/hooks/navigation/url_segments.js +56 -0
  52. package/dist/hooks/navigation/url_segments.js.map +1 -0
  53. package/dist/hooks/navigation/useBuildUrlController.js +4 -2
  54. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  55. package/dist/hooks/useBuildSidePanel.js +6 -5
  56. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  57. package/dist/hooks/useHistory.js +4 -3
  58. package/dist/hooks/useHistory.js.map +1 -1
  59. package/dist/routes/RebaseRoute.js +20 -30
  60. package/dist/routes/RebaseRoute.js.map +1 -1
  61. package/dist/util/navigation_utils.js +4 -3
  62. package/dist/util/navigation_utils.js.map +1 -1
  63. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"StringNumberFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/StringNumberFilterField.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport {\n IconButton,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n TextField,\n VirtualTableWhereFilterOp,\n XIcon\n} from \"@rebasepro/ui\";\nimport { EnumValueConfig } from \"@rebasepro/types\";\nimport { useTranslation } from \"@rebasepro/app\";\n\ninterface StringNumberFilterFieldProps {\n name: string,\n type: \"string\" | \"number\";\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (value?: [op: VirtualTableWhereFilterOp, newValue: unknown]) => void;\n isArray?: boolean;\n enumValues?: EnumValueConfig[];\n title?: string;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Any\",\n \"ilike\": \"Contains\",\n \"not-ilike\": \"Not contains\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/** Operators that match a substring, wrapped in SQL wildcards (`%value%`). */\nconst containsOperations = [\"ilike\", \"not-ilike\"];\n\n/** Strip the surrounding `%` wildcards a contains-filter adds, for display. */\nfunction unwrapContains(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/^%/, \"\").replace(/%$/, \"\");\n}\n\nexport function StringNumberFilterField({\n name,\n value,\n setValue,\n type,\n isArray,\n enumValues,\n title,\n operators\n }: StringNumberFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"is-null\", \"is-not-null\"];\n\n // Case-insensitive substring matching is only meaningful for free-text\n // string columns (not numbers, arrays, or enums).\n if (!isArray && !enumValues && type === \"string\") {\n possibleOperations.push(\"ilike\", \"not-ilike\");\n }\n\n if (enumValues) {\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n }\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n // Read back both the canonical null operators and the legacy `[\"==\", null]` /\n // `[\"!=\", null]` form saved by older filter presets.\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(\n fieldOperation === \"==\" && fieldValue === null ? \"is-null\"\n : fieldOperation === \"!=\" && fieldValue === null ? \"is-not-null\"\n : fieldOperation\n );\n const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(\n containsOperations.includes(fieldOperation) ? unwrapContains(fieldValue) : (fieldValue as string | number | string[] | number[] | null | undefined)\n );\n\n const isNullOperation = operation === \"is-null\" || operation === \"is-not-null\";\n\n // A single picked value, `0` included: a truthiness check dropped a zero\n // id's clear button and rendered a stray \"0\" where it should have been.\n const hasSingleValue = internalValue !== undefined && internalValue !== null && !Array.isArray(internalValue);\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {\n // Null-testing operators ignore their value.\n if (op === \"is-null\" || op === \"is-not-null\") {\n setOperation(op);\n setInternalValue(null);\n setValue([op, null]);\n return;\n }\n\n // Substring matching: keep the raw text in the field, emit it wrapped\n // in SQL wildcards so the backend runs `column ILIKE '%value%'`.\n if (op === \"ilike\" || op === \"not-ilike\") {\n const raw = typeof val === \"string\" ? val : \"\";\n setOperation(op);\n setInternalValue(raw);\n if (raw.length > 0) {\n setValue([op, `%${raw}%`]);\n } else {\n setValue(undefined);\n }\n return;\n }\n\n let newValue = val;\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n if (prevOpIsArray !== newOpIsArray) {\n if (newOpIsArray) {\n if (typeof val === \"string\") newValue = [val];\n else if (typeof val === \"number\") newValue = [val];\n else newValue = [];\n } else {\n newValue = undefined;\n }\n }\n\n if (typeof newValue === \"number\" && isNaN(newValue))\n newValue = undefined;\n\n setOperation(op);\n setInternalValue(newValue);\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n\n return (\n\n <div className=\"flex w-full\">\n <div className={\"w-[100px]\"}>\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n position={\"item-aligned\"}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 flex flex-col gap-2\">\n\n {!enumValues && <TextField\n size={\"medium\"}\n aria-label={`${title ?? name} filter value`}\n type={type === \"number\" ? \"number\" : undefined}\n value={internalValue !== undefined && internalValue != null ? String(internalValue) : \"\"}\n disabled={isNullOperation}\n placeholder={isNullOperation ? \"null\" : undefined}\n onChange={(evt) => {\n const val = type === \"number\"\n ? parseFloat(evt.target.value)\n : evt.target.value;\n updateFilter(operation, val);\n }}\n endAdornment={internalValue !== undefined && internalValue != null && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n />}\n\n {enumValues && !multiple &&\n <Select\n size={\"medium\"}\n position={\"item-aligned\"}\n fullWidth={true}\n disabled={isNullOperation}\n // As a string whatever the enum's type: a number enum\n // holds the picked id as a number, which the select\n // read as no value at all and showed blank.\n value={hasSingleValue ? String(internalValue) : \"\"}\n onValueChange={(value) => {\n if (value !== \"\")\n updateFilter(operation, type === \"number\" ? parseInt(value as string) : value as string)\n }}\n endAdornment={hasSingleValue && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n renderValue={(enumKey) => {\n if (enumKey === null)\n return t(\"filter_for_null_values\");\n if (enumKey === undefined)\n return null;\n\n return <EnumValuesChip\n key={`select_value_${name}_${enumKey}`}\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"small\"}/>;\n }}>\n {enumValues.map((enumConfig) => (\n <SelectItem key={`select_item_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </SelectItem>\n ))}\n </Select>\n }\n\n {enumValues && multiple &&\n <MultiSelect\n size={\"medium\"}\n value={Array.isArray(internalValue) ? internalValue.map(e => String(e)) : []}\n disabled={isNullOperation}\n onValueChange={(value) => {\n updateFilter(operation, type === \"number\" ? (value ?? []).map(v => parseInt(v)) : value)\n }}\n >\n {enumValues.map((enumConfig) => (\n <MultiSelectItem key={`select_value_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n }\n\n </div>\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;AA+BA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,SAAS;CACT,aAAa;CACb,WAAW;CACX,eAAe;AACnB;AAEA,IA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f;IACG,CAAA;IAGX,cAAc,YACX,oBAAC,aAAD;KACI,MAAM;KACN,OAAO,MAAM,QAAQ,aAAa,IAAI,cAAc,KAAI,MAAK,OAAO,CAAC,CAAC,IAAI,CAAC;KAC3E,UAAU;KACV,gBAAgB,UAAU;MACtB,aAAa,WAAW,SAAS,YAAY,SAAS,CAAC,EAAA,CAAG,KAAI,MAAK,SAAS,CAAC,CAAC,IAAI,KAAK;KAC3F;eAEC,WAAW,KAAK,eACb,oBAAC,iBAAD;MACiB,OAAO,OAAO,WAAW,EAAE;gBACxC,oBAAC,gBAAD;OACI,SAAS,OAAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACN,GANK,gBAAgB,KAAK,GAAG,WAAW,IAMxC,CACpB;IACQ,CAAA;GAGhB;IAEJ;;AAGb"}
1
+ {"version":3,"file":"StringNumberFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/StringNumberFilterField.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport {\n IconButton,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n TextField,\n VirtualTableWhereFilterOp,\n XIcon\n} from \"@rebasepro/ui\";\nimport { EnumValueConfig } from \"@rebasepro/types\";\nimport { useTranslation } from \"@rebasepro/app\";\n\ninterface StringNumberFilterFieldProps {\n name: string,\n type: \"string\" | \"number\";\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (value?: [op: VirtualTableWhereFilterOp, newValue: unknown]) => void;\n isArray?: boolean;\n enumValues?: EnumValueConfig[];\n title?: string;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Any\",\n \"ilike\": \"Contains\",\n \"not-ilike\": \"Not contains\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/** Operators that match a substring, wrapped in SQL wildcards (`%value%`). */\nconst containsOperations = [\"ilike\", \"not-ilike\"];\n\n/** Strip the surrounding `%` wildcards a contains-filter adds, for display. */\nfunction unwrapContains(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/^%/, \"\").replace(/%$/, \"\");\n}\n\nexport function StringNumberFilterField({\n name,\n value,\n setValue,\n type,\n isArray,\n enumValues,\n title,\n operators\n }: StringNumberFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"is-null\", \"is-not-null\"];\n\n // Case-insensitive substring matching is only meaningful for free-text\n // string columns (not numbers, arrays, or enums).\n if (!isArray && !enumValues && type === \"string\") {\n possibleOperations.push(\"ilike\", \"not-ilike\");\n }\n\n if (enumValues) {\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n }\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n // Read back both the canonical null operators and the legacy `[\"==\", null]` /\n // `[\"!=\", null]` form saved by older filter presets.\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(\n fieldOperation === \"==\" && fieldValue === null ? \"is-null\"\n : fieldOperation === \"!=\" && fieldValue === null ? \"is-not-null\"\n : fieldOperation\n );\n const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(\n containsOperations.includes(fieldOperation) ? unwrapContains(fieldValue) : (fieldValue as string | number | string[] | number[] | null | undefined)\n );\n\n const isNullOperation = operation === \"is-null\" || operation === \"is-not-null\";\n\n // A single picked value, `0` included: a truthiness check dropped a zero\n // id's clear button and rendered a stray \"0\" where it should have been.\n const hasSingleValue = internalValue !== undefined && internalValue !== null && !Array.isArray(internalValue);\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {\n // Null-testing operators ignore their value.\n if (op === \"is-null\" || op === \"is-not-null\") {\n setOperation(op);\n setInternalValue(null);\n setValue([op, null]);\n return;\n }\n\n // Substring matching: keep the raw text in the field, emit it wrapped\n // in SQL wildcards so the backend runs `column ILIKE '%value%'`.\n if (op === \"ilike\" || op === \"not-ilike\") {\n const raw = typeof val === \"string\" ? val : \"\";\n setOperation(op);\n setInternalValue(raw);\n if (raw.length > 0) {\n setValue([op, `%${raw}%`]);\n } else {\n setValue(undefined);\n }\n return;\n }\n\n let newValue = val;\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n if (prevOpIsArray !== newOpIsArray) {\n if (newOpIsArray) {\n if (typeof val === \"string\") newValue = [val];\n else if (typeof val === \"number\") newValue = [val];\n else newValue = [];\n } else {\n newValue = undefined;\n }\n }\n\n if (typeof newValue === \"number\" && isNaN(newValue))\n newValue = undefined;\n\n setOperation(op);\n setInternalValue(newValue);\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n\n return (\n\n <div className=\"flex w-full\">\n <div className={\"w-[100px]\"}>\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n position={\"item-aligned\"}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 flex flex-col gap-2\">\n\n {!enumValues && <TextField\n size={\"medium\"}\n aria-label={`${title ?? name} filter value`}\n type={type === \"number\" ? \"number\" : undefined}\n value={internalValue !== undefined && internalValue != null ? String(internalValue) : \"\"}\n disabled={isNullOperation}\n placeholder={isNullOperation ? \"null\" : undefined}\n onChange={(evt) => {\n // Text typed and deleted again is no filter, not a\n // filter for the empty string.\n const val = evt.target.value === \"\"\n ? undefined\n : type === \"number\"\n ? parseFloat(evt.target.value)\n : evt.target.value;\n updateFilter(operation, val);\n }}\n endAdornment={internalValue !== undefined && internalValue != null && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n />}\n\n {enumValues && !multiple &&\n <Select\n size={\"medium\"}\n position={\"item-aligned\"}\n fullWidth={true}\n disabled={isNullOperation}\n // As a string whatever the enum's type: a number enum\n // holds the picked id as a number, which the select\n // read as no value at all and showed blank.\n value={hasSingleValue ? String(internalValue) : \"\"}\n onValueChange={(value) => {\n if (value !== \"\")\n updateFilter(operation, type === \"number\" ? parseFloat(value as string) : value as string)\n }}\n endAdornment={hasSingleValue && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n renderValue={(enumKey) => {\n if (enumKey === null)\n return t(\"filter_for_null_values\");\n if (enumKey === undefined)\n return null;\n\n return <EnumValuesChip\n key={`select_value_${name}_${enumKey}`}\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"small\"}/>;\n }}>\n {enumValues.map((enumConfig) => (\n <SelectItem key={`select_item_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </SelectItem>\n ))}\n </Select>\n }\n\n {enumValues && multiple &&\n <MultiSelect\n size={\"medium\"}\n value={Array.isArray(internalValue) ? internalValue.map(e => String(e)) : []}\n disabled={isNullOperation}\n onValueChange={(value) => {\n updateFilter(operation, type === \"number\" ? (value ?? []).map(v => parseFloat(v)) : value)\n }}\n >\n {enumValues.map((enumConfig) => (\n <MultiSelectItem key={`select_value_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n }\n\n </div>\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;AA+BA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,SAAS;CACT,aAAa;CACb,WAAW;CACX,eAAe;AACnB;AAEA,IAAM,2BAA2B;CAAC;CAAsB;CAAM;AAAQ;;AAGtE,IAAM,qBAAqB,CAAC,SAAS,WAAW;;AAGhD,SAAS,eAAe,OAAwB;CAC5C,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,MAAM,QAAQ,MAAM,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE;AACnD;AAEA,SAAgB,wBAAwB,EACI,MACA,OACA,UACA,MACA,SACA,YACA,OACA,aAC6B;CACrE,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,qBAAuD,UACrD,CAAC,gBAAgB,IACjB;EAAC;EAAM;EAAM;EAAK;EAAK;EAAM;EAAM;EAAW;CAAa;CAIjE,IAAI,CAAC,WAAW,CAAC,cAAc,SAAS,UACpC,mBAAmB,KAAK,SAAS,WAAW;CAGhD,IAAI,YACA,IAAI,SACA,mBAAmB,KAAK,oBAAoB;MAE5C,mBAAmB,KAAK,MAAM,QAAQ;CAI9C,IAAI,WACA,qBAAqB,mBAAmB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useMemo, useRef, useState } from "react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { ErrorBoundary, IconButton, Maximize2Icon, XIcon } from "@rebasepro/ui";
10
+ import { hasEntityId } from "@rebasepro/common";
10
11
  import { resolveDefaultSelectedView, useComponentOverride, useTranslation } from "@rebasepro/app";
11
12
  import { useNavigate } from "react-router";
12
13
  //#region src/components/SidePanelBinding.tsx
@@ -94,12 +95,12 @@ function SidePanelBinding(props) {
94
95
  const isDialogMode = collection?.openEntityMode === "dialog";
95
96
  const [editInDialog, setEditInDialog] = useState(false);
96
97
  const showEditInPanel = isDialogMode ? editInDialog : selectedTab === "edit";
97
- const isDetailMode = collection?.defaultEntityAction === "view" && !showEditInPanel && Boolean(entityId);
98
+ const isDetailMode = collection?.defaultEntityAction === "view" && !showEditInPanel && hasEntityId(entityId);
98
99
  useEffect(() => {
99
100
  setEditInDialog(false);
100
101
  }, [entityId]);
101
102
  const openEditView = useCallback(() => {
102
- if (isDialogMode || !entityId) {
103
+ if (isDialogMode || !hasEntityId(entityId)) {
103
104
  setEditInDialog(true);
104
105
  return;
105
106
  }
@@ -118,7 +119,7 @@ function SidePanelBinding(props) {
118
119
  sidePanelController
119
120
  ]);
120
121
  const closeEditView = useCallback(() => {
121
- if (isDialogMode || !entityId) {
122
+ if (isDialogMode || !hasEntityId(entityId)) {
122
123
  setEditInDialog(false);
123
124
  return;
124
125
  }
@@ -143,7 +144,7 @@ function SidePanelBinding(props) {
143
144
  useEffect(() => {
144
145
  if (hasCorrectedDefaultView.current) return;
145
146
  if (selectedTab) return;
146
- if (!entityId || !collection?.defaultSelectedView) return;
147
+ if (!hasEntityId(entityId) || !collection?.defaultSelectedView) return;
147
148
  const effectiveDefault = resolveDefaultSelectedView(collection.defaultSelectedView, {
148
149
  status: "existing",
149
150
  entityId
@@ -223,7 +224,7 @@ function SidePanelBinding(props) {
223
224
  className: "self-center",
224
225
  size: "small",
225
226
  onClick: () => {
226
- if (entityId) {
227
+ if (hasEntityId(entityId)) {
227
228
  const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);
228
229
  navigate(fullScreenUrl, { state: null });
229
230
  }
@@ -258,7 +259,7 @@ function SidePanelBinding(props) {
258
259
  carryEdit?.();
259
260
  setBlocked(false);
260
261
  setBlockedNavigationMessage(void 0);
261
- if (entityId) {
262
+ if (hasEntityId(entityId)) {
262
263
  const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);
263
264
  navigate(fullScreenUrl, { state: null });
264
265
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"SidePanelBinding.js","names":[],"sources":["../../src/components/SidePanelBinding.tsx"],"sourcesContent":["\nimport type { SidePanelBindingProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { IconButton, Maximize2Icon, XIcon } from \"@rebasepro/ui\";\nimport { EditViewBinding } from \"./EditViewBinding\";\nimport { DetailViewBinding } from \"./DetailViewBinding\";\nimport { useSideDialogContext } from \"./SideDialogs\";\nimport { useNavigate } from \"react-router\";\nimport { useComponentOverride, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { resolveDefaultSelectedView } from \"@rebasepro/app\";\n\n/**\n * This is the component in charge of rendering the side dialog used\n * for editing entities. Use the {@link useSidePanel} to open\n * and control the dialogs.\n * This component needs a parent {@link Rebase}\n * {@link useSidePanel}\n * @group Components\n */\nexport function SidePanelBinding(props: SidePanelBindingProps) {\n const { t } = useTranslation();\n\n const {\n allowFullScreen = true,\n path,\n entityId,\n selectedTab,\n formProps\n } = props;\n\n const ResolvedDetailView = useComponentOverride(\"DetailView\", DetailViewBinding);\n\n const {\n blocked,\n setBlocked,\n setBlockedNavigationMessage,\n close\n } = useSideDialogContext();\n\n const navigate = useNavigate();\n\n const sidePanelController = useSidePanel();\n const collectionRegistryController = useCollectionRegistryController();\n const sideDialogsController = useSideDialogContext();\n const urlController = useUrlController();\n\n /**\n * The X in the identity bar.\n *\n * Unforced, so it stops at the same unsaved-changes prompt that Escape and\n * a click outside already do. It used to clear `blocked` and force the\n * close, which made the one control actually labelled \"close\" the only way\n * out of the panel that dropped an edit without asking.\n *\n * `props.onClose` is not called here: the panel carries the same callback\n * (see `propsToSidePanel`) and {@link SideDialogs} fires it once the panel\n * really closes — which is after the prompt, not before it.\n */\n const onClose = () => {\n close();\n }\n\n /**\n * Closing because the record was just saved, which is the one case that has\n * to force. `blocked` is driven by an effect on the form's dirty flag and is\n * still true for a tick after a save; prompting about unsaved changes here\n * would be asking about values that are already on the server.\n */\n const closeAfterSave = () => {\n setBlocked(false);\n close(true);\n }\n\n /**\n * The panel's response to a save, and the one place it decides where the\n * panel goes next.\n *\n * Exactly **one** panel navigation is raised here. These branches used to\n * run independently — a `replace` onto the saved record's address *and* a\n * close — and because the last navigation is the one that survives, which\n * of them the user got was settled by statement order rather than by\n * intent. Closing wins by construction now: moving a panel to a new address\n * it is about to leave is work whose only effect is to fight the close.\n *\n * `props.onUpdate` runs last for the same reason. It belongs to whoever\n * opened the panel and it is free to navigate — the reference picker's\n * selects the record and closes the picker — so the opener's intent should\n * be the final word, not something this panel overwrites on its way out.\n */\n const onUpdate = (params: OnUpdateParams) => {\n setEditInDialog(false);\n\n // Either \"save and close\" was clicked, or the opener asked for it when\n // it opened the panel.\n const closeRequested = sideDialogsController.pendingClose || props.closeOnSave;\n\n if (closeRequested) {\n sideDialogsController.setPendingClose(false);\n closeAfterSave();\n } else if (params.status !== \"existing\") {\n // A newly created entity replaces the panel with its own address,\n // which already leaves the edit view behind.\n sidePanelController.replace({\n path: params.path,\n entityId: params.entityId,\n selectedTab: params.selectedTab,\n updateUrl: collection?.openEntityMode !== \"dialog\",\n collection: params.collection\n });\n } else {\n closeEditView();\n }\n\n props.onUpdate?.(params);\n }\n\n const parentCollectionSlugs = useMemo(() => {\n return collectionRegistryController.getParentCollectionSlugs(path);\n }, [collectionRegistryController, path]);\n\n const parentEntityIds = useMemo(() => {\n return collectionRegistryController.getParentEntityIds(path);\n }, [collectionRegistryController, path]);\n\n const collection = collectionRegistryController.getCollection(path) ?? props.collection;\n\n // Dialog mode deliberately stays out of the URL, so it is the only case that\n // needs local edit state. Everywhere else `edit` is a path segment, which\n // keeps refresh and the back button working the same way they do in split.\n const isDialogMode = collection?.openEntityMode === \"dialog\";\n const [editInDialog, setEditInDialog] = useState(false);\n const showEditInPanel = isDialogMode ? editInDialog : selectedTab === \"edit\";\n const isDetailMode = collection?.defaultEntityAction === \"view\" && !showEditInPanel && Boolean(entityId);\n\n // Reset edit mode when switching entities\n useEffect(() => {\n setEditInDialog(false);\n }, [entityId]);\n\n const openEditView = useCallback(() => {\n if (isDialogMode || !entityId) {\n setEditInDialog(true);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: \"edit\",\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n const closeEditView = useCallback(() => {\n if (isDialogMode || !entityId) {\n setEditInDialog(false);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: undefined,\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n // One-time correction: when the side panel opens without the correct\n // selectedTab but the resolved collection (from the registry) has a\n // defaultSelectedView, update the panel width and URL to match.\n // This handles cases where defaultSelectedView is set via the collection\n // editor / Studio and is not available on the collection object the\n // caller passed to sidePanelController.open().\n const hasCorrectedDefaultView = useRef(false);\n useEffect(() => {\n hasCorrectedDefaultView.current = false;\n }, [entityId]);\n useEffect(() => {\n if (hasCorrectedDefaultView.current) return;\n if (selectedTab) return; // Already has a tab — no correction needed\n if (!entityId || !collection?.defaultSelectedView) return;\n\n const effectiveDefault = resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n );\n if (effectiveDefault && effectiveDefault !== \"edit\") {\n hasCorrectedDefaultView.current = true;\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: effectiveDefault,\n updateUrl: collection.openEntityMode !== \"dialog\",\n collection\n });\n }\n }, [selectedTab, entityId, collection, path, sidePanelController]);\n\n // Note: beforeunload is handled by useUnsavedChangesDialog in SideDialogView,\n // which listens to the same `blocked` state via SideDialogContext.\n\n const onValuesModified = useCallback((modified: boolean) => {\n setBlockedNavigationMessage(modified\n ? <> You have unsaved changes in this <b>{collection?.singularName ?? collection?.name}</b>.</>\n : undefined)\n setBlocked(modified);\n }, [collection?.name, setBlocked, setBlockedNavigationMessage]);\n\n if (!props || !collection) {\n return <div className={\"w-full\"}/>;\n }\n\n const closeButton = (\n <IconButton aria-label={t(\"close\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={onClose}>\n <XIcon/>\n </IconButton>\n );\n\n /**\n * Where the panel's own two controls sit, which is not the same question in\n * the two layouts that have them.\n *\n * A **side panel** slides in over the list from the right, and its leading\n * edge is the seam between the two. Close belongs on that seam — it points\n * back at the thing still visible behind it — and it is where the eye\n * already is, because the breadcrumb starts there.\n *\n * A **dialog** has no seam and nothing behind it to point at. It is a box\n * centred on a dimmed screen, and every box like it on every platform is\n * dismissed from its top-right corner. Close was sitting at the far left\n * of the bar, a full dialog's width from the expand button it belongs\n * beside, in the one corner that means \"back\" in a layout with no back.\n *\n * So in a dialog the two travel together at the trailing edge, expand then\n * close: the window controls, after the record's actions and its overflow\n * menu, in the corner a dialog is closed from.\n */\n const barActionsStart = isDialogMode ? undefined : closeButton;\n\n const windowControls = (expandButton: React.ReactNode) => (\n <div className=\"flex gap-1 items-center\">\n {expandButton}\n {isDialogMode && closeButton}\n </div>\n );\n\n return (\n <>\n <ErrorBoundary>\n {isDetailMode\n ? <ResolvedDetailView\n path={path}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n entityId={entityId!}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n onEditClick={openEditView}\n barActionsStart={barActionsStart}\n barActions={() => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n if (entityId) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n />\n : <EditViewBinding\n {...props}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n onValuesModified={onValuesModified}\n onSaved={onUpdate}\n navigateBack={closeEditView}\n barActionsStart={barActionsStart}\n barActions={({ carryEdit }) => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n // The form's own handoff, rather than a second\n // copy of the rules for it here: only an edit in\n // progress is worth carrying (a clean record\n // stashed anyway arrived announcing unsaved\n // changes to someone who had only looked at it),\n // and only the fields that were edited (carrying\n // the whole record marked every field touched).\n carryEdit?.();\n setBlocked(false);\n setBlockedNavigationMessage(undefined);\n if (entityId) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n } else {\n const fullScreenUrl = urlController.buildUrlCollectionPath(path);\n navigate(fullScreenUrl + \"#new\", { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n formProps={formProps}\n />\n }\n </ErrorBoundary>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,iBAAiB,OAA8B;CAC3D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,kBAAkB,MAClB,MACA,UACA,aACA,cACA;CAEJ,MAAM,qBAAqB,qBAAqB,cAAc,iBAAiB;CAE/E,MAAM,EACF,SACA,YACA,6BACA,UACA,qBAAqB;CAEzB,MAAM,WAAW,YAAY;CAE7B,MAAM,sBAAsB,aAAa;CACzC,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,wBAAwB,qBAAqB;CACnD,MAAM,gBAAgB,iBAAiB;;;;;;;;;;;;;CAcvC,MAAM,gBAAgB;EAClB,MAAM;CACV;;;;;;;CAQA,MAAM,uBAAuB;EACzB,WAAW,KAAK;EAChB,MAAM,IAAI;CACd;;;;;;;;;;;;;;;;;CAkBA,MAAM,YAAY,WAA2B;EACzC,gBAAgB,KAAK;EAMrB,IAFuB,sBAAsB,gBAAgB,MAAM,aAE/C;GAChB,sBAAsB,gBAAgB,KAAK;GAC3C,eAAe;EACnB,OAAO,IAAI,OAAO,WAAW,YAGzB,oBAAoB,QAAQ;GACxB,MAAM,OAAO;GACb,UAAU,OAAO;GACjB,aAAa,OAAO;GACpB,WAAW,YAAY,mBAAmB;GAC1C,YAAY,OAAO;EACvB,CAAC;OAED,cAAc;EAGlB,MAAM,WAAW,MAAM;CAC3B;CAEA,MAAM,wBAAwB,cAAc;EACxC,OAAO,6BAA6B,yBAAyB,I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,sBACV;GACF,IAAI,YAAY,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,UAAU;IACV;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;CACH,CAAA,IACC,oBAAC,iBAAD;EACE,GAAI;EACJ,QAAQ,YAAY,mBAAmB,WAAW,WAAW;EACjD;EACW;EAAwC;EAC7C;EAClB,SAAS;EACT,cAAc;EACG;EACjB,aAAa,EAAE,gBAAgB,eAC3B,mBAAmB,oBAAC,YAAD;GAAY,cAAY,EAAE,aAAa;GACtD,WAAU;GACV,MAAM;GACN,eAAe;IAQX,YAAY;IACZ,WAAW,KAAK;IAChB,4BAA4B,KAAA,CAAS;IACrC,IAAI,UAAU;KACV,MAAM,gBAAgB,cAAc,uBAAuB,GAAG,KAAK,GAAG,UAAU;KAChF,SAAS,eAAe,EAAE,OAAO,KAAK,CAAC;IAC3C,OAAO;KACH,MAAM,gBAAgB,cAAc,uBAAuB,IAAI;KAC/D,SAAS,gBAAgB,QAAQ,EAAE,OAAO,KAAK,CAAC;IACpD;GACJ;aACA,oBAAC,eAAD,CAAe,CAAA;EACP,CAAA,CAChB;EACA,cAAc,EACV,UAAU,aACV,aACA,YAAY,sBACV;GACF,IAAI,YAAY,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,UAAU;IACV;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;EACW;CACd,CAAA,EAEM,CAAA,EAEjB,CAAA;AAEV"}
1
+ {"version":3,"file":"SidePanelBinding.js","names":[],"sources":["../../src/components/SidePanelBinding.tsx"],"sourcesContent":["\nimport type { SidePanelBindingProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { IconButton, Maximize2Icon, XIcon } from \"@rebasepro/ui\";\nimport { EditViewBinding } from \"./EditViewBinding\";\nimport { DetailViewBinding } from \"./DetailViewBinding\";\nimport { useSideDialogContext } from \"./SideDialogs\";\nimport { useNavigate } from \"react-router\";\nimport { useComponentOverride, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { resolveDefaultSelectedView } from \"@rebasepro/app\";\n\n/**\n * This is the component in charge of rendering the side dialog used\n * for editing entities. Use the {@link useSidePanel} to open\n * and control the dialogs.\n * This component needs a parent {@link Rebase}\n * {@link useSidePanel}\n * @group Components\n */\nexport function SidePanelBinding(props: SidePanelBindingProps) {\n const { t } = useTranslation();\n\n const {\n allowFullScreen = true,\n path,\n entityId,\n selectedTab,\n formProps\n } = props;\n\n const ResolvedDetailView = useComponentOverride(\"DetailView\", DetailViewBinding);\n\n const {\n blocked,\n setBlocked,\n setBlockedNavigationMessage,\n close\n } = useSideDialogContext();\n\n const navigate = useNavigate();\n\n const sidePanelController = useSidePanel();\n const collectionRegistryController = useCollectionRegistryController();\n const sideDialogsController = useSideDialogContext();\n const urlController = useUrlController();\n\n /**\n * The X in the identity bar.\n *\n * Unforced, so it stops at the same unsaved-changes prompt that Escape and\n * a click outside already do. It used to clear `blocked` and force the\n * close, which made the one control actually labelled \"close\" the only way\n * out of the panel that dropped an edit without asking.\n *\n * `props.onClose` is not called here: the panel carries the same callback\n * (see `propsToSidePanel`) and {@link SideDialogs} fires it once the panel\n * really closes — which is after the prompt, not before it.\n */\n const onClose = () => {\n close();\n }\n\n /**\n * Closing because the record was just saved, which is the one case that has\n * to force. `blocked` is driven by an effect on the form's dirty flag and is\n * still true for a tick after a save; prompting about unsaved changes here\n * would be asking about values that are already on the server.\n */\n const closeAfterSave = () => {\n setBlocked(false);\n close(true);\n }\n\n /**\n * The panel's response to a save, and the one place it decides where the\n * panel goes next.\n *\n * Exactly **one** panel navigation is raised here. These branches used to\n * run independently — a `replace` onto the saved record's address *and* a\n * close — and because the last navigation is the one that survives, which\n * of them the user got was settled by statement order rather than by\n * intent. Closing wins by construction now: moving a panel to a new address\n * it is about to leave is work whose only effect is to fight the close.\n *\n * `props.onUpdate` runs last for the same reason. It belongs to whoever\n * opened the panel and it is free to navigate — the reference picker's\n * selects the record and closes the picker — so the opener's intent should\n * be the final word, not something this panel overwrites on its way out.\n */\n const onUpdate = (params: OnUpdateParams) => {\n setEditInDialog(false);\n\n // Either \"save and close\" was clicked, or the opener asked for it when\n // it opened the panel.\n const closeRequested = sideDialogsController.pendingClose || props.closeOnSave;\n\n if (closeRequested) {\n sideDialogsController.setPendingClose(false);\n closeAfterSave();\n } else if (params.status !== \"existing\") {\n // A newly created entity replaces the panel with its own address,\n // which already leaves the edit view behind.\n sidePanelController.replace({\n path: params.path,\n entityId: params.entityId,\n selectedTab: params.selectedTab,\n updateUrl: collection?.openEntityMode !== \"dialog\",\n collection: params.collection\n });\n } else {\n closeEditView();\n }\n\n props.onUpdate?.(params);\n }\n\n const parentCollectionSlugs = useMemo(() => {\n return collectionRegistryController.getParentCollectionSlugs(path);\n }, [collectionRegistryController, path]);\n\n const parentEntityIds = useMemo(() => {\n return collectionRegistryController.getParentEntityIds(path);\n }, [collectionRegistryController, path]);\n\n const collection = collectionRegistryController.getCollection(path) ?? props.collection;\n\n // Dialog mode deliberately stays out of the URL, so it is the only case that\n // needs local edit state. Everywhere else `edit` is a path segment, which\n // keeps refresh and the back button working the same way they do in split.\n const isDialogMode = collection?.openEntityMode === \"dialog\";\n const [editInDialog, setEditInDialog] = useState(false);\n const showEditInPanel = isDialogMode ? editInDialog : selectedTab === \"edit\";\n const isDetailMode = collection?.defaultEntityAction === \"view\" && !showEditInPanel && hasEntityId(entityId);\n\n // Reset edit mode when switching entities\n useEffect(() => {\n setEditInDialog(false);\n }, [entityId]);\n\n const openEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(true);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: \"edit\",\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n const closeEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(false);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: undefined,\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n // One-time correction: when the side panel opens without the correct\n // selectedTab but the resolved collection (from the registry) has a\n // defaultSelectedView, update the panel width and URL to match.\n // This handles cases where defaultSelectedView is set via the collection\n // editor / Studio and is not available on the collection object the\n // caller passed to sidePanelController.open().\n const hasCorrectedDefaultView = useRef(false);\n useEffect(() => {\n hasCorrectedDefaultView.current = false;\n }, [entityId]);\n useEffect(() => {\n if (hasCorrectedDefaultView.current) return;\n if (selectedTab) return; // Already has a tab — no correction needed\n if (!hasEntityId(entityId) || !collection?.defaultSelectedView) return;\n\n const effectiveDefault = resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n );\n if (effectiveDefault && effectiveDefault !== \"edit\") {\n hasCorrectedDefaultView.current = true;\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: effectiveDefault,\n updateUrl: collection.openEntityMode !== \"dialog\",\n collection\n });\n }\n }, [selectedTab, entityId, collection, path, sidePanelController]);\n\n // Note: beforeunload is handled by useUnsavedChangesDialog in SideDialogView,\n // which listens to the same `blocked` state via SideDialogContext.\n\n const onValuesModified = useCallback((modified: boolean) => {\n setBlockedNavigationMessage(modified\n ? <> You have unsaved changes in this <b>{collection?.singularName ?? collection?.name}</b>.</>\n : undefined)\n setBlocked(modified);\n }, [collection?.name, setBlocked, setBlockedNavigationMessage]);\n\n if (!props || !collection) {\n return <div className={\"w-full\"}/>;\n }\n\n const closeButton = (\n <IconButton aria-label={t(\"close\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={onClose}>\n <XIcon/>\n </IconButton>\n );\n\n /**\n * Where the panel's own two controls sit, which is not the same question in\n * the two layouts that have them.\n *\n * A **side panel** slides in over the list from the right, and its leading\n * edge is the seam between the two. Close belongs on that seam — it points\n * back at the thing still visible behind it — and it is where the eye\n * already is, because the breadcrumb starts there.\n *\n * A **dialog** has no seam and nothing behind it to point at. It is a box\n * centred on a dimmed screen, and every box like it on every platform is\n * dismissed from its top-right corner. Close was sitting at the far left\n * of the bar, a full dialog's width from the expand button it belongs\n * beside, in the one corner that means \"back\" in a layout with no back.\n *\n * So in a dialog the two travel together at the trailing edge, expand then\n * close: the window controls, after the record's actions and its overflow\n * menu, in the corner a dialog is closed from.\n */\n const barActionsStart = isDialogMode ? undefined : closeButton;\n\n const windowControls = (expandButton: React.ReactNode) => (\n <div className=\"flex gap-1 items-center\">\n {expandButton}\n {isDialogMode && closeButton}\n </div>\n );\n\n return (\n <>\n <ErrorBoundary>\n {isDetailMode\n ? <ResolvedDetailView\n path={path}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n entityId={entityId!}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n onEditClick={openEditView}\n barActionsStart={barActionsStart}\n barActions={() => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n />\n : <EditViewBinding\n {...props}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n onValuesModified={onValuesModified}\n onSaved={onUpdate}\n navigateBack={closeEditView}\n barActionsStart={barActionsStart}\n barActions={({ carryEdit }) => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n // The form's own handoff, rather than a second\n // copy of the rules for it here: only an edit in\n // progress is worth carrying (a clean record\n // stashed anyway arrived announcing unsaved\n // changes to someone who had only looked at it),\n // and only the fields that were edited (carrying\n // the whole record marked every field touched).\n carryEdit?.();\n setBlocked(false);\n setBlockedNavigationMessage(undefined);\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n } else {\n const fullScreenUrl = urlController.buildUrlCollectionPath(path);\n navigate(fullScreenUrl + \"#new\", { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n formProps={formProps}\n />\n }\n </ErrorBoundary>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,iBAAiB,OAA8B;CAC3D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,kBAAkB,MAClB,MACA,UACA,aACA,cACA;CAEJ,MAAM,qBAAqB,qBAAqB,cAAc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4BAA4B,KAAA,CAAS;IACrC,IAAI,YAAY,QAAQ,GAAG;KACvB,MAAM,gBAAgB,cAAc,uBAAuB,GAAG,KAAK,GAAG,UAAU;KAChF,SAAS,eAAe,EAAE,OAAO,KAAK,CAAC;IAC3C,OAAO;KACH,MAAM,gBAAgB,cAAc,uBAAuB,IAAI;KAC/D,SAAS,gBAAgB,QAAQ,EAAE,OAAO,KAAK,CAAC;IACpD;GACJ;aACA,oBAAC,eAAD,CAAe,CAAA;EACP,CAAA,CAChB;EACA,cAAc,EACV,UAAU,aACV,aACA,YAAY,sBACV;GACF,IAAI,YAAY,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,UAAU;IACV;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;EACW;CACd,CAAA,EAEM,CAAA,EAEjB,CAAA;AAEV"}
@@ -111,6 +111,7 @@ var Scaffold = React.memo(function Scaffold(props) {
111
111
  const computedDrawerOpen = drawerOpen;
112
112
  const computedDrawerHovered = Boolean(largeLayout && onHover);
113
113
  const hasAppBar = Boolean(appBarChildren.length > 0);
114
+ const menuButtonRow = Boolean(includeDrawer) && !largeLayout && !hasAppBar;
114
115
  const appContextValue = useMemo(() => ({
115
116
  hasDrawer: Boolean(includeDrawer),
116
117
  drawerOpen: computedDrawerOpen,
@@ -150,12 +151,14 @@ var Scaffold = React.memo(function Scaffold(props) {
150
151
  open: drawerOpen,
151
152
  hovered: onHover,
152
153
  setDrawerOpen,
154
+ floatingMenuButton: !menuButtonRow,
153
155
  children: includeDrawer && drawerChildren
154
156
  }),
155
157
  /* @__PURE__ */ jsxs("main", {
156
158
  className: "flex flex-col grow overflow-auto",
157
159
  children: [
158
160
  hasAppBar && /* @__PURE__ */ jsx(DrawerHeader, {}),
161
+ menuButtonRow && /* @__PURE__ */ jsx(MenuButtonRow, { onOpen: handleDrawerOpen }),
159
162
  /* @__PURE__ */ jsx(ConnectionLostBanner, { className: cls("px-2 pt-1", {
160
163
  "lg:pt-0 lg:pb-2": padding,
161
164
  "lg:pt-2": !hasAppBar && padding
@@ -181,6 +184,18 @@ var Scaffold = React.memo(function Scaffold(props) {
181
184
  var DrawerHeader = () => {
182
185
  return /* @__PURE__ */ jsx("div", { className: "flex flex-col min-h-14" });
183
186
  };
187
+ /** The small-layout menu button, in the flow above the sheet. */
188
+ function MenuButtonRow({ onOpen }) {
189
+ const { t } = useTranslation();
190
+ return /* @__PURE__ */ jsx("div", {
191
+ className: "flex items-center shrink-0 px-2 sm:px-4 pt-1",
192
+ children: /* @__PURE__ */ jsx(IconButton, {
193
+ "aria-label": t("open_menu"),
194
+ onClick: onOpen,
195
+ children: /* @__PURE__ */ jsx(MenuIcon, {})
196
+ })
197
+ });
198
+ }
184
199
  function DrawerWrapper(props) {
185
200
  const layoutWidth = !props.displayed ? 0 : props.open ? 280 : 72;
186
201
  const visualWidth = !props.displayed ? 0 : props.open || props.hovered ? 280 : 72;
@@ -199,7 +214,7 @@ function DrawerWrapper(props) {
199
214
  });
200
215
  if (!useLargeLayout()) {
201
216
  if (!props.displayed) return null;
202
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconButton, {
217
+ return /* @__PURE__ */ jsxs(Fragment, { children: [props.floatingMenuButton && /* @__PURE__ */ jsx(IconButton, {
203
218
  "aria-label": t("open_menu"),
204
219
  onClick: () => props.setDrawerOpen(true),
205
220
  className: "absolute sm:top-2 sm:left-4 top-1 left-2",
@@ -1 +1 @@
1
- {"version":3,"file":"Scaffold.js","names":[],"sources":["../../../src/components/app/Scaffold.tsx"],"sourcesContent":["import React, { PropsWithChildren, useCallback, useMemo } from \"react\";\nimport { cls, defaultBorderMixin, IconButton, Sheet, Tooltip } from \"@rebasepro/ui\";\nimport { ChevronLeftIcon, ErrorBoundary, MenuIcon } from \"@rebasepro/ui\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ConnectionLostBanner, RlsSimulationBanner, useLargeLayout, useTranslation } from \"@rebasepro/app\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { AppContext } from \"./useApp\";\n\nexport const DRAWER_WIDTH = 280;\n\n/**\n * Namespaced by base path: two admins served from one origin are two different\n * navigations, and a single key would have them overwrite each other's drawer.\n */\nexport function drawerOpenStorageKey(basePath: string | undefined) {\n return `rebase-drawer-open:${basePath || \"/\"}`;\n}\n\n/** `null` when the user has never toggled the drawer, or storage is unavailable. */\nfunction readStoredDrawerOpen(key: string): boolean | null {\n if (typeof window === \"undefined\") return null;\n try {\n const stored = window.localStorage.getItem(key);\n return stored === null ? null : stored === \"true\";\n } catch (e) {\n // Storage can be blocked: private mode, sandboxed iframe, cookie policy.\n return null;\n }\n}\n\nfunction writeStoredDrawerOpen(key: string, open: boolean) {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(key, String(open));\n } catch (e) {\n // Same as above: a drawer that forgets is better than a crash.\n }\n}\n\n/**\n * @group Core\n */\nexport interface ScaffoldProps {\n\n /**\n * Expand the collapsed drawer while the pointer is over it. On by default —\n * pass `false` to keep the rail a rail until the user clicks the toggle.\n */\n autoOpenDrawer?: boolean;\n\n /**\n * Start with the drawer expanded rather than collapsed to icons.\n *\n * Distinct from {@link autoOpenDrawer}, which is a hover behaviour: this one\n * only seeds the very first visit. Once the user toggles the drawer, that\n * choice is stored in `localStorage` and wins over this prop on every load.\n *\n * Ignored on small layouts, where an expanded drawer covers the content it is\n * meant to navigate.\n */\n defaultDrawerOpen?: boolean;\n\n /**\n * Logo to be displayed in the top bar and drawer.\n * Note that this has no effect if you are using a custom AppBar or Drawer.\n */\n logo?: string;\n\n /**\n * If true, the main content will be padded in large layouts. Defaults to true.\n */\n padding?: boolean;\n\n className?: string;\n\n style?: React.CSSProperties;\n}\n\n/**\n * This view acts as a scaffold for Rebase.\n *\n * It is in charge of displaying the navigation drawer, top bar and main\n * collection views.\n * This component needs a parent {@link Rebase}\n *\n * @param props\n\n * @group Core\n */\nexport const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(\n function Scaffold(props: PropsWithChildren<ScaffoldProps>) {\n\n const {\n children,\n autoOpenDrawer = true,\n defaultDrawerOpen = false,\n logo,\n className,\n style,\n padding = true\n } = props;\n\n // `toArray` keeps strings and numbers, and those have no `.type` at all.\n // Reading `child.type.componentType` off one threw a TypeError from\n // inside the layout, which is a bewildering way to be told that a stray\n // text node — a conditional that rendered `\"\"`, a template string —\n // reached the Scaffold. Anything that is not an element is just \"other\".\n const slotOf = (child: React.ReactNode): string | undefined =>\n React.isValidElement(child)\n ? (child.type as { componentType?: string })?.componentType\n : undefined;\n\n const childArray = React.Children.toArray(children);\n const drawerChildren = childArray.filter((child) => slotOf(child) === \"Drawer\");\n if (drawerChildren.length > 1) {\n throw Error(\"Only one Drawer component is allowed in Scaffold\");\n }\n const appBarChildren = childArray.filter((child) => slotOf(child) === \"AppBar\");\n if (appBarChildren.length > 1) {\n throw Error(\"Only one AppBar component is allowed in Scaffold\");\n }\n const otherChildren = childArray\n .filter((child) => slotOf(child) !== \"Drawer\" && slotOf(child) !== \"AppBar\");\n const includeDrawer = drawerChildren.length > 0;\n const largeLayout = useLargeLayout();\n\n const storageKey = drawerOpenStorageKey(useUrlController().basePath);\n\n // Seeded once, deliberately: a `useEffect` syncing this to the prop would\n // re-expand the drawer under a user who had just collapsed it.\n const [drawerOpen, setDrawerOpenState] = React.useState(defaultDrawerOpen && largeLayout);\n const [onHover, setOnHover] = React.useState(false);\n\n // The stored choice is a client-only fact, so it is applied after the first\n // render rather than seeded into it: reading storage while rendering would\n // make the client disagree with server-rendered HTML. A layout effect runs\n // before paint, so the drawer still arrives in its remembered state.\n // `defaultDrawerOpen` seeds the very first visit and is ignored after that.\n React.useLayoutEffect(() => {\n const stored = readStoredDrawerOpen(storageKey);\n if (stored === null) return;\n setDrawerOpenState(stored && largeLayout);\n // Deliberately not re-run on `largeLayout`: crossing the breakpoint is\n // the effect below, and re-running here would undo a user's toggle.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [storageKey]);\n\n // One piece of state drives two different things: the expanded rail on\n // large layouts, and the modal sheet on small ones. Carrying an expanded\n // rail across the breakpoint would drop that sheet, overlay and all, over\n // the content — so the crossing resets it, and widening again restores\n // whatever the user last chose.\n const wasLargeLayout = React.useRef(largeLayout);\n React.useEffect(() => {\n if (wasLargeLayout.current === largeLayout) return;\n wasLargeLayout.current = largeLayout;\n setDrawerOpenState(largeLayout ? (readStoredDrawerOpen(storageKey) ?? defaultDrawerOpen) : false);\n }, [largeLayout, defaultDrawerOpen, storageKey]);\n\n const setDrawerOpen = useCallback((open: boolean) => {\n setDrawerOpenState(open);\n // Small layouts render the drawer as a modal sheet. Remembering that\n // one would greet the next load with an overlay over the content.\n if (!largeLayout) return;\n writeStoredDrawerOpen(storageKey, open);\n }, [largeLayout, storageKey]);\n\n // The pointer has left, but a popover the drawer opened is still up, so the\n // collapse is owed rather than cancelled. See `setOnHoverFalse`.\n const collapseWhenPopoverCloses = React.useRef(false);\n\n const setOnHoverTrue = useCallback(() => {\n // Hover expansion is the default; `autoOpenDrawer={false}` opts out for\n // admins that want the rail to stay a rail until the toggle is clicked.\n if (!autoOpenDrawer) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(true);\n }, [autoOpenDrawer]);\n const setOnHoverFalse = useCallback(() => {\n // Don't collapse the drawer out from under an open popover/dropdown —\n // its content is portalled outside the drawer, so reaching for it reads\n // as a mouseleave. The collapse is owed until that popover closes.\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) {\n collapseWhenPopoverCloses.current = true;\n return;\n }\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n }, []);\n\n // Nothing fires a second mouseleave when the popover finally closes, so the\n // owed collapse has to be noticed rather than waited for. Only mounted\n // while the drawer is actually floating open.\n React.useEffect(() => {\n if (!onHover) return;\n const collapseIfOwed = () => {\n if (!collapseWhenPopoverCloses.current) return;\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n };\n const observer = new MutationObserver(collapseIfOwed);\n observer.observe(document.body, {\n childList: true,\n subtree: true\n });\n return () => observer.disconnect();\n }, [onHover]);\n\n const handleDrawerOpen = useCallback(() => {\n setDrawerOpen(true);\n }, [setDrawerOpen]);\n\n const handleDrawerClose = useCallback(() => {\n setDrawerOpen(false);\n }, [setDrawerOpen]);\n\n const computedDrawerOpen: boolean = drawerOpen;\n const computedDrawerHovered = Boolean(largeLayout && onHover);\n\n const hasAppBar = Boolean(appBarChildren.length > 0);\n const appContextValue = useMemo(() => ({\n hasDrawer: Boolean(includeDrawer),\n drawerOpen: computedDrawerOpen,\n drawerHovered: computedDrawerHovered,\n openDrawer: handleDrawerOpen,\n closeDrawer: handleDrawerClose,\n closeHover: setOnHoverFalse,\n logo\n }), [includeDrawer, computedDrawerOpen, computedDrawerHovered, handleDrawerOpen, handleDrawerClose, setOnHoverFalse, logo]);\n\n return (\n <AppContext.Provider value={appContextValue}>\n <div\n className={cls(\"flex h-screen w-screen overflow-hidden\",\n \"bg-surface-frame\",\n \"text-surface-900 dark:text-white\", className)}\n style={{\n paddingTop: \"env(safe-area-inset-top)\",\n paddingLeft: \"env(safe-area-inset-left)\",\n paddingRight: \"env(safe-area-inset-right)\",\n paddingBottom: \"env(safe-area-inset-bottom)\",\n height: \"100dvh\",\n ...style\n }}>\n {appBarChildren}\n\n <DrawerWrapper\n displayed={includeDrawer}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n open={drawerOpen}\n hovered={onHover}\n setDrawerOpen={setDrawerOpen}>\n {includeDrawer && drawerChildren}\n </DrawerWrapper>\n\n <main\n className=\"flex flex-col grow overflow-auto\">\n\n {hasAppBar && <DrawerHeader/>}\n\n {/* Above the sheet, so it is there on every screen: while\n the realtime connection is down, every live view is\n showing what it last received. */}\n <ConnectionLostBanner className={cls(\"px-2 pt-1\", {\n \"lg:pt-0 lg:pb-2\": padding,\n \"lg:pt-2\": !hasAppBar && padding\n })}/>\n\n {/* While access is simulated, every data view shows\n another identity's rows: say so on every screen. */}\n <RlsSimulationBanner className={cls(\"px-2 pt-1\", {\n \"lg:pt-0 lg:pb-2\": padding,\n \"lg:pt-2\": !hasAppBar && padding\n })}/>\n\n <div\n // The sheet is one lightness step above the frame AND carries a\n // plain hairline on its edge. The step alone (#090a0c to #111316,\n // #eff0f3 to #f8f9fa) is about 3 L* on both themes, under what a\n // dimmed screen renders, and the first pass of this system removed\n // the line on the theory that the step would do its work; the\n // frame and the sheet then read as one black. The reference's own\n // content sheet carries this line. Only in the inset `lg` layout:\n // edge-to-edge on small screens, a border draws at the viewport.\n className={cls(\"bg-surface-sheet\", \"grow overflow-auto m-0\", \"lg:border lg:border-hairline\", {\n \"mt-1 lg:m-0 lg:mx-2 lg:mb-2 lg:rounded-xl\": padding,\n // No app bar means no DrawerHeader spacer above, so inset the\n // panel by the same amount as its sides and bottom.\n // Must come after the padding classes, which reset lg margins.\n \"lg:mt-2\": !hasAppBar && padding,\n \"lg:mt-4\": !hasAppBar && !padding\n })}>\n\n <ErrorBoundary>\n {otherChildren}\n </ErrorBoundary>\n\n </div>\n </main>\n </div>\n </AppContext.Provider>\n );\n },\n equal\n)\n\nconst DrawerHeader = () => {\n return (\n <div className=\"flex flex-col min-h-14\"></div>\n );\n};\n\nfunction DrawerWrapper(props: {\n children: React.ReactNode,\n displayed: boolean,\n open: boolean,\n logo?: string,\n hovered: boolean,\n setDrawerOpen: (open: boolean) => void,\n onMouseEnter: () => void,\n onMouseMove: () => void,\n onMouseLeave: () => void\n}) {\n\n const layoutWidth = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);\n const visualWidth = !props.displayed ? 0 : ((props.open || props.hovered) ? DRAWER_WIDTH : 72);\n\n const isFloating = props.hovered && !props.open;\n const { t } = useTranslation();\n\n // The drawer is part of the frame, on both themes. When it floats over the\n // sheet it needs an edge, because a frame-coloured panel over the sheet is\n // an object at that moment; docked, it is a region and gets none.\n const innerDrawer = <div\n className={cls(\"h-full overflow-hidden bg-surface-frame\", defaultBorderMixin,\n isFloating ? \"absolute top-0 left-0 bottom-0 z-50 shadow-lg border-r\" : \"relative\")}\n style={{\n width: visualWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}\n >\n\n <div className={\"flex flex-col h-full\"}>\n {props.children}\n </div>\n\n </div>;\n\n const largeLayout = useLargeLayout();\n if (!largeLayout) {\n if (!props.displayed)\n return null;\n return <>\n <IconButton\n aria-label={t(\"open_menu\")}\n onClick={() => props.setDrawerOpen(true)}\n className=\"absolute sm:top-2 sm:left-4 top-1 left-2\"\n >\n <MenuIcon/>\n </IconButton>\n <Sheet side={\"left\"}\n transparent={true}\n open={props.open}\n onOpenChange={props.setDrawerOpen}\n title={t(\"navigation_drawer\")}\n overlayClassName={\"bg-surface-scrim\"}\n >\n {innerDrawer}\n </Sheet>\n </>;\n }\n\n return (\n <div\n className=\"z-20 relative flex-shrink-0 overflow-visible\"\n onMouseEnter={props.onMouseEnter}\n onMouseMove={props.onMouseMove}\n onMouseLeave={props.onMouseLeave}\n style={{\n width: layoutWidth,\n minWidth: layoutWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}>\n\n {innerDrawer}\n\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,qBAAqB,UAA8B;CAC/D,OAAO,sBAAsB,YAAY;AAC7C;;AAGA,SAAS,qBAAqB,KAA6B;CACvD,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,IAAI;EACA,MAAM,SAAS,OAAO,aAAa,QAAQ,GAAG;EAC9C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AM,QAAQ,MAAM,UAAA,MAA0B;CAE3F,MAAM,aAAa,MAAM,WAAW,CAAC,MAAM;CAC3C,MAAM,EAAE,MAAM,eAAe;CAK7B,MAAM,cAAc,oBAAC,OAAD;EAChB,WAAW,IAAI,2CAA2C,oBACtD,aAAa,2DAA2D,UAAU;EACtF,OAAO;GACH,OAAO;GACP,YAAY;EAChB;YAGA,oBAAC,OAAD;GAAK,WAAW;aACX,MAAM;EACN,CAAA;CAEJ,CAAA;CAGL,IAAI,CADgB,eACf,GAAa;EACd,IAAI,CAAC,MAAM,WACP,OAAO;EACX,OAAO,qBAAA,UAAA,EAAA,UAAA,CACH,oBAAC,YAAD;GACI,cAAY,EAAE,WAAW;GACzB,eAAe,MAAM,cAAc,IAAI;GACvC,WAAU;aAEV,oBAAC,UAAD,CAAU,CAAA;EACF,CAAA,GACZ,oBAAC,OAAD;GAAO,MAAM;GACT,aAAa;GACb,MAAM,MAAM;GACZ,cAAc,MAAM;GACpB,OAAO,EAAE,mBAAmB;GAC5B,kBAAkB;aAEjB;EACE,CAAA,CACT,EAAA,CAAA;CACN;CAEA,OACI,oBAAC,OAAD;EACI,WAAU;EACV,cAAc,MAAM;EACpB,aAAa,MAAM;EACnB,cAAc,MAAM;EACpB,OAAO;GACH,OAAO;GACP,UAAU;GACV,YAAY;EAChB;YAEC;CAEA,CAAA;AAEb"}
1
+ {"version":3,"file":"Scaffold.js","names":[],"sources":["../../../src/components/app/Scaffold.tsx"],"sourcesContent":["import React, { PropsWithChildren, useCallback, useMemo } from \"react\";\nimport { cls, defaultBorderMixin, IconButton, Sheet, Tooltip } from \"@rebasepro/ui\";\nimport { ChevronLeftIcon, ErrorBoundary, MenuIcon } from \"@rebasepro/ui\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ConnectionLostBanner, RlsSimulationBanner, useLargeLayout, useTranslation } from \"@rebasepro/app\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { AppContext } from \"./useApp\";\n\nexport const DRAWER_WIDTH = 280;\n\n/**\n * Namespaced by base path: two admins served from one origin are two different\n * navigations, and a single key would have them overwrite each other's drawer.\n */\nexport function drawerOpenStorageKey(basePath: string | undefined) {\n return `rebase-drawer-open:${basePath || \"/\"}`;\n}\n\n/** `null` when the user has never toggled the drawer, or storage is unavailable. */\nfunction readStoredDrawerOpen(key: string): boolean | null {\n if (typeof window === \"undefined\") return null;\n try {\n const stored = window.localStorage.getItem(key);\n return stored === null ? null : stored === \"true\";\n } catch (e) {\n // Storage can be blocked: private mode, sandboxed iframe, cookie policy.\n return null;\n }\n}\n\nfunction writeStoredDrawerOpen(key: string, open: boolean) {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(key, String(open));\n } catch (e) {\n // Same as above: a drawer that forgets is better than a crash.\n }\n}\n\n/**\n * @group Core\n */\nexport interface ScaffoldProps {\n\n /**\n * Expand the collapsed drawer while the pointer is over it. On by default —\n * pass `false` to keep the rail a rail until the user clicks the toggle.\n */\n autoOpenDrawer?: boolean;\n\n /**\n * Start with the drawer expanded rather than collapsed to icons.\n *\n * Distinct from {@link autoOpenDrawer}, which is a hover behaviour: this one\n * only seeds the very first visit. Once the user toggles the drawer, that\n * choice is stored in `localStorage` and wins over this prop on every load.\n *\n * Ignored on small layouts, where an expanded drawer covers the content it is\n * meant to navigate.\n */\n defaultDrawerOpen?: boolean;\n\n /**\n * Logo to be displayed in the top bar and drawer.\n * Note that this has no effect if you are using a custom AppBar or Drawer.\n */\n logo?: string;\n\n /**\n * If true, the main content will be padded in large layouts. Defaults to true.\n */\n padding?: boolean;\n\n className?: string;\n\n style?: React.CSSProperties;\n}\n\n/**\n * This view acts as a scaffold for Rebase.\n *\n * It is in charge of displaying the navigation drawer, top bar and main\n * collection views.\n * This component needs a parent {@link Rebase}\n *\n * @param props\n\n * @group Core\n */\nexport const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(\n function Scaffold(props: PropsWithChildren<ScaffoldProps>) {\n\n const {\n children,\n autoOpenDrawer = true,\n defaultDrawerOpen = false,\n logo,\n className,\n style,\n padding = true\n } = props;\n\n // `toArray` keeps strings and numbers, and those have no `.type` at all.\n // Reading `child.type.componentType` off one threw a TypeError from\n // inside the layout, which is a bewildering way to be told that a stray\n // text node — a conditional that rendered `\"\"`, a template string —\n // reached the Scaffold. Anything that is not an element is just \"other\".\n const slotOf = (child: React.ReactNode): string | undefined =>\n React.isValidElement(child)\n ? (child.type as { componentType?: string })?.componentType\n : undefined;\n\n const childArray = React.Children.toArray(children);\n const drawerChildren = childArray.filter((child) => slotOf(child) === \"Drawer\");\n if (drawerChildren.length > 1) {\n throw Error(\"Only one Drawer component is allowed in Scaffold\");\n }\n const appBarChildren = childArray.filter((child) => slotOf(child) === \"AppBar\");\n if (appBarChildren.length > 1) {\n throw Error(\"Only one AppBar component is allowed in Scaffold\");\n }\n const otherChildren = childArray\n .filter((child) => slotOf(child) !== \"Drawer\" && slotOf(child) !== \"AppBar\");\n const includeDrawer = drawerChildren.length > 0;\n const largeLayout = useLargeLayout();\n\n const storageKey = drawerOpenStorageKey(useUrlController().basePath);\n\n // Seeded once, deliberately: a `useEffect` syncing this to the prop would\n // re-expand the drawer under a user who had just collapsed it.\n const [drawerOpen, setDrawerOpenState] = React.useState(defaultDrawerOpen && largeLayout);\n const [onHover, setOnHover] = React.useState(false);\n\n // The stored choice is a client-only fact, so it is applied after the first\n // render rather than seeded into it: reading storage while rendering would\n // make the client disagree with server-rendered HTML. A layout effect runs\n // before paint, so the drawer still arrives in its remembered state.\n // `defaultDrawerOpen` seeds the very first visit and is ignored after that.\n React.useLayoutEffect(() => {\n const stored = readStoredDrawerOpen(storageKey);\n if (stored === null) return;\n setDrawerOpenState(stored && largeLayout);\n // Deliberately not re-run on `largeLayout`: crossing the breakpoint is\n // the effect below, and re-running here would undo a user's toggle.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [storageKey]);\n\n // One piece of state drives two different things: the expanded rail on\n // large layouts, and the modal sheet on small ones. Carrying an expanded\n // rail across the breakpoint would drop that sheet, overlay and all, over\n // the content — so the crossing resets it, and widening again restores\n // whatever the user last chose.\n const wasLargeLayout = React.useRef(largeLayout);\n React.useEffect(() => {\n if (wasLargeLayout.current === largeLayout) return;\n wasLargeLayout.current = largeLayout;\n setDrawerOpenState(largeLayout ? (readStoredDrawerOpen(storageKey) ?? defaultDrawerOpen) : false);\n }, [largeLayout, defaultDrawerOpen, storageKey]);\n\n const setDrawerOpen = useCallback((open: boolean) => {\n setDrawerOpenState(open);\n // Small layouts render the drawer as a modal sheet. Remembering that\n // one would greet the next load with an overlay over the content.\n if (!largeLayout) return;\n writeStoredDrawerOpen(storageKey, open);\n }, [largeLayout, storageKey]);\n\n // The pointer has left, but a popover the drawer opened is still up, so the\n // collapse is owed rather than cancelled. See `setOnHoverFalse`.\n const collapseWhenPopoverCloses = React.useRef(false);\n\n const setOnHoverTrue = useCallback(() => {\n // Hover expansion is the default; `autoOpenDrawer={false}` opts out for\n // admins that want the rail to stay a rail until the toggle is clicked.\n if (!autoOpenDrawer) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(true);\n }, [autoOpenDrawer]);\n const setOnHoverFalse = useCallback(() => {\n // Don't collapse the drawer out from under an open popover/dropdown —\n // its content is portalled outside the drawer, so reaching for it reads\n // as a mouseleave. The collapse is owed until that popover closes.\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) {\n collapseWhenPopoverCloses.current = true;\n return;\n }\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n }, []);\n\n // Nothing fires a second mouseleave when the popover finally closes, so the\n // owed collapse has to be noticed rather than waited for. Only mounted\n // while the drawer is actually floating open.\n React.useEffect(() => {\n if (!onHover) return;\n const collapseIfOwed = () => {\n if (!collapseWhenPopoverCloses.current) return;\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n };\n const observer = new MutationObserver(collapseIfOwed);\n observer.observe(document.body, {\n childList: true,\n subtree: true\n });\n return () => observer.disconnect();\n }, [onHover]);\n\n const handleDrawerOpen = useCallback(() => {\n setDrawerOpen(true);\n }, [setDrawerOpen]);\n\n const handleDrawerClose = useCallback(() => {\n setDrawerOpen(false);\n }, [setDrawerOpen]);\n\n const computedDrawerOpen: boolean = drawerOpen;\n const computedDrawerHovered = Boolean(largeLayout && onHover);\n\n const hasAppBar = Boolean(appBarChildren.length > 0);\n // Below `lg` the drawer is a sheet, opened from a menu button. An app\n // bar leaves room for that button; without one, the button floated over\n // the first thing on the page — the collection toolbar's view switcher —\n // so it gets a row of its own instead.\n const menuButtonRow = Boolean(includeDrawer) && !largeLayout && !hasAppBar;\n const appContextValue = useMemo(() => ({\n hasDrawer: Boolean(includeDrawer),\n drawerOpen: computedDrawerOpen,\n drawerHovered: computedDrawerHovered,\n openDrawer: handleDrawerOpen,\n closeDrawer: handleDrawerClose,\n closeHover: setOnHoverFalse,\n logo\n }), [includeDrawer, computedDrawerOpen, computedDrawerHovered, handleDrawerOpen, handleDrawerClose, setOnHoverFalse, logo]);\n\n return (\n <AppContext.Provider value={appContextValue}>\n <div\n className={cls(\"flex h-screen w-screen overflow-hidden\",\n \"bg-surface-frame\",\n \"text-surface-900 dark:text-white\", className)}\n style={{\n paddingTop: \"env(safe-area-inset-top)\",\n paddingLeft: \"env(safe-area-inset-left)\",\n paddingRight: \"env(safe-area-inset-right)\",\n paddingBottom: \"env(safe-area-inset-bottom)\",\n height: \"100dvh\",\n ...style\n }}>\n {appBarChildren}\n\n <DrawerWrapper\n displayed={includeDrawer}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n open={drawerOpen}\n hovered={onHover}\n setDrawerOpen={setDrawerOpen}\n floatingMenuButton={!menuButtonRow}>\n {includeDrawer && drawerChildren}\n </DrawerWrapper>\n\n <main\n className=\"flex flex-col grow overflow-auto\">\n\n {hasAppBar && <DrawerHeader/>}\n {menuButtonRow && <MenuButtonRow onOpen={handleDrawerOpen}/>}\n\n {/* Above the sheet, so it is there on every screen: while\n the realtime connection is down, every live view is\n showing what it last received. */}\n <ConnectionLostBanner className={cls(\"px-2 pt-1\", {\n \"lg:pt-0 lg:pb-2\": padding,\n \"lg:pt-2\": !hasAppBar && padding\n })}/>\n\n {/* While access is simulated, every data view shows\n another identity's rows: say so on every screen. */}\n <RlsSimulationBanner className={cls(\"px-2 pt-1\", {\n \"lg:pt-0 lg:pb-2\": padding,\n \"lg:pt-2\": !hasAppBar && padding\n })}/>\n\n <div\n // The sheet is one lightness step above the frame AND carries a\n // plain hairline on its edge. The step alone (#090a0c to #111316,\n // #eff0f3 to #f8f9fa) is about 3 L* on both themes, under what a\n // dimmed screen renders, and the first pass of this system removed\n // the line on the theory that the step would do its work; the\n // frame and the sheet then read as one black. The reference's own\n // content sheet carries this line. Only in the inset `lg` layout:\n // edge-to-edge on small screens, a border draws at the viewport.\n className={cls(\"bg-surface-sheet\", \"grow overflow-auto m-0\", \"lg:border lg:border-hairline\", {\n \"mt-1 lg:m-0 lg:mx-2 lg:mb-2 lg:rounded-xl\": padding,\n // No app bar means no DrawerHeader spacer above, so inset the\n // panel by the same amount as its sides and bottom.\n // Must come after the padding classes, which reset lg margins.\n \"lg:mt-2\": !hasAppBar && padding,\n \"lg:mt-4\": !hasAppBar && !padding\n })}>\n\n <ErrorBoundary>\n {otherChildren}\n </ErrorBoundary>\n\n </div>\n </main>\n </div>\n </AppContext.Provider>\n );\n },\n equal\n)\n\nconst DrawerHeader = () => {\n return (\n <div className=\"flex flex-col min-h-14\"></div>\n );\n};\n\n/** The small-layout menu button, in the flow above the sheet. */\nfunction MenuButtonRow({ onOpen }: { onOpen: () => void }) {\n const { t } = useTranslation();\n return (\n <div className=\"flex items-center shrink-0 px-2 sm:px-4 pt-1\">\n <IconButton aria-label={t(\"open_menu\")} onClick={onOpen}>\n <MenuIcon/>\n </IconButton>\n </div>\n );\n}\n\nfunction DrawerWrapper(props: {\n children: React.ReactNode,\n displayed: boolean,\n open: boolean,\n logo?: string,\n hovered: boolean,\n setDrawerOpen: (open: boolean) => void,\n /** Draw the small layout's menu button over the page; false when the page has a row for it. */\n floatingMenuButton: boolean,\n onMouseEnter: () => void,\n onMouseMove: () => void,\n onMouseLeave: () => void\n}) {\n\n const layoutWidth = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);\n const visualWidth = !props.displayed ? 0 : ((props.open || props.hovered) ? DRAWER_WIDTH : 72);\n\n const isFloating = props.hovered && !props.open;\n const { t } = useTranslation();\n\n // The drawer is part of the frame, on both themes. When it floats over the\n // sheet it needs an edge, because a frame-coloured panel over the sheet is\n // an object at that moment; docked, it is a region and gets none.\n const innerDrawer = <div\n className={cls(\"h-full overflow-hidden bg-surface-frame\", defaultBorderMixin,\n isFloating ? \"absolute top-0 left-0 bottom-0 z-50 shadow-lg border-r\" : \"relative\")}\n style={{\n width: visualWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}\n >\n\n <div className={\"flex flex-col h-full\"}>\n {props.children}\n </div>\n\n </div>;\n\n const largeLayout = useLargeLayout();\n if (!largeLayout) {\n if (!props.displayed)\n return null;\n return <>\n {props.floatingMenuButton && <IconButton\n aria-label={t(\"open_menu\")}\n onClick={() => props.setDrawerOpen(true)}\n className=\"absolute sm:top-2 sm:left-4 top-1 left-2\"\n >\n <MenuIcon/>\n </IconButton>}\n <Sheet side={\"left\"}\n transparent={true}\n open={props.open}\n onOpenChange={props.setDrawerOpen}\n title={t(\"navigation_drawer\")}\n overlayClassName={\"bg-surface-scrim\"}\n >\n {innerDrawer}\n </Sheet>\n </>;\n }\n\n return (\n <div\n className=\"z-20 relative flex-shrink-0 overflow-visible\"\n onMouseEnter={props.onMouseEnter}\n onMouseMove={props.onMouseMove}\n onMouseLeave={props.onMouseLeave}\n style={{\n width: layoutWidth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GACvC,WAAU;aAEV,oBAAC,UAAD,CAAU,CAAA;EACF,CAAA,GACZ,oBAAC,OAAD;GAAO,MAAM;GACT,aAAa;GACb,MAAM,MAAM;GACZ,cAAc,MAAM;GACpB,OAAO,EAAE,mBAAmB;GAC5B,kBAAkB;aAEjB;EACE,CAAA,CACT,EAAA,CAAA;CACN;CAEA,OACI,oBAAC,OAAD;EACI,WAAU;EACV,cAAc,MAAM;EACpB,aAAa,MAAM;EACnB,cAAc,MAAM;EACpB,OAAO;GACH,OAAO;GACP,UAAU;GACV,YAAY;EAChB;YAEC;CAEA,CAAA;AAEb"}
@@ -3,6 +3,7 @@ import { EntityHistoryEntry } from "./EntityHistoryEntry.js";
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { ErrorBoundary, HistoryIcon, IconButton, Label, Tooltip, Typography, cls } from "@rebasepro/ui";
6
+ import { hasEntityId } from "@rebasepro/common";
6
7
  import { ConfirmationDialog, usePermissions, useSnackbarController, useTranslation } from "@rebasepro/app";
7
8
  //#region src/components/history/EntityHistoryView.tsx
8
9
  /**
@@ -19,7 +20,7 @@ function EntityHistoryView({ entity, collection, formContext, refreshToken }) {
19
20
  const { entries, isLoading, hasMore, loadMore, revert } = useHistory({
20
21
  slug,
21
22
  entityId,
22
- enabled: !!entityId,
23
+ enabled: hasEntityId(entityId),
23
24
  pageSize: 10,
24
25
  refreshToken
25
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"EntityHistoryView.js","names":[],"sources":["../../../src/components/history/EntityHistoryView.tsx"],"sourcesContent":["\nimport type { EntityCustomViewParams } from \"@rebasepro/cms-types\";\nimport { useRef, useEffect } from \"react\";\nimport { cls, IconButton, Label, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { ErrorBoundary, HistoryIcon } from \"@rebasepro/ui\";\nimport { EntityHistoryEntry } from \"./EntityHistoryEntry\";\nimport { usePermissions, useSnackbarController, useTranslation } from \"@rebasepro/app\";\nimport { ConfirmationDialog } from \"@rebasepro/app\";\nimport { useState } from \"react\";\nimport { useHistory } from \"../../hooks/useHistory\";\n\n/**\n * Entity history tab view. Shows a paginated list of entity revisions\n * fetched from the backend API. Supports infinite scroll and revert.\n */\nexport function EntityHistoryView<M extends Record<string, unknown>>({\n entity,\n collection,\n formContext,\n refreshToken\n}: EntityCustomViewParams<M> & {\n /** Bumped once per save, so the list picks up the revision it just made. */\n refreshToken?: number;\n}) {\n\n const { t } = useTranslation();\n const snackbarController = useSnackbarController();\n const { canEdit } = usePermissions();\n const dirty = formContext?.formex.dirty;\n\n const slug = collection.slug;\n const entityId = entity?.id;\n\n const {\n entries,\n isLoading,\n hasMore,\n loadMore,\n revert\n } = useHistory({\n slug,\n entityId,\n enabled: !!entityId,\n pageSize: 10,\n refreshToken\n });\n\n const [revertHistoryId, setRevertHistoryId] = useState<string | undefined>();\n const [isReverting, setIsReverting] = useState(false);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const loadMoreRef = useRef<HTMLDivElement>(null);\n\n // Intersection observer for infinite scroll\n useEffect(() => {\n const currentContainer = containerRef.current;\n const currentLoadMore = loadMoreRef.current;\n\n if (!currentContainer || !currentLoadMore || !hasMore || isLoading) return;\n\n const observer = new IntersectionObserver(\n (observerEntries) => {\n if (observerEntries[0].isIntersecting && hasMore && !isLoading) {\n loadMore();\n }\n },\n {\n root: currentContainer,\n rootMargin: \"0px 0px 200px 0px\",\n threshold: 0.01\n }\n );\n\n observer.observe(currentLoadMore);\n\n return () => observer.disconnect();\n }, [hasMore, isLoading, entries.length, loadMore]);\n\n if (!entity) {\n return <div className=\"flex items-center justify-center h-full\">\n <Label>{t(\"history_new_entity\") ?? \"History is only available for existing records\"}</Label>\n </div>;\n }\n\n // A revert writes the record: offered only to someone who may edit it,\n // which no one may while access is simulated.\n const editable = canEdit(collection, entity.path ?? slug, entity);\n\n async function doRevert(historyId: string) {\n setIsReverting(true);\n try {\n const revertedValues = await revert(historyId);\n setRevertHistoryId(undefined);\n\n // Reset the form with the reverted values so the UI updates\n // immediately without requiring a page refresh.\n if (formContext?.formex?.resetForm && revertedValues) {\n formContext.formex.resetForm({\n values: revertedValues as M,\n submitCount: 0,\n touched: {}\n });\n }\n\n snackbarController.open({\n message: t(\"history_reverted\") ?? \"Reverted to selected version\",\n type: \"info\"\n });\n } catch (error) {\n console.error(\"Error reverting entity:\", error);\n const reason = error instanceof Error ? error.message : undefined;\n snackbarController.open({\n message: [t(\"history_revert_error\") ?? \"Error reverting entity\", reason].filter(Boolean).join(\": \"),\n type: \"error\"\n });\n } finally {\n setIsReverting(false);\n }\n }\n\n const revertEntry = revertHistoryId\n ? entries.find(e => e.id === revertHistoryId)\n : undefined;\n\n // `p-8` plus a `mt-24` heading were sized for a full-width tab that no\n // longer exists. In the inspector panel that was 96px of nothing above the\n // first revision, and 32px of gutter on each side of a 448px column.\n return <div\n ref={containerRef}\n className={cls(\"relative flex-1 h-full overflow-auto w-full flex flex-col gap-4 p-4 sm:p-5\")}>\n <div className=\"flex flex-col gap-2 max-w-6xl mx-auto w-full\">\n\n {isLoading && entries.length === 0 && (\n <div className=\"flex flex-col gap-4\">\n {[1, 2, 3].map(i => (\n <div key={i} className=\"flex flex-col gap-2 animate-pulse\">\n <div className=\"h-4 w-48 bg-surface-raised rounded\"/>\n <div className=\"h-12 w-full bg-surface-raised rounded-lg border border-hairline-strong\"/>\n </div>\n ))}\n </div>\n )}\n\n {!isLoading && entries.length === 0 && <>\n <Label>\n {t(\"history_empty\") ?? \"No history available\"}\n </Label>\n <Typography variant={\"caption\"}>\n {t(\"history_empty_description\") ?? \"When you save a record, a new version is created and stored in the history.\"}\n </Typography>\n </>}\n\n {entries.map((entry) => (\n <div key={entry.id} className=\"flex flex-col gap-2 w-full\">\n <EntityHistoryEntry\n entry={entry}\n collection={collection}\n size={\"medium\"}\n actions={editable &&\n <Tooltip title={t(\"history_revert\") ?? \"Revert to this version\"}\n className={\"m-2 grow-0 self-start\"}>\n <IconButton aria-label={t(\"history_revert\") ?? \"Revert to this version\"}\n onClick={() => {\n if (dirty) {\n snackbarController.open({\n message: t(\"history_revert_dirty\") ?? \"Please save or discard your changes before reverting\",\n type: \"warning\"\n });\n } else {\n setRevertHistoryId(entry.id);\n }\n }}>\n <HistoryIcon/>\n </IconButton>\n </Tooltip>\n }\n />\n </div>\n ))}\n\n {/* Load more sentinel */}\n {entries.length > 0 && (\n <div ref={loadMoreRef} className=\"py-4 text-center\">\n {isLoading && <Label>{t(\"loading\")}</Label>}\n {!hasMore && entries.length > 10 && <Label>{t(\"history_no_more\") ?? \"No more history\"}</Label>}\n </div>\n )}\n </div>\n\n <ErrorBoundary>\n <ConfirmationDialog\n open={Boolean(revertHistoryId)}\n onAccept={() => {\n if (revertHistoryId) doRevert(revertHistoryId);\n }}\n onCancel={() => setRevertHistoryId(undefined)}\n title={<Typography variant={\"subtitle2\"}>{t(\"history_revert_title\") ?? \"Revert data to this version?\"}</Typography>}\n body={revertEntry\n ? <div className=\"p-4\">\n <Typography variant={\"caption\"} color={\"secondary\"}>\n This will save the entity with the values from{\" \"}\n {new Date(revertEntry.updated_at).toLocaleString()}.\n A new history entry will be created for the revert.\n </Typography>\n </div>\n : null\n }\n />\n </ErrorBoundary>\n </div>;\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,kBAAqD,EACjE,QACA,YACA,aACA,gBAID;CAEC,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,YAAY,eAAe;CACnC,MAAM,QAAQ,aAAa,OAAO;CAElC,MAAM,OAAO,WAAW;CACxB,MAAM,WAAW,QAAQ;CAEzB,MAAM,EACF,SACA,WACA,SACA,UACA,WACA,WAAW;EACX;EACA;EACA,SAAS,CAAC,CAAC;EACX,UAAU;EACV;CACJ,CAAC;CAED,MAAM,CAAC,iBAAiB,sBAAsB,SAA6B;CAC3E,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,MAAM,eAA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A,GACzC,CAAC,WAAW,QAAQ,SAAS,MAAM,oBAAC,OAAD,EAAA,UAAQ,EAAE,iBAAiB,KAAK,kBAAyB,CAAA,CAC5F;;GAER;MAEL,oBAAC,eAAD,EAAA,UACI,oBAAC,oBAAD;GACI,MAAM,QAAQ,eAAe;GAC7B,gBAAgB;IACZ,IAAI,iBAAiB,SAAS,eAAe;GACjD;GACA,gBAAgB,mBAAmB,KAAA,CAAS;GAC5C,OAAO,oBAAC,YAAD;IAAY,SAAS;cAAc,EAAE,sBAAsB,KAAK;GAA2C,CAAA;GAClH,MAAM,cACA,oBAAC,OAAD;IAAK,WAAU;cACb,qBAAC,YAAD;KAAY,SAAS;KAAW,OAAO;eAAvC;MAAoD;MACD;MAC9C,IAAI,KAAK,YAAY,UAAU,CAAC,CAAC,eAAe;MAAE;KAE3C;;GACX,CAAA,IACH;EAET,CAAA,EACU,CAAA,CACd;;AACT"}
1
+ {"version":3,"file":"EntityHistoryView.js","names":[],"sources":["../../../src/components/history/EntityHistoryView.tsx"],"sourcesContent":["\nimport type { EntityCustomViewParams } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { useRef, useEffect } from \"react\";\nimport { cls, IconButton, Label, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { ErrorBoundary, HistoryIcon } from \"@rebasepro/ui\";\nimport { EntityHistoryEntry } from \"./EntityHistoryEntry\";\nimport { usePermissions, useSnackbarController, useTranslation } from \"@rebasepro/app\";\nimport { ConfirmationDialog } from \"@rebasepro/app\";\nimport { useState } from \"react\";\nimport { useHistory } from \"../../hooks/useHistory\";\n\n/**\n * Entity history tab view. Shows a paginated list of entity revisions\n * fetched from the backend API. Supports infinite scroll and revert.\n */\nexport function EntityHistoryView<M extends Record<string, unknown>>({\n entity,\n collection,\n formContext,\n refreshToken\n}: EntityCustomViewParams<M> & {\n /** Bumped once per save, so the list picks up the revision it just made. */\n refreshToken?: number;\n}) {\n\n const { t } = useTranslation();\n const snackbarController = useSnackbarController();\n const { canEdit } = usePermissions();\n const dirty = formContext?.formex.dirty;\n\n const slug = collection.slug;\n const entityId = entity?.id;\n\n const {\n entries,\n isLoading,\n hasMore,\n loadMore,\n revert\n } = useHistory({\n slug,\n entityId,\n enabled: hasEntityId(entityId),\n pageSize: 10,\n refreshToken\n });\n\n const [revertHistoryId, setRevertHistoryId] = useState<string | undefined>();\n const [isReverting, setIsReverting] = useState(false);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const loadMoreRef = useRef<HTMLDivElement>(null);\n\n // Intersection observer for infinite scroll\n useEffect(() => {\n const currentContainer = containerRef.current;\n const currentLoadMore = loadMoreRef.current;\n\n if (!currentContainer || !currentLoadMore || !hasMore || isLoading) return;\n\n const observer = new IntersectionObserver(\n (observerEntries) => {\n if (observerEntries[0].isIntersecting && hasMore && !isLoading) {\n loadMore();\n }\n },\n {\n root: currentContainer,\n rootMargin: \"0px 0px 200px 0px\",\n threshold: 0.01\n }\n );\n\n observer.observe(currentLoadMore);\n\n return () => observer.disconnect();\n }, [hasMore, isLoading, entries.length, loadMore]);\n\n if (!entity) {\n return <div className=\"flex items-center justify-center h-full\">\n <Label>{t(\"history_new_entity\") ?? \"History is only available for existing records\"}</Label>\n </div>;\n }\n\n // A revert writes the record: offered only to someone who may edit it,\n // which no one may while access is simulated.\n const editable = canEdit(collection, entity.path ?? slug, entity);\n\n async function doRevert(historyId: string) {\n setIsReverting(true);\n try {\n const revertedValues = await revert(historyId);\n setRevertHistoryId(undefined);\n\n // Reset the form with the reverted values so the UI updates\n // immediately without requiring a page refresh.\n if (formContext?.formex?.resetForm && revertedValues) {\n formContext.formex.resetForm({\n values: revertedValues as M,\n submitCount: 0,\n touched: {}\n });\n }\n\n snackbarController.open({\n message: t(\"history_reverted\") ?? \"Reverted to selected version\",\n type: \"info\"\n });\n } catch (error) {\n console.error(\"Error reverting entity:\", error);\n const reason = error instanceof Error ? error.message : undefined;\n snackbarController.open({\n message: [t(\"history_revert_error\") ?? \"Error reverting entity\", reason].filter(Boolean).join(\": \"),\n type: \"error\"\n });\n } finally {\n setIsReverting(false);\n }\n }\n\n const revertEntry = revertHistoryId\n ? entries.find(e => e.id === revertHistoryId)\n : undefined;\n\n // `p-8` plus a `mt-24` heading were sized for a full-width tab that no\n // longer exists. In the inspector panel that was 96px of nothing above the\n // first revision, and 32px of gutter on each side of a 448px column.\n return <div\n ref={containerRef}\n className={cls(\"relative flex-1 h-full overflow-auto w-full flex flex-col gap-4 p-4 sm:p-5\")}>\n <div className=\"flex flex-col gap-2 max-w-6xl mx-auto w-full\">\n\n {isLoading && entries.length === 0 && (\n <div className=\"flex flex-col gap-4\">\n {[1, 2, 3].map(i => (\n <div key={i} className=\"flex flex-col gap-2 animate-pulse\">\n <div className=\"h-4 w-48 bg-surface-raised rounded\"/>\n <div className=\"h-12 w-full bg-surface-raised rounded-lg border border-hairline-strong\"/>\n </div>\n ))}\n </div>\n )}\n\n {!isLoading && entries.length === 0 && <>\n <Label>\n {t(\"history_empty\") ?? \"No history available\"}\n </Label>\n <Typography variant={\"caption\"}>\n {t(\"history_empty_description\") ?? \"When you save a record, a new version is created and stored in the history.\"}\n </Typography>\n </>}\n\n {entries.map((entry) => (\n <div key={entry.id} className=\"flex flex-col gap-2 w-full\">\n <EntityHistoryEntry\n entry={entry}\n collection={collection}\n size={\"medium\"}\n actions={editable &&\n <Tooltip title={t(\"history_revert\") ?? \"Revert to this version\"}\n className={\"m-2 grow-0 self-start\"}>\n <IconButton aria-label={t(\"history_revert\") ?? \"Revert to this version\"}\n onClick={() => {\n if (dirty) {\n snackbarController.open({\n message: t(\"history_revert_dirty\") ?? \"Please save or discard your changes before reverting\",\n type: \"warning\"\n });\n } else {\n setRevertHistoryId(entry.id);\n }\n }}>\n <HistoryIcon/>\n </IconButton>\n </Tooltip>\n }\n />\n </div>\n ))}\n\n {/* Load more sentinel */}\n {entries.length > 0 && (\n <div ref={loadMoreRef} className=\"py-4 text-center\">\n {isLoading && <Label>{t(\"loading\")}</Label>}\n {!hasMore && entries.length > 10 && <Label>{t(\"history_no_more\") ?? \"No more history\"}</Label>}\n </div>\n )}\n </div>\n\n <ErrorBoundary>\n <ConfirmationDialog\n open={Boolean(revertHistoryId)}\n onAccept={() => {\n if (revertHistoryId) doRevert(revertHistoryId);\n }}\n onCancel={() => setRevertHistoryId(undefined)}\n title={<Typography variant={\"subtitle2\"}>{t(\"history_revert_title\") ?? \"Revert data to this version?\"}</Typography>}\n body={revertEntry\n ? <div className=\"p-4\">\n <Typography variant={\"caption\"} color={\"secondary\"}>\n This will save the entity with the values from{\" \"}\n {new Date(revertEntry.updated_at).toLocaleString()}.\n A new history entry will be created for the revert.\n </Typography>\n </div>\n : null\n }\n />\n </ErrorBoundary>\n </div>;\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,kBAAqD,EACjE,QACA,YACA,aACA,gBAID;CAEC,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,YAAY,eAAe;CACnC,MAAM,QAAQ,aAAa,OAAO;CAElC,MAAM,OAAO,WAAW;CACxB,MAAM,WAAW,QAAQ;CAEzB,MAAM,EACF,SACA,WACA,SACA,UACA,WACA,WAAW;EACX;EACA;EACA,SAAS,YAAY,QAAQ;EAC7B,UAAU;EACV;CACJ,CAAC;CAED,MAAM,CAAC,iBAAiB,sBAAsB,SAA6B;CAC3E,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,cAAc,OAAuB,IAAI;CAG/C,gBAAgB;EACZ,MAAM,mBAAmB,aAAa;EACtC,MAAM,kBAAkB,YAAY;EAEpC,IAAI,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,WAAW,WAAW;EAEpE,MAAM,WAAW,IAAI,sBAChB,oBAAoB;GACjB,IAAI,gBAAgB,EAAE,CAAC,kBAAkB,WAAW,CAAC,WACjD,SAAS;EAEjB,GACA;GACI,MAAM;GACN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;cAAc,EAAE,sBAAsB,KAAK;GAA2C,CAAA;GAClH,MAAM,cACA,oBAAC,OAAD;IAAK,WAAU;cACb,qBAAC,YAAD;KAAY,SAAS;KAAW,OAAO;eAAvC;MAAoD;MACD;MAC9C,IAAI,KAAK,YAAY,UAAU,CAAC,CAAC,eAAe;MAAE;KAE3C;;GACX,CAAA,IACH;EAET,CAAA,EACU,CAAA,CACd;;AACT"}
@@ -307,7 +307,7 @@ function processValueForExport(inputValue, property, exportType, dateExportType)
307
307
  if (property.type === "relation") {
308
308
  const toId = (item) => relationIdForExport(item) ?? item;
309
309
  value = Array.isArray(inputValue) ? inputValue.map(toId) : toId(inputValue);
310
- } else if (property.type === "map" && property.properties) value = processValuesForExport(inputValue, property.properties, exportType, dateExportType);
310
+ } else if (property.type === "map" && property.properties) value = inputValue !== null && typeof inputValue === "object" && !Array.isArray(inputValue) ? processValuesForExport(inputValue, property.properties, exportType, dateExportType) : inputValue;
311
311
  else if (property.type === "array") if (property.of && Array.isArray(inputValue)) if (Array.isArray(property.of)) value = property.of.map((p, i) => processValueForExport(inputValue[i], p, exportType, dateExportType));
312
312
  else if (property.of.type === "map") value = exportType === "csv" ? inputValue.map((e) => JSON.stringify(e)) : inputValue.map((e) => processValueForExport(e, property.of, exportType, dateExportType));
313
313
  else value = inputValue.map((e) => processValueForExport(e, property.of, exportType, dateExportType));
@@ -356,8 +356,8 @@ function downloadBlob(content, filename, contentType) {
356
356
  var BLOB_URL_LIFETIME_MS = 1e4;
357
357
  function downloadDataAsCsv(data, name) {
358
358
  if (data.length === 0) return;
359
- const headers = Object.keys(data[0]);
360
- downloadBlob([[headers.join(","), ...data.map((row) => headers.map((header) => toCSVCell(row[header])).join(","))].join("\r\n")], `${name}.csv`, "text/csv");
359
+ const headers = [...new Set(data.flatMap((row) => Object.keys(row)))];
360
+ downloadBlob([[headers.map(toCSVCell).join(","), ...data.map((row) => headers.map((header) => toCSVCell(row[header])).join(","))].join("\r\n")], `${name}.csv`, "text/csv");
361
361
  }
362
362
  //#endregion
363
363
  export { createCsvExportWriter, downloadBlob, downloadDataAsCsv, downloadEntitiesExport, entryToCSVRow, escapeCsvFormula, getEntityCSVExportableData, getEntityJsonExportableData, unescapeCsvFormula };