@redacto.io/consent-sdk-react 5.1.0 → 5.3.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +24 -1
  3. package/dist/index.d.ts +24 -1
  4. package/dist/index.js +149 -206
  5. package/dist/index.mjs +148 -206
  6. package/dist/privacy-center.d.mts +81 -2
  7. package/dist/privacy-center.d.ts +81 -2
  8. package/dist/privacy-center.js +2823 -1272
  9. package/dist/privacy-center.mjs +2813 -1263
  10. package/package.json +1 -1
  11. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +16 -20
  12. package/src/RedactoNoticeConsent/api/index.ts +21 -103
  13. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +5 -4
  14. package/src/RedactoNoticeConsentInline/api/index.ts +64 -117
  15. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +174 -0
  16. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +3 -0
  17. package/src/RedactoPrivacyCenter/api/actions.ts +84 -0
  18. package/src/RedactoPrivacyCenter/api/client.ts +118 -0
  19. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +15 -0
  20. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +160 -0
  21. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +18 -0
  22. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +54 -0
  23. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +57 -0
  24. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +19 -0
  25. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +92 -0
  26. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +20 -0
  27. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +58 -0
  28. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +10 -0
  29. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +112 -0
  30. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +27 -0
  31. package/src/RedactoPrivacyCenter/components/PrivacyCenterLayout.tsx +3 -2
  32. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +2 -2
  33. package/src/RedactoPrivacyCenter/lib/api.ts +77 -0
  34. package/src/RedactoPrivacyCenter/lib/constants.ts +78 -1
  35. package/src/RedactoPrivacyCenter/lib/types.ts +148 -0
  36. package/src/RedactoPrivacyCenter/lib/utils.ts +3 -0
  37. package/src/RedactoPrivacyCenter/locales/en/translation.json +27 -1
  38. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +505 -0
  39. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +23 -1
  40. package/src/index.ts +5 -0
  41. package/src/privacy-center.ts +1 -0
  42. package/src/shared/api-errors.ts +171 -0
