@redvars/peacock 4.4.0 → 4.5.1

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 (236) hide show
  1. package/dist/{BaseField-Cj2rNVeC.js → BaseField-BbOj212R.js} +3 -3
  2. package/dist/{BaseField-Cj2rNVeC.js.map → BaseField-BbOj212R.js.map} +1 -1
  3. package/dist/{BaseInput-CSOLv2-i.js → BaseInput-Cv03GZLu.js} +2 -2
  4. package/dist/{BaseInput-CSOLv2-i.js.map → BaseInput-Cv03GZLu.js.map} +1 -1
  5. package/dist/ai-badge.js +2 -2
  6. package/dist/ai-summary.js +2 -2
  7. package/dist/alert.js +2 -2
  8. package/dist/anchor-nav.js +2 -2
  9. package/dist/app-shell.js +2 -2
  10. package/dist/assistant-panel.js +2 -2
  11. package/dist/assistant-step.js +2 -2
  12. package/dist/assistant-steps.js +2 -2
  13. package/dist/avatar-group.js +2 -2
  14. package/dist/banner.js +2 -2
  15. package/dist/{base-progress-DduJjUeq.js → base-progress-CqsyiVOV.js} +2 -2
  16. package/dist/{base-progress-DduJjUeq.js.map → base-progress-CqsyiVOV.js.map} +1 -1
  17. package/dist/bottom-sheet.js +2 -2
  18. package/dist/breadcrumb.js +2 -2
  19. package/dist/calendar-column-view.js +648 -30
  20. package/dist/calendar-column-view.js.map +1 -1
  21. package/dist/calendar-drag-IXMPZrTN.js +344 -0
  22. package/dist/calendar-drag-IXMPZrTN.js.map +1 -0
  23. package/dist/{calendar-event-_OYdAT3c.js → calendar-event-BQChlMXy.js} +15 -4
  24. package/dist/calendar-event-BQChlMXy.js.map +1 -0
  25. package/dist/calendar-header-DVrfThwr.js +59 -0
  26. package/dist/calendar-header-DVrfThwr.js.map +1 -0
  27. package/dist/calendar-month-view.js +311 -21
  28. package/dist/calendar-month-view.js.map +1 -1
  29. package/dist/calendar-timeline.js +1877 -0
  30. package/dist/calendar-timeline.js.map +1 -0
  31. package/dist/calendar.js +224 -62
  32. package/dist/calendar.js.map +1 -1
  33. package/dist/{canvas-base-Bfpv5_HJ.js → canvas-base-BjiU3Ecl.js} +2 -2
  34. package/dist/{canvas-base-Bfpv5_HJ.js.map → canvas-base-BjiU3Ecl.js.map} +1 -1
  35. package/dist/carousel.js +2 -2
  36. package/dist/{cartesian-chart-SnqFbbXV.js → cartesian-chart-iE3cmeGF.js} +2 -2
  37. package/dist/{cartesian-chart-SnqFbbXV.js.map → cartesian-chart-iE3cmeGF.js.map} +1 -1
  38. package/dist/{cb-group-base-DZIzMlen.js → cb-group-base-CWctDJvy.js} +2 -2
  39. package/dist/{cb-group-base-DZIzMlen.js.map → cb-group-base-CWctDJvy.js.map} +1 -1
  40. package/dist/cb-group.js +3 -3
  41. package/dist/cb-rule.js +3 -3
  42. package/dist/chart-area.js +4 -4
  43. package/dist/chart-bar.js +4 -4
  44. package/dist/{chart-base-C2N0WQLI.js → chart-base-CDyVDmz7.js} +2 -2
  45. package/dist/{chart-base-C2N0WQLI.js.map → chart-base-CDyVDmz7.js.map} +1 -1
  46. package/dist/chart-doughnut.js +3 -3
  47. package/dist/chart-line.js +4 -4
  48. package/dist/chart-pie.js +3 -3
  49. package/dist/chat-event.js +2 -2
  50. package/dist/chat-message.js +2 -2
  51. package/dist/chat-thread.js +2 -2
  52. package/dist/checkbox-group.js +3 -3
  53. package/dist/checkbox.js +3 -3
  54. package/dist/chip-set.js +2 -2
  55. package/dist/chip.js +2 -2
  56. package/dist/circular-progress.js +3 -3
  57. package/dist/citation.js +2 -2
  58. package/dist/code-editor.js +3 -3
  59. package/dist/code-highlighter.js +2 -2
  60. package/dist/color-field.js +4 -4
  61. package/dist/color-picker.js +2 -2
  62. package/dist/command-palette.js +2 -2
  63. package/dist/comment-composer.js +4 -4
  64. package/dist/condition-builder.js +3 -3
  65. package/dist/confirm-dialog.js +2 -2
  66. package/dist/copy-button.js +2 -2
  67. package/dist/currency-field.js +4 -4
  68. package/dist/custom-elements-jsdocs.json +52 -129
  69. package/dist/custom-elements.json +3109 -5
  70. package/dist/{date-vFrYT1S9.js → date-cfPx3alz.js} +20 -3
  71. package/dist/date-cfPx3alz.js.map +1 -0
  72. package/dist/date-field.js +8 -8
  73. package/dist/date-picker.js +4 -4
  74. package/dist/date-range-field.js +8 -8
  75. package/dist/datetime-field.js +7 -7
  76. package/dist/dependency-map.js +3 -3
  77. package/dist/description-item.js +2 -2
  78. package/dist/description-list.js +2 -2
  79. package/dist/{diagram-W_Kddt7I.js → diagram-D2aM93kf.js} +2 -2
  80. package/dist/{diagram-W_Kddt7I.js.map → diagram-D2aM93kf.js.map} +1 -1
  81. package/dist/diagram-controls.js +2 -2
  82. package/dist/diagram-minimap.js +2 -2
  83. package/dist/diagram.js +4 -4
  84. package/dist/diff-viewer.js +2 -2
  85. package/dist/discussion-activity.js +2 -2
  86. package/dist/discussion-comment.js +2 -2
  87. package/dist/discussion.js +4 -4
  88. package/dist/{document-editor-dBgmcyUW.js → document-editor-BS6al7Hq.js} +2 -2
  89. package/dist/{document-editor-dBgmcyUW.js.map → document-editor-BS6al7Hq.js.map} +1 -1
  90. package/dist/document-editor.js +3 -3
  91. package/dist/draft-card.js +2 -2
  92. package/dist/erd.js +3 -3
  93. package/dist/{event-manager-CWAWPOUE.js → event-manager-KGMT2x2Q.js} +10 -8
  94. package/dist/event-manager-KGMT2x2Q.js.map +1 -0
  95. package/dist/file-upload.js +3 -3
  96. package/dist/filter-bar.js +4 -4
  97. package/dist/flow.js +4 -4
  98. package/dist/form.js +2 -2
  99. package/dist/{generative-view-CfW6yMpY.js → generative-view-DsSOPf26.js} +2 -2
  100. package/dist/{generative-view-CfW6yMpY.js.map → generative-view-DsSOPf26.js.map} +1 -1
  101. package/dist/generative-view.js +3 -3
  102. package/dist/html-editor.js +4 -4
  103. package/dist/{i18n-controller-DNAjVSIP.js → i18n-controller-BTeChxE0.js} +2 -2
  104. package/dist/{i18n-controller-DNAjVSIP.js.map → i18n-controller-BTeChxE0.js.map} +1 -1
  105. package/dist/image.js +2 -2
  106. package/dist/index.js +26 -23
  107. package/dist/index.js.map +1 -1
  108. package/dist/inline-edit.js +2 -2
  109. package/dist/input.js +3 -3
  110. package/dist/json-viewer.js +2 -2
  111. package/dist/kanban.js +2 -2
  112. package/dist/kbd.js +2 -2
  113. package/dist/linear-progress.js +3 -3
  114. package/dist/listbox.js +2 -2
  115. package/dist/loader-full.js +13 -13
  116. package/dist/loader.js +17 -13
  117. package/dist/loader.js.map +1 -1
  118. package/dist/markdown-editor.js +4 -4
  119. package/dist/mention-input.js +4 -4
  120. package/dist/modal.js +2 -2
  121. package/dist/navigation-bar.js +2 -2
  122. package/dist/navigation-drawer.js +2 -2
  123. package/dist/navigation-rail.js +2 -2
  124. package/dist/notification-center.js +2 -2
  125. package/dist/number-field.js +4 -4
  126. package/dist/page-header.js +2 -2
  127. package/dist/pagination.js +2 -2
  128. package/dist/password-field.js +4 -4
  129. package/dist/password-rules.js +2 -2
  130. package/dist/phone-field.js +4 -4
  131. package/dist/{picker-field-Mi7_hbo8.js → picker-field-DmXYPvbF.js} +3 -3
  132. package/dist/{picker-field-Mi7_hbo8.js.map → picker-field-DmXYPvbF.js.map} +1 -1
  133. package/dist/pin-input.js +4 -4
  134. package/dist/presence-indicator.js +2 -2
  135. package/dist/prompt-input.js +4 -4
  136. package/dist/radio.js +3 -3
  137. package/dist/{range-utils-BoKOhxVX.js → range-utils-DZe96GnO.js} +2 -2
  138. package/dist/{range-utils-BoKOhxVX.js.map → range-utils-DZe96GnO.js.map} +1 -1
  139. package/dist/rating.js +3 -3
  140. package/dist/redvars-loader.js +2 -2
  141. package/dist/relative-time.js +2 -2
  142. package/dist/resizable-panels.js +2 -2
  143. package/dist/{rich-text-input-O1ku1q-J.js → rich-text-input-BCZ46UF8.js} +3 -3
  144. package/dist/{rich-text-input-O1ku1q-J.js.map → rich-text-input-BCZ46UF8.js.map} +1 -1
  145. package/dist/{schema-BWH1ANdE.js → schema-D0PCeIEA.js} +2 -2
  146. package/dist/{schema-BWH1ANdE.js.map → schema-D0PCeIEA.js.map} +1 -1
  147. package/dist/search.js +3 -3
  148. package/dist/select.js +4 -4
  149. package/dist/side-sheet.js +2 -2
  150. package/dist/signature-pad.js +3 -3
  151. package/dist/site-header.js +2 -2
  152. package/dist/slider.js +3 -3
  153. package/dist/snackbar.js +2 -2
  154. package/dist/sparkline.js +2 -2
  155. package/dist/split-button.js +2 -2
  156. package/dist/src/__internal/i18n/strings.d.ts +16 -0
  157. package/dist/src/__internal/utils/date.d.ts +5 -0
  158. package/dist/src/calendar/base-event.d.ts +5 -0
  159. package/dist/src/calendar/calendar-column-view.d.ts +65 -1
  160. package/dist/src/calendar/calendar-drag.d.ts +91 -0
  161. package/dist/src/calendar/calendar-header.d.ts +28 -0
  162. package/dist/src/calendar/calendar-month-view.d.ts +39 -1
  163. package/dist/src/calendar/calendar.d.ts +83 -6
  164. package/dist/src/calendar/index.d.ts +2 -2
  165. package/dist/src/calendar/types.d.ts +32 -0
  166. package/dist/src/calendar/utils.d.ts +53 -0
  167. package/dist/src/calendar-timeline/calendar-timeline.d.ts +287 -0
  168. package/dist/src/calendar-timeline/index.d.ts +3 -0
  169. package/dist/src/calendar-timeline/layout.d.ts +39 -0
  170. package/dist/src/calendar-timeline/types.d.ts +60 -0
  171. package/dist/src/index.d.ts +4 -2
  172. package/dist/stat.js +2 -2
  173. package/dist/status-indicator.js +2 -2
  174. package/dist/step.js +2 -2
  175. package/dist/stepper.js +2 -2
  176. package/dist/{strings-BpCoUL0V.js → strings-DeiQWMd9.js} +18 -1
  177. package/dist/strings-DeiQWMd9.js.map +1 -0
  178. package/dist/svg.js +2 -2
  179. package/dist/switch.js +3 -3
  180. package/dist/table.js +2 -2
  181. package/dist/test/calendar-timeline.test.d.ts +1 -0
  182. package/dist/textarea.js +4 -4
  183. package/dist/time-field.js +7 -7
  184. package/dist/time-picker.js +4 -4
  185. package/dist/timeline-item.js +2 -2
  186. package/dist/timeline.js +2 -2
  187. package/dist/{toggle-base-BRNNka2o.js → toggle-base-BtjRAZ5z.js} +2 -2
  188. package/dist/{toggle-base-BRNNka2o.js.map → toggle-base-BtjRAZ5z.js.map} +1 -1
  189. package/dist/tour.js +2 -2
  190. package/dist/transfer-list.js +3 -3
  191. package/dist/tree-chart.js +3 -3
  192. package/dist/tree-item.js +2 -2
  193. package/dist/tree.js +2 -2
  194. package/dist/tsconfig.tsbuildinfo +1 -1
  195. package/dist/typing-indicator.js +2 -2
  196. package/dist/url-field.js +4 -4
  197. package/dist/user-menu.js +2 -2
  198. package/dist/{utils-D92ldd1V.js → utils-DcvLgexs.js} +116 -19
  199. package/dist/utils-DcvLgexs.js.map +1 -0
  200. package/dist/{video-DBdRuyh4.js → video-DPjOBk6I.js} +2 -2
  201. package/dist/{video-DBdRuyh4.js.map → video-DPjOBk6I.js.map} +1 -1
  202. package/dist/video.js +3 -3
  203. package/dist/virtual-list.js +2 -2
  204. package/dist/workflow-timeline.js +2 -2
  205. package/dist/workflow.js +3 -3
  206. package/dist/workspace-switcher.js +2 -2
  207. package/package.json +1 -1
  208. package/readme.md +1 -0
  209. package/src/__internal/i18n/strings.ts +25 -0
  210. package/src/__internal/utils/date.ts +19 -0
  211. package/src/calendar/_calendar-header.scss +33 -0
  212. package/src/calendar/base-event.ts +19 -2
  213. package/src/calendar/calendar-column-view.scss +174 -2
  214. package/src/calendar/calendar-column-view.ts +665 -37
  215. package/src/calendar/calendar-drag.ts +403 -0
  216. package/src/calendar/calendar-header.ts +78 -0
  217. package/src/calendar/calendar-month-view.scss +89 -0
  218. package/src/calendar/calendar-month-view.ts +289 -23
  219. package/src/calendar/calendar.scss +2 -27
  220. package/src/calendar/calendar.ts +264 -62
  221. package/src/calendar/event-manager.ts +11 -7
  222. package/src/calendar/index.ts +8 -2
  223. package/src/calendar/types.ts +35 -0
  224. package/src/calendar/utils.ts +160 -20
  225. package/src/calendar-timeline/calendar-timeline.scss +564 -0
  226. package/src/calendar-timeline/calendar-timeline.ts +1528 -0
  227. package/src/calendar-timeline/index.ts +14 -0
  228. package/src/calendar-timeline/layout.ts +129 -0
  229. package/src/calendar-timeline/types.ts +65 -0
  230. package/src/index.ts +18 -0
  231. package/src/loader.ts +4 -0
  232. package/dist/calendar-event-_OYdAT3c.js.map +0 -1
  233. package/dist/date-vFrYT1S9.js.map +0 -1
  234. package/dist/event-manager-CWAWPOUE.js.map +0 -1
  235. package/dist/strings-BpCoUL0V.js.map +0 -1
  236. package/dist/utils-D92ldd1V.js.map +0 -1
