@cocoar/vue-ui 3.2.0-beta.11 → 3.2.0-beta.46

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 (31) hide show
  1. package/dist/components/button/CoarButton.vue.d.ts.map +1 -1
  2. package/dist/components/checkbox/CoarCheckbox.vue.d.ts.map +1 -1
  3. package/dist/components/date-time/plain-date-picker/CoarPlainDatePicker.vue.d.ts +6 -1
  4. package/dist/components/date-time/plain-date-picker/CoarPlainDatePicker.vue.d.ts.map +1 -1
  5. package/dist/components/date-time/plain-date-time-picker/CoarPlainDateTimePicker.vue.d.ts +6 -1
  6. package/dist/components/date-time/plain-date-time-picker/CoarPlainDateTimePicker.vue.d.ts.map +1 -1
  7. package/dist/components/date-time/zoned-date-time-picker/CoarZonedDateTimePicker.vue.d.ts +6 -1
  8. package/dist/components/date-time/zoned-date-time-picker/CoarZonedDateTimePicker.vue.d.ts.map +1 -1
  9. package/dist/components/input-frame/CoarInputFrame.vue.d.ts +3 -0
  10. package/dist/components/input-frame/CoarInputFrame.vue.d.ts.map +1 -1
  11. package/dist/components/number-input/CoarNumberInput.vue.d.ts.map +1 -1
  12. package/dist/components/password-input/CoarPasswordInput.vue.d.ts.map +1 -1
  13. package/dist/components/radio-group/CoarRadioButton.vue.d.ts.map +1 -1
  14. package/dist/components/switch/CoarSwitch.vue.d.ts.map +1 -1
  15. package/dist/components/text-input/CoarTextInput.vue.d.ts.map +1 -1
  16. package/dist/index.css +1 -1
  17. package/dist/index.js +17 -8
  18. package/package.json +2 -2
  19. package/skills/cocoar-vue-ui/SKILL.md +2 -0
  20. package/skills/cocoar-vue-ui/references/components/calendar/agenda-view.md +2 -2
  21. package/skills/cocoar-vue-ui/references/components/calendar/coar-calendar.md +24 -4
  22. package/skills/cocoar-vue-ui/references/components/calendar/day-view.md +158 -2
  23. package/skills/cocoar-vue-ui/references/components/calendar/index.md +1 -0
  24. package/skills/cocoar-vue-ui/references/components/calendar/month-view.md +4 -1
  25. package/skills/cocoar-vue-ui/references/components/calendar/time-selection.md +293 -0
  26. package/skills/cocoar-vue-ui/references/components/calendar/week-view.md +122 -0
  27. package/skills/cocoar-vue-ui/references/components/calendar/work-week-view.md +8 -0
  28. package/skills/cocoar-vue-ui/references/guide/getting-started.md +6 -0
  29. package/skills/cocoar-vue-ui/references/guide/mobile.md +123 -0
  30. package/styles/tokens/all.css +3 -0
  31. package/styles/tokens/mobile.css +17 -0