@@ -1718,6 +1718,511 @@ export const injectPCStyles = () => {
1718
1718
  .pc-request-submit-revoke-notice-text {
1719
1719
  color: var(--pc-text-primary);
1720
1720
  }
1721
+
1722
+ /* ─── Notification Hub ────────────────────────────────────────────────── */
1723
+
1724
+ .pc-notification-panel {
1725
+ background-color: var(--pc-bg-primary);
1726
+ border-radius: var(--pc-border-radius-lg);
1727
+ border: 1px solid var(--pc-border-color);
1728
+ overflow: hidden;
1729
+ width: 100%;
1730
+ display: flex;
1731
+ flex-direction: column;
1732
+ }
1733
+
1734
+ .pc-notification-panel-header {
1735
+ display: flex;
1736
+ align-items: center;
1737
+ justify-content: space-between;
1738
+ padding: 1rem 1.5rem;
1739
+ border-bottom: 1px solid var(--pc-border-color);
1740
+ }
1741
+
1742
+ .pc-notification-row {
1743
+ display: flex;
1744
+ align-items: flex-start;
1745
+ gap: 1rem;
1746
+ padding: 1rem 1.5rem;
1747
+ border-bottom: 1px solid var(--pc-border-color);
1748
+ transition: background-color 0.15s ease;
1749
+ cursor: pointer;
1750
+ background-color: transparent;
1751
+ }
1752
+
1753
+ .pc-notification-row[data-read="false"] {
1754
+ background-color: var(--pc-bg-secondary);
1755
+ }
1756
+
1757
+ .pc-notification-row:hover {
1758
+ background-color: var(--pc-bg-tertiary) !important;
1759
+ }
1760
+
1761
+ .pc-notification-dropdown-row {
1762
+ display: flex;
1763
+ align-items: flex-start;
1764
+ gap: 0.75rem;
1765
+ padding: 0.875rem 1rem;
1766
+ cursor: pointer;
1767
+ transition: background-color 0.15s ease;
1768
+ background-color: transparent;
1769
+ }
1770
+
1771
+ .pc-notification-dropdown-row[data-read="false"] {
1772
+ background-color: var(--pc-bg-secondary);
1773
+ }
1774
+
1775
+ .pc-notification-dropdown-row:hover {
1776
+ background-color: var(--pc-bg-tertiary) !important;
1777
+ }
1778
+
1779
+ .pc-notification-icon {
1780
+ border-radius: 50%;
1781
+ display: flex;
1782
+ align-items: center;
1783
+ justify-content: center;
1784
+ flex-shrink: 0;
1785
+ background-color: var(--pc-notification-icon-bg, transparent);
1786
+ }
1787
+
1788
+ .pc-notification-icon-lg {
1789
+ width: 40px;
1790
+ height: 40px;
1791
+ margin-top: 0.125rem;
1792
+ }
1793
+
1794
+ .pc-notification-icon-sm {
1795
+ width: 36px;
1796
+ height: 36px;
1797
+ }
1798
+
1799
+ .pc-notification-unread-dot-lg {
1800
+ display: inline-block;
1801
+ width: 6px;
1802
+ height: 6px;
1803
+ border-radius: 50%;
1804
+ background-color: var(--pc-primary);
1805
+ flex-shrink: 0;
1806
+ }
1807
+
1808
+ .pc-notification-unread-dot-sm {
1809
+ width: 8px;
1810
+ height: 8px;
1811
+ border-radius: 50%;
1812
+ background-color: var(--pc-primary);
1813
+ flex-shrink: 0;
1814
+ margin-top: 0.375rem;
1815
+ }
1816
+
1817
+ .pc-notification-badge {
1818
+ position: absolute;
1819
+ top: 2px;
1820
+ right: 2px;
1821
+ min-width: 16px;
1822
+ height: 16px;
1823
+ border-radius: 9999px;
1824
+ background-color: #ef4444;
1825
+ color: #ffffff;
1826
+ font-size: 0.625rem;
1827
+ font-weight: 700;
1828
+ display: flex;
1829
+ align-items: center;
1830
+ justify-content: center;
1831
+ padding: 0 4px;
1832
+ line-height: 1;
1833
+ pointer-events: none;
1834
+ }
1835
+
1836
+ .pc-notification-cta {
1837
+ font-weight: 500;
1838
+ cursor: pointer;
1839
+ transition: opacity 0.15s ease;
1840
+ line-height: 1.3;
1841
+ }
1842
+
1843
+ .pc-notification-cta:hover {
1844
+ opacity: 0.85;
1845
+ }
1846
+
1847
+ .pc-notification-cta-sm {
1848
+ font-size: 0.6875rem;
1849
+ padding: 0.1875rem 0.5rem;
1850
+ border-radius: 0.25rem;
1851
+ }
1852
+
1853
+ .pc-notification-cta-lg {
1854
+ font-size: 0.75rem;
1855
+ padding: 0.25rem 0.75rem;
1856
+ border-radius: 0.375rem;
1857
+ }
1858
+
1859
+ .pc-notification-cta--primary {
1860
+ border: 1px solid var(--pc-primary);
1861
+ background-color: var(--pc-primary);
1862
+ color: #ffffff;
1863
+ }
1864
+
1865
+ .pc-notification-cta--danger {
1866
+ border: 1px solid #dc2626;
1867
+ background-color: #dc2626;
1868
+ color: #ffffff;
1869
+ }
1870
+
1871
+ .pc-notification-cta--secondary {
1872
+ border: 1px solid var(--pc-border-color);
1873
+ background-color: transparent;
1874
+ color: var(--pc-text-secondary);
1875
+ }
1876
+
1877
+ .pc-notification-status-badge {
1878
+ font-size: 0.6875rem;
1879
+ font-weight: 500;
1880
+ padding: 0.125rem 0.5rem;
1881
+ border-radius: 9999px;
1882
+ }
1883
+
1884
+ .pc-notification-bell-btn {
1885
+ display: flex;
1886
+ align-items: center;
1887
+ justify-content: center;
1888
+ width: 32px;
1889
+ height: 32px;
1890
+ border: none;
1891
+ background: none;
1892
+ cursor: pointer;
1893
+ border-radius: 0.5rem;
1894
+ color: var(--pc-text-primary);
1895
+ transition: color 0.3s ease, background-color 0.15s ease;
1896
+ padding: 0;
1897
+ }
1898
+
1899
+ .pc-notification-bell-btn:hover {
1900
+ background-color: var(--pc-bg-hover);
1901
+ }
1902
+
1903
+ .pc-notification-filter-tab {
1904
+ background: none;
1905
+ border: none;
1906
+ font-size: 0.8125rem;
1907
+ cursor: pointer;
1908
+ padding: 0.75rem 1rem;
1909
+ transition: color 0.15s ease, border-color 0.15s ease;
1910
+ }
1911
+
1912
+ .pc-notification-pagination-btn {
1913
+ font-size: 0.8125rem;
1914
+ font-weight: 500;
1915
+ padding: 0.375rem 0.75rem;
1916
+ border-radius: 0.375rem;
1917
+ border: 1px solid var(--pc-border-color);
1918
+ background-color: transparent;
1919
+ cursor: pointer;
1920
+ }
1921
+
1922
+ .pc-notification-link-btn {
1923
+ background: none;
1924
+ border: none;
1925
+ color: var(--pc-primary);
1926
+ font-size: 0.8125rem;
1927
+ font-weight: 500;
1928
+ cursor: pointer;
1929
+ padding: 0;
1930
+ }
1931
+
1932
+ .pc-notification-refresh-btn {
1933
+ display: flex;
1934
+ align-items: center;
1935
+ justify-content: center;
1936
+ background: none;
1937
+ border: none;
1938
+ color: var(--pc-text-secondary);
1939
+ padding: 0.25rem;
1940
+ border-radius: 0.375rem;
1941
+ transition: color 0.15s ease;
1942
+ cursor: pointer;
1943
+ }
1944
+
1945
+ .pc-notification-refresh-btn:hover:not(:disabled) {
1946
+ color: var(--pc-text-primary);
1947
+ }
1948
+
1949
+ .pc-notification-refresh-btn:disabled {
1950
+ cursor: default;
1951
+ opacity: 0.5;
1952
+ }
1953
+
1954
+ .pc-notification-refresh-btn--spinning > svg {
1955
+ animation: pc-spin 1s linear infinite;
1956
+ }
1957
+
1958
+ /* Keyboard focus rings for Notification Hub interactive controls */
1959
+ .pc-notification-cta:focus-visible,
1960
+ .pc-notification-bell-btn:focus-visible:not(:disabled),
1961
+ .pc-notification-filter-tab:focus-visible:not(:disabled),
1962
+ .pc-notification-pagination-btn:focus-visible:not(:disabled),
1963
+ .pc-notification-link-btn:focus-visible:not(:disabled),
1964
+ .pc-notification-refresh-btn:focus-visible:not(:disabled) {
1965
+ outline: 2px solid var(--pc-border-color-focus);
1966
+ outline-offset: 2px;
1967
+ }
1968
+
1969
+ .pc-notification-stat-card {
1970
+ display: flex;
1971
+ flex-direction: column;
1972
+ align-items: center;
1973
+ justify-content: center;
1974
+ gap: 0.375rem;
1975
+ padding: 1.25rem 1rem;
1976
+ background-color: var(--pc-bg-primary);
1977
+ border: 1px solid var(--pc-border-color);
1978
+ border-radius: var(--pc-border-radius-lg);
1979
+ }
1980
+
1981
+ .pc-notification-back-btn {
1982
+ display: inline-flex;
1983
+ align-items: center;
1984
+ gap: 0.25rem;
1985
+ background: none;
1986
+ border: none;
1987
+ color: var(--pc-primary);
1988
+ font-size: 0.8125rem;
1989
+ font-weight: 500;
1990
+ cursor: pointer;
1991
+ padding: 0.25rem 0;
1992
+ align-self: flex-start;
1993
+ }
1994
+
1995
+ .pc-notification-empty-state {
1996
+ padding: 3rem;
1997
+ text-align: center;
1998
+ color: var(--pc-text-secondary);
1999
+ font-size: 0.875rem;
2000
+ }
2001
+
2002
+ .pc-notification-dropdown-empty-state {
2003
+ padding: 2rem 1rem;
2004
+ text-align: center;
2005
+ color: var(--pc-text-secondary);
2006
+ font-size: 0.8125rem;
2007
+ }
2008
+
2009
+ .pc-notification-dropdown-footer {
2010
+ padding: 0.75rem 1rem;
2011
+ border-top: 1px solid var(--pc-border-color);
2012
+ display: flex;
2013
+ justify-content: center;
2014
+ }
2015
+
2016
+ .pc-notification-page {
2017
+ width: 100%;
2018
+ display: flex;
2019
+ flex-direction: column;
2020
+ gap: 1.25rem;
2021
+ }
2022
+
2023
+ .pc-notification-stats-grid {
2024
+ display: grid;
2025
+ grid-template-columns: repeat(4, 1fr);
2026
+ gap: 1rem;
2027
+ width: 100%;
2028
+ }
2029
+
2030
+ .pc-notification-stat-value {
2031
+ font-size: 1.75rem;
2032
+ font-weight: 700;
2033
+ line-height: 1.2;
2034
+ }
2035
+
2036
+ .pc-notification-stat-label {
2037
+ font-size: 0.8125rem;
2038
+ color: var(--pc-text-secondary);
2039
+ font-weight: 500;
2040
+ }
2041
+
2042
+ .pc-notification-bell-wrapper {
2043
+ display: inline-flex;
2044
+ position: relative;
2045
+ }
2046
+
2047
+ .pc-notification-popover-offset {
2048
+ transform: translateX(-65px) !important;
2049
+ }
2050
+
2051
+ .pc-notification-dropdown {
2052
+ width: 380px;
2053
+ max-height: 480px;
2054
+ display: flex;
2055
+ flex-direction: column;
2056
+ padding: 0;
2057
+ }
2058
+
2059
+ .pc-notification-dropdown-title {
2060
+ font-size: 0.9375rem;
2061
+ font-weight: 600;
2062
+ color: var(--pc-text-primary);
2063
+ }
2064
+
2065
+ .pc-notification-header-actions {
2066
+ display: flex;
2067
+ align-items: center;
2068
+ gap: 0.75rem;
2069
+ }
2070
+
2071
+ .pc-notification-dropdown-list {
2072
+ overflow-y: auto;
2073
+ flex: 1;
2074
+ }
2075
+
2076
+ .pc-notification-link-btn-arrow {
2077
+ display: flex;
2078
+ align-items: center;
2079
+ gap: 0.25rem;
2080
+ }
2081
+
2082
+ .pc-notification-dropdown-row:not(:last-child) {
2083
+ border-bottom: 1px solid var(--pc-border-color);
2084
+ }
2085
+
2086
+ .pc-notification-dropdown-content {
2087
+ flex: 1;
2088
+ min-width: 0;
2089
+ }
2090
+
2091
+ .pc-notification-dropdown-title-text {
2092
+ margin: 0;
2093
+ font-size: 0.8125rem;
2094
+ line-height: 1.4;
2095
+ font-weight: 400;
2096
+ color: var(--pc-text-primary);
2097
+ }
2098
+
2099
+ .pc-notification-dropdown-row[data-read="false"] .pc-notification-dropdown-title-text {
2100
+ font-weight: 600;
2101
+ }
2102
+
2103
+ .pc-notification-status-badge {
2104
+ color: #2563eb;
2105
+ background-color: #eff6ff;
2106
+ }
2107
+
2108
+ .pc-notification-dropdown-description {
2109
+ margin: 0.125rem 0 0;
2110
+ font-size: 0.75rem;
2111
+ line-height: 1.4;
2112
+ color: var(--pc-text-secondary);
2113
+ overflow: hidden;
2114
+ text-overflow: ellipsis;
2115
+ white-space: nowrap;
2116
+ }
2117
+
2118
+ .pc-notification-dropdown-time {
2119
+ margin: 0.25rem 0 0;
2120
+ font-size: 0.6875rem;
2121
+ color: var(--pc-text-tertiary);
2122
+ }
2123
+
2124
+ .pc-notification-dropdown-ctas {
2125
+ display: flex;
2126
+ gap: 0.375rem;
2127
+ margin-top: 0.375rem;
2128
+ }
2129
+
2130
+ .pc-notification-row-content {
2131
+ flex: 1;
2132
+ min-width: 0;
2133
+ }
2134
+
2135
+ .pc-notification-row-title-line {
2136
+ display: flex;
2137
+ align-items: center;
2138
+ gap: 0.5rem;
2139
+ flex-wrap: wrap;
2140
+ margin-bottom: 0.25rem;
2141
+ }
2142
+
2143
+ .pc-notification-row-title {
2144
+ font-size: 0.875rem;
2145
+ font-weight: 400;
2146
+ color: var(--pc-text-primary);
2147
+ }
2148
+
2149
+ .pc-notification-row[data-read="false"] .pc-notification-row-title {
2150
+ font-weight: 600;
2151
+ }
2152
+
2153
+ .pc-notification-row-description {
2154
+ margin: 0;
2155
+ font-size: 0.8125rem;
2156
+ color: var(--pc-text-secondary);
2157
+ line-height: 1.5;
2158
+ }
2159
+
2160
+ .pc-notification-row-ctas {
2161
+ display: flex;
2162
+ gap: 0.5rem;
2163
+ margin-top: 0.5rem;
2164
+ }
2165
+
2166
+ .pc-notification-row-time {
2167
+ font-size: 0.75rem;
2168
+ color: var(--pc-text-tertiary);
2169
+ flex-shrink: 0;
2170
+ white-space: nowrap;
2171
+ margin-top: 0.125rem;
2172
+ }
2173
+
2174
+ .pc-notification-panel-title {
2175
+ margin: 0;
2176
+ font-size: 1rem;
2177
+ font-weight: 600;
2178
+ color: var(--pc-text-primary);
2179
+ }
2180
+
2181
+ .pc-notification-panel-count {
2182
+ margin-left: 0.5rem;
2183
+ font-size: 0.75rem;
2184
+ font-weight: 500;
2185
+ color: var(--pc-text-tertiary);
2186
+ }
2187
+
2188
+ .pc-notification-filter-tabs {
2189
+ display: flex;
2190
+ gap: 0;
2191
+ border-bottom: 1px solid var(--pc-border-color);
2192
+ padding: 0 1.5rem;
2193
+ }
2194
+
2195
+ .pc-notification-filter-tab {
2196
+ border-bottom: 2px solid transparent;
2197
+ color: var(--pc-text-secondary);
2198
+ font-weight: 400;
2199
+ }
2200
+
2201
+ .pc-notification-filter-tab[data-active="true"] {
2202
+ border-bottom-color: var(--pc-primary);
2203
+ color: var(--pc-primary);
2204
+ font-weight: 600;
2205
+ }
2206
+
2207
+ .pc-notification-pagination {
2208
+ display: flex;
2209
+ align-items: center;
2210
+ justify-content: center;
2211
+ gap: 0.75rem;
2212
+ padding: 1rem 1.5rem;
2213
+ border-top: 1px solid var(--pc-border-color);
2214
+ }
2215
+
2216
+ .pc-notification-pagination-range {
2217
+ font-size: 0.75rem;
2218
+ color: var(--pc-text-secondary);
2219
+ }
2220
+
2221
+ .pc-notification-pagination-btn:disabled {
2222
+ cursor: default;
2223
+ color: var(--pc-text-tertiary);
2224
+ opacity: 0.5;
2225
+ }
1721
2226
  `;
1722
2227
 
1723
2228
  document.head.appendChild(style);
@@ -8,6 +8,7 @@ export interface PCPopoverProps {
8
8
  shadow?: 'sm' | 'md' | 'lg';
9
9
  className?: string;
10
10
  style?: CSSProperties;
11
+ onOpen?: () => void;
11
12
  }
12
13
 
13
14
  export function PCPopover({
@@ -17,6 +18,7 @@ export function PCPopover({
17
18
  shadow = 'sm',
18
19
  className = '',
19
20
  style = {},
21
+ onOpen,
20
22
  }: PCPopoverProps) {
21
23
  const [isOpen, setIsOpen] = useState(false);
22
24
  const [position, setPosition] = useState({ top: 0, left: 0 });
@@ -150,7 +152,27 @@ export function PCPopover({
150
152
  <>
151
153
  <div
152
154
  ref={triggerRef}
153
- onClick={() => setIsOpen(!isOpen)}
155
+ role="button"
156
+ tabIndex={0}
157
+ aria-expanded={isOpen}
158
+ aria-haspopup="dialog"
159
+ onClick={() => {
160
+ const opening = !isOpen;
161
+ setIsOpen(opening);
162
+ if (opening && onOpen) {
163
+ onOpen();
164
+ }
165
+ }}
166
+ onKeyDown={(e) => {
167
+ if (e.key === 'Enter' || e.key === ' ') {
168
+ e.preventDefault();
169
+ const opening = !isOpen;
170
+ setIsOpen(opening);
171
+ if (opening && onOpen) {
172
+ onOpen();
173
+ }
174
+ }
175
+ }}
154
176
  style={{ display: 'inline-block', cursor: 'pointer' }}
155
177
  >
156
178
  {children}
package/src/index.ts CHANGED
@@ -10,3 +10,8 @@ export type {
10
10
  ConsentFlowState,
11
11
  GuardianVerificationErrorCode,
12
12
  } from "./RedactoNoticeConsent/api/types";
13
+
14
+ // API errors — consumers can narrow caught errors to ApiError to read
15
+ // the typed error code, status, or developer-facing server message.
16
+ export { ApiError } from "./shared/api-errors";
17
+ export type { ApiErrorCode } from "./shared/api-errors";
@@ -6,6 +6,7 @@ export { PrivacyCenterConsentManagerPage } from './RedactoPrivacyCenter/PrivacyC
6
6
  export { PrivacyCenterFormPage } from './RedactoPrivacyCenter/PrivacyCenterFormPage';
7
7
  export { PrivacyCenterActivityPage } from './RedactoPrivacyCenter/PrivacyCenterActivityPage';
8
8
  export { PrivacyCenterCaseDetailsPage } from './RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage';
9
+ export { NotificationsPage } from './RedactoPrivacyCenter/NotificationsPage';
9
10
 
10
11
  // Privacy Center - Headless Core (API client & types)
11
12
  export { createConsentClient } from './RedactoPrivacyCenter/api/client';