@42-central/ui-react 0.17.0 → 0.17.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 (86) hide show
  1. package/README.md +36 -175
  2. package/dist/{chunk-ACE7FBWE.js → chunk-EVVMHTCL.js} +3 -3
  3. package/dist/chunk-EVVMHTCL.js.map +1 -0
  4. package/dist/{chunk-TMMEJKLI.js → chunk-NSOA3GMZ.js} +16 -3
  5. package/dist/chunk-NSOA3GMZ.js.map +1 -0
  6. package/dist/{chunk-PJL4ZL5V.js → chunk-YON5Y336.js} +3 -3
  7. package/dist/{chunk-PJL4ZL5V.js.map → chunk-YON5Y336.js.map} +1 -1
  8. package/dist/components/alert/alert.d.ts +17 -9
  9. package/dist/components/alert/alert.d.ts.map +1 -1
  10. package/dist/components/alert/index.js +2 -2
  11. package/dist/components/alert/index.js.map +1 -1
  12. package/dist/components/calendar/calendar-body.d.ts.map +1 -1
  13. package/dist/components/calendar/index.js +1 -1
  14. package/dist/components/data-table/index.js +2 -2
  15. package/dist/components/date-picker/index.js +3 -3
  16. package/dist/components/notification/create-notifier.d.ts.map +1 -1
  17. package/dist/components/notification/index.js +6 -6
  18. package/dist/components/notification/index.js.map +1 -1
  19. package/dist/components/notification/notification.d.ts +4 -4
  20. package/dist/components/notification/notification.d.ts.map +1 -1
  21. package/dist/components/schedule/index.d.ts +3 -3
  22. package/dist/components/schedule/index.js +163 -89
  23. package/dist/components/schedule/index.js.map +1 -1
  24. package/dist/components/schedule/schedule-agenda-view.d.ts +1 -1
  25. package/dist/components/schedule/schedule-agenda-view.d.ts.map +1 -1
  26. package/dist/components/schedule/schedule-create-draft.d.ts +3 -2
  27. package/dist/components/schedule/schedule-create-draft.d.ts.map +1 -1
  28. package/dist/components/schedule/schedule-dates.d.ts.map +1 -1
  29. package/dist/components/schedule/schedule-days-view.d.ts +1 -1
  30. package/dist/components/schedule/schedule-days-view.d.ts.map +1 -1
  31. package/dist/components/schedule/schedule-drag-ghost.d.ts +12 -5
  32. package/dist/components/schedule/schedule-drag-ghost.d.ts.map +1 -1
  33. package/dist/components/schedule/schedule-event-chip.d.ts.map +1 -1
  34. package/dist/components/schedule/schedule-geometry.d.ts +16 -0
  35. package/dist/components/schedule/schedule-geometry.d.ts.map +1 -1
  36. package/dist/components/schedule/schedule-grid-gesture.d.ts +29 -6
  37. package/dist/components/schedule/schedule-grid-gesture.d.ts.map +1 -1
  38. package/dist/components/schedule/schedule-month-view.d.ts +1 -1
  39. package/dist/components/schedule/schedule-month-view.d.ts.map +1 -1
  40. package/dist/components/schedule/schedule-next-up.d.ts +1 -1
  41. package/dist/components/schedule/schedule-next-up.d.ts.map +1 -1
  42. package/dist/components/schedule/schedule-timed-grid.d.ts.map +1 -1
  43. package/dist/components/schedule/schedule-toolbar.d.ts +3 -3
  44. package/dist/components/schedule/schedule-toolbar.d.ts.map +1 -1
  45. package/dist/components/schedule/schedule-types.d.ts +4 -1
  46. package/dist/components/schedule/schedule-types.d.ts.map +1 -1
  47. package/dist/components/schedule/schedule-year-view.d.ts +1 -1
  48. package/dist/components/schedule/schedule-year-view.d.ts.map +1 -1
  49. package/dist/components/schedule/schedule.d.ts.map +1 -1
  50. package/dist/components/schedule/use-event-create.d.ts.map +1 -1
  51. package/dist/components/schedule/use-event-drag.d.ts.map +1 -1
  52. package/dist/components/schedule/use-event-resize.d.ts.map +1 -1
  53. package/dist/theme.css +9 -3
  54. package/package.json +1 -1
  55. package/src/components/alert/alert.test.tsx +8 -2
  56. package/src/components/alert/alert.tsx +18 -11
  57. package/src/components/calendar/calendar-body.tsx +8 -1
  58. package/src/components/notification/create-notifier.tsx +6 -5
  59. package/src/components/notification/notification.test.tsx +15 -0
  60. package/src/components/notification/notification.tsx +4 -4
  61. package/src/components/schedule/now-cursor-line.tsx +1 -1
  62. package/src/components/schedule/schedule-agenda-view.tsx +6 -4
  63. package/src/components/schedule/schedule-all-day-row.tsx +1 -1
  64. package/src/components/schedule/schedule-create-draft.tsx +14 -5
  65. package/src/components/schedule/schedule-dates.ts +3 -2
  66. package/src/components/schedule/schedule-days-view.tsx +6 -4
  67. package/src/components/schedule/schedule-drag-ghost.tsx +27 -12
  68. package/src/components/schedule/schedule-event-chip.tsx +9 -2
  69. package/src/components/schedule/schedule-event-list-popover-content.tsx +1 -1
  70. package/src/components/schedule/schedule-geometry.ts +21 -0
  71. package/src/components/schedule/schedule-grid-gesture.test.ts +83 -1
  72. package/src/components/schedule/schedule-grid-gesture.ts +67 -28
  73. package/src/components/schedule/schedule-month-view.tsx +7 -5
  74. package/src/components/schedule/schedule-next-up.tsx +5 -3
  75. package/src/components/schedule/schedule-timed-grid.tsx +41 -3
  76. package/src/components/schedule/schedule-toolbar.tsx +23 -17
  77. package/src/components/schedule/schedule-types.ts +4 -1
  78. package/src/components/schedule/schedule-year-view.tsx +7 -5
  79. package/src/components/schedule/schedule.test.tsx +132 -14
  80. package/src/components/schedule/schedule.tsx +6 -4
  81. package/src/components/schedule/use-event-create.ts +7 -6
  82. package/src/components/schedule/use-event-drag.ts +10 -4
  83. package/src/components/schedule/use-event-resize.ts +4 -2
  84. package/src/theme.css +9 -3
  85. package/dist/chunk-ACE7FBWE.js.map +0 -1
  86. package/dist/chunk-TMMEJKLI.js.map +0 -1
