diff --git a/htmx-lucid/htmx-lucid.cabal b/htmx-lucid/htmx-lucid.cabal index 41fc969..d23cf6d 100644 --- a/htmx-lucid/htmx-lucid.cabal +++ b/htmx-lucid/htmx-lucid.cabal @@ -35,7 +35,7 @@ library build-depends: , base >=4.7 && <5 , htmx - , lucid >=2.9.12.1 && <2.11.20230408.0 + , lucid2 >=0.0.20221012 , text >=2 && <3 default-language: Haskell2010 diff --git a/htmx-lucid/src/Htmx/Lucid/Core.hs b/htmx-lucid/src/Htmx/Lucid/Core.hs index f2cc6f1..6c2b921 100644 --- a/htmx-lucid/src/Htmx/Lucid/Core.hs +++ b/htmx-lucid/src/Htmx/Lucid/Core.hs @@ -12,69 +12,69 @@ import Htmx.Event import Htmx.Render import Htmx.Swap (Swap) import Lucid (Html, HtmlT, script_, src_) -import Lucid.Base (Attribute, makeAttribute) +import Lucid.Base (Attributes, makeAttributes) -- | -- issues a GET to the specified URL -hxGet_ :: Text -> Attribute -hxGet_ = makeAttribute "hx-get" +hxGet_ :: Text -> Attributes +hxGet_ = makeAttributes "hx-get" -- | -- issues a POST to the specified URL -hxPost_ :: Text -> Attribute -hxPost_ = makeAttribute "hx-post" +hxPost_ :: Text -> Attributes +hxPost_ = makeAttributes "hx-post" -- | -- push a URL into the browser location bar to create history -hxPushUrl_ :: Text -> Attribute -hxPushUrl_ = makeAttribute "hx-push-url" +hxPushUrl_ :: Text -> Attributes +hxPushUrl_ = makeAttributes "hx-push-url" -- | -- select content to swap in from a response -hxSelect_ :: Text -> Attribute -hxSelect_ = makeAttribute "hx-select" +hxSelect_ :: Text -> Attributes +hxSelect_ = makeAttributes "hx-select" -- | -- select content to swap in from a response, somewhere other than the target -- (out of band) -hxSelectOob_ :: Text -> Attribute -hxSelectOob_ = makeAttribute "hx-select-oob" +hxSelectOob_ :: Text -> Attributes +hxSelectOob_ = makeAttributes "hx-select-oob" -- | -- controls how content will swap in (outerHTML, beforeend, afterend, …) -hxSwap_ :: Text -> Attribute -hxSwap_ = makeAttribute "hx-swap" +hxSwap_ :: Text -> Attributes +hxSwap_ = makeAttributes "hx-swap" -- | Like 'hxSwap' but takes a strongly typed swap style. -- This doesn't allow [modifiers](https://htmx.org/attributes/hx-swap/#modifiers) to be applied. -hxSwapS_ :: Swap -> Attribute -hxSwapS_ = makeAttribute "hx-swap" . render +hxSwapS_ :: Swap -> Attributes +hxSwapS_ = makeAttributes "hx-swap" . render -- | -- mark element to swap in from a response (out of band) -hxSwapOob_ :: Text -> Attribute -hxSwapOob_ = makeAttribute "hx-swap-oob" +hxSwapOob_ :: Text -> Attributes +hxSwapOob_ = makeAttributes "hx-swap-oob" -- | -- specifies the target element to be swapped -hxTarget_ :: Text -> Attribute -hxTarget_ = makeAttribute "hx-target" +hxTarget_ :: Text -> Attributes +hxTarget_ = makeAttributes "hx-target" -- | -- specifies the event that triggers the request -hxTrigger_ :: Text -> Attribute -hxTrigger_ = makeAttribute "hx-trigger" +hxTrigger_ :: Text -> Attributes +hxTrigger_ = makeAttributes "hx-trigger" -- | -- add values to submit with the request (JSON format) -hxVals_ :: Text -> Attribute -hxVals_ = makeAttribute "hx-vals" +hxVals_ :: Text -> Attributes +hxVals_ = makeAttributes "hx-vals" data OnEvent = DomOnEvent Text | HtmxOnEvent HtmxEvent -- | -- handle events with inline scripts on elements -hxOn_ :: OnEvent -> Text -> Attribute +hxOn_ :: OnEvent -> Text -> Attributes hxOn_ = \case - DomOnEvent event -> makeAttribute $ "hx-on:" <> event - HtmxOnEvent htmxEvent -> makeAttribute $ "hx-on::" <> render htmxEvent + DomOnEvent event -> makeAttributes $ "hx-on:" <> event + HtmxOnEvent htmxEvent -> makeAttributes $ "hx-on::" <> render htmxEvent diff --git a/htmx-lucid/src/Htmx/Lucid/Extension/IncludeVals.hs b/htmx-lucid/src/Htmx/Lucid/Extension/IncludeVals.hs index 19c55d9..82537e5 100644 --- a/htmx-lucid/src/Htmx/Lucid/Extension/IncludeVals.hs +++ b/htmx-lucid/src/Htmx/Lucid/Extension/IncludeVals.hs @@ -8,11 +8,10 @@ This module defines an attribute that allows you to include additional values in module Htmx.Lucid.Extension.IncludeVals where import Data.Text (Text) -import Lucid -import Lucid.Base (makeAttribute) +import Lucid.Base (makeAttributes, Attributes) -- | -- The value of this attribute is one or more name/value pairs, which will be evaluated as the fields in a javascript object literal. -- i.e. "included:true, computed: computeValue()" -includeVals_ :: Text -> Attribute -includeVals_ = makeAttribute "include-vals" +includeVals_ :: Text -> Attributes +includeVals_ = makeAttributes "include-vals" diff --git a/htmx-lucid/src/Htmx/Lucid/Extra.hs b/htmx-lucid/src/Htmx/Lucid/Extra.hs index 75f2771..b9adc94 100644 --- a/htmx-lucid/src/Htmx/Lucid/Extra.hs +++ b/htmx-lucid/src/Htmx/Lucid/Extra.hs @@ -14,81 +14,81 @@ import Data.Text (Text, pack) import Htmx.Extension import Htmx.Render import Lucid (Html, HtmlT, script_, src_) -import Lucid.Base (Attribute, makeAttribute) +import Lucid.Base (Attributes, makeAttributes) -- | -- add progressive enhancement for links and forms -hxBoost_ :: Text -> Attribute -hxBoost_ = makeAttribute "hx-boost" +hxBoost_ :: Text -> Attributes +hxBoost_ = makeAttributes "hx-boost" -- | -- shows a confirm() dialog before issuing a request -hxConfirm_ :: Text -> Attribute -hxConfirm_ = makeAttribute "hx-confirm" +hxConfirm_ :: Text -> Attributes +hxConfirm_ = makeAttributes "hx-confirm" -- | -- issues a DELETE to the specified URL -hxDelete_ :: Text -> Attribute -hxDelete_ = makeAttribute "hx-delete" +hxDelete_ :: Text -> Attributes +hxDelete_ = makeAttributes "hx-delete" -- | -- disables htmx processing for the given node and any children nodes -hxDisable_ :: Attribute -hxDisable_ = makeAttribute "hx-disable" mempty +hxDisable_ :: Attributes +hxDisable_ = makeAttributes "hx-disable" mempty -- | -- adds the disabled attribute to the specified elements while a request is in flight -hxDisabledElt_ :: Text -> Attribute -hxDisabledElt_ = makeAttribute "hx-disabled-elt" +hxDisabledElt_ :: Text -> Attributes +hxDisabledElt_ = makeAttributes "hx-disabled-elt" -- | -- control and disable automatic attribute inheritance for child nodes -hxDisinherit_ :: Text -> Attribute -hxDisinherit_ = makeAttribute "hx-disinherit" +hxDisinherit_ :: Text -> Attributes +hxDisinherit_ = makeAttributes "hx-disinherit" -- | -- changes the request encoding type -hxEncoding_ :: Text -> Attribute -hxEncoding_ = makeAttribute "hx-encoding" +hxEncoding_ :: Text -> Attributes +hxEncoding_ = makeAttributes "hx-encoding" -- | -- extensions to use for this element -hxExt_ :: Text -> Attribute -hxExt_ = makeAttribute "hx-ext" +hxExt_ :: Text -> Attributes +hxExt_ = makeAttributes "hx-ext" -- | A typesafe version of 'hxExt_' that works with the "included" extensions -- that the htmx codebase is tested against -hxExtension_ :: HtmxExtension -> Attribute -hxExtension_ = makeAttribute "hx-ext" . render +hxExtension_ :: HtmxExtension -> Attributes +hxExtension_ = makeAttributes "hx-ext" . render -- | Include multiple extensions in one declaration -hxExtensions_ :: [HtmxExtension] -> Attribute -hxExtensions_ = makeAttribute "hx-ext" . fold . intersperse "," . fmap render +hxExtensions_ :: [HtmxExtension] -> Attributes +hxExtensions_ = makeAttributes "hx-ext" . fold . intersperse "," . fmap render -- | -- adds to the headers that will be submitted with the request -hxHeaders_ :: Text -> Attribute -hxHeaders_ = makeAttribute "hx-headers" +hxHeaders_ :: Text -> Attributes +hxHeaders_ = makeAttributes "hx-headers" -- | -- prevent sensitive data being saved to the history cache -hxHistory_ :: Text -> Attribute -hxHistory_ = makeAttribute "hx-history" +hxHistory_ :: Text -> Attributes +hxHistory_ = makeAttributes "hx-history" -- | -- the element to snapshot and restore during history navigation -hxHistoryElt_ :: Attribute -hxHistoryElt_ = makeAttribute "hx-history-elt" mempty +hxHistoryElt_ :: Attributes +hxHistoryElt_ = makeAttributes "hx-history-elt" mempty -- | -- include additional data in requests -hxInclude_ :: Text -> Attribute -hxInclude_ = makeAttribute "hx-include" +hxInclude_ :: Text -> Attributes +hxInclude_ = makeAttributes "hx-include" -- | -- the element to put the htmx-request class on during the request -hxIndicator_ :: Text -> Attribute -hxIndicator_ = makeAttribute "hx-indicator" +hxIndicator_ :: Text -> Attributes +hxIndicator_ = makeAttributes "hx-indicator" data ParamsFilter = -- | Include all parameters (default) @@ -102,42 +102,42 @@ data ParamsFilter -- | -- filters the parameters that will be submitted with a request -hxParams_ :: ParamsFilter -> Attribute +hxParams_ :: ParamsFilter -> Attributes hxParams_ = \case - All -> makeAttribute "hx-params" "*" - None -> makeAttribute "hx-params" "none" - Exclude ps -> makeAttribute "hx-params" $ "not " <> (fold . intersperse "," $ ps) - Include ps -> makeAttribute "hx-params" $ fold . intersperse "," $ ps + All -> makeAttributes "hx-params" "*" + None -> makeAttributes "hx-params" "none" + Exclude ps -> makeAttributes "hx-params" $ "not " <> (fold . intersperse "," $ ps) + Include ps -> makeAttributes "hx-params" $ fold . intersperse "," $ ps -- | -- issues a PATCH to the specified URL -hxPatch_ :: Text -> Attribute -hxPatch_ = makeAttribute "hx-patch" +hxPatch_ :: Text -> Attributes +hxPatch_ = makeAttributes "hx-patch" -- | -- specifies elements to keep unchanged between requests -hxPreserve_ :: Attribute -hxPreserve_ = makeAttribute "hx-preserve" mempty +hxPreserve_ :: Attributes +hxPreserve_ = makeAttributes "hx-preserve" mempty -- | -- shows a prompt() before submitting a request -hxPrompt_ :: Text -> Attribute -hxPrompt_ = makeAttribute "hx-prompt" +hxPrompt_ :: Text -> Attributes +hxPrompt_ = makeAttributes "hx-prompt" -- | -- issues a PUT to the specified URL -hxPut_ :: Text -> Attribute -hxPut_ = makeAttribute "hx-put" +hxPut_ :: Text -> Attributes +hxPut_ = makeAttributes "hx-put" -- | -- replace the URL in the browser location bar -hxReplaceUrl_ :: Text -> Attribute -hxReplaceUrl_ = makeAttribute "hx-replace-url" +hxReplaceUrl_ :: Text -> Attributes +hxReplaceUrl_ = makeAttributes "hx-replace-url" -- | -- configures various aspects of the request -hxRequest_ :: Text -> Attribute -hxRequest_ = makeAttribute "hx-request" +hxRequest_ :: Text -> Attributes +hxRequest_ = makeAttributes "hx-request" {-# DEPRECATED hxSse_ @@ -146,8 +146,8 @@ hxRequest_ = makeAttribute "hx-request" -- | -- has been moved to an extension. Documentation for older versions -hxSse_ :: Text -> Attribute -hxSse_ = makeAttribute "hx-sse" +hxSse_ :: Text -> Attributes +hxSse_ = makeAttributes "hx-sse" data SyncStrategy = -- | drop (ignore) this request if an existing request is in flight (the default) @@ -167,29 +167,29 @@ data SyncStrategy -- | -- control how requests made by different elements are synchronized -hxSync_ :: Text -> Attribute -hxSync_ = makeAttribute "hx-sync" +hxSync_ :: Text -> Attributes +hxSync_ = makeAttributes "hx-sync" -- | -- the same as 'hxSync_' but accepts a strongly typed htmx 'SyncStrategy' -hxSyncStrategy_ :: Text -> SyncStrategy -> Attribute +hxSyncStrategy_ :: Text -> SyncStrategy -> Attributes hxSyncStrategy_ selector = \case - SyncDrop -> makeAttribute "hx-sync" $ selector <> ":" <> "drop" - SyncAbort -> makeAttribute "hx-sync" $ selector <> ":" <> "abort" - SyncReplace -> makeAttribute "hx-sync" $ selector <> ":" <> "replace" - SyncQueueFirst -> makeAttribute "hx-sync" $ selector <> ":" <> "queue first" - SyncQueueLast -> makeAttribute "hx-sync" $ selector <> ":" <> "queue last" - SyncQueueAll -> makeAttribute "hx-sync" $ selector <> ":" <> "queue all" + SyncDrop -> makeAttributes "hx-sync" $ selector <> ":" <> "drop" + SyncAbort -> makeAttributes "hx-sync" $ selector <> ":" <> "abort" + SyncReplace -> makeAttributes "hx-sync" $ selector <> ":" <> "replace" + SyncQueueFirst -> makeAttributes "hx-sync" $ selector <> ":" <> "queue first" + SyncQueueLast -> makeAttributes "hx-sync" $ selector <> ":" <> "queue last" + SyncQueueAll -> makeAttributes "hx-sync" $ selector <> ":" <> "queue all" -- | -- force elements to validate themselves before a request -hxValidate_ :: Text -> Attribute -hxValidate_ = makeAttribute "hx-validate" +hxValidate_ :: Text -> Attributes +hxValidate_ = makeAttributes "hx-validate" -- | -- adds values dynamically to the parameters to submit with the request (deprecated, please use hx-vals) -hxVars_ :: Text -> Attribute -hxVars_ = makeAttribute "hx-vars" +hxVars_ :: Text -> Attributes +hxVars_ = makeAttributes "hx-vars" {-# DEPRECATED hxWs_ @@ -198,5 +198,5 @@ hxVars_ = makeAttribute "hx-vars" -- | -- has been moved to an extension. Documentation for older versions -hxWs_ :: Text -> Attribute -hxWs_ = makeAttribute "hx-ws" +hxWs_ :: Text -> Attributes +hxWs_ = makeAttributes "hx-ws" diff --git a/htmx-lucid/src/Htmx/Lucid/Head.hs b/htmx-lucid/src/Htmx/Lucid/Head.hs index 5901a65..1cfb042 100644 --- a/htmx-lucid/src/Htmx/Lucid/Head.hs +++ b/htmx-lucid/src/Htmx/Lucid/Head.hs @@ -25,7 +25,7 @@ import GHC.Natural (Natural) import Htmx.Extension import Htmx.Render import Lucid (Html, HtmlT, script_, src_) -import Lucid.Base (Attribute, makeAttribute) +import Lucid.Base (Attributes, makeAttributes) -- | Place in your template after @useHtmx@, but before where the extension is used via @hxExt_@ -- NOTE: This uses 'recommendedVersion' as the version section of the URL diff --git a/htmx-servant/htmx-servant.cabal b/htmx-servant/htmx-servant.cabal index bc3b98d..dfef69a 100644 --- a/htmx-servant/htmx-servant.cabal +++ b/htmx-servant/htmx-servant.cabal @@ -36,7 +36,7 @@ library , base >=4.7 && <5 , htmx , htmx-lucid - , lucid >=2.9.12.1 && <2.11.20230408.0 + , lucid2 >=0.0.20221012 , servant >=0.19 && <0.30 , text >=2 && <3 diff --git a/htmx-servant/src/Htmx/Servant/Lucid.hs b/htmx-servant/src/Htmx/Servant/Lucid.hs index 34e77b1..92a75a3 100644 --- a/htmx-servant/src/Htmx/Servant/Lucid.hs +++ b/htmx-servant/src/Htmx/Servant/Lucid.hs @@ -27,28 +27,28 @@ import Htmx.Lucid.Extra ( hxPatch_, hxPut_, ) -import Lucid.Base (Attribute) +import Lucid.Base (Attributes) import Servant.API (ToHttpApiData (..), toUrlPiece) import Servant.Links (Link) -hxDeleteSafe_ :: Link -> Attribute +hxDeleteSafe_ :: Link -> Attributes hxDeleteSafe_ = hxDelete_ . toUrl -hxGetSafe_ :: Link -> Attribute +hxGetSafe_ :: Link -> Attributes hxGetSafe_ = hxGet_ . toUrl -hxPatchSafe_ :: Link -> Attribute +hxPatchSafe_ :: Link -> Attributes hxPatchSafe_ = hxPatch_ . toUrl -hxPostSafe_ :: Link -> Attribute +hxPostSafe_ :: Link -> Attributes hxPostSafe_ = hxPost_ . toUrl -hxPushUrlSafe_ :: Either Bool Link -> Attribute +hxPushUrlSafe_ :: Either Bool Link -> Attributes hxPushUrlSafe_ boolOrUrl = hxPushUrl_ $ case boolOrUrl of Left bool -> if bool then "true" else "false" Right url -> toUrl url -hxPutSafe_ :: Link -> Attribute +hxPutSafe_ :: Link -> Attributes hxPutSafe_ = hxPut_ . toUrl toUrl :: (ToHttpApiData a) => a -> Text