@alepha/ui 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AccountConnections.js +1 -1
- package/dist/account/AccountConnectionsView.js +4 -4
- package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
- package/dist/account/AccountDeleteDialog.js +5 -4
- package/dist/account/AccountDeleteDialog.js.map +1 -1
- package/dist/account/AccountDialog.js +4 -4
- package/dist/account/AccountDisplay.js +4 -4
- package/dist/account/AccountKeys.js +1 -1
- package/dist/account/AccountKeysView.js +5 -5
- package/dist/account/AccountMfaDialog.js +4 -4
- package/dist/account/AccountPasskeyProofDialog.js +2 -2
- package/dist/account/AccountPasskeyRow.js +3 -3
- package/dist/account/AccountPasskeys.js +4 -4
- package/dist/account/AccountPasswordDialog.js +4 -4
- package/dist/account/AccountPasswordDialog.js.map +1 -1
- package/dist/account/AccountPasswordGuard.js +2 -2
- package/dist/account/AccountProfile.js +1 -1
- package/dist/account/AccountProfileView.d.ts.map +1 -1
- package/dist/account/AccountProfileView.js +8 -7
- package/dist/account/AccountProfileView.js.map +1 -1
- package/dist/account/AccountRecoveryCodes.js +2 -2
- package/dist/account/AccountRecoveryCodesDialog.js +1 -1
- package/dist/account/AccountSecurity.js +1 -1
- package/dist/account/AccountSecurityView.js +5 -5
- package/dist/account/AccountSessions.js +1 -1
- package/dist/account/AccountSessionsView.js +4 -4
- package/dist/account/ApiKeyCreateDialog.js +7 -6
- package/dist/account/ApiKeyCreateDialog.js.map +1 -1
- package/dist/account/ApiKeyScopeMatrix.js +2 -2
- package/dist/account/ApiKeyStatusBadge.js +1 -1
- package/dist/admin/$pageAdmin.js +1 -1
- package/dist/admin/AdminAi.d.ts +12 -0
- package/dist/admin/AdminAi.d.ts.map +1 -0
- package/dist/admin/AdminAi.js +173 -0
- package/dist/admin/AdminAi.js.map +1 -0
- package/dist/admin/AdminAiDailyChart.d.ts +16 -0
- package/dist/admin/AdminAiDailyChart.d.ts.map +1 -0
- package/dist/admin/AdminAiDailyChart.js +87 -0
- package/dist/admin/AdminAiDailyChart.js.map +1 -0
- package/dist/admin/AdminAiUsageTable.d.ts +33 -0
- package/dist/admin/AdminAiUsageTable.d.ts.map +1 -0
- package/dist/admin/AdminAiUsageTable.js +77 -0
- package/dist/admin/AdminAiUsageTable.js.map +1 -0
- package/dist/admin/AdminAnalytics.js +3 -3
- package/dist/admin/AdminAudits.js +7 -7
- package/dist/admin/AdminBrand.js +2 -2
- package/dist/admin/AdminConnectedTile.js +1 -1
- package/dist/admin/AdminDashboard.js +3 -3
- package/dist/admin/AdminFailedAuditsTile.js +3 -3
- package/dist/admin/AdminFiles.d.ts.map +1 -1
- package/dist/admin/AdminFiles.js +8 -8
- package/dist/admin/AdminFiles.js.map +1 -1
- package/dist/admin/AdminFilesUsage.js +2 -2
- package/dist/admin/AdminFilesUsageCard.js +2 -2
- package/dist/admin/AdminJobDetail.js +7 -7
- package/dist/admin/AdminJobDetailAside.js +3 -3
- package/dist/admin/AdminJobDetailExecutions.js +6 -6
- package/dist/admin/AdminJobExecutionLogs.js +1 -1
- package/dist/admin/AdminJobExecutionSheet.js +5 -5
- package/dist/admin/AdminJobExecutionSteps.js +1 -1
- package/dist/admin/AdminJobs.js +7 -7
- package/dist/admin/AdminJobsTypeIcon.js +1 -1
- package/dist/admin/AdminKeys.js +6 -6
- package/dist/admin/AdminKeysTokenDialog.js +4 -4
- package/dist/admin/AdminLayout.js +5 -5
- package/dist/admin/AdminNotifications.js +6 -6
- package/dist/admin/AdminNotificationsDetail.js +2 -2
- package/dist/admin/AdminNotificationsDetailTabs.js +3 -3
- package/dist/admin/AdminNotificationsPreviewBody.js +1 -1
- package/dist/admin/AdminNotificationsPreviewTab.js +1 -1
- package/dist/admin/AdminParameters.d.ts.map +1 -1
- package/dist/admin/AdminParameters.js +10 -8
- package/dist/admin/AdminParameters.js.map +1 -1
- package/dist/admin/AdminParametersEditorForm.d.ts +5 -0
- package/dist/admin/AdminParametersEditorForm.d.ts.map +1 -1
- package/dist/admin/AdminParametersEditorForm.js +8 -6
- package/dist/admin/AdminParametersEditorForm.js.map +1 -1
- package/dist/admin/AdminParametersEditorPane.d.ts +5 -0
- package/dist/admin/AdminParametersEditorPane.d.ts.map +1 -1
- package/dist/admin/AdminParametersEditorPane.js +7 -6
- package/dist/admin/AdminParametersEditorPane.js.map +1 -1
- package/dist/admin/AdminParametersHistoryPane.js +5 -5
- package/dist/admin/AdminParametersTreeFooterActions.js +3 -3
- package/dist/admin/AdminParametersTreeNodeView.js +5 -5
- package/dist/admin/AdminParametersTreeNodeView.js.map +1 -1
- package/dist/admin/AdminParametersTreePane.js +4 -4
- package/dist/admin/AdminPayments.js +4 -4
- package/dist/admin/AdminRouter.d.ts +12 -5
- package/dist/admin/AdminRouter.d.ts.map +1 -1
- package/dist/admin/AdminRouter.js +39 -10
- package/dist/admin/AdminRouter.js.map +1 -1
- package/dist/admin/AdminRouterOptions.js +1 -1
- package/dist/admin/AdminSessions.js +6 -6
- package/dist/admin/AdminStatTile.js +6 -6
- package/dist/admin/AdminStatTile.js.map +1 -1
- package/dist/admin/AdminStatTileDeltaChip.js +1 -1
- package/dist/admin/AdminUserAvatarControl.js +5 -5
- package/dist/admin/AdminUserCell.js +3 -3
- package/dist/admin/AdminUserDetail.js +10 -10
- package/dist/admin/AdminUserDetailAuditsTab.js +3 -3
- package/dist/admin/AdminUserDetailIdentityAside.js +4 -4
- package/dist/admin/AdminUserDetailOverviewTab.js +3 -3
- package/dist/admin/AdminUserDetailPasskeys.js +3 -3
- package/dist/admin/AdminUserDetailPasswordDialog.js +4 -4
- package/dist/admin/AdminUserDetailSecurityTab.js +4 -4
- package/dist/admin/AdminUserDetailSessionsTab.js +3 -3
- package/dist/admin/AdminUsers.js +10 -10
- package/dist/admin/AdminUsers.js.map +1 -1
- package/dist/admin/AdminUsersCreateDialog.js +5 -5
- package/dist/admin/AdminUsersRolesPicker.js +2 -2
- package/dist/admin/AdminUsersStatusBadge.js +1 -1
- package/dist/admin/AdminUsersTile.js +2 -2
- package/dist/admin/AdminWebhookDeliveries.js +6 -6
- package/dist/admin/AdminWebhookDeliveryDialog.js +5 -5
- package/dist/admin/AdminWebhookDetail.js +6 -6
- package/dist/admin/AdminWebhookDetailAside.js +3 -3
- package/dist/admin/AdminWebhookDetailOverview.js +6 -6
- package/dist/admin/AdminWebhooks.js +7 -7
- package/dist/admin/AdminWebhooksCreateDialog.js +6 -6
- package/dist/admin/AdminWebhooksSecretDialog.js +4 -4
- package/dist/admin/AdminWebhooksStatusBadge.js +3 -3
- package/dist/admin/ParameterDiffDialog.js +3 -3
- package/dist/admin/ParameterHistoryItem.js +5 -5
- package/dist/admin/ParameterJsonDialog.js +4 -4
- package/dist/admin/ParameterSaveDialog.js +5 -5
- package/dist/admin/adminAiMoney.d.ts +10 -0
- package/dist/admin/adminAiMoney.d.ts.map +1 -0
- package/dist/admin/adminAiMoney.js +21 -0
- package/dist/admin/adminAiMoney.js.map +1 -0
- package/dist/admin/adminParametersTree.d.ts +23 -2
- package/dist/admin/adminParametersTree.d.ts.map +1 -1
- package/dist/admin/adminParametersTree.js +36 -3
- package/dist/admin/adminParametersTree.js.map +1 -1
- package/dist/admin/analytics/AdvancedSection.js +3 -3
- package/dist/admin/analytics/AnalyticsChartBars.js +1 -1
- package/dist/admin/analytics/AnalyticsChartDonut.js +1 -1
- package/dist/admin/analytics/AnalyticsChartHeader.js +1 -1
- package/dist/admin/analytics/CoarsenedBadge.js +1 -1
- package/dist/admin/analytics/CompareNote.js +1 -1
- package/dist/admin/analytics/DatasetSelect.js +4 -4
- package/dist/admin/analytics/FilterEditor.js +3 -3
- package/dist/admin/analytics/FilterValuePicker.js +3 -3
- package/dist/admin/analytics/GroupByChips.js +1 -1
- package/dist/admin/analytics/MeasureChips.js +1 -1
- package/dist/admin/analytics/QueryPanel.js +1 -1
- package/dist/admin/analytics/RangeControl.js +3 -3
- package/dist/admin/analytics/RequestDialog.js +2 -2
- package/dist/admin/analytics/ResultsPane.js +3 -3
- package/dist/admin/analytics/ResultsTable.d.ts.map +1 -1
- package/dist/admin/analytics/ResultsTable.js +3 -3
- package/dist/admin/analytics/ResultsTable.js.map +1 -1
- package/dist/admin/analytics/RunFooter.js +2 -2
- package/dist/admin/analytics/SamplingBadge.js +1 -1
- package/dist/admin/analytics/ToggleChip.js +1 -1
- package/dist/admin/analytics/TotalsCards.js +1 -1
- package/dist/admin/analytics/TruncationBanner.js +2 -2
- package/dist/admin/analytics/analyticsModel.d.ts +3 -1
- package/dist/admin/analytics/analyticsModel.d.ts.map +1 -1
- package/dist/admin/analytics/analyticsModel.js +13 -5
- package/dist/admin/analytics/analyticsModel.js.map +1 -1
- package/dist/admin/analytics/analyticsTypes.d.ts +1 -1
- package/dist/admin/analytics/analyticsTypes.d.ts.map +1 -1
- package/dist/admin/analytics/chartModel.d.ts.map +1 -1
- package/dist/admin/analytics/chartModel.js +2 -2
- package/dist/admin/analytics/chartModel.js.map +1 -1
- package/dist/admin/analytics/useAnalyticsQuery.js +2 -2
- package/dist/admin/analytics/useFilterValues.js +1 -1
- package/dist/admin/useAdminDetailTrail.js +2 -2
- package/dist/admin/useConfirmedAction.js +2 -2
- package/dist/ai/AiChat.d.ts +31 -2
- package/dist/ai/AiChat.d.ts.map +1 -1
- package/dist/ai/AiChat.js +82 -22
- package/dist/ai/AiChat.js.map +1 -1
- package/dist/ai/AiChatComposer.d.ts +9 -0
- package/dist/ai/AiChatComposer.d.ts.map +1 -1
- package/dist/ai/AiChatComposer.js +9 -4
- package/dist/ai/AiChatComposer.js.map +1 -1
- package/dist/ai/AiChatConfirmCard.d.ts +2 -2
- package/dist/ai/AiChatConfirmCard.d.ts.map +1 -1
- package/dist/ai/AiChatConfirmCard.js +15 -5
- package/dist/ai/AiChatConfirmCard.js.map +1 -1
- package/dist/ai/AiChatDock.js +3 -3
- package/dist/ai/AiChatEmpty.d.ts +5 -0
- package/dist/ai/AiChatEmpty.d.ts.map +1 -1
- package/dist/ai/AiChatEmpty.js +26 -30
- package/dist/ai/AiChatEmpty.js.map +1 -1
- package/dist/ai/AiChatFloat.d.ts +31 -2
- package/dist/ai/AiChatFloat.d.ts.map +1 -1
- package/dist/ai/AiChatFloat.js +42 -6
- package/dist/ai/AiChatFloat.js.map +1 -1
- package/dist/ai/AiChatHeaderButton.d.ts +14 -0
- package/dist/ai/AiChatHeaderButton.d.ts.map +1 -0
- package/dist/ai/AiChatHeaderButton.js +21 -0
- package/dist/ai/AiChatHeaderButton.js.map +1 -0
- package/dist/ai/AiChatHistory.d.ts.map +1 -1
- package/dist/ai/AiChatHistory.js +8 -6
- package/dist/ai/AiChatHistory.js.map +1 -1
- package/dist/ai/AiChatLauncher.d.ts +5 -0
- package/dist/ai/AiChatLauncher.d.ts.map +1 -1
- package/dist/ai/AiChatLauncher.js +3 -3
- package/dist/ai/AiChatLauncher.js.map +1 -1
- package/dist/ai/AiChatMessage.d.ts +6 -0
- package/dist/ai/AiChatMessage.d.ts.map +1 -1
- package/dist/ai/AiChatMessage.js +4 -4
- package/dist/ai/AiChatMessage.js.map +1 -1
- package/dist/ai/AiChatPanel.d.ts +46 -5
- package/dist/ai/AiChatPanel.d.ts.map +1 -1
- package/dist/ai/AiChatPanel.js +30 -30
- package/dist/ai/AiChatPanel.js.map +1 -1
- package/dist/ai/AiChatToolTrace.d.ts +13 -0
- package/dist/ai/AiChatToolTrace.d.ts.map +1 -1
- package/dist/ai/AiChatToolTrace.js +75 -48
- package/dist/ai/AiChatToolTrace.js.map +1 -1
- package/dist/ai/aiChatMotion.d.ts +24 -0
- package/dist/ai/aiChatMotion.d.ts.map +1 -0
- package/dist/ai/aiChatMotion.js +67 -0
- package/dist/ai/aiChatMotion.js.map +1 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +3 -1
- package/dist/ai/useAiChat.d.ts +11 -0
- package/dist/ai/useAiChat.d.ts.map +1 -1
- package/dist/ai/useAiChat.js +6 -4
- package/dist/ai/useAiChat.js.map +1 -1
- package/dist/ai/useAiChatFloatDrag.d.ts +23 -0
- package/dist/ai/useAiChatFloatDrag.d.ts.map +1 -0
- package/dist/ai/useAiChatFloatDrag.js +87 -0
- package/dist/ai/useAiChatFloatDrag.js.map +1 -0
- package/dist/ai/useAiContext.js +2 -2
- package/dist/auth/AuthLogin.d.ts.map +1 -1
- package/dist/auth/AuthLogin.js +18 -10
- package/dist/auth/AuthLogin.js.map +1 -1
- package/dist/auth/AuthLoginSlots.d.ts +53 -0
- package/dist/auth/AuthLoginSlots.d.ts.map +1 -0
- package/dist/auth/AuthLoginSlots.js +39 -0
- package/dist/auth/AuthLoginSlots.js.map +1 -0
- package/dist/auth/AuthMfaStep.js +7 -7
- package/dist/auth/AuthPasskeyAutofill.js +1 -1
- package/dist/auth/AuthRegister.js +9 -9
- package/dist/auth/AuthRegisterFormPhase.js +4 -4
- package/dist/auth/AuthRegisterPasswordRules.js +2 -2
- package/dist/auth/AuthResetPassword.js +10 -10
- package/dist/auth/AuthRouter.js +2 -2
- package/dist/auth/AuthVerifyEmail.js +2 -2
- package/dist/auth/AuthVerifyEmailStateful.js +3 -3
- package/dist/auth/AuthVerifyEmailView.js +4 -4
- package/dist/auth/TurnstileWidget.js +1 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -1
- package/dist/auth/usePasskey.js +1 -1
- package/dist/calendar/Calendar.js +4 -4
- package/dist/chart/Chart.js +2 -2
- package/dist/command/Command.js +4 -4
- package/dist/core/Alert.js +2 -2
- package/dist/core/AlertDialog.js +2 -2
- package/dist/core/Avatar.js +2 -2
- package/dist/core/Badge.js +2 -2
- package/dist/core/BrandIcon.js +1 -1
- package/dist/core/Breadcrumb.js +3 -3
- package/dist/core/Button.js +6 -6
- package/dist/core/Button.js.map +1 -1
- package/dist/core/ButtonGroup.js +2 -2
- package/dist/core/Card.js +1 -1
- package/dist/core/Checkbox.js +2 -2
- package/dist/core/Collapsible.js +2 -2
- package/dist/core/Combobox.d.ts.map +1 -1
- package/dist/core/Combobox.js +4 -4
- package/dist/core/Combobox.js.map +1 -1
- package/dist/core/ContextMenu.js +2 -2
- package/dist/core/Dialog.d.ts.map +1 -1
- package/dist/core/Dialog.js +4 -4
- package/dist/core/Dialog.js.map +1 -1
- package/dist/core/DirectionProvider.js +1 -1
- package/dist/core/Drawer.js +3 -3
- package/dist/core/DropdownMenu.js +2 -2
- package/dist/core/Empty.js +1 -1
- package/dist/core/HoverCard.js +1 -1
- package/dist/core/Input.js +2 -2
- package/dist/core/InputGroup.js +2 -2
- package/dist/core/Label.js +1 -1
- package/dist/core/Menubar.js +4 -4
- package/dist/core/PageOutline.d.ts +9 -1
- package/dist/core/PageOutline.d.ts.map +1 -1
- package/dist/core/PageOutline.js +25 -6
- package/dist/core/PageOutline.js.map +1 -1
- package/dist/core/Pagination.js +2 -2
- package/dist/core/PaneRail.js +1 -1
- package/dist/core/Popover.js +2 -2
- package/dist/core/Progress.js +1 -1
- package/dist/core/Segmented.d.ts +11 -1
- package/dist/core/Segmented.d.ts.map +1 -1
- package/dist/core/Segmented.js +8 -5
- package/dist/core/Segmented.js.map +1 -1
- package/dist/core/Separator.js +1 -1
- package/dist/core/Sheet.js +3 -3
- package/dist/core/Sidebar.js +7 -7
- package/dist/core/Slider.js +3 -3
- package/dist/core/Spinner.js +1 -1
- package/dist/core/Stepper.js +1 -1
- package/dist/core/Switch.js +1 -1
- package/dist/core/Table.js +1 -1
- package/dist/core/Textarea.js +1 -1
- package/dist/core/TimeAgo.d.ts +9 -1
- package/dist/core/TimeAgo.d.ts.map +1 -1
- package/dist/core/TimeAgo.js +15 -3
- package/dist/core/TimeAgo.js.map +1 -1
- package/dist/core/Toaster.js +2 -2
- package/dist/core/Tooltip.js +1 -1
- package/dist/core/UserAvatar.js +3 -3
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -2
- package/dist/core/useDialog.js +5 -5
- package/dist/core/useUndoable.js +1 -1
- package/dist/form/AutoForm.js +6 -6
- package/dist/form/AutoFormBottomBar.js +4 -4
- package/dist/form/AutoFormErrorPopover.js +4 -4
- package/dist/form/AutoFormGroupBlock.js +3 -3
- package/dist/form/AutoFormGroupGridField.js +2 -2
- package/dist/form/Control.d.ts +4 -0
- package/dist/form/Control.d.ts.map +1 -1
- package/dist/form/Control.js +9 -8
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlArray.js +7 -7
- package/dist/form/ControlDate.js +6 -6
- package/dist/form/ControlDatePopover.js +4 -4
- package/dist/form/ControlDateRange.js +5 -5
- package/dist/form/ControlMonthPopover.js +4 -4
- package/dist/form/ControlNumber.js +3 -3
- package/dist/form/ControlObject.js +7 -7
- package/dist/form/ControlPassword.js +3 -3
- package/dist/form/ControlSelect.d.ts +12 -0
- package/dist/form/ControlSelect.d.ts.map +1 -1
- package/dist/form/ControlSelect.js +13 -7
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/form/ControlSelectCombobox.js +4 -4
- package/dist/form/ControlUpload.d.ts.map +1 -1
- package/dist/form/ControlUpload.js +11 -10
- package/dist/form/ControlUpload.js.map +1 -1
- package/dist/form/ControlUploadItemThumb.js +1 -1
- package/dist/form/FormField.js +2 -2
- package/dist/form/FormFieldDescriptionTip.js +1 -1
- package/dist/form/fieldTrigger.js +3 -3
- package/dist/form/iconHint.js +1 -1
- package/dist/form/useFieldErrorText.js +1 -1
- package/dist/i18n/en/uiEn.d.ts.map +1 -1
- package/dist/i18n/en/uiEn.js +31 -2
- package/dist/i18n/en/uiEn.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +31 -2
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/markdown/MarkdownView.d.ts +9 -0
- package/dist/markdown/MarkdownView.d.ts.map +1 -1
- package/dist/markdown/MarkdownView.js +13 -7
- package/dist/markdown/MarkdownView.js.map +1 -1
- package/dist/markdown/diagram/DiagramLabel.js +1 -1
- package/dist/markdown/diagram/FlowchartDiagram.js +2 -2
- package/dist/markdown/diagram/FlowchartDiagramCluster.js +2 -2
- package/dist/markdown/diagram/FlowchartDiagramEdge.js +1 -1
- package/dist/markdown/diagram/FlowchartDiagramNode.js +1 -1
- package/dist/markdown/diagram/MermaidFence.js +2 -2
- package/dist/markdown/diagram/SequenceDiagram.js +2 -2
- package/dist/markdown/diagram/SequenceDiagramFragment.js +2 -2
- package/dist/markdown/diagram/SequenceDiagramMessage.js +1 -1
- package/dist/markdown/diagram/SequenceDiagramNote.js +1 -1
- package/dist/markdown/diagram/SequenceDiagramParticipant.js +2 -2
- package/dist/markdown/diagram/SequenceDiagramParticipantActor.js +2 -2
- package/dist/markdown/diagram/layoutFlowchart.js +1 -1
- package/dist/markdown/highlightLines.js +1 -1
- package/dist/organizations/MyOrganizationInvitations.d.ts.map +1 -1
- package/dist/organizations/MyOrganizationInvitations.js +13 -5
- package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
- package/dist/organizations/MyOrganizations.d.ts.map +1 -1
- package/dist/organizations/MyOrganizations.js +15 -5
- package/dist/organizations/MyOrganizations.js.map +1 -1
- package/dist/organizations/OrganizationInviteDialog.js +6 -6
- package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
- package/dist/organizations/OrganizationMemberRankPicker.js +5 -5
- package/dist/organizations/OrganizationMembers.d.ts.map +1 -1
- package/dist/organizations/OrganizationMembers.js +12 -6
- package/dist/organizations/OrganizationMembers.js.map +1 -1
- package/dist/organizations/OrganizationPendingInvitations.d.ts.map +1 -1
- package/dist/organizations/OrganizationPendingInvitations.js +9 -4
- package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
- package/dist/organizations/OrganizationRankColumnHeader.js +2 -2
- package/dist/organizations/OrganizationRanks.d.ts.map +1 -1
- package/dist/organizations/OrganizationRanks.js +7 -5
- package/dist/organizations/OrganizationRanks.js.map +1 -1
- package/dist/organizations/OrganizationTransferOwnershipDialog.js +5 -5
- package/dist/organizations/OrganizationTransferOwnershipDialog.js.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.js +1 -1
- package/dist/organizations/useRevokeOrganizationInvitation.js +2 -2
- package/dist/otp/InputOTP.js +2 -2
- package/dist/resizable/Resizable.js +1 -1
- package/dist/settings/$settingsDialog.js +1 -1
- package/dist/settings/$settingsSection.js +1 -1
- package/dist/settings/SettingsDangerSection.js +1 -1
- package/dist/settings/SettingsDialog.js +6 -6
- package/dist/settings/SettingsDialogHost.js +3 -3
- package/dist/settings/SettingsDialogs.js +2 -2
- package/dist/settings/useSettingsDialog.js +2 -2
- package/dist/shell/ActionErrorToaster.js +2 -2
- package/dist/shell/AppActions.js +1 -1
- package/dist/shell/AppShell.js +4 -4
- package/dist/shell/AppShellNavCollapse.js +1 -1
- package/dist/shell/AppShellNavDropdownItems.js +5 -5
- package/dist/shell/AppShellNavDropdownItems.js.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.js +7 -7
- package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
- package/dist/shell/AppShellStatefulSidebarTrigger.js +4 -4
- package/dist/shell/ButtonDark.js +3 -3
- package/dist/shell/ButtonInbox.js +5 -5
- package/dist/shell/ButtonLanguage.js +4 -4
- package/dist/shell/ButtonSettings.js +5 -5
- package/dist/shell/ButtonSettingsColorModeMenu.js +2 -2
- package/dist/shell/ButtonSettingsLanguageMenu.js +3 -3
- package/dist/shell/ButtonSettingsThemeMenu.js +4 -4
- package/dist/shell/ButtonSettingsVisionMenuItem.js +2 -2
- package/dist/shell/ButtonTheme.js +5 -5
- package/dist/shell/ButtonUser.js +1 -1
- package/dist/shell/ButtonUserAccountMenuItem.js +3 -3
- package/dist/shell/ButtonUserAdminMenuItem.js +4 -4
- package/dist/shell/ButtonUserAdminMenuItem.js.map +1 -1
- package/dist/shell/ButtonUserContent.js +5 -5
- package/dist/shell/ButtonUserDefaultMenu.js +2 -2
- package/dist/shell/ButtonUserLogoutMenuItem.js +2 -2
- package/dist/shell/ButtonVision.js +3 -3
- package/dist/shell/DetailAside.js +4 -4
- package/dist/shell/DetailLayout.d.ts +3 -1
- package/dist/shell/DetailLayout.d.ts.map +1 -1
- package/dist/shell/DetailLayout.js +29 -17
- package/dist/shell/DetailLayout.js.map +1 -1
- package/dist/shell/DetailLayoutTabMenu.d.ts +19 -0
- package/dist/shell/DetailLayoutTabMenu.d.ts.map +1 -0
- package/dist/shell/DetailLayoutTabMenu.js +65 -0
- package/dist/shell/DetailLayoutTabMenu.js.map +1 -0
- package/dist/shell/NavShell.js +2 -2
- package/dist/shell/PlateFolderTabs.js +1 -1
- package/dist/shell/PlateTabBar.js +1 -1
- package/dist/shell/SidebarBackHeader.js +3 -3
- package/dist/shell/SidebarBackHeader.js.map +1 -1
- package/dist/shell/SidebarNavAutoClose.js +1 -1
- package/dist/shell/Spotlight.js +3 -3
- package/dist/shell/useDetailTab.js +1 -1
- package/dist/shell/useNavBreadcrumbs.js +3 -3
- package/dist/shell/useNavCrumbs.js +1 -1
- package/dist/shell/useNavEntries.js +3 -3
- package/dist/shell/useNavTree.js +1 -1
- package/dist/sortable/index.js +1 -1
- package/dist/sortable/useSortableList.js +1 -1
- package/dist/styles.css +43 -0
- package/dist/swagger/SwaggerAccessBadge.js +1 -1
- package/dist/swagger/SwaggerAlephaMeta.js +1 -1
- package/dist/swagger/SwaggerCredentials.js +3 -3
- package/dist/swagger/SwaggerExplorer.js +5 -5
- package/dist/swagger/SwaggerNav.js +2 -2
- package/dist/swagger/SwaggerOperationView.js +2 -2
- package/dist/swagger/SwaggerResponseView.js +2 -2
- package/dist/swagger/SwaggerResponses.js +1 -1
- package/dist/swagger/SwaggerSchemaView.js +1 -1
- package/dist/swagger/SwaggerTryIt.js +2 -2
- package/dist/swagger/SwaggerTryItForm.js +3 -3
- package/dist/swagger/useSwaggerAccess.js +2 -2
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +44 -9
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableBody.d.ts +10 -0
- package/dist/table/DataTableBody.d.ts.map +1 -1
- package/dist/table/DataTableBody.js +32 -10
- package/dist/table/DataTableBody.js.map +1 -1
- package/dist/table/DataTableBulkBar.d.ts.map +1 -1
- package/dist/table/DataTableBulkBar.js +5 -4
- package/dist/table/DataTableBulkBar.js.map +1 -1
- package/dist/table/DataTableBulkMenu.js +2 -2
- package/dist/table/DataTableColumnPicker.js +3 -3
- package/dist/table/DataTableCompactPager.js +2 -2
- package/dist/table/DataTableFilterAdd.js +2 -2
- package/dist/table/DataTableFilterBar.js +2 -2
- package/dist/table/DataTableFilterControl.js +2 -2
- package/dist/table/DataTableFilterDialog.js +3 -3
- package/dist/table/DataTableFilterMenu.js +2 -2
- package/dist/table/DataTableFooter.d.ts +5 -1
- package/dist/table/DataTableFooter.d.ts.map +1 -1
- package/dist/table/DataTableFooter.js +27 -23
- package/dist/table/DataTableFooter.js.map +1 -1
- package/dist/table/DataTableGroupRow.js +1 -1
- package/dist/table/DataTableHeaderFilter.js +3 -3
- package/dist/table/DataTableHeaderPopup.js +3 -3
- package/dist/table/DataTableHeaderPopupChevron.js +1 -1
- package/dist/table/DataTableHeaderPopupFilter.js +1 -1
- package/dist/table/DataTableHeaderPopupList.js +1 -1
- package/dist/table/DataTableHeaderPopupRange.js +3 -3
- package/dist/table/DataTableHeaderRow.js +3 -3
- package/dist/table/DataTableHelpButton.js +2 -2
- package/dist/table/DataTableKeyHints.d.ts +11 -0
- package/dist/table/DataTableKeyHints.d.ts.map +1 -0
- package/dist/table/DataTableKeyHints.js +23 -0
- package/dist/table/DataTableKeyHints.js.map +1 -0
- package/dist/table/DataTablePresetRail.js +4 -4
- package/dist/table/DataTableRowActionPrimary.d.ts +20 -0
- package/dist/table/DataTableRowActionPrimary.d.ts.map +1 -0
- package/dist/table/DataTableRowActionPrimary.js +42 -0
- package/dist/table/DataTableRowActionPrimary.js.map +1 -0
- package/dist/table/DataTableRowActionsInline.d.ts +3 -2
- package/dist/table/DataTableRowActionsInline.d.ts.map +1 -1
- package/dist/table/DataTableRowActionsInline.js +33 -22
- package/dist/table/DataTableRowActionsInline.js.map +1 -1
- package/dist/table/DataTableRowActionsMenu.js +2 -2
- package/dist/table/DataTableSortMenuButton.d.ts +15 -0
- package/dist/table/DataTableSortMenuButton.d.ts.map +1 -0
- package/dist/table/DataTableSortMenuButton.js +62 -0
- package/dist/table/DataTableSortMenuButton.js.map +1 -0
- package/dist/table/DataTableSummaryPanel.js +2 -2
- package/dist/table/DataTableToolbar.d.ts +4 -0
- package/dist/table/DataTableToolbar.d.ts.map +1 -1
- package/dist/table/DataTableToolbar.js +8 -2
- package/dist/table/DataTableToolbar.js.map +1 -1
- package/dist/table/PermissionMatrixGroupRows.js +1 -1
- package/dist/table/dataTableBaseProps.d.ts +77 -1
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/dist/table/dataTableFilterFields.js +1 -1
- package/dist/table/dataTablePriority.d.ts +16 -0
- package/dist/table/dataTablePriority.d.ts.map +1 -0
- package/dist/table/dataTablePriority.js +31 -0
- package/dist/table/dataTablePriority.js.map +1 -0
- package/dist/table/dataTableTypes.d.ts +135 -0
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/index.d.ts +2 -1
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +2 -1
- package/dist/table/useDataTableColumns.js +1 -1
- package/dist/table/useDataTableData.d.ts +1 -0
- package/dist/table/useDataTableData.d.ts.map +1 -1
- package/dist/table/useDataTableData.js +7 -6
- package/dist/table/useDataTableData.js.map +1 -1
- package/dist/table/useDataTableFilterForm.js +3 -3
- package/dist/table/useDataTableFilterModel.d.ts +1 -0
- package/dist/table/useDataTableFilterModel.d.ts.map +1 -1
- package/dist/table/useDataTableFilterModel.js +4 -4
- package/dist/table/useDataTableFilterVisibility.js +1 -1
- package/dist/table/useDataTableKeyboard.d.ts +58 -0
- package/dist/table/useDataTableKeyboard.d.ts.map +1 -0
- package/dist/table/useDataTableKeyboard.js +157 -0
- package/dist/table/useDataTableKeyboard.js.map +1 -0
- package/dist/table/useDataTableRefresh.js +1 -1
- package/dist/table/useDataTableSummary.js +1 -1
- package/dist/table/useDataTableWake.js +1 -1
- package/dist/table/useElementWidth.d.ts +10 -0
- package/dist/table/useElementWidth.d.ts.map +1 -0
- package/dist/table/useElementWidth.js +29 -0
- package/dist/table/useElementWidth.js.map +1 -0
- package/dist/tree/TreeView.js +1 -1
- package/dist/tree/TreeViewRow.d.ts.map +1 -1
- package/dist/tree/TreeViewRow.js +3 -3
- package/dist/tree/TreeViewRow.js.map +1 -1
- package/docs/packages-alepha-ui-ai.md +1 -0
- package/package.json +10 -10
- package/src/account/AccountDeleteDialog.tsx +2 -1
- package/src/account/AccountPasswordDialog.tsx +1 -1
- package/src/account/AccountProfileView.tsx +2 -1
- package/src/account/ApiKeyCreateDialog.tsx +1 -1
- package/src/account/__tests__/AccountProfile.browser.spec.tsx +21 -5
- package/src/admin/AdminAi.tsx +231 -0
- package/src/admin/AdminAiDailyChart.tsx +93 -0
- package/src/admin/AdminAiUsageTable.tsx +115 -0
- package/src/admin/AdminFiles.tsx +4 -6
- package/src/admin/AdminParameters.tsx +13 -2
- package/src/admin/AdminParametersEditorForm.tsx +9 -4
- package/src/admin/AdminParametersEditorPane.tsx +6 -0
- package/src/admin/AdminParametersTreeNodeView.tsx +1 -1
- package/src/admin/AdminRouter.tsx +31 -5
- package/src/admin/__tests__/AdminAiDailyChart.browser.spec.tsx +57 -0
- package/src/admin/__tests__/AdminRouter.spec.ts +5 -2
- package/src/admin/adminAiMoney.ts +20 -0
- package/src/admin/adminParametersTree.spec.ts +132 -0
- package/src/admin/adminParametersTree.ts +54 -2
- package/src/admin/analytics/ResultsTable.tsx +3 -1
- package/src/admin/analytics/analyticsModel.spec.ts +61 -2
- package/src/admin/analytics/analyticsModel.ts +29 -14
- package/src/admin/analytics/analyticsTypes.ts +1 -1
- package/src/admin/analytics/chartModel.ts +6 -2
- package/src/ai/AiChat.tsx +152 -28
- package/src/ai/AiChatComposer.tsx +26 -2
- package/src/ai/AiChatConfirmCard.tsx +15 -4
- package/src/ai/AiChatEmpty.tsx +24 -11
- package/src/ai/AiChatFloat.tsx +93 -3
- package/src/ai/AiChatHeaderButton.tsx +36 -0
- package/src/ai/AiChatHistory.tsx +22 -12
- package/src/ai/AiChatLauncher.tsx +6 -1
- package/src/ai/AiChatMessage.tsx +17 -2
- package/src/ai/AiChatPanel.tsx +93 -38
- package/src/ai/AiChatToolTrace.tsx +46 -0
- package/src/ai/__tests__/AiChat.browser.spec.tsx +501 -2
- package/src/ai/aiChatMotion.ts +86 -0
- package/src/ai/index.ts +2 -0
- package/src/ai/useAiChat.ts +13 -0
- package/src/ai/useAiChatFloatDrag.ts +131 -0
- package/src/auth/AuthLogin.tsx +26 -1
- package/src/auth/AuthLoginSlots.ts +55 -0
- package/src/auth/__tests__/AuthLoginSlots.browser.spec.tsx +93 -0
- package/src/auth/index.ts +1 -0
- package/src/core/Combobox.tsx +3 -1
- package/src/core/Dialog.tsx +9 -2
- package/src/core/PageOutline.tsx +28 -4
- package/src/core/Segmented.tsx +27 -5
- package/src/core/TimeAgo.browser.spec.tsx +49 -4
- package/src/core/TimeAgo.tsx +16 -4
- package/src/core/__tests__/CoreA11y.browser.spec.tsx +1 -10
- package/src/core/__tests__/PageOutline.browser.spec.tsx +20 -0
- package/src/core/__tests__/Segmented.browser.spec.tsx +59 -1
- package/src/core/__tests__/Textarea.browser.spec.tsx +1 -0
- package/src/core/__tests__/primitiveSlots.spec.ts +0 -1
- package/src/core/index.ts +0 -11
- package/src/form/Control.tsx +5 -0
- package/src/form/ControlSelect.tsx +31 -3
- package/src/form/ControlUpload.tsx +11 -16
- package/src/form/__tests__/ControlChoices.browser.spec.tsx +42 -0
- package/src/form/__tests__/ControlSelectLongLabelDialog.browser.spec.tsx +105 -0
- package/src/form/__tests__/ControlUpload.browser.spec.tsx +24 -0
- package/src/i18n/en/uiEn.ts +33 -2
- package/src/i18n/fr/uiFr.ts +33 -2
- package/src/markdown/MarkdownView.tsx +21 -5
- package/src/markdown/__tests__/MarkdownViewLink.browser.spec.tsx +33 -0
- package/src/organizations/MyOrganizationInvitations.tsx +11 -2
- package/src/organizations/MyOrganizations.tsx +24 -3
- package/src/organizations/OrganizationInviteDialog.tsx +1 -1
- package/src/organizations/OrganizationMembers.tsx +10 -1
- package/src/organizations/OrganizationPendingInvitations.tsx +6 -0
- package/src/organizations/OrganizationRanks.tsx +2 -0
- package/src/organizations/OrganizationTransferOwnershipDialog.tsx +1 -1
- package/src/organizations/__tests__/MyOrganizations.browser.spec.tsx +2 -1
- package/src/shell/DetailLayout.tsx +27 -5
- package/src/shell/DetailLayoutTabMenu.tsx +89 -0
- package/src/shell/__tests__/DetailLayout.browser.spec.tsx +36 -1
- package/src/styles.css +43 -0
- package/src/table/DataTable.tsx +65 -2
- package/src/table/DataTableBody.tsx +48 -6
- package/src/table/DataTableBulkBar.tsx +3 -6
- package/src/table/DataTableFooter.tsx +6 -1
- package/src/table/DataTableKeyHints.tsx +40 -0
- package/src/table/DataTableRowActionPrimary.tsx +52 -0
- package/src/table/DataTableRowActionsInline.tsx +16 -2
- package/src/table/DataTableSortMenuButton.tsx +105 -0
- package/src/table/DataTableToolbar.tsx +9 -0
- package/src/table/__tests__/DataTableColumnPriority.browser.spec.tsx +147 -0
- package/src/table/__tests__/DataTableDenseHeader.browser.spec.tsx +92 -0
- package/src/table/__tests__/DataTableKeyboard.browser.spec.tsx +216 -0
- package/src/table/__tests__/DataTableRowActionPrimary.browser.spec.tsx +126 -0
- package/src/table/__tests__/DataTableSortMenu.browser.spec.tsx +126 -0
- package/src/table/__tests__/DataTableStaticLoading.browser.spec.tsx +80 -0
- package/src/table/dataTableBaseProps.ts +78 -0
- package/src/table/dataTablePriority.ts +34 -0
- package/src/table/dataTableTypes.ts +139 -0
- package/src/table/index.ts +5 -0
- package/src/table/useDataTableData.ts +5 -1
- package/src/table/useDataTableKeyboard.ts +231 -0
- package/src/table/useElementWidth.ts +35 -0
- package/src/tree/TreeViewRow.tsx +4 -12
- package/src/tree/__tests__/TreeView.browser.spec.tsx +27 -12
- package/dist/core/Tabs.d.ts +0 -15
- package/dist/core/Tabs.d.ts.map +0 -1
- package/dist/core/Tabs.js +0 -50
- package/dist/core/Tabs.js.map +0 -1
- package/src/core/Tabs.tsx +0 -86
- package/src/core/__tests__/Tabs.browser.spec.tsx +0 -23
package/dist/table/DataTable.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ClientOnly, useAlepha } from "alepha/react";
|
|
4
|
+
import { useI18n } from "alepha/react/i18n";
|
|
1
5
|
import { Table, TableHeader } from "../core/Table.js";
|
|
2
6
|
import { useIsMobile } from "../core/useIsMobile.js";
|
|
3
7
|
import { useToast } from "../core/useToast.js";
|
|
@@ -11,9 +15,12 @@ import { DataTableFooter, PAGE_SIZES } from "./DataTableFooter.js";
|
|
|
11
15
|
import { DataTableHeaderFilter } from "./DataTableHeaderFilter.js";
|
|
12
16
|
import { DataTableHeaderPopup } from "./DataTableHeaderPopup.js";
|
|
13
17
|
import { DataTableHeaderRow } from "./DataTableHeaderRow.js";
|
|
18
|
+
import { DataTableKeyHints } from "./DataTableKeyHints.js";
|
|
14
19
|
import { persistedColumns, persistedOrder, persistedSize, persistedSort } from "./dataTablePersistence.js";
|
|
15
20
|
import { DataTablePresetRail } from "./DataTablePresetRail.js";
|
|
16
21
|
import { isEmptyFilterValue } from "./dataTablePresets.js";
|
|
22
|
+
import { fitColumnsToWidth } from "./dataTablePriority.js";
|
|
23
|
+
import { DataTableSortMenuButton } from "./DataTableSortMenuButton.js";
|
|
17
24
|
import { DATA_TABLE_SQUARE_RIGHT } from "./dataTableSquareRight.js";
|
|
18
25
|
import { DataTableSummaryPanel } from "./DataTableSummaryPanel.js";
|
|
19
26
|
import { DataTableToolbar } from "./DataTableToolbar.js";
|
|
@@ -22,15 +29,13 @@ import { useDataTableColumns } from "./useDataTableColumns.js";
|
|
|
22
29
|
import { useDataTableData } from "./useDataTableData.js";
|
|
23
30
|
import { useDataTableFilterForm } from "./useDataTableFilterForm.js";
|
|
24
31
|
import { useDataTableFilterVisibility } from "./useDataTableFilterVisibility.js";
|
|
32
|
+
import { useDataTableKeyboard } from "./useDataTableKeyboard.js";
|
|
25
33
|
import { useDataTableRefresh } from "./useDataTableRefresh.js";
|
|
26
34
|
import { useDataTableSummary } from "./useDataTableSummary.js";
|
|
27
35
|
import { useDataTableWake } from "./useDataTableWake.js";
|
|
36
|
+
import { useElementWidth } from "./useElementWidth.js";
|
|
28
37
|
import { useOptimisticRows } from "./useOptimisticRows.js";
|
|
29
38
|
import { useTableSelection } from "./useTableSelection.js";
|
|
30
|
-
import { ClientOnly, useAlepha } from "alepha/react";
|
|
31
|
-
import { useI18n } from "alepha/react/i18n";
|
|
32
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
33
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
39
|
// src/table/DataTable.tsx
|
|
35
40
|
/**
|
|
36
41
|
* A data table: server-side or static rows, sorting, filters, row and bulk
|
|
@@ -136,7 +141,7 @@ const DataTable = (props) => {
|
|
|
136
141
|
onShownChange: filterVisibility.setShown
|
|
137
142
|
});
|
|
138
143
|
};
|
|
139
|
-
const { page, setPage, sizeForm, sort, setSort, data: serverData, meta, rowFilters, groupCounts, loading, loadedRequestId, lastRequestId, isStatic, refreshKey, setRefreshKey, isRefreshing, setIsRefreshing, toggleSort, setSortTo } = useDataTableData({
|
|
144
|
+
const { page, setPage, sizeForm, sort, setSort, data: serverData, meta, rowFilters, groupCounts, loading, loadedRequestId, lastRequestId, isStatic, refreshKey, setRefreshKey, isRefreshing, setIsRefreshing, toggleSort, setSortTo, applySort } = useDataTableData({
|
|
140
145
|
props: untyped,
|
|
141
146
|
size,
|
|
142
147
|
setSize,
|
|
@@ -225,6 +230,11 @@ const DataTable = (props) => {
|
|
|
225
230
|
const rowKey = useCallback((item) => rowKeyByItem.get(item) ?? "", [rowKeyByItem]);
|
|
226
231
|
const { selection, selectedItems, allSelected, someSelected, toggleRow, toggleAll, clearSelection } = useTableSelection(data, rowKey);
|
|
227
232
|
const rootRef = useRef(null);
|
|
233
|
+
const [rootElement, setRootElement] = useState(null);
|
|
234
|
+
const setRoot = useCallback((element) => {
|
|
235
|
+
rootRef.current = element;
|
|
236
|
+
setRootElement(element);
|
|
237
|
+
}, []);
|
|
228
238
|
useDataTableWake({
|
|
229
239
|
enabled: props.refreshOnFocus === true && !isStatic,
|
|
230
240
|
loadedRequestId,
|
|
@@ -287,9 +297,21 @@ const DataTable = (props) => {
|
|
|
287
297
|
clearSelection();
|
|
288
298
|
setRefreshKey((k) => k + 1);
|
|
289
299
|
}
|
|
290
|
-
const
|
|
300
|
+
const cols = orderedKeys.map((key) => [key, props.columns[key]]);
|
|
301
|
+
const hasPriorities = Object.values(props.columns).some((def) => def.priority !== void 0);
|
|
302
|
+
const tableWidth = useElementWidth(rootElement, hasPriorities);
|
|
303
|
+
const visibleCols = fitColumnsToWidth(cols.filter(([key]) => visibleColumns.has(key)), tableWidth, props.priorityWidths);
|
|
291
304
|
const hasCheckbox = Boolean(props.bulkActions?.length);
|
|
292
305
|
const hasRowActions = Boolean(props.rowActions);
|
|
306
|
+
const keyboard = useDataTableKeyboard({
|
|
307
|
+
keyboard: props.keyboard,
|
|
308
|
+
root: rootRef,
|
|
309
|
+
data,
|
|
310
|
+
rowKeys,
|
|
311
|
+
onRowClick: props.onRowClick,
|
|
312
|
+
canSelect: hasCheckbox,
|
|
313
|
+
toggleRow
|
|
314
|
+
});
|
|
293
315
|
const rowCtx = useMemo(() => ({
|
|
294
316
|
refresh,
|
|
295
317
|
reload,
|
|
@@ -356,7 +378,7 @@ const DataTable = (props) => {
|
|
|
356
378
|
const canResetFilters = hasActiveFilters || filterVisibility.differsFromDeclaration;
|
|
357
379
|
const isEmptyState = !loading && data.length === 0;
|
|
358
380
|
const hasHelp = props.help != null && props.help !== false && props.help !== "";
|
|
359
|
-
const showToolbar = !props.hideToolbar && (Boolean(props.filters) || Boolean(props.leading) || Boolean(props.toolbar) || Boolean(props.actions?.length) || hasHelp || !props.hideColumnPicker || !props.hideActionsMenu);
|
|
381
|
+
const showToolbar = !props.hideToolbar && (Boolean(props.filters) || Boolean(props.leading) || Boolean(props.toolbar) || Boolean(props.sortMenu?.items.length) || Boolean(props.actions?.length) || hasHelp || !props.hideColumnPicker || !props.hideActionsMenu);
|
|
360
382
|
const rawSummaryContent = props.summary?.content;
|
|
361
383
|
const summaryContent = typeof rawSummaryContent === "function" ? rawSummaryContent({ refreshKey }) : rawSummaryContent;
|
|
362
384
|
const hasSummaryContent = summaryContent != null && summaryContent !== false && summaryContent !== "";
|
|
@@ -405,7 +427,7 @@ const DataTable = (props) => {
|
|
|
405
427
|
filterVisibility.setShown([.../* @__PURE__ */ new Set([...filterVisibility.shown, ...setting])].filter((key) => filterDefinition.modes[key] !== "locked"), true);
|
|
406
428
|
};
|
|
407
429
|
const table = /* @__PURE__ */ jsxs("div", {
|
|
408
|
-
ref:
|
|
430
|
+
ref: setRoot,
|
|
409
431
|
className: cn("flex flex-col gap-2", rail ? "min-h-0 min-w-0 flex-1 [&>*]:rounded-s-none" : props.className),
|
|
410
432
|
children: [
|
|
411
433
|
props.header && /* @__PURE__ */ jsx("div", {
|
|
@@ -437,6 +459,11 @@ const DataTable = (props) => {
|
|
|
437
459
|
canResetFilters,
|
|
438
460
|
leading: props.leading,
|
|
439
461
|
toolbar: props.toolbar,
|
|
462
|
+
sortControl: props.sortMenu?.items.length ? /* @__PURE__ */ jsx(DataTableSortMenuButton, {
|
|
463
|
+
menu: props.sortMenu,
|
|
464
|
+
sort,
|
|
465
|
+
onSort: applySort
|
|
466
|
+
}) : void 0,
|
|
440
467
|
actions: props.actions,
|
|
441
468
|
help: hasHelp ? props.help : void 0,
|
|
442
469
|
isMobile,
|
|
@@ -464,7 +491,8 @@ const DataTable = (props) => {
|
|
|
464
491
|
/* @__PURE__ */ jsx("div", {
|
|
465
492
|
className: cn("bg-card flex min-h-0 flex-1 flex-col overflow-auto rounded-md border", (showToolbar || showSummary) && "-mt-2 rounded-t-none border-t-0", showFooter ? "rounded-b-none border-b-0" : squareRight?.bottom, flatRows, !showToolbar && !showSummary && squareRight?.top, "[&>[data-slot=table-container]]:grow"),
|
|
466
493
|
children: /* @__PURE__ */ jsxs(Table, {
|
|
467
|
-
className: cn(isEmptyState && "h-full", compact && "text-xs [&_th]:text-xs"),
|
|
494
|
+
className: cn(isEmptyState && "h-full", compact && "text-xs [&_th]:text-xs", props.denseHeader && "[&_tbody_tr]:border-b [&_th]:h-10 [&_th]:text-[11.5px] [&_th]:font-semibold [&_th]:tracking-wide [&_th]:uppercase [&_th_button]:tracking-wide [&_th_button]:uppercase"),
|
|
495
|
+
"data-dense-header": props.denseHeader || void 0,
|
|
468
496
|
children: [/* @__PURE__ */ jsx(TableHeader, {
|
|
469
497
|
className: cn("bg-muted sticky top-0 z-10 [&_th]:shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0", props.chromeClassName),
|
|
470
498
|
children: /* @__PURE__ */ jsx(DataTableHeaderRow, {
|
|
@@ -503,6 +531,8 @@ const DataTable = (props) => {
|
|
|
503
531
|
rowActionsDisplay: props.rowActionsDisplay,
|
|
504
532
|
striped: props.striped,
|
|
505
533
|
onRowClick: props.onRowClick,
|
|
534
|
+
focusedKey: keyboard.focusedKey,
|
|
535
|
+
onRowFocus: keyboard.enabled ? keyboard.focusRow : void 0,
|
|
506
536
|
isRowActive: props.isRowActive,
|
|
507
537
|
onRowHover: props.onRowHover,
|
|
508
538
|
empty: props.empty,
|
|
@@ -523,12 +553,17 @@ const DataTable = (props) => {
|
|
|
523
553
|
meta,
|
|
524
554
|
setPage
|
|
525
555
|
}),
|
|
556
|
+
keyboard.hints && !showFooter && !isMobile && /* @__PURE__ */ jsx(DataTableKeyHints, {
|
|
557
|
+
hints: keyboard.hints,
|
|
558
|
+
className: "px-1"
|
|
559
|
+
}),
|
|
526
560
|
showFooter && /* @__PURE__ */ jsx(DataTableFooter, {
|
|
527
561
|
pageSizes: props.pageSizes,
|
|
528
562
|
sizeForm,
|
|
529
563
|
meta,
|
|
530
564
|
isMobile,
|
|
531
565
|
setPage,
|
|
566
|
+
hints: keyboard.hints && !isMobile ? /* @__PURE__ */ jsx(DataTableKeyHints, { hints: keyboard.hints }) : void 0,
|
|
532
567
|
className: cn(squareRight?.bottom, flatBottom, props.chromeClassName)
|
|
533
568
|
})
|
|
534
569
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableCompactPager } from \"./DataTableCompactPager.tsx\";\nimport type { DataTableFilterBarField } from \"./DataTableFilterBar.tsx\";\nimport { dataTableFilterBarFields } from \"./dataTableFilterFields.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderFilter } from \"./DataTableHeaderFilter.tsx\";\nimport { DataTableHeaderPopup } from \"./DataTableHeaderPopup.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DataTablePresetRail } from \"./DataTablePresetRail.tsx\";\nimport { isEmptyFilterValue } from \"./dataTablePresets.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n DataTableStatCard,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useDataTableWake } from \"./useDataTableWake.ts\";\nimport { useOptimisticRows } from \"./useOptimisticRows.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize, props.persistenceStorage),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n // `filters.onChange` (#Q3779): every value on mount, then after each\n // change. Read through a ref so a new callback each render neither\n // resubscribes nor fires.\n const onFiltersChange = useRef(untyped.filters?.onChange);\n onFiltersChange.current = untyped.filters?.onChange;\n // The current filter values as state too, so a summary tile standing for\n // some of them (`DataTableStatCard.filter`) redraws pressed or not.\n const [filterValues, setFilterValues] = useState<Record<string, unknown>>(\n () => ({ ...form?.currentValues }),\n );\n useEffect(() => {\n if (!form) return;\n onFiltersChange.current?.({ ...form.currentValues });\n // No `setFilterValues` here: the state starts from the form's values,\n // and every change after that comes through the event below.\n return alepha.events.on(\"form:changed\", (event) => {\n if (event.id !== form.id) return;\n onFiltersChange.current?.({ ...form.currentValues });\n setFilterValues({ ...form.currentValues });\n });\n }, [alepha, form]);\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n persistenceStorage: props.persistenceStorage,\n });\n\n // The filters that sit in a column's header, by column: the first field\n // naming a column wins it. Only for the bar the table draws itself - a\n // caller's `filters.render` owns where its filters go, and the bar's rule\n // that a set filter shows on it is what makes a header filter safe.\n const headerFilters: Record<string, DataTableFilterBarField> = {};\n // Under `headerPopup`, every field naming a column, so a `min` / `max`\n // pair lands in one popup.\n const popupFilters: Record<string, DataTableFilterBarField[]> = {};\n if (untyped.filters && !untyped.filters.render && filterDefinition) {\n for (const field of dataTableFilterBarFields(\n untyped.filters.fields,\n filterDefinition,\n )) {\n if (!field.column || field.hidden) continue;\n if (!(field.column in headerFilters)) headerFilters[field.column] = field;\n const fields = (popupFilters[field.column] ??= []);\n const ranged = field.range !== undefined;\n if (fields.length === 0 || (ranged && fields.every((f) => f.range))) {\n fields.push(field);\n }\n }\n }\n const headerPopup = props.headerPopup\n ? (columnKey: string, def: ColumnDef<T>) => {\n const fields = form ? (popupFilters[columnKey] ?? []) : [];\n if (fields.length === 0 && !def.sortable) return undefined;\n const field = def.sortKey ?? columnKey;\n return (\n <DataTableHeaderPopup\n form={form ?? undefined}\n label={def.label}\n hinted={Boolean(def.hint)}\n fields={fields}\n sortable={Boolean(def.sortable)}\n sorted={sort?.field === field ? sort.direction : null}\n onSort={(direction) => setSortTo(columnKey, def, direction)}\n />\n );\n }\n : undefined;\n const headerFilter = (columnKey: string) => {\n const field = headerFilters[columnKey];\n if (!field || !form) return undefined;\n return (\n <DataTableHeaderFilter\n form={form}\n field={field}\n shown={filterVisibility.shown}\n onShownChange={filterVisibility.setShown}\n />\n );\n };\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data: serverData,\n meta,\n rowFilters,\n groupCounts,\n loading,\n loadedRequestId,\n lastRequestId,\n isStatic,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n // `onPage`: the page on screen and how many there are, whenever either\n // moves. Through a ref so an inline callback does not re-fire it.\n const onPageRef = useRef(props.onPage);\n onPageRef.current = props.onPage;\n const totalPages = meta?.totalPages ?? 0;\n useEffect(() => {\n onPageRef.current?.({ page, totalPages });\n }, [page, totalPages]);\n\n const {\n refresh,\n reload,\n handleRefreshClick,\n resetFilters,\n canShare,\n shareFilters,\n } = useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n persistenceStorage: props.persistenceStorage,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n /**\n * A row's key from the row alone, so a row redrawn by an optimistic patch\n * (a new object) keeps the key of the one it replaces.\n */\n const keyOf = useCallback(\n (item: T, index: number): string => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n },\n [page, props.rowKey],\n );\n\n const serverRowKeys = useMemo(\n () => serverData.map((item, index) => keyOf(item, index)),\n [serverData, keyOf],\n );\n\n // -- Optimistic overlay ----------------------------------------------------\n\n const serverKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n serverData.forEach((item, index) => map.set(item, serverRowKeys[index]));\n return map;\n }, [serverData, serverRowKeys]);\n\n const overlayKey = useCallback(\n (item: T) => serverKeyByItem.get(item) ?? keyOf(item, -1),\n [serverKeyByItem, keyOf],\n );\n\n const overlay = useOptimisticRows<T>({\n data: serverData,\n rowKeys: serverRowKeys,\n rowKey: overlayKey,\n loadedRequestId,\n lastRequestId,\n reload,\n isStatic,\n });\n const data = overlay.data;\n const rowKeys = overlay.rowKeys;\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // Back on the tab: a background reload, unless the rows are fresh or the\n // reader is mid-selection or mid-edit (#Q4069).\n const rootRef = useRef<HTMLDivElement | null>(null);\n useDataTableWake({\n enabled: props.refreshOnFocus === true && !isStatic,\n loadedRequestId,\n freshMs: 10_000,\n selecting: selection.size > 0,\n root: rootRef,\n reload,\n });\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * React re-renders before committing this, so no frame, no fetch and no\n * effect ever sees the OUTGOING scope's state under the INCOMING key. The\n * sort used to be written by an effect keyed on `persistenceKey`, which\n * would have stored the project you just left over the one you just\n * opened; every write is now the reader's own act.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n const storage = props.persistenceStorage;\n setSize(persistedSize(sizeKey, props.defaultSize, storage));\n setSort(persistedSort(sortKey, props.defaultSort, storage));\n setVisibleColumns(persistedColumns(columnsKey, props.columns, storage));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns, storage));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n // The selection is the scope's rows: a bulk action after the switch must\n // not receive rows of the project just left, off screen by now.\n clearSelection();\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n const bulkCtx: BulkActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n\n /**\n * How many filters currently narrow the list: a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n /**\n * Whether the filters are the table's declared default view\n * (`initialValues`), such as an inbox that opens on `status: open`. An\n * empty page there means the list has nothing, so its `emptyMessage`\n * still applies (#Q3820): only a filter the reader set is a \"no match\".\n */\n const filtersAtDefault = useMemo(() => {\n if (!props.filters || !form) return true;\n const canonical = (values: Record<string, unknown>) => {\n const clean = cleanFilterValues(values);\n return JSON.stringify(\n Object.keys(clean)\n .sort()\n .map((key) => [key, clean[key]]),\n );\n };\n return (\n canonical(form.currentValues ?? {}) ===\n canonical((props.filters.initialValues ?? {}) as Record<string, unknown>)\n );\n }, [props.filters, form, refreshKey]);\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n !props.hideToolbar &&\n (Boolean(props.filters) ||\n Boolean(props.leading) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu);\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n // `density=\"compact\"` defaults the padding to `small` and the type to\n // `text-xs`; an explicit `cellPadding` keeps the padding half its own.\n const compact = props.density === \"compact\";\n const cellPadding =\n DATA_TABLE_CELL_PADDING[\n props.cellPadding ?? (compact ? \"small\" : \"normal\")\n ];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n // `pagination={false}` holds for static rows only: a fetched table is\n // paged by the server, and hiding its pager would hide rows.\n const unpaged = props.pagination === false && Boolean(props.data);\n // `\"compact\"` swaps the footer for the small pager under the rows, for a\n // static and a fetched table alike: rows stay reachable, the band goes.\n const compactPager = props.pagination === \"compact\";\n const showFooter =\n !unpaged &&\n !compactPager &&\n ((props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1));\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n // The presets rail (`filters.presets`), from `md` up: on a phone the\n // filter dialog is the table's whole filter surface.\n const presets = untyped.filters?.presets;\n const rail =\n presets &&\n presets.items.length > 0 &&\n form &&\n filterDefinition &&\n !isMobile ? (\n <DataTablePresetRail\n form={form}\n keys={filterDefinition.keys}\n kept={filterDefinition.kept}\n presets={presets}\n onApply={(preset) => {\n const values = preset.values as Record<string, unknown>;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const kept = filterDefinition.kept;\n const current = (form.currentValues ?? {}) as Record<string, unknown>;\n // Every key but the kept ones (`keepOnPreset`), so a preset is\n // the whole filter: what it does not name is cleared, the way\n // Reset filters clears it.\n for (const key of filterDefinition.keys) {\n if (kept.includes(key)) continue;\n inputs[key]?.set?.(values[key]);\n }\n // The bar then shows the preset's filters, and a kept one still\n // holding a value, and nothing else.\n filterVisibility.setShown(\n [\n ...Object.keys(values).filter(\n (key) =>\n !kept.includes(key) && !isEmptyFilterValue(values[key]),\n ),\n ...kept.filter((key) => !isEmptyFilterValue(current[key])),\n ].filter((key) => filterDefinition.modes[key] !== \"locked\"),\n true,\n );\n }}\n onAll={resetFilters}\n className={cn(\n // `flat`: no frame of its own either, only the line between the\n // rail and the rows, which the table's flattened start edge no\n // longer draws.\n props.flat && \"rounded-none border-y-0 border-s-0 border-e\",\n props.chromeClassName,\n )}\n />\n ) : undefined;\n\n // A summary tile standing for filter values (`DataTableStatCard.filter`):\n // a click sets them and shows them on the bar, or clears them when they\n // all hold already.\n const selectCard = (card: DataTableStatCard) => {\n if (!form || !filterDefinition || !card.filter) return;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const keys = Object.keys(card.filter).filter((key) =>\n filterDefinition.keys.includes(key),\n );\n if (isCardActive(card, filterValues)) {\n for (const key of keys) inputs[key]?.set?.(undefined);\n return;\n }\n for (const key of keys) inputs[key]?.set?.(card.filter[key]);\n // A key the tile clears (`undefined`) adds no chip to the bar.\n const setting = keys.filter((key) => card.filter?.[key] !== undefined);\n filterVisibility.setShown(\n [...new Set([...filterVisibility.shown, ...setting])].filter(\n (key) => filterDefinition.modes[key] !== \"locked\",\n ),\n true,\n );\n };\n\n const table = (\n <div\n ref={rootRef}\n className={cn(\n \"flex flex-col gap-2\",\n // Beside the rail the table and the rail are one panel: every band\n // squares its start corners against the rail's squared end ones.\n rail ? \"min-h-0 min-w-0 flex-1 [&>*]:rounded-s-none\" : props.className,\n )}\n >\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n isActive={(card) => isCardActive(card, filterValues)}\n onSelect={form && filterDefinition ? selectCard : undefined}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n headerPopup={props.headerPopup}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n leading={props.leading}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary ? \"-mt-2 rounded-t-none border-t-0\" : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n // `bg-card`: the rows are content between the chrome bands, and\n // keep their own surface on a muted page (a Plate's body) instead\n // of taking the chrome's colour through a transparent panel.\n \"bg-card flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table\n className={cn(\n isEmptyState && \"h-full\",\n compact && \"text-xs [&_th]:text-xs\",\n )}\n >\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over.\n\n The lines sit on the cells, not on the `<thead>`: WebKit paints\n no `box-shadow` on a table section, so on Safari the header had\n no bottom line at all. Not `chrome` either, for the same reason,\n and because `cn` does not know `chrome` is a background: it kept\n `TableHeader`'s `bg-muted/50` beside it, which won. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow draws the\n // same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 [&_th]:shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n headerFilter={headerFilter}\n headerPopup={headerPopup}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n leaving={overlay.leaving}\n flash={overlay.flash}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n filtersAtDefault={filtersAtDefault}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n rowActionsDisplay={props.rowActionsDisplay}\n striped={props.striped}\n onRowClick={props.onRowClick}\n isRowActive={props.isRowActive}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n groupBy={props.groupBy}\n groupCounts={groupCounts}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {compactPager && <DataTableCompactPager meta={meta} setPage={setPage} />}\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(squareRight?.bottom, flatBottom, props.chromeClassName)}\n />\n )}\n </div>\n );\n\n return (\n <ClientOnly>\n {rail ? (\n <div className={cn(\"flex min-h-0\", props.className)}>\n {rail}\n {table}\n </div>\n ) : (\n table\n )}\n </ClientOnly>\n );\n};\n\n/**\n * Whether every filter value a summary tile stands for holds now. Compared\n * as JSON, so an array value matches the same members in the same order; an\n * `undefined` value (the tile clears that filter) holds while the field is\n * empty: unset, `\"\"` or an emptied multi-select.\n */\nconst isCardActive = (\n card: DataTableStatCard,\n values: Record<string, unknown>,\n): boolean => {\n if (!card.filter) return false;\n const entries = Object.entries(card.filter);\n const empty = (value: unknown) =>\n value === undefined ||\n value === null ||\n value === \"\" ||\n (Array.isArray(value) && value.length === 0);\n return (\n entries.length > 0 &&\n entries.every(([key, value]) =>\n value === undefined\n ? empty(values[key])\n : JSON.stringify(values[key]) === JSON.stringify(value),\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,UACJ,MAAM,SAAS,SAAS,QAAQ,KAAA,IAAY,MAAM;CAKpD,MAAM,UACJ,MAAM,WAAW,WAAW,IAAI,KAAA,IAAY,MAAM;CAKpD,MAAM,CAAC,MAAM,WAAW,eACtB,cAAc,SAAS,MAAM,aAAa,MAAM,kBAAkB,CACpE;CACA,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;;;;;;;;;;;CAWvB,MAAM,WAAW,YAAY;CAE7B,MAAM,EAAE,MAAM,YAAY,qBAAqB,uBAAuB;EACpE,OAAO;EACP;EACA;CACF,CAAC;CAKD,MAAM,kBAAkB,OAAO,QAAQ,SAAS,QAAQ;CACxD,gBAAgB,UAAU,QAAQ,SAAS;CAG3C,MAAM,CAAC,cAAc,mBAAmB,gBAC/B,EAAE,GAAG,MAAM,cAAc,EAClC;CACA,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,gBAAgB,UAAU,EAAE,GAAG,KAAK,cAAc,CAAC;EAGnD,OAAO,OAAO,OAAO,GAAG,iBAAiB,UAAU;GACjD,IAAI,MAAM,OAAO,KAAK,IAAI;GAC1B,gBAAgB,UAAU,EAAE,GAAG,KAAK,cAAc,CAAC;GACnD,gBAAgB,EAAE,G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C,qBAAC,OAAD;EAAK,WAAW,GAAG,gBAAgB,MAAM,SAAS;EAAlD,UAAA,CACG,MACA,KACE;CAEL,CAAA,IAAA,MAEQ,CAAA;AAEhB;;;;;;;AAQA,MAAM,gBACJ,MACA,WACY;CACZ,IAAI,CAAC,KAAK,QAAQ,OAAO;CACzB,MAAM,UAAU,OAAO,QAAQ,KAAK,MAAM;CAC1C,MAAM,SAAS,UACb,UAAU,KAAA,KACV,UAAU,QACV,UAAU,MACT,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;CAC5C,OACE,QAAQ,SAAS,KACjB,QAAQ,OAAO,CAAC,KAAK,WACnB,UAAU,KAAA,IACN,MAAM,OAAO,IAAI,IACjB,KAAK,UAAU,OAAO,IAAI,MAAM,KAAK,UAAU,KAAK,CAC1D;AAEJ"}
|
|
1
|
+
{"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableCompactPager } from \"./DataTableCompactPager.tsx\";\nimport type { DataTableFilterBarField } from \"./DataTableFilterBar.tsx\";\nimport { dataTableFilterBarFields } from \"./dataTableFilterFields.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderFilter } from \"./DataTableHeaderFilter.tsx\";\nimport { DataTableHeaderPopup } from \"./DataTableHeaderPopup.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport { DataTableKeyHints } from \"./DataTableKeyHints.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DataTablePresetRail } from \"./DataTablePresetRail.tsx\";\nimport { isEmptyFilterValue } from \"./dataTablePresets.ts\";\nimport { fitColumnsToWidth } from \"./dataTablePriority.ts\";\nimport { DataTableSortMenuButton } from \"./DataTableSortMenuButton.tsx\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n DataTableStatCard,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableKeyboard } from \"./useDataTableKeyboard.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useDataTableWake } from \"./useDataTableWake.ts\";\nimport { useElementWidth } from \"./useElementWidth.ts\";\nimport { useOptimisticRows } from \"./useOptimisticRows.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize, props.persistenceStorage),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n // `filters.onChange` (#Q3779): every value on mount, then after each\n // change. Read through a ref so a new callback each render neither\n // resubscribes nor fires.\n const onFiltersChange = useRef(untyped.filters?.onChange);\n onFiltersChange.current = untyped.filters?.onChange;\n // The current filter values as state too, so a summary tile standing for\n // some of them (`DataTableStatCard.filter`) redraws pressed or not.\n const [filterValues, setFilterValues] = useState<Record<string, unknown>>(\n () => ({ ...form?.currentValues }),\n );\n useEffect(() => {\n if (!form) return;\n onFiltersChange.current?.({ ...form.currentValues });\n // No `setFilterValues` here: the state starts from the form's values,\n // and every change after that comes through the event below.\n return alepha.events.on(\"form:changed\", (event) => {\n if (event.id !== form.id) return;\n onFiltersChange.current?.({ ...form.currentValues });\n setFilterValues({ ...form.currentValues });\n });\n }, [alepha, form]);\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n persistenceStorage: props.persistenceStorage,\n });\n\n // The filters that sit in a column's header, by column: the first field\n // naming a column wins it. Only for the bar the table draws itself - a\n // caller's `filters.render` owns where its filters go, and the bar's rule\n // that a set filter shows on it is what makes a header filter safe.\n const headerFilters: Record<string, DataTableFilterBarField> = {};\n // Under `headerPopup`, every field naming a column, so a `min` / `max`\n // pair lands in one popup.\n const popupFilters: Record<string, DataTableFilterBarField[]> = {};\n if (untyped.filters && !untyped.filters.render && filterDefinition) {\n for (const field of dataTableFilterBarFields(\n untyped.filters.fields,\n filterDefinition,\n )) {\n if (!field.column || field.hidden) continue;\n if (!(field.column in headerFilters)) headerFilters[field.column] = field;\n const fields = (popupFilters[field.column] ??= []);\n const ranged = field.range !== undefined;\n if (fields.length === 0 || (ranged && fields.every((f) => f.range))) {\n fields.push(field);\n }\n }\n }\n const headerPopup = props.headerPopup\n ? (columnKey: string, def: ColumnDef<T>) => {\n const fields = form ? (popupFilters[columnKey] ?? []) : [];\n if (fields.length === 0 && !def.sortable) return undefined;\n const field = def.sortKey ?? columnKey;\n return (\n <DataTableHeaderPopup\n form={form ?? undefined}\n label={def.label}\n hinted={Boolean(def.hint)}\n fields={fields}\n sortable={Boolean(def.sortable)}\n sorted={sort?.field === field ? sort.direction : null}\n onSort={(direction) => setSortTo(columnKey, def, direction)}\n />\n );\n }\n : undefined;\n const headerFilter = (columnKey: string) => {\n const field = headerFilters[columnKey];\n if (!field || !form) return undefined;\n return (\n <DataTableHeaderFilter\n form={form}\n field={field}\n shown={filterVisibility.shown}\n onShownChange={filterVisibility.setShown}\n />\n );\n };\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data: serverData,\n meta,\n rowFilters,\n groupCounts,\n loading,\n loadedRequestId,\n lastRequestId,\n isStatic,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n applySort,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n // `onPage`: the page on screen and how many there are, whenever either\n // moves. Through a ref so an inline callback does not re-fire it.\n const onPageRef = useRef(props.onPage);\n onPageRef.current = props.onPage;\n const totalPages = meta?.totalPages ?? 0;\n useEffect(() => {\n onPageRef.current?.({ page, totalPages });\n }, [page, totalPages]);\n\n const {\n refresh,\n reload,\n handleRefreshClick,\n resetFilters,\n canShare,\n shareFilters,\n } = useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n persistenceStorage: props.persistenceStorage,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n /**\n * A row's key from the row alone, so a row redrawn by an optimistic patch\n * (a new object) keeps the key of the one it replaces.\n */\n const keyOf = useCallback(\n (item: T, index: number): string => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n },\n [page, props.rowKey],\n );\n\n const serverRowKeys = useMemo(\n () => serverData.map((item, index) => keyOf(item, index)),\n [serverData, keyOf],\n );\n\n // -- Optimistic overlay ----------------------------------------------------\n\n const serverKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n serverData.forEach((item, index) => map.set(item, serverRowKeys[index]));\n return map;\n }, [serverData, serverRowKeys]);\n\n const overlayKey = useCallback(\n (item: T) => serverKeyByItem.get(item) ?? keyOf(item, -1),\n [serverKeyByItem, keyOf],\n );\n\n const overlay = useOptimisticRows<T>({\n data: serverData,\n rowKeys: serverRowKeys,\n rowKey: overlayKey,\n loadedRequestId,\n lastRequestId,\n reload,\n isStatic,\n });\n const data = overlay.data;\n const rowKeys = overlay.rowKeys;\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // Back on the tab: a background reload, unless the rows are fresh or the\n // reader is mid-selection or mid-edit (#Q4069).\n const rootRef = useRef<HTMLDivElement | null>(null);\n // The root as state too, for the width `ColumnDef.priority` reads: the\n // table mounts under `ClientOnly`, after this hook's first effect.\n const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null);\n const setRoot = useCallback((element: HTMLDivElement | null) => {\n rootRef.current = element;\n setRootElement(element);\n }, []);\n useDataTableWake({\n enabled: props.refreshOnFocus === true && !isStatic,\n loadedRequestId,\n freshMs: 10_000,\n selecting: selection.size > 0,\n root: rootRef,\n reload,\n });\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * React re-renders before committing this, so no frame, no fetch and no\n * effect ever sees the OUTGOING scope's state under the INCOMING key. The\n * sort used to be written by an effect keyed on `persistenceKey`, which\n * would have stored the project you just left over the one you just\n * opened; every write is now the reader's own act.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n const storage = props.persistenceStorage;\n setSize(persistedSize(sizeKey, props.defaultSize, storage));\n setSort(persistedSort(sortKey, props.defaultSort, storage));\n setVisibleColumns(persistedColumns(columnsKey, props.columns, storage));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns, storage));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n // The selection is the scope's rows: a bulk action after the switch must\n // not receive rows of the project just left, off screen by now.\n clearSelection();\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n // The reader's columns, less those whose `priority` the table's width\n // sheds: the picker's state is left as it is.\n const hasPriorities = Object.values(props.columns).some(\n (def) => def.priority !== undefined,\n );\n const tableWidth = useElementWidth(rootElement, hasPriorities);\n const visibleCols = fitColumnsToWidth(\n cols.filter(([key]) => visibleColumns.has(key)),\n tableWidth,\n props.priorityWidths,\n );\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const keyboard = useDataTableKeyboard<T>({\n keyboard: props.keyboard,\n root: rootRef,\n data,\n rowKeys,\n onRowClick: props.onRowClick,\n canSelect: hasCheckbox,\n toggleRow,\n });\n\n const rowCtx: RowActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n const bulkCtx: BulkActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n\n /**\n * How many filters currently narrow the list: a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n /**\n * Whether the filters are the table's declared default view\n * (`initialValues`), such as an inbox that opens on `status: open`. An\n * empty page there means the list has nothing, so its `emptyMessage`\n * still applies (#Q3820): only a filter the reader set is a \"no match\".\n */\n const filtersAtDefault = useMemo(() => {\n if (!props.filters || !form) return true;\n const canonical = (values: Record<string, unknown>) => {\n const clean = cleanFilterValues(values);\n return JSON.stringify(\n Object.keys(clean)\n .sort()\n .map((key) => [key, clean[key]]),\n );\n };\n return (\n canonical(form.currentValues ?? {}) ===\n canonical((props.filters.initialValues ?? {}) as Record<string, unknown>)\n );\n }, [props.filters, form, refreshKey]);\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n !props.hideToolbar &&\n (Boolean(props.filters) ||\n Boolean(props.leading) ||\n Boolean(props.toolbar) ||\n Boolean(props.sortMenu?.items.length) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu);\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n // `density=\"compact\"` defaults the padding to `small` and the type to\n // `text-xs`; an explicit `cellPadding` keeps the padding half its own.\n const compact = props.density === \"compact\";\n const cellPadding =\n DATA_TABLE_CELL_PADDING[\n props.cellPadding ?? (compact ? \"small\" : \"normal\")\n ];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n // `pagination={false}` holds for static rows only: a fetched table is\n // paged by the server, and hiding its pager would hide rows.\n const unpaged = props.pagination === false && Boolean(props.data);\n // `\"compact\"` swaps the footer for the small pager under the rows, for a\n // static and a fetched table alike: rows stay reachable, the band goes.\n const compactPager = props.pagination === \"compact\";\n const showFooter =\n !unpaged &&\n !compactPager &&\n ((props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1));\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n // The presets rail (`filters.presets`), from `md` up: on a phone the\n // filter dialog is the table's whole filter surface.\n const presets = untyped.filters?.presets;\n const rail =\n presets &&\n presets.items.length > 0 &&\n form &&\n filterDefinition &&\n !isMobile ? (\n <DataTablePresetRail\n form={form}\n keys={filterDefinition.keys}\n kept={filterDefinition.kept}\n presets={presets}\n onApply={(preset) => {\n const values = preset.values as Record<string, unknown>;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const kept = filterDefinition.kept;\n const current = (form.currentValues ?? {}) as Record<string, unknown>;\n // Every key but the kept ones (`keepOnPreset`), so a preset is\n // the whole filter: what it does not name is cleared, the way\n // Reset filters clears it.\n for (const key of filterDefinition.keys) {\n if (kept.includes(key)) continue;\n inputs[key]?.set?.(values[key]);\n }\n // The bar then shows the preset's filters, and a kept one still\n // holding a value, and nothing else.\n filterVisibility.setShown(\n [\n ...Object.keys(values).filter(\n (key) =>\n !kept.includes(key) && !isEmptyFilterValue(values[key]),\n ),\n ...kept.filter((key) => !isEmptyFilterValue(current[key])),\n ].filter((key) => filterDefinition.modes[key] !== \"locked\"),\n true,\n );\n }}\n onAll={resetFilters}\n className={cn(\n // `flat`: no frame of its own either, only the line between the\n // rail and the rows, which the table's flattened start edge no\n // longer draws.\n props.flat && \"rounded-none border-y-0 border-s-0 border-e\",\n props.chromeClassName,\n )}\n />\n ) : undefined;\n\n // A summary tile standing for filter values (`DataTableStatCard.filter`):\n // a click sets them and shows them on the bar, or clears them when they\n // all hold already.\n const selectCard = (card: DataTableStatCard) => {\n if (!form || !filterDefinition || !card.filter) return;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const keys = Object.keys(card.filter).filter((key) =>\n filterDefinition.keys.includes(key),\n );\n if (isCardActive(card, filterValues)) {\n for (const key of keys) inputs[key]?.set?.(undefined);\n return;\n }\n for (const key of keys) inputs[key]?.set?.(card.filter[key]);\n // A key the tile clears (`undefined`) adds no chip to the bar.\n const setting = keys.filter((key) => card.filter?.[key] !== undefined);\n filterVisibility.setShown(\n [...new Set([...filterVisibility.shown, ...setting])].filter(\n (key) => filterDefinition.modes[key] !== \"locked\",\n ),\n true,\n );\n };\n\n const table = (\n <div\n ref={setRoot}\n className={cn(\n \"flex flex-col gap-2\",\n // Beside the rail the table and the rail are one panel: every band\n // squares its start corners against the rail's squared end ones.\n rail ? \"min-h-0 min-w-0 flex-1 [&>*]:rounded-s-none\" : props.className,\n )}\n >\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n isActive={(card) => isCardActive(card, filterValues)}\n onSelect={form && filterDefinition ? selectCard : undefined}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n headerPopup={props.headerPopup}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n leading={props.leading}\n toolbar={props.toolbar}\n sortControl={\n props.sortMenu?.items.length ? (\n <DataTableSortMenuButton\n menu={props.sortMenu}\n sort={sort}\n onSort={applySort}\n />\n ) : undefined\n }\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary ? \"-mt-2 rounded-t-none border-t-0\" : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n // `bg-card`: the rows are content between the chrome bands, and\n // keep their own surface on a muted page (a Plate's body) instead\n // of taking the chrome's colour through a transparent panel.\n \"bg-card flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table\n className={cn(\n isEmptyState && \"h-full\",\n compact && \"text-xs [&_th]:text-xs\",\n // `denseHeader`: a 40 px band of uppercase labels, and a line\n // under every row. A sortable column's label is a button, which\n // the base styles reset to no text transform: it takes the\n // band's case and tracking too.\n props.denseHeader &&\n \"[&_tbody_tr]:border-b [&_th]:h-10 [&_th]:text-[11.5px] [&_th]:font-semibold [&_th]:tracking-wide [&_th]:uppercase [&_th_button]:tracking-wide [&_th_button]:uppercase\",\n )}\n data-dense-header={props.denseHeader || undefined}\n >\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over.\n\n The lines sit on the cells, not on the `<thead>`: WebKit paints\n no `box-shadow` on a table section, so on Safari the header had\n no bottom line at all. Not `chrome` either, for the same reason,\n and because `cn` does not know `chrome` is a background: it kept\n `TableHeader`'s `bg-muted/50` beside it, which won. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow draws the\n // same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 [&_th]:shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n headerFilter={headerFilter}\n headerPopup={headerPopup}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n leaving={overlay.leaving}\n flash={overlay.flash}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n filtersAtDefault={filtersAtDefault}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n rowActionsDisplay={props.rowActionsDisplay}\n striped={props.striped}\n onRowClick={props.onRowClick}\n focusedKey={keyboard.focusedKey}\n onRowFocus={keyboard.enabled ? keyboard.focusRow : undefined}\n isRowActive={props.isRowActive}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n groupBy={props.groupBy}\n groupCounts={groupCounts}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {compactPager && <DataTableCompactPager meta={meta} setPage={setPage} />}\n\n {/* The key hints sit in the footer; a table without one lists them\n under the rows. Not on a phone, which has no keys. */}\n {keyboard.hints && !showFooter && !isMobile && (\n <DataTableKeyHints hints={keyboard.hints} className=\"px-1\" />\n )}\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n hints={\n keyboard.hints && !isMobile ? (\n <DataTableKeyHints hints={keyboard.hints} />\n ) : undefined\n }\n className={cn(squareRight?.bottom, flatBottom, props.chromeClassName)}\n />\n )}\n </div>\n );\n\n return (\n <ClientOnly>\n {rail ? (\n <div className={cn(\"flex min-h-0\", props.className)}>\n {rail}\n {table}\n </div>\n ) : (\n table\n )}\n </ClientOnly>\n );\n};\n\n/**\n * Whether every filter value a summary tile stands for holds now. Compared\n * as JSON, so an array value matches the same members in the same order; an\n * `undefined` value (the tile clears that filter) holds while the field is\n * empty: unset, `\"\"` or an emptied multi-select.\n */\nconst isCardActive = (\n card: DataTableStatCard,\n values: Record<string, unknown>,\n): boolean => {\n if (!card.filter) return false;\n const entries = Object.entries(card.filter);\n const empty = (value: unknown) =>\n value === undefined ||\n value === null ||\n value === \"\" ||\n (Array.isArray(value) && value.length === 0);\n return (\n entries.length > 0 &&\n entries.every(([key, value]) =>\n value === undefined\n ? empty(values[key])\n : JSON.stringify(values[key]) === JSON.stringify(value),\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,UACJ,MAAM,SAAS,SAAS,QAAQ,KAAA,IAAY,MAAM;CAKpD,MAAM,UACJ,MAAM,WAAW,WAAW,IAAI,KAAA,IAAY,MAAM;CAKpD,MAAM,CAAC,MAAM,WAAW,eACtB,cAAc,SAAS,MAAM,aAAa,MAAM,kBAAkB,CACpE;CACA,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;;;;;;;;;;;CAWvB,MAAM,WAAW,YAAY;CAE7B,MAAM,EAAE,MAAM,YAAY,qBAAqB,uBAAuB;EACpE,OAAO;EACP;EACA;CACF,CAAC;CAKD,MAAM,kBAAkB,OAAO,QAAQ,SAAS,QAAQ;CACxD,gBAAgB,UAAU,QAAQ,SAAS;CAG3C,MAAM,CAAC,cAAc,mBAAmB,gBAC/B,EAAE,GAAG,MAAM,cAAc,EAClC;CACA,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,gBAAgB,UAAU,EAAE,GAAG,KAAK,cAAc,CAAC;EAGnD,OAAO,OAAO,OAAO,GAAG,iBAAiB,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CAC1C,MAAM,SAAS,UACb,UAAU,KAAA,KACV,UAAU,QACV,UAAU,MACT,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;CAC5C,OACE,QAAQ,SAAS,KACjB,QAAQ,OAAO,CAAC,KAAK,WACnB,UAAU,KAAA,IACN,MAAM,OAAO,IAAI,IACjB,KAAK,UAAU,OAAO,IAAI,MAAM,KAAK,UAAU,KAAK,CAC1D;AAEJ"}
|
|
@@ -54,6 +54,16 @@ export interface DataTableBodyProps<T> {
|
|
|
54
54
|
*/
|
|
55
55
|
striped?: boolean;
|
|
56
56
|
onRowClick?: (item: T) => void;
|
|
57
|
+
/**
|
|
58
|
+
* The key of the row the keyboard focus is on (the table's `keyboard`),
|
|
59
|
+
* drawn marked.
|
|
60
|
+
*/
|
|
61
|
+
focusedKey?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Called with a row's key when it is clicked, so a click moves the
|
|
64
|
+
* keyboard focus there. Absent while `keyboard` is off.
|
|
65
|
+
*/
|
|
66
|
+
onRowFocus?: (key: string) => void;
|
|
57
67
|
/**
|
|
58
68
|
* The table's `isRowActive`.
|
|
59
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableBody.d.ts","sourceRoot":"","sources":["../../src/table/DataTableBody.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DataTableBody.d.ts","sourceRoot":"","sources":["../../src/table/DataTableBody.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAWzD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;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AC,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC9B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAU,kBAAkB,CAAC,CAAC,CAAC,gCAsR7D,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { useI18n } from "alepha/react/i18n";
|
|
2
|
+
import { Inbox, SearchX } from "lucide-react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
1
4
|
import { Checkbox } from "../core/Checkbox.js";
|
|
2
5
|
import { TableBody, TableCell, TableRow } from "../core/Table.js";
|
|
3
6
|
import { cn } from "../core/utils.js";
|
|
4
7
|
import { DataTableGroupRow } from "./DataTableGroupRow.js";
|
|
8
|
+
import { DataTableRowActionPrimary, splitPrimaryRowActions } from "./DataTableRowActionPrimary.js";
|
|
5
9
|
import { DataTableRowActionsInline } from "./DataTableRowActionsInline.js";
|
|
6
10
|
import { DataTableRowActionsMenu } from "./DataTableRowActionsMenu.js";
|
|
7
11
|
import { DataTableSkeletonRows } from "./DataTableSkeletonRows.js";
|
|
8
12
|
import { useRowMotion } from "./useRowMotion.js";
|
|
9
|
-
import { useI18n } from "alepha/react/i18n";
|
|
10
|
-
import { Inbox, SearchX } from "lucide-react";
|
|
11
|
-
import { useRef, useState } from "react";
|
|
12
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
// src/table/DataTableBody.tsx
|
|
14
15
|
/**
|
|
@@ -34,22 +35,47 @@ const DataTableBody = (props) => {
|
|
|
34
35
|
const emptyTitle = emptyOverride.title ?? emptyMessage ?? String(hasActiveFilters ? tr("dataTable.noMatchTitle", { default: "No match" }) : tr("dataTable.emptyTitle", { default: "No items" }));
|
|
35
36
|
const emptyAction = emptyOverride.action;
|
|
36
37
|
const emptyDescription = emptyOverride.description ?? (emptyMessage ? void 0 : String(hasActiveFilters ? tr("dataTable.noMatchDescription", { default: "Try adjusting or clearing the filters." }) : tr("dataTable.emptyDescription", { default: "Nothing here yet." })));
|
|
38
|
+
const renderMenuActions = (item) => {
|
|
39
|
+
const { primary, rest } = splitPrimaryRowActions(props.rowActions(item));
|
|
40
|
+
if (primary.length === 0) return /* @__PURE__ */ jsx(DataTableRowActionsMenu, {
|
|
41
|
+
actions: rest,
|
|
42
|
+
item,
|
|
43
|
+
ctx: rowCtx
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: "flex items-center justify-end gap-1",
|
|
47
|
+
children: [primary.map((action) => /* @__PURE__ */ jsx(DataTableRowActionPrimary, {
|
|
48
|
+
action,
|
|
49
|
+
item,
|
|
50
|
+
ctx: rowCtx
|
|
51
|
+
}, action.label)), /* @__PURE__ */ jsx(DataTableRowActionsMenu, {
|
|
52
|
+
actions: rest,
|
|
53
|
+
item,
|
|
54
|
+
ctx: rowCtx
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
};
|
|
37
58
|
const renderRow = (item, rowIndex) => {
|
|
38
59
|
const key = rowKeys[rowIndex];
|
|
39
60
|
const isSelected = selection.has(key);
|
|
40
61
|
const isLeaving = leaving.has(key);
|
|
41
62
|
const isActive = props.isRowActive?.(item) ?? false;
|
|
63
|
+
const isFocused = props.focusedKey === key;
|
|
42
64
|
return /* @__PURE__ */ jsxs(TableRow, {
|
|
43
65
|
"data-row-key": key,
|
|
44
66
|
"data-leaving": isLeaving || void 0,
|
|
45
67
|
"aria-hidden": isLeaving || void 0,
|
|
46
68
|
"aria-current": isActive || void 0,
|
|
47
69
|
"data-active": isActive || void 0,
|
|
70
|
+
"data-focused": isFocused || void 0,
|
|
48
71
|
inert: isLeaving || void 0,
|
|
49
|
-
onClick: () =>
|
|
72
|
+
onClick: () => {
|
|
73
|
+
props.onRowFocus?.(key);
|
|
74
|
+
props.onRowClick?.(item);
|
|
75
|
+
},
|
|
50
76
|
onMouseEnter: () => props.onRowHover?.(item),
|
|
51
77
|
onMouseLeave: () => props.onRowHover?.(void 0),
|
|
52
|
-
className: cn(props.onRowClick && "cursor-pointer", props.striped && "even:bg-muted/40", isSelected && "bg-hover-weak", isActive && "bg-hover hover:bg-hover"),
|
|
78
|
+
className: cn(props.onRowClick && "cursor-pointer", props.striped && "even:bg-muted/40", isSelected && "bg-hover-weak", isActive && "bg-hover hover:bg-hover", isFocused && "bg-hover-weak [&>td:first-child]:shadow-[inset_2px_0_0_0_var(--primary)]"),
|
|
53
79
|
children: [
|
|
54
80
|
hasCheckbox && /* @__PURE__ */ jsx(TableCell, {
|
|
55
81
|
className: props.cellClassName,
|
|
@@ -71,11 +97,7 @@ const DataTableBody = (props) => {
|
|
|
71
97
|
actions: props.rowActions(item),
|
|
72
98
|
item,
|
|
73
99
|
ctx: rowCtx
|
|
74
|
-
}) :
|
|
75
|
-
actions: props.rowActions(item),
|
|
76
|
-
item,
|
|
77
|
-
ctx: rowCtx
|
|
78
|
-
})
|
|
100
|
+
}) : renderMenuActions(item)
|
|
79
101
|
})
|
|
80
102
|
]
|
|
81
103
|
}, key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableBody.js","names":[],"sources":["../../src/table/DataTableBody.tsx"],"sourcesContent":["import { useI18n } from \"alepha/react/i18n\";\nimport { Inbox, SearchX } from \"lucide-react\";\nimport { type ReactNode, useRef, useState } from \"react\";\n\nimport { Checkbox } from \"../core/Checkbox.tsx\";\nimport { TableBody, TableCell, TableRow } from \"../core/Table.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { DataTableGroupRow } from \"./DataTableGroupRow.tsx\";\nimport { DataTableRowActionsInline } from \"./DataTableRowActionsInline.tsx\";\nimport { DataTableRowActionsMenu } from \"./DataTableRowActionsMenu.tsx\";\nimport { DataTableSkeletonRows } from \"./DataTableSkeletonRows.tsx\";\nimport type {\n DataTableCellContext,\n DataTableEmptyState,\n DataTableGroupBy,\n ColumnDef,\n RowActionContext,\n RowActionEntry,\n} from \"./dataTableTypes.ts\";\nimport { useRowMotion } from \"./useRowMotion.ts\";\n\nexport interface DataTableBodyProps<T> {\n /**\n * The table's `cellPadding` classes for a body cell, merged before a\n * column's own `className`.\n */\n cellClassName?: string;\n data: T[];\n /**\n * One key per row of `data`, index for index.\n */\n rowKeys: string[];\n /**\n * Rows an optimistic remove is taking off: drawn, inert, playing their\n * exit.\n */\n leaving?: ReadonlySet<string>;\n /**\n * Rows an optimistic patch just redrew, flashed once.\n */\n flash?: Set<string>;\n loading: boolean;\n /**\n * The visible columns, in the reader's order.\n */\n visibleCols: Array<[string, ColumnDef<T>]>;\n /**\n * Handed to every cell beside its row.\n */\n cellContext: DataTableCellContext;\n hasCheckbox: boolean;\n hasRowActions: boolean;\n /**\n * Whether a filter is set, which picks the no-match empty state over the\n * no-items one.\n */\n hasActiveFilters: boolean;\n /**\n * Whether the filters are the table's declared `initialValues`: an empty\n * page there keeps `emptyMessage`.\n */\n filtersAtDefault?: boolean;\n selection: ReadonlyMap<string, T>;\n toggleRow: (item: T) => void;\n rowCtx: RowActionContext;\n rowActions?: (item: T) => RowActionEntry<T>[];\n /**\n * The table's `rowActionsDisplay`.\n */\n rowActionsDisplay?: \"menu\" | \"inline\";\n /**\n * The table's `striped`.\n */\n striped?: boolean;\n onRowClick?: (item: T) => void;\n /**\n * The table's `isRowActive`.\n */\n isRowActive?: (item: T) => boolean;\n onRowHover?: (item: T | undefined) => void;\n empty?: ReactNode;\n emptyMessage?: string;\n emptyState?: DataTableEmptyState;\n noMatchState?: DataTableEmptyState;\n /**\n * The table's `groupBy`: rows drawn under folding group headers.\n */\n groupBy?: DataTableGroupBy<T>;\n /**\n * Each group's row count over every page (static rows): what a group's\n * header shows when the table is paged. Absent, it counts the rows here.\n */\n groupCounts?: Record<string, number>;\n}\n\n/**\n * The table body: skeleton rows while the first page loads, the empty state\n * when the page came back empty, the rows otherwise.\n */\nexport const DataTableBody = <T,>(props: DataTableBodyProps<T>) => {\n const {\n data,\n rowKeys,\n loading,\n visibleCols,\n hasCheckbox,\n hasRowActions,\n hasActiveFilters,\n selection,\n toggleRow,\n rowCtx,\n } = props;\n const { tr } = useI18n();\n const bodyRef = useRef<HTMLTableSectionElement>(null);\n const leaving = props.leaving ?? NO_KEYS;\n // The groups the reader flipped from the default (open, or folded under\n // `defaultCollapsed`). Not stored: a reload shows the default again.\n const [flipped, setFlipped] = useState<ReadonlySet<string>>(NO_KEYS);\n const colSpan =\n visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0);\n useRowMotion({\n body: bodyRef,\n rowKeys,\n leaving,\n flash: props.flash ?? NO_FLASH,\n });\n\n // Which empty state applies, resolved here rather than in the JSX because\n // the answer is one boolean and the branch is four values deep.\n //\n // `hasActiveFilters` is already false whenever `props.filters` is unset, so\n // a table with no filter form can only ever reach the \"no items\" side.\n const emptyOverride =\n (hasActiveFilters ? props.noMatchState : props.emptyState) ?? {};\n const EmptyIcon = emptyOverride.icon ?? (hasActiveFilters ? SearchX : Inbox);\n // `emptyMessage` is the no-items title only (#Q3820): \"No epics yet.\" is\n // false of a list whose filter hid every row, so a filtered empty page\n // falls through to the no-match defaults.\n // A default view (`initialValues`) is the list as it is meant to be read,\n // not a reader's filter, so it keeps the message.\n const emptyMessage =\n hasActiveFilters && !props.filtersAtDefault\n ? undefined\n : props.emptyMessage;\n const emptyTitle =\n emptyOverride.title ??\n emptyMessage ??\n String(\n hasActiveFilters\n ? tr(\"dataTable.noMatchTitle\", { default: \"No match\" })\n : tr(\"dataTable.emptyTitle\", { default: \"No items\" }),\n );\n const emptyAction = emptyOverride.action;\n // Suppressed by a bare `emptyMessage`: that prop is the whole message, and\n // pairing someone's \"No artifacts yet\" with a stock second line reads as a\n // component talking over its caller.\n const emptyDescription =\n emptyOverride.description ??\n (emptyMessage\n ? undefined\n : String(\n hasActiveFilters\n ? tr(\"dataTable.noMatchDescription\", {\n default: \"Try adjusting or clearing the filters.\",\n })\n : tr(\"dataTable.emptyDescription\", {\n default: \"Nothing here yet.\",\n }),\n ));\n\n const renderRow = (item: T, rowIndex: number) => {\n const key = rowKeys[rowIndex];\n const isSelected = selection.has(key);\n const isLeaving = leaving.has(key);\n const isActive = props.isRowActive?.(item) ?? false;\n return (\n <TableRow\n key={key}\n data-row-key={key}\n data-leaving={isLeaving || undefined}\n aria-hidden={isLeaving || undefined}\n aria-current={isActive || undefined}\n data-active={isActive || undefined}\n inert={isLeaving || undefined}\n onClick={() => props.onRowClick?.(item)}\n // Per row, both halves. Moving from one row to the next fires\n // the old row's `mouseleave` BEFORE the new row's `mouseenter`,\n // so the clear can never wipe the value the enter just set.\n onMouseEnter={() => props.onRowHover?.(item)}\n onMouseLeave={() => props.onRowHover?.(undefined)}\n className={cn(\n // Stays: the global cursor rule in `styles.css` covers\n // controls and menu items, and a `<tr>` is neither. It\n // is also conditional, which no blanket rule could be -\n // a row is only clickable when a handler was given.\n props.onRowClick && \"cursor-pointer\",\n props.striped && \"even:bg-muted/40\",\n isSelected && \"bg-hover-weak\",\n isActive && \"bg-hover hover:bg-hover\",\n )}\n >\n {hasCheckbox && (\n <TableCell\n className={props.cellClassName}\n onClick={(e) => e.stopPropagation()}\n >\n <Checkbox\n checked={isSelected}\n onCheckedChange={() => toggleRow(item)}\n aria-label={tr(\"dataTable.selectRow\", {\n default: \"Select row\",\n })}\n />\n </TableCell>\n )}\n {visibleCols.map(([key, def]) => (\n <TableCell\n key={key}\n className={cn(\n props.cellClassName,\n def.className,\n def.align === \"right\" && \"text-end\",\n def.align === \"center\" && \"text-center\",\n )}\n >\n {def.cell(item, props.cellContext)}\n </TableCell>\n ))}\n {hasRowActions && (\n <TableCell\n className={cn(props.cellClassName, \"text-end\")}\n onClick={(e) => e.stopPropagation()}\n >\n {props.rowActionsDisplay === \"inline\" ? (\n <DataTableRowActionsInline\n actions={props.rowActions!(item)}\n item={item}\n ctx={rowCtx}\n />\n ) : (\n <DataTableRowActionsMenu\n actions={props.rowActions!(item)}\n item={item}\n ctx={rowCtx}\n />\n )}\n </TableCell>\n )}\n </TableRow>\n );\n };\n\n // Groups in row order (or `groupBy.order`), each with its rows' indexes\n // into `data`, so a row keeps its key, selection and motion.\n const groups = props.groupBy ? groupRows(data, props.groupBy) : undefined;\n\n return (\n <TableBody ref={bodyRef}>\n {loading && data.length === 0 ? (\n <DataTableSkeletonRows\n cellClassName={props.cellClassName}\n rows={5}\n cols={\n visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0)\n }\n />\n ) : data.length === 0 ? (\n <TableRow className=\"hover:bg-transparent\">\n <TableCell\n colSpan={\n visibleCols.length +\n (hasCheckbox ? 1 : 0) +\n (hasRowActions ? 1 : 0)\n }\n // `h-full` and the cell's inherited `align-middle` are\n // what centre the state vertically. The chain is three\n // links long and every one is load-bearing: the scroller\n // above grows to the container, the `<table>` takes its\n // height, and this - the only body row - takes what the\n // header leaves. Break any of them and the state sits\n // tucked under the header instead of in the middle.\n //\n // `whitespace-normal` undoes the `whitespace-nowrap` every\n // cell carries, which is right for a data cell and wrong\n // for a sentence: the description would run off the side\n // and widen the table's own horizontal scroller.\n className=\"h-full p-0 whitespace-normal\"\n >\n {props.empty ?? (\n <div className=\"flex flex-col items-center justify-center gap-2 px-6 py-12 text-center\">\n <EmptyIcon className=\"text-muted-foreground size-8 opacity-40\" />\n <p className=\"text-foreground text-sm font-medium\">\n {emptyTitle}\n </p>\n {emptyDescription ? (\n <p className=\"text-muted-foreground max-w-xs text-sm text-balance\">\n {emptyDescription}\n </p>\n ) : null}\n {/* `pt-2` on top of the block's `gap-2`: the action is\n a separate beat from the sentence explaining it,\n and at one gap it reads as a third line of text. */}\n {emptyAction ? <div className=\"pt-2\">{emptyAction}</div> : null}\n </div>\n )}\n </TableCell>\n </TableRow>\n ) : groups ? (\n groups.map((group) => {\n const collapsed =\n (props.groupBy?.defaultCollapsed ?? false) !==\n flipped.has(group.key);\n return [\n <DataTableGroupRow\n key={`group:${group.key}`}\n groupKey={group.key}\n label={\n props.groupBy?.label\n ? props.groupBy.label(\n group.key,\n group.indexes.map((index) => data[index]),\n )\n : group.key\n }\n count={props.groupCounts?.[group.key] ?? group.indexes.length}\n collapsed={collapsed}\n colSpan={colSpan}\n cellClassName={props.cellClassName}\n onToggle={() =>\n setFlipped((previous) => {\n const next = new Set(previous);\n if (next.has(group.key)) next.delete(group.key);\n else next.add(group.key);\n return next;\n })\n }\n />,\n ...(collapsed\n ? []\n : group.indexes.map((index) => renderRow(data[index], index))),\n ];\n })\n ) : (\n data.map((item, rowIndex) => renderRow(item, rowIndex))\n )}\n </TableBody>\n );\n};\n\nconst NO_KEYS: ReadonlySet<string> = new Set();\nconst NO_FLASH = new Set<string>();\n\n/**\n * Splits the rows into the groups of a `groupBy`: in row order unless\n * `order` sorts the keys, each group holding its rows' indexes.\n */\nconst groupRows = <T,>(\n data: T[],\n groupBy: DataTableGroupBy<T>,\n): Array<{ key: string; indexes: number[] }> => {\n const groups = new Map<string, number[]>();\n data.forEach((item, index) => {\n const key = groupBy.key(item);\n const indexes = groups.get(key);\n if (indexes) indexes.push(index);\n else groups.set(key, [index]);\n });\n const keys = [...groups.keys()];\n if (groupBy.order) keys.sort(groupBy.order);\n return keys.map((key) => ({ key, indexes: groups.get(key)! }));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmGA,MAAa,iBAAqB,UAAiC;CACjE,MAAM,EACJ,MACA,SACA,SACA,aACA,aACA,eACA,kBACA,WACA,WACA,WACE;CACJ,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,UAAU,OAAgC,IAAI;CACpD,MAAM,UAAU,MAAM,WAAW;CAGjC,MAAM,CA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AO,KAAK,CAAC;CAC9B,IAAI,QAAQ,OAAO,KAAK,KAAK,QAAQ,KAAK;CAC1C,OAAO,KAAK,KAAK,SAAS;EAAE;EAAK,SAAS,OAAO,IAAI,GAAG;CAAG,EAAE;AAC/D"}
|
|
1
|
+
{"version":3,"file":"DataTableBody.js","names":[],"sources":["../../src/table/DataTableBody.tsx"],"sourcesContent":["import { useI18n } from \"alepha/react/i18n\";\nimport { Inbox, SearchX } from \"lucide-react\";\nimport { type ReactNode, useRef, useState } from \"react\";\n\nimport { Checkbox } from \"../core/Checkbox.tsx\";\nimport { TableBody, TableCell, TableRow } from \"../core/Table.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { DataTableGroupRow } from \"./DataTableGroupRow.tsx\";\nimport { splitPrimaryRowActions } from \"./DataTableRowActionPrimary.tsx\";\nimport { DataTableRowActionPrimary } from \"./DataTableRowActionPrimary.tsx\";\nimport { DataTableRowActionsInline } from \"./DataTableRowActionsInline.tsx\";\nimport { DataTableRowActionsMenu } from \"./DataTableRowActionsMenu.tsx\";\nimport { DataTableSkeletonRows } from \"./DataTableSkeletonRows.tsx\";\nimport type {\n DataTableCellContext,\n DataTableEmptyState,\n DataTableGroupBy,\n ColumnDef,\n RowActionContext,\n RowActionEntry,\n} from \"./dataTableTypes.ts\";\nimport { useRowMotion } from \"./useRowMotion.ts\";\n\nexport interface DataTableBodyProps<T> {\n /**\n * The table's `cellPadding` classes for a body cell, merged before a\n * column's own `className`.\n */\n cellClassName?: string;\n data: T[];\n /**\n * One key per row of `data`, index for index.\n */\n rowKeys: string[];\n /**\n * Rows an optimistic remove is taking off: drawn, inert, playing their\n * exit.\n */\n leaving?: ReadonlySet<string>;\n /**\n * Rows an optimistic patch just redrew, flashed once.\n */\n flash?: Set<string>;\n loading: boolean;\n /**\n * The visible columns, in the reader's order.\n */\n visibleCols: Array<[string, ColumnDef<T>]>;\n /**\n * Handed to every cell beside its row.\n */\n cellContext: DataTableCellContext;\n hasCheckbox: boolean;\n hasRowActions: boolean;\n /**\n * Whether a filter is set, which picks the no-match empty state over the\n * no-items one.\n */\n hasActiveFilters: boolean;\n /**\n * Whether the filters are the table's declared `initialValues`: an empty\n * page there keeps `emptyMessage`.\n */\n filtersAtDefault?: boolean;\n selection: ReadonlyMap<string, T>;\n toggleRow: (item: T) => void;\n rowCtx: RowActionContext;\n rowActions?: (item: T) => RowActionEntry<T>[];\n /**\n * The table's `rowActionsDisplay`.\n */\n rowActionsDisplay?: \"menu\" | \"inline\";\n /**\n * The table's `striped`.\n */\n striped?: boolean;\n onRowClick?: (item: T) => void;\n /**\n * The key of the row the keyboard focus is on (the table's `keyboard`),\n * drawn marked.\n */\n focusedKey?: string;\n /**\n * Called with a row's key when it is clicked, so a click moves the\n * keyboard focus there. Absent while `keyboard` is off.\n */\n onRowFocus?: (key: string) => void;\n /**\n * The table's `isRowActive`.\n */\n isRowActive?: (item: T) => boolean;\n onRowHover?: (item: T | undefined) => void;\n empty?: ReactNode;\n emptyMessage?: string;\n emptyState?: DataTableEmptyState;\n noMatchState?: DataTableEmptyState;\n /**\n * The table's `groupBy`: rows drawn under folding group headers.\n */\n groupBy?: DataTableGroupBy<T>;\n /**\n * Each group's row count over every page (static rows): what a group's\n * header shows when the table is paged. Absent, it counts the rows here.\n */\n groupCounts?: Record<string, number>;\n}\n\n/**\n * The table body: skeleton rows while the first page loads, the empty state\n * when the page came back empty, the rows otherwise.\n */\nexport const DataTableBody = <T,>(props: DataTableBodyProps<T>) => {\n const {\n data,\n rowKeys,\n loading,\n visibleCols,\n hasCheckbox,\n hasRowActions,\n hasActiveFilters,\n selection,\n toggleRow,\n rowCtx,\n } = props;\n const { tr } = useI18n();\n const bodyRef = useRef<HTMLTableSectionElement>(null);\n const leaving = props.leaving ?? NO_KEYS;\n // The groups the reader flipped from the default (open, or folded under\n // `defaultCollapsed`). Not stored: a reload shows the default again.\n const [flipped, setFlipped] = useState<ReadonlySet<string>>(NO_KEYS);\n const colSpan =\n visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0);\n useRowMotion({\n body: bodyRef,\n rowKeys,\n leaving,\n flash: props.flash ?? NO_FLASH,\n });\n\n // Which empty state applies, resolved here rather than in the JSX because\n // the answer is one boolean and the branch is four values deep.\n //\n // `hasActiveFilters` is already false whenever `props.filters` is unset, so\n // a table with no filter form can only ever reach the \"no items\" side.\n const emptyOverride =\n (hasActiveFilters ? props.noMatchState : props.emptyState) ?? {};\n const EmptyIcon = emptyOverride.icon ?? (hasActiveFilters ? SearchX : Inbox);\n // `emptyMessage` is the no-items title only (#Q3820): \"No epics yet.\" is\n // false of a list whose filter hid every row, so a filtered empty page\n // falls through to the no-match defaults.\n // A default view (`initialValues`) is the list as it is meant to be read,\n // not a reader's filter, so it keeps the message.\n const emptyMessage =\n hasActiveFilters && !props.filtersAtDefault\n ? undefined\n : props.emptyMessage;\n const emptyTitle =\n emptyOverride.title ??\n emptyMessage ??\n String(\n hasActiveFilters\n ? tr(\"dataTable.noMatchTitle\", { default: \"No match\" })\n : tr(\"dataTable.emptyTitle\", { default: \"No items\" }),\n );\n const emptyAction = emptyOverride.action;\n // Suppressed by a bare `emptyMessage`: that prop is the whole message, and\n // pairing someone's \"No artifacts yet\" with a stock second line reads as a\n // component talking over its caller.\n const emptyDescription =\n emptyOverride.description ??\n (emptyMessage\n ? undefined\n : String(\n hasActiveFilters\n ? tr(\"dataTable.noMatchDescription\", {\n default: \"Try adjusting or clearing the filters.\",\n })\n : tr(\"dataTable.emptyDescription\", {\n default: \"Nothing here yet.\",\n }),\n ));\n\n // The three-dots menu, after the `primary` actions drawn as labelled\n // buttons, which leave the menu.\n const renderMenuActions = (item: T) => {\n const { primary, rest } = splitPrimaryRowActions(props.rowActions!(item));\n if (primary.length === 0) {\n return (\n <DataTableRowActionsMenu actions={rest} item={item} ctx={rowCtx} />\n );\n }\n return (\n <div className=\"flex items-center justify-end gap-1\">\n {primary.map((action) => (\n <DataTableRowActionPrimary\n key={action.label}\n action={action}\n item={item}\n ctx={rowCtx}\n />\n ))}\n <DataTableRowActionsMenu actions={rest} item={item} ctx={rowCtx} />\n </div>\n );\n };\n\n const renderRow = (item: T, rowIndex: number) => {\n const key = rowKeys[rowIndex];\n const isSelected = selection.has(key);\n const isLeaving = leaving.has(key);\n const isActive = props.isRowActive?.(item) ?? false;\n const isFocused = props.focusedKey === key;\n return (\n <TableRow\n key={key}\n data-row-key={key}\n data-leaving={isLeaving || undefined}\n aria-hidden={isLeaving || undefined}\n aria-current={isActive || undefined}\n data-active={isActive || undefined}\n data-focused={isFocused || undefined}\n inert={isLeaving || undefined}\n onClick={() => {\n props.onRowFocus?.(key);\n props.onRowClick?.(item);\n }}\n // Per row, both halves. Moving from one row to the next fires\n // the old row's `mouseleave` BEFORE the new row's `mouseenter`,\n // so the clear can never wipe the value the enter just set.\n onMouseEnter={() => props.onRowHover?.(item)}\n onMouseLeave={() => props.onRowHover?.(undefined)}\n className={cn(\n // Stays: the global cursor rule in `styles.css` covers\n // controls and menu items, and a `<tr>` is neither. It\n // is also conditional, which no blanket rule could be -\n // a row is only clickable when a handler was given.\n props.onRowClick && \"cursor-pointer\",\n props.striped && \"even:bg-muted/40\",\n isSelected && \"bg-hover-weak\",\n isActive && \"bg-hover hover:bg-hover\",\n // The keyboard focus: a tint and a bar on the start edge. The bar\n // is on the first cell, since WebKit paints no `box-shadow` on a\n // table row.\n isFocused &&\n \"bg-hover-weak [&>td:first-child]:shadow-[inset_2px_0_0_0_var(--primary)]\",\n )}\n >\n {hasCheckbox && (\n <TableCell\n className={props.cellClassName}\n onClick={(e) => e.stopPropagation()}\n >\n <Checkbox\n checked={isSelected}\n onCheckedChange={() => toggleRow(item)}\n aria-label={tr(\"dataTable.selectRow\", {\n default: \"Select row\",\n })}\n />\n </TableCell>\n )}\n {visibleCols.map(([key, def]) => (\n <TableCell\n key={key}\n className={cn(\n props.cellClassName,\n def.className,\n def.align === \"right\" && \"text-end\",\n def.align === \"center\" && \"text-center\",\n )}\n >\n {def.cell(item, props.cellContext)}\n </TableCell>\n ))}\n {hasRowActions && (\n <TableCell\n className={cn(props.cellClassName, \"text-end\")}\n onClick={(e) => e.stopPropagation()}\n >\n {props.rowActionsDisplay === \"inline\" ? (\n <DataTableRowActionsInline\n actions={props.rowActions!(item)}\n item={item}\n ctx={rowCtx}\n />\n ) : (\n renderMenuActions(item)\n )}\n </TableCell>\n )}\n </TableRow>\n );\n };\n\n // Groups in row order (or `groupBy.order`), each with its rows' indexes\n // into `data`, so a row keeps its key, selection and motion.\n const groups = props.groupBy ? groupRows(data, props.groupBy) : undefined;\n\n return (\n <TableBody ref={bodyRef}>\n {loading && data.length === 0 ? (\n <DataTableSkeletonRows\n cellClassName={props.cellClassName}\n rows={5}\n cols={\n visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0)\n }\n />\n ) : data.length === 0 ? (\n <TableRow className=\"hover:bg-transparent\">\n <TableCell\n colSpan={\n visibleCols.length +\n (hasCheckbox ? 1 : 0) +\n (hasRowActions ? 1 : 0)\n }\n // `h-full` and the cell's inherited `align-middle` are\n // what centre the state vertically. The chain is three\n // links long and every one is load-bearing: the scroller\n // above grows to the container, the `<table>` takes its\n // height, and this - the only body row - takes what the\n // header leaves. Break any of them and the state sits\n // tucked under the header instead of in the middle.\n //\n // `whitespace-normal` undoes the `whitespace-nowrap` every\n // cell carries, which is right for a data cell and wrong\n // for a sentence: the description would run off the side\n // and widen the table's own horizontal scroller.\n className=\"h-full p-0 whitespace-normal\"\n >\n {props.empty ?? (\n <div className=\"flex flex-col items-center justify-center gap-2 px-6 py-12 text-center\">\n <EmptyIcon className=\"text-muted-foreground size-8 opacity-40\" />\n <p className=\"text-foreground text-sm font-medium\">\n {emptyTitle}\n </p>\n {emptyDescription ? (\n <p className=\"text-muted-foreground max-w-xs text-sm text-balance\">\n {emptyDescription}\n </p>\n ) : null}\n {/* `pt-2` on top of the block's `gap-2`: the action is\n a separate beat from the sentence explaining it,\n and at one gap it reads as a third line of text. */}\n {emptyAction ? <div className=\"pt-2\">{emptyAction}</div> : null}\n </div>\n )}\n </TableCell>\n </TableRow>\n ) : groups ? (\n groups.map((group) => {\n const collapsed =\n (props.groupBy?.defaultCollapsed ?? false) !==\n flipped.has(group.key);\n return [\n <DataTableGroupRow\n key={`group:${group.key}`}\n groupKey={group.key}\n label={\n props.groupBy?.label\n ? props.groupBy.label(\n group.key,\n group.indexes.map((index) => data[index]),\n )\n : group.key\n }\n count={props.groupCounts?.[group.key] ?? group.indexes.length}\n collapsed={collapsed}\n colSpan={colSpan}\n cellClassName={props.cellClassName}\n onToggle={() =>\n setFlipped((previous) => {\n const next = new Set(previous);\n if (next.has(group.key)) next.delete(group.key);\n else next.add(group.key);\n return next;\n })\n }\n />,\n ...(collapsed\n ? []\n : group.indexes.map((index) => renderRow(data[index], index))),\n ];\n })\n ) : (\n data.map((item, rowIndex) => renderRow(item, rowIndex))\n )}\n </TableBody>\n );\n};\n\nconst NO_KEYS: ReadonlySet<string> = new Set();\nconst NO_FLASH = new Set<string>();\n\n/**\n * Splits the rows into the groups of a `groupBy`: in row order unless\n * `order` sorts the keys, each group holding its rows' indexes.\n */\nconst groupRows = <T,>(\n data: T[],\n groupBy: DataTableGroupBy<T>,\n): Array<{ key: string; indexes: number[] }> => {\n const groups = new Map<string, number[]>();\n data.forEach((item, index) => {\n const key = groupBy.key(item);\n const indexes = groups.get(key);\n if (indexes) indexes.push(index);\n else groups.set(key, [index]);\n });\n const keys = [...groups.keys()];\n if (groupBy.order) keys.sort(groupBy.order);\n return keys.map((key) => ({ key, indexes: groups.get(key)! }));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+GA,MAAa,iBAAqB,UAAiC;CACjE,MAAM,EACJ,MACA,SACA,SACA,aACA,aACA,eACA,kBACA,WACA,WACA,WACE;CACJ,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,UAAU,OAAgC,IAAI;CACpD,MAAM,UAAU,MAAM,WAAW;CAGjC,MAAM,CAAC,SAAS,c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":3,"file":"DataTableBulkBar.d.ts","sourceRoot":"","sources":["../../src/table/DataTableBulkBar.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC;;;OAGG;IACH,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClC,aAAa,EAAE,CAAC,EAAE,CAAC;IACnB;;;OAGG;IACH,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,EAAE,iBAAiB,CAAC;IAC3B,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAU,qBAAqB,CAAC,CAAC,CAAC,gCAiGnE,CAAC"}
|