(rum/defcs export-form < (rum/local {} ::options)
[rum-state {:keys [type ns-sym var-sym export-filter exportable?]} *state]
(let [*options (::options rum-state)
{:keys [pages]
:or {pages (if ns-sym :single :multiple)}} @*options]
[:form {:action "/dynadoc-export.zip"
:method :get
:style {:text-align "left"}}
[:div
[:label
[:input {:type "radio" :name "pages" :value "single" :checked (= pages :single)
:on-click #(swap! *options assoc :pages :single)
:disabled (nil? ns-sym)}]
"Only this page"]]
[:div
[:label
[:input {:type "radio" :name "pages" :value "multiple" :checked (= pages :multiple)
:on-click #(swap! *options assoc :pages :multiple)}]
"Multiple pages"]]
[:div {:style {:margin 10 :font-size 14}}
(case pages
:single [:i
"Only the current page will be exported"
[:br]
"and the sidebar will be hidden."]
:multiple [:i
"All the namespaces in the sidebar"
[:br]
"will be exported. You can narrow them"
[:br]
"down with the following regex:"
[:div
[:input {:type "text"
:placeholder "Export filter"
:style {:margin 5 :font-size 14}
:on-change #(->> % .-target .-value
(swap! *state assoc :export-filter))}]]])]
[:input {:type "hidden" :name "export-filter" :value export-filter}]
(when type
[:input {:type "hidden" :name "type" :value (name type)}])
(when ns-sym
[:input {:type "hidden" :name "ns-sym" :value (str ns-sym)}])
(when var-sym
[:input {:type "hidden" :name "var-sym" :value (str var-sym)}])
[:div {:style {:text-align "center"}}
[:button {:type "submit"
:disabled (not exportable?)}
"Download zip file"]]
(when-not exportable?
[:div {:style {:margin 10 :font-size 14}}
[:div [:b "You built Dynadoc with :optimizations set to :none"]]
[:div [:b "You must set it to :simple in order to export"]]])]))