@@ -110,6 +110,116 @@ export function calculateDateRange(
110
110
 
111
111
  export const LONG_EVENT_PADDING = 0.25;
112
112
 
113
+ /** Milliseconds in a day of 24 hours. */
114
+ export const DAY_MS = 86400000;
115
+
116
+ /** Milliseconds in a minute. */
117
+ export const MINUTE_MS = 60000;
118
+
119
+ export function clamp(value: number, min: number, max: number): number {
120
+ return Math.min(max, Math.max(min, value));
121
+ }
122
+
123
+ /** Whether `date` is at local midnight. */
124
+ export function isMidnight(date: Date): boolean {
125
+ return (
126
+ date.getHours() === 0 &&
127
+ date.getMinutes() === 0 &&
128
+ date.getSeconds() === 0 &&
129
+ date.getMilliseconds() === 0
130
+ );
131
+ }
132
+
133
+ /**
134
+ * Whether a range belongs in the all-day row: it lasts a day or more, or runs from one midnight to
135
+ * a later one (a day the clocks go forward on has only 23 hours).
136
+ */
137
+ export function isAllDayRange(start: Date, end: Date): boolean {
138
+ const length = end.valueOf() - start.valueOf();
139
+ return (
140
+ length >= DAY_MS || (length > 0 && isMidnight(start) && isMidnight(end))
141
+ );
142
+ }
143
+
144
+ /**
145
+ * The last day a range covers. `end` is exclusive, so a range that ends at midnight ends the day
146
+ * before. Never earlier than the day of `start`.
147
+ */
148
+ export function lastDayOf(start: Date, end: Date): Date {
149
+ const first = startOfDay(start);
150
+ const last = startOfDay(new Date(end.valueOf() - 1));
151
+ return last.valueOf() < first.valueOf() ? first : last;
152
+ }
153
+
154
+ /**
155
+ * Whether the range `start`–`end` (end exclusive) shares time with `from`–`to`. A range without
156
+ * length counts when its instant falls inside.
157
+ */
158
+ export function rangesOverlap(
159
+ start: Date,
160
+ end: Date,
161
+ from: Date,
162
+ to: Date,
163
+ ): boolean {
164
+ if (start.valueOf() >= end.valueOf()) {
165
+ return start.valueOf() >= from.valueOf() && start.valueOf() < to.valueOf();
166
+ }
167
+ return start.valueOf() < to.valueOf() && end.valueOf() > from.valueOf();
168
+ }
169
+
170
+ /**
171
+ * The start of the day after `date`'s. Unlike `addDays(day, 1)`, it lands on midnight even after a
172
+ * day whose midnight the clocks skipped, where `startOfDay` gives 01:00.
173
+ */
174
+ export function nextDay(date: Date): Date {
175
+ return startOfDay(addDays(startOfDay(date), 1));
176
+ }
177
+
178
+ /** Minutes in a day on the wall clock, which the day and week views draw. */
179
+ const DAY_MINUTES = 1440;
180
+
181
+ /**
182
+ * Wall-clock minutes from the start of `day` to `date`: negative before it, 1440 or more after
183
+ * it. The day and week views draw 24 equal hours, also on the days the clocks change.
184
+ */
185
+ export function wallMinutes(date: Date, day: Date): number {
186
+ return (
187
+ differenceInDays(date, day) * DAY_MINUTES +
188
+ date.getHours() * 60 +
189
+ date.getMinutes() +
190
+ date.getSeconds() / 60 +
191
+ date.getMilliseconds() / MINUTE_MS
192
+ );
193
+ }
194
+
195
+ /** The time `minutes` after the start of `day` on the wall clock; 1440 is the next midnight. */
196
+ export function atWallMinutes(day: Date, minutes: number): Date {
197
+ const date = startOfDay(day);
198
+ date.setHours(0, 0, 0, Math.round(minutes * MINUTE_MS));
199
+ return date;
200
+ }
201
+
202
+ /** The time at `fraction` (0 to 1) down `day`'s column: the inverse of `getTimePercent`. */
203
+ export function timeAtFraction(day: Date, fraction: number): Date {
204
+ return atWallMinutes(day, clamp(fraction, 0, 1) * DAY_MINUTES);
205
+ }
206
+
207
+ /**
208
+ * `date` moved to a multiple of `minutes` on the wall clock after the start of `day` (by default
209
+ * its own day): the nearest one, or the one before or after. The result stays within `day`, whose
210
+ * end is the next midnight.
211
+ */
212
+ export function snapTime(
213
+ date: Date,
214
+ minutes: number,
215
+ mode: 'round' | 'floor' | 'ceil' = 'round',
216
+ day: Date = date,
217
+ ): Date {
218
+ const step = Math.max(1, minutes);
219
+ const steps = Math[mode](wallMinutes(date, day) / step);
220
+ return atWallMinutes(day, clamp(steps * step, 0, DAY_MINUTES));
221
+ }
222
+
113
223
  /** Wall-clock date and time fields; `month` is 1–12. */
114
224
  export type WallClockParts = {
115
225
  year: number;
@@ -206,6 +316,50 @@ export function formatDate(
206
316
  return new Intl.DateTimeFormat(locale, options).format(date);
207
317
  }
208
318
 
319
+ /** `format.formatRange`, or both dates joined by a dash where it is missing or throws. */
320
+ function formatRange(
321
+ format: Intl.DateTimeFormat,
322
+ start: Date,
323
+ end: Date,
324
+ ): string {
325
+ try {
326
+ return format.formatRange(start, end);
327
+ } catch {
328
+ return `${format.format(start)} – ${format.format(end)}`;
329
+ }
330
+ }
331
+
332
+ /**
333
+ * When an event happens, for example `Nov 6, 2026, 9:00 – 9:30 AM`. An all-day event shows its
334
+ * days only, through the day before an `end` at midnight.
335
+ */
336
+ export function formatEventWhen(
337
+ start: Date,
338
+ end: Date,
339
+ locale: string,
340
+ allDay = false,
341
+ ): string {
342
+ if (allDay) {
343
+ const format = new Intl.DateTimeFormat(locale, { dateStyle: 'medium' });
344
+ return formatRange(format, start, lastDayOf(start, end));
345
+ }
346
+ const format = new Intl.DateTimeFormat(locale, {
347
+ dateStyle: 'medium',
348
+ timeStyle: 'short',
349
+ });
350
+ return formatRange(format, start, end);
351
+ }
352
+
353
+ /** The times of a range without its date, for example `9:00 – 10:30 AM`. */
354
+ export function formatTimeRange(
355
+ start: Date,
356
+ end: Date,
357
+ locale: string,
358
+ ): string {
359
+ const format = new Intl.DateTimeFormat(locale, { timeStyle: 'short' });
360
+ return formatRange(format, start, end);
361
+ }
362
+
209
363
  /** Accessible name of an event: its title and when it happens, for example `Standup, Nov 6, 2026, 9:00 – 9:30 AM`. */
210
364
  export function formatEventLabel(
211
365
  title: string,
@@ -214,18 +368,7 @@ export function formatEventLabel(
214
368
  locale: string,
215
369
  allDay = false,
216
370
  ): string {
217
- const format = new Intl.DateTimeFormat(
218
- locale,
219
- allDay
220
- ? { dateStyle: 'medium' }
221
- : { dateStyle: 'medium', timeStyle: 'short' },
222
- );
223
- let when: string;
224
- try {
225
- when = format.formatRange(start, end);
226
- } catch {
227
- when = `${format.format(start)} – ${format.format(end)}`;
228
- }
371
+ const when = formatEventWhen(start, end, locale, allDay);
229
372
  return title ? `${title}, ${when}` : when;
230
373
  }
231
374
 
@@ -238,13 +381,10 @@ export function onActivateKey(action: () => void) {
238
381
  };
239
382
  }
240
383
 
384
+ /**
385
+ * How far down `forDay`'s column (by default `date`'s own day) `date` falls, in percent, on a
386
+ * 24-hour wall clock: a 9:00 event sits at the 9 AM row also on the days the clocks change.
387
+ */
241
388
  export function getTimePercent(date: Date, forDay?: Date): number {
242
- const day = forDay || date;
243
- const sd = startOfDay(day);
244
- const ed = endOfDay(day);
245
- const percent =
246
- ((date.valueOf() - sd.valueOf()) / (ed.valueOf() - sd.valueOf())) * 100;
247
- if (percent < 0) return 0;
248
- if (percent > 100) return 100;
249
- return percent;
389
+ return clamp((wallMinutes(date, forDay || date) / DAY_MINUTES) * 100, 0, 100);
250
390
  }