@plumile/backoffice-react 0.1.188 → 0.1.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/auth/login/LoginFlow.js.map +1 -1
- package/lib/esm/auth/login/MethodChooser.js.map +1 -1
- package/lib/esm/auth/login/MfaChallengeForm.js.map +1 -1
- package/lib/esm/auth/login/PasskeyLoginForm.js.map +1 -1
- package/lib/esm/auth/login/loginPage.css.js +2 -0
- package/lib/esm/auth/login/synchronizeAuthStatusQuery.js.map +1 -1
- package/lib/esm/auth/pages/AcceptInvitationScreen.js.map +1 -1
- package/lib/esm/auth/pages/PasswordResetCompleteScreen.js.map +1 -1
- package/lib/esm/auth/pages/PasswordResetRequestScreen.js.map +1 -1
- package/lib/esm/auth/pages/VerifyEmailScreen.js.map +1 -1
- package/lib/esm/components/backoffice/actions/LazyBackofficeEntityActionFormDialog.js.map +1 -1
- package/lib/esm/components/backoffice/billing/BackofficeBillingUsageChart.js.map +1 -1
- package/lib/esm/components/backoffice/columns/buildDataTableColumns.js.map +1 -1
- package/lib/esm/components/backoffice/detail/BackofficeLifecycleTimelineSection.js.map +1 -1
- package/lib/esm/components/backoffice/detail/BackofficeTokenUsageBreakdown.js.map +1 -1
- package/lib/esm/components/backoffice/detail/backofficeEntitySummaryHeader.css.js +0 -1
- package/lib/esm/components/backoffice/detail/createBackofficeEntityLinkProps.js.map +1 -1
- package/lib/esm/components/backoffice/detail/detailPayloadUtils.js.map +1 -1
- package/lib/esm/components/backoffice/filters/backofficeFilterAction.css.js +0 -1
- package/lib/esm/components/backoffice/filters/deferredFilterSearchInput.css.js +0 -1
- package/lib/esm/components/backoffice/layout/breadcrumb/assertValidBreadcrumb.js.map +1 -1
- package/lib/esm/components/backoffice/layout/buildSidebarSections.js.map +1 -1
- package/lib/esm/components/backoffice/layout/mapViewerToSidebarProfileView.js.map +1 -1
- package/lib/esm/components/backoffice/layout/sidebarUtils.js.map +1 -1
- package/lib/esm/components/backoffice/links/resolveBackofficeLink.js.map +1 -1
- package/lib/esm/components/backoffice/links/resolveBackofficeTargetIcon.js.map +1 -1
- package/lib/esm/components/backoffice/list/RowFlagsCell.css.js +1 -0
- package/lib/esm/components/backoffice/list/RowFlagsCell.js.map +1 -1
- package/lib/esm/components/backoffice/pickers/EntityIdPickerDialog.js.map +1 -1
- package/lib/esm/components/backoffice/refs/BackofficeLazyEntityCount.js.map +1 -1
- package/lib/esm/components/backoffice/refs/BackofficeRelatedCountLink.js.map +1 -1
- package/lib/esm/components/backoffice/routing/BackofficeContentBoundary.js.map +1 -1
- package/lib/esm/components/backoffice/scaffolds/BackofficeEntityListScaffold.js +285 -269
- package/lib/esm/components/backoffice/scaffolds/BackofficeEntityListScaffold.js.map +1 -1
- package/lib/esm/components/backoffice/shared/backofficeFilterableCell.css.js +1 -1
- package/lib/esm/components/backoffice/technical/TechnicalIdentifierValue.js.map +1 -1
- package/lib/esm/filters/filterHelpers.js +1 -1
- package/lib/esm/filters/filterHelpers.js.map +1 -1
- package/lib/esm/hooks/useAuth.js.map +1 -1
- package/lib/esm/hooks/useBackofficeAuth.js.map +1 -1
- package/lib/esm/hooks/useBackofficeInfiniteScrollSentinel.js.map +1 -1
- package/lib/esm/hooks/useBackofficeListUrlState.js.map +1 -1
- package/lib/esm/hooks/useBackofficeSessionAuth.js.map +1 -1
- package/lib/esm/hooks/useConditionalSubscription.js.map +1 -1
- package/lib/esm/hooks/useSidebarGroupCollapse.js.map +1 -1
- package/lib/esm/i18n/createI18nInstance.js.map +1 -1
- package/lib/esm/i18n/locales/en/backofficeReact.js +406 -405
- package/lib/esm/i18n/locales/fr/backofficeReact.js +408 -407
- package/lib/esm/i18n/mergeResourceLanguages.js.map +1 -1
- package/lib/esm/i18n/resources.js +1 -1
- package/lib/esm/i18n/resources.js.map +1 -1
- package/lib/esm/i18n/useBackofficeFormats.js.map +1 -1
- package/lib/esm/modules/base64.js.map +1 -1
- package/lib/esm/modules/formatFileSize.js.map +1 -1
- package/lib/esm/modules/uploads.js +17 -17
- package/lib/esm/modules/uploads.js.map +1 -1
- package/lib/esm/modules/webauthn.js.map +1 -1
- package/lib/esm/node_modules/@babel/runtime/helpers/objectSpread2.js.map +1 -1
- package/lib/esm/node_modules/@babel/runtime/helpers/toPrimitive.js.map +1 -1
- package/lib/esm/node_modules/@babel/runtime/helpers/toPropertyKey.js.map +1 -1
- package/lib/esm/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js.map +1 -1
- package/lib/esm/node_modules/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js +1 -1
- package/lib/esm/node_modules/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js.map +1 -1
- package/lib/esm/node_modules/fbjs/lib/areEqual.js.map +1 -1
- package/lib/esm/node_modules/relay-test-utils/lib/RelayMockPayloadGenerator.js.map +1 -1
- package/lib/esm/node_modules/relay-test-utils/lib/RelayModernMockEnvironment.js.map +1 -1
- package/lib/esm/node_modules/relay-test-utils/lib/RelayResolverTestUtils.js.map +1 -1
- package/lib/esm/pages/BackofficeDashboardPage.js.map +1 -1
- package/lib/esm/pages/BackofficeDashboardWidgetContent.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.view-helpers.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityListPage.helpers.js +5 -5
- package/lib/esm/pages/BackofficeEntityListPage.helpers.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityListPage.js.map +1 -1
- package/lib/esm/pages/BackofficeHubPage.js.map +1 -1
- package/lib/esm/pages/BackofficeLayoutPage.js.map +1 -1
- package/lib/esm/pages/BackofficeLoginPage.js.map +1 -1
- package/lib/esm/pages/BackofficePasswordResetRequestPage.js.map +1 -1
- package/lib/esm/pages/BackofficeVerifyEmailPage.js.map +1 -1
- package/lib/esm/pages/detail/BackofficeEntityDetailManifestFallback.js.map +1 -1
- package/lib/esm/pages/detail/pageResolution.js.map +1 -1
- package/lib/esm/provider/BackofficeProvider.js.map +1 -1
- package/lib/esm/provider/entityRegistry.js.map +1 -1
- package/lib/esm/provider/lazyValue.js.map +1 -1
- package/lib/esm/provider/useBackofficeEntityLoader.js.map +1 -1
- package/lib/esm/relay/connectionUtils.js.map +1 -1
- package/lib/esm/relay/envHelpers.js.map +1 -1
- package/lib/esm/router/createBackofficeRoutes.js.map +1 -1
- package/lib/esm/storybook/relay/RelayStory.js.map +1 -1
- package/lib/esm/storybook/relay/mockResolvers.js.map +1 -1
- package/lib/types/components/backoffice/detail/BackofficeLifecycleTimelineSection.d.ts.map +1 -1
- package/lib/types/components/backoffice/pickers/EntityIdPickerDialog.d.ts.map +1 -1
- package/lib/types/components/backoffice/scaffolds/BackofficeEntityListScaffold.d.ts.map +1 -1
- package/lib/types/components/backoffice/technical/TechnicalIdentifierValue.d.ts.map +1 -1
- package/lib/types/filters/filterHelpers.d.ts.map +1 -1
- package/lib/types/hooks/useAuth.d.ts.map +1 -1
- package/lib/types/modules/uploads.d.ts.map +1 -1
- package/lib/types/modules/webauthn.d.ts.map +1 -1
- package/lib/types/pages/BackofficePasswordResetRequestPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeVerifyEmailPage.d.ts.map +1 -1
- package/lib/types/pages/detail/pageResolution.d.ts.map +1 -1
- package/lib/types/provider/types.d.ts.map +1 -1
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeEntityDetailPage.view-helpers.js","names":[],"sources":["../../../src/pages/BackofficeEntityDetailPage.view-helpers.ts"],"sourcesContent":["/* eslint-disable no-ternary */\nimport type {\n BackofficeBadgeItem,\n BackofficeColumnSpec,\n BackofficeDetailBlockSpec,\n BackofficeDetailFieldSpec,\n BackofficeDetailHeaderConfig,\n BackofficeDetailHeaderMetaSpec,\n BackofficeDetailHeaderStatusSpec,\n BackofficeFieldSize,\n BackofficeFlagVariant,\n BackofficeInlineValueSpec,\n BackofficePayloadFormat,\n BackofficeTone,\n BackofficeValueLabel,\n} from '@plumile/backoffice-core/types.js';\nimport type { DataTableColumn } from '@plumile/ui/components/data-table/DataTable.js';\nimport type { TFunction } from 'i18next';\nimport { Fragment, createElement, type ReactNode } from 'react';\n\nimport {\n isEmptyText,\n resolveLabel,\n resolveBadgeTone,\n resolveValueLabel,\n} from './BackofficeEntityDetailPage.helpers.js';\nimport {\n normalizeTechnicalIdentifier,\n TechnicalIdentifierValue,\n type TechnicalIdentifierVariant,\n} from '../components/backoffice/technical/TechnicalIdentifierValue.js';\n\nexport type ResolvedFieldItem = {\n id: string;\n label: string;\n size: BackofficeFieldSize;\n value: ReactNode;\n copyValue?: string;\n fullWidth?: boolean;\n};\n\nexport type ResolvedHeaderItem = {\n id: string;\n label: string;\n value: ReactNode;\n};\n\nexport type FlagIconName =\n | 'shield-lock'\n | 'shield-off'\n | 'settings-check'\n | 'settings-x'\n | 'x-badge'\n | 'chat-check'\n | 'key'\n | 'key-off'\n | 'lock'\n | 'lock-open'\n | 'robot-check'\n | 'robot-x'\n | 'rocket'\n | 'rocket-off';\n\nexport type ResolvedFlagTag = {\n tone: 'neutral' | 'info' | 'success' | 'warning' | 'danger';\n label: string;\n iconName?: FlagIconName;\n};\n\nexport const resolveFlagTag = (\n variant: BackofficeFlagVariant,\n value: boolean,\n t: TFunction,\n): ResolvedFlagTag => {\n switch (variant) {\n case 'yesNo':\n return value\n ? { tone: 'success', label: t('common.boolean.yes') }\n : { tone: 'neutral', label: t('common.boolean.no') };\n case 'capability':\n return value\n ? {\n tone: 'success',\n label: t('flags.capability.allowed'),\n iconName: 'shield-lock',\n }\n : {\n tone: 'neutral',\n label: t('flags.capability.denied'),\n iconName: 'shield-off',\n };\n case 'enabled':\n return value\n ? {\n tone: 'success',\n label: t('flags.enabled.enabled'),\n iconName: 'settings-check',\n }\n : {\n tone: 'neutral',\n label: t('flags.enabled.disabled'),\n iconName: 'settings-x',\n };\n case 'failure':\n return value\n ? {\n tone: 'danger',\n label: t('flags.failure.failed'),\n iconName: 'x-badge',\n }\n : {\n tone: 'success',\n label: t('flags.failure.ok'),\n iconName: 'chat-check',\n };\n case 'encrypted':\n return value\n ? {\n tone: 'info',\n label: t('flags.encrypted.encrypted'),\n iconName: 'key',\n }\n : {\n tone: 'neutral',\n label: t('flags.encrypted.notEncrypted'),\n iconName: 'key-off',\n };\n case 'locked':\n return value\n ? {\n tone: 'warning',\n label: t('flags.locked.locked'),\n iconName: 'lock',\n }\n : {\n tone: 'success',\n label: t('flags.locked.unlocked'),\n iconName: 'lock-open',\n };\n case 'default':\n return value\n ? { tone: 'info', label: t('flags.default.default') }\n : { tone: 'neutral', label: t('flags.default.notDefault') };\n case 'agentManaged':\n return value\n ? {\n tone: 'info',\n label: t('flags.agentManaged.agentManaged'),\n iconName: 'robot-check',\n }\n : {\n tone: 'neutral',\n label: t('flags.agentManaged.userManaged'),\n iconName: 'robot-x',\n };\n case 'deployedProduction':\n return value\n ? {\n tone: 'success',\n label: t('flags.deployedProduction.deployed'),\n iconName: 'rocket',\n }\n : {\n tone: 'neutral',\n label: t('flags.deployedProduction.notDeployed'),\n iconName: 'rocket-off',\n };\n case 'forced':\n return value\n ? { tone: 'warning', label: t('flags.forced.forced') }\n : { tone: 'neutral', label: t('flags.forced.normal') };\n default:\n throw new Error(`Unsupported flag variant: ${String(variant)}`);\n }\n};\n\nexport const resolveInlineValue = (\n value: BackofficeInlineValueSpec,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n },\n): ReactNode => {\n const { tApp, t, resolveEntityHref, renderLink } = options;\n const fallback = t('common.notAvailable');\n\n if (value.type === 'text') {\n const resolved = resolveValueLabel(value.value, tApp);\n return isEmptyText(resolved) ? fallback : resolved;\n }\n\n if (value.type === 'entityRef') {\n const { id } = value;\n if (id == null || id.trim() === '') {\n return fallback;\n }\n const resolvedLabel = resolveValueLabel(value.label, tApp);\n const label =\n resolvedLabel != null && String(resolvedLabel).trim() !== ''\n ? resolvedLabel\n : null;\n if (label == null) {\n return fallback;\n }\n const href = resolveEntityHref?.(value.entity, id) ?? null;\n return href != null ? renderLink(href, label) : label;\n }\n\n const { href } = value;\n if (href == null || href.trim() === '') {\n return fallback;\n }\n const label = resolveValueLabel(value.label, tApp);\n if (isEmptyText(label)) {\n return fallback;\n }\n return renderLink(href, label);\n};\n\nexport const resolveHeaderMeta = <Node>(\n meta: BackofficeDetailHeaderMetaSpec<Node>,\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n renderDate: (\n value: string | number | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n },\n): ReactNode => {\n const { tApp, t, resolveEntityHref, renderDate, renderLink } = options;\n const fallback = t('common.notAvailable');\n\n if (meta.type === 'dateTime') {\n return renderDate(meta.value(node), fallback);\n }\n\n if (meta.type === 'entityRef') {\n const idValue = meta.id(node);\n if (idValue == null || idValue.trim() === '') {\n return fallback;\n }\n const labelValue = resolveValueLabel(meta.value?.(node), tApp);\n const label =\n labelValue != null && String(labelValue).trim() !== ''\n ? labelValue\n : null;\n if (label == null) {\n return fallback;\n }\n const href = resolveEntityHref?.(meta.entity, idValue) ?? null;\n return href != null ? renderLink(href, label) : label;\n }\n\n if (meta.type === 'link') {\n const href = meta.href(node);\n const labelValue = resolveValueLabel(meta.value(node), tApp);\n if (href == null || href.trim() === '' || isEmptyText(labelValue)) {\n return fallback;\n }\n return renderLink(href, labelValue);\n }\n\n const value = resolveValueLabel(meta.value(node), tApp);\n return isEmptyText(value) ? fallback : value;\n};\n\nexport const resolveHeaderStatus = <Node>(\n status: BackofficeDetailHeaderStatusSpec<Node>,\n node: Node,\n tApp: TFunction,\n renderers: {\n renderBadgeRow: (items: readonly BackofficeBadgeItem[]) => ReactNode;\n renderTag: (\n tone: ReturnType<typeof resolveBadgeTone<Node>>,\n label: string,\n ) => ReactNode;\n },\n): ReactNode | undefined => {\n if (status.type === 'badgeRow') {\n const items = status.items(node).map((item) => {\n const resolvedLabel = resolveValueLabel(item.label, tApp);\n const label = resolvedLabel == null ? '' : String(resolvedLabel);\n return { ...item, label };\n });\n if (items.length === 0) {\n return undefined;\n }\n return renderers.renderBadgeRow(items);\n }\n\n const value = resolveValueLabel(status.value(node), tApp);\n const label = value == null ? '' : String(value);\n if (label.trim() === '') {\n return undefined;\n }\n const tone = resolveBadgeTone(status.tone, node);\n return renderers.renderTag(tone, label);\n};\n\nexport const buildFieldItems = <Node>(\n fields: readonly BackofficeDetailFieldSpec<Node>[],\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n formatNumber: (value: number | null | undefined) => string;\n formatCurrency: (value: number | null | undefined) => string;\n formatCurrencyTitle?: (value: number | null | undefined) => string | null;\n formatPercent: (value: number | null | undefined) => string;\n renderTag: (\n tone: ReturnType<typeof resolveBadgeTone<Node>>,\n label: string,\n ) => ReactNode;\n renderBadgeRow: (items: readonly BackofficeBadgeItem[]) => ReactNode;\n renderDate: (\n value: string | number | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderFlagTag: (tag: ResolvedFlagTag) => ReactNode;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n renderTaggedValue: (\n tag: {\n label: string;\n tone?: ReturnType<typeof resolveBadgeTone<Node>>;\n } | null,\n value: ReactNode,\n ) => ReactNode;\n wrapCustomNode: (id: string, node: ReactNode) => ReactNode;\n },\n): {\n items: ResolvedFieldItem[];\n customNodes: ReactNode[];\n} => {\n const {\n tApp,\n t,\n resolveEntityHref,\n formatNumber,\n formatCurrency,\n formatCurrencyTitle,\n formatPercent,\n renderTag,\n renderBadgeRow,\n renderDate,\n renderFlagTag,\n renderLink,\n renderTaggedValue,\n wrapCustomNode,\n } = options;\n const items: ResolvedFieldItem[] = [];\n const customNodes: ReactNode[] = [];\n const fallback = t('common.notAvailable');\n\n fields.forEach((field, index) => {\n const id = `${field.type}-${index}`;\n\n switch (field.type) {\n case 'text': {\n const value = resolveValueLabel(field.value(node), tApp);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value,\n copyValue: field.copyValue?.(node) ?? undefined,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'badge': {\n const value = resolveValueLabel(field.value(node), tApp);\n const label = value != null ? String(value) : '';\n const tone = resolveBadgeTone(field.tone, node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: label.trim() !== '' ? renderTag(tone, label) : null,\n });\n break;\n }\n case 'badgeRow': {\n const badgeItems = field.items(node).map((item) => {\n const resolvedLabel = resolveValueLabel(item.label, tApp);\n const label = resolvedLabel == null ? '' : String(resolvedLabel);\n return { ...item, label };\n });\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: badgeItems.length > 0 ? renderBadgeRow(badgeItems) : null,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'dateTime': {\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: renderDate(field.value(node), fallback),\n });\n break;\n }\n case 'number': {\n const value = field.value(node);\n let formatted: ReactNode | null = null;\n if (value != null) {\n if (field.format === 'currency') {\n const label = formatCurrency(value);\n formatted = createElement(\n 'span',\n { title: formatCurrencyTitle?.(value) ?? undefined },\n label,\n );\n } else if (field.format === 'percent') {\n formatted = formatPercent(value);\n } else {\n formatted = formatNumber(value);\n }\n }\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: formatted,\n });\n break;\n }\n case 'flag': {\n const value = field.value(node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n value != null\n ? renderFlagTag(resolveFlagTag(field.variant, value, t))\n : null,\n });\n break;\n }\n case 'entityRef': {\n const idValue = field.id(node);\n let value: ReactNode | null = null;\n if (idValue != null && idValue.trim() !== '') {\n const labelValue = field.value?.(node);\n const label =\n labelValue != null && labelValue.trim() !== '' ? labelValue : null;\n const href = resolveEntityHref?.(field.entity, idValue) ?? null;\n if (label != null) {\n value = href != null ? renderLink(href, label) : label;\n }\n }\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: value ?? fallback,\n });\n break;\n }\n case 'technicalIdentifier': {\n const value = field.value(node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n value == null\n ? null\n : createElement(TechnicalIdentifierValue, {\n value,\n copyValue: field.copyValue?.(node) ?? undefined,\n variant: field.variant,\n copyLabel: t('common.actions.copy'),\n }),\n copyValue: field.copyValue?.(node) ?? undefined,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'link': {\n const href = field.href(node);\n const labelValue = field.value(node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n href != null && href.trim() !== '' && !isEmptyText(labelValue)\n ? renderLink(href, labelValue)\n : null,\n });\n break;\n }\n case 'taggedValue': {\n const tag = field.tag(node);\n const valueNode = resolveInlineValue(field.value(node), {\n tApp,\n t,\n resolveEntityHref,\n renderLink,\n });\n const resolvedTag =\n tag == null\n ? null\n : {\n ...tag,\n label: (() => {\n const labelValue = resolveValueLabel(tag.label, tApp);\n return labelValue == null ? '' : String(labelValue);\n })(),\n };\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n resolvedTag != null || valueNode != null\n ? renderTaggedValue(resolvedTag, valueNode)\n : null,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'custom': {\n const custom = field.render(node) as ReactNode;\n if (custom == null) {\n break;\n }\n if (field.label != null) {\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: custom,\n fullWidth: field.fullWidth,\n });\n break;\n }\n customNodes.push(wrapCustomNode(id, custom));\n break;\n }\n default:\n break;\n }\n });\n\n return { items, customNodes };\n};\n\nexport const resolveHeaderItems = <Node>(\n header: BackofficeDetailHeaderConfig<Node>,\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n renderDate: (\n value: string | number | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderTag: (\n tone: ReturnType<typeof resolveBadgeTone<Node>>,\n label: string,\n ) => ReactNode;\n renderBadgeRow: (items: readonly BackofficeBadgeItem[]) => ReactNode;\n },\n): {\n title: string;\n subtitle?: ReactNode;\n badges?: ReactNode;\n status?: ReactNode;\n items?: readonly ResolvedHeaderItem[];\n} => {\n const {\n tApp,\n t,\n resolveEntityHref,\n renderLink,\n renderDate,\n renderTag,\n renderBadgeRow,\n } = options;\n const resolvedTitle =\n header.titleValue?.(node, tApp) ?? resolveLabel(header.title, tApp);\n const rawNodeId =\n node != null &&\n typeof node === 'object' &&\n 'id' in node &&\n typeof node.id === 'string'\n ? node.id.trim()\n : null;\n const title =\n resolvedTitle.trim() === '' ||\n (rawNodeId != null && resolvedTitle.trim() === rawNodeId)\n ? resolveLabel(header.title, tApp)\n : resolvedTitle;\n\n let subtitleNode: ReactNode | undefined;\n if (header.subtitleItems != null && header.subtitleItems.length > 0) {\n const { subtitleItems } = header;\n const separator = header.subtitleSeparator ?? ' / ';\n const parts: ReactNode[] = [];\n subtitleItems.forEach((item, index) => {\n parts.push(\n createElement(\n 'span',\n { key: item.id },\n resolveInlineValue(item.value(node), {\n tApp,\n t,\n resolveEntityHref,\n renderLink,\n }),\n ),\n );\n if (index < subtitleItems.length - 1) {\n parts.push(createElement('span', { key: `${item.id}-sep` }, separator));\n }\n });\n subtitleNode = createElement('span', null, ...parts);\n } else {\n const subtitleValue =\n header.subtitleValue?.(node, tApp) ??\n (header.subtitle != null ? resolveLabel(header.subtitle, tApp) : null);\n subtitleNode =\n subtitleValue != null && subtitleValue.trim() !== ''\n ? subtitleValue\n : undefined;\n }\n\n const badgeNodes: ReactNode[] = [];\n header.badges?.forEach((badge, index) => {\n const label = resolveLabel(badge.label, tApp);\n const resolvedValue = resolveValueLabel(badge.value(node), tApp);\n const value = resolvedValue == null ? '' : String(resolvedValue);\n if (value.trim() === '') {\n return;\n }\n badgeNodes.push(\n renderTag(resolveBadgeTone(badge.tone, node), `${label}: ${value}`),\n );\n if (typeof badgeNodes[badgeNodes.length - 1] === 'object') {\n badgeNodes[badgeNodes.length - 1] = createElement(\n Fragment,\n { key: `${label}-${index}` },\n badgeNodes[badgeNodes.length - 1],\n );\n }\n });\n\n const status =\n header.status != null\n ? resolveHeaderStatus(header.status, node, tApp, {\n renderBadgeRow,\n renderTag,\n })\n : undefined;\n\n const items = header.meta?.map((meta, index) => {\n const label = resolveLabel(meta.label, tApp);\n return {\n id: `${label}-${index}`,\n label,\n value: resolveHeaderMeta(meta, node, {\n tApp,\n t,\n resolveEntityHref,\n renderDate,\n renderLink,\n }),\n };\n });\n\n return {\n title,\n subtitle: subtitleNode,\n badges:\n badgeNodes.length > 0\n ? createElement(Fragment, null, ...badgeNodes)\n : undefined,\n status,\n items,\n };\n};\n\nconst renderTimelinePayload = (payload: unknown): ReactNode | undefined => {\n if (payload == null) {\n return undefined;\n }\n if (\n typeof payload === 'string' ||\n typeof payload === 'number' ||\n typeof payload === 'boolean'\n ) {\n return String(payload);\n }\n\n try {\n return createElement('pre', null, JSON.stringify(payload, null, 2));\n } catch {\n const fallback =\n payload instanceof Error ? payload.message : '[unserializable payload]';\n return createElement('pre', null, fallback);\n }\n};\n\nconst resolveTechnicalVariant = (\n refKind: 'id' | 'slug' | 'path' | 'url' | 'hash' | 'external' | 'text',\n): TechnicalIdentifierVariant | null => {\n if (refKind === 'id' || refKind === 'hash' || refKind === 'external') {\n return refKind;\n }\n return null;\n};\n\nconst renderReferenceValue = (args: {\n value: BackofficeValueLabel;\n href?: string | null;\n refKind: 'id' | 'slug' | 'path' | 'url' | 'hash' | 'external' | 'text';\n copyValue?: string | null;\n tApp: TFunction;\n t: TFunction;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n}): ReactNode => {\n const { value, href, refKind, copyValue, tApp, t, renderLink } = args;\n const resolvedValue = resolveValueLabel(value, tApp);\n const technicalVariant = resolveTechnicalVariant(refKind);\n if (technicalVariant != null) {\n const normalized = normalizeTechnicalIdentifier(resolvedValue);\n if (normalized == null) {\n return t('common.notAvailable');\n }\n return createElement(TechnicalIdentifierValue, {\n value: normalized,\n copyValue: copyValue ?? normalized,\n variant: technicalVariant,\n copyLabel: t('common.actions.copy'),\n });\n }\n if (href != null && href.trim() !== '' && !isEmptyText(resolvedValue)) {\n return renderLink(href, resolvedValue);\n }\n return resolvedValue ?? t('common.notAvailable');\n};\n\nexport const renderBlocks = <Node>(\n blocks: readonly BackofficeDetailBlockSpec<Node>[] | undefined,\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref: (entityId: string, refId: string) => string | null;\n keyPrefix?: string;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n renderDate: (\n value: string | number | Date | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderTag: (tone: BackofficeTone, label: string) => ReactNode;\n renderMetricGroup: (args: {\n key: string;\n title: string;\n description?: string;\n density?: 'compact' | 'comfortable';\n items: readonly {\n id: string;\n label: string;\n value: ReactNode;\n hint?: ReactNode;\n tone?: BackofficeTone;\n copyValue?: string;\n }[];\n }) => ReactNode;\n renderTimeline: (args: {\n key: string;\n title: string;\n description?: string;\n events: readonly {\n id: string;\n label: string;\n timestamp?: ReactNode;\n description?: ReactNode;\n actor?: ReactNode;\n tone?: BackofficeTone;\n payload?: ReactNode;\n }[];\n }) => ReactNode;\n renderAuditTimeline: (args: {\n key: string;\n title: string;\n description?: string;\n events: readonly {\n id: string;\n title: ReactNode;\n time?: ReactNode;\n actor?: ReactNode;\n source?: ReactNode;\n }[];\n }) => ReactNode;\n renderRelations: (args: {\n key: string;\n title: string;\n description?: string;\n items: readonly {\n id: string;\n label: string;\n count?: ReactNode;\n href?: string;\n description?: ReactNode;\n tone?: BackofficeTone;\n }[];\n }) => ReactNode;\n renderContextStack: (args: {\n key: string;\n title: string;\n items: readonly {\n id: string;\n label: string;\n value: ReactNode | null | undefined;\n }[];\n }) => ReactNode;\n renderCustomSection: (\n key: string,\n title: string,\n child: ReactNode,\n ) => ReactNode;\n wrapCustomNode: (key: string, node: ReactNode) => ReactNode;\n resolveTableColumns: (\n columns: readonly BackofficeColumnSpec[],\n ) => readonly DataTableColumn<unknown>[];\n renderTable: (args: {\n key: string;\n title: string;\n description?: string;\n columns: readonly DataTableColumn<unknown>[];\n rows: readonly unknown[];\n }) => ReactNode;\n renderPayload: (args: {\n key: string;\n title: string;\n description?: string;\n content: unknown;\n format: BackofficePayloadFormat;\n }) => ReactNode;\n renderKeyValueListSection: (args: {\n key: string;\n title: string;\n description?: string;\n items: readonly { id: string; label: string; value: ReactNode }[];\n }) => ReactNode;\n },\n): ReactNode[] => {\n const { tApp, t, keyPrefix } = options;\n if (blocks == null || blocks.length === 0) {\n return [];\n }\n\n return blocks.map((block, index): ReactNode => {\n const key =\n keyPrefix != null\n ? `${keyPrefix}-${block.kind}-${index}`\n : `${block.kind}-${index}`;\n\n if (block.kind === 'custom') {\n const custom = block.render(node) as ReactNode;\n if (custom == null) {\n return null;\n }\n if (block.label != null) {\n return options.renderCustomSection(\n key,\n resolveLabel(block.label, tApp),\n custom,\n );\n }\n return options.wrapCustomNode(key, custom);\n }\n\n const title =\n 'title' in block\n ? resolveLabel(block.title, tApp)\n : resolveLabel(block.label, tApp);\n const description =\n block.description != null\n ? resolveLabel(block.description, tApp)\n : undefined;\n\n if (block.kind === 'summary') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.items.map((item) => {\n const value = resolveValueLabel(item.value(node), tApp);\n const href = item.href?.(node);\n const tone = item.tone?.(node);\n let valueNode: ReactNode = value ?? t('common.notAvailable');\n if (href != null && href.trim() !== '' && !isEmptyText(value)) {\n valueNode = options.renderLink(href, value);\n } else if (tone != null && !isEmptyText(value)) {\n valueNode = options.renderTag(tone, String(value));\n }\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n value: valueNode,\n };\n }),\n });\n }\n\n if (block.kind === 'metrics') {\n return options.renderMetricGroup({\n key,\n title,\n description,\n density: block.density,\n items: block.items.map((item) => {\n const formattedValue = item.formattedValue?.(node);\n const value = resolveValueLabel(item.value(node), tApp);\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n value: formattedValue ?? value ?? t('common.notAvailable'),\n hint: resolveValueLabel(item.hint?.(node), tApp),\n tone: item.tone?.(node),\n copyValue: item.copyValue?.(node) ?? undefined,\n };\n }),\n });\n }\n\n if (block.kind === 'states') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.states.map((state) => {\n const display = state.getDisplay(state.value(node), node);\n return {\n id: state.id,\n label: resolveLabel(state.label, tApp),\n value: options.renderTag(\n display.tone,\n String(\n resolveValueLabel(display.label, tApp) ??\n t('common.notAvailable'),\n ),\n ),\n };\n }),\n });\n }\n\n if (block.kind === 'context') {\n return options.renderContextStack({\n key,\n title,\n items: block.items.map((item) => {\n const value = resolveValueLabel(item.value(node), tApp);\n const href = item.href?.(node);\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n value:\n href != null && href.trim() !== '' && !isEmptyText(value)\n ? options.renderLink(href, value)\n : value,\n };\n }),\n });\n }\n\n if (block.kind === 'relationSummary') {\n return options.renderRelations({\n key,\n title,\n description,\n items: block.items.map((item) => {\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n count: item.count?.(node) ?? null,\n href: item.href?.(node) ?? undefined,\n description: resolveValueLabel(item.description?.(node), tApp),\n tone: item.tone?.(node),\n };\n }),\n });\n }\n\n if (block.kind === 'timeline') {\n return options.renderTimeline({\n key,\n title,\n description,\n events: block.events.map((event) => {\n const state = event.state?.(node);\n const stateLabel =\n state == null ? null : resolveValueLabel(state.label, tApp);\n const stateText = stateLabel == null ? null : String(stateLabel);\n return {\n id: event.id,\n label:\n stateText == null || stateText.trim() === ''\n ? resolveLabel(event.label, tApp)\n : `${resolveLabel(event.label, tApp)}: ${stateText}`,\n timestamp:\n event.timestamp == null\n ? undefined\n : options.renderDate(\n event.timestamp(node),\n t('common.notAvailable'),\n ),\n description: resolveValueLabel(event.description?.(node), tApp),\n actor: resolveValueLabel(event.actor?.(node), tApp),\n tone: state?.tone,\n payload: renderTimelinePayload(event.payload?.(node)),\n };\n }),\n });\n }\n\n if (block.kind === 'audit') {\n return options.renderAuditTimeline({\n key,\n title,\n description,\n events: block.items.map((item) => {\n const actor = resolveValueLabel(item.actor?.(node), tApp);\n const source = resolveValueLabel(item.source?.(node), tApp);\n return {\n id: item.id,\n title: resolveLabel(item.label, tApp),\n time: options.renderDate(\n item.timestamp?.(node),\n t('common.notAvailable'),\n ),\n actor: isEmptyText(actor) ? undefined : actor,\n source: isEmptyText(source) ? undefined : source,\n };\n }),\n });\n }\n\n if (block.kind === 'references') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.references.map((reference) => {\n const href = reference.href?.(node);\n return {\n id: reference.id,\n label: resolveLabel(reference.label, tApp),\n value: renderReferenceValue({\n value: reference.value(node),\n href,\n refKind: reference.refKind ?? 'text',\n copyValue: reference.copyValue?.(node) ?? undefined,\n tApp,\n t,\n renderLink: options.renderLink,\n }),\n };\n }),\n });\n }\n\n if (block.kind === 'actionResult') {\n const items: { id: string; label: string; value: ReactNode }[] = [];\n const status = block.status?.(node);\n if (status != null) {\n items.push({\n id: `${block.id}-status`,\n label: t('detail.actionResult.status'),\n value: options.renderTag(\n status.tone,\n String(\n resolveValueLabel(status.label, tApp) ?? t('common.notAvailable'),\n ),\n ),\n });\n }\n const message = resolveValueLabel(block.message?.(node), tApp);\n if (!isEmptyText(message)) {\n items.push({\n id: `${block.id}-message`,\n label: t('detail.actionResult.message'),\n value: message,\n });\n }\n block.references?.forEach((reference) => {\n items.push({\n id: reference.id,\n label: resolveLabel(reference.label, tApp),\n value: renderReferenceValue({\n value: reference.value(node),\n href: reference.href?.(node),\n refKind: reference.refKind ?? 'text',\n copyValue: reference.copyValue?.(node) ?? undefined,\n tApp,\n t,\n renderLink: options.renderLink,\n }),\n });\n });\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items,\n });\n }\n\n if (block.kind === 'technicalFacts') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.facts.map((fact) => {\n const value = resolveValueLabel(fact.value(node), tApp);\n const href = fact.href?.(node);\n const copyValue = fact.copyValue?.(node) ?? undefined;\n return {\n id: fact.id,\n label: resolveLabel(fact.label, tApp),\n value:\n copyValue != null && copyValue.trim() !== ''\n ? createElement(TechnicalIdentifierValue, {\n value: value ?? copyValue,\n copyValue,\n variant: 'external',\n copyLabel: t('common.actions.copy'),\n })\n : href != null && href.trim() !== '' && !isEmptyText(value)\n ? options.renderLink(href, value)\n : (value ?? t('common.notAvailable')),\n };\n }),\n });\n }\n\n if (block.kind === 'table') {\n return options.renderTable({\n key,\n title,\n description,\n columns: options.resolveTableColumns(block.columns),\n rows: block.rows(node) as readonly unknown[],\n });\n }\n\n return options.renderPayload({\n key,\n title,\n description,\n content: block.value(node),\n format: block.format ?? 'json',\n });\n });\n};\n"],"mappings":";;;;AAqEA,IAAa,KACX,GACA,GACA,MACoB;CACpB,QAAQ,GAAR;EACE,KAAK,SACH,OAAO,IACH;GAAE,MAAM;GAAW,OAAO,EAAE,oBAAoB;EAAE,IAClD;GAAE,MAAM;GAAW,OAAO,EAAE,mBAAmB;EAAE;EACvD,KAAK,cACH,OAAO,IACH;GACE,MAAM;GACN,OAAO,EAAE,0BAA0B;GACnC,UAAU;EACZ,IACA;GACE,MAAM;GACN,OAAO,EAAE,yBAAyB;GAClC,UAAU;EACZ;EACN,KAAK,WACH,OAAO,IACH;GACE,MAAM;GACN,OAAO,EAAE,uBAAuB;GAChC,UAAU;EACZ,IACA;GACE,MAAM;GACN,OAAO,EAAE,wBAAwB;GACjC,UAAU;EACZ;EACN,KAAK,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IACH,CAAC;GACH,CAAC,GACM,EAAQ,0BAA0B;IACvC;IACA;IACA;IACA;GACF,CAAC;EACH;EAwCA,OAtCI,EAAM,SAAS,mBACV,EAAQ,0BAA0B;GACvC;GACA;GACA;GACA,OAAO,EAAM,MAAM,KAAK,MAAS;IAC/B,IAAM,IAAQ,EAAkB,EAAK,MAAM,CAAI,GAAG,CAAI,GAChD,IAAO,EAAK,OAAO,CAAI,GACvB,IAAY,EAAK,YAAY,CAAI,KAAK,KAAA;IAC5C,OAAO;KACL,IAAI,EAAK;KACT,OAAO,EAAa,EAAK,OAAO,CAAI;KACpC,OACE,KAAa,QAAQ,EAAU,KAAK,MAAM,KACtC,EAAc,GAA0B;MACtC,OAAO,KAAS;MAChB;MACA,SAAS;MACT,WAAW,EAAE,qBAAqB;KACpC,CAAC,IACD,KAAQ,QAAQ,EAAK,KAAK,MAAM,MAAM,CAAC,EAAY,CAAK,IACtD,EAAQ,WAAW,GAAM,CAAK,IAC7B,KAAS,EAAE,qBAAqB;IAC3C;GACF,CAAC;EACH,CAAC,IAGC,EAAM,SAAS,UACV,EAAQ,YAAY;GACzB;GACA;GACA;GACA,SAAS,EAAQ,oBAAoB,EAAM,OAAO;GAClD,MAAM,EAAM,KAAK,CAAI;EACvB,CAAC,IAGI,EAAQ,cAAc;GAC3B;GACA;GACA;GACA,SAAS,EAAM,MAAM,CAAI;GACzB,QAAQ,EAAM,UAAU;EAC1B,CAAC;CACH,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"BackofficeEntityDetailPage.view-helpers.js","names":[],"sources":["../../../src/pages/BackofficeEntityDetailPage.view-helpers.ts"],"sourcesContent":["/* eslint-disable no-ternary */\nimport type {\n BackofficeBadgeItem,\n BackofficeColumnSpec,\n BackofficeDetailBlockSpec,\n BackofficeDetailFieldSpec,\n BackofficeDetailHeaderConfig,\n BackofficeDetailHeaderMetaSpec,\n BackofficeDetailHeaderStatusSpec,\n BackofficeFieldSize,\n BackofficeFlagVariant,\n BackofficeInlineValueSpec,\n BackofficePayloadFormat,\n BackofficeTone,\n BackofficeValueLabel,\n} from '@plumile/backoffice-core/types.js';\nimport type { DataTableColumn } from '@plumile/ui/components/data-table/DataTable.js';\nimport type { TFunction } from 'i18next';\nimport { Fragment, createElement, type ReactNode } from 'react';\n\nimport {\n isEmptyText,\n resolveLabel,\n resolveBadgeTone,\n resolveValueLabel,\n} from './BackofficeEntityDetailPage.helpers.js';\nimport {\n normalizeTechnicalIdentifier,\n TechnicalIdentifierValue,\n type TechnicalIdentifierVariant,\n} from '../components/backoffice/technical/TechnicalIdentifierValue.js';\n\nexport type ResolvedFieldItem = {\n id: string;\n label: string;\n size: BackofficeFieldSize;\n value: ReactNode;\n copyValue?: string;\n fullWidth?: boolean;\n};\n\nexport type ResolvedHeaderItem = {\n id: string;\n label: string;\n value: ReactNode;\n};\n\nexport type FlagIconName =\n | 'shield-lock'\n | 'shield-off'\n | 'settings-check'\n | 'settings-x'\n | 'x-badge'\n | 'chat-check'\n | 'key'\n | 'key-off'\n | 'lock'\n | 'lock-open'\n | 'robot-check'\n | 'robot-x'\n | 'rocket'\n | 'rocket-off';\n\nexport type ResolvedFlagTag = {\n tone: 'neutral' | 'info' | 'success' | 'warning' | 'danger';\n label: string;\n iconName?: FlagIconName;\n};\n\nexport const resolveFlagTag = (\n variant: BackofficeFlagVariant,\n value: boolean,\n t: TFunction,\n): ResolvedFlagTag => {\n switch (variant) {\n case 'yesNo':\n return value\n ? { tone: 'success', label: t('common.boolean.yes') }\n : { tone: 'neutral', label: t('common.boolean.no') };\n case 'capability':\n return value\n ? {\n tone: 'success',\n label: t('flags.capability.allowed'),\n iconName: 'shield-lock',\n }\n : {\n tone: 'neutral',\n label: t('flags.capability.denied'),\n iconName: 'shield-off',\n };\n case 'enabled':\n return value\n ? {\n tone: 'success',\n label: t('flags.enabled.enabled'),\n iconName: 'settings-check',\n }\n : {\n tone: 'neutral',\n label: t('flags.enabled.disabled'),\n iconName: 'settings-x',\n };\n case 'failure':\n return value\n ? {\n tone: 'danger',\n label: t('flags.failure.failed'),\n iconName: 'x-badge',\n }\n : {\n tone: 'success',\n label: t('flags.failure.ok'),\n iconName: 'chat-check',\n };\n case 'encrypted':\n return value\n ? {\n tone: 'info',\n label: t('flags.encrypted.encrypted'),\n iconName: 'key',\n }\n : {\n tone: 'neutral',\n label: t('flags.encrypted.notEncrypted'),\n iconName: 'key-off',\n };\n case 'locked':\n return value\n ? {\n tone: 'warning',\n label: t('flags.locked.locked'),\n iconName: 'lock',\n }\n : {\n tone: 'success',\n label: t('flags.locked.unlocked'),\n iconName: 'lock-open',\n };\n case 'default':\n return value\n ? { tone: 'info', label: t('flags.default.default') }\n : { tone: 'neutral', label: t('flags.default.notDefault') };\n case 'agentManaged':\n return value\n ? {\n tone: 'info',\n label: t('flags.agentManaged.agentManaged'),\n iconName: 'robot-check',\n }\n : {\n tone: 'neutral',\n label: t('flags.agentManaged.userManaged'),\n iconName: 'robot-x',\n };\n case 'deployedProduction':\n return value\n ? {\n tone: 'success',\n label: t('flags.deployedProduction.deployed'),\n iconName: 'rocket',\n }\n : {\n tone: 'neutral',\n label: t('flags.deployedProduction.notDeployed'),\n iconName: 'rocket-off',\n };\n case 'forced':\n return value\n ? { tone: 'warning', label: t('flags.forced.forced') }\n : { tone: 'neutral', label: t('flags.forced.normal') };\n default:\n throw new Error(`Unsupported flag variant: ${String(variant)}`);\n }\n};\n\nexport const resolveInlineValue = (\n value: BackofficeInlineValueSpec,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n },\n): ReactNode => {\n const { tApp, t, resolveEntityHref, renderLink } = options;\n const fallback = t('common.notAvailable');\n\n if (value.type === 'text') {\n const resolved = resolveValueLabel(value.value, tApp);\n return isEmptyText(resolved) ? fallback : resolved;\n }\n\n if (value.type === 'entityRef') {\n const { id } = value;\n if (id == null || id.trim() === '') {\n return fallback;\n }\n const resolvedLabel = resolveValueLabel(value.label, tApp);\n const label =\n resolvedLabel != null && String(resolvedLabel).trim() !== ''\n ? resolvedLabel\n : null;\n if (label == null) {\n return fallback;\n }\n const href = resolveEntityHref?.(value.entity, id) ?? null;\n return href != null ? renderLink(href, label) : label;\n }\n\n const { href } = value;\n if (href == null || href.trim() === '') {\n return fallback;\n }\n const label = resolveValueLabel(value.label, tApp);\n if (isEmptyText(label)) {\n return fallback;\n }\n return renderLink(href, label);\n};\n\nexport const resolveHeaderMeta = <Node>(\n meta: BackofficeDetailHeaderMetaSpec<Node>,\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n renderDate: (\n value: string | number | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n },\n): ReactNode => {\n const { tApp, t, resolveEntityHref, renderDate, renderLink } = options;\n const fallback = t('common.notAvailable');\n\n if (meta.type === 'dateTime') {\n return renderDate(meta.value(node), fallback);\n }\n\n if (meta.type === 'entityRef') {\n const idValue = meta.id(node);\n if (idValue == null || idValue.trim() === '') {\n return fallback;\n }\n const labelValue = resolveValueLabel(meta.value?.(node), tApp);\n const label =\n labelValue != null && String(labelValue).trim() !== ''\n ? labelValue\n : null;\n if (label == null) {\n return fallback;\n }\n const href = resolveEntityHref?.(meta.entity, idValue) ?? null;\n return href != null ? renderLink(href, label) : label;\n }\n\n if (meta.type === 'link') {\n const href = meta.href(node);\n const labelValue = resolveValueLabel(meta.value(node), tApp);\n if (href == null || href.trim() === '' || isEmptyText(labelValue)) {\n return fallback;\n }\n return renderLink(href, labelValue);\n }\n\n const value = resolveValueLabel(meta.value(node), tApp);\n return isEmptyText(value) ? fallback : value;\n};\n\nexport const resolveHeaderStatus = <Node>(\n status: BackofficeDetailHeaderStatusSpec<Node>,\n node: Node,\n tApp: TFunction,\n renderers: {\n renderBadgeRow: (items: readonly BackofficeBadgeItem[]) => ReactNode;\n renderTag: (\n tone: ReturnType<typeof resolveBadgeTone<Node>>,\n label: string,\n ) => ReactNode;\n },\n): ReactNode | undefined => {\n if (status.type === 'badgeRow') {\n const items = status.items(node).map((item) => {\n const resolvedLabel = resolveValueLabel(item.label, tApp);\n const label = resolvedLabel == null ? '' : String(resolvedLabel);\n return { ...item, label };\n });\n if (items.length === 0) {\n return undefined;\n }\n return renderers.renderBadgeRow(items);\n }\n\n const value = resolveValueLabel(status.value(node), tApp);\n const label = value == null ? '' : String(value);\n if (label.trim() === '') {\n return undefined;\n }\n const tone = resolveBadgeTone(status.tone, node);\n return renderers.renderTag(tone, label);\n};\n\nexport const buildFieldItems = <Node>(\n fields: readonly BackofficeDetailFieldSpec<Node>[],\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n formatNumber: (value: number | null | undefined) => string;\n formatCurrency: (value: number | null | undefined) => string;\n formatCurrencyTitle?: (value: number | null | undefined) => string | null;\n formatPercent: (value: number | null | undefined) => string;\n renderTag: (\n tone: ReturnType<typeof resolveBadgeTone<Node>>,\n label: string,\n ) => ReactNode;\n renderBadgeRow: (items: readonly BackofficeBadgeItem[]) => ReactNode;\n renderDate: (\n value: string | number | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderFlagTag: (tag: ResolvedFlagTag) => ReactNode;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n renderTaggedValue: (\n tag: {\n label: string;\n tone?: ReturnType<typeof resolveBadgeTone<Node>>;\n } | null,\n value: ReactNode,\n ) => ReactNode;\n wrapCustomNode: (id: string, node: ReactNode) => ReactNode;\n },\n): {\n items: ResolvedFieldItem[];\n customNodes: ReactNode[];\n} => {\n const {\n tApp,\n t,\n resolveEntityHref,\n formatNumber,\n formatCurrency,\n formatCurrencyTitle,\n formatPercent,\n renderTag,\n renderBadgeRow,\n renderDate,\n renderFlagTag,\n renderLink,\n renderTaggedValue,\n wrapCustomNode,\n } = options;\n const items: ResolvedFieldItem[] = [];\n const customNodes: ReactNode[] = [];\n const fallback = t('common.notAvailable');\n\n fields.forEach((field, index) => {\n const id = `${field.type}-${index}`;\n\n switch (field.type) {\n case 'text': {\n const value = resolveValueLabel(field.value(node), tApp);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value,\n copyValue: field.copyValue?.(node) ?? undefined,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'badge': {\n const value = resolveValueLabel(field.value(node), tApp);\n const label = value != null ? String(value) : '';\n const tone = resolveBadgeTone(field.tone, node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: label.trim() !== '' ? renderTag(tone, label) : null,\n });\n break;\n }\n case 'badgeRow': {\n const badgeItems = field.items(node).map((item) => {\n const resolvedLabel = resolveValueLabel(item.label, tApp);\n const label = resolvedLabel == null ? '' : String(resolvedLabel);\n return { ...item, label };\n });\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: badgeItems.length > 0 ? renderBadgeRow(badgeItems) : null,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'dateTime': {\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: renderDate(field.value(node), fallback),\n });\n break;\n }\n case 'number': {\n const value = field.value(node);\n let formatted: ReactNode | null = null;\n if (value != null) {\n if (field.format === 'currency') {\n const label = formatCurrency(value);\n formatted = createElement(\n 'span',\n { title: formatCurrencyTitle?.(value) ?? undefined },\n label,\n );\n } else if (field.format === 'percent') {\n formatted = formatPercent(value);\n } else {\n formatted = formatNumber(value);\n }\n }\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: formatted,\n });\n break;\n }\n case 'flag': {\n const value = field.value(node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n value != null\n ? renderFlagTag(resolveFlagTag(field.variant, value, t))\n : null,\n });\n break;\n }\n case 'entityRef': {\n const idValue = field.id(node);\n let value: ReactNode | null = null;\n if (idValue != null && idValue.trim() !== '') {\n const labelValue = field.value?.(node);\n const label =\n labelValue != null && labelValue.trim() !== '' ? labelValue : null;\n const href = resolveEntityHref?.(field.entity, idValue) ?? null;\n if (label != null) {\n value = href != null ? renderLink(href, label) : label;\n }\n }\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: value ?? fallback,\n });\n break;\n }\n case 'technicalIdentifier': {\n const value = field.value(node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n value == null\n ? null\n : createElement(TechnicalIdentifierValue, {\n value,\n copyValue: field.copyValue?.(node) ?? undefined,\n variant: field.variant,\n copyLabel: t('common.actions.copy'),\n }),\n copyValue: field.copyValue?.(node) ?? undefined,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'link': {\n const href = field.href(node);\n const labelValue = field.value(node);\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n href != null && href.trim() !== '' && !isEmptyText(labelValue)\n ? renderLink(href, labelValue)\n : null,\n });\n break;\n }\n case 'taggedValue': {\n const tag = field.tag(node);\n const valueNode = resolveInlineValue(field.value(node), {\n tApp,\n t,\n resolveEntityHref,\n renderLink,\n });\n const resolvedTag =\n tag == null\n ? null\n : {\n ...tag,\n label: (() => {\n const labelValue = resolveValueLabel(tag.label, tApp);\n return labelValue == null ? '' : String(labelValue);\n })(),\n };\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value:\n resolvedTag != null || valueNode != null\n ? renderTaggedValue(resolvedTag, valueNode)\n : null,\n fullWidth: field.fullWidth,\n });\n break;\n }\n case 'custom': {\n const custom = field.render(node) as ReactNode;\n if (custom == null) {\n break;\n }\n if (field.label != null) {\n items.push({\n id,\n label: resolveLabel(field.label, tApp),\n size: field.size,\n value: custom,\n fullWidth: field.fullWidth,\n });\n break;\n }\n customNodes.push(wrapCustomNode(id, custom));\n break;\n }\n default:\n break;\n }\n });\n\n return { items, customNodes };\n};\n\nexport const resolveHeaderItems = <Node>(\n header: BackofficeDetailHeaderConfig<Node>,\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref?: (entityId: string, refId: string) => string | null;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n renderDate: (\n value: string | number | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderTag: (\n tone: ReturnType<typeof resolveBadgeTone<Node>>,\n label: string,\n ) => ReactNode;\n renderBadgeRow: (items: readonly BackofficeBadgeItem[]) => ReactNode;\n },\n): {\n title: string;\n subtitle?: ReactNode;\n badges?: ReactNode;\n status?: ReactNode;\n items?: readonly ResolvedHeaderItem[];\n} => {\n const {\n tApp,\n t,\n resolveEntityHref,\n renderLink,\n renderDate,\n renderTag,\n renderBadgeRow,\n } = options;\n const resolvedTitle =\n header.titleValue?.(node, tApp) ?? resolveLabel(header.title, tApp);\n const rawNodeId =\n node != null &&\n typeof node === 'object' &&\n 'id' in node &&\n typeof node.id === 'string'\n ? node.id.trim()\n : null;\n const title =\n resolvedTitle.trim() === '' ||\n (rawNodeId != null && resolvedTitle.trim() === rawNodeId)\n ? resolveLabel(header.title, tApp)\n : resolvedTitle;\n\n let subtitleNode: ReactNode | undefined;\n if (header.subtitleItems != null && header.subtitleItems.length > 0) {\n const { subtitleItems } = header;\n const separator = header.subtitleSeparator ?? ' / ';\n const parts: ReactNode[] = [];\n subtitleItems.forEach((item, index) => {\n parts.push(\n createElement(\n 'span',\n { key: item.id },\n resolveInlineValue(item.value(node), {\n tApp,\n t,\n resolveEntityHref,\n renderLink,\n }),\n ),\n );\n if (index < subtitleItems.length - 1) {\n parts.push(createElement('span', { key: `${item.id}-sep` }, separator));\n }\n });\n subtitleNode = createElement('span', null, ...parts);\n } else {\n const subtitleValue =\n header.subtitleValue?.(node, tApp) ??\n (header.subtitle != null ? resolveLabel(header.subtitle, tApp) : null);\n subtitleNode =\n subtitleValue != null && subtitleValue.trim() !== ''\n ? subtitleValue\n : undefined;\n }\n\n const badgeNodes: ReactNode[] = [];\n header.badges?.forEach((badge, index) => {\n const label = resolveLabel(badge.label, tApp);\n const resolvedValue = resolveValueLabel(badge.value(node), tApp);\n const value = resolvedValue == null ? '' : String(resolvedValue);\n if (value.trim() === '') {\n return;\n }\n badgeNodes.push(\n renderTag(resolveBadgeTone(badge.tone, node), `${label}: ${value}`),\n );\n if (typeof badgeNodes[badgeNodes.length - 1] === 'object') {\n badgeNodes[badgeNodes.length - 1] = createElement(\n Fragment,\n { key: `${label}-${index}` },\n badgeNodes[badgeNodes.length - 1],\n );\n }\n });\n\n const status =\n header.status != null\n ? resolveHeaderStatus(header.status, node, tApp, {\n renderBadgeRow,\n renderTag,\n })\n : undefined;\n\n const items = header.meta?.map((meta, index) => {\n const label = resolveLabel(meta.label, tApp);\n return {\n id: `${label}-${index}`,\n label,\n value: resolveHeaderMeta(meta, node, {\n tApp,\n t,\n resolveEntityHref,\n renderDate,\n renderLink,\n }),\n };\n });\n\n return {\n title,\n subtitle: subtitleNode,\n badges:\n badgeNodes.length > 0\n ? createElement(Fragment, null, ...badgeNodes)\n : undefined,\n status,\n items,\n };\n};\n\nconst renderTimelinePayload = (payload: unknown): ReactNode | undefined => {\n if (payload == null) {\n return undefined;\n }\n if (\n typeof payload === 'string' ||\n typeof payload === 'number' ||\n typeof payload === 'boolean'\n ) {\n return String(payload);\n }\n\n try {\n return createElement('pre', null, JSON.stringify(payload, null, 2));\n } catch {\n const fallback =\n payload instanceof Error ? payload.message : '[unserializable payload]';\n return createElement('pre', null, fallback);\n }\n};\n\nconst resolveTechnicalVariant = (\n refKind: 'id' | 'slug' | 'path' | 'url' | 'hash' | 'external' | 'text',\n): TechnicalIdentifierVariant | null => {\n if (refKind === 'id' || refKind === 'hash' || refKind === 'external') {\n return refKind;\n }\n return null;\n};\n\nconst renderReferenceValue = (args: {\n value: BackofficeValueLabel;\n href?: string | null;\n refKind: 'id' | 'slug' | 'path' | 'url' | 'hash' | 'external' | 'text';\n copyValue?: string | null;\n tApp: TFunction;\n t: TFunction;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n}): ReactNode => {\n const { value, href, refKind, copyValue, tApp, t, renderLink } = args;\n const resolvedValue = resolveValueLabel(value, tApp);\n const technicalVariant = resolveTechnicalVariant(refKind);\n if (technicalVariant != null) {\n const normalized = normalizeTechnicalIdentifier(resolvedValue);\n if (normalized == null) {\n return t('common.notAvailable');\n }\n return createElement(TechnicalIdentifierValue, {\n value: normalized,\n copyValue: copyValue ?? normalized,\n variant: technicalVariant,\n copyLabel: t('common.actions.copy'),\n });\n }\n if (href != null && href.trim() !== '' && !isEmptyText(resolvedValue)) {\n return renderLink(href, resolvedValue);\n }\n return resolvedValue ?? t('common.notAvailable');\n};\n\nexport const renderBlocks = <Node>(\n blocks: readonly BackofficeDetailBlockSpec<Node>[] | undefined,\n node: Node,\n options: {\n tApp: TFunction;\n t: TFunction;\n resolveEntityHref: (entityId: string, refId: string) => string | null;\n keyPrefix?: string;\n renderLink: (href: string, label: ReactNode) => ReactNode;\n renderDate: (\n value: string | number | Date | null | undefined,\n fallback: string,\n ) => ReactNode;\n renderTag: (tone: BackofficeTone, label: string) => ReactNode;\n renderMetricGroup: (args: {\n key: string;\n title: string;\n description?: string;\n density?: 'compact' | 'comfortable';\n items: readonly {\n id: string;\n label: string;\n value: ReactNode;\n hint?: ReactNode;\n tone?: BackofficeTone;\n copyValue?: string;\n }[];\n }) => ReactNode;\n renderTimeline: (args: {\n key: string;\n title: string;\n description?: string;\n events: readonly {\n id: string;\n label: string;\n timestamp?: ReactNode;\n description?: ReactNode;\n actor?: ReactNode;\n tone?: BackofficeTone;\n payload?: ReactNode;\n }[];\n }) => ReactNode;\n renderAuditTimeline: (args: {\n key: string;\n title: string;\n description?: string;\n events: readonly {\n id: string;\n title: ReactNode;\n time?: ReactNode;\n actor?: ReactNode;\n source?: ReactNode;\n }[];\n }) => ReactNode;\n renderRelations: (args: {\n key: string;\n title: string;\n description?: string;\n items: readonly {\n id: string;\n label: string;\n count?: ReactNode;\n href?: string;\n description?: ReactNode;\n tone?: BackofficeTone;\n }[];\n }) => ReactNode;\n renderContextStack: (args: {\n key: string;\n title: string;\n items: readonly {\n id: string;\n label: string;\n value: ReactNode | null | undefined;\n }[];\n }) => ReactNode;\n renderCustomSection: (\n key: string,\n title: string,\n child: ReactNode,\n ) => ReactNode;\n wrapCustomNode: (key: string, node: ReactNode) => ReactNode;\n resolveTableColumns: (\n columns: readonly BackofficeColumnSpec[],\n ) => readonly DataTableColumn<unknown>[];\n renderTable: (args: {\n key: string;\n title: string;\n description?: string;\n columns: readonly DataTableColumn<unknown>[];\n rows: readonly unknown[];\n }) => ReactNode;\n renderPayload: (args: {\n key: string;\n title: string;\n description?: string;\n content: unknown;\n format: BackofficePayloadFormat;\n }) => ReactNode;\n renderKeyValueListSection: (args: {\n key: string;\n title: string;\n description?: string;\n items: readonly { id: string; label: string; value: ReactNode }[];\n }) => ReactNode;\n },\n): ReactNode[] => {\n const { tApp, t, keyPrefix } = options;\n if (blocks == null || blocks.length === 0) {\n return [];\n }\n\n return blocks.map((block, index): ReactNode => {\n const key =\n keyPrefix != null\n ? `${keyPrefix}-${block.kind}-${index}`\n : `${block.kind}-${index}`;\n\n if (block.kind === 'custom') {\n const custom = block.render(node) as ReactNode;\n if (custom == null) {\n return null;\n }\n if (block.label != null) {\n return options.renderCustomSection(\n key,\n resolveLabel(block.label, tApp),\n custom,\n );\n }\n return options.wrapCustomNode(key, custom);\n }\n\n const title =\n 'title' in block\n ? resolveLabel(block.title, tApp)\n : resolveLabel(block.label, tApp);\n const description =\n block.description != null\n ? resolveLabel(block.description, tApp)\n : undefined;\n\n if (block.kind === 'summary') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.items.map((item) => {\n const value = resolveValueLabel(item.value(node), tApp);\n const href = item.href?.(node);\n const tone = item.tone?.(node);\n let valueNode: ReactNode = value ?? t('common.notAvailable');\n if (href != null && href.trim() !== '' && !isEmptyText(value)) {\n valueNode = options.renderLink(href, value);\n } else if (tone != null && !isEmptyText(value)) {\n valueNode = options.renderTag(tone, String(value));\n }\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n value: valueNode,\n };\n }),\n });\n }\n\n if (block.kind === 'metrics') {\n return options.renderMetricGroup({\n key,\n title,\n description,\n density: block.density,\n items: block.items.map((item) => {\n const formattedValue = item.formattedValue?.(node);\n const value = resolveValueLabel(item.value(node), tApp);\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n value: formattedValue ?? value ?? t('common.notAvailable'),\n hint: resolveValueLabel(item.hint?.(node), tApp),\n tone: item.tone?.(node),\n copyValue: item.copyValue?.(node) ?? undefined,\n };\n }),\n });\n }\n\n if (block.kind === 'states') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.states.map((state) => {\n const display = state.getDisplay(state.value(node), node);\n return {\n id: state.id,\n label: resolveLabel(state.label, tApp),\n value: options.renderTag(\n display.tone,\n String(\n resolveValueLabel(display.label, tApp) ??\n t('common.notAvailable'),\n ),\n ),\n };\n }),\n });\n }\n\n if (block.kind === 'context') {\n return options.renderContextStack({\n key,\n title,\n items: block.items.map((item) => {\n const value = resolveValueLabel(item.value(node), tApp);\n const href = item.href?.(node);\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n value:\n href != null && href.trim() !== '' && !isEmptyText(value)\n ? options.renderLink(href, value)\n : value,\n };\n }),\n });\n }\n\n if (block.kind === 'relationSummary') {\n return options.renderRelations({\n key,\n title,\n description,\n items: block.items.map((item) => {\n return {\n id: item.id,\n label: resolveLabel(item.label, tApp),\n count: item.count?.(node) ?? null,\n href: item.href?.(node) ?? undefined,\n description: resolveValueLabel(item.description?.(node), tApp),\n tone: item.tone?.(node),\n };\n }),\n });\n }\n\n if (block.kind === 'timeline') {\n return options.renderTimeline({\n key,\n title,\n description,\n events: block.events.map((event) => {\n const state = event.state?.(node);\n const stateLabel =\n state == null ? null : resolveValueLabel(state.label, tApp);\n const stateText = stateLabel == null ? null : String(stateLabel);\n return {\n id: event.id,\n label:\n stateText == null || stateText.trim() === ''\n ? resolveLabel(event.label, tApp)\n : `${resolveLabel(event.label, tApp)}: ${stateText}`,\n timestamp:\n event.timestamp == null\n ? undefined\n : options.renderDate(\n event.timestamp(node),\n t('common.notAvailable'),\n ),\n description: resolveValueLabel(event.description?.(node), tApp),\n actor: resolveValueLabel(event.actor?.(node), tApp),\n tone: state?.tone,\n payload: renderTimelinePayload(event.payload?.(node)),\n };\n }),\n });\n }\n\n if (block.kind === 'audit') {\n return options.renderAuditTimeline({\n key,\n title,\n description,\n events: block.items.map((item) => {\n const actor = resolveValueLabel(item.actor?.(node), tApp);\n const source = resolveValueLabel(item.source?.(node), tApp);\n return {\n id: item.id,\n title: resolveLabel(item.label, tApp),\n time: options.renderDate(\n item.timestamp?.(node),\n t('common.notAvailable'),\n ),\n actor: isEmptyText(actor) ? undefined : actor,\n source: isEmptyText(source) ? undefined : source,\n };\n }),\n });\n }\n\n if (block.kind === 'references') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.references.map((reference) => {\n const href = reference.href?.(node);\n return {\n id: reference.id,\n label: resolveLabel(reference.label, tApp),\n value: renderReferenceValue({\n value: reference.value(node),\n href,\n refKind: reference.refKind ?? 'text',\n copyValue: reference.copyValue?.(node) ?? undefined,\n tApp,\n t,\n renderLink: options.renderLink,\n }),\n };\n }),\n });\n }\n\n if (block.kind === 'actionResult') {\n const items: { id: string; label: string; value: ReactNode }[] = [];\n const status = block.status?.(node);\n if (status != null) {\n items.push({\n id: `${block.id}-status`,\n label: t('detail.actionResult.status'),\n value: options.renderTag(\n status.tone,\n String(\n resolveValueLabel(status.label, tApp) ?? t('common.notAvailable'),\n ),\n ),\n });\n }\n const message = resolveValueLabel(block.message?.(node), tApp);\n if (!isEmptyText(message)) {\n items.push({\n id: `${block.id}-message`,\n label: t('detail.actionResult.message'),\n value: message,\n });\n }\n block.references?.forEach((reference) => {\n items.push({\n id: reference.id,\n label: resolveLabel(reference.label, tApp),\n value: renderReferenceValue({\n value: reference.value(node),\n href: reference.href?.(node),\n refKind: reference.refKind ?? 'text',\n copyValue: reference.copyValue?.(node) ?? undefined,\n tApp,\n t,\n renderLink: options.renderLink,\n }),\n });\n });\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items,\n });\n }\n\n if (block.kind === 'technicalFacts') {\n return options.renderKeyValueListSection({\n key,\n title,\n description,\n items: block.facts.map((fact) => {\n const value = resolveValueLabel(fact.value(node), tApp);\n const href = fact.href?.(node);\n const copyValue = fact.copyValue?.(node) ?? undefined;\n return {\n id: fact.id,\n label: resolveLabel(fact.label, tApp),\n value:\n copyValue != null && copyValue.trim() !== ''\n ? createElement(TechnicalIdentifierValue, {\n value: value ?? copyValue,\n copyValue,\n variant: 'external',\n copyLabel: t('common.actions.copy'),\n })\n : href != null && href.trim() !== '' && !isEmptyText(value)\n ? options.renderLink(href, value)\n : (value ?? t('common.notAvailable')),\n };\n }),\n });\n }\n\n if (block.kind === 'table') {\n return options.renderTable({\n key,\n title,\n description,\n columns: options.resolveTableColumns(block.columns),\n rows: block.rows(node) as readonly unknown[],\n });\n }\n\n return options.renderPayload({\n key,\n title,\n description,\n content: block.value(node),\n format: block.format ?? 'json',\n });\n });\n};\n"],"mappings":";;;;AAqEA,IAAa,KACX,GACA,GACA,MACoB;CACpB,QAAQ,GAAR;EACE,KAAK,SACH,OAAO,IACH;GAAE,MAAM;GAAW,OAAO,EAAE,oBAAoB;EAAE,IAClD;GAAE,MAAM;GAAW,OAAO,EAAE,mBAAmB;EAAE;EACvD,KAAK,cACH,OAAO,IACH;GACE,MAAM;GACN,OAAO,EAAE,0BAA0B;GACnC,UAAU;EACZ,IACA;GACE,MAAM;GACN,OAAO,EAAE,yBAAyB;GAClC,UAAU;EACZ;EACN,KAAK,WACH,OAAO,IACH;GACE,MAAM;GACN,OAAO,EAAE,uBAAuB;GAChC,UAAU;EACZ,IACA;GACE,MAAM;GACN,OAAO,EAAE,wBAAwB;GACjC,UAAU;EACZ;EACN,KAAK,WACH,OAAO,IACH;GACE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ACtB,CAAC;IACH,CAAC;GACH,CAAC,GACM,EAAQ,0BAA0B;IACvC;IACA;IACA;IACA;GACF,CAAC;EACH;EAwCA,OAtCI,EAAM,SAAS,mBACV,EAAQ,0BAA0B;GACvC;GACA;GACA;GACA,OAAO,EAAM,MAAM,KAAK,MAAS;IAC/B,IAAM,IAAQ,EAAkB,EAAK,MAAM,CAAI,GAAG,CAAI,GAChD,IAAO,EAAK,OAAO,CAAI,GACvB,IAAY,EAAK,YAAY,CAAI,KAAK,KAAA;IAC5C,OAAO;KACL,IAAI,EAAK;KACT,OAAO,EAAa,EAAK,OAAO,CAAI;KACpC,OACE,KAAa,QAAQ,EAAU,KAAK,MAAM,KACtC,EAAc,GAA0B;MACtC,OAAO,KAAS;MAChB;MACA,SAAS;MACT,WAAW,EAAE,qBAAqB;KACpC,CAAC,IACD,KAAQ,QAAQ,EAAK,KAAK,MAAM,MAAM,CAAC,EAAY,CAAK,IACtD,EAAQ,WAAW,GAAM,CAAK,IAC7B,KAAS,EAAE,qBAAqB;IAC3C;GACF,CAAC;EACH,CAAC,IAGC,EAAM,SAAS,UACV,EAAQ,YAAY;GACzB;GACA;GACA;GACA,SAAS,EAAQ,oBAAoB,EAAM,OAAO;GAClD,MAAM,EAAM,KAAK,CAAI;EACvB,CAAC,IAGI,EAAQ,cAAc;GAC3B;GACA;GACA;GACA,SAAS,EAAM,MAAM,CAAI;GACzB,QAAQ,EAAM,UAAU;EAC1B,CAAC;CACH,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/pages/BackofficeEntityListPage.helpers.tsx
|
|
2
|
-
var e =
|
|
2
|
+
var e = {
|
|
3
3
|
xs: "minmax(3.5rem, 7rem)",
|
|
4
4
|
s: "minmax(5rem, 10rem)",
|
|
5
5
|
statusAction: "minmax(7rem, 12rem)",
|
|
@@ -7,13 +7,13 @@ var e = 24, t = 6, n = 4, r = 32, i = 8, a = {
|
|
|
7
7
|
l: "minmax(9rem, 18rem)",
|
|
8
8
|
xl: "minmax(11rem, 24rem)",
|
|
9
9
|
fluid: "minmax(0, 1fr)"
|
|
10
|
-
},
|
|
10
|
+
}, t = (e) => e <= 0 ? 0 : 8 + 24 * e + 6 * Math.max(0, e - 1), n = (e) => e <= 0 ? 0 : 28 + 32 * e + 8 * Math.max(0, e - 1), r = (t, n) => t.mobileRole === "action" ? "60px" : t.isPrimary === !0 ? "minmax(0, 1.4fr)" : "size" in t && typeof t.size == "string" ? e[t.size] : n, i = (e) => e.kind === "route", a = (e) => e.kind === "formMutation", o = (e, t) => e ?? (t === 0 ? "primary" : "secondary"), s = (e) => {
|
|
11
11
|
if (typeof e != "object" || !e || !("id" in e)) return null;
|
|
12
12
|
let t = e.id;
|
|
13
13
|
if (typeof t != "string") return null;
|
|
14
14
|
let n = t.trim();
|
|
15
15
|
return n === "" ? null : n;
|
|
16
|
-
},
|
|
16
|
+
}, c = (e, t) => e(t), l = (e) => {
|
|
17
17
|
let { ariaLabel: t, fallback: n, resolveDetailHref: r, className: i, renderAction: a } = e;
|
|
18
18
|
return {
|
|
19
19
|
id: "actions",
|
|
@@ -21,7 +21,7 @@ var e = 24, t = 6, n = 4, r = 32, i = 8, a = {
|
|
|
21
21
|
className: i,
|
|
22
22
|
mobileRole: "action",
|
|
23
23
|
cell: (e) => {
|
|
24
|
-
let i =
|
|
24
|
+
let i = s(e);
|
|
25
25
|
if (i == null) return n;
|
|
26
26
|
let o = r(i);
|
|
27
27
|
return o == null ? n : a({
|
|
@@ -32,6 +32,6 @@ var e = 24, t = 6, n = 4, r = 32, i = 8, a = {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
//#endregion
|
|
35
|
-
export {
|
|
35
|
+
export { l as buildActionsColumn, n as computeActionsColumnWidthPx, t as computeRowFlagsColumnWidthPx, a as isFormMutationAction, i as isRouteAction, o as resolveActionVariant, c as resolveLabel, s as resolveRowId, r as resolveTrackBySize };
|
|
36
36
|
|
|
37
37
|
//# sourceMappingURL=BackofficeEntityListPage.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeEntityListPage.helpers.js","names":[],"sources":["../../../src/pages/BackofficeEntityListPage.helpers.tsx"],"sourcesContent":["import type { ComponentProps, JSX } from 'react';\n\nimport type {\n BackofficeEntityFormMutationActionSpec,\n BackofficeEntityRouteActionSpec,\n BackofficeListActionSpec,\n BackofficeRuntimeConnectionListConfig,\n BackofficeRuntimeResolvedListFacetConfig,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport type { Button } from '@plumile/ui/atomic/atoms/button/Button.js';\nimport type { DataTableColumn } from '@plumile/ui/components/data-table/DataTable.js';\nimport type { TFunction } from 'i18next';\n\nimport type { BackofficeSizedDataTableColumn } from '../components/backoffice/columns/buildDataTableColumns.js';\n\ntype ButtonVariant = ComponentProps<typeof Button>['variant'];\n\nconst ROW_FLAGS_SLOT_PX = 24;\nconst ROW_FLAGS_GAP_PX = 6;\nconst ROW_FLAGS_PADDING_X_PX = 4;\n\nconst ACTIONS_SLOT_PX = 32;\nconst ACTIONS_GAP_PX = 8;\nconst ACTIONS_PADDING_X_PX = 12;\nconst ACTIONS_SAFETY_PX = 4;\n\nconst listColumnTrackBySize: Record<\n BackofficeSizedDataTableColumn<unknown>['size'],\n string\n> = {\n xs: 'minmax(3.5rem, 7rem)',\n s: 'minmax(5rem, 10rem)',\n statusAction: 'minmax(7rem, 12rem)',\n m: 'minmax(7rem, 14rem)',\n l: 'minmax(9rem, 18rem)',\n xl: 'minmax(11rem, 24rem)',\n fluid: 'minmax(0, 1fr)',\n};\n\nexport const computeRowFlagsColumnWidthPx = (flagCount: number): number => {\n if (flagCount <= 0) {\n return 0;\n }\n return (\n ROW_FLAGS_PADDING_X_PX * 2 +\n ROW_FLAGS_SLOT_PX * flagCount +\n ROW_FLAGS_GAP_PX * Math.max(0, flagCount - 1)\n );\n};\n\nexport const computeActionsColumnWidthPx = (actionCount: number): number => {\n if (actionCount <= 0) {\n return 0;\n }\n return (\n ACTIONS_SAFETY_PX +\n ACTIONS_PADDING_X_PX * 2 +\n ACTIONS_SLOT_PX * actionCount +\n ACTIONS_GAP_PX * Math.max(0, actionCount - 1)\n );\n};\n\nexport const resolveTrackBySize = (\n column: DataTableColumn<unknown>,\n fallback: string,\n): string => {\n if (column.mobileRole === 'action') {\n return '60px';\n }\n if (column.isPrimary === true) {\n return 'minmax(0, 1.4fr)';\n }\n if ('size' in column && typeof column.size === 'string') {\n return listColumnTrackBySize[\n column.size as BackofficeSizedDataTableColumn<unknown>['size']\n ];\n }\n return fallback;\n};\n\nexport const isRouteAction = (\n action: BackofficeListActionSpec,\n): action is BackofficeEntityRouteActionSpec<null> => {\n return action.kind === 'route';\n};\n\nexport const isFormMutationAction = (\n action: BackofficeListActionSpec,\n): action is BackofficeEntityFormMutationActionSpec<null, any, any, any> => {\n return action.kind === 'formMutation';\n};\n\nexport const resolveActionVariant = (\n actionVariant: ButtonVariant | undefined,\n index: number,\n): Exclude<ButtonVariant, undefined> => {\n if (actionVariant != null) {\n return actionVariant;\n }\n if (index === 0) {\n return 'primary';\n }\n return 'secondary';\n};\n\nexport const resolveRowId = (row: unknown): string | null => {\n if (row == null || typeof row !== 'object') {\n return null;\n }\n if (!('id' in row)) {\n return null;\n }\n const value = (row as { id?: unknown }).id;\n if (typeof value !== 'string') {\n return null;\n }\n const trimmed = value.trim();\n if (trimmed === '') {\n return null;\n }\n return trimmed;\n};\n\nexport type ConnectionListConfig = BackofficeRuntimeResolvedListFacetConfig & {\n list: BackofficeRuntimeConnectionListConfig;\n};\n\nexport const resolveLabel = (label: I18nLabel, tApp: TFunction): string => {\n return label(tApp);\n};\n\nexport const buildActionsColumn = (options: {\n ariaLabel: string;\n fallback: string;\n resolveDetailHref: (id: string) => string | null;\n className?: string;\n renderAction: (input: { href: string; ariaLabel: string }) => JSX.Element;\n}): DataTableColumn<unknown> => {\n const { ariaLabel, fallback, resolveDetailHref, className, renderAction } =\n options;\n\n return {\n id: 'actions',\n header: '',\n className,\n mobileRole: 'action',\n cell: (row) => {\n const id = resolveRowId(row);\n if (id == null) {\n return fallback;\n }\n const href = resolveDetailHref(id);\n if (href == null) {\n return fallback;\n }\n return renderAction({ href, ariaLabel });\n },\n };\n};\n"],"mappings":";AAkBA,
|
|
1
|
+
{"version":3,"file":"BackofficeEntityListPage.helpers.js","names":[],"sources":["../../../src/pages/BackofficeEntityListPage.helpers.tsx"],"sourcesContent":["import type { ComponentProps, JSX } from 'react';\n\nimport type {\n BackofficeEntityFormMutationActionSpec,\n BackofficeEntityRouteActionSpec,\n BackofficeListActionSpec,\n BackofficeRuntimeConnectionListConfig,\n BackofficeRuntimeResolvedListFacetConfig,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport type { Button } from '@plumile/ui/atomic/atoms/button/Button.js';\nimport type { DataTableColumn } from '@plumile/ui/components/data-table/DataTable.js';\nimport type { TFunction } from 'i18next';\n\nimport type { BackofficeSizedDataTableColumn } from '../components/backoffice/columns/buildDataTableColumns.js';\n\ntype ButtonVariant = ComponentProps<typeof Button>['variant'];\n\nconst ROW_FLAGS_SLOT_PX = 24;\nconst ROW_FLAGS_GAP_PX = 6;\nconst ROW_FLAGS_PADDING_X_PX = 4;\n\nconst ACTIONS_SLOT_PX = 32;\nconst ACTIONS_GAP_PX = 8;\nconst ACTIONS_PADDING_X_PX = 12;\nconst ACTIONS_SAFETY_PX = 4;\n\nconst listColumnTrackBySize: Record<\n BackofficeSizedDataTableColumn<unknown>['size'],\n string\n> = {\n xs: 'minmax(3.5rem, 7rem)',\n s: 'minmax(5rem, 10rem)',\n statusAction: 'minmax(7rem, 12rem)',\n m: 'minmax(7rem, 14rem)',\n l: 'minmax(9rem, 18rem)',\n xl: 'minmax(11rem, 24rem)',\n fluid: 'minmax(0, 1fr)',\n};\n\nexport const computeRowFlagsColumnWidthPx = (flagCount: number): number => {\n if (flagCount <= 0) {\n return 0;\n }\n return (\n ROW_FLAGS_PADDING_X_PX * 2 +\n ROW_FLAGS_SLOT_PX * flagCount +\n ROW_FLAGS_GAP_PX * Math.max(0, flagCount - 1)\n );\n};\n\nexport const computeActionsColumnWidthPx = (actionCount: number): number => {\n if (actionCount <= 0) {\n return 0;\n }\n return (\n ACTIONS_SAFETY_PX +\n ACTIONS_PADDING_X_PX * 2 +\n ACTIONS_SLOT_PX * actionCount +\n ACTIONS_GAP_PX * Math.max(0, actionCount - 1)\n );\n};\n\nexport const resolveTrackBySize = (\n column: DataTableColumn<unknown>,\n fallback: string,\n): string => {\n if (column.mobileRole === 'action') {\n return '60px';\n }\n if (column.isPrimary === true) {\n return 'minmax(0, 1.4fr)';\n }\n if ('size' in column && typeof column.size === 'string') {\n return listColumnTrackBySize[\n column.size as BackofficeSizedDataTableColumn<unknown>['size']\n ];\n }\n return fallback;\n};\n\nexport const isRouteAction = (\n action: BackofficeListActionSpec,\n): action is BackofficeEntityRouteActionSpec<null> => {\n return action.kind === 'route';\n};\n\nexport const isFormMutationAction = (\n action: BackofficeListActionSpec,\n): action is BackofficeEntityFormMutationActionSpec<null, any, any, any> => {\n return action.kind === 'formMutation';\n};\n\nexport const resolveActionVariant = (\n actionVariant: ButtonVariant | undefined,\n index: number,\n): Exclude<ButtonVariant, undefined> => {\n if (actionVariant != null) {\n return actionVariant;\n }\n if (index === 0) {\n return 'primary';\n }\n return 'secondary';\n};\n\nexport const resolveRowId = (row: unknown): string | null => {\n if (row == null || typeof row !== 'object') {\n return null;\n }\n if (!('id' in row)) {\n return null;\n }\n const value = (row as { id?: unknown }).id;\n if (typeof value !== 'string') {\n return null;\n }\n const trimmed = value.trim();\n if (trimmed === '') {\n return null;\n }\n return trimmed;\n};\n\nexport type ConnectionListConfig = BackofficeRuntimeResolvedListFacetConfig & {\n list: BackofficeRuntimeConnectionListConfig;\n};\n\nexport const resolveLabel = (label: I18nLabel, tApp: TFunction): string => {\n return label(tApp);\n};\n\nexport const buildActionsColumn = (options: {\n ariaLabel: string;\n fallback: string;\n resolveDetailHref: (id: string) => string | null;\n className?: string;\n renderAction: (input: { href: string; ariaLabel: string }) => JSX.Element;\n}): DataTableColumn<unknown> => {\n const { ariaLabel, fallback, resolveDetailHref, className, renderAction } =\n options;\n\n return {\n id: 'actions',\n header: '',\n className,\n mobileRole: 'action',\n cell: (row) => {\n const id = resolveRowId(row);\n if (id == null) {\n return fallback;\n }\n const href = resolveDetailHref(id);\n if (href == null) {\n return fallback;\n }\n return renderAction({ href, ariaLabel });\n },\n };\n};\n"],"mappings":";AAkBA,IASM,IAGF;CACF,IAAI;CACJ,GAAG;CACH,cAAc;CACd,GAAG;CACH,GAAG;CACH,IAAI;CACJ,OAAO;AACT,GAEa,KAAgC,MACvC,KAAa,IACR,IAGP,IACA,KAAoB,IACpB,IAAmB,KAAK,IAAI,GAAG,IAAY,CAAC,GAInC,KAA+B,MACtC,KAAe,IACV,IAGP,KAEA,KAAkB,IAClB,IAAiB,KAAK,IAAI,GAAG,IAAc,CAAC,GAInC,KACX,GACA,MAEI,EAAO,eAAe,WACjB,SAEL,EAAO,cAAc,KAChB,qBAEL,UAAU,KAAU,OAAO,EAAO,QAAS,WACtC,EACL,EAAO,QAGJ,GAGI,KACX,MAEO,EAAO,SAAS,SAGZ,KACX,MAEO,EAAO,SAAS,gBAGZ,KACX,GACA,MAEI,MAGA,MAAU,IACL,YAEF,cAGI,KAAgB,MAAgC;CAI3D,IAHmB,OAAO,KAAQ,aAA9B,KAGA,EAAE,QAAQ,IACZ,OAAO;CAET,IAAM,IAAS,EAAyB;CACxC,IAAI,OAAO,KAAU,UACnB,OAAO;CAET,IAAM,IAAU,EAAM,KAAK;CAI3B,OAHI,MAAY,KACP,OAEF;AACT,GAMa,KAAgB,GAAkB,MACtC,EAAM,CAAI,GAGN,KAAsB,MAMH;CAC9B,IAAM,EAAE,cAAW,aAAU,sBAAmB,cAAW,oBACzD;CAEF,OAAO;EACL,IAAI;EACJ,QAAQ;EACR;EACA,YAAY;EACZ,OAAO,MAAQ;GACb,IAAM,IAAK,EAAa,CAAG;GAC3B,IAAI,KAAM,MACR,OAAO;GAET,IAAM,IAAO,EAAkB,CAAE;GAIjC,OAHI,KAAQ,OACH,IAEF,EAAa;IAAE;IAAM;GAAU,CAAC;EACzC;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeEntityListPage.js","names":[],"sources":["../../../src/pages/BackofficeEntityListPage.tsx"],"sourcesContent":["import {\n Suspense,\n type JSX,\n type ReactNode,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { TFunction } from 'i18next';\nimport { useTranslation } from 'react-i18next';\nimport Link from '@plumile/router/routing/Link.js';\nimport type {\n BackofficeEntityManifestItem,\n BackofficePreparedListLayoutRoute,\n BackofficeRuntimeResolvedListFacetConfig,\n BackofficeRowFlagSpec,\n} from '@plumile/backoffice-core/types.js';\nimport { Button } from '@plumile/ui/atomic/atoms/button/Button.js';\nimport { LinkButton } from '@plumile/ui/atomic/atoms/button/LinkButton.js';\nimport {\n type DataTableColumn,\n type GetRowId,\n} from '@plumile/ui/components/data-table/DataTable.js';\nimport { TableCell } from '@plumile/ui/components/data-table/TableCell.js';\nimport { EyeSvg } from '@plumile/ui/icons/EyeSvg.js';\nimport { BackofficeEntityListScaffold } from '../components/backoffice/scaffolds/BackofficeEntityListScaffold.js';\nimport { LazyBackofficeEntityActionFormDialog } from '../components/backoffice/actions/LazyBackofficeEntityActionFormDialog.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { RowFlagsCell } from '../components/backoffice/list/RowFlagsCell.js';\nimport { useBackofficeListUrlState } from '../hooks/useBackofficeListUrlState.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport * as pageStyles from './backofficeEntityListPage.css.js';\nimport { rowFlagsColumnCell } from '../components/backoffice/list/RowFlagsCell.css.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildEntityListBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport { BackofficeEntityListRouteProvider } from './BackofficeEntityListRouteContext.js';\nimport {\n buildActionsColumn,\n computeActionsColumnWidthPx,\n computeRowFlagsColumnWidthPx,\n isFormMutationAction,\n isRouteAction,\n resolveLabel,\n resolveActionVariant,\n resolveTrackBySize,\n type ConnectionListConfig,\n} from './BackofficeEntityListPage.helpers.js';\n\nexport type BackofficeEntityListPageProps = {\n children?: ReactNode;\n entityManifest: BackofficeEntityManifestItem;\n config: BackofficeRuntimeResolvedListFacetConfig;\n prepared: BackofficePreparedListLayoutRoute;\n};\n\nconst applyListEdgeColumns = <Row,>(\n inputColumns: readonly DataTableColumn<Row>[],\n rowFlags: readonly BackofficeRowFlagSpec<Row>[] | undefined,\n actionCount: number,\n tApp: TFunction,\n): {\n columns: readonly DataTableColumn<Row>[];\n gridTemplateColumns?: string;\n} => {\n const hasFlags = rowFlags != null && rowFlags.length > 0;\n\n let columns = inputColumns;\n if (hasFlags) {\n const flagsColumn: DataTableColumn<Row> = {\n id: '__rowFlags',\n header: '',\n className: rowFlagsColumnCell,\n mobileRole: 'badge',\n cell: (row) => {\n return <RowFlagsCell row={row} flags={rowFlags} tApp={tApp} />;\n },\n };\n\n // Ensure we never pick the flags column as \"primary\".\n const withFlags = [flagsColumn, ...inputColumns];\n const hasPrimary = withFlags.some((col) => {\n return col.isPrimary === true;\n });\n\n columns = withFlags;\n if (!hasPrimary) {\n columns = withFlags.map((col, index) => {\n if (index === 1) {\n return { ...col, isPrimary: true };\n }\n return col;\n });\n }\n }\n\n let flagCount = 0;\n if (hasFlags) {\n flagCount = rowFlags.length;\n }\n const flagsWidthPx = computeRowFlagsColumnWidthPx(flagCount);\n const actionsWidthPx = computeActionsColumnWidthPx(actionCount);\n\n // We always include the right-side \"actions\" column in list pages.\n let leftColumnCount = 0;\n if (hasFlags) {\n leftColumnCount = 1;\n }\n const middleCount = columns.length - leftColumnCount - 1;\n\n const middleTracks = columns\n .slice(leftColumnCount, leftColumnCount + Math.max(0, middleCount))\n .map((column) => {\n return resolveTrackBySize(column as DataTableColumn<unknown>, '1fr');\n })\n .join(' ');\n\n let gridTemplateColumns = '';\n if (hasFlags) {\n gridTemplateColumns = `${flagsWidthPx}px ${middleTracks} ${actionsWidthPx}px`;\n } else {\n gridTemplateColumns = `${middleTracks} ${actionsWidthPx}px`;\n }\n\n return { columns, gridTemplateColumns };\n};\n\nconst BackofficeEntityConnectionListPage = ({\n children,\n config,\n breadcrumb,\n}: Omit<BackofficeEntityListPageProps, 'config' | 'prepared'> & {\n config: ConnectionListConfig;\n breadcrumb: ReturnType<typeof buildEntityListBreadcrumb>;\n}): JSX.Element | null => {\n const listConfig = config.list;\n\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const [activeFormActionId, setActiveFormActionId] = useState<string | null>(\n null,\n );\n const [countFetchKey, setCountFetchKey] = useState(0);\n const refreshRef = useRef<(() => void) | null>(null);\n\n const registerRefresh = useCallback((refresh: (() => void) | null) => {\n refreshRef.current = refresh;\n }, []);\n\n const { columns, gridTemplateColumns } = useMemo((): {\n columns: readonly DataTableColumn<unknown>[];\n gridTemplateColumns?: string;\n } => {\n const baseColumns = buildDataTableColumns(listConfig.columns, {\n tApp,\n t,\n });\n const actionsColumn = buildActionsColumn({\n ariaLabel: t('actions.view'),\n fallback: t('common.notAvailable'),\n className: pageStyles.actionsColumnCell,\n resolveDetailHref: (id) => {\n return config.routes.detail(id);\n },\n renderAction: ({ href, ariaLabel }) => {\n return (\n <TableCell.Actions>\n <Link\n to={href}\n className={pageStyles.actionTrigger}\n aria-label={ariaLabel}\n title={ariaLabel}\n preloadOnHover=\"code\"\n >\n <EyeSvg width={16} height={16} />\n </Link>\n </TableCell.Actions>\n );\n },\n });\n const allColumns = [...baseColumns, actionsColumn];\n return applyListEdgeColumns(allColumns, listConfig.rowFlags, 1, tApp);\n }, [config.routes, listConfig.columns, listConfig.rowFlags, t, tApp]);\n\n const getRowId = useCallback<GetRowId<unknown>>(\n (row) => {\n return listConfig.getRowId(row);\n },\n [listConfig],\n );\n\n const { state, pushState } = useBackofficeListUrlState(config);\n\n const handleRefreshRequest = useCallback(() => {\n setCountFetchKey((current) => {\n return current + 1;\n });\n refreshRef.current?.();\n }, []);\n\n const listActions = useMemo(() => {\n return config.listActions ?? [];\n }, [config.listActions]);\n const visibleActions = useMemo(() => {\n return listActions.filter((action) => {\n if (action.isVisible == null) {\n return true;\n }\n return action.isVisible(null);\n });\n }, [listActions]);\n\n const headerActions = useMemo(() => {\n if (visibleActions.length === 0) {\n return undefined;\n }\n return (\n <div className={pageStyles.headerActions}>\n {visibleActions.map((action, index) => {\n const { variant: actionVariant } = action;\n const label = resolveLabel(action.label, tApp);\n let ariaLabel = label;\n if (action.ariaLabel != null) {\n ariaLabel = resolveLabel(action.ariaLabel, tApp);\n }\n const variant = resolveActionVariant(actionVariant, index);\n const size = action.size ?? 'small';\n const isDisabled = action.isDisabled?.(null) === true;\n\n if (isRouteAction(action)) {\n const href = action.to(null);\n return (\n <LinkButton\n key={action.id}\n to={href}\n variant={variant}\n size={size}\n isDisabled={isDisabled}\n aria-label={ariaLabel}\n preloadOnHover=\"code-and-data\"\n >\n {label}\n </LinkButton>\n );\n }\n\n if (isFormMutationAction(action)) {\n return (\n <Button\n key={action.id}\n type=\"button\"\n variant={variant}\n size={size}\n disabled={isDisabled}\n onClick={() => {\n setActiveFormActionId(action.id);\n }}\n aria-label={ariaLabel}\n >\n {label}\n </Button>\n );\n }\n\n return null;\n })}\n </div>\n );\n }, [tApp, visibleActions]);\n\n const activeFormAction = listActions.find((action) => {\n return action.id === activeFormActionId;\n });\n\n const renderLoadingScaffold = () => {\n return (\n <BackofficeEntityListScaffold\n config={config}\n state={state}\n pushState={pushState}\n headerActions={headerActions}\n rows={[]}\n columns={columns}\n gridTemplateColumns={gridTemplateColumns}\n getRowId={getRowId}\n hasNextPage={false}\n isLoadingMore={false}\n isRefreshing={false}\n onLoadMore={() => {}}\n onRefresh={handleRefreshRequest}\n totalCount={null}\n isLoadingInitial\n />\n );\n };\n\n const contextValue = useMemo(() => {\n return {\n config,\n state,\n pushState,\n headerActions,\n columns,\n gridTemplateColumns,\n getRowId,\n countFetchKey,\n bumpCountFetchKey: () => {\n setCountFetchKey((current) => {\n return current + 1;\n });\n },\n registerRefresh,\n };\n }, [\n columns,\n config,\n countFetchKey,\n getRowId,\n gridTemplateColumns,\n headerActions,\n pushState,\n registerRefresh,\n state,\n ]);\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <BackofficeEntityListRouteProvider value={contextValue}>\n <Suspense fallback={renderLoadingScaffold()}>{children}</Suspense>\n </BackofficeEntityListRouteProvider>\n {activeFormAction != null && isFormMutationAction(activeFormAction) && (\n <LazyBackofficeEntityActionFormDialog\n isOpen\n action={activeFormAction}\n node={null}\n onClose={() => {\n setActiveFormActionId(null);\n }}\n onSuccess={handleRefreshRequest}\n />\n )}\n </BackofficeRightPageLayout>\n );\n};\n\nexport const BackofficeEntityListPage = ({\n children,\n entityManifest,\n config,\n}: BackofficeEntityListPageProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const breadcrumb = buildEntityListBreadcrumb(config, tApp);\n\n return (\n <BackofficeEntityConnectionListPage\n children={children}\n entityManifest={entityManifest}\n config={config}\n breadcrumb={breadcrumb}\n />\n );\n};\n\nexport default BackofficeEntityListPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,IAAM,KACJ,GACA,GACA,GACA,MAIG;CACH,IAAM,IAAW,KAAY,QAAQ,EAAS,SAAS,GAEnD,IAAU;CACd,IAAI,GAAU;EAYZ,IAAM,IAAY,CAAC;GAVjB,IAAI;GACJ,QAAQ;GACR,WAAW;GACX,YAAY;GACZ,OAAO,MACE,kBAAC,GAAD;IAAmB;IAAK,OAAO;IAAgB;GAAO,CAAA;EAK9C,GAAa,GAAG,CAAY,GACzC,IAAa,EAAU,MAAM,MAC1B,EAAI,cAA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;IACK,GAXD,EAAO,EAWN,IAIL;GACT,CAAC;EACE,CAAA;CAET,GAAG,CAAC,GAAM,CAAc,CAAC,GAEnB,IAAmB,EAAY,MAAM,MAClC,EAAO,OAAO,CACtB;CAqDD,OACE,kBAAC,GAAD;EAAuC;YAAvC,CACE,kBAAC,GAAD;GAAmC,OA/BlB,SACZ;IACL;IACA;IACA;IACA,eAAA;IACA;IACA;IACA;IACA;IACA,yBAAyB;KACvB,GAAkB,MACT,IAAU,CAClB;IACH;IACA;GACF,IACC;IACD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAI8C;aACxC,kBAAC,GAAD;IAAU,UApDZ,kBAAC,GAAD;KACU;KACD;KACI;KACI,eAAA;KACf,MAAM,CAAC;KACE;KACY;KACX;KACV,aAAa;KACb,eAAe;KACf,cAAc;KACd,kBAAkB,CAAC;KACnB,WAAW;KACX,YAAY;KACZ,kBAAA;IACD,CAAA;IAoC+C;GAAmB,CAAA;EAChC,CAAA,GAClC,KAAoB,QAAQ,EAAqB,CAAgB,KAChE,kBAAC,GAAD;GACE,QAAA;GACA,QAAQ;GACR,MAAM;GACN,eAAe;IACb,EAAsB,IAAI;GAC5B;GACA,WAAW;EACZ,CAAA,CAEsB;;AAE/B,GAEa,KAA4B,EACvC,aACA,mBACA,gBACuD;CACvD,IAAM,EAAE,GAAG,MAAS,EAAe;CAGnC,OACE,kBAAC,GAAD;EACY;EACM;EACR;EACI,YAPG,EAA0B,GAAQ,CAOrC;CACb,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"BackofficeEntityListPage.js","names":[],"sources":["../../../src/pages/BackofficeEntityListPage.tsx"],"sourcesContent":["import {\n Suspense,\n type JSX,\n type ReactNode,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { TFunction } from 'i18next';\nimport { useTranslation } from 'react-i18next';\nimport Link from '@plumile/router/routing/Link.js';\nimport type {\n BackofficeEntityManifestItem,\n BackofficePreparedListLayoutRoute,\n BackofficeRuntimeResolvedListFacetConfig,\n BackofficeRowFlagSpec,\n} from '@plumile/backoffice-core/types.js';\nimport { Button } from '@plumile/ui/atomic/atoms/button/Button.js';\nimport { LinkButton } from '@plumile/ui/atomic/atoms/button/LinkButton.js';\nimport {\n type DataTableColumn,\n type GetRowId,\n} from '@plumile/ui/components/data-table/DataTable.js';\nimport { TableCell } from '@plumile/ui/components/data-table/TableCell.js';\nimport { EyeSvg } from '@plumile/ui/icons/EyeSvg.js';\nimport { BackofficeEntityListScaffold } from '../components/backoffice/scaffolds/BackofficeEntityListScaffold.js';\nimport { LazyBackofficeEntityActionFormDialog } from '../components/backoffice/actions/LazyBackofficeEntityActionFormDialog.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { RowFlagsCell } from '../components/backoffice/list/RowFlagsCell.js';\nimport { useBackofficeListUrlState } from '../hooks/useBackofficeListUrlState.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport * as pageStyles from './backofficeEntityListPage.css.js';\nimport { rowFlagsColumnCell } from '../components/backoffice/list/RowFlagsCell.css.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildEntityListBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport { BackofficeEntityListRouteProvider } from './BackofficeEntityListRouteContext.js';\nimport {\n buildActionsColumn,\n computeActionsColumnWidthPx,\n computeRowFlagsColumnWidthPx,\n isFormMutationAction,\n isRouteAction,\n resolveLabel,\n resolveActionVariant,\n resolveTrackBySize,\n type ConnectionListConfig,\n} from './BackofficeEntityListPage.helpers.js';\n\nexport type BackofficeEntityListPageProps = {\n children?: ReactNode;\n entityManifest: BackofficeEntityManifestItem;\n config: BackofficeRuntimeResolvedListFacetConfig;\n prepared: BackofficePreparedListLayoutRoute;\n};\n\nconst applyListEdgeColumns = <Row,>(\n inputColumns: readonly DataTableColumn<Row>[],\n rowFlags: readonly BackofficeRowFlagSpec<Row>[] | undefined,\n actionCount: number,\n tApp: TFunction,\n): {\n columns: readonly DataTableColumn<Row>[];\n gridTemplateColumns?: string;\n} => {\n const hasFlags = rowFlags != null && rowFlags.length > 0;\n\n let columns = inputColumns;\n if (hasFlags) {\n const flagsColumn: DataTableColumn<Row> = {\n id: '__rowFlags',\n header: '',\n className: rowFlagsColumnCell,\n mobileRole: 'badge',\n cell: (row) => {\n return <RowFlagsCell row={row} flags={rowFlags} tApp={tApp} />;\n },\n };\n\n // Ensure we never pick the flags column as \"primary\".\n const withFlags = [flagsColumn, ...inputColumns];\n const hasPrimary = withFlags.some((col) => {\n return col.isPrimary === true;\n });\n\n columns = withFlags;\n if (!hasPrimary) {\n columns = withFlags.map((col, index) => {\n if (index === 1) {\n return { ...col, isPrimary: true };\n }\n return col;\n });\n }\n }\n\n let flagCount = 0;\n if (hasFlags) {\n flagCount = rowFlags.length;\n }\n const flagsWidthPx = computeRowFlagsColumnWidthPx(flagCount);\n const actionsWidthPx = computeActionsColumnWidthPx(actionCount);\n\n // We always include the right-side \"actions\" column in list pages.\n let leftColumnCount = 0;\n if (hasFlags) {\n leftColumnCount = 1;\n }\n const middleCount = columns.length - leftColumnCount - 1;\n\n const middleTracks = columns\n .slice(leftColumnCount, leftColumnCount + Math.max(0, middleCount))\n .map((column) => {\n return resolveTrackBySize(column as DataTableColumn<unknown>, '1fr');\n })\n .join(' ');\n\n let gridTemplateColumns = '';\n if (hasFlags) {\n gridTemplateColumns = `${flagsWidthPx}px ${middleTracks} ${actionsWidthPx}px`;\n } else {\n gridTemplateColumns = `${middleTracks} ${actionsWidthPx}px`;\n }\n\n return { columns, gridTemplateColumns };\n};\n\nconst BackofficeEntityConnectionListPage = ({\n children,\n config,\n breadcrumb,\n}: Omit<BackofficeEntityListPageProps, 'config' | 'prepared'> & {\n config: ConnectionListConfig;\n breadcrumb: ReturnType<typeof buildEntityListBreadcrumb>;\n}): JSX.Element | null => {\n const listConfig = config.list;\n\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const [activeFormActionId, setActiveFormActionId] = useState<string | null>(\n null,\n );\n const [countFetchKey, setCountFetchKey] = useState(0);\n const refreshRef = useRef<(() => void) | null>(null);\n\n const registerRefresh = useCallback((refresh: (() => void) | null) => {\n refreshRef.current = refresh;\n }, []);\n\n const { columns, gridTemplateColumns } = useMemo((): {\n columns: readonly DataTableColumn<unknown>[];\n gridTemplateColumns?: string;\n } => {\n const baseColumns = buildDataTableColumns(listConfig.columns, {\n tApp,\n t,\n });\n const actionsColumn = buildActionsColumn({\n ariaLabel: t('actions.view'),\n fallback: t('common.notAvailable'),\n className: pageStyles.actionsColumnCell,\n resolveDetailHref: (id) => {\n return config.routes.detail(id);\n },\n renderAction: ({ href, ariaLabel }) => {\n return (\n <TableCell.Actions>\n <Link\n to={href}\n className={pageStyles.actionTrigger}\n aria-label={ariaLabel}\n title={ariaLabel}\n preloadOnHover=\"code\"\n >\n <EyeSvg width={16} height={16} />\n </Link>\n </TableCell.Actions>\n );\n },\n });\n const allColumns = [...baseColumns, actionsColumn];\n return applyListEdgeColumns(allColumns, listConfig.rowFlags, 1, tApp);\n }, [config.routes, listConfig.columns, listConfig.rowFlags, t, tApp]);\n\n const getRowId = useCallback<GetRowId<unknown>>(\n (row) => {\n return listConfig.getRowId(row);\n },\n [listConfig],\n );\n\n const { state, pushState } = useBackofficeListUrlState(config);\n\n const handleRefreshRequest = useCallback(() => {\n setCountFetchKey((current) => {\n return current + 1;\n });\n refreshRef.current?.();\n }, []);\n\n const listActions = useMemo(() => {\n return config.listActions ?? [];\n }, [config.listActions]);\n const visibleActions = useMemo(() => {\n return listActions.filter((action) => {\n if (action.isVisible == null) {\n return true;\n }\n return action.isVisible(null);\n });\n }, [listActions]);\n\n const headerActions = useMemo(() => {\n if (visibleActions.length === 0) {\n return undefined;\n }\n return (\n <div className={pageStyles.headerActions}>\n {visibleActions.map((action, index) => {\n const { variant: actionVariant } = action;\n const label = resolveLabel(action.label, tApp);\n let ariaLabel = label;\n if (action.ariaLabel != null) {\n ariaLabel = resolveLabel(action.ariaLabel, tApp);\n }\n const variant = resolveActionVariant(actionVariant, index);\n const size = action.size ?? 'small';\n const isDisabled = action.isDisabled?.(null) === true;\n\n if (isRouteAction(action)) {\n const href = action.to(null);\n return (\n <LinkButton\n key={action.id}\n to={href}\n variant={variant}\n size={size}\n isDisabled={isDisabled}\n aria-label={ariaLabel}\n preloadOnHover=\"code-and-data\"\n >\n {label}\n </LinkButton>\n );\n }\n\n if (isFormMutationAction(action)) {\n return (\n <Button\n key={action.id}\n type=\"button\"\n variant={variant}\n size={size}\n disabled={isDisabled}\n onClick={() => {\n setActiveFormActionId(action.id);\n }}\n aria-label={ariaLabel}\n >\n {label}\n </Button>\n );\n }\n\n return null;\n })}\n </div>\n );\n }, [tApp, visibleActions]);\n\n const activeFormAction = listActions.find((action) => {\n return action.id === activeFormActionId;\n });\n\n const renderLoadingScaffold = () => {\n return (\n <BackofficeEntityListScaffold\n config={config}\n state={state}\n pushState={pushState}\n headerActions={headerActions}\n rows={[]}\n columns={columns}\n gridTemplateColumns={gridTemplateColumns}\n getRowId={getRowId}\n hasNextPage={false}\n isLoadingMore={false}\n isRefreshing={false}\n onLoadMore={() => {}}\n onRefresh={handleRefreshRequest}\n totalCount={null}\n isLoadingInitial\n />\n );\n };\n\n const contextValue = useMemo(() => {\n return {\n config,\n state,\n pushState,\n headerActions,\n columns,\n gridTemplateColumns,\n getRowId,\n countFetchKey,\n bumpCountFetchKey: () => {\n setCountFetchKey((current) => {\n return current + 1;\n });\n },\n registerRefresh,\n };\n }, [\n columns,\n config,\n countFetchKey,\n getRowId,\n gridTemplateColumns,\n headerActions,\n pushState,\n registerRefresh,\n state,\n ]);\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <BackofficeEntityListRouteProvider value={contextValue}>\n <Suspense fallback={renderLoadingScaffold()}>{children}</Suspense>\n </BackofficeEntityListRouteProvider>\n {activeFormAction != null && isFormMutationAction(activeFormAction) && (\n <LazyBackofficeEntityActionFormDialog\n isOpen\n action={activeFormAction}\n node={null}\n onClose={() => {\n setActiveFormActionId(null);\n }}\n onSuccess={handleRefreshRequest}\n />\n )}\n </BackofficeRightPageLayout>\n );\n};\n\nexport const BackofficeEntityListPage = ({\n children,\n entityManifest,\n config,\n}: BackofficeEntityListPageProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const breadcrumb = buildEntityListBreadcrumb(config, tApp);\n\n return (\n <BackofficeEntityConnectionListPage\n children={children}\n entityManifest={entityManifest}\n config={config}\n breadcrumb={breadcrumb}\n />\n );\n};\n\nexport default BackofficeEntityListPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,IAAM,KACJ,GACA,GACA,GACA,MAIG;CACH,IAAM,IAAW,KAAY,QAAQ,EAAS,SAAS,GAEnD,IAAU;CACd,IAAI,GAAU;EAYZ,IAAM,IAAY,CAAC;GAVjB,IAAI;GACJ,QAAQ;GACR,WAAW;GACX,YAAY;GACZ,OAAO,MACE,kBAAC,GAAD;IAAmB;IAAK,OAAO;IAAgB;GAAO,CAAA;EAK9C,GAAa,GAAG,CAAY,GACzC,IAAa,EAAU,MAAM,MAC1B,EAAI,cAAc,EAC1B;EAGD,AADA,IAAU,GACL,MACH,IAAU,EAAU,KAAK,GAAK,MACxB,MAAU,IACL;GAAE,GAAG;GAAK,WAAW;EAAK,IAE5B,CACR;CAEL;CAEA,IAAI,IAAY;CAChB,AAAI,MACF,IAAY,EAAS;CAEvB,IAAM,IAAe,EAA6B,CAAS,GACrD,IAAiB,EAA4B,CAAW,GAG1D,IAAkB;CACtB,AAAI,MACF,IAAkB;CAEpB,IAAM,IAAc,EAAQ,SAAS,IAAkB,GAEjD,IAAe,EAClB,MAAM,GAAiB,IAAkB,KAAK,IAAI,GAAG,CAAW,CAAC,CAAC,CAClE,KAAK,MACG,EAAmB,GAAoC,KAAK,CACpE,CAAC,CACD,KAAK,GAAG,GAEP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eAAA;KACf,MAAM,CAAC;KACE;KACY;KACX;KACV,aAAa;KACb,eAAe;KACf,cAAc;KACd,kBAAkB,CAAC;KACnB,WAAW;KACX,YAAY;KACZ,kBAAA;IACD,CAAA;IAoC+C;GAAmB,CAAA;EAChC,CAAA,GAClC,KAAoB,QAAQ,EAAqB,CAAgB,KAChE,kBAAC,GAAD;GACE,QAAA;GACA,QAAQ;GACR,MAAM;GACN,eAAe;IACb,EAAsB,IAAI;GAC5B;GACA,WAAW;EACZ,CAAA,CAEsB;;AAE/B,GAEa,KAA4B,EACvC,aACA,mBACA,gBACuD;CACvD,IAAM,EAAE,GAAG,MAAS,EAAe;CAGnC,OACE,kBAAC,GAAD;EACY;EACM;EACR;EACI,YAPG,EAA0B,GAAQ,CAOrC;CACb,CAAA;AAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeHubPage.js","names":[],"sources":["../../../src/pages/BackofficeHubPage.tsx"],"sourcesContent":["import { useMemo, useState, type JSX, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\nimport { SidebarTasksSvg } from '@plumile/ui/icons/SidebarTasksSvg.js';\nimport type { BackofficeEntityManifestMap } from '@plumile/backoffice-core/types.js';\n\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport type { BackofficeIconComponent } from '../provider/types.js';\nimport type { BackofficePreparedHubRoute } from '../router/createBackofficeRoutes.js';\nimport {\n BackofficeHubTemplate,\n type BackofficeHubTemplateGroup,\n type BackofficeHubTemplateSearch,\n} from '../components/backoffice/hub/BackofficeHubTemplate.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildHubBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport { useBackofficePermissions } from '../components/backoffice/layout/BackofficePermissionsContext.js';\nimport { resolveLabel } from '../components/backoffice/layout/sidebarUtils.js';\n\nexport type BackofficeHubPageProps = {\n prepared: BackofficePreparedHubRoute;\n};\n\ntype HubPageItemView = {\n id: string;\n kind: 'entity' | 'tool';\n label: string;\n href: string;\n icon: ReactNode;\n};\n\ntype HubPageGroupView = {\n id: string;\n title: string;\n description: string | null;\n icon: ReactNode | undefined;\n items: readonly HubPageItemView[];\n};\n\nconst renderIcon = (\n Icon: BackofficeIconComponent | undefined,\n size: number,\n): ReactNode | undefined => {\n if (Icon == null) {\n return undefined;\n }\n return <Icon width={size} height={size} aria-hidden=\"true\" />;\n};\n\nconst isItemVisible = (input: {\n entity: BackofficeEntityManifestMap[string] | null | undefined;\n kind: 'entity' | 'tool';\n permissions: unknown;\n sidebar: ReturnType<typeof useBackofficeConfig>['sidebar'];\n}): boolean => {\n const { entity, kind, permissions, sidebar } = input;\n if (entity == null) {\n return false;\n }\n if (kind === 'entity' && entity.kind !== 'tool' && !entity.hasList) {\n return false;\n }\n const isVisible = sidebar?.isItemVisible?.(\n {\n kind,\n id: entity.id,\n },\n permissions,\n );\n return isVisible !== false;\n};\n\nexport const BackofficeHubPage = ({\n prepared,\n}: BackofficeHubPageProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities, sidebar } = useBackofficeConfig();\n const permissions = useBackofficePermissions();\n const [search, setSearch] = useState('');\n const { hub } = prepared;\n const title = resolveLabel(hub.title, tApp);\n let description: string | undefined;\n if (hub.description != null) {\n description = resolveLabel(hub.description, tApp);\n }\n const breadcrumb = buildHubBreadcrumb({ id: hub.id, title });\n const normalizedSearch = search.trim().toLowerCase();\n const searchEnabled = hub.search?.enabled !== false;\n let searchPlaceholder = t('hub.search.placeholder');\n if (hub.search?.placeholder != null) {\n searchPlaceholder = resolveLabel(hub.search.placeholder, tApp);\n }\n\n const groups = useMemo<readonly HubPageGroupView[]>(() => {\n return hub.groups\n .map((group) => {\n const items = group.items\n .map((item): HubPageItemView | null => {\n const entity = entities[item.id];\n if (entity == null) {\n return null;\n }\n if (\n !isItemVisible({\n entity,\n kind: item.kind,\n permissions,\n sidebar,\n })\n ) {\n return null;\n }\n const entityConfig = entity;\n const label = resolveLabel(entityConfig.label, tApp);\n if (\n normalizedSearch !== '' &&\n !label.toLowerCase().includes(normalizedSearch)\n ) {\n return null;\n }\n return {\n id: item.id,\n kind: item.kind,\n label,\n href: entityConfig.routes.list,\n icon: renderIcon(item.icon, 20),\n };\n })\n .filter((item): item is HubPageItemView => {\n return item != null;\n });\n let groupDescription: string | null = null;\n if (group.description != null) {\n groupDescription = resolveLabel(group.description, tApp);\n }\n return {\n id: group.id,\n title: resolveLabel(group.title, tApp),\n description: groupDescription,\n icon: renderIcon(group.icon, 18),\n items,\n };\n })\n .filter((group) => {\n return group.items.length > 0;\n });\n }, [entities, hub.groups, normalizedSearch, permissions, sidebar, tApp]);\n\n let emptyTitle = t('hub.empty.title');\n if (hub.emptyState?.title != null) {\n emptyTitle = resolveLabel(hub.emptyState.title, tApp);\n }\n let emptyDescription = t('hub.empty.description');\n if (hub.emptyState?.description != null) {\n emptyDescription = resolveLabel(hub.emptyState.description, tApp);\n }\n let subtitle = t('hub.subtitle');\n if (description != null) {\n subtitle = description;\n }\n const hasMixedKinds = groups.some((group) => {\n const kinds = new Set(\n group.items.map((item) => {\n return item.kind;\n }),\n );\n return kinds.size > 1;\n });\n\n const templateGroups = useMemo<readonly BackofficeHubTemplateGroup[]>(() => {\n return groups.map((group) => {\n return {\n id: group.id,\n title: group.title,\n description: group.description,\n icon: group.icon,\n items: group.items.map((item) => {\n let metaLabel: string | null = null;\n if (hasMixedKinds) {\n metaLabel = t('hub.itemKinds.entity');\n if (item.kind === 'tool') {\n metaLabel = t('hub.itemKinds.tool');\n }\n }\n return {\n id: item.id,\n kind: item.kind,\n label: item.label,\n href: item.href,\n icon: item.icon,\n metaLabel,\n };\n }),\n };\n });\n }, [groups, hasMixedKinds, t]);\n\n let searchConfig: BackofficeHubTemplateSearch | undefined;\n if (searchEnabled) {\n searchConfig = {\n value: search,\n onChange: setSearch,\n placeholder: searchPlaceholder,\n };\n }\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n header={{\n title,\n subtitle,\n }}\n >\n <BackofficeHubTemplate\n groups={templateGroups}\n search={searchConfig}\n emptyState={{\n title: emptyTitle,\n description: emptyDescription,\n icon: <SidebarTasksSvg width={28} height={28} aria-hidden=\"true\" />,\n }}\n />\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n );\n};\n\nexport default BackofficeHubPage;\n"],"mappings":";;;;;;;;;;;;;AAyCA,IAAM,KACJ,GACA,MAC0B;CACtB,SAAQ,MAGZ,OAAO,kBAAC,GAAD;EAAM,OAAO;EAAM,QAAQ;EAAM,eAAY;CAAQ,CAAA;AAC9D,GAEM,KAAiB,MAKR;CACb,IAAM,EAAE,WAAQ,SAAM,gBAAa,eAAY;CAc/C,OAbI,KAAU,QAGV,MAAS,YAAY,EAAO,SAAS,UAAU,CAAC,EAAO,UAClD,KAES,GAAS,gBACzB;EACE;EACA,IAAI,EAAO;CACb,GACA,CACF,MACqB;AACvB,GAEa,KAAqB,EAChC,kBACyC;CACzC,IAAM,EAAE,GAAG,MAAS,EAAe,GAC7B,EAAE,SAAM,EAA8B,GACtC,EAAE,aAAU,eAAY,EAAoB,GAC5C,IAAc,EAAyB,GACvC,CAAC,GAAQ,KAAa,EAAS,EAAE,GACjC,EAAE,WAAQ,GACV,IAAQ,EAAa,EAAI,OAAO,CAAI,GACtC;CACJ,AAAI,EAAI,eAAe,SACrB,IAAc,EAAa,EAAI,aAAa,CAAI;CAElD,IAAM,IAAa,EAAmB;EAAE,IAAI,EAAI;EAAI;CAAM,CAAC,GACrD,IAAmB,EAAO,KAAK,EAAE,YAAY,GAC7C,IAAgB,EAAI,QAAQ,YAAY,IAC1C,IAAoB,EAAE,wBAAwB;CAClD,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CACrB,GAEK,IAAiB,QACd,EAAO,KAAK,OACV;EACL,IAAI,EAAM;EACV,OAAO,EAAM;EACb,aAAa,EAAM;EACnB,MAAM,EAAM;EACZ,OAAO,EAAM,MAAM,KAAK,MAAS;GAC/B,IAAI,IAA2B;GAO/B,OANI,MACF,IAAY,EAAE,sBAAsB,GAChC,EAAK,SAAS,WAChB,IAAY,EAAE,oBAAoB,KAG/B;IACL,IAAI,EAAK;IACT,MAAM,EAAK;IACX,OAAO,EAAK;IACZ,MAAM,EAAK;IACX,MAAM,EAAK;IACX;GACF;EACF,CAAC;CACH,EACD,GACA;EAAC;EAAQ;EAAe;CAAC,CAAC,GAEzB;CASJ,OARI,MACF,IAAe;EACb,OAAO;EACP,UAAU;EACV,aAAa;CACf,IAIA,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD;GACE,QAAQ;IACN;IACA;GACF;aAEA,kBAAC,GAAD;IACE,QAAQ;IACR,QAAQ;IACR,YAAY;KACV,OAAO;KACP,aAAa;KACb,MAAM,kBAAC,GAAD;MAAiB,OAAO;MAAI,QAAQ;MAAI,eAAY;KAAQ,CAAA;IACpE;GACD,CAAA;EACiB,CAAA;CACK,CAAA;AAE/B"}
|
|
1
|
+
{"version":3,"file":"BackofficeHubPage.js","names":[],"sources":["../../../src/pages/BackofficeHubPage.tsx"],"sourcesContent":["import { useMemo, useState, type JSX, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\nimport { SidebarTasksSvg } from '@plumile/ui/icons/SidebarTasksSvg.js';\nimport type { BackofficeEntityManifestMap } from '@plumile/backoffice-core/types.js';\n\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport type { BackofficeIconComponent } from '../provider/types.js';\nimport type { BackofficePreparedHubRoute } from '../router/createBackofficeRoutes.js';\nimport {\n BackofficeHubTemplate,\n type BackofficeHubTemplateGroup,\n type BackofficeHubTemplateSearch,\n} from '../components/backoffice/hub/BackofficeHubTemplate.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildHubBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport { useBackofficePermissions } from '../components/backoffice/layout/BackofficePermissionsContext.js';\nimport { resolveLabel } from '../components/backoffice/layout/sidebarUtils.js';\n\nexport type BackofficeHubPageProps = {\n prepared: BackofficePreparedHubRoute;\n};\n\ntype HubPageItemView = {\n id: string;\n kind: 'entity' | 'tool';\n label: string;\n href: string;\n icon: ReactNode;\n};\n\ntype HubPageGroupView = {\n id: string;\n title: string;\n description: string | null;\n icon: ReactNode | undefined;\n items: readonly HubPageItemView[];\n};\n\nconst renderIcon = (\n Icon: BackofficeIconComponent | undefined,\n size: number,\n): ReactNode | undefined => {\n if (Icon == null) {\n return undefined;\n }\n return <Icon width={size} height={size} aria-hidden=\"true\" />;\n};\n\nconst isItemVisible = (input: {\n entity: BackofficeEntityManifestMap[string] | null | undefined;\n kind: 'entity' | 'tool';\n permissions: unknown;\n sidebar: ReturnType<typeof useBackofficeConfig>['sidebar'];\n}): boolean => {\n const { entity, kind, permissions, sidebar } = input;\n if (entity == null) {\n return false;\n }\n if (kind === 'entity' && entity.kind !== 'tool' && !entity.hasList) {\n return false;\n }\n const isVisible = sidebar?.isItemVisible?.(\n {\n kind,\n id: entity.id,\n },\n permissions,\n );\n return isVisible !== false;\n};\n\nexport const BackofficeHubPage = ({\n prepared,\n}: BackofficeHubPageProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities, sidebar } = useBackofficeConfig();\n const permissions = useBackofficePermissions();\n const [search, setSearch] = useState('');\n const { hub } = prepared;\n const title = resolveLabel(hub.title, tApp);\n let description: string | undefined;\n if (hub.description != null) {\n description = resolveLabel(hub.description, tApp);\n }\n const breadcrumb = buildHubBreadcrumb({ id: hub.id, title });\n const normalizedSearch = search.trim().toLowerCase();\n const searchEnabled = hub.search?.enabled !== false;\n let searchPlaceholder = t('hub.search.placeholder');\n if (hub.search?.placeholder != null) {\n searchPlaceholder = resolveLabel(hub.search.placeholder, tApp);\n }\n\n const groups = useMemo<readonly HubPageGroupView[]>(() => {\n return hub.groups\n .map((group) => {\n const items = group.items\n .map((item): HubPageItemView | null => {\n const entity = entities[item.id];\n if (entity == null) {\n return null;\n }\n if (\n !isItemVisible({\n entity,\n kind: item.kind,\n permissions,\n sidebar,\n })\n ) {\n return null;\n }\n const entityConfig = entity;\n const label = resolveLabel(entityConfig.label, tApp);\n if (\n normalizedSearch !== '' &&\n !label.toLowerCase().includes(normalizedSearch)\n ) {\n return null;\n }\n return {\n id: item.id,\n kind: item.kind,\n label,\n href: entityConfig.routes.list,\n icon: renderIcon(item.icon, 20),\n };\n })\n .filter((item): item is HubPageItemView => {\n return item != null;\n });\n let groupDescription: string | null = null;\n if (group.description != null) {\n groupDescription = resolveLabel(group.description, tApp);\n }\n return {\n id: group.id,\n title: resolveLabel(group.title, tApp),\n description: groupDescription,\n icon: renderIcon(group.icon, 18),\n items,\n };\n })\n .filter((group) => {\n return group.items.length > 0;\n });\n }, [entities, hub.groups, normalizedSearch, permissions, sidebar, tApp]);\n\n let emptyTitle = t('hub.empty.title');\n if (hub.emptyState?.title != null) {\n emptyTitle = resolveLabel(hub.emptyState.title, tApp);\n }\n let emptyDescription = t('hub.empty.description');\n if (hub.emptyState?.description != null) {\n emptyDescription = resolveLabel(hub.emptyState.description, tApp);\n }\n let subtitle = t('hub.subtitle');\n if (description != null) {\n subtitle = description;\n }\n const hasMixedKinds = groups.some((group) => {\n const kinds = new Set(\n group.items.map((item) => {\n return item.kind;\n }),\n );\n return kinds.size > 1;\n });\n\n const templateGroups = useMemo<readonly BackofficeHubTemplateGroup[]>(() => {\n return groups.map((group) => {\n return {\n id: group.id,\n title: group.title,\n description: group.description,\n icon: group.icon,\n items: group.items.map((item) => {\n let metaLabel: string | null = null;\n if (hasMixedKinds) {\n metaLabel = t('hub.itemKinds.entity');\n if (item.kind === 'tool') {\n metaLabel = t('hub.itemKinds.tool');\n }\n }\n return {\n id: item.id,\n kind: item.kind,\n label: item.label,\n href: item.href,\n icon: item.icon,\n metaLabel,\n };\n }),\n };\n });\n }, [groups, hasMixedKinds, t]);\n\n let searchConfig: BackofficeHubTemplateSearch | undefined;\n if (searchEnabled) {\n searchConfig = {\n value: search,\n onChange: setSearch,\n placeholder: searchPlaceholder,\n };\n }\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n header={{\n title,\n subtitle,\n }}\n >\n <BackofficeHubTemplate\n groups={templateGroups}\n search={searchConfig}\n emptyState={{\n title: emptyTitle,\n description: emptyDescription,\n icon: <SidebarTasksSvg width={28} height={28} aria-hidden=\"true\" />,\n }}\n />\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n );\n};\n\nexport default BackofficeHubPage;\n"],"mappings":";;;;;;;;;;;;;AAyCA,IAAM,KACJ,GACA,MAC0B;CACtB,SAAQ,MAGZ,OAAO,kBAAC,GAAD;EAAM,OAAO;EAAM,QAAQ;EAAM,eAAY;CAAQ,CAAA;AAC9D,GAEM,KAAiB,MAKR;CACb,IAAM,EAAE,WAAQ,SAAM,gBAAa,eAAY;CAc/C,OAbI,KAAU,QAGV,MAAS,YAAY,EAAO,SAAS,UAAU,CAAC,EAAO,UAClD,KAES,GAAS,gBACzB;EACE;EACA,IAAI,EAAO;CACb,GACA,CACF,MACqB;AACvB,GAEa,KAAqB,EAChC,kBACyC;CACzC,IAAM,EAAE,GAAG,MAAS,EAAe,GAC7B,EAAE,SAAM,EAA8B,GACtC,EAAE,aAAU,eAAY,EAAoB,GAC5C,IAAc,EAAyB,GACvC,CAAC,GAAQ,KAAa,EAAS,EAAE,GACjC,EAAE,WAAQ,GACV,IAAQ,EAAa,EAAI,OAAO,CAAI,GACtC;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,EAAE,uBAAuB;CAChD,AAAI,EAAI,YAAY,eAAe,SACjC,IAAmB,EAAa,EAAI,WAAW,aAAa,CAAI;CAElE,IAAI,IAAW,EAAE,cAAc;CAC/B,AAAI,KAAe,SACjB,IAAW;CAEb,IAAM,IAAgB,EAAO,MAAM,MAM1B,IALW,IAChB,EAAM,MAAM,KAAK,MACR,EAAK,IACb,CAEI,CAAA,CAAM,OAAO,CACrB,GAEK,IAAiB,QACd,EAAO,KAAK,OACV;EACL,IAAI,EAAM;EACV,OAAO,EAAM;EACb,aAAa,EAAM;EACnB,MAAM,EAAM;EACZ,OAAO,EAAM,MAAM,KAAK,MAAS;GAC/B,IAAI,IAA2B;GAO/B,OANI,MACF,IAAY,EAAE,sBAAsB,GAChC,EAAK,SAAS,WAChB,IAAY,EAAE,oBAAoB,KAG/B;IACL,IAAI,EAAK;IACT,MAAM,EAAK;IACX,OAAO,EAAK;IACZ,MAAM,EAAK;IACX,MAAM,EAAK;IACX;GACF;EACF,CAAC;CACH,EACD,GACA;EAAC;EAAQ;EAAe;CAAC,CAAC,GAEzB;CASJ,OARI,MACF,IAAe;EACb,OAAO;EACP,UAAU;EACV,aAAa;CACf,IAIA,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD;GACE,QAAQ;IACN;IACA;GACF;aAEA,kBAAC,GAAD;IACE,QAAQ;IACR,QAAQ;IACR,YAAY;KACV,OAAO;KACP,aAAa;KACb,MAAM,kBAAC,GAAD;MAAiB,OAAO;MAAI,QAAQ;MAAI,eAAY;KAAQ,CAAA;IACpE;GACD,CAAA;EACiB,CAAA;CACK,CAAA;AAE/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeLayoutPage.js","names":[],"sources":["../../../src/pages/BackofficeLayoutPage.tsx"],"sourcesContent":["import {\n useEffect,\n useMemo,\n type JSX,\n type ReactNode,\n useCallback,\n useContext,\n useState,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n commitMutation,\n usePreloadedQuery,\n type PreloadedQuery,\n} from 'react-relay';\nimport type {\n GraphQLTaggedNode,\n MutationParameters,\n OperationType,\n} from 'relay-runtime';\nimport RoutingContext from '@plumile/router/routing/RoutingContext.js';\nimport useLocation from '@plumile/router/routing/useLocation.js';\n\nimport { AdminShellLayout } from '@plumile/ui/admin/templates/admin_shell_layout/AdminShellLayout.js';\nimport { ToastProvider } from '@plumile/ui/atomic/molecules/toast/ToastProvider.js';\nimport { EnvironmentBadge } from '@plumile/ui/backoffice/atoms/environment_badge/EnvironmentBadge.js';\nimport { GlobalSearchInput } from '@plumile/ui/backoffice/molecules/global_search_input/GlobalSearchInput.js';\nimport { SidebarProfileMenu } from '@plumile/ui/components/navigation/sidebar/SidebarProfileMenu.js';\n\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport type { LogoutResponse, LogoutVariables } from '../hooks/useAuth.js';\nimport { useBackofficeSidebarPins } from '../hooks/useBackofficeSidebarPins.js';\nimport { useSidebarGroupCollapse } from '../hooks/useSidebarGroupCollapse.js';\nimport { buildSidebarSections } from '../components/backoffice/layout/buildSidebarSections.js';\nimport { BackofficeContentBoundary } from '../components/backoffice/routing/BackofficeContentBoundary.js';\nimport {\n resolveActiveEntityId,\n resolveSidebarGroups,\n resolveVisibleEntityIds,\n} from '../components/backoffice/layout/sidebarUtils.js';\nimport { BackofficeTopbarPortalContextProvider } from '../components/backoffice/layout/breadcrumb/BackofficeTopbarPortalContext.js';\nimport { BackofficePermissionsProvider } from '../components/backoffice/layout/BackofficePermissionsContext.js';\nimport {\n mapViewerToSidebarProfileView,\n type BackofficeViewerIdentity,\n} from '../components/backoffice/layout/mapViewerToSidebarProfileView.js';\nimport { resetRelayStore } from '../relay/environment.js';\nimport { useRelayEnvironment } from '../relay/useRelayEnvironment.js';\nimport { getBackofficeLoginPath } from '../router/backofficeAuthPaths.js';\nimport type { BackofficeSidebarRecentItem } from '../provider/types.js';\n\nexport type BackofficeLayoutPageProps = {\n children: ReactNode;\n permissionsQuery?: GraphQLTaggedNode;\n prepared?: PreloadedQuery<OperationType> | null;\n authStatus?: {\n isLoggedIn?: boolean | null;\n me?: BackofficeViewerIdentity | null;\n } | null;\n activeGroupId?: string | null;\n};\n\ntype LayoutShellProps = {\n children: ReactNode;\n permissions: unknown;\n authStatus?: {\n isLoggedIn?: boolean | null;\n me?: BackofficeViewerIdentity | null;\n } | null;\n activeGroupId?: string | null;\n};\n\nconst DEFAULT_RECENT_ITEMS_STORAGE_KEY = 'plumile:backoffice:recent-items';\nconst DEFAULT_SIDEBAR_PREFS_STORAGE_KEY = 'plumile:backoffice:sidebar';\n\nconst readRecentItems = (\n storageKey: string,\n): readonly BackofficeSidebarRecentItem[] => {\n if (typeof window === 'undefined') {\n return [];\n }\n try {\n const raw = window.localStorage.getItem(storageKey);\n if (raw == null) {\n return [];\n }\n const parsed = JSON.parse(raw) as unknown;\n if (!Array.isArray(parsed)) {\n return [];\n }\n return parsed.filter((item): item is BackofficeSidebarRecentItem => {\n if (item == null || typeof item !== 'object') {\n return false;\n }\n const candidate = item as Partial<BackofficeSidebarRecentItem>;\n return (\n (candidate.kind === 'entity' || candidate.kind === 'tool') &&\n typeof candidate.id === 'string' &&\n typeof candidate.label === 'string' &&\n typeof candidate.href === 'string' &&\n typeof candidate.visitedAt === 'number'\n );\n });\n } catch {\n return [];\n }\n};\n\nconst writeRecentItems = (\n storageKey: string,\n items: readonly BackofficeSidebarRecentItem[],\n): void => {\n if (typeof window === 'undefined') {\n return;\n }\n try {\n window.localStorage.setItem(storageKey, JSON.stringify(items));\n } catch {\n // Ignore storage quota / privacy mode failures.\n }\n};\n\nconst BackofficeLayoutShell = ({\n children,\n permissions,\n authStatus,\n activeGroupId,\n}: LayoutShellProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { pathname } = useLocation();\n const routing = useContext(RoutingContext);\n const relayEnvironment = useRelayEnvironment();\n const {\n auth: authConfig,\n basePath,\n dashboards,\n entities,\n sidebar,\n } = useBackofficeConfig();\n const [sidebarQuery, setSidebarQuery] = useState('');\n const sidebarPreferencesStorageKey =\n sidebar?.preferences?.storageKey ?? DEFAULT_SIDEBAR_PREFS_STORAGE_KEY;\n const persistSidebarCollapsed =\n sidebar?.preferences?.persistCollapsed === true;\n const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(() => {\n if (!persistSidebarCollapsed || typeof window === 'undefined') {\n return false;\n }\n try {\n return (\n window.localStorage.getItem(\n `${sidebarPreferencesStorageKey}:collapsed`,\n ) === 'true'\n );\n } catch {\n return false;\n }\n });\n const [isSigningOut, setIsSigningOut] = useState(false);\n const [topbarTarget, setTopbarTarget] = useState<HTMLDivElement | null>(null);\n const recentItemsConfig = sidebar?.recentItems;\n const recentItemsEnabled = recentItemsConfig?.enabled === true;\n const recentItemsStorageKey =\n recentItemsConfig?.storageKey ?? DEFAULT_RECENT_ITEMS_STORAGE_KEY;\n const recentItemsMaxItems = recentItemsConfig?.maxItems ?? 8;\n const [recentItems, setRecentItems] = useState<\n readonly BackofficeSidebarRecentItem[]\n >(() => {\n if (!recentItemsEnabled) {\n return [];\n }\n return readRecentItems(recentItemsStorageKey);\n });\n\n useEffect(() => {\n if (!persistSidebarCollapsed || typeof window === 'undefined') {\n return;\n }\n try {\n window.localStorage.setItem(\n `${sidebarPreferencesStorageKey}:collapsed`,\n String(isSidebarCollapsed),\n );\n } catch {\n // Ignore storage quota / privacy mode failures.\n }\n }, [\n isSidebarCollapsed,\n persistSidebarCollapsed,\n sidebarPreferencesStorageKey,\n ]);\n\n const groups = useMemo(() => {\n return resolveSidebarGroups(entities, sidebar);\n }, [entities, sidebar]);\n\n const groupIds = useMemo(() => {\n return Object.keys(groups);\n }, [groups]);\n\n const defaultCollapsedByGroupId = useMemo(() => {\n return Object.fromEntries(\n Object.entries(groups).map(([groupId, group]) => {\n return [groupId, group.behavior?.defaultCollapsed ?? true];\n }),\n );\n }, [groups]);\n\n const visibleEntityIds = useMemo(() => {\n return resolveVisibleEntityIds(groups, entities, sidebar, permissions);\n }, [entities, groups, permissions, sidebar]);\n\n const activeEntityId = useMemo(() => {\n return resolveActiveEntityId(pathname, entities);\n }, [entities, pathname]);\n\n useEffect(() => {\n if (!recentItemsEnabled || activeEntityId == null) {\n return;\n }\n const config = entities[activeEntityId];\n if (config == null) {\n return;\n }\n if (config.kind !== 'tool' && !config.hasList) {\n return;\n }\n const href = config.routes.list;\n let kind: BackofficeSidebarRecentItem['kind'] = 'entity';\n if (config.kind === 'tool') {\n kind = 'tool';\n }\n const item: BackofficeSidebarRecentItem = {\n kind,\n id: activeEntityId,\n label: config.label(tApp),\n href,\n visitedAt: Date.now(),\n };\n setRecentItems((prev) => {\n const next = [\n item,\n ...prev.filter((entry) => {\n return entry.id !== item.id || entry.kind !== item.kind;\n }),\n ].slice(0, recentItemsMaxItems);\n writeRecentItems(recentItemsStorageKey, next);\n return next;\n });\n }, [\n activeEntityId,\n entities,\n recentItemsEnabled,\n recentItemsMaxItems,\n recentItemsStorageKey,\n tApp,\n ]);\n\n const pinningEnabled = sidebar?.pinnedItems?.enabled === true;\n\n const {\n pins,\n toggle: togglePin,\n reorder: reorderPin,\n } = useBackofficeSidebarPins({\n enabled: pinningEnabled,\n storageKey: sidebar?.pinnedItems?.storageKey,\n visibleEntityIds,\n });\n\n let sidebarPinnedEntityIds: readonly string[] | undefined;\n let sidebarTogglePin: ((entityId: string) => void) | undefined;\n let sidebarReorderPin: ((fromId: string, toId: string) => void) | undefined;\n if (pinningEnabled) {\n sidebarPinnedEntityIds = pins;\n sidebarTogglePin = togglePin;\n sidebarReorderPin = reorderPin;\n }\n\n let groupCollapseStorageKey: string | undefined;\n if (sidebar?.preferences?.storageKey != null) {\n groupCollapseStorageKey = `${sidebar.preferences.storageKey}:groups`;\n }\n\n const { collapsedByGroupId, setCollapsed } = useSidebarGroupCollapse({\n groupIds,\n activeGroupId,\n defaultCollapsedByGroupId,\n persist: sidebar?.preferences?.persistGroups === true,\n storageKey: groupCollapseStorageKey,\n });\n\n const sections = useMemo(() => {\n return buildSidebarSections({\n basePath,\n pathname,\n entities,\n dashboards,\n sidebar,\n permissions,\n searchQuery: sidebarQuery,\n tApp,\n t,\n pinnedEntityIds: sidebarPinnedEntityIds,\n recentItems,\n onTogglePin: sidebarTogglePin,\n onReorderPin: sidebarReorderPin,\n collapsedByGroupId,\n onGroupCollapsedChange: setCollapsed,\n sidebarCollapsed: false,\n });\n }, [\n basePath,\n collapsedByGroupId,\n entities,\n dashboards,\n pathname,\n permissions,\n recentItems,\n setCollapsed,\n sidebar,\n sidebarPinnedEntityIds,\n sidebarQuery,\n sidebarReorderPin,\n sidebarTogglePin,\n t,\n tApp,\n ]);\n\n const mobileSections = useMemo(() => {\n return buildSidebarSections({\n basePath,\n pathname,\n entities,\n dashboards,\n sidebar,\n permissions,\n searchQuery: sidebarQuery,\n tApp,\n t,\n pinnedEntityIds: sidebarPinnedEntityIds,\n recentItems,\n onTogglePin: sidebarTogglePin,\n onReorderPin: sidebarReorderPin,\n collapsedByGroupId,\n onGroupCollapsedChange: setCollapsed,\n sidebarCollapsed: false,\n });\n }, [\n basePath,\n collapsedByGroupId,\n entities,\n dashboards,\n pathname,\n permissions,\n recentItems,\n setCollapsed,\n sidebar,\n sidebarPinnedEntityIds,\n sidebarQuery,\n sidebarReorderPin,\n sidebarTogglePin,\n t,\n tApp,\n ]);\n\n const environment = useMemo(() => {\n const meta = import.meta as unknown as { env?: Record<string, unknown> };\n if (meta.env?.DEV === true) {\n return 'dev' as const;\n }\n return 'prod' as const;\n }, []);\n\n const handleSignOut = useCallback(() => {\n if (isSigningOut) {\n return;\n }\n\n type LogoutMutation = MutationParameters & {\n response: LogoutResponse;\n variables: LogoutVariables;\n };\n\n setIsSigningOut(true);\n\n const runSignOut = async (): Promise<void> => {\n try {\n const config = await authConfig.logout.load();\n await new Promise<void>((resolve, reject) => {\n commitMutation<LogoutMutation>(relayEnvironment, {\n mutation: config.logoutMutation,\n variables: {},\n onCompleted: () => {\n resolve();\n },\n onError: (error) => {\n reject(error);\n },\n });\n });\n localStorage.removeItem('auth_token');\n localStorage.removeItem('remember_me');\n resetRelayStore();\n routing?.history.push({ pathname: getBackofficeLoginPath(basePath) });\n } finally {\n setIsSigningOut(false);\n }\n };\n\n runSignOut().catch(() => {\n /* noop */\n });\n }, [authConfig.logout, basePath, isSigningOut, relayEnvironment, routing]);\n\n const viewer = authStatus?.me ?? null;\n const sidebarProfile = useMemo(() => {\n return mapViewerToSidebarProfileView({\n viewer,\n unknownUserLabel: t('sidebar.profile.unknownUser'),\n });\n }, [t, viewer]);\n\n const sidebarFooter = (\n <SidebarProfileMenu\n collapsed={false}\n viewer={sidebarProfile}\n labels={{\n sectionTitle: t('sidebar.profile.title'),\n menuAriaLabel: t('sidebar.profile.menuAriaLabel'),\n signOut: t('sidebar.profile.actions.signOut'),\n }}\n onSignOut={handleSignOut}\n isSigningOut={isSigningOut}\n />\n );\n\n const mobileSidebarFooter = (\n <SidebarProfileMenu\n collapsed={false}\n viewer={sidebarProfile}\n labels={{\n sectionTitle: t('sidebar.profile.title'),\n menuAriaLabel: t('sidebar.profile.menuAriaLabel'),\n signOut: t('sidebar.profile.actions.signOut'),\n }}\n onSignOut={handleSignOut}\n isSigningOut={isSigningOut}\n />\n );\n\n let contentNode: JSX.Element | null = null;\n if (topbarTarget != null) {\n contentNode = (\n <BackofficeContentBoundary>{children}</BackofficeContentBoundary>\n );\n }\n\n const sidebarSearchNode = (\n <GlobalSearchInput\n value={sidebarQuery}\n onChange={setSidebarQuery}\n placeholder={t('sidebar.search.placeholder')}\n ariaLabel={t('sidebar.search.placeholder')}\n />\n );\n\n return (\n <ToastProvider>\n <AdminShellLayout\n sidebar={{\n sections,\n header: <EnvironmentBadge environment={environment} />,\n search: sidebarSearchNode,\n footer: sidebarFooter,\n isCollapsed: isSidebarCollapsed,\n onCollapsedChange: setIsSidebarCollapsed,\n collapseToggleLabel: t('sidebar.actions.collapseSidebar'),\n expandToggleLabel: t('sidebar.actions.expandSidebar'),\n navigationAriaLabel: t('sidebar.navigationAriaLabel'),\n }}\n mobileSidebar={{\n sections: mobileSections,\n header: <EnvironmentBadge environment={environment} />,\n search: sidebarSearchNode,\n footer: mobileSidebarFooter,\n isCollapsed: false,\n hideCollapseToggle: true,\n navigationAriaLabel: t('sidebar.navigationAriaLabel'),\n }}\n topbar={{\n breadcrumb: <div ref={setTopbarTarget} />,\n }}\n contentScrollMode=\"contained\"\n >\n <BackofficePermissionsProvider permissions={permissions}>\n <BackofficeTopbarPortalContextProvider\n value={{\n target: topbarTarget,\n dashboardHref: basePath,\n dashboardLabel: t('sidebar.items.dashboard'),\n }}\n >\n {contentNode}\n </BackofficeTopbarPortalContextProvider>\n </BackofficePermissionsProvider>\n </AdminShellLayout>\n </ToastProvider>\n );\n};\n\ntype LayoutWithPermissionsProps = {\n children: ReactNode;\n permissionsQuery: GraphQLTaggedNode;\n prepared: PreloadedQuery<OperationType>;\n authStatus?: {\n isLoggedIn?: boolean | null;\n me?: BackofficeViewerIdentity | null;\n } | null;\n activeGroupId?: string | null;\n};\n\nconst LayoutWithPermissions = ({\n children,\n permissionsQuery,\n prepared,\n authStatus,\n activeGroupId,\n}: LayoutWithPermissionsProps): JSX.Element => {\n const permissions = usePreloadedQuery(permissionsQuery, prepared);\n\n return (\n <BackofficeLayoutShell\n permissions={permissions}\n authStatus={authStatus}\n activeGroupId={activeGroupId}\n >\n {children}\n </BackofficeLayoutShell>\n );\n};\n\nexport const BackofficeLayoutPage = ({\n children,\n permissionsQuery,\n prepared,\n authStatus,\n activeGroupId,\n}: BackofficeLayoutPageProps): JSX.Element => {\n if (permissionsQuery != null && prepared != null) {\n return (\n <LayoutWithPermissions\n permissionsQuery={permissionsQuery}\n prepared={prepared}\n authStatus={authStatus}\n activeGroupId={activeGroupId}\n >\n {children}\n </LayoutWithPermissions>\n );\n }\n\n return (\n <BackofficeLayoutShell\n permissions={null}\n authStatus={authStatus}\n activeGroupId={activeGroupId}\n >\n {children}\n </BackofficeLayoutShell>\n );\n};\n\nexport default BackofficeLayoutPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAM,KAAmC,mCACnC,KAAoC,8BAEpC,MACJ,MAC2C;CAC3C,IAAI,OAAO,SAAW,KACpB,OAAO,CAAC;CAEV,IAAI;EACF,IAAM,IAAM,OAAO,aAAa,QAAQ,CAAU;EAClD,IAAI,KAAO,MACT,OAAO,CAAC;EAEV,IAAM,IAAS,KAAK,MAAM,CAAG;EAI7B,OAHK,MAAM,QAAQ,CAAM,IAGlB,EAAO,QAAQ,MAA8C;GAClE,IAAoB,OAAO,KAAS,aAAhC,GACF,OAAO;GAET,IAAM,IAAY;GAClB,QACG,EAAU,SAAS,YAAY,EAAU,SAAS,WACnD,OAAO,EAAU,MAAO,YACxB,OAAO,EAAU,SAAU,YAC3B,OAAO,EAAU,QAAS,YAC1B,OAAO,EAAU,aAAc;EAEnC,CAAC,IAdQ,CAAC;CAeZ,QAAQ;EACN,OAAO,CAAC;CACV;AACF,GAEM,MACJ,GACA,MACS;CACL,aAAO,SAAW,MAGtB,IAAI;EACF,OAAO,aAAa,QAAQ,GAAY,KAAK,UAAU,CAAK,CAAC;CAC/D,QAAQ,CAER;AACF,GAEM,KAAyB,EAC7B,aACA,gBACA,eACA,uBACmC;CACnC,IAAM,EAAE,GAAG,MAAS,GAAe,GAC7B,EAAE,SAAM,EAA8B,GACtC,EAAE,gBAAa,GAAY,GAC3B,IAAU,GAAW,EAAc,GACnC,IAAmB,GAAoB,GACvC,EACJ,MAAM,GACN,aACA,eACA,aACA,eACE,EAAoB,GAClB,CAAC,GAAc,MAAmB,EAAS,EAAE,GAC7C,IACJ,GAAS,aAAa,cAAc,IAChC,IACJ,GAAS,aAAa,qBAAqB,IACvC,CAAC,GAAoB,MAAyB,QAAe;EACjE,IAAI,CAAC,KAA2B,OAAO,SAAW,KAChD,OAAO;EAET,I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,EAAO,MAAM,CAAI;GACxB;GACA,WAAW,KAAK,IAAI;EACtB;EACA,IAAgB,MAAS;GACvB,IAAM,IAAO,CACX,GACA,GAAG,EAAK,QAAQ,MACP,EAAM,OAAO,EAAK,MAAM,EAAM,SAAS,EAAK,IACpD,CACH,EAAE,MAAM,GAAG,CAAmB;GAE9B,OADA,GAAiB,GAAuB,CAAI,GACrC;EACT,CAAC;CACH,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,IAAM,IAAiB,GAAS,aAAa,YAAY,IAEnD,EACJ,UACA,QAAQ,IACR,SAAS,OACP,GAAyB;EAC3B,SAAS;EACT,YAAY,GAAS,aAAa;EAClC;CACF,CAAC,GAEG,GACA,GACA;CACJ,AAAI,MACF,IAAyB,IACzB,IAAmB,IACnB,IAAoB;CAGtB,IAAI;CACJ,AAAI,GAAS,aAAa,cAAc,SACtC,IAA0B,GAAG,EAAQ,YAAY,WAAW;CAG9D,IAAM,EAAE,uBAAoB,oBAAiB,GAAwB;EACnE;EACA;EACA;EACA,SAAS,GAAS,aAAa,kBAAkB;EACjD,YAAY;CACd,CAAC,GAEK,KAAW,QACR,EAAqB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA,iBAAiB;EACjB;EACA,aAAa;EACb,cAAc;EACd;EACA,wBAAwB;EACxB,kBAAkB;CACpB,CAAC,GACA;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GAEK,KAAiB,QACd,EAAqB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA,iBAAiB;EACjB;EACA,aAAa;EACb,cAAc;EACd;EACA,wBAAwB;EACxB,kBAAkB;CACpB,CAAC,GACA;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GAEK,IAAc,QAEd,OADgB,KACX,KAA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B;EAC3C,WAAW,EAAE,4BAA4B;CAC1C,CAAA;CAGH,OACE,kBAAC,IAAD,EAAA,UACE,kBAAC,GAAD;EACE,SAAS;GACP;GACA,QAAQ,kBAAC,GAAD,EAA+B,eAAc,CAAA;GACrD,QAAQ;GACR,QAAQ;GACR,aAAa;GACb,mBAAmB;GACnB,qBAAqB,EAAE,iCAAiC;GACxD,mBAAmB,EAAE,+BAA+B;GACpD,qBAAqB,EAAE,6BAA6B;EACtD;EACA,eAAe;GACb,UAAU;GACV,QAAQ,kBAAC,GAAD,EAA+B,eAAc,CAAA;GACrD,QAAQ;GACR,QAAQ;GACR,aAAa;GACb,oBAAoB;GACpB,qBAAqB,EAAE,6BAA6B;EACtD;EACA,QAAQ,EACN,YAAY,kBAAC,OAAD,EAAK,KAAK,GAAkB,CAAA,EAC1C;EACA,mBAAkB;YAElB,kBAAC,IAAD;GAA4C;aAC1C,kBAAC,GAAD;IACE,OAAO;KACL,QAAQ;KACR,eAAe;KACf,gBAAgB,EAAE,yBAAyB;IAC7C;cAEC;GACoC,CAAA;EACV,CAAA;CACf,CAAA,EACL,CAAA;AAEnB,GAaM,KAAyB,EAC7B,aACA,qBACA,aACA,eACA,uBAKE,kBAAC,GAAD;CACe,aAJG,EAAkB,GAAkB,CAIvC;CACD;CACG;CAEd;AACoB,CAAA,GAId,KAAwB,EACnC,aACA,qBACA,aACA,eACA,uBAEI,KAAoB,QAAQ,KAAY,OAExC,kBAAC,GAAD;CACoB;CACR;CACE;CACG;CAEd;AACoB,CAAA,IAKzB,kBAAC,GAAD;CACE,aAAa;CACD;CACG;CAEd;AACoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"BackofficeLayoutPage.js","names":[],"sources":["../../../src/pages/BackofficeLayoutPage.tsx"],"sourcesContent":["import {\n useEffect,\n useMemo,\n type JSX,\n type ReactNode,\n useCallback,\n useContext,\n useState,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n commitMutation,\n usePreloadedQuery,\n type PreloadedQuery,\n} from 'react-relay';\nimport type {\n GraphQLTaggedNode,\n MutationParameters,\n OperationType,\n} from 'relay-runtime';\nimport RoutingContext from '@plumile/router/routing/RoutingContext.js';\nimport useLocation from '@plumile/router/routing/useLocation.js';\n\nimport { AdminShellLayout } from '@plumile/ui/admin/templates/admin_shell_layout/AdminShellLayout.js';\nimport { ToastProvider } from '@plumile/ui/atomic/molecules/toast/ToastProvider.js';\nimport { EnvironmentBadge } from '@plumile/ui/backoffice/atoms/environment_badge/EnvironmentBadge.js';\nimport { GlobalSearchInput } from '@plumile/ui/backoffice/molecules/global_search_input/GlobalSearchInput.js';\nimport { SidebarProfileMenu } from '@plumile/ui/components/navigation/sidebar/SidebarProfileMenu.js';\n\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport type { LogoutResponse, LogoutVariables } from '../hooks/useAuth.js';\nimport { useBackofficeSidebarPins } from '../hooks/useBackofficeSidebarPins.js';\nimport { useSidebarGroupCollapse } from '../hooks/useSidebarGroupCollapse.js';\nimport { buildSidebarSections } from '../components/backoffice/layout/buildSidebarSections.js';\nimport { BackofficeContentBoundary } from '../components/backoffice/routing/BackofficeContentBoundary.js';\nimport {\n resolveActiveEntityId,\n resolveSidebarGroups,\n resolveVisibleEntityIds,\n} from '../components/backoffice/layout/sidebarUtils.js';\nimport { BackofficeTopbarPortalContextProvider } from '../components/backoffice/layout/breadcrumb/BackofficeTopbarPortalContext.js';\nimport { BackofficePermissionsProvider } from '../components/backoffice/layout/BackofficePermissionsContext.js';\nimport {\n mapViewerToSidebarProfileView,\n type BackofficeViewerIdentity,\n} from '../components/backoffice/layout/mapViewerToSidebarProfileView.js';\nimport { resetRelayStore } from '../relay/environment.js';\nimport { useRelayEnvironment } from '../relay/useRelayEnvironment.js';\nimport { getBackofficeLoginPath } from '../router/backofficeAuthPaths.js';\nimport type { BackofficeSidebarRecentItem } from '../provider/types.js';\n\nexport type BackofficeLayoutPageProps = {\n children: ReactNode;\n permissionsQuery?: GraphQLTaggedNode;\n prepared?: PreloadedQuery<OperationType> | null;\n authStatus?: {\n isLoggedIn?: boolean | null;\n me?: BackofficeViewerIdentity | null;\n } | null;\n activeGroupId?: string | null;\n};\n\ntype LayoutShellProps = {\n children: ReactNode;\n permissions: unknown;\n authStatus?: {\n isLoggedIn?: boolean | null;\n me?: BackofficeViewerIdentity | null;\n } | null;\n activeGroupId?: string | null;\n};\n\nconst DEFAULT_RECENT_ITEMS_STORAGE_KEY = 'plumile:backoffice:recent-items';\nconst DEFAULT_SIDEBAR_PREFS_STORAGE_KEY = 'plumile:backoffice:sidebar';\n\nconst readRecentItems = (\n storageKey: string,\n): readonly BackofficeSidebarRecentItem[] => {\n if (typeof window === 'undefined') {\n return [];\n }\n try {\n const raw = window.localStorage.getItem(storageKey);\n if (raw == null) {\n return [];\n }\n const parsed = JSON.parse(raw) as unknown;\n if (!Array.isArray(parsed)) {\n return [];\n }\n return parsed.filter((item): item is BackofficeSidebarRecentItem => {\n if (item == null || typeof item !== 'object') {\n return false;\n }\n const candidate = item as Partial<BackofficeSidebarRecentItem>;\n return (\n (candidate.kind === 'entity' || candidate.kind === 'tool') &&\n typeof candidate.id === 'string' &&\n typeof candidate.label === 'string' &&\n typeof candidate.href === 'string' &&\n typeof candidate.visitedAt === 'number'\n );\n });\n } catch {\n return [];\n }\n};\n\nconst writeRecentItems = (\n storageKey: string,\n items: readonly BackofficeSidebarRecentItem[],\n): void => {\n if (typeof window === 'undefined') {\n return;\n }\n try {\n window.localStorage.setItem(storageKey, JSON.stringify(items));\n } catch {\n // Ignore storage quota / privacy mode failures.\n }\n};\n\nconst BackofficeLayoutShell = ({\n children,\n permissions,\n authStatus,\n activeGroupId,\n}: LayoutShellProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { pathname } = useLocation();\n const routing = useContext(RoutingContext);\n const relayEnvironment = useRelayEnvironment();\n const {\n auth: authConfig,\n basePath,\n dashboards,\n entities,\n sidebar,\n } = useBackofficeConfig();\n const [sidebarQuery, setSidebarQuery] = useState('');\n const sidebarPreferencesStorageKey =\n sidebar?.preferences?.storageKey ?? DEFAULT_SIDEBAR_PREFS_STORAGE_KEY;\n const persistSidebarCollapsed =\n sidebar?.preferences?.persistCollapsed === true;\n const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(() => {\n if (!persistSidebarCollapsed || typeof window === 'undefined') {\n return false;\n }\n try {\n return (\n window.localStorage.getItem(\n `${sidebarPreferencesStorageKey}:collapsed`,\n ) === 'true'\n );\n } catch {\n return false;\n }\n });\n const [isSigningOut, setIsSigningOut] = useState(false);\n const [topbarTarget, setTopbarTarget] = useState<HTMLDivElement | null>(null);\n const recentItemsConfig = sidebar?.recentItems;\n const recentItemsEnabled = recentItemsConfig?.enabled === true;\n const recentItemsStorageKey =\n recentItemsConfig?.storageKey ?? DEFAULT_RECENT_ITEMS_STORAGE_KEY;\n const recentItemsMaxItems = recentItemsConfig?.maxItems ?? 8;\n const [recentItems, setRecentItems] = useState<\n readonly BackofficeSidebarRecentItem[]\n >(() => {\n if (!recentItemsEnabled) {\n return [];\n }\n return readRecentItems(recentItemsStorageKey);\n });\n\n useEffect(() => {\n if (!persistSidebarCollapsed || typeof window === 'undefined') {\n return;\n }\n try {\n window.localStorage.setItem(\n `${sidebarPreferencesStorageKey}:collapsed`,\n String(isSidebarCollapsed),\n );\n } catch {\n // Ignore storage quota / privacy mode failures.\n }\n }, [\n isSidebarCollapsed,\n persistSidebarCollapsed,\n sidebarPreferencesStorageKey,\n ]);\n\n const groups = useMemo(() => {\n return resolveSidebarGroups(entities, sidebar);\n }, [entities, sidebar]);\n\n const groupIds = useMemo(() => {\n return Object.keys(groups);\n }, [groups]);\n\n const defaultCollapsedByGroupId = useMemo(() => {\n return Object.fromEntries(\n Object.entries(groups).map(([groupId, group]) => {\n return [groupId, group.behavior?.defaultCollapsed ?? true];\n }),\n );\n }, [groups]);\n\n const visibleEntityIds = useMemo(() => {\n return resolveVisibleEntityIds(groups, entities, sidebar, permissions);\n }, [entities, groups, permissions, sidebar]);\n\n const activeEntityId = useMemo(() => {\n return resolveActiveEntityId(pathname, entities);\n }, [entities, pathname]);\n\n useEffect(() => {\n if (!recentItemsEnabled || activeEntityId == null) {\n return;\n }\n const config = entities[activeEntityId];\n if (config == null) {\n return;\n }\n if (config.kind !== 'tool' && !config.hasList) {\n return;\n }\n const href = config.routes.list;\n let kind: BackofficeSidebarRecentItem['kind'] = 'entity';\n if (config.kind === 'tool') {\n kind = 'tool';\n }\n const item: BackofficeSidebarRecentItem = {\n kind,\n id: activeEntityId,\n label: config.label(tApp),\n href,\n visitedAt: Date.now(),\n };\n setRecentItems((prev) => {\n const next = [\n item,\n ...prev.filter((entry) => {\n return entry.id !== item.id || entry.kind !== item.kind;\n }),\n ].slice(0, recentItemsMaxItems);\n writeRecentItems(recentItemsStorageKey, next);\n return next;\n });\n }, [\n activeEntityId,\n entities,\n recentItemsEnabled,\n recentItemsMaxItems,\n recentItemsStorageKey,\n tApp,\n ]);\n\n const pinningEnabled = sidebar?.pinnedItems?.enabled === true;\n\n const {\n pins,\n toggle: togglePin,\n reorder: reorderPin,\n } = useBackofficeSidebarPins({\n enabled: pinningEnabled,\n storageKey: sidebar?.pinnedItems?.storageKey,\n visibleEntityIds,\n });\n\n let sidebarPinnedEntityIds: readonly string[] | undefined;\n let sidebarTogglePin: ((entityId: string) => void) | undefined;\n let sidebarReorderPin: ((fromId: string, toId: string) => void) | undefined;\n if (pinningEnabled) {\n sidebarPinnedEntityIds = pins;\n sidebarTogglePin = togglePin;\n sidebarReorderPin = reorderPin;\n }\n\n let groupCollapseStorageKey: string | undefined;\n if (sidebar?.preferences?.storageKey != null) {\n groupCollapseStorageKey = `${sidebar.preferences.storageKey}:groups`;\n }\n\n const { collapsedByGroupId, setCollapsed } = useSidebarGroupCollapse({\n groupIds,\n activeGroupId,\n defaultCollapsedByGroupId,\n persist: sidebar?.preferences?.persistGroups === true,\n storageKey: groupCollapseStorageKey,\n });\n\n const sections = useMemo(() => {\n return buildSidebarSections({\n basePath,\n pathname,\n entities,\n dashboards,\n sidebar,\n permissions,\n searchQuery: sidebarQuery,\n tApp,\n t,\n pinnedEntityIds: sidebarPinnedEntityIds,\n recentItems,\n onTogglePin: sidebarTogglePin,\n onReorderPin: sidebarReorderPin,\n collapsedByGroupId,\n onGroupCollapsedChange: setCollapsed,\n sidebarCollapsed: false,\n });\n }, [\n basePath,\n collapsedByGroupId,\n entities,\n dashboards,\n pathname,\n permissions,\n recentItems,\n setCollapsed,\n sidebar,\n sidebarPinnedEntityIds,\n sidebarQuery,\n sidebarReorderPin,\n sidebarTogglePin,\n t,\n tApp,\n ]);\n\n const mobileSections = useMemo(() => {\n return buildSidebarSections({\n basePath,\n pathname,\n entities,\n dashboards,\n sidebar,\n permissions,\n searchQuery: sidebarQuery,\n tApp,\n t,\n pinnedEntityIds: sidebarPinnedEntityIds,\n recentItems,\n onTogglePin: sidebarTogglePin,\n onReorderPin: sidebarReorderPin,\n collapsedByGroupId,\n onGroupCollapsedChange: setCollapsed,\n sidebarCollapsed: false,\n });\n }, [\n basePath,\n collapsedByGroupId,\n entities,\n dashboards,\n pathname,\n permissions,\n recentItems,\n setCollapsed,\n sidebar,\n sidebarPinnedEntityIds,\n sidebarQuery,\n sidebarReorderPin,\n sidebarTogglePin,\n t,\n tApp,\n ]);\n\n const environment = useMemo(() => {\n const meta = import.meta as unknown as { env?: Record<string, unknown> };\n if (meta.env?.DEV === true) {\n return 'dev' as const;\n }\n return 'prod' as const;\n }, []);\n\n const handleSignOut = useCallback(() => {\n if (isSigningOut) {\n return;\n }\n\n type LogoutMutation = MutationParameters & {\n response: LogoutResponse;\n variables: LogoutVariables;\n };\n\n setIsSigningOut(true);\n\n const runSignOut = async (): Promise<void> => {\n try {\n const config = await authConfig.logout.load();\n await new Promise<void>((resolve, reject) => {\n commitMutation<LogoutMutation>(relayEnvironment, {\n mutation: config.logoutMutation,\n variables: {},\n onCompleted: () => {\n resolve();\n },\n onError: (error) => {\n reject(error);\n },\n });\n });\n localStorage.removeItem('auth_token');\n localStorage.removeItem('remember_me');\n resetRelayStore();\n routing?.history.push({ pathname: getBackofficeLoginPath(basePath) });\n } finally {\n setIsSigningOut(false);\n }\n };\n\n runSignOut().catch(() => {\n /* noop */\n });\n }, [authConfig.logout, basePath, isSigningOut, relayEnvironment, routing]);\n\n const viewer = authStatus?.me ?? null;\n const sidebarProfile = useMemo(() => {\n return mapViewerToSidebarProfileView({\n viewer,\n unknownUserLabel: t('sidebar.profile.unknownUser'),\n });\n }, [t, viewer]);\n\n const sidebarFooter = (\n <SidebarProfileMenu\n collapsed={false}\n viewer={sidebarProfile}\n labels={{\n sectionTitle: t('sidebar.profile.title'),\n menuAriaLabel: t('sidebar.profile.menuAriaLabel'),\n signOut: t('sidebar.profile.actions.signOut'),\n }}\n onSignOut={handleSignOut}\n isSigningOut={isSigningOut}\n />\n );\n\n const mobileSidebarFooter = (\n <SidebarProfileMenu\n collapsed={false}\n viewer={sidebarProfile}\n labels={{\n sectionTitle: t('sidebar.profile.title'),\n menuAriaLabel: t('sidebar.profile.menuAriaLabel'),\n signOut: t('sidebar.profile.actions.signOut'),\n }}\n onSignOut={handleSignOut}\n isSigningOut={isSigningOut}\n />\n );\n\n let contentNode: JSX.Element | null = null;\n if (topbarTarget != null) {\n contentNode = (\n <BackofficeContentBoundary>{children}</BackofficeContentBoundary>\n );\n }\n\n const sidebarSearchNode = (\n <GlobalSearchInput\n value={sidebarQuery}\n onChange={setSidebarQuery}\n placeholder={t('sidebar.search.placeholder')}\n ariaLabel={t('sidebar.search.placeholder')}\n />\n );\n\n return (\n <ToastProvider>\n <AdminShellLayout\n sidebar={{\n sections,\n header: <EnvironmentBadge environment={environment} />,\n search: sidebarSearchNode,\n footer: sidebarFooter,\n isCollapsed: isSidebarCollapsed,\n onCollapsedChange: setIsSidebarCollapsed,\n collapseToggleLabel: t('sidebar.actions.collapseSidebar'),\n expandToggleLabel: t('sidebar.actions.expandSidebar'),\n navigationAriaLabel: t('sidebar.navigationAriaLabel'),\n }}\n mobileSidebar={{\n sections: mobileSections,\n header: <EnvironmentBadge environment={environment} />,\n search: sidebarSearchNode,\n footer: mobileSidebarFooter,\n isCollapsed: false,\n hideCollapseToggle: true,\n navigationAriaLabel: t('sidebar.navigationAriaLabel'),\n }}\n topbar={{\n breadcrumb: <div ref={setTopbarTarget} />,\n }}\n contentScrollMode=\"contained\"\n >\n <BackofficePermissionsProvider permissions={permissions}>\n <BackofficeTopbarPortalContextProvider\n value={{\n target: topbarTarget,\n dashboardHref: basePath,\n dashboardLabel: t('sidebar.items.dashboard'),\n }}\n >\n {contentNode}\n </BackofficeTopbarPortalContextProvider>\n </BackofficePermissionsProvider>\n </AdminShellLayout>\n </ToastProvider>\n );\n};\n\ntype LayoutWithPermissionsProps = {\n children: ReactNode;\n permissionsQuery: GraphQLTaggedNode;\n prepared: PreloadedQuery<OperationType>;\n authStatus?: {\n isLoggedIn?: boolean | null;\n me?: BackofficeViewerIdentity | null;\n } | null;\n activeGroupId?: string | null;\n};\n\nconst LayoutWithPermissions = ({\n children,\n permissionsQuery,\n prepared,\n authStatus,\n activeGroupId,\n}: LayoutWithPermissionsProps): JSX.Element => {\n const permissions = usePreloadedQuery(permissionsQuery, prepared);\n\n return (\n <BackofficeLayoutShell\n permissions={permissions}\n authStatus={authStatus}\n activeGroupId={activeGroupId}\n >\n {children}\n </BackofficeLayoutShell>\n );\n};\n\nexport const BackofficeLayoutPage = ({\n children,\n permissionsQuery,\n prepared,\n authStatus,\n activeGroupId,\n}: BackofficeLayoutPageProps): JSX.Element => {\n if (permissionsQuery != null && prepared != null) {\n return (\n <LayoutWithPermissions\n permissionsQuery={permissionsQuery}\n prepared={prepared}\n authStatus={authStatus}\n activeGroupId={activeGroupId}\n >\n {children}\n </LayoutWithPermissions>\n );\n }\n\n return (\n <BackofficeLayoutShell\n permissions={null}\n authStatus={authStatus}\n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CAAI;GACxB;GACA,WAAW,KAAK,IAAI;EACtB;EACA,IAAgB,MAAS;GACvB,IAAM,IAAO,CACX,GACA,GAAG,EAAK,QAAQ,MACP,EAAM,OAAO,EAAK,MAAM,EAAM,SAAS,EAAK,IACpD,CACH,CAAC,CAAC,MAAM,GAAG,CAAmB;GAE9B,OADA,GAAiB,GAAuB,CAAI,GACrC;EACT,CAAC;CACH,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,IAAM,IAAiB,GAAS,aAAa,YAAY,IAEnD,EACJ,UACA,QAAQ,IACR,SAAS,OACP,GAAyB;EAC3B,SAAS;EACT,YAAY,GAAS,aAAa;EAClC;CACF,CAAC,GAEG,GACA,GACA;CACJ,AAAI,MACF,IAAyB,IACzB,IAAmB,IACnB,IAAoB;CAGtB,IAAI;CACJ,AAAI,GAAS,aAAa,cAAc,SACtC,IAA0B,GAAG,EAAQ,YAAY,WAAW;CAG9D,IAAM,EAAE,uBAAoB,oBAAiB,GAAwB;EACnE;EACA;EACA;EACA,SAAS,GAAS,aAAa,kBAAkB;EACjD,YAAY;CACd,CAAC,GAEK,KAAW,QACR,EAAqB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA,iBAAiB;EACjB;EACA,aAAa;EACb,cAAc;EACd;EACA,wBAAwB;EACxB,kBAAkB;CACpB,CAAC,GACA;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GAEK,KAAiB,QACd,EAAqB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA,iBAAiB;EACjB;EACA,aAAa;EACb,cAAc;EACd;EACA,wBAAwB;EACxB,kBAAkB;CACpB,CAAC,GACA;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GAEK,IAAc,QAEd,OADgB,KACX,KAAK,QAAQ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BAA4B;EAC3C,WAAW,EAAE,4BAA4B;CAC1C,CAAA;CAGH,OACE,kBAAC,IAAD,EAAA,UACE,kBAAC,GAAD;EACE,SAAS;GACP;GACA,QAAQ,kBAAC,GAAD,EAA+B,eAAc,CAAA;GACrD,QAAQ;GACR,QAAQ;GACR,aAAa;GACb,mBAAmB;GACnB,qBAAqB,EAAE,iCAAiC;GACxD,mBAAmB,EAAE,+BAA+B;GACpD,qBAAqB,EAAE,6BAA6B;EACtD;EACA,eAAe;GACb,UAAU;GACV,QAAQ,kBAAC,GAAD,EAA+B,eAAc,CAAA;GACrD,QAAQ;GACR,QAAQ;GACR,aAAa;GACb,oBAAoB;GACpB,qBAAqB,EAAE,6BAA6B;EACtD;EACA,QAAQ,EACN,YAAY,kBAAC,OAAD,EAAK,KAAK,GAAkB,CAAA,EAC1C;EACA,mBAAkB;YAElB,kBAAC,IAAD;GAA4C;aAC1C,kBAAC,GAAD;IACE,OAAO;KACL,QAAQ;KACR,eAAe;KACf,gBAAgB,EAAE,yBAAyB;IAC7C;cAEC;GACoC,CAAA;EACV,CAAA;CACf,CAAA,EACL,CAAA;AAEnB,GAaM,KAAyB,EAC7B,aACA,qBACA,aACA,eACA,uBAKE,kBAAC,GAAD;CACe,aAJG,EAAkB,GAAkB,CAIvC;CACD;CACG;CAEd;AACoB,CAAA,GAId,KAAwB,EACnC,aACA,qBACA,aACA,eACA,uBAEI,KAAoB,QAAQ,KAAY,OAExC,kBAAC,GAAD;CACoB;CACR;CACE;CACG;CAEd;AACoB,CAAA,IAKzB,kBAAC,GAAD;CACE,aAAa;CACD;CACG;CAEd;AACoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeLoginPage.js","names":[],"sources":["../../../src/pages/BackofficeLoginPage.tsx"],"sourcesContent":["import { useCallback, useContext, useRef, type JSX } from 'react';\nimport * as ReactRelay from 'react-relay';\nimport type { PreloadedQuery } from 'react-relay';\nimport type { OperationType } from 'relay-runtime';\nimport { useRelayEnvironment } from '../relay/useRelayEnvironment.js';\nimport RoutingContext from '@plumile/router/routing/RoutingContext.js';\n\nimport type { OidcProviderKind } from '../modules/sharedSchemaTypes.js';\nimport { LoginFlow } from '../auth/login/LoginFlow.js';\nimport { synchronizeAuthStatusQuery } from '../auth/login/synchronizeAuthStatusQuery.js';\nimport { useBackofficeAuth } from '../hooks/useBackofficeAuth.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { useBackofficeAuthLoginConfig } from '../provider/useBackofficeLazyValue.js';\nimport { getBackofficePasswordResetPath } from '../router/backofficeAuthPaths.js';\n\nconst { usePreloadedQuery } = ReactRelay;\n\nexport type BackofficeLoginPageProps = {\n prepared: { query: PreloadedQuery<OperationType> };\n};\n\nexport const BackofficeLoginPage = ({\n prepared,\n}: BackofficeLoginPageProps): JSX.Element => {\n const routerContext = useContext(RoutingContext);\n const { auth: authConfig, basePath } = useBackofficeConfig();\n const auth = useBackofficeAuthLoginConfig();\n const authState = useBackofficeAuth();\n const relayEnvironment = useRelayEnvironment();\n const isPostLoginSyncInFlightRef = useRef(false);\n\n const data = usePreloadedQuery(auth.loginQuery, prepared.query);\n const oidcProviders =\n (data as { oidcProviders?: readonly OidcProviderKind[] }).oidcProviders ??\n [];\n\n const handleLoginSuccess = useCallback((): void => {\n if (isPostLoginSyncInFlightRef.current) {\n return;\n }\n\n isPostLoginSyncInFlightRef.current = true;\n const runPostLoginSync = async (): Promise<void> => {\n try {\n const sessionAuth = await authConfig.session.load();\n if (sessionAuth.authStatusQuery == null) {\n routerContext?.history.push({\n pathname: basePath,\n });\n return;\n }\n\n await authConfig.lifecycle?.onLoginSuccess?.();\n\n const isLoggedIn = await synchronizeAuthStatusQuery<OperationType>(\n relayEnvironment,\n sessionAuth.authStatusQuery,\n );\n if (!isLoggedIn) {\n return;\n }\n routerContext?.history.push({\n pathname: basePath,\n });\n } catch {\n // Keep user on login page if post-login auth sync fails.\n } finally {\n isPostLoginSyncInFlightRef.current = false;\n }\n };\n\n runPostLoginSync().catch(() => {});\n }, [\n authConfig.lifecycle,\n authConfig.session,\n basePath,\n relayEnvironment,\n routerContext?.history,\n ]);\n\n const handleForgotPassword = useCallback(() => {\n routerContext?.history.push({\n pathname: getBackofficePasswordResetPath(basePath),\n });\n }, [basePath, routerContext?.history]);\n\n return (\n <LoginFlow\n auth={authState}\n oidcProviders={oidcProviders}\n onLoginSuccess={handleLoginSuccess}\n onForgotPassword={handleForgotPassword}\n />\n );\n};\n\nexport default BackofficeLoginPage;\n"],"mappings":";;;;;;;;;;;;AAeA,IAAM,EAAE,mBAAA,MAAsB,GAMjB,KAAuB,EAClC,kBAC2C;CAC3C,IAAM,IAAgB,EAAW,CAAc,GACzC,EAAE,MAAM,GAAY,gBAAa,EAAoB,GACrD,IAAO,EAA6B,GACpC,IAAY,EAAkB,GAC9B,IAAmB,EAAoB,GACvC,IAA6B,EAAO,EAAK;CAyD/C,OACE,kBAAC,GAAD;EACE,MAAM;EACS,eA1DN,EAAkB,EAAK,YAAY,EAAS,KAEtD,
|
|
1
|
+
{"version":3,"file":"BackofficeLoginPage.js","names":[],"sources":["../../../src/pages/BackofficeLoginPage.tsx"],"sourcesContent":["import { useCallback, useContext, useRef, type JSX } from 'react';\nimport * as ReactRelay from 'react-relay';\nimport type { PreloadedQuery } from 'react-relay';\nimport type { OperationType } from 'relay-runtime';\nimport { useRelayEnvironment } from '../relay/useRelayEnvironment.js';\nimport RoutingContext from '@plumile/router/routing/RoutingContext.js';\n\nimport type { OidcProviderKind } from '../modules/sharedSchemaTypes.js';\nimport { LoginFlow } from '../auth/login/LoginFlow.js';\nimport { synchronizeAuthStatusQuery } from '../auth/login/synchronizeAuthStatusQuery.js';\nimport { useBackofficeAuth } from '../hooks/useBackofficeAuth.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { useBackofficeAuthLoginConfig } from '../provider/useBackofficeLazyValue.js';\nimport { getBackofficePasswordResetPath } from '../router/backofficeAuthPaths.js';\n\nconst { usePreloadedQuery } = ReactRelay;\n\nexport type BackofficeLoginPageProps = {\n prepared: { query: PreloadedQuery<OperationType> };\n};\n\nexport const BackofficeLoginPage = ({\n prepared,\n}: BackofficeLoginPageProps): JSX.Element => {\n const routerContext = useContext(RoutingContext);\n const { auth: authConfig, basePath } = useBackofficeConfig();\n const auth = useBackofficeAuthLoginConfig();\n const authState = useBackofficeAuth();\n const relayEnvironment = useRelayEnvironment();\n const isPostLoginSyncInFlightRef = useRef(false);\n\n const data = usePreloadedQuery(auth.loginQuery, prepared.query);\n const oidcProviders =\n (data as { oidcProviders?: readonly OidcProviderKind[] }).oidcProviders ??\n [];\n\n const handleLoginSuccess = useCallback((): void => {\n if (isPostLoginSyncInFlightRef.current) {\n return;\n }\n\n isPostLoginSyncInFlightRef.current = true;\n const runPostLoginSync = async (): Promise<void> => {\n try {\n const sessionAuth = await authConfig.session.load();\n if (sessionAuth.authStatusQuery == null) {\n routerContext?.history.push({\n pathname: basePath,\n });\n return;\n }\n\n await authConfig.lifecycle?.onLoginSuccess?.();\n\n const isLoggedIn = await synchronizeAuthStatusQuery<OperationType>(\n relayEnvironment,\n sessionAuth.authStatusQuery,\n );\n if (!isLoggedIn) {\n return;\n }\n routerContext?.history.push({\n pathname: basePath,\n });\n } catch {\n // Keep user on login page if post-login auth sync fails.\n } finally {\n isPostLoginSyncInFlightRef.current = false;\n }\n };\n\n runPostLoginSync().catch(() => {});\n }, [\n authConfig.lifecycle,\n authConfig.session,\n basePath,\n relayEnvironment,\n routerContext?.history,\n ]);\n\n const handleForgotPassword = useCallback(() => {\n routerContext?.history.push({\n pathname: getBackofficePasswordResetPath(basePath),\n });\n }, [basePath, routerContext?.history]);\n\n return (\n <LoginFlow\n auth={authState}\n oidcProviders={oidcProviders}\n onLoginSuccess={handleLoginSuccess}\n onForgotPassword={handleForgotPassword}\n />\n );\n};\n\nexport default BackofficeLoginPage;\n"],"mappings":";;;;;;;;;;;;AAeA,IAAM,EAAE,mBAAA,MAAsB,GAMjB,KAAuB,EAClC,kBAC2C;CAC3C,IAAM,IAAgB,EAAW,CAAc,GACzC,EAAE,MAAM,GAAY,gBAAa,EAAoB,GACrD,IAAO,EAA6B,GACpC,IAAY,EAAkB,GAC9B,IAAmB,EAAoB,GACvC,IAA6B,EAAO,EAAK;CAyD/C,OACE,kBAAC,GAAD;EACE,MAAM;EACS,eA1DN,EAAkB,EAAK,YAAY,EAAS,KAEtD,CAAA,CAAyD,iBAC1D,CAAC;EAwDC,gBAtDuB,QAAwB;GAC7C,EAA2B,YAI/B,EAA2B,UAAU,KA8BrC,YA7BoD;IAClD,IAAI;KACF,IAAM,IAAc,MAAM,EAAW,QAAQ,KAAK;KAClD,IAAI,EAAY,mBAAmB,MAAM;MACvC,GAAe,QAAQ,KAAK,EAC1B,UAAU,EACZ,CAAC;MACD;KACF;KAQA,IANA,MAAM,EAAW,WAAW,iBAAiB,GAMzC,CAAC,MAJoB,EACvB,GACA,EAAY,eACd,GAEE;KAEF,GAAe,QAAQ,KAAK,EAC1B,UAAU,EACZ,CAAC;IACH,QAAQ,CAER,UAAU;KACR,EAA2B,UAAU;IACvC;GACF,EAEA,CAAiB,CAAC,CAAC,YAAY,CAAC,CAAC;EACnC,GAAG;GACD,EAAW;GACX,EAAW;GACX;GACA;GACA,GAAe;EACjB,CAYoB;EAChB,kBAXyB,QAAkB;GAC7C,GAAe,QAAQ,KAAK,EAC1B,UAAU,EAA+B,CAAQ,EACnD,CAAC;EACH,GAAG,CAAC,GAAU,GAAe,OAAO,CAOd;CACnB,CAAA;AAEL"}
|