@eifi1/ui-kit 0.51.4 → 0.51.6
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 +5 -5
- 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 +1 -4
- 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 +10 -8
- 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.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 +44 -56
- 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.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 +6 -8
- 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 +2 -7
- 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 +2 -8
- 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.map +1 -1
- package/dist/components/legal-page.js +14 -2
- package/dist/components/legal-page.js.map +1 -1
- package/dist/components/legal.js +12 -2
- 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.js +22 -10
- 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.d.ts +24 -2
- package/dist/components/treemap.js +28 -4
- 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.js +4 -1
- 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 +4 -1
- 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 +4 -1
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/es.js +4 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +4 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +4 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +4 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/plurals.js.map +1 -1
- package/dist/i18n/review.js +13 -7
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +16 -16
- 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 +4 -0
- 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-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.js +12 -6
- 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.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/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/contrast.d.ts +2 -2
- 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 +12 -42
- 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 +13 -14
- 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 +1 -3
- package/src/components/data-table-groups.tsx +3 -1
- package/src/components/data-table-head.tsx +27 -45
- 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 +489 -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 +6 -8
- 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 +4 -17
- package/src/components/image-grid.tsx +1 -6
- package/src/components/inline-edit-field.tsx +1 -5
- package/src/components/inline-entity-combobox.tsx +6 -21
- package/src/components/input.tsx +14 -2
- package/src/components/jump-calendar.tsx +2 -6
- package/src/components/legal-labels.ts +1 -2
- package/src/components/legal-page.tsx +18 -7
- package/src/components/legal.tsx +14 -5
- package/src/components/lightbox.tsx +1 -3
- package/src/components/line-items.tsx +7 -15
- package/src/components/list.tsx +29 -25
- 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 +59 -9
- 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 +12 -8
- 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 +33 -49
- package/src/i18n/kit-labels.tsx +5 -20
- package/src/i18n/languages.ts +2 -8
- package/src/i18n/locales/en.ts +11 -31
- package/src/i18n/locales/es.ts +35 -49
- package/src/i18n/locales/fr.ts +34 -51
- package/src/i18n/locales/hu.ts +26 -37
- package/src/i18n/locales/it.ts +35 -52
- package/src/i18n/locales/zh.ts +14 -32
- package/src/i18n/plurals.ts +4 -1
- package/src/i18n/review.ts +18 -7
- package/src/i18n/shared-labels.ts +1 -2
- package/src/index.ts +106 -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 +15 -3
- 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-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 +12 -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 +9 -8
- package/src/shell/topbar-controls.tsx +5 -19
- package/src/shell/tour-menu.tsx +9 -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
|
@@ -145,52 +145,71 @@ function NotificationInbox({
|
|
|
145
145
|
body = /* @__PURE__ */ 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,YAAY,MAAM;AACxB,QAAM,YAAY,OAA0B,IAAI;AAChD,QAAM,WAAW,OAA0B,IAAI;AAC/C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,YAAU,MAAM;AACd,QAAI,OAAQ,WAAU,SA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G,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,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,WA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AAQ,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>\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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,SAAS,uBAAuB,UAAU;AAChD,QAAM,UAAU,gBAAyB,KAAK;AAC9C,QAAM,iBAAiB,gBAA+B,QAAQ,OAAO;AACrE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAoB,IAAI;AACtD,QAAM,UAAU,WAAW;AAC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AE;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,OACH;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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifications/notifications-labels.ts"],"sourcesContent":["// The words of the notification cards (docs/notifications-harmonization.md §4.2), in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, so `en` loads as one chunk like the other languages\n// (0.34, KS U8). The cards read it through `useKitLabels(\"notifications\", …)`.\n\n/** The ten IANA regions `Intl` lists zones under — keksdose's `tz_region_*` — in the\n * kit's words. A region a runtime adds later keeps its IANA name. */\nexport interface NotificationRegionLabels {\n Africa: string;\n America: string;\n Antarctica: string;\n Arctic: string;\n Asia: string;\n Atlantic: string;\n Australia: string;\n Europe: string;\n Indian: string;\n Pacific: string;\n}\n\n/**\n * Every string the notification parts render — the `notifications` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`: the types card,\n * quiet hours, this device's push, the device list, and the\n * unsubscribe page. Cancel is `common.cancel`.\n */\nexport interface NotificationsLabels {\n /* ── The types card ─────────────────────────────────────────────────── */\n /** The types card's title. */\n typesTitle: string;\n /** The line under it. */\n typesDescription: string;\n /** 0.46 (§10.2): the channel columns' headings, and each switch's name. */\n channelApp: string;\n channelPush: string;\n channelEmail: string;\n /** Under every e-mail switch while the account's address is unverified (decision 16):\n * no notification mail goes to an unverified address. */\n emailUnverified: string;\n /** The digest's cadence select. */\n digestCadence: string;\n digestWeekly: string;\n digestMonthly: string;\n /** While the settings load. */\n typesLoading: string;\n /** The server answered no types for this account. */\n typesEmpty: string;\n\n /* ── Quiet hours ────────────────────────────────────────────────────── */\n quietTitle: string;\n /** The line under the title; `inbox`: the app keeps an inbox, which a held push still\n * reaches; `held` (0.46, §10.4): the app queues a held push and sends it when the\n * window ends, instead of dropping it. */\n quietDescription: (inbox: boolean, held?: boolean) => string;\n /** 0.46 (§10.3, automatic only): the card names the account's zone, read-only, given\n * the zone as `zoneName` writes it (\"Europe / Zurich\"); it follows the device last used. */\n quietZone: (zone: string) => string;\n /** The start time's label. */\n quietFrom: string;\n /** The end time's label. */\n quietUntil: string;\n /** One time set, the other not: quiet hours fail open until both are. */\n quietIncomplete: string;\n /** The zone's region headings, in a zone's name (\"Europe / Zurich\"). */\n regions: NotificationRegionLabels;\n\n /* ── This device ────────────────────────────────────────────────────── */\n pushTitle: string;\n pushDescription: string;\n /** The browser has no push. */\n unsupported: string;\n /** iOS outside the installed app, given the app's name. */\n iosInstall: (app: string) => string;\n /** The server has no VAPID keys. */\n notConfigured: string;\n /** The browser's permission is denied. */\n blocked: string;\n /** This device gets notifications for the signed-in account. */\n on: string;\n off: string;\n /** This browser's subscription belongs to another account. */\n otherAccount: string;\n enable: string;\n disable: string;\n sendTest: string;\n /** Turning on did not finish (the permission prompt dismissed, a refusal). */\n enableFailed: string;\n /** No service worker, or one that is not ready in 10 s. */\n noServiceWorker: string;\n /** The browser's push service did not answer in 15 s. */\n pushTimeout: string;\n /** Given how many devices the push service accepted the test for (≥ 1). */\n testSent: (count: number) => string;\n /** The test reached no device. */\n testNone: string;\n testFailed: string;\n /** The explainer before the browser's one permission prompt. */\n explainerTitle: string;\n explainerBody: (app: string) => string;\n explainerHint: string;\n explainerContinue: string;\n\n /* ── The device list ────────────────────────────────────────────────── */\n devicesTitle: string;\n devicesDescription: string;\n devicesLoading: string;\n devicesEmpty: string;\n /** A device whose user agent says nothing the kit recognises. */\n unknownDevice: string;\n /** The chip on this browser's row. */\n thisDevice: string;\n /** Given the registration date, formatted. */\n added: (date: string) => string;\n /** Given the last accepted delivery, formatted. */\n lastDelivery: (date: string) => string;\n noDelivery: string;\n /** Given the failed deliveries in a row (≥ 1). */\n failures: (count: number) => string;\n /** A row's button, visible text — and the confirm's answer. */\n remove: string;\n /** The same button's accessible name, given the device: it starts with `remove`. */\n removeItem: (device: string) => string;\n /** The question the row asks before it removes. */\n removePrompt: string;\n /** 0.46 (§10.2): the disclosure on a device's row listing the types with push on. */\n deviceTypes: string;\n /** The line inside it. */\n deviceTypesDescription: string;\n /** No type has push on for the account. */\n deviceTypesEmpty: string;\n\n /* ── The inbox and the bell (0.46, §10.1) ───────────────────────────── */\n /** The inbox's heading (keksdose's \"Inbox\"). */\n inboxTitle: string;\n inboxLoading: string;\n /** Nothing in the inbox. */\n inboxEmpty: string;\n markAllRead: string;\n /** The header's clear button, and the confirm's answer. */\n clearAll: string;\n /** The question asked before the inbox is cleared. */\n clearPrompt: string;\n /** The row that loads the next page. */\n showMore: string;\n /** The bell's name. */\n bellLabel: string;\n /** Read after the bell's name, given the unread count (≥ 1). */\n bellUnread: (count: number) => string;\n /** The bell panel's link to the app's inbox. */\n allNotifications: string;\n\n /* ── The unsubscribe page ───────────────────────────────────────────── */\n unsubscribeTitle: string;\n /** Given the type's name in the app's words. */\n unsubscribeAbout: (type: string) => string;\n /** No type name to give. */\n unsubscribeGeneric: string;\n stopThese: string;\n stopAll: (app: string) => string;\n stoppedThese: string;\n stoppedAll: (app: string) => string;\n /** Account mail is not a notification, and keeps coming. */\n accountMail: string;\n turnBackOn: string;\n openSettings: string;\n /** A token the server refused, or one that does not parse. */\n invalidLink: string;\n\n /* ── Every card ─────────────────────────────────────────────────────── */\n /** A request failed, and the app had no words of its own. */\n failed: string;\n}\n\nexport const DEFAULT_NOTIFICATIONS_LABELS: NotificationsLabels = {\n typesTitle: \"Notify me about\",\n typesDescription: \"Choose what you hear about, and how.\",\n channelApp: \"In the app\",\n channelPush: \"Push\",\n channelEmail: \"E-mail\",\n emailUnverified: \"Confirm your address to receive these.\",\n digestCadence: \"Frequency\",\n digestWeekly: \"Weekly\",\n digestMonthly: \"Monthly\",\n typesLoading: \"Loading notification settings…\",\n typesEmpty: \"There are no notifications for this account.\",\n\n quietTitle: \"Quiet hours\",\n quietDescription: (inbox, held) =>\n held\n ? inbox\n ? \"Push notifications wait during this window and arrive when it ends. They reach your inbox at once.\"\n : \"Push notifications wait during this window and arrive when it ends.\"\n : inbox\n ? \"No push notifications during this window. They still reach your inbox.\"\n : \"No push notifications during this window.\",\n quietZone: (zone) => `In your time zone (${zone}), which follows the device you last used.`,\n quietFrom: \"From\",\n quietUntil: \"Until\",\n quietIncomplete: \"Set both a start and an end time. Quiet hours take effect once both are set.\",\n regions: {\n Africa: \"Africa\",\n America: \"Americas\",\n Antarctica: \"Antarctica\",\n Arctic: \"Arctic\",\n Asia: \"Asia\",\n Atlantic: \"Atlantic\",\n Australia: \"Australia\",\n Europe: \"Europe\",\n Indian: \"Indian Ocean\",\n Pacific: \"Pacific\",\n },\n\n pushTitle: \"Push notifications\",\n pushDescription: \"Notifications on this device, also while the app is closed.\",\n unsupported: \"This browser doesn’t support push notifications.\",\n iosInstall: (app) =>\n `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,\n notConfigured: \"Push notifications aren’t set up on this server.\",\n blocked: \"Notifications are blocked in this browser’s settings.\",\n on: \"Notifications are on for this device.\",\n off: \"Notifications are off for this device.\",\n otherAccount:\n \"This browser gets notifications for another account. Turn them on here to get them for the account you’re signed in with.\",\n enable: \"Turn on notifications\",\n disable: \"Turn off\",\n sendTest: \"Send a test\",\n enableFailed: \"Couldn’t turn on notifications.\",\n noServiceWorker: \"Couldn’t reach the app’s service worker. Reload the page and try again.\",\n pushTimeout: \"The browser’s push service didn’t answer. Check your connection and try again.\",\n testSent: (count) => (count === 1 ? \"Test sent to 1 device\" : `Test sent to ${count} devices`),\n testNone: \"No device accepted the test. Turn notifications on for this device first.\",\n testFailed: \"Couldn’t send a test notification.\",\n explainerTitle: \"Turn on notifications?\",\n explainerBody: (app) =>\n `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,\n explainerHint: \"Your browser asks for permission next.\",\n explainerContinue: \"Continue\",\n\n devicesTitle: \"Notification devices\",\n devicesDescription: \"Every device that gets push notifications for your account. Remove any you no longer use.\",\n devicesLoading: \"Loading devices…\",\n devicesEmpty: \"No device gets notifications yet.\",\n unknownDevice: \"Unknown device\",\n thisDevice: \"This device\",\n added: (date) => `Added ${date}`,\n lastDelivery: (date) => `Last delivery ${date}`,\n noDelivery: \"No delivery yet\",\n failures: (count) =>\n count === 1 ? \"1 failed delivery in a row\" : `${count} failed deliveries in a row`,\n remove: \"Remove\",\n removeItem: (device) => `Remove ${device}`,\n removePrompt: \"Stop sending notifications to this device?\",\n deviceTypes: \"Types on this device\",\n deviceTypesDescription: \"Turn a type off to mute it on this device only.\",\n deviceTypesEmpty: \"No type has push notifications turned on.\",\n\n inboxTitle: \"Inbox\",\n inboxLoading: \"Loading notifications…\",\n inboxEmpty: \"You’re all caught up.\",\n markAllRead: \"Mark all as read\",\n clearAll: \"Clear all\",\n clearPrompt: \"Delete all notifications from your inbox?\",\n showMore: \"Show more\",\n bellLabel: \"Notifications\",\n bellUnread: (count) => `${count} unread`,\n allNotifications: \"All notifications\",\n\n unsubscribeTitle: \"E-mail notifications\",\n unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,\n unsubscribeGeneric: \"You get notification e-mails.\",\n stopThese: \"Stop these e-mails\",\n stopAll: (app) => `Stop all notification e-mails from ${app}`,\n stoppedThese: \"Done. You won’t get these e-mails any more.\",\n stoppedAll: (app) => `Done. You won’t get notification e-mails from ${app} any more.`,\n accountMail: \"E-mails about your account still come.\",\n turnBackOn: \"You can turn them back on at any time in Settings.\",\n openSettings: \"Open Settings\",\n invalidLink: \"This link doesn’t work any more. You can turn e-mails off in Settings instead.\",\n\n failed: \"That didn’t work. Please try again.\",\n};\n"],"mappings":";AA6KO,MAAM,+BAAoD;AAAA,EAC/D,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EAEZ,YAAY;AAAA,EACZ,kBAAkB,CAAC,OAAO,SACxB,OACI,QACE,uGACA,wEACF,QACE,2EACA;AAAA,EACR,WAAW,CAAC,SAAS,sBAAsB,IAAI;AAAA,EAC/C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,YAAY,CAAC,QACX,0BAA0B,GAAG;AAAA,EAC/B,eAAe;AAAA,EACf,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,cACE;AAAA,EACF,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,UAAU,CAAC,UAAW,UAAU,IAAI,0BAA0B,gBAAgB,KAAK;AAAA,EACnF,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe,CAAC,QACd,GAAG,GAAG;AAAA,EACR,eAAe;AAAA,EACf,mBAAmB;AAAA,EAEnB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,OAAO,CAAC,SAAS,SAAS,IAAI;AAAA,EAC9B,cAAc,CAAC,SAAS,iBAAiB,IAAI;AAAA,EAC7C,YAAY;AAAA,EACZ,UAAU,CAAC,UACT,UAAU,IAAI,+BAA+B,GAAG,KAAK;AAAA,EACvD,QAAQ;AAAA,EACR,YAAY,CAAC,WAAW,UAAU,MAAM;AAAA,EACxC,cAAc;AAAA,EACd,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAElB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,aAAa;AAAA,EACb,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY,CAAC,UAAU,GAAG,KAAK;AAAA,EAC/B,kBAAkB;AAAA,EAElB,kBAAkB;AAAA,EAClB,kBAAkB,CAAC,SAAS,0BAA0B,IAAI;AAAA,EAC1D,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,SAAS,CAAC,QAAQ,sCAAsC,GAAG;AAAA,EAC3D,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ,sDAAiD,GAAG;AAAA,EACzE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEb,QAAQ;AACV;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/notifications-labels.ts"],"sourcesContent":["// The words of the notification cards (docs/notifications-harmonization.md §4.2), in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, so `en` loads as one chunk like the other languages\n// (0.34, KS U8). The cards read it through `useKitLabels(\"notifications\", …)`.\n\n/** The ten IANA regions `Intl` lists zones under — keksdose's `tz_region_*` — in the\n * kit's words. A region a runtime adds later keeps its IANA name. */\nexport interface NotificationRegionLabels {\n Africa: string;\n America: string;\n Antarctica: string;\n Arctic: string;\n Asia: string;\n Atlantic: string;\n Australia: string;\n Europe: string;\n Indian: string;\n Pacific: string;\n}\n\n/**\n * Every string the notification parts render — the `notifications` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`: the types card,\n * quiet hours, this device's push, the device list, and the\n * unsubscribe page. Cancel is `common.cancel`.\n */\nexport interface NotificationsLabels {\n /* ── The types card ─────────────────────────────────────────────────── */\n /** The types card's title. */\n typesTitle: string;\n /** The line under it. */\n typesDescription: string;\n /** 0.46 (§10.2): the channel columns' headings, and each switch's name. */\n channelApp: string;\n channelPush: string;\n channelEmail: string;\n /** Under every e-mail switch while the account's address is unverified (decision 16):\n * no notification mail goes to an unverified address. */\n emailUnverified: string;\n /** The digest's cadence select. */\n digestCadence: string;\n digestWeekly: string;\n digestMonthly: string;\n /** While the settings load. */\n typesLoading: string;\n /** The server answered no types for this account. */\n typesEmpty: string;\n\n /* ── Quiet hours ────────────────────────────────────────────────────── */\n quietTitle: string;\n /** The line under the title; `inbox`: the app keeps an inbox, which a held push still\n * reaches; `held` (0.46, §10.4): the app queues a held push and sends it when the\n * window ends, instead of dropping it. */\n quietDescription: (inbox: boolean, held?: boolean) => string;\n /** 0.46 (§10.3, automatic only): the card names the account's zone, read-only, given\n * the zone as `zoneName` writes it (\"Europe / Zurich\"); it follows the device last used. */\n quietZone: (zone: string) => string;\n /** The start time's label. */\n quietFrom: string;\n /** The end time's label. */\n quietUntil: string;\n /** One time set, the other not: quiet hours fail open until both are. */\n quietIncomplete: string;\n /** The zone's region headings, in a zone's name (\"Europe / Zurich\"). */\n regions: NotificationRegionLabels;\n\n /* ── This device ────────────────────────────────────────────────────── */\n pushTitle: string;\n pushDescription: string;\n /** The browser has no push. */\n unsupported: string;\n /** iOS outside the installed app, given the app's name. */\n iosInstall: (app: string) => string;\n /** The server has no VAPID keys. */\n notConfigured: string;\n /** The browser's permission is denied. */\n blocked: string;\n /** This device gets notifications for the signed-in account. */\n on: string;\n off: string;\n /** This browser's subscription belongs to another account. */\n otherAccount: string;\n enable: string;\n disable: string;\n sendTest: string;\n /** Turning on did not finish (the permission prompt dismissed, a refusal). */\n enableFailed: string;\n /** No service worker, or one that is not ready in 10 s. */\n noServiceWorker: string;\n /** The browser's push service did not answer in 15 s. */\n pushTimeout: string;\n /** Given how many devices the push service accepted the test for (≥ 1). */\n testSent: (count: number) => string;\n /** The test reached no device. */\n testNone: string;\n testFailed: string;\n /** The explainer before the browser's one permission prompt. */\n explainerTitle: string;\n explainerBody: (app: string) => string;\n explainerHint: string;\n explainerContinue: string;\n\n /* ── The device list ────────────────────────────────────────────────── */\n devicesTitle: string;\n devicesDescription: string;\n devicesLoading: string;\n devicesEmpty: string;\n /** A device whose user agent says nothing the kit recognises. */\n unknownDevice: string;\n /** The chip on this browser's row. */\n thisDevice: string;\n /** Given the registration date, formatted. */\n added: (date: string) => string;\n /** Given the last accepted delivery, formatted. */\n lastDelivery: (date: string) => string;\n noDelivery: string;\n /** Given the failed deliveries in a row (≥ 1). */\n failures: (count: number) => string;\n /** A row's button, visible text — and the confirm's answer. */\n remove: string;\n /** The same button's accessible name, given the device: it starts with `remove`. */\n removeItem: (device: string) => string;\n /** The question the row asks before it removes. */\n removePrompt: string;\n /** 0.46 (§10.2): the disclosure on a device's row listing the types with push on. */\n deviceTypes: string;\n /** The line inside it. */\n deviceTypesDescription: string;\n /** No type has push on for the account. */\n deviceTypesEmpty: string;\n\n /* ── The inbox and the bell (0.46, §10.1) ───────────────────────────── */\n /** The inbox's heading (keksdose's \"Inbox\"). */\n inboxTitle: string;\n inboxLoading: string;\n /** Nothing in the inbox. */\n inboxEmpty: string;\n markAllRead: string;\n /** The header's clear button, and the confirm's answer. */\n clearAll: string;\n /** The question asked before the inbox is cleared. */\n clearPrompt: string;\n /** The row that loads the next page. */\n showMore: string;\n /** The bell's name. */\n bellLabel: string;\n /** Read after the bell's name, given the unread count (≥ 1). */\n bellUnread: (count: number) => string;\n /** The bell panel's link to the app's inbox. */\n allNotifications: string;\n\n /* ── The unsubscribe page ───────────────────────────────────────────── */\n unsubscribeTitle: string;\n /** Given the type's name in the app's words. */\n unsubscribeAbout: (type: string) => string;\n /** No type name to give. */\n unsubscribeGeneric: string;\n stopThese: string;\n stopAll: (app: string) => string;\n stoppedThese: string;\n stoppedAll: (app: string) => string;\n /** Account mail is not a notification, and keeps coming. */\n accountMail: string;\n turnBackOn: string;\n openSettings: string;\n /** A token the server refused, or one that does not parse. */\n invalidLink: string;\n\n /* ── Every card ─────────────────────────────────────────────────────── */\n /** A request failed, and the app had no words of its own. */\n failed: string;\n}\n\nexport const DEFAULT_NOTIFICATIONS_LABELS: NotificationsLabels = {\n typesTitle: \"Notify me about\",\n typesDescription: \"Choose what you hear about, and how.\",\n channelApp: \"In the app\",\n channelPush: \"Push\",\n channelEmail: \"E-mail\",\n emailUnverified: \"Confirm your address to receive these.\",\n digestCadence: \"Frequency\",\n digestWeekly: \"Weekly\",\n digestMonthly: \"Monthly\",\n typesLoading: \"Loading notification settings…\",\n typesEmpty: \"There are no notifications for this account.\",\n\n quietTitle: \"Quiet hours\",\n quietDescription: (inbox, held) =>\n held\n ? inbox\n ? \"Push notifications wait during this window and arrive when it ends. They reach your inbox at once.\"\n : \"Push notifications wait during this window and arrive when it ends.\"\n : inbox\n ? \"No push notifications during this window. They still reach your inbox.\"\n : \"No push notifications during this window.\",\n quietZone: (zone) => `In your time zone (${zone}), which follows the device you last used.`,\n quietFrom: \"From\",\n quietUntil: \"Until\",\n quietIncomplete: \"Set both a start and an end time. Quiet hours take effect once both are set.\",\n regions: {\n Africa: \"Africa\",\n America: \"Americas\",\n Antarctica: \"Antarctica\",\n Arctic: \"Arctic\",\n Asia: \"Asia\",\n Atlantic: \"Atlantic\",\n Australia: \"Australia\",\n Europe: \"Europe\",\n Indian: \"Indian Ocean\",\n Pacific: \"Pacific\",\n },\n\n pushTitle: \"Push notifications\",\n pushDescription: \"Notifications on this device, also while the app is closed.\",\n unsupported: \"This browser doesn’t support push notifications.\",\n iosInstall: (app) =>\n `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,\n notConfigured: \"Push notifications aren’t set up on this server.\",\n blocked: \"Notifications are blocked in this browser’s settings.\",\n on: \"Notifications are on for this device.\",\n off: \"Notifications are off for this device.\",\n otherAccount:\n \"This browser gets notifications for another account. Turn them on here to get them for the account you’re signed in with.\",\n enable: \"Turn on notifications\",\n disable: \"Turn off\",\n sendTest: \"Send a test\",\n enableFailed: \"Couldn’t turn on notifications.\",\n noServiceWorker: \"Couldn’t reach the app’s service worker. Reload the page and try again.\",\n pushTimeout: \"The browser’s push service didn’t answer. Check your connection and try again.\",\n testSent: (count) => (count === 1 ? \"Test sent to 1 device\" : `Test sent to ${count} devices`),\n testNone: \"No device accepted the test. Turn notifications on for this device first.\",\n testFailed: \"Couldn’t send a test notification.\",\n explainerTitle: \"Turn on notifications?\",\n explainerBody: (app) =>\n `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,\n explainerHint: \"Your browser asks for permission next.\",\n explainerContinue: \"Continue\",\n\n devicesTitle: \"Notification devices\",\n devicesDescription: \"Every device that gets push notifications for your account. Remove any you no longer use.\",\n devicesLoading: \"Loading devices…\",\n devicesEmpty: \"No device gets notifications yet.\",\n unknownDevice: \"Unknown device\",\n thisDevice: \"This device\",\n added: (date) => `Added ${date}`,\n lastDelivery: (date) => `Last delivery ${date}`,\n noDelivery: \"No delivery yet\",\n failures: (count) => (count === 1 ? \"1 failed delivery in a row\" : `${count} failed deliveries in a row`),\n remove: \"Remove\",\n removeItem: (device) => `Remove ${device}`,\n removePrompt: \"Stop sending notifications to this device?\",\n deviceTypes: \"Types on this device\",\n deviceTypesDescription: \"Turn a type off to mute it on this device only.\",\n deviceTypesEmpty: \"No type has push notifications turned on.\",\n\n inboxTitle: \"Inbox\",\n inboxLoading: \"Loading notifications…\",\n inboxEmpty: \"You’re all caught up.\",\n markAllRead: \"Mark all as read\",\n clearAll: \"Clear all\",\n clearPrompt: \"Delete all notifications from your inbox?\",\n showMore: \"Show more\",\n bellLabel: \"Notifications\",\n bellUnread: (count) => `${count} unread`,\n allNotifications: \"All notifications\",\n\n unsubscribeTitle: \"E-mail notifications\",\n unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,\n unsubscribeGeneric: \"You get notification e-mails.\",\n stopThese: \"Stop these e-mails\",\n stopAll: (app) => `Stop all notification e-mails from ${app}`,\n stoppedThese: \"Done. You won’t get these e-mails any more.\",\n stoppedAll: (app) => `Done. You won’t get notification e-mails from ${app} any more.`,\n accountMail: \"E-mails about your account still come.\",\n turnBackOn: \"You can turn them back on at any time in Settings.\",\n openSettings: \"Open Settings\",\n invalidLink: \"This link doesn’t work any more. You can turn e-mails off in Settings instead.\",\n\n failed: \"That didn’t work. Please try again.\",\n};\n"],"mappings":";AA6KO,MAAM,+BAAoD;AAAA,EAC/D,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EAEZ,YAAY;AAAA,EACZ,kBAAkB,CAAC,OAAO,SACxB,OACI,QACE,uGACA,wEACF,QACE,2EACA;AAAA,EACR,WAAW,CAAC,SAAS,sBAAsB,IAAI;AAAA,EAC/C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AA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B;AAAA,EAElB,kBAAkB;AAAA,EAClB,kBAAkB,CAAC,SAAS,0BAA0B,IAAI;AAAA,EAC1D,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,SAAS,CAAC,QAAQ,sCAAsC,GAAG;AAAA,EAC3D,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ,sDAAiD,GAAG;AAAA,EACzE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEb,QAAQ;AACV;","names":[]}
|
|
@@ -57,7 +57,12 @@ function PushDeviceSetting({
|
|
|
57
57
|
(ok) => ok ? null : { tone: "danger", text: labels.enableFailed },
|
|
58
58
|
labels.enableFailed
|
|
59
59
|
);
|
|
60
|
-
const disable = () => run(
|
|
60
|
+
const disable = () => run(
|
|
61
|
+
"disable",
|
|
62
|
+
() => push.disable(),
|
|
63
|
+
() => null,
|
|
64
|
+
labels.failed
|
|
65
|
+
);
|
|
61
66
|
const test = () => run(
|
|
62
67
|
"test",
|
|
63
68
|
() => push.sendTest(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifications/push-device-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport { PushDeviceError } from \"./use-push-device\";\nimport type { PushDevice } from \"./use-push-device\";\n\n/** Which action failed — {@link PushDeviceSettingProps.describeError}'s second argument. */\nexport type PushDeviceAction = \"enable\" | \"disable\" | \"test\";\n\nexport interface PushDeviceSettingProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** This browser's push, from {@link usePushDevice}. */\n push: PushDevice;\n /** The app's name, for the iOS line and the explainer. */\n appName: string;\n /** The app's own words for a failure, or `undefined` for the kit's. The kit already\n * has words for a missing service worker and an unanswered push service. */\n describeError?: (error: unknown, action: PushDeviceAction) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** What the line under the buttons says. */\ntype Outcome = { tone: \"status\" | \"warning\" | \"danger\"; text: ReactNode } | null;\n\n/**\n * Push on THIS device (docs/notifications-harmonization.md §2.2, §2.7, §4.2): keksdose's\n * push block, as a card of its own. Registering the device is the switch — push has no\n * account switch. One state at a time, in keksdose's order\n * (`notifications-card.tsx:333-402`):\n *\n * 1. the browser has no push;\n * 2. iOS outside the installed app (iOS delivers only to the installed app);\n * 3. push is not set up on the server (no VAPID keys);\n * 4. notifications blocked in the browser;\n * 5. on or off — with \"another account\" when this browser's subscription is someone\n * else's — and \"Turn on notifications\", or \"Send a test\" and \"Turn off\".\n *\n * **The explainer comes before the browser's one prompt**: turning on while the\n * permission is still `\"default\"` opens a dialog first (what the notifications are for,\n * that the browser asks next); with it granted, it goes straight on. A test that reached\n * no device says so (`testNone`) — a 404/410 removes the row on the server while this\n * browser still holds its subscription. Outcomes are a line under the buttons; nothing\n * toasts.\n */\nexport function PushDeviceSetting({\n push,\n appName,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDeviceSettingProps) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const [explainer, setExplainer] = useState(false);\n const [running, setRunning] = useState<PushDeviceAction | null>(null);\n const [outcome, setOutcome] = useState<Outcome>(null);\n const mounted = useMounted();\n\n const failureOf = (error: unknown, action: PushDeviceAction, fallback: string): ReactNode => {\n if (error instanceof PushDeviceError) {\n return error.code === \"no_service_worker\" ? labels.noServiceWorker : labels.pushTimeout;\n }\n return describeFailure(describeError?.(error, action), fallback);\n };\n\n const run = <T,>(action: PushDeviceAction, call: () => Promise<T>, done: (value: T) => Outcome, fallback: string) => {\n if (running) return;\n setRunning(action);\n setOutcome(null);\n call().then(\n (value) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome(done(value));\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome({ tone: \"danger\", text: failureOf(error, action, fallback) });\n },\n );\n };\n\n const enable = () =>\n run(\n \"enable\",\n () => push.enable(),\n (ok): Outcome => (ok ? null : { tone: \"danger\", text: labels.enableFailed }),\n labels.enableFailed,\n );\n const disable = () => run(\"disable\", () => push.disable(), () => null, labels.failed);\n const test = () =>\n run(\n \"test\",\n () => push.sendTest(),\n ({ sent }): Outcome =>\n sent > 0 ? { tone: \"status\", text: labels.testSent(sent) } : { tone: \"warning\", text: labels.testNone },\n labels.testFailed,\n );\n\n const turnOn = () => {\n if (push.permission === \"granted\") enable();\n else setExplainer(true);\n };\n\n let state: ReactNode;\n if (!push.supported) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.unsupported}</p>;\n } else if (push.ios && !push.installed) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.iosInstall(appName)}</p>;\n } else if (push.configured === false) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.notConfigured}</p>;\n } else if (push.permission === \"denied\") {\n state = <p className=\"text-xs text-warning\">{labels.blocked}</p>;\n } else {\n const busy = push.busy || running !== null;\n state = (\n <>\n <p className={CARD_DESCRIPTION_CLASS} data-push-state={push.subscribed ? \"on\" : \"off\"}>\n {push.subscribed ? labels.on : labels.off}\n </p>\n {push.foreignSubscription && <p className=\"text-xs text-warning\">{labels.otherAccount}</p>}\n <div className=\"flex flex-wrap gap-2\">\n {push.subscribed ? (\n <>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"test\"}\n disabled={busy && running !== \"test\"}\n onClick={test}\n >\n {labels.sendTest}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"disable\"}\n disabled={busy && running !== \"disable\"}\n onClick={disable}\n >\n {labels.disable}\n </Button>\n </>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"enable\"}\n disabled={busy && running !== \"enable\"}\n onClick={turnOn}\n >\n {labels.enable}\n </Button>\n )}\n </div>\n {outcome?.tone === \"status\" && (\n <p role=\"status\" className={CARD_DESCRIPTION_CLASS}>\n {outcome.text}\n </p>\n )}\n {outcome?.tone === \"warning\" && (\n <AlertBanner tone=\"warning\" size=\"sm\" role=\"status\">\n {outcome.text}\n </AlertBanner>\n )}\n {outcome?.tone === \"danger\" && <FailureLine>{outcome.text}</FailureLine>}\n </>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.pushTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.pushDescription}</div>\n </div>\n {state}\n <DialogFrame\n open={explainer}\n onClose={() => setExplainer(false)}\n title={labels.explainerTitle}\n description={labels.explainerBody(appName)}\n actions={(close) => (\n <div className=\"flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" onClick={close}>\n {common.cancel}\n </Button>\n <Button\n type=\"button\"\n onClick={() => {\n setExplainer(false);\n // Only now the browser's one permission prompt.\n enable();\n }}\n >\n {labels.explainerContinue}\n </Button>\n </div>\n )}\n >\n <p className={CARD_DESCRIPTION_CLASS}>{labels.explainerHint}</p>\n </DialogFrame>\n </Card>\n );\n}\n"],"mappings":";AAwHY,SAiBA,UAjBA,KAiBA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aAAa,KAAK;AAAA,QACjC,OAAO,OAAO;AAAA,QACd,aAAa,OAAO,cAAc,OAAO;AAAA,QACzC,SAAS,CAAC,UACR,qBAAC,SAAI,WAAU,0BACb;AAAA,8BAAC,UAAO,MAAK,UAAS,SAAQ,SAAQ,SAAS,OAC5C,iBAAO,QACV;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,6BAAa,KAAK;AAElB,uBAAO;AAAA,cACT;AAAA,cAEC,iBAAO;AAAA;AAAA,UACV;AAAA,WACF;AAAA,QAGF,8BAAC,OAAE,WAAW,wBAAyB,iBAAO,eAAc;AAAA;AAAA,IAC9D;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/push-device-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport { PushDeviceError } from \"./use-push-device\";\nimport type { PushDevice } from \"./use-push-device\";\n\n/** Which action failed — {@link PushDeviceSettingProps.describeError}'s second argument. */\nexport type PushDeviceAction = \"enable\" | \"disable\" | \"test\";\n\nexport interface PushDeviceSettingProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** This browser's push, from {@link usePushDevice}. */\n push: PushDevice;\n /** The app's name, for the iOS line and the explainer. */\n appName: string;\n /** The app's own words for a failure, or `undefined` for the kit's. The kit already\n * has words for a missing service worker and an unanswered push service. */\n describeError?: (error: unknown, action: PushDeviceAction) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** What the line under the buttons says. */\ntype Outcome = { tone: \"status\" | \"warning\" | \"danger\"; text: ReactNode } | null;\n\n/**\n * Push on THIS device (docs/notifications-harmonization.md §2.2, §2.7, §4.2): keksdose's\n * push block, as a card of its own. Registering the device is the switch — push has no\n * account switch. One state at a time, in keksdose's order\n * (`notifications-card.tsx:333-402`):\n *\n * 1. the browser has no push;\n * 2. iOS outside the installed app (iOS delivers only to the installed app);\n * 3. push is not set up on the server (no VAPID keys);\n * 4. notifications blocked in the browser;\n * 5. on or off — with \"another account\" when this browser's subscription is someone\n * else's — and \"Turn on notifications\", or \"Send a test\" and \"Turn off\".\n *\n * **The explainer comes before the browser's one prompt**: turning on while the\n * permission is still `\"default\"` opens a dialog first (what the notifications are for,\n * that the browser asks next); with it granted, it goes straight on. A test that reached\n * no device says so (`testNone`) — a 404/410 removes the row on the server while this\n * browser still holds its subscription. Outcomes are a line under the buttons; nothing\n * toasts.\n */\nexport function PushDeviceSetting({\n push,\n appName,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDeviceSettingProps) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const [explainer, setExplainer] = useState(false);\n const [running, setRunning] = useState<PushDeviceAction | null>(null);\n const [outcome, setOutcome] = useState<Outcome>(null);\n const mounted = useMounted();\n\n const failureOf = (error: unknown, action: PushDeviceAction, fallback: string): ReactNode => {\n if (error instanceof PushDeviceError) {\n return error.code === \"no_service_worker\" ? labels.noServiceWorker : labels.pushTimeout;\n }\n return describeFailure(describeError?.(error, action), fallback);\n };\n\n const run = <T,>(action: PushDeviceAction, call: () => Promise<T>, done: (value: T) => Outcome, fallback: string) => {\n if (running) return;\n setRunning(action);\n setOutcome(null);\n call().then(\n (value) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome(done(value));\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome({ tone: \"danger\", text: failureOf(error, action, fallback) });\n },\n );\n };\n\n const enable = () =>\n run(\n \"enable\",\n () => push.enable(),\n (ok): Outcome => (ok ? null : { tone: \"danger\", text: labels.enableFailed }),\n labels.enableFailed,\n );\n const disable = () =>\n run(\n \"disable\",\n () => push.disable(),\n () => null,\n labels.failed,\n );\n const test = () =>\n run(\n \"test\",\n () => push.sendTest(),\n ({ sent }): Outcome =>\n sent > 0 ? { tone: \"status\", text: labels.testSent(sent) } : { tone: \"warning\", text: labels.testNone },\n labels.testFailed,\n );\n\n const turnOn = () => {\n if (push.permission === \"granted\") enable();\n else setExplainer(true);\n };\n\n let state: ReactNode;\n if (!push.supported) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.unsupported}</p>;\n } else if (push.ios && !push.installed) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.iosInstall(appName)}</p>;\n } else if (push.configured === false) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.notConfigured}</p>;\n } else if (push.permission === \"denied\") {\n state = <p className=\"text-xs text-warning\">{labels.blocked}</p>;\n } else {\n const busy = push.busy || running !== null;\n state = (\n <>\n <p className={CARD_DESCRIPTION_CLASS} data-push-state={push.subscribed ? \"on\" : \"off\"}>\n {push.subscribed ? labels.on : labels.off}\n </p>\n {push.foreignSubscription && <p className=\"text-xs text-warning\">{labels.otherAccount}</p>}\n <div className=\"flex flex-wrap gap-2\">\n {push.subscribed ? (\n <>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"test\"}\n disabled={busy && running !== \"test\"}\n onClick={test}\n >\n {labels.sendTest}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"disable\"}\n disabled={busy && running !== \"disable\"}\n onClick={disable}\n >\n {labels.disable}\n </Button>\n </>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"enable\"}\n disabled={busy && running !== \"enable\"}\n onClick={turnOn}\n >\n {labels.enable}\n </Button>\n )}\n </div>\n {outcome?.tone === \"status\" && (\n <p role=\"status\" className={CARD_DESCRIPTION_CLASS}>\n {outcome.text}\n </p>\n )}\n {outcome?.tone === \"warning\" && (\n <AlertBanner tone=\"warning\" size=\"sm\" role=\"status\">\n {outcome.text}\n </AlertBanner>\n )}\n {outcome?.tone === \"danger\" && <FailureLine>{outcome.text}</FailureLine>}\n </>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.pushTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.pushDescription}</div>\n </div>\n {state}\n <DialogFrame\n open={explainer}\n onClose={() => setExplainer(false)}\n title={labels.explainerTitle}\n description={labels.explainerBody(appName)}\n actions={(close) => (\n <div className=\"flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" onClick={close}>\n {common.cancel}\n </Button>\n <Button\n type=\"button\"\n onClick={() => {\n setExplainer(false);\n // Only now the browser's one permission prompt.\n enable();\n }}\n >\n {labels.explainerContinue}\n </Button>\n </div>\n )}\n >\n <p className={CARD_DESCRIPTION_CLASS}>{labels.explainerHint}</p>\n </DialogFrame>\n </Card>\n );\n}\n"],"mappings":";AA8HY,SAiBA,UAjBA,KAiBA,YAjBA;AA9HZ,SAAS,gBAAgB;AAGzB,SAAS,oBAAwC;AACjD,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS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