@eifi1/ui-kit 0.51.3 → 0.51.5
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/README.md +6 -6
- package/dist/account/account-settings-labels.js.map +1 -1
- package/dist/account/account-settings.js +11 -9
- package/dist/account/account-settings.js.map +1 -1
- package/dist/account/delete-account-setting.js +56 -65
- package/dist/account/delete-account-setting.js.map +1 -1
- package/dist/account/email-change-setting-labels.js.map +1 -1
- package/dist/account/email-change-setting.js.map +1 -1
- package/dist/account/passkeys-setting.js.map +1 -1
- package/dist/account/sessions-setting.js.map +1 -1
- package/dist/admin/admin-action-confirm.js +1 -3
- package/dist/admin/admin-action-confirm.js.map +1 -1
- package/dist/admin/admin-action-log.js.map +1 -1
- package/dist/admin/admin-area-labels.js +4 -1
- package/dist/admin/admin-area-labels.js.map +1 -1
- package/dist/admin/admin-overview.js +19 -11
- package/dist/admin/admin-overview.js.map +1 -1
- package/dist/admin/admin-sections.js.map +1 -1
- package/dist/admin/admin-tool-links.d.ts +1 -1
- package/dist/admin/admin-tool-links.js +7 -1
- package/dist/admin/admin-tool-links.js.map +1 -1
- package/dist/admin/invitations-panel.js +2 -13
- package/dist/admin/invitations-panel.js.map +1 -1
- package/dist/admin/mail-test-card.js.map +1 -1
- package/dist/admin/reviewer-scope-editor.js +4 -11
- package/dist/admin/reviewer-scope-editor.js.map +1 -1
- package/dist/admin/role-select.js.map +1 -1
- package/dist/admin/user-roster.js +1 -9
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/auth/accept-invitation.js.map +1 -1
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/forgot-password-form.js +23 -31
- package/dist/auth/forgot-password-form.js.map +1 -1
- package/dist/auth/register-form.js.map +1 -1
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/sign-in-form.js +13 -5
- package/dist/auth/sign-in-form.js.map +1 -1
- package/dist/auth/verify-email.js +1 -8
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/billing-labels.js.map +1 -1
- package/dist/billing/checkout-processing.js.map +1 -1
- package/dist/billing/plan-card.js +91 -85
- package/dist/billing/plan-card.js.map +1 -1
- package/dist/billing/plan-limit-toast.js.map +1 -1
- package/dist/billing/plan-limit.js.map +1 -1
- package/dist/billing/plan-price.js.map +1 -1
- package/dist/billing/plan-switch.js.map +1 -1
- package/dist/billing/subscription-actions.js.map +1 -1
- package/dist/bin/eifi1-pay-page.mjs +6 -1
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/alert-banner.js +1 -5
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.js +29 -12
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.js.map +1 -1
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bulk-action-bar.js +1 -4
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/button.js +1 -7
- package/dist/components/button.js.map +1 -1
- package/dist/components/calculator.js +5 -5
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/calendar-heatmap.js +4 -10
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/card.js +1 -8
- package/dist/components/card.js.map +1 -1
- package/dist/components/chart-zoom-core.js +3 -17
- package/dist/components/chart-zoom-core.js.map +1 -1
- package/dist/components/chart.d.ts +1 -1
- package/dist/components/chart.js +4 -22
- package/dist/components/chart.js.map +1 -1
- package/dist/components/checkbox-group.js +1 -4
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/chip-input.js +4 -1
- package/dist/components/chip-input.js.map +1 -1
- package/dist/components/chip.js +10 -5
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.js +58 -74
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/column-mapper-labels.js.map +1 -1
- package/dist/components/column-mapper.js +167 -227
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox-core.js +5 -9
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.js +1 -4
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/country-select.d.ts +5 -4
- package/dist/components/country-select.js +3 -19
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-option-list.js +13 -11
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.js +1 -6
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-cells.js.map +1 -1
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-filter-popover.js +2 -18
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-fit.js +7 -5
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-groups.js +3 -1
- package/dist/components/data-table-groups.js.map +1 -1
- package/dist/components/data-table-head.js +49 -57
- package/dist/components/data-table-head.js.map +1 -1
- package/dist/components/data-table-mobile.js +31 -44
- package/dist/components/data-table-mobile.js.map +1 -1
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table-row-actions.js +19 -16
- package/dist/components/data-table-row-actions.js.map +1 -1
- package/dist/components/data-table-row.js.map +1 -1
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table-sort.js.map +1 -1
- package/dist/components/data-table-virtual.js +4 -1
- package/dist/components/data-table-virtual.js.map +1 -1
- package/dist/components/data-table.d.ts +8 -0
- package/dist/components/data-table.js +30 -39
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +1 -6
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/description-list.js +10 -10
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.js +9 -2
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.js +17 -27
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/dropdown.js +25 -35
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/field-base.js +5 -5
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-parts.d.ts +1 -1
- package/dist/components/field-parts.js +10 -14
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-sync.js +8 -10
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.js +4 -1
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/focus-ring.js.map +1 -1
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/grouped-picker.js +11 -12
- package/dist/components/grouped-picker.js.map +1 -1
- package/dist/components/hover-menu.js +1 -4
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/iban-input-labels.js.map +1 -1
- package/dist/components/icon-button.js +4 -1
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/icon-picker.js +6 -10
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/image-grid.js +41 -50
- package/dist/components/image-grid.js.map +1 -1
- package/dist/components/inline-edit-field.js.map +1 -1
- package/dist/components/inline-entity-combobox.js +6 -12
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.js +14 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/jump-calendar.js +1 -7
- package/dist/components/jump-calendar.js.map +1 -1
- package/dist/components/legal-labels.js +8 -2
- package/dist/components/legal-labels.js.map +1 -1
- package/dist/components/legal-page.d.ts +18 -1
- package/dist/components/legal-page.js +27 -2
- package/dist/components/legal-page.js.map +1 -1
- package/dist/components/legal.d.ts +40 -5
- package/dist/components/legal.js +41 -5
- package/dist/components/legal.js.map +1 -1
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/line-items.js +26 -36
- package/dist/components/line-items.js.map +1 -1
- package/dist/components/list-labels.js +3 -1
- package/dist/components/list-labels.js.map +1 -1
- package/dist/components/list.d.ts +18 -1
- package/dist/components/list.js +54 -13
- package/dist/components/list.js.map +1 -1
- package/dist/components/measured-grid.js +29 -53
- package/dist/components/measured-grid.js.map +1 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.js +13 -31
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.js +10 -21
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.js +3 -16
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/nav-pills.js +10 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.js +1 -7
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.js +1 -4
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/one-time-code-input.js +1 -7
- package/dist/components/one-time-code-input.js.map +1 -1
- package/dist/components/page-contents.js +13 -22
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.js +1 -11
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/password-strength-labels.js.map +1 -1
- package/dist/components/password-strength.js +2 -8
- package/dist/components/password-strength.js.map +1 -1
- package/dist/components/phone-input.js +42 -57
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart.js +1 -8
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress-bar.js +16 -9
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.js +1 -8
- package/dist/components/qr-code.js.map +1 -1
- package/dist/components/row-actions.js +5 -1
- package/dist/components/row-actions.js.map +1 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/select.js +28 -38
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.js +1 -5
- package/dist/components/separator.js.map +1 -1
- package/dist/components/series-chart-axes.js +4 -1
- package/dist/components/series-chart-axes.js.map +1 -1
- package/dist/components/series-chart-budget.js.map +1 -1
- package/dist/components/series-chart-ticks.js.map +1 -1
- package/dist/components/series-chart.js +29 -45
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.js +21 -17
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/share-card.js +4 -9
- package/dist/components/share-card.js.map +1 -1
- package/dist/components/sign-chip.js.map +1 -1
- package/dist/components/signature-pad.js +4 -13
- package/dist/components/signature-pad.js.map +1 -1
- package/dist/components/signed-amount.js +12 -5
- package/dist/components/signed-amount.js.map +1 -1
- package/dist/components/skeleton.js +2 -17
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.js +13 -36
- package/dist/components/slider.js.map +1 -1
- package/dist/components/sparkline.js.map +1 -1
- package/dist/components/stat-tile.js +14 -10
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swatch-picker.js +14 -4
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +1 -1
- package/dist/components/swipeable-row.js +1 -8
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/table-skeleton.js +4 -1
- package/dist/components/table-skeleton.js.map +1 -1
- package/dist/components/table.js +12 -9
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +5 -24
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/text-link.js.map +1 -1
- package/dist/components/text.js.map +1 -1
- package/dist/components/tile-radio.js +1 -7
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.js.map +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.js +6 -1
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.js +2 -11
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/tooltip.js +2 -22
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review-editor.js +1 -4
- package/dist/components/translation-review-editor.js.map +1 -1
- package/dist/components/translation-review-parts.d.ts +1 -1
- package/dist/components/translation-review-parts.js +7 -1
- package/dist/components/translation-review-parts.js.map +1 -1
- package/dist/components/translation-review.js +18 -7
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/tree-view.js +14 -10
- package/dist/components/tree-view.js.map +1 -1
- package/dist/components/treemap.js +1 -13
- package/dist/components/treemap.js.map +1 -1
- package/dist/components/trigger-aria.js.map +1 -1
- package/dist/components/use-table-state.js +14 -11
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.js +3 -26
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/demo/demo-start.js +8 -4
- package/dist/demo/demo-start.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-attachment-labels.js.map +1 -1
- package/dist/feedback/feedback-attachment.js +1 -8
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-capture.d.ts +1 -1
- package/dist/feedback/feedback-capture.js +3 -1
- package/dist/feedback/feedback-capture.js.map +1 -1
- package/dist/feedback/feedback-comment-thread.js +27 -13
- package/dist/feedback/feedback-comment-thread.js.map +1 -1
- package/dist/feedback/feedback-context.js +1 -4
- package/dist/feedback/feedback-context.js.map +1 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-public-list.js +7 -1
- package/dist/feedback/feedback-public-list.js.map +1 -1
- package/dist/feedback/feedback-record.js +1 -5
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-replies.js +25 -10
- package/dist/feedback/feedback-replies.js.map +1 -1
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-status-undo.js.map +1 -1
- package/dist/feedback/feedback-submit-dialog.js.map +1 -1
- package/dist/feedback/feedback-table.d.ts +3 -1
- package/dist/feedback/feedback-table.js +22 -5
- package/dist/feedback/feedback-table.js.map +1 -1
- package/dist/feedback/feedback-thread.js +2 -13
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/feedback/feedback-vocabulary.js.map +1 -1
- package/dist/feedback/feedback-vote-button.js.map +1 -1
- package/dist/hooks/use-anchored-rect.js.map +1 -1
- package/dist/hooks/use-document-title.js.map +1 -1
- package/dist/hooks/use-file-drop.js.map +1 -1
- package/dist/hooks/use-file-picker-labels.js.map +1 -1
- package/dist/hooks/use-file-picker.js.map +1 -1
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +10 -5
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/hooks/use-row-swipe.d.ts +1 -1
- package/dist/hooks/use-row-swipe.js +1 -6
- package/dist/hooks/use-row-swipe.js.map +1 -1
- package/dist/i18n/defaults.js +1 -4
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +15 -4
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.js +2 -8
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.js.map +1 -1
- package/dist/i18n/locales/en.js +19 -4
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/es.js +15 -4
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +15 -4
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +15 -4
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +15 -4
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +11 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/plurals.js.map +1 -1
- package/dist/i18n/review.js +15 -7
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.js +40 -23
- package/dist/index.js.map +1 -1
- package/dist/landing/access.js +1 -4
- package/dist/landing/access.js.map +1 -1
- package/dist/landing/landing-sections.js +35 -38
- package/dist/landing/landing-sections.js.map +1 -1
- package/dist/landing/page-seo.js.map +1 -1
- package/dist/lib/calc.js.map +1 -1
- package/dist/lib/clipboard-minus.js.map +1 -1
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/decimal-marks.js.map +1 -1
- package/dist/lib/device-settings.js +2 -1
- package/dist/lib/device-settings.js.map +1 -1
- package/dist/lib/direction.js.map +1 -1
- package/dist/lib/iban.js.map +1 -1
- package/dist/lib/logger.js +1 -5
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/person-name.js.map +1 -1
- package/dist/lib/phone.js.map +1 -1
- package/dist/lib/qr-encode.js +344 -8
- package/dist/lib/qr-encode.js.map +1 -1
- package/dist/lib/session-refresh.js.map +1 -1
- package/dist/lib/table-text.js +15 -3
- package/dist/lib/table-text.js.map +1 -1
- package/dist/lib/text-match.d.ts +20 -0
- package/dist/lib/text-match.js +11 -1
- package/dist/lib/text-match.js.map +1 -1
- package/dist/lib/translation-review.js.map +1 -1
- package/dist/notifications/notification-inbox.js +63 -44
- package/dist/notifications/notification-inbox.js.map +1 -1
- package/dist/notifications/notification-parts.js.map +1 -1
- package/dist/notifications/notification-types-setting.js.map +1 -1
- package/dist/notifications/notifications-labels.js.map +1 -1
- package/dist/notifications/push-device-setting.js +6 -1
- package/dist/notifications/push-device-setting.js.map +1 -1
- package/dist/notifications/push-devices-setting.js.map +1 -1
- package/dist/notifications/push-worker.js.map +1 -1
- package/dist/notifications/quiet-hours-setting.js.map +1 -1
- package/dist/notifications/use-push-device.js +4 -1
- package/dist/notifications/use-push-device.js.map +1 -1
- package/dist/offline/pwa-update-prompt.d.ts +1 -1
- package/dist/offline/pwa-update-prompt.js +7 -1
- package/dist/offline/pwa-update-prompt.js.map +1 -1
- package/dist/offline/query-persistence.js.map +1 -1
- package/dist/offline.d.ts +1 -1
- package/dist/offline.js +6 -1
- package/dist/offline.js.map +1 -1
- package/dist/pay/pay.css +8 -1
- package/dist/rhf/fields.d.ts +1 -2
- package/dist/rhf/fields.js +1 -10
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form-core.js +1 -4
- package/dist/rhf/form-core.js.map +1 -1
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
- package/dist/search/command-palette.js +71 -62
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.js +34 -5
- package/dist/search/global-search.js.map +1 -1
- package/dist/search/search-index.js.map +1 -1
- package/dist/settings/device-reset-setting.js +1 -6
- package/dist/settings/device-reset-setting.js.map +1 -1
- package/dist/settings/settings-heading.js.map +1 -1
- package/dist/settings/settings-layout.js +9 -20
- package/dist/settings/settings-layout.js.map +1 -1
- package/dist/settings/use-settings-focus.d.ts +7 -0
- package/dist/settings/use-settings-focus.js +2 -0
- package/dist/settings/use-settings-focus.js.map +1 -1
- package/dist/settings/use-settings-route.js.map +1 -1
- package/dist/shell/app-shell.js +62 -31
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.js +1 -10
- package/dist/shell/auth-layout.js.map +1 -1
- package/dist/shell/dev-menu.d.ts +5 -0
- package/dist/shell/dev-menu.js +14 -7
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/sync-status-indicator.js +7 -6
- package/dist/shell/sync-status-indicator.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +14 -1
- package/dist/shell/topbar-action-menu.js +85 -34
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.js +1 -10
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/shell/tour-menu.js +9 -1
- package/dist/shell/tour-menu.js.map +1 -1
- package/dist/shell.d.ts +1 -1
- package/dist/shell.js +2 -1
- package/dist/shell.js.map +1 -1
- package/dist/sync/db.js.map +1 -1
- package/dist/sync/engine.js +24 -6
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync.d.ts +2 -2
- package/dist/sync.js +7 -1
- package/dist/sync.js.map +1 -1
- package/dist/testing/css-variables.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -3
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/react.js.map +1 -1
- package/dist/testing/viewport.js +7 -4
- package/dist/testing/viewport.js.map +1 -1
- package/dist/theme/contrast-tokens.js +13 -2
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/palette-derive.d.ts +1 -1
- package/dist/theme/palette-derive.js +18 -29
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.js.map +1 -1
- package/dist/theme/theme-store.js +1 -3
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/tour/tour-catalogue.js.map +1 -1
- package/dist/tour/tour-dock.js +5 -1
- package/dist/tour/tour-dock.js.map +1 -1
- package/dist/tour/tour-engine.js +1 -4
- package/dist/tour/tour-engine.js.map +1 -1
- package/dist/tour/tour.js +21 -12
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour/use-tour-progress.js.map +1 -1
- package/dist/tour/use-tour-url-sync.js.map +1 -1
- package/dist/wizard/stepper-nav.js +3 -24
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +24 -28
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/validation.js.map +1 -1
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +1 -1
- package/dist/wizard/wizard-step.js +1 -8
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/package.json +5 -2
- package/src/account/account-settings-labels.ts +1 -2
- package/src/account/account-settings.tsx +11 -17
- package/src/account/delete-account-setting.tsx +1 -6
- package/src/account/email-change-setting-labels.ts +1 -2
- package/src/account/email-change-setting.tsx +3 -1
- package/src/account/passkeys-setting.tsx +1 -3
- package/src/account/sessions-setting.tsx +4 -2
- package/src/admin/admin-action-confirm.tsx +4 -7
- package/src/admin/admin-action-log.tsx +29 -29
- package/src/admin/admin-area-labels.ts +4 -1
- package/src/admin/admin-overview.tsx +8 -2
- package/src/admin/admin-sections.tsx +3 -1
- package/src/admin/admin-tool-links.tsx +7 -1
- package/src/admin/invitations-panel.tsx +5 -11
- package/src/admin/mail-test-card.tsx +1 -2
- package/src/admin/reviewer-scope-editor.tsx +4 -9
- package/src/admin/role-select.tsx +4 -2
- package/src/admin/user-roster.tsx +2 -11
- package/src/auth/accept-invitation.tsx +1 -7
- package/src/auth/auth-errors.ts +1 -6
- package/src/auth/forgot-password-form.tsx +2 -7
- package/src/auth/register-form.tsx +7 -8
- package/src/auth/reset-password-form.tsx +2 -5
- package/src/auth/sign-in-form.tsx +15 -14
- package/src/auth/verify-email.tsx +2 -7
- package/src/billing/billing-banner.tsx +3 -7
- package/src/billing/billing-labels.ts +6 -4
- package/src/billing/checkout-processing.ts +0 -1
- package/src/billing/plan-card.tsx +9 -8
- package/src/billing/plan-limit-toast.tsx +1 -2
- package/src/billing/plan-limit.ts +1 -2
- package/src/billing/plan-price.ts +1 -4
- package/src/billing/plan-switch.tsx +1 -2
- package/src/billing/subscription-actions.tsx +5 -2
- package/src/components/account-chips.tsx +1 -7
- package/src/components/alert-banner.tsx +2 -8
- package/src/components/amount-input.tsx +206 -178
- package/src/components/authed-image.tsx +7 -4
- package/src/components/autocomplete.tsx +7 -9
- package/src/components/bulk-action-bar.tsx +2 -7
- package/src/components/button-group.tsx +1 -2
- package/src/components/button-look.ts +6 -17
- package/src/components/button.tsx +1 -4
- package/src/components/calculator.tsx +6 -9
- package/src/components/calendar-heatmap.tsx +5 -10
- package/src/components/card.tsx +9 -13
- package/src/components/chart-zoom-core.tsx +6 -33
- package/src/components/chart.tsx +8 -31
- package/src/components/checkbox-group.tsx +1 -4
- package/src/components/chip-input.tsx +6 -6
- package/src/components/chip.tsx +14 -26
- package/src/components/choice-card.tsx +4 -18
- package/src/components/column-mapper-labels.ts +3 -10
- package/src/components/column-mapper.tsx +33 -122
- package/src/components/combobox-core.tsx +17 -47
- package/src/components/combobox.tsx +2 -6
- package/src/components/confirm-dialog.tsx +1 -3
- package/src/components/copy-button.tsx +2 -4
- package/src/components/country-select.tsx +9 -21
- package/src/components/currency-option-list.tsx +16 -18
- package/src/components/currency-select.tsx +2 -7
- package/src/components/danger-confirm.tsx +8 -9
- package/src/components/data-table-cells.tsx +1 -2
- package/src/components/data-table-column-settings.tsx +1 -3
- package/src/components/data-table-filter-popover.tsx +5 -19
- package/src/components/data-table-filters.ts +1 -6
- package/src/components/data-table-fit.ts +7 -7
- package/src/components/data-table-groups.tsx +3 -1
- package/src/components/data-table-head.tsx +32 -46
- package/src/components/data-table-mobile.tsx +99 -108
- package/src/components/data-table-pagination.tsx +2 -6
- package/src/components/data-table-row-actions.tsx +25 -24
- package/src/components/data-table-row.tsx +16 -17
- package/src/components/data-table-shared.tsx +10 -16
- package/src/components/data-table-sort.ts +1 -2
- package/src/components/data-table-virtual.ts +9 -4
- package/src/components/data-table.tsx +497 -501
- package/src/components/date-picker.tsx +1 -7
- package/src/components/date-range-picker.tsx +3 -13
- package/src/components/description-list.tsx +7 -13
- package/src/components/dialog-frame.tsx +12 -3
- package/src/components/disclosure.tsx +8 -12
- package/src/components/dropdown.tsx +3 -11
- package/src/components/empty-state.tsx +1 -3
- package/src/components/entity-combobox.tsx +2 -6
- package/src/components/error-boundary.tsx +7 -7
- package/src/components/field-base.tsx +8 -14
- package/src/components/field-parts.tsx +12 -23
- package/src/components/field-sync.tsx +7 -11
- package/src/components/file-button.tsx +7 -3
- package/src/components/file-dropzone.tsx +7 -12
- package/src/components/floating-panel.tsx +44 -51
- package/src/components/focus-ring.ts +1 -2
- package/src/components/form-actions.tsx +1 -4
- package/src/components/grouped-picker.tsx +21 -16
- package/src/components/hover-menu.tsx +1 -4
- package/src/components/iban-input-labels.ts +1 -2
- package/src/components/icon-button.tsx +46 -48
- package/src/components/icon-picker.tsx +9 -20
- package/src/components/image-grid.tsx +1 -6
- package/src/components/inline-edit-field.tsx +1 -5
- package/src/components/inline-entity-combobox.tsx +11 -25
- package/src/components/input.tsx +14 -2
- package/src/components/jump-calendar.tsx +2 -6
- package/src/components/legal-labels.ts +8 -3
- package/src/components/legal-page.tsx +56 -6
- package/src/components/legal.tsx +83 -10
- package/src/components/lightbox.tsx +1 -3
- package/src/components/line-items.tsx +7 -15
- package/src/components/list-labels.ts +2 -0
- package/src/components/list.tsx +81 -27
- package/src/components/measured-grid.tsx +8 -30
- package/src/components/menu-item.tsx +1 -3
- package/src/components/mini-calendar.tsx +129 -159
- package/src/components/money-field.tsx +4 -2
- package/src/components/month-picker.tsx +14 -21
- package/src/components/multi-entity-combobox.tsx +6 -26
- package/src/components/multi-select.tsx +5 -9
- package/src/components/nav-pills.tsx +10 -2
- package/src/components/number-field.tsx +18 -15
- package/src/components/number-input.tsx +3 -19
- package/src/components/numpad-sheet.tsx +9 -13
- package/src/components/one-time-code-input.tsx +6 -11
- package/src/components/page-contents.tsx +2 -9
- package/src/components/page-header.tsx +5 -10
- package/src/components/password-strength-labels.ts +1 -2
- package/src/components/password-strength.tsx +6 -9
- package/src/components/phone-input.tsx +2 -13
- package/src/components/picker-sheet.tsx +2 -5
- package/src/components/pie-chart.tsx +6 -12
- package/src/components/popover.tsx +2 -1
- package/src/components/progress-bar.tsx +16 -25
- package/src/components/qr-code.tsx +2 -9
- package/src/components/row-actions.tsx +9 -1
- package/src/components/search-field.tsx +4 -5
- package/src/components/select.tsx +2 -10
- package/src/components/separator.tsx +1 -5
- package/src/components/series-chart-axes.ts +5 -5
- package/src/components/series-chart-budget.ts +1 -4
- package/src/components/series-chart-ticks.ts +1 -4
- package/src/components/series-chart.tsx +43 -83
- package/src/components/settings-fields.tsx +20 -15
- package/src/components/share-card.tsx +6 -14
- package/src/components/sign-chip.tsx +16 -16
- package/src/components/signature-pad.tsx +21 -13
- package/src/components/signed-amount.tsx +6 -14
- package/src/components/skeleton.tsx +2 -13
- package/src/components/slider.tsx +9 -20
- package/src/components/sparkline.tsx +2 -13
- package/src/components/stat-tile.tsx +13 -24
- package/src/components/swatch-picker.tsx +8 -3
- package/src/components/swipeable-row.tsx +2 -11
- package/src/components/table-skeleton.tsx +4 -1
- package/src/components/table.tsx +12 -8
- package/src/components/tabs.tsx +24 -39
- package/src/components/text-link.tsx +6 -6
- package/src/components/text.tsx +1 -2
- package/src/components/tile-radio.tsx +6 -19
- package/src/components/time-input.tsx +4 -5
- package/src/components/toast.tsx +3 -12
- package/src/components/toggle-group.tsx +9 -9
- package/src/components/toggle-legend.tsx +4 -16
- package/src/components/tooltip.tsx +9 -48
- package/src/components/translation-review-editor.tsx +4 -4
- package/src/components/translation-review-parts.tsx +7 -1
- package/src/components/translation-review.tsx +15 -16
- package/src/components/tree-view.tsx +17 -20
- package/src/components/treemap.tsx +3 -15
- package/src/components/trigger-aria.ts +1 -4
- package/src/components/use-table-state.ts +16 -17
- package/src/components/user-avatar.tsx +4 -21
- package/src/demo/demo-start.tsx +8 -4
- package/src/feedback/feedback-attachment-labels.ts +2 -1
- package/src/feedback/feedback-attachment.tsx +16 -29
- package/src/feedback/feedback-capture.ts +3 -1
- package/src/feedback/feedback-comment-thread.tsx +9 -6
- package/src/feedback/feedback-context.tsx +1 -4
- package/src/feedback/feedback-dialog.tsx +3 -4
- package/src/feedback/feedback-inbox.tsx +3 -9
- package/src/feedback/feedback-public-list.tsx +7 -1
- package/src/feedback/feedback-record.ts +6 -14
- package/src/feedback/feedback-replies.tsx +10 -5
- package/src/feedback/feedback-row-detail.tsx +2 -5
- package/src/feedback/feedback-status-undo.ts +1 -4
- package/src/feedback/feedback-submit-dialog.tsx +4 -4
- package/src/feedback/feedback-table.tsx +29 -9
- package/src/feedback/feedback-thread.tsx +4 -16
- package/src/feedback/feedback-vocabulary.ts +72 -82
- package/src/feedback/feedback-vote-button.tsx +9 -8
- package/src/hooks/use-anchored-rect.ts +1 -4
- package/src/hooks/use-document-title.ts +3 -1
- package/src/hooks/use-file-drop.ts +1 -3
- package/src/hooks/use-file-picker-labels.ts +1 -2
- package/src/hooks/use-file-picker.tsx +1 -5
- package/src/hooks/use-focus-trap.ts +1 -2
- package/src/hooks/use-overlay-history.ts +10 -5
- package/src/hooks/use-row-swipe.ts +1 -6
- package/src/i18n/defaults.ts +1 -4
- package/src/i18n/german.ts +42 -50
- package/src/i18n/kit-labels.tsx +5 -20
- package/src/i18n/languages.ts +2 -8
- package/src/i18n/locales/en.ts +15 -31
- package/src/i18n/locales/es.ts +44 -50
- package/src/i18n/locales/fr.ts +43 -52
- package/src/i18n/locales/hu.ts +35 -38
- package/src/i18n/locales/it.ts +44 -53
- package/src/i18n/locales/zh.ts +23 -33
- package/src/i18n/plurals.ts +4 -1
- package/src/i18n/review.ts +20 -7
- package/src/i18n/shared-labels.ts +1 -2
- package/src/index.ts +107 -32
- package/src/landing/access.ts +2 -7
- package/src/landing/landing-sections.tsx +14 -15
- package/src/landing/page-seo.ts +1 -3
- package/src/lib/calc.ts +4 -1
- package/src/lib/clipboard-minus.ts +4 -1
- package/src/lib/dates.ts +2 -10
- package/src/lib/decimal-marks.ts +1 -3
- package/src/lib/device-settings.ts +2 -1
- package/src/lib/direction.ts +1 -3
- package/src/lib/iban.ts +89 -9
- package/src/lib/logger.ts +1 -5
- package/src/lib/person-name.ts +1 -3
- package/src/lib/phone.ts +5 -8
- package/src/lib/qr-encode.ts +32 -8
- package/src/lib/session-refresh.ts +5 -6
- package/src/lib/table-text.ts +24 -6
- package/src/lib/text-match.ts +43 -1
- package/src/lib/translation-review.ts +1 -3
- package/src/notifications/notification-inbox.tsx +17 -4
- package/src/notifications/notification-parts.tsx +1 -2
- package/src/notifications/notification-types-setting.tsx +19 -18
- package/src/notifications/notifications-labels.ts +1 -2
- package/src/notifications/push-device-setting.tsx +7 -1
- package/src/notifications/push-devices-setting.tsx +7 -3
- package/src/notifications/push-worker.ts +10 -2
- package/src/notifications/quiet-hours-setting.tsx +4 -1
- package/src/notifications/use-push-device.ts +4 -1
- package/src/offline/pwa-update-prompt.tsx +7 -1
- package/src/offline/query-persistence.ts +9 -6
- package/src/offline.ts +6 -1
- package/src/rhf/fields.tsx +50 -19
- package/src/rhf/form-core.tsx +2 -6
- package/src/rhf/line-items.tsx +5 -7
- package/src/rhf/use-rhf-wizard-step.ts +3 -12
- package/src/search/command-palette.tsx +15 -23
- package/src/search/global-search.tsx +38 -8
- package/src/search/search-index.ts +5 -1
- package/src/settings/device-reset-setting.tsx +5 -8
- package/src/settings/settings-heading.tsx +3 -1
- package/src/settings/settings-layout.tsx +6 -13
- package/src/settings/use-settings-focus.ts +8 -0
- package/src/settings/use-settings-route.ts +4 -3
- package/src/shell/app-shell.tsx +48 -24
- package/src/shell/auth-layout.tsx +1 -6
- package/src/shell/dev-menu.tsx +18 -6
- package/src/shell/option-switcher-menu.tsx +1 -3
- package/src/shell/sync-status-indicator.tsx +14 -12
- package/src/shell/top-bar-parts-labels.ts +1 -3
- package/src/shell/topbar-action-menu.tsx +130 -45
- package/src/shell/topbar-controls.tsx +5 -19
- package/src/shell/tour-menu.tsx +9 -1
- package/src/shell.ts +1 -1
- package/src/sync/db.ts +5 -1
- package/src/sync/engine.ts +44 -12
- package/src/sync.ts +16 -2
- package/src/testing/css-variables.ts +1 -2
- package/src/testing/index.ts +1 -6
- package/src/testing/react.ts +1 -2
- package/src/testing/viewport.ts +9 -9
- package/src/theme/contrast-tokens.ts +13 -2
- package/src/theme/palette-derive.ts +24 -50
- package/src/theme/palette-presets.ts +0 -1
- package/src/theme/palette-store.ts +1 -4
- package/src/theme/text-size.ts +1 -1
- package/src/theme/theme-store.ts +2 -6
- package/src/tour/tour-catalogue.tsx +4 -2
- package/src/tour/tour-dock.ts +5 -1
- package/src/tour/tour-engine.ts +2 -6
- package/src/tour/tour.tsx +28 -12
- package/src/tour/use-tour-progress.ts +8 -2
- package/src/tour/use-tour-url-sync.ts +3 -1
- package/src/vite-env.d.ts +1 -4
- package/src/wizard/stepper-nav.tsx +10 -35
- package/src/wizard/types.ts +1 -4
- package/src/wizard/use-wizard.ts +28 -43
- package/src/wizard/validation.ts +1 -5
- package/src/wizard/wizard-context.tsx +2 -6
- package/src/wizard/wizard-step.tsx +1 -8
- package/src/wizard/wizard-summary.tsx +2 -6
- package/tokens.css +393 -152
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/translation-review.ts"],"sourcesContent":["/**\n * The pure half of an app's translation review (H1 in docs/i18n-harmonization.md): from\n * the strings the app ships and the verdicts its server stores to one row per (locale,\n * key) with a status — keksdose's `features/translations/translation-catalogue.ts` and\n * kastlan's copy of it, which had grown apart by a fifth status and a second kind of key.\n *\n * WHY THE STRINGS ARE THE CATALOGUE. Nothing on the server lists which strings exist: a\n * verdict only says what somebody thought of one. So the rows are built from what the app\n * ships — its locale bundles, kastlan's document texts, the kit's own words\n * (`kitLabelStrings`) — and the review can never offer a string users do not see. A\n * verdict is stored WITH the wording it was given on, and a string that changed since is\n * noticed by comparing the two: `changed`, read it again, whatever the verdict was.\n *\n * WHAT STAYS IN THE APP. Which locale is read against which (keksdose: everything against\n * English, English against de-CH; kastlan: against German, German against English), where\n * the strings come from, who may review what (the locales and areas its server answers\n * with), and every request. The kit takes those as input and never derives them.\n *\n * camelCase, like the rest of the kit. The contract's wire shape is snake_case\n * (`reference_text`, `reviewer_name`, `reviewed_at`); {@link fromApiReview} and\n * {@link toApiWrite} are the two lines each app would otherwise write — both apps speak\n * the same contract, so the mapping is written once, here.\n */\n\nimport { foldForSearch } from \"./text-match\";\n\n// ── Shapes ──────────────────────────────────────────────────────────────────────\n\nexport type TranslationVerdict = \"APPROVED\" | \"NEEDS_CHANGE\";\n\n/** One stored verdict: what a reviewer said about one string in one locale. */\nexport interface TranslationReview {\n locale: string;\n key: string;\n /** The wording that was judged — compared with today's to notice a change. Empty for\n * a string the locale lacked (a suggested translation for a `missing` row). */\n text: string;\n /** The reference wording at the time. `null` from a server that did not store it. */\n referenceText: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n /** The reviewer's wording — or, for a missing string, the translation to add. */\n suggestion: string | null;\n /** `null` once the reviewer's account has been erased. */\n reviewerName: string | null;\n /** ISO timestamp. */\n reviewedAt: string;\n}\n\n/** What a save sends: the verdict plus the wording it is given on. */\nexport interface TranslationReviewWrite {\n locale: string;\n key: string;\n text: string;\n referenceText: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n suggestion: string | null;\n}\n\n/** What a reset sends: back to \"unreviewed\". */\nexport interface TranslationReviewKey {\n locale: string;\n key: string;\n}\n\n/**\n * Where a string stands, in the order a reviewer works through them: what is not there\n * at all, what nobody has read, what changed after it was read, what was sent back, and\n * what is done. `missing` never occurs for an app whose locales have every key\n * (keksdose); kastlan's French lacks 172 screen texts.\n */\nexport type ReviewStatus = \"missing\" | \"unreviewed\" | \"changed\" | \"needs_change\" | \"approved\";\n\nexport const REVIEW_STATUSES: readonly ReviewStatus[] = [\n \"missing\",\n \"unreviewed\",\n \"changed\",\n \"needs_change\",\n \"approved\",\n];\n\nexport interface TranslationRow {\n /** `${locale}|${key}` — unique across every locale on a page. A bar, not a colon:\n * kastlan's keys contain colons (`common:actions.save`). */\n id: string;\n key: string;\n /** The key's group: `budget` for `budget.rta`, `common` for `common:actions.save`,\n * `kit` for the kit's own words. See {@link keyNamespace}. */\n namespace: string;\n /** Where the string comes from, in the app's own words — kastlan's `screen` and\n * `documents`, keksdose's one source. `\"\"` when the app does not say. */\n source: string;\n locale: string;\n /** The wording users see today; empty when the locale lacks the string. */\n text: string;\n /** The same key in the reference locale. */\n reference: string;\n status: ReviewStatus;\n review: TranslationReview | null;\n /** The interpolations and tags differ from the reference's — `{{count}}` dropped, a\n * `<1>` link lost, a `{date}` renamed. A machine can check that much, so it does,\n * before a person reads. Never set on a missing string: it has nothing to lose. */\n placeholderMismatch: boolean;\n}\n\n// ── The wire contract ───────────────────────────────────────────────────────────\n\n/** A verdict as `GET /translations/reviews` returns it (H1's shared contract). Typed\n * structurally, so an app's generated OpenAPI type fits without a cast. */\nexport interface ApiTranslationReview {\n locale: string;\n key: string;\n text: string;\n reference_text: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n suggestion: string | null;\n reviewer_name: string | null;\n /** server-kit 0.10: the name's two parts (`reviewer_name` is them in the reader's order). */\n reviewer_first_name?: string | null;\n reviewer_last_name?: string | null;\n reviewed_at: string;\n}\n\n/** `GET /translations/reviews` (server-kit `TranslationReviewsResponse`): the locales and\n * areas the caller may review (`areas` null: every area; `[\"kit\"]` for a review token)\n * and every stored verdict in them. Typed structurally, as {@link ApiTranslationReview}. */\nexport interface ApiTranslationReviewsResponse {\n locales: string[];\n areas?: string[] | null;\n reviews: ApiTranslationReview[];\n}\n\n/** One item of `PUT /translations/reviews`. */\nexport interface ApiTranslationReviewWrite {\n locale: string;\n key: string;\n text: string;\n reference_text: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n suggestion: string | null;\n}\n\n/** A verdict from the server, in the kit's spelling. */\nexport function fromApiReview(review: ApiTranslationReview): TranslationReview {\n return {\n locale: review.locale,\n key: review.key,\n text: review.text,\n referenceText: review.reference_text,\n verdict: review.verdict,\n note: review.note,\n suggestion: review.suggestion,\n reviewerName: review.reviewer_name,\n reviewedAt: review.reviewed_at,\n };\n}\n\n/** A save, in the server's spelling. `TranslationReviewKey` needs no mapping — it is\n * `{ locale, key }` on both sides. */\nexport function toApiWrite(write: TranslationReviewWrite): ApiTranslationReviewWrite {\n return {\n locale: write.locale,\n key: write.key,\n text: write.text,\n reference_text: write.referenceText,\n verdict: write.verdict,\n note: write.note,\n suggestion: write.suggestion,\n };\n}\n\n// ── Strings ─────────────────────────────────────────────────────────────────────\n\n/**\n * A nested bundle as `key → string`, in the bundle's own order. Non-string leaves are\n * skipped rather than stringified into something nobody wrote.\n *\n * `prefix` is put in front of every key AS IS, so it names the separator too:\n * `flattenStrings(bundle)` is keksdose's `budget.rta`, `flattenStrings(tree, \"common:\")`\n * kastlan's `common:actions.save`, and `flattenStrings(kitLabelStrings(labels), \"kit.\")`\n * the kit's own words as `kit.combobox.resultCount(3)` — already flat, so only the prefix\n * is added.\n */\nexport function flattenStrings(tree: Readonly<Record<string, unknown>>, prefix = \"\"): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(tree)) {\n const path = `${prefix}${key}`;\n if (typeof value === \"string\") out[path] = value;\n else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n Object.assign(out, flattenStrings(value as Record<string, unknown>, `${path}.`));\n }\n }\n return out;\n}\n\n/**\n * The key's group, for the namespace filter: the part before a colon when there is one\n * (kastlan's `common:actions.save` → `common`, `doc_text.invoice:due` →\n * `doc_text.invoice`), else the first dotted segment (keksdose's `budget.rta` →\n * `budget`, the kit's `kit.combobox.resultCount(3)` → `kit`). Only the part before a\n * sample's `(` is looked at, so a colon inside one cannot move the split.\n */\nexport function keyNamespace(key: string): string {\n const head = key.split(\"(\", 1)[0];\n const colon = head.indexOf(\":\");\n return colon >= 0 ? head.slice(0, colon) : head.split(\".\", 1)[0];\n}\n\n// i18next `{{x}}` (formatting options ignored: `{{x, number}}` is `{{x}}`); a Python\n// format field `{x}` / `{0}` / `{amount:.2f}` (kastlan's document texts), but not a\n// LaTeX argument (`\\textbf{x}` — a letter or backslash right before the brace); a\n// numbered or named tag (`<1>`, `<strong>`), not prose in angle brackets (\"<deleted\n// user>\"); and a nested `$t(key)`. `{{x}}` is tried first at its position and consumed\n// whole, so it is never counted a second time as `{x}`.\nconst PLACEHOLDER_RE =\n /\\{\\{\\s*([^}\\s,]+)[^}]*\\}\\}|(?<![\\\\A-Za-z])\\{([a-z_][a-z0-9_]*|\\d+)(?:[!:][^{}]*)?\\}|<\\/?(\\d+|[a-z][a-z0-9]*)\\s*\\/?>|\\$t\\(([^)]+)\\)/g;\n\n/** The placeholders in a string, as a sorted multiset: `{{count}}`, `{date}`, `<1>`,\n * `$t(common.save)`. */\nexport function placeholderTokens(text: string): string[] {\n const found: string[] = [];\n for (const m of text.matchAll(PLACEHOLDER_RE)) {\n if (m[1]) found.push(`{{${m[1]}}}`);\n // `{ref:retention}` (ui-kit 0.28's legal cross-reference) keeps its target: a\n // translation that points at another section changed what the sentence says. Every\n // other `{x:spec}` is a format spec, which a translation may change.\n else if (m[2]) found.push(m[2] === \"ref\" ? m[0] : `{${m[2]}}`);\n else if (m[3]) found.push(`<${m[3]}>`);\n else if (m[4]) found.push(`$t(${m[4]})`);\n }\n return found.sort();\n}\n\n/** Whether `text` has other placeholders than `reference` — dropped, renamed or added.\n * Moving one is fine: a translation reorders a sentence. */\nexport function placeholderMismatch(text: string, reference: string): boolean {\n const a = placeholderTokens(text);\n const b = placeholderTokens(reference);\n return a.length !== b.length || a.some((p, i) => p !== b[i]);\n}\n\n// ── Status ──────────────────────────────────────────────────────────────────────\n\n/**\n * A verdict counts only for the wording it was given on. If the string or its reference\n * changed since, it is `changed` — read it again — whatever the verdict was. A string the\n * locale lacks is `missing` until somebody suggests its translation (stored as\n * NEEDS_CHANGE on the empty text, so it reads `needs_change`, and `changed` once a\n * developer adds the string).\n */\nexport function reviewStatus(\n review: TranslationReview | null | undefined,\n text: string,\n reference: string,\n): ReviewStatus {\n if (!review) return text === \"\" && reference !== \"\" ? \"missing\" : \"unreviewed\";\n if (review.text !== text) return \"changed\";\n if (review.referenceText != null && review.referenceText !== reference) return \"changed\";\n return review.verdict === \"APPROVED\" ? \"approved\" : \"needs_change\";\n}\n\n/**\n * Whether `key` lies in `area`: the key IS the area, or sits under it — `legal.terms`\n * and kastlan's `legal:terms` are in `legal`, `legalese.title` is not.\n *\n * 0.28: the kit's own words of that area too — `kit.legal.sections.terms.law.body(…)`\n * is in `legal`. All three apps list the kit's labels under `kit.`\n * (`flattenStrings(kitLabelStrings(labels), \"kit.\")`), and since 0.28 the kit writes\n * the shared legal sections, so a lawyer with a `[\"legal\"]` grant who was not shown\n * `kit.legal.*` would not see half of the Privacy Policy — and the server would refuse\n * the verdicts (docs/legal-harmonization.md §7.5). server-kit's `in_areas` and the apps'\n * copies of it apply the same rule.\n */\nexport function keyInArea(key: string, area: string): boolean {\n return (\n key === area || key.startsWith(`${area}.`) || key.startsWith(`${area}:`) || key.startsWith(`kit.${area}.`)\n );\n}\n\n/**\n * The area of `areas` that `key` lies in ({@link keyInArea}), or `undefined` — the\n * translation page's grouping by the same rule the filter and the server use, so\n * `kit.legal.sections.privacy.rights.lead` is grouped under `legal` with the app's own\n * legal texts instead of under `kit.legal`:\n *\n * const namespaceOf = (key: string) => reviewAreaOf(key, [\"legal\"]) ?? ownNamespaceOf(key);\n *\n * Where two areas both hold the key (`legal` and `legal.privacy`), the longer — the more\n * specific — wins, whatever their order. `inArea` is the app's own rule, as for\n * {@link keyInAreas}.\n */\nexport function reviewAreaOf(\n key: string,\n areas: readonly string[],\n inArea: (key: string, area: string) => boolean = keyInArea,\n): string | undefined {\n let found: string | undefined;\n for (const area of areas) {\n if (inArea(key, area) && (found === undefined || area.length > found.length)) found = area;\n }\n return found;\n}\n\n/**\n * Whether `key` lies in one of `areas` — the scope a reviewer may be limited to\n * (keksdose: `[\"legal\"]`, a lawyer who judges the Imprint, the Privacy Policy and the\n * Terms and sees nothing else). `null`/`undefined` is every area. The server applies the\n * same rule and refuses verdicts outside; this decides only what is listed.\n */\nexport function keyInAreas(\n key: string,\n areas: readonly string[] | null | undefined,\n inArea: (key: string, area: string) => boolean = keyInArea,\n): boolean {\n return !areas || areas.some((area) => inArea(key, area));\n}\n\nexport interface TranslationRowsInput {\n locale: string;\n /** The locale's strings, `key → text` ({@link flattenStrings}). */\n strings: Readonly<Record<string, string>>;\n /** The reference locale's strings — whichever locale THIS app reads `locale` against. */\n reference: Readonly<Record<string, string>>;\n /** The verdicts: this locale's by key, or the whole list as the server sent it (other\n * locales' verdicts are skipped). */\n reviews?: ReadonlyMap<string, TranslationReview> | readonly TranslationReview[];\n /** Default {@link keyNamespace}. */\n namespaceOf?: (key: string) => string;\n /** The row's source, an app-defined word (kastlan: `doc_text.` keys are `documents`,\n * the rest `screen`). Default: none (`\"\"`). */\n sourceOf?: (key: string) => string;\n /** Keep only keys inside these areas ({@link keyInAreas}); `null` keeps every key. */\n areas?: readonly string[] | null;\n /** Default {@link keyInArea}. */\n inArea?: (key: string, area: string) => boolean;\n}\n\n/**\n * Every key of one locale, with its status: the reference's keys first, in its order, so\n * rows read the way the app's authors wrote them; a key only this locale has is appended\n * rather than dropped (a parity test should forbid it, but the page should not lie if one\n * slips through).\n */\nexport function translationRows({\n locale,\n strings,\n reference,\n reviews,\n namespaceOf: groupOf = keyNamespace,\n sourceOf,\n areas,\n inArea,\n}: TranslationRowsInput): TranslationRow[] {\n const byKey = new Map<string, TranslationReview>();\n if (reviews instanceof Map) {\n for (const [key, review] of reviews) byKey.set(key, review);\n } else if (reviews) {\n for (const review of reviews as readonly TranslationReview[]) {\n if (review.locale === locale) byKey.set(review.key, review);\n }\n }\n const keys = Object.keys(reference);\n for (const key of Object.keys(strings)) if (!(key in reference)) keys.push(key);\n return keys\n .filter((key) => keyInAreas(key, areas, inArea))\n .map((key) => {\n const text = strings[key] ?? \"\";\n const ref = reference[key] ?? \"\";\n const review = byKey.get(key) ?? null;\n return {\n id: `${locale}|${key}`,\n key,\n namespace: groupOf(key),\n source: sourceOf?.(key) ?? \"\",\n locale,\n text,\n reference: ref,\n status: reviewStatus(review, text, ref),\n review,\n placeholderMismatch: text !== \"\" && placeholderMismatch(text, ref),\n };\n });\n}\n\n/** How many rows stand where, and how many there are. */\nexport type TranslationSummary = Record<ReviewStatus, number> & { total: number };\n\nexport function summariseRows(rows: readonly TranslationRow[]): TranslationSummary {\n const summary: TranslationSummary = {\n missing: 0,\n unreviewed: 0,\n changed: 0,\n needs_change: 0,\n approved: 0,\n total: rows.length,\n };\n for (const row of rows) summary[row.status] += 1;\n return summary;\n}\n\n// ── Filtering ───────────────────────────────────────────────────────────────────\n\n/** The panel's filters. `\"all\"` switches one off. */\nexport interface TranslationReviewFilter {\n status: ReviewStatus | \"all\";\n source: string;\n namespace: string;\n /** Searched in the key, the text and the reference, folded as every kit list's search\n * is (`foldForSearch`): no case, no accents — \"uberweisung\" finds \"Überweisung\". */\n query: string;\n placeholdersOnly: boolean;\n}\n\nexport const DEFAULT_TRANSLATION_REVIEW_FILTER: TranslationReviewFilter = {\n status: \"all\",\n source: \"all\",\n namespace: \"all\",\n query: \"\",\n placeholdersOnly: false,\n};\n\nexport function filterTranslationRows(\n rows: readonly TranslationRow[],\n filter: Partial<TranslationReviewFilter>,\n): TranslationRow[] {\n const f = { ...DEFAULT_TRANSLATION_REVIEW_FILTER, ...filter };\n // Folded as every kit list's search is (DUP-5, refactor audit 2026-10).\n const q = foldForSearch(f.query.trim());\n return rows.filter(\n (row) =>\n (f.status === \"all\" || row.status === f.status) &&\n (f.source === \"all\" || row.source === f.source) &&\n (f.namespace === \"all\" || row.namespace === f.namespace) &&\n (!f.placeholdersOnly || row.placeholderMismatch) &&\n (!q || [row.key, row.text, row.reference].some((s) => foldForSearch(s).includes(q))),\n );\n}\n\n// ── Grouping ────────────────────────────────────────────────────────────────────\n\n/** One group of rows — an area, a source — and how they stand. */\nexport interface TranslationRowGroup {\n key: string;\n rows: TranslationRow[];\n summary: TranslationSummary;\n}\n\n/**\n * Rows in groups, each group where its first row is — the reference's order, so the areas\n * read the way the app's authors wrote the bundle — and each group's rows in their own\n * order. keksdose live #377: a reviewer on a phone works area by area (\"the budget\n * strings, then the legal ones\"), and a flat list of 3859 rows is not a way to see\n * where an area stands.\n *\n * `groupOf` names a row's group: `(row) => row.namespace` for the areas,\n * `(row) => row.source` for kastlan's screen texts and documents.\n */\nexport function groupTranslationRows(\n rows: readonly TranslationRow[],\n groupOf: (row: TranslationRow) => string,\n): TranslationRowGroup[] {\n const byKey = new Map<string, TranslationRow[]>();\n for (const row of rows) {\n const key = groupOf(row);\n const list = byKey.get(key);\n if (list) list.push(row);\n else byKey.set(key, [row]);\n }\n return [...byKey].map(([key, list]) => ({ key, rows: list, summary: summariseRows(list) }));\n}\n\n/**\n * The rows a group's \"Approve the unreviewed\" takes: the ones nobody has given a verdict\n * and that have a text. Not `changed` — a string that moved since it was judged asks to\n * be READ again, which a bulk action is the opposite of — and not `missing`, which has\n * nothing to approve.\n */\nexport function unreviewedRows(rows: readonly TranslationRow[]): TranslationRow[] {\n return rows.filter((row) => row.status === \"unreviewed\" && row.text !== \"\");\n}\n\n// ── Writing ─────────────────────────────────────────────────────────────────────\n\n/** What gets stored for a verdict: the wording it was given on, so a later change of the\n * string (or of its reference) shows up as `changed`. */\nexport function reviewWrite(\n row: TranslationRow,\n verdict: TranslationVerdict,\n note: string | null = null,\n suggestion: string | null = null,\n): TranslationReviewWrite {\n return {\n locale: row.locale,\n key: row.key,\n text: row.text,\n referenceText: row.reference,\n verdict,\n note,\n suggestion,\n };\n}\n\n/** What takes a set of verdicts back: see {@link reviewUndo}. */\nexport interface TranslationReviewUndo {\n /** The verdicts the rows had before, to store again — each on the wording it was\n * given on, so a row that was `changed` reads `changed` again. */\n writes: TranslationReviewWrite[];\n /** The rows that had no verdict before: back to unreviewed. */\n clears: TranslationReviewKey[];\n}\n\n/**\n * How to take back what was just said about `rows` — the rows AS THEY WERE before the\n * write, with the verdicts they carried then. The panel's Undo toast (0.25, keksdose live\n * #377) runs it: a swipe on a phone approves in one movement, and a movement can be a\n * mistake.\n *\n * A row that had a verdict gets it stored again (its note, its suggestion, the wording it\n * was judged on); one that had none is cleared. The server stamps the restored verdict\n * with the person undoing and the time, as it stamps every write — the contract has no\n * way to write a verdict in somebody else's name, and should not.\n */\nexport function reviewUndo(rows: readonly TranslationRow[]): TranslationReviewUndo {\n const writes: TranslationReviewWrite[] = [];\n const clears: TranslationReviewKey[] = [];\n for (const row of rows) {\n const before = row.review;\n if (!before) {\n clears.push({ locale: row.locale, key: row.key });\n continue;\n }\n writes.push({\n locale: row.locale,\n key: row.key,\n text: before.text,\n referenceText: before.referenceText,\n verdict: before.verdict,\n note: before.note,\n suggestion: before.suggestion,\n });\n }\n return { writes, clears };\n}\n\n/** The app's cached verdict list with `written` in place of what was said before — a\n * save answers with the rows it wrote, so a page patches its copy instead of\n * downloading every verdict again after each click. Any spelling with `locale` and\n * `key` (the API's or the kit's). */\nexport function mergeReviews<T extends TranslationReviewKey>(prev: readonly T[], written: readonly T[]): T[] {\n const id = (r: TranslationReviewKey) => `${r.locale}|${r.key}`;\n const replaced = new Set(written.map(id));\n return [...prev.filter((r) => !replaced.has(id(r))), ...written];\n}\n\n/** The cached list without the verdicts on `cleared`. */\nexport function dropReviews<T extends TranslationReviewKey>(\n prev: readonly T[],\n cleared: readonly TranslationReviewKey[],\n): T[] {\n const gone = new Set(cleared.map((r) => `${r.locale}|${r.key}`));\n return prev.filter((r) => !gone.has(`${r.locale}|${r.key}`));\n}\n\n// ── Swipe bindings ──────────────────────────────────────────────────────────────\n\n/**\n * What a phone card's swipe can be bound to in `TranslationReviewPanel`'s `swipe`\n * (keksdose — Marcel's live #377 rework, 2026-10-03: *\"Add the swipe options to be shown\n * also to the settings /settings#interaction area where the other swipe options are\n * defined\"*). keksdose lets the user bind every list's swipes there — per side, a primary\n * action at the first threshold and a secondary one at a longer drag — and lists each\n * surface's ids in its `SWIPE_ACTIONS`; this is the translation list's, in the order a\n * settings page offers them.\n *\n * - `approve` — the string is right as it stands. With the panel's Undo toast.\n * - `edit` — open the editor with the cursor in the wording: \"Needs a change\" (or\n * \"Suggest translation\" on a missing string). Writes nothing; the editor does.\n * - `clear` — take the verdict back: unreviewed again. With the Undo toast, which stores\n * the verdict again.\n *\n * THERE IS NO SEPARATE \"needs a change\". The editor has no verdict to preselect: Approve\n * and \"Needs a change\" stand side by side in it, and \"Needs a change\" takes a note or a\n * different wording — a verdict without either tells whoever fixes the string nothing, so\n * a swipe never sends one blind (0.25). The one honest thing a \"needs a change\" swipe can\n * do is therefore open the editor with the cursor in the wording — which is `edit`, and\n * `edit` already says \"Needs a change\" on the card. A second id doing the same would arm\n * a second threshold that does what the first already did: the duplicate keksdose's\n * `resolveSwipePlan` drops for exactly that reason.\n */\nexport const TRANSLATION_REVIEW_SWIPE_ACTIONS = [\"approve\", \"edit\", \"clear\"] as const;\n\n/** One of {@link TRANSLATION_REVIEW_SWIPE_ACTIONS}. */\nexport type TranslationReviewSwipeAction = (typeof TRANSLATION_REVIEW_SWIPE_ACTIONS)[number];\n\n/**\n * Which swipe does what on a phone card — `TranslationReviewPanel`'s `swipe`. Each side is\n * an ordered ladder, exactly as `SwipeableRow` and DataTable's `mobileSwipeActions` model\n * one: index 0 commits at the first threshold, index 1 at the longer drag (and so on — the\n * thresholds spread evenly over the card's width). A side left out, or empty, does not\n * swipe.\n *\n * LOGICAL SIDES: `end` is a drag toward the reading end of the line — right in a\n * left-to-right page, left in a right-to-left one — and `start` the other way, so one\n * binding holds in both directions. An app whose settings store physical sides (keksdose's\n * `right`/`left`) hands `right` as `end` for a left-to-right page.\n */\nexport interface TranslationReviewSwipeBinding {\n /** A drag toward the reading START, nearest threshold first. */\n start?: readonly TranslationReviewSwipeAction[];\n /** A drag toward the reading END, nearest threshold first. */\n end?: readonly TranslationReviewSwipeAction[];\n}\n\n/** What `swipe={true}` means — 0.25's fixed mapping: approve toward the end, open the\n * editor (\"Needs a change\") toward the start. A settings page's \"reset\" goes back here. */\nexport const DEFAULT_TRANSLATION_REVIEW_SWIPE: TranslationReviewSwipeBinding = Object.freeze({\n start: Object.freeze([\"edit\"] as const),\n end: Object.freeze([\"approve\"] as const),\n});\n\n/** The ladders one row actually offers, from a {@link TranslationReviewSwipeBinding}. */\nexport interface TranslationReviewSwipePlan {\n start: TranslationReviewSwipeAction[];\n end: TranslationReviewSwipeAction[];\n}\n\n/**\n * The binding resolved against one row — keksdose's `resolveSwipePlan`, for this list.\n * An id the row cannot offer DROPS OUT and the ladder closes up behind it, so the second\n * stage becomes the first rather than the side going dead behind an unreachable first\n * stage (or arming a threshold that does nothing):\n *\n * - `approve`: not on a missing string (nothing to approve) or an approved one (it would\n * say it again) — the rows that have no approve button either;\n * - `clear`: not without `canClear` (the app passed no `onClear`), and not on a row with\n * no verdict to take back (unreviewed; missing with no suggestion);\n * - `edit`: on every row;\n * - an id named twice on one side: the second time (a longer drag to the same effect);\n * - an id this version does not know (a binding stored by another version, an app's own\n * \"none\" slot): dropped like one that does not apply.\n *\n * Only what the ROW decides. Whether the panel may write at all — `readOnly`, no\n * `onSave`, a write lock, the row's own write still out — is the panel's, and then no\n * side swipes.\n */\nexport function translationReviewSwipePlan(\n binding: TranslationReviewSwipeBinding,\n row: TranslationRow,\n { canClear = false }: { canClear?: boolean } = {},\n): TranslationReviewSwipePlan {\n const offers = (id: TranslationReviewSwipeAction): boolean => {\n switch (id) {\n case \"approve\":\n return row.text !== \"\" && row.status !== \"approved\";\n case \"edit\":\n return true;\n case \"clear\":\n return canClear && row.review !== null;\n default:\n return false;\n }\n };\n const side = (ids: readonly TranslationReviewSwipeAction[] | undefined): TranslationReviewSwipeAction[] => {\n const out: TranslationReviewSwipeAction[] = [];\n for (const id of ids ?? []) {\n if (!out.includes(id) && offers(id)) out.push(id);\n }\n return out;\n };\n return { start: side(binding.start), end: side(binding.end) };\n}\n\n// ── Export ──────────────────────────────────────────────────────────────────────\n\n/**\n * One entry of the \"Export corrections\" file — enough for a developer to apply the change\n * to the bundle without opening the page. snake_case `reviewed_at` on purpose: this is a\n * FILE, the one keksdose and kastlan already write, beside an API spelled that way.\n */\nexport interface TranslationCorrection {\n locale: string;\n key: string;\n status: ReviewStatus;\n current: string;\n reference: string;\n suggestion: string | null;\n note: string | null;\n reviewer: string | null;\n reviewed_at: string | null;\n}\n\n/** The rows sent back (verdict NEEDS_CHANGE — a suggested translation for a missing\n * string included), as the export file lists them. */\nexport function translationCorrections(rows: readonly TranslationRow[]): TranslationCorrection[] {\n return rows\n .filter((row) => row.review?.verdict === \"NEEDS_CHANGE\")\n .map((row) => ({\n locale: row.locale,\n key: row.key,\n status: row.status,\n current: row.text,\n reference: row.reference,\n suggestion: row.review?.suggestion ?? null,\n note: row.review?.note ?? null,\n reviewer: row.review?.reviewerName ?? null,\n reviewed_at: row.review?.reviewedAt ?? null,\n }));\n}\n"],"mappings":";AAwBA,SAAS,qBAAqB;AAkDvB,MAAM,kBAA2C;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAkEO,SAAS,cAAc,QAAiD;AAC7E,SAAO;AAAA,IACL,QAAQ,OAAO;AAAA,IACf,KAAK,OAAO;AAAA,IACZ,MAAM,OAAO;AAAA,IACb,eAAe,OAAO;AAAA,IACtB,SAAS,OAAO;AAAA,IAChB,MAAM,OAAO;AAAA,IACb,YAAY,OAAO;AAAA,IACnB,cAAc,OAAO;AAAA,IACrB,YAAY,OAAO;AAAA,EACrB;AACF;AAIO,SAAS,WAAW,OAA0D;AACnF,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,KAAK,MAAM;AAAA,IACX,MAAM,MAAM;AAAA,IACZ,gBAAgB,MAAM;AAAA,IACtB,SAAS,MAAM;AAAA,IACf,MAAM,MAAM;AAAA,IACZ,YAAY,MAAM;AAAA,EACpB;AACF;AAcO,SAAS,eAAe,MAAyC,SAAS,IAA4B;AAC3G,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,UAAM,OAAO,GAAG,MAAM,GAAG,GAAG;AAC5B,QAAI,OAAO,UAAU,SAAU,KAAI,IAAI,IAAI;AAAA,aAClC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,GAAG;AACpE,aAAO,OAAO,KAAK,eAAe,OAAkC,GAAG,IAAI,GAAG,CAAC;AAAA,IACjF;AAAA,EACF;AACA,SAAO;AACT;AASO,SAAS,aAAa,KAAqB;AAChD,QAAM,OAAO,IAAI,MAAM,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A,IACtC,MAAM,IAAI,QAAQ,QAAQ;AAAA,IAC1B,UAAU,IAAI,QAAQ,gBAAgB;AAAA,IACtC,aAAa,IAAI,QAAQ,cAAc;AAAA,EACzC,EAAE;AACN;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/translation-review.ts"],"sourcesContent":["/**\n * The pure half of an app's translation review (H1 in docs/i18n-harmonization.md): from\n * the strings the app ships and the verdicts its server stores to one row per (locale,\n * key) with a status — keksdose's `features/translations/translation-catalogue.ts` and\n * kastlan's copy of it, which had grown apart by a fifth status and a second kind of key.\n *\n * WHY THE STRINGS ARE THE CATALOGUE. Nothing on the server lists which strings exist: a\n * verdict only says what somebody thought of one. So the rows are built from what the app\n * ships — its locale bundles, kastlan's document texts, the kit's own words\n * (`kitLabelStrings`) — and the review can never offer a string users do not see. A\n * verdict is stored WITH the wording it was given on, and a string that changed since is\n * noticed by comparing the two: `changed`, read it again, whatever the verdict was.\n *\n * WHAT STAYS IN THE APP. Which locale is read against which (keksdose: everything against\n * English, English against de-CH; kastlan: against German, German against English), where\n * the strings come from, who may review what (the locales and areas its server answers\n * with), and every request. The kit takes those as input and never derives them.\n *\n * camelCase, like the rest of the kit. The contract's wire shape is snake_case\n * (`reference_text`, `reviewer_name`, `reviewed_at`); {@link fromApiReview} and\n * {@link toApiWrite} are the two lines each app would otherwise write — both apps speak\n * the same contract, so the mapping is written once, here.\n */\n\nimport { foldForSearch } from \"./text-match\";\n\n// ── Shapes ──────────────────────────────────────────────────────────────────────\n\nexport type TranslationVerdict = \"APPROVED\" | \"NEEDS_CHANGE\";\n\n/** One stored verdict: what a reviewer said about one string in one locale. */\nexport interface TranslationReview {\n locale: string;\n key: string;\n /** The wording that was judged — compared with today's to notice a change. Empty for\n * a string the locale lacked (a suggested translation for a `missing` row). */\n text: string;\n /** The reference wording at the time. `null` from a server that did not store it. */\n referenceText: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n /** The reviewer's wording — or, for a missing string, the translation to add. */\n suggestion: string | null;\n /** `null` once the reviewer's account has been erased. */\n reviewerName: string | null;\n /** ISO timestamp. */\n reviewedAt: string;\n}\n\n/** What a save sends: the verdict plus the wording it is given on. */\nexport interface TranslationReviewWrite {\n locale: string;\n key: string;\n text: string;\n referenceText: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n suggestion: string | null;\n}\n\n/** What a reset sends: back to \"unreviewed\". */\nexport interface TranslationReviewKey {\n locale: string;\n key: string;\n}\n\n/**\n * Where a string stands, in the order a reviewer works through them: what is not there\n * at all, what nobody has read, what changed after it was read, what was sent back, and\n * what is done. `missing` never occurs for an app whose locales have every key\n * (keksdose); kastlan's French lacks 172 screen texts.\n */\nexport type ReviewStatus = \"missing\" | \"unreviewed\" | \"changed\" | \"needs_change\" | \"approved\";\n\nexport const REVIEW_STATUSES: readonly ReviewStatus[] = [\n \"missing\",\n \"unreviewed\",\n \"changed\",\n \"needs_change\",\n \"approved\",\n];\n\nexport interface TranslationRow {\n /** `${locale}|${key}` — unique across every locale on a page. A bar, not a colon:\n * kastlan's keys contain colons (`common:actions.save`). */\n id: string;\n key: string;\n /** The key's group: `budget` for `budget.rta`, `common` for `common:actions.save`,\n * `kit` for the kit's own words. See {@link keyNamespace}. */\n namespace: string;\n /** Where the string comes from, in the app's own words — kastlan's `screen` and\n * `documents`, keksdose's one source. `\"\"` when the app does not say. */\n source: string;\n locale: string;\n /** The wording users see today; empty when the locale lacks the string. */\n text: string;\n /** The same key in the reference locale. */\n reference: string;\n status: ReviewStatus;\n review: TranslationReview | null;\n /** The interpolations and tags differ from the reference's — `{{count}}` dropped, a\n * `<1>` link lost, a `{date}` renamed. A machine can check that much, so it does,\n * before a person reads. Never set on a missing string: it has nothing to lose. */\n placeholderMismatch: boolean;\n}\n\n// ── The wire contract ───────────────────────────────────────────────────────────\n\n/** A verdict as `GET /translations/reviews` returns it (H1's shared contract). Typed\n * structurally, so an app's generated OpenAPI type fits without a cast. */\nexport interface ApiTranslationReview {\n locale: string;\n key: string;\n text: string;\n reference_text: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n suggestion: string | null;\n reviewer_name: string | null;\n /** server-kit 0.10: the name's two parts (`reviewer_name` is them in the reader's order). */\n reviewer_first_name?: string | null;\n reviewer_last_name?: string | null;\n reviewed_at: string;\n}\n\n/** `GET /translations/reviews` (server-kit `TranslationReviewsResponse`): the locales and\n * areas the caller may review (`areas` null: every area; `[\"kit\"]` for a review token)\n * and every stored verdict in them. Typed structurally, as {@link ApiTranslationReview}. */\nexport interface ApiTranslationReviewsResponse {\n locales: string[];\n areas?: string[] | null;\n reviews: ApiTranslationReview[];\n}\n\n/** One item of `PUT /translations/reviews`. */\nexport interface ApiTranslationReviewWrite {\n locale: string;\n key: string;\n text: string;\n reference_text: string | null;\n verdict: TranslationVerdict;\n note: string | null;\n suggestion: string | null;\n}\n\n/** A verdict from the server, in the kit's spelling. */\nexport function fromApiReview(review: ApiTranslationReview): TranslationReview {\n return {\n locale: review.locale,\n key: review.key,\n text: review.text,\n referenceText: review.reference_text,\n verdict: review.verdict,\n note: review.note,\n suggestion: review.suggestion,\n reviewerName: review.reviewer_name,\n reviewedAt: review.reviewed_at,\n };\n}\n\n/** A save, in the server's spelling. `TranslationReviewKey` needs no mapping — it is\n * `{ locale, key }` on both sides. */\nexport function toApiWrite(write: TranslationReviewWrite): ApiTranslationReviewWrite {\n return {\n locale: write.locale,\n key: write.key,\n text: write.text,\n reference_text: write.referenceText,\n verdict: write.verdict,\n note: write.note,\n suggestion: write.suggestion,\n };\n}\n\n// ── Strings ─────────────────────────────────────────────────────────────────────\n\n/**\n * A nested bundle as `key → string`, in the bundle's own order. Non-string leaves are\n * skipped rather than stringified into something nobody wrote.\n *\n * `prefix` is put in front of every key AS IS, so it names the separator too:\n * `flattenStrings(bundle)` is keksdose's `budget.rta`, `flattenStrings(tree, \"common:\")`\n * kastlan's `common:actions.save`, and `flattenStrings(kitLabelStrings(labels), \"kit.\")`\n * the kit's own words as `kit.combobox.resultCount(3)` — already flat, so only the prefix\n * is added.\n */\nexport function flattenStrings(tree: Readonly<Record<string, unknown>>, prefix = \"\"): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(tree)) {\n const path = `${prefix}${key}`;\n if (typeof value === \"string\") out[path] = value;\n else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n Object.assign(out, flattenStrings(value as Record<string, unknown>, `${path}.`));\n }\n }\n return out;\n}\n\n/**\n * The key's group, for the namespace filter: the part before a colon when there is one\n * (kastlan's `common:actions.save` → `common`, `doc_text.invoice:due` →\n * `doc_text.invoice`), else the first dotted segment (keksdose's `budget.rta` →\n * `budget`, the kit's `kit.combobox.resultCount(3)` → `kit`). Only the part before a\n * sample's `(` is looked at, so a colon inside one cannot move the split.\n */\nexport function keyNamespace(key: string): string {\n const head = key.split(\"(\", 1)[0];\n const colon = head.indexOf(\":\");\n return colon >= 0 ? head.slice(0, colon) : head.split(\".\", 1)[0];\n}\n\n// i18next `{{x}}` (formatting options ignored: `{{x, number}}` is `{{x}}`); a Python\n// format field `{x}` / `{0}` / `{amount:.2f}` (kastlan's document texts), but not a\n// LaTeX argument (`\\textbf{x}` — a letter or backslash right before the brace); a\n// numbered or named tag (`<1>`, `<strong>`), not prose in angle brackets (\"<deleted\n// user>\"); and a nested `$t(key)`. `{{x}}` is tried first at its position and consumed\n// whole, so it is never counted a second time as `{x}`.\nconst PLACEHOLDER_RE =\n /\\{\\{\\s*([^}\\s,]+)[^}]*\\}\\}|(?<![\\\\A-Za-z])\\{([a-z_][a-z0-9_]*|\\d+)(?:[!:][^{}]*)?\\}|<\\/?(\\d+|[a-z][a-z0-9]*)\\s*\\/?>|\\$t\\(([^)]+)\\)/g;\n\n/** The placeholders in a string, as a sorted multiset: `{{count}}`, `{date}`, `<1>`,\n * `$t(common.save)`. */\nexport function placeholderTokens(text: string): string[] {\n const found: string[] = [];\n for (const m of text.matchAll(PLACEHOLDER_RE)) {\n if (m[1]) found.push(`{{${m[1]}}}`);\n // `{ref:retention}` (ui-kit 0.28's legal cross-reference) keeps its target: a\n // translation that points at another section changed what the sentence says. Every\n // other `{x:spec}` is a format spec, which a translation may change.\n else if (m[2]) found.push(m[2] === \"ref\" ? m[0] : `{${m[2]}}`);\n else if (m[3]) found.push(`<${m[3]}>`);\n else if (m[4]) found.push(`$t(${m[4]})`);\n }\n return found.sort();\n}\n\n/** Whether `text` has other placeholders than `reference` — dropped, renamed or added.\n * Moving one is fine: a translation reorders a sentence. */\nexport function placeholderMismatch(text: string, reference: string): boolean {\n const a = placeholderTokens(text);\n const b = placeholderTokens(reference);\n return a.length !== b.length || a.some((p, i) => p !== b[i]);\n}\n\n// ── Status ──────────────────────────────────────────────────────────────────────\n\n/**\n * A verdict counts only for the wording it was given on. If the string or its reference\n * changed since, it is `changed` — read it again — whatever the verdict was. A string the\n * locale lacks is `missing` until somebody suggests its translation (stored as\n * NEEDS_CHANGE on the empty text, so it reads `needs_change`, and `changed` once a\n * developer adds the string).\n */\nexport function reviewStatus(\n review: TranslationReview | null | undefined,\n text: string,\n reference: string,\n): ReviewStatus {\n if (!review) return text === \"\" && reference !== \"\" ? \"missing\" : \"unreviewed\";\n if (review.text !== text) return \"changed\";\n if (review.referenceText != null && review.referenceText !== reference) return \"changed\";\n return review.verdict === \"APPROVED\" ? \"approved\" : \"needs_change\";\n}\n\n/**\n * Whether `key` lies in `area`: the key IS the area, or sits under it — `legal.terms`\n * and kastlan's `legal:terms` are in `legal`, `legalese.title` is not.\n *\n * 0.28: the kit's own words of that area too — `kit.legal.sections.terms.law.body(…)`\n * is in `legal`. All three apps list the kit's labels under `kit.`\n * (`flattenStrings(kitLabelStrings(labels), \"kit.\")`), and since 0.28 the kit writes\n * the shared legal sections, so a lawyer with a `[\"legal\"]` grant who was not shown\n * `kit.legal.*` would not see half of the Privacy Policy — and the server would refuse\n * the verdicts (docs/legal-harmonization.md §7.5). server-kit's `in_areas` and the apps'\n * copies of it apply the same rule.\n */\nexport function keyInArea(key: string, area: string): boolean {\n return key === area || key.startsWith(`${area}.`) || key.startsWith(`${area}:`) || key.startsWith(`kit.${area}.`);\n}\n\n/**\n * The area of `areas` that `key` lies in ({@link keyInArea}), or `undefined` — the\n * translation page's grouping by the same rule the filter and the server use, so\n * `kit.legal.sections.privacy.rights.lead` is grouped under `legal` with the app's own\n * legal texts instead of under `kit.legal`:\n *\n * const namespaceOf = (key: string) => reviewAreaOf(key, [\"legal\"]) ?? ownNamespaceOf(key);\n *\n * Where two areas both hold the key (`legal` and `legal.privacy`), the longer — the more\n * specific — wins, whatever their order. `inArea` is the app's own rule, as for\n * {@link keyInAreas}.\n */\nexport function reviewAreaOf(\n key: string,\n areas: readonly string[],\n inArea: (key: string, area: string) => boolean = keyInArea,\n): string | undefined {\n let found: string | undefined;\n for (const area of areas) {\n if (inArea(key, area) && (found === undefined || area.length > found.length)) found = area;\n }\n return found;\n}\n\n/**\n * Whether `key` lies in one of `areas` — the scope a reviewer may be limited to\n * (keksdose: `[\"legal\"]`, a lawyer who judges the Imprint, the Privacy Policy and the\n * Terms and sees nothing else). `null`/`undefined` is every area. The server applies the\n * same rule and refuses verdicts outside; this decides only what is listed.\n */\nexport function keyInAreas(\n key: string,\n areas: readonly string[] | null | undefined,\n inArea: (key: string, area: string) => boolean = keyInArea,\n): boolean {\n return !areas || areas.some((area) => inArea(key, area));\n}\n\nexport interface TranslationRowsInput {\n locale: string;\n /** The locale's strings, `key → text` ({@link flattenStrings}). */\n strings: Readonly<Record<string, string>>;\n /** The reference locale's strings — whichever locale THIS app reads `locale` against. */\n reference: Readonly<Record<string, string>>;\n /** The verdicts: this locale's by key, or the whole list as the server sent it (other\n * locales' verdicts are skipped). */\n reviews?: ReadonlyMap<string, TranslationReview> | readonly TranslationReview[];\n /** Default {@link keyNamespace}. */\n namespaceOf?: (key: string) => string;\n /** The row's source, an app-defined word (kastlan: `doc_text.` keys are `documents`,\n * the rest `screen`). Default: none (`\"\"`). */\n sourceOf?: (key: string) => string;\n /** Keep only keys inside these areas ({@link keyInAreas}); `null` keeps every key. */\n areas?: readonly string[] | null;\n /** Default {@link keyInArea}. */\n inArea?: (key: string, area: string) => boolean;\n}\n\n/**\n * Every key of one locale, with its status: the reference's keys first, in its order, so\n * rows read the way the app's authors wrote them; a key only this locale has is appended\n * rather than dropped (a parity test should forbid it, but the page should not lie if one\n * slips through).\n */\nexport function translationRows({\n locale,\n strings,\n reference,\n reviews,\n namespaceOf: groupOf = keyNamespace,\n sourceOf,\n areas,\n inArea,\n}: TranslationRowsInput): TranslationRow[] {\n const byKey = new Map<string, TranslationReview>();\n if (reviews instanceof Map) {\n for (const [key, review] of reviews) byKey.set(key, review);\n } else if (reviews) {\n for (const review of reviews as readonly TranslationReview[]) {\n if (review.locale === locale) byKey.set(review.key, review);\n }\n }\n const keys = Object.keys(reference);\n for (const key of Object.keys(strings)) if (!(key in reference)) keys.push(key);\n return keys\n .filter((key) => keyInAreas(key, areas, inArea))\n .map((key) => {\n const text = strings[key] ?? \"\";\n const ref = reference[key] ?? \"\";\n const review = byKey.get(key) ?? null;\n return {\n id: `${locale}|${key}`,\n key,\n namespace: groupOf(key),\n source: sourceOf?.(key) ?? \"\",\n locale,\n text,\n reference: ref,\n status: reviewStatus(review, text, ref),\n review,\n placeholderMismatch: text !== \"\" && placeholderMismatch(text, ref),\n };\n });\n}\n\n/** How many rows stand where, and how many there are. */\nexport type TranslationSummary = Record<ReviewStatus, number> & { total: number };\n\nexport function summariseRows(rows: readonly TranslationRow[]): TranslationSummary {\n const summary: TranslationSummary = {\n missing: 0,\n unreviewed: 0,\n changed: 0,\n needs_change: 0,\n approved: 0,\n total: rows.length,\n };\n for (const row of rows) summary[row.status] += 1;\n return summary;\n}\n\n// ── Filtering ───────────────────────────────────────────────────────────────────\n\n/** The panel's filters. `\"all\"` switches one off. */\nexport interface TranslationReviewFilter {\n status: ReviewStatus | \"all\";\n source: string;\n namespace: string;\n /** Searched in the key, the text and the reference, folded as every kit list's search\n * is (`foldForSearch`): no case, no accents — \"uberweisung\" finds \"Überweisung\". */\n query: string;\n placeholdersOnly: boolean;\n}\n\nexport const DEFAULT_TRANSLATION_REVIEW_FILTER: TranslationReviewFilter = {\n status: \"all\",\n source: \"all\",\n namespace: \"all\",\n query: \"\",\n placeholdersOnly: false,\n};\n\nexport function filterTranslationRows(\n rows: readonly TranslationRow[],\n filter: Partial<TranslationReviewFilter>,\n): TranslationRow[] {\n const f = { ...DEFAULT_TRANSLATION_REVIEW_FILTER, ...filter };\n // Folded as every kit list's search is (DUP-5, refactor audit 2026-10).\n const q = foldForSearch(f.query.trim());\n return rows.filter(\n (row) =>\n (f.status === \"all\" || row.status === f.status) &&\n (f.source === \"all\" || row.source === f.source) &&\n (f.namespace === \"all\" || row.namespace === f.namespace) &&\n (!f.placeholdersOnly || row.placeholderMismatch) &&\n (!q || [row.key, row.text, row.reference].some((s) => foldForSearch(s).includes(q))),\n );\n}\n\n// ── Grouping ────────────────────────────────────────────────────────────────────\n\n/** One group of rows — an area, a source — and how they stand. */\nexport interface TranslationRowGroup {\n key: string;\n rows: TranslationRow[];\n summary: TranslationSummary;\n}\n\n/**\n * Rows in groups, each group where its first row is — the reference's order, so the areas\n * read the way the app's authors wrote the bundle — and each group's rows in their own\n * order. keksdose live #377: a reviewer on a phone works area by area (\"the budget\n * strings, then the legal ones\"), and a flat list of 3859 rows is not a way to see\n * where an area stands.\n *\n * `groupOf` names a row's group: `(row) => row.namespace` for the areas,\n * `(row) => row.source` for kastlan's screen texts and documents.\n */\nexport function groupTranslationRows(\n rows: readonly TranslationRow[],\n groupOf: (row: TranslationRow) => string,\n): TranslationRowGroup[] {\n const byKey = new Map<string, TranslationRow[]>();\n for (const row of rows) {\n const key = groupOf(row);\n const list = byKey.get(key);\n if (list) list.push(row);\n else byKey.set(key, [row]);\n }\n return [...byKey].map(([key, list]) => ({ key, rows: list, summary: summariseRows(list) }));\n}\n\n/**\n * The rows a group's \"Approve the unreviewed\" takes: the ones nobody has given a verdict\n * and that have a text. Not `changed` — a string that moved since it was judged asks to\n * be READ again, which a bulk action is the opposite of — and not `missing`, which has\n * nothing to approve.\n */\nexport function unreviewedRows(rows: readonly TranslationRow[]): TranslationRow[] {\n return rows.filter((row) => row.status === \"unreviewed\" && row.text !== \"\");\n}\n\n// ── Writing ─────────────────────────────────────────────────────────────────────\n\n/** What gets stored for a verdict: the wording it was given on, so a later change of the\n * string (or of its reference) shows up as `changed`. */\nexport function reviewWrite(\n row: TranslationRow,\n verdict: TranslationVerdict,\n note: string | null = null,\n suggestion: string | null = null,\n): TranslationReviewWrite {\n return {\n locale: row.locale,\n key: row.key,\n text: row.text,\n referenceText: row.reference,\n verdict,\n note,\n suggestion,\n };\n}\n\n/** What takes a set of verdicts back: see {@link reviewUndo}. */\nexport interface TranslationReviewUndo {\n /** The verdicts the rows had before, to store again — each on the wording it was\n * given on, so a row that was `changed` reads `changed` again. */\n writes: TranslationReviewWrite[];\n /** The rows that had no verdict before: back to unreviewed. */\n clears: TranslationReviewKey[];\n}\n\n/**\n * How to take back what was just said about `rows` — the rows AS THEY WERE before the\n * write, with the verdicts they carried then. The panel's Undo toast (0.25, keksdose live\n * #377) runs it: a swipe on a phone approves in one movement, and a movement can be a\n * mistake.\n *\n * A row that had a verdict gets it stored again (its note, its suggestion, the wording it\n * was judged on); one that had none is cleared. The server stamps the restored verdict\n * with the person undoing and the time, as it stamps every write — the contract has no\n * way to write a verdict in somebody else's name, and should not.\n */\nexport function reviewUndo(rows: readonly TranslationRow[]): TranslationReviewUndo {\n const writes: TranslationReviewWrite[] = [];\n const clears: TranslationReviewKey[] = [];\n for (const row of rows) {\n const before = row.review;\n if (!before) {\n clears.push({ locale: row.locale, key: row.key });\n continue;\n }\n writes.push({\n locale: row.locale,\n key: row.key,\n text: before.text,\n referenceText: before.referenceText,\n verdict: before.verdict,\n note: before.note,\n suggestion: before.suggestion,\n });\n }\n return { writes, clears };\n}\n\n/** The app's cached verdict list with `written` in place of what was said before — a\n * save answers with the rows it wrote, so a page patches its copy instead of\n * downloading every verdict again after each click. Any spelling with `locale` and\n * `key` (the API's or the kit's). */\nexport function mergeReviews<T extends TranslationReviewKey>(prev: readonly T[], written: readonly T[]): T[] {\n const id = (r: TranslationReviewKey) => `${r.locale}|${r.key}`;\n const replaced = new Set(written.map(id));\n return [...prev.filter((r) => !replaced.has(id(r))), ...written];\n}\n\n/** The cached list without the verdicts on `cleared`. */\nexport function dropReviews<T extends TranslationReviewKey>(\n prev: readonly T[],\n cleared: readonly TranslationReviewKey[],\n): T[] {\n const gone = new Set(cleared.map((r) => `${r.locale}|${r.key}`));\n return prev.filter((r) => !gone.has(`${r.locale}|${r.key}`));\n}\n\n// ── Swipe bindings ──────────────────────────────────────────────────────────────\n\n/**\n * What a phone card's swipe can be bound to in `TranslationReviewPanel`'s `swipe`\n * (keksdose — Marcel's live #377 rework, 2026-10-03: *\"Add the swipe options to be shown\n * also to the settings /settings#interaction area where the other swipe options are\n * defined\"*). keksdose lets the user bind every list's swipes there — per side, a primary\n * action at the first threshold and a secondary one at a longer drag — and lists each\n * surface's ids in its `SWIPE_ACTIONS`; this is the translation list's, in the order a\n * settings page offers them.\n *\n * - `approve` — the string is right as it stands. With the panel's Undo toast.\n * - `edit` — open the editor with the cursor in the wording: \"Needs a change\" (or\n * \"Suggest translation\" on a missing string). Writes nothing; the editor does.\n * - `clear` — take the verdict back: unreviewed again. With the Undo toast, which stores\n * the verdict again.\n *\n * THERE IS NO SEPARATE \"needs a change\". The editor has no verdict to preselect: Approve\n * and \"Needs a change\" stand side by side in it, and \"Needs a change\" takes a note or a\n * different wording — a verdict without either tells whoever fixes the string nothing, so\n * a swipe never sends one blind (0.25). The one honest thing a \"needs a change\" swipe can\n * do is therefore open the editor with the cursor in the wording — which is `edit`, and\n * `edit` already says \"Needs a change\" on the card. A second id doing the same would arm\n * a second threshold that does what the first already did: the duplicate keksdose's\n * `resolveSwipePlan` drops for exactly that reason.\n */\nexport const TRANSLATION_REVIEW_SWIPE_ACTIONS = [\"approve\", \"edit\", \"clear\"] as const;\n\n/** One of {@link TRANSLATION_REVIEW_SWIPE_ACTIONS}. */\nexport type TranslationReviewSwipeAction = (typeof TRANSLATION_REVIEW_SWIPE_ACTIONS)[number];\n\n/**\n * Which swipe does what on a phone card — `TranslationReviewPanel`'s `swipe`. Each side is\n * an ordered ladder, exactly as `SwipeableRow` and DataTable's `mobileSwipeActions` model\n * one: index 0 commits at the first threshold, index 1 at the longer drag (and so on — the\n * thresholds spread evenly over the card's width). A side left out, or empty, does not\n * swipe.\n *\n * LOGICAL SIDES: `end` is a drag toward the reading end of the line — right in a\n * left-to-right page, left in a right-to-left one — and `start` the other way, so one\n * binding holds in both directions. An app whose settings store physical sides (keksdose's\n * `right`/`left`) hands `right` as `end` for a left-to-right page.\n */\nexport interface TranslationReviewSwipeBinding {\n /** A drag toward the reading START, nearest threshold first. */\n start?: readonly TranslationReviewSwipeAction[];\n /** A drag toward the reading END, nearest threshold first. */\n end?: readonly TranslationReviewSwipeAction[];\n}\n\n/** What `swipe={true}` means — 0.25's fixed mapping: approve toward the end, open the\n * editor (\"Needs a change\") toward the start. A settings page's \"reset\" goes back here. */\nexport const DEFAULT_TRANSLATION_REVIEW_SWIPE: TranslationReviewSwipeBinding = Object.freeze({\n start: Object.freeze([\"edit\"] as const),\n end: Object.freeze([\"approve\"] as const),\n});\n\n/** The ladders one row actually offers, from a {@link TranslationReviewSwipeBinding}. */\nexport interface TranslationReviewSwipePlan {\n start: TranslationReviewSwipeAction[];\n end: TranslationReviewSwipeAction[];\n}\n\n/**\n * The binding resolved against one row — keksdose's `resolveSwipePlan`, for this list.\n * An id the row cannot offer DROPS OUT and the ladder closes up behind it, so the second\n * stage becomes the first rather than the side going dead behind an unreachable first\n * stage (or arming a threshold that does nothing):\n *\n * - `approve`: not on a missing string (nothing to approve) or an approved one (it would\n * say it again) — the rows that have no approve button either;\n * - `clear`: not without `canClear` (the app passed no `onClear`), and not on a row with\n * no verdict to take back (unreviewed; missing with no suggestion);\n * - `edit`: on every row;\n * - an id named twice on one side: the second time (a longer drag to the same effect);\n * - an id this version does not know (a binding stored by another version, an app's own\n * \"none\" slot): dropped like one that does not apply.\n *\n * Only what the ROW decides. Whether the panel may write at all — `readOnly`, no\n * `onSave`, a write lock, the row's own write still out — is the panel's, and then no\n * side swipes.\n */\nexport function translationReviewSwipePlan(\n binding: TranslationReviewSwipeBinding,\n row: TranslationRow,\n { canClear = false }: { canClear?: boolean } = {},\n): TranslationReviewSwipePlan {\n const offers = (id: TranslationReviewSwipeAction): boolean => {\n switch (id) {\n case \"approve\":\n return row.text !== \"\" && row.status !== \"approved\";\n case \"edit\":\n return true;\n case \"clear\":\n return canClear && row.review !== null;\n default:\n return false;\n }\n };\n const side = (ids: readonly TranslationReviewSwipeAction[] | undefined): TranslationReviewSwipeAction[] => {\n const out: TranslationReviewSwipeAction[] = [];\n for (const id of ids ?? []) {\n if (!out.includes(id) && offers(id)) out.push(id);\n }\n return out;\n };\n return { start: side(binding.start), end: side(binding.end) };\n}\n\n// ── Export ──────────────────────────────────────────────────────────────────────\n\n/**\n * One entry of the \"Export corrections\" file — enough for a developer to apply the change\n * to the bundle without opening the page. snake_case `reviewed_at` on purpose: this is a\n * FILE, the one keksdose and kastlan already write, beside an API spelled that way.\n */\nexport interface TranslationCorrection {\n locale: string;\n key: string;\n status: ReviewStatus;\n current: string;\n reference: string;\n suggestion: string | null;\n note: string | null;\n reviewer: string | null;\n reviewed_at: string | null;\n}\n\n/** The rows sent back (verdict NEEDS_CHANGE — a suggested translation for a missing\n * string included), as the export file lists them. */\nexport function translationCorrections(rows: readonly TranslationRow[]): TranslationCorrection[] {\n return rows\n .filter((row) => row.review?.verdict === \"NEEDS_CHANGE\")\n .map((row) => ({\n locale: row.locale,\n key: row.key,\n status: row.status,\n current: row.text,\n reference: row.reference,\n suggestion: row.review?.suggestion ?? null,\n note: row.review?.note ?? null,\n reviewer: row.review?.reviewerName ?? null,\n reviewed_at: row.review?.reviewedAt ?? null,\n }));\n}\n"],"mappings":";AAwBA,SAAS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*/ jsx(EmptyState, { variant: "inline", title: labels.inboxEmpty, className: "px-3 py-2" });
|
|
146
146
|
} else {
|
|
147
147
|
body = // Named by the heading — except while "Clear all" asks, when the heading is away.
|
|
148
|
-
/* @__PURE__ */ jsxs(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
/* @__PURE__ */ jsxs(
|
|
149
|
+
List,
|
|
150
|
+
{
|
|
151
|
+
className: "p-1",
|
|
152
|
+
"aria-labelledby": asking ? void 0 : headingId,
|
|
153
|
+
"aria-label": asking ? labels.inboxTitle : void 0,
|
|
154
|
+
children: [
|
|
155
|
+
items.map((item) => {
|
|
156
|
+
const row = {
|
|
157
|
+
title: item.title,
|
|
158
|
+
subtitle: item.body,
|
|
159
|
+
subtitleLines: 2,
|
|
160
|
+
overline: item.company ?? void 0,
|
|
161
|
+
meta: timeOf(item.created_at),
|
|
162
|
+
icon: iconOf(item.notification_type),
|
|
163
|
+
unread: item.read_at === null,
|
|
164
|
+
align: "start"
|
|
165
|
+
};
|
|
166
|
+
if (onOpen) {
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
ListItem,
|
|
169
|
+
{
|
|
170
|
+
...row,
|
|
171
|
+
"data-inbox-item": String(item.id),
|
|
172
|
+
onClick: () => {
|
|
173
|
+
markOne(item);
|
|
174
|
+
onOpen(item);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
item.id
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
if (!item.url) {
|
|
181
|
+
return /* @__PURE__ */ jsx(ListItem, { ...row, "data-inbox-item": String(item.id), onClick: () => markOne(item) }, item.id);
|
|
182
|
+
}
|
|
183
|
+
return /* @__PURE__ */ jsx(
|
|
184
|
+
ListItem,
|
|
185
|
+
{
|
|
186
|
+
...row,
|
|
187
|
+
"data-inbox-item": String(item.id),
|
|
188
|
+
href: item.url,
|
|
189
|
+
external: !item.url.startsWith("/"),
|
|
190
|
+
onClick: () => markOne(item),
|
|
191
|
+
onAuxClick: (event) => {
|
|
192
|
+
if (event.button === 1) markOne(item);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
item.id
|
|
196
|
+
);
|
|
197
|
+
}),
|
|
198
|
+
hasMore && onLoadMore && /* @__PURE__ */ jsx("li", { className: "px-2 py-1", children: /* @__PURE__ */ jsx(
|
|
199
|
+
Button,
|
|
163
200
|
{
|
|
164
|
-
|
|
165
|
-
"
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
item.id
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
if (!item.url) {
|
|
175
|
-
return /* @__PURE__ */ jsx(ListItem, { ...row, "data-inbox-item": String(item.id), onClick: () => markOne(item) }, item.id);
|
|
176
|
-
}
|
|
177
|
-
return /* @__PURE__ */ jsx(
|
|
178
|
-
ListItem,
|
|
179
|
-
{
|
|
180
|
-
...row,
|
|
181
|
-
"data-inbox-item": String(item.id),
|
|
182
|
-
href: item.url,
|
|
183
|
-
external: !item.url.startsWith("/"),
|
|
184
|
-
onClick: () => markOne(item),
|
|
185
|
-
onAuxClick: (event) => {
|
|
186
|
-
if (event.button === 1) markOne(item);
|
|
201
|
+
type: "button",
|
|
202
|
+
size: "sm",
|
|
203
|
+
variant: "ghost",
|
|
204
|
+
pending: loadingMore,
|
|
205
|
+
onClick: onLoadMore,
|
|
206
|
+
className: "w-full",
|
|
207
|
+
children: labels.showMore
|
|
187
208
|
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
hasMore && onLoadMore && /* @__PURE__ */ jsx("li", { className: "px-2 py-1", children: /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", pending: loadingMore, onClick: onLoadMore, className: "w-full", children: labels.showMore }) })
|
|
193
|
-
] });
|
|
209
|
+
) })
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
);
|
|
194
213
|
}
|
|
195
214
|
return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("overflow-hidden p-0", className), children: [
|
|
196
215
|
header,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifications/notification-inbox.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\nimport { Bell, CheckCheck, Trash2 } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { useKitFormat } from \"../lib/format\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { EmptyState } from \"../components/empty-state\";\nimport { IconButton } from \"../components/icon-button\";\nimport { List, ListItem } from \"../components/list\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\n\n/**\n * One inbox row as `GET /notifications/inbox` answers it (server-kit `InboxItem`, §3.7):\n * the title and body already in the recipient's language.\n */\nexport interface NotificationInboxItem<Id extends string | number = string | number> {\n id: Id;\n /** The type id, for the row's icon. */\n notification_type: string;\n title: string;\n body: string;\n /** A path in the app, an absolute URL, or `null` (nothing to open). */\n url: string | null;\n /** ISO date-time. */\n created_at: string;\n /** ISO date-time, or `null` while unread. */\n read_at: string | null;\n /** 0.46 (server-kit 0.16 `InboxItem.company`): the company the row is about, named on\n * the row — kastlan's inbox holds every company's rows. */\n company?: string | null;\n /** 0.46.1 (server-kit 0.16.1 `InboxItem.company_id`): the same company by its id, so\n * `onOpen` switches to it exactly (two companies may share a name). */\n company_id?: number | string | null;\n}\n\n/** The inbox request that failed, as `describeError` gets it (0.46.1): one row marked read,\n * \"Mark all as read\", or \"Clear all\". */\nexport type NotificationInboxAction = \"read\" | \"readAll\" | \"clear\";\n\nexport interface NotificationInboxProps<Id extends string | number = string | number>\n extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"title\"> {\n /** The rows, newest first; `undefined` while the first page loads. */\n items: readonly NotificationInboxItem<Id>[] | undefined;\n /** Every unread row of the account (`unread_count`), not only this page's. */\n unreadCount: number;\n loading?: boolean;\n /** `POST /notifications/inbox/read {ids}` — these rows, or `null` for all. */\n onMarkRead: (ids: Id[] | null) => Promise<unknown> | void;\n /** `DELETE /notifications/inbox`. Asked first, in the header. */\n onClear: () => Promise<unknown> | void;\n /**\n * Open a row: the kit marks it read first, then calls this, and the app routes to\n * `item.url` (kastlan switches the acting company, `item.company_id`, first). Every row is a button then.\n * Left out, a row with a `url` is a real link — an in-app path through the provider's\n * router link, an absolute URL in a new tab — that marks itself read on a click or a\n * middle click (keksdose #451), and a row without one marks itself read.\n */\n onOpen?: (item: NotificationInboxItem<Id>) => void;\n /** The row's glyph for a type — the app's map (keksdose's `TYPE_ICONS`). `undefined`,\n * or a type it does not know (a retired one), is the `Bell`. */\n icon?: (type: string) => LucideIcon | undefined;\n /** More rows than shown: a \"Show more\" row calls `onLoadMore` (the API pages by\n * `offset`). */\n hasMore?: boolean;\n onLoadMore?: () => void;\n /** The next page is loading. */\n loadingMore?: boolean;\n /** A row's time. Default: the provider's locale and `timeZone`, date and time. */\n formatDate?: (iso: string) => string;\n /** The heading. Default `labels.inboxTitle` (\"Inbox\"). */\n title?: ReactNode;\n /** The app's own words for a failed request, or `undefined` for the kit's `failed`.\n * `action` (0.46.1) says which request failed: `\"read\"` (one row), `\"readAll\"` (\"Mark\n * all as read\") or `\"clear\"` (\"Clear all\") — so a failed mark-read is not worded as a\n * failed clear. */\n describeError?: (error: unknown, action: NotificationInboxAction) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/**\n * The in-app inbox (0.46, docs/notifications-harmonization.md §10.1), keksdose's list\n * lifted: newest first, an icon per type (`Bell` for one the app does not map), the\n * title and two lines of body, the time, and — kastlan — the company the row is about.\n * Unread rows are bold with a dot. Props only: the app keeps the data (poll the badge\n * every {@link INBOX_BADGE_INTERVAL}, invalidate on its worker's push message).\n *\n * - **Opening a row marks it read** (see `onOpen`).\n * - **\"Mark all as read\"** while anything is unread; **\"Clear all\"** asks first, in the\n * header — no `ConfirmProvider` needed — with focus on Cancel.\n * - **\"Show more\"** with `hasMore`; the list scrolls inside a box of at most\n * `min(24rem, 70vh)`, so it never pushes the settings below it off the page.\n *\n * Under a write lock the header's actions are `commit` controls exempt from billing.\n */\nexport function NotificationInbox<Id extends string | number = string | number>({\n items,\n unreadCount,\n loading,\n onMarkRead,\n onClear,\n onOpen,\n icon,\n hasMore = false,\n onLoadMore,\n loadingMore = false,\n formatDate: formatDateProp,\n title,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: NotificationInboxProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const { formatDate } = useKitFormat();\n const [asking, setAsking] = useState(false);\n const [busy, setBusy] = useState<\"read\" | \"clear\" | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n const headingId = useId();\n const cancelRef = useRef<HTMLButtonElement>(null);\n const clearRef = useRef<HTMLButtonElement>(null);\n const [returning, setReturning] = useState(false);\n useEffect(() => {\n if (asking) cancelRef.current?.focus();\n else if (returning) clearRef.current?.focus();\n }, [asking, returning]);\n\n const timeOf = (iso: string) => (formatDateProp ? formatDateProp(iso) : formatDate(iso, \"dateTime\"));\n const iconOf = (type: string): LucideIcon => icon?.(type) ?? Bell;\n\n const run = (which: \"read\" | \"clear\", call: () => unknown, after?: () => void) => {\n setBusy(which);\n setFailure(null);\n settle(call).then(\n () => {\n if (!mounted.current) return;\n setBusy(null);\n after?.();\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n setFailure(describeFailure(describeError?.(error, which === \"read\" ? \"readAll\" : \"clear\"), labels.failed));\n },\n );\n };\n\n /** Mark one row read; a failure is said under the list, the row stays as it is. */\n const markOne = (item: NotificationInboxItem<Id>) => {\n if (item.read_at !== null) return;\n settle(() => onMarkRead([item.id])).catch((error: unknown) => {\n if (mounted.current) setFailure(describeFailure(describeError?.(error, \"read\"), labels.failed));\n });\n };\n\n const leave = () => {\n setReturning(true);\n setAsking(false);\n };\n const escapeLeaves = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n leave();\n }\n };\n\n const count = items?.length ?? 0;\n\n const header = asking ? (\n <div className=\"space-y-2 border-b border-subtle px-3 py-2\" data-inbox-confirm=\"\">\n <p role=\"alert\" className=\"text-sm\">\n {labels.clearPrompt}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={busy === \"clear\"}\n onClick={() => run(\"clear\", onClear, () => setAsking(false))}\n onKeyDown={escapeLeaves}\n >\n {labels.clearAll}\n </Button>\n <Button ref={cancelRef} type=\"button\" size=\"sm\" variant=\"ghost\" onClick={leave} onKeyDown={escapeLeaves}>\n {common.cancel}\n </Button>\n </div>\n </div>\n ) : (\n <div className=\"flex items-center justify-between gap-2 border-b border-subtle px-3 py-2\">\n <SettingsCardTitle id={headingId}>{title ?? labels.inboxTitle}</SettingsCardTitle>\n <div className=\"flex items-center gap-0.5\">\n <IconButton\n type=\"button\"\n size=\"xs\"\n tone=\"muted\"\n commit={COMMIT_EXCEPT_BILLING}\n onClick={() => run(\"read\", () => onMarkRead(null))}\n disabled={unreadCount === 0 || busy !== null}\n label={labels.markAllRead}\n >\n <CheckCheck />\n </IconButton>\n <IconButton\n ref={clearRef}\n type=\"button\"\n size=\"xs\"\n tone=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n onClick={() => {\n setReturning(false);\n setAsking(true);\n }}\n disabled={count === 0 || busy !== null}\n label={labels.clearAll}\n >\n <Trash2 />\n </IconButton>\n </div>\n </div>\n );\n\n let body: ReactNode;\n if (loading || items === undefined) {\n body = <Skeleton lines={3} label={labels.inboxLoading} className=\"p-3\" />;\n } else if (items.length === 0) {\n body = <EmptyState variant=\"inline\" title={labels.inboxEmpty} className=\"px-3 py-2\" />;\n } else {\n body = (\n // Named by the heading — except while \"Clear all\" asks, when the heading is away.\n <List className=\"p-1\" aria-labelledby={asking ? undefined : headingId} aria-label={asking ? labels.inboxTitle : undefined}>\n {items.map((item) => {\n const row = {\n title: item.title,\n subtitle: item.body,\n subtitleLines: 2 as const,\n overline: item.company ?? undefined,\n meta: timeOf(item.created_at),\n icon: iconOf(item.notification_type),\n unread: item.read_at === null,\n align: \"start\" as const,\n };\n if (onOpen) {\n return (\n <ListItem\n key={item.id}\n {...row}\n data-inbox-item={String(item.id)}\n onClick={() => {\n markOne(item);\n onOpen(item);\n }}\n />\n );\n }\n if (!item.url) {\n return <ListItem key={item.id} {...row} data-inbox-item={String(item.id)} onClick={() => markOne(item)} />;\n }\n // A real link, so a middle click opens a background tab; a middle click fires no\n // `click`, hence `onAuxClick` (keksdose #451).\n return (\n <ListItem\n key={item.id}\n {...row}\n data-inbox-item={String(item.id)}\n href={item.url}\n external={!item.url.startsWith(\"/\")}\n onClick={() => markOne(item)}\n onAuxClick={(event) => {\n if (event.button === 1) markOne(item);\n }}\n />\n );\n })}\n {hasMore && onLoadMore && (\n <li className=\"px-2 py-1\">\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" pending={loadingMore} onClick={onLoadMore} className=\"w-full\">\n {labels.showMore}\n </Button>\n </li>\n )}\n </List>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"overflow-hidden p-0\", className)}>\n {header}\n <div className=\"max-h-[min(24rem,70vh)] overflow-y-auto overscroll-contain\">{body}</div>\n {failure !== null && (\n <div className=\"px-3 pb-3\">\n <FailureLine>{failure}</FailureLine>\n </div>\n )}\n </Card>\n );\n}\n\n/** How often an app polls the unread count for the badge (keksdose's 60 s, `limit:1`). */\nexport const INBOX_BADGE_INTERVAL = 60_000;\n"],"mappings":";AAsLM,cAGA,YAHA;AAtLN,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,MAAM,YAAY,cAAc;AAGzC,SAAS,oBAAwC;AACjD,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,aAAa,8BAA8B;AAsF9D,SAAS,kBAAgE;AAAA,EAC9E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,cAAc;AAAA,EACd,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAA+B;AAC7B,QAAM,SAAS,uBAAuB,UAAU;AAChD,QAAM,SAAS,aAAa,UAAU,qBAAqB;AAC3D,QAAM,EAAE,WAAW,IAAI,aAAa;AACpC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAC1C,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkC,IAAI;AAC9D,QAAM,CAAC,SAAS,UAAU,IAAI,SAAoB,IAAI;AACtD,QAAM,UAAU,WAAW;AAC3B,QAAM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,YAC3B,YAAY,CAAC,UAAU;AACrB,kBAAI,MAAM,WAAW,EAAG,SAAQ,IAAI;AAAA,YACtC;AAAA;AAAA,UARK,KAAK;AAAA,QASZ;AAAA,MAEJ,CAAC;AAAA,MACA,WAAW,cACV,oBAAC,QAAG,WAAU,aACZ,8BAAC,UAAO,MAAK,UAAS,MAAK,MAAK,SAAQ,SAAQ,SAAS,aAAa,SAAS,YAAY,WAAU,UAClG,iBAAO,UACV,GACF;AAAA,OAEJ;AAAA,EAEJ;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,uBAAuB,SAAS,GAC3D;AAAA;AAAA,IACD,oBAAC,SAAI,WAAU,8DAA8D,gBAAK;AAAA,IACjF,YAAY,QACX,oBAAC,SAAI,WAAU,aACb,8BAAC,eAAa,mBAAQ,GACxB;AAAA,KAEJ;AAEJ;AAGO,MAAM,uBAAuB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/notification-inbox.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\nimport { Bell, CheckCheck, Trash2 } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { useKitFormat } from \"../lib/format\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { EmptyState } from \"../components/empty-state\";\nimport { IconButton } from \"../components/icon-button\";\nimport { List, ListItem } from \"../components/list\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\n\n/**\n * One inbox row as `GET /notifications/inbox` answers it (server-kit `InboxItem`, §3.7):\n * the title and body already in the recipient's language.\n */\nexport interface NotificationInboxItem<Id extends string | number = string | number> {\n id: Id;\n /** The type id, for the row's icon. */\n notification_type: string;\n title: string;\n body: string;\n /** A path in the app, an absolute URL, or `null` (nothing to open). */\n url: string | null;\n /** ISO date-time. */\n created_at: string;\n /** ISO date-time, or `null` while unread. */\n read_at: string | null;\n /** 0.46 (server-kit 0.16 `InboxItem.company`): the company the row is about, named on\n * the row — kastlan's inbox holds every company's rows. */\n company?: string | null;\n /** 0.46.1 (server-kit 0.16.1 `InboxItem.company_id`): the same company by its id, so\n * `onOpen` switches to it exactly (two companies may share a name). */\n company_id?: number | string | null;\n}\n\n/** The inbox request that failed, as `describeError` gets it (0.46.1): one row marked read,\n * \"Mark all as read\", or \"Clear all\". */\nexport type NotificationInboxAction = \"read\" | \"readAll\" | \"clear\";\n\nexport interface NotificationInboxProps<Id extends string | number = string | number> extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"children\" | \"title\"\n> {\n /** The rows, newest first; `undefined` while the first page loads. */\n items: readonly NotificationInboxItem<Id>[] | undefined;\n /** Every unread row of the account (`unread_count`), not only this page's. */\n unreadCount: number;\n loading?: boolean;\n /** `POST /notifications/inbox/read {ids}` — these rows, or `null` for all. */\n onMarkRead: (ids: Id[] | null) => Promise<unknown> | void;\n /** `DELETE /notifications/inbox`. Asked first, in the header. */\n onClear: () => Promise<unknown> | void;\n /**\n * Open a row: the kit marks it read first, then calls this, and the app routes to\n * `item.url` (kastlan switches the acting company, `item.company_id`, first). Every row is a button then.\n * Left out, a row with a `url` is a real link — an in-app path through the provider's\n * router link, an absolute URL in a new tab — that marks itself read on a click or a\n * middle click (keksdose #451), and a row without one marks itself read.\n */\n onOpen?: (item: NotificationInboxItem<Id>) => void;\n /** The row's glyph for a type — the app's map (keksdose's `TYPE_ICONS`). `undefined`,\n * or a type it does not know (a retired one), is the `Bell`. */\n icon?: (type: string) => LucideIcon | undefined;\n /** More rows than shown: a \"Show more\" row calls `onLoadMore` (the API pages by\n * `offset`). */\n hasMore?: boolean;\n onLoadMore?: () => void;\n /** The next page is loading. */\n loadingMore?: boolean;\n /** A row's time. Default: the provider's locale and `timeZone`, date and time. */\n formatDate?: (iso: string) => string;\n /** The heading. Default `labels.inboxTitle` (\"Inbox\"). */\n title?: ReactNode;\n /** The app's own words for a failed request, or `undefined` for the kit's `failed`.\n * `action` (0.46.1) says which request failed: `\"read\"` (one row), `\"readAll\"` (\"Mark\n * all as read\") or `\"clear\"` (\"Clear all\") — so a failed mark-read is not worded as a\n * failed clear. */\n describeError?: (error: unknown, action: NotificationInboxAction) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/**\n * The in-app inbox (0.46, docs/notifications-harmonization.md §10.1), keksdose's list\n * lifted: newest first, an icon per type (`Bell` for one the app does not map), the\n * title and two lines of body, the time, and — kastlan — the company the row is about.\n * Unread rows are bold with a dot. Props only: the app keeps the data (poll the badge\n * every {@link INBOX_BADGE_INTERVAL}, invalidate on its worker's push message).\n *\n * - **Opening a row marks it read** (see `onOpen`).\n * - **\"Mark all as read\"** while anything is unread; **\"Clear all\"** asks first, in the\n * header — no `ConfirmProvider` needed — with focus on Cancel.\n * - **\"Show more\"** with `hasMore`; the list scrolls inside a box of at most\n * `min(24rem, 70vh)`, so it never pushes the settings below it off the page.\n *\n * Under a write lock the header's actions are `commit` controls exempt from billing.\n */\nexport function NotificationInbox<Id extends string | number = string | number>({\n items,\n unreadCount,\n loading,\n onMarkRead,\n onClear,\n onOpen,\n icon,\n hasMore = false,\n onLoadMore,\n loadingMore = false,\n formatDate: formatDateProp,\n title,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: NotificationInboxProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const { formatDate } = useKitFormat();\n const [asking, setAsking] = useState(false);\n const [busy, setBusy] = useState<\"read\" | \"clear\" | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n const headingId = useId();\n const cancelRef = useRef<HTMLButtonElement>(null);\n const clearRef = useRef<HTMLButtonElement>(null);\n const [returning, setReturning] = useState(false);\n useEffect(() => {\n if (asking) cancelRef.current?.focus();\n else if (returning) clearRef.current?.focus();\n }, [asking, returning]);\n\n const timeOf = (iso: string) => (formatDateProp ? formatDateProp(iso) : formatDate(iso, \"dateTime\"));\n const iconOf = (type: string): LucideIcon => icon?.(type) ?? Bell;\n\n const run = (which: \"read\" | \"clear\", call: () => unknown, after?: () => void) => {\n setBusy(which);\n setFailure(null);\n settle(call).then(\n () => {\n if (!mounted.current) return;\n setBusy(null);\n after?.();\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setBusy(null);\n setFailure(describeFailure(describeError?.(error, which === \"read\" ? \"readAll\" : \"clear\"), labels.failed));\n },\n );\n };\n\n /** Mark one row read; a failure is said under the list, the row stays as it is. */\n const markOne = (item: NotificationInboxItem<Id>) => {\n if (item.read_at !== null) return;\n settle(() => onMarkRead([item.id])).catch((error: unknown) => {\n if (mounted.current) setFailure(describeFailure(describeError?.(error, \"read\"), labels.failed));\n });\n };\n\n const leave = () => {\n setReturning(true);\n setAsking(false);\n };\n const escapeLeaves = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n leave();\n }\n };\n\n const count = items?.length ?? 0;\n\n const header = asking ? (\n <div className=\"space-y-2 border-b border-subtle px-3 py-2\" data-inbox-confirm=\"\">\n <p role=\"alert\" className=\"text-sm\">\n {labels.clearPrompt}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={busy === \"clear\"}\n onClick={() => run(\"clear\", onClear, () => setAsking(false))}\n onKeyDown={escapeLeaves}\n >\n {labels.clearAll}\n </Button>\n <Button ref={cancelRef} type=\"button\" size=\"sm\" variant=\"ghost\" onClick={leave} onKeyDown={escapeLeaves}>\n {common.cancel}\n </Button>\n </div>\n </div>\n ) : (\n <div className=\"flex items-center justify-between gap-2 border-b border-subtle px-3 py-2\">\n <SettingsCardTitle id={headingId}>{title ?? labels.inboxTitle}</SettingsCardTitle>\n <div className=\"flex items-center gap-0.5\">\n <IconButton\n type=\"button\"\n size=\"xs\"\n tone=\"muted\"\n commit={COMMIT_EXCEPT_BILLING}\n onClick={() => run(\"read\", () => onMarkRead(null))}\n disabled={unreadCount === 0 || busy !== null}\n label={labels.markAllRead}\n >\n <CheckCheck />\n </IconButton>\n <IconButton\n ref={clearRef}\n type=\"button\"\n size=\"xs\"\n tone=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n onClick={() => {\n setReturning(false);\n setAsking(true);\n }}\n disabled={count === 0 || busy !== null}\n label={labels.clearAll}\n >\n <Trash2 />\n </IconButton>\n </div>\n </div>\n );\n\n let body: ReactNode;\n if (loading || items === undefined) {\n body = <Skeleton lines={3} label={labels.inboxLoading} className=\"p-3\" />;\n } else if (items.length === 0) {\n body = <EmptyState variant=\"inline\" title={labels.inboxEmpty} className=\"px-3 py-2\" />;\n } else {\n body = (\n // Named by the heading — except while \"Clear all\" asks, when the heading is away.\n <List\n className=\"p-1\"\n aria-labelledby={asking ? undefined : headingId}\n aria-label={asking ? labels.inboxTitle : undefined}\n >\n {items.map((item) => {\n const row = {\n title: item.title,\n subtitle: item.body,\n subtitleLines: 2 as const,\n overline: item.company ?? undefined,\n meta: timeOf(item.created_at),\n icon: iconOf(item.notification_type),\n unread: item.read_at === null,\n align: \"start\" as const,\n };\n if (onOpen) {\n return (\n <ListItem\n key={item.id}\n {...row}\n data-inbox-item={String(item.id)}\n onClick={() => {\n markOne(item);\n onOpen(item);\n }}\n />\n );\n }\n if (!item.url) {\n return <ListItem key={item.id} {...row} data-inbox-item={String(item.id)} onClick={() => markOne(item)} />;\n }\n // A real link, so a middle click opens a background tab; a middle click fires no\n // `click`, hence `onAuxClick` (keksdose #451).\n return (\n <ListItem\n key={item.id}\n {...row}\n data-inbox-item={String(item.id)}\n href={item.url}\n external={!item.url.startsWith(\"/\")}\n onClick={() => markOne(item)}\n onAuxClick={(event) => {\n if (event.button === 1) markOne(item);\n }}\n />\n );\n })}\n {hasMore && onLoadMore && (\n <li className=\"px-2 py-1\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n pending={loadingMore}\n onClick={onLoadMore}\n className=\"w-full\"\n >\n {labels.showMore}\n </Button>\n </li>\n )}\n </List>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"overflow-hidden p-0\", className)}>\n {header}\n <div className=\"max-h-[min(24rem,70vh)] overflow-y-auto overscroll-contain\">{body}</div>\n {failure !== null && (\n <div className=\"px-3 pb-3\">\n <FailureLine>{failure}</FailureLine>\n </div>\n )}\n </Card>\n );\n}\n\n/** How often an app polls the unread count for the badge (keksdose's 60 s, `limit:1`). */\nexport const INBOX_BADGE_INTERVAL = 60_000;\n"],"mappings":";AAwLM,cAGA,YAHA;AAxLN,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,MAAM,YAAY,cAAc;AAGzC,SAAS,oBAAwC;AACjD,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,aAAa,8BAA8B;AAwF9D,SAAS,kBAAgE;AAAA,EAC9E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,cAAc;AAAA,EACd,YAAY;AAAA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BACb;AAAA;AAAA,gBANK,KAAK;AAAA,cAOZ;AAAA,YAEJ;AACA,gBAAI,CAAC,KAAK,KAAK;AACb,qBAAO,oBAAC,YAAwB,GAAG,KAAK,mBAAiB,OAAO,KAAK,EAAE,GAAG,SAAS,MAAM,QAAQ,IAAI,KAA/E,KAAK,EAA6E;AAAA,YAC1G;AAGA,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEE,GAAG;AAAA,gBACJ,mBAAiB,OAAO,KAAK,EAAE;AAAA,gBAC/B,MAAM,KAAK;AAAA,gBACX,UAAU,CAAC,KAAK,IAAI,WAAW,GAAG;AAAA,gBAClC,SAAS,MAAM,QAAQ,IAAI;AAAA,gBAC3B,YAAY,CAAC,UAAU;AACrB,sBAAI,MAAM,WAAW,EAAG,SAAQ,IAAI;AAAA,gBACtC;AAAA;AAAA,cARK,KAAK;AAAA,YASZ;AAAA,UAEJ,CAAC;AAAA,UACA,WAAW,cACV,oBAAC,QAAG,WAAU,aACZ;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,SAAS;AAAA,cACT,SAAS;AAAA,cACT,WAAU;AAAA,cAET,iBAAO;AAAA;AAAA,UACV,GACF;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,uBAAuB,SAAS,GAC3D;AAAA;AAAA,IACD,oBAAC,SAAI,WAAU,8DAA8D,gBAAK;AAAA,IACjF,YAAY,QACX,oBAAC,SAAI,WAAU,aACb,8BAAC,eAAa,mBAAQ,GACxB;AAAA,KAEJ;AAEJ;AAGO,MAAM,uBAAuB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifications/notification-parts.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { hasContent } from \"../lib/presence\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { DEFAULT_NOTIFICATIONS_LABELS } from \"./notifications-labels\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\n\n/**\n * What the notification cards share: their words, the failure line under a card, and\n * the overlay a card shows while its write runs.\n *\n * @internal Not part of the barrel; the cards are.\n */\n\n/** The `notifications` namespace: English, then the provider, then the card's prop. */\nexport function useNotificationsLabels(prop?: LabelOverride<NotificationsLabels>): NotificationsLabels {\n return useKitLabels(\"notifications\", DEFAULT_NOTIFICATIONS_LABELS, prop);\n}\n\n/** The app's words for a failure, else `fallback`. */\nexport function describeFailure(own: ReactNode | undefined, fallback: ReactNode): ReactNode {\n return hasContent(own) ? own : fallback;\n}\n\n/** A failure, said under the card's controls — nothing toasts (§4.2). */\nexport function FailureLine({ children }: { children: ReactNode }) {\n if (!hasContent(children)) return null;\n return (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {children}\n </AlertBanner>\n );\n}\n\n/** What {@link useWriteOverlay} answers. */\nexport interface WriteOverlay<V> {\n has: (key: string) => boolean;\n get: (key: string) => V | undefined;\n pending: (key: string) => boolean;\n set: (key: string, value: V) => void;\n settle: (key: string, ok: boolean) => void;\n}\n\n/**\n * Values a card shows while its write runs, over what the server last answered.\n *\n * `set(key, value)` shows `value` at once; `settle(key, ok)` drops it again when the\n * write failed (the server's value comes back) and keeps it when it succeeded, until the\n * app hands the card a new `source` — the PATCH's answer, or a refetch — which clears\n * every settled entry, so a card whose app does not update its query on success does not\n * flick back to the old value in between. `pending(key)` says whether a write for `key`\n * is still running.\n *\n * The reset on a new `source` is React's \"adjust state while rendering\" pattern, not an\n * effect: the overlay is gone in the same render that shows the new value.\n */\nexport function useWriteOverlay<V>(source: unknown): WriteOverlay<V> {\n const [entries, setEntries] = useState<ReadonlyMap<string, { value: V; running: boolean }>>(new Map());\n const [seen, setSeen] = useState(source);\n if (seen !== source) {\n setSeen(source);\n const kept = new Map([...entries].filter(([, entry]) => entry.running));\n if (kept.size !== entries.size) setEntries(kept);\n }\n return {\n has: (key: string) => entries.has(key),\n get: (key: string) => entries.get(key)?.value,\n pending: (key: string) => entries.get(key)?.running === true,\n set: (key: string, value: V)
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/notification-parts.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { hasContent } from \"../lib/presence\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { DEFAULT_NOTIFICATIONS_LABELS } from \"./notifications-labels\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\n\n/**\n * What the notification cards share: their words, the failure line under a card, and\n * the overlay a card shows while its write runs.\n *\n * @internal Not part of the barrel; the cards are.\n */\n\n/** The `notifications` namespace: English, then the provider, then the card's prop. */\nexport function useNotificationsLabels(prop?: LabelOverride<NotificationsLabels>): NotificationsLabels {\n return useKitLabels(\"notifications\", DEFAULT_NOTIFICATIONS_LABELS, prop);\n}\n\n/** The app's words for a failure, else `fallback`. */\nexport function describeFailure(own: ReactNode | undefined, fallback: ReactNode): ReactNode {\n return hasContent(own) ? own : fallback;\n}\n\n/** A failure, said under the card's controls — nothing toasts (§4.2). */\nexport function FailureLine({ children }: { children: ReactNode }) {\n if (!hasContent(children)) return null;\n return (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {children}\n </AlertBanner>\n );\n}\n\n/** What {@link useWriteOverlay} answers. */\nexport interface WriteOverlay<V> {\n has: (key: string) => boolean;\n get: (key: string) => V | undefined;\n pending: (key: string) => boolean;\n set: (key: string, value: V) => void;\n settle: (key: string, ok: boolean) => void;\n}\n\n/**\n * Values a card shows while its write runs, over what the server last answered.\n *\n * `set(key, value)` shows `value` at once; `settle(key, ok)` drops it again when the\n * write failed (the server's value comes back) and keeps it when it succeeded, until the\n * app hands the card a new `source` — the PATCH's answer, or a refetch — which clears\n * every settled entry, so a card whose app does not update its query on success does not\n * flick back to the old value in between. `pending(key)` says whether a write for `key`\n * is still running.\n *\n * The reset on a new `source` is React's \"adjust state while rendering\" pattern, not an\n * effect: the overlay is gone in the same render that shows the new value.\n */\nexport function useWriteOverlay<V>(source: unknown): WriteOverlay<V> {\n const [entries, setEntries] = useState<ReadonlyMap<string, { value: V; running: boolean }>>(new Map());\n const [seen, setSeen] = useState(source);\n if (seen !== source) {\n setSeen(source);\n const kept = new Map([...entries].filter(([, entry]) => entry.running));\n if (kept.size !== entries.size) setEntries(kept);\n }\n return {\n has: (key: string) => entries.has(key),\n get: (key: string) => entries.get(key)?.value,\n pending: (key: string) => entries.get(key)?.running === true,\n set: (key: string, value: V) => setEntries((current) => new Map(current).set(key, { value, running: true })),\n settle: (key: string, ok: boolean) =>\n setEntries((current) => {\n const entry = current.get(key);\n if (!entry) return current;\n const next = new Map(current);\n if (ok) next.set(key, { value: entry.value, running: false });\n else next.delete(key);\n return next;\n }),\n };\n}\n"],"mappings":";AA8BI;AA9BJ,SAAS,gBAAgB;AAGzB,SAAS,oBAAwC;AACjD,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,oCAAoC;AAWtC,SAAS,uBAAuB,MAAgE;AACrG,SAAO,aAAa,iBAAiB,8BAA8B,IAAI;AACzE;AAGO,SAAS,gBAAgB,KAA4B,UAAgC;AAC1F,SAAO,WAAW,GAAG,IAAI,MAAM;AACjC;AAGO,SAAS,YAAY,EAAE,SAAS,GAA4B;AACjE,MAAI,CAAC,WAAW,QAAQ,EAAG,QAAO;AAClC,SACE,oBAAC,eAAY,MAAK,UAAS,MAAK,MAAK,MAAK,SACvC,UACH;AAEJ;AAwBO,SAAS,gBAAmB,QAAkC;AACnE,QAAM,CAAC,SAAS,UAAU,IAAI,SAA8D,oBAAI,IAAI,CAAC;AACrG,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,MAAM;AACvC,MAAI,SAAS,QAAQ;AACnB,YAAQ,MAAM;AACd,UAAM,OAAO,IAAI,IAAI,CAAC,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,MAAM,OAAO,CAAC;AACtE,QAAI,KAAK,SAAS,QAAQ,KAAM,YAAW,IAAI;AAAA,EACjD;AACA,SAAO;AAAA,IACL,KAAK,CAAC,QAAgB,QAAQ,IAAI,GAAG;AAAA,IACrC,KAAK,CAAC,QAAgB,QAAQ,IAAI,GAAG,GAAG;AAAA,IACxC,SAAS,CAAC,QAAgB,QAAQ,IAAI,GAAG,GAAG,YAAY;AAAA,IACxD,KAAK,CAAC,KAAa,UAAa,WAAW,CAAC,YAAY,IAAI,IAAI,OAAO,EAAE,IAAI,KAAK,EAAE,OAAO,SAAS,KAAK,CAAC,CAAC;AAAA,IAC3G,QAAQ,CAAC,KAAa,OACpB,WAAW,CAAC,YAAY;AACtB,YAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,OAAO,IAAI,IAAI,OAAO;AAC5B,UAAI,GAAI,MAAK,IAAI,KAAK,EAAE,OAAO,MAAM,OAAO,SAAS,MAAM,CAAC;AAAA,UACvD,MAAK,OAAO,GAAG;AACpB,aAAO;AAAA,IACT,CAAC;AAAA,EACL;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifications/notification-types-setting.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { hasContent } from \"../lib/presence\";\nimport { Card } from \"../components/card\";\nimport { Select } from \"../components/select\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Switch } from \"../components/switch\";\nimport { SectionLabel } from \"../components/text\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { usePhoneLayout } from \"../hooks/use-breakpoint\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from \"./notification-parts\";\nimport type { WriteOverlay } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type {\n DigestCadence,\n NotificationChannel,\n NotificationSettingsPatch,\n NotificationSwitches,\n NotificationTypeEntry,\n NotificationTypeGroup,\n NotificationTypesValue,\n} from \"./notification-types\";\n\n/** Is this a development build? Dead code in a consumer's production bundle; on under\n * vitest, where a type the card cannot draw is a bug a test should fail on (as\n * `SettingsSection`'s catalogue check). */\nfunction devChecks(): boolean {\n return Boolean(import.meta.env?.DEV);\n}\n\nexport interface NotificationTypesSettingProps<Id extends string = string>\n extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onChange\"> {\n /** The app's words for its types, in its order. Where an app types its ids. */\n types: readonly NotificationTypeEntry<Id>[];\n /** The `GET`'s `types` (§3.2); `undefined` while the first load runs. */\n value: NotificationTypesValue | undefined;\n /** The settings are loading. */\n loading?: boolean;\n /**\n * Save one change — `PATCH /notifications/settings` with this body: one switch per\n * call (`{types: {digest: {app: true}}}`), or `{digest_cadence}`. The switch shows its\n * new state while the call runs and goes back if it rejects; hand the card the\n * PATCH's answer (or refetch) when it resolves.\n */\n onChange: (patch: NotificationSettingsPatch<Id>) => Promise<unknown> | void;\n /** Headings over the types, in the app's words (keksdose's three). Without them, one\n * list in the order of `types`. In development every type the server answered must\n * be in one. */\n groups?: readonly NotificationTypeGroup<Id>[];\n /** The digest type and the account's cadence: a cadence `Select` under that type\n * while it is on. */\n digest?: { type: Id; cadence: DigestCadence };\n /** Under a type while it is on — keksdose's low-balance threshold field. */\n renderExtra?: (id: Id) => ReactNode;\n /** The account's address is unverified: every e-mail switch says\n * `labels.emailUnverified` under it (decision 16). */\n emailUnverified?: boolean;\n /** Nothing can be changed (the switches stay readable). */\n disabled?: boolean;\n /** The app's own words for a failed save, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** One drawn type: the app's words and the server's switches. */\ninterface Row<Id extends string> {\n entry: NotificationTypeEntry<Id>;\n switches: NotificationSwitches;\n}\n\n/** A switch's key in the write overlay. */\nconst switchKey = (id: string, channel: NotificationChannel) => `${id}.${channel}`;\nconst CADENCE_KEY = \"digest_cadence\";\n\n/** The grid of a several-channel row on a wide screen: the type's words, then one narrow\n * column per channel drawn. Literal classes, so Tailwind's scan finds them. */\nconst COLUMN_GRID: Record<number, string> = {\n 1: \"grid-cols-[minmax(0,1fr)_4.5rem]\",\n 2: \"grid-cols-[minmax(0,1fr)_repeat(2,4.5rem)]\",\n 3: \"grid-cols-[minmax(0,1fr)_repeat(3,4.5rem)]\",\n};\n\n/** The channels in the card's column order (§10.2). */\nconst CHANNELS: readonly NotificationChannel[] = [\"app\", \"push\", \"email\"];\n\n/** The channels a type offers: every one the server did not answer `null` (or leave out,\n * as `push` before server-kit 0.16). */\nconst channelsOf = (switches: NotificationSwitches): NotificationChannel[] =>\n CHANNELS.filter((channel) => switches[channel] !== null && switches[channel] !== undefined);\n\n/**\n * What the person hears about, and how (docs/notifications-harmonization.md §2.1–§2.3,\n * §4.2, §10.2): one row per type the SERVER answered, the app's words on it, and a switch\n * per channel the type offers — \"In the app\", \"Push\", \"E-mail\". On a wide screen they are\n * narrow columns under those headings; on a phone they stack under the type's label. A\n * channel the server answers `null` is not drawn (kastlan and KS offer no push; KS no\n * \"in the app\"), and a row with one channel keeps a single switch named by the type\n * (Kurvenschmiede's e-mail-only rows).\n *\n * **The server's list is the only list.** The card keeps no defaults and no list of\n * types: it draws what `value` holds, in the order of `groups`, else of `types`. A type\n * the app names that the server did not answer is not drawn (kastlan's tenant receives\n * neither of its types). In development a type the server answered with no entry in\n * `types`, or in no group when `groups` is given, throws — keksdose's compile-time\n * `_EVERY_TYPE_IS_GROUPED`, now at run time, since the list is the server's.\n *\n * **Each flip saves at once**, one switch per call; the switch shows its new state while\n * the call runs and goes back if it rejects, with the failure said under the card. The\n * digest's cadence and the app's extra field (`renderExtra`) show under their type while\n * it is on.\n *\n * Under a write lock the switches are `commit` controls exempt from billing: a lapsed\n * plan never keeps a person from turning notifications off (billing §12.13).\n */\nexport function NotificationTypesSetting<Id extends string = string>({\n types,\n value,\n loading,\n onChange,\n groups,\n digest,\n renderExtra,\n emailUnverified = false,\n disabled = false,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: NotificationTypesSettingProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const overlay = useWriteOverlay<boolean>(value);\n const cadenceOverlay = useWriteOverlay<DigestCadence>(digest?.cadence);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n const groupId = useId();\n\n const answered = value ? Object.keys(value) : [];\n const entries = new Map(types.map((entry) => [entry.id as string, entry]));\n if (value && devChecks()) {\n const unnamed = answered.filter((id) => !entries.has(id));\n if (unnamed.length) {\n throw new Error(\n `NotificationTypesSetting: the server answered ${unnamed.map((id) => `\"${id}\"`).join(\", \")} with no entry in \\`types\\` — give every type the server can send its words.`,\n );\n }\n if (groups) {\n const grouped = new Set<string>(groups.flatMap((group) => group.types));\n const loose = answered.filter((id) => !grouped.has(id));\n if (loose.length) {\n throw new Error(\n `NotificationTypesSetting: ${loose.map((id) => `\"${id}\"`).join(\", \")} is in no group — a type in no group is drawn nowhere, and could not be turned off.`,\n );\n }\n }\n }\n\n const phone = usePhoneLayout();\n const rowOf = (id: Id): Row<Id> | null => {\n const switches = value?.[id];\n const entry = entries.get(id);\n if (!switches || !entry || channelsOf(switches).length === 0) return null;\n return { entry, switches };\n };\n const rowsOf = (ids: readonly Id[]) => ids.map(rowOf).filter((row): row is Row<Id> => row !== null);\n\n const shown = (id: string, channel: NotificationChannel, server: boolean): boolean => {\n const key = switchKey(id, channel);\n return overlay.get(key) ?? server;\n };\n const channelOn = ({ entry, switches }: Row<Id>, channel: NotificationChannel) =>\n shown(entry.id, channel, switches[channel] === true);\n /** The type reaches the person at all: some channel is on (the cadence and the app's\n * extra show then). */\n const rowOn = (row: Row<Id>) => channelsOf(row.switches).some((channel) => channelOn(row, channel));\n\n const save = <V,>(key: string, patch: NotificationSettingsPatch<Id>, which: WriteOverlay<V>, next: V) => {\n if (which.pending(key)) return;\n setFailure(null);\n which.set(key, next);\n settle(() => onChange(patch)).then(\n () => {\n if (mounted.current) which.settle(key, true);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n which.settle(key, false);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n },\n );\n };\n\n const flip = (id: Id, channel: NotificationChannel, on: boolean) =>\n save(\n switchKey(id, channel),\n { types: { [id]: { [channel]: on } } as NotificationSettingsPatch<Id>[\"types\"] },\n overlay,\n on,\n );\n\n const cadence = cadenceOverlay.get(CADENCE_KEY) ?? digest?.cadence;\n\n const unverifiedLine = emailUnverified ? (\n <span className=\"block\" data-email-unverified=\"\">\n {labels.emailUnverified}\n </span>\n ) : null;\n\n const channelLabel: Record<NotificationChannel, string> = {\n app: labels.channelApp,\n push: labels.channelPush,\n email: labels.channelEmail,\n };\n /** The columns on a wide screen: every channel some several-channel row offers. */\n const drawnRows = value && !loading ? rowsOf(groups ? groups.flatMap((group) => group.types) : types.map((entry) => entry.id)) : [];\n const multi = drawnRows.filter((row) => channelsOf(row.switches).length > 1);\n const columns = CHANNELS.filter((channel) => multi.some((row) => channelsOf(row.switches).includes(channel)));\n const columnHeadings =\n !phone && columns.length > 0 ? (\n // The switches carry the channel's name themselves; the headings are for the eye.\n <div aria-hidden className={cn(\"grid gap-x-2\", COLUMN_GRID[columns.length])} data-channel-headings=\"\">\n <span />\n {columns.map((channel) => (\n <span key={channel} className=\"text-center text-caption font-medium text-muted\">\n {channelLabel[channel]}\n </span>\n ))}\n </div>\n ) : null;\n\n const renderRow = (row: Row<Id>) => {\n const { entry, switches } = row;\n const on = rowOn(row);\n const offered = channelsOf(switches);\n const single = offered.length === 1 ? offered[0] : null;\n const cadenceSelect =\n on && digest?.type === entry.id && cadence ? (\n <Select\n label={labels.digestCadence}\n value={cadence}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onChange={(event) => {\n const next = event.target.value as DigestCadence;\n if (next !== cadence) save(CADENCE_KEY, { digest_cadence: next }, cadenceOverlay, next);\n }}\n className=\"max-w-44\"\n >\n <option value=\"weekly\">{labels.digestWeekly}</option>\n <option value=\"monthly\">{labels.digestMonthly}</option>\n </Select>\n ) : null;\n const extra = on ? renderExtra?.(entry.id) : null;\n const below =\n cadenceSelect || hasContent(extra) ? (\n <div className=\"ps-4 space-y-2\">\n {cadenceSelect}\n {extra}\n </div>\n ) : null;\n\n // One channel: today's single switch, named by the type (KS's e-mail-only rows).\n if (single) {\n const description =\n single === \"email\" && unverifiedLine ? (\n <>\n {entry.description !== undefined && <span className=\"block\">{entry.description}</span>}\n {unverifiedLine}\n </>\n ) : (\n entry.description\n );\n return (\n <div key={entry.id} data-notification-type={entry.id} data-channels={single} className=\"space-y-2\">\n <Switch\n label={entry.label}\n description={description}\n checked={channelOn(row, single)}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onCheckedChange={(next) => flip(entry.id, single, next)}\n />\n {below}\n </div>\n );\n }\n\n // Several channels: a group named by its type, a switch per channel — columns on a\n // wide screen (the headings above the list name them), stacked on a phone.\n const labelId = `${groupId}-type-${entry.id}`;\n const unverifiedId = `${groupId}-unverified-${entry.id}`;\n const channelSwitch = (channel: NotificationChannel) => (\n <Switch\n key={channel}\n size=\"sm\"\n label={phone ? channelLabel[channel] : undefined}\n aria-label={phone ? undefined : channelLabel[channel]}\n description={phone && channel === \"email\" ? (unverifiedLine ?? undefined) : undefined}\n aria-describedby={!phone && channel === \"email\" && unverifiedLine ? unverifiedId : undefined}\n checked={channelOn(row, channel)}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onCheckedChange={(next) => flip(entry.id, channel, next)}\n data-channel={channel}\n />\n );\n const text = (\n <div className=\"min-w-0\">\n <div id={labelId} className=\"text-sm font-medium text-primary\">\n {entry.label}\n </div>\n {(entry.description !== undefined || (!phone && offered.includes(\"email\") && unverifiedLine)) && (\n <div className={CARD_DESCRIPTION_CLASS}>\n {entry.description !== undefined && <span className=\"block\">{entry.description}</span>}\n {!phone && offered.includes(\"email\") && <span id={unverifiedId}>{unverifiedLine}</span>}\n </div>\n )}\n </div>\n );\n return (\n <div\n key={entry.id}\n data-notification-type={entry.id}\n data-channels={offered.join(\" \")}\n role=\"group\"\n aria-labelledby={labelId}\n className=\"space-y-2\"\n >\n {phone ? (\n <>\n {text}\n <div className=\"ps-4 space-y-2\" data-stacked=\"\">\n {offered.map(channelSwitch)}\n </div>\n </>\n ) : (\n <div className={cn(\"grid items-start gap-x-2\", COLUMN_GRID[columns.length])}>\n {text}\n {columns.map((channel) => (\n <div key={channel} className=\"flex justify-center pt-0.5\">\n {offered.includes(channel) ? channelSwitch(channel) : null}\n </div>\n ))}\n </div>\n )}\n {below}\n </div>\n );\n };\n\n let body: ReactNode;\n if (loading || value === undefined) {\n body = <Skeleton lines={3} label={labels.typesLoading} />;\n } else if (groups) {\n const drawn = groups\n .map((group) => ({ group, rows: rowsOf(group.types) }))\n .filter(({ rows }) => rows.length > 0);\n body =\n drawn.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.typesEmpty}</p>\n ) : (\n <>\n {columnHeadings}\n {drawn.map(({ group, rows }) => {\n const headingId = `${groupId}-${group.id}`;\n return (\n <div key={group.id} role=\"group\" aria-labelledby={headingId} className=\"space-y-3\">\n <SectionLabel as=\"div\" size=\"xs\" id={headingId}>\n {group.label}\n </SectionLabel>\n {rows.map(renderRow)}\n </div>\n );\n })}\n </>\n );\n } else {\n const rows = rowsOf(types.map((entry) => entry.id));\n body =\n rows.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.typesEmpty}</p>\n ) : (\n <div className=\"space-y-3\">\n {columnHeadings}\n {rows.map(renderRow)}\n </div>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.typesTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.typesDescription}</div>\n </div>\n {body}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n"],"mappings":";AAgNI,SA8DM,UA9DN,KAiBE,YAjBF;AAhNJ,SAAS,OAAO,gBAAgB;AAIhC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,aAAa,wBAAwB,uBAAuB;AAgBtF,SAAS,YAAqB;AAC5B,SAAO,QAAQ,YAAY,KAAK,GAAG;AACrC;AA2CA,MAAM,YAAY,CAAC,IAAY,YAAiC,GAAG,EAAE,IAAI,OAAO;AAChF,MAAM,cAAc;AAIpB,MAAM,cAAsC;AAAA,EAC1C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,WAA2C,CAAC,OAAO,QAAQ,OAAO;AAIxE,MAAM,aAAa,CAAC,aAClB,SAAS,OAAO,CAAC,YAAY,SAAS,OAAO,MAAM,QAAQ,SAAS,OAAO,MAAM,MAAS;AA0BrF,SAAS,yBAAqD;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAAsC;AACpC,QAAM,SAAS,uBAAuB,UAAU;AAChD,QAAM,UAAU,gBAAyB,KAAK;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,IAEzD,iCACC;AAAA;AAAA,MACA,MAAM,IAAI,CAAC,EAAE,OAAO,KAAK,MAAM;AAC9B,cAAM,YAAY,GAAG,OAAO,IAAI,MAAM,EAAE;AACxC,eACE,qBAAC,SAAmB,MAAK,SAAQ,mBAAiB,WAAW,WAAU,aACrE;AAAA,8BAAC,gBAAa,IAAG,OAAM,MAAK,MAAK,IAAI,WAClC,gBAAM,OACT;AAAA,UACC,KAAK,IAAI,SAAS;AAAA,aAJX,MAAM,EAKhB;AAAA,MAEJ,CAAC;AAAA,OACD;AAAA,EAEN,OAAO;AACL,UAAM,OAAO,OAAO,MAAM,IAAI,CAAC,UAAU,MAAM,EAAE,CAAC;AAClD,WACE,KAAK,WAAW,IACd,oBAAC,OAAE,WAAW,wBAAyB,iBAAO,YAAW,IAEzD,qBAAC,SAAI,WAAU,aACZ;AAAA;AAAA,MACA,KAAK,IAAI,SAAS;AAAA,OACrB;AAAA,EAEN;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,iBAAiB,SAAS,GACtD;AAAA,yBAAC,SACC;AAAA,0BAAC,qBAAmB,iBAAO,YAAW;AAAA,MACtC,oBAAC,SAAI,WAAW,wBAAyB,iBAAO,kBAAiB;AAAA,OACnE;AAAA,IACC;AAAA,IACD,oBAAC,eAAa,mBAAQ;AAAA,KACxB;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/notification-types-setting.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { hasContent } from \"../lib/presence\";\nimport { Card } from \"../components/card\";\nimport { Select } from \"../components/select\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Switch } from \"../components/switch\";\nimport { SectionLabel } from \"../components/text\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { usePhoneLayout } from \"../hooks/use-breakpoint\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from \"./notification-parts\";\nimport type { WriteOverlay } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type {\n DigestCadence,\n NotificationChannel,\n NotificationSettingsPatch,\n NotificationSwitches,\n NotificationTypeEntry,\n NotificationTypeGroup,\n NotificationTypesValue,\n} from \"./notification-types\";\n\n/** Is this a development build? Dead code in a consumer's production bundle; on under\n * vitest, where a type the card cannot draw is a bug a test should fail on (as\n * `SettingsSection`'s catalogue check). */\nfunction devChecks(): boolean {\n return Boolean(import.meta.env?.DEV);\n}\n\nexport interface NotificationTypesSettingProps<Id extends string = string> extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"children\" | \"onChange\"\n> {\n /** The app's words for its types, in its order. Where an app types its ids. */\n types: readonly NotificationTypeEntry<Id>[];\n /** The `GET`'s `types` (§3.2); `undefined` while the first load runs. */\n value: NotificationTypesValue | undefined;\n /** The settings are loading. */\n loading?: boolean;\n /**\n * Save one change — `PATCH /notifications/settings` with this body: one switch per\n * call (`{types: {digest: {app: true}}}`), or `{digest_cadence}`. The switch shows its\n * new state while the call runs and goes back if it rejects; hand the card the\n * PATCH's answer (or refetch) when it resolves.\n */\n onChange: (patch: NotificationSettingsPatch<Id>) => Promise<unknown> | void;\n /** Headings over the types, in the app's words (keksdose's three). Without them, one\n * list in the order of `types`. In development every type the server answered must\n * be in one. */\n groups?: readonly NotificationTypeGroup<Id>[];\n /** The digest type and the account's cadence: a cadence `Select` under that type\n * while it is on. */\n digest?: { type: Id; cadence: DigestCadence };\n /** Under a type while it is on — keksdose's low-balance threshold field. */\n renderExtra?: (id: Id) => ReactNode;\n /** The account's address is unverified: every e-mail switch says\n * `labels.emailUnverified` under it (decision 16). */\n emailUnverified?: boolean;\n /** Nothing can be changed (the switches stay readable). */\n disabled?: boolean;\n /** The app's own words for a failed save, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** One drawn type: the app's words and the server's switches. */\ninterface Row<Id extends string> {\n entry: NotificationTypeEntry<Id>;\n switches: NotificationSwitches;\n}\n\n/** A switch's key in the write overlay. */\nconst switchKey = (id: string, channel: NotificationChannel) => `${id}.${channel}`;\nconst CADENCE_KEY = \"digest_cadence\";\n\n/** The grid of a several-channel row on a wide screen: the type's words, then one narrow\n * column per channel drawn. Literal classes, so Tailwind's scan finds them. */\nconst COLUMN_GRID: Record<number, string> = {\n 1: \"grid-cols-[minmax(0,1fr)_4.5rem]\",\n 2: \"grid-cols-[minmax(0,1fr)_repeat(2,4.5rem)]\",\n 3: \"grid-cols-[minmax(0,1fr)_repeat(3,4.5rem)]\",\n};\n\n/** The channels in the card's column order (§10.2). */\nconst CHANNELS: readonly NotificationChannel[] = [\"app\", \"push\", \"email\"];\n\n/** The channels a type offers: every one the server did not answer `null` (or leave out,\n * as `push` before server-kit 0.16). */\nconst channelsOf = (switches: NotificationSwitches): NotificationChannel[] =>\n CHANNELS.filter((channel) => switches[channel] !== null && switches[channel] !== undefined);\n\n/**\n * What the person hears about, and how (docs/notifications-harmonization.md §2.1–§2.3,\n * §4.2, §10.2): one row per type the SERVER answered, the app's words on it, and a switch\n * per channel the type offers — \"In the app\", \"Push\", \"E-mail\". On a wide screen they are\n * narrow columns under those headings; on a phone they stack under the type's label. A\n * channel the server answers `null` is not drawn (kastlan and KS offer no push; KS no\n * \"in the app\"), and a row with one channel keeps a single switch named by the type\n * (Kurvenschmiede's e-mail-only rows).\n *\n * **The server's list is the only list.** The card keeps no defaults and no list of\n * types: it draws what `value` holds, in the order of `groups`, else of `types`. A type\n * the app names that the server did not answer is not drawn (kastlan's tenant receives\n * neither of its types). In development a type the server answered with no entry in\n * `types`, or in no group when `groups` is given, throws — keksdose's compile-time\n * `_EVERY_TYPE_IS_GROUPED`, now at run time, since the list is the server's.\n *\n * **Each flip saves at once**, one switch per call; the switch shows its new state while\n * the call runs and goes back if it rejects, with the failure said under the card. The\n * digest's cadence and the app's extra field (`renderExtra`) show under their type while\n * it is on.\n *\n * Under a write lock the switches are `commit` controls exempt from billing: a lapsed\n * plan never keeps a person from turning notifications off (billing §12.13).\n */\nexport function NotificationTypesSetting<Id extends string = string>({\n types,\n value,\n loading,\n onChange,\n groups,\n digest,\n renderExtra,\n emailUnverified = false,\n disabled = false,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: NotificationTypesSettingProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const overlay = useWriteOverlay<boolean>(value);\n const cadenceOverlay = useWriteOverlay<DigestCadence>(digest?.cadence);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n const groupId = useId();\n\n const answered = value ? Object.keys(value) : [];\n const entries = new Map(types.map((entry) => [entry.id as string, entry]));\n if (value && devChecks()) {\n const unnamed = answered.filter((id) => !entries.has(id));\n if (unnamed.length) {\n throw new Error(\n `NotificationTypesSetting: the server answered ${unnamed.map((id) => `\"${id}\"`).join(\", \")} with no entry in \\`types\\` — give every type the server can send its words.`,\n );\n }\n if (groups) {\n const grouped = new Set<string>(groups.flatMap((group) => group.types));\n const loose = answered.filter((id) => !grouped.has(id));\n if (loose.length) {\n throw new Error(\n `NotificationTypesSetting: ${loose.map((id) => `\"${id}\"`).join(\", \")} is in no group — a type in no group is drawn nowhere, and could not be turned off.`,\n );\n }\n }\n }\n\n const phone = usePhoneLayout();\n const rowOf = (id: Id): Row<Id> | null => {\n const switches = value?.[id];\n const entry = entries.get(id);\n if (!switches || !entry || channelsOf(switches).length === 0) return null;\n return { entry, switches };\n };\n const rowsOf = (ids: readonly Id[]) => ids.map(rowOf).filter((row): row is Row<Id> => row !== null);\n\n const shown = (id: string, channel: NotificationChannel, server: boolean): boolean => {\n const key = switchKey(id, channel);\n return overlay.get(key) ?? server;\n };\n const channelOn = ({ entry, switches }: Row<Id>, channel: NotificationChannel) =>\n shown(entry.id, channel, switches[channel] === true);\n /** The type reaches the person at all: some channel is on (the cadence and the app's\n * extra show then). */\n const rowOn = (row: Row<Id>) => channelsOf(row.switches).some((channel) => channelOn(row, channel));\n\n const save = <V,>(key: string, patch: NotificationSettingsPatch<Id>, which: WriteOverlay<V>, next: V) => {\n if (which.pending(key)) return;\n setFailure(null);\n which.set(key, next);\n settle(() => onChange(patch)).then(\n () => {\n if (mounted.current) which.settle(key, true);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n which.settle(key, false);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n },\n );\n };\n\n const flip = (id: Id, channel: NotificationChannel, on: boolean) =>\n save(\n switchKey(id, channel),\n { types: { [id]: { [channel]: on } } as NotificationSettingsPatch<Id>[\"types\"] },\n overlay,\n on,\n );\n\n const cadence = cadenceOverlay.get(CADENCE_KEY) ?? digest?.cadence;\n\n const unverifiedLine = emailUnverified ? (\n <span className=\"block\" data-email-unverified=\"\">\n {labels.emailUnverified}\n </span>\n ) : null;\n\n const channelLabel: Record<NotificationChannel, string> = {\n app: labels.channelApp,\n push: labels.channelPush,\n email: labels.channelEmail,\n };\n /** The columns on a wide screen: every channel some several-channel row offers. */\n const drawnRows =\n value && !loading ? rowsOf(groups ? groups.flatMap((group) => group.types) : types.map((entry) => entry.id)) : [];\n const multi = drawnRows.filter((row) => channelsOf(row.switches).length > 1);\n const columns = CHANNELS.filter((channel) => multi.some((row) => channelsOf(row.switches).includes(channel)));\n const columnHeadings =\n !phone && columns.length > 0 ? (\n // The switches carry the channel's name themselves; the headings are for the eye.\n <div aria-hidden className={cn(\"grid gap-x-2\", COLUMN_GRID[columns.length])} data-channel-headings=\"\">\n <span />\n {columns.map((channel) => (\n <span key={channel} className=\"text-center text-caption font-medium text-muted\">\n {channelLabel[channel]}\n </span>\n ))}\n </div>\n ) : null;\n\n const renderRow = (row: Row<Id>) => {\n const { entry, switches } = row;\n const on = rowOn(row);\n const offered = channelsOf(switches);\n const single = offered.length === 1 ? offered[0] : null;\n const cadenceSelect =\n on && digest?.type === entry.id && cadence ? (\n <Select\n label={labels.digestCadence}\n value={cadence}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onChange={(event) => {\n const next = event.target.value as DigestCadence;\n if (next !== cadence) save(CADENCE_KEY, { digest_cadence: next }, cadenceOverlay, next);\n }}\n className=\"max-w-44\"\n >\n <option value=\"weekly\">{labels.digestWeekly}</option>\n <option value=\"monthly\">{labels.digestMonthly}</option>\n </Select>\n ) : null;\n const extra = on ? renderExtra?.(entry.id) : null;\n const below =\n cadenceSelect || hasContent(extra) ? (\n <div className=\"ps-4 space-y-2\">\n {cadenceSelect}\n {extra}\n </div>\n ) : null;\n\n // One channel: today's single switch, named by the type (KS's e-mail-only rows).\n if (single) {\n const description =\n single === \"email\" && unverifiedLine ? (\n <>\n {entry.description !== undefined && <span className=\"block\">{entry.description}</span>}\n {unverifiedLine}\n </>\n ) : (\n entry.description\n );\n return (\n <div key={entry.id} data-notification-type={entry.id} data-channels={single} className=\"space-y-2\">\n <Switch\n label={entry.label}\n description={description}\n checked={channelOn(row, single)}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onCheckedChange={(next) => flip(entry.id, single, next)}\n />\n {below}\n </div>\n );\n }\n\n // Several channels: a group named by its type, a switch per channel — columns on a\n // wide screen (the headings above the list name them), stacked on a phone.\n const labelId = `${groupId}-type-${entry.id}`;\n const unverifiedId = `${groupId}-unverified-${entry.id}`;\n const channelSwitch = (channel: NotificationChannel) => (\n <Switch\n key={channel}\n size=\"sm\"\n label={phone ? channelLabel[channel] : undefined}\n aria-label={phone ? undefined : channelLabel[channel]}\n description={phone && channel === \"email\" ? (unverifiedLine ?? undefined) : undefined}\n aria-describedby={!phone && channel === \"email\" && unverifiedLine ? unverifiedId : undefined}\n checked={channelOn(row, channel)}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onCheckedChange={(next) => flip(entry.id, channel, next)}\n data-channel={channel}\n />\n );\n const text = (\n <div className=\"min-w-0\">\n <div id={labelId} className=\"text-sm font-medium text-primary\">\n {entry.label}\n </div>\n {(entry.description !== undefined || (!phone && offered.includes(\"email\") && unverifiedLine)) && (\n <div className={CARD_DESCRIPTION_CLASS}>\n {entry.description !== undefined && <span className=\"block\">{entry.description}</span>}\n {!phone && offered.includes(\"email\") && <span id={unverifiedId}>{unverifiedLine}</span>}\n </div>\n )}\n </div>\n );\n return (\n <div\n key={entry.id}\n data-notification-type={entry.id}\n data-channels={offered.join(\" \")}\n role=\"group\"\n aria-labelledby={labelId}\n className=\"space-y-2\"\n >\n {phone ? (\n <>\n {text}\n <div className=\"ps-4 space-y-2\" data-stacked=\"\">\n {offered.map(channelSwitch)}\n </div>\n </>\n ) : (\n <div className={cn(\"grid items-start gap-x-2\", COLUMN_GRID[columns.length])}>\n {text}\n {columns.map((channel) => (\n <div key={channel} className=\"flex justify-center pt-0.5\">\n {offered.includes(channel) ? channelSwitch(channel) : null}\n </div>\n ))}\n </div>\n )}\n {below}\n </div>\n );\n };\n\n let body: ReactNode;\n if (loading || value === undefined) {\n body = <Skeleton lines={3} label={labels.typesLoading} />;\n } else if (groups) {\n const drawn = groups.map((group) => ({ group, rows: rowsOf(group.types) })).filter(({ rows }) => rows.length > 0);\n body =\n drawn.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.typesEmpty}</p>\n ) : (\n <>\n {columnHeadings}\n {drawn.map(({ group, rows }) => {\n const headingId = `${groupId}-${group.id}`;\n return (\n <div key={group.id} role=\"group\" aria-labelledby={headingId} className=\"space-y-3\">\n <SectionLabel as=\"div\" size=\"xs\" id={headingId}>\n {group.label}\n </SectionLabel>\n {rows.map(renderRow)}\n </div>\n );\n })}\n </>\n );\n } else {\n const rows = rowsOf(types.map((entry) => entry.id));\n body =\n rows.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.typesEmpty}</p>\n ) : (\n <div className=\"space-y-3\">\n {columnHeadings}\n {rows.map(renderRow)}\n </div>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.typesTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.typesDescription}</div>\n </div>\n {body}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n"],"mappings":";AAkNI,SA+DM,UA/DN,KAkBE,YAlBF;AAlNJ,SAAS,OAAO,gBAAgB;AAIhC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,aAAa,wBAAwB,uBAAuB;AAgBtF,SAAS,YAAqB;AAC5B,SAAO,QAAQ,YAAY,KAAK,GAAG;AACrC;AA6CA,MAAM,YAAY,CAAC,IAAY,YAAiC,GAAG,EAAE,IAAI,OAAO;AAChF,MAAM,cAAc;AAIpB,MAAM,cAAsC;AAAA,EAC1C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,WAA2C,CAAC,OAAO,QAAQ,OAAO;AAIxE,MAAM,aAAa,CAAC,aAClB,SAAS,OAAO,CAAC,YAAY,SAAS,OAAO,MAAM,QAAQ,SAAS,OAAO,MAAM,MAAS;AA0BrF,SAAS,yBAAqD;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAAsC;AACpC,QAAM,SAA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