on develop help sign in
Merge pull request #286 from reflex-frp/ts-deprecate-input

Deprecate some stuff from Widget.Input

commitdf46ac928899ca9053b9fedb76090e6e3fecfdd3 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateSat 14 Dec 2019, 13:52 (7 years ago) parentfe1dac203da6a3
3 files changed+13−61
reflex-dom-core/ChangeLog.md+8 reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+1−23 reflex-dom-core/src/Reflex/Dom/Widget/Input.hs+4−38
reflex-dom-core/ChangeLog.md+8
@@ -3,6 +3,7 @@
33## Unreleased
44
55* Deprecate a number of old inflexible widget helpers in `Reflex.Dom.Widget.Basic`:
6+
67 * `Link`
78 * `button`
89 * `dtdd`
@@ -11,6 +12,13 @@
1112 * `tabDisplay`
1213 * `tableDynAttr`
1314
15+ And in `Reflex.Dom.Widget.Input`:
16+
17+ * `TextInput`
18+ * `TextAreaConfig`
19+ * `CheckboxConfig`
20+ * `FileInput`
21+
1422## 0.5.2
1523
1624* Update to use new dependent-sum/map packages and drop dependency on `*Tag` classes (e.g., `ShowTag`).
reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+1−23
@@ -272,29 +272,7 @@ dynamicAttributesToModifyAttributesWithInitial attrs0 d = do
272272 return $ if Map.null p then Nothing else Just p
273273 return modificationsNeeded
274274
275−--------------------------------------------------------------------------------
276−-- Copied and pasted from Reflex.Widget.Class
277−--------------------------------------------------------------------------------
278−
279−{-
280−schedulePostBuild x = performEvent_ . (x <$) =<< getPostBuild
281−
282−elDynHtml' :: DomBuilder t m => Text -> Dynamic t Text -> m (El t)
283−elDynHtml' elementTag html = do
284− e <- buildEmptyElement elementTag (Map.empty :: Map Text Text)
285− schedulePostBuild $ setInnerHTML e . Just =<< sample (current html)
286− performEvent_ $ fmap (setInnerHTML e . Just) $ updated html
287− wrapElement defaultDomEventHandler e
288−
289−elDynHtmlAttr' :: DomBuilder t m => Text -> Map Text Text -> Dynamic t Text -> m (El t)
290−elDynHtmlAttr' elementTag attrs html = do
291− e <- buildEmptyElement elementTag attrs
292− schedulePostBuild $ setInnerHTML e . Just =<< sample (current html)
293− performEvent_ $ fmap (setInnerHTML e . Just) $ updated html
294− wrapElement defaultDomEventHandler e
295−-}
296−
297−{-# DEPRECATED Link "Will be removed when 'linkClass' and 'link' are removed" #-}
275+{-# DEPRECATED Link "Will be removed when 'linkClass' and 'link' are removed. Follow those functions' deprecation instructions." #-}
298276newtype Link t
299277 = Link { _link_clicked :: Event t ()
300278 }
reflex-dom-core/src/Reflex/Dom/Widget/Input.hs+4−38
@@ -54,6 +54,7 @@ import qualified Text.Read as T
5454import qualified GHCJS.DOM.Event as Event
5555import qualified GHCJS.DOM.HTMLInputElement as Input
5656
57+{-# DEPRECATED TextInput, _textInput_element, TextInputConfig, textInput "Use 'inputElement' directly" #-}
5758data TextInput t
5859 = TextInput { _textInput_value :: Dynamic t Text
5960 , _textInput_input :: Event t Text
@@ -161,6 +162,7 @@ rangeInput (RangeInputConfig initial eSetValue dAttrs) = do
161162 , _rangeInput_element = _inputElement_raw i
162163 }
163164
165+{-# DEPRECATED TextAreaConfig, TextArea, textArea "Use 'textAreaElement' directly" #-}
164166data TextAreaConfig t
165167 = TextAreaConfig { _textAreaConfig_initialValue :: Text
166168 , _textAreaConfig_setValue :: Event t Text
@@ -198,6 +200,7 @@ textArea (TextAreaConfig initial eSet attrs) = do
198200 , _textArea_element = _textAreaElement_raw i
199201 }
200202
203+{-# DEPRECATED CheckboxConfig, Checkbox, checkbox, checkboxView, CheckboxViewEventResultType, regularToCheckboxViewEventType, CheckboxViewEventResult "Use 'inputElement' directly" #-}
201204data CheckboxConfig t
202205 = CheckboxConfig { _checkboxConfig_setValue :: Event t Bool
203206 , _checkboxConfig_attributes :: Dynamic t (Map Text Text)
@@ -321,6 +324,7 @@ checkboxView dAttrs dValue = do
321324 i <- inputElement inputElementConfig
322325 return $ unCheckboxViewEventResult <$> select (_element_events $ _inputElement_element i) (WrapArg Click)
323326
327+{-# DEPRECATED FileInput, FileInputConfig, fileInput "Use 'inputElement' directly" #-}
324328data FileInput d t
325329 = FileInput { _fileInput_value :: Dynamic t [File]
326330 , _fileInput_element :: RawInputElement d
@@ -681,41 +685,3 @@ instance HasValue (Dropdown t k) where
681685instance HasValue (Checkbox t) where
682686 type Value (Checkbox t) = Dynamic t Bool
683687 value = _checkbox_value
684−
685−{-
686−type family Controller sm t a where
687− Controller Edit t a = (a, Event t a) -- Initial value and setter
688− Controller View t a = Dynamic t a -- Value (always)
689−
690−type family Output sm t a where
691− Output Edit t a = Dynamic t a -- Value (always)
692− Output View t a = Event t a -- Requested changes
693−
694−data CheckboxConfig sm t
695− = CheckboxConfig { _checkbox_input :: Controller sm t Bool
696− , _checkbox_attributes :: Attributes
697− }
698−
699−instance Reflex t => Default (CheckboxConfig Edit t) where
700− def = CheckboxConfig (False, never) mempty
701−
702−data Checkbox sm t
703− = Checkbox { _checkbox_output :: Output sm t Bool
704− }
705−
706−data StateMode = Edit | View
707−
708−--TODO: There must be a more generic way to get this witness and allow us to case on the type-level StateMode
709−data StateModeWitness (sm :: StateMode) where
710− EditWitness :: StateModeWitness Edit
711− ViewWitness :: StateModeWitness View
712−
713−class HasStateModeWitness (sm :: StateMode) where
714− stateModeWitness :: StateModeWitness sm
715−
716−instance HasStateModeWitness Edit where
717− stateModeWitness = EditWitness
718−
719−instance HasStateModeWitness View where
720− stateModeWitness = ViewWitness
721−-}