@@ -8,6 +8,8 @@ import NoteInfo from "services/NoteInfo";
88import PopperSelectPortal from "components/portals/PopperSelectPortal" ;
99import { CellContext } from "components/contexts/CellContext" ;
1010import { c } from "helpers/StylesHelper" ;
11+ import CalendarPortal from "./portals/CalendarPortal" ;
12+ import { TableColumn } from "cdm/FolderModel" ;
1113
1214/**
1315 * Obtain the path of the file inside cellValue
@@ -36,12 +38,15 @@ export default function DefaultCell(cellProperties: Cell) {
3638 /** Note info of current Cell */
3739 const note : NoteInfo = ( cellProperties . row . original as any ) . note ;
3840 /** state of cell value */
39- const [ value , setValue ] = useState ( { value : initialValue , update : false } ) ;
41+ const [ contextValue , setContextValue ] = useState ( {
42+ value : initialValue ,
43+ update : false ,
44+ } ) ;
4045 /** state for keeping the timeout to trigger the editior */
4146 const [ editNoteTimeout , setEditNoteTimeout ] = useState ( null ) ;
4247 /** states for selector option */
4348 LOGGER . debug (
44- `<=> Cell.rendering dataType: ${ dataType } . value: ${ value . value } `
49+ `<=> Cell.rendering dataType: ${ dataType } . value: ${ contextValue . value } `
4550 ) ;
4651
4752 const handleKeyDown = ( event : any ) => {
@@ -56,7 +61,7 @@ export default function DefaultCell(cellProperties: Cell) {
5661 clearTimeout ( editNoteTimeout ) ;
5762 }
5863 // first update the input text as user type
59- setValue ( { value : event . target . value , update : false } ) ;
64+ setContextValue ( { value : event . target . value , update : false } ) ;
6065 // initialize a setimeout by wrapping in our editNoteTimeout so that we can clear it out using clearTimeout
6166 setEditNoteTimeout (
6267 setTimeout ( ( ) => {
@@ -82,13 +87,15 @@ export default function DefaultCell(cellProperties: Cell) {
8287 switch ( dataType ) {
8388 /** Plain text option */
8489 case DataTypes . TEXT :
85- return (
90+ return ( cellProperties . column as any ) . isMetadata ? (
91+ < span className = "data-input" > { contextValue . value . toString ( ) } </ span >
92+ ) : (
8693 < ContentEditable
87- html = { ( value . value && value . value . toString ( ) ) || "" }
94+ html = { ( contextValue . value && contextValue . value . toString ( ) ) || "" }
8895 onChange = { handleOnChange }
8996 onKeyDown = { handleKeyDown }
9097 onBlur = { ( ) =>
91- setValue ( ( old ) => ( { value : old . value , update : true } ) )
98+ setContextValue ( ( old ) => ( { value : old . value , update : true } ) )
9299 }
93100 className = "data-input"
94101 />
@@ -97,10 +104,10 @@ export default function DefaultCell(cellProperties: Cell) {
97104 case DataTypes . NUMBER :
98105 return (
99106 < ContentEditable
100- html = { ( value . value && value . value . toString ( ) ) || "" }
107+ html = { ( contextValue . value && contextValue . value . toString ( ) ) || "" }
101108 onChange = { handleOnChange }
102109 onBlur = { ( ) =>
103- setValue ( ( old ) => ( { value : old . value , update : true } ) )
110+ setContextValue ( ( old ) => ( { value : old . value , update : true } ) )
104111 }
105112 className = "data-input text-align-right"
106113 />
@@ -119,11 +126,11 @@ export default function DefaultCell(cellProperties: Cell) {
119126 ) ;
120127 } ) ;
121128
122- return < span ref = { containerRef } className = { `${ c ( "md_cell" ) } ` } > </ span > ;
129+ return < span ref = { containerRef } className = { `${ c ( "md_cell" ) } ` } > </ span > ;
123130 /** Selector option */
124131 case DataTypes . SELECT :
125132 return (
126- < CellContext . Provider value = { { value , setValue } } >
133+ < CellContext . Provider value = { { contextValue , setContextValue } } >
127134 < PopperSelectPortal
128135 dispatch = { dataDispatch }
129136 row = { cellProperties . row }
@@ -134,7 +141,17 @@ export default function DefaultCell(cellProperties: Cell) {
134141 />
135142 </ CellContext . Provider >
136143 ) ;
137-
144+ /** Calendar option */
145+ case DataTypes . CALENDAR :
146+ return (
147+ < CellContext . Provider value = { { contextValue, setContextValue } } >
148+ < CalendarPortal
149+ intialState = { ( cellProperties as any ) . initialState }
150+ column = { cellProperties . column as unknown as TableColumn }
151+ cellProperties = { cellProperties }
152+ />
153+ </ CellContext . Provider >
154+ ) ;
138155 /** Default option */
139156 default :
140157 LOGGER . warn ( `Unknown data type: ${ dataType } ` ) ;
0 commit comments