@eifi1/ui-kit 0.51.7 → 0.52.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 +141 -23
- package/dist/account/account-parts.d.ts +10 -8
- package/dist/account/account-parts.js +1 -18
- package/dist/account/account-parts.js.map +1 -1
- package/dist/account/data-export-setting-labels.js +1 -1
- package/dist/account/data-export-setting-labels.js.map +1 -1
- package/dist/account/delete-account-setting-labels.js +1 -1
- package/dist/account/delete-account-setting-labels.js.map +1 -1
- package/dist/account/email-change-setting-labels.js +1 -1
- package/dist/account/email-change-setting-labels.js.map +1 -1
- package/dist/account/passkeys-setting.d.ts +9 -2
- package/dist/account/passkeys-setting.js +41 -29
- package/dist/account/passkeys-setting.js.map +1 -1
- package/dist/account/sessions-setting.d.ts +3 -2
- package/dist/account/sessions-setting.js +10 -8
- package/dist/account/sessions-setting.js.map +1 -1
- package/dist/admin/admin-action-confirm.js +1 -3
- package/dist/admin/admin-action-confirm.js.map +1 -1
- package/dist/admin/admin-parts.d.ts +6 -3
- package/dist/admin/admin-parts.js +6 -21
- package/dist/admin/admin-parts.js.map +1 -1
- package/dist/admin/mail-test-card-labels.js +1 -1
- package/dist/admin/mail-test-card-labels.js.map +1 -1
- package/dist/admin/plan-change-labels.d.ts +2 -2
- package/dist/admin/plan-change-labels.js +1 -17
- package/dist/admin/plan-change-labels.js.map +1 -1
- package/dist/admin/plan-change.d.ts +3 -42
- package/dist/admin/plan-change.js +1 -1
- package/dist/admin/plan-change.js.map +1 -1
- package/dist/admin/reviewer-scope-editor.js +3 -3
- package/dist/admin/reviewer-scope-editor.js.map +1 -1
- package/dist/auth/auth-errors-labels.d.ts +11 -0
- package/dist/auth/auth-errors-labels.js +13 -0
- package/dist/auth/auth-errors-labels.js.map +1 -0
- package/dist/auth/auth-errors.d.ts +7 -23
- package/dist/auth/auth-errors.js +2 -15
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/auth/complete-name-dialog.js +2 -1
- package/dist/auth/complete-name-dialog.js.map +1 -1
- package/dist/auth/forgot-password-form-labels.js +1 -1
- package/dist/auth/forgot-password-form-labels.js.map +1 -1
- package/dist/auth/forgot-password-form.js +7 -2
- package/dist/auth/forgot-password-form.js.map +1 -1
- package/dist/auth/register-form-labels.js +1 -1
- package/dist/auth/register-form-labels.js.map +1 -1
- package/dist/auth/reset-password-form-labels.js +1 -1
- package/dist/auth/reset-password-form-labels.js.map +1 -1
- package/dist/auth/reset-password-form.js +5 -1
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/sign-in-form-labels.js +1 -1
- package/dist/auth/sign-in-form-labels.js.map +1 -1
- package/dist/auth/status-parts.d.ts +0 -3
- package/dist/auth/status-parts.js +0 -4
- package/dist/auth/status-parts.js.map +1 -1
- package/dist/auth/verify-email-labels.js +1 -1
- package/dist/auth/verify-email-labels.js.map +1 -1
- package/dist/auth/verify-email.js +7 -2
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/billing/cancel-subscription.d.ts +20 -8
- package/dist/billing/cancel-subscription.js +7 -5
- package/dist/billing/cancel-subscription.js.map +1 -1
- package/dist/billing/dialog-close.d.ts +29 -0
- package/dist/billing/dialog-close.js +8 -0
- package/dist/billing/dialog-close.js.map +1 -0
- package/dist/billing/plan-card.d.ts +14 -4
- package/dist/billing/plan-card.js +15 -8
- package/dist/billing/plan-card.js.map +1 -1
- package/dist/billing/plan-change-labels.d.ts +42 -0
- package/dist/billing/plan-change-labels.js +22 -0
- package/dist/billing/plan-change-labels.js.map +1 -0
- package/dist/billing/plan-switch.d.ts +19 -7
- package/dist/billing/plan-switch.js +8 -4
- package/dist/billing/plan-switch.js.map +1 -1
- package/dist/chart.d.ts +12 -0
- package/dist/chart.js +16 -1
- package/dist/chart.js.map +1 -1
- package/dist/components/account-chips.d.ts +5 -5
- package/dist/components/account-chips.js +11 -13
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/alert-banner.d.ts +16 -5
- package/dist/components/alert-banner.js +46 -1
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +13 -0
- package/dist/components/amount-input.js +1 -0
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.js +57 -65
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bulk-action-bar.d.ts +12 -2
- package/dist/components/bulk-action-bar.js +65 -21
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-look.d.ts +5 -5
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js.map +1 -1
- package/dist/components/chart-edge.d.ts +16 -0
- package/dist/components/chart-edge.js +14 -1
- package/dist/components/chart-edge.js.map +1 -1
- package/dist/components/chart-figure.d.ts +13 -0
- package/dist/components/chart-figure.js +15 -0
- package/dist/components/chart-figure.js.map +1 -0
- package/dist/components/chart-zoom-core.js +1 -4
- package/dist/components/chart-zoom-core.js.map +1 -1
- package/dist/components/chart.d.ts +8 -1
- package/dist/components/chart.js +19 -10
- package/dist/components/chart.js.map +1 -1
- package/dist/components/combobox-core.d.ts +111 -2
- package/dist/components/combobox-core.js +148 -42
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/combobox.js +141 -130
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +6 -5
- package/dist/components/copy-button.js +5 -3
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/country-select.js +2 -2
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/data-table-column-settings.d.ts +1 -1
- package/dist/components/data-table-column-settings.js +33 -7
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +4 -2
- package/dist/components/data-table-filters.js +2 -2
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-fit.d.ts +6 -4
- package/dist/components/data-table-fit.js +4 -1
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-groups.d.ts +1 -1
- package/dist/components/data-table-groups.js.map +1 -1
- package/dist/components/data-table-head.d.ts +1 -1
- package/dist/components/data-table-head.js +15 -12
- package/dist/components/data-table-head.js.map +1 -1
- package/dist/components/data-table-mobile.d.ts +12 -7
- package/dist/components/data-table-mobile.js +43 -30
- package/dist/components/data-table-mobile.js.map +1 -1
- package/dist/components/data-table-pagination.js +11 -6
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table-resize.d.ts +1 -1
- package/dist/components/data-table-resize.js.map +1 -1
- package/dist/components/data-table-row-actions.d.ts +2 -2
- package/dist/components/data-table-row-actions.js.map +1 -1
- package/dist/components/data-table-row.d.ts +6 -2
- package/dist/components/data-table-row.js +17 -10
- package/dist/components/data-table-row.js.map +1 -1
- package/dist/components/data-table-selection.d.ts +1 -1
- package/dist/components/data-table-selection.js.map +1 -1
- package/dist/components/data-table-shared.d.ts +10 -2
- package/dist/components/data-table-shared.js +18 -0
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table-sort.d.ts +21 -2
- package/dist/components/data-table-sort.js +24 -0
- package/dist/components/data-table-sort.js.map +1 -1
- package/dist/components/data-table-virtual.d.ts +1 -1
- package/dist/components/data-table-virtual.js +18 -6
- package/dist/components/data-table-virtual.js.map +1 -1
- package/dist/components/data-table.d.ts +13 -4
- package/dist/components/data-table.js +139 -36
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-field.d.ts +24 -2
- package/dist/components/date-field.js +33 -8
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.d.ts +15 -2
- package/dist/components/date-picker.js +55 -26
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.d.ts +47 -20
- package/dist/components/date-range-picker.js +23 -7
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/error-boundary.js +37 -30
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/{ui-labels.d.ts → field-base-labels.d.ts} +0 -2
- package/dist/components/{ui-labels.js → field-base-labels.js} +2 -9
- package/dist/components/field-base-labels.js.map +1 -0
- package/dist/components/field-base.d.ts +4 -3
- package/dist/components/field-base.js +3 -3
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-sync-labels.d.ts +1 -0
- package/dist/components/field-sync-labels.js.map +1 -1
- package/dist/components/field-sync.d.ts +23 -1
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/form-actions.js +11 -5
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/hover-menu.d.ts +3 -0
- package/dist/components/hover-menu.js +5 -3
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-button.js +14 -9
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/inline-confirm.d.ts +43 -0
- package/dist/components/inline-confirm.js +67 -0
- package/dist/components/inline-confirm.js.map +1 -0
- package/dist/components/inline-entity-combobox.d.ts +4 -3
- package/dist/components/inline-entity-combobox.js +148 -140
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/jump-calendar.js +28 -112
- package/dist/components/jump-calendar.js.map +1 -1
- package/dist/components/legal-page.d.ts +3 -1
- package/dist/components/legal-page.js +3 -2
- package/dist/components/legal-page.js.map +1 -1
- package/dist/components/legal.d.ts +4 -2
- package/dist/components/legal.js.map +1 -1
- package/dist/components/lightbox.d.ts +2 -2
- package/dist/components/lightbox.js +17 -6
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/list.d.ts +6 -2
- package/dist/components/list.js +3 -2
- package/dist/components/list.js.map +1 -1
- package/dist/components/measured-grid.d.ts +1 -1
- package/dist/components/measured-grid.js +2 -1
- package/dist/components/measured-grid.js.map +1 -1
- package/dist/components/mini-calendar.js +3 -5
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.js +3 -1
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-grid.d.ts +55 -0
- package/dist/components/month-grid.js +148 -0
- package/dist/components/month-grid.js.map +1 -0
- package/dist/components/month-picker.d.ts +36 -4
- package/dist/components/month-picker.js +123 -146
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-select.d.ts +2 -2
- package/dist/components/multi-select.js +11 -6
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/picker-sheet.js +2 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart-labels.d.ts +7 -0
- package/dist/components/pie-chart-labels.js +1 -0
- package/dist/components/pie-chart-labels.js.map +1 -1
- package/dist/components/pie-chart.d.ts +5 -3
- package/dist/components/pie-chart.js +7 -22
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.d.ts +3 -0
- package/dist/components/popover.js +7 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/row-actions.js +2 -1
- package/dist/components/row-actions.js.map +1 -1
- package/dist/components/section-nav.d.ts +7 -0
- package/dist/components/section-nav.js.map +1 -1
- package/dist/components/series-chart-axes.d.ts +3 -3
- package/dist/components/series-chart-axes.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +7 -4
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +31 -7
- package/dist/components/series-chart.js +72 -29
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/share-card.js +3 -3
- package/dist/components/share-card.js.map +1 -1
- package/dist/components/sign-chip-labels.d.ts +1 -0
- package/dist/components/sign-chip-labels.js.map +1 -1
- package/dist/components/sign-chip.d.ts +10 -1
- package/dist/components/sign-chip.js.map +1 -1
- package/dist/components/tabs-labels.d.ts +2 -0
- package/dist/components/tabs-labels.js +11 -0
- package/dist/components/tabs-labels.js.map +1 -0
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +2 -2
- package/dist/components/toggle-legend.js +6 -6
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/translation-review-editor.d.ts +4 -2
- package/dist/components/translation-review-editor.js +2 -3
- package/dist/components/translation-review-editor.js.map +1 -1
- package/dist/components/translation-review.d.ts +2 -1
- package/dist/components/translation-review.js +2 -2
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/treemap-labels.d.ts +26 -0
- package/dist/components/treemap-labels.js +10 -0
- package/dist/components/treemap-labels.js.map +1 -0
- package/dist/components/treemap-layout.d.ts +62 -0
- package/dist/components/treemap-layout.js +126 -0
- package/dist/components/treemap-layout.js.map +1 -0
- package/dist/components/treemap.d.ts +140 -17
- package/dist/components/treemap.js +324 -97
- package/dist/components/treemap.js.map +1 -1
- package/dist/components/use-table-state.d.ts +5 -5
- package/dist/components/use-table-state.js +4 -1
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/data-table.d.ts +6 -2
- package/dist/data-table.js +7 -2
- package/dist/data-table.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/role-utilities.d.ts +36 -7
- package/dist/eslint/role-utilities.js +42 -9
- package/dist/eslint/role-utilities.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +25 -16
- package/dist/feedback/feedback-dialog.js +6 -2
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-mutation.d.ts +30 -0
- package/dist/feedback/feedback-mutation.js +16 -0
- package/dist/feedback/feedback-mutation.js.map +1 -0
- package/dist/feedback/feedback-page-link.d.ts +53 -0
- package/dist/feedback/feedback-page-link.js +37 -0
- package/dist/feedback/feedback-page-link.js.map +1 -0
- package/dist/feedback/feedback-public-list.d.ts +12 -3
- package/dist/feedback/feedback-public-list.js +2 -1
- package/dist/feedback/feedback-public-list.js.map +1 -1
- package/dist/feedback/feedback-replies.d.ts +3 -1
- package/dist/feedback/feedback-replies.js +5 -4
- package/dist/feedback/feedback-replies.js.map +1 -1
- package/dist/feedback/feedback-row-detail-labels.js +5 -0
- package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +64 -28
- package/dist/feedback/feedback-row-detail.js +30 -28
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-status-undo.d.ts +30 -11
- package/dist/feedback/feedback-status-undo.js +10 -15
- package/dist/feedback/feedback-status-undo.js.map +1 -1
- package/dist/feedback/feedback-submit-dialog.d.ts +1 -1
- package/dist/feedback/feedback-submit-dialog.js +1 -1
- package/dist/feedback/feedback-submit-dialog.js.map +1 -1
- package/dist/feedback/feedback-submit.js +9 -3
- package/dist/feedback/feedback-submit.js.map +1 -1
- package/dist/feedback/feedback-swipe.d.ts +1 -1
- package/dist/feedback/feedback-swipe.js.map +1 -1
- package/dist/feedback/feedback-table.d.ts +21 -9
- package/dist/feedback/feedback-table.js +45 -25
- package/dist/feedback/feedback-table.js.map +1 -1
- package/dist/feedback/feedback-thread-labels.d.ts +2 -2
- package/dist/feedback/feedback-thread-labels.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +24 -23
- package/dist/feedback/feedback-thread.js +2 -1
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/feedback.d.ts +34 -0
- package/dist/feedback.js +42 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-focus-trap.d.ts +35 -0
- package/dist/hooks/use-focus-trap.js +6 -4
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-hotkey.d.ts +5 -2
- package/dist/hooks/use-hotkey.js +5 -4
- package/dist/hooks/use-hotkey.js.map +1 -1
- package/dist/hooks/use-long-press.d.ts +7 -4
- package/dist/hooks/use-long-press.js +3 -0
- package/dist/hooks/use-long-press.js.map +1 -1
- package/dist/hooks/use-media-query.js +12 -4
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-mounted.d.ts +22 -0
- package/dist/hooks/use-mounted.js +24 -0
- package/dist/hooks/use-mounted.js.map +1 -0
- package/dist/hooks/use-overlay-history.js +19 -3
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.js +4 -5
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +7 -1
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +9 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +20 -41
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +7 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +20 -10
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +9 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +7 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +8 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +5 -0
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +64 -17
- package/dist/index.js +77 -12
- package/dist/index.js.map +1 -1
- package/dist/landing/routing.d.ts +3 -1
- package/dist/landing/routing.js +4 -7
- package/dist/landing/routing.js.map +1 -1
- package/dist/lib/broadcast.d.ts +17 -0
- package/dist/lib/broadcast.js +30 -0
- package/dist/lib/broadcast.js.map +1 -0
- package/dist/lib/date-format.d.ts +37 -2
- package/dist/lib/date-format.js +34 -8
- package/dist/lib/date-format.js.map +1 -1
- package/dist/lib/day-format.d.ts +46 -0
- package/dist/lib/day-format.js +46 -0
- package/dist/lib/day-format.js.map +1 -0
- package/dist/lib/describe-failure.d.ts +14 -0
- package/dist/lib/describe-failure.js +9 -0
- package/dist/lib/describe-failure.js.map +1 -0
- package/dist/lib/direction.d.ts +16 -0
- package/dist/lib/direction.js +9 -1
- package/dist/lib/direction.js.map +1 -1
- package/dist/lib/focus-left.d.ts +63 -0
- package/dist/lib/focus-left.js +67 -0
- package/dist/lib/focus-left.js.map +1 -0
- package/dist/lib/format.js +5 -14
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/http-status.d.ts +24 -0
- package/dist/lib/http-status.js +14 -0
- package/dist/lib/http-status.js.map +1 -0
- package/dist/lib/intl-cache.d.ts +14 -0
- package/dist/lib/intl-cache.js +15 -0
- package/dist/lib/intl-cache.js.map +1 -0
- package/dist/lib/isin.d.ts +10 -0
- package/dist/lib/isin.js.map +1 -1
- package/dist/lib/iso-day.d.ts +11 -0
- package/dist/lib/iso-day.js +8 -0
- package/dist/lib/iso-day.js.map +1 -0
- package/dist/lib/lazy-with-fallback.d.ts +31 -0
- package/dist/lib/lazy-with-fallback.js +40 -0
- package/dist/lib/lazy-with-fallback.js.map +1 -0
- package/dist/lib/path-pattern.d.ts +34 -0
- package/dist/lib/path-pattern.js +24 -0
- package/dist/lib/path-pattern.js.map +1 -0
- package/dist/lib/reduced-motion.d.ts +2 -1
- package/dist/lib/reduced-motion.js.map +1 -1
- package/dist/lib/round.d.ts +2 -1
- package/dist/lib/round.js +2 -1
- package/dist/lib/round.js.map +1 -1
- package/dist/lib/safe-storage.d.ts +24 -5
- package/dist/lib/safe-storage.js +27 -2
- package/dist/lib/safe-storage.js.map +1 -1
- package/dist/lib/session-refresh.js +1 -1
- package/dist/lib/session-refresh.js.map +1 -1
- package/dist/lib/share-format.d.ts +13 -0
- package/dist/lib/share-format.js +10 -0
- package/dist/lib/share-format.js.map +1 -0
- package/dist/lib/text-case.d.ts +17 -0
- package/dist/lib/text-case.js +8 -0
- package/dist/lib/text-case.js.map +1 -0
- package/dist/lib/text-match.d.ts +29 -0
- package/dist/lib/text-match.js +20 -2
- package/dist/lib/text-match.js.map +1 -1
- package/dist/lib/thenable.d.ts +13 -0
- package/dist/lib/thenable.js +8 -0
- package/dist/lib/thenable.js.map +1 -0
- package/dist/lib/translation-review.d.ts +7 -2
- package/dist/lib/translation-review.js +4 -4
- package/dist/lib/translation-review.js.map +1 -1
- package/dist/notifications/device-zone-report.js +1 -1
- package/dist/notifications/device-zone-report.js.map +1 -1
- package/dist/notifications/notification-bell.d.ts +2 -1
- package/dist/notifications/notification-bell.js +3 -3
- package/dist/notifications/notification-bell.js.map +1 -1
- package/dist/notifications/notification-inbox.d.ts +10 -6
- package/dist/notifications/notification-inbox.js +26 -48
- package/dist/notifications/notification-inbox.js.map +1 -1
- package/dist/notifications/notification-parts.d.ts +3 -2
- package/dist/notifications/notification-parts.js +1 -3
- package/dist/notifications/notification-parts.js.map +1 -1
- package/dist/notifications/notification-types-setting.js +1 -1
- package/dist/notifications/notification-types-setting.js.map +1 -1
- package/dist/notifications/notifications-labels.d.ts +6 -0
- package/dist/notifications/notifications-labels.js +1 -0
- package/dist/notifications/notifications-labels.js.map +1 -1
- package/dist/notifications/push-device-setting.js +1 -1
- package/dist/notifications/push-device-setting.js.map +1 -1
- package/dist/notifications/push-devices-setting.d.ts +2 -1
- package/dist/notifications/push-devices-setting.js +27 -49
- package/dist/notifications/push-devices-setting.js.map +1 -1
- package/dist/notifications/quiet-hours-setting.d.ts +10 -3
- package/dist/notifications/quiet-hours-setting.js +65 -26
- package/dist/notifications/quiet-hours-setting.js.map +1 -1
- package/dist/notifications/unsubscribe-panel.js +4 -7
- package/dist/notifications/unsubscribe-panel.js.map +1 -1
- package/dist/notifications/use-push-device.d.ts +39 -1
- package/dist/notifications/use-push-device.js +28 -7
- package/dist/notifications/use-push-device.js.map +1 -1
- package/dist/offline/query-persistence.d.ts +3 -1
- package/dist/offline/query-persistence.js +19 -2
- package/dist/offline/query-persistence.js.map +1 -1
- package/dist/rhf/fields.d.ts +11 -4
- package/dist/rhf/fields.js.map +1 -1
- package/dist/search/command-palette.js +1 -1
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.js +19 -9
- package/dist/search/global-search.js.map +1 -1
- package/dist/search/use-command-key.d.ts +12 -1
- package/dist/search/use-command-key.js +3 -12
- package/dist/search/use-command-key.js.map +1 -1
- package/dist/search.d.ts +7 -0
- package/dist/search.js +10 -0
- package/dist/search.js.map +1 -1
- package/dist/settings/use-settings-focus.js +1 -0
- package/dist/settings/use-settings-focus.js.map +1 -1
- package/dist/shell/account-menu-language.d.ts +21 -5
- package/dist/shell/account-menu-language.js +3 -1
- package/dist/shell/account-menu-language.js.map +1 -1
- package/dist/shell/account-menu-text-size.d.ts +26 -9
- package/dist/shell/account-menu-text-size.js +3 -2
- package/dist/shell/account-menu-text-size.js.map +1 -1
- package/dist/shell/dev-menu.js +5 -18
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +7 -0
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/top-bar-actions.d.ts +1 -1
- package/dist/shell/top-bar-actions.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.d.ts +0 -2
- package/dist/shell/top-bar-parts-labels.js +0 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell.d.ts +27 -8
- package/dist/shell.js +28 -7
- package/dist/shell.js.map +1 -1
- package/dist/sync/engine.d.ts +30 -4
- package/dist/sync/engine.js +172 -52
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync.d.ts +6 -2
- package/dist/sync.js +6 -1
- package/dist/sync.js.map +1 -1
- package/dist/testing/css-variables.js +3 -8
- package/dist/testing/css-variables.js.map +1 -1
- package/dist/theme/contrast.d.ts +2 -1
- package/dist/theme/contrast.js +3 -8
- package/dist/theme/contrast.js.map +1 -1
- package/dist/theme/palette-store.js +6 -6
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.js +3 -8
- package/dist/theme/text-size.js.map +1 -1
- package/dist/theme/theme-store.js +3 -6
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/tour/tour-catalogue.d.ts +7 -4
- package/dist/tour/tour-catalogue.js +12 -10
- package/dist/tour/tour-catalogue.js.map +1 -1
- package/dist/tour/tour-dock.d.ts +0 -2
- package/dist/tour/tour-dock.js +0 -2
- package/dist/tour/tour-dock.js.map +1 -1
- package/dist/tour/tour-gates.d.ts +4 -0
- package/dist/tour/tour-gates.js +14 -0
- package/dist/tour/tour-gates.js.map +1 -1
- package/dist/tour/tour-overlay.d.ts +27 -0
- package/dist/tour/tour-overlay.js +741 -0
- package/dist/tour/tour-overlay.js.map +1 -0
- package/dist/tour/tour.d.ts +13 -3
- package/dist/tour/tour.js +59 -781
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour/use-tour-progress.js +1 -1
- package/dist/tour/use-tour-progress.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +5 -1
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +6 -2
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.d.ts +3 -1
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/validation.d.ts +3 -1
- package/dist/wizard/validation.js.map +1 -1
- package/package.json +10 -6
- package/src/account/account-parts.ts +5 -25
- package/src/account/data-export-setting-labels.ts +1 -1
- package/src/account/delete-account-setting-labels.ts +1 -1
- package/src/account/email-change-setting-labels.ts +1 -1
- package/src/account/passkeys-setting.tsx +60 -38
- package/src/account/sessions-setting.tsx +18 -12
- package/src/admin/admin-action-confirm.tsx +1 -5
- package/src/admin/admin-parts.ts +11 -25
- package/src/admin/mail-test-card-labels.ts +1 -1
- package/src/admin/plan-change-labels.ts +5 -23
- package/src/admin/plan-change.tsx +7 -44
- package/src/admin/reviewer-scope-editor.tsx +3 -3
- package/src/auth/auth-errors-labels.ts +23 -0
- package/src/auth/auth-errors.ts +11 -38
- package/src/auth/complete-name-dialog.tsx +4 -1
- package/src/auth/forgot-password-form-labels.ts +1 -1
- package/src/auth/forgot-password-form.tsx +11 -6
- package/src/auth/register-form-labels.ts +1 -1
- package/src/auth/reset-password-form-labels.ts +1 -1
- package/src/auth/reset-password-form.tsx +8 -4
- package/src/auth/sign-in-form-labels.ts +1 -1
- package/src/auth/status-parts.tsx +0 -6
- package/src/auth/verify-email-labels.ts +1 -1
- package/src/auth/verify-email.tsx +11 -6
- package/src/billing/cancel-subscription.tsx +26 -12
- package/src/billing/dialog-close.ts +34 -0
- package/src/billing/plan-card.tsx +36 -11
- package/src/billing/plan-change-labels.ts +66 -0
- package/src/billing/plan-switch.tsx +26 -12
- package/src/chart.ts +21 -3
- package/src/components/account-chips.tsx +20 -23
- package/src/components/alert-banner.tsx +82 -5
- package/src/components/amount-input.tsx +18 -7
- package/src/components/autocomplete.tsx +64 -70
- package/src/components/bulk-action-bar.tsx +70 -2
- package/src/components/button-look.ts +5 -5
- package/src/components/button.tsx +2 -2
- package/src/components/chart-edge.ts +34 -1
- package/src/components/chart-figure.tsx +35 -0
- package/src/components/chart-zoom-core.tsx +6 -5
- package/src/components/chart.tsx +26 -5
- package/src/components/combobox-core.tsx +293 -62
- package/src/components/combobox.tsx +183 -153
- package/src/components/copy-button.tsx +34 -23
- package/src/components/country-select.tsx +16 -11
- package/src/components/data-table-column-settings.tsx +52 -10
- package/src/components/data-table-filters.ts +6 -4
- package/src/components/data-table-fit.ts +19 -5
- package/src/components/data-table-groups.tsx +1 -1
- package/src/components/data-table-head.tsx +32 -22
- package/src/components/data-table-mobile.tsx +61 -26
- package/src/components/data-table-pagination.tsx +21 -6
- package/src/components/data-table-resize.ts +1 -1
- package/src/components/data-table-row-actions.tsx +3 -3
- package/src/components/data-table-row.tsx +25 -14
- package/src/components/data-table-selection.ts +1 -1
- package/src/components/data-table-shared.tsx +33 -1
- package/src/components/data-table-sort.ts +57 -2
- package/src/components/data-table-virtual.ts +32 -8
- package/src/components/data-table.tsx +239 -68
- package/src/components/date-field.tsx +65 -8
- package/src/components/date-picker.tsx +125 -48
- package/src/components/date-range-picker.tsx +82 -31
- package/src/components/error-boundary.tsx +53 -39
- package/src/components/field-base-labels.ts +20 -0
- package/src/components/field-base.tsx +13 -7
- package/src/components/field-sync-labels.ts +1 -0
- package/src/components/field-sync.tsx +23 -1
- package/src/components/form-actions.tsx +20 -5
- package/src/components/hover-menu.tsx +18 -8
- package/src/components/icon-button.tsx +14 -9
- package/src/components/inline-confirm.tsx +116 -0
- package/src/components/inline-entity-combobox.tsx +197 -153
- package/src/components/input.tsx +1 -1
- package/src/components/jump-calendar.tsx +30 -146
- package/src/components/legal-page.tsx +10 -7
- package/src/components/legal.tsx +4 -2
- package/src/components/lightbox.tsx +21 -8
- package/src/components/list.tsx +10 -4
- package/src/components/measured-grid.tsx +8 -4
- package/src/components/mini-calendar.tsx +6 -5
- package/src/components/modal.tsx +6 -1
- package/src/components/month-grid.tsx +229 -0
- package/src/components/month-picker.tsx +192 -200
- package/src/components/multi-select.tsx +21 -9
- package/src/components/picker-sheet.tsx +12 -9
- package/src/components/pie-chart-labels.ts +8 -0
- package/src/components/pie-chart.tsx +22 -28
- package/src/components/popover.tsx +18 -1
- package/src/components/row-actions.tsx +2 -1
- package/src/components/section-nav.tsx +7 -0
- package/src/components/series-chart-axes.ts +3 -3
- package/src/components/series-chart-labels.ts +7 -4
- package/src/components/series-chart.tsx +178 -69
- package/src/components/share-card.tsx +6 -6
- package/src/components/sign-chip-labels.ts +1 -0
- package/src/components/sign-chip.tsx +10 -1
- package/src/components/tabs-labels.ts +13 -0
- package/src/components/tabs.tsx +2 -2
- package/src/components/toggle-legend.tsx +16 -11
- package/src/components/translation-review-editor.tsx +6 -5
- package/src/components/translation-review.tsx +4 -3
- package/src/components/treemap-labels.ts +39 -0
- package/src/components/treemap-layout.ts +210 -0
- package/src/components/treemap.tsx +722 -133
- package/src/components/use-table-state.ts +12 -9
- package/src/data-table.ts +9 -2
- package/src/eslint/role-utilities.ts +97 -19
- package/src/feedback/feedback-dialog.tsx +30 -19
- package/src/feedback/feedback-mutation.ts +41 -0
- package/src/feedback/feedback-page-link.ts +90 -0
- package/src/feedback/feedback-public-list.tsx +17 -5
- package/src/feedback/feedback-replies.tsx +13 -6
- package/src/feedback/feedback-row-detail-labels.ts +5 -0
- package/src/feedback/feedback-row-detail.tsx +103 -67
- package/src/feedback/feedback-status-undo.ts +41 -27
- package/src/feedback/feedback-submit-dialog.tsx +2 -2
- package/src/feedback/feedback-submit.tsx +21 -7
- package/src/feedback/feedback-swipe.tsx +1 -1
- package/src/feedback/feedback-table.tsx +86 -38
- package/src/feedback/feedback-thread-labels.ts +2 -2
- package/src/feedback/feedback-thread.tsx +27 -25
- package/src/feedback.ts +42 -0
- package/src/hooks/use-focus-trap.ts +8 -24
- package/src/hooks/use-hotkey.ts +24 -7
- package/src/hooks/use-long-press.ts +16 -2
- package/src/hooks/use-media-query.ts +20 -4
- package/src/hooks/use-mounted.ts +39 -0
- package/src/hooks/use-overlay-history.ts +32 -3
- package/src/i18n/defaults.ts +4 -5
- package/src/i18n/german.ts +8 -2
- package/src/i18n/kit-labels.tsx +9 -2
- package/src/i18n/locales/es.ts +8 -2
- package/src/i18n/locales/fr.ts +21 -13
- package/src/i18n/locales/hu.ts +10 -2
- package/src/i18n/locales/it.ts +8 -2
- package/src/i18n/locales/zh.ts +9 -2
- package/src/i18n/review.ts +5 -0
- package/src/index.ts +103 -13
- package/src/landing/routing.tsx +14 -10
- package/src/lib/broadcast.ts +52 -0
- package/src/lib/date-format.ts +89 -13
- package/src/lib/day-format.ts +96 -0
- package/src/lib/describe-failure.ts +18 -0
- package/src/lib/direction.ts +39 -0
- package/src/lib/focus-left.ts +156 -0
- package/src/lib/format.ts +5 -17
- package/src/lib/http-status.ts +38 -0
- package/src/lib/intl-cache.ts +25 -0
- package/src/lib/isin.ts +10 -0
- package/src/lib/iso-day.ts +13 -0
- package/src/lib/lazy-with-fallback.ts +82 -0
- package/src/lib/path-pattern.ts +55 -0
- package/src/lib/reduced-motion.ts +2 -1
- package/src/lib/round.ts +7 -2
- package/src/lib/safe-storage.ts +48 -6
- package/src/lib/session-refresh.ts +1 -1
- package/src/lib/share-format.ts +18 -0
- package/src/lib/text-case.ts +19 -0
- package/src/lib/text-match.ts +57 -2
- package/src/lib/thenable.ts +19 -0
- package/src/lib/translation-review.ts +13 -5
- package/src/notifications/device-zone-report.ts +1 -1
- package/src/notifications/notification-bell.tsx +7 -4
- package/src/notifications/notification-inbox.tsx +40 -58
- package/src/notifications/notification-parts.tsx +3 -4
- package/src/notifications/notification-types-setting.tsx +1 -1
- package/src/notifications/notifications-labels.ts +7 -0
- package/src/notifications/push-device-setting.tsx +1 -1
- package/src/notifications/push-devices-setting.tsx +30 -55
- package/src/notifications/quiet-hours-setting.tsx +93 -31
- package/src/notifications/unsubscribe-panel.tsx +4 -7
- package/src/notifications/use-push-device.ts +76 -10
- package/src/offline/query-persistence.ts +35 -3
- package/src/rhf/fields.tsx +11 -4
- package/src/search/command-palette.tsx +2 -4
- package/src/search/global-search.tsx +36 -15
- package/src/search/use-command-key.ts +13 -12
- package/src/search.ts +9 -0
- package/src/settings/use-settings-focus.ts +3 -0
- package/src/shell/account-menu-language.tsx +27 -5
- package/src/shell/account-menu-text-size.tsx +32 -10
- package/src/shell/dev-menu.tsx +7 -21
- package/src/shell/role-switcher.tsx +7 -0
- package/src/shell/top-bar-actions.tsx +1 -1
- package/src/shell/top-bar-parts-labels.ts +0 -3
- package/src/shell.ts +40 -9
- package/src/sync/engine.ts +339 -61
- package/src/sync.ts +8 -1
- package/src/testing/css-variables.ts +8 -9
- package/src/theme/contrast.ts +8 -9
- package/src/theme/palette-store.ts +9 -9
- package/src/theme/text-size.ts +6 -8
- package/src/theme/theme-store.ts +7 -9
- package/src/tour/tour-catalogue.tsx +26 -15
- package/src/tour/tour-dock.ts +0 -2
- package/src/tour/tour-gates.ts +23 -0
- package/src/tour/tour-overlay.tsx +1170 -0
- package/src/tour/tour.tsx +108 -1202
- package/src/tour/use-tour-progress.ts +1 -1
- package/src/wizard/stepper-nav.tsx +3 -1
- package/src/wizard/types.ts +11 -2
- package/src/wizard/use-wizard.ts +2 -1
- package/src/wizard/validation.ts +8 -2
- package/tokens.css +2 -1
- package/dist/components/ui-labels.js.map +0 -1
- package/dist/shell/dev-switchers.d.ts +0 -6
- package/dist/shell/dev-switchers.js +0 -12
- package/dist/shell/dev-switchers.js.map +0 -1
- package/src/components/ui-labels.ts +0 -24
- package/src/shell/dev-switchers.tsx +0 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useKitLocale } from "../i18n/kit-labels.js";
|
|
4
|
+
import { useDayFormatter } from "../lib/day-format.js";
|
|
5
|
+
import { toDate } from "../lib/format.js";
|
|
6
6
|
import { formatPersonName } from "../lib/person-name.js";
|
|
7
7
|
function personLabel(person, locale) {
|
|
8
8
|
if (!person) return "";
|
|
@@ -13,25 +13,10 @@ function usePersonLabel(localeProp) {
|
|
|
13
13
|
return useCallback((person) => personLabel(person, locale), [locale]);
|
|
14
14
|
}
|
|
15
15
|
function useDayText(localeProp) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
return useCallback(
|
|
19
|
-
(value) => {
|
|
20
|
-
const date = toDate(value);
|
|
21
|
-
if (!date) return "";
|
|
22
|
-
const own = fromProvider ? fromProvider(toLocalIso(date), { unit: "day", source: "dateMark", locale, weekday: false }) : "";
|
|
23
|
-
return own || formatDate(date, "medium", { locale });
|
|
24
|
-
},
|
|
25
|
-
[fromProvider, locale]
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function settle(call) {
|
|
29
|
-
try {
|
|
30
|
-
return Promise.resolve(call());
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return Promise.reject(error);
|
|
33
|
-
}
|
|
16
|
+
const day = useDayFormatter(void 0, localeProp);
|
|
17
|
+
return useCallback((value) => toDate(value) ? day(value) : "", [day]);
|
|
34
18
|
}
|
|
19
|
+
import { settle } from "../hooks/use-mounted.js";
|
|
35
20
|
export {
|
|
36
21
|
personLabel,
|
|
37
22
|
settle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/admin-parts.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/admin/admin-parts.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useKitLocale } from \"../i18n/kit-labels\";\nimport { useDayFormatter } from \"../lib/day-format\";\nimport { toDate } from \"../lib/format\";\nimport type { DateInput } from \"../lib/format\";\nimport { formatPersonName } from \"../lib/person-name\";\n\n/**\n * What the admin parts share and do not export (0.30.0). Internal to `src/admin`.\n *\n * @internal\n */\n\n/** A callback that may answer a promise: resolve = done, reject = stay and say why. */\nexport type MaybePromise<T = unknown> = void | Promise<T>;\n\n/** A person as the admin parts show one: the two name parts of the auth contract\n * (§3.2), an older whole `name` as the fallback, and the address. The name parts are\n * read in either spelling — the kit's `first` / `last`, or server-kit's `PersonRef`\n * as it serialises (`first_name` / `last_name`), so an app hands the server's object\n * over as it came (keksdose's and kastlan's 0.30 adoptions mapped one to the other). */\nexport interface AdminPerson {\n id?: string | number | null;\n first?: string | null;\n last?: string | null;\n /** server-kit `PersonRef.first_name`; `first` wins when both are given. */\n first_name?: string | null;\n /** server-kit `PersonRef.last_name`; `last` wins when both are given. */\n last_name?: string | null;\n /** A whole name, for an API that still sends `display_name` only. */\n name?: string | null;\n email?: string | null;\n}\n\n/**\n * The name to say for a person, in the READER's order (auth §3.2,\n * {@link formatPersonName}), else the whole `name`, else the address, else `\"\"`.\n */\nexport function personLabel(person: AdminPerson | null | undefined, locale: string | undefined): string {\n if (!person) return \"\";\n return (\n formatPersonName({ first: person.first ?? person.first_name, last: person.last ?? person.last_name }, locale) ||\n (person.name ?? \"\").trim() ||\n (person.email ?? \"\").trim()\n );\n}\n\n/** {@link personLabel} in the provider's locale. */\nexport function usePersonLabel(localeProp?: string): (person: AdminPerson | null | undefined) => string {\n const locale = useKitLocale(localeProp);\n return useCallback((person) => personLabel(person, locale), [locale]);\n}\n\n/**\n * A day as words in a sentence (\"6 Nov 2026\"): the provider's `formatDate` when the app\n * set one (keksdose K12), asked for no weekday — a date in a sentence carries none — else\n * `Intl`'s medium date, in the provider's locale and `timeZone` (0.52: the kit's one day\n * ladder, `useDayFormatter` — refactor audit 2026-10-30, DUP-2). `\"\"` for no date or one\n * that does not parse: the caller leaves the sentence out.\n */\nexport function useDayText(localeProp?: string): (value: DateInput) => string {\n const day = useDayFormatter(undefined, localeProp);\n return useCallback((value) => (toDate(value) ? day(value) : \"\"), [day]);\n}\n\n/** Call a callback that may throw or answer a promise, as a promise — the kit's one\n * (hooks/use-mounted), not a copy of it (0.52 code review, this file). */\nexport { settle } from \"../hooks/use-mounted\";\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,cAAc;AAEvB,SAAS,wBAAwB;AAiC1B,SAAS,YAAY,QAAwC,QAAoC;AACtG,MAAI,CAAC,OAAQ,QAAO;AACpB,SACE,iBAAiB,EAAE,OAAO,OAAO,SAAS,OAAO,YAAY,MAAM,OAAO,QAAQ,OAAO,UAAU,GAAG,MAAM,MAC3G,OAAO,QAAQ,IAAI,KAAK,MACxB,OAAO,SAAS,IAAI,KAAK;AAE9B;AAGO,SAAS,eAAe,YAAyE;AACtG,QAAM,SAAS,aAAa,UAAU;AACtC,SAAO,YAAY,CAAC,WAAW,YAAY,QAAQ,MAAM,GAAG,CAAC,MAAM,CAAC;AACtE;AASO,SAAS,WAAW,YAAmD;AAC5E,QAAM,MAAM,gBAAgB,QAAW,UAAU;AACjD,SAAO,YAAY,CAAC,UAAW,OAAO,KAAK,IAAI,IAAI,KAAK,IAAI,IAAK,CAAC,GAAG,CAAC;AACxE;AAIA,SAAS,cAAc;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { englishRateLimited } from "../auth/auth-errors.js";
|
|
2
|
+
import { englishRateLimited } from "../auth/auth-errors-labels.js";
|
|
3
3
|
const DEFAULT_MAIL_TEST_CARD_LABELS = {
|
|
4
4
|
title: "Test mail",
|
|
5
5
|
description: "Sends one mail to your own address, through the transport this installation sends all its mail with.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/mail-test-card-labels.ts"],"sourcesContent":["// The English words of ./mail-test-card, in a module with no component code: the English\n// catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one\n// chunk like the other languages (0.34, KS U8). ./mail-test-card re-exports them.\n\nimport { englishRateLimited } from \"../auth/auth-errors\";\nimport type { MailTestCardLabels } from \"./mail-test-card\";\n\n/** docs/admin-harmonization.md §9.2.4, word for word. */\nexport const DEFAULT_MAIL_TEST_CARD_LABELS: MailTestCardLabels = {\n title: \"Test mail\",\n description: \"Sends one mail to your own address, through the transport this installation sends all its mail with.\",\n transport: (backend) => `Transport: ${backend}`,\n action: \"Send a test mail to me\",\n sent: (address) => `Sent to ${address}. Check the inbox.`,\n console: \"The console transport only logs mail; nothing was sent.\",\n failed: \"Could not send. The server log has the provider’s answer.\",\n rateLimited: englishRateLimited,\n keywords: \"test mail email e-mail transport smtp resend console send deliver\",\n};\n"],"mappings":";AAIA,SAAS,0BAA0B;AAI5B,MAAM,gCAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,aAAa;AAAA,EACb,WAAW,CAAC,YAAY,cAAc,OAAO;AAAA,EAC7C,QAAQ;AAAA,EACR,MAAM,CAAC,YAAY,WAAW,OAAO;AAAA,EACrC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,UAAU;AACZ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/mail-test-card-labels.ts"],"sourcesContent":["// The English words of ./mail-test-card, in a module with no component code: the English\n// catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one\n// chunk like the other languages (0.34, KS U8). ./mail-test-card re-exports them.\n\nimport { englishRateLimited } from \"../auth/auth-errors-labels\";\nimport type { MailTestCardLabels } from \"./mail-test-card\";\n\n/** docs/admin-harmonization.md §9.2.4, word for word. */\nexport const DEFAULT_MAIL_TEST_CARD_LABELS: MailTestCardLabels = {\n title: \"Test mail\",\n description: \"Sends one mail to your own address, through the transport this installation sends all its mail with.\",\n transport: (backend) => `Transport: ${backend}`,\n action: \"Send a test mail to me\",\n sent: (address) => `Sent to ${address}. Check the inbox.`,\n console: \"The console transport only logs mail; nothing was sent.\",\n failed: \"Could not send. The server log has the provider’s answer.\",\n rateLimited: englishRateLimited,\n keywords: \"test mail email e-mail transport smtp resend console send deliver\",\n};\n"],"mappings":";AAIA,SAAS,0BAA0B;AAI5B,MAAM,gCAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,aAAa;AAAA,EACb,WAAW,CAAC,YAAY,cAAc,OAAO;AAAA,EAC7C,QAAQ;AAAA,EACR,MAAM,CAAC,YAAY,WAAW,OAAO;AAAA,EACrC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,UAAU;AACZ;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export { DEFAULT_PLAN_CHANGE_LABELS } from "../billing/plan-change-labels.js";
|
|
2
|
+
export type { PlanChangeLabels } from "../billing/plan-change-labels.js";
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
column: "Plan",
|
|
4
|
-
title: "Change plan",
|
|
5
|
-
confirm: "Change plan",
|
|
6
|
-
plan: "Plan",
|
|
7
|
-
current: (plan) => `Current plan: ${plan}`,
|
|
8
|
-
keepsItems: "A smaller plan only blocks creating more; nothing is deleted.",
|
|
9
|
-
until: "Free until",
|
|
10
|
-
untilHint: "Leave empty for no end. A running beta keeps its own end.",
|
|
11
|
-
needsChange: "Pick another plan or an end date.",
|
|
12
|
-
changed: (from, to) => `Plan changed from ${from} to ${to}.`,
|
|
13
|
-
set: (to) => `Plan set to ${to}.`,
|
|
14
|
-
keptBeta: "The beta keeps its end; only the plan changed.",
|
|
15
|
-
untilDone: (date) => `Free until ${date}.`,
|
|
16
|
-
overLimit: "Above the new plan\u2019s limit: nothing is removed, new items are blocked.",
|
|
17
|
-
usageOf: (used, limit, dimension) => `${used} of ${limit} ${dimension}`
|
|
18
|
-
};
|
|
2
|
+
import { DEFAULT_PLAN_CHANGE_LABELS } from "../billing/plan-change-labels.js";
|
|
19
3
|
export {
|
|
20
4
|
DEFAULT_PLAN_CHANGE_LABELS
|
|
21
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/plan-change-labels.ts"],"sourcesContent":["//
|
|
1
|
+
{"version":3,"sources":["../../src/admin/plan-change-labels.ts"],"sourcesContent":["// Moved to billing/plan-change-labels in 0.52 (refactor audit 2026-10-30, MOD-6): the\n// billing and admin folders imported each other through it. Kept so the old path still\n// answers; nothing in the kit imports it any more but the English catalogue.\nexport { DEFAULT_PLAN_CHANGE_LABELS } from \"../billing/plan-change-labels\";\nexport type { PlanChangeLabels } from \"../billing/plan-change-labels\";\n"],"mappings":";AAGA,SAAS,kCAAkC;","names":[]}
|
|
@@ -5,7 +5,8 @@ import type { DataTableColumn } from "../components/data-table.js";
|
|
|
5
5
|
import type { SubscriptionStatus } from "../billing/billing-labels.js";
|
|
6
6
|
import type { AdminActionConfirmValues } from "./admin-action-confirm.js";
|
|
7
7
|
import type { AdminPerson, MaybePromise } from "./admin-parts.js";
|
|
8
|
-
import { DEFAULT_PLAN_CHANGE_LABELS } from "
|
|
8
|
+
import { DEFAULT_PLAN_CHANGE_LABELS } from "../billing/plan-change-labels.js";
|
|
9
|
+
import type { PlanChangeLabels } from "../billing/plan-change-labels.js";
|
|
9
10
|
/**
|
|
10
11
|
* The operator's plan parts (docs/billing-harmonization.md §14.12, decision 27):
|
|
11
12
|
* {@link planColumn} for the roster or the companies list, {@link PlanChangeConfirm}
|
|
@@ -19,47 +20,7 @@ import { DEFAULT_PLAN_CHANGE_LABELS } from "./plan-change-labels.js";
|
|
|
19
20
|
* codes come from `GET /admin/plans` (kastlan `GET /platform/plans`), which answers
|
|
20
21
|
* whatever the billing switch says.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
-
export interface PlanChangeLabels {
|
|
24
|
-
/** The column's header: "Plan". */
|
|
25
|
-
column: string;
|
|
26
|
-
/** The dialog's title: "Change plan". */
|
|
27
|
-
title: string;
|
|
28
|
-
/** Its confirm button: "Change plan". */
|
|
29
|
-
confirm: string;
|
|
30
|
-
/** The plan select's label: "Plan". */
|
|
31
|
-
plan: string;
|
|
32
|
-
/** The line over the select: "Current plan: Free". */
|
|
33
|
-
current: (plan: string) => string;
|
|
34
|
-
/** Under the select — the fact that is not on the button. */
|
|
35
|
-
keepsItems: string;
|
|
36
|
-
/** The end of a free grant's field: "Free until". */
|
|
37
|
-
until: string;
|
|
38
|
-
/** Under it. */
|
|
39
|
-
untilHint: string;
|
|
40
|
-
/** Why the confirm is held while nothing would change. */
|
|
41
|
-
needsChange: string;
|
|
42
|
-
/** The result: the plan moved from one to another. */
|
|
43
|
-
changed: (from: string, to: string) => string;
|
|
44
|
-
/** The result: an account with no plan before, or the same plan again. */
|
|
45
|
-
set: (to: string) => string;
|
|
46
|
-
/** The result: a running beta kept its own end (§12.34); only the plan moved. */
|
|
47
|
-
keptBeta: string;
|
|
48
|
-
/** The result: the grant runs until `date` (formatted). */
|
|
49
|
-
untilDone: (date: string) => string;
|
|
50
|
-
/** The result: the account owns more than the new plan allows. */
|
|
51
|
-
overLimit: string;
|
|
52
|
-
/**
|
|
53
|
-
* The column's usage, spelled out (its tooltip): "1 of 5 budgets". Figures arrive
|
|
54
|
-
* formatted; `dimension` is the app's word, as `usage.label` gives it — since 0.33.1
|
|
55
|
-
* in the form the LIMIT takes when the label gives its plural forms ("1 of 1 budget",
|
|
56
|
-
* "1 of 5 budgets"): in every shipped language the word follows the limit, or heads
|
|
57
|
-
* the line in German, whose `von` would want a dative plural no app form carries
|
|
58
|
-
* ("Budgets: 1 von 5"). An override of yours gets the same word. Since 0.34 the grant
|
|
59
|
-
* dialog's usage line too, when `usage` comes as the column's shape.
|
|
60
|
-
*/
|
|
61
|
-
usageOf: (used: string, limit: string, dimension: string) => string;
|
|
62
|
-
}
|
|
23
|
+
export type { PlanChangeLabels };
|
|
63
24
|
export { DEFAULT_PLAN_CHANGE_LABELS };
|
|
64
25
|
/** What a row's usage is, for the line under its plan: "1/5" — and since 0.34 what
|
|
65
26
|
* {@link PlanChangeConfirm}'s `usage` takes, for the same sentence in the dialog. */
|
|
@@ -13,7 +13,7 @@ import { useBillingLabels } from "../billing/billing-labels.js";
|
|
|
13
13
|
import { SubscriptionStatusChip } from "../billing/subscription-status-chip.js";
|
|
14
14
|
import { AdminActionConfirm } from "./admin-action-confirm.js";
|
|
15
15
|
import { personLabel, useDayText } from "./admin-parts.js";
|
|
16
|
-
import { DEFAULT_PLAN_CHANGE_LABELS } from "
|
|
16
|
+
import { DEFAULT_PLAN_CHANGE_LABELS } from "../billing/plan-change-labels.js";
|
|
17
17
|
function codeOf(raw) {
|
|
18
18
|
const code = (raw ?? "").trim().toLowerCase();
|
|
19
19
|
return code === "" ? null : code;
|
|
@@ -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 \"./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 `planChange` namespace: the column, the grant dialog and the result's lines. */\nexport interface PlanChangeLabels {\n /** The column's header: \"Plan\". */\n column: string;\n /** The dialog's title: \"Change plan\". */\n title: string;\n /** Its confirm button: \"Change plan\". */\n confirm: string;\n /** The plan select's label: \"Plan\". */\n plan: string;\n /** The line over the select: \"Current plan: Free\". */\n current: (plan: string) => string;\n /** Under the select — the fact that is not on the button. */\n keepsItems: string;\n /** The end of a free grant's field: \"Free until\". */\n until: string;\n /** Under it. */\n untilHint: string;\n /** Why the confirm is held while nothing would change. */\n needsChange: string;\n /** The result: the plan moved from one to another. */\n changed: (from: string, to: string) => string;\n /** The result: an account with no plan before, or the same plan again. */\n set: (to: string) => string;\n /** The result: a running beta kept its own end (§12.34); only the plan moved. */\n keptBeta: string;\n /** The result: the grant runs until `date` (formatted). */\n untilDone: (date: string) => string;\n /** The result: the account owns more than the new plan allows. */\n overLimit: string;\n /**\n * The column's usage, spelled out (its tooltip): \"1 of 5 budgets\". Figures arrive\n * formatted; `dimension` is the app's word, as `usage.label` gives it — since 0.33.1\n * in the form the LIMIT takes when the label gives its plural forms (\"1 of 1 budget\",\n * \"1 of 5 budgets\"): in every shipped language the word follows the limit, or heads\n * the line in German, whose `von` would want a dative plural no app form carries\n * (\"Budgets: 1 von 5\"). An override of yours gets the same word. Since 0.34 the grant\n * dialog's usage line too, when `usage` comes as the column's shape.\n */\n usageOf: (used: string, limit: string, dimension: string) => string;\n}\n\n// Defined in ./plan-change-labels, which holds no component code (0.34, KS U8).\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":";AA8KM,SACE,KADF;AA9KN,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;AA+D3C,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,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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 { 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,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,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AACD,QAAM,SAAS,aAAa;AAC5B,QAAM,SAAS,CAAC,UAAkB,aAAa,OAAO,EAAE,OAAO,CAAC;AAChE,SACE,qBAAC,SAAI,WAAU,qBAAoB,aAAW,QAAQ,QACpD;AAAA,yBAAC,SAAI,WAAU,6BACb;AAAA,0BAAC,UAAK,WAAW,OAAO,gBAAgB,cAAe,gBAAK;AAAA,MAE3D,WAAW,UAAa,oBAAC,0BAAuB,Q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AU,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":[]}
|
|
@@ -7,6 +7,7 @@ import { AlertBanner } from "../components/alert-banner.js";
|
|
|
7
7
|
import { CheckboxGroup } from "../components/checkbox-group.js";
|
|
8
8
|
import { FormActions } from "../components/form-actions.js";
|
|
9
9
|
import { Caption } from "../components/text.js";
|
|
10
|
+
import { describeFailure } from "../lib/describe-failure.js";
|
|
10
11
|
import { hasContent } from "../lib/presence.js";
|
|
11
12
|
import { DEFAULT_REVIEWER_SCOPE_LABELS } from "./reviewer-scope-editor-labels.js";
|
|
12
13
|
function languageOptions(languages) {
|
|
@@ -63,7 +64,7 @@ function ReviewerScopeEditor({
|
|
|
63
64
|
try {
|
|
64
65
|
result = onSave(scope);
|
|
65
66
|
} catch (error) {
|
|
66
|
-
setFailure(describeError?.(error)
|
|
67
|
+
setFailure(describeFailure(describeError?.(error), labels.failed));
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
if (!result || typeof result.then !== "function") return;
|
|
@@ -72,8 +73,7 @@ function ReviewerScopeEditor({
|
|
|
72
73
|
() => setPending(false),
|
|
73
74
|
(error) => {
|
|
74
75
|
setPending(false);
|
|
75
|
-
|
|
76
|
-
setFailure(hasContent(own) ? own : labels.failed);
|
|
76
|
+
setFailure(describeFailure(describeError?.(error), labels.failed));
|
|
77
77
|
}
|
|
78
78
|
);
|
|
79
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/reviewer-scope-editor.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { KIT_LANGUAGES } from \"../i18n/languages\";\nimport type { KitLanguageCode } from \"../i18n/languages\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { CheckboxGroup } from \"../components/checkbox-group\";\nimport type { CheckboxGroupOption } from \"../components/checkbox-group\";\nimport { FormActions } from \"../components/form-actions\";\nimport { Caption } from \"../components/text\";\nimport { hasContent } from \"../lib/presence\";\nimport type { MaybePromise } from \"./admin-parts\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { DEFAULT_REVIEWER_SCOPE_LABELS } from \"./reviewer-scope-editor-labels\";\n\n/**\n * Who may review which translations: the REVIEWER role and its scope, in one editor\n * (docs/user-admin-harmonization.md §4.1 `PUT /admin/users/{id}/reviewer {locales, areas}`,\n * §7). It replaces three: keksdose's `user-reviewer-role.tsx` (a checkbox per language,\n * saved on each click), Kurvenschmiede's `reviewer-dialog.tsx` (a `CheckboxGroup` in a\n * dialog with Save) and kastlan's platform column.\n *\n * - **Languages** are the scope. Ticking none takes the role away — that is how both\n * apps remove a reviewer — and the editor says so under the boxes.\n * - **Areas** narrow it: \"Only the legal pages\" (Imprint, Privacy Policy, Terms) for a\n * lawyer, who reads law, not French. An area only means something beside at least one\n * language, so the areas wait for one. Saved as `areas: null` when none is ticked —\n * server-kit's \"every area\" — never `[]`, which would be \"no area at all\".\n *\n * A draft with Save, not a save per click: keksdose saved every tick, and two quick ticks\n * could land as a set nobody chose; one Save sends the whole scope, in the languages'\n * order (CheckboxGroup's), so the answer equals the request and the row does not\n * reshuffle on refetch. The server keeps its rules (an admin reviews everything already,\n * a customer is not given the role): `disabledReason` says them here.\n */\n\n/** A reviewer's scope — the request body of `PUT …/reviewer`. */\nexport interface ReviewerScope {\n /** Language codes, in the editor's order. Empty: not a reviewer. */\n locales: string[];\n /** The areas the scope is narrowed to; `null` = every area (server-kit's rule). */\n areas: string[] | null;\n}\n\n/** One area the scope can be narrowed to. */\nexport interface ReviewerScopeArea {\n value: string;\n label: ReactNode;\n hint?: ReactNode;\n}\n\n/** One language the editor offers, when the app's list is not the kit's codes. */\nexport interface ReviewerScopeLanguage {\n value: string;\n label: ReactNode;\n}\n\n/** The `reviewerScope` namespace. */\nexport interface ReviewerScopeLabels {\n /** The language group's legend. */\n languages: string;\n /** Under the languages. */\n hint: string;\n /** Under the languages while none is ticked. */\n none: string;\n /** The area group's legend. */\n areas: string;\n /** The default area, `legal`. */\n legalOnly: string;\n legalOnlyHint: string;\n /** A rejected save, unless `describeError` says better. */\n failed: string;\n}\n\n// Defined in ./reviewer-scope-editor-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_REVIEWER_SCOPE_LABELS };\n\nexport interface ReviewerScopeEditorProps {\n /** The scope the server has — the draft starts from it. Key the editor by the\n * account (`key={user.id}`) so another account starts a fresh draft. */\n value: { locales?: readonly string[] | null; areas?: readonly string[] | null };\n /** Sends the scope. A promise keeps the editor busy, and a rejection keeps the draft\n * and shows why. */\n onSave: (scope: ReviewerScope) => MaybePromise;\n /** A Cancel beside Save — a dialog's way out. */\n onCancel?: () => void;\n /**\n * The languages offered: kit codes (named by the kit's registry, each in its own\n * language — \"Deutsch\", \"Français\") or the app's own `{ value, label }` rows. Default:\n * all seven of the kit's.\n */\n languages?: readonly KitLanguageCode[] | readonly ReviewerScopeLanguage[];\n /** The areas the scope can be narrowed to. Default: `legal` alone. `[]` for none. */\n areas?: readonly ReviewerScopeArea[];\n /** Why the scope cannot be changed for this account (\"Administrators review every\n * language already\"). Every box says it; there is no Save. */\n disabledReason?: ReactNode;\n /** The app's words for a failed save. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** Over the languages: what the role is, in the app's words. */\n intro?: ReactNode;\n /** Columns for the languages from `sm` up. Default 2 (Kurvenschmiede's dialog). */\n columns?: 1 | 2 | 3 | 4;\n /** Save COMMITS: under a locked `WriteLockProvider` it is held with the lock's reason. */\n commit?: CommitScope;\n labels?: LabelOverride<ReviewerScopeLabels>;\n}\n\nfunction languageOptions(languages: ReviewerScopeEditorProps[\"languages\"]): CheckboxGroupOption[] {\n const rows = languages ?? KIT_LANGUAGES.map((language) => language.code);\n return rows.map((row) => {\n if (typeof row !== \"string\") return { value: row.value, label: row.label };\n const language = KIT_LANGUAGES.find((entry) => entry.code === row);\n return {\n value: row,\n // Each name in its own language, marked so a screen reader says it so.\n label: language ? <span lang={language.formatLocale}>{language.nativeName}</span> : row,\n };\n });\n}\n\n/** The same set, regardless of order. */\nfunction sameSet(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const seen = new Set(a);\n return b.every((x) => seen.has(x));\n}\n\nexport function ReviewerScopeEditor({\n value,\n onSave,\n onCancel,\n languages,\n areas: areasProp,\n disabledReason,\n describeError,\n intro,\n columns = 2,\n commit,\n labels: labelsProp,\n}: ReviewerScopeEditorProps) {\n const labels = useKitLabels(\"reviewerScope\", DEFAULT_REVIEWER_SCOPE_LABELS, labelsProp);\n const areaOptions: readonly ReviewerScopeArea[] = areasProp ?? [\n { value: \"legal\", label: labels.legalOnly, hint: labels.legalOnlyHint },\n ];\n const savedLocales = [...(value.locales ?? [])];\n const savedAreas = [...(value.areas ?? [])];\n const [locales, setLocales] = useState<string[]>(savedLocales);\n const [areas, setAreas] = useState<string[]>(savedAreas);\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const locked = hasContent(disabledReason);\n\n const nextAreas = locales.length === 0 ? [] : areas;\n const dirty = !sameSet(locales, savedLocales) || !sameSet(nextAreas, locales.length === 0 ? [] : savedAreas);\n\n const save = () => {\n if (pending || locked || !dirty) return;\n const scope: ReviewerScope = {\n locales,\n areas: locales.length > 0 && areas.length > 0 ? areas : null,\n };\n setFailure(null);\n let result: MaybePromise;\n try {\n result = onSave(scope);\n } catch (error) {\n setFailure(describeError?.(error) ?? labels.failed);\n return;\n }\n if (!result || typeof result.then !== \"function\") return;\n setPending(true);\n result.then(\n () => setPending(false),\n (error: unknown) => {\n setPending(false);\n const own = describeError?.(error);\n setFailure(hasContent(own) ? own : labels.failed);\n },\n );\n };\n\n return (\n <div className=\"space-y-3\">\n {intro && <div className=\"text-sm text-secondary\">{intro}</div>}\n <CheckboxGroup\n legend={labels.languages}\n options={languageOptions(languages)}\n value={locales}\n onChange={(next) => {\n setFailure(null);\n setLocales(next);\n }}\n columns={columns}\n hint={locked ? undefined : locales.length === 0 ? labels.none : labels.hint}\n disabledReason={disabledReason}\n />\n {areaOptions.length > 0 && (\n <CheckboxGroup\n legend={labels.areas}\n options={areaOptions.map((area) => ({ value: area.value, label: area.label, hint: area.hint }))}\n value={nextAreas}\n onChange={(next) => {\n setFailure(null);\n setAreas(next);\n }}\n // An area narrows a language scope; with no language there is none to narrow.\n disabled={locales.length === 0}\n disabledReason={disabledReason}\n />\n )}\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure}\n </AlertBanner>\n )}\n {locked ? (\n <Caption>{disabledReason}</Caption>\n ) : (\n <FormActions onSubmit={save} onCancel={onCancel} pending={pending} submitDisabled={!dirty} commit={commit} />\n )}\n </div>\n );\n}\n"],"mappings":";AAoHwB,cAmEpB,YAnEoB;AApHxB,SAAS,gBAAgB;AAEzB,SAAS,oBAAwC;AACjD,SAAS,qBAAqB;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAG3B,SAAS,qCAAqC;AA+F9C,SAAS,gBAAgB,WAAyE;AAChG,QAAM,OAAO,aAAa,cAAc,IAAI,CAAC,aAAa,SAAS,IAAI;AACvE,SAAO,KAAK,IAAI,CAAC,QAAQ;AACvB,QAAI,OAAO,QAAQ,SAAU,QAAO,EAAE,OAAO,IAAI,OAAO,OAAO,IAAI,MAA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AAAA,QAC7B;AAAA;AAAA,IACF;AAAA,IAED,WACC,oBAAC,eAAY,MAAK,UAAS,MAAK,MAC7B,mBACH;AAAA,IAED,SACC,oBAAC,WAAS,0BAAe,IAEzB,oBAAC,eAAY,UAAU,MAAM,UAAoB,SAAkB,gBAAgB,CAAC,OAAO,QAAgB;AAAA,KAE/G;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/reviewer-scope-editor.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { KIT_LANGUAGES } from \"../i18n/languages\";\nimport type { KitLanguageCode } from \"../i18n/languages\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { CheckboxGroup } from \"../components/checkbox-group\";\nimport type { CheckboxGroupOption } from \"../components/checkbox-group\";\nimport { FormActions } from \"../components/form-actions\";\nimport { Caption } from \"../components/text\";\nimport { describeFailure } from \"../lib/describe-failure\";\nimport { hasContent } from \"../lib/presence\";\nimport type { MaybePromise } from \"./admin-parts\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { DEFAULT_REVIEWER_SCOPE_LABELS } from \"./reviewer-scope-editor-labels\";\n\n/**\n * Who may review which translations: the REVIEWER role and its scope, in one editor\n * (docs/user-admin-harmonization.md §4.1 `PUT /admin/users/{id}/reviewer {locales, areas}`,\n * §7). It replaces three: keksdose's `user-reviewer-role.tsx` (a checkbox per language,\n * saved on each click), Kurvenschmiede's `reviewer-dialog.tsx` (a `CheckboxGroup` in a\n * dialog with Save) and kastlan's platform column.\n *\n * - **Languages** are the scope. Ticking none takes the role away — that is how both\n * apps remove a reviewer — and the editor says so under the boxes.\n * - **Areas** narrow it: \"Only the legal pages\" (Imprint, Privacy Policy, Terms) for a\n * lawyer, who reads law, not French. An area only means something beside at least one\n * language, so the areas wait for one. Saved as `areas: null` when none is ticked —\n * server-kit's \"every area\" — never `[]`, which would be \"no area at all\".\n *\n * A draft with Save, not a save per click: keksdose saved every tick, and two quick ticks\n * could land as a set nobody chose; one Save sends the whole scope, in the languages'\n * order (CheckboxGroup's), so the answer equals the request and the row does not\n * reshuffle on refetch. The server keeps its rules (an admin reviews everything already,\n * a customer is not given the role): `disabledReason` says them here.\n */\n\n/** A reviewer's scope — the request body of `PUT …/reviewer`. */\nexport interface ReviewerScope {\n /** Language codes, in the editor's order. Empty: not a reviewer. */\n locales: string[];\n /** The areas the scope is narrowed to; `null` = every area (server-kit's rule). */\n areas: string[] | null;\n}\n\n/** One area the scope can be narrowed to. */\nexport interface ReviewerScopeArea {\n value: string;\n label: ReactNode;\n hint?: ReactNode;\n}\n\n/** One language the editor offers, when the app's list is not the kit's codes. */\nexport interface ReviewerScopeLanguage {\n value: string;\n label: ReactNode;\n}\n\n/** The `reviewerScope` namespace. */\nexport interface ReviewerScopeLabels {\n /** The language group's legend. */\n languages: string;\n /** Under the languages. */\n hint: string;\n /** Under the languages while none is ticked. */\n none: string;\n /** The area group's legend. */\n areas: string;\n /** The default area, `legal`. */\n legalOnly: string;\n legalOnlyHint: string;\n /** A rejected save, unless `describeError` says better. */\n failed: string;\n}\n\n// Defined in ./reviewer-scope-editor-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_REVIEWER_SCOPE_LABELS };\n\nexport interface ReviewerScopeEditorProps {\n /** The scope the server has — the draft starts from it. Key the editor by the\n * account (`key={user.id}`) so another account starts a fresh draft. */\n value: { locales?: readonly string[] | null; areas?: readonly string[] | null };\n /** Sends the scope. A promise keeps the editor busy, and a rejection keeps the draft\n * and shows why. */\n onSave: (scope: ReviewerScope) => MaybePromise;\n /** A Cancel beside Save — a dialog's way out. */\n onCancel?: () => void;\n /**\n * The languages offered: kit codes (named by the kit's registry, each in its own\n * language — \"Deutsch\", \"Français\") or the app's own `{ value, label }` rows. Default:\n * all seven of the kit's.\n */\n languages?: readonly KitLanguageCode[] | readonly ReviewerScopeLanguage[];\n /** The areas the scope can be narrowed to. Default: `legal` alone. `[]` for none. */\n areas?: readonly ReviewerScopeArea[];\n /** Why the scope cannot be changed for this account (\"Administrators review every\n * language already\"). Every box says it; there is no Save. */\n disabledReason?: ReactNode;\n /** The app's words for a failed save. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /** Over the languages: what the role is, in the app's words. */\n intro?: ReactNode;\n /** Columns for the languages from `sm` up. Default 2 (Kurvenschmiede's dialog). */\n columns?: 1 | 2 | 3 | 4;\n /** Save COMMITS: under a locked `WriteLockProvider` it is held with the lock's reason. */\n commit?: CommitScope;\n labels?: LabelOverride<ReviewerScopeLabels>;\n}\n\nfunction languageOptions(languages: ReviewerScopeEditorProps[\"languages\"]): CheckboxGroupOption[] {\n const rows = languages ?? KIT_LANGUAGES.map((language) => language.code);\n return rows.map((row) => {\n if (typeof row !== \"string\") return { value: row.value, label: row.label };\n const language = KIT_LANGUAGES.find((entry) => entry.code === row);\n return {\n value: row,\n // Each name in its own language, marked so a screen reader says it so.\n label: language ? <span lang={language.formatLocale}>{language.nativeName}</span> : row,\n };\n });\n}\n\n/** The same set, regardless of order. */\nfunction sameSet(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const seen = new Set(a);\n return b.every((x) => seen.has(x));\n}\n\nexport function ReviewerScopeEditor({\n value,\n onSave,\n onCancel,\n languages,\n areas: areasProp,\n disabledReason,\n describeError,\n intro,\n columns = 2,\n commit,\n labels: labelsProp,\n}: ReviewerScopeEditorProps) {\n const labels = useKitLabels(\"reviewerScope\", DEFAULT_REVIEWER_SCOPE_LABELS, labelsProp);\n const areaOptions: readonly ReviewerScopeArea[] = areasProp ?? [\n { value: \"legal\", label: labels.legalOnly, hint: labels.legalOnlyHint },\n ];\n const savedLocales = [...(value.locales ?? [])];\n const savedAreas = [...(value.areas ?? [])];\n const [locales, setLocales] = useState<string[]>(savedLocales);\n const [areas, setAreas] = useState<string[]>(savedAreas);\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const locked = hasContent(disabledReason);\n\n const nextAreas = locales.length === 0 ? [] : areas;\n const dirty = !sameSet(locales, savedLocales) || !sameSet(nextAreas, locales.length === 0 ? [] : savedAreas);\n\n const save = () => {\n if (pending || locked || !dirty) return;\n const scope: ReviewerScope = {\n locales,\n areas: locales.length > 0 && areas.length > 0 ? areas : null,\n };\n setFailure(null);\n let result: MaybePromise;\n try {\n result = onSave(scope);\n } catch (error) {\n setFailure(describeFailure(describeError?.(error), labels.failed));\n return;\n }\n if (!result || typeof result.then !== \"function\") return;\n setPending(true);\n result.then(\n () => setPending(false),\n (error: unknown) => {\n setPending(false);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n },\n );\n };\n\n return (\n <div className=\"space-y-3\">\n {intro && <div className=\"text-sm text-secondary\">{intro}</div>}\n <CheckboxGroup\n legend={labels.languages}\n options={languageOptions(languages)}\n value={locales}\n onChange={(next) => {\n setFailure(null);\n setLocales(next);\n }}\n columns={columns}\n hint={locked ? undefined : locales.length === 0 ? labels.none : labels.hint}\n disabledReason={disabledReason}\n />\n {areaOptions.length > 0 && (\n <CheckboxGroup\n legend={labels.areas}\n options={areaOptions.map((area) => ({ value: area.value, label: area.label, hint: area.hint }))}\n value={nextAreas}\n onChange={(next) => {\n setFailure(null);\n setAreas(next);\n }}\n // An area narrows a language scope; with no language there is none to narrow.\n disabled={locales.length === 0}\n disabledReason={disabledReason}\n />\n )}\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\">\n {failure}\n </AlertBanner>\n )}\n {locked ? (\n <Caption>{disabledReason}</Caption>\n ) : (\n <FormActions onSubmit={save} onCancel={onCancel} pending={pending} submitDisabled={!dirty} commit={commit} />\n )}\n </div>\n );\n}\n"],"mappings":";AAqHwB,cAkEpB,YAlEoB;AArHxB,SAAS,gBAAgB;AAEzB,SAAS,oBAAwC;AACjD,SAAS,qBAAqB;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS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,QAAQ,OAAO;AAAA,QACf,SAAS,YAAY,IAAI,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,OAAO,KAAK,OAAO,MAAM,KAAK,KAAK,EAAE;AAAA,QAC9F,OAAO;AAAA,QACP,UAAU,CAAC,SAAS;AAClB,qBAAW,IAAI;AACf,mBAAS,IAAI;AAAA,QACf;AAAA,QAEA,UAAU,QAAQ,WAAW;AAAA,QAC7B;AAAA;AAAA,IACF;AAAA,IAED,WACC,oBAAC,eAAY,MAAK,UAAS,MAAK,MAC7B,mBACH;AAAA,IAED,SACC,oBAAC,WAAS,0BAAe,IAEzB,oBAAC,eAAY,UAAU,MAAM,UAAoB,SAAkB,gBAAgB,CAAC,OAAO,QAAgB;AAAA,KAE/G;AAEJ;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The English of every `rateLimited` label (0.30.0): "Too many attempts. Try again in
|
|
3
|
+
* 30 s." with a wait under a minute, in whole minutes from one minute up (keksdose's
|
|
4
|
+
* reset throttle answers in hours, and "3600 s" is a number nobody reads), and "Wait a
|
|
5
|
+
* moment and try again." without one — or with a `0`.
|
|
6
|
+
*
|
|
7
|
+
* @internal The namespaces' English; not part of the barrel.
|
|
8
|
+
*/
|
|
9
|
+
export declare function englishRateLimited(seconds?: number): string;
|
|
10
|
+
/** "30 s", "2 min" — a wait in English, rounded up. @internal */
|
|
11
|
+
export declare function englishWait(seconds: number): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function englishRateLimited(seconds) {
|
|
3
|
+
if (!seconds || seconds <= 0) return "Too many attempts. Wait a moment and try again.";
|
|
4
|
+
return `Too many attempts. Try again in ${englishWait(seconds)}.`;
|
|
5
|
+
}
|
|
6
|
+
function englishWait(seconds) {
|
|
7
|
+
return seconds < 60 ? `${Math.ceil(seconds)} s` : `${Math.ceil(seconds / 60)} min`;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
englishRateLimited,
|
|
11
|
+
englishWait
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=auth-errors-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/auth-errors-labels.ts"],"sourcesContent":["// The English of every `rateLimited` label, in a module with no component code and no\n// error probing: the English catalogue (src/i18n/defaults.ts) reaches it through nine\n// `*-labels.ts` modules, and until 0.52 that pulled `auth/auth-errors` — and since MOD-6\n// its `lib/http-status` — into the `en` chunk (refactor audit 2026-10-30, MOD-6).\n// auth/auth-errors re-exports both.\n\n/**\n * The English of every `rateLimited` label (0.30.0): \"Too many attempts. Try again in\n * 30 s.\" with a wait under a minute, in whole minutes from one minute up (keksdose's\n * reset throttle answers in hours, and \"3600 s\" is a number nobody reads), and \"Wait a\n * moment and try again.\" without one — or with a `0`.\n *\n * @internal The namespaces' English; not part of the barrel.\n */\nexport function englishRateLimited(seconds?: number): string {\n if (!seconds || seconds <= 0) return \"Too many attempts. Wait a moment and try again.\";\n return `Too many attempts. Try again in ${englishWait(seconds)}.`;\n}\n\n/** \"30 s\", \"2 min\" — a wait in English, rounded up. @internal */\nexport function englishWait(seconds: number): string {\n return seconds < 60 ? `${Math.ceil(seconds)} s` : `${Math.ceil(seconds / 60)} min`;\n}\n"],"mappings":";AAcO,SAAS,mBAAmB,SAA0B;AAC3D,MAAI,CAAC,WAAW,WAAW,EAAG,QAAO;AACrC,SAAO,mCAAmC,YAAY,OAAO,CAAC;AAChE;AAGO,SAAS,YAAY,SAAyB;AACnD,SAAO,UAAU,KAAK,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,KAAK,KAAK,UAAU,EAAE,CAAC;AAC9E;","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { httpStatusOf } from "../lib/http-status.js";
|
|
1
2
|
/**
|
|
2
3
|
* The coded refusals of sign-in and sign-up (docs/auth-harmonization.md §5.2): every
|
|
3
4
|
* refusal the auth routes answer carries a machine-readable `code`, and the pages
|
|
@@ -158,19 +159,12 @@ export declare function isBillingError(err: unknown, code?: BillingErrorCode): b
|
|
|
158
159
|
*/
|
|
159
160
|
export declare function errorBodyWithCode(err: unknown, accept?: (code: unknown) => boolean): Record<string, unknown> | undefined;
|
|
160
161
|
/**
|
|
161
|
-
* The HTTP status a thrown error carries
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* 2. `err.status` — ofetch's `FetchError`, the generated OpenAPI clients' `ApiError`, and
|
|
166
|
-
* a `Response` thrown as it came;
|
|
167
|
-
* 3. `err.statusCode` — ofetch's alias, and Node-style errors.
|
|
168
|
-
*
|
|
169
|
-
* `undefined` when none is a whole number. Package-private — not re-exported from the
|
|
170
|
-
* barrel; {@link isRateLimited} and the session refresh's classifier read it (DUP-11,
|
|
171
|
-
* refactor audit 2026-10: the refresh carried its own copy of this probe).
|
|
162
|
+
* The HTTP status a thrown error carries ({@link httpStatusOf}): axios'
|
|
163
|
+
* `response.status`, then `status`, then `statusCode`. Lives in `lib/http-status.ts`
|
|
164
|
+
* since 0.52 (refactor audit 2026-10-30, MOD-6); re-exported here for the modules that
|
|
165
|
+
* import it from auth. Package-private — not re-exported from the barrel.
|
|
172
166
|
*/
|
|
173
|
-
export
|
|
167
|
+
export { httpStatusOf };
|
|
174
168
|
/**
|
|
175
169
|
* Whether `err` is a throttled request — HTTP `429 Too Many Requests` (0.30.0, from the
|
|
176
170
|
* apps' 0.29 adoption: every app answered a throttled sign-in, sign-up or reset through
|
|
@@ -206,14 +200,4 @@ export declare function isRateLimited(err: unknown): boolean;
|
|
|
206
200
|
* lists it in `Access-Control-Expose-Headers`.
|
|
207
201
|
*/
|
|
208
202
|
export declare function retryAfterSeconds(err: unknown, now?: number | Date): number | undefined;
|
|
209
|
-
|
|
210
|
-
* The English of every `rateLimited` label (0.30.0): "Too many attempts. Try again in
|
|
211
|
-
* 30 s." with a wait under a minute, in whole minutes from one minute up (keksdose's
|
|
212
|
-
* reset throttle answers in hours, and "3600 s" is a number nobody reads), and "Wait a
|
|
213
|
-
* moment and try again." without one — or with a `0`.
|
|
214
|
-
*
|
|
215
|
-
* @internal The namespaces' English; not part of the barrel.
|
|
216
|
-
*/
|
|
217
|
-
export declare function englishRateLimited(seconds?: number): string;
|
|
218
|
-
/** "30 s", "2 min" — a wait in English, rounded up. @internal */
|
|
219
|
-
export declare function englishWait(seconds: number): string;
|
|
203
|
+
export { englishRateLimited, englishWait } from "./auth-errors-labels.js";
|
package/dist/auth/auth-errors.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { httpStatusOf } from "../lib/http-status.js";
|
|
2
3
|
const BILLING_CODES = /* @__PURE__ */ new Set([
|
|
3
4
|
"billing_disabled",
|
|
4
5
|
"billing_read_only",
|
|
@@ -67,14 +68,6 @@ function errorBodyWithCode(err, accept = (code) => known(code) !== void 0) {
|
|
|
67
68
|
}
|
|
68
69
|
return void 0;
|
|
69
70
|
}
|
|
70
|
-
function statusOf(value) {
|
|
71
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
72
|
-
}
|
|
73
|
-
function httpStatusOf(err) {
|
|
74
|
-
if (!isBag(err)) return void 0;
|
|
75
|
-
const response = err.response;
|
|
76
|
-
return (isBag(response) ? statusOf(response.status) : void 0) ?? statusOf(err.status) ?? statusOf(err.statusCode);
|
|
77
|
-
}
|
|
78
71
|
function isRateLimited(err) {
|
|
79
72
|
return httpStatusOf(err) === 429;
|
|
80
73
|
}
|
|
@@ -110,13 +103,7 @@ function retryAfterSeconds(err, now = Date.now()) {
|
|
|
110
103
|
const value = (isBag(response) ? headerOf(response.headers, "retry-after") : void 0) ?? headerOf(err.headers, "retry-after");
|
|
111
104
|
return value === void 0 ? void 0 : parseRetryAfter(value, at);
|
|
112
105
|
}
|
|
113
|
-
|
|
114
|
-
if (!seconds || seconds <= 0) return "Too many attempts. Wait a moment and try again.";
|
|
115
|
-
return `Too many attempts. Try again in ${englishWait(seconds)}.`;
|
|
116
|
-
}
|
|
117
|
-
function englishWait(seconds) {
|
|
118
|
-
return seconds < 60 ? `${Math.ceil(seconds)} s` : `${Math.ceil(seconds / 60)} min`;
|
|
119
|
-
}
|
|
106
|
+
import { englishRateLimited, englishWait } from "./auth-errors-labels.js";
|
|
120
107
|
export {
|
|
121
108
|
authErrorCode,
|
|
122
109
|
englishRateLimited,
|