0 | module Text.HTML.DomID
2 | import Data.List.Quantifiers
3 | import Derive.Prelude
7 | %language ElabReflection
18 | %runElab derive "DomID" [Show,Eq,Ord,FromString]
22 | toID : Cast t DomID => t -> DomID
28 | withDomID : Cast t DomID => t -> Node e -> Node e
29 | withDomID = withId . value . toID
33 | forID : Cast t DomID => t -> Attribute x e
34 | forID = for . value . toID
41 | Interpolation DomID where interpolate = value
44 | Semigroup DomID where
45 | D x <+> D y = D $
x ++ "-" ++ y
48 | Cast Nat DomID where cast = D . show
51 | Cast x DomID => Cast (SnocList x) DomID where
53 | cast (sx :< x) = cast sx <+> cast x
56 | Cast x DomID => Cast (List x) DomID where
58 | cast (x::xs) = cast x <+> cast xs
61 | (prf : All (\x => Cast (f x) DomID) ks) => Cast (List.Quantifiers.All.All f ks) DomID where
63 | cast @{_::_} (x::xs) = cast x <+> cast xs
70 | tagRef : {s : _} -> (0 tag : HTMLTag s) -> Cast t DomID => t -> Ref tag
71 | tagRef _ v = Id (value $
cast v)
74 | elemRef : Cast t DomID => t -> Ref Void
75 | elemRef v = Elem (value $
cast v)
79 | btnRef : Cast t DomID => t -> Ref Tag.Button
84 | divRef : Cast t DomID => t -> Ref Tag.Div
89 | inpRef : Cast t DomID => t -> Ref Tag.Input
94 | canvasRef : Cast t DomID => t -> Ref Tag.Canvas
95 | canvasRef = tagRef _
99 | ref : {s : _} -> {0 tag : HTMLTag s} -> Cast t DomID => t -> Attribute tag e
100 | ref = Id . tagRef tag