on develop help sign in
Deprecate part of Widget.Input
d205da3Tom Smalley
reflex-dom-core/src/Reflex/Dom/Widget/Input.hs+17
@@ -54,6 +54,7 @@ import qualified Text.Read as T
54import qualified GHCJS.DOM.Event as Event
54import qualified GHCJS.DOM.Event as Event
55import qualified GHCJS.DOM.HTMLInputElement as Input
55import qualified GHCJS.DOM.HTMLInputElement as Input
56
56
57+{-# DEPRECATED TextInput "Use 'inputElement' directly" #-}
57data TextInput t
58data TextInput t
58 = TextInput { _textInput_value :: Dynamic t Text
59 = TextInput { _textInput_value :: Dynamic t Text
59 , _textInput_input :: Event t Text
60 , _textInput_input :: Event t Text
@@ -64,6 +65,7 @@ data TextInput t
64 , _textInput_builderElement :: InputElement EventResult GhcjsDomSpace t
65 , _textInput_builderElement :: InputElement EventResult GhcjsDomSpace t
65 }
66 }
66
67
68+{-# DEPRECATED _textInput_element "Use 'inputElement' directly" #-}
67_textInput_element :: TextInput t -> HTMLInputElement
69_textInput_element :: TextInput t -> HTMLInputElement
68_textInput_element = _inputElement_raw . _textInput_builderElement
70_textInput_element = _inputElement_raw . _textInput_builderElement
69
71
@@ -71,6 +73,7 @@ instance Reflex t => HasDomEvent t (TextInput t) en where
71 type DomEventType (TextInput t) en = DomEventType (InputElement EventResult GhcjsDomSpace t) en
73 type DomEventType (TextInput t) en = DomEventType (InputElement EventResult GhcjsDomSpace t) en
72 domEvent en = domEvent en . _textInput_builderElement
74 domEvent en = domEvent en . _textInput_builderElement
73
75
76+{-# DEPRECATED TextInputConfig "Use 'inputElement' directly" #-}
74data TextInputConfig t
77data TextInputConfig t
75 = TextInputConfig { _textInputConfig_inputType :: Text
78 = TextInputConfig { _textInputConfig_inputType :: Text
76 , _textInputConfig_initialValue :: Text
79 , _textInputConfig_initialValue :: Text
@@ -86,6 +89,7 @@ instance Reflex t => Default (TextInputConfig t) where
86 , _textInputConfig_attributes = constDyn mempty
89 , _textInputConfig_attributes = constDyn mempty
87 }
90 }
88
91
92+{-# DEPRECATED textInput "Use 'inputElement' directly" #-}
89-- | Create an input whose value is a string. By default, the "type" attribute is set to "text", but it can be changed using the _textInputConfig_inputType field. Note that only types for which the value is always a string will work - types whose value may be null will not work properly with this widget.
93-- | Create an input whose value is a string. By default, the "type" attribute is set to "text", but it can be changed using the _textInputConfig_inputType field. Note that only types for which the value is always a string will work - types whose value may be null will not work properly with this widget.
90{-# INLINABLE textInput #-}
94{-# INLINABLE textInput #-}
91textInput :: (DomBuilder t m, PostBuild t m, DomBuilderSpace m ~ GhcjsDomSpace) => TextInputConfig t -> m (TextInput t)
95textInput :: (DomBuilder t m, PostBuild t m, DomBuilderSpace m ~ GhcjsDomSpace) => TextInputConfig t -> m (TextInput t)
@@ -161,6 +165,7 @@ rangeInput (RangeInputConfig initial eSetValue dAttrs) = do
161 , _rangeInput_element = _inputElement_raw i
165 , _rangeInput_element = _inputElement_raw i
162 }
166 }
163
167
168+{-# DEPRECATED TextAreaConfig "Use 'textAreaElement' directly" #-}
164data TextAreaConfig t
169data TextAreaConfig t
165 = TextAreaConfig { _textAreaConfig_initialValue :: Text
170 = TextAreaConfig { _textAreaConfig_initialValue :: Text
166 , _textAreaConfig_setValue :: Event t Text
171 , _textAreaConfig_setValue :: Event t Text
@@ -174,6 +179,7 @@ instance Reflex t => Default (TextAreaConfig t) where
174 , _textAreaConfig_attributes = constDyn mempty
179 , _textAreaConfig_attributes = constDyn mempty
175 }
180 }
176
181
182+{-# DEPRECATED TextArea "Use 'textAreaElement' directly" #-}
177data TextArea t
183data TextArea t
178 = TextArea { _textArea_value :: Dynamic t Text
184 = TextArea { _textArea_value :: Dynamic t Text
179 , _textArea_input :: Event t Text
185 , _textArea_input :: Event t Text
@@ -182,6 +188,7 @@ data TextArea t
182 , _textArea_element :: HTMLTextAreaElement
188 , _textArea_element :: HTMLTextAreaElement
183 }
189 }
184
190
191+{-# DEPRECATED textArea "Use 'textAreaElement' directly" #-}
185{-# INLINABLE textArea #-}
192{-# INLINABLE textArea #-}
186textArea :: (DomBuilder t m, PostBuild t m, DomBuilderSpace m ~ GhcjsDomSpace) => TextAreaConfig t -> m (TextArea t)
193textArea :: (DomBuilder t m, PostBuild t m, DomBuilderSpace m ~ GhcjsDomSpace) => TextAreaConfig t -> m (TextArea t)
187textArea (TextAreaConfig initial eSet attrs) = do
194textArea (TextAreaConfig initial eSet attrs) = do
@@ -198,6 +205,7 @@ textArea (TextAreaConfig initial eSet attrs) = do
198 , _textArea_element = _textAreaElement_raw i
205 , _textArea_element = _textAreaElement_raw i
199 }
206 }
200
207
208+{-# DEPRECATED CheckboxConfig "Use 'inputElement' directly" #-}
201data CheckboxConfig t
209data CheckboxConfig t
202 = CheckboxConfig { _checkboxConfig_setValue :: Event t Bool
210 = CheckboxConfig { _checkboxConfig_setValue :: Event t Bool
203 , _checkboxConfig_attributes :: Dynamic t (Map Text Text)
211 , _checkboxConfig_attributes :: Dynamic t (Map Text Text)
@@ -209,11 +217,13 @@ instance Reflex t => Default (CheckboxConfig t) where
209 , _checkboxConfig_attributes = constDyn mempty
217 , _checkboxConfig_attributes = constDyn mempty
210 }
218 }
211
219
220+{-# DEPRECATED Checkbox "Use 'inputElement' directly" #-}
212data Checkbox t
221data Checkbox t
213 = Checkbox { _checkbox_value :: Dynamic t Bool
222 = Checkbox { _checkbox_value :: Dynamic t Bool
214 , _checkbox_change :: Event t Bool
223 , _checkbox_change :: Event t Bool
215 }
224 }
216
225
226+{-# DEPRECATED checkbox "Use 'inputElement' directly" #-}
217-- | Create an editable checkbox
227-- | Create an editable checkbox
218-- Note: if the "type" or "checked" attributes are provided as attributes, they will be ignored
228-- Note: if the "type" or "checked" attributes are provided as attributes, they will be ignored
219{-# INLINABLE checkbox #-}
229{-# INLINABLE checkbox #-}
@@ -232,10 +242,12 @@ checkbox checked config = do
232 , _checkbox_change = _inputElement_checkedChange i
242 , _checkbox_change = _inputElement_checkedChange i
233 }
243 }
234
244
245+{-# DEPRECATED CheckboxViewEventResultType "Use 'inputElement' directly" #-}
235type family CheckboxViewEventResultType (en :: EventTag) :: * where
246type family CheckboxViewEventResultType (en :: EventTag) :: * where
236 CheckboxViewEventResultType 'ClickTag = Bool
247 CheckboxViewEventResultType 'ClickTag = Bool
237 CheckboxViewEventResultType t = EventResultType t
248 CheckboxViewEventResultType t = EventResultType t
238
249
250+{-# DEPRECATED regularToCheckboxViewEventType "Use 'inputElement' directly" #-}
239regularToCheckboxViewEventType :: EventName t -> EventResultType t -> CheckboxViewEventResultType t
251regularToCheckboxViewEventType :: EventName t -> EventResultType t -> CheckboxViewEventResultType t
240regularToCheckboxViewEventType en r = case en of
252regularToCheckboxViewEventType en r = case en of
241 Click -> error "regularToCheckboxViewEventType: EventName Click should never be encountered"
253 Click -> error "regularToCheckboxViewEventType: EventName Click should never be encountered"
@@ -285,8 +297,10 @@ regularToCheckboxViewEventType en r = case en of
285 Touchend -> r
297 Touchend -> r
286 Touchcancel -> r
298 Touchcancel -> r
287
299
300+{-# DEPRECATED CheckboxViewEventResult "Use 'inputElement' directly" #-}
288newtype CheckboxViewEventResult en = CheckboxViewEventResult { unCheckboxViewEventResult :: CheckboxViewEventResultType en }
301newtype CheckboxViewEventResult en = CheckboxViewEventResult { unCheckboxViewEventResult :: CheckboxViewEventResultType en }
289
302
303+{-# DEPRECATED checkboxView "Use 'inputElement' directly" #-}
290--TODO
304--TODO
291{-# INLINABLE checkboxView #-}
305{-# INLINABLE checkboxView #-}
292checkboxView :: forall t m. (DomBuilder t m, DomBuilderSpace m ~ GhcjsDomSpace, PostBuild t m, MonadHold t m) => Dynamic t (Map Text Text) -> Dynamic t Bool -> m (Event t Bool)
306checkboxView :: forall t m. (DomBuilder t m, DomBuilderSpace m ~ GhcjsDomSpace, PostBuild t m, MonadHold t m) => Dynamic t (Map Text Text) -> Dynamic t Bool -> m (Event t Bool)
@@ -321,11 +335,13 @@ checkboxView dAttrs dValue = do
321 i <- inputElement inputElementConfig
335 i <- inputElement inputElementConfig
322 return $ unCheckboxViewEventResult <$> select (_element_events $ _inputElement_element i) (WrapArg Click)
336 return $ unCheckboxViewEventResult <$> select (_element_events $ _inputElement_element i) (WrapArg Click)
323
337
338+{-# DEPRECATED FileInput "Use 'inputElement' directly" #-}
324data FileInput d t
339data FileInput d t
325 = FileInput { _fileInput_value :: Dynamic t [File]
340 = FileInput { _fileInput_value :: Dynamic t [File]
326 , _fileInput_element :: RawInputElement d
341 , _fileInput_element :: RawInputElement d
327 }
342 }
328
343
344+{-# DEPRECATED FileInputConfig "Use 'inputElement' directly" #-}
329newtype FileInputConfig t
345newtype FileInputConfig t
330 = FileInputConfig { _fileInputConfig_attributes :: Dynamic t (Map Text Text)
346 = FileInputConfig { _fileInputConfig_attributes :: Dynamic t (Map Text Text)
331 }
347 }
@@ -334,6 +350,7 @@ instance Reflex t => Default (FileInputConfig t) where
334 def = FileInputConfig { _fileInputConfig_attributes = constDyn mempty
350 def = FileInputConfig { _fileInputConfig_attributes = constDyn mempty
335 }
351 }
336
352
353+{-# DEPRECATED fileInput "Use 'inputElement' directly" #-}
337fileInput :: forall t m. (MonadIO m, MonadJSM m, MonadFix m, MonadHold t m, TriggerEvent t m, DomBuilder t m, PostBuild t m, DomBuilderSpace m ~ GhcjsDomSpace)
354fileInput :: forall t m. (MonadIO m, MonadJSM m, MonadFix m, MonadHold t m, TriggerEvent t m, DomBuilder t m, PostBuild t m, DomBuilderSpace m ~ GhcjsDomSpace)
338 => FileInputConfig t -> m (FileInput (DomBuilderSpace m) t)
355 => FileInputConfig t -> m (FileInput (DomBuilderSpace m) t)
339fileInput config = do
356fileInput config = do