11import type { Meta , StoryObj } from "@storybook/react" ;
22import React from "react" ;
33import dxScheduler from "devextreme/ui/scheduler" ;
4- import type { dxSchedulerOptions } from "devextreme/ui/scheduler" ;
4+ import type { Properties } from "devextreme/ui/scheduler" ;
55import { wrapDxWithReact } from "../utils" ;
66import { data , resources } from "./data" ;
77import "./form-customization.css" ;
88
9- const Scheduler = wrapDxWithReact < dxSchedulerOptions > ( dxScheduler ) ;
9+ const Scheduler = wrapDxWithReact < Properties > ( dxScheduler ) ;
10+
11+ const iconsShowModeArgType = {
12+ "editing.form.iconsShowMode" : {
13+ control : "radio" ,
14+ options : [ "both" , "main" , "recurrence" , "none" ] ,
15+ } ,
16+ } as Record < string , unknown > ;
1017
1118const meta : Meta < typeof Scheduler > = {
1219 title : "Components/Scheduler/Form Customization" ,
@@ -24,19 +31,21 @@ const baseConfig = {
2431 height : 600 ,
2532 views : [ "day" , "week" , "workWeek" , "month" ] ,
2633 currentView : "week" ,
27- startHour : 9 ,
34+ startDayHour : 9 ,
2835 currentDate : new Date ( 2021 , 3 , 29 ) ,
2936 dataSource : data ,
30- } ;
37+ "editing.form.iconsShowMode" : "main" ,
38+ } as Properties ;
3139
3240export const DefaultForm : Story = {
3341 args : {
3442 ...baseConfig ,
3543 resources,
36- } as dxSchedulerOptions ,
44+ } ,
45+ argTypes : iconsShowModeArgType ,
3746} ;
3847
39- interface ShowOnlySpecificItemsArgs extends dxSchedulerOptions {
48+ interface ShowOnlySpecificItemsArgs extends Properties {
4049 showSubjectGroup ?: boolean ;
4150 showDateGroup ?: boolean ;
4251 showDescriptionGroup ?: boolean ;
@@ -70,6 +79,7 @@ export const ShowOnlySpecificItems: Story = {
7079 showResourcesGroup : {
7180 control : "boolean" ,
7281 } ,
82+ ...iconsShowModeArgType ,
7383 } as Record < string , unknown > ,
7484 render : ( args : ShowOnlySpecificItemsArgs ) => {
7585 const items : unknown [ ] = [ ] ;
@@ -81,17 +91,22 @@ export const ShowOnlySpecificItems: Story = {
8191
8292 return (
8393 < Scheduler
84- { ...( baseConfig as dxSchedulerOptions ) }
94+ { ...baseConfig }
8595 resources = { resources }
86- editing = { { form : { items } } as dxSchedulerOptions [ 'editing' ] }
96+ editing = { {
97+ form : {
98+ items,
99+ iconsShowMode : args [ "editing.form.iconsShowMode" ]
100+ }
101+ } as Properties [ 'editing' ] }
87102 />
88103 ) ;
89104 } ,
90105} ;
91106
92107const positions = [ 1 , 2 , 3 , 4 , 5 ] ;
93108
94- interface ReorderItemsArgs extends dxSchedulerOptions {
109+ interface ReorderItemsArgs extends Properties {
95110 subjectGroupPosition : number ;
96111 dateGroupPosition : number ;
97112 descriptionGroupPosition : number ;
@@ -130,6 +145,7 @@ export const ReorderItems: Story = {
130145 control : { type : "select" } ,
131146 options : positions ,
132147 } ,
148+ ...iconsShowModeArgType ,
133149 } as Record < string , unknown > ,
134150 render : ( args : ReorderItemsArgs ) => {
135151 const groups = [
@@ -145,9 +161,14 @@ export const ReorderItems: Story = {
145161
146162 return (
147163 < Scheduler
148- { ...( baseConfig as dxSchedulerOptions ) }
164+ { ...baseConfig }
149165 resources = { resources }
150- editing = { { form : { items } } as dxSchedulerOptions [ 'editing' ] }
166+ editing = { {
167+ form : {
168+ items,
169+ iconsShowMode : args [ "editing.form.iconsShowMode" ]
170+ }
171+ } as Properties [ 'editing' ] }
151172 />
152173 ) ;
153174 } ,
@@ -157,116 +178,177 @@ export const AddCustomItems: Story = {
157178 args : {
158179 ...baseConfig ,
159180 resources,
160- "editing.form.items" : [
161- "subjectGroup" ,
162- "dateGroup" ,
163- {
164- name : "likeGroup" ,
165- itemType : "group" ,
166- caption : "Feedback" ,
167- items : [
168- {
169- name : "commentIcon" ,
170- template : ( ) => {
171- const element = document . createElement ( "div" ) ;
172- element . classList . add ( "dx-icon" , "dx-icon-comment" ) ;
173- return element ;
174- } ,
175- } ,
176- {
177- itemType : "simple" ,
178- editorType : "dxTextArea" ,
179- name : "comments" ,
180- editorOptions : {
181- placeholder : "Your comments..." ,
182- height : 100
183- }
184- } ,
185- {
186- name : "likeButton" ,
187- itemType : "button" ,
188- buttonOptions : {
189- icon : "like" ,
190- type : "success" ,
191- text : "Like" ,
192- onClick : ( ) => {
193- alert ( "You liked this appointment!" ) ;
181+ } ,
182+ argTypes : iconsShowModeArgType ,
183+ render : ( args ) => {
184+ return (
185+ < Scheduler
186+ { ...baseConfig }
187+ resources = { resources }
188+ editing = { {
189+ form : {
190+ items : [
191+ "subjectGroup" ,
192+ "dateGroup" ,
193+ {
194+ name : "likeGroup" ,
195+ itemType : "group" ,
196+ caption : "Feedback" ,
197+ items : [
198+ {
199+ name : "commentIcon" ,
200+ template : ( ) => {
201+ const element = document . createElement ( "div" ) ;
202+ element . classList . add ( "dx-icon" , "dx-icon-comment" ) ;
203+ return element ;
204+ } ,
205+ } ,
206+ {
207+ itemType : "simple" ,
208+ editorType : "dxTextArea" ,
209+ name : "comments" ,
210+ editorOptions : {
211+ placeholder : "Your comments..." ,
212+ height : 100
213+ }
214+ } ,
215+ {
216+ name : "likeButton" ,
217+ itemType : "button" ,
218+ buttonOptions : {
219+ icon : "like" ,
220+ type : "success" ,
221+ text : "Like" ,
222+ onClick : ( ) => {
223+ alert ( "You liked this appointment!" ) ;
224+ } ,
225+ } ,
226+ } ,
227+ ] ,
194228 } ,
195- } ,
196- } ,
197- ] ,
198- } ,
199- ] ,
200- } as Record < string , unknown > ,
229+ ] ,
230+ iconsShowMode : args [ "editing.form.iconsShowMode" ]
231+ }
232+ } as Properties [ 'editing' ] }
233+ />
234+ ) ;
235+ } ,
201236} ;
202237
203238export const CustomizeExistingItems : Story = {
204239 args : {
205240 ...baseConfig ,
206241 resources,
207- "editing.form.items" : [
208- {
209- name : "subjectGroup" ,
210- items : [
211- {
212- name : "subjectIcon" ,
213- itemType : "button" ,
214- buttonOptions : {
215- elementAttr : { id : 'customize-subjectIcon' , class : "scheduler-form-custom-icon-button" } ,
216- icon : "floppy" ,
217- stylingMode : "text" ,
218- onClick : ( ) => {
219- alert ( "Subject icon clicked!" ) ;
242+ } ,
243+ argTypes : iconsShowModeArgType ,
244+ render : ( args ) => {
245+ return (
246+ < Scheduler
247+ { ...baseConfig }
248+ resources = { resources }
249+ editing = { {
250+ form : {
251+ items : [
252+ {
253+ name : "subjectGroup" ,
254+ items : [
255+ {
256+ name : "subjectIcon" ,
257+ itemType : "button" ,
258+ buttonOptions : {
259+ elementAttr : { id : 'customize-subjectIcon' , class : "scheduler-form-custom-icon-button" } ,
260+ icon : "floppy" ,
261+ stylingMode : "text" ,
262+ onClick : ( ) => {
263+ alert ( "Subject icon clicked!" ) ;
264+ } ,
265+ } ,
266+ } ,
267+ {
268+ name : "subject" ,
269+ label : { text : "Event Title" } ,
270+ editorOptions : {
271+ placeholder : "Enter event title..."
272+ }
273+ } ,
274+ ] ,
220275 } ,
221- } ,
222- } ,
223- {
224- name : "subject" ,
225- label : { text : "Event Title" } ,
226- editorOptions : {
227- placeholder : "Enter event title..."
228- }
229- } ,
230- ] ,
231- } ,
232- {
233- name : "dateGroup" ,
234- items : [
235- {
236- name : "startDate" ,
237- label : { text : "From" } ,
238- editorOptions : {
239- width : "100%"
240- }
241- } ,
242- {
243- name : "endDate" ,
244- label : { text : "To" } ,
245- editorOptions : {
246- width : "100%"
247- }
248- } ,
249- {
250- colSpan : 2 ,
251- name : "allDay" ,
252- label : { text : "All day event" }
276+ {
277+ name : "dateGroup" ,
278+ items : [
279+ {
280+ name : "startDate" ,
281+ label : { text : "From" } ,
282+ editorOptions : {
283+ width : "100%"
284+ }
285+ } ,
286+ {
287+ name : "endDate" ,
288+ label : { text : "To" } ,
289+ editorOptions : {
290+ width : "100%"
291+ }
292+ } ,
293+ {
294+ colSpan : 2 ,
295+ name : "allDay" ,
296+ label : { text : "All day event" }
297+ } ,
298+ ] ,
299+ } ,
300+ {
301+ name : "descriptionGroup" ,
302+ items : [
303+ {
304+ colSpan : 2 ,
305+ name : "description" ,
306+ label : { text : "Notes" } ,
307+ editorOptions : {
308+ height : 120 ,
309+ placeholder : "Add notes about this event..."
310+ }
311+ }
312+ ]
313+ } ,
314+ ] ,
315+ iconsShowMode : args [ "editing.form.iconsShowMode" ]
253316 } ,
254- ] ,
255- } ,
256- {
257- name : "descriptionGroup" ,
258- items : [
259- {
260- colSpan : 2 ,
261- name : "description" ,
262- label : { text : "Notes" } ,
263- editorOptions : {
264- height : 120 ,
265- placeholder : "Add notes about this event..."
266- }
317+ } as Properties [ 'editing' ] }
318+ />
319+ ) ;
320+ } ,
321+ } ;
322+
323+ export const RTL : Story = {
324+ args : {
325+ ...baseConfig ,
326+ resources,
327+ rtlEnabled : true ,
328+ } ,
329+ argTypes : iconsShowModeArgType ,
330+ } ;
331+
332+ export const LegacyPopup : Story = {
333+ args : {
334+ ...baseConfig ,
335+ "editing.form.iconsShowMode" : "none" ,
336+ } as Properties ,
337+ argTypes : iconsShowModeArgType ,
338+ render : ( args ) => {
339+ return (
340+ < Scheduler
341+ { ...baseConfig }
342+ editing = { {
343+ form : {
344+ items : [
345+ "mainGroup" ,
346+ { name : 'recurenceGroup' , visible : true }
347+ ] ,
348+ iconsShowMode : args [ "editing.form.iconsShowMode" ]
267349 }
268- ]
269- } ,
270- ] ,
271- } as Record < string , unknown > ,
350+ } as Properties [ 'editing' ] }
351+ />
352+ ) ;
353+ } ,
272354} ;
0 commit comments