@eifi1/ui-kit 0.35.0 → 0.37.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 (269) hide show
  1. package/README.md +35 -5
  2. package/dist/admin/role-select.d.ts +3 -2
  3. package/dist/admin/role-select.js +2 -0
  4. package/dist/admin/role-select.js.map +1 -1
  5. package/dist/components/amount-input.d.ts +2 -2
  6. package/dist/components/amount-input.js.map +1 -1
  7. package/dist/components/autocomplete.d.ts +2 -2
  8. package/dist/components/autocomplete.js +2 -1
  9. package/dist/components/autocomplete.js.map +1 -1
  10. package/dist/components/button-look.d.ts +1 -1
  11. package/dist/components/button-look.js +9 -4
  12. package/dist/components/button-look.js.map +1 -1
  13. package/dist/components/checkbox-group.d.ts +5 -2
  14. package/dist/components/checkbox-group.js +15 -4
  15. package/dist/components/checkbox-group.js.map +1 -1
  16. package/dist/components/column-mapper.d.ts +5 -3
  17. package/dist/components/column-mapper.js +2 -0
  18. package/dist/components/column-mapper.js.map +1 -1
  19. package/dist/components/combobox.d.ts +2 -2
  20. package/dist/components/combobox.js +2 -1
  21. package/dist/components/combobox.js.map +1 -1
  22. package/dist/components/country-select.d.ts +3 -3
  23. package/dist/components/country-select.js +3 -0
  24. package/dist/components/country-select.js.map +1 -1
  25. package/dist/components/currency-select.d.ts +3 -2
  26. package/dist/components/currency-select.js +10 -1
  27. package/dist/components/currency-select.js.map +1 -1
  28. package/dist/components/date-field.d.ts +2 -1
  29. package/dist/components/date-field.js.map +1 -1
  30. package/dist/components/date-picker.js +3 -0
  31. package/dist/components/date-picker.js.map +1 -1
  32. package/dist/components/date-range-picker.js +3 -0
  33. package/dist/components/date-range-picker.js.map +1 -1
  34. package/dist/components/entity-combobox.d.ts +2 -2
  35. package/dist/components/entity-combobox.js +2 -1
  36. package/dist/components/entity-combobox.js.map +1 -1
  37. package/dist/components/field-parts.d.ts +66 -11
  38. package/dist/components/field-parts.js +32 -10
  39. package/dist/components/field-parts.js.map +1 -1
  40. package/dist/components/field-strip.d.ts +3 -2
  41. package/dist/components/field-strip.js +2 -1
  42. package/dist/components/field-strip.js.map +1 -1
  43. package/dist/components/field.d.ts +3 -2
  44. package/dist/components/field.js +24 -15
  45. package/dist/components/field.js.map +1 -1
  46. package/dist/components/help-popover.d.ts +9 -7
  47. package/dist/components/help-popover.js.map +1 -1
  48. package/dist/components/icon-picker.d.ts +3 -2
  49. package/dist/components/icon-picker.js +3 -0
  50. package/dist/components/icon-picker.js.map +1 -1
  51. package/dist/components/inline-entity-combobox.d.ts +2 -2
  52. package/dist/components/inline-entity-combobox.js +2 -1
  53. package/dist/components/inline-entity-combobox.js.map +1 -1
  54. package/dist/components/input.d.ts +2 -2
  55. package/dist/components/input.js +2 -1
  56. package/dist/components/input.js.map +1 -1
  57. package/dist/components/month-picker.d.ts +2 -1
  58. package/dist/components/month-picker.js +8 -1
  59. package/dist/components/month-picker.js.map +1 -1
  60. package/dist/components/multi-entity-combobox.d.ts +2 -2
  61. package/dist/components/multi-entity-combobox.js +2 -1
  62. package/dist/components/multi-entity-combobox.js.map +1 -1
  63. package/dist/components/multi-select.d.ts +2 -2
  64. package/dist/components/multi-select.js +3 -0
  65. package/dist/components/multi-select.js.map +1 -1
  66. package/dist/components/number-input.d.ts +2 -2
  67. package/dist/components/number-input.js.map +1 -1
  68. package/dist/components/numeric-field.d.ts +5 -2
  69. package/dist/components/numeric-field.js +4 -1
  70. package/dist/components/numeric-field.js.map +1 -1
  71. package/dist/components/one-time-code-input.d.ts +2 -1
  72. package/dist/components/one-time-code-input.js +2 -1
  73. package/dist/components/one-time-code-input.js.map +1 -1
  74. package/dist/components/phone-input.d.ts +1 -1
  75. package/dist/components/phone-input.js +4 -0
  76. package/dist/components/phone-input.js.map +1 -1
  77. package/dist/components/popover.js +1 -1
  78. package/dist/components/popover.js.map +1 -1
  79. package/dist/components/select.d.ts +4 -3
  80. package/dist/components/select.js +2 -1
  81. package/dist/components/select.js.map +1 -1
  82. package/dist/components/slider.d.ts +3 -2
  83. package/dist/components/slider.js +7 -1
  84. package/dist/components/slider.js.map +1 -1
  85. package/dist/components/stat-tile.js +2 -11
  86. package/dist/components/stat-tile.js.map +1 -1
  87. package/dist/components/swatch-picker.d.ts +3 -2
  88. package/dist/components/swatch-picker.js +3 -0
  89. package/dist/components/swatch-picker.js.map +1 -1
  90. package/dist/components/text-link.js +3 -1
  91. package/dist/components/text-link.js.map +1 -1
  92. package/dist/components/textarea.d.ts +2 -1
  93. package/dist/components/textarea.js +9 -3
  94. package/dist/components/textarea.js.map +1 -1
  95. package/dist/components/toggle-group.d.ts +2 -2
  96. package/dist/components/toggle-group.js +7 -3
  97. package/dist/components/toggle-group.js.map +1 -1
  98. package/dist/eslint/index.js +1 -1
  99. package/dist/eslint/role-utilities.d.ts +34 -2
  100. package/dist/eslint/role-utilities.js +30 -9
  101. package/dist/eslint/role-utilities.js.map +1 -1
  102. package/dist/i18n/defaults.js +5 -1
  103. package/dist/i18n/defaults.js.map +1 -1
  104. package/dist/i18n/german.js +97 -1
  105. package/dist/i18n/german.js.map +1 -1
  106. package/dist/i18n/kit-labels.d.ts +16 -0
  107. package/dist/i18n/kit-labels.js +21 -1
  108. package/dist/i18n/kit-labels.js.map +1 -1
  109. package/dist/i18n/locales/en.js +103 -2
  110. package/dist/i18n/locales/en.js.map +3 -3
  111. package/dist/i18n/locales/es.js +95 -1
  112. package/dist/i18n/locales/es.js.map +1 -1
  113. package/dist/i18n/locales/fr.js +96 -1
  114. package/dist/i18n/locales/fr.js.map +1 -1
  115. package/dist/i18n/locales/hu.js +95 -1
  116. package/dist/i18n/locales/hu.js.map +1 -1
  117. package/dist/i18n/locales/it.js +96 -1
  118. package/dist/i18n/locales/it.js.map +1 -1
  119. package/dist/i18n/locales/zh.js +95 -1
  120. package/dist/i18n/locales/zh.js.map +1 -1
  121. package/dist/i18n/review.js +13 -0
  122. package/dist/i18n/review.js.map +1 -1
  123. package/dist/i18n/shared-labels.js +3 -1
  124. package/dist/i18n/shared-labels.js.map +1 -1
  125. package/dist/index.d.ts +21 -0
  126. package/dist/index.js +38 -0
  127. package/dist/index.js.map +1 -1
  128. package/dist/lib/device-settings.d.ts +72 -0
  129. package/dist/lib/device-settings.js +64 -0
  130. package/dist/lib/device-settings.js.map +1 -0
  131. package/dist/lib/plain-text.d.ts +11 -0
  132. package/dist/lib/plain-text.js +16 -0
  133. package/dist/lib/plain-text.js.map +1 -0
  134. package/dist/lib/safe-storage.d.ts +6 -0
  135. package/dist/lib/safe-storage.js +11 -0
  136. package/dist/lib/safe-storage.js.map +1 -1
  137. package/dist/notifications/notification-parts.d.ts +39 -0
  138. package/dist/notifications/notification-parts.js +47 -0
  139. package/dist/notifications/notification-parts.js.map +1 -0
  140. package/dist/notifications/notification-types-setting.d.ts +62 -0
  141. package/dist/notifications/notification-types-setting.js +192 -0
  142. package/dist/notifications/notification-types-setting.js.map +1 -0
  143. package/dist/notifications/notification-types.d.ts +75 -0
  144. package/dist/notifications/notification-types.js +2 -0
  145. package/dist/notifications/notification-types.js.map +1 -0
  146. package/dist/notifications/notifications-labels.d.ts +131 -0
  147. package/dist/notifications/notifications-labels.js +83 -0
  148. package/dist/notifications/notifications-labels.js.map +1 -0
  149. package/dist/notifications/push-device-setting.d.ts +37 -0
  150. package/dist/notifications/push-device-setting.js +164 -0
  151. package/dist/notifications/push-device-setting.js.map +1 -0
  152. package/dist/notifications/push-devices-setting.d.ts +44 -0
  153. package/dist/notifications/push-devices-setting.js +203 -0
  154. package/dist/notifications/push-devices-setting.js.map +1 -0
  155. package/dist/notifications/quiet-hours-setting.d.ts +47 -0
  156. package/dist/notifications/quiet-hours-setting.js +131 -0
  157. package/dist/notifications/quiet-hours-setting.js.map +1 -0
  158. package/dist/notifications/time-zone-select.d.ts +50 -0
  159. package/dist/notifications/time-zone-select.js +76 -0
  160. package/dist/notifications/time-zone-select.js.map +1 -0
  161. package/dist/notifications/unsubscribe-panel.d.ts +53 -0
  162. package/dist/notifications/unsubscribe-panel.js +139 -0
  163. package/dist/notifications/unsubscribe-panel.js.map +1 -0
  164. package/dist/notifications/use-push-device.d.ts +122 -0
  165. package/dist/notifications/use-push-device.js +230 -0
  166. package/dist/notifications/use-push-device.js.map +1 -0
  167. package/dist/rhf/fields.d.ts +26 -19
  168. package/dist/rhf/fields.js +51 -22
  169. package/dist/rhf/fields.js.map +1 -1
  170. package/dist/settings/device-reset-setting-labels.d.ts +3 -0
  171. package/dist/settings/device-reset-setting-labels.js +15 -0
  172. package/dist/settings/device-reset-setting-labels.js.map +1 -0
  173. package/dist/settings/device-reset-setting.d.ts +58 -0
  174. package/dist/settings/device-reset-setting.js +51 -0
  175. package/dist/settings/device-reset-setting.js.map +1 -0
  176. package/dist/shell/app-shell.js +5 -0
  177. package/dist/shell/app-shell.js.map +1 -1
  178. package/dist/theme/contrast-tokens.d.ts +42 -4
  179. package/dist/theme/contrast-tokens.js +56 -9
  180. package/dist/theme/contrast-tokens.js.map +1 -1
  181. package/dist/theme/contrast.d.ts +4 -2
  182. package/dist/theme/contrast.js +13 -0
  183. package/dist/theme/contrast.js.map +1 -1
  184. package/dist/theme/palette-derive.d.ts +15 -1
  185. package/dist/theme/palette-derive.js +37 -8
  186. package/dist/theme/palette-derive.js.map +1 -1
  187. package/dist/theme/palette-presets.d.ts +2 -1
  188. package/dist/theme/palette-presets.js +5 -5
  189. package/dist/theme/palette-presets.js.map +1 -1
  190. package/dist/theme/palette-store.js +6 -0
  191. package/dist/theme/palette-store.js.map +1 -1
  192. package/dist/theme/text-size.js +6 -0
  193. package/dist/theme/text-size.js.map +1 -1
  194. package/dist/theme/theme-store.js +6 -0
  195. package/dist/theme/theme-store.js.map +1 -1
  196. package/package.json +1 -1
  197. package/src/admin/role-select.tsx +4 -1
  198. package/src/components/amount-input.tsx +2 -1
  199. package/src/components/autocomplete.tsx +5 -2
  200. package/src/components/button-look.ts +15 -5
  201. package/src/components/checkbox-group.tsx +22 -4
  202. package/src/components/column-mapper.tsx +6 -2
  203. package/src/components/combobox.tsx +5 -2
  204. package/src/components/country-select.tsx +6 -1
  205. package/src/components/currency-select.tsx +12 -3
  206. package/src/components/date-field.tsx +2 -2
  207. package/src/components/date-picker.tsx +3 -0
  208. package/src/components/date-range-picker.tsx +3 -0
  209. package/src/components/entity-combobox.tsx +5 -2
  210. package/src/components/field-parts.tsx +107 -19
  211. package/src/components/field-strip.tsx +4 -3
  212. package/src/components/field.tsx +28 -15
  213. package/src/components/help-popover.tsx +9 -7
  214. package/src/components/icon-picker.tsx +8 -3
  215. package/src/components/inline-entity-combobox.tsx +5 -2
  216. package/src/components/input.tsx +4 -2
  217. package/src/components/month-picker.tsx +10 -3
  218. package/src/components/multi-entity-combobox.tsx +5 -2
  219. package/src/components/multi-select.tsx +6 -1
  220. package/src/components/number-input.tsx +2 -2
  221. package/src/components/numeric-field.ts +10 -2
  222. package/src/components/one-time-code-input.tsx +5 -3
  223. package/src/components/phone-input.tsx +4 -0
  224. package/src/components/popover.tsx +3 -1
  225. package/src/components/select.tsx +6 -3
  226. package/src/components/slider.tsx +10 -3
  227. package/src/components/stat-tile.tsx +3 -18
  228. package/src/components/swatch-picker.tsx +9 -4
  229. package/src/components/text-link.tsx +3 -1
  230. package/src/components/textarea.tsx +11 -4
  231. package/src/components/toggle-group.tsx +21 -5
  232. package/src/eslint/role-utilities.ts +67 -11
  233. package/src/i18n/defaults.ts +4 -0
  234. package/src/i18n/german.ts +113 -0
  235. package/src/i18n/kit-labels.tsx +52 -1
  236. package/src/i18n/locales/en.ts +6 -0
  237. package/src/i18n/locales/es.ts +106 -0
  238. package/src/i18n/locales/fr.ts +106 -0
  239. package/src/i18n/locales/hu.ts +104 -0
  240. package/src/i18n/locales/it.ts +105 -0
  241. package/src/i18n/locales/zh.ts +96 -0
  242. package/src/i18n/review.ts +13 -0
  243. package/src/i18n/shared-labels.ts +2 -0
  244. package/src/index.ts +50 -0
  245. package/src/lib/device-settings.ts +146 -0
  246. package/src/lib/plain-text.ts +22 -0
  247. package/src/lib/safe-storage.ts +16 -0
  248. package/src/notifications/notification-parts.tsx +83 -0
  249. package/src/notifications/notification-types-setting.tsx +309 -0
  250. package/src/notifications/notification-types.ts +80 -0
  251. package/src/notifications/notifications-labels.ts +238 -0
  252. package/src/notifications/push-device-setting.tsx +224 -0
  253. package/src/notifications/push-devices-setting.tsx +306 -0
  254. package/src/notifications/quiet-hours-setting.tsx +185 -0
  255. package/src/notifications/time-zone-select.tsx +126 -0
  256. package/src/notifications/unsubscribe-panel.tsx +203 -0
  257. package/src/notifications/use-push-device.ts +392 -0
  258. package/src/rhf/fields.tsx +77 -29
  259. package/src/settings/device-reset-setting-labels.ts +20 -0
  260. package/src/settings/device-reset-setting.tsx +119 -0
  261. package/src/shell/app-shell.tsx +8 -0
  262. package/src/theme/contrast-tokens.ts +106 -12
  263. package/src/theme/contrast.ts +30 -4
  264. package/src/theme/palette-derive.ts +68 -7
  265. package/src/theme/palette-presets.ts +9 -6
  266. package/src/theme/palette-store.ts +12 -0
  267. package/src/theme/text-size.ts +8 -0
  268. package/src/theme/theme-store.ts +10 -0
  269. package/tokens.css +38 -4
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/notifications/notifications-labels.ts"],"sourcesContent":["// The words of the notification cards (docs/notifications-harmonization.md §4.2), in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, so `en` loads as one chunk like the other languages\n// (0.34, KS U8). The cards read it through `useKitLabels(\"notifications\", …)`.\n\n/** The ten IANA regions `Intl` lists zones under — keksdose's `tz_region_*` — in the\n * kit's words. A region a runtime adds later keeps its IANA name. */\nexport interface NotificationRegionLabels {\n Africa: string;\n America: string;\n Antarctica: string;\n Arctic: string;\n Asia: string;\n Atlantic: string;\n Australia: string;\n Europe: string;\n Indian: string;\n Pacific: string;\n}\n\n/**\n * Every string the notification parts render — the `notifications` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`: the types card,\n * quiet hours and the zone picker, this device's push, the device list, and the\n * unsubscribe page. Cancel is `common.cancel`.\n */\nexport interface NotificationsLabels {\n /* ── The types card ─────────────────────────────────────────────────── */\n /** The types card's title. */\n typesTitle: string;\n /** The line under it. */\n typesDescription: string;\n /** The e-mail switch under a type that offers mail. */\n byEmail: string;\n /** Under every e-mail switch while the account's address is unverified (decision 16):\n * no notification mail goes to an unverified address. */\n emailUnverified: string;\n /** The digest's cadence select. */\n digestCadence: string;\n digestWeekly: string;\n digestMonthly: string;\n /** While the settings load. */\n typesLoading: string;\n /** The server answered no types for this account. */\n typesEmpty: string;\n\n /* ── Quiet hours ────────────────────────────────────────────────────── */\n quietTitle: string;\n /** The line under the title; `inbox`: the app keeps an inbox, which a held push still\n * reaches. */\n quietDescription: (inbox: boolean) => string;\n /** The start time's label. */\n quietFrom: string;\n /** The end time's label. */\n quietUntil: string;\n /** One time set, the other not: quiet hours fail open until both are. */\n quietIncomplete: string;\n /** The zone picker's label. */\n timeZone: string;\n /** Given the device's zone, as the picker names it, when it differs from the one the\n * server applies. */\n deviceZone: (zone: string) => string;\n /** The button that takes the device's zone. */\n useDeviceZone: string;\n /** The zone picker's region headings. */\n regions: NotificationRegionLabels;\n\n /* ── This device ────────────────────────────────────────────────────── */\n pushTitle: string;\n pushDescription: string;\n /** The browser has no push. */\n unsupported: string;\n /** iOS outside the installed app, given the app's name. */\n iosInstall: (app: string) => string;\n /** The server has no VAPID keys. */\n notConfigured: string;\n /** The browser's permission is denied. */\n blocked: string;\n /** This device gets notifications for the signed-in account. */\n on: string;\n off: string;\n /** This browser's subscription belongs to another account. */\n otherAccount: string;\n enable: string;\n disable: string;\n sendTest: string;\n /** Turning on did not finish (the permission prompt dismissed, a refusal). */\n enableFailed: string;\n /** No service worker, or one that is not ready in 10 s. */\n noServiceWorker: string;\n /** The browser's push service did not answer in 15 s. */\n pushTimeout: string;\n /** Given how many devices the push service accepted the test for (≥ 1). */\n testSent: (count: number) => string;\n /** The test reached no device. */\n testNone: string;\n testFailed: string;\n /** The explainer before the browser's one permission prompt. */\n explainerTitle: string;\n explainerBody: (app: string) => string;\n explainerHint: string;\n explainerContinue: string;\n\n /* ── The device list ────────────────────────────────────────────────── */\n devicesTitle: string;\n devicesDescription: string;\n devicesLoading: string;\n devicesEmpty: string;\n /** A device whose user agent says nothing the kit recognises. */\n unknownDevice: string;\n /** The chip on this browser's row. */\n thisDevice: string;\n /** Given the registration date, formatted. */\n added: (date: string) => string;\n /** Given the last accepted delivery, formatted. */\n lastDelivery: (date: string) => string;\n noDelivery: string;\n /** Given the failed deliveries in a row (≥ 1). */\n failures: (count: number) => string;\n /** A row's button, visible text — and the confirm's answer. */\n remove: string;\n /** The same button's accessible name, given the device: it starts with `remove`. */\n removeItem: (device: string) => string;\n /** The question the row asks before it removes. */\n removePrompt: string;\n\n /* ── The unsubscribe page ───────────────────────────────────────────── */\n unsubscribeTitle: string;\n /** Given the type's name in the app's words. */\n unsubscribeAbout: (type: string) => string;\n /** No type name to give. */\n unsubscribeGeneric: string;\n stopThese: string;\n stopAll: (app: string) => string;\n stoppedThese: string;\n stoppedAll: (app: string) => string;\n /** Account mail is not a notification, and keeps coming. */\n accountMail: string;\n turnBackOn: string;\n openSettings: string;\n /** A token the server refused, or one that does not parse. */\n invalidLink: string;\n\n /* ── Every card ─────────────────────────────────────────────────────── */\n /** A request failed, and the app had no words of its own. */\n failed: string;\n}\n\nexport const DEFAULT_NOTIFICATIONS_LABELS: NotificationsLabels = {\n typesTitle: \"Notify me about\",\n typesDescription: \"Choose what you hear about, and how.\",\n byEmail: \"By e-mail\",\n emailUnverified: \"Confirm your address to receive these.\",\n digestCadence: \"Frequency\",\n digestWeekly: \"Weekly\",\n digestMonthly: \"Monthly\",\n typesLoading: \"Loading notification settings…\",\n typesEmpty: \"There are no notifications for this account.\",\n\n quietTitle: \"Quiet hours\",\n quietDescription: (inbox) =>\n inbox\n ? \"No push notifications during this window. They still reach your inbox.\"\n : \"No push notifications during this window.\",\n quietFrom: \"From\",\n quietUntil: \"Until\",\n quietIncomplete: \"Set both a start and an end time. Quiet hours take effect once both are set.\",\n timeZone: \"Time zone\",\n deviceZone: (zone) => `This device is in ${zone}.`,\n useDeviceZone: \"Use it\",\n regions: {\n Africa: \"Africa\",\n America: \"Americas\",\n Antarctica: \"Antarctica\",\n Arctic: \"Arctic\",\n Asia: \"Asia\",\n Atlantic: \"Atlantic\",\n Australia: \"Australia\",\n Europe: \"Europe\",\n Indian: \"Indian Ocean\",\n Pacific: \"Pacific\",\n },\n\n pushTitle: \"Push notifications\",\n pushDescription: \"Notifications on this device, also while the app is closed.\",\n unsupported: \"This browser doesn’t support push notifications.\",\n iosInstall: (app) =>\n `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,\n notConfigured: \"Push notifications aren’t set up on this server.\",\n blocked: \"Notifications are blocked in this browser’s settings.\",\n on: \"Notifications are on for this device.\",\n off: \"Notifications are off for this device.\",\n otherAccount:\n \"This browser gets notifications for another account. Turn them on here to get them for the account you’re signed in with.\",\n enable: \"Turn on notifications\",\n disable: \"Turn off\",\n sendTest: \"Send a test\",\n enableFailed: \"Couldn’t turn on notifications.\",\n noServiceWorker: \"Couldn’t reach the app’s service worker. Reload the page and try again.\",\n pushTimeout: \"The browser’s push service didn’t answer. Check your connection and try again.\",\n testSent: (count) => (count === 1 ? \"Test sent to 1 device\" : `Test sent to ${count} devices`),\n testNone: \"No device accepted the test. Turn notifications on for this device first.\",\n testFailed: \"Couldn’t send a test notification.\",\n explainerTitle: \"Turn on notifications?\",\n explainerBody: (app) =>\n `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,\n explainerHint: \"Your browser asks for permission next.\",\n explainerContinue: \"Continue\",\n\n devicesTitle: \"Notification devices\",\n devicesDescription: \"Every device that gets push notifications for your account. Remove any you no longer use.\",\n devicesLoading: \"Loading devices…\",\n devicesEmpty: \"No device gets notifications yet.\",\n unknownDevice: \"Unknown device\",\n thisDevice: \"This device\",\n added: (date) => `Added ${date}`,\n lastDelivery: (date) => `Last delivery ${date}`,\n noDelivery: \"No delivery yet\",\n failures: (count) =>\n count === 1 ? \"1 failed delivery in a row\" : `${count} failed deliveries in a row`,\n remove: \"Remove\",\n removeItem: (device) => `Remove ${device}`,\n removePrompt: \"Stop sending notifications to this device?\",\n\n unsubscribeTitle: \"E-mail notifications\",\n unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,\n unsubscribeGeneric: \"You get notification e-mails.\",\n stopThese: \"Stop these e-mails\",\n stopAll: (app) => `Stop all notification e-mails from ${app}`,\n stoppedThese: \"Done. You won’t get these e-mails any more.\",\n stoppedAll: (app) => `Done. You won’t get notification e-mails from ${app} any more.`,\n accountMail: \"E-mails about your account still come.\",\n turnBackOn: \"You can turn them back on at any time in Settings.\",\n openSettings: \"Open Settings\",\n invalidLink: \"This link doesn’t work any more. You can turn e-mails off in Settings instead.\",\n\n failed: \"That didn’t work. Please try again.\",\n};\n"],"mappings":";AAoJO,MAAM,+BAAoD;AAAA,EAC/D,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EAEZ,YAAY;AAAA,EACZ,kBAAkB,CAAC,UACjB,QACI,2EACA;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,YAAY,CAAC,SAAS,qBAAqB,IAAI;AAAA,EAC/C,eAAe;AAAA,EACf,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,YAAY,CAAC,QACX,0BAA0B,GAAG;AAAA,EAC/B,eAAe;AAAA,EACf,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,cACE;AAAA,EACF,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,UAAU,CAAC,UAAW,UAAU,IAAI,0BAA0B,gBAAgB,KAAK;AAAA,EACnF,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe,CAAC,QACd,GAAG,GAAG;AAAA,EACR,eAAe;AAAA,EACf,mBAAmB;AAAA,EAEnB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,OAAO,CAAC,SAAS,SAAS,IAAI;AAAA,EAC9B,cAAc,CAAC,SAAS,iBAAiB,IAAI;AAAA,EAC7C,YAAY;AAAA,EACZ,UAAU,CAAC,UACT,UAAU,IAAI,+BAA+B,GAAG,KAAK;AAAA,EACvD,QAAQ;AAAA,EACR,YAAY,CAAC,WAAW,UAAU,MAAM;AAAA,EACxC,cAAc;AAAA,EAEd,kBAAkB;AAAA,EAClB,kBAAkB,CAAC,SAAS,0BAA0B,IAAI;AAAA,EAC1D,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,SAAS,CAAC,QAAQ,sCAAsC,GAAG;AAAA,EAC3D,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ,sDAAiD,GAAG;AAAA,EACzE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEb,QAAQ;AACV;","names":[]}
@@ -0,0 +1,37 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ import { type LabelOverride } from "../i18n/kit-labels.js";
3
+ import type { NotificationsLabels } from "./notifications-labels.js";
4
+ import type { PushDevice } from "./use-push-device.js";
5
+ /** Which action failed — {@link PushDeviceSettingProps.describeError}'s second argument. */
6
+ export type PushDeviceAction = "enable" | "disable" | "test";
7
+ export interface PushDeviceSettingProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
8
+ /** This browser's push, from {@link usePushDevice}. */
9
+ push: PushDevice;
10
+ /** The app's name, for the iOS line and the explainer. */
11
+ appName: string;
12
+ /** The app's own words for a failure, or `undefined` for the kit's. The kit already
13
+ * has words for a missing service worker and an unanswered push service. */
14
+ describeError?: (error: unknown, action: PushDeviceAction) => ReactNode | undefined;
15
+ labels?: LabelOverride<NotificationsLabels>;
16
+ }
17
+ /**
18
+ * Push on THIS device (docs/notifications-harmonization.md §2.2, §2.7, §4.2): keksdose's
19
+ * push block, as a card of its own. Registering the device is the switch — push has no
20
+ * account switch. One state at a time, in keksdose's order
21
+ * (`notifications-card.tsx:333-402`):
22
+ *
23
+ * 1. the browser has no push;
24
+ * 2. iOS outside the installed app (iOS delivers only to the installed app);
25
+ * 3. push is not set up on the server (no VAPID keys);
26
+ * 4. notifications blocked in the browser;
27
+ * 5. on or off — with "another account" when this browser's subscription is someone
28
+ * else's — and "Turn on notifications", or "Send a test" and "Turn off".
29
+ *
30
+ * **The explainer comes before the browser's one prompt**: turning on while the
31
+ * permission is still `"default"` opens a dialog first (what the notifications are for,
32
+ * that the browser asks next); with it granted, it goes straight on. A test that reached
33
+ * no device says so (`testNone`) — a 404/410 removes the row on the server while this
34
+ * browser still holds its subscription. Outcomes are a line under the buttons; nothing
35
+ * toasts.
36
+ */
37
+ export declare function PushDeviceSetting({ push, appName, describeError, labels: labelsProp, className, ...rest }: PushDeviceSettingProps): import("react").JSX.Element;
@@ -0,0 +1,164 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { useKitLabels } from "../i18n/kit-labels.js";
5
+ import { DEFAULT_COMMON_LABELS } from "../i18n/shared-labels.js";
6
+ import { cn } from "../lib/cn.js";
7
+ import { AlertBanner } from "../components/alert-banner.js";
8
+ import { Button } from "../components/button.js";
9
+ import { Card } from "../components/card.js";
10
+ import { DialogFrame } from "../components/dialog-frame.js";
11
+ import { COMMIT_EXCEPT_BILLING } from "../components/write-lock.js";
12
+ import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes.js";
13
+ import { SettingsCardTitle } from "../settings/settings-heading.js";
14
+ import { useMounted } from "../account/account-parts.js";
15
+ import { describeFailure, FailureLine, useNotificationsLabels } from "./notification-parts.js";
16
+ import { PushDeviceError } from "./use-push-device.js";
17
+ function PushDeviceSetting({
18
+ push,
19
+ appName,
20
+ describeError,
21
+ labels: labelsProp,
22
+ className,
23
+ ...rest
24
+ }) {
25
+ const labels = useNotificationsLabels(labelsProp);
26
+ const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
27
+ const [explainer, setExplainer] = useState(false);
28
+ const [running, setRunning] = useState(null);
29
+ const [outcome, setOutcome] = useState(null);
30
+ const mounted = useMounted();
31
+ const failureOf = (error, action, fallback) => {
32
+ if (error instanceof PushDeviceError) {
33
+ return error.code === "no_service_worker" ? labels.noServiceWorker : labels.pushTimeout;
34
+ }
35
+ return describeFailure(describeError?.(error, action), fallback);
36
+ };
37
+ const run = (action, call, done, fallback) => {
38
+ if (running) return;
39
+ setRunning(action);
40
+ setOutcome(null);
41
+ call().then(
42
+ (value) => {
43
+ if (!mounted.current) return;
44
+ setRunning(null);
45
+ setOutcome(done(value));
46
+ },
47
+ (error) => {
48
+ if (!mounted.current) return;
49
+ setRunning(null);
50
+ setOutcome({ tone: "danger", text: failureOf(error, action, fallback) });
51
+ }
52
+ );
53
+ };
54
+ const enable = () => run(
55
+ "enable",
56
+ () => push.enable(),
57
+ (ok) => ok ? null : { tone: "danger", text: labels.enableFailed },
58
+ labels.enableFailed
59
+ );
60
+ const disable = () => run("disable", () => push.disable(), () => null, labels.failed);
61
+ const test = () => run(
62
+ "test",
63
+ () => push.sendTest(),
64
+ ({ sent }) => sent > 0 ? { tone: "status", text: labels.testSent(sent) } : { tone: "warning", text: labels.testNone },
65
+ labels.testFailed
66
+ );
67
+ const turnOn = () => {
68
+ if (push.permission === "granted") enable();
69
+ else setExplainer(true);
70
+ };
71
+ let state;
72
+ if (!push.supported) {
73
+ state = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.unsupported });
74
+ } else if (push.ios && !push.installed) {
75
+ state = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.iosInstall(appName) });
76
+ } else if (push.configured === false) {
77
+ state = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.notConfigured });
78
+ } else if (push.permission === "denied") {
79
+ state = /* @__PURE__ */ jsx("p", { className: "text-xs text-warning", children: labels.blocked });
80
+ } else {
81
+ const busy = push.busy || running !== null;
82
+ state = /* @__PURE__ */ jsxs(Fragment, { children: [
83
+ /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, "data-push-state": push.subscribed ? "on" : "off", children: push.subscribed ? labels.on : labels.off }),
84
+ push.foreignSubscription && /* @__PURE__ */ jsx("p", { className: "text-xs text-warning", children: labels.otherAccount }),
85
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: push.subscribed ? /* @__PURE__ */ jsxs(Fragment, { children: [
86
+ /* @__PURE__ */ jsx(
87
+ Button,
88
+ {
89
+ type: "button",
90
+ size: "sm",
91
+ variant: "secondary",
92
+ commit: COMMIT_EXCEPT_BILLING,
93
+ pending: running === "test",
94
+ disabled: busy && running !== "test",
95
+ onClick: test,
96
+ children: labels.sendTest
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx(
100
+ Button,
101
+ {
102
+ type: "button",
103
+ size: "sm",
104
+ variant: "ghost",
105
+ commit: COMMIT_EXCEPT_BILLING,
106
+ pending: running === "disable",
107
+ disabled: busy && running !== "disable",
108
+ onClick: disable,
109
+ children: labels.disable
110
+ }
111
+ )
112
+ ] }) : /* @__PURE__ */ jsx(
113
+ Button,
114
+ {
115
+ type: "button",
116
+ size: "sm",
117
+ commit: COMMIT_EXCEPT_BILLING,
118
+ pending: running === "enable",
119
+ disabled: busy && running !== "enable",
120
+ onClick: turnOn,
121
+ children: labels.enable
122
+ }
123
+ ) }),
124
+ outcome?.tone === "status" && /* @__PURE__ */ jsx("p", { role: "status", className: CARD_DESCRIPTION_CLASS, children: outcome.text }),
125
+ outcome?.tone === "warning" && /* @__PURE__ */ jsx(AlertBanner, { tone: "warning", size: "sm", role: "status", children: outcome.text }),
126
+ outcome?.tone === "danger" && /* @__PURE__ */ jsx(FailureLine, { children: outcome.text })
127
+ ] });
128
+ }
129
+ return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
130
+ /* @__PURE__ */ jsxs("div", { children: [
131
+ /* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.pushTitle }),
132
+ /* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.pushDescription })
133
+ ] }),
134
+ state,
135
+ /* @__PURE__ */ jsx(
136
+ DialogFrame,
137
+ {
138
+ open: explainer,
139
+ onClose: () => setExplainer(false),
140
+ title: labels.explainerTitle,
141
+ description: labels.explainerBody(appName),
142
+ actions: (close) => /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
143
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", onClick: close, children: common.cancel }),
144
+ /* @__PURE__ */ jsx(
145
+ Button,
146
+ {
147
+ type: "button",
148
+ onClick: () => {
149
+ setExplainer(false);
150
+ enable();
151
+ },
152
+ children: labels.explainerContinue
153
+ }
154
+ )
155
+ ] }),
156
+ children: /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.explainerHint })
157
+ }
158
+ )
159
+ ] });
160
+ }
161
+ export {
162
+ PushDeviceSetting
163
+ };
164
+ //# sourceMappingURL=push-device-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/notifications/push-device-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport { PushDeviceError } from \"./use-push-device\";\nimport type { PushDevice } from \"./use-push-device\";\n\n/** Which action failed — {@link PushDeviceSettingProps.describeError}'s second argument. */\nexport type PushDeviceAction = \"enable\" | \"disable\" | \"test\";\n\nexport interface PushDeviceSettingProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** This browser's push, from {@link usePushDevice}. */\n push: PushDevice;\n /** The app's name, for the iOS line and the explainer. */\n appName: string;\n /** The app's own words for a failure, or `undefined` for the kit's. The kit already\n * has words for a missing service worker and an unanswered push service. */\n describeError?: (error: unknown, action: PushDeviceAction) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** What the line under the buttons says. */\ntype Outcome = { tone: \"status\" | \"warning\" | \"danger\"; text: ReactNode } | null;\n\n/**\n * Push on THIS device (docs/notifications-harmonization.md §2.2, §2.7, §4.2): keksdose's\n * push block, as a card of its own. Registering the device is the switch — push has no\n * account switch. One state at a time, in keksdose's order\n * (`notifications-card.tsx:333-402`):\n *\n * 1. the browser has no push;\n * 2. iOS outside the installed app (iOS delivers only to the installed app);\n * 3. push is not set up on the server (no VAPID keys);\n * 4. notifications blocked in the browser;\n * 5. on or off — with \"another account\" when this browser's subscription is someone\n * else's — and \"Turn on notifications\", or \"Send a test\" and \"Turn off\".\n *\n * **The explainer comes before the browser's one prompt**: turning on while the\n * permission is still `\"default\"` opens a dialog first (what the notifications are for,\n * that the browser asks next); with it granted, it goes straight on. A test that reached\n * no device says so (`testNone`) — a 404/410 removes the row on the server while this\n * browser still holds its subscription. Outcomes are a line under the buttons; nothing\n * toasts.\n */\nexport function PushDeviceSetting({\n push,\n appName,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDeviceSettingProps) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const [explainer, setExplainer] = useState(false);\n const [running, setRunning] = useState<PushDeviceAction | null>(null);\n const [outcome, setOutcome] = useState<Outcome>(null);\n const mounted = useMounted();\n\n const failureOf = (error: unknown, action: PushDeviceAction, fallback: string): ReactNode => {\n if (error instanceof PushDeviceError) {\n return error.code === \"no_service_worker\" ? labels.noServiceWorker : labels.pushTimeout;\n }\n return describeFailure(describeError?.(error, action), fallback);\n };\n\n const run = <T,>(action: PushDeviceAction, call: () => Promise<T>, done: (value: T) => Outcome, fallback: string) => {\n if (running) return;\n setRunning(action);\n setOutcome(null);\n call().then(\n (value) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome(done(value));\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome({ tone: \"danger\", text: failureOf(error, action, fallback) });\n },\n );\n };\n\n const enable = () =>\n run(\n \"enable\",\n () => push.enable(),\n (ok): Outcome => (ok ? null : { tone: \"danger\", text: labels.enableFailed }),\n labels.enableFailed,\n );\n const disable = () => run(\"disable\", () => push.disable(), () => null, labels.failed);\n const test = () =>\n run(\n \"test\",\n () => push.sendTest(),\n ({ sent }): Outcome =>\n sent > 0 ? { tone: \"status\", text: labels.testSent(sent) } : { tone: \"warning\", text: labels.testNone },\n labels.testFailed,\n );\n\n const turnOn = () => {\n if (push.permission === \"granted\") enable();\n else setExplainer(true);\n };\n\n let state: ReactNode;\n if (!push.supported) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.unsupported}</p>;\n } else if (push.ios && !push.installed) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.iosInstall(appName)}</p>;\n } else if (push.configured === false) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.notConfigured}</p>;\n } else if (push.permission === \"denied\") {\n state = <p className=\"text-xs text-warning\">{labels.blocked}</p>;\n } else {\n const busy = push.busy || running !== null;\n state = (\n <>\n <p className={CARD_DESCRIPTION_CLASS} data-push-state={push.subscribed ? \"on\" : \"off\"}>\n {push.subscribed ? labels.on : labels.off}\n </p>\n {push.foreignSubscription && <p className=\"text-xs text-warning\">{labels.otherAccount}</p>}\n <div className=\"flex flex-wrap gap-2\">\n {push.subscribed ? (\n <>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"test\"}\n disabled={busy && running !== \"test\"}\n onClick={test}\n >\n {labels.sendTest}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"disable\"}\n disabled={busy && running !== \"disable\"}\n onClick={disable}\n >\n {labels.disable}\n </Button>\n </>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"enable\"}\n disabled={busy && running !== \"enable\"}\n onClick={turnOn}\n >\n {labels.enable}\n </Button>\n )}\n </div>\n {outcome?.tone === \"status\" && (\n <p role=\"status\" className={CARD_DESCRIPTION_CLASS}>\n {outcome.text}\n </p>\n )}\n {outcome?.tone === \"warning\" && (\n <AlertBanner tone=\"warning\" size=\"sm\" role=\"status\">\n {outcome.text}\n </AlertBanner>\n )}\n {outcome?.tone === \"danger\" && <FailureLine>{outcome.text}</FailureLine>}\n </>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.pushTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.pushDescription}</div>\n </div>\n {state}\n <DialogFrame\n open={explainer}\n onClose={() => setExplainer(false)}\n title={labels.explainerTitle}\n description={labels.explainerBody(appName)}\n actions={(close) => (\n <div className=\"flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" onClick={close}>\n {common.cancel}\n </Button>\n <Button\n type=\"button\"\n onClick={() => {\n setExplainer(false);\n // Only now the browser's one permission prompt.\n enable();\n }}\n >\n {labels.explainerContinue}\n </Button>\n </div>\n )}\n >\n <p className={CARD_DESCRIPTION_CLASS}>{labels.explainerHint}</p>\n </DialogFrame>\n </Card>\n );\n}\n"],"mappings":";AAwHY,SAiBA,UAjBA,KAiBA,YAjBA;AAxHZ,SAAS,gBAAgB;AAGzB,SAAS,oBAAwC;AACjD,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB,aAAa,8BAA8B;AAErE,SAAS,uBAAuB;AAwCzB,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAA2B;AACzB,QAAM,SAAS,uBAAuB,UAAU;AAChD,QAAM,SAAS,aAAa,UAAU,qBAAqB;AAC3D,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAkC,IAAI;AACpE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAkB,IAAI;AACpD,QAAM,UAAU,WAAW;AAE3B,QAAM,YAAY,CAAC,OAAgB,QAA0B,aAAgC;AAC3F,Q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AS,SAAS,YACjB,oBAAC,OAAE,MAAK,UAAS,WAAW,wBACzB,kBAAQ,MACX;AAAA,MAED,SAAS,SAAS,aACjB,oBAAC,eAAY,MAAK,WAAU,MAAK,MAAK,MAAK,UACxC,kBAAQ,MACX;AAAA,MAED,SAAS,SAAS,YAAY,oBAAC,eAAa,kBAAQ,MAAK;AAAA,OAC5D;AAAA,EAEJ;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,iBAAiB,SAAS,GACtD;AAAA,yBAAC,SACC;AAAA,0BAAC,qBAAmB,iBAAO,WAAU;AAAA,MACrC,oBAAC,SAAI,WAAW,wBAAyB,iBAAO,iBAAgB;AAAA,OAClE;AAAA,IACC;AAAA,IACD;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,SAAS,MAAM,aAAa,KAAK;AAAA,QACjC,OAAO,OAAO;AAAA,QACd,aAAa,OAAO,cAAc,OAAO;AAAA,QACzC,SAAS,CAAC,UACR,qBAAC,SAAI,WAAU,0BACb;AAAA,8BAAC,UAAO,MAAK,UAAS,SAAQ,SAAQ,SAAS,OAC5C,iBAAO,QACV;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,6BAAa,KAAK;AAElB,uBAAO;AAAA,cACT;AAAA,cAEC,iBAAO;AAAA;AAAA,UACV;AAAA,WACF;AAAA,QAGF,8BAAC,OAAE,WAAW,wBAAyB,iBAAO,eAAc;AAAA;AAAA,IAC9D;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,44 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ import { type LabelOverride } from "../i18n/kit-labels.js";
3
+ import type { NotificationsLabels } from "./notifications-labels.js";
4
+ import type { PushDeviceItem } from "./notification-types.js";
5
+ /**
6
+ * A name for a stored user agent: "Chrome · Android", "Firefox · Windows" (keksdose
7
+ * `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back
8
+ * as it is, cut at 60 characters so a token soup cannot blow up the row; `null` for none.
9
+ * The order matters — Edge and Opera say "Chrome" too, and Chrome says "Safari".
10
+ */
11
+ export declare function describeUserAgent(ua: string | null): string | null;
12
+ export interface PushDevicesSettingProps<Id extends string | number = string> extends Omit<ComponentPropsWithRef<"div">, "children"> {
13
+ /** `GET /notifications/devices`, oldest first; `undefined` while the first load runs. */
14
+ devices: readonly PushDeviceItem<Id>[] | undefined;
15
+ loading?: boolean;
16
+ /** This browser's endpoint (`usePushDevice().currentEndpoint`): its row says "This
17
+ * device", and removing it also unsubscribes the browser. */
18
+ currentEndpoint?: string | null;
19
+ /** `DELETE /notifications/devices/{id}`. Asked first; refresh `devices` once it
20
+ * resolves. */
21
+ onRemove: (id: Id) => Promise<unknown> | void;
22
+ /** The dates' text. Default: the provider's locale, medium date. */
23
+ formatDate?: (date: Date) => string;
24
+ /** Overrides the provider's locale for the default format. */
25
+ locale?: string;
26
+ /** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */
27
+ describeError?: (error: unknown) => ReactNode | undefined;
28
+ labels?: LabelOverride<NotificationsLabels>;
29
+ }
30
+ /**
31
+ * Every device that gets push for the account (docs/notifications-harmonization.md §3.5,
32
+ * §4.2) — keksdose's devices card: the browser and system read from the stored user
33
+ * agent, "This device" on this browser's row, when it was added and last delivered to,
34
+ * the failures in a row in the warning tone, and "Remove".
35
+ *
36
+ * **Remove asks first, in the row**, as `PasskeysSetting` does: the card must work in an
37
+ * app without a `ConfirmProvider`, and the question belongs beside the device it names.
38
+ * Focus moves to Cancel. **Removing this device** also unsubscribes the browser and fires
39
+ * `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card
40
+ * stops saying "on".
41
+ *
42
+ * Under a write lock Remove is a `commit` control exempt from billing.
43
+ */
44
+ export declare function PushDevicesSetting<Id extends string | number = string>({ devices, loading, currentEndpoint, onRemove, formatDate: formatDateProp, locale: localeProp, describeError, labels: labelsProp, className, ...rest }: PushDevicesSettingProps<Id>): import("react").JSX.Element;
@@ -0,0 +1,203 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { MonitorSmartphone } from "lucide-react";
5
+ import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
6
+ import { DEFAULT_COMMON_LABELS } from "../i18n/shared-labels.js";
7
+ import { cn } from "../lib/cn.js";
8
+ import { formatDate } from "../lib/format.js";
9
+ import { Button } from "../components/button.js";
10
+ import { Card } from "../components/card.js";
11
+ import { Chip } from "../components/chip.js";
12
+ import { Skeleton } from "../components/skeleton.js";
13
+ import { COMMIT_EXCEPT_BILLING } from "../components/write-lock.js";
14
+ import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes.js";
15
+ import { SettingsCardTitle } from "../settings/settings-heading.js";
16
+ import { settle, useMounted } from "../account/account-parts.js";
17
+ import { describeFailure, FailureLine, useNotificationsLabels } from "./notification-parts.js";
18
+ import { notifyPushSubscriptionChanged } from "./use-push-device.js";
19
+ function describeUserAgent(ua) {
20
+ if (!ua) return null;
21
+ const browser = /edg(?:e|a|ios)?\//i.test(ua) ? "Edge" : /opr\/|opera/i.test(ua) ? "Opera" : /firefox|fxios/i.test(ua) ? "Firefox" : /chrome|crios/i.test(ua) ? "Chrome" : /safari/i.test(ua) ? "Safari" : null;
22
+ const os = /windows/i.test(ua) ? "Windows" : /android/i.test(ua) ? "Android" : /iphone|ipad|ipod/i.test(ua) ? "iOS" : /mac os x|macintosh/i.test(ua) ? "macOS" : /linux/i.test(ua) ? "Linux" : null;
23
+ if (!browser && !os) return ua.length > 60 ? `${ua.slice(0, 60)}\u2026` : ua;
24
+ return [browser, os].filter(Boolean).join(" \xB7 ");
25
+ }
26
+ async function unsubscribeThisBrowser() {
27
+ try {
28
+ const registration = await navigator.serviceWorker?.getRegistration();
29
+ const subscription = await registration?.pushManager.getSubscription();
30
+ await subscription?.unsubscribe();
31
+ } catch {
32
+ }
33
+ notifyPushSubscriptionChanged();
34
+ }
35
+ function PushDevicesSetting({
36
+ devices,
37
+ loading,
38
+ currentEndpoint,
39
+ onRemove,
40
+ formatDate: formatDateProp,
41
+ locale: localeProp,
42
+ describeError,
43
+ labels: labelsProp,
44
+ className,
45
+ ...rest
46
+ }) {
47
+ const labels = useNotificationsLabels(labelsProp);
48
+ const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
49
+ const locale = useKitLocale(localeProp);
50
+ const [asking, setAsking] = useState(null);
51
+ const [busyId, setBusyId] = useState(null);
52
+ const [failure, setFailure] = useState(null);
53
+ const mounted = useMounted();
54
+ const dateText = (iso) => {
55
+ const date = new Date(iso);
56
+ if (Number.isNaN(date.getTime())) return iso;
57
+ return formatDateProp ? formatDateProp(date) : formatDate(date, "medium", { locale });
58
+ };
59
+ const remove = (device) => {
60
+ if (busyId !== null) return;
61
+ setBusyId(device.id);
62
+ setFailure(null);
63
+ const isThis = Boolean(currentEndpoint) && device.endpoint === currentEndpoint;
64
+ settle(() => onRemove(device.id)).then(async () => {
65
+ if (isThis) await unsubscribeThisBrowser();
66
+ if (!mounted.current) return;
67
+ setBusyId(null);
68
+ setAsking(null);
69
+ }).catch((error) => {
70
+ if (!mounted.current) return;
71
+ setBusyId(null);
72
+ setFailure(describeFailure(describeError?.(error), labels.failed));
73
+ });
74
+ };
75
+ let body;
76
+ if (loading || devices === void 0) {
77
+ body = /* @__PURE__ */ jsx(Skeleton, { lines: 2, label: labels.devicesLoading });
78
+ } else if (devices.length === 0) {
79
+ body = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.devicesEmpty });
80
+ } else {
81
+ body = /* @__PURE__ */ jsx("ul", { "aria-label": labels.devicesTitle, className: "divide-y divide-subtle", children: devices.map((device) => /* @__PURE__ */ jsx(
82
+ DeviceRow,
83
+ {
84
+ device,
85
+ name: describeUserAgent(device.user_agent) ?? labels.unknownDevice,
86
+ current: Boolean(currentEndpoint) && device.endpoint === currentEndpoint,
87
+ added: dateText(device.created_at),
88
+ lastDelivery: device.last_success_at ? dateText(device.last_success_at) : null,
89
+ asking: asking === device.id,
90
+ busy: busyId === device.id,
91
+ blocked: busyId !== null && busyId !== device.id,
92
+ onAsk: () => setAsking(device.id),
93
+ onCancel: () => setAsking(null),
94
+ onConfirm: () => remove(device),
95
+ labels,
96
+ cancelLabel: common.cancel
97
+ },
98
+ device.id
99
+ )) });
100
+ }
101
+ return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
102
+ /* @__PURE__ */ jsxs("div", { children: [
103
+ /* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.devicesTitle }),
104
+ /* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.devicesDescription })
105
+ ] }),
106
+ body,
107
+ /* @__PURE__ */ jsx(FailureLine, { children: failure })
108
+ ] });
109
+ }
110
+ function DeviceRow({
111
+ device,
112
+ name,
113
+ current,
114
+ added,
115
+ lastDelivery,
116
+ asking,
117
+ busy,
118
+ blocked,
119
+ onAsk,
120
+ onCancel,
121
+ onConfirm,
122
+ labels,
123
+ cancelLabel
124
+ }) {
125
+ const cancelRef = useRef(null);
126
+ const removeRef = useRef(null);
127
+ const [returning, setReturning] = useState(false);
128
+ useEffect(() => {
129
+ if (asking) cancelRef.current?.focus();
130
+ else if (returning) removeRef.current?.focus();
131
+ }, [asking, returning]);
132
+ const leave = () => {
133
+ setReturning(true);
134
+ onCancel();
135
+ };
136
+ const escapeLeaves = (event) => {
137
+ if (event.key === "Escape") {
138
+ event.preventDefault();
139
+ event.stopPropagation();
140
+ leave();
141
+ }
142
+ };
143
+ const row = { "data-push-device-id": String(device.id), "data-current": current || void 0 };
144
+ if (asking) {
145
+ return /* @__PURE__ */ jsxs("li", { ...row, className: "space-y-2 py-2", children: [
146
+ /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm", children: labels.removePrompt }),
147
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
148
+ /* @__PURE__ */ jsx(
149
+ Button,
150
+ {
151
+ type: "button",
152
+ size: "sm",
153
+ variant: "danger",
154
+ commit: COMMIT_EXCEPT_BILLING,
155
+ pending: busy,
156
+ "aria-label": labels.removeItem(name),
157
+ onClick: onConfirm,
158
+ onKeyDown: escapeLeaves,
159
+ children: labels.remove
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx(Button, { ref: cancelRef, type: "button", size: "sm", variant: "ghost", onClick: leave, onKeyDown: escapeLeaves, children: cancelLabel })
163
+ ] })
164
+ ] });
165
+ }
166
+ return /* @__PURE__ */ jsxs("li", { ...row, className: "flex items-center gap-3 py-2", children: [
167
+ /* @__PURE__ */ jsx(MonitorSmartphone, { "aria-hidden": true, className: "size-4 shrink-0 text-muted" }),
168
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
169
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
170
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-sm font-medium", children: name }),
171
+ current && /* @__PURE__ */ jsx(Chip, { size: "sm", tone: "brand", children: labels.thisDevice })
172
+ ] }),
173
+ /* @__PURE__ */ jsxs("div", { className: CARD_DESCRIPTION_CLASS, children: [
174
+ labels.added(added),
175
+ " \xB7 ",
176
+ lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery
177
+ ] }),
178
+ device.failure_count > 0 && /* @__PURE__ */ jsx("div", { className: "text-xs text-warning", children: labels.failures(device.failure_count) })
179
+ ] }),
180
+ /* @__PURE__ */ jsx(
181
+ Button,
182
+ {
183
+ ref: removeRef,
184
+ type: "button",
185
+ size: "sm",
186
+ variant: "ghost",
187
+ commit: COMMIT_EXCEPT_BILLING,
188
+ disabled: blocked,
189
+ "aria-label": labels.removeItem(name),
190
+ onClick: () => {
191
+ setReturning(false);
192
+ onAsk();
193
+ },
194
+ children: labels.remove
195
+ }
196
+ )
197
+ ] });
198
+ }
199
+ export {
200
+ PushDevicesSetting,
201
+ describeUserAgent
202
+ };
203
+ //# sourceMappingURL=push-devices-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/notifications/push-devices-setting.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate } from \"../lib/format\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { Chip } from \"../components/chip\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type { PushDeviceItem } from \"./notification-types\";\nimport { notifyPushSubscriptionChanged } from \"./use-push-device\";\n\n/**\n * A name for a stored user agent: \"Chrome · Android\", \"Firefox · Windows\" (keksdose\n * `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back\n * as it is, cut at 60 characters so a token soup cannot blow up the row; `null` for none.\n * The order matters — Edge and Opera say \"Chrome\" too, and Chrome says \"Safari\".\n */\nexport function describeUserAgent(ua: string | null): string | null {\n if (!ua) return null;\n const browser = /edg(?:e|a|ios)?\\//i.test(ua)\n ? \"Edge\"\n : /opr\\/|opera/i.test(ua)\n ? \"Opera\"\n : /firefox|fxios/i.test(ua)\n ? \"Firefox\"\n : /chrome|crios/i.test(ua)\n ? \"Chrome\"\n : /safari/i.test(ua)\n ? \"Safari\"\n : null;\n const os = /windows/i.test(ua)\n ? \"Windows\"\n : /android/i.test(ua)\n ? \"Android\"\n : /iphone|ipad|ipod/i.test(ua)\n ? \"iOS\"\n : /mac os x|macintosh/i.test(ua)\n ? \"macOS\"\n : /linux/i.test(ua)\n ? \"Linux\"\n : null;\n if (!browser && !os) return ua.length > 60 ? `${ua.slice(0, 60)}…` : ua;\n return [browser, os].filter(Boolean).join(\" · \");\n}\n\nexport interface PushDevicesSettingProps<Id extends string | number = string>\n extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** `GET /notifications/devices`, oldest first; `undefined` while the first load runs. */\n devices: readonly PushDeviceItem<Id>[] | undefined;\n loading?: boolean;\n /** This browser's endpoint (`usePushDevice().currentEndpoint`): its row says \"This\n * device\", and removing it also unsubscribes the browser. */\n currentEndpoint?: string | null;\n /** `DELETE /notifications/devices/{id}`. Asked first; refresh `devices` once it\n * resolves. */\n onRemove: (id: Id) => Promise<unknown> | void;\n /** The dates' text. Default: the provider's locale, medium date. */\n formatDate?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n /** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** Tear down this browser's subscription after its server row went: otherwise the\n * browser still holds one, and the push card would say \"on\" for a device nothing can\n * reach. Best effort — the row is already gone. */\nasync function unsubscribeThisBrowser(): Promise<void> {\n try {\n const registration = await navigator.serviceWorker?.getRegistration();\n const subscription = await registration?.pushManager.getSubscription();\n await subscription?.unsubscribe();\n } catch {\n /* the server row is gone either way */\n }\n notifyPushSubscriptionChanged();\n}\n\n/**\n * Every device that gets push for the account (docs/notifications-harmonization.md §3.5,\n * §4.2) — keksdose's devices card: the browser and system read from the stored user\n * agent, \"This device\" on this browser's row, when it was added and last delivered to,\n * the failures in a row in the warning tone, and \"Remove\".\n *\n * **Remove asks first, in the row**, as `PasskeysSetting` does: the card must work in an\n * app without a `ConfirmProvider`, and the question belongs beside the device it names.\n * Focus moves to Cancel. **Removing this device** also unsubscribes the browser and fires\n * `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card\n * stops saying \"on\".\n *\n * Under a write lock Remove is a `commit` control exempt from billing.\n */\nexport function PushDevicesSetting<Id extends string | number = string>({\n devices,\n loading,\n currentEndpoint,\n onRemove,\n formatDate: formatDateProp,\n locale: localeProp,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDevicesSettingProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const locale = useKitLocale(localeProp);\n const [asking, setAsking] = useState<Id | null>(null);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const dateText = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n return formatDateProp ? formatDateProp(date) : formatDate(date, \"medium\", { locale });\n };\n\n const remove = (device: PushDeviceItem<Id>) => {\n if (busyId !== null) return;\n setBusyId(device.id);\n setFailure(null);\n const isThis = Boolean(currentEndpoint) && device.endpoint === currentEndpoint;\n settle(() => onRemove(device.id))\n .then(async () => {\n if (isThis) await unsubscribeThisBrowser();\n if (!mounted.current) return;\n setBusyId(null);\n setAsking(null);\n })\n .catch((error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n });\n };\n\n let body: ReactNode;\n if (loading || devices === undefined) {\n body = <Skeleton lines={2} label={labels.devicesLoading} />;\n } else if (devices.length === 0) {\n body = <p className={CARD_DESCRIPTION_CLASS}>{labels.devicesEmpty}</p>;\n } else {\n body = (\n <ul aria-label={labels.devicesTitle} className=\"divide-y divide-subtle\">\n {devices.map((device) => (\n <DeviceRow\n key={device.id}\n device={device}\n name={describeUserAgent(device.user_agent) ?? labels.unknownDevice}\n current={Boolean(currentEndpoint) && device.endpoint === currentEndpoint}\n added={dateText(device.created_at)}\n lastDelivery={device.last_success_at ? dateText(device.last_success_at) : null}\n asking={asking === device.id}\n busy={busyId === device.id}\n blocked={busyId !== null && busyId !== device.id}\n onAsk={() => setAsking(device.id)}\n onCancel={() => setAsking(null)}\n onConfirm={() => remove(device)}\n labels={labels}\n cancelLabel={common.cancel}\n />\n ))}\n </ul>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.devicesTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.devicesDescription}</div>\n </div>\n {body}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n\nfunction DeviceRow<Id extends string | number>({\n device,\n name,\n current,\n added,\n lastDelivery,\n asking,\n busy,\n blocked,\n onAsk,\n onCancel,\n onConfirm,\n labels,\n cancelLabel,\n}: {\n device: PushDeviceItem<Id>;\n name: string;\n current: boolean;\n added: string;\n lastDelivery: string | null;\n asking: boolean;\n busy: boolean;\n blocked: boolean;\n onAsk: () => void;\n onCancel: () => void;\n onConfirm: () => void;\n labels: NotificationsLabels;\n cancelLabel: string;\n}) {\n const cancelRef = useRef<HTMLButtonElement>(null);\n const removeRef = useRef<HTMLButtonElement>(null);\n // Which way the confirm closed: back to Remove, so focus does not fall to <body>.\n const [returning, setReturning] = useState(false);\n useEffect(() => {\n if (asking) cancelRef.current?.focus();\n else if (returning) removeRef.current?.focus();\n }, [asking, returning]);\n\n const leave = () => {\n setReturning(true);\n onCancel();\n };\n const escapeLeaves = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n leave();\n }\n };\n\n const row = { \"data-push-device-id\": String(device.id), \"data-current\": current || undefined };\n\n if (asking) {\n return (\n <li {...row} className=\"space-y-2 py-2\">\n <p role=\"alert\" className=\"text-sm\">\n {labels.removePrompt}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={busy}\n aria-label={labels.removeItem(name)}\n onClick={onConfirm}\n onKeyDown={escapeLeaves}\n >\n {labels.remove}\n </Button>\n <Button ref={cancelRef} type=\"button\" size=\"sm\" variant=\"ghost\" onClick={leave} onKeyDown={escapeLeaves}>\n {cancelLabel}\n </Button>\n </div>\n </li>\n );\n }\n\n return (\n <li {...row} className=\"flex items-center gap-3 py-2\">\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-muted\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{name}</span>\n {current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.thisDevice}\n </Chip>\n )}\n </div>\n <div className={CARD_DESCRIPTION_CLASS}>\n {labels.added(added)}\n {\" · \"}\n {lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery}\n </div>\n {device.failure_count > 0 && <div className=\"text-xs text-warning\">{labels.failures(device.failure_count)}</div>}\n </div>\n <Button\n ref={removeRef}\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n disabled={blocked}\n aria-label={labels.removeItem(name)}\n onClick={() => {\n setReturning(false);\n onAsk();\n }}\n >\n {labels.remove}\n </Button>\n </li>\n );\n}\n"],"mappings":";AAsJW,cA8BL,YA9BK;AAtJX,SAAS,WAAW,QAAQ,gBAAgB;AAE5C,SAAS,yBAAyB;AAElC,SAAS,cAAc,oBAAwC;AAC/D,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,a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O,WAAW,IAAI;AAAA,QAClC,SAAS,MAAM;AACb,uBAAa,KAAK;AAClB,gBAAM;AAAA,QACR;AAAA,QAEC,iBAAO;AAAA;AAAA,IACV;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,47 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ import type { LabelOverride } from "../i18n/kit-labels.js";
3
+ import type { NotificationsLabels } from "./notifications-labels.js";
4
+ import type { NotificationSettingsPatch } from "./notification-types.js";
5
+ export interface QuietHoursSettingProps extends Omit<ComponentPropsWithRef<"div">, "children" | "onChange"> {
6
+ /** The `GET`'s `quiet_hours_start`, `"HH:MM"`, or `null`. */
7
+ start: string | null;
8
+ /** The `GET`'s `quiet_hours_end`. */
9
+ end: string | null;
10
+ /** The `GET`'s `timezone`, an IANA name, or `null` (the app's zone applies). */
11
+ timezone: string | null;
12
+ /**
13
+ * Save one change — `PATCH /notifications/settings`: a time (`null` when cleared), with
14
+ * the device's zone the first time one is entered while `timezone` is `null`; or
15
+ * `{timezone}`. The field shows the new value while the call runs and goes back if it
16
+ * rejects.
17
+ */
18
+ onChange: (patch: NotificationSettingsPatch) => Promise<unknown> | void;
19
+ /** The zone shown, and the one the server applies, while `timezone` is `null`.
20
+ * Default `"Europe/Zurich"`, every app's (decision 6). */
21
+ fallbackZone?: string;
22
+ /** The app keeps an inbox, and the description says a held push still reaches it. */
23
+ inbox?: boolean;
24
+ disabled?: boolean;
25
+ /** The app's own words for a failed save, or `undefined` for the kit's `failed`. */
26
+ describeError?: (error: unknown) => ReactNode | undefined;
27
+ labels?: LabelOverride<NotificationsLabels>;
28
+ }
29
+ /**
30
+ * Quiet hours (docs/notifications-harmonization.md §2.4, §2.6, §4.2): a window of local
31
+ * times in the account's zone, which may cross midnight, when no push of a machine-sent
32
+ * type is sent. A held push is dropped, not delayed; the inbox row and the mail go as
33
+ * usual. keksdose's block, as a card of its own.
34
+ *
35
+ * - **Two times**, each saved as it is entered; a cleared time sends `null`. While only
36
+ * one is set the card says so: the window fails open until both are.
37
+ * - **The zone** shows while a time is set. The first time entered while the account has
38
+ * none sends this device's zone with it, so "22:00" means the person's 22:00
39
+ * (keksdose `notifications-card.tsx:288-292`). With none stored, the card shows
40
+ * `fallbackZone` — the zone the server then applies — never the device's (keksdose's
41
+ * card showed the device's zone while its server applied UTC).
42
+ * - **"This device is in …"** with "Use it" when the device's zone is not the one in
43
+ * effect. Never written on its own: a zone is written by a person's pick (§2.6).
44
+ *
45
+ * Under a write lock the fields are `commit` controls exempt from billing.
46
+ */
47
+ export declare function QuietHoursSetting({ start, end, timezone, onChange, fallbackZone, inbox, disabled, describeError, labels: labelsProp, className, ...rest }: QuietHoursSettingProps): import("react").JSX.Element;