<commit_before>(ns examples.simple
  (:require [reforms.rum :include-macros true :as f]
            [rum.core :as rum]
            [examples.shared.utils :refer [inspector-view]]))

(def customer (atom {:type :private}))

(defmulti render-details (comp :type deref))

(defmethod render-details :private
  [customer]
  (list
    (f/text "First name"
            customer [:first]
            :placeholder "Enter first name")
    (f/text "Last name"
            customer [:last]
            :placeholder "Enter last name")))

(defmethod render-details :corporate
  [customer]
  (list
    (f/text "Company name"
            customer [:company-name])
    (f/text "Reg number"
            customer [:reg-no])
    (f/select "Country" customer [:country]
              [[:us "USA"] [:gb "United Kingdom"] [:pl "Poland"] [:de "Germany"]])))

(defn render-address
  [customer]
  (list
    (f/text "Address"
            customer [:address1]
            :placeholder "Enter address line 1")
    (f/text customer [:address2]
            :placeholder "Enter address line 2")
    (f/text "City"
            customer [:city]
            :placeholder "Enter city name")))

(rum/defc customer-form-view < rum/cursored rum/cursored-watch
  [customer]
  (f/form
    (f/group-title {:class "group-title-main"} "Customer info")
    (f/select "Customer type" customer [:type]
              [[:private "Private"] [:corporate "Corporate"]])
    (f/group-title {:class "group-title-minor"} "Details")
    (render-details customer)
    (f/group-title {:class "group-title-minor"} "Address")
    (render-address customer)
    (f/group-title {:class "group-title-main"} "Access credentials")
    (f/text "Login" customer [:login] :placeholder "Enter login")
    (f/password "Password" customer [:password] :placeholder "Enter password")
    (f/form-buttons
      (f/button "Save" #(js/alert "clicked")))))<commit_msg>Fixed the simple example<commit_after>(ns examples.simple
  (:require [reforms.rum :include-macros true :as f]
            [rum.core :as rum]
            [examples.shared.utils :refer [inspector-view]]))

(def customer (atom {:type :private}))

(defmulti render-details (comp rum/react (fn [customer] (rum/cursor customer :type))))

(defmethod render-details :private
  [customer]
  (list
    (f/text "First name"
            customer [:first]
            :placeholder "Enter first name")
    (f/text "Last name"
            customer [:last]
            :placeholder "Enter last name")))

(defmethod render-details :corporate
  [customer]
  (list
    (f/text "Company name"
            customer [:company-name])
    (f/text "Reg number"
            customer [:reg-no])
    (f/select "Country" customer [:country]
              [[:us "USA"] [:gb "United Kingdom"] [:pl "Poland"] [:de "Germany"]])))

(defn render-address
  [customer]
  (list
    (f/text "Address"
            customer [:address1]
            :placeholder "Enter address line 1")
    (f/text customer [:address2]
            :placeholder "Enter address line 2")
    (f/text "City"
            customer [:city]
            :placeholder "Enter city name")))

(rum/defc customer-form-view < rum/reactive
  [customer]
  (f/form
    (f/group-title {:class "group-title-main"} "Customer info")
    (f/select "Customer type" customer [:type]
              [[:private "Private"] [:corporate "Corporate"]])
    (f/group-title {:class "group-title-minor"} "Details")
    (render-details customer)
    (f/group-title {:class "group-title-minor"} "Address")
    (render-address customer)
    (f/group-title {:class "group-title-main"} "Access credentials")
    (f/text "Login" customer [:login] :placeholder "Enter login")
    (f/password "Password" customer [:password] :placeholder "Enter password")
    (f/form-buttons
      (f/button "Save" #(js/alert "clicked")))))
{'fraction_non_alphanumeric': 0.1558237145855194, 'fraction_numerical': 0.002098635886673662, 'mean_word_length': 2.7940298507462686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2739221', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1175, 'n_words': 325}