@eifi1/ui-kit 0.53.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -82
- package/dist/account/delete-account-setting.d.ts +3 -2
- package/dist/account/delete-account-setting.js.map +1 -1
- package/dist/admin/plan-change.js +2 -2
- package/dist/admin/plan-change.js.map +1 -1
- package/dist/admin/user-roster.d.ts +6 -0
- package/dist/admin/user-roster.js +4 -0
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/auth/auth-errors.d.ts +36 -0
- package/dist/auth/auth-errors.js +20 -0
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/billing/billing-labels.d.ts +26 -0
- package/dist/billing/billing-labels.js +9 -0
- package/dist/billing/billing-labels.js.map +1 -1
- package/dist/billing/subscription-standing.d.ts +61 -0
- package/dist/billing/subscription-standing.js +51 -0
- package/dist/billing/subscription-standing.js.map +1 -0
- package/dist/billing/usage-meter.d.ts +52 -0
- package/dist/billing/usage-meter.js +52 -0
- package/dist/billing/usage-meter.js.map +1 -0
- package/dist/chart.d.ts +1 -0
- package/dist/chart.js +4 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/alert-banner.js +2 -3
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -1
- package/dist/components/amount-input.js +3 -15
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.js +2 -2
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bulk-action-bar.js +2 -1
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button.d.ts +35 -1
- package/dist/components/button.js +5 -9
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-heatmap.js +6 -4
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/camera-button.d.ts +89 -0
- package/dist/components/camera-button.js +122 -0
- package/dist/components/camera-button.js.map +1 -0
- package/dist/components/camera-capture.d.ts +66 -0
- package/dist/components/camera-capture.js +190 -0
- package/dist/components/camera-capture.js.map +1 -0
- package/dist/components/camera-labels.d.ts +20 -0
- package/dist/components/camera-labels.js +15 -0
- package/dist/components/camera-labels.js.map +1 -0
- package/dist/components/chart-edge.d.ts +9 -0
- package/dist/components/chart-edge.js +14 -3
- package/dist/components/chart-edge.js.map +1 -1
- package/dist/components/chart-zoom-core.js +34 -29
- package/dist/components/chart-zoom-core.js.map +1 -1
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/combobox-core.js +3 -2
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.js +2 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/consent-again-notice-labels.d.ts +25 -0
- package/dist/components/consent-again-notice-labels.js +15 -0
- package/dist/components/consent-again-notice-labels.js.map +1 -0
- package/dist/components/consent-again-notice.d.ts +85 -0
- package/dist/components/consent-again-notice.js +94 -0
- package/dist/components/consent-again-notice.js.map +1 -0
- package/dist/components/country-select.js +2 -7
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-option-list.d.ts +2 -1
- package/dist/components/currency-option-list.js +10 -3
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.d.ts +3 -1
- package/dist/components/currency-select.js +2 -2
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +22 -1
- package/dist/components/danger-confirm.js +52 -30
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-column-settings.js +2 -2
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +2 -1
- package/dist/components/data-table-filter-popover.js +3 -2
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +33 -3
- package/dist/components/data-table-filters.js +6 -4
- 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-virtual.js +13 -3
- package/dist/components/data-table-virtual.js.map +1 -1
- package/dist/components/date-field.js +2 -2
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.js +2 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js +2 -6
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +5 -1
- package/dist/components/dialog-frame.js +6 -2
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.js +7 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.js +2 -2
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-parts.d.ts +108 -6
- package/dist/components/field-parts.js +59 -6
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-suggestion-labels.d.ts +2 -0
- package/dist/components/field-suggestion-labels.js +10 -0
- package/dist/components/field-suggestion-labels.js.map +1 -0
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +1 -1
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/floating-panel.d.ts +7 -6
- package/dist/components/floating-panel.js +3 -17
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +3 -2
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/hover-menu.js +3 -2
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-button.d.ts +23 -5
- package/dist/components/icon-button.js +6 -8
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/inline-confirm.js +2 -1
- package/dist/components/inline-confirm.js.map +1 -1
- package/dist/components/inline-entity-combobox.js +2 -2
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.js +2 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/jump-calendar.js +3 -3
- package/dist/components/jump-calendar.js.map +1 -1
- package/dist/components/legal.d.ts +13 -1
- package/dist/components/legal.js +12 -0
- package/dist/components/legal.js.map +1 -1
- package/dist/components/legended-series-chart.d.ts +80 -0
- package/dist/components/legended-series-chart.js +70 -0
- package/dist/components/legended-series-chart.js.map +1 -0
- package/dist/components/lightbox.js +2 -1
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/mini-calendar.js +16 -7
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +48 -0
- package/dist/components/modal.js +26 -6
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +1 -1
- package/dist/components/month-picker.js +6 -6
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.js +2 -2
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.js +2 -6
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.js +2 -2
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/page-header-layout.d.ts +18 -0
- package/dist/components/page-header-layout.js +23 -0
- package/dist/components/page-header-layout.js.map +1 -0
- package/dist/components/page-header-skeleton.d.ts +41 -0
- package/dist/components/page-header-skeleton.js +52 -0
- package/dist/components/page-header-skeleton.js.map +1 -0
- package/dist/components/page-header.js +4 -17
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/popover.js +7 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/release-notes-labels.d.ts +16 -0
- package/dist/components/release-notes-labels.js +18 -0
- package/dist/components/release-notes-labels.js.map +1 -0
- package/dist/components/release-notes.d.ts +65 -0
- package/dist/components/release-notes.js +65 -0
- package/dist/components/release-notes.js.map +1 -0
- package/dist/components/select.js +2 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +9 -0
- package/dist/components/series-chart-labels.js +3 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +5 -0
- package/dist/components/series-chart.js +89 -36
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/stat-tile.d.ts +21 -2
- package/dist/components/stat-tile.js +4 -2
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/toggle-group.js +3 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/treemap-layout.js.map +1 -1
- package/dist/components/treemap.d.ts +17 -15
- package/dist/components/treemap.js +167 -85
- package/dist/components/treemap.js.map +1 -1
- package/dist/currencies.d.ts +16 -2
- package/dist/currencies.js +2 -1
- package/dist/currencies.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/role-utilities.d.ts +2 -2
- package/dist/eslint/role-utilities.js.map +1 -1
- package/dist/feedback/feedback-context-labels.js +2 -1
- package/dist/feedback/feedback-context-labels.js.map +1 -1
- package/dist/feedback/feedback-context.d.ts +19 -3
- package/dist/feedback/feedback-context.js +12 -1
- package/dist/feedback/feedback-context.js.map +1 -1
- package/dist/feedback/feedback-diagnostics.d.ts +17 -0
- package/dist/feedback/feedback-diagnostics.js +27 -0
- package/dist/feedback/feedback-diagnostics.js.map +1 -0
- package/dist/feedback/feedback-dialog.d.ts +10 -0
- package/dist/feedback/feedback-dialog.js +6 -4
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox-page.d.ts +260 -0
- package/dist/feedback/feedback-inbox-page.js +207 -0
- package/dist/feedback/feedback-inbox-page.js.map +1 -0
- package/dist/feedback/feedback-record.d.ts +5 -0
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-row-detail-labels.js +1 -0
- package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +3 -0
- package/dist/feedback/feedback-row-detail.js +3 -0
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-submit-dialog.d.ts +5 -1
- package/dist/feedback/feedback-submit-dialog.js +15 -3
- package/dist/feedback/feedback-submit-dialog.js.map +1 -1
- package/dist/feedback/feedback-submit.d.ts +30 -2
- package/dist/feedback/feedback-submit.js +5 -2
- package/dist/feedback/feedback-submit.js.map +1 -1
- package/dist/feedback/feedback-vocabulary.js +2 -2
- package/dist/feedback/feedback-vocabulary.js.map +1 -1
- package/dist/feedback.d.ts +1 -0
- package/dist/feedback.js +6 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-debounce.d.ts +32 -5
- package/dist/hooks/use-debounce.js +6 -5
- package/dist/hooks/use-debounce.js.map +1 -1
- package/dist/hooks/use-file-picker.d.ts +3 -1
- package/dist/hooks/use-file-picker.js.map +1 -1
- package/dist/hooks/use-focus-trap.d.ts +19 -3
- package/dist/hooks/use-focus-trap.js +15 -5
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-has-camera.d.ts +36 -0
- package/dist/hooks/use-has-camera.js +53 -0
- package/dist/hooks/use-has-camera.js.map +1 -0
- package/dist/hooks/use-hotkey.js +2 -1
- package/dist/hooks/use-hotkey.js.map +1 -1
- package/dist/hooks/use-overlay-history.d.ts +6 -1
- package/dist/hooks/use-overlay-history.js +10 -2
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +78 -4
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +20 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +95 -5
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +74 -4
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +75 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +77 -4
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +77 -4
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +74 -4
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +22 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +27 -8
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/landing/landing-labels.d.ts +8 -0
- package/dist/landing/landing-labels.js +2 -1
- package/dist/landing/landing-labels.js.map +1 -1
- package/dist/lib/changelog.d.ts +130 -0
- package/dist/lib/changelog.js +137 -0
- package/dist/lib/changelog.js.map +1 -0
- package/dist/lib/clipboard-minus.js +2 -2
- package/dist/lib/clipboard-minus.js.map +1 -1
- package/dist/lib/dates.d.ts +36 -4
- package/dist/lib/dates.js +49 -13
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/editable-content.d.ts +33 -0
- package/dist/lib/editable-content.js +15 -0
- package/dist/lib/editable-content.js.map +1 -0
- package/dist/lib/focus-left.d.ts +47 -1
- package/dist/lib/focus-left.js +11 -2
- package/dist/lib/focus-left.js.map +1 -1
- package/dist/lib/format.d.ts +37 -2
- package/dist/lib/format.js +25 -1
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/intl-cache.d.ts +4 -2
- package/dist/lib/intl-cache.js.map +1 -1
- package/dist/lib/server-wake.d.ts +49 -9
- package/dist/lib/server-wake.js +25 -14
- package/dist/lib/server-wake.js.map +1 -1
- package/dist/lib/session-refresh.d.ts +53 -0
- package/dist/lib/session-refresh.js +27 -1
- package/dist/lib/session-refresh.js.map +1 -1
- package/dist/lib/translation-review.d.ts +26 -0
- package/dist/lib/translation-review.js +14 -0
- package/dist/lib/translation-review.js.map +1 -1
- package/dist/rhf/fields.js +3 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/shell/app-shell.d.ts +25 -1
- package/dist/shell/app-shell.js +3 -1
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/dev-menu.d.ts +3 -0
- package/dist/shell/dev-menu.js +4 -2
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/held-changes-banner-labels.d.ts +23 -0
- package/dist/shell/held-changes-banner-labels.js +14 -0
- package/dist/shell/held-changes-banner-labels.js.map +1 -0
- package/dist/shell/held-changes-banner.d.ts +75 -0
- package/dist/shell/held-changes-banner.js +106 -0
- package/dist/shell/held-changes-banner.js.map +1 -0
- package/dist/shell/sync-status-indicator.d.ts +27 -12
- package/dist/shell/sync-status-indicator.js +13 -4
- package/dist/shell/sync-status-indicator.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.d.ts +5 -0
- package/dist/shell/top-bar-parts-labels.js +3 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell.d.ts +2 -0
- package/dist/shell.js +3 -0
- package/dist/shell.js.map +1 -1
- package/dist/sync/engine.d.ts +11 -2
- package/dist/sync/engine.js +13 -5
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/hooks.d.ts +3 -2
- package/dist/sync/hooks.js +4 -2
- package/dist/sync/hooks.js.map +1 -1
- package/dist/testing/css-variables.generated.d.ts +2 -2
- package/dist/testing/css-variables.generated.js +1 -1
- package/dist/testing/css-variables.generated.js.map +1 -1
- package/dist/theme/chart-palette.d.ts +18 -0
- package/dist/theme/chart-palette.js +17 -1
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/theme/contrast-tokens.d.ts +3 -3
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +4 -4
- package/dist/theme/contrast.js.map +1 -1
- package/dist/tour/tour-overlay.js +2 -1
- package/dist/tour/tour-overlay.js.map +1 -1
- package/package.json +5 -9
- package/tokens.css +19 -54
- package/src/account/account-parts.ts +0 -47
- package/src/account/account-settings-labels.ts +0 -240
- package/src/account/account-settings.tsx +0 -698
- package/src/account/data-export-setting-labels.ts +0 -20
- package/src/account/data-export-setting.tsx +0 -200
- package/src/account/delete-account-setting-labels.ts +0 -33
- package/src/account/delete-account-setting.tsx +0 -341
- package/src/account/email-change-setting-labels.ts +0 -31
- package/src/account/email-change-setting.tsx +0 -443
- package/src/account/passkeys-setting.tsx +0 -445
- package/src/account/sessions-setting-labels.ts +0 -24
- package/src/account/sessions-setting.tsx +0 -283
- package/src/admin/admin-action-confirm-labels.ts +0 -19
- package/src/admin/admin-action-confirm.tsx +0 -509
- package/src/admin/admin-action-log-labels.ts +0 -83
- package/src/admin/admin-action-log.tsx +0 -464
- package/src/admin/admin-area-labels.ts +0 -114
- package/src/admin/admin-forbidden.tsx +0 -75
- package/src/admin/admin-overview.tsx +0 -258
- package/src/admin/admin-parts.ts +0 -68
- package/src/admin/admin-sections.tsx +0 -208
- package/src/admin/admin-tool-links.tsx +0 -90
- package/src/admin/invitations-panel-labels.ts +0 -31
- package/src/admin/invitations-panel.tsx +0 -516
- package/src/admin/mail-test-card-labels.ts +0 -19
- package/src/admin/mail-test-card.tsx +0 -189
- package/src/admin/plan-change-labels.ts +0 -5
- package/src/admin/plan-change.tsx +0 -474
- package/src/admin/reviewer-scope-editor-labels.ts +0 -16
- package/src/admin/reviewer-scope-editor.tsx +0 -224
- package/src/admin/role-select-labels.ts +0 -16
- package/src/admin/role-select.tsx +0 -282
- package/src/admin/transfer-ownership-dialog-labels.ts +0 -20
- package/src/admin/transfer-ownership-dialog.tsx +0 -162
- package/src/admin/user-roster-labels.ts +0 -17
- package/src/admin/user-roster.tsx +0 -559
- package/src/auth/accept-invitation-labels.ts +0 -21
- package/src/auth/accept-invitation.tsx +0 -210
- package/src/auth/auth-errors-labels.ts +0 -23
- package/src/auth/auth-errors.ts +0 -370
- package/src/auth/complete-name-dialog-labels.ts +0 -16
- package/src/auth/complete-name-dialog.tsx +0 -253
- package/src/auth/email-tag.ts +0 -75
- package/src/auth/forgot-password-form-labels.ts +0 -20
- package/src/auth/forgot-password-form.tsx +0 -221
- package/src/auth/form-rules.ts +0 -40
- package/src/auth/new-password-fields.tsx +0 -85
- package/src/auth/not-found-page-labels.ts +0 -12
- package/src/auth/not-found-page.tsx +0 -95
- package/src/auth/register-form-labels.ts +0 -31
- package/src/auth/register-form.tsx +0 -456
- package/src/auth/reset-password-form-labels.ts +0 -27
- package/src/auth/reset-password-form.tsx +0 -341
- package/src/auth/sign-in-form-labels.ts +0 -44
- package/src/auth/sign-in-form.tsx +0 -858
- package/src/auth/status-parts.tsx +0 -132
- package/src/auth/verify-email-labels.ts +0 -26
- package/src/auth/verify-email.tsx +0 -445
- package/src/billing/billing-banner.tsx +0 -258
- package/src/billing/billing-labels.ts +0 -381
- package/src/billing/billing-lock.ts +0 -108
- package/src/billing/billing-overview.ts +0 -157
- package/src/billing/billing-standing.ts +0 -80
- package/src/billing/cancel-request.ts +0 -97
- package/src/billing/cancel-subscription.tsx +0 -98
- package/src/billing/checkout-processing.ts +0 -394
- package/src/billing/checkout-return.ts +0 -90
- package/src/billing/pay-page.ts +0 -330
- package/src/billing/plan-card.tsx +0 -562
- package/src/billing/plan-change-labels.ts +0 -66
- package/src/billing/plan-limit-notice.tsx +0 -148
- package/src/billing/plan-limit-toast.tsx +0 -90
- package/src/billing/plan-limit.ts +0 -52
- package/src/billing/plan-price.ts +0 -98
- package/src/billing/plan-switch.tsx +0 -216
- package/src/billing/provider-page.ts +0 -84
- package/src/billing/subscription-actions.tsx +0 -247
- package/src/billing/subscription-status-chip.tsx +0 -95
- package/src/chart.ts +0 -103
- package/src/components/account-chips-labels.ts +0 -16
- package/src/components/account-chips.tsx +0 -474
- package/src/components/alert-banner.tsx +0 -670
- package/src/components/amount-input.tsx +0 -815
- package/src/components/appearance-labels.ts +0 -63
- package/src/components/authed-image-labels.ts +0 -11
- package/src/components/authed-image.tsx +0 -209
- package/src/components/autocomplete.tsx +0 -645
- package/src/components/breadcrumbs-labels.ts +0 -10
- package/src/components/breadcrumbs.tsx +0 -205
- package/src/components/bulk-action-bar-labels.ts +0 -11
- package/src/components/bulk-action-bar.tsx +0 -443
- package/src/components/button-group.tsx +0 -223
- package/src/components/button-look.ts +0 -256
- package/src/components/button.tsx +0 -339
- package/src/components/calculator.tsx +0 -341
- package/src/components/calendar-heatmap-labels.ts +0 -15
- package/src/components/calendar-heatmap.tsx +0 -594
- package/src/components/card.tsx +0 -377
- package/src/components/chart-edge.ts +0 -106
- package/src/components/chart-figure.tsx +0 -35
- package/src/components/chart-height.ts +0 -30
- package/src/components/chart-zoom-core.tsx +0 -627
- package/src/components/chart-zoom.tsx +0 -22
- package/src/components/chart.tsx +0 -554
- package/src/components/checkbox-group.tsx +0 -247
- package/src/components/checkbox.tsx +0 -346
- package/src/components/chip-input.tsx +0 -370
- package/src/components/chip-labels.ts +0 -13
- package/src/components/chip.tsx +0 -843
- package/src/components/choice-card.tsx +0 -544
- package/src/components/column-mapper-labels.ts +0 -38
- package/src/components/column-mapper.tsx +0 -655
- package/src/components/combobox-core.tsx +0 -1321
- package/src/components/combobox-suggestions.tsx +0 -131
- package/src/components/combobox.tsx +0 -716
- package/src/components/confirm-context.ts +0 -7
- package/src/components/confirm-dialog-labels.ts +0 -13
- package/src/components/confirm-dialog.tsx +0 -341
- package/src/components/copy-button-labels.ts +0 -13
- package/src/components/copy-button.tsx +0 -192
- package/src/components/country-select-labels.ts +0 -11
- package/src/components/country-select.tsx +0 -539
- package/src/components/currency-option-list.tsx +0 -180
- package/src/components/currency-select.tsx +0 -341
- package/src/components/danger-confirm-labels.ts +0 -20
- package/src/components/danger-confirm.tsx +0 -934
- package/src/components/data-table-cells.tsx +0 -118
- package/src/components/data-table-column-settings.tsx +0 -198
- package/src/components/data-table-filter-popover.tsx +0 -281
- package/src/components/data-table-filters.ts +0 -287
- package/src/components/data-table-fit.ts +0 -301
- package/src/components/data-table-groups.tsx +0 -288
- package/src/components/data-table-head.tsx +0 -280
- package/src/components/data-table-labels.ts +0 -198
- package/src/components/data-table-leading-row.tsx +0 -58
- package/src/components/data-table-mobile.tsx +0 -1117
- package/src/components/data-table-pagination.tsx +0 -202
- package/src/components/data-table-resize.ts +0 -188
- package/src/components/data-table-row-actions.tsx +0 -302
- package/src/components/data-table-row.tsx +0 -496
- package/src/components/data-table-selection.ts +0 -71
- package/src/components/data-table-shared.tsx +0 -287
- package/src/components/data-table-sort.ts +0 -163
- package/src/components/data-table-virtual.ts +0 -576
- package/src/components/data-table.tsx +0 -2598
- package/src/components/date-field.tsx +0 -684
- package/src/components/date-format-setting.tsx +0 -64
- package/src/components/date-picker.tsx +0 -404
- package/src/components/date-range-picker.tsx +0 -518
- package/src/components/description-list-labels.ts +0 -9
- package/src/components/description-list.tsx +0 -386
- package/src/components/dialog-frame-labels.ts +0 -7
- package/src/components/dialog-frame.tsx +0 -276
- package/src/components/disclosure.tsx +0 -476
- package/src/components/dropdown.tsx +0 -461
- package/src/components/empty-state.tsx +0 -136
- package/src/components/entity-combobox.tsx +0 -422
- package/src/components/error-boundary-labels.ts +0 -20
- package/src/components/error-boundary.tsx +0 -675
- package/src/components/facing-pair.ts +0 -93
- package/src/components/field-base-labels.ts +0 -20
- package/src/components/field-base.tsx +0 -656
- package/src/components/field-parts.tsx +0 -825
- package/src/components/field-strip.tsx +0 -129
- package/src/components/field.tsx +0 -206
- package/src/components/file-button.tsx +0 -295
- package/src/components/file-dropzone.tsx +0 -559
- package/src/components/floating-panel-labels.ts +0 -10
- package/src/components/floating-panel.tsx +0 -828
- package/src/components/focus-ring.ts +0 -16
- package/src/components/form-actions-labels.ts +0 -11
- package/src/components/form-actions.tsx +0 -578
- package/src/components/full-bleed-dialog.tsx +0 -294
- package/src/components/grouped-picker.tsx +0 -184
- package/src/components/help-popover.tsx +0 -117
- package/src/components/hover-menu.tsx +0 -343
- package/src/components/iban-input-labels.ts +0 -14
- package/src/components/iban-input.tsx +0 -236
- package/src/components/icon-button.tsx +0 -959
- package/src/components/icon-picker-labels.ts +0 -13
- package/src/components/icon-picker.tsx +0 -232
- package/src/components/image-grid-labels.ts +0 -11
- package/src/components/image-grid.tsx +0 -202
- package/src/components/inline-confirm.tsx +0 -116
- package/src/components/inline-edit-field-labels.ts +0 -11
- package/src/components/inline-edit-field.tsx +0 -552
- package/src/components/inline-entity-combobox.tsx +0 -849
- package/src/components/input.tsx +0 -394
- package/src/components/jump-calendar.tsx +0 -265
- package/src/components/language-select.tsx +0 -93
- package/src/components/legal-labels.ts +0 -105
- package/src/components/legal-page.tsx +0 -711
- package/src/components/legal.tsx +0 -668
- package/src/components/lightbox-labels.ts +0 -18
- package/src/components/lightbox.tsx +0 -399
- package/src/components/line-items-labels.ts +0 -14
- package/src/components/line-items.tsx +0 -602
- package/src/components/list-labels.ts +0 -12
- package/src/components/list.tsx +0 -870
- package/src/components/loading-state.tsx +0 -78
- package/src/components/measured-grid-labels.ts +0 -25
- package/src/components/measured-grid.tsx +0 -837
- package/src/components/menu-item.tsx +0 -241
- package/src/components/mini-calendar-labels.ts +0 -17
- package/src/components/mini-calendar.tsx +0 -789
- package/src/components/modal.tsx +0 -505
- package/src/components/money-draft.ts +0 -83
- package/src/components/money-field.tsx +0 -76
- package/src/components/month-grid.tsx +0 -229
- package/src/components/month-picker-labels.ts +0 -22
- package/src/components/month-picker.tsx +0 -1087
- package/src/components/multi-entity-combobox.tsx +0 -369
- package/src/components/multi-select.tsx +0 -376
- package/src/components/nav-pills.tsx +0 -198
- package/src/components/number-field.tsx +0 -327
- package/src/components/number-input.tsx +0 -558
- package/src/components/numeric-field.ts +0 -169
- package/src/components/numpad-sheet.tsx +0 -285
- package/src/components/one-time-code-input.tsx +0 -270
- package/src/components/page-contents-labels.ts +0 -9
- package/src/components/page-contents.tsx +0 -282
- package/src/components/page-header-context.ts +0 -8
- package/src/components/page-header.tsx +0 -298
- package/src/components/password-strength-labels.ts +0 -22
- package/src/components/password-strength.tsx +0 -241
- package/src/components/phone-input-labels.ts +0 -10
- package/src/components/phone-input.tsx +0 -282
- package/src/components/picker-sheet.tsx +0 -330
- package/src/components/pie-chart-labels.ts +0 -40
- package/src/components/pie-chart.tsx +0 -480
- package/src/components/popover-labels.ts +0 -14
- package/src/components/popover.tsx +0 -268
- package/src/components/progress-bar-labels.ts +0 -10
- package/src/components/progress-bar.tsx +0 -479
- package/src/components/qr-code.tsx +0 -76
- package/src/components/reauth-dialog-labels.ts +0 -13
- package/src/components/reauth-dialog.tsx +0 -265
- package/src/components/row-actions-labels.ts +0 -12
- package/src/components/row-actions.tsx +0 -795
- package/src/components/scroll-area.tsx +0 -123
- package/src/components/search-field.tsx +0 -192
- package/src/components/select.tsx +0 -294
- package/src/components/separator.tsx +0 -33
- package/src/components/series-chart-axes.ts +0 -342
- package/src/components/series-chart-budget.ts +0 -150
- package/src/components/series-chart-labels.ts +0 -33
- package/src/components/series-chart-thin.ts +0 -180
- package/src/components/series-chart-ticks.ts +0 -194
- package/src/components/series-chart.tsx +0 -1906
- package/src/components/server-wake-labels.ts +0 -11
- package/src/components/server-wake.tsx +0 -129
- package/src/components/settings-fields.tsx +0 -237
- package/src/components/share-card-labels.ts +0 -30
- package/src/components/share-card.tsx +0 -675
- package/src/components/signature-pad-labels.ts +0 -24
- package/src/components/signature-pad.tsx +0 -747
- package/src/components/signed-amount-labels.ts +0 -10
- package/src/components/signed-amount.tsx +0 -336
- package/src/components/skeleton.tsx +0 -80
- package/src/components/slider.tsx +0 -338
- package/src/components/sparkline-labels.ts +0 -14
- package/src/components/sparkline.tsx +0 -322
- package/src/components/spinner.tsx +0 -81
- package/src/components/stat-tile-labels.ts +0 -15
- package/src/components/stat-tile.tsx +0 -725
- package/src/components/status-dot.tsx +0 -170
- package/src/components/swatch-picker-labels.ts +0 -10
- package/src/components/swatch-picker.tsx +0 -283
- package/src/components/swipeable-row.tsx +0 -386
- package/src/components/switch.tsx +0 -273
- package/src/components/table-skeleton.tsx +0 -136
- package/src/components/table.tsx +0 -647
- package/src/components/tabs-labels.ts +0 -13
- package/src/components/tabs.tsx +0 -693
- package/src/components/text-link.tsx +0 -359
- package/src/components/text.tsx +0 -150
- package/src/components/textarea.tsx +0 -330
- package/src/components/tile-radio.tsx +0 -332
- package/src/components/time-input.tsx +0 -121
- package/src/components/toast-labels.ts +0 -12
- package/src/components/toast.tsx +0 -519
- package/src/components/toggle-group.tsx +0 -752
- package/src/components/toggle-legend.tsx +0 -394
- package/src/components/tooltip.tsx +0 -1149
- package/src/components/translation-review-editor.tsx +0 -290
- package/src/components/translation-review-labels.ts +0 -181
- package/src/components/translation-review-parts.tsx +0 -272
- package/src/components/translation-review.tsx +0 -1240
- package/src/components/tree-view.tsx +0 -589
- package/src/components/treemap-labels.ts +0 -47
- package/src/components/treemap-layout.ts +0 -210
- package/src/components/treemap.tsx +0 -1184
- package/src/components/trigger-aria.ts +0 -44
- package/src/components/use-anchor-dir.ts +0 -20
- package/src/components/use-mobile-reveal.ts +0 -62
- package/src/components/use-table-state.ts +0 -753
- package/src/components/user-avatar.tsx +0 -116
- package/src/components/wizard-stepper.tsx +0 -42
- package/src/components/write-lock-labels.ts +0 -10
- package/src/components/write-lock.tsx +0 -253
- package/src/currencies.ts +0 -70
- package/src/data-table.ts +0 -42
- package/src/demo/demo-banner.tsx +0 -153
- package/src/demo/demo-countdown.ts +0 -136
- package/src/demo/demo-ended.tsx +0 -90
- package/src/demo/demo-labels.ts +0 -78
- package/src/demo/demo-session.ts +0 -32
- package/src/demo/demo-start.tsx +0 -156
- package/src/eslint/index.ts +0 -161
- package/src/eslint/role-utilities.generated.ts +0 -146
- package/src/eslint/role-utilities.ts +0 -233
- package/src/feedback/feedback-attachment-download.tsx +0 -77
- package/src/feedback/feedback-attachment-labels.ts +0 -37
- package/src/feedback/feedback-attachment.tsx +0 -1239
- package/src/feedback/feedback-capture.ts +0 -287
- package/src/feedback/feedback-comment-thread.tsx +0 -353
- package/src/feedback/feedback-context-labels.ts +0 -10
- package/src/feedback/feedback-context.tsx +0 -213
- package/src/feedback/feedback-crash.ts +0 -547
- package/src/feedback/feedback-dialog-labels.ts +0 -29
- package/src/feedback/feedback-dialog.tsx +0 -440
- package/src/feedback/feedback-entry-file.tsx +0 -150
- package/src/feedback/feedback-inbox.tsx +0 -552
- package/src/feedback/feedback-labels.ts +0 -144
- package/src/feedback/feedback-menu-labels.ts +0 -12
- package/src/feedback/feedback-menu.tsx +0 -177
- package/src/feedback/feedback-mutation.ts +0 -20
- package/src/feedback/feedback-page-link.ts +0 -90
- package/src/feedback/feedback-public-labels.ts +0 -81
- package/src/feedback/feedback-public-list.tsx +0 -524
- package/src/feedback/feedback-public-switch.tsx +0 -102
- package/src/feedback/feedback-public-types.ts +0 -101
- package/src/feedback/feedback-record.ts +0 -423
- package/src/feedback/feedback-replies-context.ts +0 -9
- package/src/feedback/feedback-replies.tsx +0 -343
- package/src/feedback/feedback-rework-entry-chip.tsx +0 -18
- package/src/feedback/feedback-row-detail-labels.ts +0 -30
- package/src/feedback/feedback-row-detail.tsx +0 -858
- package/src/feedback/feedback-status-undo.ts +0 -109
- package/src/feedback/feedback-submit-dialog.tsx +0 -118
- package/src/feedback/feedback-submit.tsx +0 -237
- package/src/feedback/feedback-swipe.tsx +0 -192
- package/src/feedback/feedback-table-labels.ts +0 -27
- package/src/feedback/feedback-table.tsx +0 -912
- package/src/feedback/feedback-thread-labels.ts +0 -22
- package/src/feedback/feedback-thread-parts-labels.ts +0 -41
- package/src/feedback/feedback-thread.tsx +0 -905
- package/src/feedback/feedback-vocabulary.ts +0 -263
- package/src/feedback/feedback-vote-button.tsx +0 -124
- package/src/feedback.ts +0 -116
- package/src/hooks/use-anchored-panel.ts +0 -396
- package/src/hooks/use-anchored-rect.ts +0 -77
- package/src/hooks/use-announce.ts +0 -85
- package/src/hooks/use-authed-src.ts +0 -167
- package/src/hooks/use-body-scroll-lock.ts +0 -119
- package/src/hooks/use-breakpoint.ts +0 -133
- package/src/hooks/use-close-transition.ts +0 -107
- package/src/hooks/use-copy-to-clipboard.ts +0 -122
- package/src/hooks/use-debounce.ts +0 -114
- package/src/hooks/use-dismiss.ts +0 -371
- package/src/hooks/use-document-title.ts +0 -33
- package/src/hooks/use-file-drop.ts +0 -121
- package/src/hooks/use-file-picker-labels.ts +0 -28
- package/src/hooks/use-file-picker.tsx +0 -359
- package/src/hooks/use-focus-trap.ts +0 -199
- package/src/hooks/use-hotkey.ts +0 -189
- package/src/hooks/use-large-text.ts +0 -41
- package/src/hooks/use-long-press.ts +0 -140
- package/src/hooks/use-media-query.ts +0 -39
- package/src/hooks/use-mounted.ts +0 -39
- package/src/hooks/use-noindex.ts +0 -37
- package/src/hooks/use-overlay-history.ts +0 -714
- package/src/hooks/use-row-swipe.ts +0 -207
- package/src/hooks/use-search-param-state.ts +0 -434
- package/src/hooks/use-windowed-rows.ts +0 -225
- package/src/i18n/defaults.ts +0 -267
- package/src/i18n/german.ts +0 -2057
- package/src/i18n/kit-labels.tsx +0 -1003
- package/src/i18n/languages.ts +0 -349
- package/src/i18n/locales/de-CH.ts +0 -24
- package/src/i18n/locales/en.ts +0 -267
- package/src/i18n/locales/es.ts +0 -1997
- package/src/i18n/locales/fr.ts +0 -2035
- package/src/i18n/locales/hu.ts +0 -2002
- package/src/i18n/locales/it.ts +0 -2012
- package/src/i18n/locales/zh.ts +0 -1910
- package/src/i18n/plurals.ts +0 -86
- package/src/i18n/review.ts +0 -475
- package/src/i18n/shared-labels.ts +0 -138
- package/src/i18n/swiss.ts +0 -29
- package/src/index.ts +0 -1179
- package/src/landing/access.ts +0 -93
- package/src/landing/landing-actions.tsx +0 -97
- package/src/landing/landing-labels.ts +0 -59
- package/src/landing/landing-sections.tsx +0 -341
- package/src/landing/page-seo.ts +0 -261
- package/src/landing/public-header.tsx +0 -121
- package/src/landing/public-page.tsx +0 -106
- package/src/landing/routing.tsx +0 -225
- package/src/lib/broadcast.ts +0 -52
- package/src/lib/calc.ts +0 -323
- package/src/lib/chip-edge-snap.ts +0 -212
- package/src/lib/clipboard-minus.ts +0 -107
- package/src/lib/clipping.ts +0 -34
- package/src/lib/cn.ts +0 -28
- package/src/lib/column-mapping.ts +0 -234
- package/src/lib/countries.ts +0 -91
- package/src/lib/data-attributes.ts +0 -14
- package/src/lib/date-format.ts +0 -227
- package/src/lib/dates.ts +0 -266
- package/src/lib/day-format.ts +0 -96
- package/src/lib/decimal-marks.ts +0 -108
- package/src/lib/describe-failure.ts +0 -18
- package/src/lib/device-settings.ts +0 -147
- package/src/lib/direction.ts +0 -74
- package/src/lib/document-navigation.ts +0 -17
- package/src/lib/document-title.ts +0 -41
- package/src/lib/download.ts +0 -172
- package/src/lib/float-clearance.ts +0 -70
- package/src/lib/floating-stack.ts +0 -70
- package/src/lib/focus-left.ts +0 -156
- package/src/lib/format.ts +0 -522
- package/src/lib/http-status.ts +0 -38
- package/src/lib/iban.ts +0 -251
- package/src/lib/ime.ts +0 -24
- package/src/lib/intl-cache.ts +0 -25
- package/src/lib/iso-day.ts +0 -13
- package/src/lib/lazy-with-fallback.ts +0 -82
- package/src/lib/logger.ts +0 -69
- package/src/lib/minus.ts +0 -50
- package/src/lib/path-pattern.ts +0 -55
- package/src/lib/person-name.ts +0 -155
- package/src/lib/phone.ts +0 -208
- package/src/lib/plain-text.ts +0 -22
- package/src/lib/presence.ts +0 -18
- package/src/lib/qr-encode.ts +0 -444
- package/src/lib/quiet-focus.ts +0 -32
- package/src/lib/reduced-motion.ts +0 -22
- package/src/lib/refs.ts +0 -22
- package/src/lib/round.ts +0 -43
- package/src/lib/safe-storage.ts +0 -119
- package/src/lib/server-wake.ts +0 -315
- package/src/lib/session-refresh.ts +0 -472
- package/src/lib/share-format.ts +0 -18
- package/src/lib/status-tone.ts +0 -43
- package/src/lib/strip-fade.ts +0 -287
- package/src/lib/table-text.ts +0 -554
- package/src/lib/text-case.ts +0 -19
- package/src/lib/text-match.ts +0 -169
- package/src/lib/thenable.ts +0 -19
- package/src/lib/translation-review.ts +0 -717
- package/src/notifications/device-zone-report.ts +0 -67
- package/src/notifications/feedback-notification-types-labels.ts +0 -33
- package/src/notifications/feedback-notification-types.ts +0 -71
- package/src/notifications/notification-bell.tsx +0 -119
- package/src/notifications/notification-inbox.tsx +0 -309
- package/src/notifications/notification-parts.tsx +0 -81
- package/src/notifications/notification-types-setting.tsx +0 -406
- package/src/notifications/notification-types.ts +0 -89
- package/src/notifications/notifications-labels.ts +0 -287
- package/src/notifications/push-device-setting.tsx +0 -230
- package/src/notifications/push-devices-setting.tsx +0 -374
- package/src/notifications/push-worker.ts +0 -168
- package/src/notifications/quiet-hours-setting.tsx +0 -238
- package/src/notifications/unsubscribe-panel.tsx +0 -200
- package/src/notifications/use-push-device.ts +0 -448
- package/src/offline/local-first.ts +0 -100
- package/src/offline/pwa-update-prompt-labels.ts +0 -9
- package/src/offline/pwa-update-prompt.tsx +0 -78
- package/src/offline/query-persistence.ts +0 -391
- package/src/offline/service-worker-updates.ts +0 -81
- package/src/offline/shared-computer-labels.ts +0 -8
- package/src/offline/shared-computer.tsx +0 -87
- package/src/offline/sign-out-pending-dialog-labels.ts +0 -21
- package/src/offline/sign-out-pending-dialog.tsx +0 -135
- package/src/offline.ts +0 -37
- package/src/push-worker.ts +0 -25
- package/src/rhf/fields.tsx +0 -2187
- package/src/rhf/form-core.tsx +0 -324
- package/src/rhf/form.tsx +0 -12
- package/src/rhf/line-items.tsx +0 -135
- package/src/rhf/use-rhf-wizard-step.ts +0 -104
- package/src/rhf.ts +0 -21
- package/src/search/command-palette-labels.ts +0 -16
- package/src/search/command-palette.tsx +0 -624
- package/src/search/global-search-labels.ts +0 -13
- package/src/search/global-search.tsx +0 -660
- package/src/search/search-index.ts +0 -283
- package/src/search/use-command-key.ts +0 -23
- package/src/search.ts +0 -14
- package/src/settings/device-reset-setting-labels.ts +0 -20
- package/src/settings/device-reset-setting.tsx +0 -116
- package/src/settings/settings-card-classes.ts +0 -11
- package/src/settings/settings-catalogue.ts +0 -150
- package/src/settings/settings-context.ts +0 -33
- package/src/settings/settings-heading.tsx +0 -67
- package/src/settings/settings-labels.ts +0 -87
- package/src/settings/settings-layout.tsx +0 -471
- package/src/settings/settings-section.tsx +0 -108
- package/src/settings/use-account-appearance.ts +0 -148
- package/src/settings/use-account-language.ts +0 -146
- package/src/settings/use-settings-focus.ts +0 -128
- package/src/settings/use-settings-route.ts +0 -258
- package/src/shell/account-menu-language.tsx +0 -130
- package/src/shell/account-menu-text-size.tsx +0 -80
- package/src/shell/admin-menu.tsx +0 -183
- package/src/shell/app-shell-labels.ts +0 -11
- package/src/shell/app-shell.tsx +0 -1560
- package/src/shell/auth-layout.tsx +0 -186
- package/src/shell/company-switcher-labels.ts +0 -13
- package/src/shell/company-switcher.tsx +0 -136
- package/src/shell/dev-menu.tsx +0 -257
- package/src/shell/fill-height.tsx +0 -45
- package/src/shell/language-code.ts +0 -5
- package/src/shell/option-switcher-menu.tsx +0 -84
- package/src/shell/sync-status-indicator.tsx +0 -303
- package/src/shell/top-bar-actions.tsx +0 -87
- package/src/shell/top-bar-brand.tsx +0 -78
- package/src/shell/top-bar-parts-labels.ts +0 -148
- package/src/shell/top-bar.tsx +0 -40
- package/src/shell/topbar-action-menu.tsx +0 -567
- package/src/shell/topbar-controls.tsx +0 -269
- package/src/shell/tour-menu.tsx +0 -187
- package/src/shell.ts +0 -108
- package/src/sync/db.ts +0 -129
- package/src/sync/engine.ts +0 -1011
- package/src/sync/hooks.ts +0 -98
- package/src/sync/testing.ts +0 -73
- package/src/sync/wire.ts +0 -61
- package/src/sync.ts +0 -37
- package/src/table-text.ts +0 -8
- package/src/testing/css-variables.generated.ts +0 -112
- package/src/testing/css-variables.ts +0 -189
- package/src/testing/index.ts +0 -29
- package/src/testing/react.ts +0 -58
- package/src/testing/tour.ts +0 -41
- package/src/testing/viewport.ts +0 -357
- package/src/theme/chart-palette.ts +0 -232
- package/src/theme/color.ts +0 -272
- package/src/theme/contrast-tokens.ts +0 -268
- package/src/theme/contrast.ts +0 -250
- package/src/theme/palette-derive.ts +0 -825
- package/src/theme/palette-presets.ts +0 -544
- package/src/theme/palette-store.ts +0 -108
- package/src/theme/text-size.ts +0 -289
- package/src/theme/theme-store.ts +0 -157
- package/src/tour/tour-catalogue-labels.ts +0 -75
- package/src/tour/tour-catalogue.tsx +0 -335
- package/src/tour/tour-dock.ts +0 -134
- package/src/tour/tour-engine.ts +0 -37
- package/src/tour/tour-gates.ts +0 -218
- package/src/tour/tour-guide-button.tsx +0 -64
- package/src/tour/tour-guide-labels.ts +0 -15
- package/src/tour/tour-info.ts +0 -144
- package/src/tour/tour-labels.ts +0 -23
- package/src/tour/tour-overlay.tsx +0 -1170
- package/src/tour/tour.tsx +0 -750
- package/src/tour/use-tour-progress.ts +0 -671
- package/src/tour/use-tour-url-sync.ts +0 -266
- package/src/tour.ts +0 -21
- package/src/vite-env.d.ts +0 -23
- package/src/wizard/stepper-nav.tsx +0 -360
- package/src/wizard/types.ts +0 -275
- package/src/wizard/use-wizard.ts +0 -560
- package/src/wizard/validation.ts +0 -39
- package/src/wizard/wizard-context.tsx +0 -74
- package/src/wizard/wizard-labels.ts +0 -29
- package/src/wizard/wizard-step.tsx +0 -76
- package/src/wizard/wizard-summary.tsx +0 -84
- package/src/wizard.ts +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/plan-change.tsx"],"sourcesContent":["import { isValidElement, useCallback, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { pluralForm } from \"../i18n/plurals\";\nimport type { PluralForms } from \"../i18n/plurals\";\nimport { formatNumber, EMPTY_FORMATTED_VALUE } from \"../lib/format\";\nimport { toLocalIso } from \"../lib/dates\";\nimport type { DataTableColumn } from \"../components/data-table\";\nimport { DatePicker } from \"../components/date-picker\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { Select } from \"../components/select\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { useBillingLabels } from \"../billing/billing-labels\";\nimport type { SubscriptionStatus } from \"../billing/billing-labels\";\nimport { SubscriptionStatusChip } from \"../billing/subscription-status-chip\";\nimport { AdminActionConfirm } from \"./admin-action-confirm\";\nimport type { AdminActionConfirmValues } from \"./admin-action-confirm\";\nimport { personLabel, useDayText } from \"./admin-parts\";\nimport type { AdminPerson, MaybePromise } from \"./admin-parts\";\nimport { DEFAULT_PLAN_CHANGE_LABELS } from \"../billing/plan-change-labels\";\nimport type { PlanChangeLabels } from \"../billing/plan-change-labels\";\n\n/**\n * The operator's plan parts (docs/billing-harmonization.md §14.12, decision 27):\n * {@link planColumn} for the roster or the companies list, {@link PlanChangeConfirm}\n * for the grant, and {@link usePlanChangeResult} for what the answer says.\n *\n * All three apps have the route (`POST /admin/users/{id}/plan`, kastlan's\n * `POST /platform/companies/{id}/plan`) and server-kit's `PlanChangeRequest` /\n * `PlanChangeResponse`; only keksdose had a UI (`users-panel.tsx`, `PlanConfirm` in\n * `user-admin-confirm.tsx`), and these are its parts, lifted. The plan names are the\n * app's (§3.1): every part takes `planName` or the plans with their names. The plan\n * codes come from `GET /admin/plans` (kastlan `GET /platform/plans`), which answers\n * whatever the billing switch says.\n */\n\n// The words and their type live in billing/plan-change-labels, which holds no component\n// code (0.34, KS U8): PlanSwitchConfirm reads them too, and billing importing admin while\n// this module imports billing made the two folders import each other (refactor audit\n// 2026-10-30, MOD-6).\nexport type { PlanChangeLabels };\nexport { DEFAULT_PLAN_CHANGE_LABELS };\n\n/** A plan code as the parts compare it: lowercase (§12.16 — an older row's \"FREE\" is\n * the same plan as \"free\"), and no code at all as null. */\nfunction codeOf(raw: string | null | undefined): string | null {\n const code = (raw ?? \"\").trim().toLowerCase();\n return code === \"\" ? null : code;\n}\n\n/* ── The column ────────────────────────────────────────────────────────────── */\n\n/** What a row's usage is, for the line under its plan: \"1/5\" — and since 0.34 what\n * {@link PlanChangeConfirm}'s `usage` takes, for the same sentence in the dialog. */\nexport interface PlanColumnUsage {\n used: number;\n /** The plan's limit for it; `null` (unlimited, or none known): no line. */\n limit: number | null;\n /**\n * The app's word for what is counted, as it reads after a number: \"budgets\" in \"1 of 5\n * budgets\" — the word in a sentence, not a heading's \"Budgets\".\n *\n * Its plural forms (0.33.1, keksdose): `{ one: \"budget\", other: \"budgets\" }` — your\n * catalogue's `_one` / `_other` pair, any CLDR category allowed, `other` for the rest\n * ({@link PluralForms}). The column picks the form for the limit in the provider's\n * locale, so a plan of one reads \"1 of 1 budget\". A plain string is used as it is,\n * whatever the count.\n */\n label: string | PluralForms;\n}\n\nexport interface PlanColumnOptions<T> {\n /** The column's key. Default `\"plan\"`. */\n key?: string;\n /** The row's plan code, read without case (§12.16); null for none. */\n plan: (row: T) => string | null;\n /** The plan's display name, the app's (§3.1). Gets the lowercase code. */\n planName: (code: string) => string;\n /** The row's standing, as a `SubscriptionStatusChip` beside the name. Left out, or\n * undefined for a row: no chip — billing off, where a status says nothing. */\n status?: (row: T) => SubscriptionStatus | undefined;\n /** The row's usage of its plan's limit: \"1/5\" under the name, \"1 of 5 budgets\" in\n * the tooltip (`planChange.usageOf`, with the label's form for the limit). Undefined\n * for a row, or a `null` limit: no line. */\n usage?: (row: T) => PlanColumnUsage | undefined;\n /** A select filter over these codes, each named by `planName`. Left out: none. */\n filterPlans?: readonly string[];\n /**\n * The sort. Default: by the plan code (keksdose's, `users-panel.tsx:739`). A function:\n * by its value — the catalogue's `sort` for rank order. `false`: not sortable.\n *\n * Client-side only, as every column's `sortBy`: a `DataTable` with `serverPagination`\n * holds one page, so it sorts nothing itself — with `onSortsChange` it reports the\n * column's `key` (default `\"plan\"`), and your server orders the rows by it.\n */\n sortBy?: false | ((row: T) => string | number | null | undefined);\n /** The header's text. Default `planChange.column`. */\n headerText?: string;\n /** The words, already resolved. Default English; {@link usePlanColumn} reads the\n * provider's `planChange` namespace. */\n labels?: LabelOverride<PlanChangeLabels>;\n}\n\n/**\n * A usage spelled out — `planChange.usageOf` with the figures in `locale` and the word in\n * the form the limit takes: \"1 of 1 budget\", \"Budgets: 1 von 5\". The column's tooltip\n * and the grant dialog's line both read it, so the rule lives once (round 0.34 C15).\n */\nfunction usageSentence(\n usage: PlanColumnUsage & { limit: number },\n usageOf: PlanChangeLabels[\"usageOf\"],\n locale: string | undefined,\n): string {\n const figure = (value: number) => formatNumber(value, { locale });\n const word = typeof usage.label === \"string\" ? usage.label : pluralForm(usage.limit, usage.label, locale);\n return usageOf(figure(usage.used), figure(usage.limit), word);\n}\n\n/** The cell: a component, so the figures follow the provider's locale. */\nfunction PlanCell({\n code,\n name,\n status,\n usage,\n usageOf,\n}: {\n code: string | null;\n name: string;\n status: SubscriptionStatus | undefined;\n usage: PlanColumnUsage | undefined;\n usageOf: PlanChangeLabels[\"usageOf\"];\n}) {\n const locale = useKitLocale();\n const figure = (value: number) => formatNumber(value, { locale });\n return (\n <div className=\"whitespace-nowrap\" data-plan={code ?? undefined}>\n <div className=\"flex items-center gap-1.5\">\n <span className={code ? \"font-medium\" : \"text-muted\"}>{name}</span>\n {/* The standing at a glance (§6): the kit's word and tone, never colour alone. */}\n {status !== undefined && <SubscriptionStatusChip status={status} size=\"xs\" />}\n </div>\n {usage && usage.limit !== null && (\n // \"1/5\" under the plan, \"1 of 5 budgets\" in the tooltip: the sentence spelled out\n // inline was the widest thing in keksdose's table.\n <Tooltip label={usageSentence({ ...usage, limit: usage.limit }, usageOf, locale)}>\n <span className=\"block text-xs tabular-nums text-muted\">\n {figure(usage.used)}/{figure(usage.limit)}\n </span>\n </Tooltip>\n )}\n </div>\n );\n}\n\n/**\n * The roster's (or the companies list's) plan column: the plan's display name, the\n * standing chip beside it while billing is on, and the usage under it — keksdose's\n * column, `users-panel.tsx:706-745`. Pass it in `userRosterColumns`' `extra`, or in\n * any `DataTable`'s columns:\n *\n * extra: [planColumn<AdminUserRow>({\n * plan: (u) => u.plan,\n * planName,\n * status: billingOn ? (u) => u.subscription?.status : undefined,\n * usage: (u) => ({\n * used: u.budgets_owned,\n * limit: u.limits.budgets,\n * label: { one: t(\"planUsage.budget_one\"), other: t(\"planUsage.budget_other\") },\n * }),\n * filterPlans: plans.map((p) => p.code),\n * })]\n *\n * Pure: hand it resolved words, or use {@link usePlanColumn}.\n */\nexport function planColumn<T>(options: PlanColumnOptions<T>): DataTableColumn<T> {\n const { key = \"plan\", plan, planName, status, usage, filterPlans, sortBy, headerText, labels: labelsProp } = options;\n const labels: PlanChangeLabels = { ...DEFAULT_PLAN_CHANGE_LABELS, ...labelsProp };\n const header = headerText ?? labels.column;\n const nameOf = (code: string | null) => (code ? planName(code) : EMPTY_FORMATTED_VALUE);\n return {\n key,\n header,\n headerText: header,\n cell: (row) => {\n const code = codeOf(plan(row));\n return (\n <PlanCell\n code={code}\n name={nameOf(code)}\n status={status?.(row)}\n usage={usage?.(row)}\n usageOf={labels.usageOf}\n />\n );\n },\n sortBy: sortBy === false ? undefined : (sortBy ?? ((row) => codeOf(plan(row)) ?? \"\")),\n filter: filterPlans\n ? {\n type: \"select\",\n getValue: (row) => codeOf(plan(row)) ?? \"\",\n options: [...new Set(filterPlans.map((code) => codeOf(code)).filter((code) => code !== null))].map(\n (code) => ({ value: code, label: planName(code) }),\n ),\n }\n : undefined,\n };\n}\n\n/**\n * {@link planColumn} with the `planChange` words from the provider, memoised on the\n * options — pass stable callbacks (`useCallback`), or the column is rebuilt on every\n * render.\n */\nexport function usePlanColumn<T>(options: PlanColumnOptions<T>): DataTableColumn<T> {\n const { key, plan, planName, status, usage, filterPlans, sortBy, headerText, labels: labelsProp } = options;\n const labels = useKitLabels(\"planChange\", DEFAULT_PLAN_CHANGE_LABELS, labelsProp);\n return useMemo(\n () => planColumn<T>({ key, plan, planName, status, usage, filterPlans, sortBy, headerText, labels }),\n [key, plan, planName, status, usage, filterPlans, sortBy, headerText, labels],\n );\n}\n\n/* ── The grant ─────────────────────────────────────────────────────────────── */\n\n/** What {@link PlanChangeConfirmProps.onConfirm} sends: server-kit's\n * `PlanChangeRequest` without its `acknowledged`, which comes in `values`. */\nexport interface PlanChange {\n /** The picked plan's code. */\n plan: string;\n /** The end of the free grant, as ISO UTC — only when one was picked. */\n comped_until?: string;\n}\n\nexport interface PlanChangeConfirmProps {\n /**\n * Whom it is about — a user (`AdminActionTarget`), or kastlan's company, which has no\n * address: its name is said instead (the level is `acknowledge`, so nothing is typed).\n */\n target: AdminPerson & { email?: string | null };\n /** The plans to offer, in the catalogue's order, by their display names (§3.1) — from\n * `GET /admin/plans`. */\n plans: readonly { code: string; name: string }[];\n /** The account's plan now; null for none. The select opens on it. */\n current: string | null;\n /**\n * What the account uses. The column's shape (0.34, keksdose N1) — `{ used, limit, label }`,\n * the label a word or its plural forms — is spelled out as the column's tooltip is\n * (`planChange.usageOf`, the word in the limit's form: \"1 of 1 budget\"); a `null` limit\n * gives no line. Or the app's own sentence, as it is: \"3 of 5 budgets\".\n */\n usage?: PlanColumnUsage | ReactNode;\n /** Offer \"Free until\" — only meaningful while billing is on, where a grant's end\n * means something to the payer. */\n grantEnd?: boolean;\n /**\n * Sends it: `{plan}`, and `comped_until` only when an end was picked — the END of the\n * picked day in the operator's time zone, as ISO UTC (a grant \"until 31 January\" lasts\n * through it). No end: a grant without one, or on a running beta only the plan moves\n * and the beta keeps its own end (§12.34). `values.acknowledged` is the body's\n * `acknowledged`. A promise is handled as `AdminActionConfirm`'s.\n */\n onConfirm: (change: PlanChange, values: AdminActionConfirmValues) => MaybePromise;\n onClose: (done: boolean) => void;\n /** The app's words for a failure the kit has no code for. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<PlanChangeLabels>;\n}\n\n/** The column's usage shape, told from a node: a plain object with the three fields. */\nfunction isPlanUsage(value: PlanChangeConfirmProps[\"usage\"]): value is PlanColumnUsage {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !isValidElement(value) &&\n \"used\" in value &&\n \"limit\" in value &&\n \"label\" in value\n );\n}\n\n/** The end of the day `date` (YYYY-MM-DD) names, in this device's time zone, as ISO\n * UTC — keksdose's `endOfDay` (`user-admin-confirm.tsx:44-46`). */\nfunction endOfDay(date: string): string {\n return new Date(`${date}T23:59:59`).toISOString();\n}\n\n/**\n * An operator's plan change (§14.12): `AdminActionConfirm` at `acknowledge`, the line\n * with the current plan and the app's usage sentence, a plan select, and — with\n * `grantEnd` — the end of a free grant. The confirm is held while nothing would change.\n *\n * Exempt from a BILLING lock, built in (`COMMIT_EXCEPT_BILLING`, §12.36): a plan change\n * is an admin route (§12.13), and the operator's own account or company may be lapsed —\n * kastlan's review. A demo lock still holds it.\n */\nexport function PlanChangeConfirm({\n target,\n plans,\n current: currentProp,\n usage,\n grantEnd = false,\n onConfirm,\n onClose,\n describeError,\n labels: labelsProp,\n}: PlanChangeConfirmProps) {\n const labels = useKitLabels(\"planChange\", DEFAULT_PLAN_CHANGE_LABELS, labelsProp);\n const locale = useKitLocale();\n // Seeded from the account, so the picker opens on the truth and confirming without\n // touching it is held rather than a silent free → free in the audit.\n const current = codeOf(currentProp);\n const [plan, setPlan] = useState(current ?? \"\");\n const [until, setUntil] = useState(\"\");\n // A grant ends today at the earliest; read once, not on every render.\n const [today] = useState(() => toLocalIso(new Date()));\n const options = plans.map((p) => ({ code: codeOf(p.code) ?? p.code, name: p.name }));\n const nameOf = (code: string) => options.find((p) => p.code === code)?.name ?? code;\n // An account on a plan the catalogue no longer lists still opens on it.\n if (current && !options.some((p) => p.code === current)) options.unshift({ code: current, name: current });\n const unchanged = plan === \"\" || (plan === current && !until);\n // A company has no address: the dialog says its name in the address's place.\n const who = { ...target, email: target.email || personLabel(target, locale) };\n // The column's shape in the column's sentence; the app's own sentence as it is.\n const usageLine: ReactNode | undefined = isPlanUsage(usage)\n ? usage.limit === null\n ? undefined\n : usageSentence({ ...usage, limit: usage.limit }, labels.usageOf, locale)\n : usage;\n\n return (\n <AdminActionConfirm\n level=\"acknowledge\"\n tone=\"warning\"\n target={who}\n title={labels.title}\n confirmLabel={labels.confirm}\n confirmDisabledReason={unchanged ? labels.needsChange : undefined}\n describeError={describeError}\n commit={COMMIT_EXCEPT_BILLING}\n onConfirm={(values) => onConfirm({ plan, ...(until ? { comped_until: endOfDay(until) } : {}) }, values)}\n onClose={onClose}\n >\n {(current !== null || usageLine !== undefined) && (\n <div className=\"space-y-0.5 text-xs text-muted\" data-plan-current={current ?? undefined}>\n {current !== null && <p>{labels.current(nameOf(current))}</p>}\n {usageLine !== undefined && <p>{usageLine}</p>}\n </div>\n )}\n <Select label={labels.plan} hint={labels.keepsItems} value={plan} onChange={(e) => setPlan(e.target.value)}>\n {plan === \"\" && (\n <option value=\"\" disabled>\n {EMPTY_FORMATTED_VALUE}\n </option>\n )}\n {options.map((option) => (\n <option key={option.code} value={option.code}>\n {option.name}\n </option>\n ))}\n </Select>\n {grantEnd && (\n <DatePicker\n label={labels.until}\n hint={labels.untilHint}\n value={until}\n onChange={setUntil}\n min={today}\n clearable\n />\n )}\n </AdminActionConfirm>\n );\n}\n\n/* ── The answer ────────────────────────────────────────────────────────────── */\n\n/**\n * A `PlanChangeResponse` as the page reads it — server-kit 0.7's (§14.12), which gained\n * `previous_plan` nullable, `usage`, `kept_beta` and `comped_until`.\n */\nexport interface PlanChangeOutcome {\n /** null: the account had no subscription. */\n previous_plan: string | null;\n plan: string;\n over_limit: boolean;\n /** The new plan's limits; null for unlimited. */\n limits: Readonly<Record<string, number | null>>;\n /** What the payer has, per dimension — the figures for the over-limit lines:\n * `{ budgets: 7 }`. */\n usage: Readonly<Record<string, number>>;\n /** A running beta kept its own end (§12.34). */\n kept_beta?: boolean;\n /** The grant's end as the change wrote it; null: no end, or no grant. */\n comped_until?: string | null;\n}\n\n/** A line's tone: the app's toast kind. */\nexport type PlanChangeTone = \"success\" | \"info\" | \"warning\";\n\nexport interface PlanChangeLine {\n tone: PlanChangeTone;\n text: string;\n}\n\nexport interface PlanChangeResultOptions {\n /** The app's word per dimension, for the over-limit figures: `{ budgets: \"Budgets\" }`.\n * A dimension without one is named by its key. */\n dimensionLabels?: Readonly<Record<string, string>>;\n /** How a figure is written. Default: a number in the kit's locale. */\n formatValue?: (dimension: string, value: number) => string;\n}\n\n/**\n * The lines for a plan change's answer, each with its tone, for the app's toasts —\n * echoing the SERVER's before and after, not what was picked: a toast that reported the\n * request would say \"done\" to a write that landed differently (keksdose's rule).\n *\n * const lines = usePlanChangeResult();\n * for (const line of lines(res, planName)) toast[line.tone](line.text);\n *\n * - `changed(from, to)`, or `set(to)` with no previous plan (or the same one): success;\n * - a running beta that kept its end: `keptBeta`, info; else a grant's end:\n * `untilDone(date)`, success;\n * - over the new limit: `overLimit`, then one figure line per dimension over it (\"Budgets:\n * 7 of 5\", `billing.limitUsageLine`), from `usage` and `limits`: warning. A `null`\n * limit gives no figure line.\n */\nexport function usePlanChangeResult(): (\n res: PlanChangeOutcome,\n planName: (code: string) => string,\n options?: PlanChangeResultOptions,\n) => PlanChangeLine[] {\n const labels = useKitLabels(\"planChange\", DEFAULT_PLAN_CHANGE_LABELS);\n const billing = useBillingLabels();\n const locale = useKitLocale();\n const dayText = useDayText();\n return useCallback(\n (res, planName, options = {}) => {\n const { dimensionLabels, formatValue } = options;\n const name = (raw: string) => planName(codeOf(raw) ?? raw);\n const to = name(res.plan);\n const from = codeOf(res.previous_plan);\n const lines: PlanChangeLine[] = [\n {\n tone: \"success\",\n text: from !== null && from !== codeOf(res.plan) ? labels.changed(name(from), to) : labels.set(to),\n },\n ];\n if (res.kept_beta) lines.push({ tone: \"info\", text: labels.keptBeta });\n else if (res.comped_until) lines.push({ tone: \"success\", text: labels.untilDone(dayText(res.comped_until)) });\n if (res.over_limit) {\n lines.push({ tone: \"warning\", text: labels.overLimit });\n const figure = (dimension: string, value: number) =>\n formatValue ? formatValue(dimension, value) : formatNumber(value, { locale });\n // Read defensively: an app's server from before 0.7 sent neither.\n for (const [dimension, limit] of Object.entries(res.limits ?? {})) {\n const used = res.usage?.[dimension];\n if (limit === null || used === undefined || used <= limit) continue;\n lines.push({\n tone: \"warning\",\n text: billing.limitUsageLine(\n dimensionLabels?.[dimension] ?? dimension,\n figure(dimension, used),\n figure(dimension, limit),\n ),\n });\n }\n }\n return lines;\n },\n [labels, billing, locale, dayText],\n );\n}\n"],"mappings":";AAyIM,SACE,KADF;AAzIN,SAAS,gBAAgB,aAAa,SAAS,gBAAgB;AAG/D,SAAS,cAAc,oBAAwC;AAC/D,SAAS,kBAAkB;AAE3B,SAAS,cAAc,6BAA6B;AACpD,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAEjC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAEnC,SAAS,aAAa,kBAAkB;AAExC,SAAS,kCAAkC;AA0B3C,SAAS,OAAO,KAA+C;AAC7D,QAAM,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zD,YAAM,KAAK,KAAK,IAAI,IAAI;AACxB,YAAM,OAAO,OAAO,IAAI,aAAa;AACrC,YAAM,QAA0B;AAAA,QAC9B;AAAA,UACE,MAAM;AAAA,UACN,MAAM,SAAS,QAAQ,SAAS,OAAO,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,IAAI,GAAG,EAAE,IAAI,OAAO,IAAI,EAAE;AAAA,QACnG;AAAA,MACF;AACA,UAAI,IAAI,UAAW,OAAM,KAAK,EAAE,MAAM,QAAQ,MAAM,OAAO,SAAS,CAAC;AAAA,eAC5D,IAAI,aAAc,OAAM,KAAK,EAAE,MAAM,WAAW,MAAM,OAAO,UAAU,QAAQ,IAAI,YAAY,CAAC,EAAE,CAAC;AAC5G,UAAI,IAAI,YAAY;AAClB,cAAM,KAAK,EAAE,MAAM,WAAW,MAAM,OAAO,UAAU,CAAC;AACtD,cAAM,SAAS,CAAC,WAAmB,UACjC,cAAc,YAAY,WAAW,KAAK,IAAI,aAAa,OAAO,EAAE,OAAO,CAAC;AAE9E,mBAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,IAAI,UAAU,CAAC,CAAC,GAAG;AACjE,gBAAM,OAAO,IAAI,QAAQ,SAAS;AAClC,cAAI,UAAU,QAAQ,SAAS,UAAa,QAAQ,MAAO;AAC3D,gBAAM,KAAK;AAAA,YACT,MAAM;AAAA,YACN,MAAM,QAAQ;AAAA,cACZ,kBAAkB,SAAS,KAAK;AAAA,cAChC,OAAO,WAAW,IAAI;AAAA,cACtB,OAAO,WAAW,KAAK;AAAA,YACzB;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,SAAS,QAAQ,OAAO;AAAA,EACnC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/plan-change.tsx"],"sourcesContent":["import { isValidElement, useCallback, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { pluralForm } from \"../i18n/plurals\";\nimport type { PluralForms } from \"../i18n/plurals\";\nimport { formatNumber, EMPTY_FORMATTED_VALUE } from \"../lib/format\";\nimport { todayIso } from \"../lib/dates\";\nimport type { DataTableColumn } from \"../components/data-table\";\nimport { DatePicker } from \"../components/date-picker\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { Select } from \"../components/select\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { useBillingLabels } from \"../billing/billing-labels\";\nimport type { SubscriptionStatus } from \"../billing/billing-labels\";\nimport { SubscriptionStatusChip } from \"../billing/subscription-status-chip\";\nimport { AdminActionConfirm } from \"./admin-action-confirm\";\nimport type { AdminActionConfirmValues } from \"./admin-action-confirm\";\nimport { personLabel, useDayText } from \"./admin-parts\";\nimport type { AdminPerson, MaybePromise } from \"./admin-parts\";\nimport { DEFAULT_PLAN_CHANGE_LABELS } from \"../billing/plan-change-labels\";\nimport type { PlanChangeLabels } from \"../billing/plan-change-labels\";\n\n/**\n * The operator's plan parts (docs/billing-harmonization.md §14.12, decision 27):\n * {@link planColumn} for the roster or the companies list, {@link PlanChangeConfirm}\n * for the grant, and {@link usePlanChangeResult} for what the answer says.\n *\n * All three apps have the route (`POST /admin/users/{id}/plan`, kastlan's\n * `POST /platform/companies/{id}/plan`) and server-kit's `PlanChangeRequest` /\n * `PlanChangeResponse`; only keksdose had a UI (`users-panel.tsx`, `PlanConfirm` in\n * `user-admin-confirm.tsx`), and these are its parts, lifted. The plan names are the\n * app's (§3.1): every part takes `planName` or the plans with their names. The plan\n * codes come from `GET /admin/plans` (kastlan `GET /platform/plans`), which answers\n * whatever the billing switch says.\n */\n\n// The words and their type live in billing/plan-change-labels, which holds no component\n// code (0.34, KS U8): PlanSwitchConfirm reads them too, and billing importing admin while\n// this module imports billing made the two folders import each other (refactor audit\n// 2026-10-30, MOD-6).\nexport type { PlanChangeLabels };\nexport { DEFAULT_PLAN_CHANGE_LABELS };\n\n/** A plan code as the parts compare it: lowercase (§12.16 — an older row's \"FREE\" is\n * the same plan as \"free\"), and no code at all as null. */\nfunction codeOf(raw: string | null | undefined): string | null {\n const code = (raw ?? \"\").trim().toLowerCase();\n return code === \"\" ? null : code;\n}\n\n/* ── The column ────────────────────────────────────────────────────────────── */\n\n/** What a row's usage is, for the line under its plan: \"1/5\" — and since 0.34 what\n * {@link PlanChangeConfirm}'s `usage` takes, for the same sentence in the dialog. */\nexport interface PlanColumnUsage {\n used: number;\n /** The plan's limit for it; `null` (unlimited, or none known): no line. */\n limit: number | null;\n /**\n * The app's word for what is counted, as it reads after a number: \"budgets\" in \"1 of 5\n * budgets\" — the word in a sentence, not a heading's \"Budgets\".\n *\n * Its plural forms (0.33.1, keksdose): `{ one: \"budget\", other: \"budgets\" }` — your\n * catalogue's `_one` / `_other` pair, any CLDR category allowed, `other` for the rest\n * ({@link PluralForms}). The column picks the form for the limit in the provider's\n * locale, so a plan of one reads \"1 of 1 budget\". A plain string is used as it is,\n * whatever the count.\n */\n label: string | PluralForms;\n}\n\nexport interface PlanColumnOptions<T> {\n /** The column's key. Default `\"plan\"`. */\n key?: string;\n /** The row's plan code, read without case (§12.16); null for none. */\n plan: (row: T) => string | null;\n /** The plan's display name, the app's (§3.1). Gets the lowercase code. */\n planName: (code: string) => string;\n /** The row's standing, as a `SubscriptionStatusChip` beside the name. Left out, or\n * undefined for a row: no chip — billing off, where a status says nothing. */\n status?: (row: T) => SubscriptionStatus | undefined;\n /** The row's usage of its plan's limit: \"1/5\" under the name, \"1 of 5 budgets\" in\n * the tooltip (`planChange.usageOf`, with the label's form for the limit). Undefined\n * for a row, or a `null` limit: no line. */\n usage?: (row: T) => PlanColumnUsage | undefined;\n /** A select filter over these codes, each named by `planName`. Left out: none. */\n filterPlans?: readonly string[];\n /**\n * The sort. Default: by the plan code (keksdose's, `users-panel.tsx:739`). A function:\n * by its value — the catalogue's `sort` for rank order. `false`: not sortable.\n *\n * Client-side only, as every column's `sortBy`: a `DataTable` with `serverPagination`\n * holds one page, so it sorts nothing itself — with `onSortsChange` it reports the\n * column's `key` (default `\"plan\"`), and your server orders the rows by it.\n */\n sortBy?: false | ((row: T) => string | number | null | undefined);\n /** The header's text. Default `planChange.column`. */\n headerText?: string;\n /** The words, already resolved. Default English; {@link usePlanColumn} reads the\n * provider's `planChange` namespace. */\n labels?: LabelOverride<PlanChangeLabels>;\n}\n\n/**\n * A usage spelled out — `planChange.usageOf` with the figures in `locale` and the word in\n * the form the limit takes: \"1 of 1 budget\", \"Budgets: 1 von 5\". The column's tooltip\n * and the grant dialog's line both read it, so the rule lives once (round 0.34 C15).\n */\nfunction usageSentence(\n usage: PlanColumnUsage & { limit: number },\n usageOf: PlanChangeLabels[\"usageOf\"],\n locale: string | undefined,\n): string {\n const figure = (value: number) => formatNumber(value, { locale });\n const word = typeof usage.label === \"string\" ? usage.label : pluralForm(usage.limit, usage.label, locale);\n return usageOf(figure(usage.used), figure(usage.limit), word);\n}\n\n/** The cell: a component, so the figures follow the provider's locale. */\nfunction PlanCell({\n code,\n name,\n status,\n usage,\n usageOf,\n}: {\n code: string | null;\n name: string;\n status: SubscriptionStatus | undefined;\n usage: PlanColumnUsage | undefined;\n usageOf: PlanChangeLabels[\"usageOf\"];\n}) {\n const locale = useKitLocale();\n const figure = (value: number) => formatNumber(value, { locale });\n return (\n <div className=\"whitespace-nowrap\" data-plan={code ?? undefined}>\n <div className=\"flex items-center gap-1.5\">\n <span className={code ? \"font-medium\" : \"text-muted\"}>{name}</span>\n {/* The standing at a glance (§6): the kit's word and tone, never colour alone. */}\n {status !== undefined && <SubscriptionStatusChip status={status} size=\"xs\" />}\n </div>\n {usage && usage.limit !== null && (\n // \"1/5\" under the plan, \"1 of 5 budgets\" in the tooltip: the sentence spelled out\n // inline was the widest thing in keksdose's table.\n <Tooltip label={usageSentence({ ...usage, limit: usage.limit }, usageOf, locale)}>\n <span className=\"block text-xs tabular-nums text-muted\">\n {figure(usage.used)}/{figure(usage.limit)}\n </span>\n </Tooltip>\n )}\n </div>\n );\n}\n\n/**\n * The roster's (or the companies list's) plan column: the plan's display name, the\n * standing chip beside it while billing is on, and the usage under it — keksdose's\n * column, `users-panel.tsx:706-745`. Pass it in `userRosterColumns`' `extra`, or in\n * any `DataTable`'s columns:\n *\n * extra: [planColumn<AdminUserRow>({\n * plan: (u) => u.plan,\n * planName,\n * status: billingOn ? (u) => u.subscription?.status : undefined,\n * usage: (u) => ({\n * used: u.budgets_owned,\n * limit: u.limits.budgets,\n * label: { one: t(\"planUsage.budget_one\"), other: t(\"planUsage.budget_other\") },\n * }),\n * filterPlans: plans.map((p) => p.code),\n * })]\n *\n * Pure: hand it resolved words, or use {@link usePlanColumn}.\n */\nexport function planColumn<T>(options: PlanColumnOptions<T>): DataTableColumn<T> {\n const { key = \"plan\", plan, planName, status, usage, filterPlans, sortBy, headerText, labels: labelsProp } = options;\n const labels: PlanChangeLabels = { ...DEFAULT_PLAN_CHANGE_LABELS, ...labelsProp };\n const header = headerText ?? labels.column;\n const nameOf = (code: string | null) => (code ? planName(code) : EMPTY_FORMATTED_VALUE);\n return {\n key,\n header,\n headerText: header,\n cell: (row) => {\n const code = codeOf(plan(row));\n return (\n <PlanCell\n code={code}\n name={nameOf(code)}\n status={status?.(row)}\n usage={usage?.(row)}\n usageOf={labels.usageOf}\n />\n );\n },\n sortBy: sortBy === false ? undefined : (sortBy ?? ((row) => codeOf(plan(row)) ?? \"\")),\n filter: filterPlans\n ? {\n type: \"select\",\n getValue: (row) => codeOf(plan(row)) ?? \"\",\n options: [...new Set(filterPlans.map((code) => codeOf(code)).filter((code) => code !== null))].map(\n (code) => ({ value: code, label: planName(code) }),\n ),\n }\n : undefined,\n };\n}\n\n/**\n * {@link planColumn} with the `planChange` words from the provider, memoised on the\n * options — pass stable callbacks (`useCallback`), or the column is rebuilt on every\n * render.\n */\nexport function usePlanColumn<T>(options: PlanColumnOptions<T>): DataTableColumn<T> {\n const { key, plan, planName, status, usage, filterPlans, sortBy, headerText, labels: labelsProp } = options;\n const labels = useKitLabels(\"planChange\", DEFAULT_PLAN_CHANGE_LABELS, labelsProp);\n return useMemo(\n () => planColumn<T>({ key, plan, planName, status, usage, filterPlans, sortBy, headerText, labels }),\n [key, plan, planName, status, usage, filterPlans, sortBy, headerText, labels],\n );\n}\n\n/* ── The grant ─────────────────────────────────────────────────────────────── */\n\n/** What {@link PlanChangeConfirmProps.onConfirm} sends: server-kit's\n * `PlanChangeRequest` without its `acknowledged`, which comes in `values`. */\nexport interface PlanChange {\n /** The picked plan's code. */\n plan: string;\n /** The end of the free grant, as ISO UTC — only when one was picked. */\n comped_until?: string;\n}\n\nexport interface PlanChangeConfirmProps {\n /**\n * Whom it is about — a user (`AdminActionTarget`), or kastlan's company, which has no\n * address: its name is said instead (the level is `acknowledge`, so nothing is typed).\n */\n target: AdminPerson & { email?: string | null };\n /** The plans to offer, in the catalogue's order, by their display names (§3.1) — from\n * `GET /admin/plans`. */\n plans: readonly { code: string; name: string }[];\n /** The account's plan now; null for none. The select opens on it. */\n current: string | null;\n /**\n * What the account uses. The column's shape (0.34, keksdose N1) — `{ used, limit, label }`,\n * the label a word or its plural forms — is spelled out as the column's tooltip is\n * (`planChange.usageOf`, the word in the limit's form: \"1 of 1 budget\"); a `null` limit\n * gives no line. Or the app's own sentence, as it is: \"3 of 5 budgets\".\n */\n usage?: PlanColumnUsage | ReactNode;\n /** Offer \"Free until\" — only meaningful while billing is on, where a grant's end\n * means something to the payer. */\n grantEnd?: boolean;\n /**\n * Sends it: `{plan}`, and `comped_until` only when an end was picked — the END of the\n * picked day in the operator's time zone, as ISO UTC (a grant \"until 31 January\" lasts\n * through it). No end: a grant without one, or on a running beta only the plan moves\n * and the beta keeps its own end (§12.34). `values.acknowledged` is the body's\n * `acknowledged`. A promise is handled as `AdminActionConfirm`'s.\n */\n onConfirm: (change: PlanChange, values: AdminActionConfirmValues) => MaybePromise;\n onClose: (done: boolean) => void;\n /** The app's words for a failure the kit has no code for. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<PlanChangeLabels>;\n}\n\n/** The column's usage shape, told from a node: a plain object with the three fields. */\nfunction isPlanUsage(value: PlanChangeConfirmProps[\"usage\"]): value is PlanColumnUsage {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !isValidElement(value) &&\n \"used\" in value &&\n \"limit\" in value &&\n \"label\" in value\n );\n}\n\n/** The end of the day `date` (YYYY-MM-DD) names, in this device's time zone, as ISO\n * UTC — keksdose's `endOfDay` (`user-admin-confirm.tsx:44-46`). */\nfunction endOfDay(date: string): string {\n return new Date(`${date}T23:59:59`).toISOString();\n}\n\n/**\n * An operator's plan change (§14.12): `AdminActionConfirm` at `acknowledge`, the line\n * with the current plan and the app's usage sentence, a plan select, and — with\n * `grantEnd` — the end of a free grant. The confirm is held while nothing would change.\n *\n * Exempt from a BILLING lock, built in (`COMMIT_EXCEPT_BILLING`, §12.36): a plan change\n * is an admin route (§12.13), and the operator's own account or company may be lapsed —\n * kastlan's review. A demo lock still holds it.\n */\nexport function PlanChangeConfirm({\n target,\n plans,\n current: currentProp,\n usage,\n grantEnd = false,\n onConfirm,\n onClose,\n describeError,\n labels: labelsProp,\n}: PlanChangeConfirmProps) {\n const labels = useKitLabels(\"planChange\", DEFAULT_PLAN_CHANGE_LABELS, labelsProp);\n const locale = useKitLocale();\n // Seeded from the account, so the picker opens on the truth and confirming without\n // touching it is held rather than a silent free → free in the audit.\n const current = codeOf(currentProp);\n const [plan, setPlan] = useState(current ?? \"\");\n const [until, setUntil] = useState(\"\");\n // A grant ends today at the earliest; read once, not on every render. The kit's today,\n // so it agrees with a server whose dev clock moved it (0.55).\n const [today] = useState(todayIso);\n const options = plans.map((p) => ({ code: codeOf(p.code) ?? p.code, name: p.name }));\n const nameOf = (code: string) => options.find((p) => p.code === code)?.name ?? code;\n // An account on a plan the catalogue no longer lists still opens on it.\n if (current && !options.some((p) => p.code === current)) options.unshift({ code: current, name: current });\n const unchanged = plan === \"\" || (plan === current && !until);\n // A company has no address: the dialog says its name in the address's place.\n const who = { ...target, email: target.email || personLabel(target, locale) };\n // The column's shape in the column's sentence; the app's own sentence as it is.\n const usageLine: ReactNode | undefined = isPlanUsage(usage)\n ? usage.limit === null\n ? undefined\n : usageSentence({ ...usage, limit: usage.limit }, labels.usageOf, locale)\n : usage;\n\n return (\n <AdminActionConfirm\n level=\"acknowledge\"\n tone=\"warning\"\n target={who}\n title={labels.title}\n confirmLabel={labels.confirm}\n confirmDisabledReason={unchanged ? labels.needsChange : undefined}\n describeError={describeError}\n commit={COMMIT_EXCEPT_BILLING}\n onConfirm={(values) => onConfirm({ plan, ...(until ? { comped_until: endOfDay(until) } : {}) }, values)}\n onClose={onClose}\n >\n {(current !== null || usageLine !== undefined) && (\n <div className=\"space-y-0.5 text-xs text-muted\" data-plan-current={current ?? undefined}>\n {current !== null && <p>{labels.current(nameOf(current))}</p>}\n {usageLine !== undefined && <p>{usageLine}</p>}\n </div>\n )}\n <Select label={labels.plan} hint={labels.keepsItems} value={plan} onChange={(e) => setPlan(e.target.value)}>\n {plan === \"\" && (\n <option value=\"\" disabled>\n {EMPTY_FORMATTED_VALUE}\n </option>\n )}\n {options.map((option) => (\n <option key={option.code} value={option.code}>\n {option.name}\n </option>\n ))}\n </Select>\n {grantEnd && (\n <DatePicker\n label={labels.until}\n hint={labels.untilHint}\n value={until}\n onChange={setUntil}\n min={today}\n clearable\n />\n )}\n </AdminActionConfirm>\n );\n}\n\n/* ── The answer ────────────────────────────────────────────────────────────── */\n\n/**\n * A `PlanChangeResponse` as the page reads it — server-kit 0.7's (§14.12), which gained\n * `previous_plan` nullable, `usage`, `kept_beta` and `comped_until`.\n */\nexport interface PlanChangeOutcome {\n /** null: the account had no subscription. */\n previous_plan: string | null;\n plan: string;\n over_limit: boolean;\n /** The new plan's limits; null for unlimited. */\n limits: Readonly<Record<string, number | null>>;\n /** What the payer has, per dimension — the figures for the over-limit lines:\n * `{ budgets: 7 }`. */\n usage: Readonly<Record<string, number>>;\n /** A running beta kept its own end (§12.34). */\n kept_beta?: boolean;\n /** The grant's end as the change wrote it; null: no end, or no grant. */\n comped_until?: string | null;\n}\n\n/** A line's tone: the app's toast kind. */\nexport type PlanChangeTone = \"success\" | \"info\" | \"warning\";\n\nexport interface PlanChangeLine {\n tone: PlanChangeTone;\n text: string;\n}\n\nexport interface PlanChangeResultOptions {\n /** The app's word per dimension, for the over-limit figures: `{ budgets: \"Budgets\" }`.\n * A dimension without one is named by its key. */\n dimensionLabels?: Readonly<Record<string, string>>;\n /** How a figure is written. Default: a number in the kit's locale. */\n formatValue?: (dimension: string, value: number) => string;\n}\n\n/**\n * The lines for a plan change's answer, each with its tone, for the app's toasts —\n * echoing the SERVER's before and after, not what was picked: a toast that reported the\n * request would say \"done\" to a write that landed differently (keksdose's rule).\n *\n * const lines = usePlanChangeResult();\n * for (const line of lines(res, planName)) toast[line.tone](line.text);\n *\n * - `changed(from, to)`, or `set(to)` with no previous plan (or the same one): success;\n * - a running beta that kept its end: `keptBeta`, info; else a grant's end:\n * `untilDone(date)`, success;\n * - over the new limit: `overLimit`, then one figure line per dimension over it (\"Budgets:\n * 7 of 5\", `billing.limitUsageLine`), from `usage` and `limits`: warning. A `null`\n * limit gives no figure line.\n */\nexport function usePlanChangeResult(): (\n res: PlanChangeOutcome,\n planName: (code: string) => string,\n options?: PlanChangeResultOptions,\n) => PlanChangeLine[] {\n const labels = useKitLabels(\"planChange\", DEFAULT_PLAN_CHANGE_LABELS);\n const billing = useBillingLabels();\n const locale = useKitLocale();\n const dayText = useDayText();\n return useCallback(\n (res, planName, options = {}) => {\n const { dimensionLabels, formatValue } = options;\n const name = (raw: string) => planName(codeOf(raw) ?? raw);\n const to = name(res.plan);\n const from = codeOf(res.previous_plan);\n const lines: PlanChangeLine[] = [\n {\n tone: \"success\",\n text: from !== null && from !== codeOf(res.plan) ? labels.changed(name(from), to) : labels.set(to),\n },\n ];\n if (res.kept_beta) lines.push({ tone: \"info\", text: labels.keptBeta });\n else if (res.comped_until) lines.push({ tone: \"success\", text: labels.untilDone(dayText(res.comped_until)) });\n if (res.over_limit) {\n lines.push({ tone: \"warning\", text: labels.overLimit });\n const figure = (dimension: string, value: number) =>\n formatValue ? formatValue(dimension, value) : formatNumber(value, { locale });\n // Read defensively: an app's server from before 0.7 sent neither.\n for (const [dimension, limit] of Object.entries(res.limits ?? {})) {\n const used = res.usage?.[dimension];\n if (limit === null || used === undefined || used <= limit) continue;\n lines.push({\n tone: \"warning\",\n text: billing.limitUsageLine(\n dimensionLabels?.[dimension] ?? dimension,\n figure(dimension, used),\n figure(dimension, limit),\n ),\n });\n }\n }\n return lines;\n },\n [labels, billing, locale, dayText],\n );\n}\n"],"mappings":";AAyIM,SACE,KADF;AAzIN,SAAS,gBAAgB,aAAa,SAAS,gBAAgB;AAG/D,SAAS,cAAc,oBAAwC;AAC/D,SAAS,kBAAkB;AAE3B,SAAS,cAAc,6BAA6B;AACpD,SAAS,gBAAgB;AAEzB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAEjC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAEnC,SAAS,aAAa,kBAAkB;AAExC,SAAS,kCAAkC;AA0B3C,SAAS,OAAO,KAA+C;AAC7D,QAAM,QAAQ,OAAO,IAAI,KAAK,EAAE,YAAY;AAC5C,SAAO,SAAS,KAAK,OAAO;AAC9B;AA4DA,SAAS,cACP,OACA,SACA,QACQ;AACR,QAAM,SAAS,CAAC,UAAkB,aAAa,OAAO,EAAE,OAAO,CAAC;AAChE,QAAM,OAAO,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ,WAAW,MAAM,OAAO,MAAM,OAAO,MAAM;AACxG,SAAO,QAAQ,OAAO,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,GAAG,IAAI;AAC9D;AAGA,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAC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,IAAI,YAAY,CAAC,EAAE,CAAC;AAC5G,UAAI,IAAI,YAAY;AAClB,cAAM,KAAK,EAAE,MAAM,WAAW,MAAM,OAAO,UAAU,CAAC;AACtD,cAAM,SAAS,CAAC,WAAmB,UACjC,cAAc,YAAY,WAAW,KAAK,IAAI,aAAa,OAAO,EAAE,OAAO,CAAC;AAE9E,mBAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,IAAI,UAAU,CAAC,CAAC,GAAG;AACjE,gBAAM,OAAO,IAAI,QAAQ,SAAS;AAClC,cAAI,UAAU,QAAQ,SAAS,UAAa,QAAQ,MAAO;AAC3D,gBAAM,KAAK;AAAA,YACT,MAAM;AAAA,YACN,MAAM,QAAQ;AAAA,cACZ,kBAAkB,SAAS,KAAK;AAAA,cAChC,OAAO,WAAW,IAAI;AAAA,cACtB,OAAO,WAAW,KAAK;AAAA,YACzB;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,SAAS,QAAQ,OAAO;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -85,6 +85,12 @@ export declare function adminUserStates(row: AdminUserStateFields): RosterState[
|
|
|
85
85
|
/** The server's sort keys, which are the preset's column keys (§3.1). */
|
|
86
86
|
export declare const USER_ROSTER_SORT_KEYS: readonly ["name", "email", "role", "created", "last_login"];
|
|
87
87
|
export type UserRosterSortKey = (typeof USER_ROSTER_SORT_KEYS)[number];
|
|
88
|
+
/** server-kit's `user_admin.DEFAULT_PAGE_SIZE`: the rows `GET /admin/users` answers when the
|
|
89
|
+
* query names no `page_size` (keksdose audit F-63, which copied it into its users panel). */
|
|
90
|
+
export declare const USER_ROSTER_PAGE_SIZE = 25;
|
|
91
|
+
/** server-kit's `user_admin.MAX_PAGE_SIZE`: the most rows one page may ask for, which a
|
|
92
|
+
* pager's "All" resolves to; a larger `page_size` is refused. */
|
|
93
|
+
export declare const USER_ROSTER_MAX_PAGE_SIZE = 200;
|
|
88
94
|
/**
|
|
89
95
|
* The table's sort state as the `sort` query parameter of `GET /admin/users` (§3.1), in
|
|
90
96
|
* the DataTable's own encoding ({@link encodeSorts}: `"last_login.desc"`), which
|
|
@@ -23,6 +23,8 @@ function adminUserStates(row) {
|
|
|
23
23
|
return out;
|
|
24
24
|
}
|
|
25
25
|
const USER_ROSTER_SORT_KEYS = ["name", "email", "role", "created", "last_login"];
|
|
26
|
+
const USER_ROSTER_PAGE_SIZE = 25;
|
|
27
|
+
const USER_ROSTER_MAX_PAGE_SIZE = 200;
|
|
26
28
|
function userRosterSort(sorts) {
|
|
27
29
|
const first = sorts.find((s) => USER_ROSTER_SORT_KEYS.includes(s.key));
|
|
28
30
|
return first ? encodeSorts([first]) ?? void 0 : void 0;
|
|
@@ -255,6 +257,8 @@ function useUserRosterColumns({
|
|
|
255
257
|
}
|
|
256
258
|
export {
|
|
257
259
|
DEFAULT_USER_ROSTER_LABELS,
|
|
260
|
+
USER_ROSTER_MAX_PAGE_SIZE,
|
|
261
|
+
USER_ROSTER_PAGE_SIZE,
|
|
258
262
|
USER_ROSTER_SORT_KEYS,
|
|
259
263
|
UserIdentityCell,
|
|
260
264
|
UserRowActions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/user-roster.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport type { DateInput } from \"../lib/format\";\nimport type { PersonName } from \"../lib/person-name\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { AccountStateChip, RoleChip, dateColumn } from \"../components/account-chips\";\nimport type { AccountState, RoleVocabulary } from \"../components/account-chips\";\nimport type { ChipTone } from \"../components/chip\";\nimport type { DataTableColumn } from \"../components/data-table\";\nimport { SelectWidthFloor } from \"../components/field-base\";\nimport { encodeSorts } from \"../components/data-table-sort\";\nimport type { SortState } from \"../components/data-table-sort\";\nimport { RowActions } from \"../components/row-actions\";\nimport type { RowAction, RowActionList } from \"../components/row-actions\";\nimport { UserAvatar } from \"../components/user-avatar\";\nimport { personLabel } from \"./admin-parts\";\nimport { RoleSelect } from \"./role-select\";\nimport type { RoleLock } from \"./role-select\";\nimport { DEFAULT_USER_ROSTER_LABELS } from \"./user-roster-labels\";\n\n/**\n * The admin's user list (docs/user-admin-harmonization.md §3): a column preset for the\n * kit's `DataTable`, not a table of its own.\n *\n * keksdose built its roster by hand (1150 lines, its own Badge), Kurvenschmiede on the\n * kit `DataTable` with the 0.18 chips, kastlan as a settings page. What the three share\n * is the row — name over address, a role, the account's states, created, last login, the\n * app's own columns, and a handful of actions — so that is what the kit draws, and the\n * table, its paging, its sort and its filters stay the app's `DataTable` wiring:\n *\n * ```tsx\n * const columns = useUserRosterColumns<AdminUserRow, Role>({ roles: ROLES, actions, extra });\n * <DataTable rows={page.users} columns={columns} rowKey={(r) => r.id}\n * serverPagination={{ page, pageSize, total: page.total, onPageChange }}\n * sorts={sorts} onSortsChange={setSorts} />\n * // GET /admin/users?sort=${userRosterSort(sorts)}&…\n * ```\n *\n * The column keys ARE the server's sort keys (§3.1): `name`, `email`, `role`, `created`,\n * `last_login` — so {@link userRosterSort} turns the table's sort state into the query\n * as it is. Phone cards come from the same columns: the identity is the card's headline\n * with the account's states as chips beside it, the role, last login and the actions are\n * its three fields, created is left off.\n */\n\n/* ── Rows and states ────────────────────────────────────────────────────────── */\n\n/**\n * The fields of the contract's `AdminUserRow` the preset reads (§3.2, the auth\n * contract's `UserResponse` core). An app's row has more — its `extra` — and the\n * preset passes the whole row to every callback.\n */\nexport interface UserRosterRow extends AdminUserStateFields {\n id: string | number;\n email: string;\n first_name?: string | null;\n last_name?: string | null;\n /** The derived whole name — only the fallback when both parts are blank. */\n display_name?: string | null;\n /** keksdose, Kurvenschmiede: one role. */\n role?: string | null;\n /** kastlan: the account's roles in the current company. Wins over `role`. */\n roles?: readonly string[] | null;\n created_at?: DateInput;\n /** Account-wide; kastlan's comes from its session rows (§3.2). */\n last_login_at?: DateInput;\n}\n\n/** The state fields of the contract's row that {@link adminUserStates} maps (§3.2). */\nexport interface AdminUserStateFields {\n is_active?: boolean;\n email_verified?: boolean;\n password_change_required_at?: string | null;\n /** `after_days` mode: the day the account is erased (§6.4). */\n deletion_scheduled_at?: string | null;\n /** When the user asked. The only deletion field in kastlan's `operator` mode, where\n * nothing is scheduled. */\n deletion_requested_at?: string | null;\n}\n\n/** One state chip of a row: an {@link AccountState}, or one with its `date` (the\n * `deletion` day), a `tone` or the app's own words. */\nexport type RosterState = AccountState | { state: AccountState; date?: DateInput; tone?: ChipTone; label?: ReactNode };\n\n/**\n * The contract's row as state chips (§3.2: \"map 1:1 to the kit's AccountStateChip\"):\n *\n * - marked for deletion → `deletion` with the scheduled day (none in `operator` mode),\n * IN PLACE of `inactive` — such an account is always deactivated (§2.1);\n * - else `active` / `inactive` from `is_active`;\n * - `unverified` when `email_verified` is `false` (not when it is missing);\n * - `passwordChange` while `password_change_required_at` is set.\n */\nexport function adminUserStates(row: AdminUserStateFields): RosterState[] {\n const out: RosterState[] = [];\n if (row.deletion_scheduled_at || row.deletion_requested_at) {\n out.push({ state: \"deletion\", date: row.deletion_scheduled_at ?? null });\n } else if (row.is_active !== undefined) {\n out.push(row.is_active ? \"active\" : \"inactive\");\n }\n if (row.email_verified === false) out.push(\"unverified\");\n if (row.password_change_required_at) out.push(\"passwordChange\");\n return out;\n}\n\n/** The server's sort keys, which are the preset's column keys (§3.1). */\nexport const USER_ROSTER_SORT_KEYS = [\"name\", \"email\", \"role\", \"created\", \"last_login\"] as const;\nexport type UserRosterSortKey = (typeof USER_ROSTER_SORT_KEYS)[number];\n\n/**\n * The table's sort state as the `sort` query parameter of `GET /admin/users` (§3.1), in\n * the DataTable's own encoding ({@link encodeSorts}: `\"last_login.desc\"`), which\n * server-kit 0.4 reads beside the `-key` form. Only the first criterion on one of the\n * server's keys: an app's own column (`owned`) is the client's to sort, and the query\n * takes one key — a shift-clicked second criterion is not sent. `undefined` when nothing\n * the server knows is sorted, so its default order applies.\n */\nexport function userRosterSort(sorts: readonly SortState[]): string | undefined {\n const first = sorts.find((s) => (USER_ROSTER_SORT_KEYS as readonly string[]).includes(s.key));\n return first ? (encodeSorts([first]) ?? undefined) : undefined;\n}\n\n/* ── Labels ─────────────────────────────────────────────────────────────────── */\n\n/** The `userRoster` namespace: the preset's headers and the action menu's words. */\nexport interface UserRosterLabels {\n /** The identity column — the name with the address under it. */\n name: string;\n /** The separate address column (`emailColumn`). */\n email: string;\n role: string;\n state: string;\n created: string;\n lastLogin: string;\n /** A last login that never happened. */\n never: string;\n /** The actions column's (hidden) header. */\n actions: string;\n /** The action menu's button and panel — \"Actions for Ada Example\". */\n actionsFor: (name: string) => string;\n}\n\n// Defined in ./user-roster-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_USER_ROSTER_LABELS };\n\n/* ── UserIdentityCell ───────────────────────────────────────────────────────── */\n\nexport interface UserIdentityCellProps {\n /** First and last name (auth §3.2), shown in the READER's order. */\n person?: PersonName | null;\n /** A whole name, for an API that still sends `display_name` only. */\n name?: string | null;\n email?: string | null;\n /** The initials avatar before the name. Default true. */\n avatar?: boolean;\n /** After the name, on its line — a \"You\" chip, a demo mark. */\n badge?: ReactNode;\n /** Over the provider's locale. */\n locale?: string;\n className?: string;\n}\n\n/**\n * Who an account is, in one cell (§3.3): the initials avatar, the name in the reader's\n * order ({@link formatPersonName} — \"Example Ada\" in Hungarian) and the address under it\n * — the cell both rosters drew by hand. An account with no name yet (a migrated row\n * before `CompleteNameDialog`, an invitee) shows its address once, as the name.\n *\n * Both lines carry `data-private`, so keksdose's demo blur reaches them, and both end\n * in \"…\" at Normal only: from Large up they wrap (`truncate-until-large`, 0.33,\n * docs/text-size-harmonization.md §10.17), since a cut name or address is a finding there.\n */\nexport function UserIdentityCell({\n person,\n name,\n email,\n avatar = true,\n badge,\n locale: localeProp,\n className,\n}: UserIdentityCellProps) {\n const locale = useKitLocale(localeProp);\n const named = personLabel({ first: person?.first, last: person?.last, name }, locale);\n const address = (email ?? \"\").trim();\n return (\n <div className={cn(\"flex min-w-0 items-center gap-2.5\", className)}>\n {avatar && <UserAvatar person={person} name={name} email={email} size=\"sm\" />}\n <div className=\"min-w-0\">\n <div className=\"flex min-w-0 items-center gap-1.5\">\n <span data-private className=\"truncate-until-large font-medium text-primary\">\n {named || address}\n </span>\n {badge}\n </div>\n {named && address && (\n <div data-private className=\"truncate-until-large text-xs text-muted\">\n {address}\n </div>\n )}\n </div>\n </div>\n );\n}\n\n/* ── The row's actions ──────────────────────────────────────────────────────── */\n\n/** One entry of a row's action menu (§4) — the kit's {@link RowAction} since 0.32,\n * which generalised it for every dense row (docs/text-size-harmonization.md §10.8). */\nexport type UserRowAction = RowAction;\n\n/** What `actions(row)` may return: entries, and `false` / `null` for the ones a\n * condition left out (`row.is_active && {…}`). */\nexport type UserRowActionList = RowActionList;\n\nexport interface UserRowActionsProps {\n actions: UserRowActionList;\n /** The account's name, for the menu's name — \"Actions for Ada Example\". */\n name: string;\n labels?: LabelOverride<UserRosterLabels>;\n}\n\n/**\n * A row's actions as one \"…\" button and a menu of them: keksdose had a strip of icon\n * buttons in the expanded row, Kurvenschmiede five text buttons in a cell — neither fits\n * a phone card, and both grow with every action §2.4 adds. The menu is portalled, so a\n * table's scroller cannot clip it; Escape and an outside press close it, and focus goes\n * back to the button, which is where a confirmation dialog then returns it.\n *\n * Since 0.32 this is {@link RowActions} with `collapse=\"menu\"` — the menu at every size —\n * named by the roster's own `actionsFor`.\n */\nexport function UserRowActions({ actions, name, labels: labelsProp }: UserRowActionsProps) {\n const labels = useKitLabels(\"userRoster\", DEFAULT_USER_ROSTER_LABELS, labelsProp);\n return <RowActions actions={actions} name={name} collapse=\"menu\" labels={{ actionsFor: labels.actionsFor }} />;\n}\n\n/* ── The preset ─────────────────────────────────────────────────────────────── */\n\n/** How a row's role may be changed inline: `true`, or with reasons. */\nexport interface RoleEditing<R extends string> {\n /** Why the whole select is locked for this row — `\"self\"`, `\"last_admin\"`, or words. */\n disabledReason?: RoleLock;\n /** Why one role cannot be chosen for this row (a string: it goes inside an option). */\n optionDisabledReason?: (role: R) => string | undefined;\n /** The roles that may be chosen. Default: the whole vocabulary. */\n offered?: readonly R[];\n}\n\nexport interface UserRosterColumnsOptions<T extends UserRosterRow, R extends string = string> {\n /** The app's roles, as `RoleChip` reads them. */\n roles: RoleVocabulary<R>;\n /** The row's state chips. Default {@link adminUserStates}, which reads the contract's\n * fields (`is_active`, `email_verified`, `password_change_required_at`,\n * `deletion_scheduled_at`, `deletion_requested_at`). */\n stateOf?: (row: T) => readonly RosterState[];\n /** The app's own columns — keksdose's plan and key custody, Kurvenschmiede's owned\n * counts — after the dates, before the actions. */\n extra?: readonly DataTableColumn<T>[];\n /** The row's action menu (§4). Left out: no actions column. */\n actions?: (row: T) => UserRowActionList;\n /** The actions column's heading (0.46.1, keksdose dev#598 rework — a VISIBLE \"Actions\"\n * on every table with an actions column). Default: `labels.actions`, shown. A node\n * replaces it; `false` keeps the pre-0.46.1 heading, a screen reader's name only. */\n actionsHeader?: ReactNode | false;\n /**\n * Whether this row's role is a select rather than a chip, and with which reasons.\n * Left out, or `false`: a chip. kastlan's several roles are never a select here — they\n * are a \"Manage roles\" action that opens `RolesEditor`.\n */\n editableRole?: (row: T) => boolean | RoleEditing<R>;\n /** A role was picked in a row's select. The app confirms (`acknowledge`) and sends it. */\n onRoleChange?: (row: T, role: R) => void;\n /** The row's role(s). Default `row.roles ?? row.role`. */\n roleOf?: (row: T) => R | readonly R[] | null | undefined;\n /** A separate, sortable \"Email\" column (the server's `email` sort key) beside the\n * identity. Default false: the address is under the name already. */\n emailColumn?: boolean;\n /** The words, already resolved. Default English; {@link useUserRosterColumns} reads\n * the provider's `userRoster` namespace. */\n labels?: LabelOverride<UserRosterLabels>;\n}\n\nfunction rolesOf<T extends UserRosterRow, R extends string>(\n row: T,\n roleOf: UserRosterColumnsOptions<T, R>[\"roleOf\"],\n): R[] {\n const raw = roleOf ? roleOf(row) : ((row.roles ?? row.role) as R | readonly R[] | null | undefined);\n if (raw === null || raw === undefined || raw === \"\") return [];\n return typeof raw === \"string\" ? [raw as R] : [...(raw as readonly R[])];\n}\n\n/** What a row's role select can show as its value: every role's word, and a held key\n * the vocabulary does not know (RoleSelect shows it as the key). */\nfunction roleWordsOf<R extends string>(roles: RoleVocabulary<R>, held: R | undefined): string[] {\n const words = (Object.keys(roles) as R[]).map((role) => roles[role].label);\n return held !== undefined && !(held in roles) ? [...words, held] : words;\n}\n\n/** The row's name in the reader's order — a component, because the order is the\n * READER's and the locale comes from the provider. */\nfunction RowName<T extends UserRosterRow>({ row, children }: { row: T; children: (name: string) => ReactNode }) {\n const locale = useKitLocale();\n const name = personLabel(\n { first: row.first_name, last: row.last_name, name: row.display_name, email: row.email },\n locale,\n );\n return <>{children(name)}</>;\n}\n\nfunction StateChips({ states }: { states: readonly RosterState[] }) {\n if (states.length === 0) return null;\n return (\n <div className=\"flex flex-wrap gap-1\">\n {states.map((entry) => {\n const spec = typeof entry === \"string\" ? { state: entry } : entry;\n return (\n <AccountStateChip key={spec.state} state={spec.state} date={spec.date} tone={spec.tone} size=\"xs\">\n {spec.label}\n </AccountStateChip>\n );\n })}\n </div>\n );\n}\n\n/**\n * The roster's columns, in the contract's order (§3.3):\n *\n * | key | cell | sort | phone | fit (0.50) |\n * |---|---|---|---|---|\n * | `name` | {@link UserIdentityCell} | last, first | the card's headline | `grow` |\n * | `email` | the address (`emailColumn` only) | address | hidden | — |\n * | `role` | `RoleChip`(s), or {@link RoleSelect} where `editableRole` | role | field | — |\n * | `state` | `AccountStateChip`s from `stateOf` | — | chips beside the headline | — |\n * | `created` | `dateColumn` | instant | hidden | `fitPriority: 1` |\n * | `last_login` | `dateColumn`, relative, \"Never\" | instant | field | `fitPriority: 2` |\n * | …`extra` | the app's | the app's | off the card unless marked `mobile: \"secondary\"` | the app's |\n * | `actions` | {@link UserRowActions} | — | the card's actions row (`role: \"actions\"`) | — |\n *\n * The fit (0.50, kastlan K2): Name takes the rest of the row, and a table narrower than\n * its columns leaves out Created, then Last login (DataTable's `grow` / `fitPriority`).\n * The role and state chips still wrap in their cells (0.48), and the other cells keep one\n * line at Normal. `{ ...col, grow: undefined, fitPriority: undefined }` restores the 0.49\n * layout; an `extra` column takes a `fitPriority` of its own to leave too.\n *\n * The card holds three fields — `role`, `last_login` and one more: an `extra` column marked\n * `mobile: \"secondary\"` takes that place. The actions are `role: \"actions\"` (0.49), drawn\n * after the fields and never one of the three. Drop them from the card with\n * `mobile: \"hidden\"`, or draw a `mobileCard`.\n *\n * Pure: hand it resolved words, or use {@link useUserRosterColumns}. The keys are stable,\n * so an app may drop or move a column (`columns.filter((c) => c.key !== \"created\")`).\n * Under `serverPagination` the `sortBy`s only make the headers clickable; the app sends\n * the sort ({@link userRosterSort}).\n */\nexport function userRosterColumns<T extends UserRosterRow, R extends string = string>({\n roles,\n stateOf = adminUserStates,\n extra = [],\n actions,\n actionsHeader,\n editableRole,\n onRoleChange,\n roleOf,\n emailColumn = false,\n labels: labelsProp,\n}: UserRosterColumnsOptions<T, R>): DataTableColumn<T>[] {\n const labels: UserRosterLabels = { ...DEFAULT_USER_ROSTER_LABELS, ...labelsProp };\n const roleWords = (row: T) =>\n rolesOf(row, roleOf)\n .map((role) => roles[role]?.label ?? role)\n .join(\", \");\n const columns: DataTableColumn<T>[] = [\n {\n key: \"name\",\n header: labels.name,\n cell: (row) => (\n <UserIdentityCell\n person={{ first: row.first_name, last: row.last_name }}\n name={row.display_name}\n email={row.email}\n />\n ),\n // By last name, then first (auth §3.2), as the server sorts `name`.\n sortBy: (row) => `${row.last_name ?? \"\"} ${row.first_name ?? \"\"}`.trim().toLocaleLowerCase() || row.email,\n // Either part, in either order, or the address (auth §10.6).\n filterBy: (row) =>\n [row.first_name, row.last_name, row.last_name, row.first_name, row.display_name, row.email]\n .filter(Boolean)\n .join(\" \"),\n mobilePrimary: true,\n // Takes the rest of the row and ellipsises (0.50, kastlan K2): the roster fits its\n // pane — a settings column, an admin page — instead of scrolling sideways.\n grow: true,\n },\n ];\n if (emailColumn) {\n columns.push({\n key: \"email\",\n header: labels.email,\n className: \"whitespace-nowrap\",\n cell: (row) => (\n <span data-private className=\"text-secondary\">\n {row.email}\n </span>\n ),\n sortBy: (row) => row.email.toLowerCase(),\n filterBy: (row) => row.email,\n mobileHidden: true,\n });\n }\n columns.push(\n {\n key: \"role\",\n header: labels.role,\n cell: (row) => {\n const held = rolesOf(row, roleOf);\n const editing = held.length <= 1 ? editableRole?.(row) : false;\n if (editing && onRoleChange) {\n const rules: RoleEditing<R> = editing === true ? {} : editing;\n return (\n <RowName row={row}>\n {(name) => (\n // The column keeps room for the select's longest ROLE word in the app's\n // language (0.51, Kurvenschmiede N5): beside the `grow` Name every other\n // column is squeezed to its min-content, which a `w-full` select does not\n // have, so the role select was the header's ~92px and read \"Meml…\",\n // \"Admi…\". Every word of the vocabulary, not only the row's offered\n // ones: the column is as wide as its widest row, so the rows line up, and\n // a role held but not offered (KS's Reviewer) is still a selected value.\n // Not the options' reasons (\"Customer (owns work)\"): they are never the\n // selected value, and the open list is as wide as it needs anyway.\n <div>\n <RoleSelect<R>\n size=\"sm\"\n name={name}\n value={held[0] ?? null}\n roles={roles}\n offered={rules.offered}\n disabledReason={rules.disabledReason}\n optionDisabledReason={rules.optionDisabledReason}\n onChange={(role) => onRoleChange(row, role)}\n />\n <SelectWidthFloor size=\"sm\" values={roleWordsOf(roles, held[0])} />\n </div>\n )}\n </RowName>\n );\n }\n if (held.length === 0) return null;\n return (\n <div className=\"flex flex-wrap gap-1\">\n {held.map((role) => (\n <RoleChip<R> key={role} value={role} roles={roles} size=\"xs\" />\n ))}\n </div>\n );\n },\n sortBy: roleWords,\n filter: {\n type: \"select\",\n getValue: (row) => rolesOf(row, roleOf)[0] ?? \"\",\n options: (Object.keys(roles) as R[]).map((value) => ({ value, label: roles[value].label })),\n },\n mobile: \"secondary\",\n },\n {\n key: \"state\",\n header: labels.state,\n // No states, no cell: the phone card then shows no chip beside the name.\n cell: (row) => {\n const states = stateOf(row);\n return states.length === 0 ? null : <StateChips states={states} />;\n },\n // Beside the name on the phone card, so the role, last login and the actions keep\n // the card's three fields.\n role: \"status\",\n },\n dateColumn<T>({\n key: \"created\",\n header: labels.created,\n value: (row) => row.created_at ?? null,\n // The first to leave a narrow table (0.50, kastlan K2), then last login.\n column: { mobileHidden: true, fitPriority: 1 },\n }),\n // How long ago rather than a date — the question is \"recently?\" — with the exact\n // time beside it (keksdose's last-seen column, Kurvenschmiede's; 0.32 §4: never only\n // in a tooltip).\n dateColumn<T>({\n key: \"last_login\",\n header: labels.lastLogin,\n value: (row) => row.last_login_at ?? null,\n display: \"relative\",\n empty: labels.never,\n column: { mobile: \"secondary\", fitPriority: 2 },\n }),\n ...extra,\n );\n if (actions) {\n columns.push({\n key: \"actions\",\n // On screen, as every actions column's heading is (0.46.1, keksdose dev#598 rework).\n header:\n actionsHeader === false ? <span className=\"sr-only\">{labels.actions}</span> : (actionsHeader ?? labels.actions),\n headerText: labels.actions,\n // The caller's own words only: the menu reads the provider's itself, and the\n // English defaults merged in above must not shadow them.\n cell: (row) => (\n <RowName row={row}>\n {(name) => <UserRowActions actions={actions(row)} name={name} labels={labelsProp} />}\n </RowName>\n ),\n className: \"w-px whitespace-nowrap text-end\",\n headClassName: \"w-px text-end\",\n // The menu button keeps its own click: a row link must not wrap it.\n noRowLink: true,\n // Always on the phone card, after the fields and never one of the three (0.49).\n role: \"actions\",\n });\n }\n return columns;\n}\n\n/**\n * {@link userRosterColumns} with the `userRoster` words from the provider, memoised on\n * the options — pass stable callbacks (`useCallback`) and a module-level vocabulary, or\n * the columns are rebuilt on every render.\n */\nexport function useUserRosterColumns<T extends UserRosterRow, R extends string = string>({\n roles,\n stateOf,\n extra,\n actions,\n actionsHeader,\n editableRole,\n onRoleChange,\n roleOf,\n emailColumn,\n labels: labelsProp,\n}: UserRosterColumnsOptions<T, R>): DataTableColumn<T>[] {\n const labels = useKitLabels(\"userRoster\", DEFAULT_USER_ROSTER_LABELS, labelsProp);\n return useMemo(\n () =>\n userRosterColumns<T, R>({\n roles,\n stateOf,\n extra,\n actions,\n actionsHeader,\n editableRole,\n onRoleChange,\n roleOf,\n emailColumn,\n labels,\n }),\n [roles, stateOf, extra, actions, actionsHeader, editableRole, onRoleChange, roleOf, emailColumn, labels],\n );\n}\n"],"mappings":";AA2LiB,SAwHR,UAxHQ,KAET,YAFS;AA3LjB,SAAS,eAAe;AAExB,SAAS,UAAU;AAGnB,SAAS,cAAc,oBAAwC;AAC/D,SAAS,kBAAkB,UAAU,kBAAkB;AAIvD,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAE3B,SAAS,kCAAkC;AA2EpC,SAAS,gBAAgB,KAA0C;AACxE,QAAM,MAAqB,CAAC;AAC5B,MAAI,IAAI,yBAAyB,IAAI,uBAAuB;AAC1D,QAAI,KAAK,EAAE,OAAO,YAAY,MAAM,IAAI,yBAAyB,KAAK,CAAC;AAAA,EACzE,WAAW,IAAI,cAAc,QAAW;AACtC,QAAI,KAAK,IAAI,YAAY,WAAW,UAAU;AAAA,EAChD;AACA,MAAI,IAAI,mBAAmB,MAAO,KAAI,KAAK,YAAY;AACvD,MAAI,IAAI,4BAA6B,KAAI,KAAK,gBAAgB;AAC9D,SAAO;AACT;AAGO,MAAM,wBAAwB,CAAC,QAAQ,SAAS,QAAQ,WAAW,YAAY;AAW/E,SAAS,eAAe,OAAiD;AAC9E,QAAM,QAAQ,MAAM,KAAK,CAAC,MAAO,sBAA4C,SAAS,EAAE,GAAG,CAAC;AAC5F,SAAO,QAAS,YAAY,CAAC,KAAK,CAAC,KAAK,SAAa;AACvD;AAoDO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA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E,kBAAkB,QAAQ,oBAAC,UAAK,WAAU,WAAW,iBAAO,SAAQ,IAAW,iBAAiB,OAAO;AAAA,MACzG,YAAY,OAAO;AAAA;AAAA;AAAA,MAGnB,MAAM,CAAC,QACL,oBAAC,WAAQ,KACN,WAAC,SAAS,oBAAC,kBAAe,SAAS,QAAQ,GAAG,GAAG,MAAY,QAAQ,YAAY,GACpF;AAAA,MAEF,WAAW;AAAA,MACX,eAAe;AAAA;AAAA,MAEf,WAAW;AAAA;AAAA,MAEX,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAOO,SAAS,qBAAyE;AAAA,EACvF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAyD;AACvD,QAAM,SAAS,aAAa,cAAc,4BAA4B,UAAU;AAChF,SAAO;AAAA,IACL,MACE,kBAAwB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,OAAO,SAAS,OAAO,SAAS,eAAe,cAAc,cAAc,QAAQ,aAAa,MAAM;AAAA,EACzG;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/user-roster.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport type { DateInput } from \"../lib/format\";\nimport type { PersonName } from \"../lib/person-name\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { AccountStateChip, RoleChip, dateColumn } from \"../components/account-chips\";\nimport type { AccountState, RoleVocabulary } from \"../components/account-chips\";\nimport type { ChipTone } from \"../components/chip\";\nimport type { DataTableColumn } from \"../components/data-table\";\nimport { SelectWidthFloor } from \"../components/field-base\";\nimport { encodeSorts } from \"../components/data-table-sort\";\nimport type { SortState } from \"../components/data-table-sort\";\nimport { RowActions } from \"../components/row-actions\";\nimport type { RowAction, RowActionList } from \"../components/row-actions\";\nimport { UserAvatar } from \"../components/user-avatar\";\nimport { personLabel } from \"./admin-parts\";\nimport { RoleSelect } from \"./role-select\";\nimport type { RoleLock } from \"./role-select\";\nimport { DEFAULT_USER_ROSTER_LABELS } from \"./user-roster-labels\";\n\n/**\n * The admin's user list (docs/user-admin-harmonization.md §3): a column preset for the\n * kit's `DataTable`, not a table of its own.\n *\n * keksdose built its roster by hand (1150 lines, its own Badge), Kurvenschmiede on the\n * kit `DataTable` with the 0.18 chips, kastlan as a settings page. What the three share\n * is the row — name over address, a role, the account's states, created, last login, the\n * app's own columns, and a handful of actions — so that is what the kit draws, and the\n * table, its paging, its sort and its filters stay the app's `DataTable` wiring:\n *\n * ```tsx\n * const columns = useUserRosterColumns<AdminUserRow, Role>({ roles: ROLES, actions, extra });\n * <DataTable rows={page.users} columns={columns} rowKey={(r) => r.id}\n * serverPagination={{ page, pageSize, total: page.total, onPageChange }}\n * sorts={sorts} onSortsChange={setSorts} />\n * // GET /admin/users?sort=${userRosterSort(sorts)}&…\n * ```\n *\n * The column keys ARE the server's sort keys (§3.1): `name`, `email`, `role`, `created`,\n * `last_login` — so {@link userRosterSort} turns the table's sort state into the query\n * as it is. Phone cards come from the same columns: the identity is the card's headline\n * with the account's states as chips beside it, the role, last login and the actions are\n * its three fields, created is left off.\n */\n\n/* ── Rows and states ────────────────────────────────────────────────────────── */\n\n/**\n * The fields of the contract's `AdminUserRow` the preset reads (§3.2, the auth\n * contract's `UserResponse` core). An app's row has more — its `extra` — and the\n * preset passes the whole row to every callback.\n */\nexport interface UserRosterRow extends AdminUserStateFields {\n id: string | number;\n email: string;\n first_name?: string | null;\n last_name?: string | null;\n /** The derived whole name — only the fallback when both parts are blank. */\n display_name?: string | null;\n /** keksdose, Kurvenschmiede: one role. */\n role?: string | null;\n /** kastlan: the account's roles in the current company. Wins over `role`. */\n roles?: readonly string[] | null;\n created_at?: DateInput;\n /** Account-wide; kastlan's comes from its session rows (§3.2). */\n last_login_at?: DateInput;\n}\n\n/** The state fields of the contract's row that {@link adminUserStates} maps (§3.2). */\nexport interface AdminUserStateFields {\n is_active?: boolean;\n email_verified?: boolean;\n password_change_required_at?: string | null;\n /** `after_days` mode: the day the account is erased (§6.4). */\n deletion_scheduled_at?: string | null;\n /** When the user asked. The only deletion field in kastlan's `operator` mode, where\n * nothing is scheduled. */\n deletion_requested_at?: string | null;\n}\n\n/** One state chip of a row: an {@link AccountState}, or one with its `date` (the\n * `deletion` day), a `tone` or the app's own words. */\nexport type RosterState = AccountState | { state: AccountState; date?: DateInput; tone?: ChipTone; label?: ReactNode };\n\n/**\n * The contract's row as state chips (§3.2: \"map 1:1 to the kit's AccountStateChip\"):\n *\n * - marked for deletion → `deletion` with the scheduled day (none in `operator` mode),\n * IN PLACE of `inactive` — such an account is always deactivated (§2.1);\n * - else `active` / `inactive` from `is_active`;\n * - `unverified` when `email_verified` is `false` (not when it is missing);\n * - `passwordChange` while `password_change_required_at` is set.\n */\nexport function adminUserStates(row: AdminUserStateFields): RosterState[] {\n const out: RosterState[] = [];\n if (row.deletion_scheduled_at || row.deletion_requested_at) {\n out.push({ state: \"deletion\", date: row.deletion_scheduled_at ?? null });\n } else if (row.is_active !== undefined) {\n out.push(row.is_active ? \"active\" : \"inactive\");\n }\n if (row.email_verified === false) out.push(\"unverified\");\n if (row.password_change_required_at) out.push(\"passwordChange\");\n return out;\n}\n\n/** The server's sort keys, which are the preset's column keys (§3.1). */\nexport const USER_ROSTER_SORT_KEYS = [\"name\", \"email\", \"role\", \"created\", \"last_login\"] as const;\nexport type UserRosterSortKey = (typeof USER_ROSTER_SORT_KEYS)[number];\n\n/** server-kit's `user_admin.DEFAULT_PAGE_SIZE`: the rows `GET /admin/users` answers when the\n * query names no `page_size` (keksdose audit F-63, which copied it into its users panel). */\nexport const USER_ROSTER_PAGE_SIZE = 25;\n/** server-kit's `user_admin.MAX_PAGE_SIZE`: the most rows one page may ask for, which a\n * pager's \"All\" resolves to; a larger `page_size` is refused. */\nexport const USER_ROSTER_MAX_PAGE_SIZE = 200;\n\n/**\n * The table's sort state as the `sort` query parameter of `GET /admin/users` (§3.1), in\n * the DataTable's own encoding ({@link encodeSorts}: `\"last_login.desc\"`), which\n * server-kit 0.4 reads beside the `-key` form. Only the first criterion on one of the\n * server's keys: an app's own column (`owned`) is the client's to sort, and the query\n * takes one key — a shift-clicked second criterion is not sent. `undefined` when nothing\n * the server knows is sorted, so its default order applies.\n */\nexport function userRosterSort(sorts: readonly SortState[]): string | undefined {\n const first = sorts.find((s) => (USER_ROSTER_SORT_KEYS as readonly string[]).includes(s.key));\n return first ? (encodeSorts([first]) ?? undefined) : undefined;\n}\n\n/* ── Labels ─────────────────────────────────────────────────────────────────── */\n\n/** The `userRoster` namespace: the preset's headers and the action menu's words. */\nexport interface UserRosterLabels {\n /** The identity column — the name with the address under it. */\n name: string;\n /** The separate address column (`emailColumn`). */\n email: string;\n role: string;\n state: string;\n created: string;\n lastLogin: string;\n /** A last login that never happened. */\n never: string;\n /** The actions column's (hidden) header. */\n actions: string;\n /** The action menu's button and panel — \"Actions for Ada Example\". */\n actionsFor: (name: string) => string;\n}\n\n// Defined in ./user-roster-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_USER_ROSTER_LABELS };\n\n/* ── UserIdentityCell ───────────────────────────────────────────────────────── */\n\nexport interface UserIdentityCellProps {\n /** First and last name (auth §3.2), shown in the READER's order. */\n person?: PersonName | null;\n /** A whole name, for an API that still sends `display_name` only. */\n name?: string | null;\n email?: string | null;\n /** The initials avatar before the name. Default true. */\n avatar?: boolean;\n /** After the name, on its line — a \"You\" chip, a demo mark. */\n badge?: ReactNode;\n /** Over the provider's locale. */\n locale?: string;\n className?: string;\n}\n\n/**\n * Who an account is, in one cell (§3.3): the initials avatar, the name in the reader's\n * order ({@link formatPersonName} — \"Example Ada\" in Hungarian) and the address under it\n * — the cell both rosters drew by hand. An account with no name yet (a migrated row\n * before `CompleteNameDialog`, an invitee) shows its address once, as the name.\n *\n * Both lines carry `data-private`, so keksdose's demo blur reaches them, and both end\n * in \"…\" at Normal only: from Large up they wrap (`truncate-until-large`, 0.33,\n * docs/text-size-harmonization.md §10.17), since a cut name or address is a finding there.\n */\nexport function UserIdentityCell({\n person,\n name,\n email,\n avatar = true,\n badge,\n locale: localeProp,\n className,\n}: UserIdentityCellProps) {\n const locale = useKitLocale(localeProp);\n const named = personLabel({ first: person?.first, last: person?.last, name }, locale);\n const address = (email ?? \"\").trim();\n return (\n <div className={cn(\"flex min-w-0 items-center gap-2.5\", className)}>\n {avatar && <UserAvatar person={person} name={name} email={email} size=\"sm\" />}\n <div className=\"min-w-0\">\n <div className=\"flex min-w-0 items-center gap-1.5\">\n <span data-private className=\"truncate-until-large font-medium text-primary\">\n {named || address}\n </span>\n {badge}\n </div>\n {named && address && (\n <div data-private className=\"truncate-until-large text-xs text-muted\">\n {address}\n </div>\n )}\n </div>\n </div>\n );\n}\n\n/* ── The row's actions ──────────────────────────────────────────────────────── */\n\n/** One entry of a row's action menu (§4) — the kit's {@link RowAction} since 0.32,\n * which generalised it for every dense row (docs/text-size-harmonization.md §10.8). */\nexport type UserRowAction = RowAction;\n\n/** What `actions(row)` may return: entries, and `false` / `null` for the ones a\n * condition left out (`row.is_active && {…}`). */\nexport type UserRowActionList = RowActionList;\n\nexport interface UserRowActionsProps {\n actions: UserRowActionList;\n /** The account's name, for the menu's name — \"Actions for Ada Example\". */\n name: string;\n labels?: LabelOverride<UserRosterLabels>;\n}\n\n/**\n * A row's actions as one \"…\" button and a menu of them: keksdose had a strip of icon\n * buttons in the expanded row, Kurvenschmiede five text buttons in a cell — neither fits\n * a phone card, and both grow with every action §2.4 adds. The menu is portalled, so a\n * table's scroller cannot clip it; Escape and an outside press close it, and focus goes\n * back to the button, which is where a confirmation dialog then returns it.\n *\n * Since 0.32 this is {@link RowActions} with `collapse=\"menu\"` — the menu at every size —\n * named by the roster's own `actionsFor`.\n */\nexport function UserRowActions({ actions, name, labels: labelsProp }: UserRowActionsProps) {\n const labels = useKitLabels(\"userRoster\", DEFAULT_USER_ROSTER_LABELS, labelsProp);\n return <RowActions actions={actions} name={name} collapse=\"menu\" labels={{ actionsFor: labels.actionsFor }} />;\n}\n\n/* ── The preset ─────────────────────────────────────────────────────────────── */\n\n/** How a row's role may be changed inline: `true`, or with reasons. */\nexport interface RoleEditing<R extends string> {\n /** Why the whole select is locked for this row — `\"self\"`, `\"last_admin\"`, or words. */\n disabledReason?: RoleLock;\n /** Why one role cannot be chosen for this row (a string: it goes inside an option). */\n optionDisabledReason?: (role: R) => string | undefined;\n /** The roles that may be chosen. Default: the whole vocabulary. */\n offered?: readonly R[];\n}\n\nexport interface UserRosterColumnsOptions<T extends UserRosterRow, R extends string = string> {\n /** The app's roles, as `RoleChip` reads them. */\n roles: RoleVocabulary<R>;\n /** The row's state chips. Default {@link adminUserStates}, which reads the contract's\n * fields (`is_active`, `email_verified`, `password_change_required_at`,\n * `deletion_scheduled_at`, `deletion_requested_at`). */\n stateOf?: (row: T) => readonly RosterState[];\n /** The app's own columns — keksdose's plan and key custody, Kurvenschmiede's owned\n * counts — after the dates, before the actions. */\n extra?: readonly DataTableColumn<T>[];\n /** The row's action menu (§4). Left out: no actions column. */\n actions?: (row: T) => UserRowActionList;\n /** The actions column's heading (0.46.1, keksdose dev#598 rework — a VISIBLE \"Actions\"\n * on every table with an actions column). Default: `labels.actions`, shown. A node\n * replaces it; `false` keeps the pre-0.46.1 heading, a screen reader's name only. */\n actionsHeader?: ReactNode | false;\n /**\n * Whether this row's role is a select rather than a chip, and with which reasons.\n * Left out, or `false`: a chip. kastlan's several roles are never a select here — they\n * are a \"Manage roles\" action that opens `RolesEditor`.\n */\n editableRole?: (row: T) => boolean | RoleEditing<R>;\n /** A role was picked in a row's select. The app confirms (`acknowledge`) and sends it. */\n onRoleChange?: (row: T, role: R) => void;\n /** The row's role(s). Default `row.roles ?? row.role`. */\n roleOf?: (row: T) => R | readonly R[] | null | undefined;\n /** A separate, sortable \"Email\" column (the server's `email` sort key) beside the\n * identity. Default false: the address is under the name already. */\n emailColumn?: boolean;\n /** The words, already resolved. Default English; {@link useUserRosterColumns} reads\n * the provider's `userRoster` namespace. */\n labels?: LabelOverride<UserRosterLabels>;\n}\n\nfunction rolesOf<T extends UserRosterRow, R extends string>(\n row: T,\n roleOf: UserRosterColumnsOptions<T, R>[\"roleOf\"],\n): R[] {\n const raw = roleOf ? roleOf(row) : ((row.roles ?? row.role) as R | readonly R[] | null | undefined);\n if (raw === null || raw === undefined || raw === \"\") return [];\n return typeof raw === \"string\" ? [raw as R] : [...(raw as readonly R[])];\n}\n\n/** What a row's role select can show as its value: every role's word, and a held key\n * the vocabulary does not know (RoleSelect shows it as the key). */\nfunction roleWordsOf<R extends string>(roles: RoleVocabulary<R>, held: R | undefined): string[] {\n const words = (Object.keys(roles) as R[]).map((role) => roles[role].label);\n return held !== undefined && !(held in roles) ? [...words, held] : words;\n}\n\n/** The row's name in the reader's order — a component, because the order is the\n * READER's and the locale comes from the provider. */\nfunction RowName<T extends UserRosterRow>({ row, children }: { row: T; children: (name: string) => ReactNode }) {\n const locale = useKitLocale();\n const name = personLabel(\n { first: row.first_name, last: row.last_name, name: row.display_name, email: row.email },\n locale,\n );\n return <>{children(name)}</>;\n}\n\nfunction StateChips({ states }: { states: readonly RosterState[] }) {\n if (states.length === 0) return null;\n return (\n <div className=\"flex flex-wrap gap-1\">\n {states.map((entry) => {\n const spec = typeof entry === \"string\" ? { state: entry } : entry;\n return (\n <AccountStateChip key={spec.state} state={spec.state} date={spec.date} tone={spec.tone} size=\"xs\">\n {spec.label}\n </AccountStateChip>\n );\n })}\n </div>\n );\n}\n\n/**\n * The roster's columns, in the contract's order (§3.3):\n *\n * | key | cell | sort | phone | fit (0.50) |\n * |---|---|---|---|---|\n * | `name` | {@link UserIdentityCell} | last, first | the card's headline | `grow` |\n * | `email` | the address (`emailColumn` only) | address | hidden | — |\n * | `role` | `RoleChip`(s), or {@link RoleSelect} where `editableRole` | role | field | — |\n * | `state` | `AccountStateChip`s from `stateOf` | — | chips beside the headline | — |\n * | `created` | `dateColumn` | instant | hidden | `fitPriority: 1` |\n * | `last_login` | `dateColumn`, relative, \"Never\" | instant | field | `fitPriority: 2` |\n * | …`extra` | the app's | the app's | off the card unless marked `mobile: \"secondary\"` | the app's |\n * | `actions` | {@link UserRowActions} | — | the card's actions row (`role: \"actions\"`) | — |\n *\n * The fit (0.50, kastlan K2): Name takes the rest of the row, and a table narrower than\n * its columns leaves out Created, then Last login (DataTable's `grow` / `fitPriority`).\n * The role and state chips still wrap in their cells (0.48), and the other cells keep one\n * line at Normal. `{ ...col, grow: undefined, fitPriority: undefined }` restores the 0.49\n * layout; an `extra` column takes a `fitPriority` of its own to leave too.\n *\n * The card holds three fields — `role`, `last_login` and one more: an `extra` column marked\n * `mobile: \"secondary\"` takes that place. The actions are `role: \"actions\"` (0.49), drawn\n * after the fields and never one of the three. Drop them from the card with\n * `mobile: \"hidden\"`, or draw a `mobileCard`.\n *\n * Pure: hand it resolved words, or use {@link useUserRosterColumns}. The keys are stable,\n * so an app may drop or move a column (`columns.filter((c) => c.key !== \"created\")`).\n * Under `serverPagination` the `sortBy`s only make the headers clickable; the app sends\n * the sort ({@link userRosterSort}).\n */\nexport function userRosterColumns<T extends UserRosterRow, R extends string = string>({\n roles,\n stateOf = adminUserStates,\n extra = [],\n actions,\n actionsHeader,\n editableRole,\n onRoleChange,\n roleOf,\n emailColumn = false,\n labels: labelsProp,\n}: UserRosterColumnsOptions<T, R>): DataTableColumn<T>[] {\n const labels: UserRosterLabels = { ...DEFAULT_USER_ROSTER_LABELS, ...labelsProp };\n const roleWords = (row: T) =>\n rolesOf(row, roleOf)\n .map((role) => roles[role]?.label ?? role)\n .join(\", \");\n const columns: DataTableColumn<T>[] = [\n {\n key: \"name\",\n header: labels.name,\n cell: (row) => (\n <UserIdentityCell\n person={{ first: row.first_name, last: row.last_name }}\n name={row.display_name}\n email={row.email}\n />\n ),\n // By last name, then first (auth §3.2), as the server sorts `name`.\n sortBy: (row) => `${row.last_name ?? \"\"} ${row.first_name ?? \"\"}`.trim().toLocaleLowerCase() || row.email,\n // Either part, in either order, or the address (auth §10.6).\n filterBy: (row) =>\n [row.first_name, row.last_name, row.last_name, row.first_name, row.display_name, row.email]\n .filter(Boolean)\n .join(\" \"),\n mobilePrimary: true,\n // Takes the rest of the row and ellipsises (0.50, kastlan K2): the roster fits its\n // pane — a settings column, an admin page — instead of scrolling sideways.\n grow: true,\n },\n ];\n if (emailColumn) {\n columns.push({\n key: \"email\",\n header: labels.email,\n className: \"whitespace-nowrap\",\n cell: (row) => (\n <span data-private className=\"text-secondary\">\n {row.email}\n </span>\n ),\n sortBy: (row) => row.email.toLowerCase(),\n filterBy: (row) => row.email,\n mobileHidden: true,\n });\n }\n columns.push(\n {\n key: \"role\",\n header: labels.role,\n cell: (row) => {\n const held = rolesOf(row, roleOf);\n const editing = held.length <= 1 ? editableRole?.(row) : false;\n if (editing && onRoleChange) {\n const rules: RoleEditing<R> = editing === true ? {} : editing;\n return (\n <RowName row={row}>\n {(name) => (\n // The column keeps room for the select's longest ROLE word in the app's\n // language (0.51, Kurvenschmiede N5): beside the `grow` Name every other\n // column is squeezed to its min-content, which a `w-full` select does not\n // have, so the role select was the header's ~92px and read \"Meml…\",\n // \"Admi…\". Every word of the vocabulary, not only the row's offered\n // ones: the column is as wide as its widest row, so the rows line up, and\n // a role held but not offered (KS's Reviewer) is still a selected value.\n // Not the options' reasons (\"Customer (owns work)\"): they are never the\n // selected value, and the open list is as wide as it needs anyway.\n <div>\n <RoleSelect<R>\n size=\"sm\"\n name={name}\n value={held[0] ?? null}\n roles={roles}\n offered={rules.offered}\n disabledReason={rules.disabledReason}\n optionDisabledReason={rules.optionDisabledReason}\n onChange={(role) => onRoleChange(row, role)}\n />\n <SelectWidthFloor size=\"sm\" values={roleWordsOf(roles, held[0])} />\n </div>\n )}\n </RowName>\n );\n }\n if (held.length === 0) return null;\n return (\n <div className=\"flex flex-wrap gap-1\">\n {held.map((role) => (\n <RoleChip<R> key={role} value={role} roles={roles} size=\"xs\" />\n ))}\n </div>\n );\n },\n sortBy: roleWords,\n filter: {\n type: \"select\",\n getValue: (row) => rolesOf(row, roleOf)[0] ?? \"\",\n options: (Object.keys(roles) as R[]).map((value) => ({ value, label: roles[value].label })),\n },\n mobile: \"secondary\",\n },\n {\n key: \"state\",\n header: labels.state,\n // No states, no cell: the phone card then shows no chip beside the name.\n cell: (row) => {\n const states = stateOf(row);\n return states.length === 0 ? null : <StateChips states={states} />;\n },\n // Beside the name on the phone card, so the role, last login and the actions keep\n // the card's three fields.\n role: \"status\",\n },\n dateColumn<T>({\n key: \"created\",\n header: labels.created,\n value: (row) => row.created_at ?? null,\n // The first to leave a narrow table (0.50, kastlan K2), then last login.\n column: { mobileHidden: true, fitPriority: 1 },\n }),\n // How long ago rather than a date — the question is \"recently?\" — with the exact\n // time beside it (keksdose's last-seen column, Kurvenschmiede's; 0.32 §4: never only\n // in a tooltip).\n dateColumn<T>({\n key: \"last_login\",\n header: labels.lastLogin,\n value: (row) => row.last_login_at ?? null,\n display: \"relative\",\n empty: labels.never,\n column: { mobile: \"secondary\", fitPriority: 2 },\n }),\n ...extra,\n );\n if (actions) {\n columns.push({\n key: \"actions\",\n // On screen, as every actions column's heading is (0.46.1, keksdose dev#598 rework).\n header:\n actionsHeader === false ? <span className=\"sr-only\">{labels.actions}</span> : (actionsHeader ?? labels.actions),\n headerText: labels.actions,\n // The caller's own words only: the menu reads the provider's itself, and the\n // English defaults merged in above must not shadow them.\n cell: (row) => (\n <RowName row={row}>\n {(name) => <UserRowActions actions={actions(row)} name={name} labels={labelsProp} />}\n </RowName>\n ),\n className: \"w-px whitespace-nowrap text-end\",\n headClassName: \"w-px text-end\",\n // The menu button keeps its own click: a row link must not wrap it.\n noRowLink: true,\n // Always on the phone card, after the fields and never one of the three (0.49).\n role: \"actions\",\n });\n }\n return columns;\n}\n\n/**\n * {@link userRosterColumns} with the `userRoster` words from the provider, memoised on\n * the options — pass stable callbacks (`useCallback`) and a module-level vocabulary, or\n * the columns are rebuilt on every render.\n */\nexport function useUserRosterColumns<T extends UserRosterRow, R extends string = string>({\n roles,\n stateOf,\n extra,\n actions,\n actionsHeader,\n editableRole,\n onRoleChange,\n roleOf,\n emailColumn,\n labels: labelsProp,\n}: UserRosterColumnsOptions<T, R>): DataTableColumn<T>[] {\n const labels = useKitLabels(\"userRoster\", DEFAULT_USER_ROSTER_LABELS, labelsProp);\n return useMemo(\n () =>\n userRosterColumns<T, R>({\n roles,\n stateOf,\n extra,\n actions,\n actionsHeader,\n editableRole,\n onRoleChange,\n roleOf,\n emailColumn,\n labels,\n }),\n [roles, stateOf, extra, actions, actionsHeader, editableRole, onRoleChange, roleOf, emailColumn, labels],\n );\n}\n"],"mappings":";AAkMiB,SAwHR,UAxHQ,KAET,YAFS;AAlMjB,SAAS,eAAe;AAExB,SAAS,UAAU;AAGnB,SAAS,cAAc,oBAAwC;AAC/D,SAAS,kBAAkB,UAAU,kBAAkB;AAIvD,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAE3B,SAAS,kCAAkC;AA2EpC,SAAS,gBAAgB,KAA0C;AACxE,QAAM,MAAqB,CAAC;AAC5B,MAAI,IAAI,yBAAyB,IAAI,uBAAuB;AAC1D,QAAI,KAAK,EAAE,OAAO,YAAY,MAAM,IAAI,yBAAyB,KAAK,CAAC;AAAA,EACzE,WAAW,IAAI,cAAc,QAAW;AACtC,QAAI,KAAK,IAAI,YAAY,WAAW,UAAU;AAAA,EAChD;AACA,MAAI,IAAI,mBAAmB,MAAO,KAAI,KAAK,YAAY;AACvD,MAAI,IAAI,4BAA6B,KAAI,KAAK,gBAAgB;AAC9D,SAAO;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type { BillingLabels } from "../billing/billing-labels.js";
|
|
1
2
|
import { httpStatusOf } from "../lib/http-status.js";
|
|
2
3
|
/**
|
|
3
4
|
* The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every
|
|
@@ -149,6 +150,41 @@ export declare function isAuthError(err: unknown, code?: KitErrorCode): boolean;
|
|
|
149
150
|
* handler asks before it decides between the write lock, a `PlanLimitNotice` and a toast.
|
|
150
151
|
*/
|
|
151
152
|
export declare function isBillingError(err: unknown, code?: BillingErrorCode): boolean;
|
|
153
|
+
/** Who reads a `billing_read_only` refusal — {@link billingRefusalText}'s third argument,
|
|
154
|
+
* `useBillingLockReason`'s two options. */
|
|
155
|
+
export interface BillingRefusalTextOptions {
|
|
156
|
+
/** The reader is a GUEST in someone else's item (§12.6): the words never say why. */
|
|
157
|
+
guest?: boolean;
|
|
158
|
+
/** A guest's item, by its own name ("Household 2026"). Ignored for the payer. */
|
|
159
|
+
item?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The words for a billing refusal, in `labels` (an app's `useBillingLabels()`, or its
|
|
163
|
+
* `billing` catalogue outside React), or `null` when `err` is not one — for the toast or
|
|
164
|
+
* the dialog after a billing call failed, with the app's own words for anything else
|
|
165
|
+
* (kastlan reuse audit 2026-11-02, proposal 4).
|
|
166
|
+
*
|
|
167
|
+
* All three apps mapped the codes to the labels by hand: kastlan's
|
|
168
|
+
* `billing-refusal-dialog.tsx`, keksdose's `subscription-cards.tsx` and Kurvenschmiede's
|
|
169
|
+
* `api/client.ts`, the same eight codes each. This follows the most complete of them:
|
|
170
|
+
* every {@link BillingErrorCode}, so it is `null` only for an error that is not billing's.
|
|
171
|
+
*
|
|
172
|
+
* - `billing_read_only` — the write lock's sentence, as `useBillingLockReason` says it:
|
|
173
|
+
* the payer's `lockReason`, or with `{ guest: true, item }` a guest's `guestReadOnly`,
|
|
174
|
+
* which never says why (§12.6) — kastlan's dialog, which passes `guest: !isAdmin`.
|
|
175
|
+
* - `plan_limit` — `limitReached`, "Plan limit reached". Where the figure fits, read
|
|
176
|
+
* `isPlanLimit` first and show `PlanLimitNotice` or `usePlanLimitToast`, as kastlan does.
|
|
177
|
+
* - the eight others — their labels: `disabled`, `notConfigured`, `providerUnavailable`,
|
|
178
|
+
* `notAtProvider`, `alreadySubscribed`, `planNotSold`, `notSubscribed`, `planUnchanged`.
|
|
179
|
+
*
|
|
180
|
+
* Reads the code wherever {@link authErrorCode} does (axios, ofetch, a generated client,
|
|
181
|
+
* FastAPI's nested `detail`).
|
|
182
|
+
*
|
|
183
|
+
* catch (err) {
|
|
184
|
+
* toast.error(billingRefusalText(err, labels) ?? describeError(err));
|
|
185
|
+
* }
|
|
186
|
+
*/
|
|
187
|
+
export declare function billingRefusalText(err: unknown, labels: BillingLabels, options?: BillingRefusalTextOptions): string | null;
|
|
152
188
|
/**
|
|
153
189
|
* The parsed body that carries a code, wherever {@link authErrorCode} would find it (in
|
|
154
190
|
* the same order) — the object with the `code`, so FastAPI's nested `detail` when the code
|
package/dist/auth/auth-errors.js
CHANGED
|
@@ -58,6 +58,25 @@ function isBillingError(err, code) {
|
|
|
58
58
|
const found = authErrorCode(err);
|
|
59
59
|
return found !== void 0 && BILLING_CODES.has(found) && (code === void 0 || found === code);
|
|
60
60
|
}
|
|
61
|
+
const BILLING_REFUSAL_WORDS = {
|
|
62
|
+
billing_disabled: (labels) => labels.disabled,
|
|
63
|
+
// The lock's own sentence (`useBillingLockReason`): a guest's never says why (§12.6).
|
|
64
|
+
billing_read_only: (labels, options) => options.guest ? labels.guestReadOnly(options.item) : labels.lockReason,
|
|
65
|
+
// The notice's first line. The figure and the way to more are `isPlanLimit`'s, for
|
|
66
|
+
// `PlanLimitNotice` or `usePlanLimitToast`.
|
|
67
|
+
plan_limit: (labels) => labels.limitReached,
|
|
68
|
+
billing_not_configured: (labels) => labels.notConfigured,
|
|
69
|
+
billing_provider_unavailable: (labels) => labels.providerUnavailable,
|
|
70
|
+
billing_not_at_provider: (labels) => labels.notAtProvider,
|
|
71
|
+
billing_already_subscribed: (labels) => labels.alreadySubscribed,
|
|
72
|
+
billing_plan_not_sold: (labels) => labels.planNotSold,
|
|
73
|
+
billing_not_subscribed: (labels) => labels.notSubscribed,
|
|
74
|
+
billing_plan_unchanged: (labels) => labels.planUnchanged
|
|
75
|
+
};
|
|
76
|
+
function billingRefusalText(err, labels, options = {}) {
|
|
77
|
+
const found = authErrorCode(err);
|
|
78
|
+
return found !== void 0 && BILLING_CODES.has(found) ? BILLING_REFUSAL_WORDS[found](labels, options) : null;
|
|
79
|
+
}
|
|
61
80
|
function errorBodyWithCode(err, accept = (code) => known(code) !== void 0) {
|
|
62
81
|
if (!isBag(err)) return void 0;
|
|
63
82
|
const response = err.response;
|
|
@@ -106,6 +125,7 @@ function retryAfterSeconds(err, now = Date.now()) {
|
|
|
106
125
|
import { englishRateLimited, englishWait } from "./auth-errors-labels.js";
|
|
107
126
|
export {
|
|
108
127
|
authErrorCode,
|
|
128
|
+
billingRefusalText,
|
|
109
129
|
englishRateLimited,
|
|
110
130
|
englishWait,
|
|
111
131
|
errorBodyWithCode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/auth-errors.ts"],"sourcesContent":["import { httpStatusOf } from \"../lib/http-status\";\n\n/**\n * The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every\n * refusal the auth routes answer carries a machine-readable `code`, and the pages\n * recognise the CODE, never the server's sentence.\n *\n * Today each app's pages print the server's `detail` string (keksdose's\n * `extractApiErrorMessage`), which is English on every locale and, on a credential\n * check, would be an account-enumeration oracle if it ever said more than one thing.\n * keksdose already keys one refusal on a code (`features/budgets/plan-limit.ts`,\n * `402 {detail, code: \"plan_budget_limit\"}`); §5.2 makes that the rule for auth. Each\n * app switches its server and its pages together (§9).\n *\n * - `invalid_credentials` — unknown address, wrong password AND deactivated account:\n * one answer, in the same time (§2.10). `401`.\n * - `registration_closed` — the sign-up gate refused the address. `403`.\n * - `email_taken` — an account with this address exists. `409`.\n * - `invitation_invalid`, `invitation_expired` — the `invite` token of a sign-up or an\n * accept (§4.4).\n * - `token_invalid` — a one-time token (reset, verification, a sign-in challenge) is\n * unknown, spent or expired.\n * - `account_inactive` — **no server answers it.** §2.10 decided that a deactivated\n * account gets `invalid_credentials`, because a separate answer after a correct\n * password would confirm a leaked one. It stays in the union only for a future server\n * step that is past the password (an admin view, a signed-in refresh) and may say so.\n * - `session_ended` — 0.34.0 (§11.2, decision 7; server-kit 0.8): every definitive\n * refusal of `POST /auth/refresh`, a `401`. No form shows it, so it has no label: the\n * kit's `attachSessionRefresh` decides by the STATUS, so an app whose server has not\n * switched yet keeps working.\n */\nexport type AuthErrorCode =\n | \"invalid_credentials\"\n | \"registration_closed\"\n | \"email_taken\"\n | \"invitation_invalid\"\n | \"invitation_expired\"\n | \"token_invalid\"\n /** 0.30.0: a link that WAS valid and ran out (verification, reset) — keksdose's step-3\n * refusals tell it from `token_invalid`, so a page can say \"expired, ask for a new one\". */\n | \"token_expired\"\n | \"account_inactive\"\n | \"session_ended\";\n\n/**\n * 0.30.0: the coded refusals of user administration and the account's own settings\n * (docs/user-admin-harmonization.md §4, §6) — server-kit 0.4.0's `AccountErrorCode`,\n * value for value. The same family of answer as the sign-in codes (`{detail, code}`,\n * plus `companies` on kastlan's `last_admin`), read by the same {@link authErrorCode}.\n *\n * - `last_admin` — the action would leave no active admin: deactivating, demoting or\n * deleting the last one (in kastlan, of a company; the answer names the `companies`).\n * - `self_action` — an admin acting on their own account where that is never allowed.\n * - `other_companies` — kastlan: the account belongs to other companies too, so a\n * company admin may not deactivate it; \"Remove from company\" instead (§9.6).\n * - `household_has_members` — keksdose's guard on a deletion request (§6.4).\n * - `confirmation_required`, `confirmation_mismatch` — the action's confirmation level\n * asked for a typed address (or a tick), and the request carried none, or another\n * address (§4.2).\n * - `password_incorrect` — the CURRENT password is wrong on a signed-in route (the email\n * change, the deletion request). `400`, not `401`: an app's client reads a 401 as an\n * ended session and signs the user out, the wrong answer to a typo. Every other one\n * is a `409`.\n */\nexport type AccountErrorCode =\n | \"last_admin\"\n | \"self_action\"\n | \"other_companies\"\n | \"household_has_members\"\n | \"confirmation_required\"\n | \"confirmation_mismatch\"\n | \"password_incorrect\";\n\n/**\n * 0.31.0: the demo's coded refusals (docs/landing-demo-harmonization.md §6.2) —\n * server-kit 0.5's `DemoErrorCode`, value for value, answered as `{detail, code}` like\n * the others and read by the same {@link authErrorCode}.\n *\n * - `demo_disabled` — `404`: the demo switch is off (it is \"not there\", not forbidden).\n * - `demo_rate_limited` — `429` with `Retry-After`: the per-IP window of demo starts.\n * - `demo_capacity` — `429`, no `Retry-After`: the cap of live demo users.\n * - `demo_not_ready` — `503`: the demo data has not been seeded yet.\n * - `demo_read_only` — `403`, model R: any write by a demo user. The app's write lock\n * already explains it, so it shows no toast (§5.4).\n * - `demo_refused` — `403`, both models: an action a demo never may — a way in or out,\n * mail, uploads, the account export (§6.4).\n */\nexport type DemoErrorCode =\n \"demo_disabled\" | \"demo_rate_limited\" | \"demo_capacity\" | \"demo_not_ready\" | \"demo_read_only\" | \"demo_refused\";\n\n/**\n * 0.32.0: billing's coded refusals (docs/billing-harmonization.md §3.3, §3.4, §4, §12.3) —\n * server-kit 0.6's `BillingError` and `PlanLimitError`, value for value, answered as\n * `{detail, code}` like the others and read by the same {@link authErrorCode}.\n *\n * - `billing_disabled` — `404`: the billing switch is off (§2.9), so every billing route\n * but `GET /billing/status` is \"not there\", as a switched-off demo is.\n * - `billing_read_only` — `402`: a write by (or into the data of) a payer out of good\n * standing (§3.3, §12.1). Inside a sync reply it marks the changes that were refused\n * and not applied (§12.5). The app's write lock and banner already say why, so — like\n * `demo_read_only` — it needs no toast of its own.\n * - `plan_limit` — `402`: a create past the plan's limit (§3.4), with the extra fields\n * `dimension`, `plan`, `limit` and `used` — read them with `isPlanLimit`. A lapsed payer\n * creating gets `billing_read_only` instead, never this (§12.3).\n * - `billing_not_configured` — billing is switched on but the provider's settings are\n * missing (the secrets, a price id): the operator's mistake, not the payer's.\n *\n * 0.33.0 (server-kit 0.7, §14.2): the provider's refusals, with the `billing_` prefix of\n * the others (decision 22).\n * - `billing_provider_unavailable` — `502`: Paddle didn't answer, or refused the request.\n * Try again.\n * - `billing_not_at_provider` — `409`: a portal request before the payer reached the\n * provider (§14.5) — a stale page; the overview's `at_provider` says it first.\n * - `billing_already_subscribed` — `409`: a checkout while a provider subscription runs\n * (§14.6). Since 0.39 plan changes go through the plan switch (§15.2.10).\n * - `billing_plan_not_sold` — `422`: a checkout for a plan, currency or interval the\n * catalogue doesn't sell — or (0.39) a switch to one.\n *\n * 0.39.0 (server-kit 0.12, §15.2.10): the plan switch's refusals.\n * - `billing_not_subscribed` — `409`: a switch with no running provider subscription;\n * the page offers the checkout instead.\n * - `billing_plan_unchanged` — `409`: a switch to the price the payer pays now.\n */\nexport type BillingErrorCode =\n | \"billing_disabled\"\n | \"billing_read_only\"\n | \"plan_limit\"\n | \"billing_not_configured\"\n | \"billing_provider_unavailable\"\n | \"billing_not_at_provider\"\n | \"billing_already_subscribed\"\n | \"billing_plan_not_sold\"\n | \"billing_not_subscribed\"\n | \"billing_plan_unchanged\";\n\n/** Every code the kit reads: the sign-in refusals, the account ones (0.30.0), the demo's\n * (0.31.0) and billing's (0.32.0). */\nexport type KitErrorCode = AuthErrorCode | AccountErrorCode | DemoErrorCode | BillingErrorCode;\n\nconst BILLING_CODES: ReadonlySet<BillingErrorCode> = new Set<BillingErrorCode>([\n \"billing_disabled\",\n \"billing_read_only\",\n \"plan_limit\",\n \"billing_not_configured\",\n \"billing_provider_unavailable\",\n \"billing_not_at_provider\",\n \"billing_already_subscribed\",\n \"billing_plan_not_sold\",\n \"billing_not_subscribed\",\n \"billing_plan_unchanged\",\n]);\n\nconst CODES: ReadonlySet<string> = new Set<KitErrorCode>([\n \"invalid_credentials\",\n \"registration_closed\",\n \"email_taken\",\n \"invitation_invalid\",\n \"invitation_expired\",\n \"token_invalid\",\n \"token_expired\",\n \"account_inactive\",\n \"session_ended\",\n \"last_admin\",\n \"self_action\",\n \"other_companies\",\n \"household_has_members\",\n \"confirmation_required\",\n \"confirmation_mismatch\",\n \"password_incorrect\",\n \"demo_disabled\",\n \"demo_rate_limited\",\n \"demo_capacity\",\n \"demo_not_ready\",\n \"demo_read_only\",\n \"demo_refused\",\n ...BILLING_CODES,\n]);\n\ntype Bag = Record<string, unknown>;\n\nconst isBag = (value: unknown): value is Bag => typeof value === \"object\" && value !== null;\n\n/** A known code, or undefined. */\nfunction known(value: unknown): KitErrorCode | undefined {\n return typeof value === \"string\" && CODES.has(value) ? (value as KitErrorCode) : undefined;\n}\n\n/** `{code}` on a parsed body, or FastAPI's `{detail: {code}}` — what an\n * `HTTPException(detail={\"code\": …})` serialises to. */\nfunction codeOfBody(body: unknown): KitErrorCode | undefined {\n if (!isBag(body)) return undefined;\n return known(body.code) ?? (isBag(body.detail) ? known(body.detail.code) : undefined);\n}\n\n/**\n * The code an error carries — an {@link AuthErrorCode}, since 0.30.0 an\n * {@link AccountErrorCode}, since 0.31.0 a {@link DemoErrorCode}, since 0.32.0 a\n * {@link BillingErrorCode} — or `undefined` when it carries none.\n *\n * Reads the parsed response body wherever the apps' HTTP clients put it, without\n * depending on any of them:\n *\n * 1. `err.response.data` — axios (keksdose's, kastlan's and Kurvenschmiede's clients;\n * keksdose's `isPlanBudgetLimitRefusal` reads the same path);\n * 2. `err.data` — ofetch's `FetchError`, and most `fetch` wrappers that parse the body;\n * 3. `err.body` — the generated OpenAPI clients' `ApiError`;\n * 4. `err` itself — a body thrown as it came (`throw await res.json()`).\n *\n * In each, `code` or FastAPI's nested `detail.code`. Last, `err.code` — but only when\n * it is one of the codes above: axios writes its OWN codes there (`ERR_NETWORK`,\n * `ECONNABORTED`, `ERR_BAD_REQUEST`), and so does Node, so an unknown value is never\n * read as a refusal. The HTTP status is not checked: the code is the contract, and the\n * status differs per refusal (401, 402, 403, 404, 409, 410).\n */\nexport function authErrorCode(err: unknown): KitErrorCode | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n return (\n (isBag(response) ? codeOfBody(response.data) : undefined) ??\n codeOfBody(err.data) ??\n codeOfBody(err.body) ??\n codeOfBody(err)\n );\n}\n\n/**\n * Whether `err` is a coded auth refusal — any of them, or the one named:\n *\n * ```ts\n * try { await api.register(values) }\n * catch (err) { if (isAuthError(err, \"email_taken\")) … }\n * ```\n *\n * The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject\n * with, so an app's `onSubmit` can simply let its client's error through. See\n * {@link authErrorCode} for the shapes it reads. Since 0.30.0 it knows the account codes\n * too: `isAuthError(err, \"last_admin\")`; since 0.31.0 the demo's:\n * `isAuthError(err, \"demo_read_only\")`; since 0.32.0 billing's:\n * `isAuthError(err, \"billing_read_only\")` (or {@link isBillingError}).\n */\nexport function isAuthError(err: unknown, code?: KitErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && (code === undefined || found === code);\n}\n\n/**\n * Whether `err` is one of billing's coded refusals (0.32.0, docs/billing-harmonization.md\n * §10, §14.2) — any of them, or the one named. {@link isAuthError} answers the same for a\n * named code; this one also answers \"is it billing's at all\", which an app's error\n * handler asks before it decides between the write lock, a `PlanLimitNotice` and a toast.\n */\nexport function isBillingError(err: unknown, code?: BillingErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && BILLING_CODES.has(found as BillingErrorCode) && (code === undefined || found === code);\n}\n\n/**\n * The parsed body that carries a code, wherever {@link authErrorCode} would find it (in\n * the same order) — the object with the `code`, so FastAPI's nested `detail` when the code\n * is there. For a reader of a refusal's EXTRA fields (`isPlanLimit`: `dimension`, `limit`,\n * `used` sit beside the code). `accept` decides which codes count; default, the known ones.\n *\n * @internal Not part of the barrel.\n */\nexport function errorBodyWithCode(\n err: unknown,\n accept: (code: unknown) => boolean = (code) => known(code) !== undefined,\n): Record<string, unknown> | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n for (const body of [isBag(response) ? response.data : undefined, err.data, err.body, err]) {\n if (!isBag(body)) continue;\n if (accept(body.code)) return body;\n if (isBag(body.detail) && accept(body.detail.code)) return body.detail;\n }\n return undefined;\n}\n\n/**\n * The HTTP status a thrown error carries ({@link httpStatusOf}): axios'\n * `response.status`, then `status`, then `statusCode`. Lives in `lib/http-status.ts`\n * since 0.52 (refactor audit 2026-10-30, MOD-6); re-exported here for the modules that\n * import it from auth. Package-private — not re-exported from the barrel.\n */\nexport { httpStatusOf };\n\n/**\n * Whether `err` is a throttled request — HTTP `429 Too Many Requests` (0.30.0, from the\n * apps' 0.29 adoption: every app answered a throttled sign-in, sign-up or reset through\n * its own `describeError`, with three wordings of one sentence).\n *\n * A throttle carries no `code` in the contract — the STATUS is the answer, set by the\n * apps' limiters (server-kit's `AuthLimiters`, keksdose's per-IP limit) — so this reads\n * the status, wherever the apps' HTTP clients put it ({@link httpStatusOf}).\n *\n * There is no `rate_limited` code: keksdose answers its 429s uncoded, with a\n * `Retry-After` header, and the status is the one signal every limiter gives.\n *\n * The kit's `SignInForm`, `RegisterForm`, `ForgotPasswordForm` and `ResetPasswordForm`\n * call it AFTER the app's `describeError` — an app with words of its own keeps them —\n * and before their generic failure, so \"Too many attempts. Try again in 30 s.\" (with\n * {@link retryAfterSeconds}) or \"… Wait a moment and try again.\" needs no app code.\n */\nexport function isRateLimited(err: unknown): boolean {\n return httpStatusOf(err) === 429;\n}\n\n/** A header's value from a `Headers` (fetch, ofetch's `response`), axios' `AxiosHeaders`\n * or a plain record — whose keys may come in any case. */\nfunction headerOf(headers: unknown, name: string): unknown {\n if (!isBag(headers)) return undefined;\n if (typeof headers.get === \"function\") {\n try {\n const value: unknown = (headers.get as (key: string) => unknown).call(headers, name);\n if (value !== undefined && value !== null) return value;\n } catch {\n // A `get` that is not a header lookup; the record below is.\n }\n }\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) return value;\n }\n return undefined;\n}\n\n/** `Retry-After` as seconds from `now`: delta-seconds (\"30\"), or an HTTP date\n * (\"Wed, 07 Oct 2026 10:00:00 GMT\") counted from now, never below 0 (RFC 9110 §10.2.3). */\nfunction parseRetryAfter(value: unknown, now: number): number | undefined {\n const raw = Array.isArray(value) ? (value as unknown[])[0] : value;\n if (typeof raw === \"number\") return Number.isFinite(raw) && raw >= 0 ? Math.ceil(raw) : undefined;\n if (typeof raw !== \"string\") return undefined;\n const text = raw.trim();\n if (/^\\d+$/.test(text)) return Number(text);\n // An HTTP date names its day and month (\"Wed, 07 Oct 2026 …\"). Without a letter it is\n // a malformed number (\"-5\", \"1.5\"), which `Date.parse` would happily read as a year.\n if (!/[a-z]/i.test(text)) return undefined;\n const at = Date.parse(text);\n if (Number.isNaN(at)) return undefined;\n return Math.max(0, Math.ceil((at - now) / 1000));\n}\n\n/**\n * How long a throttled request asks to wait, in whole seconds — its `Retry-After`\n * header (0.30.0, keksdose: its 429s carry no code, only the header) — or `undefined`\n * when there is none, or none that parses.\n *\n * Read where the apps' clients keep the response headers, without depending on any of\n * them: `err.response.headers` (axios' `AxiosHeaders` or a plain record; ofetch's\n * `FetchError.response`, a fetch `Headers`), then `err.headers` (a `Response` thrown as\n * it came). The value is delta-seconds, or an HTTP date turned into seconds from `now`\n * (default: the present moment) — never below 0.\n *\n * The forms hand it to their `rateLimited` label when {@link isRateLimited} is true:\n * \"Too many attempts. Try again in 30 s.\" — and, without one, \"… Wait a moment and try\n * again.\" A browser only exposes `Retry-After` to a cross-origin page when the server\n * lists it in `Access-Control-Expose-Headers`.\n */\nexport function retryAfterSeconds(err: unknown, now: number | Date = Date.now()): number | undefined {\n if (!isBag(err)) return undefined;\n const at = typeof now === \"number\" ? now : now.getTime();\n const response = err.response;\n const value =\n (isBag(response) ? headerOf(response.headers, \"retry-after\") : undefined) ?? headerOf(err.headers, \"retry-after\");\n return value === undefined ? undefined : parseRetryAfter(value, at);\n}\n\n// The English of the `rateLimited` labels, in auth-errors-labels since 0.52: the English\n// catalogue reached this module for them, and with it `lib/http-status` (refactor audit\n// 2026-10-30, MOD-6). Re-exported for the modules that import them from here.\nexport { englishRateLimited, englishWait } from \"./auth-errors-labels\";\n"],"mappings":";AAAA,SAAS,oBAAoB;AA2I7B,MAAM,gBAA+C,oBAAI,IAAsB;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,MAAM,QAA6B,oBAAI,IAAkB;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,CAAC;AAID,MAAM,QAAQ,CAAC,UAAiC,OAAO,UAAU,YAAY,UAAU;AAGvF,SAAS,MAAM,OAA0C;AACvD,SAAO,OAAO,UAAU,YAAY,MAAM,IAAI,KAAK,IAAK,QAAyB;AACnF;AAIA,SAAS,WAAW,MAAyC;AAC3D,MAAI,CAAC,MAAM,IAAI,EAAG,QAAO;AACzB,SAAO,MAAM,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,IAAI,IAAI;AAC7E;AAsBO,SAAS,cAAc,KAAwC;AACpE,MAAI,CAAC,MAAM,GAAG,EAAG,QAAO;AACxB,QAAM,WAAW,IAAI;AACrB,UACG,MAAM,QAAQ,IAAI,WAAW,SAAS,IAAI,IAAI,WAC/C,WAAW,IAAI,IAAI,KACnB,WAAW,IAAI,IAAI,KACnB,WAAW,GAAG;AAElB;AAiBO,SAAS,YAAY,KAAc,MAA8B;AACtE,QAAM,QAAQ,cAAc,GAAG;AAC/B,SAAO,UAAU,WAAc,SAAS,UAAa,UAAU;AACjE;AAQO,SAAS,eAAe,KAAc,MAAkC;AA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,KAAK;AACtB,MAAI,QAAQ,KAAK,IAAI,EAAG,QAAO,OAAO,IAAI;AAG1C,MAAI,CAAC,SAAS,KAAK,IAAI,EAAG,QAAO;AACjC,QAAM,KAAK,KAAK,MAAM,IAAI;AAC1B,MAAI,OAAO,MAAM,EAAE,EAAG,QAAO;AAC7B,SAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,OAAO,GAAI,CAAC;AACjD;AAkBO,SAAS,kBAAkB,KAAc,MAAqB,KAAK,IAAI,GAAuB;AACnG,MAAI,CAAC,MAAM,GAAG,EAAG,QAAO;AACxB,QAAM,KAAK,OAAO,QAAQ,WAAW,MAAM,IAAI,QAAQ;AACvD,QAAM,WAAW,IAAI;AACrB,QAAM,SACH,MAAM,QAAQ,IAAI,SAAS,SAAS,SAAS,aAAa,IAAI,WAAc,SAAS,IAAI,SAAS,aAAa;AAClH,SAAO,UAAU,SAAY,SAAY,gBAAgB,OAAO,EAAE;AACpE;AAKA,SAAS,oBAAoB,mBAAmB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/auth-errors.ts"],"sourcesContent":["import type { BillingLabels } from \"../billing/billing-labels\";\nimport { httpStatusOf } from \"../lib/http-status\";\n\n/**\n * The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every\n * refusal the auth routes answer carries a machine-readable `code`, and the pages\n * recognise the CODE, never the server's sentence.\n *\n * Today each app's pages print the server's `detail` string (keksdose's\n * `extractApiErrorMessage`), which is English on every locale and, on a credential\n * check, would be an account-enumeration oracle if it ever said more than one thing.\n * keksdose already keys one refusal on a code (`features/budgets/plan-limit.ts`,\n * `402 {detail, code: \"plan_budget_limit\"}`); §5.2 makes that the rule for auth. Each\n * app switches its server and its pages together (§9).\n *\n * - `invalid_credentials` — unknown address, wrong password AND deactivated account:\n * one answer, in the same time (§2.10). `401`.\n * - `registration_closed` — the sign-up gate refused the address. `403`.\n * - `email_taken` — an account with this address exists. `409`.\n * - `invitation_invalid`, `invitation_expired` — the `invite` token of a sign-up or an\n * accept (§4.4).\n * - `token_invalid` — a one-time token (reset, verification, a sign-in challenge) is\n * unknown, spent or expired.\n * - `account_inactive` — **no server answers it.** §2.10 decided that a deactivated\n * account gets `invalid_credentials`, because a separate answer after a correct\n * password would confirm a leaked one. It stays in the union only for a future server\n * step that is past the password (an admin view, a signed-in refresh) and may say so.\n * - `session_ended` — 0.34.0 (§11.2, decision 7; server-kit 0.8): every definitive\n * refusal of `POST /auth/refresh`, a `401`. No form shows it, so it has no label: the\n * kit's `attachSessionRefresh` decides by the STATUS, so an app whose server has not\n * switched yet keeps working.\n */\nexport type AuthErrorCode =\n | \"invalid_credentials\"\n | \"registration_closed\"\n | \"email_taken\"\n | \"invitation_invalid\"\n | \"invitation_expired\"\n | \"token_invalid\"\n /** 0.30.0: a link that WAS valid and ran out (verification, reset) — keksdose's step-3\n * refusals tell it from `token_invalid`, so a page can say \"expired, ask for a new one\". */\n | \"token_expired\"\n | \"account_inactive\"\n | \"session_ended\";\n\n/**\n * 0.30.0: the coded refusals of user administration and the account's own settings\n * (docs/user-admin-harmonization.md §4, §6) — server-kit 0.4.0's `AccountErrorCode`,\n * value for value. The same family of answer as the sign-in codes (`{detail, code}`,\n * plus `companies` on kastlan's `last_admin`), read by the same {@link authErrorCode}.\n *\n * - `last_admin` — the action would leave no active admin: deactivating, demoting or\n * deleting the last one (in kastlan, of a company; the answer names the `companies`).\n * - `self_action` — an admin acting on their own account where that is never allowed.\n * - `other_companies` — kastlan: the account belongs to other companies too, so a\n * company admin may not deactivate it; \"Remove from company\" instead (§9.6).\n * - `household_has_members` — keksdose's guard on a deletion request (§6.4).\n * - `confirmation_required`, `confirmation_mismatch` — the action's confirmation level\n * asked for a typed address (or a tick), and the request carried none, or another\n * address (§4.2).\n * - `password_incorrect` — the CURRENT password is wrong on a signed-in route (the email\n * change, the deletion request). `400`, not `401`: an app's client reads a 401 as an\n * ended session and signs the user out, the wrong answer to a typo. Every other one\n * is a `409`.\n */\nexport type AccountErrorCode =\n | \"last_admin\"\n | \"self_action\"\n | \"other_companies\"\n | \"household_has_members\"\n | \"confirmation_required\"\n | \"confirmation_mismatch\"\n | \"password_incorrect\";\n\n/**\n * 0.31.0: the demo's coded refusals (docs/landing-demo-harmonization.md §6.2) —\n * server-kit 0.5's `DemoErrorCode`, value for value, answered as `{detail, code}` like\n * the others and read by the same {@link authErrorCode}.\n *\n * - `demo_disabled` — `404`: the demo switch is off (it is \"not there\", not forbidden).\n * - `demo_rate_limited` — `429` with `Retry-After`: the per-IP window of demo starts.\n * - `demo_capacity` — `429`, no `Retry-After`: the cap of live demo users.\n * - `demo_not_ready` — `503`: the demo data has not been seeded yet.\n * - `demo_read_only` — `403`, model R: any write by a demo user. The app's write lock\n * already explains it, so it shows no toast (§5.4).\n * - `demo_refused` — `403`, both models: an action a demo never may — a way in or out,\n * mail, uploads, the account export (§6.4).\n */\nexport type DemoErrorCode =\n \"demo_disabled\" | \"demo_rate_limited\" | \"demo_capacity\" | \"demo_not_ready\" | \"demo_read_only\" | \"demo_refused\";\n\n/**\n * 0.32.0: billing's coded refusals (docs/billing-harmonization.md §3.3, §3.4, §4, §12.3) —\n * server-kit 0.6's `BillingError` and `PlanLimitError`, value for value, answered as\n * `{detail, code}` like the others and read by the same {@link authErrorCode}.\n *\n * - `billing_disabled` — `404`: the billing switch is off (§2.9), so every billing route\n * but `GET /billing/status` is \"not there\", as a switched-off demo is.\n * - `billing_read_only` — `402`: a write by (or into the data of) a payer out of good\n * standing (§3.3, §12.1). Inside a sync reply it marks the changes that were refused\n * and not applied (§12.5). The app's write lock and banner already say why, so — like\n * `demo_read_only` — it needs no toast of its own.\n * - `plan_limit` — `402`: a create past the plan's limit (§3.4), with the extra fields\n * `dimension`, `plan`, `limit` and `used` — read them with `isPlanLimit`. A lapsed payer\n * creating gets `billing_read_only` instead, never this (§12.3).\n * - `billing_not_configured` — billing is switched on but the provider's settings are\n * missing (the secrets, a price id): the operator's mistake, not the payer's.\n *\n * 0.33.0 (server-kit 0.7, §14.2): the provider's refusals, with the `billing_` prefix of\n * the others (decision 22).\n * - `billing_provider_unavailable` — `502`: Paddle didn't answer, or refused the request.\n * Try again.\n * - `billing_not_at_provider` — `409`: a portal request before the payer reached the\n * provider (§14.5) — a stale page; the overview's `at_provider` says it first.\n * - `billing_already_subscribed` — `409`: a checkout while a provider subscription runs\n * (§14.6). Since 0.39 plan changes go through the plan switch (§15.2.10).\n * - `billing_plan_not_sold` — `422`: a checkout for a plan, currency or interval the\n * catalogue doesn't sell — or (0.39) a switch to one.\n *\n * 0.39.0 (server-kit 0.12, §15.2.10): the plan switch's refusals.\n * - `billing_not_subscribed` — `409`: a switch with no running provider subscription;\n * the page offers the checkout instead.\n * - `billing_plan_unchanged` — `409`: a switch to the price the payer pays now.\n */\nexport type BillingErrorCode =\n | \"billing_disabled\"\n | \"billing_read_only\"\n | \"plan_limit\"\n | \"billing_not_configured\"\n | \"billing_provider_unavailable\"\n | \"billing_not_at_provider\"\n | \"billing_already_subscribed\"\n | \"billing_plan_not_sold\"\n | \"billing_not_subscribed\"\n | \"billing_plan_unchanged\";\n\n/** Every code the kit reads: the sign-in refusals, the account ones (0.30.0), the demo's\n * (0.31.0) and billing's (0.32.0). */\nexport type KitErrorCode = AuthErrorCode | AccountErrorCode | DemoErrorCode | BillingErrorCode;\n\nconst BILLING_CODES: ReadonlySet<BillingErrorCode> = new Set<BillingErrorCode>([\n \"billing_disabled\",\n \"billing_read_only\",\n \"plan_limit\",\n \"billing_not_configured\",\n \"billing_provider_unavailable\",\n \"billing_not_at_provider\",\n \"billing_already_subscribed\",\n \"billing_plan_not_sold\",\n \"billing_not_subscribed\",\n \"billing_plan_unchanged\",\n]);\n\nconst CODES: ReadonlySet<string> = new Set<KitErrorCode>([\n \"invalid_credentials\",\n \"registration_closed\",\n \"email_taken\",\n \"invitation_invalid\",\n \"invitation_expired\",\n \"token_invalid\",\n \"token_expired\",\n \"account_inactive\",\n \"session_ended\",\n \"last_admin\",\n \"self_action\",\n \"other_companies\",\n \"household_has_members\",\n \"confirmation_required\",\n \"confirmation_mismatch\",\n \"password_incorrect\",\n \"demo_disabled\",\n \"demo_rate_limited\",\n \"demo_capacity\",\n \"demo_not_ready\",\n \"demo_read_only\",\n \"demo_refused\",\n ...BILLING_CODES,\n]);\n\ntype Bag = Record<string, unknown>;\n\nconst isBag = (value: unknown): value is Bag => typeof value === \"object\" && value !== null;\n\n/** A known code, or undefined. */\nfunction known(value: unknown): KitErrorCode | undefined {\n return typeof value === \"string\" && CODES.has(value) ? (value as KitErrorCode) : undefined;\n}\n\n/** `{code}` on a parsed body, or FastAPI's `{detail: {code}}` — what an\n * `HTTPException(detail={\"code\": …})` serialises to. */\nfunction codeOfBody(body: unknown): KitErrorCode | undefined {\n if (!isBag(body)) return undefined;\n return known(body.code) ?? (isBag(body.detail) ? known(body.detail.code) : undefined);\n}\n\n/**\n * The code an error carries — an {@link AuthErrorCode}, since 0.30.0 an\n * {@link AccountErrorCode}, since 0.31.0 a {@link DemoErrorCode}, since 0.32.0 a\n * {@link BillingErrorCode} — or `undefined` when it carries none.\n *\n * Reads the parsed response body wherever the apps' HTTP clients put it, without\n * depending on any of them:\n *\n * 1. `err.response.data` — axios (keksdose's, kastlan's and Kurvenschmiede's clients;\n * keksdose's `isPlanBudgetLimitRefusal` reads the same path);\n * 2. `err.data` — ofetch's `FetchError`, and most `fetch` wrappers that parse the body;\n * 3. `err.body` — the generated OpenAPI clients' `ApiError`;\n * 4. `err` itself — a body thrown as it came (`throw await res.json()`).\n *\n * In each, `code` or FastAPI's nested `detail.code`. Last, `err.code` — but only when\n * it is one of the codes above: axios writes its OWN codes there (`ERR_NETWORK`,\n * `ECONNABORTED`, `ERR_BAD_REQUEST`), and so does Node, so an unknown value is never\n * read as a refusal. The HTTP status is not checked: the code is the contract, and the\n * status differs per refusal (401, 402, 403, 404, 409, 410).\n */\nexport function authErrorCode(err: unknown): KitErrorCode | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n return (\n (isBag(response) ? codeOfBody(response.data) : undefined) ??\n codeOfBody(err.data) ??\n codeOfBody(err.body) ??\n codeOfBody(err)\n );\n}\n\n/**\n * Whether `err` is a coded auth refusal — any of them, or the one named:\n *\n * ```ts\n * try { await api.register(values) }\n * catch (err) { if (isAuthError(err, \"email_taken\")) … }\n * ```\n *\n * The kit's `SignInForm` and `RegisterForm` call it on what their callbacks reject\n * with, so an app's `onSubmit` can simply let its client's error through. See\n * {@link authErrorCode} for the shapes it reads. Since 0.30.0 it knows the account codes\n * too: `isAuthError(err, \"last_admin\")`; since 0.31.0 the demo's:\n * `isAuthError(err, \"demo_read_only\")`; since 0.32.0 billing's:\n * `isAuthError(err, \"billing_read_only\")` (or {@link isBillingError}).\n */\nexport function isAuthError(err: unknown, code?: KitErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && (code === undefined || found === code);\n}\n\n/**\n * Whether `err` is one of billing's coded refusals (0.32.0, docs/billing-harmonization.md\n * §10, §14.2) — any of them, or the one named. {@link isAuthError} answers the same for a\n * named code; this one also answers \"is it billing's at all\", which an app's error\n * handler asks before it decides between the write lock, a `PlanLimitNotice` and a toast.\n */\nexport function isBillingError(err: unknown, code?: BillingErrorCode): boolean {\n const found = authErrorCode(err);\n return found !== undefined && BILLING_CODES.has(found as BillingErrorCode) && (code === undefined || found === code);\n}\n\n/** Who reads a `billing_read_only` refusal — {@link billingRefusalText}'s third argument,\n * `useBillingLockReason`'s two options. */\nexport interface BillingRefusalTextOptions {\n /** The reader is a GUEST in someone else's item (§12.6): the words never say why. */\n guest?: boolean;\n /** A guest's item, by its own name (\"Household 2026\"). Ignored for the payer. */\n item?: string;\n}\n\ntype RefusalWords = (labels: BillingLabels, options: BillingRefusalTextOptions) => string;\n\n/**\n * Each billing refusal's words in the `billing` labels. A `Record` over the whole union, so\n * a code server-kit adds is a type error here until it has words.\n */\nconst BILLING_REFUSAL_WORDS: Record<BillingErrorCode, RefusalWords> = {\n billing_disabled: (labels) => labels.disabled,\n // The lock's own sentence (`useBillingLockReason`): a guest's never says why (§12.6).\n billing_read_only: (labels, options) => (options.guest ? labels.guestReadOnly(options.item) : labels.lockReason),\n // The notice's first line. The figure and the way to more are `isPlanLimit`'s, for\n // `PlanLimitNotice` or `usePlanLimitToast`.\n plan_limit: (labels) => labels.limitReached,\n billing_not_configured: (labels) => labels.notConfigured,\n billing_provider_unavailable: (labels) => labels.providerUnavailable,\n billing_not_at_provider: (labels) => labels.notAtProvider,\n billing_already_subscribed: (labels) => labels.alreadySubscribed,\n billing_plan_not_sold: (labels) => labels.planNotSold,\n billing_not_subscribed: (labels) => labels.notSubscribed,\n billing_plan_unchanged: (labels) => labels.planUnchanged,\n};\n\n/**\n * The words for a billing refusal, in `labels` (an app's `useBillingLabels()`, or its\n * `billing` catalogue outside React), or `null` when `err` is not one — for the toast or\n * the dialog after a billing call failed, with the app's own words for anything else\n * (kastlan reuse audit 2026-11-02, proposal 4).\n *\n * All three apps mapped the codes to the labels by hand: kastlan's\n * `billing-refusal-dialog.tsx`, keksdose's `subscription-cards.tsx` and Kurvenschmiede's\n * `api/client.ts`, the same eight codes each. This follows the most complete of them:\n * every {@link BillingErrorCode}, so it is `null` only for an error that is not billing's.\n *\n * - `billing_read_only` — the write lock's sentence, as `useBillingLockReason` says it:\n * the payer's `lockReason`, or with `{ guest: true, item }` a guest's `guestReadOnly`,\n * which never says why (§12.6) — kastlan's dialog, which passes `guest: !isAdmin`.\n * - `plan_limit` — `limitReached`, \"Plan limit reached\". Where the figure fits, read\n * `isPlanLimit` first and show `PlanLimitNotice` or `usePlanLimitToast`, as kastlan does.\n * - the eight others — their labels: `disabled`, `notConfigured`, `providerUnavailable`,\n * `notAtProvider`, `alreadySubscribed`, `planNotSold`, `notSubscribed`, `planUnchanged`.\n *\n * Reads the code wherever {@link authErrorCode} does (axios, ofetch, a generated client,\n * FastAPI's nested `detail`).\n *\n * catch (err) {\n * toast.error(billingRefusalText(err, labels) ?? describeError(err));\n * }\n */\nexport function billingRefusalText(\n err: unknown,\n labels: BillingLabels,\n options: BillingRefusalTextOptions = {},\n): string | null {\n const found = authErrorCode(err);\n return found !== undefined && BILLING_CODES.has(found as BillingErrorCode)\n ? BILLING_REFUSAL_WORDS[found as BillingErrorCode](labels, options)\n : null;\n}\n\n/**\n * The parsed body that carries a code, wherever {@link authErrorCode} would find it (in\n * the same order) — the object with the `code`, so FastAPI's nested `detail` when the code\n * is there. For a reader of a refusal's EXTRA fields (`isPlanLimit`: `dimension`, `limit`,\n * `used` sit beside the code). `accept` decides which codes count; default, the known ones.\n *\n * @internal Not part of the barrel.\n */\nexport function errorBodyWithCode(\n err: unknown,\n accept: (code: unknown) => boolean = (code) => known(code) !== undefined,\n): Record<string, unknown> | undefined {\n if (!isBag(err)) return undefined;\n const response = err.response;\n for (const body of [isBag(response) ? response.data : undefined, err.data, err.body, err]) {\n if (!isBag(body)) continue;\n if (accept(body.code)) return body;\n if (isBag(body.detail) && accept(body.detail.code)) return body.detail;\n }\n return undefined;\n}\n\n/**\n * The HTTP status a thrown error carries ({@link httpStatusOf}): axios'\n * `response.status`, then `status`, then `statusCode`. Lives in `lib/http-status.ts`\n * since 0.52 (refactor audit 2026-10-30, MOD-6); re-exported here for the modules that\n * import it from auth. Package-private — not re-exported from the barrel.\n */\nexport { httpStatusOf };\n\n/**\n * Whether `err` is a throttled request — HTTP `429 Too Many Requests` (0.30.0, from the\n * apps' 0.29 adoption: every app answered a throttled sign-in, sign-up or reset through\n * its own `describeError`, with three wordings of one sentence).\n *\n * A throttle carries no `code` in the contract — the STATUS is the answer, set by the\n * apps' limiters (server-kit's `AuthLimiters`, keksdose's per-IP limit) — so this reads\n * the status, wherever the apps' HTTP clients put it ({@link httpStatusOf}).\n *\n * There is no `rate_limited` code: keksdose answers its 429s uncoded, with a\n * `Retry-After` header, and the status is the one signal every limiter gives.\n *\n * The kit's `SignInForm`, `RegisterForm`, `ForgotPasswordForm` and `ResetPasswordForm`\n * call it AFTER the app's `describeError` — an app with words of its own keeps them —\n * and before their generic failure, so \"Too many attempts. Try again in 30 s.\" (with\n * {@link retryAfterSeconds}) or \"… Wait a moment and try again.\" needs no app code.\n */\nexport function isRateLimited(err: unknown): boolean {\n return httpStatusOf(err) === 429;\n}\n\n/** A header's value from a `Headers` (fetch, ofetch's `response`), axios' `AxiosHeaders`\n * or a plain record — whose keys may come in any case. */\nfunction headerOf(headers: unknown, name: string): unknown {\n if (!isBag(headers)) return undefined;\n if (typeof headers.get === \"function\") {\n try {\n const value: unknown = (headers.get as (key: string) => unknown).call(headers, name);\n if (value !== undefined && value !== null) return value;\n } catch {\n // A `get` that is not a header lookup; the record below is.\n }\n }\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) return value;\n }\n return undefined;\n}\n\n/** `Retry-After` as seconds from `now`: delta-seconds (\"30\"), or an HTTP date\n * (\"Wed, 07 Oct 2026 10:00:00 GMT\") counted from now, never below 0 (RFC 9110 §10.2.3). */\nfunction parseRetryAfter(value: unknown, now: number): number | undefined {\n const raw = Array.isArray(value) ? (value as unknown[])[0] : value;\n if (typeof raw === \"number\") return Number.isFinite(raw) && raw >= 0 ? Math.ceil(raw) : undefined;\n if (typeof raw !== \"string\") return undefined;\n const text = raw.trim();\n if (/^\\d+$/.test(text)) return Number(text);\n // An HTTP date names its day and month (\"Wed, 07 Oct 2026 …\"). Without a letter it is\n // a malformed number (\"-5\", \"1.5\"), which `Date.parse` would happily read as a year.\n if (!/[a-z]/i.test(text)) return undefined;\n const at = Date.parse(text);\n if (Number.isNaN(at)) return undefined;\n return Math.max(0, Math.ceil((at - now) / 1000));\n}\n\n/**\n * How long a throttled request asks to wait, in whole seconds — its `Retry-After`\n * header (0.30.0, keksdose: its 429s carry no code, only the header) — or `undefined`\n * when there is none, or none that parses.\n *\n * Read where the apps' clients keep the response headers, without depending on any of\n * them: `err.response.headers` (axios' `AxiosHeaders` or a plain record; ofetch's\n * `FetchError.response`, a fetch `Headers`), then `err.headers` (a `Response` thrown as\n * it came). The value is delta-seconds, or an HTTP date turned into seconds from `now`\n * (default: the present moment) — never below 0.\n *\n * The forms hand it to their `rateLimited` label when {@link isRateLimited} is true:\n * \"Too many attempts. Try again in 30 s.\" — and, without one, \"… Wait a moment and try\n * again.\" A browser only exposes `Retry-After` to a cross-origin page when the server\n * lists it in `Access-Control-Expose-Headers`.\n */\nexport function retryAfterSeconds(err: unknown, now: number | Date = Date.now()): number | undefined {\n if (!isBag(err)) return undefined;\n const at = typeof now === \"number\" ? now : now.getTime();\n const response = err.response;\n const value =\n (isBag(response) ? headerOf(response.headers, \"retry-after\") : undefined) ?? headerOf(err.headers, \"retry-after\");\n return value === undefined ? undefined : parseRetryAfter(value, at);\n}\n\n// The English of the `rateLimited` labels, in auth-errors-labels since 0.52: the English\n// catalogue reached this module for them, and with it `lib/http-status` (refactor audit\n// 2026-10-30, MOD-6). Re-exported for the modules that import them from here.\nexport { englishRateLimited, englishWait } from \"./auth-errors-labels\";\n"],"mappings":";AACA,SAAS,oBAAoB;AA2I7B,MAAM,gBAA+C,oBAAI,IAAsB;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,MAAM,QAA6B,oBAAI,IAAkB;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,CAAC;AAID,MAAM,QAAQ,CAAC,UAAiC,OAAO,UAAU,YAAY,UAAU;AAGvF,SAAS,MAAM,OAA0C;AACvD,SAAO,OAAO,UAAU,YAAY,MAAM,IAAI,KAAK,IAAK,QAAyB;AACnF;AAIA,SAA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,QAAO,OAAO,IAAI;AAG1C,MAAI,CAAC,SAAS,KAAK,IAAI,EAAG,QAAO;AACjC,QAAM,KAAK,KAAK,MAAM,IAAI;AAC1B,MAAI,OAAO,MAAM,EAAE,EAAG,QAAO;AAC7B,SAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,OAAO,GAAI,CAAC;AACjD;AAkBO,SAAS,kBAAkB,KAAc,MAAqB,KAAK,IAAI,GAAuB;AACnG,MAAI,CAAC,MAAM,GAAG,EAAG,QAAO;AACxB,QAAM,KAAK,OAAO,QAAQ,WAAW,MAAM,IAAI,QAAQ;AACvD,QAAM,WAAW,IAAI;AACrB,QAAM,SACH,MAAM,QAAQ,IAAI,SAAS,SAAS,SAAS,aAAa,IAAI,WAAc,SAAS,IAAI,SAAS,aAAa;AAClH,SAAO,UAAU,SAAY,SAAY,gBAAgB,OAAO,EAAE;AACpE;AAKA,SAAS,oBAAoB,mBAAmB;","names":[]}
|
|
@@ -69,6 +69,32 @@ export interface BillingLabels {
|
|
|
69
69
|
pickFirst: string;
|
|
70
70
|
/** One word per status. */
|
|
71
71
|
status: Record<SubscriptionStatus, string>;
|
|
72
|
+
/**
|
|
73
|
+
* The subscription's standing in one line, under the plan's name: `SubscriptionStanding`
|
|
74
|
+
* and `subscriptionStanding` say the FIRST that applies, in this order. `date` arrives
|
|
75
|
+
* formatted. The words are keksdose's reviewed ones (`billing.trial_until`, …), which
|
|
76
|
+
* kastlan's page said in words of its own (kastlan reuse audit 2026-11-02, proposal 3).
|
|
77
|
+
*/
|
|
78
|
+
standing: {
|
|
79
|
+
/** Out of good standing (§3.3): the first sentence of {@link BillingLabels.planEnded}
|
|
80
|
+
* and {@link BillingLabels.lockReason}, which the plan-ended banner goes on with —
|
|
81
|
+
* "Your plan has ended." */
|
|
82
|
+
ended: string;
|
|
83
|
+
/** `past_due` while the provider retries (§3.3): still in good standing, and NO date —
|
|
84
|
+
* the payment-failed banner carries the action, and "renews on" would promise what
|
|
85
|
+
* the retries may not keep. */
|
|
86
|
+
pastDue: string;
|
|
87
|
+
/** `trialing`, with its `trial_ends_at`: "Trial until 9 Nov 2026". */
|
|
88
|
+
trialUntil: (date: string) => string;
|
|
89
|
+
/** `comped`, with its `comped_until`: "Free until 9 Nov 2026". */
|
|
90
|
+
freeUntil: (date: string) => string;
|
|
91
|
+
/** `comped` without an end (§12.8): "Free, with no end date". */
|
|
92
|
+
free: string;
|
|
93
|
+
/** Set to cancel at the period's end (`cancel_at_period_end`): "Ends on 9 Nov 2026". */
|
|
94
|
+
endsOn: (date: string) => string;
|
|
95
|
+
/** `active`, at `current_period_end`: "Renews on 9 Nov 2026". */
|
|
96
|
+
renewsOn: (date: string) => string;
|
|
97
|
+
};
|
|
72
98
|
/** A trial ends in `days` calendar days — 0 is today, 1 tomorrow. */
|
|
73
99
|
trialEnding: (days: number) => string;
|
|
74
100
|
/** A free grant (`comped_until`: a beta user's 12 months, an operator's grant) ends in
|
|
@@ -42,6 +42,15 @@ const DEFAULT_BILLING_LABELS = {
|
|
|
42
42
|
expired: "Expired",
|
|
43
43
|
comped: "Complimentary"
|
|
44
44
|
},
|
|
45
|
+
standing: {
|
|
46
|
+
ended: "Your plan has ended.",
|
|
47
|
+
pastDue: "Payment failed \u2014 we\u2019re retrying. Your plan stays active meanwhile.",
|
|
48
|
+
trialUntil: (date) => `Trial until ${date}`,
|
|
49
|
+
freeUntil: (date) => `Free until ${date}`,
|
|
50
|
+
free: "Free, with no end date",
|
|
51
|
+
endsOn: (date) => `Ends on ${date}`,
|
|
52
|
+
renewsOn: (date) => `Renews on ${date}`
|
|
53
|
+
},
|
|
45
54
|
trialEnding: (days) => `Your trial ends ${inDays(days)}. After that you can still view everything, but changes need a plan.`,
|
|
46
55
|
grantEnding: (days) => `Your free access ends ${inDays(days)}. After that you can still view everything, but changes need a plan.`,
|
|
47
56
|
paymentFailed: "Your last payment didn\u2019t go through. Update your payment method to keep your plan.",
|