@remit/ui 0.0.195 → 0.0.197
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.
- package/package.json +1 -1
- package/src/components/calendar-grid.stories.tsx +10 -0
- package/src/components/calendar-grid.tsx +4 -3
- package/src/components/calendar-toolbar.tsx +1 -1
- package/src/components/event-editor.render.test.ts +24 -1
- package/src/components/event-editor.stories.tsx +23 -0
- package/src/components/event-editor.tsx +10 -0
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -141,6 +141,16 @@ export const Overlapping: Story = {
|
|
|
141
141
|
},
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
/** An early flight and a late call: the day runs midnight to midnight. */
|
|
145
|
+
export const OutsideWorkingHours: Story = {
|
|
146
|
+
args: {
|
|
147
|
+
events: [
|
|
148
|
+
at("flight", "Flight to Lisbon", "09", "06:00", "07:00"),
|
|
149
|
+
at("late-call", "Call with Sydney", "11", "23:15", "23:45"),
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
144
154
|
export const AllDayBand: Story = {
|
|
145
155
|
args: { events: week.filter((event) => event.allDay) },
|
|
146
156
|
};
|
|
@@ -227,7 +227,10 @@ export function CalendarGrid({
|
|
|
227
227
|
const isTight = density === "compact";
|
|
228
228
|
|
|
229
229
|
return (
|
|
230
|
-
<div
|
|
230
|
+
<div
|
|
231
|
+
data-testid="calendar-grid"
|
|
232
|
+
className={cn("h-full min-h-0 w-full text-fg", className)}
|
|
233
|
+
>
|
|
231
234
|
<FullCalendar
|
|
232
235
|
ref={calendarRef}
|
|
233
236
|
plugins={PLUGINS}
|
|
@@ -251,8 +254,6 @@ export function CalendarGrid({
|
|
|
251
254
|
eventMaxStack={3}
|
|
252
255
|
moreLinkClick="popover"
|
|
253
256
|
moreLinkText={(num) => `+${num}`}
|
|
254
|
-
slotMinTime="07:00:00"
|
|
255
|
-
slotMaxTime="23:00:00"
|
|
256
257
|
scrollTime="08:30:00"
|
|
257
258
|
scrollTimeReset={false}
|
|
258
259
|
slotDuration={{ minutes: slot.slotMinutes }}
|
|
@@ -4,7 +4,7 @@ import { describe, it } from "node:test";
|
|
|
4
4
|
import { createElement } from "react";
|
|
5
5
|
import { renderToString } from "react-dom/server";
|
|
6
6
|
import type { CalendarDescriptor, EventDraft } from "./calendar-types.js";
|
|
7
|
-
import { EventEditor } from "./event-editor.js";
|
|
7
|
+
import { EventEditor, withAllDay } from "./event-editor.js";
|
|
8
8
|
|
|
9
9
|
const calendars: CalendarDescriptor[] = [
|
|
10
10
|
{
|
|
@@ -170,4 +170,27 @@ describe("EventEditor", () => {
|
|
|
170
170
|
assert.equal(alertText(dom), "");
|
|
171
171
|
assert.equal(saveControl(dom)?.disabled, false);
|
|
172
172
|
});
|
|
173
|
+
|
|
174
|
+
it("restores the overnight end when all day is ticked then unticked", () => {
|
|
175
|
+
const overnight: EventDraft = {
|
|
176
|
+
...draft,
|
|
177
|
+
startTime: "22:00",
|
|
178
|
+
endDate: "2026-06-13",
|
|
179
|
+
endTime: "01:00",
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const ticked = withAllDay(overnight, true);
|
|
183
|
+
assert.equal(ticked.allDay, true);
|
|
184
|
+
assert.equal(ticked.endDate, overnight.date);
|
|
185
|
+
|
|
186
|
+
const unticked = withAllDay(ticked, false);
|
|
187
|
+
assert.equal(unticked.allDay, false);
|
|
188
|
+
assert.equal(unticked.endDate, overnight.endDate);
|
|
189
|
+
assert.equal(unticked.startTime, overnight.startTime);
|
|
190
|
+
assert.equal(unticked.endTime, overnight.endTime);
|
|
191
|
+
|
|
192
|
+
const dom = parse({ draft: unticked });
|
|
193
|
+
assert.equal(alertText(dom), "");
|
|
194
|
+
assert.equal(saveControl(dom)?.disabled, false);
|
|
195
|
+
});
|
|
173
196
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { expect, userEvent, within } from "storybook/test";
|
|
3
4
|
import type { CalendarDescriptor, EventDraft } from "./calendar-types.js";
|
|
4
5
|
import { EventEditor } from "./event-editor.js";
|
|
5
6
|
|
|
@@ -157,6 +158,28 @@ export const AllDay: Story = {
|
|
|
157
158
|
),
|
|
158
159
|
};
|
|
159
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Ticking All day on a night, then unticking it, gives the night back rather
|
|
163
|
+
* than collapsing the end onto the start day.
|
|
164
|
+
*/
|
|
165
|
+
export const AllDayRoundTrip: Story = {
|
|
166
|
+
render: () => <Live startExpanded={false} seed={overnight} />,
|
|
167
|
+
play: async ({ canvasElement }) => {
|
|
168
|
+
const canvas = within(canvasElement);
|
|
169
|
+
const allDay = canvas.getByLabelText("All day");
|
|
170
|
+
|
|
171
|
+
await userEvent.click(allDay);
|
|
172
|
+
await expect(canvas.getByLabelText("End date")).toHaveValue("2026-06-12");
|
|
173
|
+
|
|
174
|
+
await userEvent.click(allDay);
|
|
175
|
+
await expect(canvas.getByLabelText("End date")).toHaveValue("2026-06-13");
|
|
176
|
+
await expect(canvas.getByLabelText("End time")).toHaveValue("01:00");
|
|
177
|
+
await expect(
|
|
178
|
+
canvas.queryByText(/Ends before it starts/),
|
|
179
|
+
).not.toBeInTheDocument();
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
160
183
|
/** The same form sized for a bottom sheet: every control a thumb target. */
|
|
161
184
|
export const Touch: Story = {
|
|
162
185
|
render: () => {
|
|
@@ -106,6 +106,16 @@ export function withAllDay(draft: EventDraft, allDay: boolean): EventDraft {
|
|
|
106
106
|
draft.endTime !== "" &&
|
|
107
107
|
draft.endTime < draft.startTime;
|
|
108
108
|
if (allDay && overnight) return { ...draft, allDay, endDate: draft.date };
|
|
109
|
+
const collapsedOvernight =
|
|
110
|
+
!allDay &&
|
|
111
|
+
draft.date !== "" &&
|
|
112
|
+
draft.endDate === draft.date &&
|
|
113
|
+
draft.startTime !== "" &&
|
|
114
|
+
draft.endTime !== "" &&
|
|
115
|
+
draft.endTime < draft.startTime;
|
|
116
|
+
if (collapsedOvernight) {
|
|
117
|
+
return { ...draft, allDay, endDate: addDays(draft.date, 1) };
|
|
118
|
+
}
|
|
109
119
|
return { ...draft, allDay };
|
|
110
120
|
}
|
|
111
121
|
|
package/src/index.ts
CHANGED