@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
@@ -13,22 +13,22 @@ import {
13
13
  CloseTrigger,
14
14
  Description,
15
15
  Icon,
16
- notificationSurface,
17
16
  Title,
18
17
  TOAST_STATUS,
19
18
  } from "../notification/notification"
20
19
  import type { ToastHue, ToastType } from "../notification/types"
21
20
 
22
21
  /**
23
- * Alert — a wide, static status card: the same surface as `Notification`
24
- * (the outline surface tinted by `color`, `type` presets, the `Icon` / `Title` / `Description` /
25
- * `ActionTrigger` / `CloseTrigger` parts) but full-width and always-mounted —
26
- * for an inline note in page content (a doc callout, a form-level warning),
27
- * not a floating, self-dismissing toast.
22
+ * Alert — a wide, static status card with `Notification`'s look (`type`
23
+ * presets, the `Icon` / `Title` / `Description` / `ActionTrigger` /
24
+ * `CloseTrigger` parts) but full-width and always-mounted — for an inline note
25
+ * in page content (a doc callout, a form-level warning), not a floating,
26
+ * self-dismissing toast.
28
27
  *
29
- * It reuses `Notification`'s non-width parts and `type` → hue/icon presets
30
- * directly (see `notification.tsx`) so the two stay visually identical; only
31
- * the root surface — width, shadow, enter/exit animation — differs.
28
+ * It reuses `Notification`'s parts and `type` → hue/icon presets directly (see
29
+ * `notification.tsx`). The root surface is its own: a toast floats over
30
+ * arbitrary content and needs its opaque, blurred panel, while an alert sits
31
+ * on the page, so it takes a translucent tint of its hue instead.
32
32
  *
33
33
  * @example
34
34
  * ```tsx
@@ -41,7 +41,14 @@ import type { ToastHue, ToastType } from "../notification/types"
41
41
  export type AlertType = Exclude<ToastType, "loading">
42
42
 
43
43
  /** The card surface. Full-width and flat (no toast shadow/animation) — meant
44
- * to sit inline in page content rather than float above it. */
44
+ * to sit inline in page content rather than float above it. Translucent, so
45
+ * it blends into whatever surface hosts it: a faint `--c-solid` wash carries
46
+ * the status across the whole card, edged by a translucent `--c-solid` (the
47
+ * edge `ChoiceCardGroup`'s checked `filled` card uses). The wash comes from
48
+ * `--c-solid`, not `--c-soft`: light-mode `--c-soft` is the near-white 50 step
49
+ * for every hue but `neutral` (a 16% black), so warning/error vanished while
50
+ * info turned into the heaviest card. `text-(--c-solid)` still tints the icon
51
+ * and the `current`-based triggers. */
45
52
  export const alertRoot = cva([
46
53
  "flex flex-col w-full",
47
54
  "rounded-card border px-3 py-3",
@@ -51,7 +58,7 @@ export const alertRoot = cva([
51
58
  focusStyles({ offset: false }),
52
59
  "[&_svg]:shrink-0 [&_svg]:pointer-events-none",
53
60
  "overflow-clip",
54
- notificationSurface,
61
+ "bg-(--c-solid)/8 dark:bg-(--c-solid)/12 border-(--c-solid)/45 text-(--c-solid)",
55
62
  ])
56
63
 
57
64
  export type AlertRootProps = HTMLArkProps<"div"> &
@@ -160,7 +160,14 @@ const weekNumberCell = cn(
160
160
  )
161
161
 
162
162
  const navIcon = (direction: "prev" | "next", size: Size | undefined, className?: string) => (
163
- <ActionIcon variant="subtle" color="neutral" size={size} className={className}>
163
+ // The glyphs are physical; prev sits on the inline-start edge, which is the
164
+ // right one under RTL, so both chevrons mirror to keep pointing outward.
165
+ <ActionIcon
166
+ variant="subtle"
167
+ color="neutral"
168
+ size={size}
169
+ className={cn("rtl:[&_svg]:rotate-180", className)}
170
+ >
164
171
  {direction === "prev" ? <ChevronLeftIcon /> : <ChevronRightIcon />}
165
172
  </ActionIcon>
166
173
  )
@@ -171,14 +171,15 @@ const generateId = (): ToastId => nanoid() as ToastId
171
171
  const GAP = 12
172
172
 
173
173
  /** Region positioning (fixed + anchored edge) per placement. The stacking
174
- * geometry itself lives in theme.css, keyed on `data-placement`. */
174
+ * geometry itself lives in theme.css, keyed on `data-placement`. `start`/`end`
175
+ * are logical insets, so they follow the document's `dir` (end = left in RTL). */
175
176
  const REGION_POSITION = {
176
- "top-start": "top-4 left-4",
177
+ "top-start": "top-4 inset-s-4",
177
178
  top: "top-4 left-1/2 -translate-x-1/2",
178
- "top-end": "top-4 right-4",
179
- "bottom-start": "bottom-4 left-4",
179
+ "top-end": "top-4 inset-e-4",
180
+ "bottom-start": "bottom-4 inset-s-4",
180
181
  bottom: "bottom-4 left-1/2 -translate-x-1/2",
181
- "bottom-end": "bottom-4 right-4",
182
+ "bottom-end": "bottom-4 inset-e-4",
182
183
  } as const satisfies Record<NotifyPlacement, string>
183
184
  /** Fields `notify.update` copies from the input onto a live toast — the keys
184
185
  * shared by `NotifyOptions` and `ToastData` (excludes `id`/`status`/`type`). */
@@ -175,6 +175,21 @@ describe("notify", () => {
175
175
  await Promise.resolve()
176
176
  expect(notify.getToasts()[0]!).toMatchObject({ type: "success", title: "Saved" })
177
177
  })
178
+
179
+ // jsdom has no layout, so this pins the classes: physical left/right would
180
+ // keep an `end` toaster on the right under `dir="rtl"`.
181
+ it.each([
182
+ ["top-start", "inset-s-4"],
183
+ ["top-end", "inset-e-4"],
184
+ ["bottom-start", "inset-s-4"],
185
+ ["bottom-end", "inset-e-4"],
186
+ ] as const)("anchors %s to the logical %s inset", (placement, inset) => {
187
+ const { Notifications } = createNotifier({ placement, withinPortal: false })
188
+ const markup = renderToStaticMarkup(<Notifications />)
189
+ const region = markup.slice(0, markup.indexOf(">"))
190
+ expect(region).toContain(inset)
191
+ expect(region).not.toMatch(/\b(left|right)-4\b/)
192
+ })
178
193
  })
179
194
 
180
195
  /** Split a `CollapseTrigger`'s markup at its glyph: button tag, then icon tag. */
@@ -42,10 +42,10 @@ import type { ToastFields, ToastHue, ToastType } from "./types"
42
42
  * keyframes (like modal/drawer/popover).
43
43
  */
44
44
 
45
- /** The outline surface — shared with `Alert` (the wide, static sibling) so
46
- * the two stay visually identical; only the structural classes (width,
47
- * shadow, enter/exit animation) differ between the two roots. `color` tints
48
- * the border, text and icon through `--c-solid`. */
45
+ /** The outline surface. Deliberately opaque and blurred: a toast floats over
46
+ * arbitrary content. `Alert` (the inline sibling) shares the parts but not
47
+ * this surface — it sits on the page and takes a translucent tint instead.
48
+ * `color` tints the border, text and icon through `--c-solid`. */
49
49
  export const notificationSurface = [
50
50
  "bg-brand-50/90 dark:bg-brand-950/85",
51
51
  "text-(--c-solid) border-(--c-solid) backdrop-blur-lg",
@@ -112,7 +112,7 @@ export function NowCursorLine({
112
112
  {variant === "marker" && !hideDot ? (
113
113
  <div
114
114
  data-schedule-part="now-indicator-dot"
115
- className="absolute top-0 inset-s-0 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-(--sch-now-line-color)"
115
+ className="absolute top-0 inset-s-0 size-2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full bg-(--sch-now-line-color)"
116
116
  />
117
117
  ) : null}
118
118
  </div>
@@ -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 { useRef } from "react"
6
5
  import { cn } from "../../lib/cn"
6
+ import { useLocale, useTimeZone } from "../../lib/intl"
7
7
  import { OverlayContainerProvider } from "../../lib/overlay-container"
8
8
  import { props as dataProps } from "../../lib/props"
9
9
  import type { WithTestId } from "../../lib/test-id"
@@ -92,8 +92,8 @@ export function AgendaView<P = unknown>({
92
92
  withSelection = true,
93
93
  withEventDetails = true,
94
94
  renderEventDetails,
95
- locale,
96
- timeZone = getLocalTimeZone(),
95
+ locale: localeProp,
96
+ timeZone: timeZoneProp,
97
97
  translations,
98
98
  classNames,
99
99
  className,
@@ -108,6 +108,8 @@ export function AgendaView<P = unknown>({
108
108
  testId,
109
109
  ...rest
110
110
  }: AgendaViewProps<P>) {
111
+ const locale = useLocale(localeProp)
112
+ const timeZone = useTimeZone(timeZoneProp)
111
113
  const [currentDate, setCurrentDate] = useUncontrolled<Date>({
112
114
  value: date,
113
115
  defaultValue: defaultDate,
@@ -122,7 +124,7 @@ export function AgendaView<P = unknown>({
122
124
  })
123
125
  const t = resolveScheduleTranslations(translations)
124
126
  const current = useNow(now)
125
- const range = getVisibleRange("agenda", currentDate, { timeZone, locale: locale ?? "en-US" })
127
+ const range = getVisibleRange("agenda", currentDate, { timeZone, locale })
126
128
  // `rangesOverlap` against the very range `isEventInVisibleRange` asks about
127
129
  // — not `filterUpcomingEvents`, whose open-ended lower bound is NextUp's
128
130
  // alone. The two being the same predicate over the same range is what makes
@@ -321,7 +321,7 @@ function AllDayEventBar<P>({
321
321
  )}
322
322
  >
323
323
  {event.icon != null ? (
324
- <span className="mr-1 inline-flex align-[-1px] [&_svg]:size-3">{event.icon}</span>
324
+ <span className="me-1 inline-flex align-[-1px] [&_svg]:size-3">{event.icon}</span>
325
325
  ) : null}
326
326
  {event.title}
327
327
  </button>
@@ -1,4 +1,5 @@
1
1
  import { cn } from "../../lib/cn"
2
+ import { poolPieceInsets } from "./schedule-geometry"
2
3
 
3
4
  /**
4
5
  * The click-drag-to-create ghost box. RSC — owns no state, only reads the
@@ -9,8 +10,9 @@ import { cn } from "../../lib/cn"
9
10
  * `pointermove`, matching the module's "refs are not state" discipline for
10
11
  * in-flight gesture coordinates.
11
12
  *
12
- * One of these is mounted per day column, and a single gesture writes to all
13
- * of them: a create drag has two axes, so its candidate is clipped to each
13
+ * One of these is mounted per rendered day, pooled in a layer laid over the
14
+ * day columns (`piece-pool` in `schedule-timed-grid.tsx`) and placed on its day
15
+ * by `--sch-create-col`, and a single gesture writes to all of them: a create drag has two axes, so its candidate is clipped to each
14
16
  * column's own painted band exactly the way `segmentEvents` clips a real
15
17
  * event. A cross-day draft is therefore several of these boxes, one per day,
16
18
  * not one box drawn past the bottom of its column.
@@ -31,7 +33,7 @@ export function ScheduleCreateDraft({ className }: { className?: string }) {
31
33
  aria-hidden
32
34
  data-schedule-part="create-draft"
33
35
  className={cn(
34
- "group pointer-events-none absolute inset-x-0 hidden rounded-sm border-2",
36
+ "group pointer-events-none absolute hidden rounded-sm border-2",
35
37
  // `select-none`, like every other chip surface in the grid. The label
36
38
  // rides the box's top edge, which during an upward drag *is* the
37
39
  // pointer position — so the browser extended a text selection straight
@@ -114,9 +116,15 @@ export function ScheduleCreateDraft({ className }: { className?: string }) {
114
116
  * Easing per direction comes from whichever state the transition heads
115
117
  * *to*, so the base carries `ease-in` (the leave) and `data-active` the
116
118
  * `ease-out` (the enter). `allow-discrete` rides on `display` alone.
119
+ *
120
+ * `inset-inline-start` is the drag ghost's day-change slide. A draft
121
+ * piece is keyed by its own column (create and resize are pinned where
122
+ * they began, and only grow or shrink), so it never changes column
123
+ * mid-gesture; it is listed so the two previews stay one declaration
124
+ * apart, as `height` is on the ghost.
117
125
  */
118
- "[transition:opacity_200ms_ease-in,scale_200ms_ease-in,display_200ms_ease-in_allow-discrete,top_45ms_ease-out,height_45ms_ease-out]",
119
- "data-active:[transition:opacity_200ms_ease-out,scale_200ms_ease-out,display_200ms_ease-out_allow-discrete,top_45ms_ease-out,height_45ms_ease-out]",
126
+ "[transition:opacity_200ms_ease-in,scale_200ms_ease-in,display_200ms_ease-in_allow-discrete,top_45ms_ease-out,height_45ms_ease-out,inset-inline-start_70ms_ease-out]",
127
+ "data-active:[transition:opacity_200ms_ease-out,scale_200ms_ease-out,display_200ms_ease-out_allow-discrete,top_45ms_ease-out,height_45ms_ease-out,inset-inline-start_70ms_ease-out]",
120
128
  // `!` and the full shorthand, not `transition-none`: the `data-active`
121
129
  // rule above is a class *and* an attribute selector, so a plain
122
130
  // `motion-reduce:transition-none` loses to it and the preview kept
@@ -138,6 +146,7 @@ export function ScheduleCreateDraft({ className }: { className?: string }) {
138
146
  // Safe for the inactive pieces this component also renders: they are
139
147
  // `display: none` without `data-active`, so their height never paints.
140
148
  height: "max(var(--sch-create-height, 0px), calc(1rem + 2px))",
149
+ ...poolPieceInsets("--sch-create-col"),
141
150
  }}
142
151
  >
143
152
  {/* The live drop-time readout, the same one `schedule-drag-ghost.tsx`
@@ -10,6 +10,7 @@ import {
10
10
  } from "@internationalized/date"
11
11
  import { match } from "ts-pattern"
12
12
  import { calendarValueToDate, dateToCalendarValue } from "../../lib/date-value"
13
+ import { DEFAULT_LOCALE } from "../../lib/intl"
13
14
  import type { ScheduleSlotPredicate } from "../../lib/schedule-predicates"
14
15
  import type {
15
16
  FirstDayOfWeek,
@@ -601,7 +602,7 @@ export function formatScheduleTitle(
601
602
  visibleDays?: number
602
603
  },
603
604
  ): string {
604
- const { timeZone, locale, startOfWeek, visibleDays } = options
605
+ const { timeZone, locale = DEFAULT_LOCALE, startOfWeek, visibleDays } = options
605
606
  return (
606
607
  match(view)
607
608
  .with("days", () => {
@@ -611,7 +612,7 @@ export function formatScheduleTitle(
611
612
  }
612
613
  const range = getVisibleRange("days", date, {
613
614
  timeZone,
614
- locale: locale ?? "en-US",
615
+ locale,
615
616
  startOfWeek,
616
617
  visibleDays: days,
617
618
  })
@@ -1,10 +1,10 @@
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 { Ref } from "react"
6
5
  import { useRef } from "react"
7
6
  import { cn } from "../../lib/cn"
7
+ import { useLocale, useTimeZone } from "../../lib/intl"
8
8
  import { mergeRefs } from "../../lib/merge-refs"
9
9
  import { props } from "../../lib/props"
10
10
  import type { WithTestId } from "../../lib/test-id"
@@ -108,8 +108,8 @@ export function DaysViewBody<P = unknown>({
108
108
  withEventDetails = true,
109
109
  onDayClick,
110
110
  renderEventDetails,
111
- locale,
112
- timeZone = getLocalTimeZone(),
111
+ locale: localeProp,
112
+ timeZone: timeZoneProp,
113
113
  translations,
114
114
  classNames,
115
115
  className,
@@ -147,6 +147,8 @@ export function DaysViewBody<P = unknown>({
147
147
  testId,
148
148
  ...rest
149
149
  }: DaysViewBaseProps<P> & ScheduleSlotValues) {
150
+ const locale = useLocale(localeProp)
151
+ const timeZone = useTimeZone(timeZoneProp)
150
152
  const [anchorDate, setAnchorDate] = useUncontrolled<Date>({
151
153
  value: date,
152
154
  defaultValue: defaultDate,
@@ -164,7 +166,7 @@ export function DaysViewBody<P = unknown>({
164
166
  const t = resolveScheduleTranslations(translations)
165
167
  const range = getVisibleRange("days", anchorDate, {
166
168
  timeZone,
167
- locale: locale ?? "en-US",
169
+ locale,
168
170
  startOfWeek: align,
169
171
  visibleDays,
170
172
  })
@@ -1,11 +1,13 @@
1
1
  import { cn } from "../../lib/cn"
2
+ import { poolPieceInsets } from "./schedule-geometry"
2
3
 
3
4
  /**
4
5
  * The move-drag preview. Same shape and same geometry as
5
6
  * `schedule-create-draft.tsx` — a permanently-mounted, `aria-hidden`,
6
7
  * pointer-events-none leaf driven purely by imperative CSS-var writes, never a
7
- * `useState` re-render per `pointermove` — and, like it, **one per day
8
- * column**.
8
+ * `useState` re-render per `pointermove` — and, like it, pooled: one per
9
+ * rendered day, in a layer laid over the day columns (`piece-pool` in
10
+ * `schedule-timed-grid.tsx`), each placed on its day by `--sch-ghost-col`.
9
11
  *
10
12
  * It used to be a single element at the grid level, placed by writing
11
13
  * `gridColumn`, which needed no horizontal pixel math. That was elegant and it
@@ -13,11 +15,17 @@ import { cn } from "../../lib/cn"
13
15
  * days, and one box can only ever draw one of them. Its own comment admitted
14
16
  * as much ("the ghost shows the *first* day's piece"), so dragging an event up
15
17
  * through midnight drew the piece on the previous day and simply omitted the
16
- * piece under the pointer. Per-column leaves draw every piece, exactly the way
18
+ * piece under the pointer. One piece per day draws every piece, exactly the way
17
19
  * a committed multi-day event already renders.
18
20
  *
19
- * `--sch-ghost-top`/`--sch-ghost-height` are percentages of the day column's
20
- * own height, exactly like a chip's `--sch-base-top`/`--sch-base-height`, so
21
+ * Those pieces were then mounted *inside* each day column, which fixed the
22
+ * midnight case and broke a smaller one: a piece's identity was its column, so
23
+ * moving to another day faded one element out and the next one in, where a
24
+ * vertical move glided. Placed by a var, a piece keeps its element across the
25
+ * change and slides — see `paintPieces`' `anchor`.
26
+ *
27
+ * `--sch-ghost-top`/`--sch-ghost-height` are percentages of the timed row's
28
+ * height (the pool layer's, and every day column's), exactly like a chip's `--sch-base-top`/`--sch-base-height`, so
21
29
  * the ghost lines up with the hour grid without knowing the hour height.
22
30
  */
23
31
  export function ScheduleDragGhost({ className }: { className?: string }) {
@@ -33,7 +41,7 @@ export function ScheduleDragGhost({ className }: { className?: string }) {
33
41
  // while staying under the sticky gutter (30) — same band, and same
34
42
  // reasoning, as the create draft's own.
35
43
  className={cn(
36
- "group pointer-events-none absolute inset-x-0 z-26 hidden select-none rounded-sm",
44
+ "group pointer-events-none absolute z-26 hidden select-none rounded-sm",
37
45
  // The piece carrying the readout paints above its siblings — same
38
46
  // collision the create draft has, for the same reason: the label is
39
47
  // deliberately wider than its own column so a cross-day range is not
@@ -97,12 +105,15 @@ export function ScheduleDragGhost({ className }: { className?: string }) {
97
105
  * during a move (a move preserves duration) and is listed only so the
98
106
  * two previews stay one declaration apart.
99
107
  *
100
- * Only the vertical smooths. Moving to another day swaps to a different
101
- * element — one ghost piece per day column — so a CSS transition has
102
- * nothing to interpolate across that axis.
108
+ * `inset-inline-start` eases a move onto another day the same way. The
109
+ * piece stays one element across the change (`paintPieces` keys it by
110
+ * its offset from the pointer's column), so this slides it rather than
111
+ * fading one column's piece out and the next one's in. Longer than the
112
+ * vertical step because the distance is: a column is a hundred-odd
113
+ * pixels where a slot is a dozen.
103
114
  */
104
- "[transition:opacity_200ms_ease-in,scale_200ms_ease-in,display_200ms_ease-in_allow-discrete,top_45ms_ease-out,height_45ms_ease-out]",
105
- "data-active:[transition:opacity_200ms_ease-out,scale_200ms_ease-out,display_200ms_ease-out_allow-discrete,top_45ms_ease-out,height_45ms_ease-out]",
115
+ "[transition:opacity_200ms_ease-in,scale_200ms_ease-in,display_200ms_ease-in_allow-discrete,top_45ms_ease-out,height_45ms_ease-out,inset-inline-start_70ms_ease-out]",
116
+ "data-active:[transition:opacity_200ms_ease-out,scale_200ms_ease-out,display_200ms_ease-out_allow-discrete,top_45ms_ease-out,height_45ms_ease-out,inset-inline-start_70ms_ease-out]",
106
117
  "starting:data-active:opacity-0 starting:data-active:scale-105",
107
118
  // `!` and the full shorthand, not `transition-none`: the `data-active`
108
119
  // rule above is a class *and* an attribute selector, so a plain
@@ -119,7 +130,11 @@ export function ScheduleDragGhost({ className }: { className?: string }) {
119
130
  "data-continues-after:rounded-b-none data-continues-after:border-b-0",
120
131
  className,
121
132
  )}
122
- style={{ top: "var(--sch-ghost-top, 0%)", height: "var(--sch-ghost-height, 0%)" }}
133
+ style={{
134
+ top: "var(--sch-ghost-top, 0%)",
135
+ height: "var(--sch-ghost-height, 0%)",
136
+ ...poolPieceInsets("--sch-ghost-col"),
137
+ }}
123
138
  >
124
139
  {/* The live drop-time readout. Both products that ship drag-to-page pair
125
140
  * the gesture with one, and for the same reason: once the view can move
@@ -1,5 +1,6 @@
1
1
  "use client"
2
2
 
3
+ import { useLocaleContext } from "@ark-ui/react/locale"
3
4
  import { usePresence } from "@ark-ui/react/presence"
4
5
  import { cva } from "class-variance-authority"
5
6
  import { XIcon } from "lucide-react"
@@ -928,6 +929,11 @@ function InteractiveEventChip<P = unknown>({
928
929
  locale,
929
930
  })
930
931
 
932
+ // Left/Right are physical keys, but days run right-to-left under an RTL
933
+ // locale. The locale is where the kit takes direction from (see
934
+ // `useDirectionCheck`), which is also how zag mirrors arrow keys.
935
+ const { dir } = useLocaleContext()
936
+
931
937
  const handleBodyKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {
932
938
  if (!present) return
933
939
  if (e.key === "Enter" || e.key === " ") {
@@ -943,13 +949,14 @@ function InteractiveEventChip<P = unknown>({
943
949
  // scrolls it instead of moving anything.
944
950
  e.preventDefault()
945
951
  // Left/Right move by a whole day, with no modifier variants — the
946
- // keyboard counterpart of dragging sideways. Up/Down keep their existing
952
+ // keyboard counterpart of dragging sideways, so they follow the columns:
953
+ // under RTL, Left is the *next* day. Up/Down keep their existing
947
954
  // `slotDuration` step (Shift ×4). Both go through the same displacement
948
955
  // primitive as the pointer path, so "a move never changes duration" is one
949
956
  // rule rather than two implementations of it.
950
957
  const step = e.shiftKey ? slotDuration * 4 : slotDuration
951
958
  const delta = isHorizontal
952
- ? { days: e.key === "ArrowLeft" ? -1 : 1, minutes: 0 }
959
+ ? { days: (e.key === "ArrowLeft") === (dir === "rtl") ? 1 : -1, minutes: 0 }
953
960
  : { days: 0, minutes: e.key === "ArrowUp" ? -step : step }
954
961
  const next = { ...moveRange(event, delta, { timeZone, slotDuration }) }
955
962
  const result = checkRangeCommit(next, {
@@ -98,7 +98,7 @@ export function ScheduleEventListPopoverContent<P = unknown>({
98
98
  aria-label={translations.back}
99
99
  className="-ms-1 flex items-center gap-1 rounded-sm px-1 py-0.5 text-gray-light-500 text-xs hover:bg-black/5 dark:text-gray-dark-400 dark:hover:bg-white/8"
100
100
  >
101
- <ArrowLeftIcon className="size-3.5" />
101
+ <ArrowLeftIcon className="size-3.5 rtl:rotate-180" />
102
102
  {translations.back}
103
103
  </button>
104
104
  </Popover.Header>
@@ -193,6 +193,27 @@ export function columnInsets({ column, columnCount }: ScheduleLayoutResult): {
193
193
  }
194
194
  }
195
195
 
196
+ /** The horizontal box of one preview piece in the timed grid's `piece-pool`
197
+ * layer, which spans every day column at once. `columnVar` holds the day
198
+ * index the gesture painted the piece over; `--sch-pool-columns` is the
199
+ * number of rendered days, written on the layer.
200
+ *
201
+ * Logical (`insetInlineStart`), so a column index lands on the same day in
202
+ * RTL as the grid's own placement does, with no sign math.
203
+ *
204
+ * The `min(col, 1) * 1px` terms step past the hairline every day column after
205
+ * the first draws at its start edge (`border-s`), so a piece covers exactly
206
+ * the column's padding box: the box its chips are laid out in, and the box
207
+ * the piece used to fill when it was mounted inside the column. */
208
+ export function poolPieceInsets(columnVar: string): { insetInlineStart: string; width: string } {
209
+ const col = `var(${columnVar}, 0)`
210
+ const hairline = `min(${col}, 1) * 1px`
211
+ return {
212
+ insetInlineStart: `calc(${col} * 100% / var(--sch-pool-columns, 1) + ${hairline})`,
213
+ width: `calc(100% / var(--sch-pool-columns, 1) - ${hairline})`,
214
+ }
215
+ }
216
+
196
217
  /**
197
218
  * Resolves a px-per-minute rate by measuring the day-column's *real*
198
219
  * rendered height (`getBoundingClientRect()`), divided by the window's total
@@ -1,5 +1,14 @@
1
1
  import { afterEach, describe, expect, it, vi } from "vitest"
2
- import { type ColumnBox, liveColumns, measureColumns } from "./schedule-grid-gesture"
2
+ import {
3
+ type ColumnBox,
4
+ type EdgeState,
5
+ liveColumns,
6
+ MAX_SCROLL_PX_PER_FRAME,
7
+ measureColumns,
8
+ PAGINATE_DWELL_MS,
9
+ stopEdgeBehaviours,
10
+ tickEdges,
11
+ } from "./schedule-grid-gesture"
3
12
 
4
13
  /**
5
14
  * `measureColumns` decides whether a gesture has a horizontal axis at all, and
@@ -151,3 +160,76 @@ describe("the rejection is no longer silent", () => {
151
160
  expect(warn.mock.calls[0]?.[0]).toMatch(/could not measure the day columns/)
152
161
  })
153
162
  })
163
+
164
+ /**
165
+ * Under `dir="rtl"` a scroller's `scrollLeft` runs from `0` at its right edge
166
+ * down to `-(scrollWidth - clientWidth)`, and the *left* edge leads to later
167
+ * days. jsdom has neither layout nor scrolling, so the grid's box and its
168
+ * `scrollLeft` are stubbed: the browser's own clamp is exactly what this
169
+ * function's frozen extent replaces, so a plain read/write field is faithful.
170
+ */
171
+ describe("tickEdges", () => {
172
+ const edgeState = (scrollLeft: number): EdgeState => {
173
+ const el = document.createElement("div")
174
+ let left = scrollLeft
175
+ Object.defineProperty(el, "scrollLeft", { get: () => left, set: (v: number) => (left = v) })
176
+ vi.spyOn(el, "getBoundingClientRect").mockReturnValue({
177
+ left: 0,
178
+ right: 1000,
179
+ width: 1000,
180
+ top: 0,
181
+ bottom: 500,
182
+ height: 500,
183
+ } as DOMRect)
184
+ return {
185
+ grid: el,
186
+ // Hard against the left edge, mid-height: full horizontal pressure only.
187
+ clientX: 0,
188
+ clientY: 250,
189
+ scrollRaf: null,
190
+ paginateTimer: null,
191
+ paginateDirection: null,
192
+ paginationOffset: 0,
193
+ columns: [],
194
+ maxScrollLeft: 300,
195
+ maxScrollTop: 0,
196
+ }
197
+ }
198
+
199
+ afterEach(() => vi.useRealTimers())
200
+
201
+ it("scrolls into a negative rtl scrollLeft instead of pinning it to 0", () => {
202
+ const state = edgeState(-100)
203
+ tickEdges(state, { dir: "rtl", paint: () => {}, isLive: () => true })
204
+ stopEdgeBehaviours(state)
205
+
206
+ expect(state.grid.scrollLeft).toBe(-100 - MAX_SCROLL_PX_PER_FRAME)
207
+ })
208
+
209
+ it.each([
210
+ ["ltr", 0, -1],
211
+ ["rtl", -300, 1],
212
+ ] as const)(
213
+ "pages %s at the left edge once it can't scroll further",
214
+ (dir, scrollLeft, expected) => {
215
+ vi.useFakeTimers()
216
+ const state = edgeState(scrollLeft)
217
+ const onPaginate = vi.fn()
218
+ let live = true
219
+ tickEdges(state, {
220
+ dir,
221
+ paint: () => {},
222
+ isLive: () => live,
223
+ onPaginate: (direction) => {
224
+ live = false
225
+ onPaginate(direction)
226
+ },
227
+ })
228
+ vi.advanceTimersByTime(PAGINATE_DWELL_MS)
229
+ stopEdgeBehaviours(state)
230
+
231
+ expect(onPaginate).toHaveBeenCalledExactlyOnceWith(expected)
232
+ expect(state.grid.scrollLeft).toBe(scrollLeft)
233
+ },
234
+ )
235
+ })