@eifi1/ui-kit 0.34.0 → 0.36.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 +115 -41
- package/dist/admin/role-select.d.ts +3 -2
- package/dist/admin/role-select.js +2 -0
- package/dist/admin/role-select.js.map +1 -1
- package/dist/billing/billing-banner.d.ts +5 -2
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/plan-limit-notice.d.ts +5 -2
- package/dist/billing/plan-limit-notice.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -5
- package/dist/components/amount-input.js +2 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +2 -2
- package/dist/components/autocomplete.js +2 -1
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-look.d.ts +1 -1
- package/dist/components/button-look.js +9 -4
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/calculator.d.ts +1 -4
- package/dist/components/calculator.js +1 -3
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.d.ts +0 -37
- package/dist/components/chart-zoom.js +1 -28
- package/dist/components/chart-zoom.js.map +1 -1
- package/dist/components/checkbox-group.d.ts +5 -2
- package/dist/components/checkbox-group.js +15 -4
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/chip-input.d.ts +0 -4
- package/dist/components/chip-input.js +1 -5
- package/dist/components/chip-input.js.map +1 -1
- package/dist/components/column-mapper.d.ts +5 -3
- package/dist/components/column-mapper.js +2 -0
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox.d.ts +3 -3
- package/dist/components/combobox.js +2 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/country-select.d.ts +3 -3
- package/dist/components/country-select.js +3 -0
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-option-list.d.ts +3 -8
- package/dist/components/currency-option-list.js +1 -29
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.d.ts +3 -2
- package/dist/components/currency-select.js +10 -1
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +3 -3
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +1 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +1 -42
- package/dist/components/data-table-labels.js +2 -31
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-shared.d.ts +17 -1
- package/dist/components/data-table-shared.js +22 -0
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table.d.ts +12 -2
- package/dist/components/data-table.js +18 -14
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-field.d.ts +2 -1
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.js +3 -0
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js +3 -0
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.d.ts +18 -15
- package/dist/components/dropdown.js +11 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +3 -3
- package/dist/components/entity-combobox.js +2 -1
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-base.d.ts +0 -5
- package/dist/components/field-base.js +0 -5
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-parts.d.ts +69 -22
- package/dist/components/field-parts.js +33 -19
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +9 -23
- package/dist/components/field-strip.js +26 -23
- package/dist/components/field-strip.js.map +1 -1
- package/dist/components/field-sync.d.ts +0 -4
- package/dist/components/field-sync.js +0 -4
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.d.ts +7 -6
- package/dist/components/field.js +24 -15
- package/dist/components/field.js.map +1 -1
- package/dist/components/full-bleed-dialog.js +2 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/help-popover.d.ts +9 -7
- package/dist/components/help-popover.js.map +1 -1
- package/dist/components/hover-menu.d.ts +6 -13
- package/dist/components/hover-menu.js +3 -3
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-picker.d.ts +3 -2
- package/dist/components/icon-picker.js +3 -0
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/inline-entity-combobox.d.ts +3 -3
- package/dist/components/inline-entity-combobox.js +2 -1
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +2 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/modal.d.ts +9 -1
- package/dist/components/modal.js +7 -4
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +2 -1
- package/dist/components/month-picker.js +8 -1
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +2 -2
- package/dist/components/multi-entity-combobox.js +2 -1
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +7 -18
- package/dist/components/multi-select.js +8 -10
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.d.ts +2 -5
- package/dist/components/number-input.js +2 -4
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numeric-field.d.ts +5 -2
- package/dist/components/numeric-field.js +4 -1
- package/dist/components/numeric-field.js.map +1 -1
- package/dist/components/one-time-code-input.d.ts +2 -1
- package/dist/components/one-time-code-input.js +2 -1
- package/dist/components/one-time-code-input.js.map +1 -1
- package/dist/components/phone-input.d.ts +1 -1
- package/dist/components/phone-input.js +4 -0
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popover.js +3 -3
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.d.ts +4 -3
- package/dist/components/select.js +2 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/server-wake.d.ts +0 -6
- package/dist/components/server-wake.js.map +1 -1
- package/dist/components/settings-fields.d.ts +4 -2
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/slider.d.ts +3 -2
- package/dist/components/slider.js +7 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stat-tile.d.ts +8 -2
- package/dist/components/stat-tile.js +2 -11
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swatch-picker.d.ts +3 -2
- package/dist/components/swatch-picker.js +3 -0
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +2 -17
- package/dist/components/swipeable-row.js +11 -16
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/text-link.js +3 -1
- package/dist/components/text-link.js.map +1 -1
- package/dist/components/textarea.d.ts +2 -1
- package/dist/components/textarea.js +9 -3
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/toggle-group.d.ts +2 -2
- package/dist/components/toggle-group.js +7 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +9 -1
- package/dist/components/tooltip.js +20 -5
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review.d.ts +10 -2
- package/dist/components/translation-review.js +11 -3
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/use-table-state.d.ts +31 -3
- package/dist/components/use-table-state.js +53 -8
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +2 -2
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.d.ts +1 -4
- package/dist/components/wizard-stepper.js +2 -3
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/currencies.d.ts +23 -0
- package/dist/currencies.js +38 -0
- package/dist/currencies.js.map +1 -0
- package/dist/demo/demo-banner.d.ts +7 -2
- package/dist/demo/demo-banner.js.map +1 -1
- package/dist/eslint/index.d.ts +83 -0
- package/dist/eslint/index.js +69 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/role-utilities.d.ts +48 -0
- package/dist/eslint/role-utilities.generated.d.ts +2 -0
- package/dist/eslint/role-utilities.generated.js +143 -0
- package/dist/eslint/role-utilities.generated.js.map +1 -0
- package/dist/eslint/role-utilities.js +43 -0
- package/dist/eslint/role-utilities.js.map +1 -0
- package/dist/feedback/feedback-menu.d.ts +2 -2
- package/dist/feedback/feedback-menu.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +3 -8
- package/dist/feedback/feedback-thread.js +0 -2
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +16 -3
- package/dist/hooks/use-dismiss.js +14 -2
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/i18n/defaults.js +5 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +97 -1
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +29 -4
- package/dist/i18n/kit-labels.js +21 -1
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +104 -3
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +95 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +99 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +95 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +99 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +95 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +13 -0
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js +3 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/device-settings.d.ts +72 -0
- package/dist/lib/device-settings.js +64 -0
- package/dist/lib/device-settings.js.map +1 -0
- package/dist/lib/plain-text.d.ts +11 -0
- package/dist/lib/plain-text.js +16 -0
- package/dist/lib/plain-text.js.map +1 -0
- package/dist/lib/refs.d.ts +13 -0
- package/dist/lib/refs.js +15 -0
- package/dist/lib/refs.js.map +1 -0
- package/dist/lib/safe-storage.d.ts +6 -0
- package/dist/lib/safe-storage.js +11 -0
- package/dist/lib/safe-storage.js.map +1 -1
- package/dist/notifications/notification-parts.d.ts +39 -0
- package/dist/notifications/notification-parts.js +47 -0
- package/dist/notifications/notification-parts.js.map +1 -0
- package/dist/notifications/notification-types-setting.d.ts +62 -0
- package/dist/notifications/notification-types-setting.js +192 -0
- package/dist/notifications/notification-types-setting.js.map +1 -0
- package/dist/notifications/notification-types.d.ts +75 -0
- package/dist/notifications/notification-types.js +2 -0
- package/dist/notifications/notification-types.js.map +1 -0
- package/dist/notifications/notifications-labels.d.ts +131 -0
- package/dist/notifications/notifications-labels.js +83 -0
- package/dist/notifications/notifications-labels.js.map +1 -0
- package/dist/notifications/push-device-setting.d.ts +37 -0
- package/dist/notifications/push-device-setting.js +164 -0
- package/dist/notifications/push-device-setting.js.map +1 -0
- package/dist/notifications/push-devices-setting.d.ts +44 -0
- package/dist/notifications/push-devices-setting.js +203 -0
- package/dist/notifications/push-devices-setting.js.map +1 -0
- package/dist/notifications/quiet-hours-setting.d.ts +47 -0
- package/dist/notifications/quiet-hours-setting.js +131 -0
- package/dist/notifications/quiet-hours-setting.js.map +1 -0
- package/dist/notifications/time-zone-select.d.ts +50 -0
- package/dist/notifications/time-zone-select.js +76 -0
- package/dist/notifications/time-zone-select.js.map +1 -0
- package/dist/notifications/unsubscribe-panel.d.ts +53 -0
- package/dist/notifications/unsubscribe-panel.js +139 -0
- package/dist/notifications/unsubscribe-panel.js.map +1 -0
- package/dist/notifications/use-push-device.d.ts +122 -0
- package/dist/notifications/use-push-device.js +230 -0
- package/dist/notifications/use-push-device.js.map +1 -0
- package/dist/rhf/fields.d.ts +36 -29
- package/dist/rhf/fields.js +51 -22
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form-core.d.ts +5 -4
- package/dist/rhf/form-core.js.map +1 -1
- package/dist/rhf/form.d.ts +7 -36
- package/dist/rhf/form.js +1 -16
- package/dist/rhf/form.js.map +1 -1
- package/dist/rhf/line-items.d.ts +1 -1
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
- package/dist/rhf.js.map +1 -1
- package/dist/settings/device-reset-setting-labels.d.ts +3 -0
- package/dist/settings/device-reset-setting-labels.js +15 -0
- package/dist/settings/device-reset-setting-labels.js.map +1 -0
- package/dist/settings/device-reset-setting.d.ts +58 -0
- package/dist/settings/device-reset-setting.js +51 -0
- package/dist/settings/device-reset-setting.js.map +1 -0
- package/dist/shell/app-shell.js +5 -0
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/option-switcher-menu.d.ts +5 -17
- package/dist/shell/option-switcher-menu.js +1 -3
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +1 -4
- package/dist/shell/role-switcher.js +2 -3
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +7 -19
- package/dist/shell/topbar-action-menu.js +1 -3
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +3 -12
- package/dist/shell/topbar-controls.js +6 -9
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/viewport.d.ts +25 -2
- package/dist/testing/viewport.js +61 -10
- package/dist/testing/viewport.js.map +1 -1
- package/dist/theme/contrast-tokens.d.ts +42 -4
- package/dist/theme/contrast-tokens.js +56 -9
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +4 -2
- package/dist/theme/contrast.js +13 -0
- package/dist/theme/contrast.js.map +1 -1
- package/dist/theme/palette-derive.d.ts +15 -1
- package/dist/theme/palette-derive.js +37 -8
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/theme/palette-presets.d.ts +2 -8
- package/dist/theme/palette-presets.js +5 -284
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js +6 -0
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.js +6 -0
- package/dist/theme/text-size.js.map +1 -1
- package/dist/theme/theme-store.js +6 -0
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/wizard/types.d.ts +0 -5
- package/dist/wizard/types.js +1 -5
- package/dist/wizard/types.js.map +1 -1
- package/package.json +9 -1
- package/src/admin/role-select.tsx +4 -1
- package/src/billing/billing-banner.tsx +5 -2
- package/src/billing/plan-limit-notice.tsx +5 -2
- package/src/chart.ts +5 -3
- package/src/components/amount-input.tsx +4 -7
- package/src/components/autocomplete.tsx +5 -2
- package/src/components/button-look.ts +15 -5
- package/src/components/calculator.tsx +2 -7
- package/src/components/chart-zoom.tsx +4 -47
- package/src/components/checkbox-group.tsx +22 -4
- package/src/components/chip-input.tsx +0 -7
- package/src/components/column-mapper.tsx +6 -2
- package/src/components/combobox.tsx +6 -3
- package/src/components/copy-button.tsx +5 -1
- package/src/components/country-select.tsx +6 -1
- package/src/components/currency-option-list.tsx +8 -42
- package/src/components/currency-select.tsx +12 -3
- package/src/components/danger-confirm.tsx +3 -3
- package/src/components/data-table-filter-popover.tsx +2 -1
- package/src/components/data-table-labels.ts +2 -84
- package/src/components/data-table-shared.tsx +55 -2
- package/src/components/data-table.tsx +29 -17
- package/src/components/date-field.tsx +2 -2
- package/src/components/date-picker.tsx +3 -0
- package/src/components/date-range-picker.tsx +3 -0
- package/src/components/dialog-frame.tsx +3 -1
- package/src/components/dropdown.tsx +42 -18
- package/src/components/entity-combobox.tsx +6 -3
- package/src/components/field-base.tsx +0 -11
- package/src/components/field-parts.tsx +112 -38
- package/src/components/field-strip.tsx +12 -27
- package/src/components/field-sync.tsx +0 -7
- package/src/components/field.tsx +32 -19
- package/src/components/full-bleed-dialog.tsx +4 -3
- package/src/components/help-popover.tsx +9 -7
- package/src/components/hover-menu.tsx +12 -16
- package/src/components/icon-picker.tsx +8 -3
- package/src/components/inline-entity-combobox.tsx +6 -3
- package/src/components/input.tsx +4 -2
- package/src/components/modal.tsx +20 -4
- package/src/components/month-picker.tsx +10 -3
- package/src/components/multi-entity-combobox.tsx +5 -2
- package/src/components/multi-select.tsx +19 -31
- package/src/components/number-input.tsx +5 -10
- package/src/components/numeric-field.ts +10 -2
- package/src/components/one-time-code-input.tsx +5 -3
- package/src/components/phone-input.tsx +4 -0
- package/src/components/popover.tsx +8 -4
- package/src/components/select.tsx +6 -3
- package/src/components/series-chart.tsx +1 -1
- package/src/components/server-wake.tsx +0 -6
- package/src/components/settings-fields.tsx +4 -2
- package/src/components/slider.tsx +10 -3
- package/src/components/stat-tile.tsx +11 -20
- package/src/components/swatch-picker.tsx +9 -4
- package/src/components/swipeable-row.tsx +15 -37
- package/src/components/text-link.tsx +3 -1
- package/src/components/textarea.tsx +11 -4
- package/src/components/toggle-group.tsx +21 -5
- package/src/components/tooltip.tsx +37 -6
- package/src/components/translation-review.tsx +25 -7
- package/src/components/use-table-state.ts +91 -10
- package/src/components/user-avatar.tsx +2 -2
- package/src/components/wizard-stepper.tsx +2 -6
- package/src/currencies.ts +70 -0
- package/src/demo/demo-banner.tsx +7 -2
- package/src/eslint/index.ts +161 -0
- package/src/eslint/role-utilities.generated.ts +146 -0
- package/src/eslint/role-utilities.ts +99 -0
- package/src/feedback/feedback-menu.tsx +2 -2
- package/src/feedback/feedback-thread.tsx +3 -8
- package/src/hooks/use-dismiss.ts +39 -4
- package/src/i18n/defaults.ts +4 -0
- package/src/i18n/german.ts +113 -0
- package/src/i18n/kit-labels.tsx +66 -6
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +106 -0
- package/src/i18n/locales/fr.ts +109 -2
- package/src/i18n/locales/hu.ts +104 -0
- package/src/i18n/locales/it.ts +108 -2
- package/src/i18n/locales/zh.ts +96 -0
- package/src/i18n/review.ts +13 -0
- package/src/i18n/shared-labels.ts +2 -0
- package/src/index.ts +53 -1
- package/src/lib/device-settings.ts +146 -0
- package/src/lib/plain-text.ts +22 -0
- package/src/lib/refs.ts +22 -0
- package/src/lib/safe-storage.ts +16 -0
- package/src/notifications/notification-parts.tsx +83 -0
- package/src/notifications/notification-types-setting.tsx +309 -0
- package/src/notifications/notification-types.ts +80 -0
- package/src/notifications/notifications-labels.ts +238 -0
- package/src/notifications/push-device-setting.tsx +224 -0
- package/src/notifications/push-devices-setting.tsx +306 -0
- package/src/notifications/quiet-hours-setting.tsx +185 -0
- package/src/notifications/time-zone-select.tsx +126 -0
- package/src/notifications/unsubscribe-panel.tsx +203 -0
- package/src/notifications/use-push-device.ts +392 -0
- package/src/rhf/fields.tsx +87 -39
- package/src/rhf/form-core.tsx +5 -4
- package/src/rhf/form.tsx +7 -43
- package/src/rhf/line-items.tsx +1 -1
- package/src/rhf/use-rhf-wizard-step.ts +4 -4
- package/src/rhf.ts +3 -2
- package/src/settings/device-reset-setting-labels.ts +20 -0
- package/src/settings/device-reset-setting.tsx +119 -0
- package/src/shell/app-shell.tsx +8 -0
- package/src/shell/option-switcher-menu.tsx +5 -22
- package/src/shell/role-switcher.tsx +2 -6
- package/src/shell/topbar-action-menu.tsx +7 -24
- package/src/shell/topbar-controls.tsx +6 -18
- package/src/testing/index.ts +3 -1
- package/src/testing/viewport.ts +125 -19
- package/src/theme/contrast-tokens.ts +106 -12
- package/src/theme/contrast.ts +30 -4
- package/src/theme/palette-derive.ts +68 -7
- package/src/theme/palette-presets.ts +16 -299
- package/src/theme/palette-store.ts +12 -0
- package/src/theme/text-size.ts +8 -0
- package/src/theme/theme-store.ts +10 -0
- package/src/wizard/types.ts +0 -8
- package/tokens.css +38 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isValidElement } from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The text of a label node: a string or number as is, an element by its children,
|
|
6
|
+
* recursively, whitespace collapsed. A `<Tooltip label="…">Spend</Tooltip>` label yields
|
|
7
|
+
* "Spend" — the text the reader sees, not the bubble's. `undefined` when there is no text
|
|
8
|
+
* to find (an icon), so the caller falls back to a name of its own.
|
|
9
|
+
*
|
|
10
|
+
* Package-private — not re-exported from the barrel. StatTile names its sparkline by it;
|
|
11
|
+
* a field names its `help` "?" by it ("About <label>", round 0.36).
|
|
12
|
+
*/
|
|
13
|
+
export function plainText(node: ReactNode): string | undefined {
|
|
14
|
+
const walk = (n: ReactNode): string => {
|
|
15
|
+
if (typeof n === "string" || typeof n === "number") return String(n);
|
|
16
|
+
if (Array.isArray(n)) return n.map(walk).join("");
|
|
17
|
+
if (isValidElement<{ children?: ReactNode }>(n)) return walk(n.props.children);
|
|
18
|
+
return "";
|
|
19
|
+
};
|
|
20
|
+
const text = walk(node).replace(/\s+/g, " ").trim();
|
|
21
|
+
return text === "" ? undefined : text;
|
|
22
|
+
}
|
package/src/lib/refs.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Internal (not exported from the package): the kit's ref plumbing. Here, rather than in
|
|
2
|
+
* components/field-parts (which re-exports both), since round 0.35: Tooltip needs them,
|
|
3
|
+
* and field-parts renders a Tooltip, so importing them from there closed a cycle. */
|
|
4
|
+
import type { Ref, RefCallback } from "react";
|
|
5
|
+
|
|
6
|
+
/** Point a ref — a callback or an object — at `node`. `undefined` and `null` are no ref. */
|
|
7
|
+
export function assignRef<T>(ref: Ref<T> | undefined, node: T | null): void {
|
|
8
|
+
if (typeof ref === "function") ref(node);
|
|
9
|
+
else if (ref) (ref as { current: T | null }).current = node;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One callback ref feeding several — the caller's forwarded `ref` and a field's own
|
|
14
|
+
* (DUP-11: AmountInput, FormActions, ScrollArea and SearchField each wrote this by hand).
|
|
15
|
+
* Wrap it in `useCallback` (or `useMemo`) over the same refs where a new callback every
|
|
16
|
+
* render would detach and re-attach the node.
|
|
17
|
+
*/
|
|
18
|
+
export function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): RefCallback<T> {
|
|
19
|
+
return (node) => {
|
|
20
|
+
for (const ref of refs) assignRef(ref, node);
|
|
21
|
+
};
|
|
22
|
+
}
|
package/src/lib/safe-storage.ts
CHANGED
|
@@ -59,3 +59,19 @@ export function writeSessionStored(key: string, value: string | null): void {
|
|
|
59
59
|
value === null ? storage.removeItem(key) : storage.setItem(key, value),
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Every key in `area` that starts with `prefix`, or `[]` where storage refuses — for the
|
|
65
|
+
* reset of this device's settings, which removes a table's views by their prefix
|
|
66
|
+
* (docs/settings-harmonization.md §11.4). Package-private, like {@link removeStored}.
|
|
67
|
+
*/
|
|
68
|
+
export function storedKeys(prefix: string, area: "local" | "session" = "local"): string[] {
|
|
69
|
+
return guarded(area === "session" ? "sessionStorage" : "localStorage", [], (storage) => {
|
|
70
|
+
const keys: string[] = [];
|
|
71
|
+
for (let i = 0; i < storage.length; i++) {
|
|
72
|
+
const key = storage.key(i);
|
|
73
|
+
if (key !== null && key.startsWith(prefix)) keys.push(key);
|
|
74
|
+
}
|
|
75
|
+
return keys;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { useKitLabels, type LabelOverride } from "../i18n/kit-labels";
|
|
5
|
+
import { hasContent } from "../lib/presence";
|
|
6
|
+
import { AlertBanner } from "../components/alert-banner";
|
|
7
|
+
import { DEFAULT_NOTIFICATIONS_LABELS } from "./notifications-labels";
|
|
8
|
+
import type { NotificationsLabels } from "./notifications-labels";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* What the notification cards share: their words, the failure line under a card, and
|
|
12
|
+
* the overlay a card shows while its write runs.
|
|
13
|
+
*
|
|
14
|
+
* @internal Not part of the barrel; the cards are.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** The `notifications` namespace: English, then the provider, then the card's prop. */
|
|
18
|
+
export function useNotificationsLabels(prop?: LabelOverride<NotificationsLabels>): NotificationsLabels {
|
|
19
|
+
return useKitLabels("notifications", DEFAULT_NOTIFICATIONS_LABELS, prop);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The app's words for a failure, else `fallback`. */
|
|
23
|
+
export function describeFailure(own: ReactNode | undefined, fallback: ReactNode): ReactNode {
|
|
24
|
+
return hasContent(own) ? own : fallback;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A failure, said under the card's controls — nothing toasts (§4.2). */
|
|
28
|
+
export function FailureLine({ children }: { children: ReactNode }) {
|
|
29
|
+
if (!hasContent(children)) return null;
|
|
30
|
+
return (
|
|
31
|
+
<AlertBanner tone="danger" size="sm" role="alert">
|
|
32
|
+
{children}
|
|
33
|
+
</AlertBanner>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** What {@link useWriteOverlay} answers. */
|
|
38
|
+
export interface WriteOverlay<V> {
|
|
39
|
+
has: (key: string) => boolean;
|
|
40
|
+
get: (key: string) => V | undefined;
|
|
41
|
+
pending: (key: string) => boolean;
|
|
42
|
+
set: (key: string, value: V) => void;
|
|
43
|
+
settle: (key: string, ok: boolean) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Values a card shows while its write runs, over what the server last answered.
|
|
48
|
+
*
|
|
49
|
+
* `set(key, value)` shows `value` at once; `settle(key, ok)` drops it again when the
|
|
50
|
+
* write failed (the server's value comes back) and keeps it when it succeeded, until the
|
|
51
|
+
* app hands the card a new `source` — the PATCH's answer, or a refetch — which clears
|
|
52
|
+
* every settled entry, so a card whose app does not update its query on success does not
|
|
53
|
+
* flick back to the old value in between. `pending(key)` says whether a write for `key`
|
|
54
|
+
* is still running.
|
|
55
|
+
*
|
|
56
|
+
* The reset on a new `source` is React's "adjust state while rendering" pattern, not an
|
|
57
|
+
* effect: the overlay is gone in the same render that shows the new value.
|
|
58
|
+
*/
|
|
59
|
+
export function useWriteOverlay<V>(source: unknown): WriteOverlay<V> {
|
|
60
|
+
const [entries, setEntries] = useState<ReadonlyMap<string, { value: V; running: boolean }>>(new Map());
|
|
61
|
+
const [seen, setSeen] = useState(source);
|
|
62
|
+
if (seen !== source) {
|
|
63
|
+
setSeen(source);
|
|
64
|
+
const kept = new Map([...entries].filter(([, entry]) => entry.running));
|
|
65
|
+
if (kept.size !== entries.size) setEntries(kept);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
has: (key: string) => entries.has(key),
|
|
69
|
+
get: (key: string) => entries.get(key)?.value,
|
|
70
|
+
pending: (key: string) => entries.get(key)?.running === true,
|
|
71
|
+
set: (key: string, value: V) =>
|
|
72
|
+
setEntries((current) => new Map(current).set(key, { value, running: true })),
|
|
73
|
+
settle: (key: string, ok: boolean) =>
|
|
74
|
+
setEntries((current) => {
|
|
75
|
+
const entry = current.get(key);
|
|
76
|
+
if (!entry) return current;
|
|
77
|
+
const next = new Map(current);
|
|
78
|
+
if (ok) next.set(key, { value: entry.value, running: false });
|
|
79
|
+
else next.delete(key);
|
|
80
|
+
return next;
|
|
81
|
+
}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { useId, useState } from "react";
|
|
2
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import type { LabelOverride } from "../i18n/kit-labels";
|
|
5
|
+
import { cn } from "../lib/cn";
|
|
6
|
+
import { hasContent } from "../lib/presence";
|
|
7
|
+
import { Card } from "../components/card";
|
|
8
|
+
import { Select } from "../components/select";
|
|
9
|
+
import { Skeleton } from "../components/skeleton";
|
|
10
|
+
import { Switch } from "../components/switch";
|
|
11
|
+
import { SectionLabel } from "../components/text";
|
|
12
|
+
import { COMMIT_EXCEPT_BILLING } from "../components/write-lock";
|
|
13
|
+
import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes";
|
|
14
|
+
import { SettingsCardTitle } from "../settings/settings-heading";
|
|
15
|
+
import { settle, useMounted } from "../account/account-parts";
|
|
16
|
+
import { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from "./notification-parts";
|
|
17
|
+
import type { WriteOverlay } from "./notification-parts";
|
|
18
|
+
import type { NotificationsLabels } from "./notifications-labels";
|
|
19
|
+
import type {
|
|
20
|
+
DigestCadence,
|
|
21
|
+
NotificationSettingsPatch,
|
|
22
|
+
NotificationSwitches,
|
|
23
|
+
NotificationTypeEntry,
|
|
24
|
+
NotificationTypeGroup,
|
|
25
|
+
NotificationTypesValue,
|
|
26
|
+
} from "./notification-types";
|
|
27
|
+
|
|
28
|
+
/** Is this a development build? Dead code in a consumer's production bundle; on under
|
|
29
|
+
* vitest, where a type the card cannot draw is a bug a test should fail on (as
|
|
30
|
+
* `SettingsSection`'s catalogue check). */
|
|
31
|
+
function devChecks(): boolean {
|
|
32
|
+
return Boolean(import.meta.env?.DEV);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface NotificationTypesSettingProps<Id extends string = string>
|
|
36
|
+
extends Omit<ComponentPropsWithRef<"div">, "children" | "onChange"> {
|
|
37
|
+
/** The app's words for its types, in its order. Where an app types its ids. */
|
|
38
|
+
types: readonly NotificationTypeEntry<Id>[];
|
|
39
|
+
/** The `GET`'s `types` (§3.2); `undefined` while the first load runs. */
|
|
40
|
+
value: NotificationTypesValue | undefined;
|
|
41
|
+
/** The settings are loading. */
|
|
42
|
+
loading?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Save one change — `PATCH /notifications/settings` with this body: one switch per
|
|
45
|
+
* call (`{types: {digest: {app: true}}}`), or `{digest_cadence}`. The switch shows its
|
|
46
|
+
* new state while the call runs and goes back if it rejects; hand the card the
|
|
47
|
+
* PATCH's answer (or refetch) when it resolves.
|
|
48
|
+
*/
|
|
49
|
+
onChange: (patch: NotificationSettingsPatch<Id>) => Promise<unknown> | void;
|
|
50
|
+
/** Headings over the types, in the app's words (keksdose's three). Without them, one
|
|
51
|
+
* list in the order of `types`. In development every type the server answered must
|
|
52
|
+
* be in one. */
|
|
53
|
+
groups?: readonly NotificationTypeGroup<Id>[];
|
|
54
|
+
/** The digest type and the account's cadence: a cadence `Select` under that type
|
|
55
|
+
* while it is on. */
|
|
56
|
+
digest?: { type: Id; cadence: DigestCadence };
|
|
57
|
+
/** Under a type while it is on — keksdose's low-balance threshold field. */
|
|
58
|
+
renderExtra?: (id: Id) => ReactNode;
|
|
59
|
+
/** The account's address is unverified: every e-mail switch says
|
|
60
|
+
* `labels.emailUnverified` under it (decision 16). */
|
|
61
|
+
emailUnverified?: boolean;
|
|
62
|
+
/** Nothing can be changed (the switches stay readable). */
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
/** The app's own words for a failed save, or `undefined` for the kit's `failed`. */
|
|
65
|
+
describeError?: (error: unknown) => ReactNode | undefined;
|
|
66
|
+
labels?: LabelOverride<NotificationsLabels>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** One drawn type: the app's words and the server's switches. */
|
|
70
|
+
interface Row<Id extends string> {
|
|
71
|
+
entry: NotificationTypeEntry<Id>;
|
|
72
|
+
switches: NotificationSwitches;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A switch's key in the write overlay. */
|
|
76
|
+
const switchKey = (id: string, channel: "app" | "email") => `${id}.${channel}`;
|
|
77
|
+
const CADENCE_KEY = "digest_cadence";
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* What the person hears about, and how (docs/notifications-harmonization.md §2.1–§2.3,
|
|
81
|
+
* §4.2): one row per type the SERVER answered, the app's words on it, a switch for "in
|
|
82
|
+
* the app" and "By e-mail" under it where the type offers mail. Where the app has no
|
|
83
|
+
* "in the app" channel (Kurvenschmiede), the e-mail switch is the row's own, with the
|
|
84
|
+
* type's label.
|
|
85
|
+
*
|
|
86
|
+
* **The server's list is the only list.** The card keeps no defaults and no list of
|
|
87
|
+
* types: it draws what `value` holds, in the order of `groups`, else of `types`. A type
|
|
88
|
+
* the app names that the server did not answer is not drawn (kastlan's tenant receives
|
|
89
|
+
* neither of its types). In development a type the server answered with no entry in
|
|
90
|
+
* `types`, or in no group when `groups` is given, throws — keksdose's compile-time
|
|
91
|
+
* `_EVERY_TYPE_IS_GROUPED`, now at run time, since the list is the server's.
|
|
92
|
+
*
|
|
93
|
+
* **Each flip saves at once**, one switch per call; the switch shows its new state while
|
|
94
|
+
* the call runs and goes back if it rejects, with the failure said under the card. The
|
|
95
|
+
* digest's cadence and the app's extra field (`renderExtra`) show under their type while
|
|
96
|
+
* it is on.
|
|
97
|
+
*
|
|
98
|
+
* Under a write lock the switches are `commit` controls exempt from billing: a lapsed
|
|
99
|
+
* plan never keeps a person from turning notifications off (billing §12.13).
|
|
100
|
+
*/
|
|
101
|
+
export function NotificationTypesSetting<Id extends string = string>({
|
|
102
|
+
types,
|
|
103
|
+
value,
|
|
104
|
+
loading,
|
|
105
|
+
onChange,
|
|
106
|
+
groups,
|
|
107
|
+
digest,
|
|
108
|
+
renderExtra,
|
|
109
|
+
emailUnverified = false,
|
|
110
|
+
disabled = false,
|
|
111
|
+
describeError,
|
|
112
|
+
labels: labelsProp,
|
|
113
|
+
className,
|
|
114
|
+
...rest
|
|
115
|
+
}: NotificationTypesSettingProps<Id>) {
|
|
116
|
+
const labels = useNotificationsLabels(labelsProp);
|
|
117
|
+
const overlay = useWriteOverlay<boolean>(value);
|
|
118
|
+
const cadenceOverlay = useWriteOverlay<DigestCadence>(digest?.cadence);
|
|
119
|
+
const [failure, setFailure] = useState<ReactNode>(null);
|
|
120
|
+
const mounted = useMounted();
|
|
121
|
+
const groupId = useId();
|
|
122
|
+
|
|
123
|
+
const answered = value ? Object.keys(value) : [];
|
|
124
|
+
const entries = new Map(types.map((entry) => [entry.id as string, entry]));
|
|
125
|
+
if (value && devChecks()) {
|
|
126
|
+
const unnamed = answered.filter((id) => !entries.has(id));
|
|
127
|
+
if (unnamed.length) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`NotificationTypesSetting: the server answered ${unnamed.map((id) => `"${id}"`).join(", ")} with no entry in \`types\` — give every type the server can send its words.`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
if (groups) {
|
|
133
|
+
const grouped = new Set<string>(groups.flatMap((group) => group.types));
|
|
134
|
+
const loose = answered.filter((id) => !grouped.has(id));
|
|
135
|
+
if (loose.length) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`NotificationTypesSetting: ${loose.map((id) => `"${id}"`).join(", ")} is in no group — a type in no group is drawn nowhere, and could not be turned off.`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const rowOf = (id: Id): Row<Id> | null => {
|
|
144
|
+
const switches = value?.[id];
|
|
145
|
+
const entry = entries.get(id);
|
|
146
|
+
if (!switches || !entry || (switches.app === null && switches.email === null)) return null;
|
|
147
|
+
return { entry, switches };
|
|
148
|
+
};
|
|
149
|
+
const rowsOf = (ids: readonly Id[]) => ids.map(rowOf).filter((row): row is Row<Id> => row !== null);
|
|
150
|
+
|
|
151
|
+
const shown = (id: string, channel: "app" | "email", server: boolean): boolean => {
|
|
152
|
+
const key = switchKey(id, channel);
|
|
153
|
+
return overlay.get(key) ?? server;
|
|
154
|
+
};
|
|
155
|
+
/** The row's own switch: `app`, or `email` where the app has no `app` channel. */
|
|
156
|
+
const rowOn = ({ entry, switches }: Row<Id>) =>
|
|
157
|
+
switches.app !== null
|
|
158
|
+
? shown(entry.id, "app", switches.app)
|
|
159
|
+
: shown(entry.id, "email", switches.email === true);
|
|
160
|
+
|
|
161
|
+
const save = <V,>(key: string, patch: NotificationSettingsPatch<Id>, which: WriteOverlay<V>, next: V) => {
|
|
162
|
+
if (which.pending(key)) return;
|
|
163
|
+
setFailure(null);
|
|
164
|
+
which.set(key, next);
|
|
165
|
+
settle(() => onChange(patch)).then(
|
|
166
|
+
() => {
|
|
167
|
+
if (mounted.current) which.settle(key, true);
|
|
168
|
+
},
|
|
169
|
+
(error: unknown) => {
|
|
170
|
+
if (!mounted.current) return;
|
|
171
|
+
which.settle(key, false);
|
|
172
|
+
setFailure(describeFailure(describeError?.(error), labels.failed));
|
|
173
|
+
},
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const flip = (id: Id, channel: "app" | "email", on: boolean) =>
|
|
178
|
+
save(
|
|
179
|
+
switchKey(id, channel),
|
|
180
|
+
{ types: { [id]: { [channel]: on } } as NotificationSettingsPatch<Id>["types"] },
|
|
181
|
+
overlay,
|
|
182
|
+
on,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const cadence = cadenceOverlay.get(CADENCE_KEY) ?? digest?.cadence;
|
|
186
|
+
|
|
187
|
+
const unverifiedLine = emailUnverified ? (
|
|
188
|
+
<span className="block" data-email-unverified="">
|
|
189
|
+
{labels.emailUnverified}
|
|
190
|
+
</span>
|
|
191
|
+
) : null;
|
|
192
|
+
|
|
193
|
+
const renderRow = (row: Row<Id>) => {
|
|
194
|
+
const { entry, switches } = row;
|
|
195
|
+
const on = rowOn(row);
|
|
196
|
+
const emailOnly = switches.app === null;
|
|
197
|
+
const both = !emailOnly && switches.email !== null;
|
|
198
|
+
const cadenceSelect =
|
|
199
|
+
on && digest?.type === entry.id && cadence ? (
|
|
200
|
+
<Select
|
|
201
|
+
label={labels.digestCadence}
|
|
202
|
+
value={cadence}
|
|
203
|
+
disabled={disabled}
|
|
204
|
+
commit={COMMIT_EXCEPT_BILLING}
|
|
205
|
+
onChange={(event) => {
|
|
206
|
+
const next = event.target.value as DigestCadence;
|
|
207
|
+
if (next !== cadence) save(CADENCE_KEY, { digest_cadence: next }, cadenceOverlay, next);
|
|
208
|
+
}}
|
|
209
|
+
className="max-w-44"
|
|
210
|
+
>
|
|
211
|
+
<option value="weekly">{labels.digestWeekly}</option>
|
|
212
|
+
<option value="monthly">{labels.digestMonthly}</option>
|
|
213
|
+
</Select>
|
|
214
|
+
) : null;
|
|
215
|
+
const extra = on ? renderExtra?.(entry.id) : null;
|
|
216
|
+
const description =
|
|
217
|
+
emailOnly && unverifiedLine ? (
|
|
218
|
+
<>
|
|
219
|
+
{entry.description !== undefined && <span className="block">{entry.description}</span>}
|
|
220
|
+
{unverifiedLine}
|
|
221
|
+
</>
|
|
222
|
+
) : (
|
|
223
|
+
entry.description
|
|
224
|
+
);
|
|
225
|
+
return (
|
|
226
|
+
<div
|
|
227
|
+
key={entry.id}
|
|
228
|
+
data-notification-type={entry.id}
|
|
229
|
+
// A row with two switches is a group named by its type, so "By e-mail" is heard
|
|
230
|
+
// with the type it belongs to.
|
|
231
|
+
role={both ? "group" : undefined}
|
|
232
|
+
aria-label={both ? entry.label : undefined}
|
|
233
|
+
className="space-y-2"
|
|
234
|
+
>
|
|
235
|
+
<Switch
|
|
236
|
+
label={entry.label}
|
|
237
|
+
description={description}
|
|
238
|
+
checked={on}
|
|
239
|
+
disabled={disabled}
|
|
240
|
+
commit={COMMIT_EXCEPT_BILLING}
|
|
241
|
+
onCheckedChange={(next) => flip(entry.id, emailOnly ? "email" : "app", next)}
|
|
242
|
+
/>
|
|
243
|
+
{both && (
|
|
244
|
+
<div className="ps-4">
|
|
245
|
+
<Switch
|
|
246
|
+
size="sm"
|
|
247
|
+
label={labels.byEmail}
|
|
248
|
+
description={unverifiedLine ?? undefined}
|
|
249
|
+
checked={shown(entry.id, "email", switches.email === true)}
|
|
250
|
+
disabled={disabled}
|
|
251
|
+
commit={COMMIT_EXCEPT_BILLING}
|
|
252
|
+
onCheckedChange={(next) => flip(entry.id, "email", next)}
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
255
|
+
)}
|
|
256
|
+
{(cadenceSelect || hasContent(extra)) && (
|
|
257
|
+
<div className="ps-4 space-y-2">
|
|
258
|
+
{cadenceSelect}
|
|
259
|
+
{extra}
|
|
260
|
+
</div>
|
|
261
|
+
)}
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
let body: ReactNode;
|
|
267
|
+
if (loading || value === undefined) {
|
|
268
|
+
body = <Skeleton lines={3} label={labels.typesLoading} />;
|
|
269
|
+
} else if (groups) {
|
|
270
|
+
const drawn = groups
|
|
271
|
+
.map((group) => ({ group, rows: rowsOf(group.types) }))
|
|
272
|
+
.filter(({ rows }) => rows.length > 0);
|
|
273
|
+
body =
|
|
274
|
+
drawn.length === 0 ? (
|
|
275
|
+
<p className={CARD_DESCRIPTION_CLASS}>{labels.typesEmpty}</p>
|
|
276
|
+
) : (
|
|
277
|
+
drawn.map(({ group, rows }) => {
|
|
278
|
+
const headingId = `${groupId}-${group.id}`;
|
|
279
|
+
return (
|
|
280
|
+
<div key={group.id} role="group" aria-labelledby={headingId} className="space-y-3">
|
|
281
|
+
<SectionLabel as="div" size="xs" id={headingId}>
|
|
282
|
+
{group.label}
|
|
283
|
+
</SectionLabel>
|
|
284
|
+
{rows.map(renderRow)}
|
|
285
|
+
</div>
|
|
286
|
+
);
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
} else {
|
|
290
|
+
const rows = rowsOf(types.map((entry) => entry.id));
|
|
291
|
+
body =
|
|
292
|
+
rows.length === 0 ? (
|
|
293
|
+
<p className={CARD_DESCRIPTION_CLASS}>{labels.typesEmpty}</p>
|
|
294
|
+
) : (
|
|
295
|
+
<div className="space-y-3">{rows.map(renderRow)}</div>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<Card {...rest} className={cn("p-4 space-y-3", className)}>
|
|
301
|
+
<div>
|
|
302
|
+
<SettingsCardTitle>{labels.typesTitle}</SettingsCardTitle>
|
|
303
|
+
<div className={CARD_DESCRIPTION_CLASS}>{labels.typesDescription}</div>
|
|
304
|
+
</div>
|
|
305
|
+
{body}
|
|
306
|
+
<FailureLine>{failure}</FailureLine>
|
|
307
|
+
</Card>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shapes the notification cards share (docs/notifications-harmonization.md §3.2,
|
|
5
|
+
* §3.5, §4.2): the server's `GET /notifications/settings` answer, the parts of its
|
|
6
|
+
* `PATCH` the cards send, one push device, and the app's words for its types.
|
|
7
|
+
*
|
|
8
|
+
* Types only — the kit keeps no list of notification types and no defaults (§2.1): the
|
|
9
|
+
* server's registry is the one list, and the cards draw what it answers.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The digest's cadence, one for the account (§2.5): Monday, or the 1st, in its zone. */
|
|
13
|
+
export type DigestCadence = "weekly" | "monthly";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* One type's two switches in the `GET` (§3.2). `null` where the type does not offer
|
|
17
|
+
* that channel: `email` for a type with no mail, `app` in an app with no "in the app"
|
|
18
|
+
* channel (Kurvenschmiede: `{app: null, email: true}`). An unset switch already reads as
|
|
19
|
+
* its default — the server fills it in.
|
|
20
|
+
*/
|
|
21
|
+
export interface NotificationSwitches {
|
|
22
|
+
app: boolean | null;
|
|
23
|
+
email: boolean | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The `GET`'s `types`: every type the account can receive, in the registry's order. */
|
|
27
|
+
export type NotificationTypesValue = Readonly<Record<string, NotificationSwitches>>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The app's words for one of its types — where an app TYPES its ids, so its own maps
|
|
31
|
+
* (keksdose's inbox icons) are keyed on the same list (§5.1). The kit draws the type
|
|
32
|
+
* only when the server answered it.
|
|
33
|
+
*/
|
|
34
|
+
export interface NotificationTypeEntry<Id extends string = string> {
|
|
35
|
+
id: Id;
|
|
36
|
+
/** The switch's label: what the person hears about. */
|
|
37
|
+
label: string;
|
|
38
|
+
/** The line under it, attached to the switch. */
|
|
39
|
+
description?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A heading over some of the types, in the app's words (keksdose's "Budget", "Scans &
|
|
43
|
+
* sharing", "Summaries & news"). */
|
|
44
|
+
export interface NotificationTypeGroup<Id extends string = string> {
|
|
45
|
+
/** A stable key for the group. */
|
|
46
|
+
id: string;
|
|
47
|
+
label: ReactNode;
|
|
48
|
+
/** The group's types, in the order they are drawn. */
|
|
49
|
+
types: readonly Id[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The parts of `PATCH /notifications/settings` (§3.2) the cards send. Omitted keeps; a
|
|
54
|
+
* type's `null` puts both its switches back to their defaults; `quiet_hours_*: null`
|
|
55
|
+
* clears a time. One switch per call from the types card (`{types: {digest: {app:
|
|
56
|
+
* true}}}`), or `{digest_cadence}`; quiet hours send a time, with the device's zone the
|
|
57
|
+
* first time; the zone picker sends `{timezone}`.
|
|
58
|
+
*/
|
|
59
|
+
export interface NotificationSettingsPatch<Id extends string = string> {
|
|
60
|
+
types?: Partial<Record<Id, { app?: boolean; email?: boolean } | null>>;
|
|
61
|
+
digest_cadence?: DigestCadence;
|
|
62
|
+
quiet_hours_start?: string | null;
|
|
63
|
+
quiet_hours_end?: string | null;
|
|
64
|
+
timezone?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** One registered push device, as `GET /notifications/devices` lists it (§3.5), oldest
|
|
68
|
+
* first. The owner gets the whole endpoint, which marks "this device". */
|
|
69
|
+
export interface PushDeviceItem<Id extends string | number = string> {
|
|
70
|
+
id: Id;
|
|
71
|
+
endpoint: string;
|
|
72
|
+
/** The browser's user agent at registration; `null` when it sent none. */
|
|
73
|
+
user_agent: string | null;
|
|
74
|
+
/** ISO date-time. */
|
|
75
|
+
created_at: string;
|
|
76
|
+
/** ISO date-time of the last delivery the push service accepted, or `null`. */
|
|
77
|
+
last_success_at: string | null;
|
|
78
|
+
/** Failed deliveries in a row; the server removes the device at 10. */
|
|
79
|
+
failure_count: number;
|
|
80
|
+
}
|