@@ -294,6 +294,10 @@ export const measureScrollExtent = (grid: HTMLElement) => ({
294
294
  })
295
295
 
296
296
  export type EdgeBehaviourOptions = {
297
+ /** The locale's text direction (`useLocaleContext().dir`). Under `rtl`,
298
+ * `scrollLeft` runs from `0` down to `-maxScrollLeft`, and the left edge
299
+ * leads to *later* days, so both the clamp and the page direction flip. */
300
+ dir: "ltr" | "rtl"
297
301
  /** Repaint the preview from the last known pointer position. Called every
298
302
  * frame — the pointer can be stationary while the grid moves under it. */
299
303
  paint: () => void
@@ -340,11 +344,15 @@ export const tickEdges = (state: EdgeState, options: EdgeBehaviourOptions) => {
340
344
 
341
345
  // Frozen at pointerdown, deliberately not re-read here — see
342
346
  // `EdgeState.maxScrollLeft`.
343
- const maxLeft = state.maxScrollLeft
347
+ const rtl = options.dir === "rtl"
348
+ const [minLeft, maxLeft] = rtl ? [-state.maxScrollLeft, 0] : [0, state.maxScrollLeft]
344
349
  const maxTop = state.maxScrollTop
345
350
  const beforeLeft = grid.scrollLeft
346
351
  if (hx !== 0) {
347
- grid.scrollLeft = Math.max(0, Math.min(maxLeft, grid.scrollLeft + hx * MAX_SCROLL_PX_PER_FRAME))
352
+ grid.scrollLeft = Math.max(
353
+ minLeft,
354
+ Math.min(maxLeft, grid.scrollLeft + hx * MAX_SCROLL_PX_PER_FRAME),
355
+ )
348
356
  }
349
357
  if (vy !== 0) {
350
358
  grid.scrollTop = Math.max(0, Math.min(maxTop, grid.scrollTop + vy * MAX_SCROLL_PX_PER_FRAME))
@@ -352,7 +360,9 @@ export const tickEdges = (state: EdgeState, options: EdgeBehaviourOptions) => {
352
360
 
353
361
  // Horizontal only: there is no "next range" vertically — the day is already
354
362
  // fully rendered, so the vertical edge just scrolls.
355
- const direction: -1 | 1 | null = hx < 0 ? -1 : hx > 0 ? 1 : null
363
+ // `hx` is physical (negative at the left edge); `direction` is in days,
364
+ // which run right-to-left under RTL.
365
+ const direction: -1 | 1 | null = hx === 0 ? null : hx > 0 !== rtl ? 1 : -1
356
366
  const stuck = hx !== 0 && grid.scrollLeft === beforeLeft
357
367
  if (direction !== null && stuck && options.onPaginate) {
358
368
  if (state.paginateDirection !== direction) {
@@ -397,22 +407,33 @@ export const tickEdges = (state: EdgeState, options: EdgeBehaviourOptions) => {
397
407
 
398
408
  /* ── The draft preview ──────────────────────────────────────────────────────
399
409
  *
400
- * One `schedule-create-draft.tsx` leaf is mounted per day column, and a single
401
- * gesture writes to all of them. Both authoring gestures need this: a create
402
- * drag uses it for its whole preview, and a resize falls back to it the moment
403
- * its edge leaves the chip's own day, where the chip's `--sch-resize-delta-y`
404
- * stretch stops being able to represent the candidate at all.
410
+ * A pool of preview pieces, one per rendered day, lives in a single layer laid
411
+ * over the day columns (`ScheduleTimedGrid`'s `piece-pool`), and a gesture
412
+ * writes to all of them. Both authoring gestures need this: a create drag uses
413
+ * it for its whole preview, and a resize falls back to it the moment its edge
414
+ * leaves the chip's own day, where the chip's `--sch-resize-delta-y` stretch
415
+ * stops being able to represent the candidate at all.
416
+ *
417
+ * The pieces used to be mounted *inside* each day column. That drew every
418
+ * piece of a cross-day candidate correctly, but it tied a piece's identity to
419
+ * its column: a move onto the next day hid one element and showed another, so
420
+ * every column change played a full fade-out and fade-in where a vertical move
421
+ * just glided. Placed by a column var instead, a piece can stay the same
422
+ * element while its column changes, and the browser transitions the horizontal
423
+ * position exactly the way it already transitions `top`.
405
424
  */
406
425
 
407
- /** Which per-column preview leaf a gesture paints into. Create and resize paint
408
- * the draft; a move paints the ghost. Same geometry, and since the draft lost
409
- * its dashes the same skin too — they are the same kind of object ("the box
410
- * you are about to commit") and never appear at once. */
426
+ /** Which preview a gesture paints into. Create and resize paint the draft; a
427
+ * move paints the ghost. Same geometry, and since the draft lost its dashes
428
+ * the same skin too — they are the same kind of object ("the box you are
429
+ * about to commit") and never appear at once. */
411
430
  export type PiecePreview = {
412
- /** `data-schedule-part` of the leaf, one per day column. */
431
+ /** `data-schedule-part` of the leaf, one per pool slot. */
413
432
  part: string
414
433
  topVar: string
415
434
  heightVar: string
435
+ /** The rendered day index the piece is drawn over. */
436
+ columnVar: string
416
437
  labelPart: string
417
438
  }
418
439
 
@@ -420,6 +441,7 @@ export const CREATE_DRAFT: PiecePreview = {
420
441
  part: "create-draft",
421
442
  topVar: "--sch-create-top",
422
443
  heightVar: "--sch-create-height",
444
+ columnVar: "--sch-create-col",
423
445
  labelPart: "create-draft-label",
424
446
  }
425
447
 
@@ -427,23 +449,21 @@ export const DRAG_GHOST: PiecePreview = {
427
449
  part: "drag-ghost",
428
450
  topVar: "--sch-ghost-top",
429
451
  heightVar: "--sch-ghost-height",
452
+ columnVar: "--sch-ghost-col",
430
453
  labelPart: "drag-ghost-label",
431
454
  }
432
455
 
433
- export const collectPieces = (
434
- grid: HTMLElement,
435
- preview: PiecePreview,
436
- ): Map<number, HTMLElement> => {
437
- const drafts = new Map<number, HTMLElement>()
438
- for (const column of grid.querySelectorAll<HTMLElement>(
439
- "[data-schedule-part='day-column'][data-day-index]",
440
- )) {
441
- if (!isLive(column)) continue
442
- const draft = column.querySelector<HTMLElement>(`[data-schedule-part='${preview.part}']`)
443
- if (draft) drafts.set(Number(column.dataset["dayIndex"]), draft)
444
- }
445
- return drafts
446
- }
456
+ /** The pool's pieces, keyed by slot. The pool sits outside the paged bands, so
457
+ * unlike the chips it never remounts with a page turn and needs no `isLive`
458
+ * filter: one collection lasts the whole gesture. */
459
+ export const collectPieces = (grid: HTMLElement, preview: PiecePreview): Map<number, HTMLElement> =>
460
+ new Map(
461
+ [
462
+ ...grid.querySelectorAll<HTMLElement>(
463
+ `[data-schedule-part='piece-pool'] > [data-schedule-part='${preview.part}']`,
464
+ ),
465
+ ].map((piece, slot) => [slot, piece]),
466
+ )
447
467
 
448
468
  const pieceLabel = (piece: HTMLElement, preview: PiecePreview) =>
449
469
  piece.querySelector<HTMLElement>(`[data-schedule-part='${preview.labelPart}']`)
@@ -506,6 +526,20 @@ export type PiecePaintOptions = {
506
526
  * gesture passes one; a repeat create passes one per day. */
507
527
  candidates: PieceCandidate[]
508
528
  totalWindowMinutes: number
529
+ /**
530
+ * The column a piece's identity is measured from. Default `0`, which keys
531
+ * every piece by its own column — right for create and resize, whose
532
+ * pieces are pinned where the gesture began and only grow or shrink.
533
+ *
534
+ * A move passes the column under the pointer, because there the whole
535
+ * candidate travels: keyed by offset from the pointer, the piece the user is
536
+ * holding keeps one element as it changes day, and so does every piece
537
+ * beside it, so a horizontal move *slides* the preview instead of
538
+ * cross-fading it. Not the event's start day: a vertical move through
539
+ * midnight changes that day without the pointer leaving its column, and the
540
+ * piece keyed to it would sweep diagonally into the next column.
541
+ */
542
+ anchor?: number
509
543
  }
510
544
 
511
545
  /**
@@ -526,10 +560,14 @@ export const paintPieces = ({
526
560
  bandOfColumn,
527
561
  candidates,
528
562
  totalWindowMinutes,
563
+ anchor = 0,
529
564
  }: PiecePaintOptions) => {
530
565
  const labelled = new Set<PieceCandidate>()
531
566
  for (const index of columnIndices) {
532
- const draft = pieces.get(index)
567
+ // There are as many slots as rendered days and every piece of a frame sits
568
+ // within those days, so the offsets are a run of at most `size` integers
569
+ // and folding them modulo `size` never puts two pieces in one slot.
570
+ const draft = pieces.get((((index - anchor) % pieces.size) + pieces.size) % pieces.size)
533
571
  if (!draft) continue
534
572
  const band = bandOfColumn(index)
535
573
  // Strict `<`, matching `segmentEvents` — a candidate ending exactly when a
@@ -548,6 +586,7 @@ export const paintPieces = ({
548
586
  const height = ((pieceEnd - pieceStart) / 60_000 / totalWindowMinutes) * 100
549
587
  draft.style.setProperty(preview.topVar, `${top}%`)
550
588
  draft.style.setProperty(preview.heightVar, `${height}%`)
589
+ draft.style.setProperty(preview.columnVar, `${index}`)
551
590
  draft.dataset["active"] = "true"
552
591
  if (candidate.invalid) draft.dataset["invalid"] = "true"
553
592
  else delete draft.dataset["invalid"]
@@ -1,11 +1,11 @@
1
1
  "use client"
2
2
 
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
- import { getLocalTimeZone } from "@internationalized/date"
5
4
  import type { ReactNode } from "react"
6
5
  import { useRef } from "react"
7
6
  import { cn } from "../../lib/cn"
8
7
  import { focusStyles } from "../../lib/focus-styles"
8
+ import { useLocale, useTimeZone } from "../../lib/intl"
9
9
  import { OverlayContainerProvider } from "../../lib/overlay-container"
10
10
  import { props as dataProps } from "../../lib/props"
11
11
  import type { WithTestId } from "../../lib/test-id"
@@ -212,7 +212,7 @@ function MonthEventPill<P>({
212
212
  )}
213
213
  >
214
214
  {event.icon != null ? (
215
- <span className="mr-1 inline-flex align-[-1px] [&_svg]:size-3">{event.icon}</span>
215
+ <span className="me-1 inline-flex align-[-1px] [&_svg]:size-3">{event.icon}</span>
216
216
  ) : null}
217
217
  {event.title}
218
218
  </button>
@@ -496,8 +496,8 @@ export function MonthView<P = unknown>({
496
496
  onOverflowClick,
497
497
  withOverflowDetails,
498
498
  renderOverflowDetails,
499
- locale,
500
- timeZone = getLocalTimeZone(),
499
+ locale: localeProp,
500
+ timeZone: timeZoneProp,
501
501
  translations,
502
502
  classNames,
503
503
  className,
@@ -513,6 +513,8 @@ export function MonthView<P = unknown>({
513
513
  testId,
514
514
  ...rest
515
515
  }: MonthViewProps<P>) {
516
+ const locale = useLocale(localeProp)
517
+ const timeZone = useTimeZone(timeZoneProp)
516
518
  const [currentDate, setCurrentDate] = useUncontrolled<Date>({
517
519
  value: date,
518
520
  defaultValue: defaultDate,
@@ -529,7 +531,7 @@ export function MonthView<P = unknown>({
529
531
  const todayRef = now ?? new Date()
530
532
  const range = getVisibleRange("month", currentDate, {
531
533
  timeZone,
532
- locale: locale ?? "en-US",
534
+ locale,
533
535
  startOfWeek,
534
536
  })
535
537
  const days = enumerateDays(range, timeZone)
@@ -1,9 +1,9 @@
1
1
  "use client"
2
2
 
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
- import { getLocalTimeZone } from "@internationalized/date"
5
4
  import type { ReactNode } from "react"
6
5
  import { cn } from "../../lib/cn"
6
+ import { useLocale, useTimeZone } from "../../lib/intl"
7
7
  import { props } from "../../lib/props"
8
8
  import type { WithTestId } from "../../lib/test-id"
9
9
  import { useNow } from "../../lib/use-now"
@@ -97,8 +97,8 @@ export function ScheduleNextUp<P = unknown>({
97
97
  data,
98
98
  now,
99
99
  pastEventsOffset = 30,
100
- locale,
101
- timeZone = getLocalTimeZone(),
100
+ locale: localeProp,
101
+ timeZone: timeZoneProp,
102
102
  translations,
103
103
  empty,
104
104
  renderEvent,
@@ -107,6 +107,8 @@ export function ScheduleNextUp<P = unknown>({
107
107
  testId,
108
108
  ...rest
109
109
  }: ScheduleNextUpProps<P>) {
110
+ const locale = useLocale(localeProp)
111
+ const timeZone = useTimeZone(timeZoneProp)
110
112
  const current = useNow(now)
111
113
  const agenda = buildNextUpAgenda(data, current, { pastEventsOffset, timeZone })
112
114
  const t = resolveScheduleTranslations(translations)
@@ -614,7 +614,9 @@ function DayColumn<P = unknown>({
614
614
  // its own; `align-self: stretch` (the grid default) is what makes
615
615
  // that stretch actually apply here.
616
616
  "relative row-2 h-full",
617
- // `overflow-y-clip` contains the create draft's own scale overshoot.
617
+ // `overflow-y-clip` contained the create draft's own scale overshoot
618
+ // when the draft was mounted in here; it now lives in the grid's
619
+ // `piece-pool` layer, which carries the same clip for the same reason.
618
620
  // The draft rests at `scale-105` and transitions to `scale-100` on
619
621
  // enter (see `schedule-create-draft.tsx` — the >1 resting scale is
620
622
  // deliberate, so its *leave* expands outward where it can be seen
@@ -688,8 +690,6 @@ function DayColumn<P = unknown>({
688
690
  }}
689
691
  />
690
692
  ))}
691
- <ScheduleCreateDraft className={classNames?.createDraft} />
692
- <ScheduleDragGhost className={classNames?.dragGhost} />
693
693
  {chips.map((chip) => chip.node)}
694
694
  {withNowIndicator && isToday ? (
695
695
  <NowCursorLine
@@ -1279,6 +1279,8 @@ export function ScheduleTimedGrid<P = unknown>({
1279
1279
  // details popovers are portalled *into* this subtree, so their panels
1280
1280
  // opt back in with `select-text`.
1281
1281
  "select-none",
1282
+ // Mirrors the page-turn slide: see the `schedule-page-*` keyframes.
1283
+ "rtl:[--sch-inline-dir:-1]",
1282
1284
  classNames?.grid,
1283
1285
  )}
1284
1286
  style={
@@ -1584,6 +1586,42 @@ export function ScheduleTimedGrid<P = unknown>({
1584
1586
  </div>
1585
1587
  ) : null}
1586
1588
 
1589
+ {/* The gesture previews: one create draft and one drag ghost per
1590
+ * rendered day, in one layer over every day column, each placed on
1591
+ * its day by a var (`poolPieceInsets`). Over the columns rather
1592
+ * than inside them so a piece can change day without changing
1593
+ * element — the drag ghost then *slides* to the next column instead
1594
+ * of fading out of one and into another.
1595
+ *
1596
+ * The same in-flow `relative col-[2/-1] row-2 min-w-0` wrapper the
1597
+ * now-cursor guide above uses, for the same reasons: it resolves to
1598
+ * the row's real height (so the pieces' `top` percentages share the
1599
+ * columns' basis), and `min-w-0` stops it distorting the `1fr`
1600
+ * tracks it spans. No z-index, so it forms no stacking context and
1601
+ * the pieces' own `z-26`/`z-27` still clear the columns' chips.
1602
+ *
1603
+ * Outside `renderBand` on purpose: the pool is not part of a page,
1604
+ * so a page turn mid-gesture neither remounts it nor slides it away.
1605
+ *
1606
+ * `overflow-y-clip` contains the pieces' scale overshoot (they rest
1607
+ * at `scale-105`), which would otherwise grow the grid's scrollable
1608
+ * height for the length of the fade — see `DayColumn`'s own. */}
1609
+ <div
1610
+ aria-hidden
1611
+ data-schedule-part="piece-pool"
1612
+ className="pointer-events-none relative col-[2/-1] row-2 min-w-0 overflow-y-clip"
1613
+ style={{ "--sch-pool-columns": `${days.length}` } as CSSProperties}
1614
+ >
1615
+ {days.map((_, slot) => (
1616
+ // biome-ignore lint/suspicious/noArrayIndexKey: pool slots, not days — keyed by date, a page turn would remount the pool mid-gesture.
1617
+ <ScheduleCreateDraft key={slot} className={classNames?.createDraft} />
1618
+ ))}
1619
+ {days.map((_, slot) => (
1620
+ // biome-ignore lint/suspicious/noArrayIndexKey: pool slots, not days — keyed by date, a page turn would remount the pool mid-gesture.
1621
+ <ScheduleDragGhost key={slot} className={classNames?.dragGhost} />
1622
+ ))}
1623
+ </div>
1624
+
1587
1625
  {renderBand(days, dataSegments, staticSegments, paging ? "entering" : undefined, "")}
1588
1626
  {pageOut
1589
1627
  ? renderBand(outDays, outDataSegments, outStaticSegments, "exiting", "exit-")
@@ -1,9 +1,9 @@
1
1
  "use client"
2
2
 
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
- import { getLocalTimeZone } from "@internationalized/date"
5
4
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
6
5
  import { cn } from "../../lib/cn"
6
+ import { useLocale, useTimeZone } from "../../lib/intl"
7
7
  import { props } from "../../lib/props"
8
8
  import type { Size } from "../../lib/sizes"
9
9
  import type { WithTestId } from "../../lib/test-id"
@@ -61,13 +61,14 @@ const ScheduleToolbarPrevTrigger = ({
61
61
  view,
62
62
  date,
63
63
  onDateChange,
64
- timeZone = getLocalTimeZone(),
64
+ timeZone: timeZoneProp,
65
65
  translations,
66
66
  size = "sm",
67
67
  className,
68
68
  testId,
69
69
  visibleDays,
70
70
  }: PaginationTriggerProps) => {
71
+ const timeZone = useTimeZone(timeZoneProp)
71
72
  const t = resolveScheduleTranslations(translations)
72
73
  return (
73
74
  <ActionIcon
@@ -79,7 +80,7 @@ const ScheduleToolbarPrevTrigger = ({
79
80
  className={className}
80
81
  testId={testId}
81
82
  >
82
- <ChevronLeftIcon />
83
+ <ChevronLeftIcon className="rtl:rotate-180" />
83
84
  </ActionIcon>
84
85
  )
85
86
  }
@@ -88,13 +89,14 @@ const ScheduleToolbarNextTrigger = ({
88
89
  view,
89
90
  date,
90
91
  onDateChange,
91
- timeZone = getLocalTimeZone(),
92
+ timeZone: timeZoneProp,
92
93
  translations,
93
94
  size = "sm",
94
95
  className,
95
96
  testId,
96
97
  visibleDays,
97
98
  }: PaginationTriggerProps) => {
99
+ const timeZone = useTimeZone(timeZoneProp)
98
100
  const t = resolveScheduleTranslations(translations)
99
101
  return (
100
102
  <ActionIcon
@@ -106,7 +108,7 @@ const ScheduleToolbarNextTrigger = ({
106
108
  className={className}
107
109
  testId={testId}
108
110
  >
109
- <ChevronRightIcon />
111
+ <ChevronRightIcon className="rtl:rotate-180" />
110
112
  </ActionIcon>
111
113
  )
112
114
  }
@@ -169,23 +171,27 @@ export type ScheduleToolbarTitleProps = HTMLArkProps<"h2"> &
169
171
  const ScheduleToolbarTitle = ({
170
172
  view,
171
173
  date,
172
- timeZone = getLocalTimeZone(),
173
- locale,
174
+ timeZone: timeZoneProp,
175
+ locale: localeProp,
174
176
  align,
175
177
  visibleDays,
176
178
  className,
177
179
  testId,
178
180
  ...rest
179
- }: ScheduleToolbarTitleProps) => (
180
- <ark.h2
181
- data-schedule-part="toolbar-title"
182
- className={cn("truncate font-semibold text-sm", className)}
183
- {...props({ "data-testid": testId })}
184
- {...rest}
185
- >
186
- {formatScheduleTitle(view, date, { timeZone, locale, startOfWeek: align, visibleDays })}
187
- </ark.h2>
188
- )
181
+ }: ScheduleToolbarTitleProps) => {
182
+ const locale = useLocale(localeProp)
183
+ const timeZone = useTimeZone(timeZoneProp)
184
+ return (
185
+ <ark.h2
186
+ data-schedule-part="toolbar-title"
187
+ className={cn("truncate font-semibold text-sm", className)}
188
+ {...props({ "data-testid": testId })}
189
+ {...rest}
190
+ >
191
+ {formatScheduleTitle(view, date, { timeZone, locale, startOfWeek: align, visibleDays })}
192
+ </ark.h2>
193
+ )
194
+ }
189
195
 
190
196
  export type ScheduleToolbarViewSwitcherProps<V extends ScheduleViews = DefaultScheduleViews> =
191
197
  WithTestId & {
@@ -537,8 +537,11 @@ export type ScheduleSharedProps<P = unknown> = {
537
537
  * uncontrolled anchor date from it.
538
538
  */
539
539
  now?: Date
540
+ /** BCP-47 tag for every label and the week start. Defaults to the nearest
541
+ * `IntlProvider`'s locale, else `"en-US"`; `"auto"` reads the browser's. */
540
542
  locale?: string
541
- /** Default `getLocalTimeZone()` — not Ark's own `"UTC"` default. */
543
+ /** IANA zone the events are laid out in. Defaults to the nearest
544
+ * `IntlProvider`'s zone, else `"auto"` (the browser's own). */
542
545
  timeZone?: string
543
546
  translations?: ScheduleTranslations
544
547
  classNames?: ScheduleClassNames
@@ -1,9 +1,9 @@
1
1
  "use client"
2
2
 
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
- import { getLocalTimeZone } from "@internationalized/date"
5
4
  import { cn } from "../../lib/cn"
6
5
  import { focusStyles } from "../../lib/focus-styles"
6
+ import { useLocale, useTimeZone } from "../../lib/intl"
7
7
  import { props as dataProps } from "../../lib/props"
8
8
  import type { WithTestId } from "../../lib/test-id"
9
9
  import { useUncontrolled } from "../../lib/use-uncontrolled"
@@ -81,8 +81,8 @@ export function YearView<P = unknown>({
81
81
  staticEvents = [],
82
82
  onDayClick,
83
83
  onMonthClick,
84
- locale,
85
- timeZone = getLocalTimeZone(),
84
+ locale: localeProp,
85
+ timeZone: timeZoneProp,
86
86
  translations,
87
87
  classNames,
88
88
  className,
@@ -96,6 +96,8 @@ export function YearView<P = unknown>({
96
96
  testId,
97
97
  ...rest
98
98
  }: YearViewProps<P>) {
99
+ const locale = useLocale(localeProp)
100
+ const timeZone = useTimeZone(timeZoneProp)
99
101
  const [currentDate, setCurrentDate] = useUncontrolled<Date>({
100
102
  value: date,
101
103
  defaultValue: defaultDate,
@@ -104,7 +106,7 @@ export function YearView<P = unknown>({
104
106
  })
105
107
  const t = resolveScheduleTranslations(translations)
106
108
  const todayRef = now ?? new Date()
107
- const yearRange = getVisibleRange("year", currentDate, { timeZone, locale: locale ?? "en-US" })
109
+ const yearRange = getVisibleRange("year", currentDate, { timeZone, locale })
108
110
  const monthStarts = enumerateMonths(yearRange, timeZone)
109
111
  const allEvents = [...data, ...staticEvents]
110
112
 
@@ -153,7 +155,7 @@ export function YearView<P = unknown>({
153
155
  {monthStarts.map((monthStart) => {
154
156
  const monthGrid = getVisibleRange("month", monthStart, {
155
157
  timeZone,
156
- locale: locale ?? "en-US",
158
+ locale,
157
159
  })
158
160
  const nextMonthStart = monthStarts.find((m) => m.getTime() > monthStart.getTime())
159
161
  const monthEnd = nextMonthStart ?? yearRange.end