|
| 1 | +import type { Meta, StoryObj } from "@storybook/react-webpack5"; |
| 2 | +import dxScheduler from "devextreme/ui/scheduler"; |
| 3 | +import { wrapDxWithReact } from "../utils"; |
| 4 | +import { resources } from "./data"; |
| 5 | + |
| 6 | +const Scheduler = wrapDxWithReact(dxScheduler); |
| 7 | + |
| 8 | +const data = [ |
| 9 | + { |
| 10 | + text: '1 minute', |
| 11 | + roomId: 1, |
| 12 | + assigneeId: [1], |
| 13 | + priorityId: 1, |
| 14 | + startDate: new Date(2026, 2, 15, 10, 0), |
| 15 | + endDate: new Date(2026, 2, 15, 10, 1) |
| 16 | + }, |
| 17 | + { |
| 18 | + text: '5 minutes', |
| 19 | + roomId: 1, |
| 20 | + assigneeId: [2], |
| 21 | + priorityId: 1, |
| 22 | + startDate: new Date(2026, 2, 16, 10, 0), |
| 23 | + endDate: new Date(2026, 2, 16, 10, 5) |
| 24 | + }, |
| 25 | + { |
| 26 | + text: '15 minutes', |
| 27 | + roomId: 2, |
| 28 | + assigneeId: [3], |
| 29 | + priorityId: 2, |
| 30 | + startDate: new Date(2026, 2, 17, 10, 0), |
| 31 | + endDate: new Date(2026, 2, 17, 10, 15) |
| 32 | + }, |
| 33 | + { |
| 34 | + text: '30 minutes', |
| 35 | + roomId: 2, |
| 36 | + assigneeId: [1], |
| 37 | + priorityId: 2, |
| 38 | + startDate: new Date(2026, 2, 18, 10, 0), |
| 39 | + endDate: new Date(2026, 2, 18, 10, 30) |
| 40 | + }, |
| 41 | + { |
| 42 | + text: '46 minutes', |
| 43 | + roomId: 3, |
| 44 | + assigneeId: [2], |
| 45 | + priorityId: 1, |
| 46 | + startDate: new Date(2026, 2, 19, 10, 0), |
| 47 | + endDate: new Date(2026, 2, 19, 10, 46) |
| 48 | + }, |
| 49 | + { |
| 50 | + text: '1 hour', |
| 51 | + roomId: 2, |
| 52 | + assigneeId: [4], |
| 53 | + priorityId: 1, |
| 54 | + startDate: new Date(2026, 2, 20, 10, 0), |
| 55 | + endDate: new Date(2026, 2, 20, 11, 0) |
| 56 | + }, |
| 57 | +]; |
| 58 | + |
| 59 | +const viewNames = ['day', 'week', 'workWeek', 'month', 'agenda', 'timelineDay', 'timelineWeek', 'timelineWorkWeek', 'timelineMonth']; |
| 60 | + |
| 61 | +const meta: Meta<typeof Scheduler> = { |
| 62 | + title: 'Components/Scheduler/SnapToCellsMode', |
| 63 | + component: Scheduler, |
| 64 | + parameters: { layout: 'padded' }, |
| 65 | +}; |
| 66 | +export default meta; |
| 67 | + |
| 68 | +type Story = StoryObj<typeof Scheduler>; |
| 69 | + |
| 70 | +export const Overview: Story = { |
| 71 | + args: { |
| 72 | + height: 600, |
| 73 | + views: viewNames, |
| 74 | + currentView: 'week', |
| 75 | + currentDate: new Date(2026, 2, 15), |
| 76 | + startDayHour: 9, |
| 77 | + endDayHour: 22, |
| 78 | + dataSource: data, |
| 79 | + resources, |
| 80 | + snapToCellsMode: 'auto', |
| 81 | + }, |
| 82 | + argTypes: { |
| 83 | + height: { control: 'number' }, |
| 84 | + views: { control: 'object' }, |
| 85 | + snapToCellsMode: { control: 'select', options: ['always', 'auto', 'never'] }, |
| 86 | + currentView: { control: 'select', options: viewNames }, |
| 87 | + }, |
| 88 | +}; |
| 89 | + |
| 90 | +export const PerViewOverrides: Story = { |
| 91 | + args: { |
| 92 | + height: 600, |
| 93 | + views: viewNames, |
| 94 | + currentView: 'timelineMonth', |
| 95 | + currentDate: new Date(2026, 2, 15), |
| 96 | + startDayHour: 9, |
| 97 | + endDayHour: 22, |
| 98 | + dataSource: data, |
| 99 | + resources, |
| 100 | + snapToCellsMode: 'never', |
| 101 | + }, |
| 102 | + argTypes: { |
| 103 | + height: { control: 'number' }, |
| 104 | + views: { control: 'object' }, |
| 105 | + snapToCellsMode: { control: 'select', options: ['always', 'auto', 'never'] }, |
| 106 | + currentView: { control: 'select', options: viewNames }, |
| 107 | + }, |
| 108 | +}; |
0 commit comments