@redvars/peacock 4.5.0 → 4.6.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 (252) hide show
  1. package/dist/{BaseField-BbOj212R.js → BaseField-DOCmylob.js} +16 -3
  2. package/dist/BaseField-DOCmylob.js.map +1 -0
  3. package/dist/accordion.js +1 -1
  4. package/dist/activation-gate-D4IpmwyD.js +23 -0
  5. package/dist/activation-gate-D4IpmwyD.js.map +1 -0
  6. package/dist/avatar-group.js +2 -1
  7. package/dist/avatar-group.js.map +1 -1
  8. package/dist/avatar.js +3 -0
  9. package/dist/avatar.js.map +1 -1
  10. package/dist/{base-button-BJMGMcMv.js → base-button-9tGu5RSC.js} +30 -10
  11. package/dist/base-button-9tGu5RSC.js.map +1 -0
  12. package/dist/button-group.js +5 -3
  13. package/dist/button-group.js.map +1 -1
  14. package/dist/button.js +12 -16
  15. package/dist/button.js.map +1 -1
  16. package/dist/calendar-column-view.js +4 -4
  17. package/dist/{calendar-drag-IXMPZrTN.js → calendar-drag-DdJwSpEz.js} +2 -2
  18. package/dist/{calendar-drag-IXMPZrTN.js.map → calendar-drag-DdJwSpEz.js.map} +1 -1
  19. package/dist/{calendar-event-BQChlMXy.js → calendar-event-BvbYZHx1.js} +2 -2
  20. package/dist/{calendar-event-BQChlMXy.js.map → calendar-event-BvbYZHx1.js.map} +1 -1
  21. package/dist/calendar-month-view.js +65 -14
  22. package/dist/calendar-month-view.js.map +1 -1
  23. package/dist/calendar-timeline.js +13 -8
  24. package/dist/calendar-timeline.js.map +1 -1
  25. package/dist/calendar.js +21 -6
  26. package/dist/calendar.js.map +1 -1
  27. package/dist/card.js +29 -16
  28. package/dist/card.js.map +1 -1
  29. package/dist/chart-doughnut.js +3 -1
  30. package/dist/chart-doughnut.js.map +1 -1
  31. package/dist/chart-pie.js +9 -1
  32. package/dist/chart-pie.js.map +1 -1
  33. package/dist/chip-set.js +1 -1
  34. package/dist/chip.js +10 -19
  35. package/dist/chip.js.map +1 -1
  36. package/dist/color-field.js +4 -1
  37. package/dist/color-field.js.map +1 -1
  38. package/dist/currency-field.js +4 -1
  39. package/dist/currency-field.js.map +1 -1
  40. package/dist/custom-elements-jsdocs.json +26 -20
  41. package/dist/custom-elements.json +755 -90
  42. package/dist/{datasource-OwvH7SVq.js → datasource-DxEA6jHW.js} +6 -4
  43. package/dist/datasource-DxEA6jHW.js.map +1 -0
  44. package/dist/{date-cfPx3alz.js → date-DPQOY8Zd.js} +2 -2
  45. package/dist/{date-cfPx3alz.js.map → date-DPQOY8Zd.js.map} +1 -1
  46. package/dist/date-field.js +8 -5
  47. package/dist/date-field.js.map +1 -1
  48. package/dist/date-picker.js +2 -2
  49. package/dist/date-range-field.js +8 -5
  50. package/dist/date-range-field.js.map +1 -1
  51. package/dist/datetime-field.js +7 -4
  52. package/dist/datetime-field.js.map +1 -1
  53. package/dist/diagram-controls.js +1 -1
  54. package/dist/{throttle-SQ9t-HL7.js → dispatch-event-utils-DfgqVBK8.js} +2 -24
  55. package/dist/dispatch-event-utils-DfgqVBK8.js.map +1 -0
  56. package/dist/{form-submitter-beG1CXAn.js → dispatch-hooks-J_godlHh.js} +2 -87
  57. package/dist/dispatch-hooks-J_godlHh.js.map +1 -0
  58. package/dist/dropdown-button.js +11 -7
  59. package/dist/dropdown-button.js.map +1 -1
  60. package/dist/{event-manager-KGMT2x2Q.js → event-manager-DYfeN3VE.js} +3 -3
  61. package/dist/{event-manager-KGMT2x2Q.js.map → event-manager-DYfeN3VE.js.map} +1 -1
  62. package/dist/fab.js +15 -19
  63. package/dist/fab.js.map +1 -1
  64. package/dist/filter-bar.js +3 -3
  65. package/dist/form-submission-h40coUI8.js +13 -0
  66. package/dist/form-submission-h40coUI8.js.map +1 -0
  67. package/dist/form-submitter-BIFqZ0wq.js +88 -0
  68. package/dist/form-submitter-BIFqZ0wq.js.map +1 -0
  69. package/dist/form.js +1 -9
  70. package/dist/form.js.map +1 -1
  71. package/dist/icon-button.js +15 -19
  72. package/dist/icon-button.js.map +1 -1
  73. package/dist/icon.js +1 -1
  74. package/dist/implicit-submission-ChLdbxaR.js +100 -0
  75. package/dist/implicit-submission-ChLdbxaR.js.map +1 -0
  76. package/dist/index.js +20 -15
  77. package/dist/index.js.map +1 -1
  78. package/dist/{indicator-navigation-item-CmyhsOmy.js → indicator-navigation-item-BsQE3kUr.js} +2 -2
  79. package/dist/{indicator-navigation-item-CmyhsOmy.js.map → indicator-navigation-item-BsQE3kUr.js.map} +1 -1
  80. package/dist/input.js +13 -4
  81. package/dist/input.js.map +1 -1
  82. package/dist/json-viewer.js +1 -1
  83. package/dist/kanban.js +8 -7
  84. package/dist/kanban.js.map +1 -1
  85. package/dist/link-button.js +13 -14
  86. package/dist/link-button.js.map +1 -1
  87. package/dist/list-item.js +52 -16
  88. package/dist/list-item.js.map +1 -1
  89. package/dist/list.js +5 -3
  90. package/dist/list.js.map +1 -1
  91. package/dist/listbox.js +1 -1
  92. package/dist/loader-full.js +17 -12
  93. package/dist/loader-full.js.map +1 -1
  94. package/dist/loader.js +17 -12
  95. package/dist/loader.js.map +1 -1
  96. package/dist/locale-DEsJZCQG.js.map +1 -1
  97. package/dist/mention-input.js +8 -1
  98. package/dist/mention-input.js.map +1 -1
  99. package/dist/menu-item.js +12 -12
  100. package/dist/menu-item.js.map +1 -1
  101. package/dist/menu.js +7 -3
  102. package/dist/menu.js.map +1 -1
  103. package/dist/navigation-bar-item.js +4 -3
  104. package/dist/navigation-bar-item.js.map +1 -1
  105. package/dist/navigation-bar.js +4 -3
  106. package/dist/navigation-bar.js.map +1 -1
  107. package/dist/navigation-drawer-item.js +3 -2
  108. package/dist/navigation-drawer-item.js.map +1 -1
  109. package/dist/navigation-drawer.js +3 -2
  110. package/dist/navigation-drawer.js.map +1 -1
  111. package/dist/{navigation-item-base-kUrvJgCx.js → navigation-item-base-5ljwtLG_.js} +3 -2
  112. package/dist/{navigation-item-base-kUrvJgCx.js.map → navigation-item-base-5ljwtLG_.js.map} +1 -1
  113. package/dist/navigation-rail-item.js +4 -3
  114. package/dist/navigation-rail-item.js.map +1 -1
  115. package/dist/navigation-rail.js +6 -5
  116. package/dist/navigation-rail.js.map +1 -1
  117. package/dist/number-field.js +4 -1
  118. package/dist/number-field.js.map +1 -1
  119. package/dist/option.js +3 -2
  120. package/dist/option.js.map +1 -1
  121. package/dist/password-field.js +11 -4
  122. package/dist/password-field.js.map +1 -1
  123. package/dist/phone-field.js +4 -1
  124. package/dist/phone-field.js.map +1 -1
  125. package/dist/{picker-field-DmXYPvbF.js → picker-field-BiM3iXAQ.js} +2 -2
  126. package/dist/{picker-field-DmXYPvbF.js.map → picker-field-BiM3iXAQ.js.map} +1 -1
  127. package/dist/pin-input.js +4 -1
  128. package/dist/pin-input.js.map +1 -1
  129. package/dist/{range-utils-DZe96GnO.js → range-utils-vgG1SJ2o.js} +2 -2
  130. package/dist/{range-utils-DZe96GnO.js.map → range-utils-vgG1SJ2o.js.map} +1 -1
  131. package/dist/{roving-focus-controller-fm95JkZJ.js → roving-focus-controller-YtNbxH95.js} +30 -7
  132. package/dist/roving-focus-controller-YtNbxH95.js.map +1 -0
  133. package/dist/search.js +12 -6
  134. package/dist/search.js.map +1 -1
  135. package/dist/select.js +11 -3
  136. package/dist/select.js.map +1 -1
  137. package/dist/shipped-icons.js +1 -1
  138. package/dist/split-button.js +9 -1
  139. package/dist/split-button.js.map +1 -1
  140. package/dist/src/__internal/controllers/roving-focus-controller.d.ts +14 -2
  141. package/dist/src/__internal/implicit-submission.d.ts +25 -0
  142. package/dist/src/__internal/utils/activation-gate.d.ts +8 -0
  143. package/dist/src/__internal/utils/form-submission.d.ts +2 -0
  144. package/dist/src/avatar-group/avatar-group.d.ts +1 -1
  145. package/dist/src/button/base-button/base-button.d.ts +1 -1
  146. package/dist/src/button/button/button.d.ts +2 -1
  147. package/dist/src/button/fab/fab.d.ts +2 -1
  148. package/dist/src/button/icon-button/icon-button.d.ts +2 -1
  149. package/dist/src/button/link-button/link-button.d.ts +5 -1
  150. package/dist/src/calendar/calendar-month-view.d.ts +5 -1
  151. package/dist/src/calendar/calendar.d.ts +6 -1
  152. package/dist/src/card/card.d.ts +19 -9
  153. package/dist/src/chart-pie/chart-pie.d.ts +5 -0
  154. package/dist/src/chip/chip/chip.d.ts +4 -4
  155. package/dist/src/dropdown-button/dropdown-button.d.ts +5 -1
  156. package/dist/src/input/BaseField.d.ts +7 -0
  157. package/dist/src/input/input.d.ts +5 -1
  158. package/dist/src/list/list-item.d.ts +2 -1
  159. package/dist/src/mention-input/mention-input.d.ts +2 -0
  160. package/dist/src/menu/menu-item/menu-item.d.ts +6 -4
  161. package/dist/src/password-field/password-field.d.ts +3 -1
  162. package/dist/src/search/search.d.ts +1 -0
  163. package/dist/src/select/select.d.ts +2 -0
  164. package/dist/src/split-button/split-button.d.ts +6 -1
  165. package/dist/src/stepper/step.d.ts +3 -1
  166. package/dist/src/tabs/tab.d.ts +12 -2
  167. package/dist/src/textarea/textarea.d.ts +2 -0
  168. package/dist/src/toolbar/toolbar.d.ts +13 -2
  169. package/dist/step.js +7 -1
  170. package/dist/step.js.map +1 -1
  171. package/dist/stepper.js +10 -1
  172. package/dist/stepper.js.map +1 -1
  173. package/dist/sub-menu.js +3 -2
  174. package/dist/sub-menu.js.map +1 -1
  175. package/dist/svg.js +1 -1
  176. package/dist/tab-group.js +3 -2
  177. package/dist/tab-group.js.map +1 -1
  178. package/dist/tab.js +17 -12
  179. package/dist/tab.js.map +1 -1
  180. package/dist/tabs.js +3 -2
  181. package/dist/tabs.js.map +1 -1
  182. package/dist/test/accessible-name.test.d.ts +1 -0
  183. package/dist/test/helpers/count-activations.d.ts +9 -0
  184. package/dist/test/navigation-rail.test.d.ts +1 -0
  185. package/dist/test/throttle-delay.test.d.ts +1 -0
  186. package/dist/textarea.js +8 -1
  187. package/dist/textarea.js.map +1 -1
  188. package/dist/throttle-C7ZAPqtu.js +24 -0
  189. package/dist/throttle-C7ZAPqtu.js.map +1 -0
  190. package/dist/time-field.js +7 -4
  191. package/dist/time-field.js.map +1 -1
  192. package/dist/time-picker.js +2 -2
  193. package/dist/toolbar.js +25 -8
  194. package/dist/toolbar.js.map +1 -1
  195. package/dist/tree.js +1 -1
  196. package/dist/tsconfig.tsbuildinfo +1 -1
  197. package/dist/url-field.js +4 -1
  198. package/dist/url-field.js.map +1 -1
  199. package/dist/{utils-DcvLgexs.js → utils-CQzycr9J.js} +2 -1
  200. package/dist/utils-CQzycr9J.js.map +1 -0
  201. package/package.json +2 -1
  202. package/src/__internal/controllers/roving-focus-controller.ts +35 -7
  203. package/src/__internal/i18n/locale.ts +1 -1
  204. package/src/__internal/implicit-submission.ts +102 -0
  205. package/src/__internal/utils/activation-gate.ts +20 -0
  206. package/src/__internal/utils/cache-fetch.ts +6 -3
  207. package/src/__internal/utils/form-submission.ts +11 -0
  208. package/src/avatar/avatar.scss +5 -0
  209. package/src/avatar-group/avatar-group.scss +3 -0
  210. package/src/avatar-group/avatar-group.ts +1 -1
  211. package/src/button/base-button/base-button.ts +41 -16
  212. package/src/button/button/button.ts +5 -16
  213. package/src/button/fab/fab.ts +7 -18
  214. package/src/button/icon-button/icon-button.ts +7 -18
  215. package/src/button/link-button/link-button.ts +8 -15
  216. package/src/calendar/_calendar-header.scss +7 -1
  217. package/src/calendar/calendar-month-view.scss +36 -2
  218. package/src/calendar/calendar-month-view.ts +33 -8
  219. package/src/calendar/calendar.ts +17 -2
  220. package/src/calendar/utils.ts +1 -0
  221. package/src/calendar-timeline/calendar-timeline.scss +15 -5
  222. package/src/card/card.ts +27 -16
  223. package/src/chart-doughnut/chart-doughnut.ts +6 -1
  224. package/src/chart-pie/chart-pie.ts +10 -1
  225. package/src/chip/chip/chip.ts +6 -26
  226. package/src/dropdown-button/dropdown-button.ts +7 -2
  227. package/src/form/form.ts +1 -9
  228. package/src/input/BaseField.ts +17 -0
  229. package/src/input/input.ts +13 -1
  230. package/src/kanban/kanban.scss +11 -7
  231. package/src/list/list-item.scss +5 -0
  232. package/src/list/list-item.ts +44 -16
  233. package/src/mention-input/mention-input.ts +5 -0
  234. package/src/menu/menu/menu.ts +4 -1
  235. package/src/menu/menu-item/menu-item.ts +9 -14
  236. package/src/navigation-rail/navigation-rail.scss +3 -2
  237. package/src/password-field/password-field.ts +11 -1
  238. package/src/search/search.ts +9 -0
  239. package/src/select/select.ts +5 -0
  240. package/src/split-button/split-button.ts +10 -1
  241. package/src/stepper/step.ts +7 -1
  242. package/src/stepper/stepper.scss +13 -0
  243. package/src/tabs/tab.ts +21 -17
  244. package/src/textarea/textarea.ts +5 -0
  245. package/src/toolbar/toolbar.ts +26 -7
  246. package/dist/BaseField-BbOj212R.js.map +0 -1
  247. package/dist/base-button-BJMGMcMv.js.map +0 -1
  248. package/dist/datasource-OwvH7SVq.js.map +0 -1
  249. package/dist/form-submitter-beG1CXAn.js.map +0 -1
  250. package/dist/roving-focus-controller-fm95JkZJ.js.map +0 -1
  251. package/dist/throttle-SQ9t-HL7.js.map +0 -1
  252. package/dist/utils-DcvLgexs.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","sources":["../../src/calendar/calendar.ts"],"sourcesContent":["import { LitElement, html, nothing, PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport {\n addDays,\n addMonths,\n formatDate,\n formatEventLabel,\n formatEventWhen,\n isAllDayRange,\n toZonedWallClock,\n} from './utils.js';\nimport { CalendarEvent } from './calendar-event.js';\nimport { renderCalendarHeader } from './calendar-header.js';\nimport type {\n CalendarEventAddDetail,\n CalendarEventChangeDetail,\n CalendarViewType,\n EventType,\n} from './types.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { I18nController } from '@/__internal/i18n/i18n-controller.js';\nimport type { PeacockStrings } from '@/__internal/i18n/strings.js';\nimport {\n dateToIso,\n isoToDate,\n weekStart,\n type WeekDay,\n} from '@/__internal/utils/date.js';\nimport styles from './calendar.scss';\n\nexport type {\n CalendarEventAddDetail,\n CalendarEventChangeAction,\n CalendarEventChangeDetail,\n} from './types.js';\n\n/** Detail of `date-change`. */\nexport type CalendarDateChangeDetail = {\n /** The new context date. */\n date: Date;\n /** The same date as an ISO string, `YYYY-MM-DD`. */\n value: string;\n};\n\n/**\n * Applies an `event-change` to an `events` array the way the calendar does, returning a new array\n * in which the event is replaced by a copy with the new `start` and `end`. The event is found by\n * identity, else by `id`. The copy is made with object spread, so give the calendar plain objects,\n * not class instances. Use it to apply a change you canceled, for example once the server has\n * accepted it.\n */\nexport function applyCalendarChange<T extends EventType>(\n events: readonly T[],\n change: Pick<CalendarEventChangeDetail, 'event' | 'start' | 'end'>,\n): T[] {\n const { id } = change.event;\n let index = events.indexOf(change.event as T);\n if (index < 0 && id !== undefined && id !== null) {\n index = events.findIndex(event => event.id === id);\n }\n return events.map((event, i) =>\n i === index ? { ...event, start: change.start, end: change.end } : event,\n );\n}\n\n/**\n * @label Calendar\n * @tag wc-calendar\n * @rawTag calendar\n * @summary A calendar that shows events by day, week or month, with controls to move between periods.\n *\n * @overview\n * <p>Pass events as the <code>events</code> property; each has a <code>start</code>,\n * <code>end</code>, <code>title</code> and optional palette <code>color</code>. <code>end</code> is\n * exclusive: an all-day event on November 4 runs from midnight on the 4th to midnight on the 5th.\n * The day and week views lay timed events out in a column per day, with events lasting a day or\n * more in a row above; the month view shows six weeks. <code>available-views</code> sets the views\n * offered in the header's segmented buttons, and <code>view</code> the one shown.</p>\n * <p>The header has a Today button, previous and next buttons and the current date, which is a\n * polite live region. <code>previous()</code>, <code>next()</code> and <code>today()</code> do the\n * same from code; each fires <code>date-change</code>. The date shown is <code>date</code> (an ISO\n * string) or <code>contextDate</code> (a <code>Date</code>), kept in step. Choosing a day number\n * in a column view switches to the day view and fires <code>view-change</code> and\n * <code>date-change</code>.</p>\n * <p>Events are buttons, chosen with a click, Enter or Space, which fire <code>event-click</code>.\n * With <code>events-readonly</code> they are shown but cannot be focused or clicked.\n * <code>loading</code> shows a progress bar and marks the calendar busy. <code>first-day</code>\n * sets the week start (else the locale's), <code>timezone</code> the zone the current time is\n * shown in, and <code>locale</code> the language of names and times.</p>\n * <p>With <code>editable</code>, people drag events to move them and drag their edges to change\n * when they start or end: timed events in steps of <code>minute-step</code> minutes, all-day events\n * and every event in the month view by whole days. Each drop fires the cancelable\n * <code>event-change</code>; unless it is canceled, the calendar replaces <code>events</code> with\n * a new array holding a copy of the event with its new times. To confirm a change with a server\n * first, cancel the event and apply it later with <code>applyCalendarChange()</code>. An event with\n * <code>editable: false</code> stays put, and <code>events-readonly</code> turns editing off. On\n * touch screens, hold an event briefly before dragging it. Escape cancels a drag.</p>\n * <p>With <code>addable</code>, dragging across empty time, or clicking it, fires\n * <code>event-add</code> with the range: a click gives <code>default-duration</code> minutes, and\n * the all-day row and the month view give whole days. The calendar does not add the event itself.\n * It marks the range as a new event until <code>events</code> changes, the person presses Escape\n * or starts another drag, or <code>clearPlaceholder()</code> is called, for example when a dialog\n * asking for the event's title is canceled. Each change is announced to screen readers. Dragging\n * needs a pointer, so offer another way to change an event's time too, such as the dialog that\n * <code>event-click</code> opens.</p>\n *\n * @cssprop --calendar-border-color - Border color used throughout the calendar grid.\n * @cssprop --calendar-event-bg-color - Background color for calendar events.\n * @cssprop --calendar-event-border-color - Left border color for calendar events.\n *\n * @fires {CustomEvent<{event: EventType}>} event-click - An event was clicked, or chosen with Enter or Space. Detail contains `{ event }`. Not fired with `events-readonly`.\n * @fires {CustomEvent<{view: string}>} view-change - The view changed. Detail contains `{ view }`.\n * @fires {CustomEvent<{date: Date, value: string}>} date-change - The context date changed. Detail contains `{ date, value }`: the `Date` and its ISO string.\n * @fires {CustomEvent<CalendarEventChangeDetail>} event-change - An event was dragged to a new time (`action: 'move'`) or had its start or end dragged (`action: 'resize'`). Detail contains `{ event, start, end, action }`, where `event` is the object from `events` as it was. Cancelable: cancel it to keep the event where it was. Only with `editable`.\n * @fires {CustomEvent<CalendarEventAddDetail>} event-add - Empty time was dragged across or clicked. Detail contains `{ start, end, allDay }`. Only with `addable`.\n *\n * @example\n * ```html\n * <wc-calendar view=\"week\" date=\"2026-11-06\" style=\"height: 600px\"></wc-calendar>\n * ```\n *\n * @example\n * ```html\n * <wc-calendar id=\"planner\" view=\"week\" editable addable style=\"height: 600px\"></wc-calendar>\n * <script>\n * const planner = document.getElementById('planner');\n * planner.events = [\n * { id: 1, title: 'Standup', start: new Date(2026, 10, 4, 9), end: new Date(2026, 10, 4, 9, 30) },\n * ];\n * planner.addEventListener('event-change', event => console.log(event.detail));\n * planner.addEventListener('event-add', ({ detail }) => {\n * planner.events = [...planner.events, { id: Date.now(), title: 'New event', ...detail }];\n * });\n * </script>\n * ```\n */\n@IndividualComponent\nexport class Calendar extends LitElement {\n // ── Static\n\n static styles = [styles];\n\n // ── Properties\n\n /** Calendar events array. */\n @property({ type: Array })\n events: EventType[] = [];\n\n /**\n * Available views configuration. A view without a `label` shows Peacock's `day`, `week` or\n * `month` string for those values, else its `value`.\n */\n @property({ type: Array, attribute: 'available-views' })\n availableViews: CalendarViewType[] = [\n { value: 'day', type: 'column', days: 1 },\n { value: 'week', type: 'column', days: 7 },\n { value: 'month', type: 'month' },\n ];\n\n /** Current calendar view. */\n @property({ type: String, reflect: true })\n view: string = 'week';\n\n /**\n * The date the view shows, as an ISO string (`YYYY-MM-DD`). Kept in step with `contextDate`.\n * Defaults to today.\n */\n @property({ type: String })\n date: string = '';\n\n /**\n * The date the view shows, as a `Date`. Kept in step with `date`.\n */\n @property({ type: Object, attribute: false })\n contextDate: Date | null = null;\n\n /**\n * First day of the week, `0` (Sunday) to `6` (Saturday). Defaults to the locale's week start.\n */\n @property({ type: Number, attribute: 'first-day' })\n firstDay?: number;\n\n /** Events are shown but cannot be clicked or focused, and `event-click` does not fire. */\n @property({ type: Boolean, attribute: 'events-readonly' })\n eventsReadonly: boolean = false;\n\n /**\n * People can drag events to move them and drag their edges to resize them. Each drop fires the\n * cancelable `event-change`. An event with `editable: false` stays put.\n */\n @property({ type: Boolean, reflect: true })\n editable: boolean = false;\n\n /**\n * Dragging across empty time, or clicking it, fires `event-add` with the range and marks it as a\n * new event until `events` changes.\n */\n @property({ type: Boolean, reflect: true })\n addable: boolean = false;\n\n /** Minutes that dragging moves, resizes and draws timed events by. Defaults to 15. */\n @property({ type: Number, attribute: 'minute-step' })\n minuteStep: number = 15;\n\n /** Length in minutes of an event added by clicking empty time in the day or week view. Defaults to 60. */\n @property({ type: Number, attribute: 'default-duration' })\n defaultDuration: number = 60;\n\n /** Shows a progress bar and marks the calendar busy while events load. */\n @property({ type: Boolean, reflect: true })\n loading: boolean = false;\n\n /** IANA time zone the current time is shown in, for example `America/New_York`. Defaults to the browser's. */\n @property({ type: String })\n timezone: string = '';\n\n /**\n * Locale for month and day names and times. Defaults to the nearest `lang`, then the browser\n * language.\n */\n @property({ type: String })\n locale: string = '';\n\n /** Overrides Peacock's strings for this instance only. */\n @property({ attribute: false }) strings?: Partial<PeacockStrings>;\n\n // ── State\n\n /** Now, as wall-clock time in `timezone`. */\n @state()\n private _currentTime: Date = new Date();\n\n /** The entry of `availableViews` matching `view`. */\n @state()\n private _currentView: CalendarViewType | undefined;\n\n /** The range of the last `event-add`, marked as a new event until the app adds it. */\n @state()\n private _placeholder: CalendarEventAddDetail | null = null;\n\n // ── Private fields\n\n /** Peacock's strings and the resolved locale. */\n private readonly _i18n = new I18nController(this);\n\n // ── Lifecycle\n\n override connectedCallback() {\n super.connectedCallback();\n this._currentTime = this._now();\n if (!this.contextDate && !isoToDate(this.date)) {\n this.contextDate = this._currentTime;\n }\n // Capture, so a press clears the placeholder before it starts a drag of its own.\n this.addEventListener('pointerdown', this._handlePointerDown, true);\n this.addEventListener('keydown', this._handleKeyDown);\n // Clicking empty time leaves focus on the page, so Escape is also heard there.\n window.addEventListener('keydown', this._handleWindowKeyDown);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('pointerdown', this._handlePointerDown, true);\n this.removeEventListener('keydown', this._handleKeyDown);\n window.removeEventListener('keydown', this._handleWindowKeyDown);\n }\n\n override willUpdate(changed: PropertyValues<this>) {\n super.willUpdate(changed);\n if (changed.has('view') || changed.has('availableViews')) {\n this._currentView = this.availableViews.find(v => v.value === this.view);\n }\n if (changed.has('timezone')) {\n this._currentTime = this._now();\n }\n // The new event has been added, or the person has moved on.\n if (\n this._placeholder &&\n (changed.has('events') ||\n changed.has('view') ||\n changed.has('date') ||\n changed.has('contextDate') ||\n (changed.has('addable') && !this.addable))\n ) {\n this._placeholder = null;\n }\n this._syncDate(changed);\n }\n\n // ── Public methods\n\n /** Moves back one period: a day or week in column views, a month in the month view. */\n previous() {\n this._step(-1);\n }\n\n /** Moves forward one period: a day or week in column views, a month in the month view. */\n next() {\n this._step(1);\n }\n\n /** Moves the view to today, in `timezone`. */\n today() {\n this._currentTime = this._now();\n this._setContextDate(this._currentTime);\n }\n\n /**\n * Removes the new event marked after `event-add`, for when adding it is canceled. It also goes\n * when `events` changes.\n */\n clearPlaceholder() {\n this._placeholder = null;\n }\n\n // ── Private methods\n\n /** Now, as wall-clock time in `timezone`. */\n private _now(): Date {\n return toZonedWallClock(new Date(), this.timezone);\n }\n\n /** Keeps `date` and `contextDate` in step; `date` wins when both changed. */\n private _syncDate(changed: PropertyValues<this>) {\n const current = this.contextDate ? dateToIso(this.contextDate) : '';\n if (changed.has('date') && this.date && this.date !== current) {\n const parsed = isoToDate(this.date);\n if (parsed) {\n this.contextDate = parsed;\n return;\n }\n }\n if (current && this.date !== current) {\n this.date = current;\n }\n }\n\n /** The week start in effect: `firstDay` when valid, else the locale's. */\n private _weekStart(): WeekDay {\n const day = this.firstDay;\n if (\n typeof day === 'number' &&\n Number.isInteger(day) &&\n day >= 0 &&\n day <= 6\n ) {\n return day as WeekDay;\n }\n return weekStart(this._i18n.locale);\n }\n\n /** Whether events can be clicked: not `events-readonly`. */\n private _eventsInteractive(): boolean {\n return !this.eventsReadonly;\n }\n\n /** Whether events can be dragged: `editable` and not `events-readonly`. */\n private _eventsEditable(): boolean {\n return this.editable && this._eventsInteractive();\n }\n\n private _step(direction: 1 | -1) {\n if (!this._currentView || !this.contextDate) return;\n if (this._currentView.days) {\n this._setContextDate(\n addDays(this.contextDate, direction * this._currentView.days),\n );\n } else if (this._currentView.type === 'month') {\n this._setContextDate(addMonths(this.contextDate, direction));\n }\n }\n\n private _setContextDate(date: Date) {\n this.contextDate = date;\n this.date = dateToIso(date);\n this.dispatchEvent(\n new CustomEvent<CalendarDateChangeDetail>('date-change', {\n detail: { date, value: this.date },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /**\n * Reads `message` in the live region. Its text is set directly, so an announcement does not\n * render the calendar, and its views, again.\n */\n private _announce(message: string) {\n const region = this.renderRoot.querySelector('[role=\"status\"]');\n if (!region) return;\n // Clear first, so the same message twice in a row is read again.\n region.textContent = '';\n setTimeout(() => {\n region.textContent = message;\n });\n }\n\n private readonly _handlePointerDown = () => {\n if (this._placeholder) this._placeholder = null;\n };\n\n private readonly _handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape' || !this._placeholder) return;\n // Keep an enclosing dialog open.\n event.stopPropagation();\n this._placeholder = null;\n };\n\n private readonly _handleWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && this._placeholder) this._placeholder = null;\n };\n\n private _onViewDateClick(evt: CustomEvent<{ date: Date }>) {\n evt.stopPropagation();\n this.view = 'day';\n this.dispatchEvent(\n new CustomEvent('view-change', {\n detail: { view: this.view },\n bubbles: true,\n composed: true,\n }),\n );\n this._setContextDate(evt.detail.date);\n }\n\n private _onViewEventClick(evt: CustomEvent<{ event: unknown }>) {\n evt.stopPropagation();\n if (!this._eventsInteractive()) return;\n this.dispatchEvent(\n new CustomEvent('event-click', {\n detail: { event: evt.detail.event },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _onViewEventChange(evt: CustomEvent<CalendarEventChangeDetail>) {\n evt.stopPropagation();\n if (!this._eventsEditable()) return;\n const detail = { ...evt.detail };\n const change = new CustomEvent<CalendarEventChangeDetail>('event-change', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(change)) return;\n this.events = applyCalendarChange(this.events, detail);\n const { event, start, end, action } = detail;\n const title = event.title || this._i18n.t('calendarUntitled');\n const when = formatEventWhen(\n start,\n end,\n this._i18n.locale,\n isAllDayRange(start, end),\n );\n this._announce(\n this._i18n.t(\n action === 'move' ? 'calendarEventMoved' : 'calendarEventResized',\n )(title, when),\n );\n }\n\n private _onViewEventAdd(evt: CustomEvent<CalendarEventAddDetail>) {\n evt.stopPropagation();\n if (!this.addable) return;\n const detail = { ...evt.detail };\n this._placeholder = detail;\n this.dispatchEvent(\n new CustomEvent<CalendarEventAddDetail>('event-add', {\n detail,\n bubbles: true,\n composed: true,\n }),\n );\n this._announce(\n formatEventLabel(\n this._i18n.t('calendarNewEvent'),\n detail.start,\n detail.end,\n this._i18n.locale,\n detail.allDay,\n ),\n );\n }\n\n private _changeView(value: string) {\n this.view = value;\n this.dispatchEvent(\n new CustomEvent('view-change', {\n detail: { view: this.view },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /** The view's own label, else Peacock's string for the built-in views, else its value. */\n private _viewLabel(view: CalendarViewType): string {\n if (view.label) return view.label;\n if (\n view.value === 'day' ||\n view.value === 'week' ||\n view.value === 'month'\n ) {\n return this._i18n.t(view.value);\n }\n return view.value;\n }\n\n // ── Render helpers\n\n private _renderHeader() {\n return renderCalendarHeader({\n title: this.contextDate\n ? formatDate(this.contextDate, 'MMMM d, yyyy', this._i18n.locale)\n : '',\n views: this.availableViews.map(view => ({\n value: view.value,\n label: this._viewLabel(view),\n })),\n view: this.view,\n labels: {\n today: this._i18n.t('today'),\n previous: this._i18n.t('previousPeriod'),\n next: this._i18n.t('nextPeriod'),\n },\n onToday: () => this.today(),\n onPrevious: () => this.previous(),\n onNext: () => this.next(),\n onViewChange: value => this._changeView(value),\n });\n }\n\n private _renderCalendarView() {\n if (!this._currentView) {\n return html`<div>${this._i18n.t('invalidView')}</div>`;\n }\n const { locale } = this._i18n;\n const readonly = !this._eventsInteractive();\n const editable = this._eventsEditable();\n const weekStartsOn = this._weekStart();\n const contextDate = this.contextDate ?? this._currentTime;\n const untitled = this._i18n.t('calendarUntitled');\n // Wrapped on every render, so events changed in place show after `requestUpdate()`.\n const calEvents = (this.events ?? []).map(\n event =>\n new CalendarEvent(\n event.start,\n event.end,\n event.title,\n event.color,\n event,\n ),\n );\n\n if (this._currentView.type === 'column') {\n return html`\n <wc-calendar-column-view\n .events=${calEvents}\n .view=${this._currentView.value}\n .days=${this._currentView.days || 7}\n .currentTime=${this._currentTime}\n .contextDate=${contextDate}\n .weekStartsOn=${weekStartsOn}\n .locale=${locale}\n .editable=${editable}\n .addable=${this.addable}\n .minuteStep=${this.minuteStep}\n .defaultDuration=${this.defaultDuration}\n .placeholder=${this._placeholder}\n .untitledLabel=${untitled}\n .newEventLabel=${this._i18n.t('calendarNewEvent')}\n ?events-readonly=${readonly}\n @date-click=${this._onViewDateClick}\n @event-click=${this._onViewEventClick}\n @event-change=${this._onViewEventChange}\n @event-add=${this._onViewEventAdd}\n ></wc-calendar-column-view>\n `;\n }\n if (this._currentView.type === 'month') {\n return html`\n <wc-calendar-month-view\n .events=${calEvents}\n .currentTime=${this._currentTime}\n .contextDate=${contextDate}\n .weekStartsOn=${weekStartsOn}\n .locale=${locale}\n .editable=${editable}\n .addable=${this.addable}\n .placeholder=${this._placeholder}\n .untitledLabel=${untitled}\n ?events-readonly=${readonly}\n @event-click=${this._onViewEventClick}\n @event-change=${this._onViewEventChange}\n @event-add=${this._onViewEventAdd}\n ></wc-calendar-month-view>\n `;\n }\n return nothing;\n }\n\n // ── Render\n\n render() {\n const busy = this.loading;\n return html`\n <div class=\"calendar\">\n <div class=\"calendar-header\">${this._renderHeader()}</div>\n ${busy\n ? html`<wc-linear-progress\n class=\"loader\"\n indeterminate\n label=${this._i18n.t('loading')}\n ></wc-linear-progress>`\n : nothing}\n <div class=\"calendar-body\" aria-busy=${busy ? 'true' : 'false'}>\n <div class=\"view-container\">${this._renderCalendarView()}</div>\n </div>\n <div class=\"screen-reader-only\" role=\"status\" aria-live=\"polite\"></div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","nothing","styles","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA;;;;;;AAMG;AACG,SAAU,mBAAmB,CACjC,MAAoB,EACpB,MAAkE,EAAA;AAElE,IAAA,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK;IAC3B,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAU,CAAC;AAC7C,IAAA,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,EAAE;AAChD,QAAA,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;IACpD;AACA,IAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KACzB,CAAC,KAAK,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,KAAK,CACzE;AACH;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQA,GAAU,CAAA;AAAjC,IAAA,WAAA,GAAA;;;;;QASL,IAAA,CAAA,MAAM,GAAgB,EAAE;AAExB;;;AAGG;AAEH,QAAA,IAAA,CAAA,cAAc,GAAuB;YACnC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI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AAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE;AAC5B,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,MAAA,CAAA;AAI7B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACjB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIzB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACJ,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAOtB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACN,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAGY,UAAA,CAAA;AAA/B,IAAAA,CAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AAAoC,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAM1D,UAAA,CAAA;AADP,IAAAC,CAAK;AACkC,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAIhC,UAAA,CAAA;AADP,IAAAA,CAAK;AAC6C,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAI3C,UAAA,CAAA;AADP,IAAAA,CAAK;AACqD,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AArGhD,QAAQ,GAAA,UAAA,CAAA;IADpB;AACY,CAAA,EAAA,QAAQ,CAyepB;;;;"}
1
+ {"version":3,"file":"calendar.js","sources":["../../src/calendar/calendar.ts"],"sourcesContent":["import { LitElement, html, nothing, PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport {\n addDays,\n addMonths,\n formatDate,\n formatEventLabel,\n formatEventWhen,\n isAllDayRange,\n toZonedWallClock,\n} from './utils.js';\nimport { CalendarEvent } from './calendar-event.js';\nimport { renderCalendarHeader } from './calendar-header.js';\nimport type {\n CalendarEventAddDetail,\n CalendarEventChangeDetail,\n CalendarViewType,\n EventType,\n} from './types.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { I18nController } from '@/__internal/i18n/i18n-controller.js';\nimport type { PeacockStrings } from '@/__internal/i18n/strings.js';\nimport {\n dateToIso,\n isoToDate,\n weekStart,\n type WeekDay,\n} from '@/__internal/utils/date.js';\nimport styles from './calendar.scss';\n\nexport type {\n CalendarEventAddDetail,\n CalendarEventChangeAction,\n CalendarEventChangeDetail,\n} from './types.js';\n\n/** Detail of `date-change`. */\nexport type CalendarDateChangeDetail = {\n /** The new context date. */\n date: Date;\n /** The same date as an ISO string, `YYYY-MM-DD`. */\n value: string;\n};\n\n/**\n * Applies an `event-change` to an `events` array the way the calendar does, returning a new array\n * in which the event is replaced by a copy with the new `start` and `end`. The event is found by\n * identity, else by `id`. The copy is made with object spread, so give the calendar plain objects,\n * not class instances. Use it to apply a change you canceled, for example once the server has\n * accepted it.\n */\nexport function applyCalendarChange<T extends EventType>(\n events: readonly T[],\n change: Pick<CalendarEventChangeDetail, 'event' | 'start' | 'end'>,\n): T[] {\n const { id } = change.event;\n let index = events.indexOf(change.event as T);\n if (index < 0 && id !== undefined && id !== null) {\n index = events.findIndex(event => event.id === id);\n }\n return events.map((event, i) =>\n i === index ? { ...event, start: change.start, end: change.end } : event,\n );\n}\n\n/**\n * @label Calendar\n * @tag wc-calendar\n * @rawTag calendar\n * @summary A calendar that shows events by day, week or month, with controls to move between periods.\n *\n * @overview\n * <p>Pass events as the <code>events</code> property; each has a <code>start</code>,\n * <code>end</code>, <code>title</code> and optional palette <code>color</code>. <code>end</code> is\n * exclusive: an all-day event on November 4 runs from midnight on the 4th to midnight on the 5th.\n * The day and week views lay timed events out in a column per day, with events lasting a day or\n * more in a row above; the month view shows six weeks. <code>available-views</code> sets the views\n * offered in the header's segmented buttons, and <code>view</code> the one shown.</p>\n * <p>The header has a Today button, previous and next buttons and the current date, which is a\n * polite live region. <code>previous()</code>, <code>next()</code> and <code>today()</code> do the\n * same from code; each fires <code>date-change</code>. The date shown is <code>date</code> (an ISO\n * string) or <code>contextDate</code> (a <code>Date</code>), kept in step. Choosing a day number\n * in a column view switches to the day view and fires <code>view-change</code> and\n * <code>date-change</code>. In the month view, choosing a day number selects that day (it is\n * highlighted and becomes <code>contextDate</code>) and fires <code>date-change</code>, staying on\n * the month. The header shows the month and year in the month view and the full date otherwise,\n * and wraps onto two lines when the calendar is narrow.</p>\n * <p>Events are buttons, chosen with a click, Enter or Space, which fire <code>event-click</code>.\n * With <code>events-readonly</code> they are shown but cannot be focused or clicked.\n * <code>loading</code> shows a progress bar and marks the calendar busy. <code>first-day</code>\n * sets the week start (else the locale's), <code>timezone</code> the zone the current time is\n * shown in, and <code>locale</code> the language of names and times.</p>\n * <p>With <code>editable</code>, people drag events to move them and drag their edges to change\n * when they start or end: timed events in steps of <code>minute-step</code> minutes, all-day events\n * and every event in the month view by whole days. Each drop fires the cancelable\n * <code>event-change</code>; unless it is canceled, the calendar replaces <code>events</code> with\n * a new array holding a copy of the event with its new times. To confirm a change with a server\n * first, cancel the event and apply it later with <code>applyCalendarChange()</code>. An event with\n * <code>editable: false</code> stays put, and <code>events-readonly</code> turns editing off. On\n * touch screens, hold an event briefly before dragging it. Escape cancels a drag.</p>\n * <p>With <code>addable</code>, dragging across empty time, or clicking it, fires\n * <code>event-add</code> with the range: a click gives <code>default-duration</code> minutes, and\n * the all-day row and the month view give whole days. The calendar does not add the event itself.\n * It marks the range as a new event until <code>events</code> changes, the person presses Escape\n * or starts another drag, or <code>clearPlaceholder()</code> is called, for example when a dialog\n * asking for the event's title is canceled. Each change is announced to screen readers. Dragging\n * needs a pointer, so offer another way to change an event's time too, such as the dialog that\n * <code>event-click</code> opens.</p>\n *\n * @cssprop --calendar-border-color - Border color used throughout the calendar grid.\n * @cssprop --calendar-event-bg-color - Background color for calendar events.\n * @cssprop --calendar-event-border-color - Left border color for calendar events.\n *\n * @fires {CustomEvent<{event: EventType}>} event-click - An event was clicked, or chosen with Enter or Space. Detail contains `{ event }`. Not fired with `events-readonly`.\n * @fires {CustomEvent<{view: string}>} view-change - The view changed. Detail contains `{ view }`.\n * @fires {CustomEvent<{date: Date, value: string}>} date-change - The context date changed. Detail contains `{ date, value }`: the `Date` and its ISO string.\n * @fires {CustomEvent<CalendarEventChangeDetail>} event-change - An event was dragged to a new time (`action: 'move'`) or had its start or end dragged (`action: 'resize'`). Detail contains `{ event, start, end, action }`, where `event` is the object from `events` as it was. Cancelable: cancel it to keep the event where it was. Only with `editable`.\n * @fires {CustomEvent<CalendarEventAddDetail>} event-add - Empty time was dragged across or clicked. Detail contains `{ start, end, allDay }`. Only with `addable`.\n *\n * @example\n * ```html\n * <wc-calendar view=\"week\" date=\"2026-11-06\" style=\"height: 600px\"></wc-calendar>\n * ```\n *\n * @example\n * ```html\n * <wc-calendar id=\"planner\" view=\"week\" editable addable style=\"height: 600px\"></wc-calendar>\n * <script>\n * const planner = document.getElementById('planner');\n * planner.events = [\n * { id: 1, title: 'Standup', start: new Date(2026, 10, 4, 9), end: new Date(2026, 10, 4, 9, 30) },\n * ];\n * planner.addEventListener('event-change', event => console.log(event.detail));\n * planner.addEventListener('event-add', ({ detail }) => {\n * planner.events = [...planner.events, { id: Date.now(), title: 'New event', ...detail }];\n * });\n * </script>\n * ```\n */\n@IndividualComponent\nexport class Calendar extends LitElement {\n // ── Static\n\n static styles = [styles];\n\n // ── Properties\n\n /** Calendar events array. */\n @property({ type: Array })\n events: EventType[] = [];\n\n /**\n * Available views configuration. A view without a `label` shows Peacock's `day`, `week` or\n * `month` string for those values, else its `value`.\n */\n @property({ type: Array, attribute: 'available-views' })\n availableViews: CalendarViewType[] = [\n { value: 'day', type: 'column', days: 1 },\n { value: 'week', type: 'column', days: 7 },\n { value: 'month', type: 'month' },\n ];\n\n /** Current calendar view. */\n @property({ type: String, reflect: true })\n view: string = 'week';\n\n /**\n * The date the view shows, as an ISO string (`YYYY-MM-DD`). Kept in step with `contextDate`.\n * Defaults to today.\n */\n @property({ type: String })\n date: string = '';\n\n /**\n * The date the view shows, as a `Date`. Kept in step with `date`.\n */\n @property({ type: Object, attribute: false })\n contextDate: Date | null = null;\n\n /**\n * First day of the week, `0` (Sunday) to `6` (Saturday). Defaults to the locale's week start.\n */\n @property({ type: Number, attribute: 'first-day' })\n firstDay?: number;\n\n /** Events are shown but cannot be clicked or focused, and `event-click` does not fire. */\n @property({ type: Boolean, attribute: 'events-readonly' })\n eventsReadonly: boolean = false;\n\n /**\n * People can drag events to move them and drag their edges to resize them. Each drop fires the\n * cancelable `event-change`. An event with `editable: false` stays put.\n */\n @property({ type: Boolean, reflect: true })\n editable: boolean = false;\n\n /**\n * Dragging across empty time, or clicking it, fires `event-add` with the range and marks it as a\n * new event until `events` changes.\n */\n @property({ type: Boolean, reflect: true })\n addable: boolean = false;\n\n /** Minutes that dragging moves, resizes and draws timed events by. Defaults to 15. */\n @property({ type: Number, attribute: 'minute-step' })\n minuteStep: number = 15;\n\n /** Length in minutes of an event added by clicking empty time in the day or week view. Defaults to 60. */\n @property({ type: Number, attribute: 'default-duration' })\n defaultDuration: number = 60;\n\n /** Shows a progress bar and marks the calendar busy while events load. */\n @property({ type: Boolean, reflect: true })\n loading: boolean = false;\n\n /** IANA time zone the current time is shown in, for example `America/New_York`. Defaults to the browser's. */\n @property({ type: String })\n timezone: string = '';\n\n /**\n * Locale for month and day names and times. Defaults to the nearest `lang`, then the browser\n * language.\n */\n @property({ type: String })\n locale: string = '';\n\n /** Overrides Peacock's strings for this instance only. */\n @property({ attribute: false }) strings?: Partial<PeacockStrings>;\n\n // ── State\n\n /** Now, as wall-clock time in `timezone`. */\n @state()\n private _currentTime: Date = new Date();\n\n /** The entry of `availableViews` matching `view`. */\n @state()\n private _currentView: CalendarViewType | undefined;\n\n /** The range of the last `event-add`, marked as a new event until the app adds it. */\n @state()\n private _placeholder: CalendarEventAddDetail | null = null;\n\n // ── Private fields\n\n /** Peacock's strings and the resolved locale. */\n private readonly _i18n = new I18nController(this);\n\n // ── Lifecycle\n\n override connectedCallback() {\n super.connectedCallback();\n this._currentTime = this._now();\n if (!this.contextDate && !isoToDate(this.date)) {\n this.contextDate = this._currentTime;\n }\n // Capture, so a press clears the placeholder before it starts a drag of its own.\n this.addEventListener('pointerdown', this._handlePointerDown, true);\n this.addEventListener('keydown', this._handleKeyDown);\n // Clicking empty time leaves focus on the page, so Escape is also heard there.\n window.addEventListener('keydown', this._handleWindowKeyDown);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('pointerdown', this._handlePointerDown, true);\n this.removeEventListener('keydown', this._handleKeyDown);\n window.removeEventListener('keydown', this._handleWindowKeyDown);\n }\n\n override willUpdate(changed: PropertyValues<this>) {\n super.willUpdate(changed);\n if (changed.has('view') || changed.has('availableViews')) {\n this._currentView = this.availableViews.find(v => v.value === this.view);\n }\n if (changed.has('timezone')) {\n this._currentTime = this._now();\n }\n // The new event has been added, or the person has moved on.\n if (\n this._placeholder &&\n (changed.has('events') ||\n changed.has('view') ||\n changed.has('date') ||\n changed.has('contextDate') ||\n (changed.has('addable') && !this.addable))\n ) {\n this._placeholder = null;\n }\n this._syncDate(changed);\n }\n\n // ── Public methods\n\n /** Moves back one period: a day or week in column views, a month in the month view. */\n previous() {\n this._step(-1);\n }\n\n /** Moves forward one period: a day or week in column views, a month in the month view. */\n next() {\n this._step(1);\n }\n\n /** Moves the view to today, in `timezone`. */\n today() {\n this._currentTime = this._now();\n this._setContextDate(this._currentTime);\n }\n\n /**\n * Removes the new event marked after `event-add`, for when adding it is canceled. It also goes\n * when `events` changes.\n */\n clearPlaceholder() {\n this._placeholder = null;\n }\n\n // ── Private methods\n\n /** Now, as wall-clock time in `timezone`. */\n private _now(): Date {\n return toZonedWallClock(new Date(), this.timezone);\n }\n\n /** Keeps `date` and `contextDate` in step; `date` wins when both changed. */\n private _syncDate(changed: PropertyValues<this>) {\n const current = this.contextDate ? dateToIso(this.contextDate) : '';\n if (changed.has('date') && this.date && this.date !== current) {\n const parsed = isoToDate(this.date);\n if (parsed) {\n this.contextDate = parsed;\n return;\n }\n }\n if (current && this.date !== current) {\n this.date = current;\n }\n }\n\n /** The week start in effect: `firstDay` when valid, else the locale's. */\n private _weekStart(): WeekDay {\n const day = this.firstDay;\n if (\n typeof day === 'number' &&\n Number.isInteger(day) &&\n day >= 0 &&\n day <= 6\n ) {\n return day as WeekDay;\n }\n return weekStart(this._i18n.locale);\n }\n\n /** Whether events can be clicked: not `events-readonly`. */\n private _eventsInteractive(): boolean {\n return !this.eventsReadonly;\n }\n\n /** Whether events can be dragged: `editable` and not `events-readonly`. */\n private _eventsEditable(): boolean {\n return this.editable && this._eventsInteractive();\n }\n\n private _step(direction: 1 | -1) {\n if (!this._currentView || !this.contextDate) return;\n if (this._currentView.days) {\n this._setContextDate(\n addDays(this.contextDate, direction * this._currentView.days),\n );\n } else if (this._currentView.type === 'month') {\n this._setContextDate(addMonths(this.contextDate, direction));\n }\n }\n\n private _setContextDate(date: Date) {\n this.contextDate = date;\n this.date = dateToIso(date);\n this.dispatchEvent(\n new CustomEvent<CalendarDateChangeDetail>('date-change', {\n detail: { date, value: this.date },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /**\n * Reads `message` in the live region. Its text is set directly, so an announcement does not\n * render the calendar, and its views, again.\n */\n private _announce(message: string) {\n const region = this.renderRoot.querySelector('[role=\"status\"]');\n if (!region) return;\n // Clear first, so the same message twice in a row is read again.\n region.textContent = '';\n setTimeout(() => {\n region.textContent = message;\n });\n }\n\n private readonly _handlePointerDown = () => {\n if (this._placeholder) this._placeholder = null;\n };\n\n private readonly _handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape' || !this._placeholder) return;\n // Keep an enclosing dialog open.\n event.stopPropagation();\n this._placeholder = null;\n };\n\n private readonly _handleWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && this._placeholder) this._placeholder = null;\n };\n\n private _onViewDateClick(evt: CustomEvent<{ date: Date }>) {\n evt.stopPropagation();\n this.view = 'day';\n this.dispatchEvent(\n new CustomEvent('view-change', {\n detail: { view: this.view },\n bubbles: true,\n composed: true,\n }),\n );\n this._setContextDate(evt.detail.date);\n }\n\n /** A day chosen in the month view becomes the selected day; the view stays on the month. */\n private _onMonthDateClick(evt: CustomEvent<{ date: Date }>) {\n evt.stopPropagation();\n this._setContextDate(evt.detail.date);\n }\n\n private _onViewEventClick(evt: CustomEvent<{ event: unknown }>) {\n evt.stopPropagation();\n if (!this._eventsInteractive()) return;\n this.dispatchEvent(\n new CustomEvent('event-click', {\n detail: { event: evt.detail.event },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _onViewEventChange(evt: CustomEvent<CalendarEventChangeDetail>) {\n evt.stopPropagation();\n if (!this._eventsEditable()) return;\n const detail = { ...evt.detail };\n const change = new CustomEvent<CalendarEventChangeDetail>('event-change', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(change)) return;\n this.events = applyCalendarChange(this.events, detail);\n const { event, start, end, action } = detail;\n const title = event.title || this._i18n.t('calendarUntitled');\n const when = formatEventWhen(\n start,\n end,\n this._i18n.locale,\n isAllDayRange(start, end),\n );\n this._announce(\n this._i18n.t(\n action === 'move' ? 'calendarEventMoved' : 'calendarEventResized',\n )(title, when),\n );\n }\n\n private _onViewEventAdd(evt: CustomEvent<CalendarEventAddDetail>) {\n evt.stopPropagation();\n if (!this.addable) return;\n const detail = { ...evt.detail };\n this._placeholder = detail;\n this.dispatchEvent(\n new CustomEvent<CalendarEventAddDetail>('event-add', {\n detail,\n bubbles: true,\n composed: true,\n }),\n );\n this._announce(\n formatEventLabel(\n this._i18n.t('calendarNewEvent'),\n detail.start,\n detail.end,\n this._i18n.locale,\n detail.allDay,\n ),\n );\n }\n\n private _changeView(value: string) {\n this.view = value;\n this.dispatchEvent(\n new CustomEvent('view-change', {\n detail: { view: this.view },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /** The view's own label, else Peacock's string for the built-in views, else its value. */\n private _viewLabel(view: CalendarViewType): string {\n if (view.label) return view.label;\n if (\n view.value === 'day' ||\n view.value === 'week' ||\n view.value === 'month'\n ) {\n return this._i18n.t(view.value);\n }\n return view.value;\n }\n\n // ── Render helpers\n\n private _renderHeader() {\n return renderCalendarHeader({\n // \"November 2026\" in the month view, the full date in the others.\n title: this.contextDate\n ? formatDate(\n this.contextDate,\n this._currentView?.type === 'month' ? 'MMMM yyyy' : 'MMMM d, yyyy',\n this._i18n.locale,\n )\n : '',\n views: this.availableViews.map(view => ({\n value: view.value,\n label: this._viewLabel(view),\n })),\n view: this.view,\n labels: {\n today: this._i18n.t('today'),\n previous: this._i18n.t('previousPeriod'),\n next: this._i18n.t('nextPeriod'),\n },\n onToday: () => this.today(),\n onPrevious: () => this.previous(),\n onNext: () => this.next(),\n onViewChange: value => this._changeView(value),\n });\n }\n\n private _renderCalendarView() {\n if (!this._currentView) {\n return html`<div>${this._i18n.t('invalidView')}</div>`;\n }\n const { locale } = this._i18n;\n const readonly = !this._eventsInteractive();\n const editable = this._eventsEditable();\n const weekStartsOn = this._weekStart();\n const contextDate = this.contextDate ?? this._currentTime;\n const untitled = this._i18n.t('calendarUntitled');\n // Wrapped on every render, so events changed in place show after `requestUpdate()`.\n const calEvents = (this.events ?? []).map(\n event =>\n new CalendarEvent(\n event.start,\n event.end,\n event.title,\n event.color,\n event,\n ),\n );\n\n if (this._currentView.type === 'column') {\n return html`\n <wc-calendar-column-view\n .events=${calEvents}\n .view=${this._currentView.value}\n .days=${this._currentView.days || 7}\n .currentTime=${this._currentTime}\n .contextDate=${contextDate}\n .weekStartsOn=${weekStartsOn}\n .locale=${locale}\n .editable=${editable}\n .addable=${this.addable}\n .minuteStep=${this.minuteStep}\n .defaultDuration=${this.defaultDuration}\n .placeholder=${this._placeholder}\n .untitledLabel=${untitled}\n .newEventLabel=${this._i18n.t('calendarNewEvent')}\n ?events-readonly=${readonly}\n @date-click=${this._onViewDateClick}\n @event-click=${this._onViewEventClick}\n @event-change=${this._onViewEventChange}\n @event-add=${this._onViewEventAdd}\n ></wc-calendar-column-view>\n `;\n }\n if (this._currentView.type === 'month') {\n return html`\n <wc-calendar-month-view\n .events=${calEvents}\n .currentTime=${this._currentTime}\n .contextDate=${contextDate}\n .weekStartsOn=${weekStartsOn}\n .locale=${locale}\n .editable=${editable}\n .addable=${this.addable}\n .placeholder=${this._placeholder}\n .untitledLabel=${untitled}\n ?events-readonly=${readonly}\n @date-click=${this._onMonthDateClick}\n @event-click=${this._onViewEventClick}\n @event-change=${this._onViewEventChange}\n @event-add=${this._onViewEventAdd}\n ></wc-calendar-month-view>\n `;\n }\n return nothing;\n }\n\n // ── Render\n\n render() {\n const busy = this.loading;\n return html`\n <div class=\"calendar\">\n <div class=\"calendar-header\">${this._renderHeader()}</div>\n ${busy\n ? html`<wc-linear-progress\n class=\"loader\"\n indeterminate\n label=${this._i18n.t('loading')}\n ></wc-linear-progress>`\n : nothing}\n <div class=\"calendar-body\" aria-busy=${busy ? 'true' : 'false'}>\n <div class=\"view-container\">${this._renderCalendarView()}</div>\n </div>\n <div class=\"screen-reader-only\" role=\"status\" aria-live=\"polite\"></div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","nothing","styles","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA;;;;;;AAMG;AACG,SAAU,mBAAmB,CACjC,MAAoB,EACpB,MAAkE,EAAA;AAElE,IAAA,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK;IAC3B,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,M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EAAA,QAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIzB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACJ,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAOtB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACN,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAGY,UAAA,CAAA;AAA/B,IAAAA,CAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AAAoC,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAM1D,UAAA,CAAA;AADP,IAAAC,CAAK;AACkC,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAIhC,UAAA,CAAA;AADP,IAAAA,CAAK;AAC6C,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAI3C,UAAA,CAAA;AADP,IAAAA,CAAK;AACqD,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AArGhD,QAAQ,GAAA,UAAA,CAAA;IADpB;AACY,CAAA,EAAA,QAAQ,CAqfpB;;;;"}
package/dist/card.js CHANGED
@@ -4,9 +4,10 @@ import { r } from './state-BCeDVCI9.js';
4
4
  import { e as e$1 } from './query-CHb9Ft_d.js';
5
5
  import { e } from './class-map-NDIkZErE.js';
6
6
  import { o } from './if-defined-D9DEJR_6.js';
7
- import { i as isActivationClick, d as dispatchActivationClick, t as throttle } from './throttle-SQ9t-HL7.js';
7
+ import { i as isActivationClick, d as dispatchActivationClick } from './dispatch-event-utils-DfgqVBK8.js';
8
8
  import { i as isLink } from './is-link-Dk2OV3PM.js';
9
9
  import { o as observerSlotChangesWithCallback } from './observe-slot-change-DPxaZrZF.js';
10
+ import { t as throttle } from './throttle-C7ZAPqtu.js';
10
11
  import { N as NativeHyperlinkMixin } from './NativeHyperlinkMixin-WdY0fM-H.js';
11
12
  import './base-Cl6v8-BZ.js';
12
13
  import './directive-ZPhl09Yt.js';
@@ -313,11 +314,12 @@ const DISABLED_REASON_ID = 'disabled-reason';
313
314
  * edge-to-edge media.</p>
314
315
  * <p>Set <code>actionable</code> to make the whole card a single button that fires
315
316
  * <code>click</code>, or <code>href</code> (with <code>target</code>, <code>rel</code> and
316
- * <code>download</code>) to make it a link. The content of an actionable or link card is inert, so
317
- * don't put buttons or links inside one; use a plain card with its own actions instead.
317
+ * <code>download</code>) to make it a link. The content of an actionable or link card names the
318
+ * button or link, and anything focusable or clickable inside it stops responding, so don't put
319
+ * buttons or links inside one; use a plain card with its own actions instead.
318
320
  * <code>throttle-delay</code> throttles activation.</p>
319
- * <p><code>disabled</code> dims the card and makes its content inert; an actionable or link card
320
- * also stops responding to clicks and leaves the tab order. With <code>disabled-reason</code> it
321
+ * <p><code>disabled</code> dims the card. A static card's content becomes inert; an actionable or
322
+ * link card stops responding to clicks and leaves the tab order. With <code>disabled-reason</code> it
321
323
  * stays focusable and screen readers read the reason with it.</p>
322
324
  *
323
325
  * @cssprop --card-container-shape - Corner radius of the card. Defaults to `--shape-corner-large`.
@@ -345,13 +347,14 @@ let Card = class Card extends NativeHyperlinkMixin(i$1) {
345
347
  */
346
348
  this.variant = 'elevated';
347
349
  /**
348
- * Dims the card and makes its content inert. An actionable or link card also stops responding
349
- * to clicks and leaves the tab order, unless `disabled-reason` is set.
350
+ * Dims the card. A static card's content becomes inert. An actionable or link card stops
351
+ * responding to clicks and leaves the tab order, unless `disabled-reason` is set.
350
352
  */
351
353
  this.disabled = false;
352
354
  /**
353
- * Makes the whole card a single button that fires `click`. Its content becomes inert, so don't
354
- * put buttons or links inside an actionable card.
355
+ * Makes the whole card a single button that fires `click`. Its content names the button, and
356
+ * anything focusable or clickable inside it stops responding, so don't put buttons or links
357
+ * inside an actionable card.
355
358
  */
356
359
  this.actionable = false;
357
360
  /**
@@ -405,8 +408,11 @@ let Card = class Card extends NativeHyperlinkMixin(i$1) {
405
408
  renderDisabledReason() {
406
409
  if (!this.__isSoftDisabled())
407
410
  return A;
411
+ // aria-hidden keeps the reason out of the control's name (it sits inside the button or link);
412
+ // aria-describedby still reads it as the description.
408
413
  return b `<div
409
414
  id=${DISABLED_REASON_ID}
415
+ aria-hidden="true"
410
416
  role="tooltip"
411
417
  aria-label=${this.disabledReason}
412
418
  class="screen-reader-only"
@@ -424,10 +430,9 @@ let Card = class Card extends NativeHyperlinkMixin(i$1) {
424
430
  disabled: this.disabled,
425
431
  'has-content': this.slotHasContent,
426
432
  };
427
- const inertContent = interactive || this.disabled;
428
433
  if (!interactive) {
429
434
  return b `<div class=${e(cssClasses)} id="card">
430
- ${this.renderCardContent(inertContent)}
435
+ ${this.renderCardContent(false)}
431
436
  </div>`;
432
437
  }
433
438
  const softDisabled = this.__isSoftDisabled();
@@ -441,7 +446,7 @@ let Card = class Card extends NativeHyperlinkMixin(i$1) {
441
446
  aria-disabled=${o(this.disabled ? 'true' : undefined)}
442
447
  ?disabled=${removedFromTabOrder}
443
448
  >
444
- ${this.renderCardContent(inertContent)} ${this.renderDisabledReason()}
449
+ ${this.renderCardContent(true)} ${this.renderDisabledReason()}
445
450
  </button>`;
446
451
  }
447
452
  return b `<a
@@ -456,14 +461,22 @@ let Card = class Card extends NativeHyperlinkMixin(i$1) {
456
461
  aria-describedby=${o(this.__getDisabledReasonID())}
457
462
  aria-disabled=${o(this.disabled ? 'true' : undefined)}
458
463
  >
459
- ${this.renderCardContent(inertContent)} ${this.renderDisabledReason()}
464
+ ${this.renderCardContent(true)} ${this.renderDisabledReason()}
460
465
  </a>`;
461
466
  }
462
- renderCardContent(inertContent) {
467
+ /**
468
+ * Renders the slotted content. Inside the button or link of an actionable or link card the
469
+ * content stays in the accessibility tree, because it gives the control its name: `inert` would
470
+ * remove it and leave screen readers announcing just "button" or "link". Instead, a slot with a
471
+ * negative tabindex takes everything assigned to it out of sequential focus navigation, and
472
+ * `.card-content` ignores the pointer (see card.scss). A disabled static card has no control to
473
+ * name, so its content is simply inert.
474
+ */
475
+ renderCardContent(interactive) {
463
476
  return b `
464
477
  <div class="card-content">
465
- <div class="slot-container" ?inert=${inertContent}>
466
- <slot></slot>
478
+ <div class="slot-container" ?inert=${!interactive && this.disabled}>
479
+ <slot tabindex=${o(interactive ? '-1' : undefined)}></slot>
467
480
  </div>
468
481
  </div>
469
482
  `;
package/dist/card.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"card.js","sources":["../../src/card/card.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n dispatchActivationClick,\n isActivationClick,\n} from '../__internal/utils/dispatch-event-utils.js';\nimport { isLink } from '@/__internal/utils/is-link.js';\nimport { observerSlotChangesWithCallback } from '@/__internal/utils/observe-slot-change.js';\nimport { throttle } from '@/__internal/utils/throttle.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './card.scss';\nimport colorStyles from './card-colors.scss';\nimport NativeHyperlinkMixin from '@/__internal/mixins/NativeHyperlinkMixin.js';\n\ntype CardVariant = 'elevated' | 'filled' | 'outlined';\n\nconst DISABLED_REASON_ID = 'disabled-reason';\n\n/**\n * @label Card\n * @tag wc-card\n * @rawTag card\n * @summary A surface that groups content and actions about one subject.\n *\n * @overview\n * <p>A card is <code>elevated</code> (the default), <code>filled</code> or <code>outlined</code>.\n * It adds no padding of its own: put text in <code>wc-card-content</code>, which can sit next to\n * edge-to-edge media.</p>\n * <p>Set <code>actionable</code> to make the whole card a single button that fires\n * <code>click</code>, or <code>href</code> (with <code>target</code>, <code>rel</code> and\n * <code>download</code>) to make it a link. The content of an actionable or link card is inert, so\n * don't put buttons or links inside one; use a plain card with its own actions instead.\n * <code>throttle-delay</code> throttles activation.</p>\n * <p><code>disabled</code> dims the card and makes its content inert; an actionable or link card\n * also stops responding to clicks and leaves the tab order. With <code>disabled-reason</code> it\n * stays focusable and screen readers read the reason with it.</p>\n *\n * @cssprop --card-container-shape - Corner radius of the card. Defaults to `--shape-corner-large`.\n * @cssprop --card-padding - Padding inside the card, around its children. Defaults to 0; `wc-card-content` adds its own padding.\n * @cssprop --card-gap - Gap between the card's children. Defaults to 0.\n *\n * @example\n * ```html\n * <wc-card variant=\"outlined\">\n * <wc-card-content>\n * <h3 class=\"text-title-large\">Title</h3>\n * <p class=\"text-body-medium\">Supporting text</p>\n * </wc-card-content>\n * </wc-card>\n * ```\n */\n@IndividualComponent\nexport class Card extends NativeHyperlinkMixin(LitElement) {\n // ── Static ────────────────────────────────────────────────────────────────\n\n static styles = [styles, colorStyles];\n\n // ── Properties ────────────────────────────────────────────────────────────\n\n /**\n * Visual style of the card: `elevated` (a raised surface with a shadow), `filled` (a tonal surface)\n * or `outlined` (a bordered surface). Defaults to `elevated`.\n */\n @property({ type: String, reflect: true })\n variant: CardVariant = 'elevated';\n\n /**\n * Dims the card and makes its content inert. An actionable or link card also stops responding\n * to clicks and leaves the tab order, unless `disabled-reason` is set.\n */\n @property({ type: Boolean, reflect: true })\n disabled: boolean = false;\n\n /**\n * Makes the whole card a single button that fires `click`. Its content becomes inert, so don't\n * put buttons or links inside an actionable card.\n */\n @property({ type: Boolean, reflect: true })\n actionable: boolean = false;\n\n /**\n * Why an actionable or link card is disabled. The card stays focusable and screen readers read\n * the reason with it.\n */\n @property({ attribute: 'disabled-reason' })\n disabledReason: string = '';\n\n /**\n * Delay in milliseconds for throttling activation of an actionable or link card. When unset\n * (default), no throttle is applied.\n */\n @property({ type: Number, attribute: 'throttle-delay' })\n throttleDelay?: number;\n\n /** Whether the default slot holds meaningful content. */\n @state()\n private slotHasContent = false;\n\n // ── Queries ───────────────────────────────────────────────────────────────\n\n @query('.card') readonly cardElement!: HTMLElement | null;\n\n // ── Constructor ───────────────────────────────────────────────────────────\n\n constructor() {\n super();\n // Look the handler up on every click, so the throttled version set in\n // firstUpdated() is the one that runs.\n this.addEventListener('click', event => this.__handleClick(event));\n }\n\n // ── Lifecycle ─────────────────────────────────────────────────────────────\n\n override firstUpdated() {\n if (typeof this.throttleDelay === 'number') {\n this.__dispatchClickWithThrottle = throttle(\n this.__dispatchClick,\n this.throttleDelay,\n );\n }\n observerSlotChangesWithCallback(\n this.renderRoot.querySelector('slot'),\n hasContent => {\n this.slotHasContent = hasContent;\n },\n );\n }\n\n // ── Private methods ───────────────────────────────────────────────────────\n\n __handleClick(event: MouseEvent | KeyboardEvent) {\n // A disabled card never activates, and consumer click listeners on it never run.\n if (this.disabled) {\n event.stopImmediatePropagation();\n event.preventDefault();\n return;\n }\n this.__dispatchClickWithThrottle(event);\n }\n\n __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =\n event => {\n this.__dispatchClick(event);\n };\n\n __dispatchClick = (event: MouseEvent | KeyboardEvent) => {\n if (!isActivationClick(event) || !this.cardElement) {\n return;\n }\n\n this.focus();\n dispatchActivationClick(this.cardElement);\n };\n\n /** True when a disabled interactive card should stay focusable to expose its reason. */\n __isSoftDisabled() {\n return this.disabled && !!this.disabledReason;\n }\n\n __getDisabledReasonID() {\n return this.__isSoftDisabled() ? DISABLED_REASON_ID : undefined;\n }\n\n // ── Render helpers ────────────────────────────────────────────────────────\n\n renderDisabledReason() {\n if (!this.__isSoftDisabled()) return nothing;\n return html`<div\n id=${DISABLED_REASON_ID}\n role=\"tooltip\"\n aria-label=${this.disabledReason}\n class=\"screen-reader-only\"\n >\n ${this.disabledReason}\n </div>`;\n }\n\n renderCardElement(isLinkElement: boolean) {\n const interactive = this.actionable || isLinkElement;\n const cssClasses = {\n card: true,\n 'card-element': true,\n [`variant-${this.variant}`]: true,\n actionable: interactive && !this.disabled,\n disabled: this.disabled,\n 'has-content': this.slotHasContent,\n };\n const inertContent = interactive || this.disabled;\n\n if (!interactive) {\n return html`<div class=${classMap(cssClasses)} id=\"card\">\n ${this.renderCardContent(inertContent)}\n </div>`;\n }\n\n const softDisabled = this.__isSoftDisabled();\n const removedFromTabOrder = this.disabled && !softDisabled;\n\n if (!isLinkElement) {\n return html`<button\n class=${classMap(cssClasses)}\n id=\"card\"\n type=\"button\"\n aria-describedby=${ifDefined(this.__getDisabledReasonID())}\n aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}\n ?disabled=${removedFromTabOrder}\n >\n ${this.renderCardContent(inertContent)} ${this.renderDisabledReason()}\n </button>`;\n }\n\n return html`<a\n class=${classMap(cssClasses)}\n id=\"card\"\n href=${ifDefined(this.disabled ? undefined : this.href)}\n target=${ifDefined(this.disabled ? undefined : this.target)}\n rel=${ifDefined(this.disabled ? undefined : this.rel)}\n download=${ifDefined(this.disabled ? undefined : this.download)}\n role=${ifDefined(this.disabled ? 'link' : undefined)}\n tabindex=${removedFromTabOrder ? '-1' : '0'}\n aria-describedby=${ifDefined(this.__getDisabledReasonID())}\n aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}\n >\n ${this.renderCardContent(inertContent)} ${this.renderDisabledReason()}\n </a>`;\n }\n\n renderCardContent(inertContent: boolean) {\n return html`\n <div class=\"card-content\">\n <div class=\"slot-container\" ?inert=${inertContent}>\n <slot></slot>\n </div>\n </div>\n `;\n }\n\n // ── Render ────────────────────────────────────────────────────────────────\n\n render() {\n return html`\n <wc-focus-ring class=\"focus-ring\" for=\"card\"></wc-focus-ring>\n <wc-elevation class=\"elevation\"></wc-elevation>\n <div class=\"background\"></div>\n <div class=\"outline\"></div>\n <wc-ripple class=\"ripple\" for=\"card\"></wc-ripple>\n\n ${this.renderCardElement(isLink(this))}\n `;\n }\n}\n"],"names":["LitElement","nothing","html","classMap","ifDefined","styles","colorStyles","property","state","query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,EAAA,YAAA,EAAA,MAAA,CAAA;AAO5B,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE;AACd,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAO5B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE;AAChC,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,eAAA,EAAA,MAAA,CAAA;AAIf,UAAA,CAAA;AADP,IAAAC,CAAK;AACyB,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAIN,UAAA,CAAA;IAAxBC,GAAK,CAAC,OAAO;AAA4C,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAhD/C,IAAI,GAAA,UAAA,CAAA;IADhB;AACY,CAAA,EAAA,IAAI,CAsMhB;;;;"}
1
+ {"version":3,"file":"card.js","sources":["../../src/card/card.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n dispatchActivationClick,\n isActivationClick,\n} from '../__internal/utils/dispatch-event-utils.js';\nimport { isLink } from '@/__internal/utils/is-link.js';\nimport { observerSlotChangesWithCallback } from '@/__internal/utils/observe-slot-change.js';\nimport { throttle } from '@/__internal/utils/throttle.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './card.scss';\nimport colorStyles from './card-colors.scss';\nimport NativeHyperlinkMixin from '@/__internal/mixins/NativeHyperlinkMixin.js';\n\ntype CardVariant = 'elevated' | 'filled' | 'outlined';\n\nconst DISABLED_REASON_ID = 'disabled-reason';\n\n/**\n * @label Card\n * @tag wc-card\n * @rawTag card\n * @summary A surface that groups content and actions about one subject.\n *\n * @overview\n * <p>A card is <code>elevated</code> (the default), <code>filled</code> or <code>outlined</code>.\n * It adds no padding of its own: put text in <code>wc-card-content</code>, which can sit next to\n * edge-to-edge media.</p>\n * <p>Set <code>actionable</code> to make the whole card a single button that fires\n * <code>click</code>, or <code>href</code> (with <code>target</code>, <code>rel</code> and\n * <code>download</code>) to make it a link. The content of an actionable or link card names the\n * button or link, and anything focusable or clickable inside it stops responding, so don't put\n * buttons or links inside one; use a plain card with its own actions instead.\n * <code>throttle-delay</code> throttles activation.</p>\n * <p><code>disabled</code> dims the card. A static card's content becomes inert; an actionable or\n * link card stops responding to clicks and leaves the tab order. With <code>disabled-reason</code> it\n * stays focusable and screen readers read the reason with it.</p>\n *\n * @cssprop --card-container-shape - Corner radius of the card. Defaults to `--shape-corner-large`.\n * @cssprop --card-padding - Padding inside the card, around its children. Defaults to 0; `wc-card-content` adds its own padding.\n * @cssprop --card-gap - Gap between the card's children. Defaults to 0.\n *\n * @example\n * ```html\n * <wc-card variant=\"outlined\">\n * <wc-card-content>\n * <h3 class=\"text-title-large\">Title</h3>\n * <p class=\"text-body-medium\">Supporting text</p>\n * </wc-card-content>\n * </wc-card>\n * ```\n */\n@IndividualComponent\nexport class Card extends NativeHyperlinkMixin(LitElement) {\n // ── Static ────────────────────────────────────────────────────────────────\n\n static styles = [styles, colorStyles];\n\n // ── Properties ────────────────────────────────────────────────────────────\n\n /**\n * Visual style of the card: `elevated` (a raised surface with a shadow), `filled` (a tonal surface)\n * or `outlined` (a bordered surface). Defaults to `elevated`.\n */\n @property({ type: String, reflect: true })\n variant: CardVariant = 'elevated';\n\n /**\n * Dims the card. A static card's content becomes inert. An actionable or link card stops\n * responding to clicks and leaves the tab order, unless `disabled-reason` is set.\n */\n @property({ type: Boolean, reflect: true })\n disabled: boolean = false;\n\n /**\n * Makes the whole card a single button that fires `click`. Its content names the button, and\n * anything focusable or clickable inside it stops responding, so don't put buttons or links\n * inside an actionable card.\n */\n @property({ type: Boolean, reflect: true })\n actionable: boolean = false;\n\n /**\n * Why an actionable or link card is disabled. The card stays focusable and screen readers read\n * the reason with it.\n */\n @property({ attribute: 'disabled-reason' })\n disabledReason: string = '';\n\n /**\n * Delay in milliseconds for throttling activation of an actionable or link card. When unset\n * (default), no throttle is applied.\n */\n @property({ type: Number, attribute: 'throttle-delay' })\n throttleDelay?: number;\n\n /** Whether the default slot holds meaningful content. */\n @state()\n private slotHasContent = false;\n\n // ── Queries ───────────────────────────────────────────────────────────────\n\n @query('.card') readonly cardElement!: HTMLElement | null;\n\n // ── Constructor ───────────────────────────────────────────────────────────\n\n constructor() {\n super();\n // Look the handler up on every click, so the throttled version set in\n // firstUpdated() is the one that runs.\n this.addEventListener('click', event => this.__handleClick(event));\n }\n\n // ── Lifecycle ─────────────────────────────────────────────────────────────\n\n override firstUpdated() {\n if (typeof this.throttleDelay === 'number') {\n this.__dispatchClickWithThrottle = throttle(\n this.__dispatchClick,\n this.throttleDelay,\n );\n }\n observerSlotChangesWithCallback(\n this.renderRoot.querySelector('slot'),\n hasContent => {\n this.slotHasContent = hasContent;\n },\n );\n }\n\n // ── Private methods ───────────────────────────────────────────────────────\n\n __handleClick(event: MouseEvent | KeyboardEvent) {\n // A disabled card never activates, and consumer click listeners on it never run.\n if (this.disabled) {\n event.stopImmediatePropagation();\n event.preventDefault();\n return;\n }\n this.__dispatchClickWithThrottle(event);\n }\n\n __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =\n event => {\n this.__dispatchClick(event);\n };\n\n __dispatchClick = (event: MouseEvent | KeyboardEvent) => {\n if (!isActivationClick(event) || !this.cardElement) {\n return;\n }\n\n this.focus();\n dispatchActivationClick(this.cardElement);\n };\n\n /** True when a disabled interactive card should stay focusable to expose its reason. */\n __isSoftDisabled() {\n return this.disabled && !!this.disabledReason;\n }\n\n __getDisabledReasonID() {\n return this.__isSoftDisabled() ? DISABLED_REASON_ID : undefined;\n }\n\n // ── Render helpers ────────────────────────────────────────────────────────\n\n renderDisabledReason() {\n if (!this.__isSoftDisabled()) return nothing;\n // aria-hidden keeps the reason out of the control's name (it sits inside the button or link);\n // aria-describedby still reads it as the description.\n return html`<div\n id=${DISABLED_REASON_ID}\n aria-hidden=\"true\"\n role=\"tooltip\"\n aria-label=${this.disabledReason}\n class=\"screen-reader-only\"\n >\n ${this.disabledReason}\n </div>`;\n }\n\n renderCardElement(isLinkElement: boolean) {\n const interactive = this.actionable || isLinkElement;\n const cssClasses = {\n card: true,\n 'card-element': true,\n [`variant-${this.variant}`]: true,\n actionable: interactive && !this.disabled,\n disabled: this.disabled,\n 'has-content': this.slotHasContent,\n };\n if (!interactive) {\n return html`<div class=${classMap(cssClasses)} id=\"card\">\n ${this.renderCardContent(false)}\n </div>`;\n }\n\n const softDisabled = this.__isSoftDisabled();\n const removedFromTabOrder = this.disabled && !softDisabled;\n\n if (!isLinkElement) {\n return html`<button\n class=${classMap(cssClasses)}\n id=\"card\"\n type=\"button\"\n aria-describedby=${ifDefined(this.__getDisabledReasonID())}\n aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}\n ?disabled=${removedFromTabOrder}\n >\n ${this.renderCardContent(true)} ${this.renderDisabledReason()}\n </button>`;\n }\n\n return html`<a\n class=${classMap(cssClasses)}\n id=\"card\"\n href=${ifDefined(this.disabled ? undefined : this.href)}\n target=${ifDefined(this.disabled ? undefined : this.target)}\n rel=${ifDefined(this.disabled ? undefined : this.rel)}\n download=${ifDefined(this.disabled ? undefined : this.download)}\n role=${ifDefined(this.disabled ? 'link' : undefined)}\n tabindex=${removedFromTabOrder ? '-1' : '0'}\n aria-describedby=${ifDefined(this.__getDisabledReasonID())}\n aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}\n >\n ${this.renderCardContent(true)} ${this.renderDisabledReason()}\n </a>`;\n }\n\n /**\n * Renders the slotted content. Inside the button or link of an actionable or link card the\n * content stays in the accessibility tree, because it gives the control its name: `inert` would\n * remove it and leave screen readers announcing just \"button\" or \"link\". Instead, a slot with a\n * negative tabindex takes everything assigned to it out of sequential focus navigation, and\n * `.card-content` ignores the pointer (see card.scss). A disabled static card has no control to\n * name, so its content is simply inert.\n */\n renderCardContent(interactive: boolean) {\n return html`\n <div class=\"card-content\">\n <div class=\"slot-container\" ?inert=${!interactive && this.disabled}>\n <slot tabindex=${ifDefined(interactive ? '-1' : undefined)}></slot>\n </div>\n </div>\n `;\n }\n\n // ── Render ────────────────────────────────────────────────────────────────\n\n render() {\n return html`\n <wc-focus-ring class=\"focus-ring\" for=\"card\"></wc-focus-ring>\n <wc-elevation class=\"elevation\"></wc-elevation>\n <div class=\"background\"></div>\n <div class=\"outline\"></div>\n <wc-ripple class=\"ripple\" for=\"card\"></wc-ripple>\n\n ${this.renderCardElement(isLink(this))}\n `;\n }\n}\n"],"names":["LitElement","nothing","html","classMap","ifDefined","styles","colorStyles","property","state","query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAkB,GAAG,iBAAiB;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AAEI,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,oBAAoB,CAACA,GAAU,CAAC,CAAA;;AAqDxD,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;;AA/CT;;;AAGG;QAEH,IAAA,CAAA,OAAO,GAAgB,UAAU;AAEjC;;;AAGG;QAEH,IAAA,CAAA,QAAQ,GAAY,KAAK;AAEzB;;;;AAIG;QAEH,IAA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D/C,IAAI,GAAA,UAAA,CAAA;IADhB;AACY,CAAA,EAAA,IAAI,CAgNhB;;;;"}
@@ -103,7 +103,9 @@ let ChartDoughnut = class ChartDoughnut extends ChartPie {
103
103
  const caption = active
104
104
  ? (active.label ?? active.name)
105
105
  : this.centerLabel || this.i18n.t('total');
106
- const hole = Math.max(this.radius * this.innerFraction() * 2 - 16, 0);
106
+ // From the current size, not the last draw: the draw runs after this render, so its radius
107
+ // would leave the caption 0px wide until something else re-rendered.
108
+ const hole = Math.max(this.outerRadius() * this.innerFraction() * 2 - 16, 0);
107
109
  return b `<div
108
110
  class="center"
109
111
  part="center"
@@ -1 +1 @@
1
- {"version":3,"file":"chart-doughnut.js","sources":["../../src/chart-doughnut/chart-doughnut.ts"],"sourcesContent":["import { html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { ChartPie } from '../chart-pie/chart-pie.js';\n\nexport type {\n ChartLegendMode,\n ChartPieItem,\n ChartSelectDetail,\n ChartValueFormatter,\n} from '../chart-pie/chart-pie.js';\n\n/**\n * @label Doughnut Chart\n * @tag wc-chart-doughnut\n * @rawTag chart-doughnut\n * @summary A pie chart with a hole that shows the total, or the hovered slice, in its centre.\n *\n * @overview\n * <p>A doughnut chart is a <code>wc-chart-pie</code> with a hole, and takes the same\n * <code>data</code>: an array of slices, each with a unique <code>name</code>, a <code>value</code>,\n * and an optional <code>label</code> and <code>color</code>.</p>\n * <ul>\n * <li>The centre shows the total of the visible slices with a caption, or the value and label of the\n * hovered or focused slice. <code>center-label</code> sets the caption (by default the localized\n * string \"Total\"), and the <code>center</code> slot replaces the content.</li>\n * <li><code>inner-radius</code> sets the size of the hole as a fraction of the radius, 0.62 by\n * default and at most 0.9. At 0 there is no hole and no centre content.</li>\n * <li><code>show-labels</code> prints each slice's percentage inside it when the slice is big\n * enough.</li>\n * <li><code>height</code> sets the plot height in pixels (300 by default); the width follows the\n * container.</li>\n * </ul>\n * <p>Hovering or focusing a slice pulls it out, dims the others and shows a tooltip with its value\n * and share of the visible total (<code>hide-tooltip</code> turns it off). The legend shows by\n * default (<code>legend</code>: <code>auto</code>, <code>show</code> or <code>hide</code>); each entry\n * is a toggle button that hides or shows its slice. <code>valueFormatter</code> formats the\n * values.</p>\n * <p>The plot is focusable. The arrow keys move through the slices (Left and Right follow the\n * reading direction), Home and End jump to the first and last, Escape clears the focus, and Enter or\n * Space fires <code>select</code>. Each move is announced through a polite live region, and a\n * visually hidden table lists each slice's name, value and share for screen readers. Give the chart\n * a <code>label</code> to name it.</p>\n * <p><code>loading</code> shows a skeleton, and the <code>empty</code> slot shows when no slice has a\n * value above zero. Slices animate unless <code>disable-animation</code> is set or the user prefers\n * reduced motion.</p>\n * @tags charts\n *\n * @example\n * ```html\n * <wc-chart-doughnut label=\"Visitors by browser\" center-label=\"Visitors\"></wc-chart-doughnut>\n * <script>\n * document.querySelector('wc-chart-doughnut').data = [\n * { name: 'chrome', label: 'Chrome', value: 275 },\n * { name: 'safari', label: 'Safari', value: 200 },\n * { name: 'firefox', label: 'Firefox', value: 187 },\n * ];\n * </script>\n * ```\n *\n * @slot center - Replaces the total and caption in the centre.\n * @slot empty - Shown when there is no data. Defaults to \"No data\".\n * @slot insight - Below the chart, a line that explains it, such as the assistant’s reading of a trend. The data comes from the platform; the insight only puts it into words.\n *\n * @fires {CustomEvent<ChartSelectDetail>} select - A slice was clicked or chosen with Enter. `detail` holds `index`, `series` (the slice name) and `datum`.\n *\n * @csspart container - The outer wrapper.\n * @csspart plot - The focusable plot area holding the SVG.\n * @csspart center - The centre content.\n * @csspart tooltip - The tooltip.\n * @csspart legend - The legend.\n *\n * @cssprop --color-chart-1 - Color of the first slice; slices cycle through `--color-chart-1` to `--color-chart-8`.\n * @cssprop --chart-dim-opacity - Opacity of slices that are not hovered. Defaults to `0.4`.\n */\n@IndividualComponent\nexport class ChartDoughnut extends ChartPie {\n // ── Properties\n\n /** Size of the hole as a fraction of the radius, up to 0.9. At 0 there is no hole and no centre content. */\n @property({ type: Number, attribute: 'inner-radius' }) innerRadius: number =\n 0.62;\n\n /** Caption under the total in the centre. Defaults to Peacock's `total` string (`\"Total\"`). */\n @property({ type: String, attribute: 'center-label' }) centerLabel: string =\n '';\n\n // ── Overrides\n\n protected drawProperties(): string[] {\n return [...super.drawProperties(), 'innerRadius'];\n }\n\n /** The hole as a clamped fraction of the radius. */\n protected innerFraction(): number {\n return Math.min(Math.max(this.innerRadius || 0, 0), 0.9);\n }\n\n // ── Render helpers\n\n protected renderOverlay() {\n if (this.innerFraction() <= 0) return nothing;\n const active =\n this.activeIndex >= 0 ? this.data[this.activeIndex] : undefined;\n const value = active ? active.value : this.visibleTotal();\n const caption = active\n ? (active.label ?? active.name)\n : this.centerLabel || this.i18n.t('total');\n const hole = Math.max(this.radius * this.innerFraction() * 2 - 16, 0);\n return html`<div\n class=\"center\"\n part=\"center\"\n style=${styleMap({ '--_center-width': `${hole}px` })}\n >\n <slot name=\"center\">\n <span class=\"center-value\">${this.formatValue(value)}</span>\n <span class=\"center-label\">${caption}</span>\n </slot>\n </div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'wc-chart-doughnut': ChartDoughnut;\n }\n}\n"],"names":["nothing","html","styleMap","property"],"mappings":";;;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,QAAQ,CAAA;AAApC,IAAA,WAAA,GAAA;;;;QAIkD,IAAA,CAAA,WAAW,GAChE,IAAI;;QAGiD,IAAA,CAAA,WAAW,GAChE,EAAE;IAmCN;;IA/BY,cAAc,GAAA;QACtB,OAAO,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,EAAE,aAAa,CAAC;IACnD;;IAGU,aAAa,GAAA;AACrB,QAAA,OAAO,IAAI,CA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A,EAAA,aAAA,EAAA,MAAA,CAAA;AATM,aAAa,GAAA,UAAA,CAAA;IADzB;AACY,CAAA,EAAA,aAAa,CA4CzB;;;;"}
1
+ {"version":3,"file":"chart-doughnut.js","sources":["../../src/chart-doughnut/chart-doughnut.ts"],"sourcesContent":["import { html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { ChartPie } from '../chart-pie/chart-pie.js';\n\nexport type {\n ChartLegendMode,\n ChartPieItem,\n ChartSelectDetail,\n ChartValueFormatter,\n} from '../chart-pie/chart-pie.js';\n\n/**\n * @label Doughnut Chart\n * @tag wc-chart-doughnut\n * @rawTag chart-doughnut\n * @summary A pie chart with a hole that shows the total, or the hovered slice, in its centre.\n *\n * @overview\n * <p>A doughnut chart is a <code>wc-chart-pie</code> with a hole, and takes the same\n * <code>data</code>: an array of slices, each with a unique <code>name</code>, a <code>value</code>,\n * and an optional <code>label</code> and <code>color</code>.</p>\n * <ul>\n * <li>The centre shows the total of the visible slices with a caption, or the value and label of the\n * hovered or focused slice. <code>center-label</code> sets the caption (by default the localized\n * string \"Total\"), and the <code>center</code> slot replaces the content.</li>\n * <li><code>inner-radius</code> sets the size of the hole as a fraction of the radius, 0.62 by\n * default and at most 0.9. At 0 there is no hole and no centre content.</li>\n * <li><code>show-labels</code> prints each slice's percentage inside it when the slice is big\n * enough.</li>\n * <li><code>height</code> sets the plot height in pixels (300 by default); the width follows the\n * container.</li>\n * </ul>\n * <p>Hovering or focusing a slice pulls it out, dims the others and shows a tooltip with its value\n * and share of the visible total (<code>hide-tooltip</code> turns it off). The legend shows by\n * default (<code>legend</code>: <code>auto</code>, <code>show</code> or <code>hide</code>); each entry\n * is a toggle button that hides or shows its slice. <code>valueFormatter</code> formats the\n * values.</p>\n * <p>The plot is focusable. The arrow keys move through the slices (Left and Right follow the\n * reading direction), Home and End jump to the first and last, Escape clears the focus, and Enter or\n * Space fires <code>select</code>. Each move is announced through a polite live region, and a\n * visually hidden table lists each slice's name, value and share for screen readers. Give the chart\n * a <code>label</code> to name it.</p>\n * <p><code>loading</code> shows a skeleton, and the <code>empty</code> slot shows when no slice has a\n * value above zero. Slices animate unless <code>disable-animation</code> is set or the user prefers\n * reduced motion.</p>\n * @tags charts\n *\n * @example\n * ```html\n * <wc-chart-doughnut label=\"Visitors by browser\" center-label=\"Visitors\"></wc-chart-doughnut>\n * <script>\n * document.querySelector('wc-chart-doughnut').data = [\n * { name: 'chrome', label: 'Chrome', value: 275 },\n * { name: 'safari', label: 'Safari', value: 200 },\n * { name: 'firefox', label: 'Firefox', value: 187 },\n * ];\n * </script>\n * ```\n *\n * @slot center - Replaces the total and caption in the centre.\n * @slot empty - Shown when there is no data. Defaults to \"No data\".\n * @slot insight - Below the chart, a line that explains it, such as the assistant’s reading of a trend. The data comes from the platform; the insight only puts it into words.\n *\n * @fires {CustomEvent<ChartSelectDetail>} select - A slice was clicked or chosen with Enter. `detail` holds `index`, `series` (the slice name) and `datum`.\n *\n * @csspart container - The outer wrapper.\n * @csspart plot - The focusable plot area holding the SVG.\n * @csspart center - The centre content.\n * @csspart tooltip - The tooltip.\n * @csspart legend - The legend.\n *\n * @cssprop --color-chart-1 - Color of the first slice; slices cycle through `--color-chart-1` to `--color-chart-8`.\n * @cssprop --chart-dim-opacity - Opacity of slices that are not hovered. Defaults to `0.4`.\n */\n@IndividualComponent\nexport class ChartDoughnut extends ChartPie {\n // ── Properties\n\n /** Size of the hole as a fraction of the radius, up to 0.9. At 0 there is no hole and no centre content. */\n @property({ type: Number, attribute: 'inner-radius' }) innerRadius: number =\n 0.62;\n\n /** Caption under the total in the centre. Defaults to Peacock's `total` string (`\"Total\"`). */\n @property({ type: String, attribute: 'center-label' }) centerLabel: string =\n '';\n\n // ── Overrides\n\n protected drawProperties(): string[] {\n return [...super.drawProperties(), 'innerRadius'];\n }\n\n /** The hole as a clamped fraction of the radius. */\n protected innerFraction(): number {\n return Math.min(Math.max(this.innerRadius || 0, 0), 0.9);\n }\n\n // ── Render helpers\n\n protected renderOverlay() {\n if (this.innerFraction() <= 0) return nothing;\n const active =\n this.activeIndex >= 0 ? this.data[this.activeIndex] : undefined;\n const value = active ? active.value : this.visibleTotal();\n const caption = active\n ? (active.label ?? active.name)\n : this.centerLabel || this.i18n.t('total');\n // From the current size, not the last draw: the draw runs after this render, so its radius\n // would leave the caption 0px wide until something else re-rendered.\n const hole = Math.max(\n this.outerRadius() * this.innerFraction() * 2 - 16,\n 0,\n );\n return html`<div\n class=\"center\"\n part=\"center\"\n style=${styleMap({ '--_center-width': `${hole}px` })}\n >\n <slot name=\"center\">\n <span class=\"center-value\">${this.formatValue(value)}</span>\n <span class=\"center-label\">${caption}</span>\n </slot>\n </div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'wc-chart-doughnut': ChartDoughnut;\n }\n}\n"],"names":["nothing","html","styleMap","property"],"mappings":";;;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,QAAQ,CAAA;AAApC,IAAA,WAAA,GAAA;;;;QAIkD,IAAA,CAAA,WAAW,GAChE,IAAI;;QAGiD,IAAA,CAAA,WAAW,GAChE,EAAE;IAwCN;;IApCY,cAAc,GAAA;QACtB,OAAO,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,EAAE,aAAa,CAAC;IACnD;;IAGU,aAAa,GAAA;AACrB,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC;IAC1D;;IAIU,aAAa,GAAA;AACrB,QAAA,IAAI,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC;AAAE,YAAA,OAAOA,CAAO;QAC7C,MAAM,MA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 * The outer radius for the current size. It depends only on reactive properties, so a render
566
+ * (the doughnut's centre) can read it before the chart is drawn at that size.
567
+ */
568
+ outerRadius() {
569
+ const { width, height } = this.svgSize();
570
+ return Math.max(Math.min(width, height) / 2 - PADDING, 0);
571
+ }
564
572
  draw(animate) {
565
573
  if (!this.svgElement)
566
574
  return;
567
575
  const { width, height } = this.svgSize();
568
- const radius = Math.max(Math.min(width, height) / 2 - PADDING, 0);
576
+ const radius = this.outerRadius();
569
577
  this.radius = radius;
570
578
  this.center = { x: width / 2, y: height / 2 };
571
579
  const inner = radius * this.innerFraction();