Skip to content

feat: add notification API wrapper#3096

Open
MartinCupela wants to merge 7 commits intomasterfrom
feat/notification-api-wrapper
Open

feat: add notification API wrapper#3096
MartinCupela wants to merge 7 commits intomasterfrom
feat/notification-api-wrapper

Conversation

@MartinCupela
Copy link
Copy Markdown
Contributor

🎯 Goal

Summary

This PR introduces a new notifications facade hook: useNotificationApi at src/components/Notifications/hooks/useNotificationApi.ts, and migrates notification API usage in src to use it.

What changed

  1. Added typed notification API wrapper
  • Introduced useNotificationApi(): NotificationApi.
  • Added explicit exported types for reuse:
    • AddNotificationParams
    • NotificationIncidentDescriptor
    • AddNotification
    • RemoveNotification
    • StartNotificationTimeout
    • NotificationApi
  1. Added addNotification abstraction over client.notifications.add
  • Centralizes construction of notification payload/options.
  • Supports:
    • message, emitter, severity, duration, actions, error, context, tags, targetPanels, type, incident.
  • Notification target behavior:
    • Uses inferred panel from useNotificationTarget by default.
    • Allows overriding via targetPanels (including multiple panels).
    • If targetPanels are provided, inferred panel is ignored.
  • Type behavior:
    • Uses provided type as-is.
    • If type is omitted and incident is provided, type is generated from incident descriptor.
    • If type is provided, incident is optional and not required.
  1. Added other wrappers
  • removeNotification(id) delegates to client.notifications.remove(id).
  • startNotificationTimeout(id) delegates to client.notifications.startTimeout(id).
  1. Migrated direct notification manager usage
  1. Added IconMinus component and used it in NumericInput
  2. Introduced fixes to demo app

Why

  • Reduces API surface exposure of client.notifications across components.
  • Centralizes tagging/type/origin behavior in one place.
  • Improves consistency and makes future notification behavior changes cheaper.
  • Provides reusable typed contracts for components/plugins using notifications.

Tests

  • Updated and extended tests for:
    • useNotificationApi behavior (including target panel handling and type generation).
    • Notification lifecycle usage in NotificationList.
    • Dependent tests that needed mocking alignment after migration.
  • Typecheck and targeted notification/audio-related test suites pass.

@MartinCupela MartinCupela changed the title Feat/notification api wrapper feat: add notification API wrapper Apr 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Size Change: +1.05 kB (+0.17%)

Total Size: 615 kB

📦 View Changed
Filename Size Change
dist/cjs/emojis.js 2.96 kB +2 B (+0.07%)
dist/cjs/index.js 237 kB -197 B (-0.08%)
dist/cjs/WithAudioPlayback.js 43.4 kB +691 B (+1.62%)
dist/es/emojis.mjs 2.47 kB +3 B (+0.12%)
dist/es/index.mjs 235 kB -144 B (-0.06%)
dist/es/WithAudioPlayback.mjs 43.2 kB +694 B (+1.63%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.32 kB
dist/cjs/mp3-encoder.js 1.27 kB
dist/css/emoji-replacement.css 456 B
dist/css/index.css 45.5 kB
dist/es/audioProcessing.mjs 1.31 kB
dist/es/mp3-encoder.mjs 756 B

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant