/
Types.purs
100 lines (82 loc) · 2.55 KB
/
Types.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
module Handsontable.Types where
import Prelude (class Show)
import Control.Monad.Eff (kind Effect)
import Data.Maybe (Maybe)
foreign import data HOT :: Effect
foreign import data Handsontable :: Type -> Type
foreign import data CellEditor :: Type
foreign import data MaybeNull :: Type -> Type
type Options d r = { data :: DataTable d | r }
type DataTable d = Array (Array d)
type Coords =
{ row :: Int
, col :: Int
}
type Change d =
{ row :: Int
, col :: Int
, old :: Maybe d
, new :: d
}
data ChangeSource
= ChangeAlter
| ChangeEmpty
| ChangeEdit
| ChangePopulateFromArray
| ChangeLoadData
| ChangeAutofill
| ChangePaste
| ChangeSpliceCol
| ChangeSpliceRow
instance showChangeSource :: Show ChangeSource where
show ChangeAlter = "alter"
show ChangeEmpty = "empty"
show ChangeEdit = "edit"
show ChangePopulateFromArray = "populateFromArray"
show ChangeLoadData = "loadData"
show ChangeAutofill = "autofill"
show ChangePaste = "paste"
show ChangeSpliceCol = "spliceCol"
show ChangeSpliceRow = "spliceRow"
readChangeSource :: Partial => String -> ChangeSource
readChangeSource "alter" = ChangeAlter
readChangeSource "empty" = ChangeEmpty
readChangeSource "edit" = ChangeEdit
readChangeSource "populateFromArray" = ChangePopulateFromArray
readChangeSource "loadData" = ChangeLoadData
readChangeSource "autofill" = ChangeAutofill
readChangeSource "paste" = ChangePaste
readChangeSource "spliceCol" = ChangeSpliceCol
readChangeSource "spliceRow" = ChangeSpliceRow
data AlterAction
= InsertRow
| InsertCol
| RemoveRow
| RemoveCol
instance showAlterAction :: Show AlterAction where
show InsertRow = "insert_row"
show InsertCol = "insert_col"
show RemoveRow = "remove_row"
show RemoveCol = "remove_col"
data PopulateMethod
= Overwrite
| ShiftDown
| ShiftRight
instance showPopulateMethod :: Show PopulateMethod where
show Overwrite = "overwrite"
show ShiftDown = "shift_down"
show ShiftRight = "shift_right"
readPopulateMethod :: Partial => String -> PopulateMethod
readPopulateMethod "overwrite" = Overwrite
readPopulateMethod "shift_down" = ShiftDown
readPopulateMethod "shift_right" = ShiftRight
data Direction
= DirectionLeft
| DirectionRight
| DirectionUp
| DirectionDown
instance showDirection :: Show Direction where
show DirectionLeft = "left"
show DirectionRight = "right"
show DirectionUp = "up"
show DirectionDown = "down"