@@ -0,0 +1,293 @@
1
+ <!-- Generated from apps/docs/components/calendar/time-selection.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
2
+
3
+ # Selecting time, drafts & bands (Preview)
4
+
5
+ > **Warning: Preview — new in 3.2**
6
+ >
7
+ > Everything on this page is new in 3.2 and still a Preview: the API may change before it loses this mark. It already runs in production apps; feedback is welcome.
8
+
9
+ Four opt-in features for Week, Work week and Day, in both [orientations](./day-view.md#days-as-rows-horizontal-orientation). Together they let a booking or scheduling screen work directly on the calendar: pick a range, see what a click will pick, keep the range of an open form visible, and show the working-time rules of each day behind the events.
10
+
11
+ ```ts
12
+ const draft = ref<CalendarDraft | null>(null);
13
+
14
+ builder
15
+ .timeRangeSelect(true) // drag and click select ranges
16
+ .hoverIndicator(true) // time + line under the mouse
17
+ .selectionPolicy(gapOrDurationPolicy({ minutes: 60 })) // a click picks the gap, else 1 h
18
+ .onTimeRangeSelect(({ start, end }) => {
19
+ draft.value = { start, end }; // show it …
20
+ openBookingPanel(start, end); // … while the form is open
21
+ })
22
+ .draft(draft) // follows the form; null hides it
23
+ .backgrounds((date) => workRuleBands(date)); // core time, frame, limits
24
+ ```
25
+
26
+ **Demo — `calendar/demos/TimeSelectionWeek.vue`**
27
+
28
+ ```vue
29
+ <template>
30
+ <div style="display: flex; flex-direction: column; gap: 8px">
31
+ <div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap">
32
+ <CoarButton
33
+ size="s"
34
+ :variant="orientation === 'horizontal' ? 'primary' : 'secondary'"
35
+ @click="orientation = 'horizontal'"
36
+ >
37
+ Days as rows
38
+ </CoarButton>
39
+ <CoarButton
40
+ size="s"
41
+ :variant="orientation === 'vertical' ? 'primary' : 'secondary'"
42
+ @click="orientation = 'vertical'"
43
+ >
44
+ Days as columns
45
+ </CoarButton>
46
+ <CoarButton size="s" variant="secondary" :disabled="!draft" @click="draft = null">
47
+ Clear draft
48
+ </CoarButton>
49
+ <span style="font-size: 12px; color: var(--coar-text-neutral-secondary)">{{ last }}</span>
50
+ </div>
51
+ <div
52
+ style="
53
+ height: 420px;
54
+ border: 1px solid var(--coar-border-neutral-tertiary);
55
+ border-radius: var(--coar-radius-xs);
56
+ overflow: hidden;
57
+ "
58
+ >
59
+ <CoarWeekView :builder="builder" />
60
+ </div>
61
+ </div>
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import { ref } from 'vue';
66
+ import { CoarButton } from '@cocoar/vue-ui';
67
+ import {
68
+ CoarWeekView,
69
+ useWeekView,
70
+ gapOrDurationPolicy,
71
+ Temporal,
72
+ type CalendarBand,
73
+ type CalendarDraft,
74
+ type CalendarEvent,
75
+ type CalendarTimeGridOrientation,
76
+ } from '@cocoar/vue-calendar';
77
+
78
+ const zone = 'Europe/Vienna';
79
+ const at = (date: string, time: string) => Temporal.ZonedDateTime.from(`${date}T${time}[${zone}]`);
80
+ const hhmm = (z: Temporal.ZonedDateTime) => z.toPlainTime().toString().slice(0, 5);
81
+ const block = (id: string, date: string, from: string, to: string, title: string, color: string) =>
82
+ ({ id, start: at(date, from), end: at(date, to), meta: { title, color } }) as CalendarEvent;
83
+
84
+ const events = ref<CalendarEvent[]>([
85
+ block('mo-1', '2026-04-13', '07:30', '09:30', 'Development', '#93c5fd'),
86
+ block('mo-2', '2026-04-13', '09:30', '09:45', 'Daily', '#f59e0b'),
87
+ block('mo-3', '2026-04-13', '09:45', '12:00', 'Development', '#93c5fd'),
88
+ block('tu-1', '2026-04-14', '08:00', '09:30', 'Development', '#93c5fd'),
89
+ block('tu-2', '2026-04-14', '10:00', '12:00', 'Review', '#a78bfa'),
90
+ block('tu-3', '2026-04-14', '13:00', '15:00', 'Backlog', '#f87171'),
91
+ block('we-1', '2026-04-15', '08:30', '10:00', 'Meeting', '#38bdf8'),
92
+ ]);
93
+
94
+ const T = (s: string) => Temporal.PlainTime.from(s);
95
+ // Working-time rules as bands: core time (shorter on Friday), outside the frame, a limit.
96
+ function workRules(date: Temporal.PlainDate): CalendarBand[] {
97
+ if (date.dayOfWeek >= 6) {
98
+ return [{ kind: 'outside', start: T('06:00'), end: T('19:00'), appearance: 'hatch' }];
99
+ }
100
+ return [
101
+ { kind: 'outside', start: T('06:00'), end: T('07:00'), appearance: 'hatch' },
102
+ { kind: 'core', start: T('09:00'), end: date.dayOfWeek === 5 ? T('12:00') : T('15:00') },
103
+ { kind: 'max', at: T('17:30'), label: 'max. 10:30 h' },
104
+ ];
105
+ }
106
+
107
+ const orientation = ref<CalendarTimeGridOrientation>('horizontal');
108
+ const draft = ref<CalendarDraft | null>(null);
109
+ const last = ref('Drag on free space, click a gap, or hover to see what a click selects.');
110
+
111
+ const { builder } = useWeekView();
112
+ builder
113
+ .events(events)
114
+ .date(Temporal.PlainDate.from('2026-04-15'))
115
+ .timezone(zone)
116
+ .firstDayOfWeek(1)
117
+ .timeGridOrientation(orientation)
118
+ .timeRange({ startMinutes: 6 * 60, endMinutes: 19 * 60 })
119
+ .pixelsPerHour(80)
120
+ .slotDuration(15)
121
+ .timeRangeSelect(true)
122
+ .hoverIndicator(true)
123
+ .selectionPolicy(gapOrDurationPolicy({ minutes: 60 }))
124
+ .backgrounds(workRules)
125
+ .draft(draft)
126
+ .onTimeRangeSelect(({ date, start, end, source }) => {
127
+ last.value = `onTimeRangeSelect (${source}): ${date} ${hhmm(start)}–${hhmm(end)}`;
128
+ draft.value = { start, end };
129
+ });
130
+ </script>
131
+ ```
132
+
133
+ The calendar owns the interaction and the drawing; what a pointer position selects is decided by the **selection policy**, a plain function you can replace.
134
+
135
+ ## Selecting a time range
136
+
137
+ `builder.timeRangeSelect(true)` turns free space of the time grid into a selection surface. Events keep their own behaviour: a press on a card still clicks, moves or resizes it.
138
+
139
+ | Input | What happens |
140
+ |---|---|
141
+ | Mouse drag on free space | Past 4 px the press is a drag: the range from the press to the pointer is drawn in the day pressed and on the time axis (`12:00 ─ 2:15 h ─ 14:15`). Release calls `onTimeRangeSelect` with `source: 'drag'`. |
142
+ | Mouse click | `onTimeClick` on release, then `onTimeRangeSelect` with the policy's proposal (`source: 'click'`). |
143
+ | Escape during a drag | Cancels; no call. |
144
+ | Mouse hover | The proposal a click would select is drawn faintly (not over an event). |
145
+ | Touch tap | `onTimeClick`, then `onTimeRangeSelect` (`'click'`), after the tap's click — see [Touch](./coar-calendar.md#touch-taps-not-scroll-starts). |
146
+ | Touch long press (500 ms) | Starts a drag: the policy's proposal appears, moving the finger changes the range, lifting it reports it. Scrolling and swipe paging stay off until the finger lifts. |
147
+ | Touch swipe | Unchanged: scrolls (and pages the vertical grid). Moving before the long press fires never selects. |
148
+
149
+ The **day** of a selection is the day pressed: while dragging only the time axis follows the pointer, so drifting into the next row or column does not switch days. Days lie edge to edge, so hover always belongs to the nearest day and does not flicker between rows.
150
+
151
+ ```ts
152
+ interface TimeRangeSelectPayload {
153
+ date: Temporal.PlainDate; // the day, display zone
154
+ start: Temporal.ZonedDateTime; // display zone, snapped by the policy
155
+ end: Temporal.ZonedDateTime; // exclusive; next midnight for a range up to 24:00
156
+ source: 'click' | 'drag';
157
+ native: PointerEvent; // pointerup of a drag, pointerdown of a click
158
+ }
159
+ ```
160
+
161
+ `start` / `end` are ready to store as an event's endpoints. Wall times that fall into a spring-forward gap resolve by `builder.dstPolicy()`; with `'reject'` such a selection is not reported.
162
+
163
+ > **Info: onTimeClick with selection on**
164
+ >
165
+ > With `timeRangeSelect(true)` a mouse `onTimeClick` moves from the press to the release, because only the release tells a click from a drag. A drag fires no `onTimeClick`. Without `timeRangeSelect` nothing changes.
166
+
167
+ ## Selection policy
168
+
169
+ The policy maps a pointer position to a range in **minutes of the day** (wall time in the display zone, `0` = midnight, `1440` = the next midnight), or to `null` for nothing. It is asked on every hover move, on a click and on every drag move:
170
+
171
+ ```ts
172
+ type TimeSelectionPolicy = (ctx: TimeSelectionContext) => { start: number; end: number } | null;
173
+
174
+ interface TimeSelectionContext {
175
+ phase: 'hover' | 'click' | 'drag';
176
+ date: Temporal.PlainDate;
177
+ minute: number; // under the pointer, unsnapped
178
+ anchorMinute?: number; // 'drag': where the press started
179
+ slotDuration: number;
180
+ bounds: { start: number; end: number }; // the visible time range
181
+ busy: ReadonlyArray<{ start: number; end: number; event: CalendarEvent }>; // timed events of the day, sorted
182
+ }
183
+ ```
184
+
185
+ Two policies ship with the package:
186
+
187
+ | Policy | Hover / click | Drag |
188
+ |---|---|---|
189
+ | `defaultSelectionPolicy()` (used without `selectionPolicy`) | The slot under the pointer — the same slot `onTimeClick` reports. | Both ends snapped to the slot grid; events ignored. |
190
+ | `gapOrDurationPolicy({ minutes, overlap = false })` | Between two events the **whole gap**; otherwise `minutes` from the rounded time, at most up to the next event. A start less than one slot after an event joins it. On an event: nothing. | Snapped, limited to the free range around the press — a drag never runs over an event. |
191
+
192
+ With `overlap: true`, `gapOrDurationPolicy` ignores events (`minutes` from the rounded time, drags anywhere).
193
+
194
+ A policy of your own is a small function; the helpers below are exported from `@cocoar/vue-calendar`:
195
+
196
+ ```ts
197
+ import { gapOrDurationPolicy } from '@cocoar/vue-calendar';
198
+
199
+ // Book only inside opening hours (09–18), otherwise like gapOrDurationPolicy.
200
+ const open = { start: 9 * 60, end: 18 * 60 };
201
+ const booking = gapOrDurationPolicy({ minutes: 30 });
202
+ builder.selectionPolicy((ctx) => {
203
+ const at = ctx.anchorMinute ?? ctx.minute; // a drag starts inside opening hours …
204
+ if (at < open.start || at >= open.end) return null;
205
+ return booking({ ...ctx, bounds: open }); // … and its end is clamped to them
206
+ });
207
+ ```
208
+
209
+ | Helper | Purpose |
210
+ |---|---|
211
+ | `freeRangeAt(busy, minute, bounds?)` | The free range around `minute` between the neighbouring events, or `null` inside one. |
212
+ | `snapToSlot(minute, slot)` | `minute` rounded to the nearest slot boundary. |
213
+ | `busyMinutesOn(events, date, timezone)` | The timed events of a day as sorted minutes of that day — what the calendar hands the policy as `busy`. |
214
+ | `minuteOfDayToZoned(date, minute, timezone, dstPolicy?)` | A minute of the day as a `ZonedDateTime` (`1440` = next midnight); `null` in a DST gap with `'reject'`. |
215
+
216
+ The policy is read on every call (C7): read refs inside it, or bind a function that forwards to a computed policy.
217
+
218
+ ## Hover indicator
219
+
220
+ `builder.hoverIndicator(true)` shows, under a mouse or a hovering pen, the time at the pointer — snapped to `slotDuration` — on the time axis (hour column in the vertical grid, hour header in the horizontal one) and a thin line through all days at that time. Touch has no hover, so nothing is shown there. It works with or without `timeRangeSelect`.
221
+
222
+ ## Draft
223
+
224
+ `builder.draft(source)` draws a range that is not an event — typically the one in an open booking form — as an outlined block **above** the events of its day(s). An overlap with an existing event therefore stays visible before anything is saved. The block takes no pointer events and is not part of the event layout; a draft over midnight is drawn in both days, the cut ends dashed. While nothing is hovered or dragged, the time axis shows the draft's start, duration and end.
225
+
226
+ ```ts
227
+ const form = reactive({ start: '', end: '' });
228
+ builder.draft(() =>
229
+ form.start && form.end
230
+ ? { start: toZoned(form.date, form.start), end: toZoned(form.date, form.end) }
231
+ : null, // null hides it
232
+ );
233
+ ```
234
+
235
+ `<CoarCalendar>` (and the Day / Week / Work week views) take a `#draft` slot to draw it yourself. It is called once per day the draft covers:
236
+
237
+ ```vue
238
+ <CoarCalendar :builder="builder">
239
+ <template #draft="{ start, end, segment }">
240
+ <div class="my-draft">{{ fmt(start) }} – {{ fmt(end) }}</div>
241
+ </template>
242
+ </CoarCalendar>
243
+ ```
244
+
245
+ `segment` is `{ date, startMinutes, endMinutes, clippedStart, clippedEnd, start, end }`. With the slot the default frame is not drawn; the block keeps its position and size.
246
+
247
+ ## Background bands
248
+
249
+ `builder.backgrounds((date) => CalendarBand[])` paints ranges and lines per day — core hours, opening hours, shifts, a frame outside which hatching warns, a daily limit. It is called for every visible day on render; return `[]` or `null` for none.
250
+
251
+ ```ts
252
+ type CalendarBand =
253
+ | { kind: string; start: Temporal.PlainTime; end: Temporal.PlainTime;
254
+ appearance?: 'tint' | 'hatch' | 'outline'; // default 'tint'
255
+ layer?: 'below' | 'above'; // default 'below' (behind the events)
256
+ color?: string; label?: string }
257
+ | { kind: string; at: Temporal.PlainTime; color?: string; label?: string }; // a line
258
+ ```
259
+
260
+ - Times are wall time of that day in the display zone; `end` `00:00` means midnight at the end of the day. A range over midnight is two bands, one per day. Bands are clipped to the visible `timeRange`.
261
+ - `tint` fills, `hatch` stripes, `outline` frames with a dashed border. `layer: 'above'` lays a range over the events — use it with `outline` for hints such as "work outside the frame".
262
+ - Lines are drawn above the events with their `label` beside them ("max. 10:30 h"); a range's `label` sits in its leading corner.
263
+ - Bands never take pointer events: clicks, hover, selection and drags reach the day underneath.
264
+
265
+ **Styling.** Every band carries `coar-calendar-band coar-calendar-band--{kind}` plus `--{appearance}` (or `--line`). The colour comes from `color`, else from `--coar-calendar-band-color` — set it per kind in your own CSS — else from the appearance's token:
266
+
267
+ ```css
268
+ .coar-calendar-band--core { --coar-calendar-band-color: #16a34a; }
269
+ ```
270
+
271
+ | Token | Default (light) | Used by |
272
+ |---|---|---|
273
+ | `--coar-calendar-band-tint` | `#2563eb` (12 %) | `tint` |
274
+ | `--coar-calendar-band-hatch` | `#6b7280` (26 %) | `hatch` |
275
+ | `--coar-calendar-band-outline` | `#d97706` | `outline` |
276
+ | `--coar-calendar-band-line` | `#dc2626` | lines |
277
+ | `--coar-calendar-selection-color` | accent | selection preview |
278
+ | `--coar-calendar-draft-color` | accent | draft frame and its axis marks |
279
+
280
+ Dark mode lifts the four band tokens through the package's dark token sheet.
281
+
282
+ ## Builder reference
283
+
284
+ | Setter | Argument | Default | Notes |
285
+ |---|---|---|---|
286
+ | `timeRangeSelect(b)` | `MaybeRefOrGetter<boolean>` | `false` | Drag / click / long press select ranges. `timeRangeSelect()` = on. |
287
+ | `hoverIndicator(b)` | `MaybeRefOrGetter<boolean>` | `false` | Time and line under the mouse. `hoverIndicator()` = on. |
288
+ | `selectionPolicy(fn)` | `TimeSelectionPolicy<TMeta>` | `defaultSelectionPolicy()` | What hover, click and drag select. |
289
+ | `onTimeRangeSelect(fn)` | `(payload: TimeRangeSelectPayload) => void` | — | A range was selected. |
290
+ | `draft(source)` | `MaybeRefOrGetter<CalendarDraft \| null>` | `null` | `{ start, end }` as `ZonedDateTime`s. |
291
+ | `backgrounds(fn)` | `(date: PlainDate) => CalendarBand[] \| null` | — | Bands per visible day. |
292
+
293
+ Web only: the iOS and Android calendars create events with a long press of their own and have no policy, draft or bands.
@@ -144,6 +144,128 @@ builder
144
144
  </script>
145
145
  ```
146
146
 
147
+ ## Days as rows
148
+
149
+ > **Warning: Preview — new in 3.2**
150
+ >
151
+ > The horizontal orientation is new in 3.2 and still a Preview: the API may change before it loses this mark. It already runs in production apps; feedback is welcome.
152
+
153
+ `builder.timeGridOrientation('horizontal')` lays the week out with one row per day and time running left → right — for time tracking, shifts and attendance. Window, paging, hooks and drag & drop stay the same; see [Days as rows](./day-view.md#days-as-rows-horizontal-orientation) for the details.
154
+
155
+ **Demo — `calendar/demos/WeekViewRows.vue`**
156
+
157
+ ```vue
158
+ <template>
159
+ <div style="display: flex; flex-direction: column; gap: 8px">
160
+ <div style="display: flex; gap: 8px; align-items: center">
161
+ <CoarButton
162
+ size="s"
163
+ :variant="orientation === 'horizontal' ? 'primary' : 'secondary'"
164
+ @click="orientation = 'horizontal'"
165
+ >
166
+ Days as rows
167
+ </CoarButton>
168
+ <CoarButton
169
+ size="s"
170
+ :variant="orientation === 'vertical' ? 'primary' : 'secondary'"
171
+ @click="orientation = 'vertical'"
172
+ >
173
+ Days as columns
174
+ </CoarButton>
175
+ <span style="font-size: 12px; color: var(--coar-text-neutral-secondary)">{{ last }}</span>
176
+ </div>
177
+ <div
178
+ style="
179
+ height: 420px;
180
+ border: 1px solid var(--coar-border-neutral-tertiary);
181
+ border-radius: var(--coar-radius-xs);
182
+ overflow: hidden;
183
+ "
184
+ >
185
+ <CoarWeekView :builder="builder" />
186
+ </div>
187
+ </div>
188
+ </template>
189
+
190
+ <script setup lang="ts">
191
+ import { ref } from 'vue';
192
+ import { CoarButton } from '@cocoar/vue-ui';
193
+ import {
194
+ CoarWeekView,
195
+ useWeekView,
196
+ Temporal,
197
+ type CalendarEvent,
198
+ type CalendarTimeGridOrientation,
199
+ } from '@cocoar/vue-calendar';
200
+
201
+ const zone = 'Europe/Vienna';
202
+ const at = (date: string, time: string) => Temporal.ZonedDateTime.from(`${date}T${time}[${zone}]`);
203
+ const block = (
204
+ id: string,
205
+ date: string,
206
+ from: string,
207
+ to: string,
208
+ title: string,
209
+ color: string,
210
+ ): CalendarEvent => ({
211
+ id,
212
+ start: at(date, from),
213
+ end: at(date, to),
214
+ meta: { title, color },
215
+ });
216
+
217
+ // A time-tracking week: start, end and gaps of every day at a glance.
218
+ const events = ref<CalendarEvent[]>([
219
+ block('mo-1', '2026-04-13', '07:30', '09:30', 'Development', '#93c5fd'),
220
+ block('mo-2', '2026-04-13', '09:30', '09:45', 'Daily', '#f59e0b'),
221
+ block('mo-3', '2026-04-13', '09:45', '12:00', 'Development', '#93c5fd'),
222
+ block('mo-4', '2026-04-13', '12:30', '16:00', 'Learning', '#10b981'),
223
+ block('tu-1', '2026-04-14', '08:00', '09:30', 'Development', '#93c5fd'),
224
+ block('tu-2', '2026-04-14', '09:30', '09:45', 'Daily', '#f59e0b'),
225
+ block('tu-3', '2026-04-14', '09:45', '12:00', 'Development', '#93c5fd'),
226
+ block('tu-4', '2026-04-14', '10:30', '11:30', 'Review', '#a78bfa'),
227
+ block('tu-5', '2026-04-14', '13:00', '17:00', 'Backlog', '#f87171'),
228
+ block('we-1', '2026-04-15', '08:30', '10:00', 'Meeting', '#38bdf8'),
229
+ block('we-2', '2026-04-15', '10:30', '15:30', 'Development', '#93c5fd'),
230
+ block('th-1', '2026-04-16', '07:00', '12:00', 'Support', '#fbbf24'),
231
+ block('fr-1', '2026-04-17', '08:00', '12:30', 'Development', '#93c5fd'),
232
+ {
233
+ id: 'sat-off',
234
+ start: Temporal.PlainDate.from('2026-04-18'),
235
+ end: Temporal.PlainDate.from('2026-04-20'),
236
+ meta: { title: 'Weekend trip', color: '#ec4899' },
237
+ },
238
+ ]);
239
+
240
+ const orientation = ref<CalendarTimeGridOrientation>('horizontal');
241
+ const last = ref('Drag a block onto another day, or its right edge to make it longer.');
242
+
243
+ const { builder } = useWeekView();
244
+ builder
245
+ .events(events)
246
+ .date(Temporal.PlainDate.from('2026-04-15'))
247
+ .timezone(zone)
248
+ .firstDayOfWeek(1)
249
+ .timeGridOrientation(orientation)
250
+ .timeRange({ startMinutes: 6 * 60, endMinutes: 19 * 60 })
251
+ .pixelsPerHour(80)
252
+ .slotDuration(15)
253
+ .onTimeClick(({ date, time }) => {
254
+ last.value = `onTimeClick: ${date} ${time.toString().slice(0, 5)}`;
255
+ })
256
+ .onEventDrop(({ event, next, target }) => {
257
+ last.value = `onEventDrop: ${(event.meta as { title?: string }).title} → ${target.date}`;
258
+ const idx = events.value.findIndex((e) => e.id === event.id);
259
+ if (idx < 0) return;
260
+ events.value = [
261
+ ...events.value.slice(0, idx),
262
+ { ...event, start: next.start, ...(next.end ? { end: next.end } : {}) },
263
+ ...events.value.slice(idx + 1),
264
+ ];
265
+ });
266
+ </script>
267
+ ```
268
+
147
269
  ## Custom day header
148
270
 
149
271
  The `#dayHeader` slot replaces the default per-column header. Receives `{ date, isToday, isWeekend }` so you can render whatever fits your design — the example below stacks day-of-week + day-of-month with a today indicator and weekend muting.
@@ -43,6 +43,14 @@ builder
43
43
  <CoarWorkWeekView :builder="builder" />
44
44
  ```
45
45
 
46
+ ## Days as rows
47
+
48
+ > **Warning: Preview — new in 3.2**
49
+ >
50
+ > The horizontal orientation is new in 3.2 and still a Preview: the API may change before it loses this mark. It already runs in production apps; feedback is welcome.
51
+
52
+ `builder.timeGridOrientation('horizontal')` shows the working days as rows on a horizontal time axis instead of columns — same window, paging, hooks and drag & drop. See [Days as rows](./day-view.md#days-as-rows-horizontal-orientation).
53
+
46
54
  ## Working-day conventions
47
55
 
48
56
  `workDays(d)` accepts any subset of `0..6` (`0` = Sunday, `6` = Saturday). The order in the array doesn't matter — internally it's used as a Set. The rendered columns appear in calendar order, anchored to `firstDayOfWeek`.
@@ -46,6 +46,12 @@ Toggle dark mode by adding the `.dark-mode` class to the root element. All desig
46
46
  document.documentElement.classList.toggle('dark-mode', isDark);
47
47
  ```
48
48
 
49
+ ## Mobile Presentation
50
+
51
+ Add `coar-mobile` to `body` or a local parent for touch-sized buttons and standard
52
+ inputs. The existing component APIs stay unchanged. See [Mobile presentation](./mobile.md)
53
+ for the supported controls, sizing floors, and overlay scope limitations.
54
+
49
55
  ## 5. Overlay System
50
56
 
51
57
  For components that render overlays (Dialog, Toast, Popover, Tooltip), register the plugin once:
@@ -0,0 +1,123 @@
1
+ <!-- Generated from apps/docs/guide/mobile.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
2
+
3
+ # Mobile presentation (Preview)
4
+
5
+ > **Warning: Preview — new in 3.2**
6
+ >
7
+ > The mobile presentation is new in 3.2 and still a Preview: token names and the
8
+ > set of adapted controls may change before it loses this mark.
9
+
10
+ Add `coar-mobile` to `html`, `body`, or a local parent to opt into a mobile
11
+ presentation. Import the normal `@cocoar/vue-ui/styles` stylesheet; no extra
12
+ plugin, component props, or mobile-specific components are required.
13
+
14
+ ```vue
15
+ <script setup lang="ts">
16
+ import { ref } from 'vue';
17
+ import { CoarButton, CoarFormField, CoarTextInput } from '@cocoar/vue-ui';
18
+
19
+ const name = ref('');
20
+ </script>
21
+
22
+ <template>
23
+ <div class="coar-mobile">
24
+ <CoarFormField label="Name">
25
+ <CoarTextInput v-model="name" clearable />
26
+ </CoarFormField>
27
+ <CoarButton>Save</CoarButton>
28
+ </div>
29
+ </template>
30
+ ```
31
+
32
+ For an entire iOS/Android app or a deliberately mobile web interface:
33
+
34
+ ```ts
35
+ document.body.classList.add('coar-mobile');
36
+ ```
37
+
38
+ The class is an explicit **presentation preference**, not a claim that a mouse or
39
+ keyboard is unavailable. Existing click events, keyboard handling, `v-model`,
40
+ validation, disabled/readonly states, and link-button semantics stay unchanged.
41
+ Connecting a mouse does not switch the presentation. Narrowing the viewport does
42
+ not automatically enable this mode either.
43
+
44
+ ## Supported controls
45
+
46
+ This is the first mobile-controls increment, not a mobile redesign of the entire
47
+ library.
48
+
49
+ | Component | Mobile presentation |
50
+ |-----------|---------------------|
51
+ | `CoarButton` | Size-dependent mobile heights (below), at least 44px width and 16px text; includes icon-only, loading, and link buttons |
52
+ | `CoarTextInput` | The same mobile height scale and at least 16px editable text, including multiline textareas |
53
+ | `CoarPasswordInput` | The same field floors, plus 44×44px clear/reveal targets |
54
+ | `CoarNumberInput` | The same field floors, plus 44×44px clear and stepper targets |
55
+ | `CoarCheckbox` | At least 48×48px clickable label, without enlarging the indicator |
56
+ | `CoarRadioButton` / `CoarRadioGroup` | At least 48×48px clickable option labels, without enlarging the indicators |
57
+ | `CoarSwitch` | At least 48×48px clickable label, without enlarging the track |
58
+
59
+ Text-input clear buttons also receive 44×44px targets. Clear buttons remain fully
60
+ opaque without hover or focus when a value can be cleared; empty fields retain
61
+ their hidden action slot to avoid layout jumps.
62
+
63
+ The existing `size` prop selects a different height scale in mobile mode instead
64
+ of collapsing every size to one minimum:
65
+
66
+ | Size | Desktop token height | Mobile height |
67
+ |------|----------------------|---------------|
68
+ | `xs` | 27px | 44px |
69
+ | `s` | 32px | 48px |
70
+ | `m` | 40px | 52px |
71
+ | `l` | 48px | 56px |
72
+
73
+ This scale applies to buttons and single-line text/password/number fields;
74
+ textareas can grow taller. Larger custom component heights are preserved.
75
+ The mobile input border is painted without taking layout space, so even an `xs`
76
+ field can contain 44px actions under a global `box-sizing: border-box` reset.
77
+ Rounded fields still have intentionally rounded hit regions.
78
+
79
+ A 16px editable font is intended to avoid the usual small-input focus zoom
80
+ on iOS, but actual keyboard and zoom behavior still requires device testing.
81
+
82
+ ## Scope and themes
83
+
84
+ The mode inherits through ordinary DOM descendants, including `CoarThemeScope`.
85
+ It is independent of light/dark mode. Removing the class restores normal sizing
86
+ without remounting the controls or resetting their values. Desktop siblings
87
+ outside a local mobile parent are unaffected.
88
+
89
+ **Portaled content is not automatically part of a local mobile scope.** Overlays
90
+ teleported to `body` leave that parent's DOM subtree. Use `coar-mobile` on `body`
91
+ or `html` when supported controls inside overlays should also use the mode.
92
+ This increment does not add a mobile-context bridge for local overlays.
93
+
94
+ Date/time pickers, select panels, dialogs, OTP inputs, grids, and editors do not
95
+ have dedicated mobile presentations in this increment. In particular,
96
+ `CoarZonedDateTimePicker` does not yet switch to a sheet or a stepped mobile flow.
97
+ The class is the entry point for those future presentations, not a promise that
98
+ all components are already adapted.
99
+
100
+ ## Customizing the floors
101
+
102
+ The mode sets inherited control tokens rather than changing the library's shared
103
+ desktop size tokens. Applications can override them locally:
104
+
105
+ ```css
106
+ .my-mobile-form.coar-mobile {
107
+ --coar-control-xs-height: 48px;
108
+ --coar-control-s-height: 52px;
109
+ --coar-control-m-height: 56px;
110
+ --coar-control-l-height: 60px;
111
+ --coar-control-min-font-size: 18px;
112
+ --coar-control-min-target-size: 48px;
113
+ }
114
+ ```
115
+
116
+ `--coar-control-min-size` separately controls the minimum clickable label size
117
+ for checkboxes, radios, and switches (48px by default).
118
+
119
+ Leave enough horizontal room for the field and its actions, especially for
120
+ password fields with both clear/reveal buttons and number fields with steppers.
121
+
122
+ The playground's `/mobile-controls` page demonstrates every size, local scope
123
+ switching, nested themes, textarea behavior, and non-editable states.
@@ -40,3 +40,6 @@
40
40
  @import './select-overlay.css';
41
41
  @import './tooltip.css';
42
42
  @import './new-components.css';
43
+
44
+ /* 8. Optional mobile presentation (inherited from .coar-mobile) */
45
+ @import './mobile.css';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Explicit mobile presentation. Apply to html, body or a local parent.
3
+ * These inherited floors are consumed by supported controls only; desktop size
4
+ * tokens and input methods remain unchanged. No viewport/device detection.
5
+ */
6
+ .coar-mobile {
7
+ --coar-control-xs-height: 44px;
8
+ --coar-control-s-height: 48px;
9
+ --coar-control-m-height: 52px;
10
+ --coar-control-l-height: 56px;
11
+ /* Label-based controls keep a generous target without enlarging indicators. */
12
+ --coar-control-min-size: 48px;
13
+ --coar-control-min-font-size: 16px;
14
+ --coar-control-min-target-size: 44px;
15
+ --coar-control-clear-opacity: 1;
16
+ --coar-control-align-items: center;
17
+ }